npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

objective-three

v0.0.2-i

Published

a scene/multi-scene management system for three

Downloads

9

Readme

Objective-THREE

This is a library that provides the basic structure of a THREE.js scene in a self-contained class.

Its purpose is to create a framework in which scenes and object trees can be managed in a d3-like fashion.

There is a singleton objet, O3, that has all the composite classes

One or more O3.Display instances can be created. To those instances, add one or more O3.RenderObjects, with Object3D - type instances as their content. These are wrappers for any Object3D - based instances.

These RenderObjects are then add() -ed to the display objects. RenderObjects can themselves have children, or you can add THREE.js objects to the RenderObjects' content property.

RenderObjects have an update() method which can be extended to allow time-based manipulation of the content.

When you have consturcted your display object (and added its' .renderer().domElement to the page), call O3.animate().

update timing

There is two ways to update your scene content. One is to animate content every animation cycle (the default method). The other is to manually update content based on some other trigger.

Setting the update_on_animate property of a RenderObject to false means that it will no longer get update messages every animationFrame; you will have to choose when and how to update those RenderObjects yourself. (You can still define the update metho on the RenderObjects, you'll just have to emit 'update' methods on your own time scheme.)

setting and changing scenes and cameras

You can define any number of scenes and cameras; however, the default camera /scene will be used until you activate another scene or camera by calling mydisplay.camera('secondary').activate() or mydisplay.scene('second_scene').activate().

time based change

The O3 singleton has a time() method that reflects the milliseconds since animation begun. It is a useful basis for animation. You can "scrub" time by changing the _start_time property of O3.

A sample O3 scene


    (function () {
        var display = O3.display({width: 800, height: 500});

        display.camera().translateY(-200);
        document.body.appendChild(display.renderer().domElement);

        var lightSource = new THREE.PointLight(new THREE.Color().setRGB(0.8, 0.9, 0.8).getHex());
        lightSource.position.y = 400;
        var light = new O3.RenderObject(lightSource,

            {update: function () {
                this.content.intensity = Math.cos(O3.time() / 100) + 1.1;
            }});
        display.add(light);

        var lightSource2 = new THREE.PointLight(new THREE.Color().setRGB(0, 0, 1).getHex());
        lightSource2.position.y = -400;
        lightSource2.position.z = -800;

        var light = new O3.RenderObject(lightSource2,
            {update: function () {

            }});
        display.add(light);

        var cubeGeo = new THREE.CubeGeometry(50, 50, 50);
        var mat = new THREE.MeshPhongMaterial({color: new THREE.Color().setRGB(0.5, 0.6, 0.4).getHex()});
        var mat2 = new THREE.MeshPhongMaterial({color: new THREE.Color().setRGB(1, 1, 0.8).getHex()});
        var cubeMesh = new THREE.Mesh(cubeGeo, mat);

        var cube = new O3.RenderObject(cubeMesh, {
            update: function () {
                this.content.position.z = -520 + O3.time() * -0.05;
                this.content.position.y = -100;
            }

        });
        display.add(cube);

        var sphereGeo = new THREE.SphereGeometry(10);

        var pivot = new O3.RenderObject(new THREE.Object3D(), {

            update: function () {
                console.log('rotating sphere');
                this.content.rotateY(0.1);
            }
        });

        _.each([-100, 100], function (x) {
            _.each([-100, 100], function (y) {

                var sphereMesh = new THREE.Mesh(sphereGeo, mat2);
                sphereMesh.translateX(x);
                sphereMesh.translateZ(y);
                var sphere = new O3.RenderObject(sphereMesh, {
                    update: function () {
                        this.content.scale.x = this.content.scale.y = this.content.scale.z =
                         Math.cos(O3.time() / 1000) + 1.5;
                    }

                });
                pivot.add(sphere);
            })

        })

        cube.add(pivot);

        cubeMesh.rotateY(Math.PI / 6);

        O3.animate();
    })();