@xeographics bio photo

@xeographics

Lindsay Kay
3D graphics programmer

Twitter Google+ LinkedIn Github

SceneJS Pick-Fly-Orbit Camera

Contents

The folks over at BIMSurfer.org needed a camera that flies to and orbits whatever you click on, so I made a plugin.

Try a couple of demos:

Click to run Click to run

Usage

The plugin provides a new scene node type and gets loaded as you need it. So assuming that you’ve pointed SceneJS to where you keep your plugins:

SceneJS.setConfigs({
    pluginPath: "./foo/myPluginsDir"
});

Then just wrap the node around your scene:

SceneJS.createScene({
    nodes:[
        {
            type:"cameras/pickFlyOrbit",
            look:{ x: 0, y:150, z: 0 },
            yaw:-40,
            pitch:-20,
            zoom:800,
            zoomSensitivity:-20.0,
            showCursor: true,
            cursorSize:6.0,

            nodes:[
                {
                    type:"objects/buildings/city",
                    width:600
                }
            ]
        }
    ]
});

And then everything’s pick-fly-orbitable.

The node’s properties are:

  • look - initial point-of-interest (POI) in World-coordinates
  • yaw, pitch - initial degrees of rotation of eye position about POI on Y and X axis, respectively
  • zoom - initial distance of eye from POI
  • zoomSensitivity - sensivity of mouse wheel when updating zoom. The sign of this determines which direction the wheel drives the zoom.
  • showCursor - set true to show the POI with a sphere
  • cursorSize - radius of the cursor sphere

Making scene objects unpickable

See how you can’t pick the sky in the live demos above? That’s a good thing, because otherwise you’d be able to orbit a point on the skybox, which would be rather a Truman Show moment!

Learn how to make objects unpickable in this API example.

Read More




sudo
comments powered by Disqus