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
| // SceneJS viewport node implementation | |
| SceneJs.viewport = function() { | |
| var cfg = SceneJs.private.getNodeConfig(arguments); | |
| var backend = SceneJs.backends.getBackend('viewport'); | |
| return function(scope) { | |
| var params = cfg.getParams(scope); |
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
| /** The getNodeConfig framework utility function - converts node arguments into what the node needs internally - configs | |
| * and child nodes. | |
| */ | |
| SceneJs.utils.getNodeConfig = getNodeConfig : function(args) { | |
| if (args.length == 0) { | |
| throw 'Invalid node parameters: should be a ' | |
| + 'configuration followed by zero or more 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
| // Using a SceneJS generator node to create a row of teapots | |
| generator(function() { | |
| var x = 0; | |
| return function() { | |
| x += 10.0; | |
| if (x < 60) { | |
| return { | |
| x: x | |
| }; |
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
| // Using a selector node to select active child transform nodes | |
| selector({ | |
| selection: [0, 2] | |
| }, | |
| rotate(..), | |
| translate(..), | |
| scale(..) | |
| ) |
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
| // Scope node providing angle for rotation node | |
| scope({ | |
| x : 45 | |
| }, | |
| rotate(function(scope) { | |
| return { | |
| x: scope.get('x') | |
| }; | |
| }, |
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
| // Using a generator node to render a scene in two viewports | |
| with (SceneJs) { | |
| var scene = graph({}, | |
| generator(function() { | |
| var i = 0; | |
| return function() { | |
| switch (i++) { | |
| case 0: return { x : 1, y : 1, width: 200, height: 200 }; | |
| case 1: return { x : 250, y : 1, width: 200, height: 200 }; |
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
| /** Rotate node from SceneJS as of Jan 7, 2010. | |
| */ | |
| SceneJs.rotate = function() { | |
| var cfg = SceneJs.utils.getNodeConfig(arguments); | |
| var backend = SceneJs.backends.getBackend('model-view-transform'); | |
| var mat; | |
| var xform; | |
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
| asset({ | |
| uri:"http://www.scenejs.com/app/data/assets/catalogue/assets/orangeteapot.js", | |
| proxy:"http://scenejs.com/cgi-bin/jsonp_wrapper.pl" | |
| }) |
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
| SceneJs.material({ | |
| ambient: { r:0.4, g:0.2, b:0.2 }, | |
| diffuse: { r:0.9, g:0.5, b:0.4 } | |
| }, | |
| SceneJs.generator((function() { | |
| var angle = 0; | |
| var height = -10; | |
| return function() { | |
| angle += 15.0; | |
| height += 1.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
| SceneJs.material({ | |
| ambient: { r:0.9, g:0.2, b:0.2 }, | |
| diffuse: { r:0.9, g:0.6, b:0.2 } | |
| }, | |
| SceneJs.objects.teapot() | |
| ) |