This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var node = SceneJs.node(); | |
| var scene = SceneJs.graph( | |
| SceneJs.node(node, node) | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var graph = SceneJs.graph( | |
| SceneJs.node({ | |
| childListeners: { | |
| 'alpha': { | |
| fn: function(nodeContext, event) { | |
| // Event 'alpha' has bubbled up and is handled here again at step 3. | |
| alert('Event name ' + event.name + ' handled with params ' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var graph = SceneJs.graph( | |
| SceneJs.node({ | |
| preVisit:function(nodeContext) { | |
| // Events 'alpha' and 'beta' are fired from here at Step 1. | |
| nodeContext.fireParentEvent('alpha', { | |
| foo: 'foo value', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var graph = SceneJs.graph( | |
| SceneJs.node({ | |
| preVisit: function(nodeContext) { | |
| var graphContext = nodeContext.getGraphContext(); | |
| graphContext.counter++; | |
| } | |
| }) | |
| ); | |
| var graphContext = { counter: 0 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var graph = SceneJs.graph( | |
| SceneJs.node({ | |
| preVisit: function(nodeContext) { | |
| // Parent node gets graph context from node context | |
| // and sets something on it for child | |
| var graphContext = nodeContext.getGraphContext(); | |
| graphContext.foo = 'Hi, child nodes!'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var config = { | |
| preVisit: function() { | |
| // Do something | |
| } | |
| }; | |
| var myNode1 = new SceneJs.node(config); | |
| config.preVisit = function() { // Don't do this!! | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| with (SceneJs) { | |
| var scene = graph( | |
| canvas({ canvasId: 'mycanvas' }, | |
| shaders.simpleShader( | |
| lights({ lights: [{ pos: { x: 60.0, y: 60.0, z: -100.0 } } ]}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Installation of a backend for the 'simple-shader' SceneJS shader node | |
| SceneJs.Backend.installNodeBackend(SceneJs.shaderBackend({ | |
| nodeType: 'simple-shader', | |
| vertexShaders: [ | |
| 'attribute vec3 Vertex; ' + | |
| 'attribute vec3 Normal; ' + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Example SceneJS scene definition - renders the venerable OpenGL teapot | |
| with (SceneJs) { | |
| var scene = graph({}, // node always has a config object | |
| renderer({ canvasId: 'mycanvas'}, | |
| shader({ type: 'simple-shader' }, | |
| lights({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Installation of the SceneJS viewport node backend | |
| SceneJs.backends.installBackend( | |
| new (function() { | |
| this.type = 'viewport'; | |
| var ctx; | |
| this.install = function(_ctx) { |