Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Branching - Provide SceneJS.Selector Node

#57

A SceneJS.Selector is a scene branch node that selects which among its children are currently active.

This node is useful for dynamically controlling traversal within a scene graph.

Examples

var s = new SceneJS.Selector({ selection: [0, 2]},
      new SceneJS.objects.teapot(),   // Child 0

      new SceneJS.objects.cube(),     // Child 1

      new SceneJS.objects.sphere())   // Child 2

s.setSelection([0,1,2]);  // Select all three child nodes

A more advanced example - the selector in this example switches between three viewpoints of the scene content. The content is instanced within each child of the Selector using Instance and Symbol nodes. When we render the scene, we can pass in the selection.

var myScene = new SceneJS.Scene({ ... },

   new SceneJS.symbol({ name: "theScene" },
        new SceneJS.objects.Teapot()
   ),
   new SceneJS.Selector(
           function(data) {   // Child index as a dynamic config
               return {
                   selection: [data.get("activeCamera")]  // Selection
               };
           },
       new SceneJS.LookAt({ eye : { z: 10.0 } },
            new SceneJS.Instance({ name: "theScene"})),

       new SceneJS.LookAt({ eye : { x: 10.0 }},
            new SceneJS.Instance({ name: "theScene"})),

       new SceneJS.LookAt({ eye : { x: -5.0, y: 5, z: 5 }},
            new SceneJS.Instance({ name: "theScene" })
       )
   )



); myScene.render({ activeCamera: 0 }); // Render scene for first viewpoint myScene.render({ activeCamera: 1 }); // Once more for second viewpoint

Reported by lindsay.kay (at xeolabs) · May 7th, 2010 @ 09:44 AM

State: resolved
Milestone: V0.7.4

Activity

  1. lindsay.kay (at xeolabs)
    lindsay.kay (at xeolabs)
    • State changed from new to resolved

    May 7th, 2010 @ 09:47 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.