diff --git a/about.html b/about.html index d371a93c..73fe039e 100644 --- a/about.html +++ b/about.html @@ -299,7 +299,7 @@

6. Custom Scene Node Types

z: 5.0, nodes: [{ - type: "prims/box" + type: "geometry/box" }] }, { type: "translate", @@ -307,11 +307,11 @@

6. Custom Scene Node Types

z: 5.0, nodes: [{ - type: "prims/box" + type: "geometry/box" }] }] }, { - type: "prims/teapot" + type: "geometry/teapot" }] }] }); diff --git a/api/latest/firstExample.html b/api/latest/firstExample.html index e53db56b..176850fe 100644 --- a/api/latest/firstExample.html +++ b/api/latest/firstExample.html @@ -63,9 +63,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/api/latest/plugins/node/cameras/orbit.js b/api/latest/plugins/node/cameras/orbit.js index 0c92a794..24d481b8 100644 --- a/api/latest/plugins/node/cameras/orbit.js +++ b/api/latest/plugins/node/cameras/orbit.js @@ -20,14 +20,14 @@ */ SceneJS.Types.addType("cameras/orbit", { - construct:function (params) { + construct: function (params) { var lookat = this.addNode({ - type:"lookAt", + type: "lookAt", // A plugin node type is responsible for attaching specified // child nodes within itself - nodes:params.nodes + nodes: params.nodes }); var yaw = params.yaw || 0; @@ -40,17 +40,24 @@ SceneJS.Types.addType("cameras/orbit", { var lastX; var lastY; var dragging = false; + var lookatDirty = false; - var eye = params.eye || { x:0, y:0, z:0 }; - var look = params.look || { x:0, y:0, z:0}; + var eye = params.eye || { x: 0, y: 0, z: 0 }; + var look = params.look || { x: 0, y: 0, z: 0}; lookat.set({ - eye:{ x:eye.x, y:eye.y, z:-zoom }, - look:{ x:look.x, y:look.y, z:look.z }, - up:{ x:0, y:1, z:0 } + eye: { x: eye.x, y: eye.y, z: -zoom }, + look: { x: look.x, y: look.y, z: look.z }, + up: { x: 0, y: 1, z: 0 } }); - update(); +// this._tick = this.getScene().on("tick", +// function () { +// if (lookatDirty) { +// update(); +// lookatDirty = false; +// } +// }); var canvas = this.getScene().getCanvas(); @@ -157,16 +164,19 @@ SceneJS.Types.addType("cameras/orbit", { var eye3 = SceneJS_math_transformPoint3(pitchMat, eye); eye3 = SceneJS_math_transformPoint3(yawMat, eye3); - lookat.setEye({x:eye3[0], y:eye3[1], z:eye3[2] }); + lookat.setEye({x: eye3[0], y: eye3[1], z: eye3[2] }); } + + update(); }, - setLook: function(l) { + setLook: function (l) { }, - destruct:function () { + destruct: function () { + this.getScene().off(this.tick); // TODO: remove mouse handlers } }); diff --git a/api/latest/plugins/node/cameras/pickFlyOrbit.js b/api/latest/plugins/node/cameras/pickFlyOrbit.js index f1d06f3d..95c90981 100644 --- a/api/latest/plugins/node/cameras/pickFlyOrbit.js +++ b/api/latest/plugins/node/cameras/pickFlyOrbit.js @@ -44,6 +44,7 @@ require([ style.background = "#AAFFAA"; style.opacity = "0.8"; style["border-radius"] = "3px"; + style["z-index"] = 100000; style["-moz-border-radius"] = "3px"; style["box-shadow"] = "3px 3px 3px #444444"; style.left = "0"; @@ -55,18 +56,18 @@ require([ return { // Shows label, but only if text has been set - setShown:function (shown) { + setShown: function (shown) { style.display = shown && text ? "" : "none"; }, // Sets canvas position of label - setPos:function (pos) { + setPos: function (pos) { style.left = "" + pos.x + "px"; style.top = "" + pos.y + "px"; }, // Sets text in label - setText:function (t) { + setText: function (t) { text = t; div.innerHTML = "" + text + ""; } @@ -75,19 +76,21 @@ require([ SceneJS.Types.addType("cameras/pickFlyOrbit", { - construct:function (params) { + construct: function (params) { + + var self = this; var lookat = this.addNode({ - type:"lookAt", + type: "lookAt", - nodes:[ + nodes: [ { - type:"name", - name:"noname", + type: "name", + name: "noname", // A plugin node type is responsible for attaching specified // child nodes within itself - nodes:params.nodes + nodes: params.nodes } ] }); @@ -104,44 +107,44 @@ require([ // Sphere position, with a ID so we can update this node: indicatorPos = lookat.addNode({ - type:"translate", - id:"__spherePOI" + type: "translate", + id: "__spherePOI" }); indicatorVis = indicatorPos.addNode({ - type:"flags", - flags:{ - enabled:false, - transparent:true, - specular:true, - diffuse:false + type: "flags", + flags: { + enabled: false, + transparent: true, + specular: true, + diffuse: false } }); var cursorSize = params.cursorSize || 1; indicatorSize = indicatorVis.addNode({ - type:"scale", - id:"__sphereSize", - x:cursorSize, - y:cursorSize, - z:cursorSize, - nodes:[ + type: "scale", + id: "__sphereSize", + x: cursorSize, + y: cursorSize, + z: cursorSize, + nodes: [ { - type:"material", - color:{ r:0.4, g:1.0, b:0.4 }, - specularColor:{ r:1.0, g:1.0, b:1.0 }, - emit:0.2, - nodes:[ + type: "material", + color: { r: 0.4, g: 1.0, b: 0.4 }, + specularColor: { r: 1.0, g: 1.0, b: 1.0 }, + emit: 0.2, + nodes: [ { - type:"style", - lineWidth:2, - nodes:[ + type: "style", + lineWidth: 2, + nodes: [ // Sphere primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type:"prims/sphere" + type: "geometry/sphere" } ] } @@ -158,16 +161,18 @@ require([ }); } - var eye = params.eye || { x:0, y:0, z:0 }; - var look = params.look || { x:0, y:0, z:0}; + var eye = params.eye || { x: 0, y: 0, z: 0 }; + var look = params.look || { x: 0, y: 0, z: 0}; var zoom = params.zoom || 100; var zoomSensitivity = params.zoomSensitivity || 1.0; - lookat.set({ - eye:{ x:eye.x, y:eye.y, z:eye.z}, - look:{ x:look.x, y:look.y, z:look.z }, - up:{ x:0, y:1, z:0 } - }); + var lookatArgs = { + eye: { x: eye.x, y: eye.y, z: eye.z}, + look: { x: look.x, y: look.y, z: look.z }, + up: { x: 0, y: 1, z: 0 } + }; + lookat.set(lookatArgs); + this.publish("updated", lookatArgs); var canvas = this.getScene().getCanvas(); @@ -276,7 +281,7 @@ require([ } function pick(canvasX, canvasY) { - scene.pick(canvasX, canvasY, { rayPick:true }); + scene.pick(canvasX, canvasY, { rayPick: true }); } var scene = this.getScene(); @@ -295,7 +300,7 @@ require([ if (indicatorVis) { indicatorVis.setEnabled(true); - indicatorPos.setXYZ({x:endPivot[0], y:endPivot[1], z:endPivot[2] }); + indicatorPos.setXYZ({x: endPivot[0], y: endPivot[1], z: endPivot[2] }); label.setShown(true); } @@ -372,8 +377,18 @@ require([ glmat.vec3.transformMat4(eye3, eye, mat); // Update view transform - lookat.setLook({x:look[0], y:look[1], z:look[2] }); - lookat.setEye({x:look[0] - eye3[0], y:look[1] - eye3[1], z:look[2] - eye3[2] }); + lookat.setLook({x: look[0], y: look[1], z: look[2] }); + lookat.setEye({x: look[0] - eye3[0], y: look[1] - eye3[1], z: look[2] - eye3[2] }); + + var lookatArgs = { + eye: {x: look[0], y: look[1], z: look[2] }, + look: {x: look[0] - eye3[0], y: look[1] - eye3[1], z: look[2] - eye3[2] } + }; + +// lookat.setLook(lookatArgs.look); +// lookat.setEye(lookatArgs.eye); + + self.publish("updated", lookatArgs); // Rotate complete orbiting = false; @@ -388,7 +403,7 @@ require([ }); }, - destruct:function () { + destruct: function () { // TODO: remove mouse handlers } }); diff --git a/api/latest/plugins/node/canvas/capture.js b/api/latest/plugins/node/canvas/capture.js index a32c931d..0ba95b8c 100644 --- a/api/latest/plugins/node/canvas/capture.js +++ b/api/latest/plugins/node/canvas/capture.js @@ -48,7 +48,7 @@ require([ SceneJS.Types.addType("canvas/capture", { construct:function (params) { - this._format = params.format ? supportedFormat(params.format) : "jpeg"; + this._format = params.format ? this._supportedFormat(params.format) : "jpeg"; this._width = params.width; this._height = params.height; }, diff --git a/api/latest/plugins/node/effects/crt.js b/api/latest/plugins/node/effects/crt.js deleted file mode 100644 index d2f1c411..00000000 --- a/api/latest/plugins/node/effects/crt.js +++ /dev/null @@ -1,36 +0,0 @@ -SceneJS.Types.addType("shader/crt", { - - construct:function (params) { - - this._shader = this.addNode({ - type:"shader", - - shaders:[ - - { - stage:"fragment", - code:"vec4 myPixelColorFunc(vec4 color) {\n\ - float m = mod(gl_FragCoord.y, 4.0);\n\ - if (m < 1.5) {\n\ - color = vec4(0.0, 0.0, 0.0, 1.0);\n\ - } else if (m < 2.0) {\n\ - color = vec4(0.2, 0.2, 0.2, 1.0);\n\ - } else if (m < 2.5) {\n\ - color = vec4(0.2, 0.2, 0.2, 1.0);\n\ - }\n\ - return color;\n\ - }", - - hooks:{ - pixelColor:"myPixelColorFunc" - } - } - ], - nodes:params.nodes - }); - }, - - destruct:function () { - // Not used - } -}); diff --git a/api/latest/plugins/node/effects/fog.js b/api/latest/plugins/node/effects/fog.js index 68e2091d..fe9581d7 100644 --- a/api/latest/plugins/node/effects/fog.js +++ b/api/latest/plugins/node/effects/fog.js @@ -1,159 +1,145 @@ -SceneJS.Types.addType("effects/fog", { - - construct:function (params) { - - // Holds params for custom shader node - this._shaderParams = { - fogMode:1.0, // 0.0 disabled, 1.0 linear, 2.0 exponential, 3.0 quadratic, 4.0 constant - fogDensity:0.05, // Fog density in range of [0.0..1.0] - fogStart:0.0, // Nearest point of fog in view space (receeding Z-axis is positive) - fogEnd:10000.0, // Furthest point of fog in view space - fogColor:[0.6, 0.0, 0.0] // Colour of fog - the colour that objects blend into - }; - - // Custom shader node - this._shader = this.addNode({ - type:"shader", - coreId:"effects/fog", - - shaders:[ - - { - stage:"fragment", - code:[ - - /* Parameter uniforms - */ - "uniform float fogMode;", - "uniform float fogDensity;", - "uniform float fogStart;", - "uniform float fogEnd;", - "uniform vec3 fogColor;", - - /* Collected view-space fragment position - */ - "vec4 _viewPos;", - - /* Collects view-space fragment position - */ - "void fogViewPosFunc(vec4 viewPos) {", - " _viewPos = viewPos;", - "}", - - /* Modifies fragment colour - */ - "vec4 fogPixelColorFunc(vec4 color) {", - " if (fogMode != 0.0) {", // not "disabled" - " float fogFactor = (1.0 - fogDensity);", - " if (fogMode != 4.0) {", // not "constant" - " if (fogMode == 1.0) {", // "linear" - " fogFactor *= clamp(pow(max((fogEnd - length(- _viewPos.xyz)) / " + - " (fogStart - fogEnd), 0.0), 2.0), 0.0, 1.0);", - " } else {", // "exp" or "exp2" - " fogFactor *= clamp((fogStart - length(- _viewPos.xyz)) / (fogStart - fogEnd), 0.0, 1.0);", - " }", - " }", - " return color * (fogFactor + vec4(fogColor, 1.0)) * (1.0 - fogFactor);", - " }", - " return color;", - "}" - ], - - /* Bind our functions to hooks - */ - hooks:{ - viewPos:"fogViewPosFunc", - pixelColor:"fogPixelColorFunc" +/** + * Depth-of-Field postprocess effect + * + */ +SceneJS.Types.addType("postprocess/dof", { + + construct: function (params) { + + // Unique IDs for the render target nodes + var colorTarget = this.id + ".colorTarget"; + var colorTarget2 = this.id + ".colorTarget2"; + var depthTarget = this.id + ".depthTarget"; + + + this.addNodes([ + + // Pass 1 + // Render scene to color and depth targets + { + type: "pass", + priority: 1, + nodes: [ + + // Output color target + { + type: "colorTarget", + id: colorTarget, + + nodes: [ + + // Output depth target + { + type: "depthTarget", + id: depthTarget, + + // The scene nodes + nodes: params.nodes + } + ] } - } - ], - - // Declare parameters and set default values - params:this._shaderParams, - - nodes:params.nodes - }); - - if (params.mode != undefined) { - this.setMode(params.mode); - } - if (params.density != undefined) { - this.setDensity(params.density); - } - if (params.start != undefined) { - this.setStart(params.start); - } - if (params.end != undefined) { - this.setEnd(params.end); - } - if (params.color != undefined) { - this.setColor(params.color); - } - }, - - setMode:function (mode) { - switch (mode) { - case "disabled": - this._shaderParams.fogMode = 0; - break; - case "linear": - this._shaderParams.fogMode = 1; - break; - case "exp": - this._shaderParams.fogMode = 2; - break; - case "exp2": - this._shaderParams.fogMode = 3; - break; - case "constant": - this._shaderParams.fogMode = 4; - break; - } - this._shader.setParams(this._shaderParams); - }, - - getMode:function () { - return ["disabled", "linear", "exp", "exp2", "constant"][this._shaderParams.fogMode]; // TODO: optimize - }, - - setDensity:function (density) { - this._shaderParams.fogDensity = density; - this._shader.setParams(this._shaderParams); - }, - - getDensity:function () { - return this._shaderParams.fogDensity; - }, - - setStart:function (start) { - this._shaderParams.fogStart = start; - this._shader.setParams(this._shaderParams); - }, - - getStart:function () { - return this._shaderParams.fogStart; - }, - - setEnd:function (end) { - this._shaderParams.fogEnd = end; - this._shader.setParams(this._shaderParams); - }, - - getEnd:function () { - return this._shaderParams.fogEnd; - }, - - setColor:function (color) { - this._shaderParams.fogColor = [color.r || 0, color.g || 0, color.b || 0 ]; - this._shader.setParams(this._shaderParams); - }, - - getColor:function () { - var color = this._shaderParams.fogColor; - return { r:color[0], g:color[1], b:color[2] }; - }, - - destruct:function () { - // Not used + ] + }, + + // Debug pass - renders the depth buffer to the canvas + { + type: "pass", + priority: 1.2, + nodes: [ + { + // type: "depthTarget/render", + target: depthTarget + } + ] + }, + + // Pass 2 + // Render scene with custom shader using color and depth targets as textures + { + type: "pass", + priority: 2, + + nodes: [ + + // Input color target + { + type: "textureMap", + target: colorTarget, + + nodes: [ + + // Input depth target + { + type: "textureMap", + target: depthTarget, + + nodes: [ + + // Horizontal blur shader + { + type: "shader", + coreId: "xx", + shaders: [ + + // Vertex shader simply passes through vertex position and UV + { + stage: "vertex", + code: [ + "attribute vec3 SCENEJS_aVertex;", + "attribute vec2 SCENEJS_aUVCoord;", + "varying vec2 vUv;", + "void main () {", + " gl_Position = vec4(SCENEJS_aVertex, 1.0);", + " vUv = SCENEJS_aUVCoord;", + "}" + ] + }, + + // Fragment shader + { + stage: "fragment", + code: [ + "precision highp float;", + + "uniform sampler2D SCENEJS_uSampler0;", // Colour target's texture + "uniform sampler2D SCENEJS_uSampler1;", // Depth target's texture + + /// Unpack an RGBA pixel to floating point value. + "float unpack (vec4 colour) {", + " const vec4 bitShifts = vec4(1.0,", + " 1.0 / 255.0,", + " 1.0 / (255.0 * 255.0),", + " 1.0 / (255.0 * 255.0 * 255.0));", + " return dot(colour, bitShifts);", + "}", + + "void main () {", + " float depth = unpack(texture2D(SCENEJS_uSampler1, vUv));", + " gl_FragColor = depth * texture2D(SCENEJS_uSampler0, vUv);", + "}" + ] + } + ], + + params: { + }, + + nodes: [ + + // Quad primitive, implemented by plugin at + // http://scenejs.org/api/latest/plugins/node/geometry/quad.js + { + type: "geometry/quad" + } + ] + } + ] + } + ] + } + ] + } + ]); } }); + diff --git a/api/latest/plugins/node/effects/snowyPeaks.js b/api/latest/plugins/node/effects/snowyPeaks.js deleted file mode 100644 index a44c1d0d..00000000 --- a/api/latest/plugins/node/effects/snowyPeaks.js +++ /dev/null @@ -1,50 +0,0 @@ -SceneJS.Types.addType("effects/snowyPeaks", { - - construct:function (params) { - - var altitude = params.altitude || 0; - - this._shader = this.addNode({ - type:"shader", - shaders:[ - { - stage:"fragment", - code:[ - "float posY = 0.0;", - "vec4 myWorldPosFunc(vec4 pos){", - " posY=pos.y;", - " return pos;", - "}", - - "uniform float altitude;", - "vec3 myMaterialBaseColorFunc(vec3 color) {", - " if (posY > altitude) {", - " color = vec3(1.0, 1.0, 1.0);", - " }", - " return color;", - "}" - ], - hooks:{ - materialBaseColor:"myMaterialBaseColorFunc", - worldPos:"myWorldPosFunc" - } - } - ], - params:{ - altitude:altitude - }, - nodes:params.nodes - }); - }, - - setAltitude:function (altitude) { - this._shader.setParams({ - altitude:altitude - }); - }, - - destruct:function () { - // Not used - } -}) -; diff --git a/api/latest/plugins/node/effects/wobble.js b/api/latest/plugins/node/effects/wobble.js deleted file mode 100644 index 6b36447d..00000000 --- a/api/latest/plugins/node/effects/wobble.js +++ /dev/null @@ -1,42 +0,0 @@ -SceneJS.Types.addType("effects/wobble", { - - construct:function (params) { - - var shader = this.addNode({ - type:"shader", - shaders:[ - { - stage:"vertex", - code:"uniform float time;\n\ - vec4 myWorldPosFunc(vec4 pos){\n\ - pos.x=pos.x+sin(pos.x*5.0+time+10.0)*0.1;\n\ - pos.y=pos.y+sin(pos.y*5.0+time+10.0)*0.1;\n\ - pos.z=pos.z+sin(pos.z*5.0+time+10.0)*0.1;\n\ - return pos;\n\ - }\n", - hooks:{ - worldPos:"myWorldPosFunc" - } - } - ], - params:{ - time:0.5 - }, - nodes:params.nodes - }); - - var time = 0; - - this._tick = this.getScene().on("tick", - function () { - shader.setParams({ - time:time - }); - time += 0.1; - }); - }, - - destruct:function () { - this.getScene().off(this._tick); - } -}); diff --git a/api/latest/plugins/node/frustum/body.js b/api/latest/plugins/node/frustum/body.js deleted file mode 100644 index bccd850b..00000000 --- a/api/latest/plugins/node/frustum/body.js +++ /dev/null @@ -1,112 +0,0 @@ -require([ - // Prefix routes to plugin support libs - "scenejsPluginDeps/frustum/frustumCullSystemPool" -], - function (pool) { - - SceneJS.Types.addType("frustum/body", { - - construct:function (params) { - - // Frustum culling and projected canvas size enabled by default - this._frustumCull = params.frustumCull != undefined ? params.frustumCull : true; - this._detailCull = params.detailCull != undefined ? params.detailCull : true; - - var shape = params.shape || "box"; - - switch (shape) { - case "box": - this._bodyCfg = { - shape:shape, - min:params.min || [0, 0, 0], - max:params.max || [0, 0, 0], - frustumCull:this._frustumCull, - detailCull:this._detailCull - }; - if (params.showBoundary) { - this.addNode({ - type:"prims/boundary", - min:params.min || [0, 0, 0], - max:params.max || [0, 0, 0], - wire:true - }); - } - break; - -// case "sphere": -// this._bodyCfg = { -// shape:"sphere", -// center:params.center || [0, 0, 0], -// radius:params.radius || 1.0 -// }; -// break; - - default: - this.log("error", "Unsupported value for attribute 'shape'"); - } - - if (params.nodes) { - this.addNodes(params.nodes); - } - }, - - preCompile:function () { - - // This node might have been relocated in the scene graph - // and therefore inherits new view and projection transforms, - // so we'll release any existing system just in case. - - this._putBody(); - this._getBody(); - }, - - _putBody:function () { - if (this._bodyId) { - this._system.removeBody(this._bodyId); - this._bodyId = null; - } - if (this._system) { - pool.putSystem(this._system); - this._system = null; - } - }, - - _getBody:function () { - try { - this._system = pool.getSystem(this); - var self = this; - this._bodyId = this._system.createBody(this._bodyCfg, - function (intersect, canvasSize) { // Body update handler - - // Not that much overhead in relaying status - // updates via pub/sub because they only happen sparsely, - // ie. for bodies whose status actually changes - - if (self._frustumCull) { // Frustum culling switching enabled - self.publish("intersect", intersect); - } - - if (self._detailCull) { // LOD switching enabled - self.publish("canvasSize", canvasSize); - } - - // self.log(" intersect = " + intersect + ", canvasSize = " + canvasSize); - }); - } catch (e) { - this.log("Error : " + e); - if (this._system) { - pool.putSystem(this._system); - this._system = null; - } - } - }, - - postCompile:function () { - // Not used - }, - - destruct:function () { - this._putBody(); - } - }); - }); diff --git a/api/latest/plugins/node/frustum/lod.js b/api/latest/plugins/node/frustum/lod.js deleted file mode 100644 index 07bf092a..00000000 --- a/api/latest/plugins/node/frustum/lod.js +++ /dev/null @@ -1,125 +0,0 @@ -SceneJS.Types.addType("frustum/lod", { - - construct:function (params) { - - var self = this; - - var sizes = params.sizes; - if (!sizes) { - this.log("error", "mandatory attribute missing: 'sizes'"); - return; - } - - var nodes = params.nodes; - if (!nodes) { - this.log("error", "mandatory attribute missing: 'nodes'"); - return; - } - - if (sizes.length != nodes.length) { - this.log("error", "invalid attribute(s): 'sizes' and 'nodes' should be arrays of equal length"); - return; - } - - for (var i = 0, len = sizes.length; i < len; i++) { - if (sizes[i] <= 0) { - this.log("error", "invalid attribute: values in 'sizes' should be greater than zero"); - return; - } - if (i > 0) { - if (sizes[i] <= sizes[i - 1]) { - this.log("error", "invalid attribute: values in 'sizes' should be in ascending order"); - return; - } - } - } - - this.addNode({ - type:"frustum/body", - shape:params.shape, - min:params.min, - max:params.max, - showBoundary:params.showBoundary, - frustumCull: params.frustumCull ? params.frustumCull : true, // Enable frustum culling? - detailCull:true // Enable detail culling information (default) - }, - function (body) { - if (params.nodes) { - var childNodes = []; - for (var i = 0, len = params.nodes.length; i < len; i++) { - childNodes.push(self.addNode({ - type:"enable", - enabled:false, - nodes:[ - params.nodes[i] - ] - })); - } - - // The currently active child node - var currentNode; - - // If frustum culling is not disabled by - // params.frustumCull, then we'll get notification - // whenever the boundaries intersection status - // changes with respect to the view frustum. - - body.on("intersect", - function (intersect) { - if (currentNode) { - switch (intersect) { - case 0: // Completely outside frustum - currentNode.setEnabled(false); - break; - case 1: // Partially inside frustum - currentNode.setEnabled(true); - break; - case 2: // Completely inside frustum - currentNode.setEnabled(true); - break; - } - } - }); - - // If frustum culling is not disabled by params.frustumCull, - // then we'll get notifications of change in projected canvas - // size for the boundary as long as the "intersect" notification - // reported that the boundary is not outside the view frustum. - - // If frustum culling is disabled. then we'll get - // notification of canvas size changes regardless of - // whether the boundary is outside the frustum of not. - - body.on("canvasSize", - function (canvasSize) { - - if (currentNode) { - - // We only get a 2d size update when the size has changed, - // so its safe to say we'll not be immediately re-enabling - // the currently enabled child node. No need to avoid - // any redundant re-enabling or disabling here. - - currentNode.setEnabled(false); - } -// - if (canvasSize == -1) { - // All Culled - return; - } - - // Enable the appropriate child, if any, - // for the boundary's projected 2D size - - for (var i = sizes.length - 1; i >= 0; i--) { - if (canvasSize >= sizes[i]) { - currentNode = childNodes[i]; - currentNode.setEnabled(true); - return; - } - } - }); - } - }); - } -}); \ No newline at end of file diff --git a/api/latest/plugins/node/heightmaps/custom.js b/api/latest/plugins/node/heightmaps/custom.js deleted file mode 100644 index 1e666705..00000000 --- a/api/latest/plugins/node/heightmaps/custom.js +++ /dev/null @@ -1,164 +0,0 @@ -(function () { - - SceneJS.Types.addType("heightmaps/custom", { - - construct:function (params) { - - if (!params.src) { - throw "heightmap param expected: src"; - } - - params.xSize = params.xSize || 1.0; - params.ySize = params.ySize || 0.25; - params.zSize = params.zSize || 1.0; - - params.xSegments = params.xSegments || 100; - params.zSegments = params.zSegments || 100; - - var self = this; - - // Notify SceneJS so it can support loading/busy indicators etc - this._taskId = this.taskStarted("Loading heightmap"); - - var image = new Image(); - - image.onload = function (e) { - - var element = window.document.createElement('canvas'); - element.width = image.width; - element.height = image.height; - - var c = element.getContext("2d"); - - c.drawImage(image, 0, 0); - - var imageData = c.getImageData(0, 0, image.width, image.height).data; - - var mesh = createMeshData(params, image, imageData); - - var wire = params.wire; - - if (self._taskId) { - - self._taskId = self.taskFinished(self._taskId); - - // Create geometry node - self.addNode({ - type:"rotate", - x:1, - angle:90, - nodes:[ - { - type:"geometry", - primitive:wire ? "lines" : "triangles", - positions:mesh.positions, - normals:!wire ? "auto" : null, // Get SceneJS to compute the normals - uv:!wire ? mesh.uv : null, - indices:mesh.indices, - coreId:"heightmap_" + (wire == true ? "wire_" : "") + params.zSize + "_" + params.xSize + "_" + params.ySize + "_" + params.xSegments + "_" + params.zSegments - } - ] - }); - } - }; - - image.onerror = function () { - self._taskId = self.taskFailed(self._taskId); - }; - - image.src = params.src; - }, - - destruct:function () { - this._taskId = self.taskFinished(this._taskId); - } - }); - - function createMeshData(params, image, imageData) { - - var imageWidth = image.width; - var imageHeight = image.height; - - var positions = []; - var uvs = []; - var indices = []; - - var width = params.xSize; - var height = params.zSize; - - var xSegments = params.xSegments; - var zSegments = params.zSegments; - - var halfWidth = width / 2; - var halfHeight = height / 2; - - var gridX = xSegments; - var gridZ = zSegments; - - var gridX1 = gridX + 1; - var gridZ1 = gridZ + 1; - - var segWidth = width / gridX; - var segHeight = height / gridZ; - - var imgX; - var imgY; - - var x; - var y; - var z; - - for (var px = 0; px <= gridZ; px++) { - for (var py = 0; py <= gridX; py++) { - - x = px * segWidth; - y = py * segHeight; - - imgX = Math.round((x / width) * (imageWidth - 1)); - imgY = Math.round((y / height) * (imageHeight - 1)); - - z = (imageData[(imageWidth * imgY + imgX) * 4]) / 255 * params.ySize; - - if (z == undefined || isNaN(z)) { - z = 0; - } - - positions.push(x - halfWidth); - positions.push(-y + halfHeight); - positions.push(-z); - - uvs.push(py / gridX); - uvs.push(1 - px / gridZ); - } - } - - var a; - var b; - var c; - var d; - - for (var iz = 0; iz < gridZ; iz++) { - for (var ix = 0; ix < gridX; ix++) { - - a = ix + gridX1 * iz; - b = ix + gridX1 * ( iz + 1 ); - c = ( ix + 1 ) + gridX1 * ( iz + 1 ); - d = ( ix + 1 ) + gridX1 * iz; - - indices.push(a); - indices.push(b); - indices.push(c); - - indices.push(c); - indices.push(d); - indices.push(a); - } - } - - return { - positions:positions, - uv:uvs, - indices:indices - }; - } -})(); diff --git a/api/latest/plugins/node/import/md2.js b/api/latest/plugins/node/import/md2.js index 3a13fbd2..e9a2c47e 100644 --- a/api/latest/plugins/node/import/md2.js +++ b/api/latest/plugins/node/import/md2.js @@ -19,6 +19,7 @@ require([ if (!params.src) { this.log("error", "Attribute expected: src"); + return; } // Notify SceneJS so it can support loading/busy indicators etc diff --git a/api/latest/plugins/node/objects/buildings/building.js b/api/latest/plugins/node/objects/buildings/building.js index 47b8ba67..23fd78d9 100644 --- a/api/latest/plugins/node/objects/buildings/building.js +++ b/api/latest/plugins/node/objects/buildings/building.js @@ -2,9 +2,9 @@ var buildingTypes = initBuildingTypes(); - SceneJS.Types.addType("objects/buildings/building", { + SceneJS.Types.addType("models/buildings/building", { - construct:function (params) { + construct: function (params) { var type = params.buildingType || 0; var buildingType = buildingTypes[type]; if (!buildingType) { @@ -12,162 +12,164 @@ } var pos = params.pos || {}; createBuilding(buildingType, this, { - xmin:(pos.x || 0) - 10, - zmin:(pos.z || 0) - 10, - xmax:(pos.x || 0) + 10, - zmax:(pos.z || 0) + 10 + xmin: (pos.x || 0) - 10, + zmin: (pos.z || 0) - 10, + xmax: (pos.x || 0) + 10, + zmax: (pos.z || 0) + 10 }); } }); function initBuildingTypes() { - var texturePath = SceneJS.getConfigs("pluginPath") + "/node/objects/buildings/building/"; + var texturePath = SceneJS.getConfigs("pluginPath") + "/node/models/buildings/building/"; return [ // Building 1 { - freq:50, - material:{ - type:"material", - coreId:"building.1.material", - baseColor:{ - r:1.0, - g:1.0, - b:1.0 + freq: 50, + material: { + type: "material", + coreId: "building.1.material", + baseColor: { + r: 1.0, + g: 1.0, + b: 1.0 }, - specularColor:[ 1.0, 1.0, 1.0 ], - specular:0.4, - shine:20.0 + specularColor: [ 1.0, 1.0, 1.0 ], + specular: 0.4, + shine: 20.0 }, - texture:{ - type:"texture", - coreId:"building.1.texture", - layers:[ + texture: { + type: "texture", + coreId: "building.1.texture", + layers: [ { - src:texturePath + "highrise-windows.jpg", - applyTo:"baseColor", - blendMode:"multiply", - wrapS:"repeat", - wrapT:"repeat", - scale:{ - x:0.04, - y:0.05 + src: texturePath + "highrise-windows.jpg", + applyTo: "baseColor", + blendMode: "multiply", + wrapS: "repeat", + wrapT: "repeat", + scale: { + x: 0.04, + y: 0.05 } } ] }, - roof:{ - height:1, - material:{ - type:"material", - coreId:"building.1.roof", - baseColor:{ - r:1.0, - g:1.0, - b:1.0 + roof: { + height: 1, + material: { + type: "material", + coreId: "building.1.roof", + baseColor: { + r: 1.0, + g: 1.0, + b: 1.0 } } } }, // Building 2 { - freq:30, - material:{ - type:"material", - coreId:"building.2.material", - baseColor:{ - r:1.0, - g:1.0, - b:1.0 + freq: 30, + material: { + type: "material", + coreId: "building.2.material", + baseColor: { + r: 1.0, + g: 1.0, + b: 1.0 }, - specularColor:[ 1.0, 1.0, 1.0 ], - specular:1.0, - shine:5.0 + specularColor: [ 1.0, 1.0, 1.0 ], + specular: 1.0, + shine: 5.0 }, - texture:{ - type:"texture", - coreId:"building.2.texture", - layers:[ + texture: { + type: "texture", + coreId: "building.2.texture", + layers: [ { - src:texturePath + "HighRiseGlass.jpg", - applyTo:"baseColor", - blendMode:"multiply", - wrapS:"repeat", - wrapT:"repeat", - scale:{ - x:0.25, - y:0.2 + src: texturePath + "HighRiseGlass.jpg", + applyTo: "baseColor", + blendMode: "multiply", + wrapS: "repeat", + wrapT: "repeat", + scale: { + x: 0.25, + y: 0.2 } }, { - src:texturePath + "HighRiseGlassSpecular.jpg", - applyTo:"specular", - blendMode:"multiply", - wrapS:"repeat", - wrapT:"repeat", - scale:{ - x:0.25, - y:0.2 + src: texturePath + "HighRiseGlassSpecular.jpg", + applyTo: "specular", + blendMode: "multiply", + wrapS: "repeat", + wrapT: "repeat", + scale: { + x: 0.25, + y: 0.2 } } ] }, - roof:{ - height:1, - material:{ - type:"material", - coreId:"building.2.roof", - baseColor:{ - r:0.4, - g:0.4, - b:0.4 - } + roof: { + height: 1, + material: { + type: "material", + coreId: "building.2.roof", + baseColor: { + r: 0.4, + g: 0.4, + b: 0.4 + }, + specular: 0.2 } } }, // Building 3 { - freq:20, - material:{ - type:"material", - coreId:"building.3.material", - baseColor:{ - r:1.0, - g:1.0, - b:1.0 + freq: 20, + material: { + type: "material", + coreId: "building.3.material", + baseColor: { + r: 1.0, + g: 1.0, + b: 1.0 }, - specularColor:[ 1.0, 1.0, 1.0 ], - specular:0.4, - shine:20.0 + specularColor: [ 1.0, 1.0, 1.0 ], + specular: 0.4, + shine: 20.0 }, - texture:{ - type:"texture", - coreId:"building.3.texture", - layers:[ + texture: { + type: "texture", + coreId: "building.3.texture", + layers: [ { - src:texturePath + "pixelcity_windows7.jpg", - applyTo:"baseColor", - blendMode:"multiply", - wrapS:"repeat", - wrapT:"repeat", - scale:{ - x:0.015, - y:0.01 + src: texturePath + "pixelcity_windows7.jpg", + applyTo: "baseColor", + blendMode: "multiply", + wrapS: "repeat", + wrapT: "repeat", + scale: { + x: 0.015, + y: 0.01 } } ] }, - roof:{ - height:1, - material:{ - type:"material", - coreId:"building.3.roof", - baseColor:{ - r:0.0, - g:0.0, - b:0.0 - } + roof: { + height: 1, + material: { + type: "material", + coreId: "building.3.roof", + baseColor: { + r: 0.0, + g: 0.0, + b: 0.0 + }, + specular: 0.2 } } } @@ -281,26 +283,23 @@ function addBase(buildingType, node, xpos, zpos, xsize, ysize, zsize) { node.addNode({ - type:"translate", - x:xpos, - y:ysize, - z:zpos, - nodes:[ + type: "translate", + x: xpos, + y: ysize, + z: zpos, + nodes: [ { - type:"material", - baseColor:{ - r:0.6, g:.6, b:0.6 + type: "material", + baseColor: { + r: 0.6, g: .6, b: 0.6 }, - coreId:"building.base", - nodes:[ + coreId: "building.base", + nodes: [ { - type:"geometry", - source:{ - type:"box", - xSize:xsize, - ySize:ysize, - zSize:zsize - } + type: "geometry/box", + xSize: xsize, + ySize: ysize, + zSize: zsize } ] } @@ -314,19 +313,16 @@ */ node.addNode(buildingType.roof.material) .addNode({ - type:"translate", - x:xpos, - y:ypos + ysize + buildingType.roof.height, - z:zpos + type: "translate", + x: xpos, + y: ypos + ysize + buildingType.roof.height, + z: zpos }) .addNode({ - type:"geometry", - source:{ - type:"box", - xSize:xsize, - ySize:buildingType.roof.height, - zSize:zsize - } + type: "geometry/box", + xSize: xsize, + ySize: buildingType.roof.height, + zSize: zsize }); /* Body with texture @@ -334,19 +330,16 @@ node.addNode(buildingType.material)// Current material .addNode(buildingType.texture)// Current texture .addNode({ - type:"translate", - x:xpos, - y:ypos, - z:zpos + type: "translate", + x: xpos, + y: ypos, + z: zpos }) .addNode({ - type:"geometry", - source:{ - type:"box", - xSize:xsize, - ySize:ysize, - zSize:zsize - } + type: "geometry/box", + xSize: xsize, + ySize: ysize, + zSize: zsize }); } })(); \ No newline at end of file diff --git a/api/latest/plugins/node/objects/buildings/city.js b/api/latest/plugins/node/objects/buildings/city.js index 4ffc121e..7ffda93e 100644 --- a/api/latest/plugins/node/objects/buildings/city.js +++ b/api/latest/plugins/node/objects/buildings/city.js @@ -1,4 +1,4 @@ -SceneJS.Types.addType("objects/buildings/city", { +SceneJS.Types.addType("models/buildings/city", { construct:function (params) { @@ -12,7 +12,7 @@ SceneJS.Types.addType("objects/buildings/city", { for (var x = -halfWidth; x < halfWidth; x += 50) { for (var z = -halfWidth; z < halfWidth; z += 50) { this.addNode({ - type:"objects/buildings/building", + type:"models/buildings/building", buildingType:Math.floor(Math.random() * 3), // Three building types pos:{ x:x, diff --git a/api/latest/plugins/node/objects/plants/ghostTree.js b/api/latest/plugins/node/objects/plants/ghostTree.js index 161ace79..8983b1d7 100644 --- a/api/latest/plugins/node/objects/plants/ghostTree.js +++ b/api/latest/plugins/node/objects/plants/ghostTree.js @@ -7,7 +7,7 @@ * http://www.chromeexperiments.com/detail/ghost-trees/ * * Tree generation code is wrapped in a custom SceneJS node type defined in: - * http://scenejs.org/api/latest/plugins/node/objects/plants/ghostTree.js + * http://scenejs.org/api/latest/plugins/node/models/plants/ghostTree.js * * All the parameters for the tree generator are exposed as configurations * for the node type. @@ -21,7 +21,7 @@ ], function (glmat) { - SceneJS.Types.addType("objects/plants/ghostTree", { + SceneJS.Types.addType("models/plants/ghostTree", { construct:function (params) { diff --git a/api/latest/plugins/node/objects/space/planets/earth.js b/api/latest/plugins/node/objects/space/planets/earth.js index dbb403be..3db6bfe2 100644 --- a/api/latest/plugins/node/objects/space/planets/earth.js +++ b/api/latest/plugins/node/objects/space/planets/earth.js @@ -1,8 +1,8 @@ -SceneJS.Types.addType("objects/space/planets/earth", { +SceneJS.Types.addType("models/space/planets/earth", { construct:function (params) { - var texturePath = SceneJS.getConfigs("pluginPath") + "/node/objects/space/planets/earth/"; + var texturePath = SceneJS.getConfigs("pluginPath") + "/node/models/space/planets/earth/"; var node = this.addNode({ type:"rotate", diff --git a/api/latest/plugins/node/objects/toys/drinkingBird.js b/api/latest/plugins/node/objects/toys/drinkingBird.js index eb46c8da..28a985d7 100644 --- a/api/latest/plugins/node/objects/toys/drinkingBird.js +++ b/api/latest/plugins/node/objects/toys/drinkingBird.js @@ -6,12 +6,12 @@ * Usage example: * * someNode.addNode({ - * type: "objects/toys/drinkingBird", + * type: "models/toys/drinkingBird", * rotate: true // Default false - causes bird to drink when true * }); * */ -SceneJS.Types.addType("objects/toys/drinkingBird", { +SceneJS.Types.addType("models/toys/drinkingBird", { init:function (params) { @@ -110,7 +110,7 @@ SceneJS.Types.addType("objects/toys/drinkingBird", { color:{ r:0.53, g:0.53, b:0.53 }, nodes:[ { - type:"prims/cylinder", + type:"geometry/cylinder", radiusTop:5, radiusBottom:5, height:300, @@ -137,7 +137,7 @@ SceneJS.Types.addType("objects/toys/drinkingBird", { coreId:"feetMaterial", nodes:[ { - type:"prims/box", + type:"geometry/box", xSize:83, ySize:2, zSize:(110 + 64 + 20) / 2 @@ -161,7 +161,7 @@ SceneJS.Types.addType("objects/toys/drinkingBird", { coreId:"feetMaterial", nodes:[ { - type:"prims/box", + type:"geometry/box", xSize:3, ySize:52 / 2, zSize:(110 + 64 + 20) / 2 @@ -179,7 +179,7 @@ SceneJS.Types.addType("objects/toys/drinkingBird", { coreId:"feetMaterial", nodes:[ { - type:"prims/box", + type:"geometry/box", xSize:3, ySize:15, zSize:64 / 2 @@ -197,7 +197,7 @@ SceneJS.Types.addType("objects/toys/drinkingBird", { coreId:"legMaterial", nodes:[ { - type:"prims/box", + type:"geometry/box", xSize:3, ySize:(334 - 30) / 2, zSize:64 / 2 @@ -221,7 +221,7 @@ SceneJS.Types.addType("objects/toys/drinkingBird", { coreId:"feetMaterial", nodes:[ { - type:"prims/box", + type:"geometry/box", xSize:3, ySize:52 / 2, zSize:(110 + 64 + 20) / 2 @@ -239,7 +239,7 @@ SceneJS.Types.addType("objects/toys/drinkingBird", { coreId:"feetMaterial", nodes:[ { - type:"prims/box", + type:"geometry/box", xSize:3, ySize:15, zSize:64 / 2 @@ -257,7 +257,7 @@ SceneJS.Types.addType("objects/toys/drinkingBird", { coreId:"legMaterial", nodes:[ { - type:"prims/box", + type:"geometry/box", xSize:3, ySize:(334 - 30) / 2, zSize:64 / 2 @@ -304,7 +304,7 @@ SceneJS.Types.addType("objects/toys/drinkingBird", { coreId:"waterMaterial", nodes:[ { - type:"prims/cylinder", + type:"geometry/cylinder", radiusTop:8, radiusBottom:8, height:300, @@ -345,7 +345,7 @@ SceneJS.Types.addType("objects/toys/drinkingBird", { coreId:"waterMaterial", nodes:[ { - type:"prims/cylinder", + type:"geometry/cylinder", radiusTop:52, radiusBottom:52, height:0, @@ -366,7 +366,7 @@ SceneJS.Types.addType("objects/toys/drinkingBird", { coreId:"glassMaterial", nodes:[ { - type:"prims/cylinder", + type:"geometry/cylinder", radiusTop:12, radiusBottom:12, height:435, @@ -434,7 +434,7 @@ SceneJS.Types.addType("objects/toys/drinkingBird", { coreId:"headMaterial", nodes:[ { - type:"prims/cylinder", + type:"geometry/cylinder", radiusTop:8, radiusBottom:15, height:70, @@ -573,7 +573,7 @@ SceneJS.Types.addType("objects/toys/drinkingBird", { coreId:"hatMaterial", nodes:[ { - type:"prims/cylinder", + type:"geometry/cylinder", radiusTop:71, radiusBottom:71, height:10, @@ -590,7 +590,7 @@ SceneJS.Types.addType("objects/toys/drinkingBird", { coreId:"hatMaterial", nodes:[ { - type:"prims/cylinder", + type:"geometry/cylinder", radiusTop:45, radiusBottom:45, height:66, diff --git a/api/latest/plugins/node/physics/box.js b/api/latest/plugins/node/physics/box.js index 230e27c1..26464e7c 100644 --- a/api/latest/plugins/node/physics/box.js +++ b/api/latest/plugins/node/physics/box.js @@ -20,7 +20,7 @@ SceneJS.Types.addType("physics/box", { nodes:[ { - type:"prims/box", + type:"geometry/box", size: params.size } ] diff --git a/api/latest/plugins/node/physics/plane.js b/api/latest/plugins/node/physics/plane.js index b81daefc..5daebf29 100644 --- a/api/latest/plugins/node/physics/plane.js +++ b/api/latest/plugins/node/physics/plane.js @@ -31,7 +31,7 @@ SceneJS.Types.addType("physics/plane", { angle:90, nodes:[ { - type:"prims/plane", + type:"geometry/plane", wire:params.wire, xSegments:params.xSegments || 100, zSegments:params.zSegments || 100 diff --git a/api/latest/plugins/node/physics/sphere.js b/api/latest/plugins/node/physics/sphere.js index be88e842..fe104dec 100644 --- a/api/latest/plugins/node/physics/sphere.js +++ b/api/latest/plugins/node/physics/sphere.js @@ -20,7 +20,7 @@ SceneJS.Types.addType("physics/sphere", { nodes:[ { - type:"prims/radius", + type:"geometry/radius", latitudeBands: params.latitudeBands, longitudeBands: params.longitudeBands, radius: params.radius diff --git a/api/latest/plugins/node/physics/teapot.js b/api/latest/plugins/node/physics/teapot.js index 0dee1a6e..7e0a5e79 100644 --- a/api/latest/plugins/node/physics/teapot.js +++ b/api/latest/plugins/node/physics/teapot.js @@ -20,7 +20,7 @@ SceneJS.Types.addType("physics/teapot", { nodes:[ { - type:"prims/teapot" + type:"geometry/teapot" } ] }); diff --git a/api/latest/plugins/node/prims/quad.js b/api/latest/plugins/node/prims/quad.js deleted file mode 100644 index 44f25d45..00000000 --- a/api/latest/plugins/node/prims/quad.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Quad geometry node type - * - * Usage example: - * - * someNode.addNode({ - * type: "prims/quad", - * wire: false // Default - * }); - */ -(function () { - - SceneJS.Types.addType("prims/quad", { - construct:function (params) { - this.addNode(build.call(this, params)); - } - }); - - function build(params) { - - var coreId = "prims/quad" + (params.wire ? "wire" : "_solid"); - - // If a node core already exists for a prim with the given properties, - // then for efficiency we'll share that core rather than create another geometry - if (this.getScene().hasCore("geometry", coreId)) { - return { - type: "geometry", - coreId:coreId - }; - } - - // Otherwise, create a new geometry - return { - type: "geometry", - primitive:params.wire ? "lines" : "triangles", - coreId:coreId, - positions:[ 1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0 ], - normals:[ -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0 ], - uv:[ 1, 1, 0, 1, 0, 0, 1, 0 ], - indices:[ 0, 1, 2, 0, 2, 3 ] - }; - } -})(); \ No newline at end of file diff --git a/api/latest/plugins/node/reflections/london.js b/api/latest/plugins/node/reflections/london.js deleted file mode 100644 index 67e86521..00000000 --- a/api/latest/plugins/node/reflections/london.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Reflection map of a street in London - * - * Usage example: - * - * someNode.addNode({ - * type: "reflections/london", - * intensity: 0.2 - * }); - */ -SceneJS.Types.addType("reflections/london", { - - construct: function (params) { - - var path = SceneJS.getConfigs("pluginPath") + "/node/reflections/textures/london/"; - - this.addNode({ - type: "reflect", - intensity: params.intensity, - src: [ - path + "pos-x.png", - path + "neg-x.png", - path + "pos-y.png", - path + "neg-y.png", - path + "pos-z.png", - path + "neg-z.png" - ], - - // Attach given child nodes - nodes: params.nodes - }) - } -}); diff --git a/api/latest/plugins/node/skyboxes/clouds.js b/api/latest/plugins/node/skyboxes/clouds.js deleted file mode 100644 index d6ff14d0..00000000 --- a/api/latest/plugins/node/skyboxes/clouds.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Cloudy skybox node type, with fine clouds - * - * Usage example: - * - * someNode.addNode({ - * type: "skyboxes/clouds" - * }); - */ -SceneJS.Types.addType("skyboxes/clouds", { - construct:function (params) { - - // Wraps a 'custom' skybox node type, passing in a clouds texture - this.addNode({ - type:"skyboxes/custom", - src:SceneJS.getConfigs("pluginPath") + "/node/skyboxes/textures/clouds.jpg" - }) - } -}); diff --git a/api/latest/plugins/node/skyboxes/cloudySea.js b/api/latest/plugins/node/skyboxes/cloudySea.js deleted file mode 100644 index 46e74aa4..00000000 --- a/api/latest/plugins/node/skyboxes/cloudySea.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Cloudy skybox node type, with clouds reflected in a calm sea - * - * Usage example: - * - * someNode.addNode({ - * type: "skyboxes/cloudySea" - * }); - */ -SceneJS.Types.addType("skyboxes/cloudySea", { - construct:function (params) { - - // Wraps a 'custom' skybox node type, passing in a cloudySea texture - this.addNode({ - type:"skyboxes/custom", - src:SceneJS.getConfigs("pluginPath") + "/node/skyboxes/textures/cloudySea.jpg" - }) - } -}); diff --git a/api/latest/plugins/node/skyboxes/custom.js b/api/latest/plugins/node/skyboxes/custom.js deleted file mode 100644 index 5cdb9f13..00000000 --- a/api/latest/plugins/node/skyboxes/custom.js +++ /dev/null @@ -1,163 +0,0 @@ -/** - * Customizable skybox node type, which allows you to customize its texture - * - * Usage example: - * - * someNode.addNode({ - * type: "skyboxes/custom", - * texture: "foo/bar/mySkyboxTexture.jpg", - * size: 5000 // Box half-size on each axis - default is 5000 - * }); - */ -SceneJS.Types.addType("skyboxes/custom", { - - // TODO: expose node props to tweak the geometry coords to map to variations in texture UV mappings? - - construct: function (params) { - - var self = this; - - // Fall back on clouds texture by default - var src = params.src || SceneJS.getConfigs("pluginPath") + "/node/skyboxes/textures/clouds.jpg"; - - var image = new Image(); - image.onload = function () { - buildNodes(); - }; - image.onerror = function () { - }; - image.src = src; - - function buildNodes() { - - // Sky box dimensions on each axis - var size = params.size || 5000.0; - - // Vertex shader which anchors the skybox translation - self.addNode({ - - // Special pick name so that we can ignore picks on sky boxes - type: "name", - name: "__SceneJS_dontPickMe", - - nodes: [ - { - type: "shader", - shaders: [ - { - stage: "vertex", - code: [ - "mat4 myViewMatrix(mat4 m) {", - " m[3][0] =m[3][1] = m[3][2] = 0.0;", - "return m;", - "}" - ], - // Bind our injected functions to SceneJS hook points - hooks: { - viewMatrix: "myViewMatrix" - } - } - ], - nodes: [ - // Disable lighting for the sky box - { - type: "flags", - flags: { - specular: false, - diffuse: false, - ambient: false - }, - nodes: [ - { - type: "material", - color: { r: 0, g: 0, b: 0 }, - emit: 0.0, - nodes: [ - // Clouds texture - { - type: "texture", - layers: [ - { - src: src, - blendMode: "add" - } - ], - nodes: [ - { - type: "scale", - x: size, y: size, z: size, - nodes: [ - // Sky box geometry - { - type: "geometry", - positions: [ - 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, // v0-v1-v2-v3 front - 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, // v0-v3-v4-v5 right - 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, // v0-v5-v6-v1 top - -1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, // v1-v6-v7-v2 left - -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, // v7-v4-v3-v2 bottom - 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1 // v4-v7-v6-v5 back - ], - uv: [ - 0.5, 0.6666, - 0.25, 0.6666, - 0.25, 0.3333, - 0.5, 0.3333, - - 0.5, 0.6666, - 0.5, 0.3333, - 0.75, 0.3333, - 0.75, 0.6666, - - 0.5, 0.6666, - 0.5, 1, - 0.25, 1, - 0.25, 0.6666, - - 0.25, 0.6666, - 0.0, 0.6666, - 0.0, 0.3333, - 0.25, 0.3333, - - 0.25, 0, - 0.50, 0, - 0.50, 0.3333, - 0.25, 0.3333, - - 0.75, 0.3333, - 1.0, 0.3333, - 1.0, 0.6666, - 0.75, 0.6666 - ], - indices: [ - 0, 1, 2, - 0, 2, 3, - 4, 5, 6, - 4, 6, 7, - 8, 9, 10, - 8, 10, 11, - 12, 13, 14, - 12, 14, 15, - - 16, 17, 18, - 16, 18, 19, - - 20, 21, 22, - 20, 22, 23 - ] - } - ] - } - ] - } - ] - } - ] - } - ] - } - ] - }); - } - } -}); diff --git a/api/latest/plugins/node/skyboxes/grimmNight.js b/api/latest/plugins/node/skyboxes/grimmNight.js deleted file mode 100644 index a06e0f43..00000000 --- a/api/latest/plugins/node/skyboxes/grimmNight.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Skybox node type, with gloomy night clouds - * - * Usage example: - * - * someNode.addNode({ - * type: "skyboxes/grimmNight" - * }); - */ -SceneJS.Types.addType("skyboxes/grimmNight", { - construct:function (params) { - - // Wraps a 'custom' skybox node type, passing in a the grimmNight texture - this.addNode({ - type:"skyboxes/custom", - src:SceneJS.getConfigs("pluginPath") + "/node/skyboxes/textures/grimmNight.jpg" - }) - } -}); diff --git a/api/latest/plugins/node/skyboxes/violentDays.js b/api/latest/plugins/node/skyboxes/violentDays.js deleted file mode 100644 index 5355c80e..00000000 --- a/api/latest/plugins/node/skyboxes/violentDays.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Skybox node type, with firey apocalyptic clouds - * - * Usage example: - * - * someNode.addNode({ - * type: "skyboxes/violentDays" - * }); - */ -SceneJS.Types.addType("skyboxes/violentDays", { - construct:function (params) { - - // Wraps a 'custom' skybox node type, passing in the violentDays texture - this.addNode({ - type:"skyboxes/custom", - src:SceneJS.getConfigs("pluginPath") + "/node/skyboxes/textures/violentDays.jpg" - }) - } -}); diff --git a/api/latest/plugins/node/textures/video.js b/api/latest/plugins/node/textures/video.js deleted file mode 100644 index d1b42bf9..00000000 --- a/api/latest/plugins/node/textures/video.js +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Video texture - * - */ - -SceneJS.Types.addType("textures/video", { - - construct: function (params) { - - if (!params.src) { - this.log("error", "Attribute expected: src"); - } - - this._texture = this.addNode({ - type: "textureMap", - minFilter: "linear", - magFilter: "linear", - wrapS: params.wrapS, - wrapT: params.wrapT, - applyTo: params.applyTo, - nodes: params.nodes - }); - - var canvas = document.createElement("canvas"); - document.getElementsByTagName("body")[0].appendChild(canvas); - var ctx = canvas.getContext("2d"); - - // Create hidden video canvas - var video = document.createElement("video"); - video.style.display = "none"; - video.setAttribute("loop", "loop"); - video.autoplay = true; - video.addEventListener("ended", // looping broken in FF - function () { - this.play(); - }, - true); - document.getElementsByTagName("body")[0].appendChild(video); - //video.crossOrigin = "anonymous"; - video.src = params.src; - - var self = this; - - // Periodically feed images from canvas into texture - this._tick = this.getScene().on("tick", - function () { - if (video.readyState > 0) { - if (video.height <= 0) { - video.style.display = ""; - video.height = video.offsetHeight; - video.width = video.offsetWidth; - video.style.display = "none"; - } - self._texture.setImage(video); - } - }); - }, - - /** - * Sets the texture's blend factor with respect to other active textures. - * @param {number} blendFactor The blend factor, in range [0..1] - */ - setBlendFactor: function (blendFactor) { - this._texture.setBlendFactor(blendFactor); - }, - - getBlendFactor: function () { - return this._texture.getBlendFactor(); - }, - - setTranslate: function (t) { - this._texture.setTranslate(t); - }, - - getTranslate: function () { - return this._texture.getTranslate(); - }, - - setScale: function (s) { - this._texture.setScale(s); - }, - - getScale: function () { - return this._texture.getScale(); - }, - - setRotate: function (angle) { - this._texture.setRotate(s); - }, - - getRotate: function () { - return this._texture.getRotate(); - }, - - getMatrix: function () { - return this._texture.getMatrix(); - }, - - destruct: function () { - this.getScene.off(this._tick); - } -}); diff --git a/api/latest/scenejs.js b/api/latest/scenejs.js index 8e5e509c..0b20d679 100644 --- a/api/latest/scenejs.js +++ b/api/latest/scenejs.js @@ -1231,6 +1231,29 @@ var SceneJS = new (function () { return o2; }; + var hasOwnProperty = Object.prototype.hasOwnProperty; + + /** + * Tests is an object is empty + * @param obj + * @returns {boolean} + * @private + */ + this._isEmpty =function(obj) { + // null and undefined are "empty" + if (obj == null) return true; + // Assume if it has a length property with a non-zero value + // that that property is correct. + if (obj.length > 0) return false; + if (obj.length === 0) return true; + // Otherwise, does it have any properties of its own? + // Note that this doesn't handle + // toString and valueOf enumeration bugs in IE < 9 + for (var key in obj) { + if (hasOwnProperty.call(obj, key)) return false; + } + return true; + }; /** * Resets SceneJS, destroying all existing scenes @@ -1761,7 +1784,6 @@ SceneJS_Canvas.prototype.initWebGL = function () { for (var i = 0; !this.gl && i < this._WEBGL_CONTEXT_NAMES.length; i++) { try { this.gl = this.canvas.getContext(this._WEBGL_CONTEXT_NAMES[i], this.contextAttr); - } catch (e) { // Try with next context name } } @@ -1772,13 +1794,14 @@ SceneJS_Canvas.prototype.initWebGL = function () { 'Failed to get a WebGL context'); } + // this.gl.enable(this.gl.SCISSOR_TEST); // this.gl.clearColor(1.0, 1.0, 1.0, 1.0); - this.gl.clearDepth(1.0); - this.gl.enable(this.gl.DEPTH_TEST); - this.gl.disable(this.gl.CULL_FACE); - this.gl.depthRange(0, 1); - this.gl.disable(this.gl.SCISSOR_TEST); - this.gl.viewport(0, 0, this.canvas.width, this.canvas.height); +// this.gl.clearDepth(1.0); +// this.gl.enable(this.gl.DEPTH_TEST); +// this.gl.disable(this.gl.CULL_FACE); +// this.gl.depthRange(0, 1); +// this.gl.disable(this.gl.SCISSOR_TEST); +// this.gl.viewport(0, 0, this.canvas.width, this.canvas.height); }; @@ -1809,6 +1832,14 @@ var SceneJS_Engine = function (json, options) { */ this.id = json.id; + + /** + * Number of times the scene is drawn each time it's rendered. + *

This is useful for when we need to do things like render for left and right eyes. + * @type {*|number} + */ + this._numPasses = json.numPasses || 1; + /** * Canvas and GL context for this engine */ @@ -1834,8 +1865,9 @@ var SceneJS_Engine = function (json, options) { * @type SceneJS_Display */ this.display = new SceneJS_Display({ - canvas:this.canvas, - transparent: json.transparent + canvas: this.canvas, + transparent: json.transparent, + dof: json.dof }); /** @@ -1878,8 +1910,8 @@ var SceneJS_Engine = function (json, options) { * The current scene graph status */ this.sceneStatus = { - nodes:{}, // Status for each node - numTasks:0 // Number of loads currently in progress + nodes: {}, // Status for each node + numTasks: 0 // Number of loads currently in progress }; var self = this; @@ -1901,7 +1933,7 @@ var SceneJS_Engine = function (json, options) { function (event) { event.preventDefault(); self.stop(); - SceneJS_events.fireEvent(SceneJS_events.WEBGL_CONTEXT_LOST, { scene:self.scene }); + SceneJS_events.fireEvent(SceneJS_events.WEBGL_CONTEXT_LOST, { scene: self.scene }); }, false); @@ -1911,12 +1943,22 @@ var SceneJS_Engine = function (json, options) { self.canvas.initWebGL(); self._coreFactory.webglRestored(); // Reallocate WebGL resources for node state cores self.display.webglRestored(); // Reallocate shaders and re-cache shader var locations for display state chunks - SceneJS_events.fireEvent(SceneJS_events.WEBGL_CONTEXT_RESTORED, { scene:self.scene }); + SceneJS_events.fireEvent(SceneJS_events.WEBGL_CONTEXT_RESTORED, { scene: self.scene }); self.start(); }, false); }; +/** + * Sets the number of times the scene is drawn on each render. + *

This is useful for when we need to do things like render for left and right eyes. + * @param {Number} numPasses The number of times the scene is drawn on each frame. + * @see #getTagMask + * @see SceneJS.Tag + */ +SceneJS_Engine.prototype.setNumPasses = function (numPasses) { + this._numPasses = numPasses; +}; /** * Simulate a lost WebGL context. @@ -1996,17 +2038,11 @@ SceneJS_Engine.prototype.createNode = function (json, ok) { * node and core pools for reuse, respectively. */ SceneJS_Engine.prototype._doDestroyNodes = function () { - var node; - while (this._numNodesToDestroy > 0) { - node = this._nodesToDestroy[--this._numNodesToDestroy]; - node._doDestroy(); - this._coreFactory.putCore(node._core); // Release state core for reuse - this._nodeFactory.putNode(node); // Release node for reuse } }; @@ -2083,18 +2119,49 @@ SceneJS_Engine.prototype.branchDirty = function (node) { * Ordinarily the frame is rendered only if compilations or draw graph updates were performed, * but may be forced to render the frame regardless. * - * @param {{String:String}} params Rendering parameters + * @param {*} params Rendering parameters + * @param {Boolean} params.clear True to clear the display first (default) */ SceneJS_Engine.prototype.renderFrame = function (params) { - if (this._tryCompile() || (params && params.force)) { // Do any pending (re)compilations + var rendered = false; - this.display.render(params); + if (this._needCompile() || (params && params.force)) { - return true; +// // Render display graph +// this.display.render(params); + + var time = (new Date()).getTime(); + + // Render the scene once for each pass + for (var i = 0; i < this._numPasses; i++) { + + // Notify that render is upcoming + this.scene.publish("rendering", { + pass: i + }); + + // Compile scene graph to display graph, if necessary + this._doCompile(); + + // Render display graph + // Clear buffers only on first frame + this.display.render({ + clear: i == 0 + }); + + // Notify that render completed + this.scene.publish("rendered", { + sceneId: this.id, + time: time, + pass: i + }); + + rendered = true; + } } - return false; + return rendered; }; /** @@ -2102,78 +2169,101 @@ SceneJS_Engine.prototype.renderFrame = function (params) { */ SceneJS_Engine.prototype.start = function () { - if (!this.running) { + if (!this.running) { // Do nothing if already started this.running = true; this.paused = false; + this.sceneDirty = true; var self = this; var fnName = "__scenejs_sceneLoop" + this.id; - var sleeping = false; - - this.sceneDirty = true; - - var tick = { - sceneId:this.id, - startTime:(new Date()).getTime() - }; - - self.events.fireEvent("started", tick); - var time = (new Date()).getTime(); - + var prevTime = time; + var startTime = time; var scene = this.scene; + var rendered = false; + + // Notify started + this.events.fireEvent("started", { + sceneId: self.id, + startTime: startTime + }); + // Animation frame callback window[fnName] = function () { - if (self.running && !self.paused) { // idleFunc may have paused scene + if (self.running && !self.paused) { - tick.prevTime = time; time = (new Date()).getTime(); - tick.time = time; - scene.publish("tick", tick); + scene.publish("tick", { + sceneId: self.id, + startTime: startTime, + prevTime: prevTime, + time: time + }); + + prevTime = time; - if (!self.running) { // idleFunc may have destroyed scene + if (!self.running) { // "tick" handler have destroyed scene return; } - if (self._tryCompile()) { // Attempt pending compile and redraw + rendered = false; - sleeping = false; + // Render the scene once for each pass + for (var i = 0; i < self._numPasses; i++) { - self.display.render(); + if (self._needCompile() || rendered) { - scene.publish("rendered", tick); + sleeping = false; - if (self.running) { - window.requestAnimationFrame(window[fnName]); - } + // Notify we're about to do a render + scene.publish("rendering", { + pass: i + }); - } else { + // Compile scene graph to display graph, if necessary + self._doCompile(); - if (!sleeping) { - scene.publish("sleep", tick); - } + // Render display graph + // Clear buffers only on first frame + self.display.render({ + clear: i == 0 + }); - sleeping = true; + // Notify that we've just done a render + scene.publish("rendered", { + sceneId: self.id, + time: time, + pass: i + }); - if (self.running) { - window.requestAnimationFrame(window[fnName]); + rendered = true; } } - } else { - if (self.running) { - window.requestAnimationFrame(window[fnName]); + // If any of the passes did not render anything, then put the render loop to sleep again + if (!rendered) { + if (!sleeping) { + scene.publish("sleep", { + sceneId: self.id, + startTime: startTime, + prevTime: time, + time: time + }); + } + sleeping = true; } } + + if (self.running) { + window.requestAnimationFrame(window[fnName]); + } }; - if (self.running) { - window.requestAnimationFrame(window[fnName]); - } + window.requestAnimationFrame(window[fnName]); } }; @@ -2193,59 +2283,52 @@ SceneJS_Engine.prototype.start = function () { */ SceneJS_Engine.prototype.pick = function (canvasX, canvasY, options) { - this._tryCompile(); // Do any pending scene compilations + // Do any pending scene compilations + if (this._needCompile()) { + this._doCompile(); + } var hit = this.display.pick({ - canvasX:canvasX, - canvasY:canvasY, - rayPick:options ? options.rayPick : false + canvasX: canvasX, + canvasY: canvasY, + rayPick: options ? options.rayPick : false }); return hit; }; /** - * Performs any pending scene compilations or display rebuilds, returns true if any of those were done, - * in which case a display re-render is then needed - * - * @returns {Boolean} True when any compilations or display rebuilds were done + * Returns true if view needs refreshing from scene + * @returns {Boolean} + * @private */ -SceneJS_Engine.prototype._tryCompile = function () { - - // this._doAddNodes(); - - if (this.display.imageDirty // Frame buffer needs redraw +SceneJS_Engine.prototype._needCompile = function () { + return (this.display.imageDirty // Frame buffer needs redraw || this.display.drawListDirty // Draw list needs rebuild || this.display.stateSortDirty // Draw list needs to redetermine state order || this.display.stateOrderDirty // Draw list needs state sort || this.display.objectListDirty // Draw list needs to be rebuilt || this._sceneBranchesDirty // One or more branches in scene graph need (re)compilation - || this.sceneDirty) { // Whole scene needs recompilation - - if (this._sceneBranchesDirty || this.sceneDirty) { // Need scene graph compilation - - this._sceneBranchesDirty = false; - - SceneJS_events.fireEvent(SceneJS_events.SCENE_COMPILING, { // Notify compilation support start - engine:this // Compilation support modules get ready - }); - - this.pubSubProxy = new SceneJS_PubSubProxy(this.scene, null); - var ctx = { - pubSubProxy : this.pubSubProxy - }; - - this.scene._compileNodes(ctx); // Begin depth-first compilation descent into scene sub-nodes - - this.sceneDirty = false; - } - - this._doDestroyNodes(); // Garbage collect destroyed nodes - node destructions set imageDirty true + || this.sceneDirty); // Whole scene needs recompilation +}; - return true; // Compilation was performed, need frame redraw now +/** + * Performs any pending scene compilations or display rebuilds + */ +SceneJS_Engine.prototype._doCompile = function () { + if (this._sceneBranchesDirty || this.sceneDirty) { // Need scene graph compilation + this._sceneBranchesDirty = false; + SceneJS_events.fireEvent(SceneJS_events.SCENE_COMPILING, { // Notify compilation support start + engine: this // Compilation support modules get ready + }); + this.pubSubProxy = new SceneJS_PubSubProxy(this.scene, null); + var ctx = { + pubSubProxy: this.pubSubProxy + }; + this.scene._compileNodes(ctx); // Begin depth-first compilation descent into scene sub-nodes + this.sceneDirty = false; } - - return false; + this._doDestroyNodes(); // Garbage collect destroyed nodes - node destructions set imageDirty true }; /** @@ -2260,14 +2343,10 @@ SceneJS_Engine.prototype.pause = function (doPause) { * Stops the render loop */ SceneJS_Engine.prototype.stop = function () { - if (this.running) { - this.running = false; this.paused = false; - window["__scenejs_sceneLoop" + this.id] = null; - // this.events.fireEvent("stopped", { sceneId: this.id }); } }; @@ -2297,9 +2376,7 @@ SceneJS_Engine.prototype.destroyNode = function (node) { * Destroys this engine */ SceneJS_Engine.prototype.destroy = function () { - this.destroyed = true; - // this.events.fireEvent("destroyed", { sceneId: this.id }); }; @@ -2486,7 +2563,7 @@ var SceneJS_configsModule = new (function () { for (var i = 0; cfg && i < parts.length; i++) { cfg = cfg[parts[i]]; } - return cfg || {}; + return (cfg != undefined) ? cfg : {}; } }; @@ -4872,7 +4949,9 @@ var SceneJS_sceneStatusModule = new (function () { dismissPopup(task.element); } var nodeState = task.nodeState; - nodeState.numTasks--; + if (--nodeState.numTasks < 0) { + nodeState.numTasks = 0; + } delete nodeState.tasks[taskId]; if (nodeState.numTasks == 0) { delete sceneState.nodeStates[nodeState.nodeId]; @@ -5091,7 +5170,7 @@ SceneJS._webgl.RenderBuffer = function (cfg) { this._touch = function () { var width = canvas.canvas.width; var height = canvas.canvas.height; - if (buf) { // Currently have a pick buffer + if (buf) { // Currently have a buffer if (buf.width == width && buf.height == height) { // Canvas size unchanged, buffer still good return; } else { // Buffer needs reallocation for new canvas size @@ -5155,7 +5234,7 @@ SceneJS._webgl.RenderBuffer = function (cfg) { */ this.clear = function () { if (!bound) { - throw "Pick buffer not bound"; + throw "Render buffer not bound"; } gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); gl.disable(gl.BLEND); @@ -5182,15 +5261,20 @@ SceneJS._webgl.RenderBuffer = function (cfg) { /** Returns the texture */ this.getTexture = function () { - this._touch(); return { bind: function (unit) { - gl.activeTexture(gl["TEXTURE" + unit]); - gl.bindTexture(gl.TEXTURE_2D, buf.texture); + if (buf && buf.texture) { + gl.activeTexture(gl["TEXTURE" + unit]); + gl.bindTexture(gl.TEXTURE_2D, buf.texture); + return true; + } + return false; }, unbind: function (unit) { - gl.activeTexture(gl["TEXTURE" + unit]); - gl.bindTexture(gl.TEXTURE_2D, null); + if (buf && buf.texture) { + gl.activeTexture(gl["TEXTURE" + unit]); + gl.bindTexture(gl.TEXTURE_2D, null); + } } }; }; @@ -6020,6 +6104,12 @@ SceneJS.Node.prototype._construct = function (engine, core, cfg, nodeId) { */ this._core = core; + /** + * The core ID + * @type {String|Number} + */ + this.coreId = core.coreId; + /** * ID of this node, unique within its scene. The ID is a string if it was defined by the application * via the node's JSON configuration, otherwise it is a number if it was left to SceneJS to automatically create. @@ -6405,9 +6495,12 @@ SceneJS.Node.prototype.disconnect = function () { if (this.parent) { for (var i = 0; i < this.parent.nodes.length; i++) { if (this.parent.nodes[i] === this) { - return this.parent.disconnectNodeAt(i); + var node = this.parent.disconnectNodeAt(i); + this.parent = null; + return node; } } + this.parent = null; } return null; }; @@ -6465,19 +6558,13 @@ SceneJS.Node.prototype.removeNode = function (node) { /** Disconnects all child nodes from their parent node and returns them in an array. */ SceneJS.Node.prototype.disconnectNodes = function () { - var len = this.nodes.length; - for (var i = 0; i < len; i++) { // Unlink nodes from this this.nodes[i].parent = null; } - var nodes = this.nodes; - this.nodes = []; - this._engine.display.objectListDirty = true; - return nodes; }; @@ -7580,14 +7667,14 @@ SceneJS_NodeFactory.prototype.putNode = function (node) { if (this._core.useCount == 1) { this.setOptics(params.optics); // Can be undefined - // Rebuild on every scene tick - // https://github.com/xeolabs/scenejs/issues/277 - var self = this; - this._tick = this.getScene().on("tick", function () { - if (self._core.dirty) { - self._core.rebuild(); - } - }); +// // Rebuild on every scene tick +// // https://github.com/xeolabs/scenejs/issues/277 +// var self = this; +// this._tick = this.getScene().on("tick", function () { +// if (self._core.dirty) { +// self._core.rebuild(); +// } +// }); } }; @@ -8195,12 +8282,12 @@ SceneJS_NodeFactory.prototype.putNode = function (node) { new (function () { var defaultCore = { - type: "framebuf", + type: "renderTarget", stateId: SceneJS._baseStateId++, - framebuf: null + targets: null }; - // Map of framebuf nodes to cores, for reallocation on WebGL context restore + // Map of nodes to cores, for reallocation on WebGL context restore var nodeCoreMap = {}; var coreStack = []; @@ -8209,11 +8296,12 @@ new (function () { SceneJS_events.addListener( SceneJS_events.SCENE_COMPILING, function (params) { - params.engine.display.framebuf = defaultCore; + params.engine.display.renderTarget = defaultCore; stackLen = 0; }); - SceneJS_events.addListener(// Reallocate VBOs when context restored after loss + // Reallocate VBOs when context restored after loss + SceneJS_events.addListener( SceneJS_events.WEBGL_CONTEXT_RESTORED, function () { for (var nodeId in nodeCoreMap) { @@ -8223,32 +8311,90 @@ new (function () { } }); - /** - * @class Scene graph node which sets up a frame buffer to which the {@link SceneJS.Geometry} nodes in its subgraph will be rendered. - * The frame buffer may be referenced as an image source by successive {@link SceneJS.Texture} nodes. - * @extends SceneJS.Node - */ - SceneJS.Framebuf = SceneJS_NodeFactory.createNodeType("framebuf"); + SceneJS.ColorTarget = SceneJS_NodeFactory.createNodeType("colorTarget"); - SceneJS.Framebuf.prototype._init = function () { + SceneJS.ColorTarget.prototype._init = function (params) { nodeCoreMap[this._core.coreId] = this; - this._buildNodeCore(); + this._core.bufType = "color"; + this._core.renderBuf = new SceneJS._webgl.RenderBuffer({ canvas: this._engine.canvas }); + }; + + SceneJS.ColorTarget.prototype._compile = function (ctx) { + if (!this.__core) { + this.__core = this._engine._coreFactory.getCore("renderTarget"); + } + var parentCore = this._engine.display.renderTarget; + if (!this._core.empty) { + this.__core.targets = (parentCore && parentCore.targets) ? parentCore.targets.concat([this._core]) : [this._core]; + } + coreStack[stackLen++] = this.__core; + this._engine.display.renderTarget = this.__core; + this._compileNodes(ctx); + this._engine.display.renderTarget = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore; }; - SceneJS.Framebuf.prototype._buildNodeCore = function () { - if (!this._core) { - this._core = {}; + + SceneJS.ColorTarget.prototype._destroy = function () { + if (this._core) { + delete nodeCoreMap[this._core.coreId]; } - this._core.framebuf = new SceneJS._webgl.RenderBuffer({ canvas: this._engine.canvas }); + }; +})();new (function () { + + var defaultCore = { + type: "renderTarget", + stateId: SceneJS._baseStateId++, + targets: null + }; + + // Map of nodes to cores, for reallocation on WebGL context restore + var nodeCoreMap = {}; + + var coreStack = []; + var stackLen = 0; + + SceneJS_events.addListener( + SceneJS_events.SCENE_COMPILING, + function (params) { + params.engine.display.renderTarget = defaultCore; + stackLen = 0; + }); + + // Reallocate VBOs when context restored after loss + SceneJS_events.addListener( + SceneJS_events.WEBGL_CONTEXT_RESTORED, + function () { + for (var nodeId in nodeCoreMap) { + if (nodeCoreMap.hasOwnProperty(nodeId)) { + nodeCoreMap[nodeId]._buildNodeCore(); + } + } + }); + + SceneJS.DepthTarget = SceneJS_NodeFactory.createNodeType("depthTarget"); + + SceneJS.DepthTarget.prototype._init = function (params) { + nodeCoreMap[this._core.coreId] = this; + this._core.bufType = "depth"; + this._core.renderBuf = new SceneJS._webgl.RenderBuffer({ canvas: this._engine.canvas }); }; - SceneJS.Framebuf.prototype._compile = function (ctx) { - this._engine.display.framebuf = coreStack[stackLen++] = this._core; + SceneJS.DepthTarget.prototype._compile = function (ctx) { + if (!this.__core) { + this.__core = this._engine._coreFactory.getCore("renderTarget"); + } + var parentCore = this._engine.display.renderTarget; + if (!this._core.empty) { + this.__core.targets = (parentCore && parentCore.targets) ? parentCore.targets.concat([this._core]) : [this._core]; + } + coreStack[stackLen++] = this.__core; + this._engine.display.renderTarget = this.__core; this._compileNodes(ctx); - this._engine.display.framebuf = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore; + this._engine.display.renderTarget = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore; }; - SceneJS.Framebuf.prototype._destroy = function () { + + SceneJS.DepthTarget.prototype._destroy = function () { if (this._core) { delete nodeCoreMap[this._core.coreId]; } @@ -8283,10 +8429,12 @@ new (function () { autoNormals: params.normals == "auto" }); - SceneJS.Geometry._buildNodeCore(this._engine.canvas.gl, this._core); + this._buildNodeCore(this._engine.canvas.gl, this._core); + + var self = this; this._core.webglRestored = function () { - SceneJS.Geometry._buildNodeCore(self._engine.canvas.gl, self._core); + self._buildNodeCore(self._engine.canvas.gl, self._core); }; } @@ -8454,20 +8602,20 @@ new (function () { * In addition to initially allocating those, this is called to reallocate them after * WebGL context is regained after being lost. */ - SceneJS.Geometry._buildNodeCore = function (gl, core) { + SceneJS.Geometry.prototype._buildNodeCore = function (gl, core) { var usage = gl.STATIC_DRAW; //var usage = (!arrays.fixed) ? gl.STREAM_DRAW : gl.STATIC_DRAW; try { // TODO: Modify usage flags in accordance with how often geometry is evicted var arrays = core.arrays; - var canInterleave = true; + var canInterleave = (SceneJS.getConfigs("enableInterleaving") !== false); var dataLength = 0; var interleavedValues = 0; var interleavedArrays = []; var interleavedArrayStrides = []; - var prepareInterleaveBuffer = function (array, strideInElements) { + var prepareInterleaveBuffer = function(array, strideInElements) { if (dataLength == 0) { dataLength = array.length / strideInElements; } else if (array.length / strideInElements != dataLength) { @@ -8480,27 +8628,37 @@ new (function () { }; if (arrays.positions) { - core.interleavedPositionOffset = prepareInterleaveBuffer(arrays.positions, 3); + if (canInterleave) { + core.interleavedPositionOffset = prepareInterleaveBuffer(arrays.positions, 3); + } core.vertexBuf = new SceneJS._webgl.ArrayBuffer(gl, gl.ARRAY_BUFFER, arrays.positions, arrays.positions.length, 3, usage); } if (arrays.normals) { - core.interleavedNormalOffset = prepareInterleaveBuffer(arrays.normals, 3); + if (canInterleave) { + core.interleavedNormalOffset = prepareInterleaveBuffer(arrays.normals, 3); + } core.normalBuf = new SceneJS._webgl.ArrayBuffer(gl, gl.ARRAY_BUFFER, arrays.normals, arrays.normals.length, 3, usage); } if (arrays.uv) { - core.interleavedUVOffset = prepareInterleaveBuffer(arrays.uv, 2); + if (canInterleave) { + core.interleavedUVOffset = prepareInterleaveBuffer(arrays.uv, 2); + } core.uvBuf = new SceneJS._webgl.ArrayBuffer(gl, gl.ARRAY_BUFFER, arrays.uv, arrays.uv.length, 2, usage); } if (arrays.uv2) { - core.interleavedUV2Offset = prepareInterleaveBuffer(arrays.uv2, 2); + if (canInterleave) { + core.interleavedUV2Offset = prepareInterleaveBuffer(arrays.uv2, 2); + } core.uvBuf2 = new SceneJS._webgl.ArrayBuffer(gl, gl.ARRAY_BUFFER, arrays.uv2, arrays.uv2.length, 2, usage); } if (arrays.colors) { - core.interleavedColorOffset = prepareInterleaveBuffer(arrays.colors, 4); + if (canInterleave) { + core.interleavedColorOffset = prepareInterleaveBuffer(arrays.colors, 4); + } core.colorBuf = new SceneJS._webgl.ArrayBuffer(gl, gl.ARRAY_BUFFER, arrays.colors, arrays.colors.length, 4, usage); } @@ -8713,6 +8871,10 @@ new (function () { return this.primitive; }; + /** Returns the Model-space boundary of this geometry + * + * @returns {*} + */ SceneJS.Geometry.prototype.getBoundary = function () { if (this._boundary) { return this._boundary; @@ -8886,17 +9048,17 @@ new (function () { } }; -}) - (); +})(); (function() { /** - * The default state core singleton for {@link SceneJS.Layer} nodes + * The default state core singleton for {@link SceneJS.Stage} nodes */ var defaultCore = { - type: "layer", + type: "stage", stateId: SceneJS._baseStateId++, priority: 0, + pickable: true, enabled: true }; @@ -8906,24 +9068,96 @@ new (function () { SceneJS_events.addListener( SceneJS_events.SCENE_COMPILING, function(params) { - params.engine.display.layer = defaultCore; + params.engine.display.stage = defaultCore; stackLen = 0; }); + /** + * @class Scene graph node which assigns the {@link SceneJS.Geometry}s within its subgraph to a prioritised render bin + * @extends SceneJS.Node + */ + SceneJS.Stage = SceneJS_NodeFactory.createNodeType("stage"); + + SceneJS.Stage.prototype._init = function(params) { + if (this._core.useCount == 1) { // This node defines the resource + this._core.priority = params.priority || 0; + this._core.enabled = params.enabled !== false; + this._core.pickable = !!params.pickable; + } + }; + + SceneJS.Stage.prototype.setPriority = function(priority) { + priority = priority || 0; + if (this._core.priority != priority) { + this._core.priority = priority; + this._engine.display.stateOrderDirty = true; + } + }; + + SceneJS.Stage.prototype.getPriority = function() { + return this._core.priority; + }; + + SceneJS.Stage.prototype.setEnabled = function(enabled) { + enabled = !!enabled; + if (this._core.enabled != enabled) { + this._core.enabled = enabled; + this._engine.display.drawListDirty = true; + } + }; + + SceneJS.Stage.prototype.getEnabled = function() { + return this._core.enabled; + }; + + SceneJS.Stage.prototype.getEnabled = function() { + return this._core.enabled; + }; + + SceneJS.Stage.prototype._compile = function(ctx) { + this._engine.display.stage = coreStack[stackLen++] = this._core; + this._compileNodes(ctx); + this._engine.display.stage = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore; + }; + +})(); + +(function () { + + /** + * The default state core singleton for {@link SceneJS.Layer} nodes + */ + var defaultCore = { + type: "layer", + stateId: SceneJS._baseStateId++, + priority: 0, + enabled: true + }; + + var coreStack = []; + var stackLen = 0; + + SceneJS_events.addListener( + SceneJS_events.SCENE_COMPILING, + function (params) { + params.engine.display.layer = defaultCore; + stackLen = 0; + }); + /** * @class Scene graph node which assigns the {@link SceneJS.Geometry}s within its subgraph to a prioritised render bin * @extends SceneJS.Node */ SceneJS.Layer = SceneJS_NodeFactory.createNodeType("layer"); - SceneJS.Layer.prototype._init = function(params) { + SceneJS.Layer.prototype._init = function (params) { if (this._core.useCount == 1) { // This node defines the resource this._core.priority = params.priority || 0; this._core.enabled = params.enabled !== false; } }; - SceneJS.Layer.prototype.setPriority = function(priority) { + SceneJS.Layer.prototype.setPriority = function (priority) { priority = priority || 0; if (this._core.priority != priority) { this._core.priority = priority; @@ -8931,11 +9165,11 @@ new (function () { } }; - SceneJS.Layer.prototype.getPriority = function() { + SceneJS.Layer.prototype.getPriority = function () { return this._core.priority; }; - SceneJS.Layer.prototype.setEnabled = function(enabled) { + SceneJS.Layer.prototype.setEnabled = function (enabled) { enabled = !!enabled; if (this._core.enabled != enabled) { this._core.enabled = enabled; @@ -8943,15 +9177,15 @@ new (function () { } }; - SceneJS.Layer.prototype.getEnabled = function() { + SceneJS.Layer.prototype.getEnabled = function () { return this._core.enabled; }; - SceneJS.Layer.prototype.getEnabled = function() { + SceneJS.Layer.prototype.getEnabled = function () { return this._core.enabled; }; - SceneJS.Layer.prototype.setClearDepth = function(clearDepth) { + SceneJS.Layer.prototype.setClearDepth = function (clearDepth) { clearDepth = clearDepth || 0; if (this._core.clearDepth != clearDepth) { this._core.clearDepth = clearDepth; @@ -8959,7 +9193,7 @@ new (function () { } }; - SceneJS.Layer.prototype.getClearDepth = function() { + SceneJS.Layer.prototype.getClearDepth = function () { return this._core.clearDepth; }; @@ -10230,7 +10464,7 @@ new (function () { SceneJS.Name.prototype.setName = function (name) { this._core.name = name || "unnamed"; - this._engine.display.imageDirty = true; + this._engine.branchDirty(this); // Need to recompile name path }; SceneJS.Name.prototype.getName = function () { @@ -10255,7 +10489,7 @@ new (function () { this._compileNodes(ctx); this._engine.display.name = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore; }; -})();new (function() { +})();new (function () { /** * The default state core singleton for {@link SceneJS.Renderer} nodes @@ -10271,10 +10505,10 @@ new (function () { var stackLen = 0; SceneJS_events.addListener( - SceneJS_events.SCENE_COMPILING, - function(params) { + SceneJS_events.SCENE_COMPILING, + function (params) { - canvas = params.engine.canvas; + canvas = params.engine.canvas; // // TODO: Below is a HACK // @@ -10309,10 +10543,10 @@ new (function () { // } // }); - stackLen = 0; + stackLen = 0; - params.engine.display.renderer = coreStack[stackLen++] = defaultCore; - }); + params.engine.display.renderer = coreStack[stackLen++] = defaultCore; + }); function createProps(props) { @@ -10334,11 +10568,11 @@ new (function () { props: props, - setProps: function(gl) { + setProps: function (gl) { setProperties(gl, props); }, - restoreProps : function(gl) { + restoreProps: function (gl) { if (restore) { restoreProperties(gl, restore); } @@ -10346,14 +10580,16 @@ new (function () { }; } - var getSuperProperty = function(name) { + var getSuperProperty = function (name) { var props; var prop; for (var i = stackLen - 1; i >= 0; i--) { props = coreStack[i].props; - prop = props[name]; - if (prop != undefined && prop != null) { - return props[name]; + if (props) { + prop = props[name]; + if (prop != undefined && prop != null) { + return props[name]; + } } } return null; // Cause default to be set @@ -10375,7 +10611,7 @@ new (function () { } } - var setProperties = function(gl, props) { + var setProperties = function (gl, props) { for (var key in props) { // Set order-insensitive properties (modes) if (props.hasOwnProperty(key)) { @@ -10403,7 +10639,7 @@ new (function () { * Restores previous renderer properties, except for clear - that's the reason we * have a seperate set and restore semantic - we don't want to keep clearing the buffer. */ - var restoreProperties = function(gl, props) { + var restoreProperties = function (gl, props) { var value; @@ -10433,23 +10669,23 @@ new (function () { * Maps renderer node properties to WebGL gl enums * @private */ - var glEnum = function(gl, name) { + var glEnum = function (gl, name) { if (!name) { throw SceneJS_error.fatalError( - SceneJS.errors.ILLEGAL_NODE_CONFIG, - "Null SceneJS.State node config: \"" + name + "\""); + SceneJS.errors.ILLEGAL_NODE_CONFIG, + "Null SceneJS.State node config: \"" + name + "\""); } var result = SceneJS._webgl.enumMap[name]; if (!result) { throw SceneJS_error.fatalError( - SceneJS.errors.ILLEGAL_NODE_CONFIG, - "Unrecognised SceneJS.State node config value: \"" + name + "\""); + SceneJS.errors.ILLEGAL_NODE_CONFIG, + "Unrecognised SceneJS.State node config value: \"" + name + "\""); } var value = gl[result]; if (!value) { throw SceneJS_error.fatalError( - SceneJS.errors.ILLEGAL_NODE_CONFIG, - "This browser's WebGL does not support renderer node config value: \"" + name + "\""); + SceneJS.errors.ILLEGAL_NODE_CONFIG, + "This browser's WebGL does not support renderer node config value: \"" + name + "\""); } return value; }; @@ -10474,7 +10710,7 @@ new (function () { */ var glModeSetters = { - enableBlend: function(gl, flag) { + enableBlend: function (gl, flag) { if (!gl) { if (flag == null || flag == undefined) { flag = false; @@ -10488,7 +10724,7 @@ new (function () { } }, - blendColor: function(gl, color) { + blendColor: function (gl, color) { if (!gl) { color = color || {}; return { @@ -10501,7 +10737,7 @@ new (function () { gl.blendColor(color.r, color.g, color.b, color.a); }, - blendEquation: function(gl, eqn) { + blendEquation: function (gl, eqn) { if (!gl) { return eqn || "funcAdd"; } @@ -10510,87 +10746,87 @@ new (function () { /** Sets the RGB blend equation and the alpha blend equation separately */ - blendEquationSeparate: function(gl, eqn) { + blendEquationSeparate: function (gl, eqn) { if (!gl) { eqn = eqn || {}; return { - rgb : eqn.rgb || "funcAdd", - alpha : eqn.alpha || "funcAdd" + rgb: eqn.rgb || "funcAdd", + alpha: eqn.alpha || "funcAdd" }; } gl.blendEquation(glEnum(gl, eqn.rgb), glEnum(gl, eqn.alpha)); }, - blendFunc: function(gl, funcs) { + blendFunc: function (gl, funcs) { if (!gl) { funcs = funcs || {}; return { - sfactor : funcs.sfactor || "srcAlpha", - dfactor : funcs.dfactor || "oneMinusSrcAlpha" + sfactor: funcs.sfactor || "srcAlpha", + dfactor: funcs.dfactor || "oneMinusSrcAlpha" }; } gl.blendFunc(glEnum(gl, funcs.sfactor || "srcAlpha"), glEnum(gl, funcs.dfactor || "oneMinusSrcAlpha")); }, - blendFuncSeparate: function(gl, func) { + blendFuncSeparate: function (gl, func) { if (!gl) { func = func || {}; return { - srcRGB : func.srcRGB || "zero", - dstRGB : func.dstRGB || "zero", - srcAlpha : func.srcAlpha || "zero", - dstAlpha : func.dstAlpha || "zero" + srcRGB: func.srcRGB || "zero", + dstRGB: func.dstRGB || "zero", + srcAlpha: func.srcAlpha || "zero", + dstAlpha: func.dstAlpha || "zero" }; } gl.blendFuncSeparate( - glEnum(gl, func.srcRGB || "zero"), - glEnum(gl, func.dstRGB || "zero"), - glEnum(gl, func.srcAlpha || "zero"), - glEnum(gl, func.dstAlpha || "zero")); + glEnum(gl, func.srcRGB || "zero"), + glEnum(gl, func.dstRGB || "zero"), + glEnum(gl, func.srcAlpha || "zero"), + glEnum(gl, func.dstAlpha || "zero")); }, - clearColor: function(gl, color) { + clearColor: function (gl, color) { if (!gl) { color = color || {}; return { - r : color.r || 0, - g : color.g || 0, - b : color.b || 0, - a : (color.a == undefined || color.a == null) ? 1 : color.a + r: color.r || 0, + g: color.g || 0, + b: color.b || 0, + a: (color.a == undefined || color.a == null) ? 1 : color.a }; } gl.clearColor(color.r, color.g, color.b, color.a); }, - clearDepth: function(gl, depth) { + clearDepth: function (gl, depth) { if (!gl) { return (depth == null || depth == undefined) ? 1 : depth; } gl.clearDepth(depth); }, - clearStencil: function(gl, clearValue) { + clearStencil: function (gl, clearValue) { if (!gl) { return clearValue || 0; } gl.clearStencil(clearValue); }, - colorMask: function(gl, color) { + colorMask: function (gl, color) { if (!gl) { color = color || {}; return { - r : color.r || 0, - g : color.g || 0, - b : color.b || 0, - a : (color.a == undefined || color.a == null) ? 1 : color.a + r: color.r || 0, + g: color.g || 0, + b: color.b || 0, + a: (color.a == undefined || color.a == null) ? 1 : color.a }; } gl.colorMask(color.r, color.g, color.b, color.a); }, - enableCullFace: function(gl, flag) { + enableCullFace: function (gl, flag) { if (!gl) { return flag; } @@ -10601,14 +10837,14 @@ new (function () { } }, - cullFace: function(gl, mode) { + cullFace: function (gl, mode) { if (!gl) { return mode || "back"; } gl.cullFace(glEnum(gl, mode)); }, - enableDepthTest: function(gl, flag) { + enableDepthTest: function (gl, flag) { if (!gl) { if (flag == null || flag == undefined) { flag = true; @@ -10622,14 +10858,14 @@ new (function () { } }, - depthFunc: function(gl, func) { + depthFunc: function (gl, func) { if (!gl) { return func || "less"; } gl.depthFunc(glEnum(gl, func)); }, - enableDepthMask: function(gl, flag) { + enableDepthMask: function (gl, flag) { if (!gl) { if (flag == null || flag == undefined) { flag = true; @@ -10639,32 +10875,32 @@ new (function () { gl.depthMask(flag); }, - depthRange: function(gl, range) { + depthRange: function (gl, range) { if (!gl) { range = range || {}; return { - zNear : (range.zNear == undefined || range.zNear == null) ? 0 : range.zNear, - zFar : (range.zFar == undefined || range.zFar == null) ? 1 : range.zFar + zNear: (range.zNear == undefined || range.zNear == null) ? 0 : range.zNear, + zFar: (range.zFar == undefined || range.zFar == null) ? 1 : range.zFar }; } gl.depthRange(range.zNear, range.zFar); - } , + }, - frontFace: function(gl, mode) { + frontFace: function (gl, mode) { if (!gl) { return mode || "ccw"; } gl.frontFace(glEnum(gl, mode)); }, - lineWidth: function(gl, width) { + lineWidth: function (gl, width) { if (!gl) { return width || 1; } gl.lineWidth(width); }, - enableScissorTest: function(gl, flag) { + enableScissorTest: function (gl, flag) { if (!gl) { return flag; } @@ -10693,12 +10929,12 @@ new (function () { /** Set viewport on the given gl */ - viewport: function(gl, v) { + viewport: function (gl, v) { if (!gl) { v = v || {}; return { - x : v.x || 1, - y : v.y || 1, + x: v.x || 1, + y: v.y || 1, width: v.width || canvas.canvas.width, height: v.height || canvas.canvas.height }; @@ -10708,12 +10944,12 @@ new (function () { /** Sets scissor region on the given gl */ - scissor: function(gl, s) { + scissor: function (gl, s) { if (!gl) { s = s || {}; return { - x : s.x || 0, - y : s.y || 0, + x: s.x || 0, + y: s.y || 0, width: s.width || 1.0, height: s.height || 1.0 }; @@ -10723,7 +10959,7 @@ new (function () { /** Clears buffers on the given gl as specified in mask */ - clear:function(gl, mask) { + clear: function (gl, mask) { if (!gl) { mask = mask || {}; return mask; @@ -10739,14 +10975,14 @@ new (function () { m = m | gl.STENCIL_BUFFER_BIT; } if (m) { - // gl.clear(m); + // gl.clear(m); } } }; SceneJS.Renderer = SceneJS_NodeFactory.createNodeType("renderer"); - SceneJS.Renderer.prototype._init = function(params) { + SceneJS.Renderer.prototype._init = function (params) { if (this._core.useCount == 1) { // This node defines the resource for (var key in params) { if (params.hasOwnProperty(key)) { @@ -10757,282 +10993,289 @@ new (function () { } }; - SceneJS.Renderer.prototype.setViewport = function(viewport) { + SceneJS.Renderer.prototype.setViewport = function (viewport) { this._core.viewport = viewport ? { - x : viewport.x || 1, - y : viewport.y || 1, + x: viewport.x || 1, + y: viewport.y || 1, width: viewport.width || 1000, height: viewport.height || 1000 } : undefined; this._core.dirty = true; + this._engine.display.imageDirty = true; }; - SceneJS.Renderer.prototype.getViewport = function() { + SceneJS.Renderer.prototype.getViewport = function () { return this._core.viewport ? { - x : this._core.viewport.x, - y : this._core.viewport.y, + x: this._core.viewport.x, + y: this._core.viewport.y, width: this._core.viewport.width, height: this._core.viewport.height } : undefined; }; - SceneJS.Renderer.prototype.setScissor = function(scissor) { + SceneJS.Renderer.prototype.setScissor = function (scissor) { this._core.scissor = scissor ? { - x : scissor.x || 1, - y : scissor.y || 1, + x: scissor.x || 1, + y: scissor.y || 1, width: scissor.width || 1000, height: scissor.height || 1000 } : undefined; this._core.dirty = true; + this._engine.display.imageDirty = true; }; - SceneJS.Renderer.prototype.getScissor = function() { + SceneJS.Renderer.prototype.getScissor = function () { return this._core.scissor ? { - x : this._core.scissor.x, - y : this._core.scissor.y, + x: this._core.scissor.x, + y: this._core.scissor.y, width: this._core.scissor.width, height: this._core.scissor.height } : undefined; }; - SceneJS.Renderer.prototype.setClear = function(clear) { + SceneJS.Renderer.prototype.setClear = function (clear) { this._core.clear = clear ? { - r : clear.r || 0, - g : clear.g || 0, - b : clear.b || 0 + r: clear.r || 0, + g: clear.g || 0, + b: clear.b || 0 } : undefined; this._core.dirty = true; + this._engine.display.imageDirty = true; }; - SceneJS.Renderer.prototype.getClear = function() { + SceneJS.Renderer.prototype.getClear = function () { return this._core.clear ? { - r : this._core.clear.r, - g : this._core.clear.g, - b : this._core.clear.b + r: this._core.clear.r, + g: this._core.clear.g, + b: this._core.clear.b } : null; }; - SceneJS.Renderer.prototype.setEnableBlend = function(enableBlend) { + SceneJS.Renderer.prototype.setEnableBlend = function (enableBlend) { this._core.enableBlend = enableBlend; this._core.dirty = true; + this._engine.display.imageDirty = true; }; - SceneJS.Renderer.prototype.getEnableBlend = function() { + SceneJS.Renderer.prototype.getEnableBlend = function () { return this._core.enableBlend; }; - SceneJS.Renderer.prototype.setBlendColor = function(color) { + SceneJS.Renderer.prototype.setBlendColor = function (color) { this._core.blendColor = color ? { - r : color.r || 0, - g : color.g || 0, - b : color.b || 0, - a : (color.a == undefined || color.a == null) ? 1 : color.a + r: color.r || 0, + g: color.g || 0, + b: color.b || 0, + a: (color.a == undefined || color.a == null) ? 1 : color.a } : undefined; this._core.dirty = true; + this._engine.display.imageDirty = true; }; - SceneJS.Renderer.prototype.getBlendColor = function() { + SceneJS.Renderer.prototype.getBlendColor = function () { return this._core.blendColor ? { - r : this._core.blendColor.r, - g : this._core.blendColor.g, - b : this._core.blendColor.b, - a : this._core.blendColor.a + r: this._core.blendColor.r, + g: this._core.blendColor.g, + b: this._core.blendColor.b, + a: this._core.blendColor.a } : undefined; }; - SceneJS.Renderer.prototype.setBlendEquation = function(eqn) { + SceneJS.Renderer.prototype.setBlendEquation = function (eqn) { this._core.blendEquation = eqn; this._core.dirty = true; + this._engine.display.imageDirty = true; }; - SceneJS.Renderer.prototype.getBlendEquation = function() { + SceneJS.Renderer.prototype.getBlendEquation = function () { return this._core.blendEquation; }; - SceneJS.Renderer.prototype.setBlendEquationSeparate = function(eqn) { + SceneJS.Renderer.prototype.setBlendEquationSeparate = function (eqn) { this._core.blendEquationSeparate = eqn ? { - rgb : eqn.rgb || "funcAdd", - alpha : eqn.alpha || "funcAdd" + rgb: eqn.rgb || "funcAdd", + alpha: eqn.alpha || "funcAdd" } : undefined; this._core.dirty = true; + this._engine.display.imageDirty = true; }; - SceneJS.Renderer.prototype.getBlendEquationSeparate = function() { + SceneJS.Renderer.prototype.getBlendEquationSeparate = function () { return this._core.blendEquationSeparate ? { - rgb : this._core.rgb, - alpha : this._core.alpha + rgb: this._core.rgb, + alpha: this._core.alpha } : undefined; + this._engine.display.imageDirty = true; }; - SceneJS.Renderer.prototype.setBlendFunc = function(funcs) { + SceneJS.Renderer.prototype.setBlendFunc = function (funcs) { this._core.blendFunc = funcs ? { - sfactor : funcs.sfactor || "srcAlpha", - dfactor : funcs.dfactor || "one" + sfactor: funcs.sfactor || "srcAlpha", + dfactor: funcs.dfactor || "one" } : undefined; this._core.dirty = true; + this._engine.display.imageDirty = true; }; - SceneJS.Renderer.prototype.getBlendFunc = function() { + SceneJS.Renderer.prototype.getBlendFunc = function () { return this._core.blendFunc ? { - sfactor : this._core.sfactor, - dfactor : this._core.dfactor + sfactor: this._core.sfactor, + dfactor: this._core.dfactor } : undefined; }; - SceneJS.Renderer.prototype.setBlendFuncSeparate = function(eqn) { + SceneJS.Renderer.prototype.setBlendFuncSeparate = function (eqn) { this._core.blendFuncSeparate = eqn ? { - srcRGB : eqn.srcRGB || "zero", - dstRGB : eqn.dstRGB || "zero", - srcAlpha : eqn.srcAlpha || "zero", - dstAlpha : eqn.dstAlpha || "zero" + srcRGB: eqn.srcRGB || "zero", + dstRGB: eqn.dstRGB || "zero", + srcAlpha: eqn.srcAlpha || "zero", + dstAlpha: eqn.dstAlpha || "zero" } : undefined; this._core.dirty = true; }; - SceneJS.Renderer.prototype.getBlendFuncSeparate = function() { + SceneJS.Renderer.prototype.getBlendFuncSeparate = function () { return this._core.blendFuncSeparate ? { - srcRGB : this._core.blendFuncSeparate.srcRGB, - dstRGB : this._core.blendFuncSeparate.dstRGB, - srcAlpha : this._core.blendFuncSeparate.srcAlpha, - dstAlpha : this._core.blendFuncSeparate.dstAlpha + srcRGB: this._core.blendFuncSeparate.srcRGB, + dstRGB: this._core.blendFuncSeparate.dstRGB, + srcAlpha: this._core.blendFuncSeparate.srcAlpha, + dstAlpha: this._core.blendFuncSeparate.dstAlpha } : undefined; }; - SceneJS.Renderer.prototype.setEnableCullFace = function(enableCullFace) { + SceneJS.Renderer.prototype.setEnableCullFace = function (enableCullFace) { this._core.enableCullFace = enableCullFace; this._core.dirty = true; }; - SceneJS.Renderer.prototype.getEnableCullFace = function() { + SceneJS.Renderer.prototype.getEnableCullFace = function () { return this._core.enableCullFace; }; - SceneJS.Renderer.prototype.setCullFace = function(cullFace) { + SceneJS.Renderer.prototype.setCullFace = function (cullFace) { this._core.cullFace = cullFace; this._core.dirty = true; }; - SceneJS.Renderer.prototype.getCullFace = function() { + SceneJS.Renderer.prototype.getCullFace = function () { return this._core.cullFace; }; - SceneJS.Renderer.prototype.setEnableDepthTest = function(enableDepthTest) { + SceneJS.Renderer.prototype.setEnableDepthTest = function (enableDepthTest) { this._core.enableDepthTest = enableDepthTest; this._core.dirty = true; }; - SceneJS.Renderer.prototype.getEnableDepthTest = function() { + SceneJS.Renderer.prototype.getEnableDepthTest = function () { return this._core.enableDepthTest; }; - SceneJS.Renderer.prototype.setDepthFunc = function(depthFunc) { + SceneJS.Renderer.prototype.setDepthFunc = function (depthFunc) { this._core.depthFunc = depthFunc; this._core.dirty = true; }; - SceneJS.Renderer.prototype.getDepthFunc = function() { + SceneJS.Renderer.prototype.getDepthFunc = function () { return this._core.depthFunc; }; - SceneJS.Renderer.prototype.setEnableDepthMask = function(enableDepthMask) { + SceneJS.Renderer.prototype.setEnableDepthMask = function (enableDepthMask) { this._core.enableDepthMask = enableDepthMask; this._core.dirty = true; }; - SceneJS.Renderer.prototype.getEnableDepthMask = function() { + SceneJS.Renderer.prototype.getEnableDepthMask = function () { return this._core.enableDepthMask; }; - SceneJS.Renderer.prototype.setClearDepth = function(clearDepth) { + SceneJS.Renderer.prototype.setClearDepth = function (clearDepth) { this._core.clearDepth = clearDepth; this._core.dirty = true; }; - SceneJS.Renderer.prototype.getClearDepth = function() { + SceneJS.Renderer.prototype.getClearDepth = function () { return this._core.clearDepth; }; - SceneJS.Renderer.prototype.setDepthRange = function(range) { + SceneJS.Renderer.prototype.setDepthRange = function (range) { this._core.depthRange = range ? { - zNear : (range.zNear == undefined || range.zNear == null) ? 0 : range.zNear, - zFar : (range.zFar == undefined || range.zFar == null) ? 1 : range.zFar + zNear: (range.zNear == undefined || range.zNear == null) ? 0 : range.zNear, + zFar: (range.zFar == undefined || range.zFar == null) ? 1 : range.zFar } : undefined; this._core.dirty = true; }; - SceneJS.Renderer.prototype.getDepthRange = function() { + SceneJS.Renderer.prototype.getDepthRange = function () { return this._core.depthRange ? { - zNear : this._core.depthRange.zNear, - zFar : this._core.depthRange.zFar + zNear: this._core.depthRange.zNear, + zFar: this._core.depthRange.zFar } : undefined; }; - SceneJS.Renderer.prototype.setFrontFace = function(frontFace) { + SceneJS.Renderer.prototype.setFrontFace = function (frontFace) { this._core.frontFace = frontFace; this._core.dirty = true; }; - SceneJS.Renderer.prototype.getFrontFace = function() { + SceneJS.Renderer.prototype.getFrontFace = function () { return this._core.frontFace; }; - SceneJS.Renderer.prototype.setLineWidth = function(lineWidth) { + SceneJS.Renderer.prototype.setLineWidth = function (lineWidth) { this._core.lineWidth = lineWidth; this._core.dirty = true; }; - SceneJS.Renderer.prototype.getLineWidth = function() { + SceneJS.Renderer.prototype.getLineWidth = function () { return this._core.lineWidth; }; - SceneJS.Renderer.prototype.setEnableScissorTest = function(enableScissorTest) { + SceneJS.Renderer.prototype.setEnableScissorTest = function (enableScissorTest) { this._core.enableScissorTest = enableScissorTest; this._core.dirty = true; }; - SceneJS.Renderer.prototype.getEnableScissorTest = function() { + SceneJS.Renderer.prototype.getEnableScissorTest = function () { return this._core.enableScissorTest; }; - SceneJS.Renderer.prototype.setClearStencil = function(clearStencil) { + SceneJS.Renderer.prototype.setClearStencil = function (clearStencil) { this._core.clearStencil = clearStencil; this._core.dirty = true; }; - SceneJS.Renderer.prototype.getClearStencil = function() { + SceneJS.Renderer.prototype.getClearStencil = function () { return this._core.clearStencil; }; - SceneJS.Renderer.prototype.setColorMask = function(color) { + SceneJS.Renderer.prototype.setColorMask = function (color) { this._core.colorMask = color ? { - r : color.r || 0, - g : color.g || 0, - b : color.b || 0, - a : (color.a == undefined || color.a == null) ? 1 : color.a + r: color.r || 0, + g: color.g || 0, + b: color.b || 0, + a: (color.a == undefined || color.a == null) ? 1 : color.a } : undefined; this._core.dirty = true; }; - SceneJS.Renderer.prototype.getColorMask = function() { + SceneJS.Renderer.prototype.getColorMask = function () { return this._core.colorMask ? { - r : this._core.colorMask.r, - g : this._core.colorMask.g, - b : this._core.colorMask.b, - a : this._core.colorMask.a + r: this._core.colorMask.r, + g: this._core.colorMask.g, + b: this._core.colorMask.b, + a: this._core.colorMask.a } : undefined; }; - SceneJS.Renderer.prototype._compile = function(ctx) { - -// if (this._core.dirty) { -// this._core.props = createProps(this._core); -// this._core.dirty = false; -// } -// -// this._engine.display.renderer = coreStack[stackLen++] = this._core; + SceneJS.Renderer.prototype._compile = function (ctx) { + if (this._core.dirty) { + this._core.props = createProps(this._core); + this._core.dirty = false; + } + this._engine.display.renderer = coreStack[stackLen++] = this._core; this._compileNodes(ctx); - //this._engine.display.renderer = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore; + this._engine.display.renderer = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore; }; })();(function () { @@ -11047,7 +11290,7 @@ new (function () { // The default state core singleton for {@link SceneJS.DepthBuf} nodes var defaultCore = { - type:"depthbuf", + type:"depthBuffer", stateId:SceneJS._baseStateId++, enabled:true, clearDepth:1, @@ -11064,7 +11307,7 @@ new (function () { if (defaultCore.depthFunc === null) { // Lazy-init depthFunc now we can get a context defaultCore.depthFunc = params.engine.canvas.gl.LESS; } - params.engine.display.depthbuf = defaultCore; + params.engine.display.depthBuffer = defaultCore; stackLen = 0; }); @@ -11072,7 +11315,7 @@ new (function () { * @class Scene graph node which configures the depth buffer for its subgraph * @extends SceneJS.Node */ - SceneJS.DepthBuf = SceneJS_NodeFactory.createNodeType("depthbuf"); + SceneJS.DepthBuf = SceneJS_NodeFactory.createNodeType("depthBuffer"); SceneJS.DepthBuf.prototype._init = function (params) { @@ -11093,6 +11336,12 @@ new (function () { } else if (this._core.useCount == 1) { this.setDepthFunc("less"); } + + if (params.clear != undefined) { + this.setClear(params.clear); + } else if (this._core.useCount == 1) { + this.setClear(true); + } }; /** @@ -11118,6 +11367,29 @@ new (function () { return this._core.enabled; }; + /** + * Sets whether or not to clear the depth buffer before each render + * + * @param clear + * @return {*} + */ + SceneJS.DepthBuf.prototype.setClear = function (clear) { + if (this._core.clear != clear) { + this._core.clear = clear; + this._engine.display.imageDirty = true; + } + return this; + }; + + /** + * Get whether or not the depth buffer is cleared before each render + * + * @return Boolean + */ + SceneJS.DepthBuf.prototype.getClear = function () { + return this._core.clear; + }; + /** * Specify the clear value for the depth buffer. * Initial value is 1, and the given value will be clamped to [0..1]. @@ -11151,7 +11423,7 @@ new (function () { if (this._core._depthFuncName != depthFunc) { var enumName = lookup[depthFunc]; if (enumName == undefined) { - throw "unsupported value for 'clearFunc' attribute on depthbuf node: '" + depthFunc + throw "unsupported value for 'clearFunc' attribute on depthBuffer node: '" + depthFunc + "' - supported values are 'less', 'equal', 'lequal', 'greater', 'notequal' and 'gequal'"; } this._core.depthFunc = this._engine.canvas.gl[enumName]; @@ -11170,18 +11442,19 @@ new (function () { }; SceneJS.DepthBuf.prototype._compile = function (ctx) { - this._engine.display.depthbuf = coreStack[stackLen++] = this._core; + this._engine.display.depthBuffer = coreStack[stackLen++] = this._core; this._compileNodes(ctx); - this._engine.display.depthbuf = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore; + this._engine.display.depthBuffer = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore; }; })();(function () { - // The default state core singleton for {@link SceneJS.ColorBuf} nodes + // The default state core singleton for {@link SceneJS.ColorBuffer} nodes var defaultCore = { - type:"colorbuf", - stateId:SceneJS._baseStateId++, - blendEnabled:false + type: "colorBuffer", + stateId: SceneJS._baseStateId++, + blendEnabled: false, + colorMask: { r: true, g: true, b: true, a: true } }; var coreStack = []; @@ -11190,7 +11463,7 @@ new (function () { SceneJS_events.addListener( SceneJS_events.SCENE_COMPILING, function (params) { - params.engine.display.colorbuf = defaultCore; + params.engine.display.colorBuffer = defaultCore; stackLen = 0; }); @@ -11198,44 +11471,66 @@ new (function () { * @class Scene graph node which configures the color buffer for its subgraph * @extends SceneJS.Node */ - SceneJS.ColorBuf = SceneJS_NodeFactory.createNodeType("colorbuf"); - - SceneJS.ColorBuf.prototype._init = function (params) { + SceneJS.ColorBuffer = SceneJS_NodeFactory.createNodeType("colorBuffer"); + SceneJS.ColorBuffer.prototype._init = function (params) { if (params.blendEnabled != undefined) { this.setBlendEnabled(params.blendEnabled); } else if (this._core.useCount == 1) { // This node defines the core this.setBlendEnabled(false); } + this.setColorMask(params); }; /** * Enable or disable blending * * @param blendEnabled Specifies whether depth buffer is blendEnabled or not - * @return {*} */ - SceneJS.ColorBuf.prototype.setBlendEnabled = function (blendEnabled) { + SceneJS.ColorBuffer.prototype.setBlendEnabled = function (blendEnabled) { if (this._core.blendEnabled != blendEnabled) { this._core.blendEnabled = blendEnabled; this._engine.display.imageDirty = true; } - return this; + this._engine.display.imageDirty = true; }; /** * Get whether or not blending is enabled - * * @return Boolean */ - SceneJS.ColorBuf.prototype.getBlendEnabled = function () { + SceneJS.ColorBuffer.prototype.getBlendEnabled = function () { return this._core.blendEnabled; }; - SceneJS.ColorBuf.prototype._compile = function (ctx) { - this._engine.display.colorbuf = coreStack[stackLen++] = this._core; + /** + * Enable and disable writing of buffer's color components. + * Components default to true where not given. + * @param mask The mask + */ + SceneJS.ColorBuffer.prototype.setColorMask = function (mask) { + this._core.colorMask = { + r: mask.r != undefined && mask.r != null ? mask.r : true, + g: mask.g != undefined && mask.g != null ? mask.g : true, + b: mask.b != undefined && mask.b != null ? mask.b : true, + a: mask.a != undefined && mask.a != null ? mask.a : true + }; + this._engine.display.imageDirty = true; + }; + + /** + * Gets the color mask + * @return {{}} + */ + SceneJS.ColorBuffer.prototype.getColorMask = function () { + return this._core.colorMask; + }; + + SceneJS.ColorBuffer.prototype._compile = function (ctx) { + this._engine.display.colorBuffer = coreStack[stackLen++] = this._core; this._compileNodes(ctx); - this._engine.display.colorbuf = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore; + this._engine.display.colorBuffer = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore; + this._engine.display.imageDirty = true; }; })();(function () { @@ -11362,9 +11657,7 @@ SceneJS.Scene.prototype.getGL = function () { /** Returns the Z-buffer depth in bits of the webgl context that this scene is to bound to. */ SceneJS.Scene.prototype.getZBufferDepth = function () { - var gl = this._engine.canvas.gl; - return gl.getParameter(gl.DEPTH_BITS); }; @@ -11375,16 +11668,12 @@ SceneJS.Scene.prototype.getZBufferDepth = function () { * @see SceneJS.Tag */ SceneJS.Scene.prototype.setTagMask = function (tagMask) { - tagMask = tagMask || "XXXXXXXXXXXXXXXXXXXXXXXXXX"; // HACK to select nothing by default - if (!this._tagSelector) { this._tagSelector = {}; } - this._tagSelector.mask = tagMask; this._tagSelector.regex = tagMask ? new RegExp(tagMask) : null; - this._engine.display.selectTags(this._tagSelector); }; @@ -11398,6 +11687,17 @@ SceneJS.Scene.prototype.getTagMask = function () { return this._tagSelector ? this._tagSelector.mask : null; }; +/** + * Sets the number of times this scene is drawn on each render. + *

This is useful for when we need to do things like render for left and right eyes. + * @param {Number} numPasses The number of times the scene is drawn on each frame. + * @see #getTagMask + * @see SceneJS.Tag + */ +SceneJS.Scene.prototype.setNumPasses = function (numPasses) { + this._engine.setNumPasses(numPasses); +}; + /** * Render a single frame if new frame pending, or force a new frame * Returns true if frame rendered @@ -11406,6 +11706,14 @@ SceneJS.Scene.prototype.renderFrame = function (params) { return this._engine.renderFrame(params); }; +/** + * Signals that a new frame will be needed + * @param params + */ +SceneJS.Scene.prototype.needFrame = function () { + this._engine.display.imageDirty = true; +}; + /** * Starts the render loop for this scene */ @@ -11434,7 +11742,7 @@ SceneJS.Scene.prototype.isRunning = function () { */ SceneJS.Scene.prototype.pick = function (canvasX, canvasY, options) { var result = this._engine.pick(canvasX, canvasY, options); - this.renderFrame({force:true }); // HACK: canvas blanks after picking + this.renderFrame({force: true }); // HACK: canvas blanks after picking if (result) { this.publish("pick", result); return result; @@ -11448,12 +11756,9 @@ SceneJS.Scene.prototype.pick = function (canvasX, canvasY, options) { * @private */ SceneJS.Scene.prototype._destroy = function () { - if (!this.destroyed) { - delete SceneJS._engines[this.id]; // HACK: circular dependency SceneJS._engineIds.removeItem(this.id); // HACK: circular dependency - this.destroyed = true; } }; @@ -11553,7 +11858,7 @@ SceneJS.Scene.prototype.getStatus = function () { var sceneStatus = SceneJS_sceneStatusModule.sceneStatus[this.id]; if (!sceneStatus) { return { - destroyed:true + destroyed: true }; } return SceneJS._shallowClone(sceneStatus); @@ -11607,11 +11912,11 @@ new (function() { shaders: { fragment: { - code: shaderFragmentCodeStack.slice(0, stackLen).join("\n"), + code: shaderFragmentCodeStack.slice(0, stackLen).join(""), hooks: combineMapStack(shaderFragmentHooksStack) }, vertex: { - code: shaderVertexCodeStack.slice(0, stackLen).join("\n"), + code: shaderVertexCodeStack.slice(0, stackLen).join(""), hooks: combineMapStack(shaderVertexHooksStack) } }, @@ -12028,11 +12333,11 @@ new (function () { layerParams = params.layers[i]; - if (!layerParams.source && !layerParams.uri && !layerParams.src && !layerParams.framebuf && !layerParams.video) { + if (!layerParams.source && !layerParams.uri && !layerParams.src && !layerParams.colorTarget && !layerParams.video) { throw SceneJS_error.fatalError( SceneJS.errors.NODE_CONFIG_EXPECTED, - "texture layer " + i + " has no uri, src, source, framebuf, video or canvasId specified"); + "texture layer " + i + " has no uri, src, source, colorTarget, video or canvasId specified"); } if (layerParams.applyFrom) { @@ -12063,11 +12368,11 @@ new (function () { } if (layerParams.blendMode) { - if (layerParams.blendMode != "add" && layerParams.blendMode != "multiply") { + if (layerParams.blendMode != "add" && layerParams.blendMode != "multiply" && layerParams.blendMode != "mix") { throw SceneJS_error.fatalError( SceneJS.errors.NODE_CONFIG_EXPECTED, "texture layer " + i + " blendMode value is unsupported - " + - "should be either 'add' or 'multiply'"); + "should be either 'add', 'multiply' or 'mix'"); } } @@ -12091,10 +12396,10 @@ new (function () { this._setLayerTransform(layerParams, layer); - if (layer.framebuf) { // Create from a framebuf node preceeding this texture in the scene graph - var targetNode = this._engine.findNode(layer.framebuf); - if (targetNode && targetNode.type == "framebuf") { - layer.texture = targetNode._core.framebuf.getTexture(); // TODO: what happens when the framebuf is destroyed? + if (layer.colorTarget) { // Create from a colorTarget node preceeding this texture in the scene graph + var targetNode = this._engine.findNode(layer.colorTarget); + if (targetNode && targetNode.type == "colorTarget") { + layer.texture = targetNode._core.colorTarget.getTexture(); // TODO: what happens when the colorTarget is destroyed? } } else { // Create from texture node's layer configs this._loadLayerTexture(gl, layer); @@ -12556,10 +12861,10 @@ new (function () { this._core.image = params.image; this._initTexture(params.image); - } else if (params.framebuf) { // Render to this texture - this.getScene().getNode(params.framebuf, - function (framebuf) { - self.setFramebuf(framebuf); + } else if (params.target) { // Render to this texture + this.getScene().getNode(params.target, + function (target) { + self.setTarget(target); }); } @@ -12570,12 +12875,11 @@ new (function () { } else if (self._core.image) { self._initTexture(self._core.image); - } else if (self._core.framebuf) { - self.getScene().getNode(params.framebuf, - function (framebuf) { - self.setFramebuf(framebuf); - }); - self.setFramebuf(self._core.framebuf); + } else if (self._core.target) { +// self.getScene().getNode(params.target, +// function (target) { +// self.setTarget(self._core.target); +// }); } }; } @@ -12707,27 +13011,28 @@ new (function () { SceneJS.TextureMap.prototype.setSrc = function (src) { this._core.image = null; this._core.src = src; - this._core.framebuf = null; + this._core.target = null; this._loadTexture(src); }; SceneJS.TextureMap.prototype.setImage = function (image) { this._core.image = image; this._core.src = null; - this._core.framebuf = null; + this._core.target = null; this._initTexture(image); }; - SceneJS.TextureMap.prototype.setFramebuf = function (framebuf) { - if (!framebuf.type == "framebuf") { - console.log("Not a 'framebuf' node - ignoring"); + SceneJS.TextureMap.prototype.setTarget = function (target) { + if (target.type != "colorTarget" && target.type != "depthTarget") { + console.log("Target node type not compatible: " + target.type); return; } delete this._core.src; - this._core.framebuf = framebuf; + this._core.target = target; this._core.src = null; this._core.image = null; - this._core.texture = framebuf._core.framebuf.getTexture(); // TODO: what happens when the framebuf is destroyed? + this._core.texture = target._core.renderBuf.getTexture(); // TODO: what happens when the target is destroyed? + this._core.texture.bufType = target._core.bufType; this._engine.display.imageDirty = true; }; @@ -12833,13 +13138,13 @@ new (function () { SceneJS.TextureMap.prototype._destroy = function () { if (this._core.useCount == 1) { // Last core user - if (this._core.texture && !this._core.framebuf) { // Don't wipe out framebuf texture + if (this._core.texture && !this._core.target) { // Don't wipe out target texture this._core.texture.destroy(); this._core.texture = null; } } if (this._core) { - this._coreFactory.putCore(this._core); + this._engine._coreFactory.putCore(this._core); } }; @@ -12910,8 +13215,6 @@ new (function () { gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture); gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); gl.texImage2D(face, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, ensureImageSizePowerOfTwo(image)); - //self._core.texture = texture; - //gl.texImage2D(face, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, ensureImageSizePowerOfTwo(image)); if (++numImagesLoaded == faces.length) { self._core.texture = new SceneJS._webgl.Texture2D(gl, { texture: texture, @@ -13900,11 +14203,11 @@ SceneJS.Types = new (function () { })(); /** - * @class Renders and picks a {@link SceneJS.Scene} + * @class Display compiled from a {@link SceneJS.Scene}, providing methods to render and pick. * @private * *

A Display is a container of {@link SceneJS_Object}s which are created (or updated) by a depth-first - * compilation traversal of the nodes within a {@link SceneJS.Scene}. + * compilation traversal of a {@link SceneJS.Scene}. * *

Rendering Pipeline

* @@ -13959,29 +14262,24 @@ SceneJS.Types = new (function () { * in the branch.

* *

Draw List

- *

The draw list is actually comprised of three lists of state chunks: a "pick" list to render a pick buffer - * for colour-indexed GPU picking, along with an "opaque" list and "transparent" list for normal image rendering. - * For normal rendering the opaque list is rendered, then blending is enabled and the transparent list is rendered. - * The chunks in these lists are held in the state-sorted order of their objects in #_objectList, with runs of - * duplicate states removed, as mentioned.

+ *

The draw list is actually comprised of two lists of state chunks: a "pick" list to render a pick buffer + * for colour-indexed GPU picking, along with a "draw" list for normal image rendering. The chunks in these lists + * are held in the state-sorted order of their objects in #_objectList, with runs of duplicate states removed.

* *

After a scene update, we set a flag on the display to indicate the stage we will need to redo from. The pipeline is * then lazy-redone on the next call to #render or #pick.

*/ var SceneJS_Display = function (cfg) { - /* Display is bound to the lifetime of an HTML5 canvas - */ + // Display is bound to the lifetime of an HTML5 canvas this._canvas = cfg.canvas; - /* Factory which creates and recycles {@link SceneJS_Program} instances - */ + // Factory which creates and recycles {@link SceneJS_Program} instances this._programFactory = new SceneJS_ProgramFactory({ canvas: cfg.canvas }); - /* Factory which creates and recycles {@link SceneJS.Chunk} instances - */ + // Factory which creates and recycles {@link SceneJS.Chunk} instances this._chunkFactory = new SceneJS_ChunkFactory(); /** @@ -14008,6 +14306,12 @@ var SceneJS_Display = function (cfg) { */ this.layer = null; + /** + * Node state core for the last {@link SceneJS.Stage} visited during scene graph compilation traversal + * @type Object + */ + this.stage = null; + /** * Node state core for the last {@link SceneJS.Renderer} visited during scene graph compilation traversal * @type Object @@ -14018,13 +14322,13 @@ var SceneJS_Display = function (cfg) { * Node state core for the last {@link SceneJS.DepthBuf} visited during scene graph compilation traversal * @type Object */ - this.depthbuf = null; + this.depthBuffer = null; /** * Node state core for the last {@link SceneJS.ColorBuf} visited during scene graph compilation traversal * @type Object */ - this.colorbuf = null; + this.colorBuffer = null; /** * Node state core for the last {@link SceneJS.View} visited during scene graph compilation traversal @@ -14075,10 +14379,10 @@ var SceneJS_Display = function (cfg) { this.projTransform = null; /** - * Node state core for the last {@link SceneJS.Framebuf} visited during scene graph compilation traversal + * Node state core for the last {@link SceneJS.ColorTarget} visited during scene graph compilation traversal * @type Object */ - this.framebuf = null; + this.renderTarget = null; /** * Node state core for the last {@link SceneJS.Clips} visited during scene graph compilation traversal @@ -14156,22 +14460,18 @@ var SceneJS_Display = function (cfg) { /* The "draw list", comprised collectively of three lists of state chunks belong to visible objects * within #_objectList: a "pick" list to render a pick buffer for colour-indexed GPU picking, along with an - * "opaque" list and "transparent" list for normal image rendering. For normal rendering the opaque list is - * rendered, then blending is enabled and the transparent list is rendered. The chunks in these lists - * are held in the state-sorted order of their objects in #_objectList, with runs of duplicate states removed. + * "draw" list for normal image rendering. The chunks in these lists are held in the state-sorted order of + * their objects in #_objectList, with runs of duplicate states removed. */ this._drawList = []; // State chunk list to render all objects this._drawListLen = 0; - this._opaqueDrawList = []; // State chunk list to render opaque objects - this._opaqueDrawListLen = 0; - - this._transparentDrawList = []; // State chunk list to render transparent objects - this._transparentDrawListLen = 0; - - this._pickDrawList = []; // State chunk list to render scene to pick buffer + this._pickDrawList = []; // State chunk list to render scene to pick buffer this._pickDrawListLen = 0; + this._targetList = []; + this._targetListLen = 0; + /* The frame context holds state shared across a single render of the draw list, along with any results of * the render, such as pick hits */ @@ -14242,21 +14542,15 @@ var SceneJS_Display = function (cfg) { * Reallocates WebGL resources for objects within this display */ SceneJS_Display.prototype.webglRestored = function () { - this._programFactory.webglRestored();// Reallocate programs - this._chunkFactory.webglRestored(); // Recache shader var locations - var gl = this._canvas.gl; - if (this.pickBuf) { this.pickBuf.webglRestored(gl); // Rebuild pick buffers } - if (this.rayPickBuf) { this.rayPickBuf.webglRestored(gl); } - this.imageDirty = true; // Need redraw }; @@ -14272,13 +14566,13 @@ SceneJS_Display.prototype.buildObject = function (objectId) { var object = this._objects[objectId]; if (!object) { // Create object - object = this._objects[objectId] = this._objectFactory.getObject(objectId); - this.objectListDirty = true; } + object.stage = this.stage; object.layer = this.layer; + object.renderTarget = this.renderTarget; object.texture = this.texture; object.cubemap = this.cubemap; object.geometry = this.geometry; @@ -14296,25 +14590,20 @@ SceneJS_Display.prototype.buildObject = function (objectId) { this.texture.hash, this.cubemap.hash, this.lights.hash - ]).join(";"); if (!object.program || hash != object.hash) { - - /* Get new program for object if no program or hash mismatch - */ - + // Get new program for object if no program or hash mismatch if (object.program) { this._programFactory.putProgram(object.program); } - object.program = this._programFactory.getProgram(hash, this); object.hash = hash; } //} - /* Build draw chunks for object - */ + // Build draw chunks for object + this._setChunk(object, 0, "program"); // Must be first this._setChunk(object, 1, "xform", this.modelTransform); this._setChunk(object, 2, "lookAt", this.viewTransform); @@ -14323,16 +14612,16 @@ SceneJS_Display.prototype.buildObject = function (objectId) { this._setChunk(object, 5, "shader", this.shader); this._setChunk(object, 6, "shaderParams", this.shaderParams); this._setChunk(object, 7, "style", this.style); - this._setChunk(object, 8, "depthbuf", this.depthbuf); - this._setChunk(object, 9, "colorbuf", this.colorbuf); + this._setChunk(object, 8, "depthBuffer", this.depthBuffer); + this._setChunk(object, 9, "colorBuffer", this.colorBuffer); this._setChunk(object, 10, "view", this.view); this._setChunk(object, 11, "name", this.name); this._setChunk(object, 12, "lights", this.lights); this._setChunk(object, 13, "material", this.material); this._setChunk(object, 14, "texture", this.texture); this._setChunk(object, 15, "cubemap", this.cubemap); - this._setChunk(object, 16, "framebuf", this.framebuf); - this._setChunk(object, 17, "clips", this.clips); + this._setChunk(object, 16, "clips", this.clips); + this._setChunk(object, 17, "renderer", this.renderer); this._setChunk(object, 18, "geometry", this.morphGeometry, this.geometry); this._setChunk(object, 19, "listeners", this.renderListeners); // Must be after the above chunks this._setChunk(object, 20, "draw", this.geometry); // Must be last @@ -14347,20 +14636,16 @@ SceneJS_Display.prototype._setChunk = function (object, order, chunkType, core, // Core supplied if (core.empty) { // Only set default cores for state types that have them - var oldChunk = object.chunks[order]; - if (oldChunk) { this._chunkFactory.putChunk(oldChunk); // Release previous chunk to pool } - object.chunks[order] = null; - return; } // Note that core.stateId can be either a number or a string, that's why we make - // chunkId a string here. String stateId can come from at least nodeEvents.js. + // chunkId a string here. // TODO: Would it be better if all were numbers? chunkId = chunkClass.prototype.programGlobal ? '_' + core.stateId @@ -14384,11 +14669,9 @@ SceneJS_Display.prototype._setChunk = function (object, order, chunkType, core, var oldChunk = object.chunks[order]; if (oldChunk) { - if (oldChunk.id == chunkId) { // Avoid needless chunk reattachment return; } - this._chunkFactory.putChunk(oldChunk); // Release previous chunk to pool } @@ -14421,22 +14704,15 @@ SceneJS_Display.prototype._setAmbient = function (core) { * @param {String} objectId ID of object to remove */ SceneJS_Display.prototype.removeObject = function (objectId) { - var object = this._objects[objectId]; - if (!object) { return; } - this._programFactory.putProgram(object.program); - object.program = null; object.hash = null; - this._objectFactory.putObject(object); - delete this._objects[objectId]; - this.objectListDirty = true; }; @@ -14450,46 +14726,42 @@ SceneJS_Display.prototype.selectTags = function (tagSelector) { /** * Render this display. What actually happens in the method depends on what flags are set. + * */ SceneJS_Display.prototype.render = function (params) { params = params || {}; if (this.objectListDirty) { - this._buildObjectList(); // Build object render bin - this.objectListDirty = false; this.stateOrderDirty = true; // Now needs state ordering } if (this.stateOrderDirty) { - this._makeStateSortKeys(); // Compute state sort order - this.stateOrderDirty = false; this.stateSortDirty = true; // Now needs state sorting } if (this.stateSortDirty) { - this._stateSort(); // State sort the object render bin - this.stateSortDirty = false; this.drawListDirty = true; // Now needs new visible object bin + //this._logObjectList(); } if (this.drawListDirty) { // Render visible list while building transparent list - this._buildDrawList(); - this.imageDirty = true; + //this._logDrawList(); + //this._logPickList(); } if (this.imageDirty || params.force) { - - this._render({}); // Render, no pick - + this._doDrawList({ // Render, no pick + clear: (params.clear !== false) // Clear buffers by default + }); this.imageDirty = false; this.pickBufDirty = true; // Pick buff will now need rendering on next pick } @@ -14504,31 +14776,36 @@ SceneJS_Display.prototype._buildObjectList = function () { } }; -SceneJS_Display.prototype._makeStateSortKeys = function () { // TODO: state sort for sound objects? +SceneJS_Display.prototype._makeStateSortKeys = function () { + // console.log("--------------------------------------------------------------------------------------------------"); + // console.log("SceneJS_Display_makeSortKeys"); var object; for (var i = 0, len = this._objectListLen; i < len; i++) { object = this._objectList[i]; - object.sortKey = object.program - ? (((object.layer.priority + 1) * 1000000) - + ((object.program.id + 1) * 1000) - + (object.texture.stateId)) - : -1; // Non-visual object (eg. sound) - } -}; - -//SceneJS_Display.prototype._makeStateSortKeys = function () { // TODO: state sort for sound objects? -// var object; -// for (var i = 0, len = this._objectListLen; i < len; i++) { -// object = this._objectList[i]; -// object.sortKey = object.program -// ? (((object.layer.priority + 1) * 1000000000) -// + ((object.program.id + 1) * 1000000) -// + (object.texture.stateId * 10000) -// + (object.geometry.stateId)) -// // + i // Force stability among same-priority objects across multiple sorts -// : -1; // Non-visual object (eg. sound) -// } -//}; + if (!object.program) { + // Non-visual object (eg. sound) + object.sortKey = -1; + } else { + +// console.log("object.stage.priority = " + ((object.stage.priority + 1) * 1000000000000)); +// console.log("object.flags.transparent = " + ((object.flags.transparent ? 2 : 1) * 1000000000)); +// console.log("object.layer.priority = " + ((object.layer.priority + 1) * 1000000)); +// console.log("object.program.id = " + ((object.program.id + 1) * 1000)); +// console.log("object.texture.stateId = " + object.texture.stateId); + + object.sortKey = + ((object.stage.priority + 1) * 1000000000000) + + ((object.flags.transparent ? 2 : 1) * 1000000000) + + ((object.layer.priority + 1) * 1000000) + + ((object.program.id + 1) * 1000) + + object.texture.stateId; + + //console.log("object.sortKey = " + object.sortKey); + // console.log(""); + } + } + // console.log("--------------------------------------------------------------------------------------------------"); +}; SceneJS_Display.prototype._stateSort = function () { this._objectList.length = this._objectListLen; @@ -14539,40 +14816,51 @@ SceneJS_Display.prototype._stateSortObjects = function (a, b) { return a.sortKey - b.sortKey; }; +SceneJS_Display.prototype._logObjectList = function () { + console.log("--------------------------------------------------------------------------------------------------"); + console.log(this._objectListLen + " objects"); + for (var i = 0, len = this._objectListLen; i < len; i++) { + var object = this._objectList[i]; + console.log("SceneJS_Display : object[" + i + "] sortKey = " + object.sortKey); + } + console.log("--------------------------------------------------------------------------------------------------"); +}; + SceneJS_Display.prototype._buildDrawList = function () { this._lastStateId = this._lastStateId || []; this._lastPickStateId = this._lastPickStateId || []; - for (var i = 0; i < 21; i++) { + for (var i = 0; i < 23; i++) { this._lastStateId[i] = null; this._lastPickStateId[i] = null; } this._drawListLen = 0; - this._opaqueDrawListLen = 0; this._pickDrawListLen = 0; - this._transparentDrawListLen = 0; + + // For each render target, a list of objects to render to that target + var targetObjectLists = {}; + + // A list of all the render target object lists + var targetListList = []; + + // List of all targets + var targetList = []; var object; var tagMask; var tagRegex; var tagCore; var flags; - var chunks; - var chunk; - var transparent; - var picking; if (this._tagSelector) { tagMask = this._tagSelector.mask; tagRegex = this._tagSelector.regex; } - if (!this._xpBuf) { - this._xpBuf = []; - } - this._xpBufLen = 0; + this._objectDrawList = this._objectDrawList || []; + this._objectDrawListLen = 0; for (var i = 0, len = this._objectListLen; i < len; i++) { @@ -14590,157 +14878,187 @@ SceneJS_Display.prototype._buildDrawList = function () { continue; } - if (!object.layer.enabled) { // Skip disabled layers + // Cull objects in disabled layers + if (!object.layer.enabled) { continue; } - if (tagMask) { // Skip unmatched tags. No tag matching in visible bin prevent this being done on every frame. - + // Cull objects with unmatched tags + if (tagMask) { tagCore = object.tag; - if (tagCore.tag) { - if (tagCore.mask != tagMask) { // Scene tag mask was updated since last render tagCore.mask = tagMask; tagCore.matches = tagRegex.test(tagCore.tag); } - if (!tagCore.matches) { continue; } } } - transparent = flags.transparent; + // Put objects with render targets into a bin for each target + if (object.renderTarget.targets) { + var targets = object.renderTarget.targets; + var target; + var coreId; + var list; + for (var j = 0, lenj = targets.length; j < lenj; j++) { + target = targets[j]; + coreId = target.coreId; + list = targetObjectLists[coreId]; + if (!list) { + list = []; + targetObjectLists[coreId] = list; + targetListList.push(list); + targetList.push(this._chunkFactory.getChunk(target.stateId, "renderTarget", object.program, target)); + } + list.push(object); + } + } else { - if (transparent) { - this._xpBuf[this._xpBufLen++] = object; + // + this._objectDrawList[this._objectDrawListLen++] = object; } + } - /* Add object's chunks to appropriate chunk list - */ - - chunks = object.chunks; - - picking = flags.picking; - - for (var j = 0, lenj = chunks.length; j < lenj; j++) { - - chunk = chunks[j]; + // Append chunks for objects within render targets first - if (chunk) { + var list; + var target; + var object; + var pickable; - // As we apply the state chunk lists we track the ID of most types of chunk in order - // to cull redundant re-applications of runs of the same chunk - except for those chunks with a - // 'unique' flag. We don't want to cull runs of draw chunks because they contain the GL - // drawElements calls which render the objects. + for (var i = 0, len = targetListList.length; i < len; i++) { - // Chunk IDs are only considered unique within the same program. Therefore, whenever we do a - // program switch, we'll be applying all the different types of chunk again. + list = targetListList[i]; + target = targetList[i]; - if (!transparent && chunk.draw) { - if (chunk.unique || this._lastStateId[j] != chunk.id) { - this._opaqueDrawList[this._opaqueDrawListLen++] = chunk; - this._drawList[this._drawListLen++] = chunk; - this._lastStateId[j] = chunk.id; - } - } + this._appendRenderTargetChunk(target); - if (chunk.pick) { // Transparent objects are pickable - if (picking) { // Don't pick unpickable objects - if (chunk.unique || this._lastPickStateId[j] != chunk.id) { - this._pickDrawList[this._pickDrawListLen++] = chunk; - this._lastPickStateId[j] = chunk.id; - } - } - } - } + for (var j = 0, lenj = list.length; j < lenj; j++) { + object = list[j]; + pickable = object.stage && object.stage.pickable; // We'll only pick objects in pickable stages + this._appendObjectToDrawLists(object, pickable); } } - if (this._xpBufLen > 0) { + if (object) { - for (var i = 0; i < this._lastStateId.length; i++) { - this._lastStateId[i] = null; - } + // Unbinds any render target bound previously + this._appendRenderTargetChunk(this._chunkFactory.getChunk(-1, "renderTarget", object.program, {})); + } - for (var i = 0; i < this._xpBufLen; i++) { + // Append chunks for objects not in render targets + for (var i = 0, len = this._objectDrawListLen; i < len; i++) { + object = this._objectDrawList[i]; + pickable = !object.stage || (object.stage && object.stage.pickable); // We'll only pick objects in pickable stages + this._appendObjectToDrawLists(object, pickable); + } - object = this._xpBuf[i]; - chunks = object.chunks; + this.drawListDirty = false; +}; - for (var j = 0, lenj = chunks.length; j < lenj; j++) { - chunk = chunks[j]; +SceneJS_Display.prototype._appendRenderTargetChunk = function (chunk) { + this._drawList[this._drawListLen++] = chunk; +}; - if (chunk && chunk.draw) { +/** + * Appends an object to the draw and pick lists. + * @param object + * @param pickable + * @private + */ +SceneJS_Display.prototype._appendObjectToDrawLists = function (object, pickable) { + var chunks = object.chunks; + var picking = object.flags.picking; + var chunk; + for (var i = 0, len = chunks.length; i < len; i++) { + chunk = chunks[i]; + if (chunk) { + + // As we apply the state chunk lists we track the ID of most types of chunk in order + // to cull redundant re-applications of runs of the same chunk - except for those chunks with a + // 'unique' flag, because we don't want to cull runs of draw chunks because they contain the GL + // drawElements calls which render the objects. + + if (chunk.draw) { + if (chunk.unique || this._lastStateId[i] != chunk.id) { // Don't reapply repeated states + this._drawList[this._drawListLen++] = chunk; + this._lastStateId[i] = chunk.id; + } + } - if (chunk.unique || this._lastStateId[j] != chunk.id) { - this._transparentDrawList[this._transparentDrawListLen++] = chunk; - this._drawList[this._drawListLen++] = chunk; - this._lastStateId[j] = chunk.id; + if (chunk.pick) { + if (pickable !== false) { // Don't pick objects in unpickable stages + if (picking) { // Don't pick unpickable objects + if (chunk.unique || this._lastPickStateId[i] != chunk.id) { // Don't reapply repeated states + this._pickDrawList[this._pickDrawListLen++] = chunk; + this._lastPickStateId[i] = chunk.id; + } } } } } } - - this.drawListDirty = false; }; -SceneJS_Display.prototype._render = function (params) { - - if (params.dof) { - - // Multi-pass depth-of-field (DOF) render - - // DOF image - - var dofImageBuf = this.dofImageBuf; // Lazy-create pick buffer - if (!dofImageBuf) { - dofImageBuf = this.dofImageBuf = new SceneJS._webgl.RenderBuffer({ canvas: this._canvas }); +/** + * Logs the contents of the draw list to the console. + * @private + */ +SceneJS_Display.prototype._logDrawList = function () { + console.log("--------------------------------------------------------------------------------------------------"); + console.log(this._drawListLen + " draw list chunks"); + for (var i = 0, len = this._drawListLen; i < len; i++) { + var chunk = this._drawList[i]; + console.log("[chunk " + i + "] type = " + chunk.type); + switch (chunk.type) { + case "draw": + console.log("\n"); + break; + case "renderTarget": + console.log(" bufType = " + chunk.core.bufType); + break; } - dofImageBuf.bind(); // Bind pick buffer - dofImageBuf.clear(); - this._doDrawList({}); - this._canvas.gl.finish(); - - // DOF depth + } + console.log("--------------------------------------------------------------------------------------------------"); +}; - var dofDepthBuf = this.dofDepthBuf; // Lazy-create pick buffer - if (!dofDepthBuf) { - dofDepthBuf = this.dofDepthBuf = new SceneJS._webgl.RenderBuffer({ canvas: this._canvas }); +/** + * Logs the contents of the pick list to the console. + * @private + */ +SceneJS_Display.prototype._logPickList = function () { + console.log("--------------------------------------------------------------------------------------------------"); + console.log(this._pickDrawListLen + " pick list chunks"); + for (var i = 0, len = this._pickDrawListLen; i < len; i++) { + var chunk = this._pickDrawList[i]; + console.log("[chunk " + i + "] type = " + chunk.type); + switch (chunk.type) { + case "draw": + console.log("\n"); + break; + case "renderTarget": + console.log(" bufType = " + chunk.core.bufType); + break; } - dofDepthBuf.bind(); // Bind pick buffer - dofDepthBuf.clear(); - this._doDrawList({ - all: true - }); - this._canvas.gl.finish(); - - // DOF blur - // .. TODO - - // DOF image - // .. TODO - - } else { - - // Default render - - this._doDrawList({}); } + console.log("--------------------------------------------------------------------------------------------------"); }; +/** + * Performs a pick on the display graph and returns info on the result. + * @param {*} params + * @returns {*} + */ SceneJS_Display.prototype.pick = function (params) { var canvas = this._canvas.canvas; - var hit = null; - var canvasX = params.canvasX; var canvasY = params.canvasY; - var pickBuf = this.pickBuf; // Lazy-create pick buffer if (!pickBuf) { @@ -14753,15 +15071,12 @@ SceneJS_Display.prototype.pick = function (params) { pickBuf.bind(); // Bind pick buffer if (this.pickBufDirty) { // Render pick buffer - pickBuf.clear(); - this._doDrawList({ - pick: true + pick: true, + clear: true }); - this._canvas.gl.finish(); - this.pickBufDirty = false; // Pick buffer up to date this.rayPickBufDirty = true; // Ray pick buffer now dirty } @@ -14769,7 +15084,6 @@ SceneJS_Display.prototype.pick = function (params) { var pix = pickBuf.read(canvasX, canvasY); // Read pick buffer var pickedObjectIndex = pix[0] + pix[1] * 256 + pix[2] * 65536; var pickIndex = (pickedObjectIndex >= 1) ? pickedObjectIndex - 1 : -1; - pickBuf.unbind(); // Unbind pick buffer var pickName = this._frameCtx.pickNames[pickIndex]; // Map pixel to name @@ -14784,7 +15098,6 @@ SceneJS_Display.prototype.pick = function (params) { }; if (params.rayPick) { // Ray pick to find position - var rayPickBuf = this.rayPickBuf; // Lazy-create Z-pick buffer if (!rayPickBuf) { rayPickBuf = this.rayPickBuf = new SceneJS._webgl.RenderBuffer({ canvas: this._canvas }); @@ -14793,14 +15106,12 @@ SceneJS_Display.prototype.pick = function (params) { rayPickBuf.bind(); if (this.rayPickBufDirty) { - rayPickBuf.clear(); - this._doDrawList({ pick: true, - rayPick: true + rayPick: true, + clear: true }); - this.rayPickBufDirty = false; } @@ -14808,34 +15119,24 @@ SceneJS_Display.prototype.pick = function (params) { rayPickBuf.unbind(); - /* Read normalised device Z coordinate, which will be - * in range of [0..1] with z=0 at front - */ + // Read normalised device Z coordinate, which will be + // in range of [0..1] with z=0 at front var screenZ = this._unpackDepth(pix); - var w = canvas.width; var h = canvas.height; - - /* Calculate clip space coordinates, which will be in range - * of x=[-1..1] and y=[-1..1], with y=(+1) at top - */ + // Calculate clip space coordinates, which will be in range + // of x=[-1..1] and y=[-1..1], with y=(+1) at top var x = (canvasX - w / 2) / (w / 2); // Calculate clip space coordinates var y = -(canvasY - h / 2) / (h / 2); - var projMat = this._frameCtx.cameraMat; var viewMat = this._frameCtx.viewMat; - var pvMat = SceneJS_math_mulMat4(projMat, viewMat, []); var pvMatInverse = SceneJS_math_inverseMat4(pvMat, []); - var world1 = SceneJS_math_transformVector4(pvMatInverse, [x, y, -1, 1]); world1 = SceneJS_math_mulVec4Scalar(world1, 1 / world1[3]); - var world2 = SceneJS_math_transformVector4(pvMatInverse, [x, y, 1, 1]); world2 = SceneJS_math_mulVec4Scalar(world2, 1 / world2[3]); - var dir = SceneJS_math_subVec3(world2, world1, []); - var vWorld = SceneJS_math_addVec3(world1, SceneJS_math_mulVec4Scalar(dir, screenZ, []), []); hit.worldPos = vWorld; @@ -14845,117 +15146,105 @@ SceneJS_Display.prototype.pick = function (params) { return hit; }; +/** + * Unpacks a color-encoded depth + * @param {Array(Number)} depthZ Depth encoded as an RGBA color value + * @returns {Number} + * @private + */ SceneJS_Display.prototype._unpackDepth = function (depthZ) { var vec = [depthZ[0] / 256.0, depthZ[1] / 256.0, depthZ[2] / 256.0, depthZ[3] / 256.0]; var bitShift = [1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0]; return SceneJS_math_dotVector4(vec, bitShift); }; +/** Renders either the draw or pick list. + * + * @param {*} params + * @param {Boolean} params.clear Set true to clear the color, depth and stencil buffers first + * @param {Boolean} params.pick Set true to render for picking + * @param {Boolean} params.rayPick Set true to render for ray-picking + * @private + */ SceneJS_Display.prototype._doDrawList = function (params) { - var frameCtx = this._frameCtx; // Reset rendering context - var gl = this._canvas.gl; - frameCtx.framebuf = null; + // Reset frame context + var frameCtx = this._frameCtx; + frameCtx.renderTarget = null; + frameCtx.targetIndex = 0; + frameCtx.renderBuf = null; frameCtx.viewMat = null; frameCtx.modelMat = null; frameCtx.cameraMat = null; frameCtx.renderer = null; - frameCtx.depthbufEnabled = null; frameCtx.clearDepth = null; frameCtx.depthFunc = gl.LESS; - frameCtx.scissorTestEnabled = false; - frameCtx.blendEnabled = false; - frameCtx.backfaces = true; frameCtx.frontface = "ccw"; frameCtx.pick = !!params.pick; + frameCtx.rayPick = !!params.rayPick; + frameCtx.pickIndex = 0; frameCtx.textureUnit = 0; - frameCtx.lineWidth = 1; + frameCtx.transparent = false; + frameCtx.ambientColor = this._ambientColor; - frameCtx.transparencyPass = false; - - // The extension needs to be re-queried in case the context was lost and - // has been recreated. + // The extension needs to be re-queried in case the context was lost and has been recreated. var VAO = gl.getExtension("OES_vertex_array_object"); - if (VAO) { - frameCtx.VAO = VAO; - } + frameCtx.VAO = (VAO) ? VAO : null; gl.viewport(0, 0, this._canvas.canvas.width, this._canvas.canvas.height); + if (this.transparent) { gl.clearColor(0, 0, 0, 0); } else { gl.clearColor(this._ambientColor[0], this._ambientColor[1], this._ambientColor[2], 1.0); } - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); + + if (params.clear) { + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); + } + gl.frontFace(gl.CCW); gl.disable(gl.CULL_FACE); if (params.pick) { - - // Render to pick buffer - - frameCtx.pickIndex = 0; - frameCtx.rayPick = !!params.rayPick; - - for (var i = 0, len = this._pickDrawListLen; i < len; i++) { // Push picking chunks + // Render for pick + for (var i = 0, len = this._pickDrawListLen; i < len; i++) { this._pickDrawList[i].pick(frameCtx); } - - } else if (params.all) { - - // Render all - + } else { + // Render for draw for (var i = 0, len = this._drawListLen; i < len; i++) { // Push opaque rendering chunks this._drawList[i].draw(frameCtx); } + } - } else { - - // Normal draw - - for (var i = 0, len = this._opaqueDrawListLen; i < len; i++) { // Push opaque rendering chunks - this._opaqueDrawList[i].draw(frameCtx); - } - - if (this._transparentDrawListLen > 0) { - - // Disables some types of state changes during - // transparency pass, such as blending disable - frameCtx.transparencyPass = true; - - // Enable blending - gl.enable(gl.BLEND); - frameCtx.blendEnabled = true; - - gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); - - for (var i = 0, len = this._transparentDrawListLen; i < len; i++) { // Push transparent rendering chunks - this._transparentDrawList[i].draw(frameCtx); - } - - // Disable blending - gl.disable(gl.BLEND); - frameCtx.blendEnabled = false; + gl.flush(); - frameCtx.transparencyPass = false; - } + if (frameCtx.renderBuf) { + gl.finish(); + frameCtx.renderBuf.unbind(); } - gl.flush(); // Flush GL - if (frameCtx.VAO) { frameCtx.VAO.bindVertexArrayOES(null); for (var i = 0; i < 10; i++) { gl.disableVertexAttribArray(i); } } +// +// var numTextureUnits = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); +// for (var ii = 0; ii < numTextureUnits; ++ii) { +// gl.activeTexture(gl.TEXTURE0 + ii); +// gl.bindTexture(gl.TEXTURE_CUBE_MAP, null); +// gl.bindTexture(gl.TEXTURE_2D, null); +// } }; SceneJS_Display.prototype.destroy = function () { @@ -15014,6 +15303,15 @@ var SceneJS_ProgramSourceFactory = new (function () { var customFragmentShader = customShaders.fragment || {}; var fragmentHooks = customFragmentShader.hooks || {}; + // Do a full custom shader replacement if code supplied without hooks + if (customShaders.vertex + && customShaders.vertex.code + && customShaders.vertex.code != "" + && SceneJS._isEmpty(customShaders.vertex.hooks)) { + return [customShaders.vertex.code]; + } + + var clipping = states.clips.clips.length > 0; var morphing = !!states.morphGeometry.targets; var normals = this._hasNormals(states); @@ -15126,6 +15424,14 @@ var SceneJS_ProgramSourceFactory = new (function () { var customFragmentShader = customShaders.fragment || {}; var fragmentHooks = customFragmentShader.hooks || {}; + // Do a full custom shader replacement if code supplied without hooks + if (customShaders.fragment + && customShaders.fragment.code + && customShaders.fragment.code != "" + && SceneJS._isEmpty(customShaders.fragment.hooks)) { + return [customShaders.fragment.code]; + } + var clipping = states.clips.clips.length > 0; var normals = this._hasNormals(states); @@ -15142,6 +15448,7 @@ var SceneJS_ProgramSourceFactory = new (function () { src.push(" return res;"); src.push("}"); + src.push("varying vec4 SCENEJS_vWorldVertex;"); src.push("varying vec4 SCENEJS_vViewVertex;"); // View-space vertex src.push("varying vec4 SCENEJS_vProjVertex;"); @@ -15272,10 +15579,12 @@ var SceneJS_ProgramSourceFactory = new (function () { var customShaders = states.shader.shaders || {}; - /* Do a full custom shader replacement if code supplied without hooks - */ - if (customShaders.vertex && customShaders.vertex.code && !customShaders.vertex.hooks) { - return customShaders.vertex.code; + // Do a full custom shader replacement if code supplied without hooks + if (customShaders.vertex + && customShaders.vertex.code + && customShaders.vertex.code != "" + && SceneJS._isEmpty(customShaders.vertex.hooks)) { + return [customShaders.vertex.code]; } var customVertexShader = customShaders.vertex || {}; @@ -15356,9 +15665,9 @@ var SceneJS_ProgramSourceFactory = new (function () { src.push("varying vec4 SCENEJS_vWorldVertex;"); // Varying for fragment clip or world pos hook } - if (fragmentHooks.viewPos) { - src.push("varying vec4 SCENEJS_vViewVertex;"); // Varying for fragment view clip hook - } + // if (fragmentHooks.viewPos) { + src.push("varying vec4 SCENEJS_vViewVertex;"); // Varying for fragment view clip hook + // } if (texturing) { // Varyings for fragment texturing if (states.geometry.uvBuf) { @@ -15444,9 +15753,9 @@ var SceneJS_ProgramSourceFactory = new (function () { src.push(" SCENEJS_vWorldVertex = worldVertex;"); // Varying for fragment world clip or hooks } - if (fragmentHooks.viewPos) { - src.push(" SCENEJS_vViewVertex = viewVertex;"); // Varying for fragment hooks - } + // if (fragmentHooks.viewPos) { + src.push(" SCENEJS_vViewVertex = viewVertex;"); // Varying for fragment hooks + // } if (vertexHooks.projMatrix) { src.push("gl_Position = " + vertexHooks.projMatrix + "(SCENEJS_uPMatrix) * viewVertex;"); @@ -15542,10 +15851,12 @@ var SceneJS_ProgramSourceFactory = new (function () { var customShaders = states.shader.shaders || {}; - /* Do a full custom shader replacement if code supplied without hooks - */ - if (customShaders.fragment && customShaders.fragment.code && !customShaders.fragment.hooks) { - return customShaders.fragment.code; + // Do a full custom shader replacement if code supplied without hooks + if (customShaders.fragment + && customShaders.fragment.code + && customShaders.fragment.code != "" + && SceneJS._isEmpty(customShaders.fragment.hooks)) { + return [customShaders.fragment.code]; } var customFragmentShader = customShaders.fragment || {}; @@ -15565,9 +15876,13 @@ var SceneJS_ProgramSourceFactory = new (function () { src.push("varying vec4 SCENEJS_vWorldVertex;"); // World-space vertex } - if (fragmentHooks.viewPos) { - src.push("varying vec4 SCENEJS_vViewVertex;"); // View-space vertex - } + // if (fragmentHooks.viewPos) { + src.push("varying vec4 SCENEJS_vViewVertex;"); // View-space vertex + // } + + src.push("uniform float SCENEJS_uZNear;"); // Used in Z-pick mode + src.push("uniform float SCENEJS_uZFar;"); // Used in Z-pick mode + /*----------------------------------------------------------------------------------- * Variables @@ -15617,6 +15932,9 @@ var SceneJS_ProgramSourceFactory = new (function () { src.push("uniform bool SCENEJS_uDiffuse;"); src.push("uniform bool SCENEJS_uReflection;"); + // Added in v4.0 to support depth targets + src.push("uniform bool SCENEJS_uDepthMode;"); + /* True when rendering transparency */ src.push("uniform bool SCENEJS_uTransparent;"); @@ -15629,7 +15947,7 @@ var SceneJS_ProgramSourceFactory = new (function () { src.push("uniform vec3 SCENEJS_uAmbientColor;"); // Scene ambient colour - taken from clear colour - src.push("uniform vec3 SCENEJS_uMaterialBaseColor;"); + src.push("uniform vec3 SCENEJS_uMaterialColor;"); src.push("uniform float SCENEJS_uMaterialAlpha;"); src.push("uniform float SCENEJS_uMaterialEmit;"); src.push("uniform vec3 SCENEJS_uMaterialSpecularColor;"); @@ -15713,7 +16031,7 @@ var SceneJS_ProgramSourceFactory = new (function () { if (states.geometry.colorBuf) { src.push(" vec3 color = SCENEJS_vColor.rgb;"); } else { - src.push(" vec3 color = SCENEJS_uMaterialBaseColor;") + src.push(" vec3 color = SCENEJS_uMaterialColor;") } src.push(" float alpha = SCENEJS_uMaterialAlpha;"); @@ -15744,6 +16062,7 @@ var SceneJS_ProgramSourceFactory = new (function () { if (normals) { src.push(" float attenuation = 1.0;"); src.push(" vec3 viewNormalVec = SCENEJS_vViewNormal;"); + src.push(" vec3 worldNormalVec = SCENEJS_vWorldNormal;"); } var layer; @@ -15802,6 +16121,10 @@ var SceneJS_ProgramSourceFactory = new (function () { } else if (layer.blendMode == "add") { src.push("alpha = ((1.0 - SCENEJS_uLayer" + i + "BlendFactor) * alpha) + (SCENEJS_uLayer" + i + "BlendFactor * texture2D(SCENEJS_uSampler" + i + ", vec2(textureCoord.x, 1.0 - textureCoord.y)).b);"); } + + //===================================================================== + // TODO: "mix" blendMode + //===================================================================== } /* Texture output @@ -15840,7 +16163,7 @@ var SceneJS_ProgramSourceFactory = new (function () { if (layer.applyTo == "normals" && normals) { src.push("vec3 bump = normalize(texture2D(SCENEJS_uSampler" + i + ", vec2(textureCoord.x, -textureCoord.y)).xyz * 2.0 - 1.0);"); - src.push("viewNormalVec *= -bump;"); + src.push("worldNormalVec = bump;"); } } if (normals) { @@ -15850,7 +16173,7 @@ var SceneJS_ProgramSourceFactory = new (function () { if (normals && cubeMapping) { src.push("if (SCENEJS_uReflection) {"); // Flag which can enable/disable reflection - src.push("vec3 envLookup = reflect(normalize(SCENEJS_vWorldEyeVec), normalize(SCENEJS_vWorldNormal));"); + src.push("vec3 envLookup = reflect(normalize(SCENEJS_vWorldEyeVec), normalize(worldNormalVec));"); src.push("envLookup.y = envLookup.y * -1.0;"); // Need to flip textures on Y-axis for some reason src.push("vec4 envColor;"); for (var i = 0, len = states.cubemap.layers.length; i < len; i++) { @@ -15945,11 +16268,24 @@ var SceneJS_ProgramSourceFactory = new (function () { if (fragmentHooks.pixelColor) { src.push("fragColor=" + fragmentHooks.pixelColor + "(fragColor);"); } - if (false && debugCfg.whitewash === true) { src.push(" gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);"); } else { - src.push(" gl_FragColor = fragColor;"); + src.push(" if (SCENEJS_uDepthMode) {"); + src.push(" float depth = length(SCENEJS_vViewVertex) / (SCENEJS_uZFar - SCENEJS_uZNear);"); + src.push(" const vec4 bias = vec4(1.0 / 255.0,"); + src.push(" 1.0 / 255.0,"); + src.push(" 1.0 / 255.0,"); + src.push(" 0.0);"); + src.push(" float r = depth;"); + src.push(" float g = fract(r * 255.0);"); + src.push(" float b = fract(g * 255.0);"); + src.push(" float a = fract(b * 255.0);"); + src.push(" vec4 colour = vec4(r, g, b, a);"); + src.push(" gl_FragColor = colour - (colour.yzww * bias);"); + src.push(" } else {"); + src.push(" gl_FragColor = fragColor;"); + src.push(" };"); } src.push("}"); @@ -16466,6 +16802,8 @@ SceneJS_ChunkFactory.prototype.getChunk = function(chunkId, type, program, core, } + chunk.type = type; + chunk.useCount = 1; this._chunks[chunkId] = chunk; @@ -16524,13 +16862,15 @@ SceneJS_ChunkFactory.createChunkType({ build : function() { this._uPMatrixDraw = this.program.draw.getUniformLocation("SCENEJS_uPMatrix"); + this._uZNearDraw = this.program.draw.getUniformLocation("SCENEJS_uZNear"); + this._uZFarDraw = this.program.draw.getUniformLocation("SCENEJS_uZFar"); this._uPMatrixPick = this.program.pick.getUniformLocation("SCENEJS_uPMatrix"); this._uZNearPick = this.program.pick.getUniformLocation("SCENEJS_uZNear"); this._uZFarPick = this.program.pick.getUniformLocation("SCENEJS_uZFar"); }, - draw : function(ctx) { + draw : function(frameCtx) { if (this.core.dirty) { this.core.rebuild(); @@ -16542,11 +16882,19 @@ SceneJS_ChunkFactory.createChunkType({ gl.uniformMatrix4fv(this._uPMatrixDraw, gl.FALSE, this.core.mat); } - ctx.cameraMat = this.core.mat; // Query only in draw pass + if (this._uZNearDraw) { + gl.uniform1f(this._uZNearDraw, this.core.optics.near); + } + + if (this._uZFarDraw) { + gl.uniform1f(this._uZFarDraw, this.core.optics.far); + } + + frameCtx.cameraMat = this.core.mat; // Query only in draw pass }, - pick : function(ctx) { + pick : function(frameCtx) { var gl = this.program.gl; @@ -16554,7 +16902,7 @@ SceneJS_ChunkFactory.createChunkType({ gl.uniformMatrix4fv(this._uPMatrixPick, gl.FALSE, this.core.mat); } - if (ctx.rayPick) { // Z-pick pass: feed near and far clip planes into shader + if (frameCtx.rayPick) { // Z-pick pass: feed near and far clip planes into shader if (this._uZNearPick) { gl.uniform1f(this._uZNearPick, this.core.optics.near); @@ -16565,7 +16913,7 @@ SceneJS_ChunkFactory.createChunkType({ } } - ctx.cameraMat = this.core.mat; // Query only in draw pass + frameCtx.cameraMat = this.core.mat; // Query only in draw pass } });/** * Create display state chunk type for draw and pick render of user clipping planes @@ -16599,9 +16947,9 @@ SceneJS_ChunkFactory.createChunkType({ } }, - drawAndPick: function(ctx) { + drawAndPick: function(frameCtx) { - var vars = (ctx.pick) ? this._pick : this._draw; + var vars = (frameCtx.pick) ? this._pick : this._draw; var mode; var normalAndDist; @@ -16611,7 +16959,7 @@ SceneJS_ChunkFactory.createChunkType({ for (var i = 0, len = clips.length; i < len; i++) { - if (ctx.pick) { + if (frameCtx.pick) { mode = vars[i].uClipMode; normalAndDist = vars[i].uClipNormalAndDist; } else { @@ -16655,13 +17003,16 @@ SceneJS_ChunkFactory.createChunkType({ */ unique:true, - build:function () {}, - - drawAndPick:function (ctx) { + build:function () { + this._depthModeDraw = this.program.draw.getUniformLocation("SCENEJS_uDepthMode"); + this._depthModePick = this.program.pick.getUniformLocation("SCENEJS_uDepthMode"); + }, + drawAndPick:function (frameCtx) { var gl = this.program.gl; - + gl.uniform1i(frameCtx.pick ? this._depthModePick : this._depthModeDraw, frameCtx.depthMode); gl.drawElements(this.core.primitive, this.core.indexBuf.numItems, gl.UNSIGNED_SHORT, 0); + //frameCtx.textureUnit = 0; } }); /** @@ -16669,9 +17020,9 @@ SceneJS_ChunkFactory.createChunkType({ */ SceneJS_ChunkFactory.createChunkType({ - type:"flags", + type: "flags", - build:function () { + build: function () { var draw = this.program.draw; @@ -16688,43 +17039,64 @@ SceneJS_ChunkFactory.createChunkType({ this._uClippingPick = pick.getUniformLocation("SCENEJS_uClipping"); }, - drawAndPick:function (ctx) { + drawAndPick: function (frameCtx) { var gl = this.program.gl; var backfaces = this.core.backfaces; - if (ctx.backfaces != backfaces) { + if (frameCtx.backfaces != backfaces) { if (backfaces) { gl.disable(gl.CULL_FACE); } else { gl.enable(gl.CULL_FACE); } - ctx.backfaces = backfaces; + frameCtx.backfaces = backfaces; } var frontface = this.core.frontface; - if (ctx.frontface != frontface) { + if (frameCtx.frontface != frontface) { if (frontface == "ccw") { gl.frontFace(gl.CCW); } else { gl.frontFace(gl.CW); } - ctx.frontface = frontface; + frameCtx.frontface = frontface; } - if (ctx.pick) { + var transparent = this.core.transparent; + + if (frameCtx.transparent != transparent) { + if (transparent) { + + // Entering a transparency bin + + gl.enable(gl.BLEND); + gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); + frameCtx.blendEnabled = true; + + } else { + + // Leaving a transparency bin + + gl.disable(gl.BLEND); + frameCtx.blendEnabled = false; + } + frameCtx.transparent = transparent; + } + + if (frameCtx.pick) { gl.uniform1i(this._uClippingPick, this.core.clipping); } else { var drawUniforms = (this.core.backfaceTexturing ? 1 : 0) + - (this.core.backfaceLighting ? 2 : 0) + - (this.core.specular ? 4 : 0) + - (this.core.clipping ? 8 : 0) + - (this.core.ambient ? 16 : 0) + - (this.core.diffuse ? 32 : 0) + - (this.core.reflection ? 64 : 0); + (this.core.backfaceLighting ? 2 : 0) + + (this.core.specular ? 4 : 0) + + (this.core.clipping ? 8 : 0) + + (this.core.ambient ? 16 : 0) + + (this.core.diffuse ? 32 : 0) + + (this.core.reflection ? 64 : 0); if (this.program.drawUniformFlags != drawUniforms) { gl.uniform1i(this._uBackfaceTexturingDraw, this.core.backfaceTexturing); gl.uniform1i(this._uBackfaceLightingDraw, this.core.backfaceLighting); @@ -16739,41 +17111,54 @@ SceneJS_ChunkFactory.createChunkType({ } }); /** - * Create display state chunk type for draw and pick render of framebuf + * Create display state chunk type for draw and pick render of renderTarget */ SceneJS_ChunkFactory.createChunkType({ - type: "framebuf", + type: "renderTarget", - // Avoid reapplication of a chunk after a program switch. - programGlobal:true, - - build: function() { - }, + // Avoid reapplication of this chunk type after a program switch. + programGlobal: true, - drawAndPick: function(ctx) { + draw: function (frameCtx) { var gl = this.program.gl; - if (ctx.framebuf) { - - gl.finish(); // Force framebuf to complete - - ctx.framebuf.unbind(); - - ctx.framebuf = null; + // Flush and unbind any render buffer already bound + if (frameCtx.renderBuf) { + gl.finish(); + frameCtx.renderBuf.unbind(); + frameCtx.renderBuf = null; } - var framebuf = this.core.framebuf; + // Set depthMode false and bail if no render buffer for this chunk + var renderBuf = this.core.renderBuf; + if (!renderBuf) { + frameCtx.depthMode = false; + return; + } - if (framebuf) { + // Bind this chunk's render buffer, set depthMode, enable blend if depthMode false, clear buffer + renderBuf.bind(); - framebuf.bind(); + frameCtx.depthMode = (this.core.bufType === "depth"); - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); + if (!frameCtx.depthMode) { - ctx.framebuf = framebuf; // Must flush on cleanup + // Enable blending for non-depth targets + if (frameCtx.blendEnabled) { + gl.enable(gl.BLEND); + gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA); + } } + + var canvas = frameCtx.canvas.canvas; + gl.viewport(0, 0, canvas.width, canvas.height); + gl.clearColor(frameCtx.ambientColor[0], frameCtx.ambientColor[1], frameCtx.ambientColor[2], 1.0); + gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT); + // gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); + + frameCtx.renderBuf = renderBuf; } });/** * Create display state chunk type for draw and pick render of geometry @@ -16866,12 +17251,12 @@ SceneJS_ChunkFactory.createChunkType({ }, - draw:function (ctx) { + draw:function (frameCtx) { var doMorph = this.core.targets && this.core.targets.length; var cleanInterleavedBuf = this.core2.interleavedBuf && !this.core2.interleavedBuf.dirty; if (this.VAO) { - ctx.VAO.bindVertexArrayOES(this.VAO); + frameCtx.VAO.bindVertexArrayOES(this.VAO); if (doMorph) { if (this.VAOMorphKey1 == this.core.key1 && this.VAOMorphKey2 == this.core.key2) { this.setDrawMorphFactor(); @@ -16880,11 +17265,11 @@ SceneJS_ChunkFactory.createChunkType({ } else if (cleanInterleavedBuf || !this.VAOHasInterleavedBuf) { return; } - } else if (ctx.VAO) { + } else if (frameCtx.VAO) { // Start creating a new VAO by switching to the default VAO, which doesn't have attribs enabled. - ctx.VAO.bindVertexArrayOES(null); - this.VAO = ctx.VAO.createVertexArrayOES(); - ctx.VAO.bindVertexArrayOES(this.VAO); + frameCtx.VAO.bindVertexArrayOES(null); + this.VAO = frameCtx.VAO.createVertexArrayOES(); + frameCtx.VAO.bindVertexArrayOES(this.VAO); var gl = this.program.gl; } @@ -16970,7 +17355,7 @@ SceneJS_ChunkFactory.createChunkType({ }, - pick:function (ctx) { + pick:function (frameCtx) { if (this.core.targets && this.core.targets.length) { this.morphPick(); @@ -17041,9 +17426,9 @@ SceneJS_ChunkFactory.createChunkType({ } }, - draw:function (ctx) { + draw:function (frameCtx) { - if (ctx.dirty) { + if (frameCtx.dirty) { this.build(); } @@ -17092,10 +17477,10 @@ SceneJS_ChunkFactory.createChunkType({ build : function() { }, - draw : function(ctx) { + draw : function(frameCtx) { var listeners = this.core.listeners; - var renderListenerCtx = ctx.renderListenerCtx; + var renderListenerCtx = frameCtx.renderListenerCtx; for (var i = listeners.length - 1; i >= 0; i--) { // Child listeners first if (listeners[i](renderListenerCtx) === true) { // Call listener with query facade object as scope @@ -17119,7 +17504,7 @@ SceneJS_ChunkFactory.createChunkType({ this._uvMatrixPick = this.program.pick.getUniformLocation("SCENEJS_uVMatrix"); }, - draw : function(ctx) { + draw : function(frameCtx) { if (this.core.dirty) { this.core.rebuild(); @@ -17139,10 +17524,10 @@ SceneJS_ChunkFactory.createChunkType({ gl.uniform3fv(this._uWorldEyeDraw, this.core.lookAt.eye); } - ctx.viewMat = this.core.mat; + frameCtx.viewMat = this.core.mat; }, - pick : function(ctx) { + pick : function(frameCtx) { var gl = this.program.gl; @@ -17150,7 +17535,7 @@ SceneJS_ChunkFactory.createChunkType({ gl.uniformMatrix4fv(this._uvMatrixPick, gl.FALSE, this.core.mat); } - ctx.viewMat = this.core.mat; + frameCtx.viewMat = this.core.mat; } });/** * Create display state chunk type for draw render of material transform @@ -17163,7 +17548,7 @@ SceneJS_ChunkFactory.createChunkType({ var draw = this.program.draw; - this._uMaterialBaseColor = draw.getUniformLocation("SCENEJS_uMaterialBaseColor"); + this._uMaterialBaseColor = draw.getUniformLocation("SCENEJS_uMaterialColor"); this._uMaterialSpecularColor = draw.getUniformLocation("SCENEJS_uMaterialSpecularColor"); this._uMaterialSpecular = draw.getUniformLocation("SCENEJS_uMaterialSpecular"); this._uMaterialShine = draw.getUniformLocation("SCENEJS_uMaterialShine"); @@ -17222,15 +17607,15 @@ SceneJS_ChunkFactory.createChunkType({ this._uPickColor = this.program.pick.getUniformLocation("SCENEJS_uPickColor"); }, - pick : function(ctx) { + pick : function(frameCtx) { if (this._uPickColor && this.core.name) { - ctx.pickNames[ctx.pickIndex++] = this.core; + frameCtx.pickNames[frameCtx.pickIndex++] = this.core; - var b = ctx.pickIndex >> 16 & 0xFF; - var g = ctx.pickIndex >> 8 & 0xFF; - var r = ctx.pickIndex & 0xFF; + var b = frameCtx.pickIndex >> 16 & 0xFF; + var g = frameCtx.pickIndex >> 8 & 0xFF; + var r = frameCtx.pickIndex & 0xFF; this.program.gl.uniform3fv(this._uPickColor, [r / 255, g / 255, b / 255]); } @@ -17240,38 +17625,35 @@ SceneJS_ChunkFactory.createChunkType({ type: "program", build : function() { + + // Note that "program" chunks are always after "renderTarget" chunks + this._depthModeDraw = this.program.draw.getUniformLocation("SCENEJS_uDepthMode"); + this._depthModePick = this.program.pick.getUniformLocation("SCENEJS_uDepthMode"); this._rayPickMode = this.program.pick.getUniformLocation("SCENEJS_uRayPickMode"); }, draw : function(frameCtx) { - var drawProgram = this.program.draw; - drawProgram.bind(); - frameCtx.textureUnit = 0; - var gl = this.program.gl; - + gl.uniform1i(this._depthModeDraw, frameCtx.depthMode); if (!frameCtx.VAO) { for (var i = 0; i < 10; i++) { gl.disableVertexAttribArray(i); } } + + frameCtx.drawProgram = this.program.draw; }, pick : function(frameCtx) { - var pickProgram = this.program.pick; - pickProgram.bind(); - var gl = this.program.gl; - gl.uniform1i(this._rayPickMode, frameCtx.rayPick); - + gl.uniform1i(this._depthModePick, frameCtx.depthMode); frameCtx.textureUnit = 0; - for (var i = 0; i < 10; i++) { gl.disableVertexAttribArray(i); } @@ -17284,23 +17666,20 @@ SceneJS_ChunkFactory.createChunkType({ * */ SceneJS_ChunkFactory.createChunkType({ - + type: "renderer", - build : function() { + build: function () { }, - drawAndPick : function(ctx) { + drawAndPick: function (frameCtx) { if (this.core.props) { - var gl = this.program.gl; - - if (ctx.renderer) { - ctx.renderer.props.restoreProps(gl); - ctx.renderer = this.core; + if (frameCtx.renderer) { + frameCtx.renderer.props.restoreProps(gl); + frameCtx.renderer = this.core; } - this.core.props.setProps(gl); } } @@ -17310,37 +17689,41 @@ SceneJS_ChunkFactory.createChunkType({ */ SceneJS_ChunkFactory.createChunkType({ - type:"depthbuf", + type:"depthBuffer", // Avoid reapplication of a chunk after a program switch. programGlobal:true, - drawAndPick:function (ctx) { + drawAndPick:function (frameCtx) { var enabled = this.core.enabled; - if (ctx.depthbufEnabled != enabled) { + if (frameCtx.depthbufEnabled != enabled) { var gl = this.program.gl; if (enabled) { gl.enable(gl.DEPTH_TEST); } else { gl.disable(gl.DEPTH_TEST); } - ctx.depthbufEnabled = enabled; + frameCtx.depthbufEnabled = enabled; } var clearDepth = this.core.clearDepth; - if (ctx.clearDepth != clearDepth) { + if (frameCtx.clearDepth != clearDepth) { gl.clearDepth(clearDepth); - ctx.clearDepth = clearDepth; + frameCtx.clearDepth = clearDepth; } var depthFunc = this.core.depthFunc; - if (ctx.depthFunc != depthFunc) { + if (frameCtx.depthFunc != depthFunc) { gl.depthFunc(depthFunc); - ctx.depthFunc = depthFunc; + frameCtx.depthFunc = depthFunc; + } + + if (this.core.clear) { + gl.clear(gl.DEPTH_BUFFER_BIT); } } }); @@ -17349,7 +17732,7 @@ SceneJS_ChunkFactory.createChunkType({ */ SceneJS_ChunkFactory.createChunkType({ - type:"colorbuf", + type:"colorBuffer", // Avoid reapplication of a chunk after a program switch. programGlobal:true, @@ -17357,21 +17740,25 @@ SceneJS_ChunkFactory.createChunkType({ build:function () { }, - drawAndPick:function (ctx) { + drawAndPick:function (frameCtx) { - if (!ctx.transparencyPass) { // Blending forced when rendering transparent bin + if (!frameCtx.transparent) { // Blending forced when rendering transparent bin var blendEnabled = this.core.blendEnabled; - if (ctx.blendEnabled != blendEnabled) { - var gl = this.program.gl; + var gl = this.program.gl; + + if (frameCtx.blendEnabled != blendEnabled) { if (blendEnabled) { gl.enable(gl.BLEND); } else { gl.disable(gl.BLEND); } - ctx.blendEnabled = blendEnabled; + frameCtx.blendEnabled = blendEnabled; } + + var colorMask = this.core.colorMask; + gl.colorMask(colorMask.r, colorMask.g, colorMask.b, colorMask.a); } } }); @@ -17388,18 +17775,18 @@ SceneJS_ChunkFactory.createChunkType({ build:function () { }, - drawAndPick:function (ctx) { + drawAndPick:function (frameCtx) { var scissorTestEnabled = this.core.scissorTestEnabled; - if (ctx.scissorTestEnabled != scissorTestEnabled) { + if (frameCtx.scissorTestEnabled != scissorTestEnabled) { var gl = this.program.gl; if (scissorTestEnabled) { gl.enable(gl.SCISSOR_TEST); } else { gl.disable(gl.SCISSOR_TEST); } - ctx.scissorTestEnabled = scissorTestEnabled; + frameCtx.scissorTestEnabled = scissorTestEnabled; } } }); @@ -17413,13 +17800,13 @@ SceneJS_ChunkFactory.createChunkType({ build : function() { }, - drawAndPick : function(ctx) { + drawAndPick : function(frameCtx) { var paramsStack = this.core.paramsStack; if (paramsStack) { - var program = ctx.pick ? this.program.pick : this.program.draw; + var program = frameCtx.pick ? this.program.pick : this.program.draw; var params; var name; @@ -17443,13 +17830,13 @@ SceneJS_ChunkFactory.createChunkType({ build : function() { }, - drawAndPick: function(ctx) { + drawAndPick: function(frameCtx) { var paramsStack = this.core.paramsStack; if (paramsStack) { - var program = ctx.pick ? this.program.pick : this.program.draw; + var program = frameCtx.pick ? this.program.pick : this.program.draw; var params; var name; @@ -17473,14 +17860,14 @@ SceneJS_ChunkFactory.createChunkType({ // Avoid reapplication of a chunk after a program switch. programGlobal:true, - drawAndPick:function (ctx) { + drawAndPick:function (frameCtx) { var lineWidth = this.core.lineWidth; - if (ctx.lineWidth != lineWidth) { + if (frameCtx.lineWidth != lineWidth) { var gl = this.program.gl; gl.lineWidth(lineWidth); - ctx.lineWidth = lineWidth; + frameCtx.lineWidth = lineWidth; } } }); @@ -17518,7 +17905,9 @@ SceneJS_ChunkFactory.createChunkType({ } }, - draw : function(ctx) { + draw : function(frameCtx) { + + frameCtx.textureUnit = 0; var layers = this.core.layers; @@ -17533,7 +17922,7 @@ SceneJS_ChunkFactory.createChunkType({ if (this._uTexSampler[i] && layer.texture) { // Lazy-loads - draw.bindTexture(this._uTexSampler[i], layer.texture, ctx.textureUnit++); + draw.bindTexture(this._uTexSampler[i], layer.texture, frameCtx.textureUnit++); if (layer._matrixDirty && layer.buildMatrix) { layer.buildMatrix.call(layer); @@ -17548,13 +17937,13 @@ SceneJS_ChunkFactory.createChunkType({ } } else { - // draw.bindTexture(this._uTexSampler[i], null, i); // Unbind + // draw.bindTexture(this._uTexSampler[i], null, i); // Unbind } } } - if (ctx.textureUnit > 10) { // TODO: Find how many textures allowed - ctx.textureUnit = 0; + if (frameCtx.textureUnit > 10) { // TODO: Find how many textures allowed + frameCtx.textureUnit = 0; } } });SceneJS_ChunkFactory.createChunkType({ @@ -17576,7 +17965,7 @@ SceneJS_ChunkFactory.createChunkType({ } }, - draw: function (ctx) { + draw: function (frameCtx) { var layers = this.core.layers; if (layers) { var layer; @@ -17584,7 +17973,7 @@ SceneJS_ChunkFactory.createChunkType({ for (var i = 0, len = layers.length; i < len; i++) { layer = layers[i]; if (this._uCubeMapSampler[i] && layer.texture) { - draw.bindTexture(this._uCubeMapSampler[i], layer.texture, ctx.textureUnit++); + draw.bindTexture(this._uCubeMapSampler[i], layer.texture, frameCtx.textureUnit++); if (this._uCubeMapIntensity[i]) { this._uCubeMapIntensity[i].setValue(layer.intensity); } @@ -17592,8 +17981,8 @@ SceneJS_ChunkFactory.createChunkType({ } } - if (ctx.textureUnit > 10) { // TODO: Find how many textures allowed - ctx.textureUnit = 0; + if (frameCtx.textureUnit > 10) { // TODO: Find how many textures allowed + frameCtx.textureUnit = 0; } } });SceneJS_ChunkFactory.createChunkType({ @@ -17613,7 +18002,7 @@ SceneJS_ChunkFactory.createChunkType({ this._uNormalMatLocationPick = pick.getUniformLocation("SCENEJS_uMNMatrix"); }, - draw : function(ctx) { + draw : function(frameCtx) { /* Rebuild core's matrix from matrices at cores on path up to root */ @@ -17631,10 +18020,10 @@ SceneJS_ChunkFactory.createChunkType({ gl.uniformMatrix4fv(this._uNormalMatLocationDraw, gl.FALSE, this.core.normalMat); } - ctx.modelMat = this.core.mat; + frameCtx.modelMat = this.core.mat; }, - pick : function(ctx) { + pick : function(frameCtx) { /* Rebuild core's matrix from matrices at cores on path up to root */ @@ -17652,7 +18041,7 @@ SceneJS_ChunkFactory.createChunkType({ gl.uniformMatrix4fv(this._uNormalMatLocationPick, gl.FALSE, this.core.normalMat); } - ctx.modelMat = this.core.mat; + frameCtx.modelMat = this.core.mat; } }); SceneJS.configure({ pluginPath: "http://xeolabs.github.com/scenejs/api/latest/plugins" }); \ No newline at end of file diff --git a/build.js b/build.js index 3ed67711..a4249473 100755 --- a/build.js +++ b/build.js @@ -152,8 +152,10 @@ "src/core/scene/clips.js", "src/core/scene/enable.js", "src/core/scene/flags.js", - "src/core/scene/framebuf.js", + "src/core/scene/colorTarget.js", + "src/core/scene/depthTarget.js", "src/core/scene/geometry.js", + "src/core/scene/stage.js", "src/core/scene/layer.js", "src/core/scene/library.js", "src/core/scene/lights.js", @@ -162,8 +164,8 @@ "src/core/scene/morphGeometry.js", "src/core/scene/name.js", "src/core/scene/renderer.js", - "src/core/scene/depthbuf.js", - "src/core/scene/colorbuf.js", + "src/core/scene/depthBuffer.js", + "src/core/scene/colorBuffer.js", "src/core/scene/view.js", "src/core/scene/scene.js", "src/core/scene/shader.js", @@ -200,7 +202,7 @@ "src/core/display/chunks/clipsChunk.js", "src/core/display/chunks/drawChunk.js", "src/core/display/chunks/flagsChunk.js", - "src/core/display/chunks/framebufChunk.js", + "src/core/display/chunks/renderTargetChunk.js", "src/core/display/chunks/geometryChunk.js", "src/core/display/chunks/lightsChunk.js", "src/core/display/chunks/listenersChunk.js", @@ -209,8 +211,8 @@ "src/core/display/chunks/nameChunk.js", "src/core/display/chunks/programChunk.js", "src/core/display/chunks/rendererChunk.js", - "src/core/display/chunks/depthbufChunk.js", - "src/core/display/chunks/colorbufChunk.js", + "src/core/display/chunks/depthBufferChunk.js", + "src/core/display/chunks/colorBufferChunk.js", "src/core/display/chunks/viewChunk.js", "src/core/display/chunks/shaderChunk.js", "src/core/display/chunks/shaderParamsChunk.js", @@ -253,6 +255,7 @@ var productionBuild = true; var distDir = "api/" + (productionBuild ? "latest" : "dev"); +// var distDir = "/media/lindsay/3d58a38b-6943-4956-9cd2-94656da3c188/xeolabs/human-web6/human-web/lib/scenejs"; var distPluginDir = distDir + "/plugins"; var distExtrasDir = distDir + "/extras"; diff --git a/css/styles.css b/css/styles.css index 939de699..0a5808a9 100644 --- a/css/styles.css +++ b/css/styles.css @@ -661,6 +661,30 @@ h3.feature-category { background: url("../images/bullet-point.png") no-repeat 8px 2px !important; } + +.feature-category-description { + color: #71705a; + text-decoration: none; + font-size: 14px; + padding-top: 4px; + padding-bottom: 4px; + margin-top: 10px; + margin-bottom: 10px; + font-weight: normal; +} + +/*.infoFirst {*/ + /*color: #71705a;*/ + /*text-decoration: none;*/ + /*font-style: italic;*/ + /*font-size: 14px;*/ + /*background-color: aliceblue;*/ + /*padding-top: 4px;*/ + /*padding-bottom: 4px;*/ + /*margin-top: 0;*/ + /*margin-bottom: 4px;*/ +/*}*/ + pre { font-family: 'Droid Sans Mono', 'Courier New', monospace; diff --git a/demos/cameras-pickFlyOrbit-city.html b/demos/cameras-pickFlyOrbit-city.html deleted file mode 100644 index 0c6ffac0..00000000 --- a/demos/cameras-pickFlyOrbit-city.html +++ /dev/null @@ -1,188 +0,0 @@ - - - - SceneJS Example - - - - - - - - -
- SceneJS experimental camera - plugin - -
- - - - \ No newline at end of file diff --git a/demos/cameras-pickFlyOrbit-terrain.html b/demos/cameras-pickFlyOrbit-terrain.html deleted file mode 100644 index 03fb05a3..00000000 --- a/demos/cameras-pickFlyOrbit-terrain.html +++ /dev/null @@ -1,140 +0,0 @@ - - - - SceneJS Example - - - - - - - - -
- SceneJS experimental camera plugin - -
- - - - \ No newline at end of file diff --git a/demos/heightmaps-custom.html b/demos/heightmaps-custom.html deleted file mode 100644 index b46bfbe8..00000000 --- a/demos/heightmaps-custom.html +++ /dev/null @@ -1,108 +0,0 @@ - - - - SceneJS Example - - - - - - - - - - - - \ No newline at end of file diff --git a/demos/heightmaps-snowypeaks.html b/demos/heightmaps-snowypeaks.html deleted file mode 100644 index 196fb180..00000000 --- a/demos/heightmaps-snowypeaks.html +++ /dev/null @@ -1,143 +0,0 @@ - - - - SceneJS Example - - - - - - - - - - - - \ No newline at end of file diff --git a/demos/nodes-custom-tank.html b/demos/nodes-custom-tank.html deleted file mode 100644 index d0749c0a..00000000 --- a/demos/nodes-custom-tank.html +++ /dev/null @@ -1,109 +0,0 @@ - - - - SceneJS Example - - - - - - - - - - - - \ No newline at end of file diff --git a/demos/physics-spheres.html b/demos/physics-spheres.html deleted file mode 100644 index 8d8a244c..00000000 --- a/demos/physics-spheres.html +++ /dev/null @@ -1,224 +0,0 @@ - - - - SceneJS Example - - - - - - - - - - - - - - \ No newline at end of file diff --git a/demos/textures-bumpMap-add.html b/demos/textures-bumpMap-add.html deleted file mode 100644 index 376d0980..00000000 --- a/demos/textures-bumpMap-add.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - SceneJS Example - - - - - - - - - - \ No newline at end of file diff --git a/demos/textures-bumpMap-colorMap.html b/demos/textures-bumpMap-colorMap.html deleted file mode 100644 index c5ba09ac..00000000 --- a/demos/textures-bumpMap-colorMap.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - SceneJS Example - - - - - - - - - - \ No newline at end of file diff --git a/demos/textures-bumpMap-multiply.html b/demos/textures-bumpMap-multiply.html deleted file mode 100644 index 16ec4a40..00000000 --- a/demos/textures-bumpMap-multiply.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - SceneJS Example - - - - - - - - - - \ No newline at end of file diff --git a/demos/textures-glowMap-vertexDisplace.html b/demos/textures-glowMap-vertexDisplace.html deleted file mode 100644 index a7f50cfe..00000000 --- a/demos/textures-glowMap-vertexDisplace.html +++ /dev/null @@ -1,179 +0,0 @@ - - - - SceneJS Example - - - - - - - - - - \ No newline at end of file diff --git a/demos/textures-rtt.html b/demos/textures-rtt.html deleted file mode 100644 index 16f4968a..00000000 --- a/demos/textures-rtt.html +++ /dev/null @@ -1,175 +0,0 @@ - - - - SceneJS Example - - - - - - - - - - - - \ No newline at end of file diff --git a/docs/files.html b/docs/files.html deleted file mode 100644 index 2cc77a37..00000000 --- a/docs/files.html +++ /dev/null @@ -1,1116 +0,0 @@ - - - - - - JsDoc Reference - File Index - - - - - - - - -
-
Class Index -| File Index
-
-

Classes

- -
-
- -
-

File Index

- - -
-

licenses/license-header.js

- -
- - - - -
-
-
- -
-

src/core/canvas.js

- -
- - - - -
-
-
- -
-

src/core/config.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/cameraChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/chunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/chunkFactory.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/clipsChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/drawChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/flagsChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/framebufChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/geometryChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/lightsChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/listenersChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/lookAtChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/materialChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/morphGeometryChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/nameChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/programChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/rendererChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/shaderChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/shaderParamsChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/textureChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/chunks/xformChunk.js

- -
- - - - -
-
-
- -
-

src/core/display/display.js

- -
- - - - -
-
-
- -
-

src/core/display/object.js

- -
- - - - -
-
-
- -
-

src/core/display/objectFactory.js

- -
- - - - -
-
-
- -
-

src/core/display/program.js

- -
- - - - -
-
-
- -
-

src/core/display/programFactory.js

- -
- - - - -
-
-
- -
-

src/core/display/programSource.js

- -
- - - - -
-
-
- -
-

src/core/display/programSourceFactory.js

- -
- - - - -
-
-
- -
-

src/core/display/renderContext.js

- -
- - - - -
-
-
- -
-

src/core/engine.js

- -
- - - - -
-
-
- -
-

src/core/errors.js

- -
- - - - -
-
-
- -
-

src/core/eventManager.js

- -
- - - - -
-
-
- -
-

src/core/events.js

- -
- - - - -
-
-
- -
-

src/core/log.js

- -
- - - - -
-
-
- -
-

src/core/map.js

- -
- - - - -
-
-
- -
-

src/core/math.js

- -
- - - - -
-
-
- -
-

src/core/plugins.js

- -
- - - - -
-
-
- -
-

src/core/scene/camera.js

- -
- - - - -
-
-
- -
-

src/core/scene/clips.js

- -
- - - - -
-
-
- -
-

src/core/scene/core.js

- -
- - - - -
-
-
- -
-

src/core/scene/coreFactory.js

- -
- - - - -
-
-
- -
-

src/core/scene/flags.js

- -
- - - - -
-
-
- -
-

src/core/scene/framebuf.js

- -
- - - - -
-
-
- -
-

src/core/scene/geometry.js

- -
- - - - -
-
-
- -
-

src/core/scene/layer.js

- -
- - - - -
-
-
- -
-

src/core/scene/library.js

- -
- - - - -
-
-
- -
-

src/core/scene/lights.js

- -
- - - - -
-
-
- -
-

src/core/scene/lookAt.js

- -
- - - - -
-
-
- -
-

src/core/scene/material.js

- -
- - - - -
-
-
- -
-

src/core/scene/matrix.js

- -
- - - - -
-
-
- -
-

src/core/scene/modelXFormStack.js

- -
- - - - -
-
-
- -
-

src/core/scene/morphGeometry.js

- -
- - - - -
-
-
- -
-

src/core/scene/name.js

- -
- - - - -
-
-
- -
-

src/core/scene/node.js

- -
- - - - -
-
-
- -
-

src/core/scene/nodeEvents.js

- -
- - - - -
-
-
- -
-

src/core/scene/nodeFactory.js

- -
- - - - -
-
-
- -
-

src/core/scene/renderer.js

- -
- - - - -
-
-
- -
-

src/core/scene/rotate.js

- -
- - - - -
-
-
- -
-

src/core/scene/scale.js

- -
- - - - -
-
-
- -
-

src/core/scene/scene.js

- -
- - - - -
-
-
- -
-

src/core/scene/shader.js

- -
- - - - -
-
-
- -
-

src/core/scene/shaderParams.js

- -
- - - - -
-
-
- -
-

src/core/scene/tag.js

- -
- - - - -
-
-
- -
-

src/core/scene/texture.js

- -
- - - - -
-
-
- -
-

src/core/scene/translate.js

- -
- - - - -
-
-
- -
-

src/core/scene/xform.js

- -
- - - - -
-
-
- -
-

src/core/scenejs.js

- -
- - - - -
-
-
- -
-

src/core/status.js

- -
- - - - -
-
-
- -
-

src/core/webgl-debug-utils.js

- -
- - - - -
-
-
- -
-

src/core/webgl.js

- -
- - - - -
-
-
- - -
-
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - \ No newline at end of file diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 88cc8444..00000000 --- a/docs/index.html +++ /dev/null @@ -1,402 +0,0 @@ - - - - - - JsDoc Reference - Index - - - - - - - - -
-
Class Index -| File Index
-
-

Classes

- -
-
- -
-

Class Index

- - -
-

_global_

- -
-
- -
-

SceneJS.Camera

- Scene graph node which defines the projection transform to apply to the SceneJS.Geometry nodes in its subgraph -
-
- -
-

SceneJS.Clips

- Scene graph node which defines one or more arbitrarily-aligned clip planes to clip the SceneJS.Geometry nodes in its subgraph -
-
- -
-

SceneJS.Flags

- Scene graph node which sets rendering mode flags for its subgraph -
-
- -
-

SceneJS.Framebuf

- Scene graph node which sets up a frame buffer to which the SceneJS.Geometry nodes in its subgraph will be rendered. -
-
- -
-

SceneJS.Geometry

- Scene graph node that defines geometry. -
-
- -
-

SceneJS.Layer

- Scene graph node which assigns the SceneJS.Geometrys within its subgraph to a prioritised render bin -
-
- -
-

SceneJS.Library

- Scene graph node which assigns nodes in its subgraph to a library -
-
- -
-

SceneJS.Lights

- Scene graph node which defines light sources to illuminate the SceneJS.Geometrys within its subgraph -
-
- -
-

SceneJS.Lookat

- Scene graph node which defines the viewing transform for the SceneJS.Geometrys within its subgraph -
-
- -
-

SceneJS.Material

- Scene graph node which defines surface material properties for the SceneJS.Geometrys within its subgraph -
-
- -
-

SceneJS.Matrix

- Scene graph node which defines a modelling transform matrix to apply to the objects in its subgraph -
-
- -
-

SceneJS.MorphGeometry

- Scene graph node which defines morphing behaviour for the SceneJS.Geometrys within its subgraph -
-
- -
-

SceneJS.Name

- Scene graph node which assigns a pick name to the SceneJS.Geometry nodes in its subgraph. -
-
- -
-

SceneJS.Node

- The basic scene graph node type -
-
- -
-

SceneJS.Node#constructor

- Basic scene graph node -
-
- -
-

SceneJS.RenderContext

- A facade which exposes internal scene rendering state to "rendered" event listeners bound to scene graph nodes with SceneJS.Node#bind. -
-
- -
-

SceneJS.Rotate

- Scene graph node which defines a rotation modelling transform to apply to the objects in its subgraph -
-
- -
-

SceneJS.Scale

- Scene graph node which defines a rotation modelling transform to apply to the objects in its subgraph -
-
- -
-

SceneJS.Scene

- The root node of a scenegraph -
-
- -
-

SceneJS.Tag

- Scene graph node which assigns a symbolic tag name to the SceneJS.Geometry nodes in its subgraph. -
-
- -
-

SceneJS.Texture

- Scene graph node which defines one or more textures to apply to the SceneJS.Geometry nodes in its subgraph -
-
- -
-

SceneJS.Translate

- Scene graph node which defines a translation modelling transform to apply to the objects in its subgraph -
-
- -
-

SceneJS.XForm

- Scene graph node which defines the modelling transform to apply to the objects in its subgraph -
-
- -
-

SceneJS_webgl_Program

- Wrapper for a WebGL program -
-
- - -
-
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - \ No newline at end of file diff --git a/docs/symbols/SceneJS.Camera.html b/docs/symbols/SceneJS.Camera.html deleted file mode 100644 index 6d27acae..00000000 --- a/docs/symbols/SceneJS.Camera.html +++ /dev/null @@ -1,498 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Camera - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Camera -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which defines the projection transform to apply to the SceneJS.Geometry nodes in its subgraph - - -
Defined in: camera.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  - -
-
  - -
-
  -
setOptics(optics) -
-
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Camera() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - getMatrix() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getOptics() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - setOptics(optics) - -
-
- - - -
- - - - -
-
Parameters:
- -
- optics - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Clips.html b/docs/symbols/SceneJS.Clips.html deleted file mode 100644 index 3478038c..00000000 --- a/docs/symbols/SceneJS.Clips.html +++ /dev/null @@ -1,430 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Clips - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Clips -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which defines one or more arbitrarily-aligned clip planes to clip the SceneJS.Geometry nodes in its subgraph - - -
Defined in: clips.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  -
setClips(clips) -
-
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Clips() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - setClips(clips) - -
-
- - - -
- - - - -
-
Parameters:
- -
- clips - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Flags.html b/docs/symbols/SceneJS.Flags.html deleted file mode 100644 index 602ff817..00000000 --- a/docs/symbols/SceneJS.Flags.html +++ /dev/null @@ -1,1220 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Flags - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Flags -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which sets rendering mode flags for its subgraph - - -
Defined in: flags.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  -
addFlags(flags) -
-
-
  - -
-
  - -
-
  - -
-
  - -
-
  - -
-
  - -
-
  - -
-
  - -
-
  - -
-
  - -
-
  -
setAmbient(ambient) -
-
-
  -
setBackfaceLighting(backfaceLighting) -
-
-
  -
setBackfaces(backfaces) -
-
-
  -
setBackfaceTexturing(backfaceTexturing) -
-
-
  -
setClipping(clipping) -
-
-
  -
setEnabled(enabled) -
-
-
  -
setFlags(flags) -
-
-
  -
setFrontface(frontface) -
-
-
  -
setPicking(picking) -
-
-
  -
setTransparent(transparent) -
-
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Flags() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - addFlags(flags) - -
-
- - - -
- - - - -
-
Parameters:
- -
- flags - -
-
- -
- - - - - - - - -
- - -
- - - getAmbient() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getBackfaceLighting() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getBackfaces() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getBackfaceTexturing() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getClipping() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getEnabled() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getFlags() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getFrontface() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getPicking() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getTransparent() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - setAmbient(ambient) - -
-
- - - -
- - - - -
-
Parameters:
- -
- ambient - -
-
- -
- - - - - - - - -
- - -
- - - setBackfaceLighting(backfaceLighting) - -
-
- - - -
- - - - -
-
Parameters:
- -
- backfaceLighting - -
-
- -
- - - - - - - - -
- - -
- - - setBackfaces(backfaces) - -
-
- - - -
- - - - -
-
Parameters:
- -
- backfaces - -
-
- -
- - - - - - - - -
- - -
- - - setBackfaceTexturing(backfaceTexturing) - -
-
- - - -
- - - - -
-
Parameters:
- -
- backfaceTexturing - -
-
- -
- - - - - - - - -
- - -
- - - setClipping(clipping) - -
-
- - - -
- - - - -
-
Parameters:
- -
- clipping - -
-
- -
- - - - - - - - -
- - -
- - - setEnabled(enabled) - -
-
- - - -
- - - - -
-
Parameters:
- -
- enabled - -
-
- -
- - - - - - - - -
- - -
- - - setFlags(flags) - -
-
- - - -
- - - - -
-
Parameters:
- -
- flags - -
-
- -
- - - - - - - - -
- - -
- - - setFrontface(frontface) - -
-
- - - -
- - - - -
-
Parameters:
- -
- frontface - -
-
- -
- - - - - - - - -
- - -
- - - setPicking(picking) - -
-
- - - -
- - - - -
-
Parameters:
- -
- picking - -
-
- -
- - - - - - - - -
- - -
- - - setTransparent(transparent) - -
-
- - - -
- - - - -
-
Parameters:
- -
- transparent - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Framebuf.html b/docs/symbols/SceneJS.Framebuf.html deleted file mode 100644 index 51c06287..00000000 --- a/docs/symbols/SceneJS.Framebuf.html +++ /dev/null @@ -1,368 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Framebuf - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Framebuf -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which sets up a frame buffer to which the SceneJS.Geometry nodes in its subgraph will be rendered. -The frame buffer may be referenced as an image source by successive SceneJS.Texture nodes. - - -
Defined in: framebuf.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Framebuf() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Geometry.html b/docs/symbols/SceneJS.Geometry.html deleted file mode 100644 index 52b230e7..00000000 --- a/docs/symbols/SceneJS.Geometry.html +++ /dev/null @@ -1,951 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Geometry - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Geometry -

- - -

- -
Extends - SceneJS.Node -When this node is at a leaf, it defines a scene object which inherits the state set up by all the nodes above it -on the path up to the root. These nodes can be nested, so that child geometries inherit arrays -defined by parent geometries..
- - - Scene graph node that defines geometry. - - -
Defined in: geometry.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  - -
-
  - -
-
  - -
-
  - -
-
  - -
-
  - -
-
  - -
-
  -
getUV() -
-
-
  -
getUV2() -
-
-
  -
setColors(data) -
-
-
  -
setNormals(data) -
-
-
  -
setPositions(data) -
-
-
  -
setSource(sourceConfigs) -
-
-
  -
setUV(data) -
-
-
  -
setUV2(data) -
-
-
- - - - - - - - - -
-
- Class Detail -
- -
- SceneJS.Geometry() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - getBoundary() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getColors() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getIndices() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getNormals() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getPositions() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getPrimitive() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getSource() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getUV() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getUV2() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - setColors(data) - -
-
- - - -
- - - - -
-
Parameters:
- -
- data - -
-
- -
- - - - - - - - -
- - -
- - - setNormals(data) - -
-
- - - -
- - - - -
-
Parameters:
- -
- data - -
-
- -
- - - - - - - - -
- - -
- - - setPositions(data) - -
-
- - - -
- - - - -
-
Parameters:
- -
- data - -
-
- -
- - - - - - - - -
- - -
- - - setSource(sourceConfigs) - -
-
- - - -
- - - - -
-
Parameters:
- -
- sourceConfigs - -
-
- -
- - - - - - - - -
- - -
- - - setUV(data) - -
-
- - - -
- - - - -
-
Parameters:
- -
- data - -
-
- -
- - - - - - - - -
- - -
- - - setUV2(data) - -
-
- - - -
- - - - -
-
Parameters:
- -
- data - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Layer.html b/docs/symbols/SceneJS.Layer.html deleted file mode 100644 index f638e99f..00000000 --- a/docs/symbols/SceneJS.Layer.html +++ /dev/null @@ -1,543 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Layer - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Layer -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which assigns the SceneJS.Geometrys within its subgraph to a prioritised render bin - - -
Defined in: layer.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  - -
-
  - -
-
  -
setEnabled(enabled) -
-
-
  -
setPriority(priority) -
-
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Layer() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - getEnabled() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getPriority() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - setEnabled(enabled) - -
-
- - - -
- - - - -
-
Parameters:
- -
- enabled - -
-
- -
- - - - - - - - -
- - -
- - - setPriority(priority) - -
-
- - - -
- - - - -
-
Parameters:
- -
- priority - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Library.html b/docs/symbols/SceneJS.Library.html deleted file mode 100644 index 8eead211..00000000 --- a/docs/symbols/SceneJS.Library.html +++ /dev/null @@ -1,367 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Library - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Library -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which assigns nodes in its subgraph to a library - - -
Defined in: library.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Library() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Lights.html b/docs/symbols/SceneJS.Lights.html deleted file mode 100644 index d92f381b..00000000 --- a/docs/symbols/SceneJS.Lights.html +++ /dev/null @@ -1,430 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Lights - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Lights -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which defines light sources to illuminate the SceneJS.Geometrys within its subgraph - - -
Defined in: lights.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  -
setLights(lights) -
-
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Lights() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - setLights(lights) - -
-
- - - -
- - - - -
-
Parameters:
- -
- lights - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Lookat.html b/docs/symbols/SceneJS.Lookat.html deleted file mode 100644 index 074555bb..00000000 --- a/docs/symbols/SceneJS.Lookat.html +++ /dev/null @@ -1,1642 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Lookat - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Lookat -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which defines the viewing transform for the SceneJS.Geometrys within its subgraph - - -
Defined in: lookAt.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  - -
-
  -
getEye() -
-
-
  -
getLook() -
-
-
  - -
Returns a copy of the matrix as a 1D array of 16 elements
-
  -
getUp() -
-
-
  -
incEye(eye) -
-
-
  -
incEyeX(x) -
-
-
  -
incEyeY(y) -
-
-
  -
incEyeZ(z) -
-
-
  -
incLook(look) -
-
-
  -
incLookX(x) -
-
-
  -
incLookY(y) -
-
-
  -
incLookZ(z) -
-
-
  -
incUp(up) -
-
-
  -
incUpX(x) -
-
-
  -
incUpY(y) -
-
-
  -
incUpZ(z) -
-
-
  -
setEye(eye) -
-
-
  -
setEyeX(x) -
-
-
  -
setEyeY(y) -
-
-
  -
setEyeZ(z) -
-
-
  -
setLook(look) -
-
-
  -
setLookX(x) -
-
-
  -
setLookY(y) -
-
-
  -
setLookZ(z) -
-
-
  -
setUp(up) -
-
-
  -
setUpX(x) -
-
-
  -
setUpY(y) -
-
-
  -
setUpZ(z) -
-
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Lookat() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - getAttributes() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getEye() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getLook() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - {Number[16]} - getMatrix() - -
-
- Returns a copy of the matrix as a 1D array of 16 elements - - -
- - - - - - - - -
-
Returns:
- -
{Number[16]}
- -
- - - - -
- - -
- - - getUp() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - incEye(eye) - -
-
- - - -
- - - - -
-
Parameters:
- -
- eye - -
-
- -
- - - - - - - - -
- - -
- - - incEyeX(x) - -
-
- - - -
- - - - -
-
Parameters:
- -
- x - -
-
- -
- - - - - - - - -
- - -
- - - incEyeY(y) - -
-
- - - -
- - - - -
-
Parameters:
- -
- y - -
-
- -
- - - - - - - - -
- - -
- - - incEyeZ(z) - -
-
- - - -
- - - - -
-
Parameters:
- -
- z - -
-
- -
- - - - - - - - -
- - -
- - - incLook(look) - -
-
- - - -
- - - - -
-
Parameters:
- -
- look - -
-
- -
- - - - - - - - -
- - -
- - - incLookX(x) - -
-
- - - -
- - - - -
-
Parameters:
- -
- x - -
-
- -
- - - - - - - - -
- - -
- - - incLookY(y) - -
-
- - - -
- - - - -
-
Parameters:
- -
- y - -
-
- -
- - - - - - - - -
- - -
- - - incLookZ(z) - -
-
- - - -
- - - - -
-
Parameters:
- -
- z - -
-
- -
- - - - - - - - -
- - -
- - - incUp(up) - -
-
- - - -
- - - - -
-
Parameters:
- -
- up - -
-
- -
- - - - - - - - -
- - -
- - - incUpX(x) - -
-
- - - -
- - - - -
-
Parameters:
- -
- x - -
-
- -
- - - - - - - - -
- - -
- - - incUpY(y) - -
-
- - - -
- - - - -
-
Parameters:
- -
- y - -
-
- -
- - - - - - - - -
- - -
- - - incUpZ(z) - -
-
- - - -
- - - - -
-
Parameters:
- -
- z - -
-
- -
- - - - - - - - -
- - -
- - - setEye(eye) - -
-
- - - -
- - - - -
-
Parameters:
- -
- eye - -
-
- -
- - - - - - - - -
- - -
- - - setEyeX(x) - -
-
- - - -
- - - - -
-
Parameters:
- -
- x - -
-
- -
- - - - - - - - -
- - -
- - - setEyeY(y) - -
-
- - - -
- - - - -
-
Parameters:
- -
- y - -
-
- -
- - - - - - - - -
- - -
- - - setEyeZ(z) - -
-
- - - -
- - - - -
-
Parameters:
- -
- z - -
-
- -
- - - - - - - - -
- - -
- - - setLook(look) - -
-
- - - -
- - - - -
-
Parameters:
- -
- look - -
-
- -
- - - - - - - - -
- - -
- - - setLookX(x) - -
-
- - - -
- - - - -
-
Parameters:
- -
- x - -
-
- -
- - - - - - - - -
- - -
- - - setLookY(y) - -
-
- - - -
- - - - -
-
Parameters:
- -
- y - -
-
- -
- - - - - - - - -
- - -
- - - setLookZ(z) - -
-
- - - -
- - - - -
-
Parameters:
- -
- z - -
-
- -
- - - - - - - - -
- - -
- - - setUp(up) - -
-
- - - -
- - - - -
-
Parameters:
- -
- up - -
-
- -
- - - - - - - - -
- - -
- - - setUpX(x) - -
-
- - - -
- - - - -
-
Parameters:
- -
- x - -
-
- -
- - - - - - - - -
- - -
- - - setUpY(y) - -
-
- - - -
- - - - -
-
Parameters:
- -
- y - -
-
- -
- - - - - - - - -
- - -
- - - setUpZ(z) - -
-
- - - -
- - - - -
-
Parameters:
- -
- z - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Material.html b/docs/symbols/SceneJS.Material.html deleted file mode 100644 index 5bc87d7c..00000000 --- a/docs/symbols/SceneJS.Material.html +++ /dev/null @@ -1,859 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Material - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Material -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which defines surface material properties for the SceneJS.Geometrys within its subgraph - - -
Defined in: material.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  - -
-
  - -
-
  -
getEmit() -
-
-
  - -
-
  - -
-
  - -
-
  -
setAlpha(alpha) -
-
-
  -
setBaseColor(color) -
-
-
  -
setEmit(emit) -
-
-
  -
setShine(shine) -
-
-
  -
setSpecular(specular) -
-
-
  - -
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Material() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - getAlpha() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getBaseColor() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getEmit() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getShine() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getSpecular() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getSpecularColor() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - setAlpha(alpha) - -
-
- - - -
- - - - -
-
Parameters:
- -
- alpha - -
-
- -
- - - - - - - - -
- - -
- - - setBaseColor(color) - -
-
- - - -
- - - - -
-
Parameters:
- -
- color - -
-
- -
- - - - - - - - -
- - -
- - - setEmit(emit) - -
-
- - - -
- - - - -
-
Parameters:
- -
- emit - -
-
- -
- - - - - - - - -
- - -
- - - setShine(shine) - -
-
- - - -
- - - - -
-
Parameters:
- -
- shine - -
-
- -
- - - - - - - - -
- - -
- - - setSpecular(specular) - -
-
- - - -
- - - - -
-
Parameters:
- -
- specular - -
-
- -
- - - - - - - - -
- - -
- - - setSpecularColor(color) - -
-
- - - -
- - - - -
-
Parameters:
- -
- color - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Matrix.html b/docs/symbols/SceneJS.Matrix.html deleted file mode 100644 index 9ad624f6..00000000 --- a/docs/symbols/SceneJS.Matrix.html +++ /dev/null @@ -1,563 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Matrix - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Matrix -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which defines a modelling transform matrix to apply to the objects in its subgraph - - -
Defined in: matrix.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - - - - - - - - - - - - - - - -
Field Summary
Field AttributesField Name and Description
  - -
Sets the matrix elements
-
- - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  - -
Get Model matrix
-
  - -
Get World matrix.
-
  -
setMatrix(elements) -
-
Sets the matrix elements
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Matrix() -
- -
- - -
- - - - - - - - - - - - -
- - - - -
- Field Detail -
- - -
- - - setElements - -
-
- Sets the matrix elements - - -
- - - - - - - - - - - - - - -
- Method Detail -
- - -
- - {*} - getModelMatrix() - -
-
- Get Model matrix - - -
- - - - - - - - -
-
Returns:
- -
{*}
- -
- - - - -
- - -
- - {*} - getWorldMatrix() - -
-
- Get World matrix. That's the multiplication of this node's Model matrix by the World matrix of the the next -tranform (scale, matrix, translate etc) node on the path to the scene root. - - -
- - - - - - - - -
-
Returns:
- -
{*}
- -
- - - - -
- - -
- - - setMatrix(elements) - -
-
- Sets the matrix elements - - -
- - - - -
-
Parameters:
- -
- elements - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.MorphGeometry.html b/docs/symbols/SceneJS.MorphGeometry.html deleted file mode 100644 index e29ff10d..00000000 --- a/docs/symbols/SceneJS.MorphGeometry.html +++ /dev/null @@ -1,543 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.MorphGeometry - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.MorphGeometry -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which defines morphing behaviour for the SceneJS.Geometrys within its subgraph - - -
Defined in: morphGeometry.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  - -
-
  - -
-
  -
setFactor(factor) -
-
-
  -
setSource(sourceConfigs) -
-
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.MorphGeometry() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - getFactor() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getSource() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - setFactor(factor) - -
-
- - - -
- - - - -
-
Parameters:
- -
- factor - -
-
- -
- - - - - - - - -
- - -
- - - setSource(sourceConfigs) - -
-
- - - -
- - - - -
-
Parameters:
- -
- sourceConfigs - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Name.html b/docs/symbols/SceneJS.Name.html deleted file mode 100644 index 964a8806..00000000 --- a/docs/symbols/SceneJS.Name.html +++ /dev/null @@ -1,464 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Name - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Name -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which assigns a pick name to the SceneJS.Geometry nodes in its subgraph. - - -
Defined in: name.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  -
- SceneJS.Name() -
-
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  -
getName() -
-
-
  -
setName(name) -
-
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Name() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - getName() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - setName(name) - -
-
- - - -
- - - - -
-
Parameters:
- -
- name - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Node#constructor.html b/docs/symbols/SceneJS.Node#constructor.html deleted file mode 100644 index a277e8f2..00000000 --- a/docs/symbols/SceneJS.Node#constructor.html +++ /dev/null @@ -1,347 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Node#constructor - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Node#constructor -

- - -

- - - - Basic scene graph node - - -
Defined in: node.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - - - - - -
-
- Class Detail -
- -
- SceneJS.Node#constructor() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Node.html b/docs/symbols/SceneJS.Node.html deleted file mode 100644 index f5fba29b..00000000 --- a/docs/symbols/SceneJS.Node.html +++ /dev/null @@ -1,2757 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Node - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Node -

- - -

- - - - The basic scene graph node type - - -
Defined in: node.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  -
- SceneJS.Node() -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Field Summary
Field AttributesField Name and Description
  - -
-
  -
- data -
-
Optional arbitrary JSON object attached to this node
-
  -
- dirty -
-
-
  -
- id -
-
ID of this node, unique within its scene.
-
  -
- nodes -
-
Child nodes
-
  -
- parent -
-
Parent node
-
  -
- type -
-
Type of this node (eg.
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  -
add(attr, value) -
-
-
  -
addListener(eventName, fn, options) -
-
Registers a listener for a given event on this node.
-
  -
addNode(node) -
-
Appends a child node
-
  -
addNodes(nodes) -
-
Appends multiple child nodes
-
  -
bind(name, handler) -
-
Binds a listener to an event on the selected node
-
  -
destroy() -
-
Destroys this node.
-
  -
disconnect(id) -
-
Disconnects the child node from its parent, given as a node object
-
  - -
Disconnects the child node at the given index from its parent node
-
  - -
Disconnects all child nodes from their parent node and returns them in an array.
-
  -
eachNode(fn, options) -
-
Iterates over sub-nodes of the selected node, executing a function -for each.
-
  -
eachParent(fn) -
-
Iterates over parent nodes on the path from the selected node to the root, executing a function -for each.
-
  -
findNodesByType(type, recursive) -
-
Returns either all child or all sub-nodes of the given type, depending on whether search is recursive or not.
-
  - -
Finds the first node on path up to root whose type equals that given
-
  -
get(attr) -
-
-
  - -
Returns the ID of this node's core
-
  -
getData() -
-
Returns the data object attached to this node.
-
  - -
Returns first child node.
-
  -
getId() -
-
Alias for getID
-
  -
getID() -
-
Get the node's ID
-
  -
getJSON() -
-
Returns an object containing the attributes that were given when creating the node.
-
  - -
Returns last child node.
-
  -
getNode(id) -
-
Returns child node with the given ID.
-
  -
getNodeAt(index) -
-
Returns child node at given index.
-
  - -
Alias for getID
-
  - -
Returns child nodes
-
  - -
Returns the number of child nodes
-
  - -
Returns the parent node
-
  - -
Returns this node's SceneJS.Scene
-
  -
getType() -
-
Returns the node's type.
-
  -
hasListener(eventName) -
-
Returns true if this node has any listeners for the given event
-
  - -
Returns true if this node has any listeners at all.
-
  -
hasNode(node) -
-
Returns true if a child node matching given ID or index exists on this node
-
  -
inc(attr, value) -
-
-
  -
insert(attr, value) -
-
-
  -
insertNode(node, i) -
-
Inserts a subgraph into child nodes
-
  -
mapNodes(func) -
-
Calls the given function on each node in the subgraph rooted by this node, including this node.
-
  -
node(node) -
-
Selects a child node matching given ID or index
-
  - -
-
  -
remove(attr, value) -
-
-
  -
removeListener(eventName, fn) -
-
Removes a handler that is registered for the given event on this node.
-
  - -
Removes all listeners registered on this node.
-
  -
removeNode(id) -
-
Removes the child node, given as either a node object or an ID string.
-
  -
removeNodeAt(index) -
-
Removes the child node at the given index
-
  - -
Removes all child nodes and returns them in an array.
-
  -
set(attr, value) -
-
Given a map of name-value pairs, calls a getter method for each name, -feeding into it the corresponding value.
-
  -
setData(data) -
-
Sets a data object on this node.
-
  -
splice() -
-
Destroys this node and moves children up to parent, inserting them where this node resided.
-
  -
unbind(name, handler) -
-
Unbinds a listener for an event on the selected node
-
- - - - - - - - - -
-
- Class Detail -
- -
- SceneJS.Node() -
- -
- - -
- - - - - - - - - - - - -
- - - - -
- Field Detail -
- - -
- - - branchDirty - -
-
- - - -
- - - - - - - - -
- - -
- - {JSON} - data - -
-
- Optional arbitrary JSON object attached to this node - - -
- - - - - - - - -
- - -
- - - dirty - -
-
- - - -
- - - - - - - - -
- - -
- - {String|Number} - id - -
-
- ID of this node, unique within its scene. The ID is a string if it was defined by the application -via the node's JSON configuration, otherwise it is a number if it was left to SceneJS to automatically create. - - -
- - - - - - - - -
- - -
- - {SceneJS.Node[]} - nodes - -
-
- Child nodes - - -
- - - - - - - - -
- - -
- - {SceneJS.Node} - parent - -
-
- Parent node - - -
- - - - - - - - -
- - -
- - {String} - type - -
-
- Type of this node (eg. "material", "texture" etc) - - -
- - - - - - - - - - - - - - -
- Method Detail -
- - -
- - - add(attr, value) - -
-
- - - -
- - - - -
-
Parameters:
- -
- attr - -
-
- -
- value - -
-
- -
- - - - - - - - -
- - -
- - {Node} - addListener(eventName, fn, options) - -
-
- Registers a listener for a given event on this node. If the event type -is not supported by this node type, then the listener will never be called. -

Example: -


-var node = new Node();
-
-node.addListener(
-
-             // eventName
-             "some-event",
-
-             // handler
-             function(node,      // Node we are listening to
-                      params) {  // Whatever params accompany the event type
-
-                    // ...
-             }
-);
-
-
-
- - -
- - - - -
-
Parameters:
- -
- {String} eventName - -
-
One of the event types supported by this node
- -
- {Function} fn - -
-
- Handler function that be called as specified
- -
- options - -
-
- Optional options for the handler as specified
- -
- - - - - -
-
Returns:
- -
{Node} this
- -
- - - - -
- - -
- - - addNode(node) - -
-
- Appends a child node - - -
- - - - -
-
Parameters:
- -
- node - -
-
- -
- - - - - - - - -
- - -
- - - addNodes(nodes) - -
-
- Appends multiple child nodes - - -
- - - - -
-
Parameters:
- -
- nodes - -
-
- -
- - - - - - - - -
- - -
- - - bind(name, handler) - -
-
- Binds a listener to an event on the selected node - - -
- - - - -
-
Parameters:
- -
- {String} name - -
-
Event name
- -
- {Function} handler - -
-
Event handler
- -
- - - - - - - - -
- - -
- - - destroy() - -
-
- Destroys this node. It is marked for destruction; when the next scene traversal begins (or the current one ends) -it will be destroyed and removed from it's parent. - - -
- - - - - - - - - - - -
- - -
- - {Node} - disconnect(id) - -
-
- Disconnects the child node from its parent, given as a node object - - -
- - - - -
-
Parameters:
- -
- {String | Node} id - -
-
The target child node, or its ID
- -
- - - - - -
-
Returns:
- -
{Node} The removed child node if located
- -
- - - - -
- - -
- - {Node} - disconnectNodeAt(index) - -
-
- Disconnects the child node at the given index from its parent node - - -
- - - - -
-
Parameters:
- -
- {int} index - -
-
Child node index
- -
- - - - - -
-
Returns:
- -
{Node} The disconnected child node if located, else null
- -
- - - - -
- - -
- - - disconnectNodes() - -
-
- Disconnects all child nodes from their parent node and returns them in an array. - - -
- - - - - - - - - - - -
- - -
- - {Object} - eachNode(fn, options) - -
-
- Iterates over sub-nodes of the selected node, executing a function -for each. With the optional options object we can configure is depth-first or breadth-first order. -If neither, then only the child nodes are iterated. -If the function returns true at any node, then traversal stops and a selector is -returned for that node. - - -
- - - - -
-
Parameters:
- -
- {Function(index|node)} fn - -
-
Function to execute on each child node
- -
- options - -
-
- -
- - - - - -
-
Returns:
- -
{Object} Selector for selected node, if any
- -
- - - - -
- - -
- - {Object} - eachParent(fn) - -
-
- Iterates over parent nodes on the path from the selected node to the root, executing a function -for each. -If the function returns true at any node, then traversal stops and a selector is -returned for that node. - - -
- - - - -
-
Parameters:
- -
- {Function(node|index)} fn - -
-
Function to execute on each instance node
- -
- - - - - -
-
Returns:
- -
{Object} Selector for selected node, if any
- -
- - - - -
- - -
- - - findNodesByType(type, recursive) - -
-
- Returns either all child or all sub-nodes of the given type, depending on whether search is recursive or not. - - -
- - - - -
-
Parameters:
- -
- type - -
-
- -
- recursive - -
-
- -
- - - - - - - - -
- - -
- - - findParentByType(type) - -
-
- Finds the first node on path up to root whose type equals that given - - -
- - - - -
-
Parameters:
- -
- type - -
-
- -
- - - - - - - - -
- - -
- - - get(attr) - -
-
- - - -
- - - - -
-
Parameters:
- -
- attr - -
-
- -
- - - - - - - - -
- - -
- - - getCoreId() - -
-
- Returns the ID of this node's core - - -
- - - - - - - - - - - -
- - -
- - - getData() - -
-
- Returns the data object attached to this node. - - -
- - - - - - - - - - - -
- - -
- - {Node} - getFirstNode() - -
-
- Returns first child node. Returns null if no child nodes. - - -
- - - - - - - - -
-
Returns:
- -
{Node} First child node, or null if not found
- -
- - - - -
- - -
- - - getId() - -
-
- Alias for getID - - -
- - - - - - - - - - - -
- - -
- - - getID() - -
-
- Get the node's ID - - -
- - - - - - - - - - - -
- - -
- - - getJSON() - -
-
- Returns an object containing the attributes that were given when creating the node. Obviously, the map will have -the current values, plus any attributes that were later added through set/add methods on the node - - -
- - - - - - - - - - - -
- - -
- - {Node} - getLastNode() - -
-
- Returns last child node. Returns null if no child nodes. - - -
- - - - - - - - -
-
Returns:
- -
{Node} Last child node, or null if not found
- -
- - - - -
- - -
- - - getNode(id) - -
-
- Returns child node with the given ID. -Returns null if no such child node found. - - -
- - - - -
-
Parameters:
- -
- id - -
-
- -
- - - - - - - - -
- - -
- - {Node} - getNodeAt(index) - -
-
- Returns child node at given index. Returns null if no node at that index. - - -
- - - - -
-
Parameters:
- -
- {Number} index - -
-
The child index
- -
- - - - - -
-
Returns:
- -
{Node} Child node, or null if not found
- -
- - - - -
- - -
- - - getNodeId() - -
-
- Alias for getID - - -
- - - - - - - - - - - -
- - -
- - {Array} - getNodes() - -
-
- Returns child nodes - - -
- - - - - - - - -
-
Returns:
- -
{Array} Child nodes
- -
- - - - -
- - -
- - - getNumNodes() - -
-
- Returns the number of child nodes - - -
- - - - - - - - - - - -
- - -
- - - getParent() - -
-
- Returns the parent node - - -
- - - - - - - - - - - -
- - -
- - - getScene() - -
-
- Returns this node's SceneJS.Scene - - -
- - - - - - - - - - - -
- - -
- - - getType() - -
-
- Returns the node's type. For the Node base class, it is "node", overridden in sub-classes. - - -
- - - - - - - - - - - -
- - -
- - - hasListener(eventName) - -
-
- Returns true if this node has any listeners for the given event - - -
- - - - -
-
Parameters:
- -
- eventName - -
-
- -
- - - - - - - - -
- - -
- - - hasListeners() - -
-
- Returns true if this node has any listeners at all. - - -
- - - - - - - - - - - -
- - -
- - - hasNode(node) - -
-
- Returns true if a child node matching given ID or index exists on this node - - -
- - - - -
-
Parameters:
- -
- {Number|String} node - -
-
Child node index or ID
- -
- - - - - - - - -
- - -
- - - inc(attr, value) - -
-
- - - -
- - - - -
-
Parameters:
- -
- attr - -
-
- -
- value - -
-
- -
- - - - - - - - -
- - -
- - - insert(attr, value) - -
-
- - - -
- - - - -
-
Parameters:
- -
- attr - -
-
- -
- value - -
-
- -
- - - - - - - - -
- - -
- - {Node} - insertNode(node, i) - -
-
- Inserts a subgraph into child nodes - - -
- - - - -
-
Parameters:
- -
- {Node} node - -
-
Child node
- -
- {int} i - -
-
Index for new child node
- -
- - - - - -
-
Returns:
- -
{Node} The child node
- -
- - - - -
- - -
- - - mapNodes(func) - -
-
- Calls the given function on each node in the subgraph rooted by this node, including this node. -The callback takes each node as it's sole argument and traversal stops as soon as the function returns -true and returns the node. - - -
- - - - -
-
Parameters:
- -
- {function(Node)} func - -
-
The function
- -
- - - - - - - - -
- - -
- - - node(node) - -
-
- Selects a child node matching given ID or index - - -
- - - - -
-
Parameters:
- -
- {Number|String} node - -
-
Child node index or ID
- -
- - - - - - - - -
- - -
- - - numNodes() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - remove(attr, value) - -
-
- - - -
- - - - -
-
Parameters:
- -
- attr - -
-
- -
- value - -
-
- -
- - - - - - - - -
- - -
- - - removeListener(eventName, fn) - -
-
- Removes a handler that is registered for the given event on this node. -Does nothing if no such handler registered. - - -
- - - - -
-
Parameters:
- -
- eventName - -
-
- -
- fn - -
-
- -
- - - - - - - - -
- - -
- - - removeListeners() - -
-
- Removes all listeners registered on this node. - - -
- - - - - - - - - - - -
- - -
- - {Node} - removeNode(id) - -
-
- Removes the child node, given as either a node object or an ID string. - - -
- - - - -
-
Parameters:
- -
- {String | Node} id - -
-
The target child node, or its ID
- -
- - - - - -
-
Returns:
- -
{Node} The removed child node if located
- -
- - - - -
- - -
- - - removeNodeAt(index) - -
-
- Removes the child node at the given index - - -
- - - - -
-
Parameters:
- -
- {int} index - -
-
Child node index
- -
- - - - - - - - -
- - -
- - - removeNodes() - -
-
- Removes all child nodes and returns them in an array. - - -
- - - - - - - - - - - -
- - -
- - {*} - set(attr, value) - -
-
- Given a map of name-value pairs, calls a getter method for each name, -feeding into it the corresponding value. - - -
- - - - -
-
Parameters:
- -
- attr - -
-
- -
- value - -
-
- -
- - - - - -
-
Returns:
- -
{*}
- -
- - - - -
- - -
- - - setData(data) - -
-
- Sets a data object on this node. - - -
- - - - -
-
Parameters:
- -
- data - -
-
- -
- - - - - - - - -
- - -
- - - splice() - -
-
- Destroys this node and moves children up to parent, inserting them where this node resided. - - -
- - - - - - - - - - - -
- - -
- - - unbind(name, handler) - -
-
- Unbinds a listener for an event on the selected node - - -
- - - - -
-
Parameters:
- -
- {String} name - -
-
Event name
- -
- {Function} handler - -
-
Event handler
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.RenderContext.html b/docs/symbols/SceneJS.RenderContext.html deleted file mode 100644 index 69190523..00000000 --- a/docs/symbols/SceneJS.RenderContext.html +++ /dev/null @@ -1,729 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.RenderContext - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.RenderContext -

- - -

- - - - A facade which exposes internal scene rendering state to "rendered" event listeners bound to scene graph nodes with SceneJS.Node#bind. - -

The listener is fired for each SceneJS.Geometry that is rendered within the subgraph of the bound node. -An instance of this facade is passed into the listener's handler, enabling the listener to obtain the various transform -matrices that are active at that SceneJS.Geometry.

- -

The facade instance is only valid within the callback's execution; internally, SceneJS reuses the same instance of the -facade with each scene.

- - -
Defined in: renderContext.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  -
- SceneJS.RenderContext(frameCtx) -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  - -
Get the projection matrix, as defined by the active SceneJS.Camera node.
-
  -
getCameraPos(offset) -
-
Transforms the given world coordinate by the model and view matrices defined by the active SceneJS.XForm and SceneJS.LookAt nodes.
-
  -
getCanvasPos(offset) -
-
Transforms the given world coordinate by the model, view and projection matrices defined by the active SceneJS.XForm, SceneJS.LookAt and SceneJS.Camera nodes.
-
  - -
Get the model matrix, as defined by the active SceneJS.XForm node.
-
  -
getProjPos(offset) -
-
-
  - -
Get the view matrix, as defined by the active SceneJS.LookAt node.
-
  -
getViewPos(offset) -
-
-
  -
getWorldPos(offset) -
-
-
- - - - - - - - - -
-
- Class Detail -
- -
- SceneJS.RenderContext(frameCtx) -
- -
- - -
- - - - - -
-
Parameters:
- -
- frameCtx - -
-
- -
- - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - getCameraMatrix() - -
-
- Get the projection matrix, as defined by the active SceneJS.Camera node. - - -
- - - - - - - - - - - -
- - -
- - - getCameraPos(offset) - -
-
- Transforms the given world coordinate by the model and view matrices defined by the active SceneJS.XForm and SceneJS.LookAt nodes. - - -
- - - - -
-
Parameters:
- -
- offset - -
-
- -
- - - - - -
-
Returns:
- -
[Number] The 3D Projection-space coordinate
- -
- - - - -
- - -
- - - getCanvasPos(offset) - -
-
- Transforms the given world coordinate by the model, view and projection matrices defined by the active SceneJS.XForm, SceneJS.LookAt and SceneJS.Camera nodes. - - -
- - - - -
-
Parameters:
- -
- offset - -
-
- -
- - - - - -
-
Returns:
- -
[Number] The 2D Canvas-space coordinate
- -
- - - - -
- - -
- - - getModelMatrix() - -
-
- Get the model matrix, as defined by the active SceneJS.XForm node. - - -
- - - - - - - - - - - -
- - -
- - - getProjPos(offset) - -
-
- - - -
- - - - -
-
Parameters:
- -
- offset - -
-
- -
- - - - - - - - -
- - -
- - - getViewMatrix() - -
-
- Get the view matrix, as defined by the active SceneJS.LookAt node. - - -
- - - - - - - - - - - -
- - -
- - - getViewPos(offset) - -
-
- - - -
- - - - -
-
Parameters:
- -
- offset - -
-
- -
- - - - - - - - -
- - -
- - - getWorldPos(offset) - -
-
- - - -
- - - - -
-
Parameters:
- -
- offset - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Rotate.html b/docs/symbols/SceneJS.Rotate.html deleted file mode 100644 index 5eff20b9..00000000 --- a/docs/symbols/SceneJS.Rotate.html +++ /dev/null @@ -1,955 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Rotate - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Rotate -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which defines a rotation modelling transform to apply to the objects in its subgraph - - -
Defined in: rotate.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  - -
-
  - -
Get Model matrix
-
  - -
Get World matrix.
-
  -
getX() -
-
-
  -
getXYZ() -
-
-
  -
getY() -
-
-
  -
getZ() -
-
-
  -
incAngle(angle) -
-
-
  -
setAngle(angle) -
-
-
  -
setMultOrder(multOrder) -
-
Sets the multiplication order of this node's transform matrix with respect to the parent modeling transform -in the scene graph.
-
  -
setX(x) -
-
-
  -
setXYZ(xyz) -
-
-
  -
setY(y) -
-
-
  -
setZ(z) -
-
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Rotate() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - getAngle() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - {*} - getModelMatrix() - -
-
- Get Model matrix - - -
- - - - - - - - -
-
Returns:
- -
{*}
- -
- - - - -
- - -
- - {*} - getWorldMatrix() - -
-
- Get World matrix. That's the multiplication of this node's Model matrix by the World matrix of the the next -tranform (scale, rotate, translate etc) node on the path to the scene root. - - -
- - - - - - - - -
-
Returns:
- -
{*}
- -
- - - - -
- - -
- - - getX() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getXYZ() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getY() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getZ() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - incAngle(angle) - -
-
- - - -
- - - - -
-
Parameters:
- -
- angle - -
-
- -
- - - - - - - - -
- - -
- - - setAngle(angle) - -
-
- - - -
- - - - -
-
Parameters:
- -
- angle - -
-
- -
- - - - - - - - -
- - -
- - - setMultOrder(multOrder) - -
-
- Sets the multiplication order of this node's transform matrix with respect to the parent modeling transform -in the scene graph. - - -
- - - - -
-
Parameters:
- -
- {String} multOrder - -
-
Mulplication order - "post" and "pre"
- -
- - - - - - - - -
- - -
- - - setX(x) - -
-
- - - -
- - - - -
-
Parameters:
- -
- x - -
-
- -
- - - - - - - - -
- - -
- - - setXYZ(xyz) - -
-
- - - -
- - - - -
-
Parameters:
- -
- xyz - -
-
- -
- - - - - - - - -
- - -
- - - setY(y) - -
-
- - - -
- - - - -
-
Parameters:
- -
- y - -
-
- -
- - - - - - - - -
- - -
- - - setZ(z) - -
-
- - - -
- - - - -
-
Parameters:
- -
- z - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Scale.html b/docs/symbols/SceneJS.Scale.html deleted file mode 100644 index 04aac2d9..00000000 --- a/docs/symbols/SceneJS.Scale.html +++ /dev/null @@ -1,1000 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Scale - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Scale -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which defines a rotation modelling transform to apply to the objects in its subgraph - - -
Defined in: scale.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  - -
-
  - -
Get Model matrix
-
  - -
Get World matrix.
-
  -
getX() -
-
-
  -
getXYZ() -
-
-
  -
getY() -
-
-
  -
getZ() -
-
-
  -
incX(x) -
-
-
  -
incY(y) -
-
-
  -
incZ(z) -
-
-
  -
setMultOrder(multOrder) -
-
Sets the multiplication order of this node's transform matrix with respect to the parent modeling transform -in the scene graph.
-
  -
setX(x) -
-
-
  -
setXYZ(xyz) -
-
-
  -
setY(y) -
-
-
  -
setZ(z) -
-
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Scale() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - getAngle() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - {*} - getModelMatrix() - -
-
- Get Model matrix - - -
- - - - - - - - -
-
Returns:
- -
{*}
- -
- - - - -
- - -
- - {*} - getWorldMatrix() - -
-
- Get World matrix. That's the multiplication of this node's Model matrix by the World matrix of the the next -tranform (scale, scale, translate etc) node on the path to the scene root. - - -
- - - - - - - - -
-
Returns:
- -
{*}
- -
- - - - -
- - -
- - - getX() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getXYZ() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getY() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getZ() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - incX(x) - -
-
- - - -
- - - - -
-
Parameters:
- -
- x - -
-
- -
- - - - - - - - -
- - -
- - - incY(y) - -
-
- - - -
- - - - -
-
Parameters:
- -
- y - -
-
- -
- - - - - - - - -
- - -
- - - incZ(z) - -
-
- - - -
- - - - -
-
Parameters:
- -
- z - -
-
- -
- - - - - - - - -
- - -
- - - setMultOrder(multOrder) - -
-
- Sets the multiplication order of this node's transform matrix with respect to the parent modeling transform -in the scene graph. - - -
- - - - -
-
Parameters:
- -
- {String} multOrder - -
-
Mulplication order - "post" and "pre"
- -
- - - - - - - - -
- - -
- - - setX(x) - -
-
- - - -
- - - - -
-
Parameters:
- -
- x - -
-
- -
- - - - - - - - -
- - -
- - - setXYZ(xyz) - -
-
- - - -
- - - - -
-
Parameters:
- -
- xyz - -
-
- -
- - - - - - - - -
- - -
- - - setY(y) - -
-
- - - -
- - - - -
-
Parameters:
- -
- y - -
-
- -
- - - - - - - - -
- - -
- - - setZ(z) - -
-
- - - -
- - - - -
-
Parameters:
- -
- z - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Scene.html b/docs/symbols/SceneJS.Scene.html deleted file mode 100644 index f7974668..00000000 --- a/docs/symbols/SceneJS.Scene.html +++ /dev/null @@ -1,1287 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Scene - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Scene -

- - -

- -
Extends - SceneJS.Node.
- - - The root node of a scenegraph - - -
Defined in: scene.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  -
containsNode(nodeId) -
-
Determines if node exists in this scene
-
  -
findNode(nodeId) -
-
Finds the node with the given ID in this scene
-
  -
findNodes(nodeIdRegex) -
-
Finds nodes in this scene that have nodes IDs matching the given regular expression
-
  - -
Returns the HTML canvas for this scene
-
  -
getGL() -
-
Returns the WebGL context for this scene
-
  -
getNode(nodeId) -
-
-
  - -
Returns the current status of this scene.
-
  - -
Gets the regular expression which will select which of the scene subgraphs that are rooted by SceneJS.Tag nodes are included in scene renders
-
  - -
Returns the Z-buffer depth in bits of the webgl context that this scene is to bound to.
-
  - -
Returns true if scene active, ie.
-
  - -
Returns true if the scene's render loop is currently running.
-
  - -
Simulate a lost WebGL context for testing purposes.
-
  -
onEvent(type, callback) -
-
Subscribes to an event on this scene
-
  -
pause(doPause) -
-
Pauses/unpauses current render loop that was started with #start.
-
  -
pick(canvasX, canvasY, options) -
-
Picks whatever geometry will be rendered at the given canvas coordinates.
-
  -
renderFrame(params) -
-
Render a single frame if new frame pending, or force a new frame -Returns true if frame rendered
-
  -
setTagMask(tagMask) -
-
Sets a regular expression to select which of the scene subgraphs that are rooted by SceneJS.Tag nodes are included in scene renders
-
  -
start(params) -
-
Starts the render loop for this scene
-
  -
stop() -
-
Stops current render loop that was started with #start.
-
  -
unEvent(handle) -
-
Unsubscribes to an event previously subscribed to on scene
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Scene() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - containsNode(nodeId) - -
-
- Determines if node exists in this scene - - -
- - - - -
-
Parameters:
- -
- nodeId - -
-
- -
- - - - - - - - -
- - -
- - {SceneJS.Node} - findNode(nodeId) - -
-
- Finds the node with the given ID in this scene - - -
- - - - -
-
Parameters:
- -
- nodeId - -
-
- -
- - - - - -
-
Returns:
- -
{SceneJS.Node} The node if found, else null
- -
- - - - -
- - -
- - {[SceneJS.Node]} - findNodes(nodeIdRegex) - -
-
- Finds nodes in this scene that have nodes IDs matching the given regular expression - - -
- - - - -
-
Parameters:
- -
- {String} nodeIdRegex - -
-
Regular expression to match on node IDs
- -
- - - - - -
-
Returns:
- -
{[SceneJS.Node]} Array of nodes whose IDs match the given regex
- -
- - - - -
- - -
- - {HTMLCanvas} - getCanvas() - -
-
- Returns the HTML canvas for this scene - - -
- - - - - - - - -
-
Returns:
- -
{HTMLCanvas} The canvas
- -
- - - - -
- - -
- - - getGL() - -
-
- Returns the WebGL context for this scene - - -
- - - - - - - - - - - -
- - -
- - {SceneJS.Node} - getNode(nodeId) - -
-
- - - -
- - - - -
-
Parameters:
- -
- nodeId - -
-
- -
- - - - - -
-
Returns:
- -
{SceneJS.Node} The node if found, else null
- -
- - - - -
- - -
- - - getStatus() - -
-
- Returns the current status of this scene. - -When the scene has been destroyed, the returned status will be a map like this: - -{ - destroyed: true -} - -Otherwise, the status will be: - -{ - numTasks: Number // Number of asset loads (eg. texture, geometry stream etc.) currently in progress -} - - -
- - - - - - - - - - - -
- - -
- - {String} - getTagMask() - -
-
- Gets the regular expression which will select which of the scene subgraphs that are rooted by SceneJS.Tag nodes are included in scene renders - - -
- - - - - - - - -
-
Returns:
- -
{String} Regular expression string that will be matched on the tag attributes of SceneJS.Tag nodes
- -
- - - -
-
See:
- -
#setTagMask
- -
SceneJS.Tag
- -
- - -
- - -
- - - getZBufferDepth() - -
-
- Returns the Z-buffer depth in bits of the webgl context that this scene is to bound to. - - -
- - - - - - - - - - - -
- - -
- - - isActive() - -
-
- Returns true if scene active, ie. not destroyed. A destroyed scene becomes active again -when you render it. - - -
- - - - - - - - - - - -
- - -
- - {Boolean} - isRunning() - -
-
- Returns true if the scene's render loop is currently running. - - -
- - - - - - - - -
-
Returns:
- -
{Boolean} True when scene render loop is running
- -
- - - - -
- - -
- - - loseWebGLContext() - -
-
- Simulate a lost WebGL context for testing purposes. -Only works if the simulateWebGLLost was given as an option to SceneJS.createScene. - - -
- - - - - - - - - - - -
- - -
- - {String} - onEvent(type, callback) - -
-
- Subscribes to an event on this scene - - -
- - - - -
-
Parameters:
- -
- {String} type - -
-
Event type
- -
- {Function} callback - -
-
Callback that will be called with the event parameters
- -
- - - - - -
-
Returns:
- -
{String} handle Handle to the subcription
- -
- - - - -
- - -
- - - pause(doPause) - -
-
- Pauses/unpauses current render loop that was started with #start. After this, #isRunning will return false. - - -
- - - - -
-
Parameters:
- -
- {Boolean} doPause - -
-
Indicates whether to pause or unpause the render loop
- -
- - - - - - - - -
- - -
- - - pick(canvasX, canvasY, options) - -
-
- Picks whatever geometry will be rendered at the given canvas coordinates. - - -
- - - - -
-
Parameters:
- -
- canvasX - -
-
- -
- canvasY - -
-
- -
- options - -
-
- -
- - - - - - - - -
- - -
- - - renderFrame(params) - -
-
- Render a single frame if new frame pending, or force a new frame -Returns true if frame rendered - - -
- - - - -
-
Parameters:
- -
- params - -
-
- -
- - - - - - - - -
- - -
- - - setTagMask(tagMask) - -
-
- Sets a regular expression to select which of the scene subgraphs that are rooted by SceneJS.Tag nodes are included in scene renders - - -
- - - - -
-
Parameters:
- -
- {String} tagMask - -
-
Regular expression string to match on the tag attributes of SceneJS.Tag nodes
- -
- - - - - - - -
-
See:
- -
#getTagMask
- -
SceneJS.Tag
- -
- - -
- - -
- - - start(params) - -
-
- Starts the render loop for this scene - - -
- - - - -
-
Parameters:
- -
- params - -
-
- -
- - - - - - - - -
- - -
- - - stop() - -
-
- Stops current render loop that was started with #start. After this, #isRunning will return false. - - -
- - - - - - - - - - - -
- - -
- - - unEvent(handle) - -
-
- Unsubscribes to an event previously subscribed to on scene - - -
- - - - -
-
Parameters:
- -
- {String} handle - -
-
Subscription handle
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Tag.html b/docs/symbols/SceneJS.Tag.html deleted file mode 100644 index 0fbe501e..00000000 --- a/docs/symbols/SceneJS.Tag.html +++ /dev/null @@ -1,465 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Tag - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Tag -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which assigns a symbolic tag name to the SceneJS.Geometry nodes in its subgraph. -The subgraph can then be included or excluded from scene rendering using SceneJS.Scene#setTagMask. - - -
Defined in: tag.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  -
- SceneJS.Tag() -
-
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  -
getTag() -
-
-
  -
setTag(tag) -
-
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Tag() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - getTag() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - setTag(tag) - -
-
- - - -
- - - - -
-
Parameters:
- -
- tag - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Texture.html b/docs/symbols/SceneJS.Texture.html deleted file mode 100644 index 69654868..00000000 --- a/docs/symbols/SceneJS.Texture.html +++ /dev/null @@ -1,475 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Texture - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Texture -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which defines one or more textures to apply to the SceneJS.Geometry nodes in its subgraph - - -
Defined in: texture.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  -
setLayer(cfg) -
-
Set some writeable properties on a layer
-
  -
setLayers(layers) -
-
Set some writeable properties on multiple layers
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Texture() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - setLayer(cfg) - -
-
- Set some writeable properties on a layer - - -
- - - - -
-
Parameters:
- -
- cfg - -
-
- -
- - - - - - - - -
- - -
- - - setLayers(layers) - -
-
- Set some writeable properties on multiple layers - - -
- - - - -
-
Parameters:
- -
- layers - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.Translate.html b/docs/symbols/SceneJS.Translate.html deleted file mode 100644 index 97e881ad..00000000 --- a/docs/symbols/SceneJS.Translate.html +++ /dev/null @@ -1,966 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.Translate - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.Translate -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which defines a translation modelling transform to apply to the objects in its subgraph - - -
Defined in: translate.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  - -
Get Model matrix
-
  - -
Get World matrix.
-
  -
getX() -
-
-
  -
getXYZ() -
-
-
  -
getY() -
-
-
  -
getZ() -
-
-
  -
incX(x) -
-
-
  -
incY(y) -
-
-
  -
incZ(z) -
-
-
  -
setMultOrder(multOrder) -
-
Sets the multiplication order of this node's transform matrix with respect to the parent modeling transform -in the scene graph.
-
  -
setX(x) -
-
-
  -
setXYZ(xyz) -
-
-
  -
setY(y) -
-
-
  -
setZ(z) -
-
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.Translate() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - {*} - getModelMatrix() - -
-
- Get Model matrix - - -
- - - - - - - - -
-
Returns:
- -
{*}
- -
- - - - -
- - -
- - {*} - getWorldMatrix() - -
-
- Get World matrix. That's the multiplication of this node's Model matrix by the World matrix of the the next -tranform (scale, translate, translate etc) node on the path to the scene root. - - -
- - - - - - - - -
-
Returns:
- -
{*}
- -
- - - - -
- - -
- - - getX() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getXYZ() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getY() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getZ() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - incX(x) - -
-
- - - -
- - - - -
-
Parameters:
- -
- x - -
-
- -
- - - - - - - - -
- - -
- - - incY(y) - -
-
- - - -
- - - - -
-
Parameters:
- -
- y - -
-
- -
- - - - - - - - -
- - -
- - - incZ(z) - -
-
- - - -
- - - - -
-
Parameters:
- -
- z - -
-
- -
- - - - - - - - -
- - -
- - - setMultOrder(multOrder) - -
-
- Sets the multiplication order of this node's transform matrix with respect to the parent modeling transform -in the scene graph. - - -
- - - - -
-
Parameters:
- -
- {String} multOrder - -
-
Mulplication order - "post" and "pre"
- -
- - - - - - - - -
- - -
- - - setX(x) - -
-
- - - -
- - - - -
-
Parameters:
- -
- x - -
-
- -
- - - - - - - - -
- - -
- - - setXYZ(xyz) - -
-
- - - -
- - - - -
-
Parameters:
- -
- xyz - -
-
- -
- - - - - - - - -
- - -
- - - setY(y) - -
-
- - - -
- - - - -
-
Parameters:
- -
- y - -
-
- -
- - - - - - - - -
- - -
- - - setZ(z) - -
-
- - - -
- - - - -
-
Parameters:
- -
- z - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS.XForm.html b/docs/symbols/SceneJS.XForm.html deleted file mode 100644 index 0262a8b3..00000000 --- a/docs/symbols/SceneJS.XForm.html +++ /dev/null @@ -1,513 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS.XForm - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS.XForm -

- - -

- -
Extends - SceneJS.Node.
- - - Scene graph node which defines the modelling transform to apply to the objects in its subgraph - - -
Defined in: xform.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  - -
-
- - - - - - - - -
-
Fields borrowed from class SceneJS.Node:
branchDirty, data, dirty, id, nodes, parent, type
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  - -
Get Model matrix
-
  - -
Get World matrix.
-
  -
setElements(elements) -
-
-
- - - -
-
Methods borrowed from class SceneJS.Node:
add, addListener, addNode, addNodes, bind, destroy, disconnect, disconnectNodeAt, disconnectNodes, eachNode, eachParent, findNodesByType, findParentByType, get, getCoreId, getData, getFirstNode, getId, getID, getJSON, getLastNode, getNode, getNodeAt, getNodeId, getNodes, getNumNodes, getParent, getScene, getType, hasListener, hasListeners, hasNode, inc, insert, insertNode, mapNodes, node, numNodes, remove, removeListener, removeListeners, removeNode, removeNodeAt, removeNodes, set, setData, splice, unbind
-
- - - - - - - -
-
- Class Detail -
- -
- SceneJS.XForm() -
- -
- - -
- - - - - - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - {*} - getModelMatrix() - -
-
- Get Model matrix - - -
- - - - - - - - -
-
Returns:
- -
{*}
- -
- - - - -
- - -
- - {*} - getWorldMatrix() - -
-
- Get World matrix. That's the multiplication of this node's Model matrix by the World matrix of the the next -tranform (scale, XForm, translate etc) node on the path to the scene root. - - -
- - - - - - - - -
-
Returns:
- -
{*}
- -
- - - - -
- - -
- - - setElements(elements) - -
-
- - - -
- - - - -
-
Parameters:
- -
- elements - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/SceneJS_webgl_Program.html b/docs/symbols/SceneJS_webgl_Program.html deleted file mode 100644 index 15449d68..00000000 --- a/docs/symbols/SceneJS_webgl_Program.html +++ /dev/null @@ -1,846 +0,0 @@ - - - - - - - JsDoc Reference - SceneJS_webgl_Program - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Class SceneJS_webgl_Program -

- - -

- - - - Wrapper for a WebGL program - - -
Defined in: webgl.js. - -

- - - - - - - - - - - - - - - - - -
Class Summary
Constructor AttributesConstructor Name and Description
  -
- SceneJS_webgl_Program(hash, gl, vertexSources, fragmentSources, logging) -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  -
bind() -
-
-
  -
bindFloatArrayBuffer(name, buffer) -
-
-
  -
bindTexture(name, texture, unit) -
-
-
  -
destroy() -
-
-
  -
getAttribute(name) -
-
-
  -
getUniform(name) -
-
-
  - -
-
  -
setProfile(profile) -
-
-
  -
setUniform(name, value) -
-
-
  -
unbind() -
-
-
- - - - - - - - - -
-
- Class Detail -
- -
- SceneJS_webgl_Program(hash, gl, vertexSources, fragmentSources, logging) -
- -
- - -
- - - - - -
-
Parameters:
- -
- hash - -
-
SceneJS-managed ID for program
- -
- gl - -
-
WebGL gl
- -
- vertexSources - -
-
Source codes for vertex shaders
- -
- fragmentSources - -
-
Source codes for fragment shaders
- -
- logging - -
-
Program and shaders will write to logging's debug channel as they compile and link
- -
- - - - - - - - -
- - - - - - - -
- Method Detail -
- - -
- - - bind() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - bindFloatArrayBuffer(name, buffer) - -
-
- - - -
- - - - -
-
Parameters:
- -
- name - -
-
- -
- buffer - -
-
- -
- - - - - - - - -
- - -
- - - bindTexture(name, texture, unit) - -
-
- - - -
- - - - -
-
Parameters:
- -
- name - -
-
- -
- texture - -
-
- -
- unit - -
-
- -
- - - - - - - - -
- - -
- - - destroy() - -
-
- - - -
- - - - - - - - - - - -
- - -
- - - getAttribute(name) - -
-
- - - -
- - - - -
-
Parameters:
- -
- name - -
-
- -
- - - - - - - - -
- - -
- - - getUniform(name) - -
-
- - - -
- - - - -
-
Parameters:
- -
- name - -
-
- -
- - - - - - - - -
- - -
- - - getUniformLocation(name) - -
-
- - - -
- - - - -
-
Parameters:
- -
- name - -
-
- -
- - - - - - - - -
- - -
- - - setProfile(profile) - -
-
- - - -
- - - - -
-
Parameters:
- -
- profile - -
-
- -
- - - - - - - - -
- - -
- - - setUniform(name, value) - -
-
- - - -
- - - - -
-
Parameters:
- -
- name - -
-
- -
- value - -
-
- -
- - - - - - - - -
- - -
- - - unbind() - -
-
- - - -
- - - - - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/_global_.html b/docs/symbols/_global_.html deleted file mode 100644 index d9408376..00000000 --- a/docs/symbols/_global_.html +++ /dev/null @@ -1,4539 +0,0 @@ - - - - - - - JsDoc Reference - _global_ - - - - - - - - - - - -
- -
Class Index -| File Index
-
-

Classes

- -
- -
- -
- -

- - Built-In Namespace _global_ -

- - -

- - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Field Summary
Field AttributesField Name and Description
  -
- _engines -
-
-
  - -
Attributes given when initialising the WebGL context
-
  -
- gl -
-
The WebGL context
-
  -
- options -
-
WebGL context options
-
  -
- SceneJS -
-
The SceneJS object.
-
  - -
Default lookat properties in array form - eye at 0,0,1, looking at 0,0,0, up vector pointing up Y-axis
-
  - -
Default lookat properties - eye at 0,0,1, looking at 0,0,0, up vector pointing up Y-axis
-
  - -
Default orthographic projection properties
-
  - -
Provides a model transform stack in front of the renderer.
-
  -
- VERSION -
-
This SceneJS version
-
  - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Method Summary
Method AttributesMethod Name and Description
  -
__log(channel, message) -
-
-
  -
_allocate(values, numItems) -
-
-
  - -
-
  - -
-
  - -
-
  -
_flush(channel) -
-
-
  -
_hasNormals(states) -
-
-
  -
_isTexturing(states) -
-
-
  -
_log(channel, message) -
-
-
  -
_setIndent(_indent) -
-
-
  - -
-
  -
_touch() -
-
-
  -
addPlugin(nodeType, pluginType, plugin) -
-
Installs a plugin into SceneJS
-
  -
bind() -
-
-
  - -
-
  -
bindTexture(texture, unit) -
-
-
  -
buildCore(core) -
-
Creates a fresh transformation core
-
  -
clear() -
-
-
  -
createScene(json, options) -
-
Creates a new scene from the given JSON description
-
  -
debug(msg) -
-
-
  -
destroy() -
-
-
  -
error(msg) -
-
-
  -
fatalError(code, message) -
-
-
  -
func(v) -
-
-
  -
getConfigs(path) -
-
-
  - -
-
  - -
-
  -
getPlugin(nodeType, pluginType, ok) -
-
Returns installed plugin of given type and ID
-
  -
getProjectedState(modelCoords) -
-
-
  -
getScene(sceneId) -
-
Gets an existing scene
-
  - -
Gets existing scenes
-
  -
getSource(hash, states) -
-
Get sourcecode for a program to render the given states
-
  - -
-
  -
hasPlugin(nodeType, pluginType) -
-
Tests if given plugin is installed
-
  -
info(msg) -
-
-
  -
init(_gl) -
-
Initialises the pick buffer
-
  -
nodeLoaded(node) -
-
-
  -
nodeLoading(node) -
-
-
  -
pop() -
-
-
  -
postVisitNode(node) -
-
-
  -
preVisitNode(node) -
-
-
  -
push(core) -
-
-
  -
putSource(hash) -
-
Releases program source code
-
  -
read(pickX, pickY) -
-
Reads pick buffer pixel at given coordinates, returns index of associated object else (-1)
-
  -
removeListener(handle) -
-
Removes a listener
-
  -
reset() -
-
Resets SceneJS, destroying all existing scenes
-
  -
scene(sceneId) -
-
Gets an existing scene
-
  -
SceneJS_Canvas(id, canvasId, contextAttr, options) -
-
-
  - -
-
  - -
-
  - -
-
  - -
-
  -
SceneJS_math_lerpVec3(t, t1, t2, p1, p2) -
-
-
  -
SceneJS_math_lookAtMat4v(pos, target, up, dest) -
-
-
  - -
-
  - -
-
  - -
-
  - -
-
  -
SceneJS_math_slerp(t, q1, q2) -
-
-
  - -
-
  - -
-
  - -
-
  - -
-
  - -
-
  - -
-
  -
SceneJS_webgl_ProgramAttribute(gl, program, name, type, size, location) -
-
An attribute within a shader
-
  -
SceneJS_webgl_ProgramSampler(gl, program, name, type, size, location) -
-
-
  -
SceneJS_webgl_ProgramUniform(gl, program, name, type, size, location, logging) -
-
-
  - -
-
  -
setConfigs(path, data) -
-
-
  -
setData(data, offset) -
-
-
  -
setFuncs(l) -
-
-
  -
unbind() -
-
-
  -
warn(msg) -
-
-
  - -
Called when WebGL context restored
-
- - - - - - - - - - - - -
- Field Detail -
- - -
- - - _engines - -
-
- - -
- Defined in: scenejs.js. - - -
- - - - - - - - -
- - -
- - - contextAttr - -
-
- Attributes given when initialising the WebGL context - -
- Defined in: canvas.js. - - -
- - - - - - - - -
- - -
- - - gl - -
-
- The WebGL context - -
- Defined in: canvas.js. - - -
- - - - - - - - -
- - -
- - - options - -
-
- WebGL context options - -
- Defined in: canvas.js. - - -
- - - - - - - - -
- - -
- - - SceneJS - -
-
- The SceneJS object. - -
- Defined in: scenejs.js. - - -
- - - - - - - - -
- - -
- - - SceneJS_math_LOOKAT_ARRAYS - -
-
- Default lookat properties in array form - eye at 0,0,1, looking at 0,0,0, up vector pointing up Y-axis - -
- Defined in: math.js. - - -
- - - - - - - - -
- - -
- - - SceneJS_math_LOOKAT_OBJ - -
-
- Default lookat properties - eye at 0,0,1, looking at 0,0,0, up vector pointing up Y-axis - -
- Defined in: math.js. - - -
- - - - - - - - -
- - -
- - - SceneJS_math_ORTHO_OBJ - -
-
- Default orthographic projection properties - -
- Defined in: math.js. - - -
- - - - - - - - -
- - -
- - - SceneJS_modelXFormStack - -
-
- Provides a model transform stack in front of the renderer. -Nodes peek push and pop to the stack, while the renderer peeks at -the transform on the top of the stack whenever it builds a renderer node. - -
- Defined in: modelXFormStack.js. - - -
- - - - - - - - -
- - -
- - - VERSION - -
-
- This SceneJS version - -
- Defined in: scenejs.js. - - -
- - - - - - - - -
- - -
- - - WebGLDebugUtils - -
-
- - -
- Defined in: webgl-debug-utils.js. - - -
- - - - - - - - - - - - - - -
- Method Detail -
- - -
- - - __log(channel, message) - -
-
- - -
- Defined in: log.js. - - -
- - - - -
-
Parameters:
- -
- channel - -
-
- -
- message - -
-
- -
- - - - - - - - -
- - -
- - - _allocate(values, numItems) - -
-
- - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- values - -
-
- -
- numItems - -
-
- -
- - - - - - - - -
- - -
- - - _composePickingVertexShader(states) - -
-
- - -
- Defined in: programSourceFactory.js. - - -
- - - - -
-
Parameters:
- -
- states - -
-
- -
- - - - - - - - -
- - -
- - - _composeRenderingFragmentShader(states) - -
-
- - -
- Defined in: programSourceFactory.js. - - -
- - - - -
-
Parameters:
- -
- states - -
-
- -
- - - - - - - - -
- - -
- - - _composeRenderingVertexShader(states) - -
-
- - -
- Defined in: programSourceFactory.js. - - -
- - - - -
-
Parameters:
- -
- states - -
-
- -
- - - - - - - - -
- - -
- - - _flush(channel) - -
-
- - -
- Defined in: log.js. - - -
- - - - -
-
Parameters:
- -
- channel - -
-
- -
- - - - - - - - -
- - -
- - - _hasNormals(states) - -
-
- - -
- Defined in: programSourceFactory.js. - - -
- - - - -
-
Parameters:
- -
- states - -
-
- -
- - - - - - - - -
- - -
- - - _isTexturing(states) - -
-
- - -
- Defined in: programSourceFactory.js. - - -
- - - - -
-
Parameters:
- -
- states - -
-
- -
- - - - - - - - -
- - -
- - - _log(channel, message) - -
-
- - -
- Defined in: log.js. - - -
- - - - -
-
Parameters:
- -
- channel - -
-
- -
- message - -
-
- -
- - - - - - - - -
- - -
- - - _setIndent(_indent) - -
-
- - -
- Defined in: log.js. - - -
- - - - -
-
Parameters:
- -
- _indent - -
-
- -
- - - - - - - - -
- - -
- - - _shallowClone(o) - -
-
- - -
- Defined in: scenejs.js. - - -
- - - - -
-
Parameters:
- -
- o - -
-
- -
- - - - - - - - -
- - -
- - - _touch() - -
-
- - -
- Defined in: webgl.js. - - -
- - - - - - - - - - - -
- - -
- - - addPlugin(nodeType, pluginType, plugin) - -
-
- Installs a plugin into SceneJS - -
- Defined in: plugins.js. - - -
- - - - -
-
Parameters:
- -
- nodeType - -
-
- -
- pluginType - -
-
- -
- plugin - -
-
- -
- - - - - - - - -
- - -
- - - bind() - -
-
- - -
- Defined in: webgl.js. - - -
- - - - - - - - - - - -
- - -
- - - bindFloatArrayBuffer(buffer) - -
-
- - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- buffer - -
-
- -
- - - - - - - - -
- - -
- - - bindTexture(texture, unit) - -
-
- - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- texture - -
-
- -
- unit - -
-
- -
- - - - - - - - -
- - -
- - - buildCore(core) - -
-
- Creates a fresh transformation core - -
- Defined in: modelXFormStack.js. - - -
- - - - -
-
Parameters:
- -
- core - -
-
- -
- - - - - - - - -
- - -
- - - clear() - -
-
- - -
- Defined in: webgl.js. - - -
- - - - - - - - - - - -
- - -
- - {SceneJS.Scene} - createScene(json, options) - -
-
- Creates a new scene from the given JSON description - -
- Defined in: scenejs.js. - - -
- - - - -
-
Parameters:
- -
- {String} json - -
-
JSON scene description
- -
- options - -
-
Optional options
- -
- options.simulateWebGLContextLost - -
-
Optional options
- -
- - - - - -
-
Returns:
- -
{SceneJS.Scene} New scene
- -
- - - - -
- - -
- - - debug(msg) - -
-
- - -
- Defined in: log.js. - - -
- - - - -
-
Parameters:
- -
- msg - -
-
- -
- - - - - - - - -
- - -
- - - destroy() - -
-
- - -
- Defined in: webgl.js. - - -
- - - - - - - - - - - -
- - -
- - - error(msg) - -
-
- - -
- Defined in: log.js. - - -
- - - - -
-
Parameters:
- -
- msg - -
-
- -
- - - - - - - - -
- - -
- - - fatalError(code, message) - -
-
- - -
- Defined in: errors.js. - - -
- - - - -
-
Parameters:
- -
- code - -
-
- -
- message - -
-
- -
- - - - - - - - -
- - -
- - - func(v) - -
-
- - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- v - -
-
- -
- - - - - - - - -
- - -
- - - getConfigs(path) - -
-
- - -
- Defined in: config.js. - - -
- - - - -
-
Parameters:
- -
- path - -
-
- -
- - - - - - - - -
- - -
- - - getFuncs() - -
-
- - -
- Defined in: log.js. - - -
- - - - - - - - - - - -
- - -
- - - getLocation() - -
-
- - -
- Defined in: webgl.js. - - -
- - - - - - - - - - - -
- - -
- - - getPlugin(nodeType, pluginType, ok) - -
-
- Returns installed plugin of given type and ID - -
- Defined in: plugins.js. - - -
- - - - -
-
Parameters:
- -
- nodeType - -
-
- -
- pluginType - -
-
- -
- ok - -
-
- -
- - - - - - - - -
- - -
- - - getProjectedState(modelCoords) - -
-
- - -
- Defined in: math.js. - - -
- - - - -
-
Parameters:
- -
- modelCoords - -
-
- -
- - - - - - - - -
- - -
- - {SceneJS.Scene} - getScene(sceneId) - -
-
- Gets an existing scene - -
- Defined in: scenejs.js. - - -
- - - - -
-
Parameters:
- -
- {String} sceneId - -
-
ID of target scene
- -
- - - - - -
-
Returns:
- -
{SceneJS.Scene} The selected scene
- -
- - - - -
- - -
- - - getScenes() - -
-
- Gets existing scenes - -
- Defined in: scenejs.js. - - -
- - - - - - - - -
-
Returns:
- -
Existing scenes, mapped to their IDs
- -
- - - - -
- - -
- - - getSource(hash, states) - -
-
- Get sourcecode for a program to render the given states - -
- Defined in: programSourceFactory.js. - - -
- - - - -
-
Parameters:
- -
- hash - -
-
- -
- states - -
-
- -
- - - - - - - - -
- - -
- - - getValue() - -
-
- - -
- Defined in: webgl.js. - - -
- - - - - - - - - - - -
- - -
- - - hasPlugin(nodeType, pluginType) - -
-
- Tests if given plugin is installed - -
- Defined in: plugins.js. - - -
- - - - -
-
Parameters:
- -
- nodeType - -
-
- -
- pluginType - -
-
- -
- - - - - - - - -
- - -
- - - info(msg) - -
-
- - -
- Defined in: log.js. - - -
- - - - -
-
Parameters:
- -
- msg - -
-
- -
- - - - - - - - -
- - -
- - - init(_gl) - -
-
- Initialises the pick buffer - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- _gl - -
-
WebGL context
- -
- - - - - - - - -
- - -
- - - nodeLoaded(node) - -
-
- - -
- Defined in: status.js. - - -
- - - - -
-
Parameters:
- -
- node - -
-
- -
- - - - - - - - -
- - -
- - - nodeLoading(node) - -
-
- - -
- Defined in: status.js. - - -
- - - - -
-
Parameters:
- -
- node - -
-
- -
- - - - - - - - -
- - -
- - - pop() - -
-
- - -
- Defined in: modelXFormStack.js. - - -
- - - - - - - - - - - -
- - -
- - - postVisitNode(node) - -
-
- - -
- Defined in: nodeEvents.js. - - -
- - - - -
-
Parameters:
- -
- node - -
-
- -
- - - - - - - - -
- - -
- - - preVisitNode(node) - -
-
- - -
- Defined in: nodeEvents.js. - - -
- - - - -
-
Parameters:
- -
- node - -
-
- -
- - - - - - - - -
- - -
- - - push(core) - -
-
- - -
- Defined in: modelXFormStack.js. - - -
- - - - -
-
Parameters:
- -
- core - -
-
- -
- - - - - - - - -
- - -
- - - putSource(hash) - -
-
- Releases program source code - -
- Defined in: programSourceFactory.js. - - -
- - - - -
-
Parameters:
- -
- hash - -
-
- -
- - - - - - - - -
- - -
- - - read(pickX, pickY) - -
-
- Reads pick buffer pixel at given coordinates, returns index of associated object else (-1) - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- pickX - -
-
- -
- pickY - -
-
- -
- - - - - - - - -
- - -
- - - removeListener(handle) - -
-
- Removes a listener - -
- Defined in: events.js. - - -
- - - - -
-
Parameters:
- -
- handle - -
-
Subscription handle
- -
- - - - - - - - -
- - -
- - - reset() - -
-
- Resets SceneJS, destroying all existing scenes - -
- Defined in: scenejs.js. - - -
- - - - - - - - - - - -
- - -
- - {SceneJS.Scene} - scene(sceneId) - -
-
- Gets an existing scene - -
- Defined in: scenejs.js. - - -
- - - - -
-
Parameters:
- -
- {String} sceneId - -
-
ID of target scene
- -
- - - - - -
-
Returns:
- -
{SceneJS.Scene} The selected scene
- -
- - - - -
- - -
- - - SceneJS_Canvas(id, canvasId, contextAttr, options) - -
-
- - -
- Defined in: canvas.js. - - -
- - - - -
-
Parameters:
- -
- id - -
-
- -
- canvasId - -
-
- -
- contextAttr - -
-
- -
- options - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_math_angleAxisFromQuaternion(q) - -
-
- - -
- Defined in: math.js. - - -
- - - - -
-
Parameters:
- -
- q - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_math_angleAxisQuaternion(x, y, z, degrees) - -
-
- - -
- Defined in: math.js. - - -
- - - - -
-
Parameters:
- -
- x - -
-
- -
- y - -
-
- -
- z - -
-
- -
- degrees - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_math_conjugateQuaternion(q) - -
-
- - -
- Defined in: math.js. - - -
- - - - -
-
Parameters:
- -
- q - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_math_identityQuaternion() - -
-
- - -
- Defined in: math.js. - - -
- - - - - - - - - - - -
- - -
- - - SceneJS_math_lerpVec3(t, t1, t2, p1, p2) - -
-
- - -
- Defined in: math.js. - - -
- - - - -
-
Parameters:
- -
- t - -
-
- -
- t1 - -
-
- -
- t2 - -
-
- -
- p1 - -
-
- -
- p2 - -
-
- -
- - - - - - - - -
- - -
- - {mat4} - SceneJS_math_lookAtMat4v(pos, target, up, dest) - -
-
- - -
- Defined in: math.js. - - -
- - - - -
-
Parameters:
- -
- pos - -
-
vec3 position of the viewer
- -
- target - -
-
vec3 point the viewer is looking at
- -
- up - -
-
vec3 pointing "up"
- -
- dest - -
-
mat4 Optional, mat4 frustum matrix will be written into
- -
- - - - - -
-
Returns:
- -
{mat4} dest if specified, a new mat4 otherwise
- -
- - - - -
- - -
- - - SceneJS_math_mulQuaternions(p, q) - -
-
- - -
- Defined in: math.js. - - -
- - - - -
-
Parameters:
- -
- p - -
-
- -
- q - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_math_newMat4FromQuaternion(q) - -
-
- - -
- Defined in: math.js. - - -
- - - - -
-
Parameters:
- -
- q - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_math_normalizeQuaternion(q) - -
-
- - -
- Defined in: math.js. - - -
- - - - -
-
Parameters:
- -
- q - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_math_normalizeVec2(v, dest) - -
-
- - -
- Defined in: math.js. - - -
- - - - -
-
Parameters:
- -
- v - -
-
- -
- dest - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_math_slerp(t, q1, q2) - -
-
- - -
- Defined in: math.js. - - -
- - - - -
-
Parameters:
- -
- t - -
-
- -
- q1 - -
-
- -
- q2 - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_math_transformVector4(m, v) - -
-
- - -
- Defined in: math.js. - - -
- - - - -
-
Parameters:
- -
- m - -
-
- -
- v - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_PickBuffer(cfg) - -
-
- - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- cfg - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_PickBufferOLD(cfg) - -
-
- - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- cfg - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_webgl_ensureImageSizePowerOfTwo(image) - -
-
- - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- image - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_webgl_isPowerOfTwo(x) - -
-
- - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- x - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_webgl_nextHighestPowerOfTwo(x) - -
-
- - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- x - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_webgl_ProgramAttribute(gl, program, name, type, size, location) - -
-
- An attribute within a shader - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- gl - -
-
- -
- program - -
-
- -
- name - -
-
- -
- type - -
-
- -
- size - -
-
- -
- location - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_webgl_ProgramSampler(gl, program, name, type, size, location) - -
-
- - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- gl - -
-
- -
- program - -
-
- -
- name - -
-
- -
- type - -
-
- -
- size - -
-
- -
- location - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_webgl_ProgramUniform(gl, program, name, type, size, location, logging) - -
-
- - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- gl - -
-
- -
- program - -
-
- -
- name - -
-
- -
- type - -
-
- -
- size - -
-
- -
- location - -
-
- -
- logging - -
-
- -
- - - - - - - - -
- - -
- - - SceneJS_webgl_Texture2D(gl, cfg) - -
-
- - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- gl - -
-
- -
- cfg - -
-
- -
- - - - - - - - -
- - -
- - - setConfigs(path, data) - -
-
- - -
- Defined in: config.js. - - -
- - - - -
-
Parameters:
- -
- path - -
-
- -
- data - -
-
- -
- - - - - - - - -
- - -
- - - setData(data, offset) - -
-
- - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- data - -
-
- -
- offset - -
-
- -
- - - - - - - - -
- - -
- - - setFuncs(l) - -
-
- - -
- Defined in: log.js. - - -
- - - - -
-
Parameters:
- -
- l - -
-
- -
- - - - - - - - -
- - -
- - - unbind() - -
-
- - -
- Defined in: webgl.js. - - -
- - - - - - - - - - - -
- - -
- - - warn(msg) - -
-
- - -
- Defined in: log.js. - - -
- - - - -
-
Parameters:
- -
- msg - -
-
- -
- - - - - - - - -
- - -
- - - webglRestored(_gl) - -
-
- Called when WebGL context restored - -
- Defined in: webgl.js. - - -
- - - - -
-
Parameters:
- -
- _gl - -
-
- -
- - - - - - - - - - - - - - - -
-
- - - -
- - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Mar 22 2013 02:49:02 GMT+0100 (CET) -
- - diff --git a/docs/symbols/src/licenses_license-header.js.html b/docs/symbols/src/licenses_license-header.js.html deleted file mode 100644 index 8a21f2a4..00000000 --- a/docs/symbols/src/licenses_license-header.js.html +++ /dev/null @@ -1,24 +0,0 @@ -
  1 /*
-  2  * SceneJS WebGL Scene Graph Library for JavaScript
-  3  * http://scenejs.org/
-  4  * Dual licensed under the MIT or GPL Version 2 licenses.
-  5  * http://scenejs.org/license
-  6   * Copyright 2010, Lindsay Kay
-  7  *
-  8  * Includes WebGLTrace
-  9  * Various functions for helping debug WebGL apps.
- 10  * http://github.com/jackpal/webgltrace
- 11  * Copyright (c) 2009 The Chromium Authors. All rights reserved.
- 12  *
- 13  * Includes WebGL-Debug
- 14  * Various functions for helping debug WebGL apps.
- 15  * http://khronos.org/webgl/wiki/Debugging
- 16  * Copyright (c) 2009 The Chromium Authors. All rights reserved.
- 17  */
\ No newline at end of file diff --git a/docs/symbols/src/src_core_canvas.js.html b/docs/symbols/src/src_core_canvas.js.html deleted file mode 100644 index 361a709f..00000000 --- a/docs/symbols/src/src_core_canvas.js.html +++ /dev/null @@ -1,114 +0,0 @@ -
  1 /**
-  2  *
-  3  */
-  4 var SceneJS_Canvas = function (id, canvasId, contextAttr, options) {
-  5 
-  6     /**
-  7      * ID of this canvas
-  8      */
-  9     this.canvasId;
- 10 
- 11     if (!canvasId) {
- 12         // Automatic default canvas
- 13         canvasId = "canvas-" + id;
- 14         var body = document.getElementsByTagName("body")[0];
- 15         body.innerHTML = '';
- 16         var newdiv = document.createElement('div');
- 17         newdiv.style.height = "100%";
- 18         newdiv.style.width = "100%";
- 19         newdiv.innerHTML = '<canvas id="' + canvasId + '" style="width: 100%; height: 100%; margin: 0; padding: 0;"></canvas>';
- 20         body.appendChild(newdiv);
- 21     }
- 22 
- 23     // Bind to canvas
- 24     var canvas = document.getElementById(canvasId);
- 25     if (!canvas) {
- 26         throw SceneJS_error.fatalError(SceneJS.errors.CANVAS_NOT_FOUND,
- 27             "SceneJS.Scene attribute 'canvasId' does not match any elements in the page");
- 28     }
- 29     this.canvasId = canvasId;
- 30 
- 31     /**
- 32      * WebGL context options
- 33      */
- 34     this.options = options || {};
- 35 
- 36     this.canvas = (this.options.simulateWebGLContextLost)
- 37         ? WebGLDebugUtils.makeLostContextSimulatingCanvas(canvas)
- 38         : canvas;
- 39 
- 40     // If the canvas uses css styles to specify the sizes make sure the basic
- 41     // width and height attributes match or the WebGL context will use 300 x 150
- 42 
- 43     this.canvas.width = this.canvas.clientWidth;
- 44     this.canvas.height = this.canvas.clientHeight;
- 45 
- 46     /**
- 47      * Attributes given when initialising the WebGL context
- 48      */
- 49     this.contextAttr = contextAttr;
- 50 
- 51     /**
- 52      * The WebGL context
- 53      */
- 54     this.gl = null;
- 55 
- 56     this.initWebGL();
- 57 };
- 58 
- 59 /**
- 60  * Names of recognised WebGL contexts
- 61  */
- 62 SceneJS_Canvas.prototype._WEBGL_CONTEXT_NAMES = [
- 63     "webgl",
- 64     "experimental-webgl",
- 65     "webkit-3d",
- 66     "moz-webgl",
- 67     "moz-glweb20"
- 68 ];
- 69 
- 70 /**
- 71  * Initialise the WebGL context
- 72 
- 73  */
- 74 SceneJS_Canvas.prototype.initWebGL = function () {
- 75 
- 76     for (var i = 0; !this.gl && i < this._WEBGL_CONTEXT_NAMES.length; i++) {
- 77         try {
- 78             this.gl = this.canvas.getContext(this._WEBGL_CONTEXT_NAMES[i], this.contextAttr);
- 79 
- 80         } catch (e) { // Try with next context name
- 81         }
- 82     }
- 83 
- 84     if (!this.gl) {
- 85         throw SceneJS_error.fatalError(
- 86             SceneJS.errors.WEBGL_NOT_SUPPORTED,
- 87             'Failed to get a WebGL context');
- 88     }
- 89 
- 90 //    this.gl.clearColor(1.0, 1.0, 1.0, 1.0);
- 91     this.gl.clearDepth(1.0);
- 92     this.gl.enable(this.gl.DEPTH_TEST);
- 93     this.gl.disable(this.gl.CULL_FACE);
- 94     this.gl.depthRange(0, 1);
- 95     this.gl.disable(this.gl.SCISSOR_TEST);
- 96 };
- 97 
- 98 
- 99 /**
-100  * Simulate a lost WebGL context.
-101  * Only works if the simulateWebGLContextLost was given as an option to the canvas' constructor.
-102  */
-103 SceneJS_Canvas.prototype.loseWebGLContext = function () {
-104     if (this.options.simulateWebGLContextLost) {
-105         this.canvas.loseContext();
-106     }
-107 };
\ No newline at end of file diff --git a/docs/symbols/src/src_core_config.js.html b/docs/symbols/src/src_core_config.js.html deleted file mode 100644 index 89b305eb..00000000 --- a/docs/symbols/src/src_core_config.js.html +++ /dev/null @@ -1,71 +0,0 @@ -
  1 /**
-  2  * Backend that manages configurations.
-  3  *
-  4  * @class SceneJS_debugModule
-  5  * @private
-  6  */
-  7 var SceneJS_debugModule = new (function() {
-  8 
-  9     this.configs = {};
- 10 
- 11     this.getConfigs = function(path) {
- 12         if (!path) {
- 13             return this.configs;
- 14         } else {
- 15             var cfg = this.configs;
- 16             var parts = path.split(".");
- 17             for (var i = 0; cfg && i < parts.length; i++) {
- 18                 cfg = cfg[parts[i]];
- 19             }
- 20             return cfg || {};
- 21         }
- 22     };
- 23 
- 24     this.setConfigs = function(path, data) {
- 25         if (!path) {
- 26             this.configs = data;
- 27         } else {
- 28             var parts = path.split(".");
- 29             var cfg = this.configs;
- 30             var subCfg;
- 31             var name;
- 32             for (var i = 0; i < parts.length - 1; i++) {
- 33                 name = parts[i];
- 34                 subCfg = cfg[name];
- 35                 if (!subCfg) {
- 36                     subCfg = cfg[name] = {};
- 37                 }
- 38                 cfg = subCfg;
- 39             }
- 40             cfg[parts.length - 1] = data;
- 41         }
- 42     };
- 43 
- 44 })();
- 45 
- 46 /** Sets configurations.
- 47  */
- 48 SceneJS.configure = SceneJS.setConfigs = SceneJS.setDebugConfigs = function () {
- 49     if (arguments.length == 1) {
- 50         SceneJS_debugModule.setConfigs(null, arguments[0]);
- 51     } else if (arguments.length == 2) {
- 52         SceneJS_debugModule.setConfigs(arguments[0], arguments[1]);
- 53     } else {
- 54         throw SceneJS_error.fatalError("Illegal arguments given to SceneJS.setDebugs - should be either ({String}:name, {Object}:cfg) or ({Object}:cfg)");
- 55     }
- 56 };
- 57 
- 58 /** Gets configurations
- 59  */
- 60 SceneJS.getConfigs = SceneJS.getDebugConfigs = function (path) {
- 61     return SceneJS_debugModule.getConfigs(path);
- 62 };
- 63 
- 64 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_cameraChunk.js.html b/docs/symbols/src/src_core_display_chunks_cameraChunk.js.html deleted file mode 100644 index 91bca006..00000000 --- a/docs/symbols/src/src_core_display_chunks_cameraChunk.js.html +++ /dev/null @@ -1,54 +0,0 @@ -
  1 SceneJS_ChunkFactory.createChunkType({
-  2 
-  3     type: "camera",
-  4 
-  5     build : function() {
-  6 
-  7         this._uPMatrixDraw = this.program.draw.getUniformLocation("SCENEJS_uPMatrix");
-  8 
-  9         this._uPMatrixPick = this.program.pick.getUniformLocation("SCENEJS_uPMatrix");
- 10         this._uZNearPick = this.program.pick.getUniformLocation("SCENEJS_uZNear");
- 11         this._uZFarPick = this.program.pick.getUniformLocation("SCENEJS_uZFar");
- 12     },
- 13 
- 14     draw : function(ctx) {
- 15 
- 16         var gl = this.program.gl;
- 17 
- 18         if (this._uPMatrixDraw) {
- 19             gl.uniformMatrix4fv(this._uPMatrixDraw, gl.FALSE, this.core.mat);
- 20         }
- 21 
- 22         ctx.cameraMat = this.core.mat; // Query only in draw pass
- 23     },
- 24 
- 25 
- 26     pick : function(ctx) {
- 27 
- 28         var gl = this.program.gl;
- 29 
- 30         if (this._uPMatrixPick) {
- 31             gl.uniformMatrix4fv(this._uPMatrixPick, gl.FALSE, this.core.mat);
- 32         }
- 33 
- 34         if (ctx.rayPick) { // Z-pick pass: feed near and far clip planes into shader
- 35 
- 36             if (this._uZNearPick) {
- 37                 gl.uniform1f(this._uZNearPick, this.core.optics.near);
- 38             }
- 39 
- 40             if (this._uZFarPick) {
- 41                 gl.uniform1f(this._uZFarPick, this.core.optics.far);
- 42             }
- 43         }
- 44 
- 45         ctx.cameraMat = this.core.mat; // Query only in draw pass
- 46     }
- 47 });
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_chunk.js.html b/docs/symbols/src/src_core_display_chunks_chunk.js.html deleted file mode 100644 index 21cada62..00000000 --- a/docs/symbols/src/src_core_display_chunks_chunk.js.html +++ /dev/null @@ -1,74 +0,0 @@ -
  1 /**
-  2  * @class A chunk of WebGL state changes to render a {@link SceneJS_Core} for drawing and picking (if applicable to the core type).
-  3  *
-  4  * <p>Instances of this class are created and recycled by a {@link SceneJS_ChunkFactory}.</p>
-  5  *
-  6  * <p>Each {@link SceneJS_Object} has a list of chunks to render it's {@link SceneJS_Core}s</p>
-  7  *
-  8  * @private
-  9  */
- 10 var SceneJS_Chunk = function(id, type, program, core) {
- 11 
- 12     /**
- 13      * The type of the corresponding {@link SceneJS_Core}
- 14      * @type String
- 15      * @see {SceneJS_Core#type}
- 16      */
- 17     this.type = type;
- 18 
- 19     /**
- 20      * The chunk ID
- 21      * @type Number
- 22      */
- 23     this.id = id;
- 24 
- 25     /**
- 26      * The program this chunk will render with
- 27      * @type {SceneJS_Program}
- 28      */
- 29     this.program = program;
- 30 
- 31     /**
- 32      * The state core rendered by this chunk
- 33      * @type {SceneJS_Core}
- 34      */
- 35     this.core = core;
- 36 
- 37     /**
- 38      * Count of {@link SceneJS_Object} instances using this chunk
- 39      * @type Number
- 40      */
- 41     this.useCount = 0;
- 42 
- 43     if (this.build) {
- 44         this.build();
- 45     }
- 46 };
- 47 
- 48 /**
- 49  * Initialises the chunk. This is called within the constructor, and also to by the owner {@link SceneJS_ChunkFactory}
- 50  * when recycling a chunk from its free chunk pool. This method sets the given properties on the chunk, then calls the
- 51  * chunk instance's <b>build</b> method if the chunk has been augmented with one.
- 52  *
- 53  * @param {Number} id Chunk ID
- 54  * @param {SceneJS_Program} program Program to render the chunk
- 55  * @param {SceneJS_Core} core The state core rendered by this chunk
- 56  */
- 57 SceneJS_Chunk.prototype.init = function(id, program, core) {
- 58 
- 59     this.id = id;
- 60     this.program = program;
- 61     this.core = core;
- 62 
- 63     if (this.build) {
- 64         this.build();
- 65     }
- 66 };
- 67 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_chunkFactory.js.html b/docs/symbols/src/src_core_display_chunks_chunkFactory.js.html deleted file mode 100644 index 7cb1ab44..00000000 --- a/docs/symbols/src/src_core_display_chunks_chunkFactory.js.html +++ /dev/null @@ -1,148 +0,0 @@ -
  1 /**
-  2  * @class Manages creation, reuse and destruction of {@link SceneJS_Chunk}s for the nodes within a single {@link SceneJS_Display}.
-  3  * @private
-  4  */
-  5 var SceneJS_ChunkFactory = function() {
-  6 
-  7     this._chunks = {};
-  8 };
-  9 
- 10 /**
- 11  * Sub-classes of {@link SceneJS_Chunk} provided by this factory
- 12  */
- 13 SceneJS_ChunkFactory._chunkTypes = {};    // Supported chunk classes, installed by #createChunkType
- 14 
- 15 /**
- 16  * Free pool of unused {@link SceneJS_Chunk} instances
- 17  */
- 18 SceneJS_ChunkFactory._freeChunks = {};    // Free chunk pool for each type
- 19 
- 20 /**
- 21  * Creates a chunk class for instantiation by this factory
- 22  *
- 23  * @param params Members to augment the chunk class prototype with
- 24  * @param params.type Type name for the new chunk class
- 25  * @param params.draw Method to render the chunk in draw render
- 26  * @param params.pick Method to render the chunk in pick render
- 27  * @param params.drawAndPick Method to render the chunk in both draw and pick renders
- 28  */
- 29 SceneJS_ChunkFactory.createChunkType = function(params) {
- 30 
- 31     if (!params.type) {
- 32         throw "'type' expected in params";
- 33     }
- 34 
- 35     var supa = SceneJS_Chunk;
- 36 
- 37     var chunkClass = function() { // Create the class
- 38         supa.apply(this, arguments);
- 39         this.type = params.type;
- 40     };
- 41 
- 42     chunkClass.prototype = new supa();              // Inherit from base class
- 43     chunkClass.prototype.constructor = chunkClass;
- 44 
- 45     if (params.drawAndPick) {                       // Common method for draw and pick render
- 46         params.draw = params.pick = params.drawAndPick;
- 47     }
- 48 
- 49     SceneJS_ChunkFactory._chunkTypes[params.type] = chunkClass;
- 50 
- 51     SceneJS._apply(params, chunkClass.prototype);   // Augment subclass
- 52 
- 53     SceneJS_ChunkFactory._freeChunks[params.type] = { // Set up free chunk pool for this type
- 54         chunks: [],
- 55         chunksLen: 0
- 56     };
- 57 
- 58     return chunkClass;
- 59 };
- 60 
- 61 /**
- 62  *
- 63  */
- 64 SceneJS_ChunkFactory.prototype.getChunk = function(chunkId, type, program, core) {
- 65 
- 66     var chunkClass = SceneJS_ChunkFactory._chunkTypes[type]; // Check type supported
- 67 
- 68     if (!chunkClass) {
- 69         throw "chunk type not supported: '" + type + "'";
- 70     }
- 71 
- 72     var chunk = this._chunks[chunkId];  // Try to reference an existing chunk
- 73 
- 74     if (chunk) {
- 75         chunk.useCount++;
- 76         return chunk;
- 77     }
- 78 
- 79     var freeChunks = SceneJS_ChunkFactory._freeChunks[type]; // Try to recycle a free chunk
- 80 
- 81     if (freeChunks.chunksLen > 0) {
- 82         chunk = freeChunks.chunks[--freeChunks.chunksLen];
- 83     }
- 84 
- 85     if (chunk) {    // Reinitialise the recycled chunk
- 86 
- 87         chunk.init(chunkId, program, core);
- 88 
- 89     } else {        // Instantiate a fresh chunk
- 90 
- 91         chunk = new chunkClass(chunkId, type, program, core); // Create new chunk
- 92     }
- 93 
- 94     chunk.useCount = 1;
- 95 
- 96     this._chunks[chunkId] = chunk;
- 97 
- 98     return chunk;
- 99 };
-100 
-101 /**
-102  * Releases a display state chunk back to this factory, destroying it if the chunk's use count is then zero.
-103  *
-104  * @param {SceneJS_Chunk} chunk Chunk to release
-105  */
-106 SceneJS_ChunkFactory.prototype.putChunk = function (chunk) {
-107 
-108     if (chunk.useCount == 0) {
-109         return; // In case of excess puts
-110     }
-111 
-112     if (--chunk.useCount <= 0) {    // Release shared core if use count now zero
-113 
-114         this._chunks[chunk.id] = null;
-115 
-116         var freeChunks = SceneJS_ChunkFactory._freeChunks[chunk.type];
-117 
-118         freeChunks.chunks[freeChunks.chunksLen++] = chunk;
-119     }
-120 };
-121 
-122 /**
-123  * Re-cache shader variable locations for each active chunk
-124  */
-125 SceneJS_ChunkFactory.prototype.webglRestored = function () {
-126 
-127     var chunk;
-128 
-129     for (var chunkId in this._chunks) {
-130 
-131         if (this._chunks.hasOwnProperty(chunkId)) {
-132 
-133             chunk = this._chunks[chunkId]; // Re-cache chunk's shader variable locations
-134 
-135             if (chunk.build) {
-136                 chunk.build();
-137             }
-138         }
-139     }
-140 };
-141 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_clipsChunk.js.html b/docs/symbols/src/src_core_display_chunks_clipsChunk.js.html deleted file mode 100644 index 1211382e..00000000 --- a/docs/symbols/src/src_core_display_chunks_clipsChunk.js.html +++ /dev/null @@ -1,80 +0,0 @@ -
  1 /**
-  2  * Create display state chunk type for draw and pick render of user clipping planes
-  3  */
-  4 SceneJS_ChunkFactory.createChunkType({
-  5 
-  6     type: "clips",
-  7 
-  8     build : function() {
-  9 
- 10         this._draw = this._draw || [];
- 11 
- 12         var draw = this.program.draw;
- 13 
- 14         for (var i = 0, len = this.core.clips.length; i < len; i++) {
- 15             this._draw[i] = {
- 16                 uClipMode :draw.getUniformLocation("SCENEJS_uClipMode" + i),
- 17                 uClipNormalAndDist: draw.getUniformLocation("SCENEJS_uClipNormalAndDist" + i)
- 18             };
- 19         }
- 20 
- 21         this._pick = this._pick || [];
- 22 
- 23         var pick = this.program.pick;
- 24 
- 25         for (var i = 0, len = this.core.clips.length; i < len; i++) {
- 26             this._pick[i] = {
- 27                 uClipMode :pick.getUniformLocation("SCENEJS_uClipMode" + i),
- 28                 uClipNormalAndDist: pick.getUniformLocation("SCENEJS_uClipNormalAndDist" + i)
- 29             };
- 30         }
- 31     },
- 32 
- 33     drawAndPick: function(ctx) {
- 34 
- 35         var vars = (ctx.pick) ? this._pick : this._draw;
- 36 
- 37         var mode;
- 38         var normalAndDist;
- 39         var clips = this.core.clips;
- 40         var clip;
- 41         var gl = this.program.gl;
- 42 
- 43         for (var i = 0, len = clips.length; i < len; i++) {
- 44 
- 45             if (ctx.pick) {
- 46                 mode = vars[i].uClipMode;
- 47                 normalAndDist = vars[i].uClipNormalAndDist;
- 48             } else {
- 49                 mode = vars[i].uClipMode;
- 50                 normalAndDist = vars[i].uClipNormalAndDist;
- 51             }
- 52 
- 53             if (mode && normalAndDist) {
- 54 
- 55                 clip = clips[i];
- 56 
- 57                 if (clip.mode == "inside") {
- 58 
- 59                     gl.uniform1f(mode, 2);
- 60                     gl.uniform4fv(normalAndDist, clip.normalAndDist);
- 61 
- 62                 } else if (clip.mode == "outside") {
- 63 
- 64                     gl.uniform1f(mode, 1);
- 65                     gl.uniform4fv(normalAndDist, clip.normalAndDist);
- 66 
- 67                 } else { // disabled
- 68                     gl.uniform1f(mode, 0);
- 69                 }
- 70             }
- 71         }
- 72     }
- 73 });
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_drawChunk.js.html b/docs/symbols/src/src_core_display_chunks_drawChunk.js.html deleted file mode 100644 index 643f9bd0..00000000 --- a/docs/symbols/src/src_core_display_chunks_drawChunk.js.html +++ /dev/null @@ -1,32 +0,0 @@ -
  1 /**
-  2  *
-  3  */
-  4 SceneJS_ChunkFactory.createChunkType({
-  5 
-  6     type:"draw",
-  7 
-  8     /**
-  9      * As we apply a list of state chunks in a {@link SceneJS_Display}, we track the ID of each chunk
- 10      * in order to avoid redundantly re-applying the same chunk.
- 11      *
- 12      * We don't want that for draw chunks however, because they contain GL drawElements calls,
- 13      * which we need to do for each object.
- 14      */
- 15     unique:true,
- 16 
- 17     build:function () {},
- 18 
- 19     drawAndPick:function (ctx) {
- 20 
- 21         var gl = this.program.gl;
- 22 
- 23         gl.drawElements(this.core.primitive, this.core.indexBuf.numItems, gl.UNSIGNED_SHORT, 0);
- 24     }
- 25 });
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_flagsChunk.js.html b/docs/symbols/src/src_core_display_chunks_flagsChunk.js.html deleted file mode 100644 index b18ebd9e..00000000 --- a/docs/symbols/src/src_core_display_chunks_flagsChunk.js.html +++ /dev/null @@ -1,67 +0,0 @@ -
  1 /**
-  2  *  Create display state chunk type for draw and pick render of flags
-  3  */
-  4 SceneJS_ChunkFactory.createChunkType({
-  5 
-  6     type: "flags",
-  7 
-  8     build : function() {
-  9 
- 10         var draw = this.program.draw;
- 11 
- 12         this._uBackfaceTexturingDraw = draw.getUniformLocation("SCENEJS_uBackfaceTexturing");
- 13         this._uBackfaceLightingDraw = draw.getUniformLocation("SCENEJS_uBackfaceLighting");
- 14         this._uSpecularLightingDraw = draw.getUniformLocation("SCENEJS_uSpecularLighting");
- 15         this._uClippingDraw = draw.getUniformLocation("SCENEJS_uClipping");
- 16         this._uAmbientDraw = draw.getUniformLocation("SCENEJS_uAmbient");
- 17 
- 18         var pick = this.program.pick;
- 19 
- 20         this._uClippingPick = pick.getUniformLocation("SCENEJS_uClipping");
- 21     },
- 22 
- 23     drawAndPick : function(ctx) {
- 24 
- 25         var gl = this.program.gl;
- 26 
- 27         var backfaces = this.core.backfaces;
- 28 
- 29         if (ctx.backfaces != backfaces) {
- 30             if (backfaces) {
- 31                 gl.disable(gl.CULL_FACE);
- 32             } else {
- 33                 gl.enable(gl.CULL_FACE);
- 34             }
- 35             ctx.backfaces = backfaces;
- 36         }
- 37 
- 38         var frontface = this.core.frontface;
- 39 
- 40 //        if (ctx.frontface != frontface) {
- 41 //            if (frontface == "ccw") {
- 42 //                gl.frontFace(gl.CCW);
- 43 //            } else {
- 44 //                gl.frontFace(gl.CW);
- 45 //            }
- 46 //            ctx.frontface = frontface;
- 47 //        }
- 48 
- 49         if (ctx.pick) {
- 50             gl.uniform1i(this._uClippingPick, this.core.clipping);
- 51 
- 52         } else {
- 53             gl.uniform1i(this._uBackfaceTexturingDraw, this.core.backfaceTexturing);
- 54             gl.uniform1i(this._uBackfaceLightingDraw, this.core.backfaceLighting);
- 55             gl.uniform1i(this._uSpecularLightingDraw, this.core.specular);
- 56             gl.uniform1i(this._uClippingDraw, this.core.clipping);
- 57             gl.uniform1i(this._uAmbientDraw, this.core.ambient);
- 58         }
- 59     }
- 60 });
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_framebufChunk.js.html b/docs/symbols/src/src_core_display_chunks_framebufChunk.js.html deleted file mode 100644 index 4ae40059..00000000 --- a/docs/symbols/src/src_core_display_chunks_framebufChunk.js.html +++ /dev/null @@ -1,36 +0,0 @@ -
  1 /**
-  2  *   Create display state chunk type for draw and pick render of framebuf
-  3  */
-  4 SceneJS_ChunkFactory.createChunkType({
-  5 
-  6     type: "framebuf",
-  7 
-  8     build: function() {
-  9     },
- 10 
- 11     drawAndPick: function(ctx) {
- 12 
- 13         if (ctx.framebuf) {
- 14 
- 15             this.program.gl.finish(); // Force framebuf to complete
- 16 
- 17             ctx.framebuf.unbind();
- 18         }
- 19 
- 20         var framebuf = this.core.framebuf;
- 21 
- 22         if (framebuf) {
- 23 
- 24             framebuf.bind();
- 25 
- 26             ctx.framebuf = framebuf;  // Must flush on cleanup
- 27         }
- 28     }
- 29 });
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_geometryChunk.js.html b/docs/symbols/src/src_core_display_chunks_geometryChunk.js.html deleted file mode 100644 index b1719de3..00000000 --- a/docs/symbols/src/src_core_display_chunks_geometryChunk.js.html +++ /dev/null @@ -1,106 +0,0 @@ -
  1 /**
-  2  *  Create display state chunk type for draw and pick render of geometry
-  3  */
-  4 SceneJS_ChunkFactory.createChunkType({
-  5 
-  6     type:"geometry",
-  7 
-  8     /**
-  9      * As we apply a list of state chunks in a {@link SceneJS_Display}, we track the ID of each chunk
- 10      * in order to avoid redundantly re-applying the same chunk.
- 11      *
- 12      * We don't want that for draw chunks however, because they contain GL drawElements calls,
- 13      * which we need to do for each object.
- 14      */
- 15     unique:true,
- 16 
- 17     build:function () {
- 18 
- 19         var draw = this.program.draw;
- 20 
- 21         this._aVertexDraw = draw.getAttribute("SCENEJS_aVertex");
- 22         this._aNormalDraw = draw.getAttribute("SCENEJS_aNormal");
- 23         this._aUVDraw = draw.getAttribute("SCENEJS_aUVCoord");
- 24         this._aUV2Draw = draw.getAttribute("SCENEJS_aUVCoord2");
- 25         this._aColorDraw = draw.getAttribute("SCENEJS_aVertexColor");
- 26 
- 27         var pick = this.program.pick;
- 28 
- 29         this._aVertexPick = pick.getAttribute("SCENEJS_aVertex");
- 30         this._aNormalPick = pick.getAttribute("SCENEJS_aNormal");
- 31         this._aUVPick = pick.getAttribute("SCENEJS_aUVCoord");
- 32         this._aUV2Pick = pick.getAttribute("SCENEJS_aUVCoord2");
- 33         this._aColorPick = pick.getAttribute("SCENEJS_aVertexColor");
- 34     },
- 35 
- 36     draw:function (ctx) {
- 37 
- 38         var gl = this.program.gl;
- 39 
- 40         if (ctx.geoChunkId != this.id) { // HACK until we have distinct state chunks for VBOs and draw call
- 41 
- 42             if (this._aVertexDraw && !ctx.vertexBuf) {
- 43                 this._aVertexDraw.bindFloatArrayBuffer(this.core.vertexBuf);
- 44             }
- 45 
- 46             if (this._aNormalDraw && !ctx.normalBuf) {
- 47                 this._aNormalDraw.bindFloatArrayBuffer(this.core.normalBuf);
- 48             }
- 49 
- 50             if (this._aUVDraw && !ctx.uvBuf) {
- 51                 this._aUVDraw.bindFloatArrayBuffer(this.core.uvBuf);
- 52             }
- 53 
- 54             if (this._aUV2Draw && !ctx.uvBuf2) {
- 55                 this._aUV2Draw.bindFloatArrayBuffer(this.core.uvBuf2);
- 56             }
- 57 
- 58             if (this._aColorDraw && !ctx.colorBuf) {
- 59                 this._aColorDraw.bindFloatArrayBuffer(this.core.colorBuf);
- 60             }
- 61 
- 62             this.core.indexBuf.bind();
- 63 
- 64             ctx.geoChunkId = this.id;
- 65         }
- 66 
- 67         gl.drawElements(this.core.primitive, this.core.indexBuf.numItems, gl.UNSIGNED_SHORT, 0);
- 68     },
- 69 
- 70     pick:function (ctx) {
- 71 
- 72         var gl = this.program.gl;
- 73 
- 74         if (ctx.geoChunkId != this.id) { // HACK until we have distinct state chunks for VBOs and draw call
- 75 
- 76             if (this._aVertexPick && !ctx.vertexBuf) {
- 77                 this._aVertexPick.bindFloatArrayBuffer(this.core.vertexBuf);
- 78             }
- 79 
- 80             if (this._aNormalPick && !ctx.normalBuf) {
- 81                 this._aNormalPick.bindFloatArrayBuffer(this.core.normalBuf);
- 82             }
- 83 
- 84             if (this._aUVPick && !ctx.uvBuf) {
- 85                 this._aUVPick.bindFloatArrayBuffer(this.core.uvBuf);
- 86             }
- 87 
- 88             if (this._aUV2Pick && !ctx.uvBuf2) {
- 89                 this._aUV2Pick.bindFloatArrayBuffer(this.core.uvBuf2);
- 90             }
- 91 
- 92             this.core.indexBuf.bind();
- 93 
- 94             ctx.geoChunkId = this.id;
- 95         }
- 96 
- 97         gl.drawElements(this.core.primitive, this.core.indexBuf.numItems, gl.UNSIGNED_SHORT, 0);
- 98     }
- 99 });
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_lightsChunk.js.html b/docs/symbols/src/src_core_display_chunks_lightsChunk.js.html deleted file mode 100644 index 1fa6a267..00000000 --- a/docs/symbols/src/src_core_display_chunks_lightsChunk.js.html +++ /dev/null @@ -1,85 +0,0 @@ -
  1 /**
-  2  *  Create display state chunk type for draw render of lights projection
-  3  */
-  4 SceneJS_ChunkFactory.createChunkType({
-  5 
-  6     type:"lights",
-  7 
-  8     build:function () {
-  9 
- 10         this._uAmbientColor = this._uAmbientColor || [];
- 11         this._uLightColor = this._uLightColor || [];
- 12         this._uLightDir = this._uLightDir || [];
- 13         this._uLightPos = this._uLightPos || [];
- 14         this._uLightCutOff = this._uLightCutOff || [];
- 15         this._uLightSpotExp = this._uLightSpotExp || [];
- 16         this._uLightAttenuation = this._uLightAttenuation || [];
- 17 
- 18         var lights = this.core.lights;
- 19         var program = this.program;
- 20 
- 21         for (var i = 0, len = lights.length; i < len; i++) {
- 22 
- 23             switch (lights[i].mode) {
- 24 
- 25                 case "ambient":
- 26                     this._uAmbientColor[i] = (program.draw.getUniformLocation("SCENEJS_uAmbientColor"));
- 27                     break;
- 28 
- 29                 case "dir":
- 30                     this._uLightColor[i] = program.draw.getUniformLocation("SCENEJS_uLightColor" + i);
- 31                     this._uLightPos[i] = null;
- 32                     this._uLightDir[i] = program.draw.getUniformLocation("SCENEJS_uLightDir" + i);
- 33                     break;
- 34 
- 35                 case "point":
- 36                     this._uLightColor[i] = program.draw.getUniformLocation("SCENEJS_uLightColor" + i);
- 37                     this._uLightPos[i] = program.draw.getUniformLocation("SCENEJS_uLightPos" + i);
- 38                     this._uLightDir[i] = null;
- 39                     break;
- 40             }
- 41         }
- 42     },
- 43 
- 44     draw:function (ctx) {
- 45 
- 46         if (ctx.dirty) {
- 47             this.build();
- 48         }
- 49 
- 50         var lights = this.core.lights;
- 51         var light;
- 52 
- 53         var gl = this.program.gl;
- 54 
- 55         for (var i = 0, len = lights.length; i < len; i++) {
- 56 
- 57             light = lights[i];
- 58 
- 59             if (this._uAmbientColor[i]) {
- 60                 gl.uniform3fv(this._uAmbientColor[i], light.color);
- 61 
- 62             } else {
- 63 
- 64                 if (this._uLightColor[i]) {
- 65                     gl.uniform3fv(this._uLightColor[i], light.color);
- 66                 }
- 67 
- 68                 if (this._uLightPos[i]) {
- 69                     gl.uniform3fv(this._uLightPos[i], light.pos);
- 70                 }
- 71 
- 72                 if (this._uLightDir[i]) {
- 73                     gl.uniform3fv(this._uLightDir[i], light.dir);
- 74                 }
- 75             }
- 76         }
- 77     }
- 78 });
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_listenersChunk.js.html b/docs/symbols/src/src_core_display_chunks_listenersChunk.js.html deleted file mode 100644 index 8aa00630..00000000 --- a/docs/symbols/src/src_core_display_chunks_listenersChunk.js.html +++ /dev/null @@ -1,29 +0,0 @@ -
  1 /**
-  2  *
-  3  */
-  4 SceneJS_ChunkFactory.createChunkType({
-  5 
-  6     type: "listeners",
-  7 
-  8     build : function() {
-  9     },
- 10 
- 11     draw : function(ctx) {
- 12 
- 13         var listeners = this.core.listeners;
- 14         var renderListenerCtx = ctx.renderListenerCtx;
- 15 
- 16         for (var i = listeners.length - 1; i >= 0; i--) { // Child listeners first
- 17             if (listeners[i](renderListenerCtx) === true) { // Call listener with query facade object as scope
- 18                 return true;
- 19             }
- 20         }
- 21     }
- 22 });
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_lookAtChunk.js.html b/docs/symbols/src/src_core_display_chunks_lookAtChunk.js.html deleted file mode 100644 index 36ac4e8b..00000000 --- a/docs/symbols/src/src_core_display_chunks_lookAtChunk.js.html +++ /dev/null @@ -1,57 +0,0 @@ -
  1 /**
-  2  * Create display state chunk type for draw and pick render of lookAt transform
-  3  */
-  4 SceneJS_ChunkFactory.createChunkType({
-  5 
-  6     type: "lookAt",
-  7 
-  8     build : function() {
-  9 
- 10         this._uvMatrixDraw = this.program.draw.getUniformLocation("SCENEJS_uVMatrix");
- 11         this._uVNMatrixDraw = this.program.draw.getUniformLocation("SCENEJS_uVNMatrix");
- 12         this._uWorldEyeDraw = this.program.draw.getUniformLocation("SCENEJS_uWorldEye");
- 13 
- 14         this._uvMatrixPick = this.program.pick.getUniformLocation("SCENEJS_uVMatrix");
- 15     },
- 16 
- 17     draw : function(ctx) {
- 18 
- 19         if (this.core.dirty) {
- 20             this.core.rebuild();
- 21         }
- 22 
- 23         var gl = this.program.gl;
- 24 
- 25         if (this._uvMatrixDraw) {
- 26             gl.uniformMatrix4fv(this._uvMatrixDraw, gl.FALSE, this.core.mat);
- 27         }
- 28 
- 29         if (this._uVNMatrixDraw) {
- 30             gl.uniformMatrix4fv(this._uVNMatrixDraw, gl.FALSE, this.core.normalMat);
- 31         }
- 32 
- 33         if (this._uWorldEyeDraw) {
- 34             gl.uniform3fv(this._uWorldEyeDraw, this.core.lookAt.eye);
- 35         }
- 36 
- 37         ctx.viewMat = this.core.mat;
- 38     },
- 39 
- 40     pick : function(ctx) {
- 41 
- 42         var gl = this.program.gl;
- 43 
- 44         if (this._uvMatrixPick) {
- 45             gl.uniformMatrix4fv(this._uvMatrixPick, gl.FALSE, this.core.mat);
- 46         }
- 47 
- 48         ctx.viewMat = this.core.mat;
- 49     }
- 50 });
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_materialChunk.js.html b/docs/symbols/src/src_core_display_chunks_materialChunk.js.html deleted file mode 100644 index cc8c2f1f..00000000 --- a/docs/symbols/src/src_core_display_chunks_materialChunk.js.html +++ /dev/null @@ -1,55 +0,0 @@ -
  1 /**
-  2  * Create display state chunk type for draw render of material transform
-  3  */
-  4 SceneJS_ChunkFactory.createChunkType({
-  5 
-  6     type: "material",
-  7 
-  8     build : function() {
-  9 
- 10         var draw = this.program.draw;
- 11 
- 12         this._uMaterialBaseColor = draw.getUniformLocation("SCENEJS_uMaterialBaseColor");
- 13         this._uMaterialSpecularColor = draw.getUniformLocation("SCENEJS_uMaterialSpecularColor");
- 14         this._uMaterialSpecular = draw.getUniformLocation("SCENEJS_uMaterialSpecular");
- 15         this._uMaterialShine = draw.getUniformLocation("SCENEJS_uMaterialShine");
- 16         this._uMaterialEmit = draw.getUniformLocation("SCENEJS_uMaterialEmit");
- 17         this._uMaterialAlpha = draw.getUniformLocation("SCENEJS_uMaterialAlpha");
- 18     },
- 19 
- 20     draw : function() {
- 21 
- 22         var gl = this.program.gl;
- 23 
- 24         if (this._uMaterialBaseColor) {
- 25             gl.uniform3fv(this._uMaterialBaseColor, this.core.baseColor);
- 26         }
- 27 
- 28         if (this._uMaterialSpecularColor) {
- 29             gl.uniform3fv(this._uMaterialSpecularColor, this.core.specularColor);
- 30         }
- 31 
- 32         if (this._uMaterialSpecular) {
- 33             gl.uniform1f(this._uMaterialSpecular, this.core.specular);
- 34         }
- 35 
- 36         if (this._uMaterialShine) {
- 37             gl.uniform1f(this._uMaterialShine, this.core.shine);
- 38         }
- 39 
- 40         if (this._uMaterialEmit) {
- 41             gl.uniform1f(this._uMaterialEmit, this.core.emit);
- 42         }
- 43 
- 44         if (this._uMaterialAlpha) {
- 45             gl.uniform1f(this._uMaterialAlpha, this.core.alpha);
- 46         }
- 47     }
- 48 });
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_morphGeometryChunk.js.html b/docs/symbols/src/src_core_display_chunks_morphGeometryChunk.js.html deleted file mode 100644 index 5398193c..00000000 --- a/docs/symbols/src/src_core_display_chunks_morphGeometryChunk.js.html +++ /dev/null @@ -1,174 +0,0 @@ -
  1 /**
-  2  * Create display state chunk type for draw render of material transform
-  3  */
-  4 SceneJS_ChunkFactory.createChunkType({
-  5 
-  6     type:"morphGeometry",
-  7 
-  8     build:function () {
-  9 
- 10         var draw = this.program.draw;
- 11 
- 12         this._aVertexDraw = draw.getAttribute("SCENEJS_aVertex");
- 13         this._aNormalDraw = draw.getAttribute("SCENEJS_aNormal");
- 14         this._aUVDraw = draw.getAttribute("SCENEJS_aUVCoord");
- 15         this._aUV2Draw = draw.getAttribute("SCENEJS_aUVCoord2");
- 16         this._aColorDraw = draw.getAttribute("SCENEJS_aVertexColor");
- 17 
- 18         this._aMorphVertexDraw = draw.getAttribute("SCENEJS_aMorphVertex");
- 19         this._aMorphNormalDraw = draw.getAttribute("SCENEJS_aMorphNormal");
- 20         this._aMorphUVDraw = draw.getAttribute("SCENEJS_aMorphUVCoord");
- 21         this._aMorphUV2Draw = draw.getAttribute("SCENEJS_aMorphUVCoord2");
- 22         this._aMorphColorDraw = draw.getAttribute("SCENEJS_aMorphColor");
- 23         this._uMorphFactorDraw = draw.getUniformLocation("SCENEJS_uMorphFactor");
- 24 
- 25         var pick = this.program.pick;
- 26 
- 27         this._aVertexPick = pick.getAttribute("SCENEJS_aVertex");
- 28         this._aNormalPick = pick.getAttribute("SCENEJS_aNormal");
- 29         this._aUVPick = pick.getAttribute("SCENEJS_aUVCoord");
- 30         this._aUV2Pick = pick.getAttribute("SCENEJS_aUVCoord2");
- 31         this._aColorPick = pick.getAttribute("SCENEJS_aVertexColor");
- 32 
- 33         this._aMorphVertexPick = pick.getAttribute("SCENEJS_aMorphVertex");
- 34         this._aMorphNormalPick = pick.getAttribute("SCENEJS_aMorphNormal");
- 35         this._aMorphUVPick = pick.getAttribute("SCENEJS_aMorphUVCoord");
- 36         this._aMorphUV2Pick = pick.getAttribute("SCENEJS_aMorphUVCoord2");
- 37         this._aMorphColorPick = pick.getAttribute("SCENEJS_aMorphColor");
- 38         this._uMorphFactorPick = pick.getUniformLocation("SCENEJS_uMorphFactor");
- 39     },
- 40 
- 41     draw:function (ctx) {
- 42 
- 43         var targets = this.core.targets;
- 44 
- 45         if (!targets || targets.length == 0) {
- 46             ctx.vertexBuf = false;
- 47             ctx.normalBuf = false;
- 48             ctx.uvBuf = false;
- 49             ctx.uvBuf2 = false;
- 50             ctx.colorBuf = false;
- 51             return;
- 52         }
- 53 
- 54         var gl = this.program.gl;
- 55 
- 56         var target1 = this.core.targets[this.core.key1]; // Keys will update
- 57         var target2 = this.core.targets[this.core.key2];
- 58 
- 59         if (this._aMorphVertexDraw) {
- 60             this._aVertexDraw.bindFloatArrayBuffer(target1.vertexBuf);
- 61             this._aMorphVertexDraw.bindFloatArrayBuffer(target2.vertexBuf);
- 62             ctx.vertexBuf = true;
- 63         } else {
- 64             ctx.vertexBuf = false;
- 65         }
- 66 
- 67         if (this._aMorphNormalDraw) {
- 68             this._aNormalDraw.bindFloatArrayBuffer(target1.normalBuf);
- 69             this._aMorphNormalDraw.bindFloatArrayBuffer(target2.normalBuf);
- 70             ctx.normalBuf = true;
- 71         } else {
- 72             ctx.normalBuf = false;
- 73         }
- 74 
- 75         if (this._aMorphUVDraw) {
- 76             this._aUVDraw.bindFloatArrayBuffer(target1.uvBuf);
- 77             this._aMorphUVDraw.bindFloatArrayBuffer(target2.uvBuf);
- 78             ctx.uvBuf = true;
- 79         } else {
- 80             ctx.uvBuf = false;
- 81         }
- 82 
- 83         if (this._aMorphUV2Draw) {
- 84             this._aUV2Draw.bindFloatArrayBuffer(target1.uvBuf2);
- 85             this._aMorphUV2Draw.bindFloatArrayBuffer(target2.uvBuf2);
- 86             ctx.uvBuf2 = true;
- 87         } else {
- 88             ctx.uvBuf2 = false;
- 89         }
- 90 
- 91         if (this._aMorphColorDraw) {
- 92             this._aColorDraw.bindFloatArrayBuffer(target1.colorBuf);
- 93             this._aMorphColorDraw.bindFloatArrayBuffer(target2.colorBuf);
- 94             ctx.colorBuf = true;
- 95         } else {
- 96             ctx.colorBuf = false;
- 97         }
- 98 
- 99         if (this._uMorphFactorDraw) {
-100             gl.uniform1f(this._uMorphFactorDraw, this.core.factor); // Bind LERP factor
-101         }
-102     },
-103 
-104     pick:function (ctx) {
-105 
-106         var targets = this.core.targets;
-107 
-108         if (!targets || targets.length == 0) {
-109             ctx.vertexBuf = false;
-110             ctx.normalBuf = false;
-111             ctx.uvBuf = false;
-112             ctx.uvBuf2 = false;
-113             ctx.colorBuf = false;
-114             return;
-115         }
-116 
-117         var gl = this.program.gl;
-118 
-119         var target1 = targets[this.core.key1]; // Keys will update
-120         var target2 = targets[this.core.key2];
-121 
-122         if (this._aMorphVertexPick) {
-123             this._aVertexPick.bindFloatArrayBuffer(target1.vertexBuf);
-124             this._aMorphVertexPick.bindFloatArrayBuffer(target2.vertexBuf);
-125             ctx.vertexBuf = true;
-126         } else {
-127             ctx.vertexBuf = false;
-128         }
-129 
-130         if (this._aMorphNormalPick) {
-131             this._aNormalPick.bindFloatArrayBuffer(target1.normalBuf);
-132             this._aMorphNormalPick.bindFloatArrayBuffer(target2.normalBuf);
-133             ctx.normalBuf = true;
-134         } else {
-135             ctx.normalBuf = false;
-136         }
-137 
-138         if (this._aMorphUVPick) {
-139             this._aUVPick.bindFloatArrayBuffer(target1.uvBuf);
-140             this._aMorphUVPick.bindFloatArrayBuffer(target2.uvBuf);
-141             ctx.uvBuf = true;
-142         } else {
-143             ctx.uvBuf = false;
-144         }
-145 
-146         if (this._aMorphUV2Pick) {
-147             this._aUV2Pick.bindFloatArrayBuffer(target1.uvBuf2);
-148             this._aMorphUV2Pick.bindFloatArrayBuffer(target2.uvBuf2);
-149             ctx.uvBuf2 = true;
-150         } else {
-151             ctx.uvBuf2 = false;
-152         }
-153 
-154         if (this._aMorphColorPick) {
-155             this._aColorPick.bindFloatArrayBuffer(target1.colorBuf);
-156             this._aMorphColorPick.bindFloatArrayBuffer(target2.colorBuf);
-157             ctx.colorBuf = true;
-158         } else {
-159             ctx.colorBuf = false;
-160         }
-161 
-162         if (this._uMorphFactorPick) {
-163             gl.uniform1f(this._uMorphFactorPick, this.core.factor); // Bind LERP factor
-164         }
-165     }
-166 });
-167 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_nameChunk.js.html b/docs/symbols/src/src_core_display_chunks_nameChunk.js.html deleted file mode 100644 index b6ef7040..00000000 --- a/docs/symbols/src/src_core_display_chunks_nameChunk.js.html +++ /dev/null @@ -1,32 +0,0 @@ -
  1 /**
-  2  * Create display state chunk type for draw render of material transform
-  3  */
-  4 SceneJS_ChunkFactory.createChunkType({
-  5 
-  6     type: "name",
-  7 
-  8     build : function() {
-  9         this._uPickColor = this.program.pick.getUniformLocation("SCENEJS_uPickColor");
- 10     },
- 11 
- 12     pick : function(ctx) {
- 13 
- 14         if (this._uPickColor && this.core.name) {
- 15 
- 16             ctx.pickNames[ctx.pickIndex++] = this.core.name;
- 17 
- 18             var b = ctx.pickIndex >> 16 & 0xFF;
- 19             var g = ctx.pickIndex >> 8 & 0xFF;
- 20             var r = ctx.pickIndex & 0xFF;
- 21 
- 22             this.program.gl.uniform3fv(this._uPickColor, [r / 255, g / 255, b / 255]);
- 23         }
- 24     }
- 25 });
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_programChunk.js.html b/docs/symbols/src/src_core_display_chunks_programChunk.js.html deleted file mode 100644 index b73bfd59..00000000 --- a/docs/symbols/src/src_core_display_chunks_programChunk.js.html +++ /dev/null @@ -1,81 +0,0 @@ -
  1 SceneJS_ChunkFactory.createChunkType({
-  2 
-  3     type: "program",
-  4 
-  5     build : function() {
-  6         this._rayPickMode = this.program.pick.getUniformLocation("SCENEJS_uRayPickMode");
-  7     },
-  8 
-  9     draw : function(frameCtx) {
- 10 
- 11         var drawProgram = this.program.draw;
- 12 
- 13         if (frameCtx.program) {
- 14             frameCtx.program.unbind();
- 15         }
- 16 
- 17         drawProgram.bind();
- 18 
- 19         frameCtx.program = drawProgram;
- 20 
- 21         /*
- 22          * HACK until we have distinct chunk for each VBO (maybe)
- 23          */
- 24         frameCtx.vertexBuf = false;
- 25         frameCtx.normalBuf = false;
- 26         frameCtx.uvBuf = false;
- 27         frameCtx.uvBuf2 = false;
- 28         frameCtx.colorBuf = false;
- 29 
- 30         frameCtx.geoChunkId = null; // HACK until we have distinct state chunks for VBOs and draw call
- 31 
- 32         var gl = this.program.gl;
- 33 
- 34         for (var i = 0; i < 10; i++) {
- 35             gl.disableVertexAttribArray(i);
- 36         }
- 37     },
- 38 
- 39     pick : function(frameCtx) {
- 40 
- 41         var pickProgram = this.program.pick;
- 42 
- 43         if (frameCtx.program) {
- 44             frameCtx.program.unbind();
- 45         }
- 46 
- 47         pickProgram.bind();
- 48 
- 49         var gl = this.program.gl;
- 50 
- 51         gl.uniform1i(this._rayPickMode, frameCtx.rayPick);
- 52 
- 53         frameCtx.program = pickProgram;
- 54 
- 55         /*
- 56         * HACK until we have distinct chunk for each VBO (maybe)
- 57          */
- 58         frameCtx.vertexBuf = false;
- 59         frameCtx.normalBuf = false;
- 60         frameCtx.uvBuf = false;
- 61         frameCtx.uvBuf2 = false;
- 62         frameCtx.colorBuf = false;
- 63 
- 64         frameCtx.geoChunkId = null; // HACK until we have distinct state chunks for VBOs and draw call
- 65 
- 66         for (var i = 0; i < 10; i++) {
- 67             gl.disableVertexAttribArray(i);
- 68         }
- 69     }
- 70 });
- 71 
- 72 
- 73 
- 74 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_rendererChunk.js.html b/docs/symbols/src/src_core_display_chunks_rendererChunk.js.html deleted file mode 100644 index 75339d8f..00000000 --- a/docs/symbols/src/src_core_display_chunks_rendererChunk.js.html +++ /dev/null @@ -1,33 +0,0 @@ -
  1 /**
-  2  *
-  3  */
-  4 SceneJS_ChunkFactory.createChunkType({
-  5     
-  6     type: "renderer",
-  7 
-  8     build : function() {
-  9     },
- 10 
- 11     drawAndPick : function(ctx) {
- 12 
- 13         if (this.core.props) {
- 14 
- 15             var gl = this.program.gl;
- 16 
- 17             if (ctx.renderer) {
- 18                 ctx.renderer.props.restoreProps(gl);
- 19                 ctx.renderer = this.core;
- 20             }
- 21 
- 22             this.core.props.setProps(gl);
- 23         }
- 24     }
- 25 });
- 26 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_shaderChunk.js.html b/docs/symbols/src/src_core_display_chunks_shaderChunk.js.html deleted file mode 100644 index 13942d4e..00000000 --- a/docs/symbols/src/src_core_display_chunks_shaderChunk.js.html +++ /dev/null @@ -1,38 +0,0 @@ -
  1 /**
-  2  *
-  3  */
-  4 SceneJS_ChunkFactory.createChunkType({
-  5 
-  6     type: "shader",
-  7 
-  8     build : function() {
-  9     },
- 10 
- 11     drawAndPick : function(ctx) {
- 12 
- 13         var paramsStack = this.core.paramsStack;
- 14 
- 15         if (paramsStack) {
- 16 
- 17             var program = ctx.pick ? this.program.pick : this.program.draw;
- 18             var params;
- 19             var name;
- 20 
- 21             for (var i = 0, len = paramsStack.length; i < len; i++) {
- 22                 params = paramsStack[i];
- 23                 for (name in params) {
- 24                     if (params.hasOwnProperty(name)) {
- 25                         program.setUniform(name, params[name]);  // TODO: cache locations
- 26                     }
- 27                 }
- 28             }
- 29         }
- 30     }
- 31 });
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_shaderParamsChunk.js.html b/docs/symbols/src/src_core_display_chunks_shaderParamsChunk.js.html deleted file mode 100644 index 37675bb9..00000000 --- a/docs/symbols/src/src_core_display_chunks_shaderParamsChunk.js.html +++ /dev/null @@ -1,38 +0,0 @@ -
  1 /**
-  2  *
-  3  */
-  4 SceneJS_ChunkFactory.createChunkType({
-  5 
-  6     type: "shaderParams",
-  7 
-  8     build : function() {
-  9     },
- 10 
- 11     drawAndPick: function(ctx) {
- 12 
- 13         var paramsStack = this.core.paramsStack;
- 14 
- 15         if (paramsStack) {
- 16 
- 17             var program = ctx.pick ? this.program.pick : this.program.draw;
- 18             var params;
- 19             var name;
- 20 
- 21             for (var i = 0, len = paramsStack.length; i < len; i++) {
- 22                 params = paramsStack[i];
- 23                 for (name in params) {
- 24                     if (params.hasOwnProperty(name)) {
- 25                         program.setUniform(name, params[name]);  // TODO: cache locations
- 26                     }
- 27                 }
- 28             }
- 29         }
- 30     }
- 31 });
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_textureChunk.js.html b/docs/symbols/src/src_core_display_chunks_textureChunk.js.html deleted file mode 100644 index 55b55735..00000000 --- a/docs/symbols/src/src_core_display_chunks_textureChunk.js.html +++ /dev/null @@ -1,71 +0,0 @@ -
  1 SceneJS_ChunkFactory.createChunkType({
-  2 
-  3     type: "texture",
-  4 
-  5     build : function() {
-  6 
-  7         this._uTexSampler = this._uTexSampler || [];
-  8         this._uTexMatrix = this._uTexMatrix || [];
-  9         this._uTexBlendFactor = this._uTexBlendFactor || [];
- 10 
- 11         var layers = this.core.layers;
- 12 
- 13         if (layers) {
- 14 
- 15             var layer;
- 16             var draw = this.program.draw;
- 17 
- 18             for (var i = 0, len = layers.length; i < len; i++) {
- 19 
- 20                 layer = layers[i];
- 21 
- 22                 this._uTexSampler[i] = "SCENEJS_uSampler" + i;
- 23 
- 24                 this._uTexMatrix[i] = layer.matrixAsArray
- 25                         ? draw.getUniform("SCENEJS_uLayer" + i + "Matrix")
- 26                         : null;
- 27 
- 28                 this._uTexBlendFactor[i] = draw.getUniform("SCENEJS_uLayer" + i + "BlendFactor");
- 29             }
- 30         }
- 31     },
- 32 
- 33     draw : function() {
- 34 
- 35         var layers = this.core.layers;
- 36 
- 37         if (layers) {
- 38 
- 39             var draw = this.program.draw;
- 40             var layer;
- 41 
- 42             for (var i = 0, len = layers.length; i < len; i++) {
- 43 
- 44                 layer = layers[i];
- 45 
- 46                 if (this._uTexSampler[i] && layer.texture) {    // Lazy-loads
- 47 
- 48                     draw.bindTexture(this._uTexSampler[i], layer.texture, i);
- 49 
- 50                     if (this._uTexMatrix[i]) {
- 51                         this._uTexMatrix[i].setValue(layer.matrixAsArray);
- 52                     }
- 53 
- 54                     if (this._uTexBlendFactor[i]) {
- 55                         this._uTexBlendFactor[i].setValue(layer.blendFactor);
- 56                     }
- 57 
- 58                 } else {
- 59                    //   draw.bindTexture(this._uTexSampler[i], null, i); // Unbind
- 60                 }
- 61             }
- 62         }
- 63     }
- 64 });
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_chunks_xformChunk.js.html b/docs/symbols/src/src_core_display_chunks_xformChunk.js.html deleted file mode 100644 index 02cfe960..00000000 --- a/docs/symbols/src/src_core_display_chunks_xformChunk.js.html +++ /dev/null @@ -1,67 +0,0 @@ -
  1 SceneJS_ChunkFactory.createChunkType({
-  2 
-  3     type: "xform",
-  4 
-  5     build : function() {
-  6 
-  7         var draw = this.program.draw;
-  8 
-  9         this._uMatLocationDraw = draw.getUniformLocation("SCENEJS_uMMatrix");
- 10         this._uNormalMatLocationDraw = draw.getUniformLocation("SCENEJS_uMNMatrix");
- 11 
- 12         var pick = this.program.pick;
- 13 
- 14         this._uMatLocationPick = pick.getUniformLocation("SCENEJS_uMMatrix");
- 15         this._uNormalMatLocationPick = pick.getUniformLocation("SCENEJS_uMNMatrix");
- 16     },
- 17 
- 18     draw : function(ctx) {
- 19 
- 20         /* Rebuild core's matrix from matrices at cores on path up to root
- 21          */
- 22        if (this.core.dirty && this.core.build) {
- 23             this.core.build();
- 24         }
- 25 
- 26         var gl = this.program.gl;
- 27 
- 28         if (this._uMatLocationDraw) {
- 29             gl.uniformMatrix4fv(this._uMatLocationDraw, gl.FALSE, this.core.mat);
- 30         }
- 31 
- 32         if (this._uNormalMatLocationDraw) {
- 33             gl.uniformMatrix4fv(this._uNormalMatLocationDraw, gl.FALSE, this.core.normalMat);
- 34         }
- 35 
- 36         ctx.modelMat = this.core.mat;
- 37     },
- 38 
- 39     pick : function(ctx) {
- 40 
- 41         /* Rebuild core's matrix from matrices at cores on path up to root
- 42          */
- 43         if (this.core.dirty) {
- 44             this.core.build();
- 45         }
- 46 
- 47         var gl = this.program.gl;
- 48 
- 49         if (this._uMatLocationPick) {
- 50             gl.uniformMatrix4fv(this._uMatLocationPick, gl.FALSE, this.core.mat);
- 51         }
- 52 
- 53         if (this._uNormalMatLocationPick) {
- 54             gl.uniformMatrix4fv(this._uNormalMatLocationPick, gl.FALSE, this.core.normalMat);
- 55         }
- 56 
- 57         ctx.modelMat = this.core.mat;
- 58     }
- 59 });
- 60 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_display.js.html b/docs/symbols/src/src_core_display_display.js.html deleted file mode 100644 index b8061c92..00000000 --- a/docs/symbols/src/src_core_display_display.js.html +++ /dev/null @@ -1,917 +0,0 @@ -
  1 /**
-  2  * @class Renders and picks a {@link SceneJS.Scene}
-  3  * @private
-  4  *
-  5  * <p>A Display is a container of {@link SceneJS_Object}s which are created (or updated) by a depth-first
-  6  * <b>compilation traversal</b> of the nodes within a {@link SceneJS.Scene}.</b>
-  7  *
-  8  * <h2>Rendering Pipeline</h2>
-  9  *
- 10  * <p>Conceptually, a Display implements a pipeline with the following stages:</p>
- 11  *
- 12  * <ol>
- 13  * <li>Create or update {@link SceneJS_Object}s during scene compilation</li>
- 14  * <li>Organise the {@link SceneJS_Object} into an <b>object list</b></li>
- 15  * <li>Determine the GL state sort order for the object list</li>
- 16  * <li>State sort the object list</li>
- 17  * <li>Create a <b>draw list</b> containing {@link SceneJS_Chunk}s belonging to the {@link SceneJS_Object}s in the object list</li>
- 18  * <li>Render the draw list to draw the image</li>
- 19  * </ol>
- 20  *
- 21  * <p>An update to the scene causes the pipeline to be re-executed from one of these stages, and SceneJS is designed
- 22  * so that the pipeline is always re-executed from the latest stage possible to avoid redoing work.</p>
- 23  *
- 24  * <p>For example:</p>
- 25  *
- 26  * <ul>
- 27  * <li>when an object is created or updated, we need to (re)do stages 2, 3, 4, 5 and 6</li>
- 28  * <li>when an object is made invisible, we need to redo stages 5 and 6</li>
- 29  * <li>when an object is assigned to a different scene render layer (works like a render bin), we need to redo
- 30  *   stages 3, 4, 5, and 6</li>
- 31  *<li>when the colour of an object changes, or maybe when the viewpoint changes, we simplt redo stage 6</li>
- 32  * </ul>
- 33  *
- 34  * <h2>Object Creation</h2>
- 35  * <p>The object soup (stage 1) is constructed by a depth-first traversal of the scene graph, which we think of as
- 36  * "compiling" the scene graph into the Display. As traversal visits each scene node, the node's state core is
- 37  * set on the Display (such as {@link #flags}, {@link #layer}, {@link #renderer} etc), which we think of as the
- 38  * cores that are active at that instant during compilation. Each of the scene's leaf nodes is always
- 39  * a {@link SceneJS.Geometry}, and when traversal visits one of those it calls {@link #buildObject} to create an
- 40  * object in the soup. For each of the currently active cores, the object is given a {@link SceneJS_Chunk}
- 41  * containing the WebGL calls for rendering it.</p>
- 42  *
- 43  * <p>The object also gets a shader (implemented by {@link SceneJS_Program}), taylored to render those state cores.</p>
- 44  *
- 45  * <p>Limited re-compilation may also be done on portions of a scene that have been added or sufficiently modified. When
- 46  * traversal visits a {@link SceneJS.Geometry} for which an object already exists in the display, {@link #buildObject}
- 47  * may update the {@link SceneJS_Chunk}s on the object as required for any changes in the core soup since the
- 48  * last time the object was built. If differences among the cores require it, then {@link #buildObject} may also replace
- 49  * the object's {@link SceneJS_Program} in order to render the new core soup configuration.</p>
- 50  *
- 51  * <p>So in summary, to each {@link SceneJS_Object} it builds, {@link #buildObject} creates a list of
- 52  * {@link SceneJS_Chunk}s to render the set of node state cores that are currently set on the {@link SceneJS_Display}.
- 53  * When {@link #buildObject} is re-building an existing object, it may replace one or more {@link SceneJS_Chunk}s
- 54  * for state cores that have changed from the last time the object was built or re-built.</p>
- 55 
- 56  * <h2>Object Destruction</h2>
- 57  * <p>Destruction of a scene graph branch simply involves a call to {@link #removeObject} for each {@link SceneJS.Geometry}
- 58  * in the branch.</p>
- 59  *
- 60  * <h2>Draw List</h2>
- 61  * <p>The draw list is actually comprised of three lists of state chunks: a "pick" list to render a pick buffer
- 62  * for colour-indexed GPU picking, along with an "opaque" list and "transparent" list for normal image rendering.
- 63  * For normal rendering the opaque list is rendered, then blending is enabled and the transparent list is rendered.
- 64  * The chunks in these lists are held in the state-sorted order of their objects in #_objectList, with runs of
- 65  * duplicate states removed, as mentioned.</p>
- 66  *
- 67  * <p>After a scene update, we set a flag on the display to indicate the stage we will need to redo from. The pipeline is
- 68  * then lazy-redone on the next call to #render or #pick.</p>
- 69  */
- 70 var SceneJS_Display = function (cfg) {
- 71 
- 72     /* Display is bound to the lifetime of an HTML5 canvas
- 73      */
- 74     this._canvas = cfg.canvas;
- 75 
- 76     /* Factory which creates and recycles {@link SceneJS_Program} instances
- 77      */
- 78     this._programFactory = new SceneJS_ProgramFactory({
- 79         canvas:cfg.canvas
- 80     });
- 81 
- 82     /* Factory which creates and recycles {@link SceneJS.Chunk} instances
- 83      */
- 84     this._chunkFactory = new SceneJS_ChunkFactory();
- 85 
- 86     /**
- 87      * Node state core for the last {@link SceneJS.Flags} visited during scene graph compilation traversal
- 88      * @type Object
- 89      */
- 90     this.flags = null;
- 91 
- 92     /**
- 93      * Node state core for the last {@link SceneJS.Layer} visited during scene graph compilation traversal
- 94      * @type Object
- 95      */
- 96     this.layer = null;
- 97 
- 98     /**
- 99      * Node state core for the last {@link SceneJS.Renderer} visited during scene graph compilation traversal
-100      * @type Object
-101      */
-102     this.renderer = null;
-103 
-104     /**
-105      * Node state core for the last {@link SceneJS.Lights} visited during scene graph compilation traversal
-106      * @type Object
-107      */
-108     this.lights = null;
-109 
-110     /**
-111      * Node state core for the last {@link SceneJS.Material} visited during scene graph compilation traversal
-112      * @type Object
-113      */
-114     this.material = null;
-115 
-116     /**
-117      * Node state core for the last {@link SceneJS.Texture} visited during scene graph compilation traversal
-118      * @type Object
-119      */
-120     this.texture = null;
-121 
-122     /**
-123      * Node state core for the last {@link SceneJS.XForm} visited during scene graph compilation traversal
-124      * @type Object
-125      */
-126     this.modelTransform = null;
-127 
-128     /**
-129      * Node state core for the last {@link SceneJS.LookAt} visited during scene graph compilation traversal
-130      * @type Object
-131      */
-132     this.viewTransform = null;
-133 
-134     /**
-135      * Node state core for the last {@link SceneJS.Camera} visited during scene graph compilation traversal
-136      * @type Object
-137      */
-138     this.projTransform = null;
-139 
-140     /**
-141      * Node state core for the last {@link SceneJS.Framebuf} visited during scene graph compilation traversal
-142      * @type Object
-143      */
-144     this.framebuf = null;
-145 
-146     /**
-147      * Node state core for the last {@link SceneJS.Clips} visited during scene graph compilation traversal
-148      * @type Object
-149      */
-150     this.clips = null;
-151 
-152     /**
-153      * Node state core for the last {@link SceneJS.MorphGeometry} visited during scene graph compilation traversal
-154      * @type Object
-155      */
-156     this.morphGeometry = null;
-157 
-158     /**
-159      * Node state core for the last {@link SceneJS.Name} visited during scene graph compilation traversal
-160      * @type Object
-161      */
-162     this.name = null;
-163 
-164     /**
-165      * Node state core for the last {@link SceneJS.Tag} visited during scene graph compilation traversal
-166      * @type Object
-167      */
-168     this.tag = null;
-169 
-170     /**
-171      * Node state core for the last render {@link SceneJS.Node} listener encountered during scene graph compilation traversal
-172      * @type Object
-173      */
-174     this.renderListeners = null;
-175 
-176     /**
-177      * Node state core for the last {@link SceneJS.Shader} visited during scene graph compilation traversal
-178      * @type Object
-179      */
-180     this.shader = null;
-181 
-182     /**
-183      * Node state core for the last {@link SceneJS.ShaderParams} visited during scene graph compilation traversal
-184      * @type Object
-185      */
-186     this.shaderParams = null;
-187 
-188     /**
-189      * Node state core for the last {@link SceneJS.Geometry} visited during scene graph compilation traversal
-190      * @type Object
-191      */
-192     this.geometry = null;
-193 
-194     /* Factory which creates and recycles {@link SceneJS_Object} instances
-195      */
-196     this._objectFactory = new SceneJS_ObjectFactory();
-197 
-198     /**
-199      * The objects in the display
-200      */
-201     this._objects = {};
-202 
-203     /**
-204      * Ambient color, which must be given to gl.clearColor before draw list iteration
-205      */
-206     this._ambientColor = [0, 0, 0];
-207 
-208     /**
-209      * The object list, containing all elements of #_objects, kept in GL state-sorted order
-210      */
-211     this._objectList = [];
-212     this._objectListLen = 0;
-213 
-214     /* The "draw list", comprised collectively of three lists of state chunks belong to visible objects
-215      * within #_objectList: a "pick" list to render a pick buffer for colour-indexed GPU picking, along with an
-216      * "opaque" list and "transparent" list for normal image rendering. For normal rendering the opaque list is
-217      * rendered, then blending is enabled and the transparent list is rendered. The chunks in these lists
-218      * are held in the state-sorted order of their objects in #_objectList, with runs of duplicate states removed.
-219      */
-220     this._opaqueDrawList = [];         // State chunk list to render opaque objects
-221     this._opaqueDrawListLen = 0;
-222 
-223     this._transparentDrawList = [];    // State chunk list to render transparent objects
-224     this._transparentDrawListLen = 0;
-225 
-226     this._pickDrawList = [];           // State chunk list to render scene to pick buffer
-227     this._pickDrawListLen = 0;
-228 
-229     /* The frame context holds state shared across a single render of the draw list, along with any results of
-230      * the render, such as pick hits
-231      */
-232     this._frameCtx = {
-233         pickNames:[], // Pick names of objects hit during pick render
-234         canvas:this._canvas            // The canvas
-235     };
-236 
-237     /* The frame context has this facade which is given to scene node "rendered" listeners
-238      * to allow application code to access things like transform matrices from within those listeners.
-239      */
-240     this._frameCtx.renderListenerCtx = new SceneJS.RenderContext(this._frameCtx);
-241 
-242     /*-------------------------------------------------------------------------------------
-243      * Flags which schedule what the display is to do when #render is next called.
-244      *------------------------------------------------------------------------------------*/
-245 
-246     /**
-247      * Flags the object list as needing to be rebuilt from existing objects on the next call to {@link #render} or {@link #pick}.
-248      * Setting this will cause the rendering pipeline to be executed from stage #2 (see class comment),
-249      * causing object list rebuild, state order determination, state sort, draw list construction and image render.
-250      * @type Boolean
-251      */
-252     this.objectListDirty = true;
-253 
-254     /**
-255      * Flags the object list as needing state orders to be computed on the next call to {@link #render} or {@link #pick}.
-256      * Setting this will cause the rendering pipeline to be executed from stage #3 (see class comment),
-257      * causing state order determination, state sort, draw list construction and image render.
-258      * @type Boolean
-259      */
-260     this.stateOrderDirty = true;
-261 
-262     /**
-263      * Flags the object list as needing to be state sorted on the next call to {@link #render} or {@link #pick}.
-264      * Setting this will cause the rendering pipeline to be executed from stage #4 (see class comment),
-265      * causing state sort, draw list construction and image render.
-266      * @type Boolean
-267      */
-268     this.stateSortDirty = true;
-269 
-270     /**
-271      * Flags the draw list as needing to be rebuilt from the object list on the next call to {@link #render} or {@link #pick}.
-272      * Setting this will cause the rendering pipeline to be executed from stage #5 (see class comment),
-273      * causing draw list construction and image render.
-274      * @type Boolean
-275      */
-276     this.drawListDirty = true;
-277 
-278     /**
-279      * Flags the image as needing to be redrawn from the draw list on the next call to {@link #render} or {@link #pick}.
-280      * Setting this will cause the rendering pipeline to be executed from stage #6 (see class comment),
-281      * causing the image render.
-282      * @type Boolean
-283      */
-284     this.imageDirty = true;
-285 
-286     /**
-287      * Flags the neccessity for the image buffer to be re-rendered from the draw list.
-288      * @type Boolean
-289      */
-290     this.pickBufDirty = true;           // Redraw pick buffer
-291     this.rayPickBufDirty = true;        // Redraw raypick buffer
-292 };
-293 
-294 /**
-295  * Reallocates WebGL resources for objects within this display
-296  */
-297 SceneJS_Display.prototype.webglRestored = function () {
-298 
-299     this._programFactory.webglRestored();// Reallocate programs
-300 
-301     this._chunkFactory.webglRestored(); // Recache shader var locations
-302 
-303     var gl = this._canvas.gl;
-304 
-305     if (this.pickBuf) {
-306         this.pickBuf.webglRestored(gl);          // Rebuild pick buffers
-307     }
-308 
-309     if (this.rayPickBuf) {
-310         this.rayPickBuf.webglRestored(gl);
-311     }
-312 
-313     this.imageDirty = true;             // Need redraw
-314 };
-315 
-316 /**
-317  * Internally creates (or updates) a {@link SceneJS_Object} of the given ID from whatever node state cores are currently set
-318  * on this {@link SceneJS_Display}. The object is created if it does not already exist in the display, otherwise it is
-319  * updated with the current state cores, possibly replacing cores already referenced by the object.
-320  *
-321  * @param {String} objectId ID of object to create or update
-322  */
-323 SceneJS_Display.prototype.buildObject = function (objectId) {
-324 
-325     var object = this._objects[objectId];
-326 
-327     if (!object) { // Create object
-328 
-329         object = this._objects[objectId] = this._objectFactory.getObject(objectId);
-330 
-331         this.objectListDirty = true;
-332     }
-333 
-334     object.layer = this.layer;
-335     object.texture = this.texture;
-336     object.geometry = this.geometry;
-337     object.flags = this.flags;
-338     object.tag = this.tag;
-339 
-340     //if (!object.hash) {
-341 
-342     var hash = ([                   // Build current state hash
-343         this.geometry.hash,
-344         this.shader.hash,
-345         this.clips.hash,
-346         this.morphGeometry.hash,
-347         this.texture.hash,
-348         this.lights.hash
-349 
-350     ]).join(";");
-351 
-352     if (!object.program || hash != object.hash) {
-353 
-354         /* Get new program for object if no program or hash mismatch
-355          */
-356 
-357         if (object.program) {
-358             this._programFactory.putProgram(object.program);
-359         }
-360 
-361         object.program = this._programFactory.getProgram(hash, this);
-362         object.hash = hash;
-363     }
-364     //}
-365 
-366     /* Build draw chunks for object
-367      */
-368     this._setChunk(object, 0, "program");          // Must be first
-369     this._setChunk(object, 1, "xform", this.modelTransform);
-370     this._setChunk(object, 2, "lookAt", this.viewTransform);
-371     this._setChunk(object, 3, "camera", this.projTransform);
-372     this._setChunk(object, 4, "flags", this.flags);
-373     this._setChunk(object, 5, "shader", this.shader);
-374     this._setChunk(object, 6, "shaderParams", this.shaderParams);
-375     //  this._setChunk(object, 7, this.renderer, true);
-376     this._setChunk(object, 7, "name", this.name);
-377     this._setChunk(object, 8, "lights", this.lights);
-378     this._setChunk(object, 9, "material", this.material);
-379     this._setChunk(object, 10, "texture", this.texture);
-380     this._setChunk(object, 11, "framebuf", this.framebuf);
-381     this._setChunk(object, 12, "clips", this.clips);
-382     this._setChunk(object, 13, "morphGeometry", this.morphGeometry);
-383     this._setChunk(object, 14, "listeners", this.renderListeners);      // Must be after the above chunks
-384     this._setChunk(object, 15, "geometry", this.geometry); // Must be last
-385 };
-386 
-387 SceneJS_Display.prototype._setChunk = function (object, order, chunkType, core, unique) {
-388 
-389     var chunkId;
-390 
-391     if (unique) {
-392 
-393         chunkId = core.stateId + 1;
-394 
-395     } else if (core) {
-396 
-397         if (core.empty) { // Only set default cores for state types that have them
-398 
-399             var oldChunk = object.chunks[order];
-400 
-401             if (oldChunk) {
-402                 this._chunkFactory.putChunk(oldChunk); // Release previous chunk to pool
-403             }
-404 
-405             object.chunks[order] = null;
-406 
-407             return;
-408         }
-409 
-410         chunkId = ((object.program.id + 1) * 50000) + core.stateId + 1;
-411 
-412     } else {
-413 
-414         chunkId = ((object.program.id + 1) * 50000);
-415     }
-416 
-417     var oldChunk = object.chunks[order];
-418 
-419     if (oldChunk) {
-420 
-421         if (oldChunk.id == chunkId) { // Avoid needless chunk reattachment
-422             return;
-423         }
-424 
-425         this._chunkFactory.putChunk(oldChunk); // Release previous chunk to pool
-426     }
-427 
-428     object.chunks[order] = this._chunkFactory.getChunk(chunkId, chunkType, object.program, core); // Attach new chunk
-429 
-430     // Ambient light is global across everything in display, and
-431     // can never be disabled, so grab it now because we want to
-432     // feed it to gl.clearColor before each display list render
-433     if (chunkType == "lights") {
-434         this._setAmbient(core);
-435     }
-436 };
-437 
-438 SceneJS_Display.prototype._setAmbient = function (core) {
-439     var lights = core.lights;
-440     var light;
-441     for (var i = 0, len = lights.length; i < len; i++) {
-442         light = lights[i];
-443         if (light.mode == "ambient") {
-444             this._ambientColor = light.color;
-445         }
-446     }
-447 };
-448 
-449 /**
-450  * Removes an object from this display
-451  *
-452  * @param {String} objectId ID of object to remove
-453  */
-454 SceneJS_Display.prototype.removeObject = function (objectId) {
-455 
-456     var object = this._objects[objectId];
-457 
-458     if (!object) {
-459         return;
-460     }
-461 
-462     this._programFactory.putProgram(object.program);
-463 
-464     object.program = null;
-465     object.hash = null;
-466 
-467     this._objectFactory.putObject(object);
-468 
-469     delete this._objects[objectId];
-470 
-471     this.objectListDirty = true;
-472 };
-473 
-474 /**
-475  * Set a tag selector to selectively activate objects that have matching SceneJS.Tag nodes
-476  */
-477 SceneJS_Display.prototype.selectTags = function (tagSelector) {
-478     this._tagSelector = tagSelector;
-479     this.drawListDirty = true;
-480 };
-481 
-482 /**
-483  * Render this display. What actually happens in the method depends on what flags are set.
-484  */
-485 SceneJS_Display.prototype.render = function (params) {
-486 
-487     params = params || {};
-488 
-489     if (this.objectListDirty) {
-490 
-491         this._buildObjectList();          // Build object render bin
-492 
-493         this.objectListDirty = false;
-494         this.stateOrderDirty = true;        // Now needs state ordering
-495     }
-496 
-497     if (this.stateOrderDirty) {
-498 
-499         this._makeStateSortKeys();       // Compute state sort order
-500 
-501         this.stateOrderDirty = false;
-502         this.stateSortDirty = true;     // Now needs state sorting
-503     }
-504 
-505     if (this.stateSortDirty) {
-506 
-507         this._stateSort();              // State sort the object render bin
-508 
-509         this.stateSortDirty = false;
-510         this.drawListDirty = true;      // Now needs new visible object bin
-511     }
-512 
-513     if (this.drawListDirty) {           // Render visible list while building transparent list
-514 
-515         this._buildDrawList();
-516 
-517         this.imageDirty = true;
-518     }
-519 
-520     if (this.imageDirty || params.force) {
-521 
-522         this._doDrawList(false);        // Render, no pick
-523 
-524         this.imageDirty = false;
-525         this.pickBufDirty = true;       // Pick buff will now need rendering on next pick
-526     }
-527 };
-528 
-529 SceneJS_Display.prototype._buildObjectList = function () {
-530     this._objectListLen = 0;
-531     for (var objectId in this._objects) {
-532         if (this._objects.hasOwnProperty(objectId)) {
-533             this._objectList[this._objectListLen++] = this._objects[objectId];
-534         }
-535     }
-536 };
-537 
-538 SceneJS_Display.prototype._makeStateSortKeys = function () { // TODO: state sort for sound objects?
-539     var object;
-540     for (var i = 0, len = this._objectListLen; i < len; i++) {
-541         object = this._objectList[i];
-542         object.sortKey = object.program
-543             ? (((object.layer.priority + 1) * 100000000)
-544             + ((object.program.id + 1) * 100000)
-545             + (object.texture.stateId * 1000))
-546             //    + i // Force stability among same-priority objects across multiple sorts
-547             : -1;   // Non-visual object (eg. sound)
-548     }
-549 };
-550 
-551 //SceneJS_Display.prototype._makeStateSortKeys = function () { // TODO: state sort for sound objects?
-552 //    var object;
-553 //    for (var i = 0, len = this._objectListLen; i < len; i++) {
-554 //        object = this._objectList[i];
-555 //        object.sortKey = object.program
-556 //            ? (((object.layer.priority + 1) * 1000000000)
-557 //            + ((object.program.id + 1) * 1000000)
-558 //            + (object.texture.stateId * 10000)
-559 //            + (object.geometry.stateId))
-560 //            //    + i // Force stability among same-priority objects across multiple sorts
-561 //            : -1;   // Non-visual object (eg. sound)
-562 //    }
-563 //};
-564 
-565 SceneJS_Display.prototype._stateSort = function () {
-566     this._objectList.length = this._objectListLen;
-567     this._objectList.sort(this._stateSortObjects);
-568 };
-569 
-570 SceneJS_Display.prototype._stateSortObjects = function (a, b) {
-571     return a.sortKey - b.sortKey;
-572 };
-573 
-574 SceneJS_Display.prototype._buildDrawList = function () {
-575 
-576     this._lastStateId = this._lastStateId || [];
-577     this._lastPickStateId = this._lastPickStateId || [];
-578 
-579     for (var i = 0; i < 20; i++) {
-580         this._lastStateId[i] = null;
-581         this._lastPickStateId[i] = null;
-582     }
-583 
-584     this._opaqueDrawListLen = 0;
-585     this._pickDrawListLen = 0;
-586     this._transparentDrawListLen = 0;
-587 
-588     var object;
-589     var tagMask;
-590     var tagRegex;
-591     var tagCore;
-592     var flags;
-593     var chunks;
-594     var chunk;
-595     var transparent;
-596     var picking;
-597 
-598     if (this._tagSelector) {
-599         tagMask = this._tagSelector.mask;
-600         tagRegex = this._tagSelector.regex;
-601     }
-602 
-603     if (!this._xpBuf) {
-604         this._xpBuf = [];
-605     }
-606     this._xpBufLen = 0;
-607 
-608     for (var i = 0, len = this._objectListLen; i < len; i++) {
-609 
-610         object = this._objectList[i];
-611 
-612         flags = object.flags;
-613 
-614         /* Cull invisible objects
-615          */
-616 
-617         if (flags.enabled === false) {                              // Skip disabled object
-618             continue;
-619         }
-620 
-621         if (!object.layer.enabled) { // Skip disabled layers
-622             continue;
-623         }
-624 
-625         if (tagMask) { // Skip unmatched tags. No tag matching in visible bin prevent this being done on every frame.
-626 
-627             tagCore = object.tag;
-628 
-629             if (tagCore.tag) {
-630 
-631                 if (tagCore.mask != tagMask) { // Scene tag mask was updated since last render
-632                     tagCore.mask = tagMask;
-633                     tagCore.matches = tagRegex.test(tagCore.tag);
-634                 }
-635 
-636                 if (!tagCore.matches) {
-637                     continue;
-638                 }
-639             }
-640         }
-641 
-642         transparent = flags.transparent;
-643 
-644         if (transparent) {
-645             this._xpBuf[this._xpBufLen++] = object;
-646         }
-647 
-648         /* Add object's chunks to appropriate chunk list
-649          */
-650 
-651         chunks = object.chunks;
-652 
-653         picking = flags.picking;
-654 
-655         for (var j = 0, lenj = chunks.length; j < lenj; j++) {
-656 
-657             chunk = chunks[j];
-658 
-659             if (chunk) {
-660 
-661                 /*
-662                  * As we apply the state chunk lists we track the ID of most types of chunk in order
-663                  * to cull redundant re-applications of runs of the same chunk - except for those chunks with a
-664                  * 'unique' flag. We don't want to cull runs of geometry chunks because they contain the GL
-665                  * drawElements calls which render the objects.
-666                  */
-667 
-668                 if (!transparent && chunk.draw) {
-669                     if (chunk.unique || this._lastStateId[j] != chunk.id) {
-670                         this._opaqueDrawList[this._opaqueDrawListLen++] = chunk;
-671                         this._lastStateId[j] = chunk.id;
-672                     }
-673                 }
-674 
-675                 if (chunk.pick) { // Transparent objects are pickable
-676                     if (picking) { // Don't pick unpickable objects
-677                         if (chunk.unique || this._lastPickStateId[j] != chunk.id) {
-678                             this._pickDrawList[this._pickDrawListLen++] = chunk;
-679                             this._lastPickStateId[j] = chunk.id;
-680                         }
-681                     }
-682                 }
-683             }
-684         }
-685     }
-686 
-687     if (this._xpBufLen > 0) {
-688 
-689         for (var i = 0; i < 20; i++) {
-690             this._lastStateId[i] = null;
-691         }
-692 
-693         for (var i = 0; i < this._xpBufLen; i++) {
-694 
-695             object = this._xpBuf[i];
-696             chunks = object.chunks;
-697 
-698             for (var j = 0, lenj = chunks.length; j < lenj; j++) {
-699 
-700                 chunk = chunks[j];
-701 
-702                 if (chunk && chunk.draw) {
-703 
-704                     if (chunk.unique || this._lastStateId[j] != chunk.id) {
-705                         this._transparentDrawList[this._transparentDrawListLen++] = chunk;
-706                         this._lastStateId[j] = chunk.id;
-707                     }
-708                 }
-709             }
-710         }
-711     }
-712 
-713     this.drawListDirty = false;
-714 };
-715 
-716 SceneJS_Display.prototype.pick = function (params) {
-717 
-718     //return;
-719 
-720     var canvas = this._canvas.canvas;
-721 
-722     var hit = null;
-723 
-724     var canvasX = params.canvasX;
-725     var canvasY = params.canvasY;
-726 
-727     /*-------------------------------------------------------------
-728      * Pick object using normal GPU colour-indexed pick
-729      *-----------------------------------------------------------*/
-730 
-731     var pickBuf = this.pickBuf;                                                   // Lazy-create pick buffer
-732 
-733     if (!pickBuf) {
-734         pickBuf = this.pickBuf = new SceneJS_PickBuffer({ canvas:this._canvas });
-735         this.pickBufDirty = true;                                                 // Freshly-created pick buffer is dirty
-736     }
-737 
-738     this.render(); // Do any pending visible render
-739 
-740     pickBuf.bind();                                                                 // Bind pick buffer
-741 
-742     if (this.pickBufDirty) {                          // Render pick buffer
-743 
-744         pickBuf.clear();
-745 
-746         this._doDrawList(true);
-747 
-748         this._canvas.gl.finish();
-749 
-750         this.pickBufDirty = false;                                                  // Pick buffer up to date
-751         this.rayPickBufDirty = true;                                                // Ray pick buffer now dirty
-752     }
-753 
-754     var pix = pickBuf.read(canvasX, canvasY);                                       // Read pick buffer
-755     var pickedObjectIndex = pix[0] + pix[1] * 256 + pix[2] * 65536;
-756     var pickIndex = (pickedObjectIndex >= 1) ? pickedObjectIndex - 1 : -1;
-757 
-758     pickBuf.unbind();                                                               // Unbind pick buffer
-759 
-760     var pickName = this._frameCtx.pickNames[pickIndex];                                   // Map pixel to name
-761 
-762     if (pickName) {
-763 
-764         hit = {
-765             name:pickName
-766         };
-767 
-768         if (params.rayPick) { // Ray pick to find position
-769 
-770             var rayPickBuf = this.rayPickBuf; // Lazy-create Z-pick buffer
-771             if (!rayPickBuf) {
-772                 rayPickBuf = this.rayPickBuf = new SceneJS_PickBuffer({ canvas:this._canvas });
-773             }
-774 
-775             rayPickBuf.bind();
-776 
-777             if (this.rayPickBufDirty) {
-778 
-779                 rayPickBuf.clear();
-780 
-781                 this._doDrawList(true, true); // pick, rayPick
-782 
-783                 this.rayPickBufDirty = false;
-784             }
-785 
-786             pix = rayPickBuf.read(canvasX, canvasY);
-787 
-788             rayPickBuf.unbind();
-789 
-790             /* Read normalised device Z coordinate, which will be
-791              * in range of [0..1] with z=0 at front
-792              */
-793             var screenZ = this._unpackDepth(pix);
-794 
-795             var w = canvas.width;
-796             var h = canvas.height;
-797 
-798             /* Calculate clip space coordinates, which will be in range
-799              * of x=[-1..1] and y=[-1..1], with y=(+1) at top
-800              */
-801             var x = (canvasX - w / 2) / (w / 2);           // Calculate clip space coordinates
-802             var y = -(canvasY - h / 2) / (h / 2);
-803 
-804             var projMat = this._frameCtx.cameraMat;
-805             var viewMat = this._frameCtx.viewMat;
-806 
-807             var pvMat = SceneJS_math_mulMat4(projMat, viewMat, []);
-808             var pvMatInverse = SceneJS_math_inverseMat4(pvMat, []);
-809 
-810             var world1 = SceneJS_math_transformVector4(pvMatInverse, [x, y, -1, 1]);
-811             world1 = SceneJS_math_mulVec4Scalar(world1, 1 / world1[3]);
-812 
-813             var world2 = SceneJS_math_transformVector4(pvMatInverse, [x, y, 1, 1]);
-814             world2 = SceneJS_math_mulVec4Scalar(world2, 1 / world2[3]);
-815 
-816             var dir = SceneJS_math_subVec3(world2, world1, []);
-817 
-818             var vWorld = SceneJS_math_addVec3(world1, SceneJS_math_mulVec4Scalar(dir, screenZ, []), []);
-819 
-820             hit.canvasPos = [canvasX, canvasY];
-821             hit.worldPos = vWorld;
-822         }
-823     }
-824 
-825     return hit;
-826 };
-827 
-828 SceneJS_Display.prototype._unpackDepth = function (depthZ) {
-829     var vec = [depthZ[0] / 256.0, depthZ[1] / 256.0, depthZ[2] / 256.0, depthZ[3] / 256.0];
-830     var bitShift = [1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0];
-831     return SceneJS_math_dotVector4(vec, bitShift);
-832 };
-833 
-834 SceneJS_Display.prototype._doDrawList = function (pick, rayPick) {
-835 
-836     var frameCtx = this._frameCtx;                                                // Reset rendering context
-837 
-838     frameCtx.program = null;
-839     frameCtx.framebuf = null;
-840     frameCtx.viewMat = null;
-841     frameCtx.modelMat = null;
-842     frameCtx.cameraMat = null;
-843     frameCtx.renderer = null;
-844     frameCtx.vertexBuf = false;
-845     frameCtx.normalBuf = false;
-846     frameCtx.uvBuf = false;
-847     frameCtx.uvBuf2 = false;
-848     frameCtx.colorBuf = false;
-849     frameCtx.backfaces = false;
-850     frameCtx.frontface = "ccw";
-851     frameCtx.pick = !!pick;
-852 
-853     var gl = this._canvas.gl;
-854 
-855     gl.viewport(0, 0, this._canvas.canvas.width, this._canvas.canvas.height);
-856     gl.clearColor(this._ambientColor[0], this._ambientColor[1], this._ambientColor[2], 1.0);
-857     gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
-858     gl.lineWidth(3);
-859     gl.frontFace(gl.CCW);
-860     //   gl.disable(gl.CULL_FACE);
-861 
-862     if (pick) { // Pick
-863 
-864         frameCtx.pickIndex = 0;
-865         frameCtx.rayPick = !!rayPick;
-866 
-867         for (var i = 0, len = this._pickDrawListLen; i < len; i++) {        // Push picking chunks
-868             this._pickDrawList[i].pick(frameCtx);
-869         }
-870 
-871     } else { // Draw
-872 
-873         for (var i = 0, len = this._opaqueDrawListLen; i < len; i++) {      // Push opaque rendering chunks
-874             this._opaqueDrawList[i].draw(frameCtx);
-875         }
-876 
-877         if (this._transparentDrawListLen > 0) {
-878 
-879             gl.enable(gl.BLEND);                                            // Enable blending
-880             gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
-881 
-882             for (var i = 0, len = this._transparentDrawListLen; i < len; i++) { // Push transparent rendering chunks
-883                 this._transparentDrawList[i].draw(frameCtx);
-884             }
-885 
-886             gl.disable(gl.BLEND);                                           //  Disable blending
-887         }
-888     }
-889 
-890     gl.flush();                                                         // Flush GL
-891 
-892     if (frameCtx.program) {                                                  // Unbind remaining program
-893         //frameCtx.program.unbind();
-894     }
-895 
-896     if (frameCtx.framebuf) {                                                 // Unbind remaining frame buffer
-897         gl.finish();
-898         frameCtx.framebuf.unbind();
-899     }
-900 
-901     if (frameCtx.renderer) {                           // Forget last call-time renderer properties
-902         //     frameCtx.renderer.props.restoreProps(gl);
-903     }
-904 };
-905 
-906 SceneJS_Display.prototype.destroy = function () {
-907     this._programFactory.destroy();
-908 };
-909 
-910 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_object.js.html b/docs/symbols/src/src_core_display_object.js.html deleted file mode 100644 index aa136780..00000000 --- a/docs/symbols/src/src_core_display_object.js.html +++ /dev/null @@ -1,69 +0,0 @@ -
  1 /**
-  2  * @class An object within a {@link SceneJS_Display}
-  3  * @private
-  4  */
-  5 var SceneJS_Object = function(id) {
-  6 
-  7     /**
-  8      * ID for this objects, unique among all objects in the display
-  9      * @type Number
- 10      */
- 11     this.id = id;
- 12 
- 13     /**
- 14      * Hash code for this object, unique among all objects in the display
- 15      * @type String
- 16      */
- 17     this.hash = null;
- 18 
- 19     /**
- 20      * State sort key, computed from {@link #layer}, {@link #program} and {@link #texture}
- 21      * @type Number
- 22      */
- 23     this.sortKey = null;
- 24 
- 25     /**
- 26      * Sequence of state chunks applied to render this object
- 27      * @type {[SceneJS_Chunk]} chunks
- 28      */
- 29     this.chunks = [];
- 30 
- 31     /**
- 32      * Number of state chunks applied to render this object
- 33      * @type Number
- 34      */
- 35     this.chunksLen = 0;
- 36 
- 37     /**
- 38      * Shader programs that render this object, also used for (re)computing {@link #sortKey}
- 39      * @type SceneJS_Program
- 40      */
- 41     this.program = null;
- 42 
- 43     /**
- 44      * State core for the {@link SceneJS.Layer} that this object was compiled from, used for (re)computing {@link #sortKey} and visibility cull
- 45      */
- 46     this.layer = null;
- 47 
- 48      /**
- 49      * State core for the {@link SceneJS.Texture} that this object was compiled from, used for (re)computing {@link #sortKey}
- 50      */
- 51     this.texture = null;
- 52 
- 53     /**
- 54      * State core for the {@link SceneJS.Flags} that this object was compiled from, used for visibility cull
- 55      */
- 56     this.flags = null;
- 57 
- 58     /**
- 59      * State core for the {@link SceneJS.Tag} that this object was compiled from, used for visibility cull
- 60      */
- 61     this.tag = null;
- 62 };
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_objectFactory.js.html b/docs/symbols/src/src_core_display_objectFactory.js.html deleted file mode 100644 index ac122322..00000000 --- a/docs/symbols/src/src_core_display_objectFactory.js.html +++ /dev/null @@ -1,54 +0,0 @@ -
  1 /**
-  2  * @class Manages creation and recycle of {@link SceneJS_Object} instances
-  3  * @private
-  4  */
-  5 var SceneJS_ObjectFactory = function() {
-  6 
-  7 };
-  8 
-  9 /**
- 10  * @property {[SceneJS_Object]} _freeObjects Pool of free display objects, shared by all object factories
- 11  */
- 12 SceneJS_ObjectFactory.prototype._freeObjects = [];
- 13 
- 14 /**
- 15  * @property {Number} _numFreeObjects Number of free objects
- 16  */
- 17 SceneJS_ObjectFactory.prototype._numFreeObjects = 0;
- 18 
- 19 /**
- 20  * Gets a display object from this factory
- 21  *
- 22  * @param {String} id ID to assign to the object
- 23  * @returns {SceneJS_Object} The object
- 24  */
- 25 SceneJS_ObjectFactory.prototype.getObject = function(id) {
- 26 
- 27     var object;
- 28 
- 29     if (this._numFreeObjects > 0) {
- 30 
- 31         object = this._freeObjects[--this._numFreeObjects];
- 32         object.id = id;
- 33 
- 34         return object;
- 35     }
- 36 
- 37     return new SceneJS_Object(id);
- 38 };
- 39 
- 40 /**
- 41  * Releases a display object back to this factory
- 42  * @param {SceneJS_Object} object Object to release
- 43  */
- 44 SceneJS_ObjectFactory.prototype.putObject = function (object) {
- 45 
- 46     this._freeObjects[this._numFreeObjects++] = object;
- 47 };
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_program.js.html b/docs/symbols/src/src_core_display_program.js.html deleted file mode 100644 index 5cdb3b4d..00000000 --- a/docs/symbols/src/src_core_display_program.js.html +++ /dev/null @@ -1,72 +0,0 @@ -
  1 /**
-  2  * @class Vertex and fragment shaders for pick and draw
-  3  * @private
-  4  *
-  5  * @param {Number} id ID unique among all programs in the owner {@link SceneJS_ProgramFactory}
-  6  * @param {String} hash Hash code which uniquely identifies the capabilities of the program, computed from hashes on the {@link Scene_Core}s that the {@link SceneJS_ProgramSource} composed to render
-  7  * @param {SceneJS_ProgramSource} source Sourcecode from which the the program is compiled in {@link #build}
-  8  * @param {WebGLRenderingContext} gl WebGL context 
-  9  */
- 10 var SceneJS_Program = function(id, hash, source, gl) {
- 11 
- 12     /**
- 13      * ID for this program, unique among all programs in the display
- 14      * @type Number
- 15      */
- 16     this.id = id;
- 17 
- 18     /**
- 19      * Hash code for this program's capabilities, same as the hash on {@link #source}
- 20      * @type String
- 21      */
- 22     this.hash = source.hash;
- 23 
- 24     /**
- 25      * Source code for this program's shaders
- 26      * @type SceneJS_ProgramSource
- 27      */
- 28     this.source = source;
- 29 
- 30     /**
- 31      * WebGL context on which this program's shaders are allocated
- 32      * @type WebGLRenderingContext
- 33      */
- 34     this.gl = gl;
- 35 
- 36     /**
- 37      * The drawing program
- 38      * @type SceneJS_webgl_Program
- 39      */
- 40     this.draw = null;
- 41 
- 42     /**
- 43      * The picking program
- 44      * @type SceneJS_webgl_Program
- 45      */
- 46     this.pick = null;
- 47 
- 48     /**
- 49      * The count of display objects using this program
- 50      * @type Number
- 51      */
- 52     this.useCount = 0;
- 53 
- 54     this.build(gl);
- 55 };
- 56 
- 57 /**
- 58  *  Creates the render and pick programs.
- 59  * This is also re-called to re-create them after WebGL context loss.
- 60  */
- 61 SceneJS_Program.prototype.build = function(gl) {
- 62     this.gl = gl;
- 63     this.draw = new SceneJS_webgl_Program(gl, [this.source.drawVertexSrc.join("\n")], [this.source.drawFragmentSrc.join("\n")]);
- 64     this.pick = new SceneJS_webgl_Program(gl, [this.source.pickVertexSrc.join("\n")], [this.source.pickFragmentSrc.join("\n")]);
- 65 };
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_programFactory.js.html b/docs/symbols/src/src_core_display_programFactory.js.html deleted file mode 100644 index 5d33a13b..00000000 --- a/docs/symbols/src/src_core_display_programFactory.js.html +++ /dev/null @@ -1,77 +0,0 @@ -
  1 /**  
-  2  * @class Manages creation, sharing and recycle of {@link SceneJS_Program} instances
-  3  * @private
-  4  */
-  5 var SceneJS_ProgramFactory = function(cfg) {
-  6 
-  7     this._canvas = cfg.canvas;
-  8 
-  9     this._programs = {};
- 10 
- 11     this._nextProgramId = 0;
- 12 };
- 13 
- 14 /**
- 15  * Gets a program to render the given states
- 16  */
- 17 SceneJS_ProgramFactory.prototype.getProgram = function(hash, states) {
- 18 
- 19     var program = this._programs[hash];
- 20 
- 21     if (!program) {
- 22 
- 23         var source = SceneJS_ProgramSourceFactory.getSource(hash, states);
- 24 
- 25         program = new SceneJS_Program(this._nextProgramId++, hash, source, this._canvas.gl);
- 26 
- 27         this._programs[hash] = program;
- 28     }
- 29 
- 30     program.useCount++;
- 31 
- 32     return program;
- 33 };
- 34 
- 35 /**
- 36  * Releases a program back to the shader factory
- 37  */
- 38 SceneJS_ProgramFactory.prototype.putProgram = function(program) {
- 39 
- 40     if (--program.useCount <= 0) {
- 41 
- 42         program.draw.destroy();
- 43         program.pick.destroy();
- 44 
- 45         SceneJS_ProgramSourceFactory.putSource(program.hash);
- 46 
- 47         this._programs[program.hash] = null;
- 48     }
- 49 };
- 50 
- 51 /**
- 52  * Notifies this shader factory that the WebGL context has been restored after previously being lost
- 53  */
- 54 SceneJS_ProgramFactory.prototype.webglRestored = function() {
- 55 
- 56     var gl = this._canvas.gl;
- 57 
- 58     for (var id in this._programs) {
- 59         if (this._programs.hasOwnProperty(id)) {
- 60             this._programs[id].build(gl);
- 61         }
- 62     }
- 63 };
- 64 
- 65 /**
- 66  * Destroys this shader factory
- 67  */
- 68 SceneJS_ProgramFactory.prototype.destroy = function() {
- 69 };
- 70 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_programSource.js.html b/docs/symbols/src/src_core_display_programSource.js.html deleted file mode 100644 index 4913ee03..00000000 --- a/docs/symbols/src/src_core_display_programSource.js.html +++ /dev/null @@ -1,57 +0,0 @@ -
  1 /**
-  2  * @class Source code for pick and draw shader programs, to be compiled into one or more {@link SceneJS_Program}s
-  3  * @private
-  4  * 
-  5  * @param {String} hash Hash code identifying the rendering capabilities of the programs
-  6  * @param {String} pickVertexSrc Source code of the pick vertex shader
-  7  * @param {String} pickFragmentSrc Source code of the pick fragment shader
-  8  * @param {String} drawVertexSrc Source code of the draw vertex shader
-  9  * @param {String} drawFragmentSrc Source code of the draw fragment shader
- 10  */
- 11 var SceneJS_ProgramSource = function(hash, pickVertexSrc, pickFragmentSrc, drawVertexSrc, drawFragmentSrc) {
- 12 
- 13     /**
- 14      * Hash code identifying the capabilities of the {@link SceneJS_Program} that is compiled from this source
- 15      * @type String
- 16      */
- 17     this.hash = hash;
- 18 
- 19     /**
- 20      * Source code for pick vertex shader
- 21      * @type String
- 22      */
- 23     this.pickVertexSrc = pickVertexSrc;
- 24 
- 25     /**
- 26      * Source code for pick fragment shader
- 27      * @type String
- 28      */
- 29     this.pickFragmentSrc = pickFragmentSrc;
- 30 
- 31     /**
- 32      * Source code for draw vertex shader
- 33      * @type String
- 34      */
- 35     this.drawVertexSrc = drawVertexSrc;
- 36 
- 37     /**
- 38      * Source code for draw fragment shader
- 39      * @type String
- 40      */
- 41     this.drawFragmentSrc = drawFragmentSrc;
- 42 
- 43     /**
- 44      * Count of {@link SceneJS_Program}s compiled from this program source code
- 45      * @type Number
- 46      */
- 47     this.useCount = 0;
- 48 };
- 49 
- 50 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_programSourceFactory.js.html b/docs/symbols/src/src_core_display_programSourceFactory.js.html deleted file mode 100644 index bd10097c..00000000 --- a/docs/symbols/src/src_core_display_programSourceFactory.js.html +++ /dev/null @@ -1,957 +0,0 @@ -
  1 /**
-  2  * @class Manages creation, sharing and recycle of {@link SceneJS_ProgramSource} instances
-  3  * @private
-  4  */
-  5 var SceneJS_ProgramSourceFactory = new (function() {
-  6 
-  7     this._sourceCache = {}; // Source codes are shared across all scenes
-  8 
-  9 
- 10     /**
- 11      * Get sourcecode for a program to render the given states
- 12      */
- 13     this.getSource = function(hash, states) {
- 14 
- 15         var source = this._sourceCache[hash];
- 16         if (source) {
- 17             source.useCount++;
- 18             return source;
- 19         }
- 20 
- 21         return this._sourceCache[hash] = new SceneJS_ProgramSource(
- 22 
- 23                 hash,
- 24 
- 25                 this._composePickingVertexShader(states), // pickVertexSrc
- 26                 this._composePickingFragmentShader(states), // pickFragmentSrc
- 27                 this._composeRenderingVertexShader(states), // drawVertexSrc
- 28                 this._composeRenderingFragmentShader(states)  // drawfragmentSrc
- 29                 );
- 30     };
- 31 
- 32     /**
- 33      * Releases program source code
- 34      */
- 35     this.putSource = function(hash) {
- 36         var source = this._sourceCache[hash];
- 37         if (source) {
- 38             if (--source.useCount == 0) {
- 39                 this._sourceCache[source.hash] = null;
- 40             }
- 41         }
- 42     };
- 43 
- 44     this._composePickingVertexShader = function(states) {
- 45 
- 46         var customShaders = states.shader.shaders || {};
- 47 
- 48         var customVertexShader = customShaders.vertex || {};
- 49         var vertexHooks = customVertexShader.hooks || {};
- 50 
- 51         var customFragmentShader = customShaders.fragment || {};
- 52         var fragmentHooks = customFragmentShader.hooks || {};
- 53 
- 54         var clipping = states.clips.clips.length > 0;
- 55         var morphing = !!states.morphGeometry.targets;
- 56         var normals = this._hasNormals(states);
- 57 
- 58         var src = [
- 59             "precision mediump float;",
- 60             "attribute vec3 SCENEJS_aVertex;",
- 61             "attribute vec3 SCENEJS_aNormal;",
- 62 
- 63             "uniform mat4 SCENEJS_uMMatrix;",
- 64             "uniform mat4 SCENEJS_uMNMatrix;",
- 65             "uniform mat4 SCENEJS_uVMatrix;",
- 66             "uniform mat4 SCENEJS_uVNMatrix;",
- 67             "uniform mat4 SCENEJS_uPMatrix;"
- 68         ];
- 69 
- 70         if (normals && (fragmentHooks.worldNormal || fragmentHooks.viewNormal)) {
- 71             src.push("varying   vec3 SCENEJS_vWorldNormal;");   // Output world-space vertex normal
- 72             src.push("varying   vec3 SCENEJS_vViewNormal;");   // Output world-space vertex normal
- 73         }
- 74 
- 75         src.push("varying vec4 SCENEJS_vModelVertex;");
- 76 
- 77         // if (clipping || fragmentHooks.worldPosClip) {
- 78         src.push("varying vec4 SCENEJS_vWorldVertex;");
- 79         // }
- 80 
- 81 
- 82         src.push("varying vec4 SCENEJS_vViewVertex;\n");
- 83         src.push("varying vec4 SCENEJS_vProjVertex;\n");
- 84 
- 85         src.push("uniform vec3 SCENEJS_uWorldEye;");                     // World-space eye position
- 86         src.push("varying vec3 SCENEJS_vWorldEyeVec;");
- 87 
- 88         if (customVertexShader.code) {
- 89             src.push("\n" + customVertexShader.code + "\n");
- 90         }
- 91 
- 92         if (morphing) {
- 93             src.push("uniform float SCENEJS_uMorphFactor;");       // LERP factor for morph
- 94             if (states.morphGeometry.targets[0].vertexBuf) {      // target2 has these arrays also
- 95                 src.push("attribute vec3 SCENEJS_aMorphVertex;");
- 96             }
- 97         }
- 98 
- 99         src.push("void main(void) {");
-100         src.push("   vec4 tmpVertex=vec4(SCENEJS_aVertex, 1.0); ");
-101 
-102         if (normals) {
-103             src.push("  vec4 modelNormal = vec4(SCENEJS_aNormal, 0.0); ");
-104         }
-105 
-106         src.push("  SCENEJS_vModelVertex = tmpVertex; ");
-107 
-108         if (vertexHooks.modelPos) {
-109             src.push("tmpVertex=" + vertexHooks.modelPos + "(tmpVertex);");
-110         }
-111 
-112         if (morphing) {
-113             if (states.morphGeometry.targets[0].vertexBuf) {
-114                 src.push("  vec4 vMorphVertex = vec4(SCENEJS_aMorphVertex, 1.0); ");
-115 
-116                 if (vertexHooks.modelPos) {
-117                     src.push("vMorphVertex=" + vertexHooks.modelPos + "(vMorphVertex);");
-118                 }
-119 
-120                 src.push("  tmpVertex = vec4(mix(tmpVertex.xyz, vMorphVertex.xyz, SCENEJS_uMorphFactor), 1.0); ");
-121             }
-122         }
-123 
-124 
-125         src.push("  tmpVertex = SCENEJS_uMMatrix * tmpVertex; ");
-126 
-127         if (vertexHooks.worldPos) {
-128             src.push("tmpVertex=" + vertexHooks.worldPos + "(tmpVertex);");
-129         }
-130 
-131         // if (clipping || fragmentHooks.worldPosClip) {
-132         src.push("  SCENEJS_vWorldVertex = tmpVertex; ");
-133         //    }
-134 
-135         src.push("SCENEJS_vWorldEyeVec = normalize(SCENEJS_uWorldEye - tmpVertex.xyz);");
-136 
-137         src.push("  tmpVertex = SCENEJS_uVMatrix * tmpVertex; ");
-138 
-139         if (vertexHooks.viewPos) {
-140             src.push("tmpVertex=" + vertexHooks.viewPos + "(tmpVertex);");
-141         }
-142 
-143         src.push("  SCENEJS_vViewVertex = tmpVertex;");
-144 
-145         if (normals && (fragmentHooks.worldNormal || fragmentHooks.viewNormal)) {
-146             src.push("  vec3 worldNormal = normalize((SCENEJS_uMNMatrix * modelNormal).xyz); ");
-147             src.push("  SCENEJS_vWorldNormal = worldNormal;");
-148             src.push("  SCENEJS_vViewNormal = (SCENEJS_uVNMatrix * vec4(worldNormal, 1.0)).xyz;");
-149         }
-150 
-151         src.push("  SCENEJS_vProjVertex = SCENEJS_uPMatrix * tmpVertex;");
-152 
-153 
-154         src.push("  gl_Position = SCENEJS_vProjVertex;");
-155         src.push("}");
-156 
-157         if (false && debugCfg.logScripts == true) {
-158             SceneJS.log.info(src);
-159         }
-160         return src;
-161     };
-162 
-163     /**
-164      * Composes a fragment shader script for rendering mode in current scene state
-165      * @private
-166      */
-167     this._composePickingFragmentShader = function(states) {
-168 
-169         var customShaders = states.shader.shaders || {};
-170         var customFragmentShader = customShaders.fragment || {};
-171         var fragmentHooks = customFragmentShader.hooks || {};
-172 
-173         var clipping = states.clips.clips.length > 0;
-174 
-175         var normals = this._hasNormals(states);
-176 
-177         var src = [
-178             "precision mediump float;"
-179         ];
-180 
-181         src.push("vec4 packDepth(const in float depth) {");
-182         src.push("  const vec4 bitShift = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);");
-183         src.push("  const vec4 bitMask  = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);");
-184         src.push("  vec4 res = fract(depth * bitShift);");
-185         src.push("  res -= res.xxyz * bitMask;");
-186         src.push("  return res;");
-187         src.push("}");
-188 
-189         src.push("varying vec4 SCENEJS_vModelVertex;");
-190         src.push("varying vec4 SCENEJS_vWorldVertex;");
-191         src.push("varying vec4 SCENEJS_vViewVertex;");                  // View-space vertex
-192         src.push("varying vec4 SCENEJS_vProjVertex;");
-193 
-194         src.push("uniform bool SCENEJS_uRayPickMode;");                   // Z-pick mode when true else colour-pick
-195 
-196         src.push("uniform vec3 SCENEJS_uPickColor;");                   // Used in colour-pick mode
-197 
-198         src.push("uniform float SCENEJS_uZNear;");                      // Used in Z-pick mode
-199         src.push("uniform float SCENEJS_uZFar;");                       // Used in Z-pick mode
-200 
-201         src.push("varying vec3 SCENEJS_vWorldEyeVec;");                          // Direction of view-space vertex from eye
-202 
-203         src.push("uniform bool  SCENEJS_uClipping;");
-204 
-205         if (normals && (fragmentHooks.worldNormal || fragmentHooks.viewNormal)) {
-206 
-207             src.push("varying vec3 SCENEJS_vWorldNormal;");                  // World-space normal
-208             src.push("varying vec3 SCENEJS_vViewNormal;");                   // View-space normal
-209         }
-210         /*-----------------------------------------------------------------------------------
-211          * Variables - Clipping
-212          *----------------------------------------------------------------------------------*/
-213 
-214         if (clipping) {
-215             for (var i = 0; i < states.clips.clips.length; i++) {
-216                 src.push("uniform float SCENEJS_uClipMode" + i + ";");
-217                 src.push("uniform vec4  SCENEJS_uClipNormalAndDist" + i + ";");
-218             }
-219         }
-220 
-221         /*-----------------------------------------------------------------------------------
-222          * Custom GLSL
-223          *----------------------------------------------------------------------------------*/
-224 
-225         if (customFragmentShader.code) {
-226             src.push("\n" + customFragmentShader.code + "\n");
-227         }
-228 
-229         src.push("void main(void) {");
-230 
-231         if (fragmentHooks.worldPosClip) {
-232             src.push("if (" + fragmentHooks.worldPosClip + "(SCENEJS_vWorldVertex) == false) { discard; };");
-233         }
-234         if (fragmentHooks.viewPosClip) {
-235             src.push("if (!" + fragmentHooks.viewPosClip + "(SCENEJS_vViewVertex) == false) { discard; };");
-236         }
-237 
-238         if (clipping) {
-239             src.push("if (SCENEJS_uClipping) {");
-240             src.push("  float   dist;");
-241             for (var i = 0; i < states.clips.clips.length; i++) {
-242                 src.push("    if (SCENEJS_uClipMode" + i + " != 0.0) {");
-243                 src.push("        dist = dot(SCENEJS_vWorldVertex.xyz, SCENEJS_uClipNormalAndDist" + i + ".xyz) - SCENEJS_uClipNormalAndDist" + i + ".w;");
-244                 src.push("        if (SCENEJS_uClipMode" + i + " == 1.0) {");
-245                 src.push("            if (dist > 0.0) { discard; }");
-246                 src.push("        }");
-247                 src.push("        if (SCENEJS_uClipMode" + i + " == 2.0) {");
-248                 src.push("            if (dist > 0.0) { discard; }");
-249                 src.push("        }");
-250                 src.push("    }");
-251             }
-252             src.push("}");
-253         }
-254 
-255         if (fragmentHooks.worldPos) {
-256             src.push(fragmentHooks.worldPos + "(SCENEJS_vWorldVertex);");
-257         }
-258 
-259         if (fragmentHooks.viewPos) {
-260             src.push(fragmentHooks.viewPos + "(SCENEJS_vViewVertex);");
-261         }
-262 
-263         if (fragmentHooks.worldEyeVec) {
-264             src.push(fragmentHooks.worldEyeVec + "(SCENEJS_vWorldEyeVec);");
-265         }
-266 
-267         if (normals && fragmentHooks.worldNormal) {
-268             src.push(fragmentHooks.worldNormal + "(SCENEJS_vWorldNormal);");
-269         }
-270 
-271         if (normals && fragmentHooks.viewNormal) {
-272             src.push(fragmentHooks.viewNormal + "(SCENEJS_vViewNormal);");
-273         }
-274 
-275         src.push("    if (SCENEJS_uRayPickMode) {");
-276         src.push("          float zNormalizedDepth = abs((SCENEJS_uZNear + SCENEJS_vViewVertex.z) / (SCENEJS_uZFar - SCENEJS_uZNear));");
-277         src.push("          gl_FragColor = packDepth(zNormalizedDepth); ");
-278 
-279         src.push("    } else {");
-280         src.push("          gl_FragColor = vec4(SCENEJS_uPickColor.rgb, 1.0);  ");
-281         src.push("    }");
-282         src.push("}");
-283 
-284 
-285         if (false && debugCfg.logScripts == true) {
-286             SceneJS.log.info(src);
-287         }
-288         return src;
-289     };
-290 
-291 
-292     /*===================================================================================================================
-293      *
-294      * Rendering vertex shader
-295      *
-296      *==================================================================================================================*/
-297 
-298     this._isTexturing = function(states) {
-299         if (states.texture.layers && states.texture.layers.length > 0) {
-300             if (states.geometry.uvBuf || states.geometry.uvBuf2) {
-301                 return true;
-302             }
-303             if (states.morphGeometry.targets && (states.morphGeometry.targets[0].uvBuf || states.morphGeometry.targets[0].uvBuf2)) {
-304                 return true;
-305             }
-306         }
-307         return false;
-308     };
-309 
-310     this._hasNormals = function(states) {
-311         if (states.geometry.normalBuf) {
-312             return true;
-313         }
-314         if (states.morphGeometry.targets && states.morphGeometry.targets[0].normalBuf) {
-315             return true;
-316         }
-317         return false;
-318     };
-319 
-320     this._composeRenderingVertexShader = function(states) {
-321 
-322         var customShaders = states.shader.shaders || {};
-323 
-324         /* Do a full custom shader replacement if code supplied without hooks
-325          */
-326         if (customShaders.vertex && customShaders.vertex.code && !customShaders.vertex.hooks) {
-327             return customShaders.vertex.code;
-328         }
-329 
-330         var customVertexShader = customShaders.vertex || {};
-331         var vertexHooks = customVertexShader.hooks || {};
-332 
-333         var customFragmentShader = customShaders.fragment || {};
-334         var fragmentHooks = customFragmentShader.hooks || {};
-335 
-336         var texturing = this._isTexturing(states);
-337         var normals = this._hasNormals(states);
-338         var clipping = states.clips.clips.length > 0;
-339         var morphing = !!states.morphGeometry.targets;
-340 
-341         var src = [
-342             "precision mediump float;"
-343         ];
-344 
-345         src.push("attribute vec3 SCENEJS_aVertex;");                // Model coordinates
-346 
-347         src.push("uniform vec3 SCENEJS_uWorldEye;");                     // World-space eye position
-348         src.push("varying vec3 SCENEJS_vWorldEyeVec;");                  // Output world-space eye vector
-349 
-350         /*-----------------------------------------------------------------------------------
-351          * Variables - normals
-352          *----------------------------------------------------------------------------------*/
-353 
-354         if (normals) {
-355 
-356             src.push("attribute vec3 SCENEJS_aNormal;");        // Normal vectors
-357             src.push("uniform   mat4 SCENEJS_uMNMatrix;");      // Model normal matrix
-358             src.push("uniform   mat4 SCENEJS_uVNMatrix;");      // View normal matrix
-359 
-360             src.push("varying   vec3 SCENEJS_vWorldNormal;");   // Output world-space vertex normal
-361             src.push("varying   vec3 SCENEJS_vViewNormal;");    // Output view-space vertex normal
-362 
-363             for (var i = 0; i < states.lights.lights.length; i++) {
-364                 var light = states.lights.lights[i];
-365                 if (light.mode == "dir") {
-366                     src.push("uniform vec3 SCENEJS_uLightDir" + i + ";");
-367                 }
-368                 if (light.mode == "point") {
-369                     src.push("uniform vec4 SCENEJS_uLightPos" + i + ";");
-370                 }
-371                 if (light.mode == "spot") {
-372                     src.push("uniform vec4 SCENEJS_uLightPos" + i + ";");
-373                 }
-374 
-375                 /* Vector from vertex to light, packaged with the pre-computed length of that vector
-376                  */
-377                 src.push("varying vec4 SCENEJS_vViewLightVecAndDist" + i + ";");    // varying for fragment lighting
-378             }
-379         }
-380 
-381         if (texturing) {
-382             if (states.geometry.uvBuf) {
-383                 src.push("attribute vec2 SCENEJS_aUVCoord;");      // UV coords
-384             }
-385             if (states.geometry.uvBuf2) {
-386                 src.push("attribute vec2 SCENEJS_aUVCoord2;");     // UV2 coords
-387             }
-388         }
-389 
-390         /* Vertex color variables
-391          */
-392         if (states.geometry.colorBuf) {
-393             src.push("attribute vec4 SCENEJS_aVertexColor;");       // UV2 coords
-394             src.push("varying vec4 SCENEJS_vColor;");               // Varying for fragment texturing
-395         }
-396 
-397         src.push("uniform mat4 SCENEJS_uMMatrix;");                 // Model matrix
-398         src.push("uniform mat4 SCENEJS_uVMatrix;");                 // View matrix
-399         src.push("uniform mat4 SCENEJS_uPMatrix;");                 // Projection matrix
-400 
-401         if (clipping || fragmentHooks.worldPos) {
-402             src.push("varying vec4 SCENEJS_vWorldVertex;");         // Varying for fragment clip or world pos hook
-403         }
-404 
-405         if (fragmentHooks.viewPos) {
-406             src.push("varying vec4 SCENEJS_vViewVertex;");          // Varying for fragment view clip hook
-407         }
-408 
-409         if (texturing) {                                            // Varyings for fragment texturing
-410             if (states.geometry.uvBuf) {
-411                 src.push("varying vec2 SCENEJS_vUVCoord;");
-412             }
-413             if (states.geometry.uvBuf2) {
-414                 src.push("varying vec2 SCENEJS_vUVCoord2;");
-415             }
-416         }
-417 
-418         /*-----------------------------------------------------------------------------------
-419          * Variables - Morphing
-420          *----------------------------------------------------------------------------------*/
-421 
-422         if (morphing) {
-423             src.push("uniform float SCENEJS_uMorphFactor;");       // LERP factor for morph
-424             if (states.morphGeometry.targets[0].vertexBuf) {      // target2 has these arrays also
-425                 src.push("attribute vec3 SCENEJS_aMorphVertex;");
-426             }
-427             if (normals) {
-428                 if (states.morphGeometry.targets[0].normalBuf) {
-429                     src.push("attribute vec3 SCENEJS_aMorphNormal;");
-430                 }
-431             }
-432         }
-433 
-434         if (customVertexShader.code) {
-435             src.push("\n" + customVertexShader.code + "\n");
-436         }
-437 
-438 
-439         src.push("void main(void) {");
-440         src.push("vec4 tmpVertex=vec4(SCENEJS_aVertex, 1.0); ");
-441 
-442         if (vertexHooks.modelPos) {
-443             src.push("tmpVertex=" + vertexHooks.modelPos + "(tmpVertex);");
-444         }
-445 
-446         src.push("  vec4 modelVertex = tmpVertex; ");
-447         if (normals) {
-448             src.push("  vec4 modelNormal = vec4(SCENEJS_aNormal, 0.0); ");
-449         }
-450 
-451         /*
-452          * Morphing - morph targets are in same model space as the geometry
-453          */
-454         if (morphing) {
-455             if (states.morphGeometry.targets[0].vertexBuf) {
-456                 src.push("  vec4 vMorphVertex = vec4(SCENEJS_aMorphVertex, 1.0); ");
-457                 src.push("  modelVertex = vec4(mix(modelVertex.xyz, vMorphVertex.xyz, SCENEJS_uMorphFactor), 1.0); ");
-458             }
-459             if (normals) {
-460                 if (states.morphGeometry.targets[0].normalBuf) {
-461                     src.push("  vec4 vMorphNormal = vec4(SCENEJS_aMorphNormal, 1.0); ");
-462                     src.push("  modelNormal = vec4( mix(modelNormal.xyz, vMorphNormal.xyz, SCENEJS_uMorphFactor), 1.0); ");
-463                 }
-464             }
-465         }
-466 
-467         src.push("  vec4 worldVertex = SCENEJS_uMMatrix * modelVertex; ");
-468 
-469         if (vertexHooks.worldPos) {
-470             src.push("worldVertex=" + vertexHooks.worldPos + "(worldVertex);");
-471         }
-472 
-473         if (vertexHooks.viewMatrix) {
-474             src.push("vec4 viewVertex = " + vertexHooks.viewMatrix + "(SCENEJS_uVMatrix) * worldVertex;");
-475         } else {
-476             src.push("vec4 viewVertex  = SCENEJS_uVMatrix * worldVertex; ");
-477         }
-478 
-479 
-480         if (vertexHooks.viewPos) {
-481             src.push("viewVertex=" + vertexHooks.viewPos + "(viewVertex);");    // Vertex hook function
-482         }
-483 
-484         if (normals) {
-485             src.push("  vec3 worldNormal = normalize((SCENEJS_uMNMatrix * modelNormal).xyz); ");
-486             src.push("  SCENEJS_vWorldNormal = worldNormal;");
-487             src.push("  SCENEJS_vViewNormal = (SCENEJS_uVNMatrix * vec4(worldNormal, 1.0)).xyz;");
-488         }
-489 
-490         if (clipping || fragmentHooks.worldPos) {
-491             src.push("  SCENEJS_vWorldVertex = worldVertex;");                  // Varying for fragment world clip or hooks
-492         }
-493 
-494         if (fragmentHooks.viewPos) {
-495             src.push("  SCENEJS_vViewVertex = viewVertex;");                    // Varying for fragment hooks
-496         }
-497 
-498         if (vertexHooks.projMatrix) {
-499             src.push("gl_Position = " + vertexHooks.projMatrix + "(SCENEJS_uPMatrix) * viewVertex;");
-500         } else {
-501             src.push("  gl_Position = SCENEJS_uPMatrix * viewVertex;");
-502         }
-503 
-504         /*-----------------------------------------------------------------------------------
-505          * Logic - normals
-506          *
-507          * Transform the world-space lights into view space
-508          *----------------------------------------------------------------------------------*/
-509 
-510         src.push("  vec3 tmpVec3;");
-511         if (normals) {
-512             for (var i = 0; i < states.lights.lights.length; i++) {
-513 
-514                 light = states.lights.lights[i];
-515 
-516                 if (light.mode == "dir") {
-517 
-518                     /* Directional light
-519                      */
-520                     if (light.space == "world") {
-521 
-522                         /* World space light - transform vector to View space
-523                          */
-524                         src.push("SCENEJS_vViewLightVecAndDist" + i + " = vec4(-normalize((SCENEJS_uVMatrix * vec4(SCENEJS_uLightDir" + i + ", 0.0)).xyz), 0.0);");
-525 
-526                     } else {
-527 
-528                         /* View space light
-529                          */
-530                         src.push("SCENEJS_vViewLightVecAndDist" + i + " = vec4(-normalize(SCENEJS_uLightDir" + i + "), 0.0);");
-531                     }
-532                 }
-533 
-534                 if (light.mode == "point") {
-535 
-536                     /* Positional light
-537                      */
-538                     if (light.space == "world") {
-539 
-540                         /* World space light - transform position to View space
-541                          */
-542                         src.push("tmpVec3 = ((SCENEJS_uVMatrix * vec4(SCENEJS_uLightPos" + i + ", 1.0)).xyz - worldVertex.xyz);");
-543                         src.push("SCENEJS_vViewLightVecAndDist" + i + " = vec4(normalize(tmpVec3), length(tmpVec3));");
-544 
-545                     } else {
-546 
-547                         /* View space light
-548                          */
-549                         src.push("tmpVec3 = (SCENEJS_uLightPos" + i + ".xyz - worldVertex.xyz);");
-550                         src.push("SCENEJS_vViewLightVecAndDist" + i + " = vec4(normalize(tmpVec3), length(tmpVec3));");
-551                     }
-552                 }
-553             }
-554         }
-555 
-556         src.push("SCENEJS_vWorldEyeVec = normalize(SCENEJS_uWorldEye - worldVertex.xyz);");
-557 
-558         if (texturing) {                                                        // varyings for fragment texturing
-559             if (states.geometry.uvBuf) {
-560                 src.push("SCENEJS_vUVCoord = SCENEJS_aUVCoord;");
-561             }
-562             if (states.geometry.uvBuf2) {
-563                 src.push("SCENEJS_vUVCoord2 = SCENEJS_aUVCoord2;");
-564             }
-565         }
-566 
-567         if (states.geometry.colorBuf) {
-568             src.push("SCENEJS_vColor = SCENEJS_aVertexColor;");                 // Varyings for fragment interpolated vertex coloring
-569         }
-570         src.push("}");
-571 
-572 
-573         if (false && debugCfg.logScripts === true) {
-574             SceneJS.log.info(src);
-575         }
-576         return src;
-577     };
-578 
-579     /*-----------------------------------------------------------------------------------------------------------------
-580      * Rendering Fragment shader
-581      *---------------------------------------------------------------------------------------------------------------*/
-582 
-583     this._composeRenderingFragmentShader = function(states) {
-584 
-585         var customShaders = states.shader.shaders || {};
-586 
-587         /* Do a full custom shader replacement if code supplied without hooks
-588          */
-589         if (customShaders.fragment && customShaders.fragment.code && !customShaders.fragment.hooks) {
-590             return customShaders.fragment.code;
-591         }
-592 
-593         var customFragmentShader = customShaders.fragment || {};
-594         var fragmentHooks = customFragmentShader.hooks || {};
-595 
-596         var texturing = this._isTexturing(states);
-597         var normals = this._hasNormals(states);
-598         var clipping = states.clips.clips.length > 0;
-599 
-600         var src = ["\n"];
-601 
-602         src.push("precision mediump float;");
-603 
-604 
-605         if (clipping || fragmentHooks.worldPos) {
-606             src.push("varying vec4 SCENEJS_vWorldVertex;");             // World-space vertex
-607         }
-608 
-609         if (fragmentHooks.viewPos) {
-610             src.push("varying vec4 SCENEJS_vViewVertex;");              // View-space vertex
-611         }
-612 
-613         /*-----------------------------------------------------------------------------------
-614          * Variables - Clipping
-615          *----------------------------------------------------------------------------------*/
-616 
-617         if (clipping) {
-618             for (var i = 0; i < states.clips.clips.length; i++) {
-619                 src.push("uniform float SCENEJS_uClipMode" + i + ";");
-620                 src.push("uniform vec4  SCENEJS_uClipNormalAndDist" + i + ";");
-621             }
-622         }
-623 
-624         if (texturing) {
-625             if (states.geometry.uvBuf) {
-626                 src.push("varying vec2 SCENEJS_vUVCoord;");
-627             }
-628             if (states.geometry.uvBuf2) {
-629                 src.push("varying vec2 SCENEJS_vUVCoord2;");
-630             }
-631             var layer;
-632             for (var i = 0, len = states.texture.layers.length; i < len; i++) {
-633                 layer = states.texture.layers[i];
-634                 src.push("uniform sampler2D SCENEJS_uSampler" + i + ";");
-635                 if (layer.matrix) {
-636                     src.push("uniform mat4 SCENEJS_uLayer" + i + "Matrix;");
-637                 }
-638                 src.push("uniform float SCENEJS_uLayer" + i + "BlendFactor;");
-639             }
-640         }
-641 
-642         /* True when lighting
-643          */
-644         src.push("uniform bool  SCENEJS_uBackfaceTexturing;");
-645         src.push("uniform bool  SCENEJS_uBackfaceLighting;");
-646         src.push("uniform bool  SCENEJS_uSpecularLighting;");
-647         src.push("uniform bool  SCENEJS_uClipping;");
-648         src.push("uniform bool  SCENEJS_uAmbient;");
-649 
-650         /* True when rendering transparency
-651          */
-652         src.push("uniform bool  SCENEJS_uTransparent;");
-653 
-654         /* Vertex color variable
-655          */
-656         if (states.geometry.colorBuf) {
-657             src.push("varying vec4 SCENEJS_vColor;");
-658         }
-659 
-660         src.push("uniform vec3  SCENEJS_uAmbientColor;");                         // Scene ambient colour - taken from clear colour
-661 
-662         src.push("uniform vec3  SCENEJS_uMaterialBaseColor;");
-663         src.push("uniform float SCENEJS_uMaterialAlpha;");
-664         src.push("uniform float SCENEJS_uMaterialEmit;");
-665         src.push("uniform vec3  SCENEJS_uMaterialSpecularColor;");
-666         src.push("uniform float SCENEJS_uMaterialSpecular;");
-667         src.push("uniform float SCENEJS_uMaterialShine;");
-668 
-669         src.push("  vec3    ambient= SCENEJS_uAmbient ? SCENEJS_uAmbientColor : vec3(0.0, 0.0, 0.0);");
-670         src.push("  float   emit    = SCENEJS_uMaterialEmit;");
-671 
-672         src.push("varying vec3 SCENEJS_vWorldEyeVec;");                          // Direction of view-space vertex from eye
-673 
-674         if (normals) {
-675 
-676             src.push("varying vec3 SCENEJS_vWorldNormal;");                  // World-space normal
-677             src.push("varying vec3 SCENEJS_vViewNormal;");                   // View-space normal
-678 
-679             var light;
-680             for (var i = 0; i < states.lights.lights.length; i++) {
-681                 light = states.lights.lights[i];
-682                 src.push("uniform vec3  SCENEJS_uLightColor" + i + ";");
-683                 if (light.mode == "point") {
-684                     src.push("uniform vec3  SCENEJS_uLightAttenuation" + i + ";");
-685                 }
-686                 src.push("varying vec4  SCENEJS_vViewLightVecAndDist" + i + ";");         // Vector from light to vertex
-687             }
-688         }
-689 
-690         if (customFragmentShader.code) {
-691             src.push("\n" + customFragmentShader.code + "\n");
-692         }
-693 
-694         src.push("void main(void) {");
-695 
-696         /*-----------------------------------------------------------------------------------
-697          * Logic - Clipping
-698          *----------------------------------------------------------------------------------*/
-699 
-700         if (clipping) {
-701             src.push("if (SCENEJS_uClipping) {");
-702             src.push("  float   dist;");
-703             for (var i = 0; i < states.clips.clips.length; i++) {
-704                 src.push("    if (SCENEJS_uClipMode" + i + " != 0.0) {");
-705                 src.push("        dist = dot(SCENEJS_vWorldVertex.xyz, SCENEJS_uClipNormalAndDist" + i + ".xyz) - SCENEJS_uClipNormalAndDist" + i + ".w;");
-706                 src.push("        if (SCENEJS_uClipMode" + i + " == 1.0) {");
-707                 src.push("            if (dist > 0.0) { discard; }");
-708                 src.push("        }");
-709                 src.push("        if (SCENEJS_uClipMode" + i + " == 2.0) {");
-710                 src.push("            if (dist > 0.0) { discard; }");
-711                 src.push("        }");
-712                 src.push("    }");
-713             }
-714             src.push("}");
-715         }
-716 
-717         if (fragmentHooks.worldPos) {
-718             src.push(fragmentHooks.worldPos + "(SCENEJS_vWorldVertex);");
-719         }
-720 
-721         if (fragmentHooks.viewPos) {
-722             src.push(fragmentHooks.viewPos + "(SCENEJS_vViewVertex);");
-723         }
-724 
-725         if (fragmentHooks.worldEyeVec) {
-726             src.push(fragmentHooks.worldEyeVec + "(SCENEJS_vWorldEyeVec);");
-727         }
-728 
-729         if (normals && fragmentHooks.worldNormal) {
-730             src.push(fragmentHooks.worldNormal + "(SCENEJS_vWorldNormal);");
-731         }
-732 
-733         if (normals && fragmentHooks.viewNormal) {
-734             src.push(fragmentHooks.viewNormal + "(SCENEJS_vViewNormal);");
-735         }
-736 
-737         if (states.geometry.colorBuf) {
-738             src.push("  vec3    color   = SCENEJS_vColor.rgb;");
-739         } else {
-740             src.push("  vec3    color   = SCENEJS_uMaterialBaseColor;")
-741         }
-742 
-743         src.push("  float alpha         = SCENEJS_uMaterialAlpha;");
-744         src.push("  float emit          = SCENEJS_uMaterialEmit;");
-745         src.push("  float specular      = SCENEJS_uMaterialSpecular;");
-746         src.push("  vec3  specularColor = SCENEJS_uMaterialSpecularColor;");
-747         src.push("  float shine         = SCENEJS_uMaterialShine;");
-748 
-749         if (fragmentHooks.materialBaseColor) {
-750             src.push("color=" + fragmentHooks.materialBaseColor + "(color);");
-751         }
-752         if (fragmentHooks.materialAlpha) {
-753             src.push("alpha=" + fragmentHooks.materialAlpha + "(alpha);");
-754         }
-755         if (fragmentHooks.materialEmit) {
-756             src.push("emit=" + fragmentHooks.materialEmit + "(emit);");
-757         }
-758         if (fragmentHooks.materialSpecular) {
-759             src.push("specular=" + fragmentHooks.materialSpecular + "(specular);");
-760         }
-761         if (fragmentHooks.materialSpecularColor) {
-762             src.push("specularColor=" + fragmentHooks.materialSpecularColor + "(specularColor);");
-763         }
-764         if (fragmentHooks.materialShine) {
-765             src.push("shine=" + fragmentHooks.materialShine + "(shine);");
-766         }
-767 
-768         if (normals) {
-769             src.push("  float   attenuation = 1.0;");
-770             src.push("  vec3    viewNormalVec = SCENEJS_vViewNormal;");
-771         }
-772 
-773         var layer;
-774         if (texturing) {
-775 
-776             if (normals) {
-777                 src.push("if (SCENEJS_uBackfaceTexturing || dot(SCENEJS_vWorldNormal, SCENEJS_vWorldEyeVec) > 0.0) {");
-778             }
-779 
-780             src.push("  vec4    texturePos;");
-781             src.push("  vec2    textureCoord=vec2(0.0,0.0);");
-782 
-783             for (var i = 0, len = states.texture.layers.length; i < len; i++) {
-784                 layer = states.texture.layers[i];
-785 
-786                 /* Texture input
-787                  */
-788                 if (layer.applyFrom == "normal" && normals) {
-789                     if (states.geometry.normalBuf) {
-790                         src.push("texturePos=vec4(viewNormalVec.xyz, 1.0);");
-791                     } else {
-792                         SceneJS.log.warn("Texture layer applyFrom='normal' but geo has no normal vectors");
-793                         continue;
-794                     }
-795                 }
-796                 if (layer.applyFrom == "uv") {
-797                     if (states.geometry.uvBuf) {
-798                         src.push("texturePos = vec4(SCENEJS_vUVCoord.s, SCENEJS_vUVCoord.t, 1.0, 1.0);");
-799                     } else {
-800                         SceneJS.log.warn("Texture layer applyTo='uv' but geometry has no UV coordinates");
-801                         continue;
-802                     }
-803                 }
-804                 if (layer.applyFrom == "uv2") {
-805                     if (states.geometry.uvBuf2) {
-806                         src.push("texturePos = vec4(SCENEJS_vUVCoord2.s, SCENEJS_vUVCoord2.t, 1.0, 1.0);");
-807                     } else {
-808                         SceneJS.log.warn("Texture layer applyTo='uv2' but geometry has no UV2 coordinates");
-809                         continue;
-810                     }
-811                 }
-812 
-813                 /* Texture matrix
-814                  */
-815                 if (layer.matrix) {
-816                     src.push("textureCoord=(SCENEJS_uLayer" + i + "Matrix * texturePos).xy;");
-817                 } else {
-818                     src.push("textureCoord=texturePos.xy;");
-819                 }
-820 
-821                 /* Alpha from Texture
-822                  * */
-823                 if (layer.applyTo == "alpha") {
-824                     if (layer.blendMode == "multiply") {
-825                         src.push("alpha = alpha * (SCENEJS_uLayer" + i + "BlendFactor * texture2D(SCENEJS_uSampler" + i + ", vec2(textureCoord.x, 1.0 - textureCoord.y)).b);");
-826                     } else if (layer.blendMode == "add") {
-827                         src.push("alpha = ((1.0 - SCENEJS_uLayer" + i + "BlendFactor) * alpha) + (SCENEJS_uLayer" + i + "BlendFactor * texture2D(SCENEJS_uSampler" + i + ", vec2(textureCoord.x, 1.0 - textureCoord.y)).b);");
-828                     }
-829                 }
-830 
-831                 /* Texture output
-832                  */
-833                 if (layer.applyTo == "baseColor") {
-834                     if (layer.blendMode == "multiply") {
-835                         src.push("color = color * (SCENEJS_uLayer" + i + "BlendFactor * texture2D(SCENEJS_uSampler" + i + ", vec2(textureCoord.x, 1.0 - textureCoord.y)).rgb);");
-836                     } else {
-837                         src.push("color = ((1.0 - SCENEJS_uLayer" + i + "BlendFactor) * color) + (SCENEJS_uLayer" + i + "BlendFactor * texture2D(SCENEJS_uSampler" + i + ", vec2(textureCoord.x, 1.0 - textureCoord.y)).rgb);");
-838                     }
-839                 }
-840 
-841                 if (layer.applyTo == "emit") {
-842                     if (layer.blendMode == "multiply") {
-843                         src.push("emit  = emit * (SCENEJS_uLayer" + i + "BlendFactor * texture2D(SCENEJS_uSampler" + i + ", vec2(textureCoord.x, 1.0 - textureCoord.y)).r);");
-844                     } else {
-845                         src.push("emit = ((1.0 - SCENEJS_uLayer" + i + "BlendFactor) * emit) + (SCENEJS_uLayer" + i + "BlendFactor * texture2D(SCENEJS_uSampler" + i + ", vec2(textureCoord.x, 1.0 - textureCoord.y)).r);");
-846                     }
-847                 }
-848 
-849                 if (layer.applyTo == "specular" && normals) {
-850                     if (layer.blendMode == "multiply") {
-851                         src.push("specular  = specular * (SCENEJS_uLayer" + i + "BlendFactor * texture2D(SCENEJS_uSampler" + i + ", vec2(textureCoord.x, 1.0 - textureCoord.y)).r);");
-852                     } else {
-853                         src.push("specular = ((1.0 - SCENEJS_uLayer" + i + "BlendFactor) * specular) + (SCENEJS_uLayer" + i + "BlendFactor * texture2D(SCENEJS_uSampler" + i + ", vec2(textureCoord.x, 1.0 - textureCoord.y)).r);");
-854                     }
-855                 }
-856 
-857                 if (layer.applyTo == "normals" && normals) {
-858                     src.push("vec3 bump = normalize(texture2D(SCENEJS_uSampler" + i + ", vec2(textureCoord.x, -textureCoord.y)).xyz * 2.0 - 1.0);");
-859                     src.push("viewNormalVec *= -bump;");
-860                 }
-861             }
-862             if (normals) {
-863                 src.push("}");
-864             }
-865         }
-866 
-867         src.push("  vec4    fragColor;");
-868 
-869         if (normals) {
-870 
-871             src.push("if (SCENEJS_uBackfaceLighting || dot(SCENEJS_vWorldNormal, SCENEJS_vWorldEyeVec) > 0.0) {");
-872 
-873             src.push("  vec3    lightValue      = vec3(0.0, 0.0, 0.0);");
-874             src.push("  vec3    specularValue   = vec3(0.0, 0.0, 0.0);");
-875             src.push("  vec3    viewLightVec;");
-876             src.push("  float   dotN;");
-877             src.push("  float   lightDist;");
-878 
-879             var light;
-880 
-881             for (var i = 0, len = states.lights.lights.length; i < len; i++) {
-882                 light = states.lights.lights[i];
-883 
-884                 src.push("viewLightVec = SCENEJS_vViewLightVecAndDist" + i + ".xyz;");
-885 
-886                 if (light.mode == "point") {
-887 
-888                     src.push("dotN = max(dot(viewNormalVec, viewLightVec) ,0.0);");
-889 
-890                     //src.push("if (dotN > 0.0) {");
-891 
-892                     src.push("lightDist = SCENEJS_vViewLightVecAndDist" + i + ".w;");
-893 
-894                     src.push("  attenuation = 1.0 / (" +
-895                              "  SCENEJS_uLightAttenuation" + i + "[0] + " +
-896                              "  SCENEJS_uLightAttenuation" + i + "[1] * lightDist + " +
-897                              "  SCENEJS_uLightAttenuation" + i + "[2] * lightDist * lightDist);");
-898 
-899                     if (light.diffuse) {
-900                         src.push("  lightValue += dotN *  SCENEJS_uLightColor" + i + " * attenuation;");
-901                     }
-902 
-903                     if (light.specular) {
-904                         src.push("if (SCENEJS_uSpecularLighting) specularValue += attenuation * specularColor * SCENEJS_uLightColor" + i +
-905                                  " * specular * pow(max(dot(reflect(viewLightVec, viewNormalVec), vec3(0.0,0.0,1.0)), 0.0), shine);");
-906                     }
-907                     //src.push("}");
-908                 }
-909 
-910                 if (light.mode == "dir") {
-911 
-912                     src.push("dotN = max(dot(viewNormalVec,viewLightVec),0.0);");
-913 
-914                     //src.push("if (dotN > 0.0) {");
-915                     if (light.diffuse) {
-916                         src.push("lightValue += dotN * SCENEJS_uLightColor" + i + ";");
-917                     }
-918 
-919                     if (light.specular) {
-920                         src.push("if (SCENEJS_uSpecularLighting) specularValue += specularColor * SCENEJS_uLightColor" + i +
-921                                  " * specular * pow(max(dot(reflect(viewLightVec, viewNormalVec), vec3(0.0,0.0,1.0)), 0.0), shine);");
-922                     }
-923                     // src.push("}");
-924                 }
-925             }
-926 
-927             src.push("      fragColor = vec4((specularValue.rgb + color.rgb * (lightValue.rgb + ambient.rgb)) + (emit * color.rgb), alpha);");
-928             src.push("   } else {");
-929             src.push("      fragColor = vec4((color.rgb + (emit * color.rgb)) *  (vec3(1.0, 1.0, 1.0) + ambient.rgb), alpha);");
-930             src.push("   }");
-931 
-932         } else { // No normals
-933             src.push("fragColor = vec4((color.rgb + (emit * color.rgb)) *  (vec3(1.0, 1.0, 1.0) + ambient.rgb), alpha);");
-934         }
-935 
-936         if (fragmentHooks.pixelColor) {
-937             src.push("fragColor=" + fragmentHooks.pixelColor + "(fragColor);");
-938         }
-939 
-940         if (false && debugCfg.whitewash === true) {
-941             src.push("    gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);");
-942         } else {
-943             src.push("    gl_FragColor = fragColor;");
-944         }
-945         src.push("}");
-946 
-947         return src;
-948     };
-949 
-950 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_display_renderContext.js.html b/docs/symbols/src/src_core_display_renderContext.js.html deleted file mode 100644 index 36717e89..00000000 --- a/docs/symbols/src/src_core_display_renderContext.js.html +++ /dev/null @@ -1,95 +0,0 @@ -
  1 /**
-  2  * @class A facade which exposes internal scene rendering state to "rendered" event listeners bound to scene graph nodes with {@link SceneJS.Node#bind}.
-  3  *
-  4  * <p>The listener is fired for each {@link SceneJS.Geometry} that is rendered within the subgraph of the bound node.
-  5  * An instance of this facade is passed into the listener's handler, enabling the listener to obtain the various transform
-  6  * matrices that are active at that {@link SceneJS.Geometry}.</p>
-  7  *
-  8  * <p>The facade instance is only valid within the callback's execution; internally, SceneJS reuses the same instance of the
-  9  * facade with each scene.</p>
- 10  */
- 11 SceneJS.RenderContext = function(frameCtx) {
- 12     this._frameCtx = frameCtx;
- 13 };
- 14 
- 15 /**
- 16  * Get the projection matrix, as defined by the active {@link SceneJS.Camera} node.
- 17  */
- 18 SceneJS.RenderContext.prototype.getCameraMatrix = function() {
- 19     return this._frameCtx.cameraMat;
- 20 };
- 21 
- 22 /**
- 23  * Get the view matrix, as defined by the active {@link SceneJS.LookAt} node.
- 24  */
- 25 SceneJS.RenderContext.prototype.getViewMatrix = function() {
- 26     return this._frameCtx.viewMat;
- 27 };
- 28 
- 29 /**
- 30  * Get the model matrix, as defined by the active {@link SceneJS.XForm} node.
- 31  */
- 32 SceneJS.RenderContext.prototype.getModelMatrix = function() {
- 33     return this._frameCtx.modelMat;
- 34 };
- 35 
- 36 /**
- 37  * Transforms the given world coordinate by the model, view and projection matrices defined by the active {@link SceneJS.XForm}, {@link SceneJS.LookAt} and {@link SceneJS.Camera} nodes.
- 38  * @returns [Number] The 2D Canvas-space coordinate
- 39  */
- 40 SceneJS.RenderContext.prototype.getCanvasPos = function(offset) {
- 41 
- 42     this.getProjPos(offset);
- 43 
- 44     var canvas = this._frameCtx.canvas.canvas;
- 45     var canvasWidth = canvas.width;
- 46     var canvasHeight = canvas.height;
- 47 
- 48     /* Projection division and map to canvas
- 49      */
- 50     var pc = this._pc;
- 51 
- 52     var x = (pc[0] / pc[3]) * canvasWidth * 0.5;
- 53     var y = (pc[1] / pc[3]) * canvasHeight * 0.5;
- 54 
- 55     return {
- 56         x: x + (canvasWidth * 0.5),
- 57         y: canvasHeight - y - (canvasHeight * 0.5)
- 58     };
- 59 };
- 60 
- 61 /**
- 62  * Transforms the given world coordinate by the model and view matrices defined by the active {@link SceneJS.XForm} and {@link SceneJS.LookAt} nodes.
- 63  * @returns [Number] The 3D Projection-space coordinate
- 64  */
- 65 SceneJS.RenderContext.prototype.getCameraPos = function(offset) {
- 66     this.getProjPos(offset);
- 67     this._camPos = SceneJS_math_normalizeVec3(this._pc, [0,0,0]);
- 68     return { x: this._camPos[0], y: this._camPos[1], z: this._camPos[2] }; // TODO: return _camPos and lose the temp object
- 69 };
- 70 
- 71 
- 72 SceneJS.RenderContext.prototype.getProjPos = function(offset) {
- 73     this.getViewPos(offset);
- 74     this._pc = SceneJS_math_transformPoint3(this._frameCtx.cameraMat, this._vc);
- 75     return { x: this._pc[0], y: this._pc[1], z: this._pc[2],  w: this._pc[3] };
- 76 };
- 77 
- 78 SceneJS.RenderContext.prototype.getViewPos = function(offset) {
- 79     this.getWorldPos(offset);
- 80     this._vc = SceneJS_math_transformPoint3(this._frameCtx.viewMat, this._wc);
- 81     return { x: this._vc[0], y: this._vc[1], z: this._vc[2],  w: this._vc[3] };
- 82 };
- 83 
- 84 SceneJS.RenderContext.prototype.getWorldPos = function(offset) {
- 85     this._wc = SceneJS_math_transformPoint3(this._frameCtx.modelMat, offset || [0,0,0]);
- 86     return { x: this._wc[0], y: this._wc[1], z: this._wc[2],  w: this._wc[3] };
- 87 };
- 88 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_engine.js.html b/docs/symbols/src/src_core_engine.js.html deleted file mode 100644 index 19375543..00000000 --- a/docs/symbols/src/src_core_engine.js.html +++ /dev/null @@ -1,567 +0,0 @@ -
  1 /**
-  2  * @class A container for a scene graph and its display
-  3  *
-  4  *
-  5  * @private
-  6  */
-  7 var SceneJS_Engine = function(json, options) {
-  8 
-  9     json.type = "scene"; // The type property supplied by user on the root JSON node is ignored - would always be 'scene'
- 10 
- 11     /**
- 12      * ID of this engine, also the ID of this engine's {@link SceneJS.Scene}
- 13      * @type String
- 14      */
- 15     this.id = json.id;
- 16 
- 17     /**
- 18      * Canvas and GL context for this engine
- 19      */
- 20     this.canvas = new SceneJS_Canvas(this.id, json.canvasId, json.contextAttr, options);
- 21 
- 22     /**
- 23      * Manages firing of and subscription to events
- 24      */
- 25     this.events = new SceneJS_eventManager();
- 26 
- 27     this.events.createEvent("started");
- 28     this.events.createEvent("tick");
- 29     this.events.createEvent("rendered");
- 30     this.events.createEvent("sleep");
- 31     this.events.createEvent("stopped");
- 32     this.events.createEvent("loading");     // Loading processes now exist
- 33     this.events.createEvent("loaded");      // No loading processes now exist
- 34     this.events.createEvent("destroyed");
- 35 
- 36     /**
- 37      * State core factory - creates, stores, shares and destroys cores
- 38      */
- 39     this._coreFactory = new SceneJS_CoreFactory();
- 40 
- 41     /**
- 42      * Manages creation, recycle and destruction of {@link SceneJS.Node} instances for this engine's scene graph
- 43      */
- 44     this._nodeFactory = new SceneJS_NodeFactory();
- 45 
- 46     /**
- 47      * The engine's scene renderer
- 48      * @type SceneJS_Display
- 49      */
- 50     this.display = new SceneJS_Display({
- 51         canvas:  this.canvas
- 52     });
- 53 
- 54     /**
- 55      * Flags the entirety of the scene graph as needing to be (re)compiled into the display
- 56      */
- 57     this.sceneDirty = false;
- 58 
- 59     /**
- 60      * Flag set when at least one branch of the scene graph needs recompilation
- 61      */
- 62     this._sceneBranchesDirty = false;
- 63 
- 64     /**
- 65      * List of nodes scheduled for destruction by #destroyNode
- 66      * Destructions are done in a batch at the end of each render so as not to disrupt the render.
- 67      */
- 68     this._nodesToDestroy = [];
- 69 
- 70     /**
- 71      * Number of nodes in destruction list
- 72      */
- 73     this._numNodesToDestroy = 0;
- 74 
- 75     /**
- 76      * Flag which is set while this engine is running - set after call to #start, unset after #stop or #pause
- 77      */
- 78     this.running = false;
- 79 
- 80     /**
- 81      * Flag which is set while this engine is paused - set after call to #pause, unset after #stop or #start
- 82      */
- 83     this.paused = false;
- 84 
- 85     /**
- 86      * Flag set once this engine has been destroyed
- 87      */
- 88     this.destroyed = false;
- 89 
- 90     /**
- 91      * The current scene graph status
- 92      */
- 93     this.sceneStatus = {
- 94         nodes: {},          // Status for each node 
- 95         numTasks: 0       // Number of loads currently in progress
- 96     };
- 97 
- 98     /**
- 99      * The engine's scene graph
-100      * @type SceneJS.Scene
-101      */
-102     this.scene = this.createNode(json); // Scene back-references this engine, so is defined after other engine members
-103 
-104     var self = this;
-105 
-106     this.canvas.canvas.addEventListener(// WebGL context lost
-107             "webglcontextlost",
-108             function(event) {
-109 
-110                 event.preventDefault();
-111 
-112                 SceneJS_events.fireEvent(SceneJS_events.WEBGL_CONTEXT_LOST, { scene: self.scene });
-113 
-114             },
-115             false);
-116 
-117     this.canvas.canvas.addEventListener(// WebGL context recovered
-118             "webglcontextrestored",
-119             function(event) {
-120 
-121                 event.preventDefault();
-122 
-123                 self.canvas.initWebGL();
-124 
-125                 self._coreFactory.webglRestored();  // Reallocate WebGL resources for node state cores
-126 
-127                 self.display.webglRestored(); // Reallocate shaders and re-cache shader var locations for display state chunks
-128 
-129                 SceneJS_events.fireEvent(SceneJS_events.WEBGL_CONTEXT_RESTORED, { scene: self.scene });
-130             },
-131             false);
-132 };
-133 
-134 
-135 /**
-136  * Simulate a lost WebGL context.
-137  * Only works if the simulateWebGLContextLost was given as an option to the engine's constructor.
-138  */
-139 SceneJS_Engine.prototype.loseWebGLContext = function() {
-140     this.canvas.loseWebGLContext();
-141 };
-142 
-143 /**
-144  * Recursively parse the given JSON scene graph representation and return a scene (sub)graph.
-145  *
-146  * @param {Object} json JSON definition of a scene graph or subgraph
-147  * @returns {SceneJS.Node} Root of the new (sub)graph
-148  */
-149 SceneJS_Engine.prototype.createNode = function(json) {
-150 
-151     json.type = json.type || "node"; // Nodes are SceneJS.Node type by default
-152 
-153     var core = this._coreFactory.getCore(json.type, json.coreId); // Create or share a core
-154 
-155     var node;
-156 
-157     //try {
-158     node = this._nodeFactory.getNode(this, json, core);
-159 
-160     SceneJS_events.fireEvent(SceneJS_events.NODE_CREATED, {
-161         sceneId: this.id, // Engine ID is same as scene ID
-162         nodeId: node.nodeId
-163     });
-164 
-165 
-166     //    } catch (e) {
-167     //
-168     //        this._coreFactory.putCore(core); // Clean up after node create failed
-169     //
-170     //        throw e;
-171     //    }
-172 
-173     if (json.nodes) {
-174 
-175         for (var i = 0, len = json.nodes.length; i < len; i++) { // Create sub-nodes
-176             node.addNode(this.createNode(json.nodes[i]));
-177         }
-178     }
-179 
-180     return node;
-181 };
-182 
-183 /**
-184  * Finds the node with the given ID in this engine's scene graph
-185  * @return {SceneJS.Node} The node if found, else null
-186  */
-187 SceneJS_Engine.prototype.findNode = function(nodeId) {
-188     return this._nodeFactory.nodes.items[nodeId];
-189 };
-190 
-191 /** Finds nodes in this engine's scene graph that have nodes IDs matching the given regular expression
-192  * @param {String} nodeIdRegex Regular expression to match on node IDs
-193  * @return {[SceneJS.Node]} Array of nodes whose IDs match the given regex
-194  */
-195 SceneJS_Engine.prototype.findNodes = function(nodeIdRegex) {
-196 
-197     var regex = new RegExp(nodeIdRegex);
-198     var nodes = [];
-199     var nodeMap = this._nodeFactory.nodes.items;
-200 
-201     for (var nodeId in nodeMap) {
-202         if (nodeMap.hasOwnProperty(nodeId)) {
-203 
-204             if (regex.test(nodeId)) {
-205                 nodes.push(nodeMap[nodeId]);
-206             }
-207         }
-208     }
-209 
-210     return nodes;
-211 };
-212 
-213 /**
-214  * Schedules the given subtree of this engine's {@link SceneJS.Scene} for recompilation
-215  *
-216  * @param {SceneJS.Node} node Root node of the subtree to recompile
-217  */
-218 SceneJS_Engine.prototype.branchDirty = function(node) {
-219 
-220     if (this.sceneDirty) {
-221         return; // Whole scene will recompile anyway
-222     }
-223 
-224     /* Dealing with some weirdness with the embedded window and iframe / window fascism.
-225      */
-226     if (node == window) {
-227         return;
-228     }
-229 
-230     node.branchDirty = true;
-231     node.dirty = true;
-232 
-233     for (var n = node.parent; n && !(n.dirty || n.branchDirty); n = n.parent) { // Flag path down to this node
-234         n.dirty = true;
-235     }
-236 
-237     this._sceneBranchesDirty = true;
-238 };
-239 
-240 
-241 SceneJS_Engine.prototype.nodeLoading = function(node) {
-242 
-243     var nodeStatus = this.sceneStatus.nodes[node.id] || (this.sceneStatus.nodes[node.id] = { numTasks: 0 });
-244 
-245     nodeStatus.numTasks++;
-246 
-247     this.sceneStatus.numTasks++;
-248 
-249     this.events.fireEvent("loading", this.sceneStatus);
-250 };
-251 
-252 SceneJS_Engine.prototype.nodeLoaded = function(node) {
-253 
-254     var nodeStatus = this.sceneStatus.nodes[node.id];
-255 
-256     if (!nodeStatus) {
-257         return;
-258     }
-259 
-260     nodeStatus.numTasks--;
-261 
-262     this.sceneStatus.numTasks--;
-263 
-264     if (nodeStatus.numTasks == 0) {
-265         delete this.sceneStatus.nodes[node.id];
-266     }
-267 
-268     this.events.fireEvent("loaded", this.sceneStatus);
-269 };
-270 
-271 
-272 /**
-273  * Renders a single frame. Does any pending scene compilations or draw graph updates first.
-274  * Ordinarily the frame is rendered only if compilations or draw graph updates were performed,
-275  * but may be forced to render the frame regardless.
-276  *
-277  * @param {{String:String}} params Rendering parameters
-278  */
-279 SceneJS_Engine.prototype.renderFrame = function(params) {
-280 
-281     if (this._tryCompile() || (params && params.force)) { // Do any pending (re)compilations
-282 
-283 //        var eventParams = {
-284 //            sceneId: this.id
-285 //        };
-286 //
-287         //self.events.fireEvent("tick", eventParams);
-288 
-289         this.display.render(params);
-290 
-291         return true;
-292     }
-293 
-294     return false;
-295 };
-296 
-297 /**
-298  * Starts the render loop on this engine.
-299  * @params cfg Render loop configs
-300  * @params cfg.idleFunc {Function} Callback to call on each loop iteration
-301  * @params cfg.frameFunc {Function} Callback to call after a render is done to update the scene image
-302  * @params cfg.sleepFunc {Function}
-303  */
-304 SceneJS_Engine.prototype.start = function(cfg) {
-305 
-306     if (!this.running) {
-307 
-308         cfg = cfg || {};
-309 
-310         this.running = true;
-311         this.paused = false;
-312 
-313         var self = this;
-314         var fnName = "__scenejs_sceneLoop" + this.id;
-315 
-316         var sleeping = false;
-317 
-318         this.sceneDirty = true;
-319 
-320         var idleEventParams = {
-321             sceneId: this.id
-322         };
-323 
-324         self.events.fireEvent("started", idleEventParams);
-325 
-326         window[fnName] = function() {
-327 
-328             if (self.running && !self.paused) {  // idleFunc may have paused scene
-329 
-330                 self.events.fireEvent("tick", idleEventParams);
-331 
-332                 if (cfg.idleFunc) {
-333                     cfg.idleFunc();
-334                 }
-335 
-336                 if (!self.running) { // idleFunc may have destroyed scene
-337                     return;
-338                 }
-339 
-340                 if (self._tryCompile()) {         // Attempt pending compile and redraw
-341 
-342                     sleeping = false;
-343 
-344                     self.display.render();
-345 
-346                     self.events.fireEvent("rendered", idleEventParams);
-347 
-348                     if (cfg.frameFunc) {
-349                         cfg.frameFunc();
-350                     }
-351 
-352                     window.requestAnimationFrame(window[fnName]);
-353 
-354                 } else {
-355 
-356                     if (!sleeping && cfg.sleepFunc) {
-357                         cfg.sleepFunc();
-358                     }
-359 
-360                     sleeping = true;
-361 
-362                     self.events.fireEvent("sleep", idleEventParams);
-363 
-364                     window.requestAnimationFrame(window[fnName]);
-365                 }
-366             } else {
-367 
-368                 window.requestAnimationFrame(window[fnName]);
-369             }
-370         };
-371 
-372         this._startCfg = cfg;
-373 
-374         window.requestAnimationFrame(window[fnName]);
-375     }
-376 };
-377 
-378 /**
-379  * Performs a pick on this engine and returns a hit record containing at least the name of the picked
-380  * scene object (as configured by SceneJS.Name nodes) and the canvas pick coordinates. Ordinarily, picking
-381  * is the simple GPU color-name mapped method, but this method can instead perform a ray-intersect pick
-382  * when the 'rayPick' flag is set on the options parameter for this method. For that mode, this method will
-383  * also find the intersection point on the picked object's near surface with a ray cast from the eye that passes
-384  * through the mouse position on the projection plane.
-385  *
-386  * @param {Number} canvasX X-axis canvas pick coordinate
-387  * @param {Number} canvasY Y-axis canvas pick coordinate
-388  * @param options Pick options
-389  * @param options.rayPick Performs additional ray-intersect pick when true
-390  * @returns The pick record
-391  */
-392 SceneJS_Engine.prototype.pick = function(canvasX, canvasY, options) {
-393 
-394     this._tryCompile();  // Do any pending scene compilations
-395 
-396     var hit = this.display.pick({
-397         canvasX : canvasX,
-398         canvasY : canvasY,
-399         rayPick: options ? options.rayPick : false
-400     });
-401 
-402     if (hit) {
-403         hit.canvasX = canvasX;
-404         hit.canvasY = canvasY;
-405     }
-406 
-407     return hit;
-408 };
-409 
-410 /**
-411  * Performs any pending scene compilations or display rebuilds, returns true if any of those were done,
-412  * in which case a display re-render is then needed
-413  *
-414  * @returns {Boolean} True when any compilations or display rebuilds were done
-415  */
-416 SceneJS_Engine.prototype._tryCompile = function() {
-417 
-418     if (this.display.imageDirty // Frame buffer needs redraw
-419             || this.display.drawListDirty // Draw list needs rebuild
-420             || this.display.stateSortDirty // Draw list needs to redetermine state order
-421             || this.display.stateOrderDirty // Draw list needs state sort
-422             || this.display.objectListDirty // Draw list needs to be rebuilt
-423             || this._sceneBranchesDirty // One or more branches in scene graph need (re)compilation
-424             || this.sceneDirty) { // Whole scene needs recompilation
-425 
-426         this._doDestroyNodes(); // Garbage collect destroyed nodes - node destructions set imageDirty true
-427 
-428         if (this._sceneBranchesDirty || this.sceneDirty) { // Need scene graph compilation
-429 
-430             SceneJS_events.fireEvent(SceneJS_events.SCENE_COMPILING, {  // Notify compilation support start
-431                 engine: this                                            // Compilation support modules get ready
-432             });
-433 
-434             this.scene._compileNodes(); // Begin depth-first compilation descent into scene sub-nodes
-435         }
-436 
-437         this._sceneBranchesDirty = false;
-438         this.sceneDirty = false;
-439 
-440         return true; // Compilation was performed, need frame redraw now
-441     }
-442 
-443     return false;
-444 };
-445 
-446 /**
-447  * Pauses/unpauses the render loop
-448  * @param {Boolean} doPause Pauses or unpauses the render loop
-449  */
-450 SceneJS_Engine.prototype.pause = function(doPause) {
-451     this.paused = doPause;
-452 };
-453 
-454 /**
-455  * Stops the render loop
-456  */
-457 SceneJS_Engine.prototype.stop = function() {
-458 
-459     if (this.running) {
-460 
-461         this.running = false;
-462         this.paused = false;
-463 
-464         window["__scenejs_sceneLoop" + this.id] = null;
-465 
-466         this.events.fireEvent("stopped", { sceneId: this.id });
-467     }
-468 };
-469 
-470 /**
-471  * Destroys a node within this engine's {@link SceneJS.Scene}
-472  *
-473  * @param {SceneJS.Node} node Node to destroy
-474  */
-475 SceneJS_Engine.prototype.destroyNode = function(node) {
-476 
-477     /* The node is actually scheduled for lazy destruction within the next invocation of #_tryCompile
-478      */
-479     this._nodesToDestroy[this._numNodesToDestroy++] = node;
-480 
-481     /* Stop tracking node's status
-482      */
-483     var nodeStatus = this.sceneStatus.nodes[node.id];
-484 
-485     if (nodeStatus) {
-486         this.sceneStatus.numTasks -= nodeStatus.numTasks;
-487         delete this.sceneStatus.nodes[node.id];
-488     }
-489 };
-490 
-491 /**
-492  * Performs pending node destructions. When destroyed, each node and its core is released back to the
-493  * node and core pools for reuse, respectively.
-494  */
-495 SceneJS_Engine.prototype._doDestroyNodes = function() {
-496 
-497     var node;
-498 
-499     while (this._numNodesToDestroy > 0) {
-500 
-501         node = this._nodesToDestroy[--this._numNodesToDestroy];
-502 
-503         node._doDestroy();
-504 
-505         this._coreFactory.putCore(node._core);    // Release state core for reuse
-506 
-507         this._nodeFactory.putNode(node);         // Release node for reuse
-508     }
-509 };
-510 
-511 /**
-512  * Destroys this engine
-513  */
-514 SceneJS_Engine.prototype.destroy = function() {
-515 
-516     this.destroyed = true;
-517 
-518     this.events.fireEvent("destroyed", { sceneId: this.id });
-519 };
-520 
-521 /*---------------------------------------------------------------------------------------------------------------------
-522  * JavaScript augmentations to support render loop
-523  *--------------------------------------------------------------------------------------------------------------------*/
-524 
-525 if (! self.Int32Array) {
-526     self.Int32Array = Array;
-527     self.Float32Array = Array;
-528 }
-529 
-530 // Ripped off from THREE.js - https://github.com/mrdoob/three.js/blob/master/src/Three.js
-531 // http://paulirish.com/2011/requestanimationframe-for-smart-animating/
-532 // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
-533 
-534 (function() {
-535     var lastTime = 0;
-536     var vendors = ['ms', 'moz', 'webkit', 'o'];
-537     for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
-538         window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
-539         window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame']
-540                 || window[vendors[x] + 'RequestCancelAnimationFrame'];
-541     }
-542 
-543     if (!window.requestAnimationFrame)
-544         window.requestAnimationFrame = function(callback, element) {
-545             var currTime = new Date().getTime();
-546             var timeToCall = Math.max(0, 16 - (currTime - lastTime));
-547             var id = window.setTimeout(function() {
-548                 callback(currTime + timeToCall);
-549             },
-550                     timeToCall);
-551             lastTime = currTime + timeToCall;
-552             return id;
-553         };
-554 
-555     if (!window.cancelAnimationFrame)
-556         window.cancelAnimationFrame = function(id) {
-557             clearTimeout(id);
-558         };
-559 }());
-560 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_errors.js.html b/docs/symbols/src/src_core_errors.js.html deleted file mode 100644 index 6c6c8752..00000000 --- a/docs/symbols/src/src_core_errors.js.html +++ /dev/null @@ -1,92 +0,0 @@ -
  1 /**
-  2  * Backend module that provides single point through which exceptions may be raised
-  3  *
-  4  * @class SceneJS_error
-  5  * @private
-  6  */
-  7 var SceneJS_error = new (function() {
-  8 
-  9     var activeSceneId;
- 10 
- 11     SceneJS_events.addListener(
- 12             SceneJS_events.SCENE_COMPILING, // Set default logging for scene root
- 13             function(params) {
- 14                 activeSceneId = params.engine.id;
- 15             });
- 16 
- 17     SceneJS_events.addListener(
- 18             SceneJS_events.RESET,
- 19             function() {
- 20                 activeSceneId = null;
- 21             },
- 22             100000);  // Really low priority - must be reset last
- 23 
- 24     this.fatalError = function(code, message) {
- 25         if (typeof code == "string") {
- 26             message = code;
- 27             code = SceneJS.errors.ERROR;
- 28         }
- 29         var error = {
- 30             errorName: SceneJS.errors._getErrorName(code) || "ERROR",
- 31             code: code,
- 32             exception: message,
- 33             fatal: true
- 34         };
- 35         if (activeSceneId) {
- 36             error.sceneId = activeSceneId;
- 37         }
- 38         SceneJS_events.fireEvent(SceneJS_events.ERROR, error);
- 39         return message;
- 40     };
- 41 
- 42     this.error = function(code, message) {
- 43         var error = {
- 44             errorName: SceneJS.errors._getErrorName(code) || "ERROR",
- 45             code: code,
- 46             exception: message,
- 47             fatal: false
- 48         };
- 49         if (activeSceneId) {
- 50             error.sceneId = activeSceneId;
- 51         }
- 52         SceneJS_events.fireEvent(SceneJS_events.ERROR, error);
- 53     };
- 54 })();
- 55 
- 56 (function() {
- 57     SceneJS.errors = {};
- 58 
- 59     var n = 0;
- 60     SceneJS.errors.ERROR = n++;
- 61     SceneJS.errors.WEBGL_NOT_SUPPORTED = n++;
- 62     SceneJS.errors.WEBGL_CONTEXT_LOST = n++;
- 63     SceneJS.errors.NODE_CONFIG_EXPECTED = n++;
- 64     SceneJS.errors.ILLEGAL_NODE_CONFIG = n++;
- 65     SceneJS.errors.SHADER_COMPILATION_FAILURE = n++;
- 66     SceneJS.errors.SHADER_LINK_FAILURE = n++;
- 67     SceneJS.errors.CANVAS_NOT_FOUND = n++;
- 68     SceneJS.errors.OUT_OF_VRAM = n++;
- 69     SceneJS.errors.WEBGL_UNSUPPORTED_NODE_CONFIG = n++;
- 70     SceneJS.errors.NODE_NOT_FOUND = n++;
- 71     SceneJS.errors.NODE_ILLEGAL_STATE = n++;
- 72     SceneJS.errors.ID_CLASH = n++;
- 73     SceneJS.errors.PLUGIN_INVALID = n++;
- 74 })();
- 75 
- 76 SceneJS.errors._getErrorName = function(code) {
- 77     for (var key in SceneJS.errors) {
- 78         if (SceneJS.errors.hasOwnProperty(key) && SceneJS.errors[key] == code) {
- 79             return key;
- 80         }
- 81     }
- 82     return null;
- 83 };
- 84 
- 85 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_eventManager.js.html b/docs/symbols/src/src_core_eventManager.js.html deleted file mode 100644 index 74adda52..00000000 --- a/docs/symbols/src/src_core_eventManager.js.html +++ /dev/null @@ -1,103 +0,0 @@ -
  1 /**
-  2  *  @private
-  3  */
-  4 var SceneJS_eventManager = function() {
-  5 
-  6     this._handlerIds = new SceneJS_Map();
-  7 
-  8     this.typeHandlers = {};
-  9 };
- 10 
- 11 /**
- 12  *
- 13  */
- 14 SceneJS_eventManager.prototype.createEvent = function(type) {
- 15 
- 16     if (this.typeHandlers[type]) {
- 17         return;
- 18     }
- 19 
- 20     this.typeHandlers[type] = {
- 21         handlers: {},
- 22         numSubs: 0
- 23     };
- 24 };
- 25 
- 26 /**
- 27  * Subscribes to an event defined on this event manager
- 28  *
- 29  * @param {String} type Event type one of the values in SceneJS_events
- 30  * @param {Function} callback Handler function that will accept whatever parameter object accompanies the event
- 31  * @return {String} handle Handle to the event binding
- 32  */
- 33 SceneJS_eventManager.prototype.onEvent = function(type, callback) {
- 34 
- 35     var handlersForType = this.typeHandlers[type];
- 36 
- 37     if (!handlersForType) {
- 38         throw "event type not supported: '" + type + "'";
- 39     }
- 40 
- 41     var handlerId = this._handlerIds.addItem(type);
- 42 
- 43     var handlers = handlersForType.handlers;
- 44     handlers[handlerId] = callback;
- 45     handlersForType.numSubs++;
- 46 
- 47     return handlerId;
- 48 };
- 49 
- 50 /**
- 51  *
- 52  */
- 53 SceneJS_eventManager.prototype.fireEvent = function(type, params) {
- 54 
- 55     var handlersForType = this.typeHandlers[type];
- 56 
- 57     if (!handlersForType) {
- 58         throw "event not supported: '" + type + "'";
- 59     }
- 60 
- 61     if (handlersForType.numSubs > 0) {
- 62 
- 63         var handlers = handlersForType.handlers;
- 64 
- 65         for (var handlerId in handlers) {
- 66             if (handlers.hasOwnProperty(handlerId)) {
- 67                 handlers[handlerId](params);
- 68             }
- 69         }
- 70     }
- 71 };
- 72 
- 73 /**
- 74  * Unsubscribes to an event previously subscribed to on this manager
- 75  *
- 76  * @param {String} handlerId Subscription handle
- 77  */
- 78 SceneJS_eventManager.prototype.unEvent = function(handlerId) {
- 79 
- 80     var type = this._handlerIds.items[handlerId];
- 81     if (!type) {
- 82         return;
- 83     }
- 84 
- 85     this._handlerIds.removeItem(handlerId);
- 86 
- 87     var handlers = this.typeHandlers[type];
- 88 
- 89     if (!handlers) {
- 90         return;
- 91     }
- 92 
- 93     delete handlers[handlerId];
- 94     this.typeHandlers[type].numSubs--;
- 95 };
- 96 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_events.js.html b/docs/symbols/src/src_core_events.js.html deleted file mode 100644 index 392e0430..00000000 --- a/docs/symbols/src/src_core_events.js.html +++ /dev/null @@ -1,194 +0,0 @@ -
  1 /**
-  2  *  @private
-  3  */
-  4 var SceneJS_events = new (function () {
-  5 
-  6     this.ERROR = 0;
-  7     this.RESET = 1;                         // SceneJS framework reset
-  8     this.NODE_CREATED = 2;                 // Scene has just been created
-  9     this.SCENE_CREATED = 3;                 // Scene has just been created
- 10     this.SCENE_COMPILING = 4;               // Scene about to be compiled and drawn
- 11     this.SCENE_DESTROYED = 5;               // Scene just been destroyed
- 12     this.OBJECT_COMPILING = 6;
- 13     this.WEBGL_CONTEXT_LOST = 7;
- 14     this.WEBGL_CONTEXT_RESTORED = 8;
- 15 
- 16     /* Priority queue for each type of event
- 17      */
- 18     var events = [];
- 19 
- 20     /**
- 21      * Registers a handler for the given event and returns a subscription handle
- 22      *
- 23      * The handler can be registered with an optional priority number which specifies the order it is
- 24      * called among the other handler already registered for the event.
- 25      *
- 26      * So, with n being the number of commands registered for the given event:
- 27      *
- 28      * (priority <= 0)      - command will be the first called
- 29      * (priority >= n)      - command will be the last called
- 30      * (0 < priority < n)   - command will be called at the order given by the priority
- 31      * @private
- 32      * @param type Event type - one of the values in SceneJS_events
- 33      * @param command - Handler function that will accept whatever parameter object accompanies the event
- 34      * @param priority - Optional priority number (see above)
- 35      * @return {String} - Subscription handle
- 36      */
- 37     this.addListener = function (type, command, priority) {
- 38 
- 39         var list = events[type];
- 40 
- 41         if (!list) {
- 42             list = [];
- 43             events[type] = list;
- 44         }
- 45 
- 46         var handler = {
- 47             command:command,
- 48             priority:(priority == undefined) ? list.length : priority
- 49         };
- 50 
- 51         var index = -1;
- 52 
- 53         for (var i = 0, len = list.length; i < len; i++) {
- 54             if (!list[i]) {
- 55                 index = i;
- 56                 break;
- 57             }
- 58         }
- 59 
- 60         if (index < 0) {
- 61             list.push(handler);
- 62             index = list.length - 1;
- 63         }
- 64 
- 65 //
- 66 //        for (var i = 0; i < list.length; i++) {
- 67 //            if (list[i].priority > handler.priority) {
- 68 //                list.splice(i, 0, handler);
- 69 //                return i;
- 70 //            }
- 71 //        }
- 72 
- 73 
- 74         var handle = type + "." + index;
- 75 
- 76         return handle;
- 77     };
- 78 
- 79     /**
- 80      * Removes a listener
- 81      * @param handle Subscription handle
- 82      */
- 83     this.removeListener = function (handle) {
- 84 
- 85         var lastIdx = handle.lastIndexOf(".");
- 86 
- 87         var type = parseInt(handle.substr(0, lastIdx));
- 88         var index = parseInt(handle.substr(lastIdx + 1));
- 89 
- 90         var list = events[type];
- 91 
- 92         if (!list) {
- 93             return;
- 94         }
- 95 
- 96         delete list[index];
- 97     };
- 98 
- 99     /**
-100      * @private
-101      */
-102     this.fireEvent = function (type, params) {
-103 
-104         var list = events[type];
-105 
-106         if (list) {
-107             params = params || {};
-108             for (var i = 0; i < list.length; i++) {
-109                 if (list[i]) {
-110                     list[i].command(params);
-111                 }
-112             }
-113         }
-114     };
-115 
-116 })();
-117 
-118 
-119 /**
-120  * Subscribe to SceneJS events
-121  * @deprecated
-122  */
-123 SceneJS.bind = function (name, func) {
-124     switch (name) {
-125 
-126         case "error" :
-127 
-128             return SceneJS_events.addListener(SceneJS_events.ERROR, func);
-129             break;
-130 
-131         case "nodeCreated" :
-132 
-133             return SceneJS_events.addListener(
-134                 SceneJS_events.NODE_CREATED,
-135                 function (params) {
-136                     func(params);
-137                 });
-138             break;
-139 
-140         case "reset" :
-141 
-142             return SceneJS_events.addListener(
-143                 SceneJS_events.RESET,
-144                 function () {
-145                     func();
-146                 });
-147             break;
-148 
-149         case "webglcontextlost" :
-150 
-151             return SceneJS_events.addListener(
-152                 SceneJS_events.WEBGL_CONTEXT_LOST,
-153                 function (params) {
-154                     func(params);
-155                 });
-156             break;
-157 
-158         case "webglcontextrestored" :
-159 
-160             return SceneJS_events.addListener(
-161                 SceneJS_events.WEBGL_CONTEXT_RESTORED,
-162                 function (params) {
-163                     func(params);
-164                 });
-165             break;
-166 
-167         default:
-168             throw SceneJS_error.fatalError("SceneJS.bind - this event type not supported: '" + name + "'");
-169     }
-170 };
-171 
-172 /* Subscribe to SceneJS events
-173  * @deprecated
-174  */
-175 SceneJS.onEvent = SceneJS.bind;
-176 
-177 /* Unsubscribe from event
-178  */
-179 SceneJS.unEvent = function (handle) {
-180     return SceneJS_events.removeListener(handle);
-181 };
-182 
-183 SceneJS.subscribe = SceneJS.addListener = SceneJS.onEvent = SceneJS.bind;
-184 
-185 SceneJS.unsubscribe = SceneJS.unEvent;
-186 
-187 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_log.js.html b/docs/symbols/src/src_core_log.js.html deleted file mode 100644 index 8fbbedfd..00000000 --- a/docs/symbols/src/src_core_log.js.html +++ /dev/null @@ -1,109 +0,0 @@ -
  1 /**
-  2  * @class Manages logging
-  3  *  @private
-  4  */
-  5 SceneJS.log = new (function() {
-  6 
-  7     var activeSceneId;
-  8     var funcs = null;
-  9     var queues = {};
- 10     var indent = 0;
- 11     var indentStr = "";
- 12 
- 13     SceneJS_events.addListener(
- 14             SceneJS_events.SCENE_COMPILING, // Set default logging for scene root
- 15             function(params) {
- 16                 activeSceneId = params.engine.id;
- 17             });
- 18 
- 19     SceneJS_events.addListener(
- 20             SceneJS_events.RESET,
- 21             function() {
- 22                 queues = {};
- 23                 funcs = null;
- 24                 activeSceneId = null;
- 25             },
- 26             100000);  // Really low priority - must be reset last
- 27 
- 28     this._setIndent = function(_indent) {
- 29         indent = _indent;
- 30         var indentArray = [];
- 31         for (var i = 0; i < indent; i++) {
- 32             indentArray.push("----");
- 33         }
- 34         indentStr = indentArray.join("");
- 35     };
- 36 
- 37     this.error = function(msg) {
- 38         this._log("error", msg);
- 39     };
- 40 
- 41     this.warn = function(msg) {
- 42         this._log("warn", msg);
- 43     };
- 44 
- 45     this.info = function(msg) {
- 46         this._log("info", msg);
- 47     };
- 48 
- 49     this.debug = function(msg) {
- 50         this._log("debug", msg);
- 51     };
- 52 
- 53     this.setFuncs = function(l) {
- 54         if (l) {
- 55             funcs = l;
- 56             for (var channel in queues) {
- 57                 this._flush(channel);
- 58             }
- 59         }
- 60     };
- 61 
- 62     this._flush = function(channel) {
- 63         var queue = queues[channel];
- 64         if (queue) {
- 65             var func = funcs ? funcs[channel] : null;
- 66             if (func) {
- 67                 for (var i = 0; i < queue.length; i++) {
- 68                     func(queue[i]);
- 69                 }
- 70                 queues[channel] = [];
- 71             }
- 72         }
- 73     };
- 74 
- 75     this._log = function(channel, message) {
- 76         if (SceneJS._isArray(message)) {
- 77             for (var i = 0; i < message.length; i++) {
- 78                 this.__log(channel, message[i]);
- 79             }
- 80         } else {
- 81             this.__log(channel, message);
- 82         }
- 83     };
- 84 
- 85     this.__log = function(channel, message) {
- 86         message = activeSceneId
- 87                 ? indentStr + activeSceneId + ": " + message
- 88                 : indentStr + message;
- 89 
- 90         if (funcs && funcs[channel]) {
- 91             funcs[channel](message);
- 92 
- 93         } else if (console && console[channel]) {
- 94             console[channel](message);
- 95         }
- 96     };
- 97 
- 98     this.getFuncs = function() {
- 99         return funcs;
-100     };
-101 
-102 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_map.js.html b/docs/symbols/src/src_core_map.js.html deleted file mode 100644 index fcb9fe01..00000000 --- a/docs/symbols/src/src_core_map.js.html +++ /dev/null @@ -1,72 +0,0 @@ -
  1 /**
-  2  * @class Generic map of IDs to items - can generate own IDs or accept given IDs. IDs should be strings in order to not
-  3  * clash with internally generated IDs, which are numbers.
-  4  * @private
-  5  */
-  6 var SceneJS_Map = function(items, _baseId) {
-  7 
-  8     /**
-  9      * @property Items in this map
- 10      */
- 11     this.items = items || [];
- 12 
- 13 
- 14     var baseId = _baseId || 0;
- 15     var lastUniqueId = baseId + 1;
- 16 
- 17     /**
- 18      * Adds an item to the map and returns the ID of the item in the map. If an ID is given, the item is
- 19      * mapped to that ID. Otherwise, the map automatically generates the ID and maps to that.
- 20      *
- 21      * id = myMap.addItem("foo") // ID internally generated
- 22      *
- 23      * id = myMap.addItem("foo", "bar") // ID is "foo"
- 24      *
- 25      */
- 26     this.addItem = function() {
- 27 
- 28         var item;
- 29 
- 30         if (arguments.length == 2) {
- 31 
- 32             var id = arguments[0];
- 33 
- 34             item = arguments[1];
- 35 
- 36             if (this.items[id]) { // Won't happen if given ID is string
- 37                 throw SceneJS_error.fatalError(SceneJS.errors.ID_CLASH, "ID clash: '" + id + "'");
- 38             }
- 39 
- 40             this.items[id] = item;
- 41 
- 42             return id;
- 43 
- 44         } else {
- 45 
- 46             while (true) {
- 47 
- 48                 item = arguments[0];
- 49                 var findId = lastUniqueId++;
- 50 
- 51                 if (!this.items[findId]) {
- 52                     this.items[findId] = item;
- 53                     return findId;
- 54                 }
- 55             }
- 56         }
- 57     };
- 58 
- 59     /**
- 60      * Removes the item of the given ID from the map
- 61      */
- 62     this.removeItem = function(id) {
- 63         delete this.items[id];
- 64     };
- 65 };
\ No newline at end of file diff --git a/docs/symbols/src/src_core_math.js.html b/docs/symbols/src/src_core_math.js.html deleted file mode 100644 index 5c97588e..00000000 --- a/docs/symbols/src/src_core_math.js.html +++ /dev/null @@ -1,2117 +0,0 @@ -
  1 /* 
-  2  * Optimizations made based on glMatrix by Brandon Jones
-  3  */
-  4 
-  5 /*
-  6  * Copyright (c) 2010 Brandon Jones
-  7  *
-  8  * This software is provided 'as-is', without any express or implied
-  9  * warranty. In no event will the authors be held liable for any damages
- 10  * arising from the use of this software.
- 11  *
- 12  * Permission is granted to anyone to use this software for any purpose,
- 13  * including commercial applications, and to alter it and redistribute it
- 14  * freely, subject to the following restrictions:
- 15  *
- 16  *    1. The origin of this software must not be misrepresented; you must not
- 17  *    claim that you wrote the original software. If you use this software
- 18  *    in a product, an acknowledgment in the product documentation would be
- 19  *    appreciated but is not required.
- 20  *
- 21  *    2. Altered source versions must be plainly marked as such, and must not
- 22  *    be misrepresented as being the original software.
- 23  *
- 24  *    3. This notice may not be removed or altered from any source
- 25  *    distribution.
- 26  */
- 27 
- 28 
- 29 /**
- 30  * @param u vec3
- 31  * @param v vec3
- 32  * @param dest vec3 - optional destination
- 33  * @return {vec3} dest if specified, u otherwise
- 34  * @private
- 35  */
- 36 var SceneJS_math_divVec3 = function(u, v, dest) {
- 37     if (!dest) {
- 38         dest = u;
- 39     }
- 40 
- 41     dest[0] = u[0] / v[0];
- 42     dest[1] = u[1] / v[1];
- 43     dest[2] = u[2] / v[2];
- 44 
- 45     return dest;
- 46 };
- 47 
- 48 /**
- 49  * @param v vec4
- 50  * @param dest vec4 - optional destination
- 51  * @return {vec4} dest if specified, v otherwise
- 52  * @private
- 53  */
- 54 var SceneJS_math_negateVector4 = function(v, dest) {
- 55     if (!dest) {
- 56         dest = v;
- 57     }
- 58     dest[0] = -v[0];
- 59     dest[1] = -v[1];
- 60     dest[2] = -v[2];
- 61     dest[3] = -v[3];
- 62 
- 63     return dest;
- 64 };
- 65 
- 66 /**
- 67  * @param u vec4
- 68  * @param v vec4
- 69  * @param dest vec4 - optional destination
- 70  * @return {vec4} dest if specified, u otherwise
- 71  * @private
- 72  */
- 73 var SceneJS_math_addVec4 = function(u, v, dest) {
- 74     if (!dest) {
- 75         dest = u;
- 76     }
- 77 
- 78     dest[0] = u[0] + v[0];
- 79     dest[1] = u[1] + v[1];
- 80     dest[2] = u[2] + v[2];
- 81     dest[3] = u[3] + v[3];
- 82 
- 83     return dest;
- 84 };
- 85 
- 86 
- 87 /**
- 88  * @param v vec4
- 89  * @param s scalar
- 90  * @param dest vec4 - optional destination
- 91  * @return {vec4} dest if specified, v otherwise
- 92  * @private
- 93  */
- 94 var SceneJS_math_addVec4s = function(v, s, dest) {
- 95     if (!dest) {
- 96         dest = v;
- 97     }
- 98 
- 99     dest[0] = v[0] + s;
-100     dest[1] = v[1] + s;
-101     dest[2] = v[2] + s;
-102     dest[3] = v[3] + s;
-103 
-104     return dest;
-105 };
-106 
-107 /**
-108  * @param u vec3
-109  * @param v vec3
-110  * @param dest vec3 - optional destination
-111  * @return {vec3} dest if specified, u otherwise
-112  * @private
-113  */
-114 var SceneJS_math_addVec3 = function(u, v, dest) {
-115     if (!dest) {
-116         dest = u;
-117     }
-118 
-119     dest[0] = u[0] + v[0];
-120     dest[1] = u[1] + v[1];
-121     dest[2] = u[2] + v[2];
-122 
-123     return dest;
-124 };
-125 
-126 /**
-127  * @param v vec3
-128  * @param s scalar
-129  * @param dest vec3 - optional destination
-130  * @return {vec3} dest if specified, v otherwise
-131  * @private
-132  */
-133 var SceneJS_math_addVec3s = function(v, s, dest) {
-134     if (!dest) {
-135         dest = v;
-136     }
-137 
-138     dest[0] = v[0] + s;
-139     dest[1] = v[1] + s;
-140     dest[2] = v[2] + s;
-141 
-142     return dest;
-143 };
-144 
-145 /** @private */
-146 var SceneJS_math_addScalarVec4 = function(s, v, dest) {
-147     return SceneJS_math_addVec4s(v, s, dest);
-148 };
-149 
-150 /**
-151  * @param u vec4
-152  * @param v vec4
-153  * @param dest vec4 - optional destination
-154  * @return {vec4} dest if specified, u otherwise
-155  * @private
-156  */
-157 var SceneJS_math_subVec4 = function(u, v, dest) {
-158     if (!dest) {
-159         dest = u;
-160     }
-161 
-162     dest[0] = u[0] - v[0];
-163     dest[1] = u[1] - v[1];
-164     dest[2] = u[2] - v[2];
-165     dest[3] = u[3] - v[3];
-166 
-167     return dest;
-168 };
-169 
-170 /**
-171  * @param u vec3
-172  * @param v vec3
-173  * @param dest vec3 - optional destination
-174  * @return {vec3} dest if specified, v otherwise
-175  * @private
-176  */
-177 var SceneJS_math_subVec3 = function(u, v, dest) {
-178     if (!dest) {
-179         dest = u;
-180     }
-181 
-182     dest[0] = u[0] - v[0];
-183     dest[1] = u[1] - v[1];
-184     dest[2] = u[2] - v[2];
-185 
-186     return dest;
-187 };
-188 
-189 var SceneJS_math_lerpVec3 = function(t, t1, t2, p1, p2) {
-190     var f2 = (t - t1) / (t2 - t1);
-191     var f1 = 1.0 - f2;
-192     return  {
-193         x: p1.x * f1 + p2.x * f2,
-194         y: p1.y * f1 + p2.y * f2,
-195         z: p1.z * f1 + p2.z * f2
-196     };
-197 };
-198 
-199 
-200 /**
-201  * @param u vec2
-202  * @param v vec2
-203  * @param dest vec2 - optional destination
-204  * @return {vec2} dest if specified, u otherwise
-205  * @private
-206  */
-207 var SceneJS_math_subVec2 = function(u, v, dest) {
-208     if (!dest) {
-209         dest = u;
-210     }
-211 
-212     dest[0] = u[0] - v[0];
-213     dest[1] = u[1] - v[1];
-214 
-215     return dest;
-216 };
-217 
-218 /**
-219  * @param v vec4
-220  * @param s scalar
-221  * @param dest vec4 - optional destination
-222  * @return {vec4} dest if specified, v otherwise
-223  * @private
-224  */
-225 var SceneJS_math_subVec4Scalar = function(v, s, dest) {
-226     if (!dest) {
-227         dest = v;
-228     }
-229 
-230     dest[0] = v[0] - s;
-231     dest[1] = v[1] - s;
-232     dest[2] = v[2] - s;
-233     dest[3] = v[3] - s;
-234 
-235     return dest;
-236 };
-237 
-238 /**
-239  * @param v vec4
-240  * @param s scalar
-241  * @param dest vec4 - optional destination
-242  * @return {vec4} dest if specified, v otherwise
-243  * @private
-244  */
-245 var SceneJS_math_subScalarVec4 = function(v, s, dest) {
-246     if (!dest) {
-247         dest = v;
-248     }
-249 
-250     dest[0] = s - v[0];
-251     dest[1] = s - v[1];
-252     dest[2] = s - v[2];
-253     dest[3] = s - v[3];
-254 
-255     return dest;
-256 };
-257 
-258 /**
-259  * @param u vec4
-260  * @param v vec4
-261  * @param dest vec4 - optional destination
-262  * @return {vec4} dest if specified, u otherwise
-263  * @private
-264  */
-265 var SceneJS_math_mulVec4 = function(u, v, dest) {
-266     if (!dest) {
-267         dest = u;
-268     }
-269 
-270     dest[0] = u[0] * v[0];
-271     dest[1] = u[1] * v[1];
-272     dest[2] = u[2] * v[2];
-273     dest[3] = u[3] * v[3];
-274 
-275     return dest;
-276 };
-277 
-278 /**
-279  * @param v vec4
-280  * @param s scalar
-281  * @param dest vec4 - optional destination
-282  * @return {vec4} dest if specified, v otherwise
-283  * @private
-284  */
-285 var SceneJS_math_mulVec4Scalar = function(v, s, dest) {
-286     if (!dest) {
-287         dest = v;
-288     }
-289 
-290     dest[0] = v[0] * s;
-291     dest[1] = v[1] * s;
-292     dest[2] = v[2] * s;
-293     dest[3] = v[3] * s;
-294 
-295     return dest;
-296 };
-297 
-298 
-299 /**
-300  * @param v vec3
-301  * @param s scalar
-302  * @param dest vec3 - optional destination
-303  * @return {vec3} dest if specified, v otherwise
-304  * @private
-305  */
-306 var SceneJS_math_mulVec3Scalar = function(v, s, dest) {
-307     if (!dest) {
-308         dest = v;
-309     }
-310 
-311     dest[0] = v[0] * s;
-312     dest[1] = v[1] * s;
-313     dest[2] = v[2] * s;
-314 
-315     return dest;
-316 };
-317 
-318 /**
-319  * @param v vec2
-320  * @param s scalar
-321  * @param dest vec2 - optional destination
-322  * @return {vec2} dest if specified, v otherwise
-323  * @private
-324  */
-325 var SceneJS_math_mulVec2Scalar = function(v, s, dest) {
-326     if (!dest) {
-327         dest = v;
-328     }
-329 
-330     dest[0] = v[0] * s;
-331     dest[1] = v[1] * s;
-332 
-333     return dest;
-334 };
-335 
-336 
-337 /**
-338  * @param u vec4
-339  * @param v vec4
-340  * @param dest vec4 - optional destination
-341  * @return {vec4} dest if specified, u otherwise
-342  * @private
-343  */
-344 var SceneJS_math_divVec4 = function(u, v, dest) {
-345     if (!dest) {
-346         dest = u;
-347     }
-348 
-349     dest[0] = u[0] / v[0];
-350     dest[1] = u[1] / v[1];
-351     dest[2] = u[2] / v[2];
-352     dest[3] = u[3] / v[3];
-353 
-354     return dest;
-355 };
-356 
-357 /**
-358  * @param v vec3
-359  * @param s scalar
-360  * @param dest vec3 - optional destination
-361  * @return {vec3} dest if specified, v otherwise
-362  * @private
-363  */
-364 var SceneJS_math_divScalarVec3 = function(s, v, dest) {
-365     if (!dest) {
-366         dest = v;
-367     }
-368 
-369     dest[0] = s / v[0];
-370     dest[1] = s / v[1];
-371     dest[2] = s / v[2];
-372 
-373     return dest;
-374 };
-375 
-376 /**
-377  * @param v vec3
-378  * @param s scalar
-379  * @param dest vec3 - optional destination
-380  * @return {vec3} dest if specified, v otherwise
-381  * @private
-382  */
-383 var SceneJS_math_divVec3s = function(v, s, dest) {
-384     if (!dest) {
-385         dest = v;
-386     }
-387 
-388     dest[0] = v[0] / s;
-389     dest[1] = v[1] / s;
-390     dest[2] = v[2] / s;
-391 
-392     return dest;
-393 };
-394 
-395 /**
-396  * @param v vec4
-397  * @param s scalar
-398  * @param dest vec4 - optional destination
-399  * @return {vec4} dest if specified, v otherwise
-400  * @private
-401  */
-402 var SceneJS_math_divVec4s = function(v, s, dest) {
-403     if (!dest) {
-404         dest = v;
-405     }
-406 
-407     dest[0] = v[0] / s;
-408     dest[1] = v[1] / s;
-409     dest[2] = v[2] / s;
-410     dest[3] = v[3] / s;
-411 
-412     return dest;
-413 };
-414 
-415 
-416 /**
-417  * @param s scalar
-418  * @param v vec4
-419  * @param dest vec4 - optional destination
-420  * @return {vec4} dest if specified, v otherwise
-421  * @private
-422  */
-423 var SceneJS_math_divScalarVec4 = function(s, v, dest) {
-424     if (!dest) {
-425         dest = v;
-426     }
-427 
-428     dest[0] = s / v[0];
-429     dest[1] = s / v[1];
-430     dest[2] = s / v[2];
-431     dest[3] = s / v[3];
-432 
-433     return dest;
-434 };
-435 
-436 
-437 /** @private */
-438 var SceneJS_math_dotVector4 = function(u, v) {
-439     return (u[0] * v[0] + u[1] * v[1] + u[2] * v[2] + u[3] * v[3]);
-440 };
-441 
-442 /** @private */
-443 var SceneJS_math_cross3Vec4 = function(u, v) {
-444     var u0 = u[0], u1 = u[1], u2 = u[2];
-445     var v0 = v[0], v1 = v[1], v2 = v[2];
-446     return [
-447         u1 * v2 - u2 * v1,
-448         u2 * v0 - u0 * v2,
-449         u0 * v1 - u1 * v0,
-450         0.0];
-451 };
-452 
-453 /**
-454  * @param u vec3
-455  * @param v vec3
-456  * @param dest vec3 - optional destination
-457  * @return {vec3} dest if specified, u otherwise
-458  * @private
-459  */
-460 var SceneJS_math_cross3Vec3 = function(u, v, dest) {
-461     if (!dest) {
-462         dest = u;
-463     }
-464 
-465     var x = u[0], y = u[1], z = u[2];
-466     var x2 = v[0], y2 = v[1], z2 = v[2];
-467 
-468     dest[0] = y * z2 - z * y2;
-469     dest[1] = z * x2 - x * z2;
-470     dest[2] = x * y2 - y * x2;
-471 
-472     return dest;
-473 };
-474 
-475 /** @private */
-476 var SceneJS_math_sqLenVec4 = function(v) {
-477     return SceneJS_math_dotVector4(v, v);
-478 };
-479 
-480 /** @private */
-481 var SceneJS_math_lenVec4 = function(v) {
-482     return Math.sqrt(SceneJS_math_sqLenVec4(v));
-483 };
-484 
-485 /** @private */
-486 var SceneJS_math_dotVector3 = function(u, v) {
-487     return (u[0] * v[0] + u[1] * v[1] + u[2] * v[2]);
-488 };
-489 
-490 /** @private */
-491 var SceneJS_math_dotVector2 = function(u, v) {
-492     return (u[0] * v[0] + u[1] * v[1]);
-493 };
-494 
-495 /** @private */
-496 var SceneJS_math_sqLenVec3 = function(v) {
-497     return SceneJS_math_dotVector3(v, v);
-498 };
-499 
-500 /** @private */
-501 var SceneJS_math_sqLenVec2 = function(v) {
-502     return SceneJS_math_dotVector2(v, v);
-503 };
-504 
-505 /** @private */
-506 var SceneJS_math_lenVec3 = function(v) {
-507     return Math.sqrt(SceneJS_math_sqLenVec3(v));
-508 };
-509 
-510 /** @private */
-511 var SceneJS_math_lenVec2 = function(v) {
-512     return Math.sqrt(SceneJS_math_sqLenVec2(v));
-513 };
-514 
-515 /**
-516  * @param v vec3
-517  * @param dest vec3 - optional destination
-518  * @return {vec3} dest if specified, v otherwise
-519  * @private
-520  */
-521 var SceneJS_math_rcpVec3 = function(v, dest) {
-522     return SceneJS_math_divScalarVec3(1.0, v, dest);
-523 };
-524 
-525 /**
-526  * @param v vec4
-527  * @param dest vec4 - optional destination
-528  * @return {vec4} dest if specified, v otherwise
-529  * @private
-530  */
-531 var SceneJS_math_normalizeVec4 = function(v, dest) {
-532     var f = 1.0 / SceneJS_math_lenVec4(v);
-533     return SceneJS_math_mulVec4Scalar(v, f, dest);
-534 };
-535 
-536 /** @private */
-537 var SceneJS_math_normalizeVec3 = function(v, dest) {
-538     var f = 1.0 / SceneJS_math_lenVec3(v);
-539     return SceneJS_math_mulVec3Scalar(v, f, dest);
-540 };
-541 
-542 // @private
-543 var SceneJS_math_normalizeVec2 = function(v, dest) {
-544     var f = 1.0 / SceneJS_math_lenVec2(v);
-545     return SceneJS_math_mulVec2Scalar(v, f, dest);
-546 };
-547 
-548 /** @private */
-549 var SceneJS_math_mat4 = function() {
-550     return new Array(16);
-551 };
-552 
-553 /** @private */
-554 var SceneJS_math_dupMat4 = function(m) {
-555     return m.slice(0, 16);
-556 };
-557 
-558 /** @private */
-559 var SceneJS_math_getCellMat4 = function(m, row, col) {
-560     return m[row + col * 4];
-561 };
-562 
-563 /** @private */
-564 var SceneJS_math_setCellMat4 = function(m, row, col, s) {
-565     m[row + col * 4] = s;
-566 };
-567 
-568 /** @private */
-569 var SceneJS_math_getRowMat4 = function(m, r) {
-570     return [m[r], m[r + 4], m[r + 8], m[r + 12]];
-571 };
-572 
-573 /** @private */
-574 var SceneJS_math_setRowMat4 = function(m, r, v) {
-575     m[r] = v[0];
-576     m[r + 4] = v[1];
-577     m[r + 8] = v[2];
-578     m[r + 12] = v[3];
-579 };
-580 
-581 /** @private */
-582 var SceneJS_math_setRowMat4c = function(m, r, x, y, z, w) {
-583     SceneJS_math_setRowMat4(m, r, [x,y,z,w]);
-584 };
-585 
-586 /** @private */
-587 var SceneJS_math_setRowMat4s = function(m, r, s) {
-588     SceneJS_math_setRowMat4c(m, r, s, s, s, s);
-589 };
-590 
-591 /** @private */
-592 var SceneJS_math_getColMat4 = function(m, c) {
-593     var i = c * 4;
-594     return [m[i], m[i + 1],m[i + 2],m[i + 3]];
-595 };
-596 
-597 /** @private */
-598 var SceneJS_math_setColMat4v = function(m, c, v) {
-599     var i = c * 4;
-600     m[i] = v[0];
-601     m[i + 1] = v[1];
-602     m[i + 2] = v[2];
-603     m[i + 3] = v[3];
-604 };
-605 
-606 /** @private */
-607 var SceneJS_math_setColMat4c = function(m, c, x, y, z, w) {
-608     SceneJS_math_setColMat4v(m, c, [x,y,z,w]);
-609 };
-610 
-611 /** @private */
-612 var SceneJS_math_setColMat4Scalar = function(m, c, s) {
-613     SceneJS_math_setColMat4c(m, c, s, s, s, s);
-614 };
-615 
-616 /** @private */
-617 var SceneJS_math_mat4To3 = function(m) {
-618     return [
-619         m[0],m[1],m[2],
-620         m[4],m[5],m[6],
-621         m[8],m[9],m[10]
-622     ];
-623 };
-624 
-625 /** @private */
-626 var SceneJS_math_m4s = function(s) {
-627     return [
-628         s,s,s,s,
-629         s,s,s,s,
-630         s,s,s,s,
-631         s,s,s,s
-632     ];
-633 };
-634 
-635 /** @private */
-636 var SceneJS_math_setMat4ToZeroes = function() {
-637     return SceneJS_math_m4s(0.0);
-638 };
-639 
-640 /** @private */
-641 var SceneJS_math_setMat4ToOnes = function() {
-642     return SceneJS_math_m4s(1.0);
-643 };
-644 
-645 /** @private */
-646 var SceneJS_math_diagonalMat4v = function(v) {
-647     return [
-648         v[0], 0.0, 0.0, 0.0,
-649         0.0,v[1], 0.0, 0.0,
-650         0.0, 0.0, v[2],0.0,
-651         0.0, 0.0, 0.0, v[3]
-652     ];
-653 };
-654 
-655 /** @private */
-656 var SceneJS_math_diagonalMat4c = function(x, y, z, w) {
-657     return SceneJS_math_diagonalMat4v([x,y,z,w]);
-658 };
-659 
-660 /** @private */
-661 var SceneJS_math_diagonalMat4s = function(s) {
-662     return SceneJS_math_diagonalMat4c(s, s, s, s);
-663 };
-664 
-665 /** @private */
-666 var SceneJS_math_identityMat4 = function() {
-667     return SceneJS_math_diagonalMat4v([1.0,1.0,1.0,1.0]);
-668 };
-669 
-670 /** @private */
-671 var SceneJS_math_isIdentityMat4 = function(m) {
-672     if (m[0] !== 1.0 || m[1] !== 0.0 || m[2] !== 0.0 || m[3] !== 0.0 ||
-673         m[4] !== 0.0 || m[5] !== 1.0 || m[6] !== 0.0 || m[7] !== 0.0 ||
-674         m[8] !== 0.0 || m[9] !== 0.0 || m[10] !== 1.0 || m[11] !== 0.0 ||
-675         m[12] !== 0.0 || m[13] !== 0.0 || m[14] !== 0.0 || m[15] !== 1.0)
-676     {
-677         return false;
-678     }
-679 
-680     return true;
-681 };
-682 
-683 /**
-684  * @param m mat4
-685  * @param dest mat4 - optional destination
-686  * @return {mat4} dest if specified, m otherwise
-687  * @private
-688  */
-689 var SceneJS_math_negateMat4 = function(m, dest) {
-690     if (!dest) {
-691         dest = m;
-692     }
-693 
-694     dest[0] = -m[0];
-695     dest[1] = -m[1];
-696     dest[2] = -m[2];
-697     dest[3] = -m[3];
-698     dest[4] = -m[4];
-699     dest[5] = -m[5];
-700     dest[6] = -m[6];
-701     dest[7] = -m[7];
-702     dest[8] = -m[8];
-703     dest[9] = -m[9];
-704     dest[10] = -m[10];
-705     dest[11] = -m[11];
-706     dest[12] = -m[12];
-707     dest[13] = -m[13];
-708     dest[14] = -m[14];
-709     dest[15] = -m[15];
-710 
-711     return dest;
-712 };
-713 
-714 /**
-715  * @param a mat4
-716  * @param b mat4
-717  * @param dest mat4 - optional destination
-718  * @return {mat4} dest if specified, a otherwise
-719  * @private
-720  */
-721 var SceneJS_math_addMat4 = function(a, b, dest) {
-722     if (!dest) {
-723         dest = a;
-724     }
-725 
-726     dest[0] = a[0] + b[0];
-727     dest[1] = a[1] + b[1];
-728     dest[2] = a[2] + b[2];
-729     dest[3] = a[3] + b[3];
-730     dest[4] = a[4] + b[4];
-731     dest[5] = a[5] + b[5];
-732     dest[6] = a[6] + b[6];
-733     dest[7] = a[7] + b[7];
-734     dest[8] = a[8] + b[8];
-735     dest[9] = a[9] + b[9];
-736     dest[10] = a[10] + b[10];
-737     dest[11] = a[11] + b[11];
-738     dest[12] = a[12] + b[12];
-739     dest[13] = a[13] + b[13];
-740     dest[14] = a[14] + b[14];
-741     dest[15] = a[15] + b[15];
-742 
-743     return dest;
-744 };
-745 
-746 /**
-747  * @param m mat4
-748  * @param s scalar
-749  * @param dest mat4 - optional destination
-750  * @return {mat4} dest if specified, m otherwise
-751  * @private
-752  */
-753 var SceneJS_math_addMat4Scalar = function(m, s, dest) {
-754     if (!dest) {
-755         dest = m;
-756     }
-757 
-758     dest[0] = m[0] + s;
-759     dest[1] = m[1] + s;
-760     dest[2] = m[2] + s;
-761     dest[3] = m[3] + s;
-762     dest[4] = m[4] + s;
-763     dest[5] = m[5] + s;
-764     dest[6] = m[6] + s;
-765     dest[7] = m[7] + s;
-766     dest[8] = m[8] + s;
-767     dest[9] = m[9] + s;
-768     dest[10] = m[10] + s;
-769     dest[11] = m[11] + s;
-770     dest[12] = m[12] + s;
-771     dest[13] = m[13] + s;
-772     dest[14] = m[14] + s;
-773     dest[15] = m[15] + s;
-774 
-775     return dest;
-776 };
-777 
-778 /** @private */
-779 var SceneJS_math_addScalarMat4 = function(s, m, dest) {
-780     return SceneJS_math_addMat4Scalar(m, s, dest);
-781 };
-782 
-783 /**
-784  * @param a mat4
-785  * @param b mat4
-786  * @param dest mat4 - optional destination
-787  * @return {mat4} dest if specified, a otherwise
-788  * @private
-789  */
-790 var SceneJS_math_subMat4 = function(a, b, dest) {
-791     if (!dest) {
-792         dest = a;
-793     }
-794 
-795     dest[0] = a[0] - b[0];
-796     dest[1] = a[1] - b[1];
-797     dest[2] = a[2] - b[2];
-798     dest[3] = a[3] - b[3];
-799     dest[4] = a[4] - b[4];
-800     dest[5] = a[5] - b[5];
-801     dest[6] = a[6] - b[6];
-802     dest[7] = a[7] - b[7];
-803     dest[8] = a[8] - b[8];
-804     dest[9] = a[9] - b[9];
-805     dest[10] = a[10] - b[10];
-806     dest[11] = a[11] - b[11];
-807     dest[12] = a[12] - b[12];
-808     dest[13] = a[13] - b[13];
-809     dest[14] = a[14] - b[14];
-810     dest[15] = a[15] - b[15];
-811 
-812     return dest;
-813 };
-814 
-815 /**
-816  * @param m mat4
-817  * @param s scalar
-818  * @param dest mat4 - optional destination
-819  * @return {mat4} dest if specified, m otherwise
-820  * @private
-821  */
-822 var SceneJS_math_subMat4Scalar = function(m, s, dest) {
-823     if (!dest) {
-824         dest = m;
-825     }
-826 
-827     dest[0] = m[0] - s;
-828     dest[1] = m[1] - s;
-829     dest[2] = m[2] - s;
-830     dest[3] = m[3] - s;
-831     dest[4] = m[4] - s;
-832     dest[5] = m[5] - s;
-833     dest[6] = m[6] - s;
-834     dest[7] = m[7] - s;
-835     dest[8] = m[8] - s;
-836     dest[9] = m[9] - s;
-837     dest[10] = m[10] - s;
-838     dest[11] = m[11] - s;
-839     dest[12] = m[12] - s;
-840     dest[13] = m[13] - s;
-841     dest[14] = m[14] - s;
-842     dest[15] = m[15] - s;
-843 
-844     return dest;
-845 };
-846 
-847 /**
-848  * @param s scalar
-849  * @param m mat4
-850  * @param dest mat4 - optional destination
-851  * @return {mat4} dest if specified, m otherwise
-852  * @private
-853  */
-854 var SceneJS_math_subScalarMat4 = function(s, m, dest) {
-855     if (!dest) {
-856         dest = m;
-857     }
-858 
-859     dest[0] = s - m[0];
-860     dest[1] = s - m[1];
-861     dest[2] = s - m[2];
-862     dest[3] = s - m[3];
-863     dest[4] = s - m[4];
-864     dest[5] = s - m[5];
-865     dest[6] = s - m[6];
-866     dest[7] = s - m[7];
-867     dest[8] = s - m[8];
-868     dest[9] = s - m[9];
-869     dest[10] = s - m[10];
-870     dest[11] = s - m[11];
-871     dest[12] = s - m[12];
-872     dest[13] = s - m[13];
-873     dest[14] = s - m[14];
-874     dest[15] = s - m[15];
-875 
-876     return dest;
-877 };
-878 
-879 /**
-880  * @param a mat4
-881  * @param b mat4
-882  * @param dest mat4 - optional destination
-883  * @return {mat4} dest if specified, a otherwise
-884  * @private
-885  */
-886 var SceneJS_math_mulMat4 = function(a, b, dest) {
-887     if (!dest) {
-888         dest = a;
-889     }
-890 
-891     // Cache the matrix values (makes for huge speed increases!)
-892     var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3];
-893     var a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7];
-894     var a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11];
-895     var a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];
-896 
-897     var b00 = b[0], b01 = b[1], b02 = b[2], b03 = b[3];
-898     var b10 = b[4], b11 = b[5], b12 = b[6], b13 = b[7];
-899     var b20 = b[8], b21 = b[9], b22 = b[10], b23 = b[11];
-900     var b30 = b[12], b31 = b[13], b32 = b[14], b33 = b[15];
-901 
-902     dest[0] = b00 * a00 + b01 * a10 + b02 * a20 + b03 * a30;
-903     dest[1] = b00 * a01 + b01 * a11 + b02 * a21 + b03 * a31;
-904     dest[2] = b00 * a02 + b01 * a12 + b02 * a22 + b03 * a32;
-905     dest[3] = b00 * a03 + b01 * a13 + b02 * a23 + b03 * a33;
-906     dest[4] = b10 * a00 + b11 * a10 + b12 * a20 + b13 * a30;
-907     dest[5] = b10 * a01 + b11 * a11 + b12 * a21 + b13 * a31;
-908     dest[6] = b10 * a02 + b11 * a12 + b12 * a22 + b13 * a32;
-909     dest[7] = b10 * a03 + b11 * a13 + b12 * a23 + b13 * a33;
-910     dest[8] = b20 * a00 + b21 * a10 + b22 * a20 + b23 * a30;
-911     dest[9] = b20 * a01 + b21 * a11 + b22 * a21 + b23 * a31;
-912     dest[10] = b20 * a02 + b21 * a12 + b22 * a22 + b23 * a32;
-913     dest[11] = b20 * a03 + b21 * a13 + b22 * a23 + b23 * a33;
-914     dest[12] = b30 * a00 + b31 * a10 + b32 * a20 + b33 * a30;
-915     dest[13] = b30 * a01 + b31 * a11 + b32 * a21 + b33 * a31;
-916     dest[14] = b30 * a02 + b31 * a12 + b32 * a22 + b33 * a32;
-917     dest[15] = b30 * a03 + b31 * a13 + b32 * a23 + b33 * a33;
-918 
-919     return dest;
-920 };
-921 
-922 /**
-923  * @param m mat4
-924  * @param s scalar
-925  * @param dest mat4 - optional destination
-926  * @return {mat4} dest if specified, m otherwise
-927  * @private
-928  */
-929 var SceneJS_math_mulMat4s = function(m, s, dest)
-930 {
-931     if (!dest) {
-932         dest = m;
-933     }
-934 
-935     dest[0] = m[0] * s;
-936     dest[1] = m[1] * s;
-937     dest[2] = m[2] * s;
-938     dest[3] = m[3] * s;
-939     dest[4] = m[4] * s;
-940     dest[5] = m[5] * s;
-941     dest[6] = m[6] * s;
-942     dest[7] = m[7] * s;
-943     dest[8] = m[8] * s;
-944     dest[9] = m[9] * s;
-945     dest[10] = m[10] * s;
-946     dest[11] = m[11] * s;
-947     dest[12] = m[12] * s;
-948     dest[13] = m[13] * s;
-949     dest[14] = m[14] * s;
-950     dest[15] = m[15] * s;
-951 
-952     return dest;
-953 };
-954 
-955 /**
-956  * @param m mat4
-957  * @param v vec4
-958  * @return {vec4}
-959  * @private
-960  */
-961 var SceneJS_math_mulMat4v4 = function(m, v) {
-962     var v0 = v[0], v1 = v[1], v2 = v[2], v3 = v[3];
-963 
-964     return [
-965         m[0] * v0 + m[4] * v1 + m[8] * v2 + m[12] * v3,
-966         m[1] * v0 + m[5] * v1 + m[9] * v2 + m[13] * v3,
-967         m[2] * v0 + m[6] * v1 + m[10] * v2 + m[14] * v3,
-968         m[3] * v0 + m[7] * v1 + m[11] * v2 + m[15] * v3
-969     ];
-970 };
-971 
-972 /**
-973  * @param mat mat4
-974  * @param dest mat4 - optional destination
-975  * @return {mat4} dest if specified, mat otherwise
-976  * @private
-977  */
-978 var SceneJS_math_transposeMat4 = function(mat, dest) {
-979     // If we are transposing ourselves we can skip a few steps but have to cache some values
-980     var m4 = mat[4], m14 = mat[14], m8 = mat[8];
-981     var m13 = mat[13], m12 = mat[12], m9 = mat[9];
-982     if (!dest || mat == dest) {
-983         var a01 = mat[1], a02 = mat[2], a03 = mat[3];
-984         var a12 = mat[6], a13 = mat[7];
-985         var a23 = mat[11];
-986 
-987         mat[1] = m4;
-988         mat[2] = m8;
-989         mat[3] = m12;
-990         mat[4] = a01;
-991         mat[6] = m9;
-992         mat[7] = m13;
-993         mat[8] = a02;
-994         mat[9] = a12;
-995         mat[11] = m14;
-996         mat[12] = a03;
-997         mat[13] = a13;
-998         mat[14] = a23;
-999         return mat;
-1000     }
-1001 
-1002     dest[0] = mat[0];
-1003     dest[1] = m4;
-1004     dest[2] = m8;
-1005     dest[3] = m12;
-1006     dest[4] = mat[1];
-1007     dest[5] = mat[5];
-1008     dest[6] = m9;
-1009     dest[7] = m13;
-1010     dest[8] = mat[2];
-1011     dest[9] = mat[6];
-1012     dest[10] = mat[10];
-1013     dest[11] = m14;
-1014     dest[12] = mat[3];
-1015     dest[13] = mat[7];
-1016     dest[14] = mat[11];
-1017     dest[15] = mat[15];
-1018     return dest;
-1019 };
-1020 
-1021 /** @private */
-1022 var SceneJS_math_determinantMat4 = function(mat) {
-1023     // Cache the matrix values (makes for huge speed increases!)
-1024     var a00 = mat[0], a01 = mat[1], a02 = mat[2], a03 = mat[3];
-1025     var a10 = mat[4], a11 = mat[5], a12 = mat[6], a13 = mat[7];
-1026     var a20 = mat[8], a21 = mat[9], a22 = mat[10], a23 = mat[11];
-1027     var a30 = mat[12], a31 = mat[13], a32 = mat[14], a33 = mat[15];
-1028 
-1029     return a30 * a21 * a12 * a03 - a20 * a31 * a12 * a03 - a30 * a11 * a22 * a03 + a10 * a31 * a22 * a03 +
-1030            a20 * a11 * a32 * a03 - a10 * a21 * a32 * a03 - a30 * a21 * a02 * a13 + a20 * a31 * a02 * a13 +
-1031            a30 * a01 * a22 * a13 - a00 * a31 * a22 * a13 - a20 * a01 * a32 * a13 + a00 * a21 * a32 * a13 +
-1032            a30 * a11 * a02 * a23 - a10 * a31 * a02 * a23 - a30 * a01 * a12 * a23 + a00 * a31 * a12 * a23 +
-1033            a10 * a01 * a32 * a23 - a00 * a11 * a32 * a23 - a20 * a11 * a02 * a33 + a10 * a21 * a02 * a33 +
-1034            a20 * a01 * a12 * a33 - a00 * a21 * a12 * a33 - a10 * a01 * a22 * a33 + a00 * a11 * a22 * a33;
-1035 };
-1036 
-1037 /**
-1038  * @param mat mat4
-1039  * @param dest mat4 - optional destination
-1040  * @return {mat4} dest if specified, mat otherwise
-1041  * @private
-1042  */
-1043 var SceneJS_math_inverseMat4 = function(mat, dest) {
-1044     if (!dest) {
-1045         dest = mat;
-1046     }
-1047 
-1048     // Cache the matrix values (makes for huge speed increases!)
-1049     var a00 = mat[0], a01 = mat[1], a02 = mat[2], a03 = mat[3];
-1050     var a10 = mat[4], a11 = mat[5], a12 = mat[6], a13 = mat[7];
-1051     var a20 = mat[8], a21 = mat[9], a22 = mat[10], a23 = mat[11];
-1052     var a30 = mat[12], a31 = mat[13], a32 = mat[14], a33 = mat[15];
-1053 
-1054     var b00 = a00 * a11 - a01 * a10;
-1055     var b01 = a00 * a12 - a02 * a10;
-1056     var b02 = a00 * a13 - a03 * a10;
-1057     var b03 = a01 * a12 - a02 * a11;
-1058     var b04 = a01 * a13 - a03 * a11;
-1059     var b05 = a02 * a13 - a03 * a12;
-1060     var b06 = a20 * a31 - a21 * a30;
-1061     var b07 = a20 * a32 - a22 * a30;
-1062     var b08 = a20 * a33 - a23 * a30;
-1063     var b09 = a21 * a32 - a22 * a31;
-1064     var b10 = a21 * a33 - a23 * a31;
-1065     var b11 = a22 * a33 - a23 * a32;
-1066 
-1067     // Calculate the determinant (inlined to avoid double-caching)
-1068     var invDet = 1 / (b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06);
-1069 
-1070     dest[0] = (a11 * b11 - a12 * b10 + a13 * b09) * invDet;
-1071     dest[1] = (-a01 * b11 + a02 * b10 - a03 * b09) * invDet;
-1072     dest[2] = (a31 * b05 - a32 * b04 + a33 * b03) * invDet;
-1073     dest[3] = (-a21 * b05 + a22 * b04 - a23 * b03) * invDet;
-1074     dest[4] = (-a10 * b11 + a12 * b08 - a13 * b07) * invDet;
-1075     dest[5] = (a00 * b11 - a02 * b08 + a03 * b07) * invDet;
-1076     dest[6] = (-a30 * b05 + a32 * b02 - a33 * b01) * invDet;
-1077     dest[7] = (a20 * b05 - a22 * b02 + a23 * b01) * invDet;
-1078     dest[8] = (a10 * b10 - a11 * b08 + a13 * b06) * invDet;
-1079     dest[9] = (-a00 * b10 + a01 * b08 - a03 * b06) * invDet;
-1080     dest[10] = (a30 * b04 - a31 * b02 + a33 * b00) * invDet;
-1081     dest[11] = (-a20 * b04 + a21 * b02 - a23 * b00) * invDet;
-1082     dest[12] = (-a10 * b09 + a11 * b07 - a12 * b06) * invDet;
-1083     dest[13] = (a00 * b09 - a01 * b07 + a02 * b06) * invDet;
-1084     dest[14] = (-a30 * b03 + a31 * b01 - a32 * b00) * invDet;
-1085     dest[15] = (a20 * b03 - a21 * b01 + a22 * b00) * invDet;
-1086 
-1087     return dest;
-1088 };
-1089 
-1090 /** @private */
-1091 var SceneJS_math_traceMat4 = function(m) {
-1092     return (m[0] + m[5] + m[10] + m[15]);
-1093 };
-1094 
-1095 /** @private */
-1096 var SceneJS_math_translationMat4v = function(v) {
-1097     var m = SceneJS_math_identityMat4();
-1098     m[12] = v[0];
-1099     m[13] = v[1];
-1100     m[14] = v[2];
-1101     return m;
-1102 };
-1103 
-1104 /** @private */
-1105 var SceneJS_math_translationMat4c = function(x, y, z) {
-1106     return SceneJS_math_translationMat4v([x,y,z]);
-1107 };
-1108 
-1109 /** @private */
-1110 var SceneJS_math_translationMat4s = function(s) {
-1111     return SceneJS_math_translationMat4c(s, s, s);
-1112 };
-1113 
-1114 /** @private */
-1115 var SceneJS_math_rotationMat4v = function(anglerad, axis) {
-1116     var ax = SceneJS_math_normalizeVec4([axis[0],axis[1],axis[2],0.0]);
-1117     var s = Math.sin(anglerad);
-1118     var c = Math.cos(anglerad);
-1119     var q = 1.0 - c;
-1120 
-1121     var x = ax[0];
-1122     var y = ax[1];
-1123     var z = ax[2];
-1124 
-1125     var xy,yz,zx,xs,ys,zs;
-1126 
-1127     //xx = x * x; used once
-1128     //yy = y * y; used once
-1129     //zz = z * z; used once
-1130     xy = x * y;
-1131     yz = y * z;
-1132     zx = z * x;
-1133     xs = x * s;
-1134     ys = y * s;
-1135     zs = z * s;
-1136 
-1137     var m = SceneJS_math_mat4();
-1138 
-1139     m[0] = (q * x * x) + c;
-1140     m[1] = (q * xy) + zs;
-1141     m[2] = (q * zx) - ys;
-1142     m[3] = 0.0;
-1143 
-1144     m[4] = (q * xy) - zs;
-1145     m[5] = (q * y * y) + c;
-1146     m[6] = (q * yz) + xs;
-1147     m[7] = 0.0;
-1148 
-1149     m[8] = (q * zx) + ys;
-1150     m[9] = (q * yz) - xs;
-1151     m[10] = (q * z * z) + c;
-1152     m[11] = 0.0;
-1153 
-1154     m[12] = 0.0;
-1155     m[13] = 0.0;
-1156     m[14] = 0.0;
-1157     m[15] = 1.0;
-1158 
-1159     return m;
-1160 };
-1161 
-1162 /** @private */
-1163 var SceneJS_math_rotationMat4c = function(anglerad, x, y, z) {
-1164     return SceneJS_math_rotationMat4v(anglerad, [x,y,z]);
-1165 };
-1166 
-1167 /** @private */
-1168 var SceneJS_math_scalingMat4v = function(v) {
-1169     var m = SceneJS_math_identityMat4();
-1170     m[0] = v[0];
-1171     m[5] = v[1];
-1172     m[10] = v[2];
-1173     return m;
-1174 };
-1175 
-1176 /** @private */
-1177 var SceneJS_math_scalingMat4c = function(x, y, z) {
-1178     return SceneJS_math_scalingMat4v([x,y,z]);
-1179 };
-1180 
-1181 /** @private */
-1182 var SceneJS_math_scalingMat4s = function(s) {
-1183     return SceneJS_math_scalingMat4c(s, s, s);
-1184 };
-1185 
-1186 /**
-1187  * Default lookat properties - eye at 0,0,1, looking at 0,0,0, up vector pointing up Y-axis
-1188  */
-1189 var SceneJS_math_LOOKAT_OBJ = {
-1190     eye:    {x: 0, y:0, z:1.0 },
-1191     look:   {x:0, y:0, z:0.0 },
-1192     up:     {x:0, y:1, z:0.0 }
-1193 };
-1194 
-1195 /**
-1196  * Default lookat properties in array form - eye at 0,0,1, looking at 0,0,0, up vector pointing up Y-axis
-1197  */
-1198 var SceneJS_math_LOOKAT_ARRAYS = {
-1199     eye:    [0, 0, 1.0],
-1200     look:   [0, 0, 0.0 ],
-1201     up:     [0, 1, 0.0 ]
-1202 };
-1203 
-1204 /**
-1205  * Default orthographic projection properties
-1206  */
-1207 var SceneJS_math_ORTHO_OBJ = {
-1208     left: -1.0,
-1209     right: 1.0,
-1210     bottom: -1.0,
-1211     near: 0.1,
-1212     top: 1.0,
-1213     far: 5000.0
-1214 };
-1215 
-1216 /**
-1217  * @param pos vec3 position of the viewer
-1218  * @param target vec3 point the viewer is looking at
-1219  * @param up vec3 pointing "up"
-1220  * @param dest mat4 Optional, mat4 frustum matrix will be written into
-1221  *
-1222  * @return {mat4} dest if specified, a new mat4 otherwise
-1223  */
-1224 var SceneJS_math_lookAtMat4v = function(pos, target, up, dest) {
-1225     if (!dest) {
-1226         dest = SceneJS_math_mat4();
-1227     }
-1228 
-1229     var posx = pos[0],
-1230             posy = pos[1],
-1231             posz = pos[2],
-1232             upx = up[0],
-1233             upy = up[1],
-1234             upz = up[2],
-1235             targetx = target[0],
-1236             targety = target[1],
-1237             targetz = target[2];
-1238 
-1239     if (posx == targetx && posy == targety && posz == targetz) {
-1240         return SceneJS_math_identityMat4();
-1241     }
-1242 
-1243     var z0,z1,z2,x0,x1,x2,y0,y1,y2,len;
-1244 
-1245     //vec3.direction(eye, center, z);
-1246     z0 = posx - targetx;
-1247     z1 = posy - targety;
-1248     z2 = posz - targetz;
-1249 
-1250     // normalize (no check needed for 0 because of early return)
-1251     len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);
-1252     z0 *= len;
-1253     z1 *= len;
-1254     z2 *= len;
-1255 
-1256     //vec3.normalize(vec3.cross(up, z, x));
-1257     x0 = upy * z2 - upz * z1;
-1258     x1 = upz * z0 - upx * z2;
-1259     x2 = upx * z1 - upy * z0;
-1260     len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);
-1261     if (!len) {
-1262         x0 = 0;
-1263         x1 = 0;
-1264         x2 = 0;
-1265     } else {
-1266         len = 1 / len;
-1267         x0 *= len;
-1268         x1 *= len;
-1269         x2 *= len;
-1270     }
-1271 
-1272     //vec3.normalize(vec3.cross(z, x, y));
-1273     y0 = z1 * x2 - z2 * x1;
-1274     y1 = z2 * x0 - z0 * x2;
-1275     y2 = z0 * x1 - z1 * x0;
-1276 
-1277     len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);
-1278     if (!len) {
-1279         y0 = 0;
-1280         y1 = 0;
-1281         y2 = 0;
-1282     } else {
-1283         len = 1 / len;
-1284         y0 *= len;
-1285         y1 *= len;
-1286         y2 *= len;
-1287     }
-1288 
-1289     dest[0] = x0;
-1290     dest[1] = y0;
-1291     dest[2] = z0;
-1292     dest[3] = 0;
-1293     dest[4] = x1;
-1294     dest[5] = y1;
-1295     dest[6] = z1;
-1296     dest[7] = 0;
-1297     dest[8] = x2;
-1298     dest[9] = y2;
-1299     dest[10] = z2;
-1300     dest[11] = 0;
-1301     dest[12] = -(x0 * posx + x1 * posy + x2 * posz);
-1302     dest[13] = -(y0 * posx + y1 * posy + y2 * posz);
-1303     dest[14] = -(z0 * posx + z1 * posy + z2 * posz);
-1304     dest[15] = 1;
-1305 
-1306     return dest;
-1307 };
-1308 
-1309 /** @private */
-1310 var SceneJS_math_lookAtMat4c = function(posx, posy, posz, targetx, targety, targetz, upx, upy, upz) {
-1311     return SceneJS_math_lookAtMat4v([posx,posy,posz], [targetx,targety,targetz], [upx,upy,upz]);
-1312 };
-1313 
-1314 /** @private */
-1315 var SceneJS_math_orthoMat4c = function(left, right, bottom, top, near, far, dest) {
-1316     if (!dest) {
-1317         dest = SceneJS_math_mat4();
-1318     }
-1319     var rl = (right - left);
-1320     var tb = (top - bottom);
-1321     var fn = (far - near);
-1322 
-1323     dest[0] = 2.0 / rl;
-1324     dest[1] = 0.0;
-1325     dest[2] = 0.0;
-1326     dest[3] = 0.0;
-1327 
-1328     dest[4] = 0.0;
-1329     dest[5] = 2.0 / tb;
-1330     dest[6] = 0.0;
-1331     dest[7] = 0.0;
-1332 
-1333     dest[8] = 0.0;
-1334     dest[9] = 0.0;
-1335     dest[10] = -2.0 / fn;
-1336     dest[11] = 0.0;
-1337 
-1338     dest[12] = -(left + right) / rl;
-1339     dest[13] = -(top + bottom) / tb;
-1340     dest[14] = -(far + near) / fn;
-1341     dest[15] = 1.0;
-1342 
-1343     return dest;
-1344 };
-1345 
-1346 /** @private */
-1347 var SceneJS_math_frustumMat4v = function(fmin, fmax) {
-1348     var fmin4 = [fmin[0],fmin[1],fmin[2],0.0];
-1349     var fmax4 = [fmax[0],fmax[1],fmax[2],0.0];
-1350     var vsum = SceneJS_math_mat4();
-1351     SceneJS_math_addVec4(fmax4, fmin4, vsum);
-1352     var vdif = SceneJS_math_mat4();
-1353     SceneJS_math_subVec4(fmax4, fmin4, vdif);
-1354     var t = 2.0 * fmin4[2];
-1355 
-1356     var m = SceneJS_math_mat4();
-1357     var vdif0 = vdif[0], vdif1 = vdif[1], vdif2 = vdif[2];
-1358 
-1359     m[0] = t / vdif0;
-1360     m[1] = 0.0;
-1361     m[2] = 0.0;
-1362     m[3] = 0.0;
-1363 
-1364     m[4] = 0.0;
-1365     m[5] = t / vdif1;
-1366     m[6] = 0.0;
-1367     m[7] = 0.0;
-1368 
-1369     m[8] = vsum[0] / vdif0;
-1370     m[9] = vsum[1] / vdif1;
-1371     m[10] = -vsum[2] / vdif2;
-1372     m[11] = -1.0;
-1373 
-1374     m[12] = 0.0;
-1375     m[13] = 0.0;
-1376     m[14] = -t * fmax4[2] / vdif2;
-1377     m[15] = 0.0;
-1378 
-1379     return m;
-1380 };
-1381 
-1382 /** @private */
-1383 var SceneJS_math_frustumMatrix4 = function(left, right, bottom, top, near, far, dest) {
-1384     if (!dest) {
-1385         dest = SceneJS_math_mat4();
-1386     }
-1387     var rl = (right - left);
-1388     var tb = (top - bottom);
-1389     var fn = (far - near);
-1390     dest[0] = (near * 2) / rl;
-1391     dest[1] = 0;
-1392     dest[2] = 0;
-1393     dest[3] = 0;
-1394     dest[4] = 0;
-1395     dest[5] = (near * 2) / tb;
-1396     dest[6] = 0;
-1397     dest[7] = 0;
-1398     dest[8] = (right + left) / rl;
-1399     dest[9] = (top + bottom) / tb;
-1400     dest[10] = -(far + near) / fn;
-1401     dest[11] = -1;
-1402     dest[12] = 0;
-1403     dest[13] = 0;
-1404     dest[14] = -(far * near * 2) / fn;
-1405     dest[15] = 0;
-1406     return dest;
-1407 };
-1408 
-1409 
-1410 /** @private */
-1411 var SceneJS_math_perspectiveMatrix4 = function(fovyrad, aspectratio, znear, zfar) {
-1412     var pmin = [];
-1413     var pmax = [];
-1414 
-1415     pmin[2] = znear;
-1416     pmax[2] = zfar;
-1417 
-1418     pmax[1] = pmin[2] * Math.tan(fovyrad / 2.0);
-1419     pmin[1] = -pmax[1];
-1420 
-1421     pmax[0] = pmax[1] * aspectratio;
-1422     pmin[0] = -pmax[0];
-1423 
-1424     return SceneJS_math_frustumMat4v(pmin, pmax);
-1425 };
-1426 
-1427 /** @private */
-1428 var SceneJS_math_transformPoint3 = function(m, p) {
-1429     var p0 = p[0], p1 = p[1], p2 = p[2];
-1430     return [
-1431         (m[0] * p0) + (m[4] * p1) + (m[8] * p2) + m[12],
-1432         (m[1] * p0) + (m[5] * p1) + (m[9] * p2) + m[13],
-1433         (m[2] * p0) + (m[6] * p1) + (m[10] * p2) + m[14],
-1434         (m[3] * p0) + (m[7] * p1) + (m[11] * p2) + m[15]
-1435     ];
-1436 };
-1437 
-1438 
-1439 /** @private */
-1440 var SceneJS_math_transformPoints3 = function(m, points) {
-1441     var result = new Array(points.length);
-1442     var len = points.length;
-1443     var p0, p1, p2;
-1444     var pi;
-1445 
-1446     // cache values
-1447     var m0 = m[0], m1 = m[1], m2 = m[2], m3 = m[3];
-1448     var m4 = m[4], m5 = m[5], m6 = m[6], m7 = m[7];
-1449     var m8 = m[8], m9 = m[9], m10 = m[10], m11 = m[11];
-1450     var m12 = m[12], m13 = m[13], m14 = m[14], m15 = m[15];
-1451 
-1452     for (var i = 0; i < len; ++i) {
-1453         // cache values
-1454         pi = points[i];
-1455         p0 = pi[0];
-1456         p1 = pi[1];
-1457         p2 = pi[2];
-1458 
-1459         result[i] = [
-1460             (m0 * p0) + (m4 * p1) + (m8 * p2) + m12,
-1461             (m1 * p0) + (m5 * p1) + (m9 * p2) + m13,
-1462             (m2 * p0) + (m6 * p1) + (m10 * p2) + m14,
-1463             (m3 * p0) + (m7 * p1) + (m11 * p2) + m15
-1464         ];
-1465     }
-1466 
-1467     return result;
-1468 };
-1469 
-1470 /** @private */
-1471 var SceneJS_math_transformVector3 = function(m, v) {
-1472     var v0 = v[0], v1 = v[1], v2 = v[2];
-1473     return [
-1474         (m[0] * v0) + (m[4] * v1) + (m[8] * v2),
-1475         (m[1] * v0) + (m[5] * v1) + (m[9] * v2),
-1476         (m[2] * v0) + (m[6] * v1) + (m[10] * v2)
-1477     ];
-1478 };
-1479 
-1480 var SceneJS_math_transformVector4 = function(m, v) {
-1481     var v0 = v[0], v1 = v[1], v2 = v[2], v3 = v[3];
-1482     return [
-1483         m[ 0] * v0 + m[ 4] * v1 + m[ 8] * v2 + m[12] * v3,
-1484         m[ 1] * v0 + m[ 5] * v1 + m[ 9] * v2 + m[13] * v3,
-1485         m[ 2] * v0 + m[ 6] * v1 + m[10] * v2 + m[14] * v3,
-1486         m[ 3] * v0 + m[ 7] * v1 + m[11] * v2 + m[15] * v3
-1487     ];
-1488 };
-1489 
-1490 /** @private */
-1491 var SceneJS_math_projectVec4 = function(v) {
-1492     var f = 1.0 / v[3];
-1493     return [v[0] * f, v[1] * f, v[2] * f, 1.0];
-1494 };
-1495 
-1496 
-1497 /** @private */
-1498 var SceneJS_math_Plane3 = function (normal, offset, normalize) {
-1499     this.normal = [0.0, 0.0, 1.0 ];
-1500 
-1501     this.offset = 0.0;
-1502     if (normal && offset) {
-1503         var normal0 = normal[0], normal1 = normal[1], normal2 = normal[2];
-1504         this.offset = offset;
-1505 
-1506         if (normalize) {
-1507             var s = Math.sqrt(
-1508                     normal0 * normal0 +
-1509                     normal1 * normal1 +
-1510                     normal2 * normal2
-1511                     );
-1512             if (s > 0.0) {
-1513                 s = 1.0 / s;
-1514                 this.normal[0] = normal0 * s;
-1515                 this.normal[1] = normal1 * s;
-1516                 this.normal[2] = normal2 * s;
-1517                 this.offset *= s;
-1518             }
-1519         }
-1520     }
-1521 };
-1522 
-1523 /** @private */
-1524 var SceneJS_math_MAX_DOUBLE = Number.POSITIVE_INFINITY;
-1525 /** @private */
-1526 var SceneJS_math_MIN_DOUBLE = Number.NEGATIVE_INFINITY;
-1527 
-1528 /** @private
-1529  *
-1530  */
-1531 var SceneJS_math_Box3 = function(min, max) {
-1532     this.min = min || [ SceneJS_math_MAX_DOUBLE,SceneJS_math_MAX_DOUBLE,SceneJS_math_MAX_DOUBLE ];
-1533     this.max = max || [ SceneJS_math_MIN_DOUBLE,SceneJS_math_MIN_DOUBLE,SceneJS_math_MIN_DOUBLE ];
-1534 
-1535     /** @private */
-1536     this.init = function(min, max) {
-1537         this.min[0] = min[0];
-1538         this.min[1] = min[1];
-1539         this.min[2] = min[2];
-1540         this.max[0] = max[0];
-1541         this.max[1] = max[1];
-1542         this.max[2] = max[2];
-1543         return this;
-1544     };
-1545 
-1546     /** @private */
-1547     this.fromPoints = function(points) {
-1548         var pointsLength = points.length;
-1549 
-1550         for (var i = 0; i < pointsLength; ++i) {
-1551             var points_i3 = points[i][3];
-1552             var pDiv0 = points[i][0] / points_i3;
-1553             var pDiv1 = points[i][1] / points_i3;
-1554             var pDiv2 = points[i][2] / points_i3;
-1555 
-1556             if (pDiv0 < this.min[0]) {
-1557                 this.min[0] = pDiv0;
-1558             }
-1559             if (pDiv1 < this.min[1]) {
-1560                 this.min[1] = pDiv1;
-1561             }
-1562             if (pDiv2 < this.min[2]) {
-1563                 this.min[2] = pDiv2;
-1564             }
-1565 
-1566             if (pDiv0 > this.max[0]) {
-1567                 this.max[0] = pDiv0;
-1568             }
-1569             if (pDiv1 > this.max[1]) {
-1570                 this.max[1] = pDiv1;
-1571             }
-1572             if (pDiv2 > this.max[2]) {
-1573                 this.max[2] = pDiv2;
-1574             }
-1575         }
-1576         return this;
-1577     };
-1578 
-1579     /** @private */
-1580     this.isEmpty = function() {
-1581         return (
-1582                 (this.min[0] >= this.max[0]) &&
-1583                 (this.min[1] >= this.max[1]) &&
-1584                 (this.min[2] >= this.max[2])
-1585                 );
-1586     };
-1587 
-1588     /** @private */
-1589     this.getCenter = function() {
-1590         return [
-1591             (this.max[0] + this.min[0]) / 2.0,
-1592             (this.max[1] + this.min[1]) / 2.0,
-1593             (this.max[2] + this.min[2]) / 2.0
-1594         ];
-1595     };
-1596 
-1597     /** @private */
-1598     this.getSize = function() {
-1599         return [
-1600             (this.max[0] - this.min[0]),
-1601             (this.max[1] - this.min[1]),
-1602             (this.max[2] - this.min[2])
-1603         ];
-1604     };
-1605 
-1606     /** @private */
-1607     this.getFacesAreas = function() {
-1608         var s = this.size;
-1609         return [
-1610             (s[1] * s[2]),
-1611             (s[0] * s[2]),
-1612             (s[0] * s[1])
-1613         ];
-1614     };
-1615 
-1616     /** @private */
-1617     this.getSurfaceArea = function() {
-1618         var a = this.getFacesAreas();
-1619         return ((a[0] + a[1] + a[2]) * 2.0);
-1620     };
-1621 
-1622     /** @private */
-1623     this.getVolume = function() {
-1624         var s = this.size;
-1625         return (s[0] * s[1] * s[2]);
-1626     };
-1627 
-1628     /** @private */
-1629     this.getOffset = function(half_delta) {
-1630         this.min[0] -= half_delta;
-1631         this.min[1] -= half_delta;
-1632         this.min[2] -= half_delta;
-1633         this.max[0] += half_delta;
-1634         this.max[1] += half_delta;
-1635         this.max[2] += half_delta;
-1636         return this;
-1637     };
-1638 };
-1639 
-1640 /** @private
-1641  *
-1642  * @param min
-1643  * @param max
-1644  */
-1645 var SceneJS_math_AxisBox3 = function(min, max) {
-1646     var min0 = min[0], min1 = min[1], min2 = min[2];
-1647     var max0 = max[0], max1 = max[1], max2 = max[2];
-1648 
-1649     this.verts = [
-1650         [min0, min1, min2],
-1651         [max0, min1, min2],
-1652         [max0, max1, min2],
-1653         [min0, max1, min2],
-1654 
-1655         [min0, min1, max2],
-1656         [max0, min1, max2],
-1657         [max0, max1, max2],
-1658         [min0, max1, max2]
-1659     ];
-1660 
-1661     /** @private */
-1662     this.toBox3 = function() {
-1663         var box = new SceneJS_math_Box3();
-1664         for (var i = 0; i < 8; ++i) {
-1665             var v = this.verts[i];
-1666             for (var j = 0; j < 3; ++j) {
-1667                 if (v[j] < box.min[j]) {
-1668                     box.min[j] = v[j];
-1669                 }
-1670                 if (v[j] > box.max[j]) {
-1671                     box.max[j] = v[j];
-1672                 }
-1673             }
-1674         }
-1675     };
-1676 };
-1677 
-1678 /** @private
-1679  *
-1680  * @param center
-1681  * @param radius
-1682  */
-1683 var SceneJS_math_Sphere3 = function(center, radius) {
-1684     this.center = [center[0], center[1], center[2] ];
-1685     this.radius = radius;
-1686 
-1687     /** @private */
-1688     this.isEmpty = function() {
-1689         return (this.radius === 0.0);
-1690     };
-1691 
-1692     /** @private */
-1693     this.surfaceArea = function() {
-1694         return (4.0 * Math.PI * this.radius * this.radius);
-1695     };
-1696 
-1697     /** @private */
-1698     this.getVolume = function() {
-1699         var thisRadius = this.radius;
-1700         return ((4.0 / 3.0) * Math.PI * thisRadius * thisRadius * thisRadius);
-1701     };
-1702 };
-1703 
-1704 /** Creates billboard matrix from given view matrix
-1705  * @private
-1706  */
-1707 var SceneJS_math_billboardMat = function(viewMatrix) {
-1708     var rotVec = [
-1709         SceneJS_math_getColMat4(viewMatrix, 0),
-1710         SceneJS_math_getColMat4(viewMatrix, 1),
-1711         SceneJS_math_getColMat4(viewMatrix, 2)
-1712     ];
-1713 
-1714     var scaleVec = [
-1715         SceneJS_math_lenVec4(rotVec[0]),
-1716         SceneJS_math_lenVec4(rotVec[1]),
-1717         SceneJS_math_lenVec4(rotVec[2])
-1718     ];
-1719 
-1720     var scaleVecRcp = SceneJS_math_mat4();
-1721     SceneJS_math_rcpVec3(scaleVec, scaleVecRcp);
-1722     var sMat = SceneJS_math_scalingMat4v(scaleVec);
-1723     //var sMatInv = SceneJS_math_scalingMat4v(scaleVecRcp);
-1724 
-1725     SceneJS_math_mulVec4Scalar(rotVec[0], scaleVecRcp[0]);
-1726     SceneJS_math_mulVec4Scalar(rotVec[1], scaleVecRcp[1]);
-1727     SceneJS_math_mulVec4Scalar(rotVec[2], scaleVecRcp[2]);
-1728 
-1729     var rotMatInverse = SceneJS_math_identityMat4();
-1730 
-1731     SceneJS_math_setRowMat4(rotMatInverse, 0, rotVec[0]);
-1732     SceneJS_math_setRowMat4(rotMatInverse, 1, rotVec[1]);
-1733     SceneJS_math_setRowMat4(rotMatInverse, 2, rotVec[2]);
-1734 
-1735     //return rotMatInverse;
-1736     //return SceneJS_math_mulMat4(sMatInv, SceneJS_math_mulMat4(rotMatInverse, sMat));
-1737     return SceneJS_math_mulMat4(rotMatInverse, sMat);
-1738     // return SceneJS_math_mulMat4(sMat, SceneJS_math_mulMat4(rotMatInverse, sMat));
-1739     //return SceneJS_math_mulMat4(sMatInv, SceneJS_math_mulMat4(rotMatInverse, sMat));
-1740 };
-1741 
-1742 /** @private */
-1743 var SceneJS_math_FrustumPlane = function(nx, ny, nz, offset) {
-1744     var s = 1.0 / Math.sqrt(nx * nx + ny * ny + nz * nz);
-1745     this.normal = [nx * s, ny * s, nz * s];
-1746     this.offset = offset * s;
-1747     this.testVertex = [
-1748         (this.normal[0] >= 0.0) ? (1) : (0),
-1749         (this.normal[1] >= 0.0) ? (1) : (0),
-1750         (this.normal[2] >= 0.0) ? (1) : (0)];
-1751 };
-1752 
-1753 /** @private */
-1754 var SceneJS_math_OUTSIDE_FRUSTUM = 3;
-1755 /** @private */
-1756 var SceneJS_math_INTERSECT_FRUSTUM = 4;
-1757 /** @private */
-1758 var SceneJS_math_INSIDE_FRUSTUM = 5;
-1759 
-1760 /** @private */
-1761 var SceneJS_math_Frustum = function(viewMatrix, projectionMatrix, viewport) {
-1762     var m = SceneJS_math_mat4();
-1763     SceneJS_math_mulMat4(projectionMatrix, viewMatrix, m);
-1764 
-1765     // cache m indexes
-1766     var m0 = m[0], m1 = m[1], m2 = m[2], m3 = m[3];
-1767     var m4 = m[4], m5 = m[5], m6 = m[6], m7 = m[7];
-1768     var m8 = m[8], m9 = m[9], m10 = m[10], m11 = m[11];
-1769     var m12 = m[12], m13 = m[13], m14 = m[14], m15 = m[15];
-1770 
-1771     //var q = [ m[3], m[7], m[11] ]; just reuse m indexes instead of making new var
-1772     var planes = [
-1773         new SceneJS_math_FrustumPlane(m3 - m0, m7 - m4, m11 - m8, m15 - m12),
-1774         new SceneJS_math_FrustumPlane(m3 + m0, m7 + m4, m11 + m8, m15 + m12),
-1775         new SceneJS_math_FrustumPlane(m3 - m1, m7 - m5, m11 - m9, m15 - m13),
-1776         new SceneJS_math_FrustumPlane(m3 + m1, m7 + m5, m11 + m9, m15 + m13),
-1777         new SceneJS_math_FrustumPlane(m3 - m2, m7 - m6, m11 - m10, m15 - m14),
-1778         new SceneJS_math_FrustumPlane(m3 + m2, m7 + m6, m11 + m10, m15 + m14)
-1779     ];
-1780 
-1781     /* Resources for LOD
-1782      */
-1783     var rotVec = [
-1784         SceneJS_math_getColMat4(viewMatrix, 0),
-1785         SceneJS_math_getColMat4(viewMatrix, 1),
-1786         SceneJS_math_getColMat4(viewMatrix, 2)
-1787     ];
-1788 
-1789     var scaleVec = [
-1790         SceneJS_math_lenVec4(rotVec[0]),
-1791         SceneJS_math_lenVec4(rotVec[1]),
-1792         SceneJS_math_lenVec4(rotVec[2])
-1793     ];
-1794 
-1795     var scaleVecRcp = SceneJS_math_rcpVec3(scaleVec);
-1796     var sMat = SceneJS_math_scalingMat4v(scaleVec);
-1797     var sMatInv = SceneJS_math_scalingMat4v(scaleVecRcp);
-1798 
-1799     SceneJS_math_mulVec4Scalar(rotVec[0], scaleVecRcp[0]);
-1800     SceneJS_math_mulVec4Scalar(rotVec[1], scaleVecRcp[1]);
-1801     SceneJS_math_mulVec4Scalar(rotVec[2], scaleVecRcp[2]);
-1802 
-1803     var rotMatInverse = SceneJS_math_identityMat4();
-1804 
-1805     SceneJS_math_setRowMat4(rotMatInverse, 0, rotVec[0]);
-1806     SceneJS_math_setRowMat4(rotMatInverse, 1, rotVec[1]);
-1807     SceneJS_math_setRowMat4(rotMatInverse, 2, rotVec[2]);
-1808 
-1809     if (!this.matrix) {
-1810         this.matrix = SceneJS_math_mat4();
-1811     }
-1812     SceneJS_math_mulMat4(projectionMatrix, viewMatrix, this.matrix);
-1813     if (!this.billboardMatrix) {
-1814         this.billboardMatrix = SceneJS_math_mat4();
-1815     }
-1816     SceneJS_math_mulMat4(sMatInv, SceneJS_math_mulMat4(rotMatInverse, sMat), this.billboardMatrix);
-1817     this.viewport = viewport.slice(0, 4);
-1818 
-1819     /** @private */
-1820     this.textAxisBoxIntersection = function(box) {
-1821         var ret = SceneJS_math_INSIDE_FRUSTUM;
-1822         var bminmax = [ box.min, box.max ];
-1823         var plane = null;
-1824 
-1825         for (var i = 0; i < 6; ++i) {
-1826             plane = planes[i];
-1827             if (((plane.normal[0] * bminmax[plane.testVertex[0]][0]) +
-1828                  (plane.normal[1] * bminmax[plane.testVertex[1]][1]) +
-1829                  (plane.normal[2] * bminmax[plane.testVertex[2]][2]) +
-1830                  (plane.offset)) < 0.0) {
-1831                 return SceneJS_math_OUTSIDE_FRUSTUM;
-1832             }
-1833             if (((plane.normal[0] * bminmax[1 - plane.testVertex[0]][0]) +
-1834                  (plane.normal[1] * bminmax[1 - plane.testVertex[1]][1]) +
-1835                  (plane.normal[2] * bminmax[1 - plane.testVertex[2]][2]) +
-1836                  (plane.offset)) < 0.0) {
-1837                 ret = SceneJS_math_INTERSECT_FRUSTUM;
-1838             }
-1839         }
-1840         return ret;
-1841     };
-1842 
-1843     /** @private */
-1844     this.getProjectedSize = function(box) {
-1845         var diagVec = SceneJS_math_mat4();
-1846         SceneJS_math_subVec3(box.max, box.min, diagVec);
-1847 
-1848         var diagSize = SceneJS_math_lenVec3(diagVec);
-1849 
-1850         var size = Math.abs(diagSize);
-1851 
-1852         var p0 = [
-1853             (box.min[0] + box.max[0]) * 0.5,
-1854             (box.min[1] + box.max[1]) * 0.5,
-1855             (box.min[2] + box.max[2]) * 0.5,
-1856             0.0];
-1857 
-1858         var halfSize = size * 0.5;
-1859         var p1 = [ -halfSize, 0.0, 0.0, 1.0 ];
-1860         var p2 = [  halfSize, 0.0, 0.0, 1.0 ];
-1861 
-1862         p1 = SceneJS_math_mulMat4v4(this.billboardMatrix, p1);
-1863         p1 = SceneJS_math_addVec4(p1, p0);
-1864         p1 = SceneJS_math_projectVec4(SceneJS_math_mulMat4v4(this.matrix, p1));
-1865 
-1866         p2 = SceneJS_math_mulMat4v4(this.billboardMatrix, p2);
-1867         p2 = SceneJS_math_addVec4(p2, p0);
-1868         p2 = SceneJS_math_projectVec4(SceneJS_math_mulMat4v4(this.matrix, p2));
-1869 
-1870         return viewport[2] * Math.abs(p2[0] - p1[0]);
-1871     };
-1872 
-1873 
-1874     this.getProjectedState = function(modelCoords) {
-1875         var viewCoords = SceneJS_math_transformPoints3(this.matrix, modelCoords);
-1876 
-1877         //var canvasBox = {
-1878         //    min: [10000000, 10000000 ],
-1879         //    max: [-10000000, -10000000]
-1880         //};
-1881         // separate variables instead of indexing an array
-1882         var canvasBoxMin0 = 10000000, canvasBoxMin1 = 10000000;
-1883         var canvasBoxMax0 = -10000000, canvasBoxMax1 = -10000000;
-1884 
-1885         var v, x, y;
-1886 
-1887         var arrLen = viewCoords.length;
-1888         for (var i = 0; i < arrLen; ++i) {
-1889             v = SceneJS_math_projectVec4(viewCoords[i]);
-1890             x = v[0];
-1891             y = v[1];
-1892 
-1893             if (x < -0.5) {
-1894                 x = -0.5;
-1895             }
-1896 
-1897             if (y < -0.5) {
-1898                 y = -0.5;
-1899             }
-1900 
-1901             if (x > 0.5) {
-1902                 x = 0.5;
-1903             }
-1904 
-1905             if (y > 0.5) {
-1906                 y = 0.5;
-1907             }
-1908 
-1909 
-1910             if (x < canvasBoxMin0) {
-1911                 canvasBoxMin0 = x;
-1912             }
-1913             if (y < canvasBoxMin1) {
-1914                 canvasBoxMin1 = y;
-1915             }
-1916 
-1917             if (x > canvasBoxMax0) {
-1918                 canvasBoxMax0 = x;
-1919             }
-1920             if (y > canvasBoxMax1) {
-1921                 canvasBoxMax1 = y;
-1922             }
-1923         }
-1924 
-1925         canvasBoxMin0 += 0.5;
-1926         canvasBoxMin1 += 0.5;
-1927         canvasBoxMax0 += 0.5;
-1928         canvasBoxMax1 += 0.5;
-1929 
-1930         // cache viewport indexes
-1931         var viewport2 = viewport[2], viewport3 = viewport[3];
-1932 
-1933         canvasBoxMin0 = (canvasBoxMin0 * (viewport2 + 15));
-1934         canvasBoxMin1 = (canvasBoxMin1 * (viewport3 + 15));
-1935         canvasBoxMax0 = (canvasBoxMax0 * (viewport2 + 15));
-1936         canvasBoxMax1 = (canvasBoxMax1 * (viewport3 + 15));
-1937 
-1938         var diagCanvasBoxVec = SceneJS_math_mat4();
-1939         SceneJS_math_subVec2([canvasBoxMax0, canvasBoxMax1],
-1940                 [canvasBoxMin0, canvasBoxMin1],
-1941                 diagCanvasBoxVec);
-1942         var diagCanvasBoxSize = SceneJS_math_lenVec2(diagCanvasBoxVec);
-1943 
-1944         if (canvasBoxMin0 < 0) {
-1945             canvasBoxMin0 = 0;
-1946         }
-1947         if (canvasBoxMax0 > viewport2) {
-1948             canvasBoxMax0 = viewport2;
-1949         }
-1950 
-1951         if (canvasBoxMin1 < 0) {
-1952             canvasBoxMin1 = 0;
-1953         }
-1954         if (canvasBoxMax1 > viewport3) {
-1955             canvasBoxMax1 = viewport3;
-1956         }
-1957         return {
-1958             canvasBox:  {
-1959                 min: [canvasBoxMin0, canvasBoxMin1 ],
-1960                 max: [canvasBoxMax0, canvasBoxMax1 ]
-1961             },
-1962             canvasSize: diagCanvasBoxSize
-1963         };
-1964     };
-1965 };
-1966 
-1967 var SceneJS_math_identityQuaternion = function() {
-1968     return [ 0.0, 0.0, 0.0, 1.0 ];
-1969 };
-1970 
-1971 var SceneJS_math_angleAxisQuaternion = function(x, y, z, degrees) {
-1972     var angleRad = (degrees / 180.0) * Math.PI;
-1973     var halfAngle = angleRad / 2.0;
-1974     var fsin = Math.sin(halfAngle);
-1975     return [
-1976         fsin * x,
-1977         fsin * y,
-1978         fsin * z,
-1979         Math.cos(halfAngle)
-1980     ];
-1981 };
-1982 
-1983 var SceneJS_math_mulQuaternions = function(p, q) {
-1984     var p0 = p[0], p1 = p[1], p2 = p[2], p3 = p[3];
-1985     var q0 = q[0], q1 = q[1], q2 = q[2], q3 = q[3];
-1986     return [
-1987         p3 * q0 + p0 * q3 + p1 * q2 - p2 * q1,
-1988         p3 * q1 + p1 * q3 + p2 * q0 - p0 * q2,
-1989         p3 * q2 + p2 * q3 + p0 * q1 - p1 * q0,
-1990         p3 * q3 - p0 * q0 - p1 * q1 - p2 * q2
-1991     ];
-1992 };
-1993 
-1994 var SceneJS_math_newMat4FromQuaternion = function(q) {
-1995     var q0 = q[0], q1 = q[1], q2 = q[2], q3 = q[3];
-1996     var tx = 2.0 * q0;
-1997     var ty = 2.0 * q1;
-1998     var tz = 2.0 * q2;
-1999     var twx = tx * q3;
-2000     var twy = ty * q3;
-2001     var twz = tz * q3;
-2002     var txx = tx * q0;
-2003     var txy = ty * q0;
-2004     var txz = tz * q0;
-2005     var tyy = ty * q1;
-2006     var tyz = tz * q1;
-2007     var tzz = tz * q2;
-2008     var m = SceneJS_math_identityMat4();
-2009     SceneJS_math_setCellMat4(m, 0, 0, 1.0 - (tyy + tzz));
-2010     SceneJS_math_setCellMat4(m, 0, 1, txy - twz);
-2011     SceneJS_math_setCellMat4(m, 0, 2, txz + twy);
-2012     SceneJS_math_setCellMat4(m, 1, 0, txy + twz);
-2013     SceneJS_math_setCellMat4(m, 1, 1, 1.0 - (txx + tzz));
-2014     SceneJS_math_setCellMat4(m, 1, 2, tyz - twx);
-2015     SceneJS_math_setCellMat4(m, 2, 0, txz - twy);
-2016     SceneJS_math_setCellMat4(m, 2, 1, tyz + twx);
-2017     SceneJS_math_setCellMat4(m, 2, 2, 1.0 - (txx + tyy));
-2018     return m;
-2019 };
-2020 
-2021 
-2022 //var SceneJS_math_slerp(t, q1, q2) {
-2023 //    var result = SceneJS_math_identityQuaternion();
-2024 //    var cosHalfAngle = q1[3] * q2[3] + q1[0] * q2[0] + q1[1] * q2[1] + q1[2] * q2[2];
-2025 //    if (Math.abs(cosHalfAngle) >= 1) {
-2026 //        return [ q1[0],q1[1], q1[2], q1[3] ];
-2027 //    } else {
-2028 //        var halfAngle = Math.acos(cosHalfAngle);
-2029 //        var sinHalfAngle = Math.sqrt(1 - cosHalfAngle * cosHalfAngle);
-2030 //        if (Math.abs(sinHalfAngle) < 0.001) {
-2031 //            return [
-2032 //                q1[0] * 0.5 + q2[0] * 0.5,
-2033 //                q1[1] * 0.5 + q2[1] * 0.5,
-2034 //                q1[2] * 0.5 + q2[2] * 0.5,
-2035 //                q1[3] * 0.5 + q2[3] * 0.5
-2036 //            ];
-2037 //        } else {
-2038 //            var a = Math.sin((1 - t) * halfAngle) / sinHalfAngle;
-2039 //            var b = Math.sin(t * halfAngle) / sinHalfAngle;
-2040 //            return [
-2041 //                q1[0] * a + q2[0] * b,
-2042 //                q1[1] * a + q2[1] * b,
-2043 //                q1[2] * a + q2[2] * b,
-2044 //                q1[3] * a + q2[3] * b
-2045 //            ];
-2046 //        }
-2047 //    }
-2048 //}
-2049 
-2050 var SceneJS_math_slerp = function(t, q1, q2) {
-2051     //var result = SceneJS_math_identityQuaternion();
-2052     var q13 = q1[3] * 0.0174532925;
-2053     var q23 = q2[3] * 0.0174532925;
-2054     var cosHalfAngle = q13 * q23 + q1[0] * q2[0] + q1[1] * q2[1] + q1[2] * q2[2];
-2055     if (Math.abs(cosHalfAngle) >= 1) {
-2056         return [ q1[0],q1[1], q1[2], q1[3] ];
-2057     } else {
-2058         var halfAngle = Math.acos(cosHalfAngle);
-2059         var sinHalfAngle = Math.sqrt(1 - cosHalfAngle * cosHalfAngle);
-2060         if (Math.abs(sinHalfAngle) < 0.001) {
-2061             return [
-2062                 q1[0] * 0.5 + q2[0] * 0.5,
-2063                 q1[1] * 0.5 + q2[1] * 0.5,
-2064                 q1[2] * 0.5 + q2[2] * 0.5,
-2065                 q1[3] * 0.5 + q2[3] * 0.5
-2066             ];
-2067         } else {
-2068             var a = Math.sin((1 - t) * halfAngle) / sinHalfAngle;
-2069             var b = Math.sin(t * halfAngle) / sinHalfAngle;
-2070             return [
-2071                 q1[0] * a + q2[0] * b,
-2072                 q1[1] * a + q2[1] * b,
-2073                 q1[2] * a + q2[2] * b,
-2074                 (q13 * a + q23 * b) * 57.295779579
-2075             ];
-2076         }
-2077     }
-2078 };
-2079 
-2080 var SceneJS_math_normalizeQuaternion = function(q) {
-2081     var len = SceneJS_math_lenVec4([q[0], q[1], q[2], q[3]]);
-2082     return [ q[0] / len, q[1] / len, q[2] / len, q[3] / len ];
-2083 };
-2084 
-2085 var SceneJS_math_conjugateQuaternion = function(q) {
-2086     return[-q[0],-q[1],-q[2],q[3]];
-2087 };
-2088 
-2089 var SceneJS_math_angleAxisFromQuaternion = function(q) {
-2090     q = SceneJS_math_normalizeQuaternion(q);
-2091     var q3 = q[3];
-2092     var angle = 2 * Math.acos(q3);
-2093     var s = Math.sqrt(1 - q3 * q3);
-2094     if (s < 0.001) { // test to avoid divide by zero, s is always positive due to sqrt
-2095         return {
-2096             x : q[0],
-2097             y : q[1],
-2098             z : q[2],
-2099             angle: angle * 57.295779579
-2100         };
-2101     } else {
-2102         return {
-2103             x : q[0] / s,
-2104             y : q[1] / s,
-2105             z : q[2] / s,
-2106             angle: angle * 57.295779579
-2107         };
-2108     }
-2109 };
-2110 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_plugins.js.html b/docs/symbols/src/src_core_plugins.js.html deleted file mode 100644 index 8fe56b88..00000000 --- a/docs/symbols/src/src_core_plugins.js.html +++ /dev/null @@ -1,74 +0,0 @@ -
  1 /**
-  2  * SceneJS plugin registry
-  3  */
-  4 SceneJS.Plugins = new (function () {
-  5 
-  6     this._nodePlugins = {};
-  7 
-  8     /**
-  9      * Installs a plugin into SceneJS
- 10      */
- 11     this.addPlugin = function (nodeType, pluginType, plugin) {
- 12         var plugins = this._nodePlugins[nodeType] || (this._nodePlugins[nodeType] = {});
- 13         plugins[pluginType] = plugin;
- 14     };
- 15 
- 16     /**
- 17      * Tests if given plugin is installed
- 18      */
- 19     this.hasPlugin = function (nodeType, pluginType) {
- 20         var plugins = this._nodePlugins[nodeType];
- 21         return (plugins && !!plugins[pluginType]);
- 22     };
- 23 
- 24     /**
- 25      * Returns installed plugin of given type and ID
- 26      */
- 27     this.getPlugin = function (nodeType, pluginType, ok) {
- 28         var plugins = this._nodePlugins[nodeType];
- 29         if (plugins) {
- 30             var plugin = plugins[pluginType];
- 31             if (plugin) {
- 32                 ok(plugin);
- 33             }
- 34         }
- 35         // lazy-load
- 36         var self = this;
- 37         var pluginPath = SceneJS_debugModule.configs.pluginPath;
- 38         if (!pluginPath) {
- 39             throw "no pluginPath config"; // Build script error - should create this config
- 40         }
- 41         loadScript(pluginPath + "/" + nodeType + "/" + pluginType + ".js",
- 42             function () {
- 43                 ok(self._nodePlugins[nodeType][pluginType]);
- 44             });
- 45     };
- 46 
- 47     function loadScript(url, ok) {
- 48         var script = document.createElement("script");
- 49         script.type = "text/javascript";
- 50         if (script.readyState) {  //IE
- 51             script.onreadystatechange = function () {
- 52                 if (script.readyState == "loaded" ||
- 53                     script.readyState == "complete") {
- 54                     script.onreadystatechange = null;
- 55                     ok();
- 56                 }
- 57             };
- 58         } else {  //Others
- 59             script.onload = function () {
- 60                 ok();
- 61             };
- 62         }
- 63         script.src = url;
- 64         document.getElementsByTagName("head")[0].appendChild(script);
- 65     }
- 66 
- 67 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_camera.js.html b/docs/symbols/src/src_core_scene_camera.js.html deleted file mode 100644 index c227c914..00000000 --- a/docs/symbols/src/src_core_scene_camera.js.html +++ /dev/null @@ -1,170 +0,0 @@ -
  1 (function () {
-  2 
-  3     // The default state core singleton for {@link SceneJS.Camera} nodes
-  4     var defaultCore = {
-  5 
-  6         type:"camera",
-  7 
-  8         stateId:SceneJS._baseStateId++,
-  9 
- 10         // Default perspective projection matrix
- 11         mat:SceneJS_math_perspectiveMatrix4(
- 12             45, // fovy
- 13             1, // aspect
- 14             0.1, // near
- 15             5000), // far
- 16 
- 17         //Default optical attributes for perspective projection
- 18         optics:{
- 19             type:"perspective",
- 20             fovy:45.0,
- 21             aspect:1.0,
- 22             near:0.1,
- 23             far:5000.0
- 24         }
- 25     };
- 26 
- 27     var coreStack = [];
- 28     var stackLen = 0;
- 29 
- 30     // Set default core on the display at the start of each new scene compilation
- 31     SceneJS_events.addListener(
- 32         SceneJS_events.SCENE_COMPILING,
- 33         function (params) {
- 34             params.engine.display.projTransform = defaultCore;
- 35             stackLen = 0;
- 36         });
- 37 
- 38     /**
- 39      * @class Scene graph node which defines the projection transform to apply to the {@link SceneJS.Geometry} nodes in its subgraph
- 40      * @extends SceneJS.Node
- 41      */
- 42     SceneJS.Camera = SceneJS_NodeFactory.createNodeType("camera");
- 43 
- 44     SceneJS.Camera.prototype._init = function (params) {
- 45         if (this._core.useCount == 1) {
- 46             this.setOptics(params.optics); // Can be undefined
- 47         }
- 48     };
- 49 
- 50     SceneJS.Camera.prototype.setOptics = function (optics) {
- 51         var core = this._core;
- 52         if (!optics) {
- 53             core.optics = {
- 54                 type:type,
- 55                 fovy:60.0,
- 56                 aspect:1.0,
- 57                 near:0.1,
- 58                 far:5000.0
- 59             };
- 60         } else {
- 61             var type = optics.type || core.optics.type;
- 62             if (type == "ortho") {
- 63                 core.optics = SceneJS._applyIf(SceneJS_math_ORTHO_OBJ, {
- 64                     type:type,
- 65                     left:optics.left,
- 66                     bottom:optics.bottom,
- 67                     near:optics.near,
- 68                     right:optics.right,
- 69                     top:optics.top,
- 70                     far:optics.far
- 71                 });
- 72             } else if (type == "frustum") {
- 73                 core.optics = {
- 74                     type:type,
- 75                     left:optics.left || -1.0,
- 76                     bottom:optics.bottom || -1.0,
- 77                     near:optics.near || 0.1,
- 78                     right:optics.right || 1.00,
- 79                     top:optics.top || 1.0,
- 80                     far:optics.far || 5000.0
- 81                 };
- 82             } else if (type == "perspective") {
- 83                 core.optics = {
- 84                     type:type,
- 85                     fovy:optics.fovy || 60.0,
- 86                     aspect:optics.aspect == undefined ? 1.0 : optics.aspect,
- 87                     near:optics.near || 0.1,
- 88                     far:optics.far || 5000.0
- 89                 };
- 90             } else if (!optics.type) {
- 91                 throw SceneJS_error.fatalError(
- 92                     SceneJS.errors.ILLEGAL_NODE_CONFIG,
- 93                     "SceneJS.Camera configuration invalid: optics type not specified - " +
- 94                         "supported types are 'perspective', 'frustum' and 'ortho'");
- 95             } else {
- 96                 throw SceneJS_error.fatalError(
- 97                     SceneJS.errors.ILLEGAL_NODE_CONFIG,
- 98                     "SceneJS.Camera configuration invalid: optics type not supported - " +
- 99                         "supported types are 'perspective', 'frustum' and 'ortho'");
-100             }
-101         }
-102         this._rebuild();
-103         this._engine.display.imageDirty = true;
-104     };
-105 
-106     SceneJS.Camera.prototype._rebuild = function () {
-107         var optics = this._core.optics;
-108         if (optics.type == "ortho") {
-109             this._core.matrix = SceneJS_math_orthoMat4c(
-110                 optics.left,
-111                 optics.right,
-112                 optics.bottom,
-113                 optics.top,
-114                 optics.near,
-115                 optics.far);
-116 
-117         } else if (optics.type == "frustum") {
-118             this._core.matrix = SceneJS_math_frustumMatrix4(
-119                 optics.left,
-120                 optics.right,
-121                 optics.bottom,
-122                 optics.top,
-123                 optics.near,
-124                 optics.far);
-125 
-126         } else if (optics.type == "perspective") {
-127             this._core.matrix = SceneJS_math_perspectiveMatrix4(
-128                 optics.fovy * Math.PI / 180.0,
-129                 optics.aspect,
-130                 optics.near,
-131                 optics.far);
-132         }
-133         if (!this._core.mat) {
-134             this._core.mat = new Float32Array(this._core.matrix);
-135         } else {
-136             this._core.mat.set(this._core.matrix);
-137         }
-138     };
-139 
-140     SceneJS.Camera.prototype.getOptics = function () {
-141         var optics = {};
-142         for (var key in this._core.optics) {
-143             if (this._core.optics.hasOwnProperty(key)) {
-144                 optics[key] = this._core.optics[key];
-145             }
-146         }
-147         return optics;
-148     };
-149 
-150     SceneJS.Camera.prototype.getMatrix = function () {
-151         return this._core.matrix.slice(0);
-152     };
-153 
-154     /**
-155      * Compiles this camera node, setting this node's state core on the display, compiling sub-nodes,
-156      * then restoring the previous camera state core back onto the display on exit.
-157      */
-158     SceneJS.Camera.prototype._compile = function () {
-159         this._engine.display.projTransform = coreStack[stackLen++] = this._core;
-160         this._compileNodes();
-161         this._engine.display.projTransform = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore;
-162     };
-163 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_clips.js.html b/docs/symbols/src/src_core_scene_clips.js.html deleted file mode 100644 index ac1d1a2d..00000000 --- a/docs/symbols/src/src_core_scene_clips.js.html +++ /dev/null @@ -1,105 +0,0 @@ -
  1 (function() {
-  2 
-  3     /**
-  4      * The default state core singleton for {@link SceneJS.Clips} nodes
-  5      */
-  6     var defaultCore = {
-  7         type: "clips",
-  8         stateId: SceneJS._baseStateId++,
-  9         empty: true,        
- 10         hash: "",
- 11         clips : []
- 12     };
- 13 
- 14     var coreStack = [];
- 15     var stackLen = 0;
- 16 
- 17     SceneJS_events.addListener(
- 18             SceneJS_events.SCENE_COMPILING,
- 19             function(params) {
- 20                 params.engine.display.clips = defaultCore;
- 21                 stackLen = 0;
- 22             });
- 23 
- 24     /**
- 25      * @class Scene graph node which defines one or more arbitrarily-aligned clip planes to clip the {@link SceneJS.Geometry} nodes in its subgraph
- 26      * @extends SceneJS.Node
- 27      */
- 28     SceneJS.Clips = SceneJS_NodeFactory.createNodeType("clips");
- 29 
- 30     SceneJS.Clips.prototype._init = function(params) {
- 31 
- 32         if (this._core.useCount == 1) { // This node defines the resource
- 33 
- 34             var clips = params.clips;
- 35 
- 36             if (!clips) {
- 37                 throw SceneJS_error.fatalError(
- 38                         SceneJS.errors.NODE_CONFIG_EXPECTED,
- 39                         "clips node attribute missing : 'clips'");
- 40             }
- 41 
- 42             this._core.clips = this._core.clips || [];
- 43 
- 44             for (var i = 0, len = clips.length; i < len; i++) {
- 45                 this._setClip(i, clips[i]);
- 46             }
- 47         }
- 48     };
- 49 
- 50     SceneJS.Clips.prototype.setClips = function(clips) {
- 51         var indexNum;
- 52         for (var index in clips) {
- 53             if (clips.hasOwnProperty(index)) {
- 54                 if (index != undefined || index != null) {
- 55                     indexNum = parseInt(index);
- 56                     if (indexNum < 0 || indexNum >= this._core.clips.length) {
- 57                         throw SceneJS_error.fatalError(
- 58                                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
- 59                                 "Invalid argument to set 'clips': index out of range (" + this._core.clips.length + " clips defined)");
- 60                     }
- 61                     this._setClip(indexNum, clips[index] || {});
- 62                 }
- 63             }
- 64         }
- 65         this._engine.display.imageDirty = true;
- 66     };
- 67 
- 68     SceneJS.Clips.prototype._setClip = function(index, cfg) {
- 69 
- 70         var clip = this._core.clips[index] || (this._core.clips[index] = {});
- 71 
- 72         clip.normalAndDist = [cfg.x || 0,  cfg.y || 0, cfg.z || 0, cfg.dist || 0];
- 73 
- 74         var mode = cfg.mode || clip.mode || "disabled";
- 75 
- 76         if (mode != "inside" && mode != "outside" && mode != "disabled") {
- 77             throw SceneJS_error.fatalError(
- 78                     SceneJS.errors.ILLEGAL_NODE_CONFIG,
- 79                     "clips node invalid value for property 'mode': should be 'inside' or 'outside' or 'disabled'");
- 80         }
- 81         clip.mode = mode;
- 82 
- 83         this._core.hash = null;
- 84     };
- 85 
- 86     SceneJS.Clips.prototype._compile = function() {
- 87 
- 88         if (!this._core.hash) {
- 89             this._core.hash = this._core.clips.length;
- 90         }
- 91 
- 92         this._engine.display.clips = coreStack[stackLen++] = this._core;
- 93         this._compileNodes();
- 94         this._engine.display.clips = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore;
- 95     };
- 96 
- 97 
- 98 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_core.js.html b/docs/symbols/src/src_core_scene_core.js.html deleted file mode 100644 index 938bde40..00000000 --- a/docs/symbols/src/src_core_scene_core.js.html +++ /dev/null @@ -1,50 +0,0 @@ -
  1 /**
-  2  * @class Holds state for one or more {@link SceneJS.Node}s.
-  3  *
-  4  * <p>Each {@link SceneJS.Node} has a state core to hold its state, and the core may be shared by other
-  5  * {@link SceneJS.Nodes}s of the same type.</p>
-  6  *
-  7  * <p>The state held by core is rendered by a {@link SceneJS_Chunk}  
-  8  *
-  9  * @private
- 10  */
- 11 var SceneJS_Core = function(type) {
- 12 
- 13     /**
- 14      * The state core type, which will be the same value as the type property on the {@link SceneJS.Node}s that use the core
- 15      * @type String
- 16      * @see SceneJS.Node#type
- 17      */
- 18     this.type = type;
- 19 
- 20     /**
- 21      * The state core ID, unique within the scene. This ID may be either a string assigned by the application layer via
- 22      * scene node configs, or a number that is automatically generated by the {@link SceneJS_CoreFactory} managing
- 23      * this core instance.
- 24      * @type String|Number
- 25      */
- 26     this.coreId = null;
- 27 
- 28     /**
- 29      * Uniquely identifies this state core within a {@link SceneJS_Display}.
- 30      *
- 31      * This ID is used by a {@link SceneJS_Display} to reduce redundant state changes when rendering a sequence of cores, 
- 32      * where as a {@link SceneJS_Display} renders a frame it avoids applying consecutive cores that have the
- 33      * same value for this ID.
- 34      *
- 35      * @type Number
- 36      */
- 37     this.stateId = null;
- 38 
- 39     /**
- 40      * Count of {@link SceneJS.Node} instances this core holds state for
- 41      */
- 42     this.useCount = 0;
- 43 };
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_coreFactory.js.html b/docs/symbols/src/src_core_scene_coreFactory.js.html deleted file mode 100644 index 82555f8f..00000000 --- a/docs/symbols/src/src_core_scene_coreFactory.js.html +++ /dev/null @@ -1,162 +0,0 @@ -
  1 /**
-  2  * @class Manages creation, recycle and destruction of {@link SceneJS_Core} instances
-  3  * @private
-  4  */
-  5 var SceneJS_CoreFactory = function () {
-  6 
-  7     this._stateMap = new SceneJS_Map(null, SceneJS._baseStateId);  // For creating unique state IDs for cores
-  8 
-  9     this._cores = {}; // Map of cores for each type
- 10 };
- 11 
- 12 /**
- 13  * State core classes provided by this factory
- 14  * @type {SceneJS.Core}
- 15  */
- 16 SceneJS_CoreFactory.coreTypes = {};    // Supported core classes, installed by #createCoreType
- 17 
- 18 /**
- 19  * Creates a core class for instantiation by this factory
- 20  * @param {String} type Name of type, eg. "camera"
- 21  * @param {Node} [superType] Class of super type - SceneJS.Node by default
- 22  * @returns The new node class
- 23  */
- 24 SceneJS_CoreFactory.createCoreType = function (type, superType) {
- 25     //
- 26     //    var supa = SceneJS_CoreFactory.coreTypes[superType];
- 27     //
- 28     //    if (!supa) {
- 29     //        supa = SceneJS.Core; // Super class is Core by default
- 30     //    }
- 31     //
- 32     //    var nodeType = function() { // Create the class
- 33     //        supa.apply(this, arguments);
- 34     //        this.type = type;
- 35     //    };
- 36     //
- 37     //    nodeType.prototype = new supa();            // Inherit from base class
- 38     //    nodeType.prototype.constructor = nodeType;
- 39     //
- 40     //    SceneJS_CoreFactory.nodeTypes[type] = nodeType;
- 41     //
- 42     //    return nodeType;
- 43 };
- 44 
- 45 SceneJS_CoreFactory.addCoreBuilder = function (type, factory) {
- 46 
- 47 };
- 48 
- 49 /* HACK - allows different types of node to have same type of core, eg. "rotate" and "translate" nodes can both have an "xform" core    
- 50  */
- 51 SceneJS_CoreFactory.coreAliases = {
- 52     "rotate":"xform",
- 53     "translate":"xform",
- 54     "scale":"xform",
- 55     "matrix":"xform",
- 56     "xform":"xform"
- 57 };
- 58 
- 59 /**
- 60  * Gets a core of the given type from this factory. Reuses any existing existing core of the same type and ID.
- 61  *
- 62  * The caller (a scene node) will then augment the core with type-specific attributes and methods.
- 63  *
- 64  * @param {String} type Type name of core, e.g. "material", "texture"
- 65  * @param {String} coreId ID for the core, unique among all cores of the given type within this factory
- 66  * @returns {Core} The core
- 67  */
- 68 SceneJS_CoreFactory.prototype.getCore = function (type, coreId) {
- 69 
- 70     /* HACK - allows different types of node to have same type of core, eg. "rotate" and "translate" nodes can both have an "xform" core    
- 71      */
- 72     var alias = SceneJS_CoreFactory.coreAliases[type];
- 73     if (alias) {
- 74         type = alias;
- 75     }
- 76 
- 77     var cores = this._cores[type];
- 78 
- 79     if (!cores) {
- 80         cores = this._cores[type] = {};
- 81     }
- 82 
- 83     var core;
- 84 
- 85     if (coreId) { // Attempt to reuse a core
- 86 
- 87         core = cores[coreId];
- 88 
- 89         if (core) {
- 90             core.useCount++;
- 91             return core;
- 92         }
- 93     }
- 94 
- 95     core = new SceneJS_Core(type);
- 96     core.useCount = 1;  // One user so far
- 97 
- 98     core.stateId = this._stateMap.addItem(core);
- 99     core.coreId = (coreId != undefined && coreId != null) ? coreId : core.stateId; // Use state ID as core ID by default
-100 
-101     cores[core.coreId] = core;
-102 
-103     return core;
-104 };
-105 
-106 /**
-107  * Releases a state core back to this factory, destroying it if the core's use count is then zero.
-108  * @param {Core} core Core to release
-109  */
-110 SceneJS_CoreFactory.prototype.putCore = function (core) {
-111 
-112     if (core.useCount == 0) {
-113         return; // In case of excess puts
-114     }
-115 
-116     if (--core.useCount <= 0) {                    // Release shared core if use count now zero
-117 
-118         var cores = this._cores[core.type];
-119 
-120         cores[core.coreId] = null;
-121 
-122         this._stateMap.removeItem(core.stateId);  // Release state ID for reuse
-123     }
-124 };
-125 
-126 /**
-127  * Reallocates WebGL resources for cores within this factory
-128  */
-129 SceneJS_CoreFactory.prototype.webglRestored = function () {
-130 
-131     var cores;
-132     var core;
-133 
-134     for (var type in this._cores) {
-135         if (this._cores.hasOwnProperty(type)) {
-136 
-137             cores = this._cores[type];
-138 
-139             if (cores) {
-140 
-141                 for (var coreId in cores) {
-142                     if (cores.hasOwnProperty(coreId)) {
-143 
-144                         core = cores[coreId];
-145 
-146                         if (core.webglRestored) { // Method augmented on core by user
-147                             core.webglRestored();
-148                         }
-149                     }
-150                 }
-151             }
-152         }
-153     }
-154 };
-155 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_flags.js.html b/docs/symbols/src/src_core_scene_flags.js.html deleted file mode 100644 index 05a1dbc3..00000000 --- a/docs/symbols/src/src_core_scene_flags.js.html +++ /dev/null @@ -1,287 +0,0 @@ -
  1 (function() {
-  2 
-  3     /**
-  4      * The default state core singleton for {@link SceneJS.Flags} nodes
-  5      */
-  6     var defaultCore = {
-  7 
-  8         stateId: SceneJS._baseStateId++,
-  9         type: "flags",
- 10 
- 11         picking : true,             // Picking enabled
- 12         clipping : true,            // User-defined clipping enabled
- 13         enabled : true,             // Node not culled from traversal
- 14         transparent: false,         // Node transparent - works in conjunction with matarial alpha properties
- 15         backfaces: true,            // Show backfaces
- 16         frontface: "ccw",           // Default vertex winding for front face
- 17         backfaceLighting: true,     // Shading enabled for backfaces
- 18         backfaceTexturing: true,    // Texturing enabled for backfaces
- 19         specular: true,             // Specular lighting enabled
- 20         ambient: true               // Ambient lighting enabled
- 21     };
- 22 
- 23     var coreStack = [];
- 24     var stackLen = 0;
- 25 
- 26     SceneJS_events.addListener(
- 27             SceneJS_events.SCENE_COMPILING,
- 28             function(params) {
- 29                 params.engine.display.flags = defaultCore;
- 30                 stackLen = 0;
- 31             });
- 32 
- 33     /**
- 34      * @class Scene graph node which sets rendering mode flags for its subgraph
- 35      * @extends SceneJS.Node
- 36      */
- 37     SceneJS.Flags = SceneJS_NodeFactory.createNodeType("flags");
- 38 
- 39     SceneJS.Flags.prototype._init = function(params) {
- 40 
- 41         if (this._core.useCount == 1) {         // This node is first to reference the state core, so sets it up
- 42 
- 43             this._core.picking = true;           // Picking enabled
- 44             this._core.clipping = true;          // User-defined clipping enabled
- 45             this._core.enabled = true;           // Node not culled from traversal
- 46             this._core.transparent = false;      // Node transparent - works in conjunction with matarial alpha properties
- 47             this._core.backfaces = true;         // Show backfaces
- 48             this._core.frontface = "ccw";        // Default vertex winding for front face
- 49             this._core.backfaceLighting = true;  // Shading enabled for backfaces
- 50             this._core.backfaceTexturing = true; // Texturing enabled for backfaces
- 51             this._core.specular = true;          // Specular lighting enabled by default
- 52             this._core.ambient = true;           // Ambient lighting enabled by default
- 53 
- 54             if (params.flags) {                 // 'flags' property is actually optional in the node definition
- 55                 this.setFlags(params.flags);
- 56             }
- 57         }
- 58     };
- 59 
- 60     SceneJS.Flags.prototype.setFlags = function(flags) {
- 61 
- 62         var core = this._core;
- 63 
- 64         if (flags.picking != undefined) {
- 65             core.picking = !!flags.picking;
- 66             this._engine.display.drawListDirty = true;
- 67         }
- 68 
- 69         if (flags.clipping != undefined) {
- 70             core.clipping = !!flags.clipping;
- 71             this._engine.display.imageDirty = true;
- 72         }
- 73 
- 74         if (flags.enabled != undefined) {
- 75             core.enabled = !!flags.enabled;
- 76             this._engine.display.drawListDirty = true;
- 77         }
- 78 
- 79         if (flags.transparent != undefined) {
- 80             core.transparent = !!flags.transparent;
- 81             this._engine.display.drawListDirty = true;
- 82         }
- 83 
- 84         if (flags.backfaces != undefined) {
- 85             core.backfaces = !!flags.backfaces;
- 86             this._engine.display.imageDirty = true;
- 87         }
- 88 
- 89         if (flags.frontface != undefined) {
- 90             core.frontface = !!flags.frontface;
- 91             this._engine.display.imageDirty = true;
- 92         }
- 93 
- 94         if (flags.backfaceLighting != undefined) {
- 95             core.backfaceLighting = !!flags.backfaceLighting;
- 96             this._engine.display.imageDirty = true;
- 97         }
- 98 
- 99         if (flags.backfaceTexturing != undefined) {
-100             core.backfaceTexturing = !!flags.backfaceTexturing;
-101             this._engine.display.imageDirty = true;
-102         }
-103 
-104         if (flags.specular != undefined) {
-105             core.specular = !!flags.specular;
-106             this._engine.display.imageDirty = true;
-107         }
-108 
-109         if (flags.ambient != undefined) {
-110             core.ambient = !!flags.ambient;
-111             this._engine.display.imageDirty = true;
-112         }
-113 
-114         return this;
-115     };
-116 
-117     SceneJS.Flags.prototype.addFlags = function(flags) {
-118         return this.setFlags(flags);
-119         //        var core = this._core;
-120         //        if (flags.picking != undefined) core.picking = flags.picking;
-121         //        if (flags.clipping != undefined) core.clipping = flags.clipping;
-122         //        if (flags.enabled != undefined) core.enabled = flags.enabled;
-123         //        if (flags.transparent != undefined) core.transparent = flags.transparent;
-124         //        if (flags.backfaces != undefined) core.backfaces = flags.backfaces;
-125         //        if (flags.frontface != undefined) core.frontface = flags.frontface;
-126         //        if (flags.backfaceLighting != undefined) core.backfaceLighting = flags.backfaceLighting;
-127         //        if (flags.backfaceTexturing != undefined) core.backfaceTexturing = flags.backfaceTexturing;
-128         //        return this;
-129     };
-130 
-131     SceneJS.Flags.prototype.getFlags = function() {
-132         var core = this._core;
-133         return {
-134             picking : core.picking,
-135             clipping : core.clipping,
-136             enabled : core.enabled,
-137             transparent: core.transparent,
-138             backfaces: core.backfaces,
-139             frontface: core.frontface,
-140             specular: core.specular,
-141             ambient: core.ambient
-142         };
-143     };
-144 
-145     SceneJS.Flags.prototype.setPicking = function(picking) {
-146         picking = !!picking;
-147         if (this._core.picking != picking) {
-148             this._core.picking = picking;
-149             this._engine.display.drawListDirty = true;
-150         }
-151         return this;
-152     };
-153 
-154     SceneJS.Flags.prototype.getPicking = function() {
-155         return this._core.picking;
-156     };
-157 
-158     SceneJS.Flags.prototype.setClipping = function(clipping) {
-159         clipping = !!clipping;
-160         if (this._core.clipping != clipping) {
-161             this._core.clipping = clipping;
-162             this._engine.display.imageDirty = true;
-163         }
-164         return this;
-165     };
-166 
-167     SceneJS.Flags.prototype.getClipping = function() {
-168         return this._core.clipping;
-169     };
-170 
-171     SceneJS.Flags.prototype.setEnabled = function(enabled) {
-172         enabled = !!enabled;
-173         if (this._core.enabled != enabled) {
-174             this._core.enabled = enabled;
-175             this._engine.display.drawListDirty = true;
-176         }
-177         return this;
-178     };
-179 
-180     SceneJS.Flags.prototype.getEnabled = function() {
-181         return this._core.enabled;
-182     };
-183 
-184     SceneJS.Flags.prototype.setTransparent = function(transparent) {
-185         transparent = !!transparent;
-186         if (this._core.transparent != transparent) {
-187             this._core.transparent = transparent;
-188             this._engine.display.drawListDirty = true;
-189         }
-190         return this;
-191     };
-192 
-193     SceneJS.Flags.prototype.getTransparent = function() {
-194         return this._core.transparent;
-195     };
-196 
-197     SceneJS.Flags.prototype.setBackfaces = function(backfaces) {
-198         backfaces = !!backfaces;
-199         if (this._core.backfaces != backfaces) {
-200             this._core.backfaces = backfaces;
-201             this._engine.display.imageDirty = true;
-202         }
-203         return this;
-204     };
-205 
-206     SceneJS.Flags.prototype.getBackfaces = function() {
-207         return this._core.backfaces;
-208     };
-209 
-210     SceneJS.Flags.prototype.setFrontface = function(frontface) {
-211         if (this._core.frontface != frontface) {
-212             this._core.frontface = frontface;
-213             this._engine.display.imageDirty = true;
-214         }
-215         return this;
-216     };
-217 
-218     SceneJS.Flags.prototype.getFrontface = function() {
-219         return this._core.frontface;
-220     };
-221 
-222     SceneJS.Flags.prototype.setBackfaceLighting = function(backfaceLighting) {
-223         backfaceLighting = !!backfaceLighting;
-224         if (this._core.backfaceLighting != backfaceLighting) {
-225             this._core.backfaceLighting = backfaceLighting;
-226             this._engine.display.imageDirty = true;
-227         }
-228         return this;
-229     };
-230 
-231     SceneJS.Flags.prototype.getBackfaceLighting = function() {
-232         return this._core.backfaceLighting;
-233     };
-234 
-235     SceneJS.Flags.prototype.setBackfaceTexturing = function(backfaceTexturing) {
-236         backfaceTexturing = !!backfaceTexturing;
-237         if (this._core.backfaceTexturing != backfaceTexturing) {
-238             this._core.backfaceTexturing = backfaceTexturing;
-239             this._engine.display.imageDirty = true;
-240         }
-241         return this;
-242     };
-243 
-244     SceneJS.Flags.prototype.getBackfaceTexturing = function() {
-245         return this._core.backfaceTexturing;
-246     };
-247 
-248     SceneJS.Flags.prototype.setAmbient = function(ambient) {
-249         ambient = !!ambient;
-250         if (this._core.ambient != ambient) {
-251             this._core.ambient = ambient;
-252             this._engine.display.imageDirty = true;
-253         }
-254         return this;
-255     };
-256 
-257     SceneJS.Flags.prototype.getAmbient = function() {
-258         return this._core.ambient;
-259     };
-260 
-261     SceneJS.Flags.prototype.setAmbient = function(ambient) {
-262         ambient = !!ambient;
-263         if (this._core.ambient != ambient) {
-264             this._core.ambient = ambient;
-265             this._engine.display.imageDirty = true;
-266         }
-267         return this;
-268     };
-269 
-270     SceneJS.Flags.prototype.getAmbient = function() {
-271         return this._core.ambient;
-272     };
-273 
-274     SceneJS.Flags.prototype._compile = function() {
-275         this._engine.display.flags = coreStack[stackLen++] = this._core;
-276         this._compileNodes();
-277         this._engine.display.flags = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore;
-278     };
-279 
-280 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_framebuf.js.html b/docs/symbols/src/src_core_scene_framebuf.js.html deleted file mode 100644 index 65b92f00..00000000 --- a/docs/symbols/src/src_core_scene_framebuf.js.html +++ /dev/null @@ -1,208 +0,0 @@ -
  1 new (function() {
-  2 
-  3     /**
-  4      * The default state core singleton for {@link SceneJS.Framebuf} nodes
-  5      */
-  6     var defaultCore = {
-  7 
-  8         type: "framebuf",
-  9         stateId: SceneJS._baseStateId++,
- 10         empty: true,
- 11 
- 12         framebuf: null
- 13     };
- 14 
- 15     var nodeCoreMap = {}; // Map of framebuf nodes to cores, for reallocation on WebGL context restore
- 16 
- 17     var coreStack = [];
- 18     var stackLen = 0;
- 19 
- 20     SceneJS_events.addListener(
- 21             SceneJS_events.SCENE_COMPILING,
- 22             function(params) {
- 23                 params.engine.display.framebuf = defaultCore;
- 24                 stackLen = 0;
- 25             });
- 26 
- 27     SceneJS_events.addListener(// Reallocate VBOs when context restored after loss
- 28             SceneJS_events.WEBGL_CONTEXT_RESTORED,
- 29             function() {
- 30 
- 31                 var node;
- 32 
- 33                 for (var nodeId in nodeCoreMap) {
- 34                     if (nodeCoreMap.hasOwnProperty(nodeId)) {
- 35 
- 36                         node = nodeCoreMap[nodeId];
- 37 
- 38                         if (!node._core._loading) {
- 39                             node._buildNodeCore();
- 40                         }
- 41                     }
- 42                 }
- 43             });
- 44 
- 45     SceneJS_events.addListener(
- 46             SceneJS_events.SCENE_DESTROYED,
- 47             function(params) {
- 48                 //     sceneBufs[params.sceneId] = null;
- 49             });
- 50 
- 51     /**
- 52      * @class Scene graph node which sets up a frame buffer to which the {@link SceneJS.Geometry} nodes in its subgraph will be rendered.
- 53      * The frame buffer may be referenced as an image source by successive {@link SceneJS.Texture} nodes.
- 54      * @extends SceneJS.Node
- 55      */
- 56     SceneJS.Framebuf = SceneJS_NodeFactory.createNodeType("framebuf");
- 57 
- 58     SceneJS.Framebuf.prototype._init = function() {
- 59 
- 60         nodeCoreMap[this._core.coreId] = this; // Register for core rebuild on WEBGL_CONTEXT_RESTORED
- 61 
- 62         this._buildNodeCore();
- 63     };
- 64 
- 65     SceneJS.Framebuf.prototype._buildNodeCore = function() {
- 66 
- 67         var canvas = this._engine.canvas;
- 68         var gl = canvas.gl;
- 69         var width = canvas.canvas.width;
- 70         var height = canvas.canvas.height;
- 71 
- 72         var framebuf = gl.createFramebuffer();
- 73         var renderbuf = gl.createRenderbuffer();
- 74         var texture = gl.createTexture() ;
- 75 
- 76         var rendered = false;
- 77 
- 78         if (!this._core) {
- 79             this._core = {};
- 80         }
- 81 
- 82         gl.bindFramebuffer(gl.FRAMEBUFFER, framebuf);
- 83 
- 84         gl.bindTexture(gl.TEXTURE_2D, texture);
- 85         gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
- 86         gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
- 87         gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
- 88         gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
- 89 
- 90         try {
- 91             // Do it the way the spec requires
- 92             gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
- 93         } catch (exception) {
- 94             // Workaround for what appears to be a Minefield bug.
- 95             var textureStorage = new WebGLUnsignedByteArray(width * height * 4);
- 96             gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, textureStorage);
- 97         }
- 98         gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuf);
- 99         gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
-100         gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
-101         gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, renderbuf);
-102         gl.bindTexture(gl.TEXTURE_2D, null);
-103         gl.bindRenderbuffer(gl.RENDERBUFFER, null);
-104         gl.bindFramebuffer(gl.FRAMEBUFFER, null);
-105 
-106         /* Verify framebuffer is OK
-107          */
-108         gl.bindFramebuffer(gl.FRAMEBUFFER, framebuf);
-109 
-110         if (!gl.isFramebuffer(framebuf)) {
-111             throw SceneJS_error.fatalError("Invalid framebuffer");
-112         }
-113 
-114         var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
-115 
-116         gl.bindRenderbuffer(gl.RENDERBUFFER, null);
-117         gl.bindFramebuffer(gl.FRAMEBUFFER, null);
-118 
-119         switch (status) {
-120             case gl.FRAMEBUFFER_COMPLETE:
-121                 break;
-122             case gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
-123                 throw SceneJS_error.fatalError("Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
-124             case gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
-125                 throw SceneJS_error.fatalError("Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");
-126             case gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
-127                 throw SceneJS_error.fatalError("Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
-128             case gl.FRAMEBUFFER_UNSUPPORTED:
-129                 throw SceneJS_error.fatalError("Incomplete framebuffer: FRAMEBUFFER_UNSUPPORTED");
-130             default:
-131                 throw SceneJS_error.fatalError("Incomplete framebuffer: " + status);
-132         }
-133 
-134         this._core.framebuf = {
-135 
-136             id: this.id, // TODO: maybe unused?
-137 
-138             /** Binds the image buffer as target for subsequent geometry renders
-139              */
-140             bind: function() {
-141              //   gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuf);
-142                 gl.bindFramebuffer(gl.FRAMEBUFFER, framebuf);
-143                 gl.clearColor(0.0, 0.0, 0.0, 1.0);
-144                 gl.clearDepth(1.0);
-145                 gl.enable(gl.DEPTH_TEST);
-146                 gl.disable(gl.CULL_FACE);
-147                 gl.depthRange(0, 1);
-148                 gl.disable(gl.SCISSOR_TEST);
-149                 //  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
-150                 gl.disable(gl.BLEND);
-151             },
-152 
-153             /** Unbinds image buffer, the default buffer then becomes the rendering target
-154              */
-155             unbind:function() {
-156                 gl.bindFramebuffer(gl.FRAMEBUFFER, null);
-157                // gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
-158                 gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuf);
-159                 rendered = true;
-160             },
-161 
-162             /** Returns true if this texture has been rendered
-163              */
-164             isRendered: function() {
-165                 return rendered;
-166             },
-167 
-168             /** Gets the texture from this image buffer
-169              */
-170             getTexture: function() {
-171 
-172                 return {
-173 
-174                     bind: function(unit) {
-175                         gl.activeTexture(gl["TEXTURE" + unit]);
-176                         gl.bindTexture(gl.TEXTURE_2D, texture);
-177                     },
-178 
-179                     unbind : function(unit) {
-180                         gl.activeTexture(gl["TEXTURE" + unit]);
-181                         gl.bindTexture(gl.TEXTURE_2D, null);
-182                     }
-183                 };
-184             }
-185         };
-186     };
-187 
-188     SceneJS.Framebuf.prototype._compile = function() {
-189         this._engine.display.framebuf = coreStack[stackLen++] = this._core;
-190         this._compileNodes();
-191         this._engine.display.framebuf = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore;
-192     };
-193 
-194     SceneJS.Framebuf.prototype._destroy = function() {
-195         if (this._core) {
-196             //destroyFrameBuffer(this._buf);
-197         }
-198     };
-199 
-200 
-201 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_geometry.js.html b/docs/symbols/src/src_core_scene_geometry.js.html deleted file mode 100644 index 8d70c7de..00000000 --- a/docs/symbols/src/src_core_scene_geometry.js.html +++ /dev/null @@ -1,695 +0,0 @@ -
  1 new (function () {
-  2 
-  3     var coreStack = [];
-  4     var stackLen = 0;
-  5 
-  6     SceneJS_events.addListener(
-  7         SceneJS_events.SCENE_COMPILING,
-  8         function () {
-  9             stackLen = 0;
- 10         });
- 11 
- 12     /**
- 13      * @class Scene graph node that defines geometry.
- 14      * @extends SceneJS.Node
- 15      * When this node is at a leaf, it defines a scene object which inherits the state set up by all the nodes above it
- 16      * on the path up to the root. These nodes can be nested, so that child geometries inherit arrays
- 17      * defined by parent geometries.
- 18      */
- 19     SceneJS.Geometry = SceneJS_NodeFactory.createNodeType("geometry");
- 20 
- 21     SceneJS.Geometry.prototype._init = function (params) {
- 22 
- 23         if (this._core.useCount == 1) { // This node defines the core
- 24 
- 25             var options = {
- 26                 origin:params.origin,
- 27                 scale:params.scale
- 28             };
- 29 
- 30             var self = this;
- 31 
- 32             this._sourceConfigs = null;
- 33             this._source = null;
- 34 
- 35             if (params.plugin) {
- 36                 this._sourceConfigs = SceneJS._apply({ type:params.plugin }, params);
- 37             } else if (params.source) {
- 38                 this._sourceConfigs = params.source;
- 39             }
- 40 
- 41             if (this._sourceConfigs) {
- 42 
- 43                 /*---------------------------------------------------------------------------------------------------
- 44                  * Build node core (possibly asynchronously) using a factory object
- 45                  *--------------------------------------------------------------------------------------------------*/
- 46 
- 47                 if (!this._sourceConfigs.type) {
- 48                     throw SceneJS_error.fatalError(
- 49                         SceneJS.errors.ILLEGAL_NODE_CONFIG,
- 50                         "geometry config expected: source.type");
- 51                 }
- 52 
- 53                 SceneJS.Plugins.getPlugin(
- 54                     "geometry",
- 55                     this._sourceConfigs.type,
- 56                     function (plugin) {
- 57 
- 58                         if (!plugin.getSource) {
- 59                             throw SceneJS_error.fatalError(
- 60                                 SceneJS.errors.PLUGIN_INVALID,
- 61                                 "geometry: 'getSource' method missing on plugin for geometry source type '" + this._sourceConfigs.type + "'.");
- 62                         }
- 63 
- 64                         self._source = plugin.getSource();
- 65 
- 66                         if (!self._source.onUpdate) {
- 67                             throw SceneJS_error.fatalError(
- 68                                 SceneJS.errors.PLUGIN_INVALID,
- 69                                 "geometry: 'onUpdate' method missing on plugin for geometry source type '" + this._sourceConfigs.type + "'");
- 70                         }
- 71 
- 72                         self._source.onCreate(// Get notification when source creates the geometry
- 73                             function (data) { // Data contains both typed arrays and primitive name
- 74 
- 75                                 if (options) { // HACK - should apply this on GPU
- 76                                     data.positions = data.positions
- 77                                         ? new Float32Array((options.scale || options.origin)
- 78                                         ? self._applyOptions(data.positions, options)
- 79                                         : data.positions) : undefined;
- 80                                 }
- 81 
- 82                                 self._initNodeCore(data);
- 83 
- 84                                 SceneJS.Geometry._buildNodeCore(self._engine.canvas.gl, self._core);
- 85 
- 86                                 self._core._loading = false;
- 87                                 self._fireEvent("loaded");
- 88 
- 89                                 self._engine.display.imageDirty = true;
- 90 
- 91                                 self._engine.branchDirty(self); // TODO
- 92                             });
- 93 
- 94                         if (self._source.onUpdate) {
- 95                             self._source.onUpdate(// Reload core arrays from factory updates to the geometry
- 96                                 function (data) {
- 97 
- 98                                     var core = self._core;
- 99 
-100                                     if (data.positions && core.vertexBuf) {
-101 
-102 //                                    if (data.positions.length > core.vertexBuf.length) {
-103 //                                        alert("too long");
-104 //                                    }
-105 
-106                                         core.vertexBuf.bind();
-107                                         core.vertexBuf.setData(data.positions, data.positionsOffset || 0);
-108 
-109                                         if (data.positions.length > core.arrays.positions.length) {
-110                                             core.arrays.positions = data.positions;
-111 
-112                                         } else {
-113                                             core.arrays.positions.set(data.positions, data.positionsOffset || 0);
-114                                         }
-115                                     }
-116 
-117                                     if (data.normals && core.normalBuf) {
-118 
-119                                         core.normalBuf.bind();
-120                                         core.normalBuf.setData(data.normals, data.normalsOffset || 0);
-121 
-122                                         if (data.normals.length > core.arrays.normals.length) {
-123                                             core.arrays.normals = data.normals;
-124 
-125                                         } else {
-126                                             core.arrays.normals.set(data.normals, data.normalsOffset || 0);
-127                                         }
-128                                     }
-129 
-130                                     if (data.uv && core.uvBuf) {
-131 
-132                                         core.uvBuf.bind();
-133                                         core.uvBuf.setData(data.uv, data.uvOffset || 0);
-134 
-135                                         if (data.uv.length > core.arrays.uv.length) {
-136                                             core.arrays.uv = data.uv;
-137 
-138                                         } else {
-139                                             core.arrays.uv.set(data.uv, data.uvOffset || 0);
-140                                         }
-141                                     }
-142 
-143                                     if (data.uv2 && core.uvBuf2) {
-144 
-145                                         core.uvBuf2.bind();
-146                                         core.uvBuf2.setData(data.uv2, data.uv2Offset || 0);
-147 
-148                                         if (data.uv2.length > core.arrays.uv2.length) {
-149                                             core.arrays.uv2 = data.uv2;
-150 
-151                                         } else {
-152                                             core.arrays.uv2.set(data.uv2, data.uv2Offset || 0);
-153                                         }
-154                                     }
-155 
-156                                     if (data.colors && core.colorBuf) {
-157 
-158                                         if (data.colors.length > core.arrays.colors.length) {
-159                                             core.arrays.colors = data.colors;
-160 
-161                                         } else {
-162                                             core.arrays.colors.set(data.colors, data.colorsOffset || 0);
-163                                         }
-164 
-165                                         core.colorBuf.bind();
-166                                         core.colorBuf.setData(data.colors, data.colorsOffset || 0);
-167                                     }
-168 
-169                                     if (data.indices && core.indexBuf) {
-170 
-171                                         if (data.indices.length > core.arrays.indices.length) {
-172                                             core.arrays.indices = data.indices;
-173 
-174                                         } else {
-175                                             core.arrays.indices.set(data.indices, data.indicesOffset || 0);
-176                                         }
-177 
-178                                         core.indexBuf.bind();
-179                                         core.indexBuf.setData(data.indices, data.indicesOffset || 0);
-180 
-181                                         for (var i = 0; i < data.indices.length; i++) {
-182                                             var idx = data.indices[i];
-183                                             if (idx < 0 || idx >= core.arrays.positions.length) {
-184                                                 alert("out of range ");
-185                                             }
-186                                             if (core.arrays.normals && (idx < 0 || idx >= core.arrays.normals.length)) {
-187                                                 alert("out of range ");
-188                                             }
-189                                             if (core.arrays.uv && (idx < 0 || idx >= core.arrays.uv.length)) {
-190                                                 alert("out of range ");
-191                                             }
-192                                             if (core.arrays.uv2 && (idx < 0 || idx >= core.arrays.uv2.length)) {
-193                                                 alert("out of range ");
-194                                             }
-195                                             if (core.arrays.colors && (idx < 0 || idx >= core.arrays.colors.length)) {
-196                                                 alert("out of range ");
-197                                             }
-198                                         }
-199                                     }
-200 
-201                                     self._engine.display.imageDirty = true;
-202                                 });
-203                         }
-204 
-205                         self._core._loading = true;
-206 
-207                         self._fireEvent("loading");
-208 
-209                         self._source.setConfigs(self._sourceConfigs);
-210                     });
-211 
-212             } else {
-213 
-214                 // Build node core from JSON arrays and primitive name given in node properties
-215 
-216                 this._initNodeCore(params, options);
-217 
-218                 SceneJS.Geometry._buildNodeCore(this._engine.canvas.gl, this._core);
-219             }
-220 
-221             this._core.webglRestored = function () {
-222                 SceneJS.Geometry._buildNodeCore(self._engine.canvas.gl, self._core);
-223             };
-224 
-225         }
-226     };
-227 
-228     /**
-229      * Convert JSON arrays into typed arrays,
-230      * apply optional baked Model-space transforms to positions
-231      */
-232     SceneJS.Geometry.prototype._initNodeCore = function (data, options) {
-233 
-234         options = options || {};
-235 
-236         this._core.primitive = this._getPrimitiveType(data.primitive || "triangles");
-237 
-238         this._core.arrays = {
-239             positions:data.positions
-240                 ? new Float32Array((options.scale || options.origin)
-241                 ? this._applyOptions(data.positions, options)
-242                 : data.positions) : undefined,
-243 
-244             normals:data.normals ? new Float32Array(data.normals) : undefined,
-245             uv:data.uv ? new Float32Array(data.uv) : undefined,
-246             uv2:data.uv2 ? new Float32Array(data.uv2) : undefined,
-247             colors:data.colors ? new Float32Array(data.colors) : undefined,
-248             indices:data.indices ? new Uint16Array(data.indices) : undefined
-249         };
-250     };
-251 
-252     /**
-253      * Returns WebGL constant for primitive name
-254      */
-255     SceneJS.Geometry.prototype._getPrimitiveType = function (primitive) {
-256 
-257         var gl = this._engine.canvas.gl;
-258 
-259         switch (primitive) {
-260 
-261             case "points":
-262                 return gl.POINTS;
-263 
-264             case "lines":
-265                 return gl.LINES;
-266 
-267             case "line-loop":
-268                 return gl.LINE_LOOP;
-269 
-270             case "line-strip":
-271                 return gl.LINE_STRIP;
-272 
-273             case "triangles":
-274                 return gl.TRIANGLES;
-275 
-276             case "triangle-strip":
-277                 return gl.TRIANGLE_STRIP;
-278 
-279             case "triangle-fan":
-280                 return gl.TRIANGLE_FAN;
-281 
-282             default:
-283                 throw SceneJS_error.fatalError(
-284                     SceneJS.errors.ILLEGAL_NODE_CONFIG,
-285                     "geometry primitive unsupported: '" +
-286                         primitive +
-287                         "' - supported types are: 'points', 'lines', 'line-loop', " +
-288                         "'line-strip', 'triangles', 'triangle-strip' and 'triangle-fan'");
-289         }
-290     };
-291 
-292     /**
-293      * Apply baked Model-space transformations to give position array
-294      */
-295     SceneJS.Geometry.prototype._applyOptions = function (positions, options) {
-296 
-297         var positions2 = positions.slice ? positions.slice(0) : new Float32Array(positions);  // HACK
-298 
-299         if (options.scale) {
-300 
-301             var scaleX = options.scale.x != undefined ? options.scale.x : 1.0;
-302             var scaleY = options.scale.y != undefined ? options.scale.y : 1.0;
-303             var scaleZ = options.scale.z != undefined ? options.scale.z : 1.0;
-304 
-305             for (var i = 0, len = positions2.length; i < len; i += 3) {
-306                 positions2[i    ] *= scaleX;
-307                 positions2[i + 1] *= scaleY;
-308                 positions2[i + 2] *= scaleZ;
-309             }
-310         }
-311 
-312         if (options.origin) {
-313 
-314             var originX = options.origin.x != undefined ? options.origin.x : 0.0;
-315             var originY = options.origin.y != undefined ? options.origin.y : 0.0;
-316             var originZ = options.origin.z != undefined ? options.origin.z : 0.0;
-317 
-318             for (var i = 0, len = positions2.length; i < len; i += 3) {
-319                 positions2[i    ] -= originX;
-320                 positions2[i + 1] -= originY;
-321                 positions2[i + 2] -= originZ;
-322             }
-323         }
-324 
-325         return positions2;
-326     };
-327 
-328     /**
-329      * Allocates WebGL buffers for geometry arrays
-330      *
-331      * In addition to initially allocating those, this is called to reallocate them after
-332      * WebGL context is regained after being lost.
-333      */
-334     SceneJS.Geometry._buildNodeCore = function (gl, core) {
-335 
-336         var usage = gl.STATIC_DRAW; //var usage = (!arrays.fixed) ? gl.STREAM_DRAW : gl.STATIC_DRAW;
-337 
-338         try { // TODO: Modify usage flags in accordance with how often geometry is evicted
-339 
-340             var arrays = core.arrays;
-341 
-342             if (arrays.positions) {
-343                 core.vertexBuf = new SceneJS_webgl_ArrayBuffer(gl, gl.ARRAY_BUFFER, arrays.positions, arrays.positions.length, 3, usage);
-344             }
-345 
-346             if (arrays.normals) {
-347                 core.normalBuf = new SceneJS_webgl_ArrayBuffer(gl, gl.ARRAY_BUFFER, arrays.normals, arrays.normals.length, 3, usage);
-348             }
-349 
-350             if (arrays.uv) {
-351                 core.uvBuf = new SceneJS_webgl_ArrayBuffer(gl, gl.ARRAY_BUFFER, arrays.uv, arrays.uv.length, 2, usage);
-352             }
-353 
-354             if (arrays.uv2) {
-355                 core.uvBuf2 = new SceneJS_webgl_ArrayBuffer(gl, gl.ARRAY_BUFFER, arrays.uv2, arrays.uv2.length, 2, usage);
-356             }
-357 
-358             if (arrays.colors) {
-359                 core.colorBuf = new SceneJS_webgl_ArrayBuffer(gl, gl.ARRAY_BUFFER, arrays.colors, arrays.colors.length, 4, usage);
-360             }
-361 
-362             if (arrays.indices) {
-363                 core.indexBuf = new SceneJS_webgl_ArrayBuffer(gl, gl.ELEMENT_ARRAY_BUFFER, arrays.indices, arrays.indices.length, 1, usage);
-364             }
-365 
-366         } catch (e) { // Allocation failure - delete whatever buffers got allocated
-367 
-368             if (core.vertexBuf) {
-369                 core.vertexBuf.destroy();
-370                 core.vertexBuf = null;
-371             }
-372 
-373             if (core.normalBuf) {
-374                 core.normalBuf.destroy();
-375                 core.normalBuf = null;
-376             }
-377 
-378             if (core.uvBuf) {
-379                 core.uvBuf.destroy();
-380                 core.uvBuf = null;
-381             }
-382 
-383             if (core.uvBuf2) {
-384                 core.uvBuf2.destroy();
-385                 core.uvBuf2 = null;
-386             }
-387 
-388             if (core.colorBuf) {
-389                 core.colorBuf.destroy();
-390                 core.colorBuf = null;
-391             }
-392 
-393             if (core.indexBuf) {
-394                 core.indexBuf.destroy();
-395                 core.indexBuf = null;
-396             }
-397 
-398             throw SceneJS_error.fatalError(
-399                 SceneJS.errors.ERROR,
-400                 "Failed to allocate geometry: " + e);
-401         }
-402     };
-403 
-404     SceneJS.Geometry.prototype._updateArray = function (array, items, offset) {
-405 
-406         var arrayLen = array.length;
-407         var itemsLen = items.length;
-408 
-409         if (itemsLen + offset > arrayLen) {
-410             itemsLen -= (itemsLen + offset) - arrayLen;
-411         }
-412 
-413         for (var i = offset, j = 0; j < itemsLen; i++, j++) {
-414             array[i] = items[j];
-415         }
-416 
-417     };
-418 
-419     SceneJS.Geometry.prototype.setSource = function (sourceConfigs) {
-420         this._sourceConfigs = sourceConfigs;
-421         var source = this._source;
-422         if (source) {
-423             source.setConfigs(sourceConfigs);
-424         }
-425     };
-426 
-427     SceneJS.Geometry.prototype.getSource = function () {
-428         return this._sourceConfigs || {};
-429     };
-430 
-431     SceneJS.Geometry.prototype.setPositions = function (data) {
-432         if (data.positions && this._core.vertexBuf) {
-433             var core = this._core;
-434             core.vertexBuf.bind();
-435             core.vertexBuf.setData(new Float32Array(data.positions), data.positionsOffset || 0);
-436             core.arrays.positions.set(data.positions, data.positionsOffset || 0);
-437             this._engine.display.imageDirty = true;
-438         }
-439     };
-440 
-441     SceneJS.Geometry.prototype.getPositions = function () {
-442         return this._core.arrays ? this._core.arrays.positions : null;
-443     };
-444 
-445     SceneJS.Geometry.prototype.setNormals = function (data) {
-446         if (data.normals && this._core.normalBuf) {
-447             var core = this._core;
-448             core.normalBuf.bind();
-449             core.normalBuf.setData(new Float32Array(data.normals), data.normalsOffset || 0);
-450             core.arrays.normals.set(data.normals, data.normalsOffset || 0);
-451             this._engine.display.imageDirty = true;
-452         }
-453     };
-454 
-455     SceneJS.Geometry.prototype.getNormals = function () {
-456         return this._core.arrays ? this._core.arrays.normals : null;
-457     };
-458 
-459     SceneJS.Geometry.prototype.setColors = function (data) {
-460         if (data.colors && this._core.colorBuf) {
-461             var core = this._core;
-462             core.colorBuf.bind();
-463             core.colorBuf.setData(new Float32Array(data.colors), data.colorsOffset || 0);
-464             core.arrays.colors.set(data.colors, data.colorsOffset || 0);
-465             this._engine.display.imageDirty = true;
-466         }
-467     };
-468 
-469     SceneJS.Geometry.prototype.getColors = function () {
-470         return this._core.arrays ? this._core.arrays.colors : null;
-471     };
-472 
-473     SceneJS.Geometry.prototype.getIndices = function () {
-474         return this._core.arrays ? this._core.arrays.indices : null;
-475     };
-476 
-477     SceneJS.Geometry.prototype.setUV = function (data) {
-478         if (data.uv && this._core.colorBuf) {
-479             var core = this._core;
-480             core.colorBuf.bind();
-481             core.colorBuf.setData(new Float32Array(data.uv), data.uvOffset || 0);
-482             core.arrays.uv.set(data.uv, data.uvOffset || 0);
-483             this._engine.display.imageDirty = true;
-484         }
-485     };
-486 
-487     SceneJS.Geometry.prototype.getUV = function () {
-488         return this._core.arrays ? this._core.arrays.uv : null;
-489     };
-490 
-491     SceneJS.Geometry.prototype.setUV2 = function (data) {
-492         if (data.uv2 && this._core.colorBuf) {
-493             var core = this._core;
-494             core.colorBuf.bind();
-495             core.colorBuf.setData(new Float32Array(data.uv2), data.uv2Offset || 0);
-496             core.arrays.uv2.set(data.uv2, data.uv2Offset || 0);
-497             this._engine.display.imageDirty = true;
-498         }
-499     };
-500 
-501     SceneJS.Geometry.prototype.getUV2 = function () {
-502         return this._core.arrays ? this._core.arrays.uv2 : null;
-503     };
-504 
-505     SceneJS.Geometry.prototype.getPrimitive = function () {
-506         return this.primitive;
-507     };
-508 
-509     SceneJS.Geometry.prototype.getBoundary = function () {
-510         if (this._boundary) {
-511             return this._boundary;
-512         }
-513 
-514         var arrays = this._core.arrays;
-515 
-516         if (!arrays) {
-517             return null;
-518         }
-519 
-520         var positions = arrays.positions;
-521 
-522         if (!positions) {
-523             return null;
-524         }
-525 
-526         this._boundary = {
-527             xmin:SceneJS_math_MAX_DOUBLE,
-528             ymin:SceneJS_math_MAX_DOUBLE,
-529             zmin:SceneJS_math_MAX_DOUBLE,
-530             xmax:SceneJS_math_MIN_DOUBLE,
-531             ymax:SceneJS_math_MIN_DOUBLE,
-532             zmax:SceneJS_math_MIN_DOUBLE
-533         };
-534 
-535         var x, y, z;
-536 
-537         for (var i = 0, len = positions.length - 2; i < len; i += 3) {
-538 
-539             x = positions[i];
-540             y = positions[i + 1];
-541             z = positions[i + 2];
-542 
-543             if (x < this._boundary.xmin) {
-544                 this._boundary.xmin = x;
-545             }
-546             if (y < this._boundary.ymin) {
-547                 this._boundary.ymin = y;
-548             }
-549             if (z < this._boundary.zmin) {
-550                 this._boundary.zmin = z;
-551             }
-552             if (x > this._boundary.xmax) {
-553                 this._boundary.xmax = x;
-554             }
-555             if (y > this._boundary.ymax) {
-556                 this._boundary.ymax = y;
-557             }
-558             if (z > this._boundary.zmax) {
-559                 this._boundary.zmax = z;
-560             }
-561         }
-562 
-563         return this._boundary;
-564     };
-565 
-566     SceneJS.Geometry.prototype._compile = function () {
-567 
-568         if (this._core._loading) {
-569             this._compileNodes();
-570             return;
-571         }
-572 
-573         var core = this._core;
-574 
-575         if (!core.vertexBuf) {
-576 
-577             /* SceneJS.Geometry has no vertex buffer - it must be therefore be indexing a vertex/uv buffers defined
-578              * by a higher Geometry, as part of a composite geometry:
-579              *
-580              * It must therefore inherit the vertex buffer, along with UV coord buffers.
-581              *
-582              * We'll leave it to the render state graph traversal to ensure that the
-583              * vertex and UV buffers are not needlessly rebound for this geometry.
-584              */
-585             core = this._inheritVBOs(core);
-586         }
-587 
-588         if (core.indexBuf) { // Can only render when we have indices
-589 
-590             core.hash = ([                           // Safe to build geometry hash here - geometry is immutable
-591                 core.normalBuf ? "t" : "f",
-592                 core.uvBuf ? "t" : "f",
-593                 core.uvBuf2 ? "t" : "f",
-594                 core.colorBuf ? "t" : "f",
-595                 core.primitive
-596             ]).join("");
-597 
-598             core.stateId = this._core.stateId;
-599             core.type = "geometry";
-600 
-601             this._engine.display.geometry = coreStack[stackLen++] = core;
-602 
-603             SceneJS_events.fireEvent(SceneJS_events.OBJECT_COMPILING, { // Pull in state updates from scenes nodes
-604                 display:this._engine.display
-605             });
-606 
-607             this._engine.display.buildObject(this.id); // Use node ID since we may inherit from many cores
-608 
-609         } else {
-610             coreStack[stackLen++] = this._core;
-611         }
-612 
-613         this._compileNodes();
-614 
-615         stackLen--;
-616     };
-617 
-618     SceneJS.Geometry.prototype._inheritVBOs = function (core) {
-619 
-620         var core2 = {
-621             primitive:core.primitive,
-622             boundary:core.boundary,
-623             normalBuf:core.normalBuf,
-624             uvBuf:core.uvBuf,
-625             uvBuf2:core.uvBuf2,
-626             colorBuf:core.colorBuf,
-627             indexBuf:core.indexBuf
-628         };
-629 
-630         for (var i = stackLen - 1; i >= 0; i--) {
-631             if (coreStack[i].vertexBuf) {
-632                 core2.vertexBuf = coreStack[i].vertexBuf;
-633                 core2.boundary = coreStack[i].boundary;
-634                 core2.normalBuf = coreStack[i].normalBuf;
-635                 core2.uvBuf = coreStack[i].uvBuf;           // Vertex and UVs are a package
-636                 core2.uvBuf2 = coreStack[i].uvBuf2;
-637                 core2.colorBuf = coreStack[i].colorBuf;
-638                 return core2;
-639             }
-640         }
-641 
-642         return core2;
-643     };
-644 
-645     SceneJS.Geometry.prototype._destroy = function () {
-646 
-647         this._engine.display.removeObject(this.id);
-648 
-649         /* Destroy core if no other references
-650          */
-651         if (this._core.useCount == 1) {
-652 
-653             this._destroyNodeCore();
-654 
-655             if (this._source) {
-656                 this._source.destroy();
-657             }
-658         }
-659     };
-660 
-661     SceneJS.Geometry.prototype._destroyNodeCore = function () {
-662 
-663         if (document.getElementById(this._engine.canvas.canvasId)) { // Context won't exist if canvas has disappeared
-664 
-665             var core = this._core;
-666 
-667             if (core.vertexBuf) {
-668                 core.vertexBuf.destroy();
-669             }
-670             if (core.normalBuf) {
-671                 core.normalBuf.destroy();
-672             }
-673             if (core.uvBuf) {
-674                 core.uvBuf.destroy();
-675             }
-676             if (core.uvBuf2) {
-677                 core.uvBuf2.destroy();
-678             }
-679             if (core.colorBuf) {
-680                 core.colorBuf.destroy();
-681             }
-682             if (core.indexBuf) {
-683                 core.indexBuf.destroy();
-684             }
-685         }
-686     };
-687 
-688 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_layer.js.html b/docs/symbols/src/src_core_scene_layer.js.html deleted file mode 100644 index 91994569..00000000 --- a/docs/symbols/src/src_core_scene_layer.js.html +++ /dev/null @@ -1,75 +0,0 @@ -
  1 (function() {
-  2 
-  3     /**
-  4      * The default state core singleton for {@link SceneJS.Layer} nodes
-  5      */
-  6     var defaultCore = {
-  7         type: "layer",
-  8         stateId: SceneJS._baseStateId++,
-  9         priority: 0,
- 10         enabled: true
- 11     };
- 12 
- 13     var coreStack = [];
- 14     var stackLen = 0;
- 15 
- 16     SceneJS_events.addListener(
- 17             SceneJS_events.SCENE_COMPILING,
- 18             function(params) {
- 19                 params.engine.display.layer = defaultCore;
- 20                 stackLen = 0;
- 21             });
- 22 
- 23     /**
- 24      * @class Scene graph node which assigns the {@link SceneJS.Geometry}s within its subgraph to a prioritised render bin
- 25      * @extends SceneJS.Node
- 26      */
- 27     SceneJS.Layer = SceneJS_NodeFactory.createNodeType("layer");
- 28 
- 29     SceneJS.Layer.prototype._init = function(params) {
- 30         if (this._core.useCount == 1) { // This node defines the resource
- 31             this._core.priority = params.priority || 0;
- 32             this._core.enabled = params.enabled !== false;
- 33         }
- 34     };
- 35 
- 36     SceneJS.Layer.prototype.setPriority = function(priority) {
- 37         priority = priority || 0;
- 38         if (this._core.priority != priority) {
- 39             this._core.priority = priority;
- 40             this._engine.display.stateOrderDirty = true;
- 41         }
- 42     };
- 43 
- 44     SceneJS.Layer.prototype.getPriority = function() {
- 45         return this._core.priority;
- 46     };
- 47 
- 48     SceneJS.Layer.prototype.setEnabled = function(enabled) {
- 49         enabled = !!enabled;
- 50         if (this._core.enabled != enabled) {
- 51             this._core.enabled = enabled;
- 52             this._engine.display.drawListDirty = true;
- 53         }
- 54     };
- 55 
- 56     SceneJS.Layer.prototype.getEnabled = function() {
- 57         return this._core.enabled;
- 58     };
- 59 
- 60     SceneJS.Layer.prototype._compile = function() {
- 61         this._engine.display.layer = coreStack[stackLen++] = this._core;
- 62         this._compileNodes();
- 63         this._engine.display.layer = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore;
- 64     };
- 65 
- 66 })();
- 67 
- 68 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_library.js.html b/docs/symbols/src/src_core_scene_library.js.html deleted file mode 100644 index 5348c2c3..00000000 --- a/docs/symbols/src/src_core_scene_library.js.html +++ /dev/null @@ -1,16 +0,0 @@ -
  1 /**
-  2  * @class Scene graph node which assigns nodes in its subgraph to a library
-  3  * @extends SceneJS.Node
-  4  */
-  5 SceneJS.Library = SceneJS_NodeFactory.createNodeType("library");
-  6 SceneJS.Library.prototype._compile = function() { // Bypass child nodes
-  7 };
-  8 
-  9 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_lights.js.html b/docs/symbols/src/src_core_scene_lights.js.html deleted file mode 100644 index c96aebe6..00000000 --- a/docs/symbols/src/src_core_scene_lights.js.html +++ /dev/null @@ -1,181 +0,0 @@ -
  1 (function () {
-  2 
-  3     /**
-  4      * The default state core singleton for {@link SceneJS.Lights} nodes
-  5      */
-  6     var defaultCore = {
-  7         type:"lights",
-  8         stateId:SceneJS._baseStateId++,
-  9         hash:null,
- 10         empty:false,
- 11         lights:[
- 12             {
- 13                 mode:"ambient",
- 14                 color:[0.6, 0.6, 0.6], // Core has arrays for WebGL loading
- 15                 diffuse:true,
- 16                 specular:false
- 17             },
- 18             {
- 19                 mode:"dir",
- 20                 color:[1.0, 1.0, 1.0 ],
- 21                 diffuse:true,
- 22                 specular:true,
- 23                 dir:[0.5, -1.0, -0.6 ]
- 24             },
- 25             {
- 26                 mode:"dir",
- 27                 color:[1.0, 1.0, 1.0 ],
- 28                 diffuse:true,
- 29                 specular:true,
- 30                 dir:[-1.0, 0.0, 0.0 ]
- 31             }
- 32         ]
- 33     };
- 34 
- 35     makeHash(defaultCore);
- 36 
- 37     function makeHash(core) {
- 38         if (core.lights && core.lights.length > 0) {
- 39             var lights = core.lights;
- 40             var parts = [];
- 41             var light;
- 42             for (var i = 0, len = lights.length; i < len; i++) {
- 43                 light = lights[i];
- 44                 parts.push(light.mode);
- 45                 if (light.specular) {
- 46                     parts.push("s");
- 47                 }
- 48                 if (light.diffuse) {
- 49                     parts.push("d");
- 50                 }
- 51                 parts.push((light.space == "world") ? "w" : "v");
- 52             }
- 53             core.hash = parts.join("");
- 54 
- 55         } else {
- 56             core.hash = "";
- 57         }
- 58     }
- 59 
- 60     var coreStack = [];
- 61     var stackLen = 0;
- 62 
- 63     SceneJS_events.addListener(
- 64         SceneJS_events.SCENE_COMPILING,
- 65         function (params) {
- 66             params.engine.display.lights = defaultCore;
- 67             stackLen = 0;
- 68         });
- 69 
- 70     /**
- 71      * @class Scene graph node which defines light sources to illuminate the {@link SceneJS.Geometry}s within its subgraph
- 72      * @extends SceneJS.Node
- 73      */
- 74     SceneJS.Lights = SceneJS_NodeFactory.createNodeType("lights");
- 75 
- 76     SceneJS.Lights.prototype._init = function (params) {
- 77 
- 78         if (this._core.useCount == 1) { // This node defines the resource
- 79 
- 80             var lights = params.lights;
- 81 
- 82             if (!lights) {
- 83                 throw SceneJS_error.fatalError(
- 84                     SceneJS.errors.NODE_CONFIG_EXPECTED,
- 85                     "lights node attribute missing : 'lights'");
- 86             }
- 87 
- 88             this._core.lights = this._core.lights || [];
- 89 
- 90             for (var i = 0, len = lights.length; i < len; i++) {
- 91                 this._setLight(i, lights[i]);
- 92             }
- 93         }
- 94     };
- 95 
- 96     SceneJS.Lights.prototype.setLights = function (lights) {
- 97         var indexNum;
- 98         for (var index in lights) {
- 99             if (lights.hasOwnProperty(index)) {
-100                 if (index != undefined || index != null) {
-101                     indexNum = parseInt(index);
-102                     if (indexNum < 0 || indexNum >= this._core.lights.length) {
-103                         throw SceneJS_error.fatalError(
-104                             SceneJS.errors.ILLEGAL_NODE_CONFIG,
-105                             "Invalid argument to set 'lights': index out of range (" + this._core.lights.length + " lights defined)");
-106                     }
-107                     this._setLight(indexNum, lights[index] || {});
-108                 }
-109             }
-110         }
-111         this._engine.display.imageDirty = true;
-112     };
-113 
-114     SceneJS.Lights.prototype._setLight = function (index, cfg) {
-115 
-116         var light = this._core.lights[index] || (this._core.lights[index] = []);
-117 
-118         var mode = cfg.mode || "dir";
-119         if (mode != "dir" && mode != "point" && mode != "ambient") {
-120             throw SceneJS_error.fatalError(
-121                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
-122                 "Light mode not supported - should be 'dir' or 'point' or 'ambient'");
-123         }
-124 
-125         var pos = cfg.pos;
-126         var dir = cfg.dir;
-127 
-128         var color = cfg.color;
-129         light.color = [
-130             color.r != undefined ? color.r : 1.0,
-131             color.g != undefined ? color.g : 1.0,
-132             color.b != undefined ? color.b : 1.0
-133         ];
-134 
-135         // Ambient lights hardwired to contribute to diffuse lighting
-136         light.mode = mode;
-137         light.diffuse = (mode == "ambient") ? true : ((cfg.diffuse != undefined) ? cfg.diffuse : true);
-138         light.specular = (mode == "ambient") ? false : ((cfg.specular != undefined) ? cfg.specular : true);
-139         light.pos = cfg.pos ? [ pos.x || 0, pos.y || 0, pos.z || 0 ] : undefined;
-140         light.dir = cfg.dir ? [dir.x || 0, dir.y || 0, dir.z || 0] : undefined;
-141         light.constantAttenuation = (cfg.constantAttenuation != undefined) ? cfg.constantAttenuation : 1.0;
-142         light.linearAttenuation = (cfg.linearAttenuation || 0.0);
-143         light.quadraticAttenuation = (cfg.quadraticAttenuation || 0.0);
-144 
-145         var space = cfg.space;
-146 
-147         if (!space) {
-148 
-149             space = "world";
-150 
-151         } else if (space != "view" && space != "world") {
-152 
-153             throw SceneJS_error.fatalError(
-154                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
-155                 "lights node invalid value for property 'space': '" + space + "' - should be 'view' or 'world'");
-156         }
-157 
-158         light.space = space;
-159 
-160         this._core.hash = null;
-161     };
-162 
-163     SceneJS.Lights.prototype._compile = function () {
-164 
-165         if (!this._core.hash) {
-166             makeHash(this._core);
-167         }
-168 
-169         this._engine.display.lights = coreStack[stackLen++] = this._core;
-170         this._compileNodes();
-171         this._engine.display.lights = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore;
-172     };
-173 
-174 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_lookAt.js.html b/docs/symbols/src/src_core_scene_lookAt.js.html deleted file mode 100644 index c6878112..00000000 --- a/docs/symbols/src/src_core_scene_lookAt.js.html +++ /dev/null @@ -1,394 +0,0 @@ -
  1 (function() {
-  2 
-  3     var defaultMatrix = SceneJS_math_identityMat4();
-  4     var defaultMat = new Float32Array(defaultMatrix);
-  5 
-  6     var normalMat = SceneJS_math_transposeMat4(
-  7             SceneJS_math_inverseMat4(
-  8                     SceneJS_math_identityMat4(),
-  9                     SceneJS_math_mat4()));
- 10     var defaultNormalMat = new Float32Array(normalMat);
- 11 
- 12     /**
- 13      * The default state core singleton for {@link SceneJS.LookAt} nodes
- 14      */
- 15     var defaultCore = {
- 16         type: "lookAt",
- 17         stateId: SceneJS._baseStateId++,
- 18         matrix: defaultMatrix,
- 19         mat : defaultMat,
- 20         normalMatrix: normalMat,
- 21         normalMat : defaultNormalMat,
- 22         lookAt: SceneJS_math_LOOKAT_ARRAYS
- 23     };
- 24 
- 25     var coreStack = [];
- 26     var stackLen = 0;
- 27 
- 28     SceneJS_events.addListener(
- 29             SceneJS_events.SCENE_COMPILING,
- 30             function(params) {
- 31                 params.engine.display.viewTransform = defaultCore;
- 32                 stackLen = 0;
- 33             });
- 34 
- 35     /**
- 36      * @class Scene graph node which defines the viewing transform for the {@link SceneJS.Geometry}s within its subgraph
- 37      * @extends SceneJS.Node
- 38      */
- 39     SceneJS.Lookat = SceneJS_NodeFactory.createNodeType("lookAt");
- 40 
- 41     SceneJS.Lookat.prototype._init = function(params) {
- 42 
- 43         this._mat = null;
- 44 
- 45         this._xf = {
- 46             type: "lookat"
- 47         };
- 48 
- 49         if (this._core.useCount == 1) { // This node is the resource definer
- 50 
- 51             this._core.eyeX = 0;
- 52             this._core.eyeY = 0;
- 53             this._core.eyeZ = 1.0;
- 54 
- 55             this._core.lookX = 0;
- 56             this._core.lookY = 0;
- 57             this._core.lookZ = 0;
- 58 
- 59             this._core.upX = 0;
- 60             this._core.upY = 1;
- 61             this._core.upZ = 0;
- 62 
- 63             if (!params.eye && !params.look && !params.up) {
- 64                 this.setEye({x: 0, y: 0, z: 1.0 });
- 65                 this.setLook({x: 0, y: 0, z: 0 });
- 66                 this.setUp({x: 0, y: 1.0, z: 0 });
- 67             } else {
- 68                 this.setEye(params.eye);
- 69                 this.setLook(params.look);
- 70                 this.setUp(params.up);
- 71             }
- 72 
- 73             var core = this._core;
- 74 
- 75             this._core.rebuild = function() {
- 76 
- 77                 core.matrix = SceneJS_math_lookAtMat4c(
- 78                         core.eyeX, core.eyeY, core.eyeZ,
- 79                         core.lookX, core.lookY, core.lookZ,
- 80                         core.upX, core.upY, core.upZ);
- 81 
- 82                 core.lookAt = {
- 83                     eye: [core.eyeX, core.eyeY, core.eyeZ ],
- 84                     look: [core.lookX, core.lookY, core.lookZ ],
- 85                     up:  [core.upX, core.upY, core.upZ ]
- 86                 };
- 87 
- 88                 if (!core.mat) { // Lazy-create arrays
- 89                     core.mat = new Float32Array(core.matrix);
- 90                     core.normalMat = new Float32Array(
- 91                             SceneJS_math_transposeMat4(SceneJS_math_inverseMat4(core.matrix, SceneJS_math_mat4())));
- 92 
- 93                 } else { // Insert into arrays
- 94                     core.mat.set(core.matrix);
- 95                     core.normalMat.set(SceneJS_math_transposeMat4(SceneJS_math_inverseMat4(core.matrix, SceneJS_math_mat4())));
- 96                 }
- 97 
- 98                 core.dirty = false;
- 99             };
-100 
-101             this._core.dirty = true;
-102         }
-103     };
-104 
-105     SceneJS.Lookat.prototype.setEye = function(eye) {
-106 
-107         eye = eye || {};
-108 
-109         if (eye.x != undefined && eye.x != null) {
-110             this._core.eyeX = eye.x;
-111         }
-112 
-113         if (eye.y != undefined && eye.y != null) {
-114             this._core.eyeY = eye.y;
-115         }
-116 
-117         if (eye.z != undefined && eye.z != null) {
-118             this._core.eyeZ = eye.z;
-119         }
-120 
-121         this._core.dirty = true;
-122         this._engine.display.imageDirty = true;
-123 
-124         return this;
-125     };
-126 
-127     SceneJS.Lookat.prototype.incEye = function(eye) {
-128         eye = eye || {};
-129         this._core.eyeX += (eye.x != undefined && eye.x != null) ? eye.x : 0;
-130         this._core.eyeY += (eye.y != undefined && eye.y != null) ? eye.y : 0;
-131         this._core.eyeZ += (eye.z != undefined && eye.z != null) ? eye.z : 0;
-132         this._core.dirty = true;
-133         this._engine.display.imageDirty = true;
-134         return this;
-135     };
-136 
-137     SceneJS.Lookat.prototype.setEyeX = function(x) {
-138         this._core.eyeX = x || 0;
-139         this._core.dirty = true;
-140         this._engine.display.imageDirty = true;
-141         return this;
-142     };
-143 
-144     SceneJS.Lookat.prototype.setEyeY = function(y) {
-145         this._core.eyeY = y || 0;
-146         this._core.dirty = true;
-147         this._engine.display.imageDirty = true;
-148         return this;
-149     };
-150 
-151     SceneJS.Lookat.prototype.setEyeZ = function(z) {
-152         this._core.eyeZ = z || 0;
-153         this._core.dirty = true;
-154         this._engine.display.imageDirty = true;
-155         return this;
-156     };
-157 
-158     SceneJS.Lookat.prototype.incEyeX = function(x) {
-159         this._core.eyeX += x;
-160         this._core.dirty = true;
-161         this._engine.display.imageDirty = true;
-162         return this;
-163     };
-164 
-165     SceneJS.Lookat.prototype.incEyeY = function(y) {
-166         this._core.eyeY += y;
-167         this._core.dirty = true;
-168         this._engine.display.imageDirty = true;
-169         return this;
-170     };
-171 
-172     SceneJS.Lookat.prototype.incEyeZ = function(z) {
-173         this._core.eyeZ += z;
-174         this._core.dirty = true;
-175         this._engine.display.imageDirty = true;
-176         return this;
-177     };
-178 
-179     SceneJS.Lookat.prototype.getEye = function() {
-180         return {
-181             x: this._core.eyeX,
-182             y: this._core.eyeY,
-183             z: this._core.eyeZ
-184         };
-185     };
-186 
-187     SceneJS.Lookat.prototype.setLook = function(look) {
-188         look = look || {};
-189 
-190         if (look.x != undefined && look.x != null) {
-191             this._core.lookX = look.x;
-192         }
-193 
-194         if (look.y != undefined && look.y != null) {
-195             this._core.lookY = look.y;
-196         }
-197 
-198         if (look.z != undefined && look.z != null) {
-199             this._core.lookZ = look.z;
-200         }
-201 
-202         this._core.dirty = true;
-203         this._engine.display.imageDirty = true;
-204         return this;
-205     };
-206 
-207     SceneJS.Lookat.prototype.incLook = function(look) {
-208         look = look || {};
-209         this._core.lookX += (look.x != undefined && look.x != null) ? look.x : 0;
-210         this._core.lookY += (look.y != undefined && look.y != null) ? look.y : 0;
-211         this._core.lookZ += (look.z != undefined && look.z != null) ? look.z : 0;
-212         this._core.dirty = true;
-213         this._engine.display.imageDirty = true;
-214         return this;
-215     };
-216 
-217     SceneJS.Lookat.prototype.setLookX = function(x) {
-218         this._core.lookX = x || 0;
-219         this._core.dirty = true;
-220         this._engine.display.imageDirty = true;
-221         return this;
-222     };
-223 
-224     SceneJS.Lookat.prototype.setLookY = function(y) {
-225         this._core.lookY = y || 0;
-226         this._core.dirty = true;
-227         this._engine.display.imageDirty = true;
-228         return this;
-229     };
-230 
-231     SceneJS.Lookat.prototype.setLookZ = function(z) {
-232         this._core.lookZ = z || 0;
-233         this._core.dirty = true;
-234         this._engine.display.imageDirty = true;
-235         return this;
-236     };
-237 
-238     SceneJS.Lookat.prototype.incLookX = function(x) {
-239         this._core.lookX += x;
-240         this._core.dirty = true;
-241         this._engine.display.imageDirty = true;
-242         return this;
-243     };
-244 
-245     SceneJS.Lookat.prototype.incLookY = function(y) {
-246         this._core.lookY += y;
-247         this._core.dirty = true;
-248         this._engine.display.imageDirty = true;
-249         return this;
-250     };
-251 
-252     SceneJS.Lookat.prototype.incLookZ = function(z) {
-253         this._core.lookZ += z;
-254         this._core.dirty = true;
-255         this._engine.display.imageDirty = true;
-256         return this;
-257     };
-258 
-259     SceneJS.Lookat.prototype.getLook = function() {
-260         return {
-261             x: this._core.lookX,
-262             y: this._core.lookY,
-263             z: this._core.lookZ
-264         };
-265     };
-266 
-267     SceneJS.Lookat.prototype.setUp = function(up) {
-268         up = up || {};
-269 
-270         if (up.x != undefined && up.x != null) {
-271             this._core.upX = up.x;
-272         }
-273 
-274         if (up.y != undefined && up.y != null) {
-275             this._core.upY = up.y;
-276         }
-277 
-278         if (up.z != undefined && up.z != null) {
-279             this._core.upZ = up.z;
-280         }
-281 
-282         this._core.dirty = true;
-283         this._engine.display.imageDirty = true;
-284 
-285         return this;
-286     };
-287 
-288     SceneJS.Lookat.prototype.incUp = function(up) {
-289         up = up || {};
-290         this._core.upX += (up.x != undefined && up.x != null) ? up.x : 0;
-291         this._core.upY += (up.y != undefined && up.y != null) ? up.y : 0;
-292         this._core.upZ += (up.z != undefined && up.z != null) ? up.z : 0;
-293         this._core.dirty = true;
-294         this._engine.display.imageDirty = true;
-295         return this;
-296     };
-297 
-298     SceneJS.Lookat.prototype.setUpX = function(x) {
-299         this._core.upX = x || 0;
-300         this._core.dirty = true;
-301         this._engine.display.imageDirty = true;
-302         return this;
-303     };
-304 
-305     SceneJS.Lookat.prototype.setUpY = function(y) {
-306         this._core.upY = y || 0;
-307         this._core.dirty = true;
-308         this._engine.display.imageDirty = true;
-309         return this;
-310     };
-311 
-312     SceneJS.Lookat.prototype.setUpZ = function(z) {
-313         this._core.upZ = z || 0;
-314         this._core.dirty = true;
-315         this._engine.display.imageDirty = true;
-316         return this;
-317     };
-318 
-319     SceneJS.Lookat.prototype.incUpX = function(x) {
-320         this._core.upX += x;
-321         this._core.dirty = true;
-322         this._engine.display.imageDirty = true;
-323         return this;
-324     };
-325 
-326     SceneJS.Lookat.prototype.incUpY = function(y) {
-327         this._core.upY += y;
-328         this._core.dirty = true;
-329         this._engine.display.imageDirty = true;
-330         return this;
-331     };
-332 
-333     SceneJS.Lookat.prototype.incUpZ = function(z) {
-334         this._core.upZ += z;
-335         this._core.dirty = true;
-336         this._engine.display.imageDirty = true;
-337         return this;
-338     };
-339 
-340     SceneJS.Lookat.prototype.getUp = function() {
-341         return {
-342             x: this._core.upX,
-343             y: this._core.upY,
-344             z: this._core.upZ
-345         };
-346     };
-347 
-348     /**
-349      * Returns a copy of the matrix as a 1D array of 16 elements
-350      * @returns {Number[16]}
-351      */
-352     SceneJS.Lookat.prototype.getMatrix = function() {
-353 
-354         if (this._core.dirty) {
-355             this._core.rebuild();
-356         }
-357 
-358         return  this._mat.slice(0);
-359     };
-360 
-361     SceneJS.Lookat.prototype.getAttributes = function() {
-362         return {
-363             look: {
-364                 x: this._core.lookX,
-365                 y: this._core.lookY,
-366                 z: this._core.lookZ
-367             },
-368             eye: {
-369                 x: this._core.eyeX,
-370                 y: this._core.eyeY,
-371                 z: this._core.eyeZ
-372             },
-373             up: {
-374                 x: this._core.upX,
-375                 y: this._core.upY,
-376                 z: this._core.upZ
-377             }
-378         };
-379     };
-380 
-381     SceneJS.Lookat.prototype._compile = function() {
-382         this._engine.display.viewTransform = coreStack[stackLen++] = this._core;
-383         this._compileNodes();
-384         this._engine.display.viewTransform = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore;
-385     };
-386 
-387 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_material.js.html b/docs/symbols/src/src_core_scene_material.js.html deleted file mode 100644 index 91061eb0..00000000 --- a/docs/symbols/src/src_core_scene_material.js.html +++ /dev/null @@ -1,149 +0,0 @@ -
  1 /*
-  2 
-  3  TODO: material system from virtualworldframework:
-  4 
-  5  "color":
-  6  "ambient":
-  7  "specColor":
-  8  "shininess":
-  9  "reflect":
- 10  "specular":
- 11  "emit":
- 12  "alpha":
- 13  "binaryAlpha":
- 14  */
- 15 new (function() {
- 16 
- 17     /**
- 18      * The default state core singleton for {@link SceneJS.Material} nodes
- 19      */
- 20     var defaultCore = {
- 21         type: "material",
- 22         stateId: SceneJS._baseStateId++,
- 23         baseColor :  [ 1.0, 1.0, 1.0 ],
- 24         specularColor :  [ 1.0,  1.0,  1.0 ],
- 25         specular : 0.4,
- 26         shine :  20.0,
- 27         alpha :  1.0,
- 28         emit :  0.0
- 29     };
- 30 
- 31     var coreStack = [];
- 32     var stackLen = 0;
- 33 
- 34     SceneJS_events.addListener(
- 35             SceneJS_events.SCENE_COMPILING,
- 36             function(params) {
- 37                 params.engine.display.material = defaultCore;
- 38                 stackLen = 0;
- 39             });
- 40 
- 41     /**
- 42      * @class Scene graph node which defines surface material properties for the {@link SceneJS.Geometry}s within its subgraph
- 43      * @extends SceneJS.Node
- 44      */
- 45     SceneJS.Material = SceneJS_NodeFactory.createNodeType("material");
- 46 
- 47     SceneJS.Material.prototype._init = function(params) {
- 48         if (this._core.useCount == 1) {
- 49             this.setBaseColor(params.baseColor);
- 50             this.setSpecularColor(params.specularColor);
- 51             this.setSpecular(params.specular);
- 52             this.setShine(params.shine);
- 53             this.setEmit(params.emit);
- 54             this.setAlpha(params.alpha);
- 55         }
- 56     };
- 57 
- 58     SceneJS.Material.prototype.setBaseColor = function(color) {
- 59         var defaultBaseColor = defaultCore.baseColor;
- 60         this._core.baseColor = color ? [
- 61             color.r != undefined && color.r != null ? color.r : defaultBaseColor[0],
- 62             color.g != undefined && color.g != null ? color.g : defaultBaseColor[1],
- 63             color.b != undefined && color.b != null ? color.b : defaultBaseColor[2]
- 64         ] : defaultCore.baseColor;
- 65         this._engine.display.imageDirty = true;
- 66         return this;
- 67     };
- 68 
- 69     SceneJS.Material.prototype.getBaseColor = function() {
- 70         return {
- 71             r: this._core.baseColor[0],
- 72             g: this._core.baseColor[1],
- 73             b: this._core.baseColor[2]
- 74         };
- 75     };
- 76 
- 77     SceneJS.Material.prototype.setSpecularColor = function(color) {
- 78         var defaultSpecularColor = defaultCore.specularColor;
- 79         this._core.specularColor = color ? [
- 80             color.r != undefined && color.r != null ? color.r : defaultSpecularColor[0],
- 81             color.g != undefined && color.g != null ? color.g : defaultSpecularColor[1],
- 82             color.b != undefined && color.b != null ? color.b : defaultSpecularColor[2]
- 83         ] : defaultCore.specularColor;
- 84         this._engine.display.imageDirty = true;
- 85         return this;
- 86     };
- 87 
- 88     SceneJS.Material.prototype.getSpecularColor = function() {
- 89         return {
- 90             r: this._core.specularColor[0],
- 91             g: this._core.specularColor[1],
- 92             b: this._core.specularColor[2]
- 93         };
- 94     };
- 95 
- 96     SceneJS.Material.prototype.setSpecular = function(specular) {
- 97         this._core.specular = (specular != undefined && specular != null) ? specular : defaultCore.specular;
- 98         this._engine.display.imageDirty = true;
- 99         return this;
-100     };
-101 
-102     SceneJS.Material.prototype.getSpecular = function() {
-103         return this._core.specular;
-104     };
-105 
-106     SceneJS.Material.prototype.setShine = function(shine) {
-107         this._core.shine = (shine != undefined && shine != null) ? shine : defaultCore.shine;
-108         this._engine.display.imageDirty = true;
-109         return this;
-110     };
-111 
-112     SceneJS.Material.prototype.getShine = function() {
-113         return this._core.shine;
-114     };
-115 
-116     SceneJS.Material.prototype.setEmit = function(emit) {
-117         this._core.emit = (emit != undefined && emit != null) ? emit : defaultCore.emit;
-118         this._engine.display.imageDirty = true;
-119         return this;
-120     };
-121 
-122     SceneJS.Material.prototype.getEmit = function() {
-123         return this._core.emit;
-124     };
-125 
-126     SceneJS.Material.prototype.setAlpha = function(alpha) {
-127         this._core.alpha = (alpha != undefined && alpha != null) ? alpha : defaultCore.alpha;
-128         this._engine.display.imageDirty = true;
-129         return this;
-130     };
-131 
-132     SceneJS.Material.prototype.getAlpha = function() {
-133         return this._core.alpha;
-134     };
-135 
-136     SceneJS.Material.prototype._compile = function() {
-137         this._engine.display.material = coreStack[stackLen++] = this._core;
-138         this._compileNodes();
-139         this._engine.display.material = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore;
-140     };
-141 
-142 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_matrix.js.html b/docs/symbols/src/src_core_scene_matrix.js.html deleted file mode 100644 index b736784d..00000000 --- a/docs/symbols/src/src_core_scene_matrix.js.html +++ /dev/null @@ -1,93 +0,0 @@ -
  1 
-  2 /**
-  3  * @class Scene graph node which defines a modelling transform matrix to apply to the objects in its subgraph
-  4  * @extends SceneJS.Node
-  5  */
-  6 SceneJS.Matrix = SceneJS_NodeFactory.createNodeType("matrix");
-  7 
-  8 SceneJS.Matrix.prototype._init = function(params) {
-  9 
- 10     if (this._core.useCount == 1) { // This node is the resource definer
- 11 
- 12         SceneJS_modelXFormStack.buildCore(this._core);
- 13 
- 14         this.setElements(params.elements);
- 15     }
- 16 };
- 17 
- 18 /**
- 19  * Get Model matrix
- 20  * @return {*}
- 21  */
- 22 SceneJS.Matrix.prototype.getModelMatrix = function() {
- 23     if (this._core.dirty) {
- 24         this._core.build();
- 25     }
- 26     return this._core.matrix;
- 27 };
- 28 
- 29 /**
- 30  * Get World matrix. That's the multiplication of this node's Model matrix by the World matrix of the the next
- 31  * tranform (scale, matrix, translate etc) node on the path to the scene root.
- 32  * @return {*}
- 33  */
- 34 SceneJS.Matrix.prototype.getWorldMatrix = function() {
- 35     if (this._core.dirty) {
- 36         this._core.build();
- 37     }
- 38     return Array.apply( [], this._core.mat);
- 39 };
- 40 
- 41 /**
- 42  * Sets the matrix elements
- 43  * @type {Function}
- 44  */
- 45 SceneJS.Matrix.prototype.setMatrix = function(elements) {
- 46 
- 47     elements = elements || SceneJS_math_identityMat4();
- 48 
- 49     if (elements.length != 16) {
- 50         throw SceneJS_error.fatalError(
- 51                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
- 52                 "SceneJS.Matrix elements should number 16");
- 53     }
- 54 
- 55     var core = this._core;
- 56 
- 57     if (!core.matrix) {
- 58         core.matrix = elements;
- 59 
- 60     } else {
- 61 
- 62         for (var i = 0; i < 16; i++) {
- 63             core.matrix[i] = elements[i];
- 64         }
- 65     }
- 66 
- 67     core.setDirty();
- 68 
- 69     this._engine.display.imageDirty = true;
- 70 
- 71     return this;
- 72 };
- 73 
- 74 /**
- 75  * Sets the matrix elements
- 76  * @deprecated
- 77  * @type {Function}
- 78  */
- 79 SceneJS.Matrix.prototype.setElements = SceneJS.Matrix.prototype.setMatrix;
- 80 
- 81 SceneJS.Matrix.prototype._compile = function() {
- 82     SceneJS_modelXFormStack.push(this._core);
- 83     this._compileNodes();
- 84     SceneJS_modelXFormStack.pop();
- 85 };
- 86 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_modelXFormStack.js.html b/docs/symbols/src/src_core_scene_modelXFormStack.js.html deleted file mode 100644 index cc4096b6..00000000 --- a/docs/symbols/src/src_core_scene_modelXFormStack.js.html +++ /dev/null @@ -1,223 +0,0 @@ -
  1 /**
-  2  * Provides a model transform stack in front of the renderer.
-  3  * Nodes peek push and pop to the stack, while the renderer peeks at
-  4  * the transform on the top of the stack whenever it builds a renderer node.
-  5  *
-  6  */
-  7 var SceneJS_modelXFormStack = new (function () {
-  8 
-  9     var defaultMatrix = SceneJS_math_identityMat4();
- 10     var defaultMat = new Float32Array(defaultMatrix);
- 11 
- 12     var defaultNormalMatrix = SceneJS_math_transposeMat4(
- 13         SceneJS_math_inverseMat4(
- 14             SceneJS_math_identityMat4(),
- 15             SceneJS_math_mat4()));
- 16     var defaultNormalMat = new Float32Array(defaultNormalMatrix);
- 17 
- 18     var defaultCore = {
- 19         type:"xform",
- 20         stateId:SceneJS._baseStateId++,
- 21 
- 22         matrix:defaultMatrix,
- 23         mat:defaultMat,
- 24 
- 25         normalMatrix:defaultNormalMatrix,
- 26         normalMat:defaultNormalMat,
- 27 
- 28         parent:null, // Parent transform core
- 29         cores:[], // Child transform cores
- 30         numCores:0, // Number of child transform cores
- 31         dirty:false, // Does this subtree need matrices rebuilt
- 32         matrixDirty:false
- 33     };
- 34 
- 35     var transformStack = [];
- 36     var stackLen = 0;
- 37 
- 38     this.top = defaultCore;
- 39 
- 40     var dirty;
- 41 
- 42     var self = this;
- 43 
- 44     SceneJS_events.addListener(
- 45         SceneJS_events.SCENE_COMPILING,
- 46         function () {
- 47             stackLen = 0;
- 48             self.top = defaultCore;
- 49             dirty = true;
- 50         });
- 51 
- 52     SceneJS_events.addListener(
- 53         SceneJS_events.OBJECT_COMPILING,
- 54         function (params) {
- 55 
- 56             if (dirty) {
- 57 
- 58                 if (stackLen > 0) {
- 59 
- 60                     params.display.modelTransform = transformStack[stackLen - 1];
- 61 
- 62                 } else {
- 63 
- 64                     params.display.modelTransform = defaultCore;
- 65                 }
- 66 
- 67                 dirty = false;
- 68             }
- 69         });
- 70 
- 71     /**
- 72      * Creates a fresh transformation core
- 73      * @param core
- 74      */
- 75     this.buildCore = function (core) {
- 76 
- 77         /*
- 78          * Transform tree node properties
- 79          */
- 80         core.parent = null;         // Parent transform core
- 81         core.cores = [];            // Child transform cores
- 82         core.numCores = 0;          // Number of child transform cores
- 83         core.matrixDirty = false;
- 84 
- 85         core.matrix = SceneJS_math_identityMat4();
- 86 
- 87         core.mat = new Float32Array(core.matrix);
- 88         core.normalMat = new Float32Array(
- 89             SceneJS_math_transposeMat4(
- 90                 SceneJS_math_inverseMat4(core.matrix, SceneJS_math_mat4())));
- 91 
- 92         core.dirty = false;         // Does this subtree need matrices rebuilt
- 93 
- 94         core.setDirty = function () {
- 95 
- 96             core.matrixDirty = true;
- 97 
- 98             if (core.dirty) {
- 99                 // return;
-100             }
-101 
-102             setDirty(core);
-103         };
-104 
-105         /**
-106          * Recursively flag this subtree of transforms cores as dirty,
-107          * ie. needing their matrices rebuilt.
-108          */
-109         function setDirty(core) {
-110 
-111             core.dirty = true;
-112             core.matrixDirty = true;
-113 
-114             for (var i = 0, len = core.numCores; i < len; i++) {
-115                 setDirty(core.cores[i]);
-116             }
-117         }
-118 
-119         /**
-120          * Pre-multiply matrices at cores on path up to root into matrix at this core
-121          */
-122         core.build = function () {
-123 
-124             if (core.matrixDirty) {
-125                 if (core.buildMatrix) { // Matrix might be explicit property on some transform node types
-126                     core.buildMatrix();
-127                 }
-128                 core.matrixDirty = false;
-129             }
-130 
-131             var parent = core.parent;
-132 
-133             var matrix;
-134 
-135             if (parent) {
-136 
-137                 matrix = core.matrix.slice(0);
-138 
-139                 while (parent) {
-140 
-141                     if (parent.matrixDirty) {
-142 
-143                         if (parent.buildMatrix) { // Matrix might be explicit property on some transform node types
-144                             parent.buildMatrix();
-145                         }
-146                         parent.mat.set(parent.matrix);
-147                         parent.normalMat.set(
-148                             SceneJS_math_transposeMat4(
-149                                 SceneJS_math_inverseMat4(parent.matrix, SceneJS_math_mat4())));
-150 
-151                         parent.matrixDirty = false;
-152                     }
-153 
-154                     SceneJS_math_mulMat4(parent.matrix, matrix, matrix);
-155 
-156                     if (!parent.dirty) {
-157                         //   break;
-158                     }
-159 
-160                     //  parent.dirty = false;
-161 
-162                     parent = parent.parent;
-163                 }
-164 
-165             } else {
-166 
-167                 matrix = core.matrix;
-168             }
-169 
-170             //            if (!core.mat) {
-171             //
-172             //                core.mat = new Float32Array(matrix);
-173             //
-174             //                core.normalMat = new Float32Array(
-175             //                        SceneJS_math_transposeMat4(
-176             //                                SceneJS_math_inverseMat4(matrix, SceneJS_math_mat4())));
-177             //            } else {
-178 
-179             core.mat.set(matrix);
-180 
-181             core.normalMat.set(
-182                 SceneJS_math_transposeMat4(
-183                     SceneJS_math_inverseMat4(matrix, SceneJS_math_mat4())));
-184             //}
-185 
-186             core.dirty = false;
-187         };
-188     };
-189 
-190     this.push = function (core) {
-191 
-192         transformStack[stackLen++] = core;
-193 
-194         core.parent = this.top;
-195         core.dirty = true;
-196 
-197         if (this.top) {
-198             this.top.cores[this.top.numCores++] = core;
-199         }
-200 
-201         core.numCores = 0;
-202 
-203         this.top = core;
-204 
-205         dirty = true;
-206     };
-207 
-208     this.pop = function () {
-209 
-210         this.top = (--stackLen > 0) ? transformStack[stackLen - 1] : defaultCore;
-211 
-212         dirty = true;
-213     };
-214 
-215 })();
-216 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_morphGeometry.js.html b/docs/symbols/src/src_core_scene_morphGeometry.js.html deleted file mode 100644 index c5345297..00000000 --- a/docs/symbols/src/src_core_scene_morphGeometry.js.html +++ /dev/null @@ -1,390 +0,0 @@ -
  1 new (function() {
-  2 
-  3     /**
-  4      * The default state core singleton for {@link SceneJS.MorphGeometry} nodes
-  5      */
-  6     var defaultCore = {
-  7         type: "morphGeometry",
-  8         stateId: SceneJS._baseStateId++,
-  9         hash: "",
- 10         //         empty: true,
- 11         morph: null
- 12     };
- 13 
- 14     var coreStack = [];
- 15     var stackLen = 0;
- 16 
- 17     SceneJS_events.addListener(
- 18             SceneJS_events.SCENE_COMPILING,
- 19             function(params) {
- 20                 params.engine.display.morphGeometry = defaultCore;
- 21                 stackLen = 0;
- 22             });
- 23 
- 24     /**
- 25      * @class Scene graph node which defines morphing behaviour for the {@link SceneJS.Geometry}s within its subgraph
- 26      * @extends SceneJS.Node
- 27      */
- 28     SceneJS.MorphGeometry = SceneJS_NodeFactory.createNodeType("morphGeometry");
- 29 
- 30     SceneJS.MorphGeometry.prototype._init = function(params) {
- 31 
- 32         if (this._core.useCount == 1) { // This node defines the resource
- 33 
- 34             this._sourceConfigs = params.source;
- 35             this._source = null;
- 36 
- 37             if (params.source) {
- 38 
- 39                 /*---------------------------------------------------------------------------------------------------
- 40                  * Build node core (possibly asynchronously) using a factory object
- 41                  *--------------------------------------------------------------------------------------------------*/
- 42 
- 43                 if (!params.source.type) {
- 44                     throw SceneJS_error.fatalError(
- 45                             SceneJS.errors.ILLEGAL_NODE_CONFIG,
- 46                             "morphGeometry config expected: source.type");
- 47                 }
- 48 
- 49                 var sourceService = SceneJS.Plugins.getPlugin(SceneJS.Plugins.MORPH_GEO_SOURCE_PLUGIN, this._sourceConfigs.type);
- 50 
- 51                 if (!sourceService) {
- 52                     throw SceneJS_error.fatalError(
- 53                             SceneJS.errors.PLUGIN_INVALID,
- 54                             "morphGeometry: no support for source type '" + this._sourceConfigs.type + "' - need to include plugin for this source type, " +
- 55                             "or install a custom source service with SceneJS.Plugins.addPlugin(SceneJS.Plugins.MORPH_GEO_SOURCE_PLUGIN, '" + this._sourceConfigs.type + "', <your service>).");
- 56                 }
- 57 
- 58                 if (!sourceService.getSource) {
- 59                     throw SceneJS_error.fatalError(
- 60                             SceneJS.errors.PLUGIN_INVALID,
- 61                             "morphGeometry: 'getSource' method not found on MorphGeoFactoryService (SceneJS.Plugins.MORPH_GEO_SOURCE_PLUGIN)");
- 62                 }
- 63 
- 64                 this._source = sourceService.getSource();
- 65 
- 66                 if (!this._source.onUpdate) {
- 67                     throw SceneJS_error.fatalError(
- 68                             SceneJS.errors.PLUGIN_INVALID,
- 69                             "morphGeometry: 'onUpdate' method not found on source provided by plugin type '" + params.source.type + "'");
- 70                 }
- 71 
- 72                 var self = this;
- 73 
- 74                 this._source.onCreate(// Get notification when factory creates the morph
- 75                         function(data) {
- 76 
- 77                             self._buildNodeCore(data);
- 78 
- 79                             self._core._loading = false;
- 80                             self._fireEvent("loaded");
- 81 
- 82                             self._engine.branchDirty(this); // TODO
- 83                         });
- 84 
- 85                 if (this._source.onUpdate) {
- 86                     this._source.onUpdate(// Reload factory updates to the morph
- 87                             function(data) {
- 88 
- 89                                 if (data.targets) {
- 90 
- 91                                     var dataTargets = data.targets;
- 92                                     var dataTarget;
- 93                                     var index;
- 94                                     var morphTargets = self._core.targets;
- 95                                     var morphTarget;
- 96 
- 97                                     for (var i = 0, len = dataTargets.length; i < len; i++) {
- 98                                         dataTarget = dataTargets[i];
- 99                                         index = dataTarget.targetIndex;
-100                                         morphTarget = morphTargets[index];
-101 
-102                                         if (dataTarget.positions && morphTarget.vertexBuf) {
-103                                             morphTarget.vertexBuf.bind();
-104                                             morphTarget.vertexBuf.setData(dataTarget.positions, 0);
-105                                         }
-106                                     }
-107                                 }
-108 
-109                                 // TODO: factory can update factor?
-110                                 // this.setFactor(params.factor);
-111 
-112                                 self._display.imageDirty = true;
-113                             });
-114                 }
-115 
-116                 this._core._loading = true;
-117 
-118                 this._fireEvent("loading");
-119 
-120                 this._source.setConfigs(this._sourceConfigs);
-121 
-122             } else if (params.create instanceof Function) {
-123 
-124                 /*---------------------------------------------------------------------------------------------------
-125                  * Build node core from JSON arrays and primitive name returned by factory function
-126                  *--------------------------------------------------------------------------------------------------*/
-127 
-128                 this._buildNodeCore(params.create());
-129 
-130             } else {
-131 
-132                 /*---------------------------------------------------------------------------------------------------
-133                  * Build node core from JSON arrays and primitive name given in node properties
-134                  *--------------------------------------------------------------------------------------------------*/
-135 
-136                 this._buildNodeCore(params);
-137             }
-138 
-139             this._core.webglRestored = function() {
-140                 //self._buildNodeCore(self._engine.canvas.gl, self._core);
-141             };
-142 
-143             this.setFactor(params.factor);
-144         }
-145 
-146         // TODO: factor shared on cores?
-147         this._core.factor = params.factor || 0;
-148         this._core.clamp = !!params.clamp;
-149     };
-150 
-151     SceneJS.MorphGeometry.prototype._buildNodeCore = function(data) {
-152 
-153         var targetsData = data.targets || [];
-154         if (targetsData.length < 2) {
-155             throw SceneJS_error.fatalError(
-156                     SceneJS.errors.ILLEGAL_NODE_CONFIG,
-157                     "morphGeometry node should have at least two targets");
-158         }
-159 
-160         var keysData = data.keys || [];
-161         if (keysData.length != targetsData.length) {
-162             throw SceneJS_error.fatalError(
-163                     SceneJS.errors.ILLEGAL_NODE_CONFIG,
-164                     "morphGeometry node mismatch in number of keys and targets");
-165         }
-166 
-167         var core = this._core;
-168         var gl = this._engine.canvas.gl;
-169         var usage = gl.STATIC_DRAW; //var usage = (!arrays.fixed) ? gl.STREAM_DRAW : gl.STATIC_DRAW;
-170 
-171         core.keys = keysData;
-172         core.targets = [];
-173         core.key1 = 0;
-174         core.key2 = 1;
-175 
-176         /* First target's arrays are defaults for where not given on previous and subsequent targets.
-177          * When target does have array, subsequent targets without array inherit it.
-178          */
-179 
-180         var positions;
-181         var normals;
-182         var uv;
-183         var uv2;
-184 
-185         var targetData;
-186 
-187         for (var i = 0, len = targetsData.length; i < len; i++) {
-188             targetData = targetsData[i];
-189             if (!positions && targetData.positions) {
-190                 positions = targetData.positions;
-191             }
-192             if (!normals && targetData.normals) {
-193                 normals = targetData.normals;
-194             }
-195             if (!uv && targetData.uv) {
-196                 uv = targetData.uv;
-197             }
-198             if (!uv2 && targetData.uv2) {
-199                 uv2 = targetData.uv2;
-200             }
-201         }
-202 
-203         try {
-204             var target;
-205             var arry;
-206 
-207             for (var i = 0, len = targetsData.length; i < len; i++) {
-208                 targetData = targetsData[i];
-209                 target = {};
-210 
-211                 arry = targetData.positions || positions;
-212                 if (arry) {
-213                     target.vertexBuf = new SceneJS_webgl_ArrayBuffer(gl, gl.ARRAY_BUFFER,
-214                             (typeof arry == "Float32Array") ? arry : new Float32Array(arry),
-215                             arry.length, 3, usage);
-216                     positions = arry;
-217                 }
-218 
-219                 arry = targetData.normals || normals;
-220                 if (arry) {
-221                     target.normalBuf = new SceneJS_webgl_ArrayBuffer(gl, gl.ARRAY_BUFFER,
-222                             (typeof arry == "Float32Array") ? arry : new Float32Array(arry),
-223                             arry.length,
-224                             3, usage);
-225                     normals = arry;
-226                 }
-227 
-228                 arry = targetData.uv || uv;
-229                 if (arry) {
-230                     target.uvBuf = new SceneJS_webgl_ArrayBuffer(gl, gl.ARRAY_BUFFER,
-231                             (typeof arry == "Float32Array") ? arry : new Float32Array(arry),
-232                             arry.length, 2, usage);
-233                     uv = arry;
-234                 }
-235 
-236                 arry = targetData.uv2 || uv2;
-237                 if (arry) {
-238                     target.uvBuf2 = new SceneJS_webgl_ArrayBuffer(gl, gl.ARRAY_BUFFER,
-239                             (typeof arry == "Float32Array") ? arry : new Float32Array(arry),
-240                             arry.length, 2, usage);
-241                     uv2 = arry;
-242                 }
-243 
-244                 core.targets.push(target);  // We'll iterate this to destroy targets when we recover from error
-245             }
-246 
-247         } catch (e) {
-248 
-249             /* Allocation failure - deallocate target VBOs
-250              */
-251             for (var i = 0, len = core.targets.length; i < len; i++) {
-252 
-253                 target = core.targets[i];
-254 
-255                 if (target.vertexBuf) {
-256                     target.vertexBuf.destroy();
-257                 }
-258                 if (target.normalBuf) {
-259                     target.normalBuf.destroy();
-260                 }
-261                 if (target.uvBuf) {
-262                     target.uvBuf.destroy();
-263                 }
-264                 if (target.uvBuf2) {
-265                     target.uvBuf2.destroy();
-266                 }
-267             }
-268 
-269             throw SceneJS_error.fatalError(
-270                     SceneJS.errors.ERROR,
-271                     "Failed to allocate VBO(s) for morphGeometry: " + e);
-272         }
-273     };
-274 
-275     SceneJS.MorphGeometry.prototype.setSource = function(sourceConfigs) {
-276         this._sourceConfigs = sourceConfigs;
-277         var source = this._source;
-278         if (source) {
-279             source.setConfigs(sourceConfigs);
-280         }
-281     };
-282 
-283     SceneJS.MorphGeometry.prototype.getSource = function() {
-284         return this._sourceConfigs;
-285     };
-286 
-287     SceneJS.MorphGeometry.prototype.setFactor = function(factor) {
-288         factor = factor || 0.0;
-289 
-290         var core = this._core;
-291 
-292         var keys = core.keys;
-293         var key1 = core.key1;
-294         var key2 = core.key2;
-295 
-296         if (factor < keys[0]) {
-297             key1 = 0;
-298             key2 = 1;
-299 
-300         } else if (factor > keys[keys.length - 1]) {
-301             key1 = keys.length - 2;
-302             key2 = key1 + 1;
-303 
-304         } else {
-305             while (keys[key1] > factor) {
-306                 key1--;
-307                 key2--;
-308             }
-309             while (keys[key2] < factor) {
-310                 key1++;
-311                 key2++;
-312             }
-313         }
-314 
-315         /* Normalise factor to range [0.0..1.0] for the target frame
-316          */
-317         core.factor = (factor - keys[key1]) / (keys[key2] - keys[key1]);
-318         core.key1 = key1;
-319         core.key2 = key2;
-320 
-321         this._engine.display.imageDirty = true;
-322     };
-323 
-324     SceneJS.MorphGeometry.prototype.getFactor = function() {
-325         return this._core.factor;
-326     };
-327 
-328     SceneJS.MorphGeometry.prototype._compile = function() {
-329 
-330         if (!this._core.hash) {
-331             this._makeHash();
-332         }
-333 
-334         this._engine.display.morphGeometry = coreStack[stackLen++] = this._core;
-335         this._compileNodes();
-336         this._engine.display.morphGeometry = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore;
-337     };
-338 
-339     SceneJS.MorphGeometry.prototype._makeHash = function() {
-340         var core = this._core;
-341         if (core.targets.length > 0) {
-342             var target0 = core.targets[0];  // All targets have same arrays
-343             var t = "t";
-344             var f = "f";
-345             core.hash = ([
-346                 target0.vertexBuf ? t : f,
-347                 target0.normalBuf ? t : f,
-348                 target0.uvBuf ? t : f,
-349                 target0.uvBuf2 ? t : f
-350             ]).join("");
-351         } else {
-352             core.hash = "";
-353         }
-354     };
-355 
-356     SceneJS.MorphGeometry.prototype._destroy = function() {
-357         if (this._core.useCount == 1) { // Destroy core if no other references
-358             if (document.getElementById(this._engine.canvas.canvasId)) { // Context won't exist if canvas has disappeared
-359                 var core = this._core;
-360                 var target;
-361                 for (var i = 0, len = core.targets.length; i < len; i++) {
-362                     target = core.targets[i];
-363                     if (target.vertexBuf) {
-364                         target.vertexBuf.destroy();
-365                     }
-366                     if (target.normalBuf) {
-367                         target.normalBuf.destroy();
-368                     }
-369                     if (target.uvBuf) {
-370                         target.uvBuf.destroy();
-371                     }
-372                     if (target.uvBuf2) {
-373                         target.uvBuf2.destroy();
-374                     }
-375                 }
-376             }
-377             if (this._source) {
-378                 this._source.destroy();
-379             }
-380         }
-381     };
-382 
-383 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_name.js.html b/docs/symbols/src/src_core_scene_name.js.html deleted file mode 100644 index 48c9ca1a..00000000 --- a/docs/symbols/src/src_core_scene_name.js.html +++ /dev/null @@ -1,55 +0,0 @@ -
  1 (function() {
-  2 
-  3     /**
-  4      * The default state core singleton for {@link SceneJS.Name} nodes
-  5      */
-  6     var defaultCore = {
-  7         type: "name",
-  8         stateId: SceneJS._baseStateId++,
-  9         name: null
- 10     };
- 11 
- 12     var coreStack = [];
- 13     var stackLen = 0;
- 14 
- 15     SceneJS_events.addListener(
- 16             SceneJS_events.SCENE_COMPILING,
- 17             function(params) {
- 18                 params.engine.display.name = defaultCore;
- 19                 stackLen = 0;
- 20             });
- 21 
- 22     /**
- 23      * @class Scene graph node which assigns a pick name to the {@link SceneJS.Geometry} nodes in its subgraph.
- 24      * @extends SceneJS.Node
- 25      */
- 26     SceneJS.Name = SceneJS_NodeFactory.createNodeType("name");
- 27 
- 28     SceneJS.Name.prototype._init = function(params) {
- 29         if (this._core.useCount == 1) {
- 30             this.setName(params.name);
- 31         }
- 32     };
- 33 
- 34     SceneJS.Name.prototype.setName = function(name) {
- 35         this._core.name = name || "unnamed";
- 36         this._engine.display.imageDirty = true;
- 37     };
- 38 
- 39     SceneJS.Name.prototype.getName = function() {
- 40         return this._core.name;
- 41     };
- 42 
- 43     SceneJS.Name.prototype._compile = function() {
- 44         this._engine.display.name = coreStack[stackLen++] = this._core;
- 45         this._compileNodes();
- 46         this._engine.display.name = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore;
- 47     };
- 48 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_node.js.html b/docs/symbols/src/src_core_scene_node.js.html deleted file mode 100644 index c6a0fa64..00000000 --- a/docs/symbols/src/src_core_scene_node.js.html +++ /dev/null @@ -1,1161 +0,0 @@ -
  1 /**
-  2  * @class The basic scene graph node type
-  3  */
-  4 SceneJS.Node = function() {
-  5 };
-  6 
-  7 /**
-  8  * @class Basic scene graph node
-  9  */
- 10 SceneJS.Node.prototype.constructor = SceneJS.Node;
- 11 
- 12 /**
- 13  * Called by SceneJS_Engine after it has instantiated the node
- 14  *
- 15  * @param {SceneJS_Engine} engine The engine which will manage this node
- 16  * @param {SceneJS_Core} core The core which will hold state for this node, may be shared with other nodes of the same type
- 17  * @param cfg Configuration for this node
- 18  * @param {String} cfg.id ID for the node, unique among all nodes in the scene
- 19  * @param {String} cfg.type type Type of this node (eg. "material", "texture" etc)
- 20  * @param {Object} cfg.data Optional arbitrary JSON object to attach to node
- 21  * @param {String} nodeId Optional ID for node
- 22  */
- 23 SceneJS.Node.prototype._construct = function(engine, core, cfg, nodeId) {
- 24 
- 25     /**
- 26      * Engine that manages this node
- 27      * @type SceneJS_Engine
- 28      */
- 29     this._engine = engine;
- 30 
- 31     /**
- 32      * The core which holds state for this node, may be shared with other nodes of the same type
- 33      * @type SceneJS_Core
- 34      */
- 35     this._core = core;
- 36 
- 37     /**
- 38      * ID of this node, unique within its scene. The ID is a string if it was defined by the application
- 39      * via the node's JSON configuration, otherwise it is a number if it was left to SceneJS to automatically create.
- 40      * @type String|Number
- 41      */
- 42     this.id = cfg.id || cfg.nodeId || nodeId;
- 43 
- 44     /**
- 45      * Type of this node (eg. "material", "texture" etc)
- 46      * @type String
- 47      */
- 48     this.type = cfg.type || "node";
- 49 
- 50     /**
- 51      * Optional arbitrary JSON object attached to this node
- 52      * @type JSON
- 53      */
- 54     this.data = cfg.data;
- 55 
- 56     /**
- 57      * Parent node
- 58      * @type SceneJS.Node
- 59      */
- 60     this.parent = null;
- 61 
- 62     /**
- 63      * Child nodes
- 64      * @type SceneJS.Node[]
- 65      */
- 66     this.nodes = [];
- 67 
- 68     /**
- 69      *
- 70      */
- 71     this._listeners = {};
- 72 
- 73     /**
- 74      *
- 75      */
- 76     this._numListeners = 0; // Useful for quick check whether node observes any events
- 77 
- 78     /**
- 79      *
- 80      */
- 81     this.dirty = false;
- 82 
- 83     /**
- 84      *
- 85      */
- 86     this.branchDirty = false;
- 87 
- 88     if (this._init) {
- 89         this._init(cfg);
- 90     }
- 91 };
- 92 
- 93 
- 94 /**
- 95  * Returns this node's {@link SceneJS.Scene}
- 96  */
- 97 SceneJS.Node.prototype.getScene = function() {
- 98     return this._engine.scene;
- 99 };
-100 
-101 
-102 /**
-103  * Returns the ID of this node's core
-104  */
-105 SceneJS.Node.prototype.getCoreId = function() {
-106     return this._core.coreId;
-107 };
-108 
-109 /**
-110  * Get the node's ID
-111  *
-112  */
-113 SceneJS.Node.prototype.getID = function() {
-114     return this.id;
-115 };
-116 
-117 /**
-118  * Alias for getID
-119  *  @function
-120  */
-121 SceneJS.Node.prototype.getId = function() {
-122     return this.id;
-123 };
-124 
-125 /**
-126  * Alias for getID
-127  *  @function
-128  */
-129 SceneJS.Node.prototype.getNodeId = function() {
-130     return this.id;
-131 };
-132 
-133 
-134 /**
-135  * Returns the node's type. For the Node base class, it is "node", overridden in sub-classes.
-136  */
-137 SceneJS.Node.prototype.getType = function() {
-138     return this.type;
-139 };
-140 
-141 /**
-142  * Returns the data object attached to this node.
-143  */
-144 SceneJS.Node.prototype.getData = function() {
-145     return this.data;
-146 };
-147 
-148 /**
-149  * Sets a data object on this node.
-150  */
-151 SceneJS.Node.prototype.setData = function(data) {
-152     this.data = data;
-153     return this;
-154 };
-155 
-156 /**
-157  * Returns the number of child nodes
-158  */
-159 SceneJS.Node.prototype.getNumNodes = function() {
-160     return this.nodes.length;
-161 };
-162 
-163 /** Returns child nodes
-164  * @returns {Array} Child nodes
-165  */
-166 SceneJS.Node.prototype.getNodes = function() {
-167     return this.nodes.slice(0);
-168 };
-169 
-170 /** Returns child node at given index. Returns null if no node at that index.
-171  * @param {Number} index The child index
-172  * @returns {Node} Child node, or null if not found
-173  */
-174 SceneJS.Node.prototype.getNodeAt = function(index) {
-175     if (index < 0 || index >= this.nodes.length) {
-176         return null;
-177     }
-178     return this.nodes[index];
-179 };
-180 
-181 /** Returns first child node. Returns null if no child nodes.
-182  * @returns {Node} First child node, or null if not found
-183  */
-184 SceneJS.Node.prototype.getFirstNode = function() {
-185     if (this.nodes.length == 0) {
-186         return null;
-187     }
-188     return this.nodes[0];
-189 };
-190 
-191 /** Returns last child node. Returns null if no child nodes.
-192  * @returns {Node} Last child node, or null if not found
-193  */
-194 SceneJS.Node.prototype.getLastNode = function() {
-195     if (this.nodes.length == 0) {
-196         return null;
-197     }
-198     return this.nodes[this.nodes.length - 1];
-199 };
-200 
-201 /** Returns child node with the given ID.
-202  * Returns null if no such child node found.
-203  */
-204 SceneJS.Node.prototype.getNode = function(id) {
-205     for (var i = 0; i < this.nodes.length; i++) {
-206         if (this.nodes[i].id == id) {
-207             return this.nodes[i];
-208         }
-209     }
-210     return null;
-211 };
-212 
-213 /** Disconnects the child node at the given index from its parent node
-214  * @param {int} index Child node index
-215  * @returns {Node} The disconnected child node if located, else null
-216  */
-217 SceneJS.Node.prototype.disconnectNodeAt = function(index) {
-218     var r = this.nodes.splice(index, 1);
-219     if (r.length > 0) {
-220         r[0].parent = null;
-221         this._engine.display.objectListDirty = true;
-222         return r[0];
-223     } else {
-224         return null;
-225     }
-226 };
-227 
-228 /** Disconnects the child node from its parent, given as a node object
-229  * @param {String | Node} id The target child node, or its ID
-230  * @returns {Node} The removed child node if located
-231  */
-232 SceneJS.Node.prototype.disconnect = function() {
-233     if (this.parent) {
-234         for (var i = 0; i < this.parent.nodes.length; i++) {
-235             if (this.parent.nodes[i] === this) {
-236                 return this.parent.disconnectNodeAt(i);
-237             }
-238         }
-239     }
-240     return null;
-241 };
-242 
-243 /** Removes the child node at the given index
-244  * @param {int} index Child node index
-245  */
-246 SceneJS.Node.prototype.removeNodeAt = function(index) {
-247     var child = this.disconnectNodeAt(index);
-248     if (child) {
-249         child.destroy();
-250         this._engine.display.objectListDirty = true;
-251     }
-252 };
-253 
-254 /** Removes the child node, given as either a node object or an ID string.
-255  * @param {String | Node} id The target child node, or its ID
-256  * @returns {Node} The removed child node if located
-257  */
-258 SceneJS.Node.prototype.removeNode = function(node) {
-259 
-260     if (!node) {
-261         throw SceneJS_error.fatalError(
-262                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
-263                 "Node#removeNode - node argument undefined");
-264     }
-265 
-266     if (!node._compile) {
-267         if (typeof node == "string") {
-268             var gotNode = this._engine.nodes.items[node];
-269             if (!gotNode) {
-270                 throw SceneJS_error.fatalError(
-271                         SceneJS.errors.NODE_NOT_FOUND,
-272                         "Node#removeNode - node not found anywhere: '" + node + "'");
-273             }
-274             node = gotNode;
-275         }
-276     }
-277 
-278     if (node._compile) { //  instance of node
-279         for (var i = 0; i < this.nodes.length; i++) {
-280             if (this.nodes[i] === node) {
-281                 var removedNode = this.removeNodeAt(i);
-282                 this._engine.display.objectListDirty = true;
-283                 return removedNode;
-284             }
-285         }
-286     }
-287 
-288     throw SceneJS_error.fatalError(
-289             SceneJS.errors.NODE_NOT_FOUND,
-290             "Node#removeNode - child node not found: " + (node._compile ? ": " + node.id : node));
-291 };
-292 
-293 /** Disconnects all child nodes from their parent node and returns them in an array.
-294  */
-295 SceneJS.Node.prototype.disconnectNodes = function() {
-296 
-297     var len = this.nodes.length;
-298 
-299     for (var i = 0; i < len; i++) {  // Unlink nodes from this
-300         this.nodes[i].parent = null;
-301     }
-302 
-303     var nodes = this.nodes;
-304 
-305     this.nodes = [];
-306 
-307     this._engine.display.objectListDirty = true;
-308 
-309     return nodes;
-310 };
-311 
-312 /** Removes all child nodes and returns them in an array.
-313  */
-314 SceneJS.Node.prototype.removeNodes = function() {
-315     var nodes = this.disconnectNodes();
-316     for (var i = 0; i < nodes.length; i++) {
-317         this.nodes[i].destroy();
-318         this._engine.display.objectListDirty = true;
-319     }
-320 };
-321 
-322 /** Destroys this node and moves children up to parent, inserting them where this node resided.
-323  */
-324 SceneJS.Node.prototype.splice = function() {
-325 
-326     var i, len;
-327 
-328     if (this.parent == null) {
-329         return null;
-330     }
-331     var parent = this.parent;
-332     var nodes = this.disconnectNodes();
-333     for (i = 0,len = nodes.length; i < len; i++) {  // Link this node's nodes to new parent
-334         nodes[i].parent = this.parent;
-335     }
-336     for (i = 0,len = parent.nodes.length; i < len; i++) { // Replace node on parent's nodes with this node's nodes
-337         if (parent.nodes[i] === this) {
-338 
-339             parent.nodes.splice.apply(parent.nodes, [i, 1].concat(nodes));
-340 
-341             this.nodes = [];
-342             this.parent = null;
-343 
-344             this.destroy();
-345 
-346             this._engine.branchDirty(parent);
-347 
-348             return parent;
-349         }
-350     }
-351 };
-352 
-353 /** Appends multiple child nodes
-354  */
-355 SceneJS.Node.prototype.addNodes = function(nodes) {
-356 
-357     if (!nodes) {
-358         throw SceneJS_error.fatalError(
-359                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
-360                 "Node#addNodes - nodes argument is undefined");
-361     }
-362 
-363     var node;
-364     var result = [];
-365 
-366     for (var i = nodes.length - 1; i >= 0; i--) {
-367 
-368         node = this.addNode(nodes[i]);
-369 
-370         result[i] = node;
-371 
-372         this._engine.branchDirty(node); // Schedule compilation of new node
-373     }
-374 
-375     return result;
-376 };
-377 
-378 /** Appends a child node
-379  */
-380 SceneJS.Node.prototype.addNode = function(node) {
-381 
-382     if (!node) {
-383         throw SceneJS_error.fatalError(
-384                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
-385                 "Node#addNode - node argument is undefined");
-386     }
-387 
-388     if (!node._compile) {
-389         if (typeof node == "string") {
-390             var gotNode = this._engine.nodes.items[node];
-391             if (!gotNode) {
-392                 throw SceneJS_error.fatalError(
-393                         SceneJS.errors.ILLEGAL_NODE_CONFIG,
-394                         "Node#addNode - node not found: '" + node + "'");
-395             }
-396             node = gotNode;
-397         } else {
-398             node = this._engine.createNode(node);
-399         }
-400     }
-401 
-402     if (!node._compile) {
-403         throw SceneJS_error.fatalError(
-404                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
-405                 "Node#addNode - node argument is not a Node or subclass");
-406     }
-407 
-408     if (node.parent != null) {
-409         throw SceneJS_error.fatalError(
-410                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
-411                 "Node#addNode - node argument is still attached to another parent");
-412     }
-413 
-414     this.nodes.push(node);
-415 
-416     node.parent = this;
-417 
-418     this._engine.branchDirty(node);
-419 
-420     return node;
-421 };
-422 
-423 /** Inserts a subgraph into child nodes
-424  * @param {Node} node Child node
-425  * @param {int} i Index for new child node
-426  * @return {Node} The child node
-427  */
-428 SceneJS.Node.prototype.insertNode = function(node, i) {
-429 
-430     if (!node) {
-431         throw SceneJS_error.fatalError(
-432                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
-433                 "Node#insertNode - node argument is undefined");
-434     }
-435 
-436     if (!node._compile) {
-437         node = this._engine.createNode(node);
-438     }
-439 
-440     if (!node._compile) {
-441         throw SceneJS_error.fatalError(
-442                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
-443                 "Node#insertNode - node argument is not a Node or subclass!");
-444     }
-445 
-446     if (node.parent != null) {
-447         throw SceneJS_error.fatalError(
-448                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
-449                 "Node#insertNode - node argument is still attached to another parent!");
-450     }
-451 
-452     if (i == undefined || i == null) {
-453 
-454         /* Insert node above nodes when no index given
-455          */
-456         var nodes = this.disconnectNodes();
-457 
-458         /* Move nodes to right-most leaf of inserted graph
-459          */
-460         var leaf = node;
-461         while (leaf.getNumNodes() > 0) {
-462             leaf = leaf.getLastNode();
-463         }
-464 
-465         leaf.addNodes(nodes);
-466 
-467         this.addNode(node);
-468 
-469     } else if (i < 0) {
-470 
-471         throw SceneJS_error.fatalError(
-472                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
-473                 "Node#insertNode - node index out of range: -1");
-474 
-475     } else if (i >= this.nodes.length) {
-476         this.nodes.push(node);
-477 
-478     } else {
-479         this.nodes.splice(i, 0, node);
-480     }
-481 
-482     node.parent = this;
-483     return node;
-484 };
-485 
-486 /** Calls the given function on each node in the subgraph rooted by this node, including this node.
-487  * The callback takes each node as it's sole argument and traversal stops as soon as the function returns
-488  * true and returns the node.
-489  * @param {function(Node)} func The function
-490  */
-491 SceneJS.Node.prototype.mapNodes = function(func) {
-492     if (func(this)) {
-493         return this;
-494     }
-495     var result;
-496     for (var i = 0; i < this.nodes.length; i++) {
-497         result = this.nodes[i].mapNodes(func);
-498         if (result) {
-499             return result;
-500         }
-501     }
-502     return null;
-503 };
-504 
-505 /**
-506  * Registers a listener for a given event on this node. If the event type
-507  * is not supported by this node type, then the listener will never be called.
-508  * <p><b>Example:</b>
-509  * <pre><code>
-510  * var node = new Node();
-511  *
-512  * node.addListener(
-513  *
-514  *              // eventName
-515  *              "some-event",
-516  *
-517  *              // handler
-518  *              function(node,      // Node we are listening to
-519  *                       params) {  // Whatever params accompany the event type
-520  *
-521  *                     // ...
-522  *              }
-523  * );
-524  *
-525  *
-526  * </code></pre>
-527  *
-528  * @param {String} eventName One of the event types supported by this node
-529  * @param {Function} fn - Handler function that be called as specified
-530  * @param options - Optional options for the handler as specified
-531  * @return {Node} this
-532  */
-533 SceneJS.Node.prototype.addListener = function(eventName, fn, options) {
-534     var list = this._listeners[eventName];
-535     if (!list) {
-536         list = [];
-537         this._listeners[eventName] = list;
-538     }
-539     list.push({
-540         eventName : eventName,
-541         fn: fn,
-542         options : options || {}
-543     });
-544     this._numListeners++;
-545     return this;
-546 };
-547 
-548 /**
-549  * Fires an event at this node, immediately calling listeners registered for the event
-550  */
-551 SceneJS.Node.prototype._fireEvent = function(eventName, params, options) {
-552     var list = this._listeners[eventName];
-553     if (list) {
-554         if (!params) {
-555             params = {};
-556         }
-557         var event = {
-558             name: eventName,
-559             params : params,
-560             options: options || {}
-561         };
-562         var listener;
-563         for (var i = 0, len = list.length; i < len; i++) {
-564             listener = list[i];
-565             if (listener.options.scope) {
-566                 listener.fn.call(listener.options.scope, event);
-567             } else {
-568                 listener.fn.call(this, event);
-569             }
-570         }
-571     }
-572 };
-573 
-574 /**
-575  * Removes a handler that is registered for the given event on this node.
-576  * Does nothing if no such handler registered.
-577  */
-578 SceneJS.Node.prototype.removeListener = function(eventName, fn) {
-579     var list = this._listeners[eventName];
-580     if (!list) {
-581         return null;
-582     }
-583     for (var i = 0; i < list.length; i++) {
-584         if (list[i].fn == fn) {
-585             list.splice(i, 1);
-586             return fn;
-587         }
-588     }
-589     this._numListeners--;
-590     return null;
-591 };
-592 
-593 /**
-594  * Returns true if this node has any listeners for the given event
-595  */
-596 SceneJS.Node.prototype.hasListener = function(eventName) {
-597     return this._listeners[eventName];
-598 };
-599 
-600 /**
-601  * Returns true if this node has any listeners at all.
-602  */
-603 SceneJS.Node.prototype.hasListeners = function() {
-604     return (this._numListeners > 0);
-605 };
-606 
-607 /** Removes all listeners registered on this node.
-608  */
-609 SceneJS.Node.prototype.removeListeners = function() {
-610     this._listeners = {};
-611     this._numListeners = 0;
-612     return this;
-613 };
-614 
-615 /** Returns the parent node
-616  */
-617 SceneJS.Node.prototype.getParent = function() {
-618     return this.parent;
-619 };
-620 
-621 /**
-622  * Iterates over parent nodes on the path from the selected node to the root, executing a function
-623  * for each.
-624  * If the function returns true at any node, then traversal stops and a selector is
-625  * returned for that node.
-626  * @param {Function(node, index)} fn Function to execute on each instance node
-627  * @return {Object} Selector for selected node, if any
-628  */
-629 SceneJS.Node.prototype.eachParent = function(fn) {
-630 
-631     if (!fn) {
-632         throw "SceneJS.Node.eachParent param 'fn' is null or undefined";
-633     }
-634 
-635     var count = 0;
-636     var node = this;
-637 
-638     while (node.parent) {
-639         if (fn.call(node.parent, count++) === true) {
-640             return node.parent;
-641         }
-642         node = node.parent;
-643     }
-644 
-645     return null;
-646 };
-647 
-648 /** Returns true if a child node matching given ID or index exists on this node
-649  * @param {Number|String} node Child node index or ID
-650  */
-651 SceneJS.Node.prototype.hasNode = function(node) {
-652 
-653     if (node === null || node === undefined) {
-654         throw "SceneJS.Node.hasNode param 'node' is null or undefined";
-655     }
-656 
-657     var type = typeof node;
-658     var nodeGot;
-659 
-660     if (type == "number") {
-661         nodeGot = this.getNodeAt(node);
-662 
-663     } else if (type == "string") {
-664         nodeGot = this.getNode(node);
-665 
-666     } else {
-667         throw "SceneJS.Node.hasNode param 'node' should be either an index number or an ID string";
-668     }
-669 
-670     return (nodeGot != undefined && nodeGot != null);
-671 };
-672 
-673 /** Selects a child node matching given ID or index
-674  * @param {Number|String} node Child node index or ID
-675  */
-676 SceneJS.Node.prototype.node = function(node) {
-677 
-678     if (node === null || node === undefined) {
-679         throw "SceneJS.Node.node param 'node' is null or undefined";
-680     }
-681 
-682     var type = typeof node;
-683     var nodeGot;
-684 
-685     if (type == "number") {
-686         nodeGot = this.getNodeAt(node);
-687 
-688     } else if (type == "string") {
-689         nodeGot = this.getNode(node);
-690 
-691     } else {
-692         throw "SceneJS.Node.node param 'node' should be either an index number or an ID string";
-693     }
-694 
-695     if (!nodeGot) {
-696         throw "SceneJS.Node.node - node not found: '" + node + "'";
-697     }
-698 
-699     return nodeGot;
-700 };
-701 
-702 /**
-703  * Iterates over sub-nodes of the selected node, executing a function
-704  * for each. With the optional options object we can configure is depth-first or breadth-first order.
-705  * If neither, then only the child nodes are iterated.
-706  * If the function returns true at any node, then traversal stops and a selector is
-707  * returned for that node.
-708  * @param {Function(index, node)} fn Function to execute on each child node
-709  * @return {Object} Selector for selected node, if any
-710  */
-711 SceneJS.Node.prototype.eachNode = function(fn, options) {
-712 
-713     if (!fn) {
-714         throw "SceneJS.Node.eachNode param 'fn' is null or undefined";
-715     }
-716 
-717     if (typeof fn != "function") {
-718         throw "SceneJS.Node.eachNode param 'fn' should be a function";
-719     }
-720 
-721     var stoppedNode;
-722     options = options || {};
-723     var count = 0;
-724 
-725     if (options.andSelf) {
-726         if (fn.call(this, count++) === true) {
-727             return this;
-728         }
-729     }
-730 
-731     if (!options.depthFirst && !options.breadthFirst) {
-732         stoppedNode = this._iterateEachNode(fn, this, count);
-733 
-734     } else if (options.depthFirst) {
-735         stoppedNode = this._iterateEachNodeDepthFirst(fn, this, count, false); // Not below root yet
-736 
-737     } else {
-738         // TODO: breadth-first
-739     }
-740 
-741     if (stoppedNode) {
-742         return stoppedNode;
-743     }
-744 
-745     return undefined; // IDE happy now
-746 };
-747 
-748 SceneJS.Node.prototype.numNodes = function() {
-749     return this.nodes.length;
-750 };
-751 
-752 SceneJS.Node.prototype._iterateEachNode = function(fn, node, count) {
-753 
-754     var len = node.nodes.length;
-755     var child;
-756 
-757     for (var i = 0; i < len; i++) {
-758         child = node.nodes[i];
-759 
-760         if (fn.call(child, count++) === true) {
-761             return child;
-762         }
-763     }
-764 
-765     return null;
-766 };
-767 
-768 SceneJS.Node.prototype._iterateEachNodeDepthFirst = function(fn, node, count, belowRoot) {
-769 
-770     if (belowRoot) {
-771 
-772         /* Visit this node - if we are below root, because entry point visits the root
-773          */
-774         if (fn.call(node, count++) === true) {
-775             return node;
-776         }
-777     }
-778 
-779     belowRoot = true;
-780 
-781     /* Iterate nodes
-782      */
-783     var len = node.nodes.length;
-784     var child;
-785     for (var i = 0; i < len; i++) {
-786         child = this._iterateEachNodeDepthFirst(fn, node.nodes[i], count, belowRoot);
-787         if (child) {
-788             return child;
-789         }
-790     }
-791 
-792     return null;
-793 };
-794 
-795 /** Returns either all child or all sub-nodes of the given type, depending on whether search is recursive or not.
-796  */
-797 SceneJS.Node.prototype.findNodesByType = function(type, recursive) {
-798     return this._findNodesByType(type, [], recursive);
-799 };
-800 
-801 SceneJS.Node.prototype._findNodesByType = function(type, list, recursive) {
-802     var i;
-803     for (i = 0; i < this.nodes; i++) {
-804         var node = this.nodes[i];
-805         if (node.type == type) {
-806             list.add(node);
-807         }
-808     }
-809     if (recursive) {
-810         for (i = 0; i < this.nodes; i++) {
-811             this.nodes[i]._findNodesByType(type, list, recursive);
-812         }
-813     }
-814     return list;
-815 };
-816 
-817 /** Finds the first node on path up to root whose type equals that given
-818  */
-819 SceneJS.Node.prototype.findParentByType = function(type) {
-820     var parent = this.parent;
-821     while (parent && parent.type != type) {
-822         parent = parent.parent;
-823     }
-824     return parent;
-825 };
-826 
-827 
-828 /**
-829  * Given a map of name-value pairs, calls a getter method for each name,
-830  * feeding into it the corresponding value.
-831  *
-832  * @param attr
-833  * @param value
-834  * @return {*}
-835  */
-836 SceneJS.Node.prototype.set = function(attr, value) {
-837 
-838     if (typeof attr == "object") { // Attribute map - recurse for each attribute
-839         for (var subAttr in attr) {
-840             if (attr.hasOwnProperty(subAttr)) {
-841                 this.set(subAttr, attr[subAttr]);
-842             }
-843         }
-844         return;
-845     }
-846 
-847     if (this._set) {
-848         var method = this._set[attr];
-849         if (method) {
-850             return method.call(this, value);
-851         }
-852     }
-853 
-854     return this._createAccessor("set", attr, value);
-855 };
-856 
-857 SceneJS.Node.prototype.get = function(attr) {
-858 
-859     if (this._get) {
-860         var method = this._get[attr];
-861         if (method) {
-862             return method.call(this);
-863         }
-864     }
-865 
-866     return this._createAccessor("get", attr);
-867 };
-868 
-869 SceneJS.Node.prototype.add = function(attr, value) {
-870 
-871     if (typeof attr == "object") { // Attribute map - recurse for each attribute
-872         for (var subAttr in attr) {
-873             if (attr.hasOwnProperty(subAttr)) {
-874                 this.add(subAttr, attr[subAttr]);
-875             }
-876         }
-877         return;
-878     }
-879 
-880     if (this._add) {
-881         var method = this._add[attr];
-882         if (method) {
-883             return method.call(this, value);
-884         }
-885     }
-886 
-887     return this._createAccessor("add", attr, value);
-888 };
-889 
-890 SceneJS.Node.prototype.inc = function(attr, value) {
-891 
-892     if (typeof attr == "object") { // Attribute map - recurse for each attribute
-893         for (var subAttr in attr) {
-894             if (attr.hasOwnProperty(subAttr)) {
-895                 this.inc(subAttr, attr[subAttr]);
-896             }
-897         }
-898         return;
-899     }
-900 
-901     if (this._inc) {
-902         var method = this._inc[attr];
-903         if (method) {
-904             return method.call(this, value);
-905         }
-906     }
-907 
-908     return this._createAccessor("inc", attr, value);
-909 };
-910 
-911 SceneJS.Node.prototype.insert = function(attr, value) {
-912 
-913     if (typeof attr == "object") { // Attribute map - recurse for each attribute
-914         for (var subAttr in attr) {
-915             if (attr.hasOwnProperty(subAttr)) {
-916                 this.insert(subAttr, attr[subAttr]);
-917             }
-918         }
-919         return;
-920     }
-921 
-922     if (this._set) {
-923         var method = this._set[attr];
-924         if (method) {
-925             return method.call(this, value);
-926         }
-927     }
-928 
-929     return this._createAccessor("insert", attr, value);
-930 };
-931 
-932 SceneJS.Node.prototype.remove = function(attr, value) {
-933 
-934     if (typeof attr == "object") { // Attribute map - recurse for each attribute
-935         for (var subAttr in attr) {
-936             if (attr.hasOwnProperty(subAttr)) {
-937                 this.remove(subAttr, attr[subAttr]);
-938             }
-939         }
-940         return;
-941     }
-942 
-943     if (this._remove) {
-944         var method = this._remove[attr];
-945         if (method) {
-946             return method.call(this, value);
-947         }
-948     }
-949 
-950     return this._createAccessor("remove", attr, value);
-951 };
-952 
-953 SceneJS.Node.prototype._createAccessor = function(op, attr, value) {
-954 
-955     var methodName = op + attr.substr(0, 1).toUpperCase() + attr.substr(1);
-956 
-957     var method = this[methodName];
-958 
-959     if (!method) {
-960         throw "Method not found on node: '" + methodName + "'";
-961     }
-962 
-963     //var proto = (this.type == "node") ? SceneJS.Node.prototype : this._engine.nodeTypes[this.type].prototype;
-964 
-965     var proto = this.__proto__;
-966 
-967     var accessors;
-968     switch (op) {
-969         case "set":
-970             accessors = (proto._set || (proto._set = {}));
-971             break;
-972 
-973         case "get":
-974             accessors = (proto._get || (proto._get = {}));
-975             break;
-976 
-977         case "inc":
-978             accessors = (proto._inc || (proto._inc = {}));
-979             break;
-980 
-981         case "add":
-982             accessors = (proto._add || (proto._add = {}));
-983             break;
-984 
-985         case "insert":
-986             accessors = (proto._insert || (proto._insert = {}));
-987             break;
-988 
-989         case "remove":
-990             accessors = (proto._remove || (proto._remove = {}));
-991             break;
-992     }
-993 
-994     accessors[attr] = method;
-995 
-996     return method.call(this, value); // value can be undefined
-997 };
-998 
-999 /** Binds a listener to an event on the selected node
-1000  *
-1001  * @param {String} name Event name
-1002  * @param {Function} handler Event handler
-1003  */
-1004 SceneJS.Node.prototype.bind = function(name, handler) {
-1005 
-1006     if (!name) {
-1007         throw "SceneJS.Node.bind param 'name' null or undefined";
-1008     }
-1009 
-1010     if (typeof name != "string") {
-1011         throw "SceneJS.Node.bind param 'name' should be a string";
-1012     }
-1013 
-1014     if (!handler) {
-1015         throw "SceneJS.Node.bind param 'handler' null or undefined";
-1016     }
-1017 
-1018     if (typeof handler != "function") {
-1019         throw "SceneJS.Node.bind param 'handler' should be a function";
-1020     }
-1021 
-1022     this.addListener(name, handler, { scope: this });
-1023 
-1024     this._engine.branchDirty(this);
-1025 
-1026     return this;
-1027 };
-1028 
-1029 /** Unbinds a listener for an event on the selected node
-1030  *
-1031  * @param {String} name Event name
-1032  * @param {Function} handler Event handler
-1033  */
-1034 SceneJS.Node.prototype.unbind = function(name, handler) {
-1035     if (!name) {
-1036         throw "SceneJS.Node.bind param 'name' null or undefined";
-1037     }
-1038     if (typeof name != "string") {
-1039         throw "SceneJS.Node.bind param 'name' should be a string";
-1040     }
-1041     if (!handler) {
-1042         throw "SceneJS.Node.bind param 'handler' null or undefined";
-1043     }
-1044     if (typeof handler != "function") {
-1045         throw "SceneJS.Node.bind param 'handler' should be a function";
-1046     }
-1047 
-1048     this.removeListener(name, handler);
-1049 
-1050     this._engine.branchDirty(this);
-1051 
-1052     return this;
-1053 };
-1054 
-1055 /**
-1056  * Returns an object containing the attributes that were given when creating the node. Obviously, the map will have
-1057  * the current values, plus any attributes that were later added through set/add methods on the node
-1058  *
-1059  */
-1060 SceneJS.Node.prototype.getJSON = function() {
-1061     return this;
-1062 };
-1063 
-1064 
-1065 SceneJS.Node.prototype._compile = function() {
-1066     this._compileNodes();
-1067 };
-1068 
-1069 SceneJS.Node.prototype._compileNodes = function() {
-1070 
-1071     var renderListeners = this._listeners["rendered"];
-1072 
-1073     if (renderListeners) {
-1074         SceneJS_nodeEventsModule.preVisitNode(this);
-1075     }
-1076 
-1077     var child;
-1078 
-1079     for (var i = 0, len = this.nodes.length; i < len; i++) {
-1080 
-1081         child = this.nodes[i];
-1082 
-1083         child.branchDirty = child.branchDirty || this.branchDirty; // Compile subnodes if scene branch dirty
-1084 
-1085         if (child.dirty || child.branchDirty || this._engine.sceneDirty) {  // Compile nodes that are flagged dirty
-1086 
-1087             child._compile();
-1088 
-1089             child.dirty = false;
-1090             child.branchDirty = false;
-1091         }
-1092     }
-1093 
-1094     if (renderListeners) {
-1095         SceneJS_nodeEventsModule.postVisitNode(this);
-1096     }
-1097 };
-1098 
-1099 
-1100 /**
-1101  * Destroys this node. It is marked for destruction; when the next scene traversal begins (or the current one ends)
-1102  * it will be destroyed and removed from it's parent.
-1103  */
-1104 SceneJS.Node.prototype.destroy = function() {
-1105 
-1106     if (!this.destroyed) {
-1107 
-1108         if (this.parent) {
-1109 
-1110             /* Remove from parent's child node list
-1111              */
-1112             for (var i = 0; i < this.nodes.length; i++) {
-1113                 if (this.parent.nodes[i].id === this.id) {
-1114                     this.parent.nodes.splice(i, 1);
-1115                     break;
-1116                 }
-1117             }
-1118         }
-1119 
-1120         /* Recusrsively destroy child nodes without
-1121          * bothering to remove them from their parents
-1122          */
-1123         this._destroyTree();
-1124 
-1125         /* Need object list recompilation on display
-1126          */
-1127         this._engine.display.objectListDirty = true;
-1128     }
-1129 
-1130     return this;
-1131 };
-1132 
-1133 SceneJS.Node.prototype._destroyTree = function() {
-1134 
-1135     this.destroyed = true;
-1136 
-1137     this._engine.destroyNode(this); // Release node object
-1138 
-1139     for (var i = 0, len = this.nodes.length; i < len; i++) {
-1140         this.nodes[i]._destroyTree();
-1141     }
-1142 };
-1143 
-1144 /**
-1145  * Performs the actual destruction of this node, calling the node's optional template destroy method
-1146  */
-1147 SceneJS.Node.prototype._doDestroy = function() {
-1148 
-1149     if (this._destroy) {  // Call destruction handler for each node subclass
-1150         this._destroy();
-1151     }
-1152 
-1153     return this;
-1154 };
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_nodeEvents.js.html b/docs/symbols/src/src_core_scene_nodeEvents.js.html deleted file mode 100644 index e1566adc..00000000 --- a/docs/symbols/src/src_core_scene_nodeEvents.js.html +++ /dev/null @@ -1,87 +0,0 @@ -
  1 /**
-  2  * Manages scene node event listeners
-  3  * @private
-  4  */
-  5 var SceneJS_nodeEventsModule = new (function() {
-  6 
-  7     var idStack = [];
-  8     var listenerStack = [];
-  9     var stackLen = 0;
- 10     var dirty;
- 11 
- 12     var defaultCore = {
- 13         type: "listeners",
- 14         stateId: SceneJS._baseStateId++,
- 15         empty: true,
- 16         listeners:  []
- 17     };
- 18 
- 19     SceneJS_events.addListener(
- 20             SceneJS_events.SCENE_COMPILING,
- 21             function() {
- 22                 stackLen = 0;
- 23                 dirty = true;
- 24             });
- 25 
- 26     SceneJS_events.addListener(
- 27             SceneJS_events.OBJECT_COMPILING,
- 28             function(params) {
- 29 
- 30                 if (dirty) {
- 31 
- 32                     if (stackLen > 0) {
- 33 
- 34                         var core = {
- 35                             type: "listeners",
- 36                             stateId: idStack[stackLen - 1],
- 37                             listeners: listenerStack.slice(0, stackLen)
- 38                         };
- 39 
- 40                         params.display.renderListeners = core;
- 41 
- 42                     } else {
- 43 
- 44                         params.display.renderListeners = defaultCore;
- 45                     }
- 46 
- 47                     dirty = false;
- 48                 }
- 49             });
- 50 
- 51     this.preVisitNode = function(node) {
- 52 
- 53         var listeners = node._listeners["rendered"];
- 54 
- 55         if (listeners && listeners.length > 0) {
- 56             idStack[stackLen] = node.id;
- 57 
- 58             var fn = node.__fireRenderedEvent;
- 59             if (!fn) {
- 60                 fn = node.__fireRenderedEvent = function (params) {
- 61                     node._fireEvent("rendered", params);
- 62                 };
- 63             }
- 64 
- 65             listenerStack[stackLen] = fn;
- 66             stackLen++;
- 67             dirty = true;
- 68         }
- 69     };
- 70 
- 71     this.postVisitNode = function(node) {
- 72         if (node.id == idStack[stackLen - 1]) {
- 73             stackLen--;
- 74             dirty = true;
- 75         }
- 76     };
- 77 
- 78 })();
- 79 
- 80 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_nodeFactory.js.html b/docs/symbols/src/src_core_scene_nodeFactory.js.html deleted file mode 100644 index d633a135..00000000 --- a/docs/symbols/src/src_core_scene_nodeFactory.js.html +++ /dev/null @@ -1,91 +0,0 @@ -
  1 /**
-  2  * @class Manages creation, recycle and destruction of {@link SceneJS.Node} instances
-  3  * @private
-  4  */
-  5 var SceneJS_NodeFactory = function() {
-  6 
-  7     this.nodes = new SceneJS_Map({});
-  8 };
-  9 
- 10 /**
- 11  * Scene graph node classes provided by the SceneJS_NodeFactory class
- 12  *
- 13  * @type {[SceneJS.Node]}
- 14  */
- 15 SceneJS_NodeFactory.nodeTypes = {};    // Supported node classes, installed by #createNodeType
- 16 
- 17 /**
- 18  * Creates a node class for instantiation by this factory
- 19  *
- 20  * @param {String} nodeTypeName Name of type, eg. "rotate"
- 21  * @param {String} coreTypeName Optional name of core type for the node, eg. "xform" - defaults to type name of node
- 22  * @returns The new node class
- 23  */
- 24 SceneJS_NodeFactory.createNodeType = function(nodeTypeName, coreTypeName) {
- 25 
- 26     var nodeType = function() { // Create the class
- 27         SceneJS.Node.apply(this, arguments);
- 28         this.type = nodeTypeName;
- 29     };
- 30 
- 31     nodeType.prototype = new SceneJS.Node();            // Inherit from base class
- 32     nodeType.prototype.constructor = nodeType;
- 33 
- 34     SceneJS_NodeFactory.nodeTypes[nodeTypeName] = nodeType;
- 35 
- 36     return nodeType;
- 37 };
- 38 
- 39 /**
- 40  *
- 41  */
- 42 SceneJS_NodeFactory.prototype.getNode = function(engine, json, core) {
- 43 
- 44     json.type = json.type || "node"; // Nodes are SceneJS.Node type by default
- 45 
- 46     var nodeType;
- 47 
- 48     if (json.type == "node") {
- 49 
- 50         nodeType = SceneJS.Node;
- 51 
- 52     } else {
- 53 
- 54         nodeType = SceneJS_NodeFactory.nodeTypes[json.type];
- 55 
- 56         if (!nodeType) {
- 57             throw SceneJS_error.fatalError("node type not supported: '" + json.type + "'");
- 58         }
- 59     }
- 60 
- 61     var node = new nodeType();
- 62 
- 63     var id = json.id || json.nodeId; // 'id' and 'nodeId' are aliases
- 64 
- 65     if (id) {
- 66         this.nodes.addItem(id, node);
- 67 
- 68     } else {
- 69         id = this.nodes.addItem(node);
- 70     }
- 71 
- 72     node._construct(engine, core, json, id); // Instantiate node
- 73 
- 74     return node;
- 75 };
- 76 
- 77 /**
- 78  * Releases a node back to this factory
- 79  */
- 80 SceneJS_NodeFactory.prototype.putNode = function(node) {
- 81 
- 82     this.nodes.removeItem(node.id);
- 83 };
- 84 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_renderer.js.html b/docs/symbols/src/src_core_scene_renderer.js.html deleted file mode 100644 index d5774432..00000000 --- a/docs/symbols/src/src_core_scene_renderer.js.html +++ /dev/null @@ -1,787 +0,0 @@ -
  1 new (function() {
-  2 
-  3     /**
-  4      * The default state core singleton for {@link SceneJS.Renderer} nodes
-  5      */
-  6     var defaultCore = {
-  7         type: "renderer",
-  8         stateId: SceneJS._baseStateId++,
-  9         props: null
- 10     };
- 11 
- 12     var canvas;         // Currently active canvas
- 13     var coreStack = [];
- 14     var stackLen = 0;
- 15 
- 16     SceneJS_events.addListener(
- 17             SceneJS_events.SCENE_COMPILING,
- 18             function(params) {
- 19 
- 20                 canvas = params.engine.canvas;
- 21 
- 22 //                // TODO: Below is a HACK
- 23 //
- 24 //                defaultCore.props = createProps({  // Dont set props - just define for restoring to on props pop
- 25 //                    clear: {
- 26 //                        depth : true,
- 27 //                        color : true
- 28 //                    },
- 29 //                    // clearColor: {r: 0, g : 0, b : 0 },
- 30 //                    clearDepth: 1.0,
- 31 //                    enableDepthTest:true,
- 32 //                    enableCullFace: false,
- 33 //                    frontFace: "ccw",
- 34 //                    cullFace: "back",
- 35 //                    depthFunc: "less",
- 36 //                    depthRange: {
- 37 //                        zNear: 0,
- 38 //                        zFar: 1
- 39 //                    },
- 40 //                    enableScissorTest: false,
- 41 //                    viewport:{
- 42 //                        x : 1,
- 43 //                        y : 1,
- 44 //                        width: canvas.canvas.width,
- 45 //                        height: canvas.canvas.height
- 46 //                    },
- 47 //                    enableClip: undefined,
- 48 //                    enableBlend: false,
- 49 //                    blendFunc: {
- 50 //                        sfactor: "srcAlpha",
- 51 //                        dfactor: "one"
- 52 //                    }
- 53 //                });
- 54 
- 55                 stackLen = 0;
- 56 
- 57                 params.engine.display.renderer = coreStack[stackLen++] = defaultCore;
- 58             });
- 59 
- 60     function createProps(props) {
- 61 
- 62         var restore;
- 63         if (stackLen > 0) {  // can't restore when no previous props set
- 64             restore = {};
- 65             for (var name in props) {
- 66                 if (props.hasOwnProperty(name)) {
- 67                     if (!(props[name] == undefined)) {
- 68                         restore[name] = getSuperProperty(name);
- 69                     }
- 70                 }
- 71             }
- 72         }
- 73 
- 74         processProps(props.props);
- 75 
- 76         return {
- 77 
- 78             props: props,
- 79 
- 80             setProps: function(gl) {
- 81                 setProperties(gl, props);
- 82             },
- 83 
- 84             restoreProps : function(gl) {
- 85                 if (restore) {
- 86                     restoreProperties(gl, restore);
- 87                 }
- 88             }
- 89         };
- 90     }
- 91 
- 92     var getSuperProperty = function(name) {
- 93         var props;
- 94         var prop;
- 95         for (var i = stackLen - 1; i >= 0; i--) {
- 96             props = coreStack[i].props;
- 97             prop = props[name];
- 98             if (prop != undefined && prop != null) {
- 99                 return props[name];
-100             }
-101         }
-102         return null; // Cause default to be set
-103     };
-104 
-105     function processProps(props) {
-106         var prop;
-107         for (var name in props) {
-108             if (props.hasOwnProperty(name)) {
-109                 prop = props[name];
-110                 if (prop != undefined && prop != null) {
-111                     if (glModeSetters[name]) {
-112                         props[name] = glModeSetters[name](null, prop);
-113                     } else if (glStateSetters[name]) {
-114                         props[name] = glStateSetters[name](null, prop);
-115                     }
-116                 }
-117             }
-118         }
-119     }
-120 
-121     var setProperties = function(gl, props) {
-122 
-123         for (var key in props) {        // Set order-insensitive properties (modes)
-124             if (props.hasOwnProperty(key)) {
-125                 var setter = glModeSetters[key];
-126                 if (setter) {
-127                     setter(gl, props[key]);
-128                 }
-129             }
-130         }
-131 
-132         if (props.viewport) {           // Set order-sensitive properties (states)
-133             glStateSetters.viewport(gl, props.viewport);
-134         }
-135 
-136         if (props.scissor) {
-137             glStateSetters.clear(gl, props.scissor);
-138         }
-139 
-140         if (props.clear) {
-141             glStateSetters.clear(gl, props.clear);
-142         }
-143     };
-144 
-145     /**
-146      * Restores previous renderer properties, except for clear - that's the reason we
-147      * have a seperate set and restore semantic - we don't want to keep clearing the buffer.
-148      */
-149     var restoreProperties = function(gl, props) {
-150 
-151         var value;
-152 
-153         for (var key in props) {            // Set order-insensitive properties (modes)
-154             if (props.hasOwnProperty(key)) {
-155                 value = props[key];
-156                 if (value != undefined && value != null) {
-157                     var setter = glModeSetters[key];
-158                     if (setter) {
-159                         setter(gl, value);
-160                     }
-161                 }
-162             }
-163         }
-164 
-165         if (props.viewport) {               //  Set order-sensitive properties (states)
-166             glStateSetters.viewport(gl, props.viewport);
-167         }
-168 
-169         if (props.scissor) {
-170             glStateSetters.clear(gl, props.scissor);
-171         }
-172     };
-173 
-174 
-175     /**
-176      * Maps renderer node properties to WebGL gl enums
-177      * @private
-178      */
-179     var glEnum = function(gl, name) {
-180         if (!name) {
-181             throw SceneJS_error.fatalError(
-182                     SceneJS.errors.ILLEGAL_NODE_CONFIG,
-183                     "Null SceneJS.State node config: \"" + name + "\"");
-184         }
-185         var result = SceneJS_webgl_enumMap[name];
-186         if (!result) {
-187             throw SceneJS_error.fatalError(
-188                     SceneJS.errors.ILLEGAL_NODE_CONFIG,
-189                     "Unrecognised SceneJS.State node config value: \"" + name + "\"");
-190         }
-191         var value = gl[result];
-192         if (!value) {
-193             throw SceneJS_error.fatalError(
-194                     SceneJS.errors.ILLEGAL_NODE_CONFIG,
-195                     "This browser's WebGL does not support renderer node config value: \"" + name + "\"");
-196         }
-197         return value;
-198     };
-199 
-200 
-201     /**
-202      * Order-insensitive functions that set WebGL modes ie. not actually causing an
-203      * immediate change.
-204      *
-205      * These map to renderer properties and are called in whatever order their
-206      * property is found on the renderer config.
-207      *
-208      * Each of these wrap a state-setter function on the WebGL gl. Each function
-209      * also uses the glEnum map to convert its renderer node property argument to the
-210      * WebGL enum constant required by its wrapped function.
-211      *
-212      * When called with undefined/null gl, will condition and return the value given
-213      * ie. set it to default if value is undefined. When called with a gl, will
-214      * set the value on the gl using the wrapped function.
-215      *
-216      * @private
-217      */
-218     var glModeSetters = {
-219 
-220         enableBlend: function(gl, flag) {
-221             if (!gl) {
-222                 if (flag == null || flag == undefined) {
-223                     flag = false;
-224                 }
-225                 return flag;
-226             }
-227             if (flag) {
-228                 gl.enable(gl.BLEND);
-229             } else {
-230                 gl.disable(gl.BLEND);
-231             }
-232         },
-233 
-234         blendColor: function(gl, color) {
-235             if (!gl) {
-236                 color = color || {};
-237                 return {
-238                     r: color.r || 0,
-239                     g: color.g || 0,
-240                     b: color.b || 0,
-241                     a: (color.a == undefined || color.a == null) ? 1 : color.a
-242                 };
-243             }
-244             gl.blendColor(color.r, color.g, color.b, color.a);
-245         },
-246 
-247         blendEquation: function(gl, eqn) {
-248             if (!gl) {
-249                 return eqn || "funcAdd";
-250             }
-251             gl.blendEquation(gl, glEnum(gl, eqn));
-252         },
-253 
-254         /** Sets the RGB blend equation and the alpha blend equation separately
-255          */
-256         blendEquationSeparate: function(gl, eqn) {
-257             if (!gl) {
-258                 eqn = eqn || {};
-259                 return {
-260                     rgb : eqn.rgb || "funcAdd",
-261                     alpha : eqn.alpha || "funcAdd"
-262                 };
-263             }
-264             gl.blendEquation(glEnum(gl, eqn.rgb), glEnum(gl, eqn.alpha));
-265         },
-266 
-267         blendFunc: function(gl, funcs) {
-268             if (!gl) {
-269                 funcs = funcs || {};
-270                 return  {
-271                     sfactor : funcs.sfactor || "srcAlpha",
-272                     dfactor : funcs.dfactor || "oneMinusSrcAlpha"
-273                 };
-274             }
-275             gl.blendFunc(glEnum(gl, funcs.sfactor || "srcAlpha"), glEnum(gl, funcs.dfactor || "oneMinusSrcAlpha"));
-276         },
-277 
-278         blendFuncSeparate: function(gl, func) {
-279             if (!gl) {
-280                 func = func || {};
-281                 return {
-282                     srcRGB : func.srcRGB || "zero",
-283                     dstRGB : func.dstRGB || "zero",
-284                     srcAlpha : func.srcAlpha || "zero",
-285                     dstAlpha :  func.dstAlpha || "zero"
-286                 };
-287             }
-288             gl.blendFuncSeparate(
-289                     glEnum(gl, func.srcRGB || "zero"),
-290                     glEnum(gl, func.dstRGB || "zero"),
-291                     glEnum(gl, func.srcAlpha || "zero"),
-292                     glEnum(gl, func.dstAlpha || "zero"));
-293         },
-294 
-295         clearColor: function(gl, color) {
-296             if (!gl) {
-297                 color = color || {};
-298                 return {
-299                     r : color.r || 0,
-300                     g : color.g || 0,
-301                     b : color.b || 0,
-302                     a : (color.a == undefined || color.a == null) ? 1 : color.a
-303                 };
-304             }
-305             gl.clearColor(color.r, color.g, color.b, color.a);
-306         },
-307 
-308         clearDepth: function(gl, depth) {
-309             if (!gl) {
-310                 return (depth == null || depth == undefined) ? 1 : depth;
-311             }
-312             gl.clearDepth(depth);
-313         },
-314 
-315         clearStencil: function(gl, clearValue) {
-316             if (!gl) {
-317                 return  clearValue || 0;
-318             }
-319             gl.clearStencil(clearValue);
-320         },
-321 
-322         colorMask: function(gl, color) {
-323             if (!gl) {
-324                 color = color || {};
-325                 return {
-326                     r : color.r || 0,
-327                     g : color.g || 0,
-328                     b : color.b || 0,
-329                     a : (color.a == undefined || color.a == null) ? 1 : color.a
-330                 };
-331 
-332             }
-333             gl.colorMask(color.r, color.g, color.b, color.a);
-334         },
-335 
-336         enableCullFace: function(gl, flag) {
-337             if (!gl) {
-338                 return flag;
-339             }
-340             if (flag) {
-341                 gl.enable(gl.CULL_FACE);
-342             } else {
-343                 gl.disable(gl.CULL_FACE);
-344             }
-345         },
-346 
-347         cullFace: function(gl, mode) {
-348             if (!gl) {
-349                 return mode || "back";
-350             }
-351             gl.cullFace(glEnum(gl, mode));
-352         },
-353 
-354         enableDepthTest: function(gl, flag) {
-355             if (!gl) {
-356                 if (flag == null || flag == undefined) {
-357                     flag = true;
-358                 }
-359                 return flag;
-360             }
-361             if (flag) {
-362                 gl.enable(gl.DEPTH_TEST);
-363             } else {
-364                 gl.disable(gl.DEPTH_TEST);
-365             }
-366         },
-367 
-368         depthFunc: function(gl, func) {
-369             if (!gl) {
-370                 return func || "less";
-371             }
-372             gl.depthFunc(glEnum(gl, func));
-373         },
-374 
-375         enableDepthMask: function(gl, flag) {
-376             if (!gl) {
-377                 if (flag == null || flag == undefined) {
-378                     flag = true;
-379                 }
-380                 return flag;
-381             }
-382             gl.depthMask(flag);
-383         },
-384 
-385         depthRange: function(gl, range) {
-386             if (!gl) {
-387                 range = range || {};
-388                 return {
-389                     zNear : (range.zNear == undefined || range.zNear == null) ? 0 : range.zNear,
-390                     zFar : (range.zFar == undefined || range.zFar == null) ? 1 : range.zFar
-391                 };
-392             }
-393             gl.depthRange(range.zNear, range.zFar);
-394         } ,
-395 
-396         frontFace: function(gl, mode) {
-397             if (!gl) {
-398                 return mode || "ccw";
-399             }
-400             gl.frontFace(glEnum(gl, mode));
-401         },
-402 
-403         lineWidth: function(gl, width) {
-404             if (!gl) {
-405                 return width || 1;
-406             }
-407             gl.lineWidth(width);
-408         },
-409 
-410         enableScissorTest: function(gl, flag) {
-411             if (!gl) {
-412                 return flag;
-413             }
-414             if (flag) {
-415                 gl.enable(gl.SCISSOR_TEST);
-416             } else {
-417                 flag = false;
-418                 gl.disable(gl.SCISSOR_TEST);
-419             }
-420         }
-421     };
-422 
-423     /**
-424      * Order-sensitive functions that immediately effect WebGL state change.
-425      *
-426      * These map to renderer properties and are called in a particular order since they
-427      * affect one another.
-428      *
-429      * Each of these wrap a state-setter function on the WebGL gl. Each function
-430      * also uses the glEnum map to convert its renderer node property argument to the
-431      * WebGL enum constant required by its wrapped function.
-432      *
-433      * @private
-434      */
-435     var glStateSetters = {
-436 
-437         /** Set viewport on the given gl
-438          */
-439         viewport: function(gl, v) {
-440             if (!gl) {
-441                 v = v || {};
-442                 return {
-443                     x : v.x || 1,
-444                     y : v.y || 1,
-445                     width: v.width || canvas.canvas.width,
-446                     height: v.height || canvas.canvas.height
-447                 };
-448             }
-449             gl.viewport(v.x, v.y, v.width, v.height);
-450         },
-451 
-452         /** Sets scissor region on the given gl
-453          */
-454         scissor: function(gl, s) {
-455             if (!gl) {
-456                 s = s || {};
-457                 return {
-458                     x : s.x || 0,
-459                     y : s.y || 0,
-460                     width: s.width || 1.0,
-461                     height: s.height || 1.0
-462                 };
-463             }
-464             gl.scissor(s.x, s.y, s.width, s.height);
-465         },
-466 
-467         /** Clears buffers on the given gl as specified in mask
-468          */
-469         clear:function(gl, mask) {
-470             if (!gl) {
-471                 mask = mask || {};
-472                 return mask;
-473             }
-474             var m;
-475             if (mask.color) {
-476                 m = gl.COLOR_BUFFER_BIT;
-477             }
-478             if (mask.depth) {
-479                 m = m | gl.DEPTH_BUFFER_BIT;
-480             }
-481             if (mask.stencil) {
-482                 m = m | gl.STENCIL_BUFFER_BIT;
-483             }
-484             if (m) {
-485                 //    gl.clear(m);
-486             }
-487         }
-488     };
-489 
-490     SceneJS.Renderer = SceneJS_NodeFactory.createNodeType("renderer");
-491 
-492     SceneJS.Renderer.prototype._init = function(params) {
-493         if (this._core.useCount == 1) { // This node defines the resource
-494             for (var key in params) {
-495                 if (params.hasOwnProperty(key)) {
-496                     this._core[key] = params[key];
-497                 }
-498             }
-499             this._core.dirty = true;
-500         }
-501     };
-502 
-503     SceneJS.Renderer.prototype.setViewport = function(viewport) {
-504         this._core.viewport = viewport ? {
-505             x : viewport.x || 1,
-506             y : viewport.y || 1,
-507             width: viewport.width || 1000,
-508             height: viewport.height || 1000
-509         } : undefined;
-510         this._core.dirty = true;
-511     };
-512 
-513     SceneJS.Renderer.prototype.getViewport = function() {
-514         return this._core.viewport ? {
-515             x : this._core.viewport.x,
-516             y : this._core.viewport.y,
-517             width: this._core.viewport.width,
-518             height: this._core.viewport.height
-519         } : undefined;
-520     };
-521 
-522     SceneJS.Renderer.prototype.setScissor = function(scissor) {
-523         this._core.scissor = scissor ? {
-524             x : scissor.x || 1,
-525             y : scissor.y || 1,
-526             width: scissor.width || 1000,
-527             height: scissor.height || 1000
-528         } : undefined;
-529         this._core.dirty = true;
-530     };
-531 
-532     SceneJS.Renderer.prototype.getScissor = function() {
-533         return this._core.scissor ? {
-534             x : this._core.scissor.x,
-535             y : this._core.scissor.y,
-536             width: this._core.scissor.width,
-537             height: this._core.scissor.height
-538         } : undefined;
-539     };
-540 
-541     SceneJS.Renderer.prototype.setClear = function(clear) {
-542         this._core.clear = clear ? {
-543             r : clear.r || 0,
-544             g : clear.g || 0,
-545             b : clear.b || 0
-546         } : undefined;
-547         this._core.dirty = true;
-548     };
-549 
-550     SceneJS.Renderer.prototype.getClear = function() {
-551         return this._core.clear ? {
-552             r : this._core.clear.r,
-553             g : this._core.clear.g,
-554             b : this._core.clear.b
-555         } : null;
-556     };
-557 
-558     SceneJS.Renderer.prototype.setEnableBlend = function(enableBlend) {
-559         this._core.enableBlend = enableBlend;
-560         this._core.dirty = true;
-561     };
-562 
-563     SceneJS.Renderer.prototype.getEnableBlend = function() {
-564         return this._core.enableBlend;
-565     };
-566 
-567     SceneJS.Renderer.prototype.setBlendColor = function(color) {
-568         this._core.blendColor = color ? {
-569             r : color.r || 0,
-570             g : color.g || 0,
-571             b : color.b || 0,
-572             a : (color.a == undefined || color.a == null) ? 1 : color.a
-573         } : undefined;
-574         this._core.dirty = true;
-575     };
-576 
-577     SceneJS.Renderer.prototype.getBlendColor = function() {
-578         return this._core.blendColor ? {
-579             r : this._core.blendColor.r,
-580             g : this._core.blendColor.g,
-581             b : this._core.blendColor.b,
-582             a : this._core.blendColor.a
-583         } : undefined;
-584     };
-585 
-586     SceneJS.Renderer.prototype.setBlendEquation = function(eqn) {
-587         this._core.blendEquation = eqn;
-588         this._core.dirty = true;
-589     };
-590 
-591     SceneJS.Renderer.prototype.getBlendEquation = function() {
-592         return this._core.blendEquation;
-593     };
-594 
-595     SceneJS.Renderer.prototype.setBlendEquationSeparate = function(eqn) {
-596         this._core.blendEquationSeparate = eqn ? {
-597             rgb : eqn.rgb || "funcAdd",
-598             alpha : eqn.alpha || "funcAdd"
-599         } : undefined;
-600         this._core.dirty = true;
-601     };
-602 
-603     SceneJS.Renderer.prototype.getBlendEquationSeparate = function() {
-604         return this._core.blendEquationSeparate ? {
-605             rgb : this._core.rgb,
-606             alpha : this._core.alpha
-607         } : undefined;
-608     };
-609 
-610     SceneJS.Renderer.prototype.setBlendFunc = function(funcs) {
-611         this._core.blendFunc = funcs ? {
-612             sfactor : funcs.sfactor || "srcAlpha",
-613             dfactor : funcs.dfactor || "one"
-614         } : undefined;
-615         this._core.dirty = true;
-616     };
-617 
-618     SceneJS.Renderer.prototype.getBlendFunc = function() {
-619         return this._core.blendFunc ? {
-620             sfactor : this._core.sfactor,
-621             dfactor : this._core.dfactor
-622         } : undefined;
-623     };
-624 
-625     SceneJS.Renderer.prototype.setBlendFuncSeparate = function(eqn) {
-626         this._core.blendFuncSeparate = eqn ? {
-627             srcRGB : eqn.srcRGB || "zero",
-628             dstRGB : eqn.dstRGB || "zero",
-629             srcAlpha : eqn.srcAlpha || "zero",
-630             dstAlpha : eqn.dstAlpha || "zero"
-631         } : undefined;
-632         this._core.dirty = true;
-633     };
-634 
-635     SceneJS.Renderer.prototype.getBlendFuncSeparate = function() {
-636         return this._core.blendFuncSeparate ? {
-637             srcRGB : this._core.blendFuncSeparate.srcRGB,
-638             dstRGB : this._core.blendFuncSeparate.dstRGB,
-639             srcAlpha : this._core.blendFuncSeparate.srcAlpha,
-640             dstAlpha : this._core.blendFuncSeparate.dstAlpha
-641         } : undefined;
-642     };
-643 
-644     SceneJS.Renderer.prototype.setEnableCullFace = function(enableCullFace) {
-645         this._core.enableCullFace = enableCullFace;
-646         this._core.dirty = true;
-647     };
-648 
-649     SceneJS.Renderer.prototype.getEnableCullFace = function() {
-650         return this._core.enableCullFace;
-651     };
-652 
-653 
-654     SceneJS.Renderer.prototype.setCullFace = function(cullFace) {
-655         this._core.cullFace = cullFace;
-656         this._core.dirty = true;
-657     };
-658 
-659     SceneJS.Renderer.prototype.getCullFace = function() {
-660         return this._core.cullFace;
-661     };
-662 
-663     SceneJS.Renderer.prototype.setEnableDepthTest = function(enableDepthTest) {
-664         this._core.enableDepthTest = enableDepthTest;
-665         this._core.dirty = true;
-666     };
-667 
-668     SceneJS.Renderer.prototype.getEnableDepthTest = function() {
-669         return this._core.enableDepthTest;
-670     };
-671 
-672     SceneJS.Renderer.prototype.setDepthFunc = function(depthFunc) {
-673         this._core.depthFunc = depthFunc;
-674         this._core.dirty = true;
-675     };
-676 
-677     SceneJS.Renderer.prototype.getDepthFunc = function() {
-678         return this._core.depthFunc;
-679     };
-680 
-681     SceneJS.Renderer.prototype.setEnableDepthMask = function(enableDepthMask) {
-682         this._core.enableDepthMask = enableDepthMask;
-683         this._core.dirty = true;
-684     };
-685 
-686     SceneJS.Renderer.prototype.getEnableDepthMask = function() {
-687         return this._core.enableDepthMask;
-688     };
-689 
-690     SceneJS.Renderer.prototype.setClearDepth = function(clearDepth) {
-691         this._core.clearDepth = clearDepth;
-692         this._core.dirty = true;
-693     };
-694 
-695     SceneJS.Renderer.prototype.getClearDepth = function() {
-696         return this._core.clearDepth;
-697     };
-698 
-699     SceneJS.Renderer.prototype.setDepthRange = function(range) {
-700         this._core.depthRange = range ? {
-701             zNear : (range.zNear == undefined || range.zNear == null) ? 0 : range.zNear,
-702             zFar : (range.zFar == undefined || range.zFar == null) ? 1 : range.zFar
-703         } : undefined;
-704         this._core.dirty = true;
-705     };
-706 
-707     SceneJS.Renderer.prototype.getDepthRange = function() {
-708         return this._core.depthRange ? {
-709             zNear : this._core.depthRange.zNear,
-710             zFar : this._core.depthRange.zFar
-711         } : undefined;
-712     };
-713 
-714     SceneJS.Renderer.prototype.setFrontFace = function(frontFace) {
-715         this._core.frontFace = frontFace;
-716         this._core.dirty = true;
-717     };
-718 
-719     SceneJS.Renderer.prototype.getFrontFace = function() {
-720         return this._core.frontFace;
-721     };
-722 
-723     SceneJS.Renderer.prototype.setLineWidth = function(lineWidth) {
-724         this._core.lineWidth = lineWidth;
-725         this._core.dirty = true;
-726     };
-727 
-728     SceneJS.Renderer.prototype.getLineWidth = function() {
-729         return this._core.lineWidth;
-730     };
-731 
-732     SceneJS.Renderer.prototype.setEnableScissorTest = function(enableScissorTest) {
-733         this._core.enableScissorTest = enableScissorTest;
-734         this._core.dirty = true;
-735     };
-736 
-737     SceneJS.Renderer.prototype.getEnableScissorTest = function() {
-738         return this._core.enableScissorTest;
-739     };
-740 
-741     SceneJS.Renderer.prototype.setClearStencil = function(clearStencil) {
-742         this._core.clearStencil = clearStencil;
-743         this._core.dirty = true;
-744     };
-745 
-746     SceneJS.Renderer.prototype.getClearStencil = function() {
-747         return this._core.clearStencil;
-748     };
-749 
-750     SceneJS.Renderer.prototype.setColorMask = function(color) {
-751         this._core.colorMask = color ? {
-752             r : color.r || 0,
-753             g : color.g || 0,
-754             b : color.b || 0,
-755             a : (color.a == undefined || color.a == null) ? 1 : color.a
-756         } : undefined;
-757         this._core.dirty = true;
-758     };
-759 
-760     SceneJS.Renderer.prototype.getColorMask = function() {
-761         return this._core.colorMask ? {
-762             r : this._core.colorMask.r,
-763             g : this._core.colorMask.g,
-764             b : this._core.colorMask.b,
-765             a : this._core.colorMask.a
-766         } : undefined;
-767     };
-768 
-769     SceneJS.Renderer.prototype._compile = function() {
-770 
-771 //        if (this._core.dirty) {
-772 //            this._core.props = createProps(this._core);
-773 //            this._core.dirty = false;
-774 //        }
-775 //
-776 //        this._engine.display.renderer = coreStack[stackLen++] = this._core;
-777         this._compileNodes();
-778         //this._engine.display.renderer = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore;
-779     };
-780 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_rotate.js.html b/docs/symbols/src/src_core_scene_rotate.js.html deleted file mode 100644 index da2eeb48..00000000 --- a/docs/symbols/src/src_core_scene_rotate.js.html +++ /dev/null @@ -1,156 +0,0 @@ -
  1 /**
-  2  * @class Scene graph node which defines a rotation modelling transform to apply to the objects in its subgraph
-  3  * @extends SceneJS.Node
-  4  */
-  5 SceneJS.Rotate = SceneJS_NodeFactory.createNodeType("rotate");
-  6 
-  7 SceneJS.Rotate.prototype._init = function(params) {
-  8 
-  9     if (this._core.useCount == 1) { // This node is the resource definer
- 10 
- 11         SceneJS_modelXFormStack.buildCore(this._core);
- 12         
- 13         this.setMultOrder(params.multOrder);
- 14 
- 15         this.setAngle(params.angle);
- 16 
- 17         this.setXYZ({
- 18             x: params.x,
- 19             y: params.y,
- 20             z: params.z
- 21         });
- 22 
- 23         var core = this._core;
- 24 
- 25         this._core.buildMatrix = function() {
- 26             core.matrix = SceneJS_math_rotationMat4v(core.angle * Math.PI / 180.0, [core.x, core.y, core.z]);
- 27         };
- 28     }
- 29 };
- 30 
- 31 /**
- 32  * Get Model matrix
- 33  * @return {*}
- 34  */
- 35 SceneJS.Rotate.prototype.getModelMatrix = function() {
- 36     if (this._core.dirty) {
- 37         this._core.build();
- 38     }
- 39     return this._core.matrix;
- 40 };
- 41 
- 42 /**
- 43  * Get World matrix. That's the multiplication of this node's Model matrix by the World matrix of the the next
- 44  * tranform (scale, rotate, translate etc) node on the path to the scene root.
- 45  * @return {*}
- 46  */
- 47 SceneJS.Rotate.prototype.getWorldMatrix = function() {
- 48     if (this._core.dirty) {
- 49         this._core.build();
- 50     }
- 51     return Array.apply( [], this._core.mat);
- 52 };
- 53 
- 54 /**
- 55  * Sets the multiplication order of this node's transform matrix with respect to the parent modeling transform
- 56  * in the scene graph.
- 57  *
- 58  * @param {String} multOrder Mulplication order - "post" and "pre"
- 59  */
- 60 SceneJS.Rotate.prototype.setMultOrder = function(multOrder) {
- 61 
- 62     multOrder = multOrder || "post";
- 63 
- 64     if (multOrder != "post" && multOrder != "pre") {
- 65 
- 66         throw SceneJS_error.fatalError(
- 67                 SceneJS.errors.NODE_CONFIG_EXPECTED,
- 68                 "Illegal multOrder for rotate node - '" + multOrder + "' should be 'pre' or 'post'");
- 69     }
- 70 
- 71     this._core.multOrder = multOrder;
- 72 
- 73     this._core.setDirty();
- 74     this._engine.display.imageDirty = true;
- 75 };
- 76 
- 77 SceneJS.Rotate.prototype.setAngle = function(angle) {
- 78     this._core.angle = angle || 0;
- 79     this._core.setDirty();
- 80     this._engine.display.imageDirty = true;
- 81 };
- 82 
- 83 SceneJS.Rotate.prototype.getAngle = function() {
- 84     return this._core.angle;
- 85 };
- 86 
- 87 SceneJS.Rotate.prototype.setXYZ = function(xyz) {
- 88 
- 89     xyz = xyz || {};
- 90 
- 91     this._core.x = xyz.x || 0;
- 92     this._core.y = xyz.y || 0;
- 93     this._core.z = xyz.z || 0;
- 94 
- 95     this._core.setDirty();
- 96 
- 97     this._engine.display.imageDirty = true;
- 98 };
- 99 
-100 SceneJS.Rotate.prototype.getXYZ = function() {
-101     return {
-102         x: this._core.x,
-103         y: this._core.y,
-104         z: this._core.z
-105     };
-106 };
-107 
-108 SceneJS.Rotate.prototype.setX = function(x) {
-109     this._core.x = x;
-110     this._core.setDirty();
-111     this._engine.display.imageDirty = true;
-112 };
-113 
-114 SceneJS.Rotate.prototype.getX = function() {
-115     return this._core.x;
-116 };
-117 
-118 SceneJS.Rotate.prototype.setY = function(y) {
-119     this._core.y = y;
-120     this._core.setDirty();
-121     this._engine.display.imageDirty = true;
-122 };
-123 
-124 SceneJS.Rotate.prototype.getY = function() {
-125     return this._core.y;
-126 };
-127 
-128 SceneJS.Rotate.prototype.setZ = function(z) {
-129     this._core.z = z;
-130     this._core.setDirty();
-131     this._engine.display.imageDirty = true;
-132 };
-133 
-134 SceneJS.Rotate.prototype.getZ = function() {
-135     return this._core.z;
-136 };
-137 
-138 SceneJS.Rotate.prototype.incAngle = function(angle) {
-139     this._core.angle += angle;
-140     this._core.setDirty();
-141     this._engine.display.imageDirty = true;
-142 };
-143 
-144 SceneJS.Rotate.prototype._compile = function() {
-145     SceneJS_modelXFormStack.push(this._core);
-146     this._compileNodes();
-147     SceneJS_modelXFormStack.pop();
-148 };
-149 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_scale.js.html b/docs/symbols/src/src_core_scene_scale.js.html deleted file mode 100644 index 6a0ee033..00000000 --- a/docs/symbols/src/src_core_scene_scale.js.html +++ /dev/null @@ -1,160 +0,0 @@ -
  1 /**
-  2  * @class Scene graph node which defines a rotation modelling transform to apply to the objects in its subgraph
-  3  * @extends SceneJS.Node
-  4  */
-  5 SceneJS.Scale = SceneJS_NodeFactory.createNodeType("scale");
-  6 
-  7 SceneJS.Scale.prototype._init = function(params) {
-  8 
-  9     if (this._core.useCount == 1) { // This node is the resource definer
- 10 
- 11         SceneJS_modelXFormStack.buildCore(this._core);
- 12 
- 13         this.setMultOrder(params.multOrder);
- 14 
- 15         this.setXYZ({
- 16             x: params.x,
- 17             y: params.y,
- 18             z: params.z
- 19         });
- 20 
- 21         var core = this._core;
- 22 
- 23         this._core.buildMatrix = function() {
- 24             core.matrix = SceneJS_math_scalingMat4v([core.x, core.y, core.z]);
- 25         };
- 26     }
- 27 };
- 28 
- 29 /**
- 30  * Get Model matrix
- 31  * @return {*}
- 32  */
- 33 SceneJS.Scale.prototype.getModelMatrix = function() {
- 34     if (this._core.dirty) {
- 35         this._core.build();
- 36     }
- 37     return this._core.matrix;
- 38 };
- 39 
- 40 /**
- 41  * Get World matrix. That's the multiplication of this node's Model matrix by the World matrix of the the next
- 42  * tranform (scale, scale, translate etc) node on the path to the scene root.
- 43  * @return {*}
- 44  */
- 45 SceneJS.Scale.prototype.getWorldMatrix = function() {
- 46     if (this._core.dirty) {
- 47         this._core.build();
- 48     }
- 49     return Array.apply( [], this._core.mat);
- 50 };
- 51 
- 52 
- 53 /**
- 54  * Sets the multiplication order of this node's transform matrix with respect to the parent modeling transform
- 55  * in the scene graph.
- 56  *
- 57  * @param {String} multOrder Mulplication order - "post" and "pre"
- 58  */
- 59 SceneJS.Scale.prototype.setMultOrder = function(multOrder) {
- 60 
- 61     multOrder = multOrder || "post";
- 62 
- 63     if (multOrder != "post" && multOrder != "pre") {
- 64 
- 65         throw SceneJS_error.fatalError(
- 66                 SceneJS.errors.NODE_CONFIG_EXPECTED,
- 67                 "Illegal multOrder for scale node - '" + multOrder + "' should be 'pre' or 'post'");
- 68     }
- 69 
- 70     this._core.multOrder = multOrder;
- 71 
- 72     this._core.setDirty();
- 73     this._engine.display.imageDirty = true;
- 74 };
- 75 
- 76 SceneJS.Scale.prototype.getAngle = function() {
- 77     return this._core.angle;
- 78 };
- 79 
- 80 SceneJS.Scale.prototype.setXYZ = function(xyz) {
- 81 
- 82     xyz = xyz || {};
- 83 
- 84     this._core.x = xyz.x || 0;
- 85     this._core.y = xyz.y || 0;
- 86     this._core.z = xyz.z || 0;
- 87 
- 88     this._core.setDirty();
- 89 
- 90     this._engine.display.imageDirty = true;
- 91 };
- 92 
- 93 SceneJS.Scale.prototype.getXYZ = function() {
- 94     return {
- 95         x: this._core.x,
- 96         y: this._core.y,
- 97         z: this._core.z
- 98     };
- 99 };
-100 
-101 SceneJS.Scale.prototype.setX = function(x) {
-102     this._core.x = x;
-103     this._core.setDirty();
-104     this._engine.display.imageDirty = true;
-105 };
-106 
-107 SceneJS.Scale.prototype.getX = function() {
-108     return this._core.x;
-109 };
-110 
-111 SceneJS.Scale.prototype.setY = function(y) {
-112     this._core.y = y;
-113     this._core.setDirty();
-114     this._engine.display.imageDirty = true;
-115 };
-116 
-117 SceneJS.Scale.prototype.getY = function() {
-118     return this._core.y;
-119 };
-120 
-121 SceneJS.Scale.prototype.setZ = function(z) {
-122     this._core.z = z;
-123     this._core.setDirty();
-124     this._engine.display.imageDirty = true;
-125 };
-126 
-127 SceneJS.Scale.prototype.getZ = function() {
-128     return this._core.z;
-129 };
-130 
-131 SceneJS.Scale.prototype.incX = function(x) {
-132     this._core.x += x;
-133     this._core.setDirty();
-134     this._engine.display.imageDirty = true;
-135 };
-136 
-137 SceneJS.Scale.prototype.incY = function(y) {
-138     this._core.y += y;
-139     this._core.matrixDirty = true;
-140 };
-141 
-142 SceneJS.Scale.prototype.incZ = function(z) {
-143     this._core.z += z;
-144     this._core.setDirty();
-145     this._engine.display.imageDirty = true;
-146 };
-147 
-148 SceneJS.Scale.prototype._compile = function() {
-149     SceneJS_modelXFormStack.push(this._core);
-150     this._compileNodes();
-151     SceneJS_modelXFormStack.pop();
-152 };
-153 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_scene.js.html b/docs/symbols/src/src_core_scene_scene.js.html deleted file mode 100644 index 0556d344..00000000 --- a/docs/symbols/src/src_core_scene_scene.js.html +++ /dev/null @@ -1,228 +0,0 @@ -
  1 /**
-  2  * @class The root node of a scenegraph
-  3  * @extends SceneJS.Node
-  4  *
-  5  */
-  6 
-  7 SceneJS.Scene = SceneJS_NodeFactory.createNodeType("scene");
-  8 
-  9 SceneJS.Scene.prototype._init = function(params) {
- 10 
- 11     if (params.tagMask) {
- 12         this.setTagMask(params.tagMask);
- 13     }
- 14 
- 15     this._tagSelector = null;
- 16 };
- 17 
- 18 /**
- 19  * Subscribes to an event on this scene
- 20  *
- 21  * @param {String} type Event type
- 22  * @param {Function} callback Callback that will be called with the event parameters
- 23  * @return {String} handle Handle to the subcription
- 24  */
- 25 SceneJS.Scene.prototype.onEvent = function(type, callback) {
- 26     return this._engine.events.onEvent(type, callback);
- 27 };
- 28 
- 29 /**
- 30  * Unsubscribes to an event previously subscribed to on scene
- 31  *
- 32  * @param {String} handle Subscription handle
- 33  */
- 34 SceneJS.Scene.prototype.unEvent = function(handle) {
- 35     this._engine.events.unEvent(handle);
- 36 };
- 37 
- 38 /**
- 39  * Simulate a lost WebGL context for testing purposes.
- 40  * Only works if the simulateWebGLLost was given as an option to {@link SceneJS.createScene}.
- 41  */
- 42 SceneJS.Scene.prototype.loseWebGLContext = function() {
- 43     this._engine.loseWebGLContext();
- 44 };
- 45 
- 46 
- 47 /**
- 48  * Returns the HTML canvas for this scene
- 49  * @return {HTMLCanvas} The canvas
- 50  */
- 51 SceneJS.Scene.prototype.getCanvas = function() {
- 52     return this._engine.canvas.canvas;
- 53 };
- 54 
- 55 /**
- 56  * Returns the WebGL context for this scene
- 57  */
- 58 SceneJS.Scene.prototype.getGL = function() {
- 59     return this._engine.canvas.gl;
- 60 };
- 61 
- 62 /** Returns the Z-buffer depth in bits of the webgl context that this scene is to bound to.
- 63  */
- 64 SceneJS.Scene.prototype.getZBufferDepth = function() {
- 65 
- 66     var gl = this._engine.canvas.gl;
- 67 
- 68     return gl.getParameter(gl.DEPTH_BITS);
- 69 };
- 70 
- 71 /**
- 72  * Sets a regular expression to select which of the scene subgraphs that are rooted by {@link SceneJS.Tag} nodes are included in scene renders
- 73  * @param {String} tagMask Regular expression string to match on the tag attributes of {@link SceneJS.Tag} nodes
- 74  * @see #getTagMask
- 75  * @see SceneJS.Tag
- 76  */
- 77 SceneJS.Scene.prototype.setTagMask = function(tagMask) {
- 78 
- 79     if (!this._tagSelector) {
- 80         this._tagSelector = {};
- 81     }
- 82 
- 83     this._tagSelector.mask = tagMask;
- 84     this._tagSelector.regex = tagMask ? new RegExp(tagMask) : null;
- 85 
- 86     this._engine.display.selectTags(this._tagSelector);
- 87 };
- 88 
- 89 /**
- 90  * Gets the regular expression which will select which of the scene subgraphs that are rooted by {@link SceneJS.Tag} nodes are included in scene renders
- 91  * @see #setTagMask
- 92  * @see SceneJS.Tag
- 93  * @returns {String} Regular expression string that will be matched on the tag attributes of {@link SceneJS.Tag} nodes
- 94  */
- 95 SceneJS.Scene.prototype.getTagMask = function() {
- 96     return this._tagSelector ? this._tagSelector.mask : null;
- 97 };
- 98 
- 99 /**
-100  * Render a single frame if new frame pending, or force a new frame
-101  * Returns true if frame rendered
-102  */
-103 SceneJS.Scene.prototype.renderFrame = function(params) {
-104     return this._engine.renderFrame(params);
-105 };
-106 
-107 /**
-108  * Starts the render loop for this scene
-109  */
-110 SceneJS.Scene.prototype.start = function(params) {
-111     this._engine.start(params);
-112 };
-113 
-114 /**
-115  * Pauses/unpauses current render loop that was started with {@link #start}. After this, {@link #isRunning} will return false.
-116  * @param {Boolean} doPause Indicates whether to pause or unpause the render loop
-117  */
-118 SceneJS.Scene.prototype.pause = function(doPause) {
-119     this._engine.pause(doPause);
-120 };
-121 
-122 /**
-123  * Returns true if the scene's render loop is currently running.
-124  * @returns {Boolean} True when scene render loop is running
-125  */
-126 SceneJS.Scene.prototype.isRunning = function() {
-127     return this._engine.running;
-128 };
-129 
-130 /**
-131  * Picks whatever geometry will be rendered at the given canvas coordinates.
-132  */
-133 SceneJS.Scene.prototype.pick = function(canvasX, canvasY, options) {
-134     return this._engine.pick(canvasX, canvasY, options);
-135 };
-136 
-137 /**                                  p
-138  * Scene node's destroy handler, called by {@link SceneJS_node#destroy}
-139  * @private
-140  */
-141 SceneJS.Scene.prototype.destroy = function() {
-142 
-143     if (!this.destroyed) {
-144 
-145         delete SceneJS._engines[this.id];  // HACK: circular dependency
-146         SceneJS._engineIds.removeItem(this.id); // HACK: circular dependency
-147 
-148         this.destroyed = true;
-149     }
-150 };
-151 
-152 /**
-153  * Returns true if scene active, ie. not destroyed. A destroyed scene becomes active again
-154  * when you render it.
-155  */
-156 SceneJS.Scene.prototype.isActive = function() {
-157     return !this._engine.destroyed;
-158 };
-159 
-160 /**
-161  * Stops current render loop that was started with {@link #start}. After this, {@link #isRunning} will return false.
-162  */
-163 SceneJS.Scene.prototype.stop = function() {
-164     this._engine.stop();
-165 };
-166 
-167 /** Determines if node exists in this scene
-168  */
-169 SceneJS.Scene.prototype.containsNode = function(nodeId) {
-170     return !!this._engine.findNode(nodeId);
-171 };
-172 
-173 /**
-174  * Finds nodes in this scene that have nodes IDs matching the given regular expression
-175  *
-176  * @param {String} nodeIdRegex Regular expression to match on node IDs
-177  * @return {[SceneJS.Node]} Array of nodes whose IDs match the given regex
-178  */
-179 SceneJS.Scene.prototype.findNodes = function(nodeIdRegex) {
-180     return this._engine.findNodes(nodeIdRegex);
-181 };
-182 
-183 /**
-184  * Finds the node with the given ID in this scene
-185  * @deprecated
-186  * @return {SceneJS.Node} The node if found, else null
-187  */
-188 SceneJS.Scene.prototype.findNode = function(nodeId) {
-189     return this._engine.findNode(nodeId);
-190 };
-191 
-192 /**
-193  * @function Finds the node with the given ID in this scene
-194  * @return {SceneJS.Node} The node if found, else null
-195  */
-196 SceneJS.Scene.prototype.getNode  = function(nodeId) {
-197     return this._engine.findNode(nodeId);
-198 };
-199 
-200 /**
-201  * Returns the current status of this scene.
-202  *
-203  * When the scene has been destroyed, the returned status will be a map like this:
-204  *
-205  * {
-206  *      destroyed: true
-207  * }
-208  *
-209  * Otherwise, the status will be:
-210  *
-211  * {
-212  *      numTasks: Number // Number of asset loads (eg. texture, geometry stream etc.) currently in progress
-213  * }
-214  *
-215  */
-216 SceneJS.Scene.prototype.getStatus = function() {
-217     return (this._engine.destroyed)
-218             ? { destroyed: true }
-219             : SceneJS._shallowClone(SceneJS_sceneStatusModule.sceneStatus[this.id]);
-220 };
-221 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_shader.js.html b/docs/symbols/src/src_core_scene_shader.js.html deleted file mode 100644 index 344b4a23..00000000 --- a/docs/symbols/src/src_core_scene_shader.js.html +++ /dev/null @@ -1,201 +0,0 @@ -
  1 new (function() {
-  2 
-  3     /**
-  4      * The default state core singleton for {@link SceneJS.Shader} nodes
-  5      */
-  6     var defaultCore = {
-  7         type: "shader",
-  8         stateId: SceneJS._baseStateId++,
-  9         hash: "",
- 10         empty: true,
- 11         shader : {}
- 12     };
- 13 
- 14     var idStack = [];
- 15     var shaderVertexCodeStack = [];
- 16     var shaderVertexHooksStack = [];
- 17     var shaderFragmentCodeStack = [];
- 18     var shaderFragmentHooksStack = [];
- 19     var shaderParamsStack = [];
- 20 
- 21     var stackLen = 0;
- 22 
- 23     var dirty = true;
- 24 
- 25     SceneJS_events.addListener(
- 26             SceneJS_events.SCENE_COMPILING,
- 27             function(params) {
- 28 
- 29                 params.engine.display.shader = defaultCore;
- 30 
- 31                 stackLen = 0;
- 32 
- 33                 dirty = true;
- 34             });
- 35 
- 36     SceneJS_events.addListener(
- 37             SceneJS_events.OBJECT_COMPILING,
- 38             function(params) {
- 39                 if (dirty) {
- 40 
- 41                     if (stackLen > 0) {
- 42 
- 43                         var core = {
- 44                             type: "shader",
- 45                             stateId: idStack[stackLen - 1],
- 46                             hash: idStack.slice(0, stackLen).join("."),
- 47 
- 48                             shaders: {
- 49                                 fragment: {
- 50                                     code: shaderFragmentCodeStack.slice(0, stackLen).join("\n"),
- 51                                     hooks: combineMapStack(shaderFragmentHooksStack)
- 52                                 },
- 53                                 vertex: {
- 54                                     code: shaderVertexCodeStack.slice(0, stackLen).join("\n"),
- 55                                     hooks: combineMapStack(shaderVertexHooksStack)
- 56                                 }
- 57                             },
- 58 
- 59                             paramsStack: shaderParamsStack.slice(0, stackLen)
- 60                         };
- 61 
- 62                         params.display.shader = core;
- 63 
- 64                     } else {
- 65 
- 66                         params.display.shader = defaultCore;
- 67                     }
- 68 
- 69                     dirty = false;
- 70                 }
- 71             });
- 72 
- 73     function combineMapStack(maps) {
- 74         var map1;
- 75         var map2 = {};
- 76         var name;
- 77         for (var i = 0; i < stackLen; i++) {
- 78             map1 = maps[i];
- 79             for (name in map1) {
- 80                 if (map1.hasOwnProperty(name)) {
- 81                     map2[name] = map1[name];
- 82                 }
- 83             }
- 84         }
- 85         return map2;
- 86     }
- 87 
- 88     function pushHooks(hooks, hookStacks) {
- 89         var stack;
- 90         for (var key in hooks) {
- 91             if (hooks.hasOwnProperty(key)) {
- 92                 stack = hookStacks[key];
- 93                 if (!stack) {
- 94                     stack = hookStacks[key] = [];
- 95                 }
- 96                 stack.push(hooks[key]);
- 97             }
- 98         }
- 99     }
-100 
-101     SceneJS.Shader = SceneJS_NodeFactory.createNodeType("shader");
-102 
-103     SceneJS.Shader.prototype._init = function(params) {
-104         if (this._core.useCount == 1) { // This node is the resource definer
-105             this._setShaders(params.shaders);
-106             this.setParams(params.params);
-107         }
-108     };
-109 
-110     SceneJS.Shader.prototype._setShaders = function(shaders) {
-111         shaders = shaders || [];
-112         this._core.shaders = {};
-113         var shader;
-114 
-115         for (var i = 0, len = shaders.length; i < len; i++) {
-116             shader = shaders[i];
-117 
-118             if (!shader.stage) {
-119                 throw SceneJS_error.fatalError(
-120                         SceneJS.errors.ILLEGAL_NODE_CONFIG,
-121                         "shader 'stage' attribute expected");
-122             }
-123 
-124             var code;
-125             if (shader.code) {
-126                 if (SceneJS._isArray(shader.code)) {
-127                     code = shader.code.join("");
-128                 } else {
-129                     code = shader.code;
-130                 }
-131             }
-132 
-133             this._core.shaders[shader.stage] = {
-134                 code: code,
-135                 hooks: shader.hooks
-136             };
-137         }
-138     };
-139 
-140     SceneJS.Shader.prototype.setParams = function(params) {
-141         params = params || {};
-142         var coreParams = this._core.params;
-143         if (!coreParams) {
-144             coreParams = this._core.params = {};
-145         }
-146         for (var name in params) {
-147             if (params.hasOwnProperty(name)) {
-148                 coreParams[name] = params[name];
-149             }
-150         }
-151         this._engine.display.imageDirty = true;
-152     };
-153 
-154     SceneJS.Shader.prototype.getParams = function() {
-155         var coreParams = this._core.params;
-156         if (!coreParams) {
-157             return {};
-158         }
-159         var params = {};
-160         for (var name in coreParams) {
-161             if (coreParams.hasOwnProperty(name)) {
-162                 params[name] = coreParams[name];
-163             }
-164         }
-165         return params;
-166     };
-167 
-168     SceneJS.Shader.prototype._compile = function() {
-169 
-170         idStack[stackLen] = this._core.coreId; // Draw list node tied to core, not node
-171 
-172         var shaders = this._core.shaders;
-173 
-174         var fragment = shaders.fragment || {};
-175         var vertex = shaders.vertex || {};
-176 
-177         shaderFragmentCodeStack[stackLen] = fragment.code || "";
-178         shaderFragmentHooksStack[stackLen] = fragment.hooks || {};
-179 
-180         shaderVertexCodeStack[stackLen] = vertex.code || "";
-181         shaderVertexHooksStack[stackLen] = vertex.hooks || {};
-182 
-183         shaderParamsStack[stackLen] = this._core.params || {};
-184 
-185         stackLen++;
-186         dirty = true;
-187 
-188         this._compileNodes();
-189 
-190         stackLen--;
-191         dirty = true;
-192     };
-193 
-194 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_shaderParams.js.html b/docs/symbols/src/src_core_scene_shaderParams.js.html deleted file mode 100644 index dae64c0f..00000000 --- a/docs/symbols/src/src_core_scene_shaderParams.js.html +++ /dev/null @@ -1,104 +0,0 @@ -
  1 new (function() {
-  2 
-  3     /**
-  4      * The default state core singleton for {@link SceneJS.ShaderParams} nodes
-  5      */
-  6     var defaultCore = {
-  7         type: "shaderParams",
-  8         stateId: SceneJS._baseStateId++,
-  9         empty: true
- 10     };
- 11 
- 12     var idStack = [];
- 13     var shaderParamsStack = [];
- 14     var stackLen = 0;
- 15     var dirty;
- 16 
- 17     SceneJS_events.addListener(
- 18             SceneJS_events.SCENE_COMPILING,
- 19             function(params) {
- 20 
- 21                 params.engine.display.shaderParams = defaultCore;
- 22 
- 23                 stackLen = 0;
- 24                 dirty = true;
- 25             });
- 26 
- 27     SceneJS_events.addListener(
- 28             SceneJS_events.OBJECT_COMPILING,
- 29             function(params) {
- 30                 if (dirty) {
- 31 
- 32                     if (stackLen > 0) {
- 33                         var core = {
- 34                             type: "shaderParams",
- 35                             stateId: idStack[stackLen - 1],
- 36                             paramsStack: shaderParamsStack.slice(0, stackLen)
- 37                         };
- 38                         params.display.shaderParams = core;
- 39 
- 40                     } else {
- 41                         params.display.shaderParams = defaultCore;
- 42                     }
- 43 
- 44                     dirty = false;
- 45                 }
- 46             });
- 47 
- 48     SceneJS.ShaderParams = SceneJS_NodeFactory.createNodeType("shaderParams");
- 49 
- 50     SceneJS.ShaderParams.prototype._init = function(params) {
- 51         if (this._core.useCount == 1) { // This node is the resource definer
- 52             this.setParams(params.params);
- 53         }
- 54     };
- 55 
- 56     SceneJS.ShaderParams.prototype.setParams = function(params) {
- 57         params = params || {};
- 58         var core = this._core;
- 59         if (!core.params) {
- 60             core.params = {};
- 61         }
- 62         for (var name in params) {
- 63             if (params.hasOwnProperty(name)) {
- 64                 core.params[name] = params[name];
- 65             }
- 66         }
- 67         this._engine.display.imageDirty = true;
- 68     };
- 69 
- 70     SceneJS.ShaderParams.prototype.getParams = function() {
- 71         var coreParams = this._core.params;
- 72         if (!coreParams) {
- 73             return {};
- 74         }
- 75         var params = {};
- 76         for (var name in coreParams) {
- 77             if (coreParams.hasOwnProperty(name)) {
- 78                 params[name] = coreParams[name];
- 79             }
- 80         }
- 81         return params;
- 82     };
- 83 
- 84     SceneJS.ShaderParams.prototype._compile = function() {
- 85 
- 86         idStack[stackLen] = this._core.coreId; // Tie draw list state to core, not to scene node
- 87         shaderParamsStack[stackLen] = this._core.params;
- 88         stackLen++;
- 89         dirty = true;
- 90 
- 91         this._compileNodes();
- 92 
- 93         stackLen--;
- 94         dirty = true;
- 95     };
- 96 
- 97 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_tag.js.html b/docs/symbols/src/src_core_scene_tag.js.html deleted file mode 100644 index 059b8f6e..00000000 --- a/docs/symbols/src/src_core_scene_tag.js.html +++ /dev/null @@ -1,67 +0,0 @@ -
  1 (function() {
-  2 
-  3     /**
-  4      * The default state core singleton for {@link SceneJS.Tag} nodes
-  5      */
-  6     var defaultCore = {
-  7         type: "tag",
-  8         stateId: SceneJS._baseStateId++,
-  9         tag : null
- 10     };
- 11 
- 12     var coreStack = [];
- 13     var stackLen = 0;
- 14 
- 15     SceneJS_events.addListener(
- 16             SceneJS_events.SCENE_COMPILING,
- 17             function(params) {
- 18                 params.engine.display.tag = defaultCore;
- 19                 stackLen = 0;
- 20             });
- 21 
- 22     /**
- 23      * @class Scene graph node which assigns a symbolic tag name to the {@link SceneJS.Geometry} nodes in its subgraph.
- 24      * The subgraph can then be included or excluded from scene rendering using {@link SceneJS.Scene#setTagMask}.
- 25      * @extends SceneJS.Node
- 26      */
- 27     SceneJS.Tag = SceneJS_NodeFactory.createNodeType("tag");
- 28 
- 29     SceneJS.Tag.prototype._init = function(params) {
- 30         if (this._core.useCount == 1) { // This node defines the resource
- 31             if (!params.tag) {
- 32                 throw SceneJS_error.fatalError(
- 33                         SceneJS.errors.NODE_CONFIG_EXPECTED,
- 34                         "tag node attribute missing : 'tag'");
- 35             }
- 36             this.setTag(params.tag);
- 37         }
- 38     };
- 39 
- 40     SceneJS.Tag.prototype.setTag = function(tag) {
- 41 
- 42         var core = this._core;
- 43 
- 44         core.tag = tag;
- 45         core.pattern = null;    // To be recomputed
- 46         core.matched = false;   // To be rematched
- 47 
- 48         this._engine.display.drawListDirty = true;
- 49     };
- 50 
- 51     SceneJS.Tag.prototype.getTag = function() {
- 52         return this._core.tag;
- 53     };
- 54 
- 55     SceneJS.Tag.prototype._compile = function() {
- 56         this._engine.display.tag = coreStack[stackLen++] = this._core;
- 57         this._compileNodes();
- 58         this._engine.display.tag = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore;
- 59     };
- 60 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_texture.js.html b/docs/symbols/src/src_core_scene_texture.js.html deleted file mode 100644 index 6a311cbc..00000000 --- a/docs/symbols/src/src_core_scene_texture.js.html +++ /dev/null @@ -1,507 +0,0 @@ -
  1 /**
-  2  * @class Scene graph node which defines textures to apply to the objects in its subgraph
-  3  * @extends SceneJS.Node
-  4  */
-  5 new (function () {
-  6 
-  7     /**
-  8      * The default state core singleton for {@link SceneJS.Texture} nodes
-  9      */
- 10     var defaultCore = {
- 11         type:"texture",
- 12         stateId:SceneJS._baseStateId++,
- 13         empty:true,
- 14         hash:""
- 15     };
- 16 
- 17     var coreStack = [];
- 18     var stackLen = 0;
- 19 
- 20     SceneJS_events.addListener(
- 21         SceneJS_events.SCENE_COMPILING,
- 22         function (params) {
- 23             params.engine.display.texture = defaultCore;
- 24             stackLen = 0;
- 25         });
- 26 
- 27     /**
- 28      * @class Scene graph node which defines one or more textures to apply to the {@link SceneJS.Geometry} nodes in its subgraph
- 29      * @extends SceneJS.Node
- 30      */
- 31     SceneJS.Texture = SceneJS_NodeFactory.createNodeType("texture");
- 32 
- 33     SceneJS.Texture.prototype._init = function (params) {
- 34 
- 35         if (this._core.useCount == 1) { // This node is the resource definer
- 36 
- 37             this._core.layers = [];
- 38             this._core.params = {};
- 39 
- 40             var waitForLoad = !!params.waitForLoad;
- 41 
- 42             if (!params.layers) {
- 43                 throw SceneJS_error.fatalError(
- 44                     SceneJS.errors.NODE_CONFIG_EXPECTED,
- 45                     "texture layers missing");
- 46             }
- 47 
- 48             if (!SceneJS._isArray(params.layers)) {
- 49                 throw SceneJS_error.fatalError(
- 50                     SceneJS.errors.NODE_CONFIG_EXPECTED,
- 51                     "texture layers should be an array");
- 52             }
- 53 
- 54             var layerParams;
- 55             var gl = this._engine.canvas.gl;
- 56 
- 57             for (var i = 0; i < params.layers.length; i++) {
- 58 
- 59                 layerParams = params.layers[i];
- 60 
- 61                 if (!layerParams.source && !layerParams.uri && !layerParams.src && !layerParams.framebuf && !layerParams.video) {
- 62 
- 63                     throw SceneJS_error.fatalError(
- 64                         SceneJS.errors.NODE_CONFIG_EXPECTED,
- 65                         "texture layer " + i + "  has no uri, src, source, framebuf, video or canvasId specified");
- 66                 }
- 67 
- 68                 if (layerParams.applyFrom) {
- 69 
- 70                     if (layerParams.applyFrom != "uv" &&
- 71                         layerParams.applyFrom != "uv2" &&
- 72                         layerParams.applyFrom != "normal" &&
- 73                         layerParams.applyFrom != "geometry") {
- 74 
- 75                         throw SceneJS_error.fatalError(
- 76                             SceneJS.errors.NODE_CONFIG_EXPECTED,
- 77                             "texture layer " + i + "  applyFrom value is unsupported - " +
- 78                                 "should be either 'uv', 'uv2', 'normal' or 'geometry'");
- 79                     }
- 80                 }
- 81 
- 82                 if (layerParams.applyTo) {
- 83 
- 84                     if (layerParams.applyTo != "baseColor" && // Colour map
- 85                         layerParams.applyTo != "specular" && // Specular map
- 86                         layerParams.applyTo != "emit" && // Emission map
- 87                         layerParams.applyTo != "alpha" && // Alpha map
- 88                         layerParams.applyTo != "normals") {
- 89 
- 90                         throw SceneJS_error.fatalError(
- 91                             SceneJS.errors.NODE_CONFIG_EXPECTED,
- 92                             "texture layer " + i + " applyTo value is unsupported - " +
- 93                                 "should be either 'baseColor', 'specular' or 'normals'");
- 94                     }
- 95                 }
- 96 
- 97                 if (layerParams.blendMode) {
- 98 
- 99                     if (layerParams.blendMode != "add" && layerParams.blendMode != "multiply") {
-100 
-101                         throw SceneJS_error.fatalError(
-102                             SceneJS.errors.NODE_CONFIG_EXPECTED,
-103                             "texture layer " + i + " blendMode value is unsupported - " +
-104                                 "should be either 'add' or 'multiply'");
-105                     }
-106                 }
-107 
-108                 var layer = SceneJS._apply(layerParams, {
-109                     waitForLoad:waitForLoad,
-110                     texture:null,
-111                     applyFrom:layerParams.applyFrom || "uv",
-112                     applyTo:layerParams.applyTo || "baseColor",
-113                     blendMode:layerParams.blendMode || "multiply",
-114                     blendFactor:(layerParams.blendFactor != undefined && layerParams.blendFactor != null) ? layerParams.blendFactor : 1.0,
-115                     translate:{ x:0, y:0},
-116                     scale:{ x:1, y:1 },
-117                     rotate:{ z:0.0 }
-118                 });
-119 
-120                 this._core.layers.push(layer);
-121 
-122                 this._setLayerTransform(layerParams, layer);
-123 
-124                 if (layer.framebuf) { // Create from a framebuf node preceeding this texture in the scene graph
-125 
-126                     var targetNode = this._engine.findNode(layer.framebuf);
-127 
-128                     if (targetNode && targetNode.type == "framebuf") {
-129                         layer.texture = targetNode._core.framebuf.getTexture(); // TODO: what happens when the framebuf is destroyed?
-130                     }
-131 
-132                 } else { // Create from texture node's layer configs
-133                     this._loadLayerTexture(gl, layer);
-134                 }
-135             }
-136 
-137             var self = this;
-138 
-139             /**
-140              * WebGL restored handler - rebuilds the texture layers
-141              */
-142             this._core.webglRestored = function () {
-143 
-144                 var layers = self._core.layers;
-145                 var gl = self._engine.canvas.gl;
-146 
-147                 for (var i = 0, len = layers.length; i < len; i++) {
-148                     self._loadLayerTexture(gl, layers[i]);
-149                 }
-150             };
-151         }
-152     };
-153 
-154     SceneJS.Texture.prototype._loadLayerTexture = function (gl, layer) {
-155 
-156         SceneJS_sceneStatusModule.nodeLoading(this);
-157 
-158         this._engine.nodeLoading(this);
-159 
-160         this._fireEvent("loading");
-161 
-162         var self = this;
-163 
-164         var sourceConfigs = layer.source;
-165 
-166         if (sourceConfigs) {
-167 
-168             if (!sourceConfigs.type) {
-169                 throw SceneJS_error.fatalError(
-170                     SceneJS.errors.ILLEGAL_NODE_CONFIG,
-171                     "texture layer config expected: source.type");
-172             }
-173 
-174             SceneJS.Plugins.getPlugin(
-175                 "texture",
-176                 sourceConfigs.type,
-177                 function (plugin) {
-178 
-179                     if (!plugin.getSource) {
-180                         throw SceneJS_error.fatalError(
-181                             SceneJS.errors.PLUGIN_INVALID,
-182                             "texture: 'getSource' method missing on plugin for texture source type '" + sourceConfigs.type + "'.");
-183                     }
-184 
-185                     var source = plugin.getSource({ gl:gl });
-186 
-187                     if (!source.onUpdate) {
-188                         throw SceneJS_error.fatalError(
-189                             SceneJS.errors.PLUGIN_INVALID,
-190                             "texture: 'onUpdate' method missing on plugin for texture source type '" + sourceConfigs.type + "'");
-191                     }
-192 
-193                     source.onUpdate(// Get notification whenever source updates the texture
-194                         (function () {
-195                             var loaded = false;
-196                             return function () {
-197                                 if (!loaded) { // Texture first initialised - create layer
-198                                     loaded = true;
-199                                     self._setLayerTexture(gl, layer, source.getTexture());
-200 
-201                                 } else { // Texture updated - layer already has the handle to it, so just signal a redraw
-202                                     self._engine.display.imageDirty = true;
-203                                 }
-204                             };
-205                         })());
-206 
-207                     source.setConfigs(sourceConfigs); // Configure the source, which may cause it to update the texture
-208 
-209                     layer._source = source;
-210                 });
-211 
-212         } else {
-213 
-214             /* Load from URL
-215              */
-216             var image = new Image();
-217 
-218             image.onload = function () {
-219                 var texture = gl.createTexture();
-220                 gl.bindTexture(gl.TEXTURE_2D, texture);
-221                 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, self._ensureImageSizePowerOfTwo(image));
-222                 self._setLayerTexture(gl, layer, texture);
-223             };
-224 
-225             image.crossOrigin = "";
-226             image.src = layer.uri || layer.src;
-227         }
-228     };
-229 
-230     SceneJS.Texture.prototype._ensureImageSizePowerOfTwo = function (image) {
-231 
-232         if (!this._isPowerOfTwo(image.width) || !this._isPowerOfTwo(image.height)) {
-233 
-234             var canvas = document.createElement("canvas");
-235             canvas.width = this._nextHighestPowerOfTwo(image.width);
-236             canvas.height = this._nextHighestPowerOfTwo(image.height);
-237 
-238             var ctx = canvas.getContext("2d");
-239 
-240             ctx.drawImage(image,
-241                 0, 0, image.width, image.height,
-242                 0, 0, canvas.width, canvas.height);
-243 
-244             image = canvas;
-245             image.crossOrigin = "";
-246         }
-247         return image;
-248     };
-249 
-250     SceneJS.Texture.prototype._isPowerOfTwo = function (x) {
-251         return (x & (x - 1)) == 0;
-252     };
-253 
-254     SceneJS.Texture.prototype._nextHighestPowerOfTwo = function (x) {
-255         --x;
-256         for (var i = 1; i < 32; i <<= 1) {
-257             x = x | x >> i;
-258         }
-259         return x + 1;
-260     };
-261 
-262     SceneJS.Texture.prototype._setLayerTexture = function (gl, layer, texture) {
-263 
-264         layer.texture = new SceneJS_webgl_Texture2D(gl, {
-265             texture:texture, // WebGL texture object
-266             minFilter:this._getGLOption("minFilter", gl, layer, gl.LINEAR_MIPMAP_NEAREST),
-267             magFilter:this._getGLOption("magFilter", gl, layer, gl.LINEAR),
-268             wrapS:this._getGLOption("wrapS", gl, layer, gl.CLAMP_TO_EDGE),
-269             wrapT:this._getGLOption("wrapT", gl, layer, gl.CLAMP_TO_EDGE),
-270             isDepth:this._getOption(layer.isDepth, false),
-271             depthMode:this._getGLOption("depthMode", gl, layer, gl.LUMINANCE),
-272             depthCompareMode:this._getGLOption("depthCompareMode", gl, layer, gl.COMPARE_R_TO_TEXTURE),
-273             depthCompareFunc:this._getGLOption("depthCompareFunc", gl, layer, gl.LEQUAL),
-274             flipY:this._getOption(layer.flipY, true),
-275             width:this._getOption(layer.width, 1),
-276             height:this._getOption(layer.height, 1),
-277             internalFormat:this._getGLOption("internalFormat", gl, layer, gl.LEQUAL),
-278             sourceFormat:this._getGLOption("sourceType", gl, layer, gl.ALPHA),
-279             sourceType:this._getGLOption("sourceType", gl, layer, gl.UNSIGNED_BYTE),
-280             update:null
-281         });
-282 
-283         SceneJS_sceneStatusModule.nodeLoaded(this);
-284 
-285         this._engine.nodeLoaded(this);
-286 
-287         this._fireEvent("loaded");
-288 
-289         if (this.destroyed) { // Node was destroyed while loading
-290             layer.texture.destroy();
-291         }
-292 
-293         this._engine.display.imageDirty = true;
-294     };
-295 
-296     SceneJS.Texture.prototype._getGLOption = function (name, gl, layer, defaultVal) {
-297         var value = layer[name];
-298         if (value == undefined) {
-299             return defaultVal;
-300         }
-301         var glName = SceneJS_webgl_enumMap[value];
-302         if (glName == undefined) {
-303             throw SceneJS_error.fatalError(
-304                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
-305                 "Unrecognised value for texture node property '" + name + "' value: '" + value + "'");
-306         }
-307         var glValue = gl[glName];
-308         //                if (!glValue) {
-309         //                    throw new SceneJS.errors.WebGLUnsupportedNodeConfigException(
-310         //                            "This browser's WebGL does not support value of SceneJS.texture node property '" + name + "' value: '" + value + "'");
-311         //                }
-312         return glValue;
-313     };
-314 
-315     SceneJS.Texture.prototype._getOption = function (value, defaultVal) {
-316         return (value == undefined) ? defaultVal : value;
-317     };
-318 
-319     /**
-320      * Set some writeable properties on a layer
-321      */
-322     SceneJS.Texture.prototype.setLayer = function (cfg) {
-323 
-324         if (cfg.index == undefined || cfg.index == null) {
-325             throw SceneJS_error.fatalError(
-326                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
-327                 "Invalid texture set layer argument: index null or undefined");
-328         }
-329 
-330         if (cfg.index < 0 || cfg.index >= this._core.layers.length) {
-331             throw SceneJS_error.fatalError(
-332                 SceneJS.errors.ILLEGAL_NODE_CONFIG,
-333                 "Invalid texture set layer argument: index out of range (" + this._core.layers.length + " layers defined)");
-334         }
-335 
-336         this._setLayer(parseInt(cfg.index), cfg);
-337 
-338         this._engine.display.imageDirty = true;
-339     };
-340 
-341     /**
-342      * Set some writeable properties on multiple layers
-343      */
-344     SceneJS.Texture.prototype.setLayers = function (layers) {
-345         var indexNum;
-346         for (var index in layers) {
-347             if (layers.hasOwnProperty(index)) {
-348                 if (index != undefined || index != null) {
-349                     indexNum = parseInt(index);
-350                     if (indexNum < 0 || indexNum >= this._core.layers.length) {
-351                         throw SceneJS_error.fatalError(
-352                             SceneJS.errors.ILLEGAL_NODE_CONFIG,
-353                             "Invalid texture set layer argument: index out of range (" + this._core.layers.length + " layers defined)");
-354                     }
-355                     this._setLayer(indexNum, layers[index] || {});
-356                 }
-357             }
-358         }
-359         this._engine.display.imageDirty = true;
-360     };
-361 
-362     SceneJS.Texture.prototype._setLayer = function (index, cfg) {
-363 
-364         cfg = cfg || {};
-365 
-366         var layer = this._core.layers[index];
-367 
-368         if (cfg.blendFactor != undefined && cfg.blendFactor != null) {
-369             layer.blendFactor = cfg.blendFactor;
-370         }
-371 
-372         if (cfg.source) {
-373             var source = layer._source;
-374             if (source) {
-375                 source.setConfigs(cfg.source);
-376             }
-377         }
-378 
-379         if (cfg.translate || cfg.rotate || cfg.scale) {
-380             this._setLayerTransform(cfg, layer);
-381         }
-382     };
-383 
-384     SceneJS.Texture.prototype._setLayerTransform = function (cfg, layer) {
-385 
-386         var matrix;
-387         var t;
-388 
-389         if (cfg.translate) {
-390             var translate = cfg.translate;
-391             if (translate.x != undefined) {
-392                 layer.translate.x = translate.x;
-393             }
-394             if (translate.y != undefined) {
-395                 layer.translate.y = translate.y;
-396             }
-397             matrix = SceneJS_math_translationMat4v([ translate.x || 0, translate.y || 0, 0]);
-398         }
-399 
-400         if (cfg.scale) {
-401             var scale = cfg.scale;
-402             if (scale.x != undefined) {
-403                 layer.scale.x = scale.x;
-404             }
-405             if (scale.y != undefined) {
-406                 layer.scale.y = scale.y;
-407             }
-408             t = SceneJS_math_scalingMat4v([ scale.x || 1, scale.y || 1, 1]);
-409             matrix = matrix ? SceneJS_math_mulMat4(matrix, t) : t;
-410         }
-411 
-412         if (cfg.rotate) {
-413             var rotate = cfg.rotate;
-414             if (rotate.z != undefined) {
-415                 layer.rotate.z = rotate.z || 0;
-416             }
-417             t = SceneJS_math_rotationMat4v(rotate.z * 0.0174532925, [0, 0, 1]);
-418             matrix = matrix ? SceneJS_math_mulMat4(matrix, t) : t;
-419         }
-420 
-421         if (matrix) {
-422             layer.matrix = matrix;
-423             if (!layer.matrixAsArray) {
-424                 layer.matrixAsArray = new Float32Array(layer.matrix);
-425             } else {
-426                 layer.matrixAsArray.set(layer.matrix);
-427             }
-428 
-429             layer.matrixAsArray = new Float32Array(layer.matrix); // TODO - reinsert into array
-430         }
-431     };
-432 
-433     SceneJS.Texture.prototype._compile = function () {
-434 
-435         if (!this._core.hash) {
-436             this._makeHash();
-437         }
-438 
-439         this._engine.display.texture = coreStack[stackLen++] = this._core;
-440         this._compileNodes();
-441         this._engine.display.texture = (--stackLen > 0) ? coreStack[stackLen - 1] : defaultCore;
-442     };
-443 
-444     SceneJS.Texture.prototype._makeHash = function () {
-445 
-446         var core = this._core;
-447         var hash;
-448 
-449         if (core.layers && core.layers.length > 0) {
-450 
-451             var layers = core.layers;
-452             var hashParts = [];
-453             var texLayer;
-454 
-455             for (var i = 0, len = layers.length; i < len; i++) {
-456 
-457                 texLayer = layers[i];
-458 
-459                 hashParts.push("/");
-460                 hashParts.push(texLayer.applyFrom);
-461                 hashParts.push("/");
-462                 hashParts.push(texLayer.applyTo);
-463                 hashParts.push("/");
-464                 hashParts.push(texLayer.blendMode);
-465 
-466                 if (texLayer.matrix) {
-467                     hashParts.push("/anim");
-468                 }
-469             }
-470 
-471             hash = hashParts.join("");
-472 
-473         } else {
-474             hash = "";
-475         }
-476 
-477         if (core.hash != hash) {
-478             core.hash = hash;
-479         }
-480     };
-481 
-482     SceneJS.Texture.prototype._destroy = function () {
-483         if (this._core.useCount == 1) { // Last resource user
-484             var layers = this._core.layers;
-485             var layer;
-486             var source;
-487             for (var i = 0, len = layers.length; i < len; i++) {
-488                 layer = layers[i];
-489                 if (layer.texture) {
-490                     layer.texture.destroy();
-491                 }
-492                 source = layer._source;
-493                 if (source && source.destroy) {
-494                     source.destroy();
-495                 }
-496             }
-497         }
-498     };
-499 
-500 })();
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_translate.js.html b/docs/symbols/src/src_core_scene_translate.js.html deleted file mode 100644 index 094e53f1..00000000 --- a/docs/symbols/src/src_core_scene_translate.js.html +++ /dev/null @@ -1,166 +0,0 @@ -
  1 /**
-  2  * @class Scene graph node which defines a translation modelling transform to apply to the objects in its subgraph
-  3  * @extends SceneJS.Node
-  4  */
-  5 SceneJS.Translate = SceneJS_NodeFactory.createNodeType("translate");
-  6 
-  7 SceneJS.Translate.prototype._init = function(params) {
-  8 
-  9     if (this._core.useCount == 1) { // This node is the resource definer
- 10 
- 11         SceneJS_modelXFormStack.buildCore(this._core);
- 12         
- 13         this.setMultOrder(params.multOrder);
- 14 
- 15         this.setXYZ({
- 16             x: params.x,
- 17             y: params.y,
- 18             z: params.z
- 19         });
- 20 
- 21         var core = this._core;
- 22 
- 23         this._core.buildMatrix = function() {
- 24             core.matrix = SceneJS_math_translationMat4v([core.x, core.y, core.z], core.matrix);
- 25         };
- 26     }
- 27 };
- 28 
- 29 /**
- 30  * Get Model matrix
- 31  * @return {*}
- 32  */
- 33 SceneJS.Translate.prototype.getModelMatrix = function() {
- 34     if (this._core.dirty) {
- 35         this._core.build();
- 36     }
- 37     return this._core.matrix;
- 38 };
- 39 
- 40 /**
- 41  * Get World matrix. That's the multiplication of this node's Model matrix by the World matrix of the the next
- 42  * tranform (scale, translate, translate etc) node on the path to the scene root.
- 43  * @return {*}
- 44  */
- 45 SceneJS.Translate.prototype.getWorldMatrix = function() {
- 46     if (this._core.dirty) {
- 47         this._core.build();
- 48     }
- 49     return Array.apply( [], this._core.mat);
- 50 };
- 51 
- 52 
- 53 /**
- 54  * Sets the multiplication order of this node's transform matrix with respect to the parent modeling transform
- 55  * in the scene graph.
- 56  *
- 57  * @param {String} multOrder Mulplication order - "post" and "pre"
- 58  */
- 59 SceneJS.Translate.prototype.setMultOrder = function(multOrder) {
- 60 
- 61     multOrder = multOrder || "post";
- 62 
- 63     if (multOrder != "post" && multOrder != "pre") {
- 64 
- 65         throw SceneJS_error.fatalError(
- 66                 SceneJS.errors.NODE_CONFIG_EXPECTED,
- 67                 "Illegal multOrder for translate node - '" + multOrder + "' should be 'pre' or 'post'");
- 68     }
- 69 
- 70     this._core.multOrder = multOrder;
- 71 
- 72     this._core.setDirty();
- 73 
- 74     this._engine.display.imageDirty = true;
- 75 };
- 76 
- 77 SceneJS.Translate.prototype.setXYZ = function(xyz) {
- 78 
- 79     xyz = xyz || {};
- 80 
- 81     this._core.x = xyz.x || 0;
- 82     this._core.y = xyz.y || 0;
- 83     this._core.z = xyz.z || 0;
- 84 
- 85     this._core.setDirty();
- 86 
- 87     this._engine.display.imageDirty = true;
- 88 
- 89     return this;
- 90 };
- 91 
- 92 SceneJS.Translate.prototype.getXYZ = function() {
- 93     return {
- 94         x: this._core.x,
- 95         y: this._core.y,
- 96         z: this._core.z
- 97     };
- 98 };
- 99 
-100 SceneJS.Translate.prototype.setX = function(x) {
-101     this._core.x = x;
-102     this._core.setDirty();
-103     this._engine.display.imageDirty = true;
-104     return this;
-105 };
-106 
-107 SceneJS.Translate.prototype.getX = function() {
-108     return this._core.x;
-109 };
-110 
-111 SceneJS.Translate.prototype.setY = function(y) {
-112     this._core.y = y;
-113     this._core.setDirty();
-114     this._engine.display.imageDirty = true;
-115     return this;
-116 };
-117 
-118 SceneJS.Translate.prototype.getY = function() {
-119     return this._core.y;
-120 };
-121 
-122 SceneJS.Translate.prototype.setZ = function(z) {
-123     this._core.z = z;
-124     this._core.setDirty();
-125     this._engine.display.imageDirty = true;
-126     return this;
-127 };
-128 
-129 SceneJS.Translate.prototype.getZ = function() {
-130     return this._core.z;
-131 };
-132 
-133 SceneJS.Translate.prototype.incX = function(x) {
-134     this._core.x += x;
-135     this._core.setDirty();
-136     this._engine.display.imageDirty = true;
-137     return this;
-138 };
-139 
-140 SceneJS.Translate.prototype.incY = function(y) {
-141     this._core.y += y;
-142     this._core.setDirty();
-143     this._engine.display.imageDirty = true;
-144     return this;
-145 };
-146 
-147 SceneJS.Translate.prototype.incZ = function(z) {
-148     this._core.z += z;
-149     this._core.setDirty();
-150     this._engine.display.imageDirty = true;
-151     return this;
-152 };
-153 
-154 SceneJS.Translate.prototype._compile = function() {
-155     SceneJS_modelXFormStack.push(this._core);
-156     this._compileNodes();
-157     SceneJS_modelXFormStack.pop();
-158 };
-159 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scene_xform.js.html b/docs/symbols/src/src_core_scene_xform.js.html deleted file mode 100644 index 53b79cbb..00000000 --- a/docs/symbols/src/src_core_scene_xform.js.html +++ /dev/null @@ -1,88 +0,0 @@ -
  1 /**
-  2  * @class Scene graph node which defines the modelling transform to apply to the objects in its subgraph
-  3  * @extends SceneJS.Node
-  4  */
-  5 SceneJS.XForm = SceneJS_NodeFactory.createNodeType("xform");
-  6 
-  7 SceneJS.XForm.prototype._init = function (params) {
-  8 
-  9     if (this._core.useCount == 1) { // This node is the resource definer
- 10 
- 11         SceneJS_modelXFormStack.buildCore(this._core);
- 12 
- 13         this.setElements(params.elements);
- 14     }
- 15 };
- 16 
- 17 /**
- 18  * Get Model matrix
- 19  * @return {*}
- 20  */
- 21 SceneJS.XForm.prototype.getModelMatrix = function() {
- 22     if (this._core.dirty) {
- 23         this._core.build();
- 24     }
- 25     return this._core.matrix;
- 26 };
- 27 
- 28 /**
- 29  * Get World matrix. That's the multiplication of this node's Model matrix by the World matrix of the the next
- 30  * tranform (scale, XForm, translate etc) node on the path to the scene root.
- 31  * @return {*}
- 32  */
- 33 SceneJS.XForm.prototype.getWorldMatrix = function() {
- 34     if (this._core.dirty) {
- 35         this._core.build();
- 36     }
- 37     return Array.apply( [], this._core.mat);
- 38 };
- 39 
- 40 
- 41 SceneJS.XForm.prototype.setElements = function (elements) {
- 42 
- 43     elements = elements || SceneJS_math_identityMat4();
- 44 
- 45     if (elements.length != 16) {
- 46         throw SceneJS_error.fatalError(
- 47             SceneJS.errors.ILLEGAL_NODE_CONFIG,
- 48             "SceneJS.XForm elements should number 16");
- 49     }
- 50 
- 51     var core = this._core;
- 52 
- 53     if (!core.matrix) {
- 54         core.matrix = elements;
- 55 
- 56     } else {
- 57 
- 58         for (var i = 0; i < 16; i++) {
- 59             core.matrix[i] = elements[i];
- 60         }
- 61     }
- 62 
- 63 //    core.mat.set(core.matrix);
- 64 //    core.normalMat.set(
- 65 //        SceneJS_math_transposeMat4(
- 66 //            SceneJS_math_inverseMat4(core.matrix, SceneJS_math_mat4())));
- 67 
- 68 
- 69     core.setDirty();
- 70 
- 71     this._engine.display.imageDirty = true;
- 72 
- 73     return this;
- 74 };
- 75 
- 76 SceneJS.XForm.prototype._compile = function () {
- 77     SceneJS_modelXFormStack.push(this._core);
- 78     this._compileNodes();
- 79     SceneJS_modelXFormStack.pop();
- 80 };
- 81 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_scenejs.js.html b/docs/symbols/src/src_core_scenejs.js.html deleted file mode 100644 index 834cdd8c..00000000 --- a/docs/symbols/src/src_core_scenejs.js.html +++ /dev/null @@ -1,194 +0,0 @@ -
  1 /**
-  2  * The SceneJS object.
-  3  */
-  4 var SceneJS = new (function () {
-  5 
-  6     /**
-  7      * This SceneJS version
-  8      */
-  9     this.VERSION = '3.0.0.0';
- 10 
- 11     this._baseStateId = 0;
- 12 
- 13     /**
- 14      * @property {SceneJS_Engine} Engines currently in existance
- 15      */
- 16     this._engines = {};
- 17 
- 18     this._engineIds = new SceneJS_Map();
- 19 
- 20     /**
- 21      * Creates a new scene from the given JSON description
- 22      *
- 23      * @param {String} json JSON scene description
- 24      * @param options Optional options
- 25      * @param options.simulateWebGLContextLost Optional options
- 26      * @returns {SceneJS.Scene} New scene
- 27      */
- 28     this.createScene = function (json, options) {
- 29 
- 30         if (!json) {
- 31             throw SceneJS_error.fatalError("param 'json' is null or undefined");
- 32         }
- 33 
- 34         if (json.id) {
- 35             if (this._engines[json.id]) {
- 36                 throw SceneJS_error.fatalError(
- 37                     SceneJS.errors.ILLEGAL_NODE_CONFIG,
- 38                     "Scene already exists with this ID: '" + json.id + "'");
- 39             }
- 40             this._engineIds.addItem(json.id, {});
- 41         } else {
- 42             json.id = this._engineIds.addItem({});
- 43         }
- 44 
- 45         var engine = new SceneJS_Engine(json, options);
- 46 
- 47         this._engines[json.id] = engine;
- 48 
- 49         SceneJS_events.fireEvent(SceneJS_events.SCENE_CREATED, {    // Notify modules that need to know about new scene
- 50             engine:engine
- 51         });
- 52 
- 53         return engine.scene;
- 54     };
- 55 
- 56     /**
- 57      * Gets an existing scene
- 58      *
- 59      * @param {String} sceneId ID of target scene
- 60      * @deprecated
- 61      * @returns {SceneJS.Scene} The selected scene
- 62      */
- 63     this.scene = function (sceneId) {
- 64 
- 65         var engine = this._engines[sceneId];
- 66 
- 67         return engine ? engine.scene : null;
- 68     };
- 69 
- 70     /**
- 71      * Gets an existing scene
- 72      *
- 73      * @param {String} sceneId ID of target scene
- 74      * @returns {SceneJS.Scene} The selected scene
- 75      */
- 76     this.getScene = function (sceneId) {
- 77 
- 78         var engine = this._engines[sceneId];
- 79 
- 80         return engine ? engine.scene : null;
- 81     };
- 82 
- 83     /**
- 84      * Gets existing scenes
- 85      *
- 86      * @returns  Existing scenes, mapped to their IDs
- 87      */
- 88     this.getScenes = function () {
- 89 
- 90         var scenes = {};
- 91 
- 92         for (var sceneId in this._engines) {
- 93             if (this._engines.hasOwnProperty(sceneId)) {
- 94                 scenes[sceneId] = this._engines[sceneId].scene;
- 95             }
- 96         }
- 97 
- 98         return scenes;
- 99     };
-100 
-101     /**
-102      * Tests if the given object is an array
-103      * @private
-104      */
-105     this._isArray = function (testObject) {
-106         return testObject && !(testObject.propertyIsEnumerable('length'))
-107             && typeof testObject === 'object' && typeof testObject.length === 'number';
-108     };
-109 
-110     /**
-111      *
-112      */
-113     this._shallowClone = function (o) {
-114         var o2 = {};
-115         for (var name in o) {
-116             if (o.hasOwnProperty(name)) {
-117                 o2[name] = o[name];
-118             }
-119         }
-120         return o2;
-121     };
-122 
-123     /**
-124      * Add properties of o to o2 where undefined or null on o2
-125      * @private
-126      */
-127     this._applyIf = function (o, o2) {
-128         for (var name in o) {
-129             if (o.hasOwnProperty(name)) {
-130                 if (o2[name] == undefined || o2[name] == null) {
-131                     o2[name] = o[name];
-132                 }
-133             }
-134         }
-135         return o2;
-136     };
-137 
-138     /**
-139      * Add properties of o to o2, overwriting them on o2 if already there.
-140      * The optional clear flag causes properties on o2 to be cleared first
-141      * @private
-142      */
-143     this._apply = function (o, o2, clear) {
-144         var name;
-145         if (clear) {
-146             for (name in o2) {
-147                 if (o2.hasOwnProperty(name)) {
-148                     delete o2[name];
-149                 }
-150             }
-151         }
-152         for (name in o) {
-153             if (o.hasOwnProperty(name)) {
-154                 o2[name] = o[name];
-155             }
-156         }
-157         return o2;
-158     };
-159 
-160 
-161     /**
-162      * Resets SceneJS, destroying all existing scenes
-163      */
-164     this.reset = function () {
-165 
-166         var temp = [];
-167 
-168         for (var id in this._engines) { // Collect engines to destroy
-169             if (this._engines.hasOwnProperty(id)) {
-170 
-171                 temp.push(this._engines[id]);
-172 
-173                 delete this._engines[id];
-174 
-175                 this._engineIds.removeItem(id);
-176             }
-177         }
-178 
-179         while (temp.length > 0) { // Destroy the engines
-180             temp.pop().destroy();
-181         }
-182 
-183         SceneJS_events.fireEvent(SceneJS_events.RESET);
-184     };
-185 
-186 })();
-187 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_status.js.html b/docs/symbols/src/src_core_status.js.html deleted file mode 100644 index 7f29c426..00000000 --- a/docs/symbols/src/src_core_status.js.html +++ /dev/null @@ -1,58 +0,0 @@ -
  1 /**
-  2  * Backend that tracks statistics on loading states of nodes during scene traversal.
-  3  *
-  4  * This supports the "loading-status" events that we can listen for on scene nodes.
-  5  *
-  6  * When a node with that listener is pre-visited, it will call getStatus on this module to
-  7  * save a copy of the status. Then when it is post-visited, it will call diffStatus on this
-  8  * module to find the status for its sub-nodes, which it then reports through the "loading-status" event.
-  9  *
- 10  * @private
- 11  */
- 12 var SceneJS_sceneStatusModule = new (function() {
- 13 
- 14     this.sceneStatus = {};
- 15 
- 16     var self = this;
- 17 
- 18     SceneJS_events.addListener(
- 19             SceneJS_events.SCENE_CREATED,
- 20             function(params) {
- 21                 self.sceneStatus[params.engine.id] = {
- 22                     numTasks: 0
- 23                 };
- 24             });
- 25 
- 26     SceneJS_events.addListener(
- 27             SceneJS_events.SCENE_DESTROYED,
- 28             function(params) {
- 29                 delete self.sceneStatus[params.engine.id];
- 30             });
- 31 
- 32     this.nodeLoading = function(node) {
- 33 
- 34         var status = self.sceneStatus[node._engine.id];
- 35 
- 36         if (!status) {
- 37             status = self.sceneStatus[node._engine.id] = {
- 38                 numTasks: 0
- 39             };
- 40 
- 41         }
- 42         status.numTasks++;
- 43     };
- 44 
- 45     this.nodeLoaded = function(node) {
- 46         this.sceneStatus[node._engine.id].numTasks--;
- 47     };
- 48 
- 49 })();
- 50 
- 51 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_webgl-debug-utils.js.html b/docs/symbols/src/src_core_webgl-debug-utils.js.html deleted file mode 100644 index e8d7b602..00000000 --- a/docs/symbols/src/src_core_webgl-debug-utils.js.html +++ /dev/null @@ -1,847 +0,0 @@ -
  1 
-  2 WebGLDebugUtils = function() {
-  3 
-  4 /**
-  5  * Wrapped logging function.
-  6  * @param {string} msg Message to log.
-  7  */
-  8 var log = function(msg) {
-  9   if (window.console && window.console.log) {
- 10     window.console.log(msg);
- 11   }
- 12 };
- 13 
- 14 /**
- 15  * Which arguements are enums.
- 16  * @type {!Object.<number, string>}
- 17  */
- 18 var glValidEnumContexts = {
- 19 
- 20   // Generic setters and getters
- 21 
- 22   'enable': { 0:true },
- 23   'disable': { 0:true },
- 24   'getParameter': { 0:true },
- 25 
- 26   // Rendering
- 27 
- 28   'drawArrays': { 0:true },
- 29   'drawElements': { 0:true, 2:true },
- 30 
- 31   // Shaders
- 32 
- 33   'createShader': { 0:true },
- 34   'getShaderParameter': { 1:true },
- 35   'getProgramParameter': { 1:true },
- 36 
- 37   // Vertex attributes
- 38 
- 39   'getVertexAttrib': { 1:true },
- 40   'vertexAttribPointer': { 2:true },
- 41 
- 42   // Textures
- 43 
- 44   'bindTexture': { 0:true },
- 45   'activeTexture': { 0:true },
- 46   'getTexParameter': { 0:true, 1:true },
- 47   'texParameterf': { 0:true, 1:true },
- 48   'texParameteri': { 0:true, 1:true, 2:true },
- 49   'texImage2D': { 0:true, 2:true, 6:true, 7:true },
- 50   'texSubImage2D': { 0:true, 6:true, 7:true },
- 51   'copyTexImage2D': { 0:true, 2:true },
- 52   'copyTexSubImage2D': { 0:true },
- 53   'generateMipmap': { 0:true },
- 54 
- 55   // Buffer objects
- 56 
- 57   'bindBuffer': { 0:true },
- 58   'bufferData': { 0:true, 2:true },
- 59   'bufferSubData': { 0:true },
- 60   'getBufferParameter': { 0:true, 1:true },
- 61 
- 62   // Renderbuffers and framebuffers
- 63 
- 64   'pixelStorei': { 0:true, 1:true },
- 65   'readPixels': { 4:true, 5:true },
- 66   'bindRenderbuffer': { 0:true },
- 67   'bindFramebuffer': { 0:true },
- 68   'checkFramebufferStatus': { 0:true },
- 69   'framebufferRenderbuffer': { 0:true, 1:true, 2:true },
- 70   'framebufferTexture2D': { 0:true, 1:true, 2:true },
- 71   'getFramebufferAttachmentParameter': { 0:true, 1:true, 2:true },
- 72   'getRenderbufferParameter': { 0:true, 1:true },
- 73   'renderbufferStorage': { 0:true, 1:true },
- 74 
- 75   // Frame buffer operations (clear, blend, depth test, stencil)
- 76 
- 77   'clear': { 0:true },
- 78   'depthFunc': { 0:true },
- 79   'blendFunc': { 0:true, 1:true },
- 80   'blendFuncSeparate': { 0:true, 1:true, 2:true, 3:true },
- 81   'blendEquation': { 0:true },
- 82   'blendEquationSeparate': { 0:true, 1:true },
- 83   'stencilFunc': { 0:true },
- 84   'stencilFuncSeparate': { 0:true, 1:true },
- 85   'stencilMaskSeparate': { 0:true },
- 86   'stencilOp': { 0:true, 1:true, 2:true },
- 87   'stencilOpSeparate': { 0:true, 1:true, 2:true, 3:true },
- 88 
- 89   // Culling
- 90 
- 91   'cullFace': { 0:true },
- 92   'frontFace': { 0:true },
- 93 };
- 94 
- 95 /**
- 96  * Map of numbers to names.
- 97  * @type {Object}
- 98  */
- 99 var glEnums = null;
-100 
-101 /**
-102  * Initializes this module. Safe to call more than once.
-103  * @param {!WebGLRenderingContext} ctx A WebGL context. If
-104  *    you have more than one context it doesn't matter which one
-105  *    you pass in, it is only used to pull out constants.
-106  */
-107 function init(ctx) {
-108   if (glEnums == null) {
-109     glEnums = { };
-110     for (var propertyName in ctx) {
-111       if (typeof ctx[propertyName] == 'number') {
-112         glEnums[ctx[propertyName]] = propertyName;
-113       }
-114     }
-115   }
-116 }
-117 
-118 /**
-119  * Checks the utils have been initialized.
-120  */
-121 function checkInit() {
-122   if (glEnums == null) {
-123     throw 'WebGLDebugUtils.init(ctx) not called';
-124   }
-125 }
-126 
-127 /**
-128  * Returns true or false if value matches any WebGL enum
-129  * @param {*} value Value to check if it might be an enum.
-130  * @return {boolean} True if value matches one of the WebGL defined enums
-131  */
-132 function mightBeEnum(value) {
-133   checkInit();
-134   return (glEnums[value] !== undefined);
-135 }
-136 
-137 /**
-138  * Gets an string version of an WebGL enum.
-139  *
-140  * Example:
-141  *   var str = WebGLDebugUtil.glEnumToString(ctx.getError());
-142  *
-143  * @param {number} value Value to return an enum for
-144  * @return {string} The string version of the enum.
-145  */
-146 function glEnumToString(value) {
-147   checkInit();
-148   var name = glEnums[value];
-149   return (name !== undefined) ? name :
-150       ("*UNKNOWN WebGL ENUM (0x" + value.toString(16) + ")");
-151 }
-152 
-153 /**
-154  * Returns the string version of a WebGL argument.
-155  * Attempts to convert enum arguments to strings.
-156  * @param {string} functionName the name of the WebGL function.
-157  * @param {number} argumentIndx the index of the argument.
-158  * @param {*} value The value of the argument.
-159  * @return {string} The value as a string.
-160  */
-161 function glFunctionArgToString(functionName, argumentIndex, value) {
-162   var funcInfo = glValidEnumContexts[functionName];
-163   if (funcInfo !== undefined) {
-164     if (funcInfo[argumentIndex]) {
-165       return glEnumToString(value);
-166     }
-167   }
-168   if (value === null) {
-169     return "null";
-170   } else if (value === undefined) {
-171     return "undefined";
-172   } else {
-173     return value.toString();
-174   }
-175 }
-176 
-177 /**
-178  * Converts the arguments of a WebGL function to a string.
-179  * Attempts to convert enum arguments to strings.
-180  *
-181  * @param {string} functionName the name of the WebGL function.
-182  * @param {number} args The arguments.
-183  * @return {string} The arguments as a string.
-184  */
-185 function glFunctionArgsToString(functionName, args) {
-186   // apparently we can't do args.join(",");
-187   var argStr = "";
-188   for (var ii = 0; ii < args.length; ++ii) {
-189     argStr += ((ii == 0) ? '' : ', ') +
-190         glFunctionArgToString(functionName, ii, args[ii]);
-191   }
-192   return argStr;
-193 };
-194 
-195 
-196 function makePropertyWrapper(wrapper, original, propertyName) {
-197   //log("wrap prop: " + propertyName);
-198   wrapper.__defineGetter__(propertyName, function() {
-199     return original[propertyName];
-200   });
-201   // TODO(gmane): this needs to handle properties that take more than
-202   // one value?
-203   wrapper.__defineSetter__(propertyName, function(value) {
-204     //log("set: " + propertyName);
-205     original[propertyName] = value;
-206   });
-207 }
-208 
-209 // Makes a function that calls a function on another object.
-210 function makeFunctionWrapper(original, functionName) {
-211   //log("wrap fn: " + functionName);
-212   var f = original[functionName];
-213   return function() {
-214     //log("call: " + functionName);
-215     var result = f.apply(original, arguments);
-216     return result;
-217   };
-218 }
-219 
-220 /**
-221  * Given a WebGL context returns a wrapped context that calls
-222  * gl.getError after every command and calls a function if the
-223  * result is not gl.NO_ERROR.
-224  *
-225  * @param {!WebGLRenderingContext} ctx The webgl context to
-226  *        wrap.
-227  * @param {!function(err, funcName, args): void} opt_onErrorFunc
-228  *        The function to call when gl.getError returns an
-229  *        error. If not specified the default function calls
-230  *        console.log with a message.
-231  * @param {!function(funcName, args): void} opt_onFunc The
-232  *        function to call when each webgl function is called.
-233  *        You can use this to log all calls for example.
-234  */
-235 function makeDebugContext(ctx, opt_onErrorFunc, opt_onFunc) {
-236   init(ctx);
-237   opt_onErrorFunc = opt_onErrorFunc || function(err, functionName, args) {
-238         // apparently we can't do args.join(",");
-239         var argStr = "";
-240         for (var ii = 0; ii < args.length; ++ii) {
-241           argStr += ((ii == 0) ? '' : ', ') +
-242               glFunctionArgToString(functionName, ii, args[ii]);
-243         }
-244         log("WebGL error "+ glEnumToString(err) + " in "+ functionName +
-245             "(" + argStr + ")");
-246       };
-247 
-248   // Holds booleans for each GL error so after we get the error ourselves
-249   // we can still return it to the client app.
-250   var glErrorShadow = { };
-251 
-252   // Makes a function that calls a WebGL function and then calls getError.
-253   function makeErrorWrapper(ctx, functionName) {
-254     return function() {
-255       if (opt_onFunc) {
-256         opt_onFunc(functionName, arguments);
-257       }
-258       var result = ctx[functionName].apply(ctx, arguments);
-259       var err = ctx.getError();
-260       if (err != 0) {
-261         glErrorShadow[err] = true;
-262         opt_onErrorFunc(err, functionName, arguments);
-263       }
-264       return result;
-265     };
-266   }
-267 
-268   // Make a an object that has a copy of every property of the WebGL context
-269   // but wraps all functions.
-270   var wrapper = {};
-271   for (var propertyName in ctx) {
-272     if (typeof ctx[propertyName] == 'function') {
-273        wrapper[propertyName] = makeErrorWrapper(ctx, propertyName);
-274      } else {
-275        makePropertyWrapper(wrapper, ctx, propertyName);
-276      }
-277   }
-278 
-279   // Override the getError function with one that returns our saved results.
-280   wrapper.getError = function() {
-281     for (var err in glErrorShadow) {
-282       if (glErrorShadow.hasOwnProperty(err)) {
-283         if (glErrorShadow[err]) {
-284           glErrorShadow[err] = false;
-285           return err;
-286         }
-287       }
-288     }
-289     return ctx.NO_ERROR;
-290   };
-291 
-292   return wrapper;
-293 }
-294 
-295 function resetToInitialState(ctx) {
-296   var numAttribs = ctx.getParameter(ctx.MAX_VERTEX_ATTRIBS);
-297   var tmp = ctx.createBuffer();
-298   ctx.bindBuffer(ctx.ARRAY_BUFFER, tmp);
-299   for (var ii = 0; ii < numAttribs; ++ii) {
-300     ctx.disableVertexAttribArray(ii);
-301     ctx.vertexAttribPointer(ii, 4, ctx.FLOAT, false, 0, 0);
-302     ctx.vertexAttrib1f(ii, 0);
-303   }
-304   ctx.deleteBuffer(tmp);
-305 
-306   var numTextureUnits = ctx.getParameter(ctx.MAX_TEXTURE_IMAGE_UNITS);
-307   for (var ii = 0; ii < numTextureUnits; ++ii) {
-308     ctx.activeTexture(ctx.TEXTURE0 + ii);
-309     ctx.bindTexture(ctx.TEXTURE_CUBE_MAP, null);
-310     ctx.bindTexture(ctx.TEXTURE_2D, null);
-311   }
-312 
-313   ctx.activeTexture(ctx.TEXTURE0);
-314   ctx.useProgram(null);
-315   ctx.bindBuffer(ctx.ARRAY_BUFFER, null);
-316   ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, null);
-317   ctx.bindFramebuffer(ctx.FRAMEBUFFER, null);
-318   ctx.bindRenderbuffer(ctx.RENDERBUFFER, null);
-319   ctx.disable(ctx.BLEND);
-320   ctx.disable(ctx.CULL_FACE);
-321   ctx.disable(ctx.DEPTH_TEST);
-322   ctx.disable(ctx.DITHER);
-323   ctx.disable(ctx.SCISSOR_TEST);
-324   ctx.blendColor(0, 0, 0, 0);
-325   ctx.blendEquation(ctx.FUNC_ADD);
-326   ctx.blendFunc(ctx.ONE, ctx.ZERO);
-327   ctx.clearColor(0, 0, 0, 0);
-328   ctx.clearDepth(1);
-329   ctx.clearStencil(-1);
-330   ctx.colorMask(true, true, true, true);
-331   ctx.cullFace(ctx.BACK);
-332   ctx.depthFunc(ctx.LESS);
-333   ctx.depthMask(true);
-334   ctx.depthRange(0, 1);
-335   ctx.frontFace(ctx.CCW);
-336   ctx.hint(ctx.GENERATE_MIPMAP_HINT, ctx.DONT_CARE);
-337   ctx.lineWidth(1);
-338   ctx.pixelStorei(ctx.PACK_ALIGNMENT, 4);
-339   ctx.pixelStorei(ctx.UNPACK_ALIGNMENT, 4);
-340   ctx.pixelStorei(ctx.UNPACK_FLIP_Y_WEBGL, false);
-341   ctx.pixelStorei(ctx.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
-342   // TODO: Delete this IF.
-343   if (ctx.UNPACK_COLORSPACE_CONVERSION_WEBGL) {
-344     ctx.pixelStorei(ctx.UNPACK_COLORSPACE_CONVERSION_WEBGL, ctx.BROWSER_DEFAULT_WEBGL);
-345   }
-346   ctx.polygonOffset(0, 0);
-347   ctx.sampleCoverage(1, false);
-348   ctx.scissor(0, 0, ctx.canvas.width, ctx.canvas.height);
-349   ctx.stencilFunc(ctx.ALWAYS, 0, 0xFFFFFFFF);
-350   ctx.stencilMask(0xFFFFFFFF);
-351   ctx.stencilOp(ctx.KEEP, ctx.KEEP, ctx.KEEP);
-352   ctx.viewport(0, 0, ctx.canvas.width, ctx.canvas.height);
-353   ctx.clear(ctx.COLOR_BUFFER_BIT | ctx.DEPTH_BUFFER_BIT | ctx.STENCIL_BUFFER_BIT);
-354 
-355   // TODO: This should NOT be needed but Firefox fails with 'hint'
-356   while(ctx.getError());
-357 }
-358 
-359 function makeLostContextSimulatingCanvas(canvas) {
-360   var unwrappedContext_;
-361   var wrappedContext_;
-362   var onLost_ = [];
-363   var onRestored_ = [];
-364   var wrappedContext_ = {};
-365   var contextId_ = 1;
-366   var contextLost_ = false;
-367   var resourceId_ = 0;
-368   var resourceDb_ = [];
-369   var numCallsToLoseContext_ = 0;
-370   var numCalls_ = 0;
-371   var canRestore_ = false;
-372   var restoreTimeout_ = 0;
-373 
-374   // Holds booleans for each GL error so can simulate errors.
-375   var glErrorShadow_ = { };
-376 
-377   canvas.getContext = function(f) {
-378     return function() {
-379       var ctx = f.apply(canvas, arguments);
-380       // Did we get a context and is it a WebGL context?
-381       if (ctx instanceof WebGLRenderingContext) {
-382         if (ctx != unwrappedContext_) {
-383           if (unwrappedContext_) {
-384             throw "got different context"
-385           }
-386           unwrappedContext_ = ctx;
-387           wrappedContext_ = makeLostContextSimulatingContext(unwrappedContext_);
-388         }
-389         return wrappedContext_;
-390       }
-391       return ctx;
-392     }
-393   }(canvas.getContext);
-394 
-395   function wrapEvent(listener) {
-396     if (typeof(listener) == "function") {
-397       return listener;
-398     } else {
-399       return function(info) {
-400         listener.handleEvent(info);
-401       }
-402     }
-403   }
-404 
-405   var addOnContextLostListener = function(listener) {
-406     onLost_.push(wrapEvent(listener));
-407   };
-408 
-409   var addOnContextRestoredListener = function(listener) {
-410     onRestored_.push(wrapEvent(listener));
-411   };
-412 
-413 
-414   function wrapAddEventListener(canvas) {
-415     var f = canvas.addEventListener;
-416     canvas.addEventListener = function(type, listener, bubble) {
-417       switch (type) {
-418         case 'webglcontextlost':
-419           addOnContextLostListener(listener);
-420           break;
-421         case 'webglcontextrestored':
-422           addOnContextRestoredListener(listener);
-423           break;
-424         default:
-425           f.apply(canvas, arguments);
-426       }
-427     };
-428   }
-429 
-430   wrapAddEventListener(canvas);
-431 
-432   canvas.loseContext = function() {
-433     if (!contextLost_) {
-434       contextLost_ = true;
-435       numCallsToLoseContext_ = 0;
-436       ++contextId_;
-437       while (unwrappedContext_.getError());
-438       clearErrors();
-439       glErrorShadow_[unwrappedContext_.CONTEXT_LOST_WEBGL] = true;
-440       var event = makeWebGLContextEvent("context lost");
-441       var callbacks = onLost_.slice();
-442       setTimeout(function() {
-443           //log("numCallbacks:" + callbacks.length);
-444           for (var ii = 0; ii < callbacks.length; ++ii) {
-445             //log("calling callback:" + ii);
-446             callbacks[ii](event);
-447           }
-448           if (restoreTimeout_ >= 0) {
-449             setTimeout(function() {
-450                 canvas.restoreContext();
-451               }, restoreTimeout_);
-452           }
-453         }, 0);
-454     }
-455   };
-456 
-457   canvas.restoreContext = function() {
-458     if (contextLost_) {
-459       if (onRestored_.length) {
-460         setTimeout(function() {
-461             if (!canRestore_) {
-462               throw "can not restore. webglcontestlost listener did not call event.preventDefault";
-463             }
-464             freeResources();
-465             resetToInitialState(unwrappedContext_);
-466             contextLost_ = false;
-467             numCalls_ = 0;
-468             canRestore_ = false;
-469             var callbacks = onRestored_.slice();
-470             var event = makeWebGLContextEvent("context restored");
-471             for (var ii = 0; ii < callbacks.length; ++ii) {
-472               callbacks[ii](event);
-473             }
-474           }, 0);
-475       }
-476     }
-477   };
-478 
-479   canvas.loseContextInNCalls = function(numCalls) {
-480     if (contextLost_) {
-481       throw "You can not ask a lost contet to be lost";
-482     }
-483     numCallsToLoseContext_ = numCalls_ + numCalls;
-484   };
-485 
-486   canvas.getNumCalls = function() {
-487     return numCalls_;
-488   };
-489 
-490   canvas.setRestoreTimeout = function(timeout) {
-491     restoreTimeout_ = timeout;
-492   };
-493 
-494   function isWebGLObject(obj) {
-495     //return false;
-496     return (obj instanceof WebGLBuffer ||
-497             obj instanceof WebGLFramebuffer ||
-498             obj instanceof WebGLProgram ||
-499             obj instanceof WebGLRenderbuffer ||
-500             obj instanceof WebGLShader ||
-501             obj instanceof WebGLTexture);
-502   }
-503 
-504   function checkResources(args) {
-505     for (var ii = 0; ii < args.length; ++ii) {
-506       var arg = args[ii];
-507       if (isWebGLObject(arg)) {
-508         return arg.__webglDebugContextLostId__ == contextId_;
-509       }
-510     }
-511     return true;
-512   }
-513 
-514   function clearErrors() {
-515     var k = Object.keys(glErrorShadow_);
-516     for (var ii = 0; ii < k.length; ++ii) {
-517       delete glErrorShadow_[k];
-518     }
-519   }
-520 
-521   function loseContextIfTime() {
-522     ++numCalls_;
-523     if (!contextLost_) {
-524       if (numCallsToLoseContext_ == numCalls_) {
-525         canvas.loseContext();
-526       }
-527     }
-528   }
-529 
-530   // Makes a function that simulates WebGL when out of context.
-531   function makeLostContextFunctionWrapper(ctx, functionName) {
-532     var f = ctx[functionName];
-533     return function() {
-534       // log("calling:" + functionName);
-535       // Only call the functions if the context is not lost.
-536       loseContextIfTime();
-537       if (!contextLost_) {
-538         //if (!checkResources(arguments)) {
-539         //  glErrorShadow_[wrappedContext_.INVALID_OPERATION] = true;
-540         //  return;
-541         //}
-542 
-543         var result = f.apply(ctx, arguments);
-544         return result;
-545       }
-546     };
-547   }
-548 
-549   function freeResources() {
-550     for (var ii = 0; ii < resourceDb_.length; ++ii) {
-551       var resource = resourceDb_[ii];
-552       if (resource instanceof WebGLBuffer) {
-553         unwrappedContext_.deleteBuffer(resource);
-554       } else if (resource instanceof WebGLFramebuffer) {
-555         unwrappedContext_.deleteFramebuffer(resource);
-556       } else if (resource instanceof WebGLProgram) {
-557         unwrappedContext_.deleteProgram(resource);
-558       } else if (resource instanceof WebGLRenderbuffer) {
-559         unwrappedContext_.deleteRenderbuffer(resource);
-560       } else if (resource instanceof WebGLShader) {
-561         unwrappedContext_.deleteShader(resource);
-562       } else if (resource instanceof WebGLTexture) {
-563         unwrappedContext_.deleteTexture(resource);
-564       }
-565     }
-566   }
-567 
-568   function makeWebGLContextEvent(statusMessage) {
-569     return {
-570       statusMessage: statusMessage,
-571       preventDefault: function() {
-572           canRestore_ = true;
-573         }
-574     };
-575   }
-576 
-577   return canvas;
-578 
-579   function makeLostContextSimulatingContext(ctx) {
-580     // copy all functions and properties to wrapper
-581     for (var propertyName in ctx) {
-582       if (typeof ctx[propertyName] == 'function') {
-583          wrappedContext_[propertyName] = makeLostContextFunctionWrapper(
-584              ctx, propertyName);
-585        } else {
-586          makePropertyWrapper(wrappedContext_, ctx, propertyName);
-587        }
-588     }
-589 
-590     // Wrap a few functions specially.
-591     wrappedContext_.getError = function() {
-592       loseContextIfTime();
-593       if (!contextLost_) {
-594         var err;
-595         while (err = unwrappedContext_.getError()) {
-596           glErrorShadow_[err] = true;
-597         }
-598       }
-599       for (var err in glErrorShadow_) {
-600         if (glErrorShadow_[err]) {
-601           delete glErrorShadow_[err];
-602           return err;
-603         }
-604       }
-605       return wrappedContext_.NO_ERROR;
-606     };
-607 
-608     var creationFunctions = [
-609       "createBuffer",
-610       "createFramebuffer",
-611       "createProgram",
-612       "createRenderbuffer",
-613       "createShader",
-614       "createTexture"
-615     ];
-616     for (var ii = 0; ii < creationFunctions.length; ++ii) {
-617       var functionName = creationFunctions[ii];
-618       wrappedContext_[functionName] = function(f) {
-619         return function() {
-620           loseContextIfTime();
-621           if (contextLost_) {
-622             return null;
-623           }
-624           var obj = f.apply(ctx, arguments);
-625           obj.__webglDebugContextLostId__ = contextId_;
-626           resourceDb_.push(obj);
-627           return obj;
-628         };
-629       }(ctx[functionName]);
-630     }
-631 
-632     var functionsThatShouldReturnNull = [
-633       "getActiveAttrib",
-634       "getActiveUniform",
-635       "getBufferParameter",
-636       "getContextAttributes",
-637       "getAttachedShaders",
-638       "getFramebufferAttachmentParameter",
-639       "getParameter",
-640       "getProgramParameter",
-641       "getProgramInfoLog",
-642       "getRenderbufferParameter",
-643       "getShaderParameter",
-644       "getShaderInfoLog",
-645       "getShaderSource",
-646       "getTexParameter",
-647       "getUniform",
-648       "getUniformLocation",
-649       "getVertexAttrib"
-650     ];
-651     for (var ii = 0; ii < functionsThatShouldReturnNull.length; ++ii) {
-652       var functionName = functionsThatShouldReturnNull[ii];
-653       wrappedContext_[functionName] = function(f) {
-654         return function() {
-655           loseContextIfTime();
-656           if (contextLost_) {
-657             return null;
-658           }
-659           return f.apply(ctx, arguments);
-660         }
-661       }(wrappedContext_[functionName]);
-662     }
-663 
-664     var isFunctions = [
-665       "isBuffer",
-666       "isEnabled",
-667       "isFramebuffer",
-668       "isProgram",
-669       "isRenderbuffer",
-670       "isShader",
-671       "isTexture"
-672     ];
-673     for (var ii = 0; ii < isFunctions.length; ++ii) {
-674       var functionName = isFunctions[ii];
-675       wrappedContext_[functionName] = function(f) {
-676         return function() {
-677           loseContextIfTime();
-678           if (contextLost_) {
-679             return false;
-680           }
-681           return f.apply(ctx, arguments);
-682         }
-683       }(wrappedContext_[functionName]);
-684     }
-685 
-686     wrappedContext_.checkFramebufferStatus = function(f) {
-687       return function() {
-688         loseContextIfTime();
-689         if (contextLost_) {
-690           return wrappedContext_.FRAMEBUFFER_UNSUPPORTED;
-691         }
-692         return f.apply(ctx, arguments);
-693       };
-694     }(wrappedContext_.checkFramebufferStatus);
-695 
-696     wrappedContext_.getAttribLocation = function(f) {
-697       return function() {
-698         loseContextIfTime();
-699         if (contextLost_) {
-700           return -1;
-701         }
-702         return f.apply(ctx, arguments);
-703       };
-704     }(wrappedContext_.getAttribLocation);
-705 
-706     wrappedContext_.getVertexAttribOffset = function(f) {
-707       return function() {
-708         loseContextIfTime();
-709         if (contextLost_) {
-710           return 0;
-711         }
-712         return f.apply(ctx, arguments);
-713       };
-714     }(wrappedContext_.getVertexAttribOffset);
-715 
-716     wrappedContext_.isContextLost = function() {
-717       return contextLost_;
-718     };
-719 
-720     return wrappedContext_;
-721   }
-722 }
-723 
-724 return {
-725     /**
-726      * Initializes this module. Safe to call more than once.
-727      * @param {!WebGLRenderingContext} ctx A WebGL context. If
-728     }
-729    *    you have more than one context it doesn't matter which one
-730    *    you pass in, it is only used to pull out constants.
-731    */
-732   'init': init,
-733 
-734   /**
-735    * Returns true or false if value matches any WebGL enum
-736    * @param {*} value Value to check if it might be an enum.
-737    * @return {boolean} True if value matches one of the WebGL defined enums
-738    */
-739   'mightBeEnum': mightBeEnum,
-740 
-741   /**
-742    * Gets an string version of an WebGL enum.
-743    *
-744    * Example:
-745    *   WebGLDebugUtil.init(ctx);
-746    *   var str = WebGLDebugUtil.glEnumToString(ctx.getError());
-747    *
-748    * @param {number} value Value to return an enum for
-749    * @return {string} The string version of the enum.
-750    */
-751   'glEnumToString': glEnumToString,
-752 
-753   /**
-754    * Converts the argument of a WebGL function to a string.
-755    * Attempts to convert enum arguments to strings.
-756    *
-757    * Example:
-758    *   WebGLDebugUtil.init(ctx);
-759    *   var str = WebGLDebugUtil.glFunctionArgToString('bindTexture', 0, gl.TEXTURE_2D);
-760    *
-761    * would return 'TEXTURE_2D'
-762    *
-763    * @param {string} functionName the name of the WebGL function.
-764    * @param {number} argumentIndx the index of the argument.
-765    * @param {*} value The value of the argument.
-766    * @return {string} The value as a string.
-767    */
-768   'glFunctionArgToString': glFunctionArgToString,
-769 
-770   /**
-771    * Converts the arguments of a WebGL function to a string.
-772    * Attempts to convert enum arguments to strings.
-773    *
-774    * @param {string} functionName the name of the WebGL function.
-775    * @param {number} args The arguments.
-776    * @return {string} The arguments as a string.
-777    */
-778   'glFunctionArgsToString': glFunctionArgsToString,
-779 
-780   /**
-781    * Given a WebGL context returns a wrapped context that calls
-782    * gl.getError after every command and calls a function if the
-783    * result is not NO_ERROR.
-784    *
-785    * You can supply your own function if you want. For example, if you'd like
-786    * an exception thrown on any GL error you could do this
-787    *
-788    *    function throwOnGLError(err, funcName, args) {
-789    *      throw WebGLDebugUtils.glEnumToString(err) +
-790    *            " was caused by call to " + funcName;
-791    *    };
-792    *
-793    *    ctx = WebGLDebugUtils.makeDebugContext(
-794    *        canvas.getContext("webgl"), throwOnGLError);
-795    *
-796    * @param {!WebGLRenderingContext} ctx The webgl context to wrap.
-797    * @param {!function(err, funcName, args): void} opt_onErrorFunc The function
-798    *     to call when gl.getError returns an error. If not specified the default
-799    *     function calls console.log with a message.
-800    * @param {!function(funcName, args): void} opt_onFunc The
-801    *     function to call when each webgl function is called. You
-802    *     can use this to log all calls for example.
-803    */
-804   'makeDebugContext': makeDebugContext,
-805 
-806   /**
-807    * Given a canvas element returns a wrapped canvas element that will
-808    * simulate lost context. The canvas returned adds the following functions.
-809    *
-810    * loseContext:
-811    *   simulates a lost context event.
-812    *
-813    * restoreContext:
-814    *   simulates the context being restored.
-815    *
-816    * lostContextInNCalls:
-817    *   loses the context after N gl calls.
-818    *
-819    * getNumCalls:
-820    *   tells you how many gl calls there have been so far.
-821    *
-822    * setRestoreTimeout:
-823    *   sets the number of milliseconds until the context is restored
-824    *   after it has been lost. Defaults to 0. Pass -1 to prevent
-825    *   automatic restoring.
-826    *
-827    * @param {!Canvas} canvas The canvas element to wrap.
-828    */
-829   'makeLostContextSimulatingCanvas': makeLostContextSimulatingCanvas,
-830 
-831   /**
-832    * Resets a context to the initial state.
-833    * @param {!WebGLRenderingContext} ctx The webgl context to
-834    *     reset.
-835    */
-836   'resetToInitialState': resetToInitialState
-837 };
-838 
-839 }();
-840 
\ No newline at end of file diff --git a/docs/symbols/src/src_core_webgl.js.html b/docs/symbols/src/src_core_webgl.js.html deleted file mode 100644 index 7eab381e..00000000 --- a/docs/symbols/src/src_core_webgl.js.html +++ /dev/null @@ -1,844 +0,0 @@ -
  1 /** Maps SceneJS node parameter names to WebGL enum names
-  2  * @private
-  3  */
-  4 var SceneJS_webgl_enumMap = {
-  5     funcAdd:"FUNC_ADD",
-  6     funcSubtract:"FUNC_SUBTRACT",
-  7     funcReverseSubtract:"FUNC_REVERSE_SUBTRACT",
-  8     zero:"ZERO",
-  9     one:"ONE",
- 10     srcColor:"SRC_COLOR",
- 11     oneMinusSrcColor:"ONE_MINUS_SRC_COLOR",
- 12     dstColor:"DST_COLOR",
- 13     oneMinusDstColor:"ONE_MINUS_DST_COLOR",
- 14     srcAlpha:"SRC_ALPHA",
- 15     oneMinusSrcAlpha:"ONE_MINUS_SRC_ALPHA",
- 16     dstAlpha:"DST_ALPHA",
- 17     oneMinusDstAlpha:"ONE_MINUS_DST_ALPHA",
- 18     contantColor:"CONSTANT_COLOR",
- 19     oneMinusConstantColor:"ONE_MINUS_CONSTANT_COLOR",
- 20     constantAlpha:"CONSTANT_ALPHA",
- 21     oneMinusConstantAlpha:"ONE_MINUS_CONSTANT_ALPHA",
- 22     srcAlphaSaturate:"SRC_ALPHA_SATURATE",
- 23     front:"FRONT",
- 24     back:"BACK",
- 25     frontAndBack:"FRONT_AND_BACK",
- 26     never:"NEVER",
- 27     less:"LESS",
- 28     equal:"EQUAL",
- 29     lequal:"LEQUAL",
- 30     greater:"GREATER",
- 31     notequal:"NOTEQUAL",
- 32     gequal:"GEQUAL",
- 33     always:"ALWAYS",
- 34     cw:"CW",
- 35     ccw:"CCW",
- 36     linear:"LINEAR",
- 37     nearest:"NEAREST",
- 38     linearMipMapNearest:"LINEAR_MIPMAP_NEAREST",
- 39     nearestMipMapNearest:"NEAREST_MIPMAP_NEAREST",
- 40     nearestMipMapLinear:"NEAREST_MIPMAP_LINEAR",
- 41     linearMipMapLinear:"LINEAR_MIPMAP_LINEAR",
- 42     repeat:"REPEAT",
- 43     clampToEdge:"CLAMP_TO_EDGE",
- 44     mirroredRepeat:"MIRRORED_REPEAT",
- 45     alpha:"ALPHA",
- 46     rgb:"RGB",
- 47     rgba:"RGBA",
- 48     luminance:"LUMINANCE",
- 49     luminanceAlpha:"LUMINANCE_ALPHA",
- 50     textureBinding2D:"TEXTURE_BINDING_2D",
- 51     textureBindingCubeMap:"TEXTURE_BINDING_CUBE_MAP",
- 52     compareRToTexture:"COMPARE_R_TO_TEXTURE", // Hardware Shadowing Z-depth,
- 53     unsignedByte:"UNSIGNED_BYTE"
- 54 };
- 55 
- 56 var SceneJS_webgl_ProgramUniform = function (gl, program, name, type, size, location, logging) {
- 57 
- 58     var func = null;
- 59     if (type == gl.BOOL) {
- 60         func = function (v) {
- 61             gl.uniform1i(location, v);
- 62         };
- 63     } else if (type == gl.BOOL_VEC2) {
- 64         func = function (v) {
- 65             gl.uniform2iv(location, v);
- 66         };
- 67     } else if (type == gl.BOOL_VEC3) {
- 68         func = function (v) {
- 69             gl.uniform3iv(location, v);
- 70         };
- 71     } else if (type == gl.BOOL_VEC4) {
- 72         func = function (v) {
- 73             gl.uniform4iv(location, v);
- 74         };
- 75     } else if (type == gl.INT) {
- 76         func = function (v) {
- 77             gl.uniform1iv(location, v);
- 78         };
- 79     } else if (type == gl.INT_VEC2) {
- 80         func = function (v) {
- 81             gl.uniform2iv(location, v);
- 82         };
- 83     } else if (type == gl.INT_VEC3) {
- 84         func = function (v) {
- 85             gl.uniform3iv(location, v);
- 86         };
- 87     } else if (type == gl.INT_VEC4) {
- 88         func = function (v) {
- 89             gl.uniform4iv(location, v);
- 90         };
- 91     } else if (type == gl.FLOAT) {
- 92         func = function (v) {
- 93             gl.uniform1f(location, v);
- 94         };
- 95     } else if (type == gl.FLOAT_VEC2) {
- 96         func = function (v) {
- 97             gl.uniform2fv(location, v);
- 98         };
- 99     } else if (type == gl.FLOAT_VEC3) {
-100         func = function (v) {
-101             gl.uniform3fv(location, v);
-102         };
-103     } else if (type == gl.FLOAT_VEC4) {
-104         func = function (v) {
-105             gl.uniform4fv(location, v);
-106         };
-107     } else if (type == gl.FLOAT_MAT2) {
-108         func = function (v) {
-109             gl.uniformMatrix2fv(location, gl.FALSE, v);
-110         };
-111     } else if (type == gl.FLOAT_MAT3) {
-112         func = function (v) {
-113             gl.uniformMatrix3fv(location, gl.FALSE, v);
-114         };
-115     } else if (type == gl.FLOAT_MAT4) {
-116         func = function (v) {
-117             gl.uniformMatrix4fv(location, gl.FALSE, v);
-118         };
-119     } else {
-120         throw "Unsupported shader uniform type: " + type;
-121     }
-122 
-123     this.setValue = func;
-124 
-125 
-126     this.getValue = function () {
-127         return gl.getUniform(program, location);
-128     };
-129 
-130     this.getLocation = function () {
-131         return location;
-132     };
-133 };
-134 
-135 var SceneJS_webgl_ProgramSampler = function (gl, program, name, type, size, location) {
-136     this.bindTexture = function (texture, unit) {
-137         if (texture.bind(unit)) {
-138             gl.uniform1i(location, unit);
-139             return true;
-140         }
-141         return false;
-142     };
-143 };
-144 
-145 /** An attribute within a shader
-146  */
-147 var SceneJS_webgl_ProgramAttribute = function (gl, program, name, type, size, location) {
-148     this.bindFloatArrayBuffer = function (buffer) {
-149         buffer.bind();
-150         gl.enableVertexAttribArray(location);
-151         gl.vertexAttribPointer(location, buffer.itemSize, gl.FLOAT, false, 0, 0);   // Vertices are not homogeneous - no w-element
-152     };
-153 
-154 };
-155 
-156 /**
-157  * A vertex/fragment shader in a program
-158  *
-159  * @private
-160  * @param gl WebGL gl
-161  * @param gl.VERTEX_SHADER | gl.FRAGMENT_SHADER
-162  * @param source Source code for shader
-163  * @param logging Shader will write logging's debug channel as it compiles
-164  */
-165 var SceneJS_webgl_Shader = function (gl, type, source) {
-166 
-167     this.handle = gl.createShader(type);
-168 
-169     gl.shaderSource(this.handle, source);
-170     gl.compileShader(this.handle);
-171 
-172     this.valid = (gl.getShaderParameter(this.handle, gl.COMPILE_STATUS) != 0);
-173 
-174     if (!this.valid) {
-175 
-176         if (!gl.isContextLost()) { // Handled explicitely elsewhere, so wont rehandle here
-177 
-178             SceneJS.log.error("Shader program failed to compile: " + gl.getShaderInfoLog(this.handle));
-179             SceneJS.log.error("Shader source:");
-180             var lines = source.split('\n');
-181             for (var j = 0; j < lines.length; j++) {
-182                 SceneJS.log.error(lines[j]);
-183             }
-184 
-185             throw SceneJS_error.fatalError(
-186                 SceneJS.errors.SHADER_COMPILATION_FAILURE, "Shader program failed to compile");
-187         }
-188     }
-189 };
-190 
-191 /**
-192  * @class Wrapper for a WebGL program
-193  *
-194  * @param hash SceneJS-managed ID for program
-195  * @param gl WebGL gl
-196  * @param vertexSources Source codes for vertex shaders
-197  * @param fragmentSources Source codes for fragment shaders
-198  * @param logging Program and shaders will write to logging's debug channel as they compile and link
-199  */
-200 var SceneJS_webgl_Program = function (gl, vertexSources, fragmentSources) {
-201 
-202     var a, i, u, u_name, location, shader;
-203 
-204     this._uniforms = {};
-205     this._samplers = {};
-206     this._attributes = {};
-207 
-208     /* Create shaders from sources
-209      */
-210     this._shaders = [];
-211     for (i = 0; i < vertexSources.length; i++) {
-212         this._shaders.push(new SceneJS_webgl_Shader(gl, gl.VERTEX_SHADER, vertexSources[i]));
-213     }
-214     for (i = 0; i < fragmentSources.length; i++) {
-215         this._shaders.push(new SceneJS_webgl_Shader(gl, gl.FRAGMENT_SHADER, fragmentSources[i]));
-216     }
-217 
-218     /* Create program, attach shaders, link and validate program
-219      */
-220     var handle = gl.createProgram();
-221 
-222     for (i = 0; i < this._shaders.length; i++) {
-223         shader = this._shaders[i];
-224         if (shader.valid) {
-225             gl.attachShader(handle, shader.handle);
-226         }
-227     }
-228     gl.linkProgram(handle);
-229 
-230     this.valid = (gl.getProgramParameter(handle, gl.LINK_STATUS) != 0);
-231 
-232     var debugCfg = SceneJS_debugModule.getConfigs("shading");
-233     if (debugCfg.validate !== false) {
-234         gl.validateProgram(handle);
-235         this.valid = this.valid && (gl.getProgramParameter(handle, gl.VALIDATE_STATUS) != 0);
-236     }
-237 
-238     if (!this.valid) {
-239 
-240         if (!gl.isglLost()) { // Handled explicitely elsewhere, so wont rehandle here
-241 
-242             SceneJS.log.error("Shader program failed to link: " + gl.getProgramInfoLog(handle));
-243 
-244             SceneJS.log.error("Vertex shader(s):");
-245             for (i = 0; i < vertexSources.length; i++) {
-246                 SceneJS.log.error("Vertex shader #" + i + ":");
-247                 var lines = vertexSources[i].split('\n');
-248                 for (var j = 0; j < lines.length; j++) {
-249                     SceneJS.log.error(lines[j]);
-250 
-251                 }
-252             }
-253 
-254             SceneJS.log.error("Fragment shader(s):");
-255             for (i = 0; i < fragmentSources.length; i++) {
-256                 SceneJS.log.error("Fragment shader #" + i + ":");
-257                 var lines = fragmentSources[i].split('\n');
-258                 for (var j = 0; j < lines.length; j++) {
-259                     SceneJS.log.error(lines[j]);
-260                 }
-261             }
-262 
-263             throw SceneJS_error.fatalError(
-264                 SceneJS.errors.SHADER_LINK_FAILURE, "Shader program failed to link");
-265         }
-266     }
-267 
-268     /* Discover active uniforms and samplers
-269      */
-270 
-271     var numUniforms = gl.getProgramParameter(handle, gl.ACTIVE_UNIFORMS);
-272 
-273     for (i = 0; i < numUniforms; ++i) {
-274         u = gl.getActiveUniform(handle, i);
-275         if (u) {
-276             u_name = u.name;
-277             if (u_name[u_name.length - 1] == "\u0000") {
-278                 u_name = u_name.substr(0, u_name.length - 1);
-279             }
-280             location = gl.getUniformLocation(handle, u_name);
-281             if ((u.type == gl.SAMPLER_2D) || (u.type == gl.SAMPLER_CUBE) || (u.type == 35682)) {
-282 
-283                 this._samplers[u_name] = new SceneJS_webgl_ProgramSampler(
-284                     gl,
-285                     handle,
-286                     u_name,
-287                     u.type,
-288                     u.size,
-289                     location);
-290             } else {
-291                 this._uniforms[u_name] = new SceneJS_webgl_ProgramUniform(
-292                     gl,
-293                     handle,
-294                     u_name,
-295                     u.type,
-296                     u.size,
-297                     location);
-298             }
-299         }
-300     }
-301 
-302     /* Discover attributes
-303      */
-304 
-305     var numAttribs = gl.getProgramParameter(handle, gl.ACTIVE_ATTRIBUTES);
-306     for (i = 0; i < numAttribs; i++) {
-307         a = gl.getActiveAttrib(handle, i);
-308         if (a) {
-309             location = gl.getAttribLocation(handle, a.name);
-310             this._attributes[a.name] = new SceneJS_webgl_ProgramAttribute(
-311                 gl,
-312                 handle,
-313                 a.name,
-314                 a.type,
-315                 a.size,
-316                 location);
-317         }
-318     }
-319 
-320     this.setProfile = function (profile) {
-321         this._profile = profile;
-322     };
-323 
-324     this.bind = function () {
-325         gl.useProgram(handle);
-326         if (this._profile) {
-327             this._profile.program++;
-328         }
-329     };
-330 
-331     this.getUniformLocation = function (name) {
-332         var u = this._uniforms[name];
-333         if (u) {
-334             return u.getLocation();
-335         } else {
-336             // SceneJS.log.warn("Uniform not found in shader : " + name);
-337         }
-338     };
-339 
-340     this.getUniform = function (name) {
-341         var u = this._uniforms[name];
-342         if (u) {
-343             return u;
-344         } else {
-345             //      SceneJS.log.warn("Shader uniform load failed - uniform not found in shader : " + name);
-346         }
-347     };
-348 
-349     this.setUniform = function (name, value) {
-350         var u = this._uniforms[name];
-351         if (u) {
-352             u.setValue(value);
-353             if (this._profile) {
-354                 this._profile.uniform++;
-355             }
-356         } else {
-357             //      SceneJS.log.warn("Shader uniform load failed - uniform not found in shader : " + name);
-358         }
-359     };
-360 
-361     this.getAttribute = function (name) {
-362         var attr = this._attributes[name];
-363         if (attr) {
-364             return attr;
-365         } else {
-366             //  logging.warn("Shader attribute bind failed - attribute not found in shader : " + name);
-367         }
-368     };
-369 
-370     this.bindFloatArrayBuffer = function (name, buffer) {
-371         var attr = this._attributes[name];
-372         if (attr) {
-373             attr.bindFloatArrayBuffer(buffer);
-374             if (this._profile) {
-375                 this._profile.varying++;
-376             }
-377         } else {
-378             //  logging.warn("Shader attribute bind failed - attribute not found in shader : " + name);
-379         }
-380     };
-381 
-382     this.bindTexture = function (name, texture, unit) {
-383         var sampler = this._samplers[name];
-384         if (sampler) {
-385             if (this._profile) {
-386                 this._profile.texture++;
-387             }
-388             return sampler.bindTexture(texture, unit);
-389         } else {
-390             return false;
-391         }
-392     };
-393 
-394     this.unbind = function () {
-395         //     gl.useProgram(0);
-396     };
-397 
-398     this.destroy = function () {
-399 
-400         if (this.valid) {
-401 
-402             //   SceneJS.log.debug("Destroying shader program: '" + hash + "'");
-403             gl.deleteProgram(handle);
-404             for (var s in this._shaders) {
-405                 gl.deleteShader(this._shaders[s].handle);
-406             }
-407             this._attributes = null;
-408             this._uniforms = null;
-409             this._samplers = null;
-410             this.valid = false;
-411         }
-412     };
-413 };
-414 
-415 var SceneJS_webgl_Texture2D = function (gl, cfg) {
-416 
-417     this.target = gl.TEXTURE_2D;
-418     this.minFilter = cfg.minFilter;
-419     this.magFilter = cfg.magFilter;
-420     this.wrapS = cfg.wrapS;
-421     this.wrapT = cfg.wrapT;
-422     this.update = cfg.update;  // For dynamically-sourcing textures (ie movies etc)
-423     this.texture = cfg.texture;
-424     this.format = gl.RGBA;
-425     this.isDepth = false;
-426     this.depthMode = 0;
-427     this.depthCompareMode = 0;
-428     this.depthCompareFunc = 0;
-429 
-430     try {
-431         gl.bindTexture(this.target, this.texture);
-432 
-433         if (cfg.minFilter) {
-434             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, cfg.minFilter);
-435         }
-436 
-437         if (cfg.magFilter) {
-438             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, cfg.magFilter);
-439         }
-440 
-441         if (cfg.wrapS) {
-442             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, cfg.wrapS);
-443         }
-444 
-445         if (cfg.wrapT) {
-446             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, cfg.wrapT);
-447         }
-448 
-449         if (cfg.minFilter == gl.NEAREST_MIPMAP_NEAREST ||
-450             cfg.minFilter == gl.LINEAR_MIPMAP_NEAREST ||
-451             cfg.minFilter == gl.NEAREST_MIPMAP_LINEAR ||
-452             cfg.minFilter == gl.LINEAR_MIPMAP_LINEAR) {
-453             gl.generateMipmap(gl.TEXTURE_2D);
-454         }
-455 
-456         gl.bindTexture(this.target, null);
-457 
-458     } catch (e) {
-459         throw SceneJS_error.fatalError(SceneJS.errors.ERROR, "Failed to create texture: " + e.message || e);
-460     }
-461 
-462     this.bind = function (unit) {
-463         if (this.texture) {
-464             gl.activeTexture(gl["TEXTURE" + unit]);
-465             gl.bindTexture(this.target, this.texture);
-466             if (this.update) {
-467                 this.update(gl);
-468             }
-469             return true;
-470         }
-471         return false;
-472     };
-473 
-474     this.unbind = function (unit) {
-475         if (this.texture) {
-476             gl.activeTexture(gl["TEXTURE" + unit]);
-477             gl.bindTexture(this.target, null);
-478         }
-479     };
-480 
-481     this.destroy = function () {
-482         if (this.texture) {
-483             gl.deleteTexture(this.texture);
-484             this.texture = null;
-485         }
-486     };
-487 };
-488 
-489 
-490 function SceneJS_webgl_ensureImageSizePowerOfTwo(image) {
-491     if (!SceneJS_webgl_isPowerOfTwo(image.width) || !SceneJS_webgl_isPowerOfTwo(image.height)) {
-492         var canvas = document.createElement("canvas");
-493         canvas.width = SceneJS_webgl_nextHighestPowerOfTwo(image.width);
-494         canvas.height = SceneJS_webgl_nextHighestPowerOfTwo(image.height);
-495         var ctx = canvas.getContext("2d");
-496         ctx.drawImage(image,
-497             0, 0, image.width, image.height,
-498             0, 0, canvas.width, canvas.height);
-499         image = canvas;
-500     }
-501     return image;
-502 }
-503 
-504 function SceneJS_webgl_isPowerOfTwo(x) {
-505     return (x & (x - 1)) == 0;
-506 }
-507 
-508 function SceneJS_webgl_nextHighestPowerOfTwo(x) {
-509     --x;
-510     for (var i = 1; i < 32; i <<= 1) {
-511         x = x | x >> i;
-512     }
-513     return x + 1;
-514 }
-515 
-516 /** Buffer for vertices and indices
-517  *
-518  * @private
-519  * @param gl  WebGL gl
-520  * @param type     Eg. ARRAY_BUFFER, ELEMENT_ARRAY_BUFFER
-521  * @param values   WebGL array wrapper
-522  * @param numItems Count of items in array wrapper
-523  * @param itemSize Size of each item
-524  * @param usage    Eg. STATIC_DRAW
-525  */
-526 
-527 var SceneJS_webgl_ArrayBuffer = function (gl, type, values, numItems, itemSize, usage) {
-528 
-529 
-530     this.type = type;
-531     this.itemSize = itemSize;
-532 
-533     this._allocate = function (values, numItems) {
-534         this.handle = gl.createBuffer();
-535         this.handle.numItems = numItems;
-536         this.handle.itemSize = itemSize;
-537         gl.bindBuffer(type, this.handle);
-538         gl.bufferData(type, values, usage);
-539         this.handle.numItems = numItems;
-540         gl.bindBuffer(type, null);
-541         this.numItems = numItems;
-542         this.length = values.length;
-543     };
-544 
-545     this._allocate(values, numItems);
-546 
-547     this.bind = function () {
-548         gl.bindBuffer(type, this.handle);
-549     };
-550 
-551     this.setData = function (data, offset) {
-552 
-553         if (data.length > this.length) {
-554             this.destroy();
-555             this._allocate(data, data.length);
-556 
-557         } else {
-558 
-559             if (offset || offset === 0) {
-560                 gl.bufferSubData(type, offset, data);
-561             } else {
-562                 gl.bufferData(type, data);
-563             }
-564         }
-565     };
-566 
-567     this.unbind = function () {
-568         gl.bindBuffer(type, null);
-569     };
-570 
-571     this.destroy = function () {
-572         gl.deleteBuffer(this.handle);
-573     };
-574 };
-575 
-576 
-577 var SceneJS_PickBuffer = function (cfg) {
-578 
-579     var canvas = cfg.canvas;
-580     var gl = canvas.gl;
-581 
-582     var pickBuf;
-583     var bound = false;
-584 
-585     /**
-586      * Called when WebGL context restored
-587      */
-588     this.webglRestored = function (_gl) {
-589         gl = _gl;
-590         pickBuf = null;
-591     };
-592 
-593     this._touch = function () {
-594 
-595         var width = canvas.canvas.width;
-596         var height = canvas.canvas.height;
-597 
-598         if (pickBuf) { // Currently have a pick buffer
-599             if (pickBuf.width == width && pickBuf.height == height) { // Canvas size unchanged, buffer still good
-600                 return;
-601             } else { // Buffer needs reallocation for new canvas size
-602 
-603                 gl.deleteTexture(pickBuf.texture);
-604                 gl.deleteFramebuffer(pickBuf.framebuf);
-605                 gl.deleteRenderbuffer(pickBuf.renderbuf);
-606             }
-607         }
-608 
-609         pickBuf = {
-610             framebuf:gl.createFramebuffer(),
-611             renderbuf:gl.createRenderbuffer(),
-612             texture:gl.createTexture(),
-613             width:width,
-614             height:height
-615         };
-616 
-617         gl.bindFramebuffer(gl.FRAMEBUFFER, pickBuf.framebuf);
-618 
-619         gl.bindTexture(gl.TEXTURE_2D, pickBuf.texture);
-620         gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
-621         gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
-622         gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
-623         gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
-624 
-625         try {
-626             // Do it the way the spec requires
-627             gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
-628         } catch (exception) {
-629             // Workaround for what appears to be a Minefield bug.
-630             var textureStorage = new WebGLUnsignedByteArray(width * height * 3);
-631             gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, textureStorage);
-632         }
-633         gl.bindRenderbuffer(gl.RENDERBUFFER, pickBuf.renderbuf);
-634         gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
-635         gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, pickBuf.texture, 0);
-636         gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, pickBuf.renderbuf);
-637         gl.bindTexture(gl.TEXTURE_2D, null);
-638         gl.bindRenderbuffer(gl.RENDERBUFFER, null);
-639         gl.bindFramebuffer(gl.FRAMEBUFFER, null);
-640 
-641         /* Verify framebuffer is OK
-642          */
-643         gl.bindFramebuffer(gl.FRAMEBUFFER, pickBuf.framebuf);
-644         if (!gl.isFramebuffer(pickBuf.framebuf)) {
-645             throw  SceneJS_errorModule.fatalError("Invalid framebuffer");
-646         }
-647         var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
-648         switch (status) {
-649             case gl.FRAMEBUFFER_COMPLETE:
-650                 break;
-651             case gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
-652                 throw  SceneJS_errorModule.fatalError("Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
-653             case gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
-654                 throw  SceneJS_errorModule.fatalError("Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");
-655             case gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
-656                 throw  SceneJS_errorModule.fatalError("Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
-657             case gl.FRAMEBUFFER_UNSUPPORTED:
-658                 throw  SceneJS_errorModule.fatalError("Incomplete framebuffer: FRAMEBUFFER_UNSUPPORTED");
-659             default:
-660                 throw  SceneJS_errorModule.fatalError("Incomplete framebuffer: " + status);
-661         }
-662 
-663         bound = false;
-664     };
-665 
-666     this.bind = function () {
-667 
-668         this._touch();
-669 
-670         if (bound) {
-671             return;
-672         }
-673 
-674         gl.bindFramebuffer(gl.FRAMEBUFFER, pickBuf.framebuf);
-675 
-676         bound = true;
-677     };
-678 
-679     this.clear = function () {
-680 
-681         if (!bound) {
-682             throw "Pick buffer not bound";
-683         }
-684 
-685         gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
-686         gl.disable(gl.BLEND);
-687     };
-688 
-689 
-690     /** Reads pick buffer pixel at given coordinates, returns index of associated object else (-1)
-691      */
-692     this.read = function (pickX, pickY) {
-693         var x = pickX;
-694         var y = canvas.canvas.height - pickY;
-695         var pix = new Uint8Array(4);
-696         gl.readPixels(x, y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pix);
-697         return pix;
-698     };
-699 
-700     this.unbind = function () {
-701         gl.bindFramebuffer(gl.FRAMEBUFFER, null);
-702         bound = false;
-703     };
-704 };
-705 
-706 var SceneJS_PickBufferOLD = function (cfg) {
-707 
-708     var canvas = cfg.canvas;
-709     var gl = cfg.canvas.gl;
-710 
-711     var pickBuf;
-712     this.bound = false;
-713 
-714     /**
-715      * Initialises the pick buffer
-716      * @param _gl WebGL context
-717      */
-718     this.init = function (_gl) {
-719 
-720         gl = _gl;
-721         pickBuf = null;
-722 
-723         var width = canvas.canvas.width;
-724         var height = canvas.canvas.height;
-725 
-726         if (pickBuf) { // Currently have a pick buffer
-727 
-728             if (pickBuf.width == width && pickBuf.height == height) { // Canvas size unchanged, buffer still good
-729                 return;
-730 
-731             } else { // Buffer needs reallocation for new canvas size
-732 
-733                 gl.deleteTexture(pickBuf.texture);
-734                 gl.deleteFramebuffer(pickBuf.framebuf);
-735                 gl.deleteRenderbuffer(pickBuf.renderbuf);
-736             }
-737         }
-738 
-739         pickBuf = {
-740             framebuf:gl.createFramebuffer(),
-741             renderbuf:gl.createRenderbuffer(),
-742             texture:gl.createTexture(),
-743             width:width,
-744             height:height
-745         };
-746 
-747         gl.bindFramebuffer(gl.FRAMEBUFFER, pickBuf.framebuf);
-748 
-749         gl.bindTexture(gl.TEXTURE_2D, pickBuf.texture);
-750         gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
-751         gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
-752         gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
-753         gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
-754 
-755         try {
-756             // Do it the way the spec requires
-757             gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
-758         } catch (exception) {
-759             // Workaround for what appears to be a Minefield bug.
-760             var textureStorage = new WebGLUnsignedByteArray(width * height * 3);
-761             gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, textureStorage);
-762         }
-763 
-764         gl.bindRenderbuffer(gl.RENDERBUFFER, pickBuf.renderbuf);
-765         gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
-766         gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, pickBuf.texture, 0);
-767         gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, pickBuf.renderbuf);
-768 
-769         gl.bindTexture(gl.TEXTURE_2D, null);
-770         gl.bindRenderbuffer(gl.RENDERBUFFER, null);
-771         gl.bindFramebuffer(gl.FRAMEBUFFER, null);
-772 
-773         /* Verify framebuffer is OK
-774          */
-775         gl.bindFramebuffer(gl.FRAMEBUFFER, pickBuf.framebuf);
-776         if (!gl.isFramebuffer(pickBuf.framebuf)) {
-777             throw  SceneJS_error.fatalError("Invalid framebuffer");
-778         }
-779 
-780         var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
-781 
-782         switch (status) {
-783             case gl.FRAMEBUFFER_COMPLETE:
-784                 break;
-785             case gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
-786                 throw  SceneJS_error.fatalError("Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_ATTACHMENT");
-787             case gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
-788                 throw  SceneJS_error.fatalError("Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT");
-789             case gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
-790                 throw  SceneJS_error.fatalError("Incomplete framebuffer: FRAMEBUFFER_INCOMPLETE_DIMENSIONS");
-791             case gl.FRAMEBUFFER_UNSUPPORTED:
-792                 throw  SceneJS_error.fatalError("Incomplete framebuffer: FRAMEBUFFER_UNSUPPORTED");
-793             default:
-794                 throw  SceneJS_error.fatalError("Incomplete framebuffer: " + status);
-795         }
-796 
-797         this.bound = false;
-798     };
-799 
-800     this.bind = function () {
-801         if (this.bound) {
-802             return;
-803         }
-804         gl.bindFramebuffer(gl.FRAMEBUFFER, pickBuf.framebuf);
-805         this.bound = true;
-806     };
-807 
-808     this.clear = function () {
-809         if (this.bound) {
-810             return;
-811         }
-812         gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
-813         gl.disable(gl.BLEND);
-814     };
-815 
-816 
-817     /** Reads pick buffer pixel at given coordinates, returns index of associated object else (-1)
-818      */
-819     this.read = function (pickX, pickY) {
-820         var x = pickX;
-821         var y = canvas.canvas.height - pickY;
-822         var pix = new Uint8Array(4);
-823         gl.readPixels(x, y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pix);
-824         return pix;
-825     };
-826 
-827     this.unbind = function () {
-828         if (this.bound) {
-829             return;
-830         }
-831         gl.bindFramebuffer(gl.FRAMEBUFFER, null);
-832         this.bound = false;
-833     };
-834 
-835     this.init(cfg.canvas.gl);
-836 };
-837 
\ No newline at end of file diff --git a/examples.html b/examples.html index d74c0e7c..aa3e5ee3 100644 --- a/examples.html +++ b/examples.html @@ -7,7 +7,6 @@ - @@ -16,6 +15,7 @@ html, body { height: 100%; } + body { margin: 0px; overflow: hidden; @@ -24,40 +24,171 @@ diff --git a/examples/_index.html b/examples/_index.html new file mode 100644 index 00000000..6cc03ab3 --- /dev/null +++ b/examples/_index.html @@ -0,0 +1,624 @@ + + + + + SceneJS v4.0 - Examples + + + + + +
+
+

SceneJS / examples

+ +

v4.0 pre

+
+
+ + + + + + \ No newline at end of file diff --git a/demos/plugins-backgrounds-gradient.html b/examples/background_gradient.html similarity index 95% rename from demos/plugins-backgrounds-gradient.html rename to examples/background_gradient.html index b126b0c3..0af96d91 100644 --- a/demos/plugins-backgrounds-gradient.html +++ b/examples/background_gradient.html @@ -21,7 +21,7 @@ + + + + + + + \ No newline at end of file diff --git a/examples/benchmarks_10000boxes.html b/examples/benchmarks_10000boxes.html new file mode 100644 index 00000000..d101e8a4 --- /dev/null +++ b/examples/benchmarks_10000boxes.html @@ -0,0 +1,81 @@ + + + + SceneJS Example + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/benchmarks_40000boxes.html b/examples/benchmarks_40000boxes.html new file mode 100644 index 00000000..ce8cb61b --- /dev/null +++ b/examples/benchmarks_40000boxes.html @@ -0,0 +1,81 @@ + + + + SceneJS Example + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/benchmarks_5000boxes.html b/examples/benchmarks_5000boxes.html new file mode 100644 index 00000000..6a0dd5fa --- /dev/null +++ b/examples/benchmarks_5000boxes.html @@ -0,0 +1,81 @@ + + + + SceneJS Example + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/cameras-orbit.html b/examples/cameras_orbit.html similarity index 80% rename from demos/cameras-orbit.html rename to examples/cameras_orbit.html index b6655db7..a5eaa4dd 100644 --- a/demos/cameras-orbit.html +++ b/examples/cameras_orbit.html @@ -21,7 +21,9 @@ + + + +
+ SceneJS experimental camera + plugin + +
+ + + + \ No newline at end of file diff --git a/examples/cameras_pickFlyOrbit_city.html b/examples/cameras_pickFlyOrbit_city.html new file mode 100644 index 00000000..2a242ca8 --- /dev/null +++ b/examples/cameras_pickFlyOrbit_city.html @@ -0,0 +1,103 @@ + + + + SceneJS Example + + + + + + + + +
+ SceneJS experimental camera + plugin + +
+ + + + \ No newline at end of file diff --git a/examples/cameras_pickFlyOrbit_terrain.html b/examples/cameras_pickFlyOrbit_terrain.html new file mode 100644 index 00000000..40e3cf5e --- /dev/null +++ b/examples/cameras_pickFlyOrbit_terrain.html @@ -0,0 +1,127 @@ + + + + SceneJS Example + + + + + + + + +
+ SceneJS experimental camera + plugin + +
+ + + + \ No newline at end of file diff --git a/demos/canvas-capture.html b/examples/canvas_capture.html similarity index 97% rename from demos/canvas-capture.html rename to examples/canvas_capture.html index f2ea8b72..a1d00b48 100644 --- a/demos/canvas-capture.html +++ b/examples/canvas_capture.html @@ -62,9 +62,9 @@ nodes:[ // City, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/object/buildings/city.js + // http://scenejs.org/api/latest/plugins/node/models/buildings/city.js { - type:"objects/buildings/city", + type:"models/buildings/city", width:600 } ] diff --git a/examples/canvas_capture_customSize.html b/examples/canvas_capture_customSize.html new file mode 100644 index 00000000..fdddbc33 --- /dev/null +++ b/examples/canvas_capture_customSize.html @@ -0,0 +1,117 @@ + + + + SceneJS Example + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/canvas-external.html b/examples/canvas_external.html similarity index 84% rename from demos/canvas-external.html rename to examples/canvas_external.html index 7657fb78..60517cab 100644 --- a/demos/canvas-external.html +++ b/examples/canvas_external.html @@ -12,13 +12,18 @@ -khtml-user-select: none; -webkit-user-select: none; } + #myCanvas { + width: 100%; + height: 100%; + margin: 0; + padding: 0; + position: absolute; + } - - - + - + @@ -55,7 +63,7 @@ yaw: 30, pitch: -30, zoom: 10, - zoomSensitivity: 10.0, + zoomSensitivity: 1.0, nodes: [ { type: "material", @@ -63,9 +71,9 @@ nodes: [ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type: "prims/teapot" + type: "geometry/teapot" } ] } diff --git a/demos/canvas-transparent.html b/examples/canvas_transparent.html similarity index 95% rename from demos/canvas-transparent.html rename to examples/canvas_transparent.html index 21c97c20..3515980f 100644 --- a/demos/canvas-transparent.html +++ b/examples/canvas_transparent.html @@ -58,9 +58,9 @@ nodes: [ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type: "prims/teapot" + type: "geometry/teapot" } ] } diff --git a/examples/colorBuffer_blendEnabled.html b/examples/colorBuffer_blendEnabled.html new file mode 100644 index 00000000..4ee2b8d8 --- /dev/null +++ b/examples/colorBuffer_blendEnabled.html @@ -0,0 +1,118 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/colorBuffer_colorMask.html b/examples/colorBuffer_colorMask.html new file mode 100644 index 00000000..0771d211 --- /dev/null +++ b/examples/colorBuffer_colorMask.html @@ -0,0 +1,124 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/configs-statusPopups.html b/examples/configs_disableStatusPopups.html similarity index 94% rename from demos/configs-statusPopups.html rename to examples/configs_disableStatusPopups.html index 803f1ded..e567f058 100644 --- a/demos/configs-statusPopups.html +++ b/examples/configs_disableStatusPopups.html @@ -52,9 +52,9 @@ nodes:[ // Torus primitive, - // implemented by plugin at ../../../../api/latest/plugins/node/prims/torus.js + // implemented by plugin at ../../../../api/latest/plugins/node/geometry/torus.js { - type:"prims/torus", + type:"geometry/torus", radius:1.0, tube:0.30, segmentsR:60, diff --git a/examples/configs_optimizations.html b/examples/configs_optimizations.html new file mode 100644 index 00000000..e567f058 --- /dev/null +++ b/examples/configs_optimizations.html @@ -0,0 +1,73 @@ + + + + SceneJS Example + + + + + + + + + + + \ No newline at end of file diff --git a/demos/configs-pluginPath.html b/examples/configs_pluginPath.html similarity index 95% rename from demos/configs-pluginPath.html rename to examples/configs_pluginPath.html index a19eb41d..40827f5b 100644 --- a/demos/configs-pluginPath.html +++ b/examples/configs_pluginPath.html @@ -50,9 +50,9 @@ nodes:[ // Torus primitive, - // implemented by plugin at ../../../../api/latest/plugins/node/prims/torus.js + // implemented by plugin at ../../../../api/latest/plugins/node/geometry/torus.js { - type:"prims/torus", + type:"geometry/torus", radius:1.0, tube:0.30, segmentsR:60, diff --git a/demos/css/prettify.css b/examples/css/prettify.css similarity index 100% rename from demos/css/prettify.css rename to examples/css/prettify.css diff --git a/demos/css/styles.css b/examples/css/styles.css similarity index 98% rename from demos/css/styles.css rename to examples/css/styles.css index 8f6c76e3..fcf53b6f 100644 --- a/demos/css/styles.css +++ b/examples/css/styles.css @@ -24,7 +24,7 @@ body { } .xeolabsLogo { - background-image: url("../examples/images/a-xeolabs-project.png"); + background-image: url("./images/a-xeolabs-project.png"); position: absolute; left: 0; top: 0; diff --git a/demos/depthBuf-clearDepth.html b/examples/depthBuffer_clearDepth.html similarity index 91% rename from demos/depthBuf-clearDepth.html rename to examples/depthBuffer_clearDepth.html index c43fd3c9..46e32a01 100644 --- a/demos/depthBuf-clearDepth.html +++ b/examples/depthBuffer_clearDepth.html @@ -22,7 +22,7 @@ + + + + + + + + \ No newline at end of file diff --git a/examples/effects_anaglyph_pickFlyOrbit.html b/examples/effects_anaglyph_pickFlyOrbit.html new file mode 100644 index 00000000..f06a22cb --- /dev/null +++ b/examples/effects_anaglyph_pickFlyOrbit.html @@ -0,0 +1,141 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/effects_oculusRift.html b/examples/effects_oculusRift.html new file mode 100644 index 00000000..5dc4176a --- /dev/null +++ b/examples/effects_oculusRift.html @@ -0,0 +1,90 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/effects_oculusRift_externalCanvas.html b/examples/effects_oculusRift_externalCanvas.html new file mode 100644 index 00000000..098c68df --- /dev/null +++ b/examples/effects_oculusRift_externalCanvas.html @@ -0,0 +1,93 @@ + + + + SceneJS Example + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/effects_oculusRift_pickFlyOrbit.html b/examples/effects_oculusRift_pickFlyOrbit.html new file mode 100644 index 00000000..27007a49 --- /dev/null +++ b/examples/effects_oculusRift_pickFlyOrbit.html @@ -0,0 +1,85 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/effects_stereo.html b/examples/effects_stereo.html new file mode 100644 index 00000000..01d072d7 --- /dev/null +++ b/examples/effects_stereo.html @@ -0,0 +1,127 @@ + + + + SceneJS Example + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/effects_stereo_pickFlyOrbit.html b/examples/effects_stereo_pickFlyOrbit.html new file mode 100644 index 00000000..2ed1c4d9 --- /dev/null +++ b/examples/effects_stereo_pickFlyOrbit.html @@ -0,0 +1,122 @@ + + + + SceneJS Example + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/environments_gridRoom_teapot.html b/examples/environments_gridRoom_teapot.html new file mode 100644 index 00000000..ccbcca33 --- /dev/null +++ b/examples/environments_gridRoom_teapot.html @@ -0,0 +1,63 @@ + + + + SceneJS Example + + + + + + + + + + + + + diff --git a/examples/environments_holoDeck.html b/examples/environments_holoDeck.html new file mode 100644 index 00000000..4f328339 --- /dev/null +++ b/examples/environments_holoDeck.html @@ -0,0 +1,63 @@ + + + + SceneJS Example + + + + + + + + + + + + + diff --git a/examples/environments_lawn_city.html b/examples/environments_lawn_city.html new file mode 100644 index 00000000..b727c825 --- /dev/null +++ b/examples/environments_lawn_city.html @@ -0,0 +1,99 @@ + + + + SceneJS Example + + + + + + + + +
+ SceneJS experimental camera + plugin + +
+ + + + \ No newline at end of file diff --git a/examples/environments_lawn_teapots.html b/examples/environments_lawn_teapots.html new file mode 100644 index 00000000..f4bd584f --- /dev/null +++ b/examples/environments_lawn_teapots.html @@ -0,0 +1,82 @@ + + + + SceneJS Example + + + + + + + + + + + + + diff --git a/examples/environments_modelView_teapot.html b/examples/environments_modelView_teapot.html new file mode 100644 index 00000000..c2689af4 --- /dev/null +++ b/examples/environments_modelView_teapot.html @@ -0,0 +1,46 @@ + + + + SceneJS Example + + + + + + + + + + + + + diff --git a/examples/exampleLinks.json b/examples/exampleLinks.json new file mode 100644 index 00000000..7dcc97b4 --- /dev/null +++ b/examples/exampleLinks.json @@ -0,0 +1,281 @@ +{ + + "showcase": [ + "#stuff made with SceneJS", + "scenegraph_firstExample", + "showcase_BioDigitalHuman", + "showcase_BioDigitalHuman_eye", + "showcase_earth", + "showcase_tronTank" + ], + + "configuration": [ + "#getting SceneJS ready", + "configuration_pluginPath", + "configuration_disableStatusPopups" + ], + + "scenegraph": [ + "#basic scene graph functionality", + "scenegraph_firstExample", + "scenegraph_events_misc", + "scenegraph_events_status", + "scenegraph_events_status2", + "scenegraph_nodes_adding", + "scenegraph_nodes_events_rendered", + "scenegraph_nodes_instancing", + "scenegraph_nodes_moving", + "scenegraph_multipleScenes", + "scenegraph_webglContextRecovery", + + "#selectively enable rendering modes for subgraphs", + "scenegraph_enable", + "scenegraph_tags", + "scenegraph_flags", + "scenegraph_flags_ambient", + "scenegraph_flags_backfaceLighting", + "scenegraph_flags_backfaces", + "scenegraph_flags_backfaceTexturing", + "scenegraph_flags_diffuse", + "scenegraph_flags_enabled", + "scenegraph_flags_frontface", + "scenegraph_flags_picking", + "scenegraph_flags_reflection", + "scenegraph_flags_specular", + "scenegraph_flags_transparent" + ], + + "canvas": [ + "canvas_capture", + "canvas_capture_customSize", + "canvas_external", + "canvas_external_transparent", + "canvas_transparent" + ], + + "cameras": [ + "camera_orbit", + "camera_path", + "camera_pickFlyOrbit_city", + "camera_pickFlyOrbit_terrain", + "camera_stereo", + "camera_oculusRift", + "camera_anaglyph" + ], + + "geometry": [ + "geometry_autoNormals", + "geometry_box", + "geometry_cylinder", + "geometry_lines", + "geometry_morphTargets", + "geometry_morphTargets_typedArrays", + "geometry_plane", + "geometry_points", + "geometry_sphere", + "geometry_teapot", + "geometry_vectorText", + "geometry_torus", + "geometry_torus_wireframe", + "geometry_triangles", + "geometry_typedArrays", + "geometry_vertexColors", + "geometry_heightmap", + "geometry_heightmap_texture", + "geometry_heightmap_texture_video", + "geometry_heightmap_transparent" + ], + + "transforms": [ + "transforms_modelling_hierarchy", + "transforms_modelling_matrix", + "transforms_modelling_rotate", + "transforms_modelling_scale", + "transforms_modelling_translate", + "transforms_modelling_quaternion", + "transforms_projection_default", + "transforms_projection_frustum", + "transforms_projection_ortho", + "transforms_projection_perspective", + "transforms_viewing" + ], + + "lighting": [ + "lighting_material", + "lighting_ambient", + "lighting_default", + "lighting_directional_view", + "lighting_directional_world", + "lighting_directional_world_texture", + "lighting_point_view", + "lighting_point_world" + ], + + "textures": [ + "texture_alpha", + "texture_alpha_add", + "texture_alpha_mix", + "texture_alpha_multiply", + "texture_alpha_video", + "texture_atlas", + "texture_color", + "texture_color_add", + "texture_color_animated", + "texture_color_multiply", + "texture_color_video", + "texture_emit", + "texture_emit_add", + "texture_emit_multiply", + "texture_emit_video", + "texture_multiTexture", + "texture_normals", + "texture_normals_video", + "texture_rtt_color", + "texture_rtt_depth", + "texture_rtt_depthAndColor", + "texture_rtt_heightmap", + "texture_rtt_manyTextures", + "texture_rtt_shader", + "texture_rtt_withVideo", + "texture_specular", + "texture_specular_add", + "texture_specular_multiply", + "texture_specular_video", + "texture_uvLayers" + ], + + "reflections": [ + "#environmental reflection using cubemaps", + "reflections_custom", + "reflections_intensity", + "reflections_multipleSeparate", + "reflections_multipleCombined", + "reflections_shinyRaptor", + "reflections_manyObjects", + "reflections_withNormalMap", + "reflections_withTransparency", + "reflections_withSpecularMaterial", + "reflections_withSpecularMap" + ], + + "skyboxes": [ + "skyboxes_custom", + "skyboxes_clouds", + "skyboxes_cloudySea", + "skyboxes_grimmNight", + "skyboxes_interstellarClouds", + "skyboxes_miramarClouds", + "skyboxes_stormyDays", + "skyboxes_violentDays" + ], + + "passes": [ + "#multiple passes on each render", + "passes_twoPasses", + "passes_threePasses" + ], + + "stages": [ + "#custom effect pipelines", + "stages_twoStages", + "stages_threeStages", + "stages_withPicking", + "stages_withReflection", + "stages_withSharedShader", + "stages_withTransparencySort" + ], + + "layers": [ + "#prioritised render bins", + "layers_enableDisable", + "layers_transparencySort" + ], + + "depthBuffer": [ + +// "#Depth buffer control", + "depthBuf_clearDepth", + "depthBuf_depthFunc", + "depthBuf_enableDisable" + ], + + "shaders": [ + "shaders_xray", + "shaders_scanline", + "shaders_custom_material_color", + "shaders_custom_texture", + "shaders_custom_twoTextures", + "shaders_custom_threeTextures", + "shaders_custom_transforms", + "shaders_vertexDisplacement" + ], + + "posteffects": [ + "postEffects_blur", + "postEffects_depthOfField", + "postEffects_fog", + "postEffects_lens", + "postEffects_scanlines", + "postEffects_sepia", + "postEffects_scanlinesAndSepia" + ], + + "physics": [ + "physics_balls", + "physics_boxes", + "physics_materials", + "physics_multithreaded" + ], + + "picking": [ + "picking_basic", + "picking_disabling", + "picking_names", + "picking_spheres", + "picking_throughTransparency", + "picking_rayPicking", + "picking_rayPicking_performance" + ], + + "importing": [ + "importing_3ds_lexus", + "importing_md2_lion", + "importing_obj_duck", + "importing_obj_raptor" + ], + + "optimization": [ + "#optimizing your scene graphs", + "optimization_discreteLOD", + "optimization_frustumClipping", + "optimization_instancing", + "optimization_textureAtlas", + "optimization_vertexSharing" + ], + + "benchmarks": [ + "benchmarks_5000boxes" + ], + + "extending": [ + "#adding new node types to SceneJS", + "extending_nodes_custom", + "extending_nodes_custom_animation", + "extending_nodes_custom_pubSub", + "extending_nodes_custom_tasks" + ], + + "environments": [ + "#prebuilt scenes to drop your nodes into", + "environments_lawn", + "environments_gridRoom", + "environments_holoDeck" + ], + + "models": [ + "#a selection of models from the examples library", + "models_vehicles_tank", + "models_buildings_city", + "models_space_earth" + ] +}; \ No newline at end of file diff --git a/demos/nodes-custom-basic.html b/examples/extending_nodes_custom.html similarity index 97% rename from demos/nodes-custom-basic.html rename to examples/extending_nodes_custom.html index f7580f30..eb0b0852 100644 --- a/demos/nodes-custom-basic.html +++ b/examples/extending_nodes_custom.html @@ -117,9 +117,9 @@ // Teapot primitive, - // implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/nodes-custom-animated.html b/examples/extending_nodes_custom_animation.html similarity index 97% rename from demos/nodes-custom-animated.html rename to examples/extending_nodes_custom_animation.html index 8342dc7e..2cd032c8 100644 --- a/demos/nodes-custom-animated.html +++ b/examples/extending_nodes_custom_animation.html @@ -77,9 +77,9 @@ nodes:[ // Teapot primitive, - // implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/nodes-custom-pubsub.html b/examples/extending_nodes_custom_pubSub.html similarity index 97% rename from demos/nodes-custom-pubsub.html rename to examples/extending_nodes_custom_pubSub.html index b1ef9f69..6ceae13d 100644 --- a/demos/nodes-custom-pubsub.html +++ b/examples/extending_nodes_custom_pubSub.html @@ -57,9 +57,9 @@ nodes:[ // Teapot primitive, - // implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/nodes-custom-tasks.html b/examples/extending_nodes_custom_tasks.html similarity index 97% rename from demos/nodes-custom-tasks.html rename to examples/extending_nodes_custom_tasks.html index 88df62b0..01384021 100644 --- a/demos/nodes-custom-tasks.html +++ b/examples/extending_nodes_custom_tasks.html @@ -62,9 +62,9 @@ nodes:[ // Teapot primitive, - // implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/examples/features.json b/examples/features.json new file mode 100644 index 00000000..36860f33 --- /dev/null +++ b/examples/features.json @@ -0,0 +1,472 @@ +[ + { + "title": "Scene graph", + "description": "Declarative JSON-based runtime-editable scene graph", + "nodes": [ + { + "nodes": [ + { + "title": "Transform hierarchies", + "page": "transforms_modelling_hierarchy" + } + ] + }, + { + "nodes": [ + { + "title": "Multiple scenes", + "page": "scenegraph_multipleScenes" + } + ] + }, + { + "nodes": [ + { + "title": "Auto WebGLContextLost recovery", + "page": "scenegraph_webglContextRecovery" + } + ] + } + ] + }, + { + "title": "Effects", + "description": "Extensible library of post-effects and shaders, access to full WebGL shader capabilities", + "nodes": [ + { + "nodes": [ + { + "title": "Depth-of-field", + "page": "postprocessing_depthOfField" + }, + { + "title": "Blur", + "page": "postprocessing_blur" + }, + { + "title": "Fog", + "page": "postprocessing_fog" + }, + { + "title": "X-Ray", + "page": "shaders_xray" + }, + { + "title": "Film grain", + "page": "postprocessing_filmGrain" + }, + { + "title": "Vertex displacement", + "page": "shaders_vertexDisplacement" + } + ] + }, + { + "nodes": [ + { + "title": "Reflection", + "page": "reflections_custom" + } + ] + }, + { + "nodes": [ + { + "title": "Custom fragment shaders", + "page": "shaders_custom_water" + } + ] + }, + { + "nodes": [ + { + "title": "Custom vertex shaders", + "page": "shaders_vertexDisplacement" + } + ] + }, + { + "nodes": [ + { + "title": "Transparency sorting", + "page": "layers_transparencySort" + } + ] + }, + { + "nodes": [ + { + "title": "Oculus Rift", + "page": "effects_oculusRift_pickFlyOrbit" + }, + { + "title": "Anaglyph 3D", + "page": "effects_anaglyph_pickFlyOrbit" + }, + { + "title": "Stereo", + "page": "effects_stereo_pickFlyOrbit" + } + ] + } + ] + }, + { + "title": "Physics", + "nodes": [ + { + "nodes": [ + { + "title": "Rigid body dynamics", + "page": "physics_balls" + } + ] + }, + { + "nodes": [ + { + "title": "Multithreaded", + "page": "physics_multithreaded" + } + ] + } + ] + }, + { + "title": "Importers", + "nodes": [ + { + "nodes": [ + { + "title": ".OBJ", + "page": "importing_obj_raptor" + }, + { + "title": ".3DS", + "page": "importing_3ds_lexus" + }, + { + "title": ".MD2", + "page": "importing_md2_lion" + } + ] + } + ] + }, + { + "title": "Optimization", + "nodes": [ + { + "nodes": [ + { + "title": "Frustum Culling", + "page": "optimization_frustumClipping" + } + ] + }, + { + "nodes": [ + { + "title": "Level-of-Detail", + "page": "optimization_discreteLOD" + } + ] + }, + { + "nodes": [ + { + "title": "Instancing", + "page": "optimization_instancing" + } + ] + }, + { + "nodes": [ + { + "title": "Vertex sharing", + "page": "optimization_vertexSharing" + } + ] + }, + { + "nodes": [ + { + "title": "Texture atlases", + "page": "optimization_textureAtlas" + } + ] + } + ] + }, + { + "title": "Picking", + "nodes": [ + { + "nodes": [ + { + "title": "Object picking", + "page": "picking_names" + } + ] + }, + { + "nodes": [ + { + "title": "3D ray picking", + "page": "picking_rayPicking_performance" + } + ] + } + ] + }, + { + "title": "Lighting", + "nodes": [ + { + "nodes": [ + { + "title": "Ambient", + "page": "lighting_ambient" + }, + { + "title": "Directional", + "page": "lighting_directional_world" + }, + { + "title": "Point", + "page": "lighting_point_world" + } + ] + } + ] + }, + { + "title": "Cameras", + "nodes": [ + { + "nodes": [ + { + "title": "Orthographic", + "page": "transforms_projection_ortho" + }, + { + "title": "Perspective", + "page": "transforms_projection_perspective" + }, + { + "title": "Frustum", + "page": "transforms_projection_frustum" + } + ] + }, + { + "nodes": [ + { + "title": "Orbiting", + "page": "cameras_orbit" + }, + { + "title": "Pick-Fly-Orbit", + "page": "cameras_pickFlyOrbit_city" + } + ] + } + ] + }, + { + "title": "Geometry", + "nodes": [ + { + "nodes": [ + { + "title": "Triangles", + "page": "geometry_triangles" + }, + { + "title": "Lines", + "page": "geometry_lines" + }, + { + "title": "Points", + "page": "geometry_points" + } + ] + }, + { + "nodes": [ + { + "title": "Plane", + "page": "geometry_plane" + }, + { + "title": "Box", + "page": "geometry_box" + }, + { + "title": "Cylinder", + "page": "geometry_cylinder" + }, + { + "title": "Sphere", + "page": "geometry_sphere" + }, + { + "title": "Torus", + "page": "geometry_torus" + }, + { + "title": "Teapot", + "page": "geometry_teapot" + } + ] + }, + { + "nodes": [ + { + "title": "Terrain", + "page": "geometry_heightmap" + } + ] + }, + { + "nodes": [ + { + "title": "Text", + "page": "geometry_vectorText" + } + ] + }, + { + "nodes": [ + { + "title": "Vertex coloring", + "page": "geometry_vertexColors" + } + ] + }, + { + "nodes": [ + { + "title": "Automatic normals", + "page": "geometry_autoNormals" + } + ] + } + ] + }, + { + "title": "Texture", + "nodes": [ + { + "nodes": [ + { + "title": "Color", + "page": "texture_color" + }, + { + "title": "Alpha", + "page": "texture_alpha" + }, + { + "title": "Specular", + "page": "texture_specular" + }, + { + "title": "Normal", + "page": "texture_normals" + }, + { + "title": "Glow", + "page": "texture_emit" + } + ] + }, + { + "nodes": [ + { + "title": "Procedural", + "page": "texture_procedural_color_water" + } + ] + }, + { + "nodes": [ + { + "title": "Reflection", + "page": "reflections_custom" + } + ] + }, + { + "nodes": [ + { + "title": "Multi-texturing", + "page": "texture_multiTexture" + } + ] + }, + { + "nodes": [ + { + "title": "Animation", + "page": "texture_animation" + } + ] + }, + { + "nodes": [ + { + "title": "Render-to-texture", + "page": "texture_rtt_color" + } + ] + }, + { + "nodes": [ + { + "title": "Video", + "page": "texture_video_color" + } + ] + }, + { + "nodes": [ + { + "title": "UV layers", + "page": "texture_uvLayers" + } + ] + } + ] + }, + + { + "title": "Asset library, eg:", + "nodes": [ + { + "nodes": [ + { + "title": "Skyboxes", + "page": "skyboxes_miramarClouds" + } + ] + }, + { + "nodes": [ + { + "title": "City", + "page": "models_buildings_city" + }, + { + "title": "Tank", + "page": "models_vehicles_tank" + }, + { + "title": "Earth", + "page": "models_space_earth" + } + ] + } + ] + } +] \ No newline at end of file diff --git a/demos/geometry-autoNormals.html b/examples/geometry_autoNormals.html similarity index 100% rename from demos/geometry-autoNormals.html rename to examples/geometry_autoNormals.html diff --git a/demos/geometry-box.html b/examples/geometry_box.html similarity index 83% rename from demos/geometry-box.html rename to examples/geometry_box.html index 171413c9..036b34d3 100644 --- a/demos/geometry-box.html +++ b/examples/geometry_box.html @@ -31,10 +31,10 @@ SceneJS.createScene({ nodes:[ - // Mouse-orbited camera, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/cameras/orbit.js + // Asset viewing environment, implemented by plugin at + // http://scenejs.org/api/latest/plugins/node/environments/assetViewer.js { - type:"cameras/orbit", + type:"environments/modelView", yaw:30, pitch:-30, zoom:5, @@ -47,9 +47,9 @@ nodes:[ // Box primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box", + type:"geometry/box", xSize: 1, ySize: 1, zSize: 1.2 diff --git a/demos/geometry-cylinder.html b/examples/geometry_cylinder.html similarity index 95% rename from demos/geometry-cylinder.html rename to examples/geometry_cylinder.html index c7b1c556..2dcbd666 100644 --- a/demos/geometry-cylinder.html +++ b/examples/geometry_cylinder.html @@ -47,10 +47,10 @@ nodes:[ // Cylinder primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/cylinder.js + // http://scenejs.org/api/latest/plugins/node/geometry/cylinder.js // Author: Moritz Kornher { - type:"prims/cylinder", + type:"geometry/cylinder", radiusTop:20, // Default 20 radiusBottom:20, // Default 20 height:100, // Default 100 diff --git a/examples/geometry_heightmap.html b/examples/geometry_heightmap.html new file mode 100644 index 00000000..cabee51d --- /dev/null +++ b/examples/geometry_heightmap.html @@ -0,0 +1,88 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/geometry_heightmap_fogAndGrid.html b/examples/geometry_heightmap_fogAndGrid.html new file mode 100644 index 00000000..4a6a0705 --- /dev/null +++ b/examples/geometry_heightmap_fogAndGrid.html @@ -0,0 +1,127 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/heightmaps-textured.html b/examples/geometry_heightmap_texture.html similarity index 82% rename from demos/heightmaps-textured.html rename to examples/geometry_heightmap_texture.html index 8ec18f8a..8b5d96d3 100644 --- a/demos/heightmaps-textured.html +++ b/examples/geometry_heightmap_texture.html @@ -20,7 +20,7 @@ + + + + + + + \ No newline at end of file diff --git a/demos/geometry-vertexColors.html b/examples/geometry_vertexColors.html similarity index 100% rename from demos/geometry-vertexColors.html rename to examples/geometry_vertexColors.html diff --git a/demos/images/chrome-experiment.png b/examples/images/chrome-experiment.png similarity index 100% rename from demos/images/chrome-experiment.png rename to examples/images/chrome-experiment.png diff --git a/demos/import-3ds-lexus.html b/examples/importing_3ds_lexus.html similarity index 100% rename from demos/import-3ds-lexus.html rename to examples/importing_3ds_lexus.html diff --git a/demos/import-md2-lion.html b/examples/importing_md2_lion.html similarity index 100% rename from demos/import-md2-lion.html rename to examples/importing_md2_lion.html diff --git a/demos/import-obj-duck.html b/examples/importing_obj_duck.html similarity index 100% rename from demos/import-obj-duck.html rename to examples/importing_obj_duck.html diff --git a/demos/import-obj-raptor.html b/examples/importing_obj_raptor.html similarity index 100% rename from demos/import-obj-raptor.html rename to examples/importing_obj_raptor.html diff --git a/demos/layers-enableDisable.html b/examples/layers_enableDisable.html similarity index 95% rename from demos/layers-enableDisable.html rename to examples/layers_enableDisable.html index e96b1145..ce652a6a 100644 --- a/demos/layers-enableDisable.html +++ b/examples/layers_enableDisable.html @@ -67,9 +67,9 @@ nodes:[ // Sphere primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type:"prims/sphere" + type:"geometry/sphere" } ] } @@ -96,9 +96,9 @@ z:3, nodes:[ - // Box primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } @@ -129,9 +129,9 @@ y:-1, nodes:[ - // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/layers-transparencySort.html b/examples/layers_transparencySort.html similarity index 94% rename from demos/layers-transparencySort.html rename to examples/layers_transparencySort.html index 507ded04..7012e0a4 100644 --- a/demos/layers-transparencySort.html +++ b/examples/layers_transparencySort.html @@ -78,9 +78,9 @@ nodes:[ // Box primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } @@ -114,9 +114,9 @@ nodes:[ // Box primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } @@ -145,9 +145,9 @@ nodes:[ // Box primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } diff --git a/demos/libs/cityBuilder.js b/examples/libs/cityBuilder.js similarity index 100% rename from demos/libs/cityBuilder.js rename to examples/libs/cityBuilder.js diff --git a/demos/libs/dat.gui.min.js b/examples/libs/dat.gui.min.js similarity index 100% rename from demos/libs/dat.gui.min.js rename to examples/libs/dat.gui.min.js diff --git a/demos/libs/gl-matrix-min.js b/examples/libs/gl-matrix-min.js similarity index 100% rename from demos/libs/gl-matrix-min.js rename to examples/libs/gl-matrix-min.js diff --git a/demos/libs/gl-matrix.js b/examples/libs/gl-matrix.js similarity index 100% rename from demos/libs/gl-matrix.js rename to examples/libs/gl-matrix.js diff --git a/demos/libs/jquery-1.8.3.min.js b/examples/libs/jquery-1.8.3.min.js similarity index 100% rename from demos/libs/jquery-1.8.3.min.js rename to examples/libs/jquery-1.8.3.min.js diff --git a/demos/libs/stats.min.js b/examples/libs/stats.min.js similarity index 100% rename from demos/libs/stats.min.js rename to examples/libs/stats.min.js diff --git a/demos/libs/sylvester.js b/examples/libs/sylvester.js similarity index 100% rename from demos/libs/sylvester.js rename to examples/libs/sylvester.js diff --git a/demos/lights-ambient.html b/examples/lighting_ambient.html similarity index 95% rename from demos/lights-ambient.html rename to examples/lighting_ambient.html index cbc02fbe..1f226d88 100644 --- a/demos/lights-ambient.html +++ b/examples/lighting_ambient.html @@ -62,9 +62,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/lights-default.html b/examples/lighting_default.html similarity index 97% rename from demos/lights-default.html rename to examples/lighting_default.html index a437cfde..e685bb90 100644 --- a/demos/lights-default.html +++ b/examples/lighting_default.html @@ -89,9 +89,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/lights-directional-view.html b/examples/lighting_directional_view.html similarity index 98% rename from demos/lights-directional-view.html rename to examples/lighting_directional_view.html index cebee806..e74e1032 100644 --- a/demos/lights-directional-view.html +++ b/examples/lighting_directional_view.html @@ -72,9 +72,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/lights-directional-world.html b/examples/lighting_directional_world.html similarity index 95% rename from demos/lights-directional-world.html rename to examples/lighting_directional_world.html index 051a10aa..76c3f0a8 100644 --- a/demos/lights-directional-world.html +++ b/examples/lighting_directional_world.html @@ -69,9 +69,9 @@ nodes:[ - // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/lights-directional-world-texture.html b/examples/lighting_directional_world_texture.html similarity index 96% rename from demos/lights-directional-world-texture.html rename to examples/lighting_directional_world_texture.html index 80449adc..8599e0fb 100644 --- a/demos/lights-directional-world-texture.html +++ b/examples/lighting_directional_world_texture.html @@ -79,9 +79,9 @@ nodes:[ // Box primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } diff --git a/examples/lighting_material_custom.html b/examples/lighting_material_custom.html new file mode 100644 index 00000000..0dd55109 --- /dev/null +++ b/examples/lighting_material_custom.html @@ -0,0 +1,109 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/materials-default.html b/examples/lighting_material_defaults.html similarity index 96% rename from demos/materials-default.html rename to examples/lighting_material_defaults.html index 595d13a8..c02a3abd 100644 --- a/demos/materials-default.html +++ b/examples/lighting_material_defaults.html @@ -21,6 +21,8 @@ + + + + + + \ No newline at end of file diff --git a/examples/models_space_earth.html b/examples/models_space_earth.html new file mode 100644 index 00000000..10d83797 --- /dev/null +++ b/examples/models_space_earth.html @@ -0,0 +1,53 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/models_vehicles_tank.html b/examples/models_vehicles_tank.html new file mode 100644 index 00000000..ddb3ecfd --- /dev/null +++ b/examples/models_vehicles_tank.html @@ -0,0 +1,54 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/movies/bumpMap.ogg b/examples/movies/bumpMap.ogg similarity index 100% rename from demos/movies/bumpMap.ogg rename to examples/movies/bumpMap.ogg diff --git a/demos/movies/bunny.ogg b/examples/movies/bunny.ogg similarity index 100% rename from demos/movies/bunny.ogg rename to examples/movies/bunny.ogg diff --git a/demos/movies/testVideo.ogv b/examples/movies/testVideo.ogv similarity index 100% rename from demos/movies/testVideo.ogv rename to examples/movies/testVideo.ogv diff --git a/examples/multipass_threePasses.html b/examples/multipass_threePasses.html new file mode 100644 index 00000000..12881471 --- /dev/null +++ b/examples/multipass_threePasses.html @@ -0,0 +1,121 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/multipass_twoPasses.html b/examples/multipass_twoPasses.html new file mode 100644 index 00000000..14f82489 --- /dev/null +++ b/examples/multipass_twoPasses.html @@ -0,0 +1,116 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/culling-frustum-detail.html b/examples/optimization_discreteLOD.html similarity index 92% rename from demos/culling-frustum-detail.html rename to examples/optimization_discreteLOD.html index 1b74af75..265646b0 100644 --- a/demos/culling-frustum-detail.html +++ b/examples/optimization_discreteLOD.html @@ -21,9 +21,9 @@ // // Demonstrates Detail Culling using the axis-aligned bounding box node defined -// by the plugin in http://scenejs.org/api/latest/plugins/node/frustum/lod.js +// by the plugin in http://scenejs.org/api/latest/plugins/node/cull/detail.js // -// The frustum/lod node encloses its child nodes in an axis-aligned World-space bounding +// The cull/detail node encloses its child nodes in an axis-aligned World-space bounding // box and enables the appropriate child for the box's current projected 2D canvas size. // As shown in the example below, we configure the node with a 2D size threshold for @@ -94,12 +94,12 @@ // Detail culling node, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/frustum/lod.js + // http://scenejs.org/api/latest/plugins/node/cull/detail.js // // More info at: https://github.com/xeolabs/scenejs/wiki/Detail-Culling nodes.push({ - type: "frustum/lod", + type: "cull/detail", // World-space axis-aligned bounding box min: [xPos - 8, yPos - 3, zPos - 5], @@ -148,9 +148,9 @@ nodes: [ // Box primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -187,9 +187,9 @@ nodes: [ // Sphere primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type: "prims/sphere", + type: "geometry/sphere", radius: 5, latitudeBands: 16, // A fairly low-rez sphere longitudeBands: 16 @@ -225,9 +225,10 @@ nodes: [ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type: "prims/teapot" + type: "geometry/teapot" + //type: "models/space/planets/earth" } ] } diff --git a/demos/culling-frustum.html b/examples/optimization_frustumClipping.html similarity index 95% rename from demos/culling-frustum.html rename to examples/optimization_frustumClipping.html index 8df4b69c..6aa45655 100644 --- a/demos/culling-frustum.html +++ b/examples/optimization_frustumClipping.html @@ -24,7 +24,7 @@ + + + + + + + + + \ No newline at end of file diff --git a/demos/nodes-cores-sharing.html b/examples/optimization_instancing.html similarity index 100% rename from demos/nodes-cores-sharing.html rename to examples/optimization_instancing.html diff --git a/examples/optimization_textureAtlas.html b/examples/optimization_textureAtlas.html new file mode 100644 index 00000000..0f755294 --- /dev/null +++ b/examples/optimization_textureAtlas.html @@ -0,0 +1,117 @@ + + + + SceneJS Example + + + + + + + + + + \ No newline at end of file diff --git a/demos/geometry-vertexSharing.html b/examples/optimization_vertexSharing.html similarity index 100% rename from demos/geometry-vertexSharing.html rename to examples/optimization_vertexSharing.html diff --git a/examples/physics_balls.html b/examples/physics_balls.html new file mode 100644 index 00000000..4d26c457 --- /dev/null +++ b/examples/physics_balls.html @@ -0,0 +1,236 @@ + + + + SceneJS Example + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/physics-boxes.html b/examples/physics_boxes.html similarity index 96% rename from demos/physics-boxes.html rename to examples/physics_boxes.html index b6b75e12..52d08b7c 100644 --- a/demos/physics-boxes.html +++ b/examples/physics_boxes.html @@ -106,9 +106,9 @@ nodes:[ // Grid ground plane geometry, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/grid.js + // http://scenejs.org/api/latest/plugins/node/geometry/grid.js { - type:"prims/grid", + type:"geometry/grid", size:{ x:1000, z:1000 }, xSegments:200, zSegments:200 @@ -130,7 +130,7 @@ ] }); - // Returns a bunch of "prims/sphere" nodes, each wrapped by a spherical "physics/body" node + // Returns a bunch of "geometry/sphere" nodes, each wrapped by a spherical "physics/body" node function makeBodies(numBodies) { var nodes = []; @@ -195,9 +195,9 @@ nodes:[ // Sphere primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type:"prims/box", + type:"geometry/box", xSize:xSize / 2, ySize:ySize / 2, zSize:zSize / 2 diff --git a/demos/physics-materials.html b/examples/physics_materials.html similarity index 92% rename from demos/physics-materials.html rename to examples/physics_materials.html index f97b5551..8a9f3655 100644 --- a/demos/physics-materials.html +++ b/examples/physics_materials.html @@ -138,13 +138,6 @@ // Mass not relevant for unmoving object? mass:0.0, - // The coefficient of restitution (COR) of two colliding objects is a - // fractional value representing the ratio of speeds after and before - // an impact, taken along the line of the impact. - restitution:0.9, - - friction:0.3, - // Specify that this body is not able to move movable:false, @@ -160,9 +153,9 @@ nodes:[ // Grid ground plane geometry, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/grid.js + // http://scenejs.org/api/latest/plugins/node/geometry/grid.js { - type:"prims/grid", + type:"geometry/grid", size:{ x:50, z:50 }, xSegments:100, zSegments:100 @@ -184,7 +177,7 @@ } -// Returns a bunch of "prims/sphere" nodes, each wrapped by a spherical "physics/body" node +// Returns a bunch of "geometry/sphere" nodes, each wrapped by a spherical "physics/body" node function makeBodies(numBodies, systemId) { var nodes = []; @@ -238,9 +231,9 @@ nodes:[ // Sphere primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type:"prims/sphere", + type:"geometry/sphere", radius:1 } ] diff --git a/demos/physics-multithreaded.html b/examples/physics_multithreaded.html similarity index 96% rename from demos/physics-multithreaded.html rename to examples/physics_multithreaded.html index 78c03d98..0ca79259 100644 --- a/demos/physics-multithreaded.html +++ b/examples/physics_multithreaded.html @@ -136,9 +136,9 @@ nodes:[ // Grid ground plane geometry, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/grid.js + // http://scenejs.org/api/latest/plugins/node/geometry/grid.js { - type:"prims/grid", + type:"geometry/grid", size:{ x:50, z:50 }, xSegments:20, zSegments:20 @@ -160,7 +160,7 @@ } -// Returns a bunch of "prims/sphere" nodes, each wrapped by a spherical "physics/body" node +// Returns a bunch of "geometry/sphere" nodes, each wrapped by a spherical "physics/body" node function makeBodies(numBodies, systemId) { var nodes = []; @@ -214,9 +214,9 @@ nodes:[ // Sphere primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type:"prims/sphere", + type:"geometry/sphere", radius:1, latitudeBands:16, // A fairly low-rez sphere diff --git a/demos/picking.html b/examples/picking_basic.html similarity index 93% rename from demos/picking.html rename to examples/picking_basic.html index 03f4d2e1..e2dcf132 100644 --- a/demos/picking.html +++ b/examples/picking_basic.html @@ -59,7 +59,8 @@ // Pickable red teapot with name "redTeapot" { - type: "name", name: "redTeapot", + type: "name", + name: "redTeapot", nodes: [ { type: "material", color: { r: 1.0, g: 0.3, b: 0.3 }, @@ -69,9 +70,9 @@ nodes: [ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type: "prims/teapot" + type: "geometry/teapot" } ] } @@ -82,7 +83,8 @@ // Pickable blue teapot with name "blueTeapot" { - type: "name", name: "blueTeapot", + type: "name", + name: "blueTeapot", nodes: [ { type: "material", color: { r: 0.3, g: 0.3, b: 1.0 }, @@ -92,9 +94,9 @@ nodes: [ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type: "prims/teapot" + type: "geometry/teapot" } ] } diff --git a/demos/picking-disabling.html b/examples/picking_disabling.html similarity index 95% rename from demos/picking-disabling.html rename to examples/picking_disabling.html index 4e46bc54..05447e5e 100644 --- a/demos/picking-disabling.html +++ b/examples/picking_disabling.html @@ -64,9 +64,9 @@ nodes: [ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type: "prims/teapot" + type: "geometry/teapot" } ] } @@ -93,9 +93,9 @@ nodes: [ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type: "prims/teapot" + type: "geometry/teapot" } ] } diff --git a/demos/picking-names.html b/examples/picking_names.html similarity index 96% rename from demos/picking-names.html rename to examples/picking_names.html index b2f04ab1..cd58e3da 100644 --- a/demos/picking-names.html +++ b/examples/picking_names.html @@ -103,9 +103,9 @@ nodes:[ - // Box primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } @@ -137,9 +137,9 @@ nodes:[ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } @@ -170,9 +170,9 @@ nodes:[ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } @@ -203,9 +203,9 @@ nodes:[ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } @@ -236,9 +236,9 @@ nodes:[ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } @@ -289,9 +289,9 @@ nodes:[ // Node type implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type:"prims/torus" + type:"geometry/torus" } ] } @@ -329,9 +329,9 @@ nodes:[ // Node type implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type:"prims/torus" + type:"geometry/torus" } ] } @@ -369,9 +369,9 @@ nodes:[ // Node type implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type:"prims/torus" + type:"geometry/torus" } ] } @@ -409,9 +409,9 @@ nodes:[ // Node type implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type:"prims/torus" + type:"geometry/torus" } ] } @@ -454,9 +454,9 @@ nodes:[ // Node type implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } @@ -495,9 +495,9 @@ nodes:[ - // Sphere geometry node implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // Sphere geometry node implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type:"prims/sphere" + type:"geometry/sphere" } ] } diff --git a/demos/picking-ray.html b/examples/picking_rayPicking.html similarity index 94% rename from demos/picking-ray.html rename to examples/picking_rayPicking.html index 5b099184..df50ee32 100644 --- a/demos/picking-ray.html +++ b/examples/picking_rayPicking.html @@ -62,9 +62,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } @@ -82,9 +82,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } @@ -109,9 +109,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } @@ -171,9 +171,9 @@ z:0.1, nodes:[ - // Sphere primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // Sphere primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type:"prims/sphere" + type:"geometry/sphere" } ] } diff --git a/demos/picking-ray-spheres.html b/examples/picking_rayPicking_performance.html similarity index 97% rename from demos/picking-ray-spheres.html rename to examples/picking_rayPicking_performance.html index 1bfb32bf..f30b3319 100644 --- a/demos/picking-ray-spheres.html +++ b/examples/picking_rayPicking_performance.html @@ -100,9 +100,9 @@ nodes:[ // Sphere geometry node implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type:"prims/sphere" + type:"geometry/sphere" } ] } @@ -164,9 +164,9 @@ z:0.2, nodes:[ - // Sphere primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // Sphere primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type:"prims/sphere" + type:"geometry/sphere" } ] } diff --git a/demos/picking-spheres.html b/examples/picking_spheres.html similarity index 98% rename from demos/picking-spheres.html rename to examples/picking_spheres.html index f71d4097..ccdada5e 100644 --- a/demos/picking-spheres.html +++ b/examples/picking_spheres.html @@ -86,9 +86,9 @@ shine: 70.0, nodes: [ - // Sphere geometry node implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // Sphere geometry node implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type: "prims/sphere" + type: "geometry/sphere" } ] } diff --git a/demos/picking-throughTransparency.html b/examples/picking_throughTransparency.html similarity index 95% rename from demos/picking-throughTransparency.html rename to examples/picking_throughTransparency.html index 4917b191..368c8972 100644 --- a/demos/picking-throughTransparency.html +++ b/examples/picking_throughTransparency.html @@ -64,9 +64,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } @@ -91,9 +91,9 @@ nodes:[ // Box primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box", xSize:3.5, ySize:2, zSize:3.5 + type:"geometry/box", xSize:3.5, ySize:2, zSize:3.5 } ] } diff --git a/examples/postprocessing_blur.html b/examples/postprocessing_blur.html new file mode 100644 index 00000000..4f092702 --- /dev/null +++ b/examples/postprocessing_blur.html @@ -0,0 +1,124 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/postprocessing_crt.html b/examples/postprocessing_crt.html new file mode 100644 index 00000000..677ae49d --- /dev/null +++ b/examples/postprocessing_crt.html @@ -0,0 +1,73 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/postprocessing_custom_twoStagesWithPicking.html b/examples/postprocessing_custom_twoStagesWithPicking.html new file mode 100644 index 00000000..6a93c4c0 --- /dev/null +++ b/examples/postprocessing_custom_twoStagesWithPicking.html @@ -0,0 +1,268 @@ + + + + SceneJS Example + + + + + + + + + + +
Click on an object to pick it +
+ + + + + \ No newline at end of file diff --git a/examples/postprocessing_depthOfField.html b/examples/postprocessing_depthOfField.html new file mode 100644 index 00000000..44c706ab --- /dev/null +++ b/examples/postprocessing_depthOfField.html @@ -0,0 +1,171 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/postprocessing_depthOfField_autofocus.html b/examples/postprocessing_depthOfField_autofocus.html new file mode 100644 index 00000000..8e165f53 --- /dev/null +++ b/examples/postprocessing_depthOfField_autofocus.html @@ -0,0 +1,128 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/postprocessing_filmGrain.html b/examples/postprocessing_filmGrain.html new file mode 100644 index 00000000..ef418876 --- /dev/null +++ b/examples/postprocessing_filmGrain.html @@ -0,0 +1,75 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/effects-fog.html b/examples/postprocessing_fog.html similarity index 89% rename from demos/effects-fog.html rename to examples/postprocessing_fog.html index 5ef64dba..9d32ea22 100644 --- a/demos/effects-fog.html +++ b/examples/postprocessing_fog.html @@ -19,7 +19,7 @@ + + + + + + \ No newline at end of file diff --git a/examples/postprocessing_pipeline.html b/examples/postprocessing_pipeline.html new file mode 100644 index 00000000..292b240c --- /dev/null +++ b/examples/postprocessing_pipeline.html @@ -0,0 +1,187 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/postprocessing_scanlines.html b/examples/postprocessing_scanlines.html new file mode 100644 index 00000000..0b4b4eef --- /dev/null +++ b/examples/postprocessing_scanlines.html @@ -0,0 +1,73 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/postprocessing_scanlinesAndSepia.html b/examples/postprocessing_scanlinesAndSepia.html new file mode 100644 index 00000000..336e8217 --- /dev/null +++ b/examples/postprocessing_scanlinesAndSepia.html @@ -0,0 +1,90 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/postprocessing_sepia.html b/examples/postprocessing_sepia.html new file mode 100644 index 00000000..6bc46d64 --- /dev/null +++ b/examples/postprocessing_sepia.html @@ -0,0 +1,79 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/import-3ds-teapot.html b/examples/postprocessing_technicolor.html similarity index 55% rename from demos/import-3ds-teapot.html rename to examples/postprocessing_technicolor.html index fc11c423..103c6b2a 100644 --- a/demos/import-3ds-teapot.html +++ b/examples/postprocessing_technicolor.html @@ -20,48 +20,48 @@ \ No newline at end of file diff --git a/examples/reflections_clouds.html b/examples/reflections_clouds.html new file mode 100644 index 00000000..6d78d496 --- /dev/null +++ b/examples/reflections_clouds.html @@ -0,0 +1,102 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/reflection.html b/examples/reflections_custom.html similarity index 94% rename from demos/reflection.html rename to examples/reflections_custom.html index 8c23f4bb..3f54c736 100644 --- a/demos/reflection.html +++ b/examples/reflections_custom.html @@ -28,7 +28,7 @@ // // 1. a "reflect" node, which defines a cube map texture to be reflected on child geometries, // 2. a "material" node, which defines the amount of surface reflectivity via its "specular" property, and - // 3. one or more geometry nodes (eg. "prims/teapot"), which define the surface. + // 3. one or more geometry nodes (eg. "geometry/teapot"), which define the surface. // // The amount of reflectivity of the surface is controlled by the "specular" property // on the material, while the intensity of the cube map texture that is applied is @@ -85,9 +85,9 @@ nodes: [ // Teapot primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type: "prims/teapot" + type: "geometry/teapot" } ] } diff --git a/demos/reflection-intensity.html b/examples/reflections_intensity.html similarity index 89% rename from demos/reflection-intensity.html rename to examples/reflections_intensity.html index 316131dd..c3ba8ba9 100644 --- a/demos/reflection-intensity.html +++ b/examples/reflections_intensity.html @@ -27,7 +27,7 @@ // // 1. a "reflect" node, which defines a cube map texture to be reflected on child geometries, // 2. a "material" node, which defines the amount of surface reflectivity via its "specular" property, and - // 3. one or more geometry nodes (eg. "prims/teapot"), which define the surface. + // 3. one or more geometry nodes (eg. "geometry/teapot"), which define the surface. // // The amount of reflectivity of the surface is controlled by the "specular" property // on the material, while the intensity of the cube map texture that is applied is @@ -71,7 +71,7 @@ x: -30, nodes: [ - { type: "prims/vectorText", text: "Intensity 0.05" }, + { type: "geometry/vectorText", text: "Intensity 0.05" }, // Reflection cube map // Images taken from: http://hristo.oskov.com/projects/cs418/mp3/ @@ -90,9 +90,9 @@ nodes: [ // Tron tank primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/objects/vehicles/tank.js + // http://scenejs.org/api/latest/plugins/node/models/vehicles/tank.js { - type: "objects/vehicles/tank" + type: "models/vehicles/tank" } ] } @@ -105,7 +105,7 @@ x: -10, nodes: [ - { type: "prims/vectorText", text: "Intensity 0.2" }, + { type: "geometry/vectorText", text: "Intensity 0.2" }, // Reflection cube map // Images taken from: http://hristo.oskov.com/projects/cs418/mp3/ @@ -124,9 +124,9 @@ nodes: [ // Tron tank primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/objects/vehicles/tank.js + // http://scenejs.org/api/latest/plugins/node/models/vehicles/tank.js { - type: "objects/vehicles/tank" + type: "models/vehicles/tank" } ] } @@ -139,7 +139,7 @@ x: 10, nodes: [ - { type: "prims/vectorText", text: "Intensity 0.4" }, + { type: "geometry/vectorText", text: "Intensity 0.4" }, // Reflection cube map // Images taken from: http://hristo.oskov.com/projects/cs418/mp3/ @@ -158,9 +158,9 @@ nodes: [ // Tron tank primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/objects/vehicles/tank.js + // http://scenejs.org/api/latest/plugins/node/models/vehicles/tank.js { - type: "objects/vehicles/tank" + type: "models/vehicles/tank" } ] } @@ -171,7 +171,7 @@ x: 30, nodes: [ - { type: "prims/vectorText", text: "Intensity 1.0" }, + { type: "geometry/vectorText", text: "Intensity 1.0" }, // Reflection cube map // Images taken from: http://hristo.oskov.com/projects/cs418/mp3/ @@ -190,9 +190,9 @@ nodes: [ // Tron tank primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/objects/vehicles/tank.js + // http://scenejs.org/api/latest/plugins/node/models/vehicles/tank.js { - type: "objects/vehicles/tank" + type: "models/vehicles/tank" } ] } diff --git a/demos/reflection-multipleObjects.html b/examples/reflections_manyObjects.html similarity index 97% rename from demos/reflection-multipleObjects.html rename to examples/reflections_manyObjects.html index 367adcf5..9585a321 100644 --- a/demos/reflection-multipleObjects.html +++ b/examples/reflections_manyObjects.html @@ -77,9 +77,9 @@ nodes: [ - // Box primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -102,9 +102,9 @@ nodes: [ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -127,9 +127,9 @@ nodes: [ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -152,9 +152,9 @@ nodes: [ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -177,9 +177,9 @@ nodes: [ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -213,7 +213,7 @@ nodes: [ { - type: "prims/torus" + type: "geometry/torus" } ] } @@ -242,7 +242,7 @@ nodes: [ { - type: "prims/torus" + type: "geometry/torus" } ] } @@ -271,7 +271,7 @@ nodes: [ { - type: "prims/torus" + type: "geometry/torus" } ] } @@ -300,7 +300,7 @@ nodes: [ { - type: "prims/torus" + type: "geometry/torus" } ] } @@ -332,9 +332,9 @@ nodes: [ - // Node type implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // Node type implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type: "prims/teapot" + type: "geometry/teapot" } ] } @@ -365,9 +365,9 @@ nodes: [ - // Sphere geometry node implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // Sphere geometry node implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type: "prims/sphere" + type: "geometry/sphere" } ] } diff --git a/demos/reflection-multiple.html b/examples/reflections_multipleCombined.html similarity index 95% rename from demos/reflection-multiple.html rename to examples/reflections_multipleCombined.html index 50fe8ff8..4f9e643f 100644 --- a/demos/reflection-multiple.html +++ b/examples/reflections_multipleCombined.html @@ -21,7 +21,7 @@ + + + + + + + \ No newline at end of file diff --git a/demos/reflection-obj.html b/examples/reflections_shinyRaptor.html similarity index 95% rename from demos/reflection-obj.html rename to examples/reflections_shinyRaptor.html index 7434d914..329a93f8 100644 --- a/demos/reflection-obj.html +++ b/examples/reflections_shinyRaptor.html @@ -76,7 +76,7 @@ type: "texture", layers: [ { - src: "../../../models/obj/raptor.jpg" + src: "models/obj/raptor.jpg" } ], nodes: [ @@ -91,7 +91,7 @@ { type: "import/obj", - src: "../../../models/obj/raptor.obj" + src: "models/obj/raptor.obj" } ] } diff --git a/examples/reflections_withNormalMap.html b/examples/reflections_withNormalMap.html new file mode 100644 index 00000000..8aa25212 --- /dev/null +++ b/examples/reflections_withNormalMap.html @@ -0,0 +1,173 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/reflection-specularMap.html b/examples/reflections_withSpecularMap.html similarity index 94% rename from demos/reflection-specularMap.html rename to examples/reflections_withSpecularMap.html index ee319ee8..3e0c0745 100644 --- a/demos/reflection-specularMap.html +++ b/examples/reflections_withSpecularMap.html @@ -91,9 +91,9 @@ nodes: [ // Box primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -119,9 +119,9 @@ nodes: [ // Box primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -147,9 +147,9 @@ nodes: [ // Box primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } diff --git a/demos/reflection-specularity.html b/examples/reflections_withSpecularMaterial.html similarity index 93% rename from demos/reflection-specularity.html rename to examples/reflections_withSpecularMaterial.html index fdbfe2fe..f7257057 100644 --- a/demos/reflection-specularity.html +++ b/examples/reflections_withSpecularMaterial.html @@ -28,7 +28,7 @@ // // 1. a "reflect" node, which defines a cube map texture to be reflected on child geometries, // 2. a "material" nodes, which defines the amount of surface reflectivity via its "specular" property, and - // 3. a geometry node (eg. "prims/teapot"), which define the surface. + // 3. a geometry node (eg. "geometry/teapot"), which define the surface. // // // While the amount of reflectivity of the surface is controlled by the "specular" property on the @@ -92,9 +92,9 @@ nodes: [ // Sphere primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type: "prims/sphere" + type: "geometry/sphere" } ] } @@ -117,9 +117,9 @@ nodes: [ // Sphere primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type: "prims/sphere" + type: "geometry/sphere" } ] } @@ -142,9 +142,9 @@ nodes: [ // Sphere primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type: "prims/sphere" + type: "geometry/sphere" } ] } diff --git a/demos/reflection-transparent.html b/examples/reflections_withTransparency.html similarity index 96% rename from demos/reflection-transparent.html rename to examples/reflections_withTransparency.html index ec0353da..bc734dc3 100644 --- a/demos/reflection-transparent.html +++ b/examples/reflections_withTransparency.html @@ -78,9 +78,9 @@ nodes: [ // Box primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -127,7 +127,7 @@ { type: "material", color: { r: 0.2, g: 1.0, b: 0.2 }, - alpha: 0.5, + alpha: 0.4, specular: 0.5, nodes: [ @@ -140,9 +140,9 @@ nodes: [ // Sphere primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type: "prims/teapot" + type: "geometry/sphere" } ] } diff --git a/demos/culling-enable.html b/examples/scenegraph_enable.html similarity index 96% rename from demos/culling-enable.html rename to examples/scenegraph_enable.html index 23f37d21..6c7a28ee 100644 --- a/demos/culling-enable.html +++ b/examples/scenegraph_enable.html @@ -67,9 +67,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/scene-events-misc.html b/examples/scenegraph_events_misc.html similarity index 89% rename from demos/scene-events-misc.html rename to examples/scenegraph_events_misc.html index 54da2309..3f48917e 100644 --- a/demos/scene-events-misc.html +++ b/examples/scenegraph_events_misc.html @@ -19,15 +19,21 @@ diff --git a/demos/scene-events-status2.html b/examples/scenegraph_events_status2.html similarity index 93% rename from demos/scene-events-status2.html rename to examples/scenegraph_events_status2.html index 580c63cf..a231db5c 100644 --- a/demos/scene-events-status2.html +++ b/examples/scenegraph_events_status2.html @@ -34,8 +34,8 @@ type:"cameras/orbit", yaw:-100, pitch:-10, - zoom:10, - zoomSensitivity:10.0, + zoom:6, + zoomSensitivity:1.0, nodes:[ { @@ -54,9 +54,9 @@ nodes:[ // Planet Earth, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/objects/space/planets/earth.js + // http://scenejs.org/api/latest/plugins/node/models/space/planets/earth.js { - type:"objects/space/planets/earth" + type:"models/space/planets/earth" } ] } diff --git a/demos/geometry-text.html b/examples/scenegraph_firstExample.html similarity index 53% rename from demos/geometry-text.html rename to examples/scenegraph_firstExample.html index 448edcb7..488a2f47 100644 --- a/demos/geometry-text.html +++ b/examples/scenegraph_firstExample.html @@ -26,40 +26,32 @@ pluginPath:"../api/latest/plugins" }); - // Create scene - SceneJS.createScene({ + // Define scene + var scene = SceneJS.createScene({ nodes:[ - - // Mouse-orbited camera, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/cameras/orbit.js { - type:"cameras/orbit", - yaw:30, - pitch:-30, - zoom:20, - zoomSensitivity:1.0, + type:"lookAt", + eye:{ y:5, z:7 }, + look:{ x:0, y:1, z:0 }, nodes:[ - - // Override default material to make text glow blue { type:"material", - color:{ r:0.5, g:0.5, b:1.0 }, - emit:1, - nodes:[ + color:{ r:0.3, g:0.3, b:1.0 }, + nodes:[ { - type:"translate", - x:-10, + type:"rotate", + id:"myRotate", + y:1.0, + angle:0, + nodes:[ - // A line of vector text + // Teapot primitive, implemented by plugin at + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"geometry", - source:{ - type:"vectorText", - text:"One line of vector text, please." - } + type:"geometry/teapot" } ] } @@ -70,6 +62,18 @@ ] }); + // On each frame, spin the teapot a little bit + + scene.getNode("myRotate", function (myRotate) { + + var angle = 0; + + scene.on("tick", + function () { + myRotate.setAngle(angle += 0.5); + }); + }); + \ No newline at end of file diff --git a/demos/flags.html b/examples/scenegraph_flags.html similarity index 96% rename from demos/flags.html rename to examples/scenegraph_flags.html index b334567e..f5a8b3d1 100644 --- a/demos/flags.html +++ b/examples/scenegraph_flags.html @@ -69,9 +69,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/flags-ambient.html b/examples/scenegraph_flags_ambient.html similarity index 97% rename from demos/flags-ambient.html rename to examples/scenegraph_flags_ambient.html index b69b6d19..72d72d35 100644 --- a/demos/flags-ambient.html +++ b/examples/scenegraph_flags_ambient.html @@ -114,9 +114,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/flags-backfaceLighting.html b/examples/scenegraph_flags_backfaceLighting.html similarity index 96% rename from demos/flags-backfaceLighting.html rename to examples/scenegraph_flags_backfaceLighting.html index 1ff94c76..87921598 100644 --- a/demos/flags-backfaceLighting.html +++ b/examples/scenegraph_flags_backfaceLighting.html @@ -69,9 +69,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/flags-backfaceTexturing.html b/examples/scenegraph_flags_backfaceTexturing.html similarity index 96% rename from demos/flags-backfaceTexturing.html rename to examples/scenegraph_flags_backfaceTexturing.html index 2c87e1d7..d7df5194 100644 --- a/demos/flags-backfaceTexturing.html +++ b/examples/scenegraph_flags_backfaceTexturing.html @@ -80,9 +80,9 @@ nodes:[ // Plane primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/plane.js + // http://scenejs.org/api/latest/plugins/node/geometry/plane.js { - type:"prims/plane" + type:"geometry/plane" } ] } diff --git a/demos/flags-backfaces.html b/examples/scenegraph_flags_backfaces.html similarity index 96% rename from demos/flags-backfaces.html rename to examples/scenegraph_flags_backfaces.html index ef1263f0..d1114deb 100644 --- a/demos/flags-backfaces.html +++ b/examples/scenegraph_flags_backfaces.html @@ -66,9 +66,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/flags-diffuse.html b/examples/scenegraph_flags_diffuse.html similarity index 97% rename from demos/flags-diffuse.html rename to examples/scenegraph_flags_diffuse.html index 13e4b35f..92b12d3f 100644 --- a/demos/flags-diffuse.html +++ b/examples/scenegraph_flags_diffuse.html @@ -111,9 +111,9 @@ ], nodes:[ - // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/flags-enabled.html b/examples/scenegraph_flags_enabled.html similarity index 96% rename from demos/flags-enabled.html rename to examples/scenegraph_flags_enabled.html index 3c84c496..90523ba0 100644 --- a/demos/flags-enabled.html +++ b/examples/scenegraph_flags_enabled.html @@ -66,9 +66,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/flags-frontface.html b/examples/scenegraph_flags_frontface.html similarity index 96% rename from demos/flags-frontface.html rename to examples/scenegraph_flags_frontface.html index 943ea626..41cc3328 100644 --- a/demos/flags-frontface.html +++ b/examples/scenegraph_flags_frontface.html @@ -66,9 +66,9 @@ nodes:[ - // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/flags-picking.html b/examples/scenegraph_flags_picking.html similarity index 97% rename from demos/flags-picking.html rename to examples/scenegraph_flags_picking.html index 225d0647..41dffbba 100644 --- a/demos/flags-picking.html +++ b/examples/scenegraph_flags_picking.html @@ -66,9 +66,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/flags-reflection.html b/examples/scenegraph_flags_reflection.html similarity index 97% rename from demos/flags-reflection.html rename to examples/scenegraph_flags_reflection.html index a031e9ab..5c3720b3 100644 --- a/demos/flags-reflection.html +++ b/examples/scenegraph_flags_reflection.html @@ -94,9 +94,9 @@ nodes: [ // Teapot primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type: "prims/teapot" + type: "geometry/teapot" } ] } diff --git a/demos/flags-specular.html b/examples/scenegraph_flags_specular.html similarity index 97% rename from demos/flags-specular.html rename to examples/scenegraph_flags_specular.html index 3dbc549e..9d8b35a7 100644 --- a/demos/flags-specular.html +++ b/examples/scenegraph_flags_specular.html @@ -112,9 +112,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type:"prims/torus" + type:"geometry/torus" } ] } diff --git a/demos/flags-transparent.html b/examples/scenegraph_flags_transparent.html similarity index 94% rename from demos/flags-transparent.html rename to examples/scenegraph_flags_transparent.html index 3bb8c459..a4aecf40 100644 --- a/demos/flags-transparent.html +++ b/examples/scenegraph_flags_transparent.html @@ -74,9 +74,9 @@ nodes:[ - // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } @@ -98,9 +98,9 @@ y:0.4, z:0.4, nodes:[ - // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type:"prims/sphere" + type:"geometry/sphere" } ] } diff --git a/demos/scenes-multiple.html b/examples/scenegraph_multipleScenes.html similarity index 84% rename from demos/scenes-multiple.html rename to examples/scenegraph_multipleScenes.html index 659da7b4..aa4965e1 100644 --- a/demos/scenes-multiple.html +++ b/examples/scenegraph_multipleScenes.html @@ -69,10 +69,10 @@ // A different primitive type for each scene { type:[ - "prims/torus", // http://scenejs.org/api/latest/plugins/node/prims/torus.js - "prims/teapot", // http://scenejs.org/api/latest/plugins/node/prims/teapot.js - "prims/box", // http://scenejs.org/api/latest/plugins/node/prims/box.js - "prims/sphere" // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + "geometry/torus", // http://scenejs.org/api/latest/plugins/node/geometry/torus.js + "geometry/teapot", // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js + "geometry/box", // http://scenejs.org/api/latest/plugins/node/geometry/box.js + "geometry/sphere" // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js ][i % 4] } ] diff --git a/demos/nodes-adding.html b/examples/scenegraph_nodes_adding.html similarity index 51% rename from demos/nodes-adding.html rename to examples/scenegraph_nodes_adding.html index 81a4d6f8..38cbef85 100644 --- a/demos/nodes-adding.html +++ b/examples/scenegraph_nodes_adding.html @@ -25,7 +25,7 @@ // Point SceneJS to the bundled plugins SceneJS.setConfigs({ - pluginPath:"../api/latest/plugins" + pluginPath: "../api/latest/plugins" }); // Create scene @@ -34,54 +34,60 @@ // Add mouse-orbited camera, implemented by plugin at // http://scenejs.org/api/latest/plugins/node/cameras/orbit.js scene.addNode({ - type:"cameras/orbit", - yaw:30, - pitch:-30, - zoom:5, - zoomSensitivity:10.0 - }, - - // The 'cameras/orbit' node is instantiated from an asynchronously-loaded plugin, - // so we need to get the node instance via callback. + type: "cameras/orbit", + yaw: 30, + pitch: -30, + zoom: 7, + zoomSensitivity: 1.0, + + nodes: [ + + // We can't use #addNode to add nodes to a "cameras/orbit" node, + // so we'll insert this container node that we can get by ID + { + id: "content" + } + ] + }); - function (cameraOrbit) { + scene.getNode("content", + function (content) { // Create blue torus - var material = cameraOrbit.addNode({ - type:"material", - color:{ r:0.2, g:0.2, b:0.6 } + var material = content.addNode({ + type: "material", + color: { r: 0.2, g: 0.2, b: 0.6 } }); var translate = material.addNode({ - type:"translate", - x:-4 + type: "translate", + x: -2 }); + // Torus primitive, implemented by plugin at + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js var geometry = translate.addNode({ - type:"geometry", - source:{ - type:"torus" - } + type: "geometry/torus" }); // Create red torus - var material2 = scene.addNode({ - type:"material", - color:{ r:0.6, g:0.2, b:0.2 } + var material2 = content.addNode({ + type: "material", + color: { r: 0.6, g: 0.2, b: 0.2 } }); // This time we'll add a subgraph of nodes + material2.addNode({ + type: "translate", + x: 2, + nodes: [ - material.addNode({ - type:"translate", - x:4, - nodes:[ - // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // Torus primitive, implemented by plugin at + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type:"prims/torus" + type: "geometry/torus" } ] }); diff --git a/demos/node-events-rendered.html b/examples/scenegraph_nodes_events_rendered.html similarity index 95% rename from demos/node-events-rendered.html rename to examples/scenegraph_nodes_events_rendered.html index f0a9d420..77bf6fb1 100644 --- a/demos/node-events-rendered.html +++ b/examples/scenegraph_nodes_events_rendered.html @@ -106,7 +106,7 @@ // Point SceneJS to the bundled plugins SceneJS.setConfigs({ - pluginPath:"../../../api/latest/plugins" + pluginPath:"../api/latest/plugins" }); var scene = SceneJS.createScene({ @@ -132,9 +132,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } @@ -151,9 +151,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } @@ -170,9 +170,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/examples/scenegraph_nodes_instancing.html b/examples/scenegraph_nodes_instancing.html new file mode 100644 index 00000000..3a57b7aa --- /dev/null +++ b/examples/scenegraph_nodes_instancing.html @@ -0,0 +1,183 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/nodes-moving.html b/examples/scenegraph_nodes_moving.html similarity index 94% rename from demos/nodes-moving.html rename to examples/scenegraph_nodes_moving.html index 913f47cb..b5ea76da 100644 --- a/demos/nodes-moving.html +++ b/examples/scenegraph_nodes_moving.html @@ -60,9 +60,9 @@ }); // Torus primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js translate.addNode({ - type: "prims/torus", + type: "geometry/torus", id: "myTorus" }); @@ -83,9 +83,9 @@ }); // Sphere primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js translate2.addNode({ - type: "prims/sphere", + type: "geometry/sphere", id: "mySphere" }); diff --git a/demos/culling-regex.html b/examples/scenegraph_tags.html similarity index 93% rename from demos/culling-regex.html rename to examples/scenegraph_tags.html index 8885066e..87032d18 100644 --- a/demos/culling-regex.html +++ b/examples/scenegraph_tags.html @@ -64,9 +64,9 @@ nodes:[ // Box primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } @@ -91,9 +91,9 @@ nodes:[ // Sphere geometry node implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type:"prims/sphere" + type:"geometry/sphere" } ] } @@ -123,9 +123,9 @@ nodes:[ // Node type implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } @@ -152,9 +152,9 @@ nodes:[ // Node type implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type:"prims/torus" + type:"geometry/torus" } ] } diff --git a/examples/scenegraph_webglContextRecovery.html b/examples/scenegraph_webglContextRecovery.html new file mode 100644 index 00000000..5f5e22d6 --- /dev/null +++ b/examples/scenegraph_webglContextRecovery.html @@ -0,0 +1,425 @@ + + + + SceneJS V3 Lost WebGL Context Recovery + + + + + + +
+
+ + + + + + \ No newline at end of file diff --git a/examples/setups_lawn.html b/examples/setups_lawn.html new file mode 100644 index 00000000..2c6bb2c8 --- /dev/null +++ b/examples/setups_lawn.html @@ -0,0 +1,49 @@ + + + + SceneJS Example + + + + + + + + + + + + + diff --git a/examples/setups_workshop.html b/examples/setups_workshop.html new file mode 100644 index 00000000..e8064af5 --- /dev/null +++ b/examples/setups_workshop.html @@ -0,0 +1,45 @@ + + + + SceneJS Example + + + + + + + + + + + + + diff --git a/examples/shaders_custom_material_color.html b/examples/shaders_custom_material_color.html new file mode 100644 index 00000000..5c739ffe --- /dev/null +++ b/examples/shaders_custom_material_color.html @@ -0,0 +1,87 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/shaders_custom_skybox.html b/examples/shaders_custom_skybox.html new file mode 100644 index 00000000..46edbb65 --- /dev/null +++ b/examples/shaders_custom_skybox.html @@ -0,0 +1,201 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/shaders_custom_water.html b/examples/shaders_custom_water.html new file mode 100644 index 00000000..96d755d7 --- /dev/null +++ b/examples/shaders_custom_water.html @@ -0,0 +1,105 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/shaders_custom_withTexture.html b/examples/shaders_custom_withTexture.html new file mode 100644 index 00000000..8d622f00 --- /dev/null +++ b/examples/shaders_custom_withTexture.html @@ -0,0 +1,83 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/shaders_custom_withThreeTextures.html b/examples/shaders_custom_withThreeTextures.html new file mode 100644 index 00000000..3c103ecd --- /dev/null +++ b/examples/shaders_custom_withThreeTextures.html @@ -0,0 +1,107 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/shaders_custom_withTransforms.html b/examples/shaders_custom_withTransforms.html new file mode 100644 index 00000000..f2b8e42a --- /dev/null +++ b/examples/shaders_custom_withTransforms.html @@ -0,0 +1,89 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/shaders_custom_withTwoTextures.html b/examples/shaders_custom_withTwoTextures.html new file mode 100644 index 00000000..b56111a1 --- /dev/null +++ b/examples/shaders_custom_withTwoTextures.html @@ -0,0 +1,96 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/effects-crt.html b/examples/shaders_scanline.html similarity index 86% rename from demos/effects-crt.html rename to examples/shaders_scanline.html index 77352815..c2850285 100644 --- a/demos/effects-crt.html +++ b/examples/shaders_scanline.html @@ -21,7 +21,7 @@ + + + + + + + + + + + + diff --git a/demos/skyboxes-clouds.html b/examples/skyboxes_clouds.html similarity index 87% rename from demos/skyboxes-clouds.html rename to examples/skyboxes_clouds.html index d544fb3f..e594d153 100644 --- a/demos/skyboxes-clouds.html +++ b/examples/skyboxes_clouds.html @@ -20,7 +20,7 @@ + + + + + + \ No newline at end of file diff --git a/demos/skyboxes-grimmNight.html b/examples/skyboxes_grimmNight.html similarity index 91% rename from demos/skyboxes-grimmNight.html rename to examples/skyboxes_grimmNight.html index 9e7ca7df..b9e58f4f 100644 --- a/demos/skyboxes-grimmNight.html +++ b/examples/skyboxes_grimmNight.html @@ -20,7 +20,7 @@ + + + + + + \ No newline at end of file diff --git a/examples/stages_scanlines.html b/examples/stages_scanlines.html new file mode 100644 index 00000000..e5e840df --- /dev/null +++ b/examples/stages_scanlines.html @@ -0,0 +1,184 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/stages_threeStages.html b/examples/stages_threeStages.html new file mode 100644 index 00000000..1a28f36c --- /dev/null +++ b/examples/stages_threeStages.html @@ -0,0 +1,229 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/stages_twoStages.html b/examples/stages_twoStages.html new file mode 100644 index 00000000..b20da581 --- /dev/null +++ b/examples/stages_twoStages.html @@ -0,0 +1,185 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/stages_withPicking.html b/examples/stages_withPicking.html new file mode 100644 index 00000000..57ee8fc5 --- /dev/null +++ b/examples/stages_withPicking.html @@ -0,0 +1,245 @@ + + + + SceneJS Example + + + + + + + + + + + +
Click on an object to pick it +
+ + + + \ No newline at end of file diff --git a/examples/stages_withReflection.html b/examples/stages_withReflection.html new file mode 100644 index 00000000..8df90f9c --- /dev/null +++ b/examples/stages_withReflection.html @@ -0,0 +1,185 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/stages_withSharedShader.html b/examples/stages_withSharedShader.html new file mode 100644 index 00000000..485be4ad --- /dev/null +++ b/examples/stages_withSharedShader.html @@ -0,0 +1,220 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/stages_withTransparencySort.html b/examples/stages_withTransparencySort.html new file mode 100644 index 00000000..1c072917 --- /dev/null +++ b/examples/stages_withTransparencySort.html @@ -0,0 +1,256 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/nodes-custom-drinkingBird.html b/examples/tests_drinkingBird.html similarity index 85% rename from demos/nodes-custom-drinkingBird.html rename to examples/tests_drinkingBird.html index 1e27a50c..f5ec425c 100644 --- a/demos/nodes-custom-drinkingBird.html +++ b/examples/tests_drinkingBird.html @@ -21,7 +21,7 @@ + + + + + + + \ No newline at end of file diff --git a/demos/textures-alphaMap-multiply.html b/examples/texture_alpha_multiply.html similarity index 93% rename from demos/textures-alphaMap-multiply.html rename to examples/texture_alpha_multiply.html index 4b814aa7..c3021068 100644 --- a/demos/textures-alphaMap-multiply.html +++ b/examples/texture_alpha_multiply.html @@ -1,7 +1,7 @@ - SceneJS V3 Texture Animation + SceneJS Example @@ -69,9 +69,9 @@ ], nodes:[ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } @@ -93,9 +93,9 @@ nodes:[ // Box primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } diff --git a/demos/textures-colorMap-animated.html b/examples/texture_animation.html similarity index 97% rename from demos/textures-colorMap-animated.html rename to examples/texture_animation.html index e99d2a34..dbd910c7 100644 --- a/demos/textures-colorMap-animated.html +++ b/examples/texture_animation.html @@ -79,9 +79,9 @@ nodes: [ // Box primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } diff --git a/demos/textures-bumpMap.html b/examples/texture_bump.html similarity index 91% rename from demos/textures-bumpMap.html rename to examples/texture_bump.html index b92b820e..1dade8b9 100644 --- a/demos/textures-bumpMap.html +++ b/examples/texture_bump.html @@ -66,18 +66,18 @@ type:"texture", layers:[ { - uri:"textures/normal_map.jpg", + uri:"textures/normalMap.png", wrapS:"repeat", wrapT:"repeat", - applyTo:"normals" + applyTo:"normals" // Apply to geometry normal vectors } ], nodes:[ // Box primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } diff --git a/demos/textures-colorMap.html b/examples/texture_color.html similarity index 95% rename from demos/textures-colorMap.html rename to examples/texture_color.html index 2c1c8353..9210610f 100644 --- a/demos/textures-colorMap.html +++ b/examples/texture_color.html @@ -48,9 +48,9 @@ nodes: [ // Box primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } diff --git a/demos/textures-colorMap-add.html b/examples/texture_color_add.html similarity index 95% rename from demos/textures-colorMap-add.html rename to examples/texture_color_add.html index dbbe661d..df9a3da5 100644 --- a/demos/textures-colorMap-add.html +++ b/examples/texture_color_add.html @@ -56,9 +56,9 @@ nodes: [ // Box primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } diff --git a/demos/textures-colorMap-multiply.html b/examples/texture_color_multiply.html similarity index 93% rename from demos/textures-colorMap-multiply.html rename to examples/texture_color_multiply.html index 6f59927a..b49c8d21 100644 --- a/demos/textures-colorMap-multiply.html +++ b/examples/texture_color_multiply.html @@ -54,9 +54,9 @@ nodes: [ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } diff --git a/demos/textures-glowMap.html b/examples/texture_emit.html similarity index 97% rename from demos/textures-glowMap.html rename to examples/texture_emit.html index c8c6ac5d..7518d062 100644 --- a/demos/textures-glowMap.html +++ b/examples/texture_emit.html @@ -71,9 +71,9 @@ ], nodes: [ - // Torus primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/torus.js + // Torus primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type: "prims/torus", + type: "geometry/torus", radius: 1.0, tube: 0.30, segmentsR: 60, diff --git a/demos/textures-glowMap-add.html b/examples/texture_emit_add.html similarity index 98% rename from demos/textures-glowMap-add.html rename to examples/texture_emit_add.html index 229c27c0..6d04fd2a 100644 --- a/demos/textures-glowMap-add.html +++ b/examples/texture_emit_add.html @@ -86,9 +86,9 @@ nodes:[ // Torus primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type:"prims/torus", + type:"geometry/torus", radius:1.0, tube:0.30, segmentsR:60, diff --git a/demos/textures-glowMap-multiply.html b/examples/texture_emit_multiply.html similarity index 98% rename from demos/textures-glowMap-multiply.html rename to examples/texture_emit_multiply.html index 84d8b4c2..1399322e 100644 --- a/demos/textures-glowMap-multiply.html +++ b/examples/texture_emit_multiply.html @@ -85,9 +85,9 @@ nodes:[ // Torus primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type:"prims/torus", + type:"geometry/torus", radius:1.0, tube:0.30, segmentsR:60, diff --git a/examples/texture_legacy_color.html b/examples/texture_legacy_color.html new file mode 100644 index 00000000..f243daae --- /dev/null +++ b/examples/texture_legacy_color.html @@ -0,0 +1,68 @@ + + + + SceneJS Example + + + + + + + + + + \ No newline at end of file diff --git a/examples/texture_lib_oil.html b/examples/texture_lib_oil.html new file mode 100644 index 00000000..7c61a5ec --- /dev/null +++ b/examples/texture_lib_oil.html @@ -0,0 +1,63 @@ + + + + SceneJS Example + + + + + + + + + + \ No newline at end of file diff --git a/examples/texture_lib_slime.html b/examples/texture_lib_slime.html new file mode 100644 index 00000000..00feb4bf --- /dev/null +++ b/examples/texture_lib_slime.html @@ -0,0 +1,63 @@ + + + + SceneJS Example + + + + + + + + + + \ No newline at end of file diff --git a/examples/texture_lib_tunnel.html b/examples/texture_lib_tunnel.html new file mode 100644 index 00000000..2358b2fc --- /dev/null +++ b/examples/texture_lib_tunnel.html @@ -0,0 +1,63 @@ + + + + SceneJS Example + + + + + + + + + + \ No newline at end of file diff --git a/examples/texture_lib_water.html b/examples/texture_lib_water.html new file mode 100644 index 00000000..8d71b1e4 --- /dev/null +++ b/examples/texture_lib_water.html @@ -0,0 +1,63 @@ + + + + SceneJS Example + + + + + + + + + + \ No newline at end of file diff --git a/demos/textures-multitexture.html b/examples/texture_multiTexture.html similarity index 72% rename from demos/textures-multitexture.html rename to examples/texture_multiTexture.html index 0b29f902..56ffd10f 100644 --- a/demos/textures-multitexture.html +++ b/examples/texture_multiTexture.html @@ -20,49 +20,50 @@ // Point SceneJS to the bundled plugins SceneJS.setConfigs({ - pluginPath:"../api/latest/plugins" + pluginPath: "../api/latest/plugins" }); // Create scene var scene = SceneJS.createScene({ - nodes:[ + nodes: [ // Orbiting camera node, implemented by plugin at // http://scenejs.org/api/latest/plugins/node/cameras/orbit.js { - type:"cameras/orbit", - yaw:30, - pitch:-30, - zoom:10, - zoomSensitivity:1.0, + type: "cameras/orbit", + yaw: 30, + pitch: -30, + zoom: 7, + zoomSensitivity: 1.0, - nodes:[ + nodes: [ // Custom lighting to simulate the Sun { - type:"lights", - lights:[ + type: "lights", + lights: [ { - mode:"dir", - color:{ r:1.0, g:1.0, b:1.0 }, - diffuse:true, - specular:true, - dir:{ x:-0.5, y:-0.5, z:-0.75 } + mode: "dir", + color: { r: 1.0, g: 1.0, b: 1.0 }, + diffuse: true, + specular: true, + dir: { x: -0.5, y: -0.5, z: -0.75 } } ], - nodes:[ + nodes: [ { - type:"rotate", - z:1, - angle:195, - nodes:[ + type: "rotate", + z: 1, + angle: 195, + + nodes: [ { - type:"rotate", - y:1, - id:"earth-rotate", + type: "rotate", + y: 1, + id: "earth-rotate", - nodes:[ + nodes: [ // Layer 0: Earth's surface with color, specular // and emissive maps @@ -70,53 +71,62 @@ // The priority on this layer ensure that it's rendered before the // clouds in the second layer { - type:"layer", - priority:0, + type: "layer", + priority: 0, enabled: true, - nodes:[ + nodes: [ { - type:"scale", - x:2, - y:2, - z:2, + type: "scale", + x: 2, + y: 2, + z: 2, - nodes:[ + nodes: [ { - type:"material", - emit:1, - color:{ r:1.0, g:1.0, b:1.0 }, - specularColor:{ r:0.5, g:0.5, b:0.5 }, - specular:5.0, - shine:70.0, + type: "material", + emit: 1, + color: { r: 1.0, g: 1.0, b: 1.0 }, + specularColor: { r: 0.5, g: 0.5, b: 0.5 }, + specular: 5.0, + shine: 70.0, - nodes:[ + nodes: [ - // Multitexture containing color, specular and emission maps + // Color map { - type:"texture", - layers:[ - { - src:"textures/earth.jpg", - applyTo:"color" // Apply to material "color" property (default) - }, - { - src:"textures/earth-specular.png", - applyTo:"specular" // Apply to material "specular" property - } , - { - src:"textures/earth-lights.gif", - applyTo:"emit" // Apply to material "emit" property - } - ], - nodes:[ + type: "textureMap", + src: "textures/earth.jpg", + applyTo: "color", - // Sphere geometry node implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + nodes: [ + + // Specular map for shiny oceans { - type:"prims/sphere", - latitudeBands:120, - longitudeBands:120 + type: "textureMap", + src: "textures/earth-specular.png", + applyTo: "specular", + + nodes: [ + + // Glow map for lights on night side + { + type: "textureMap", + src: "textures/earth-lights.gif", + applyTo: "emit", + + nodes: [ + + // Sphere geometry node implemented by plugin at + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js + { + type: "geometry/sphere", + latitudeBands: 120, + longitudeBands: 120 + } + ] + } + ] } ] } @@ -131,63 +141,59 @@ // The priority on this this layer ensures that it's rendered after the // Earth surface in the previously-defined layer { - type:"layer", - priority:1, + type: "layer", + priority: 1, - nodes:[ + nodes: [ // Flags to enable cloud transparency { - type:"flags", - flags:{ - transparent:true, - specular:true + type: "flags", + flags: { + transparent: true, + specular: true }, - nodes:[ + nodes: [ // Material with alpha channel { - type:"material", - emit:0.1, - alpha:0.7, - color:{ r:1, g:1, b:1 }, - specularColor:{ r:1.0, g:1.0, b:1.0 }, - specular:0.5, - shine:1.0, - nodes:[ + type: "material", + emit: 0.1, + alpha: 0.7, + color: { r: 1, g: 1, b: 1 }, + specularColor: { r: 1.0, g: 1.0, b: 1.0 }, + specular: 0.5, + shine: 1.0, + nodes: [ { - type:"scale", - x:2.05, - y:2.05, - z:2.05, + type: "scale", + x: 2.05, + y: 2.05, + z: 2.05, - nodes:[ + nodes: [ // Alpha map for clouds { - type:"texture", - layers:[ - { - src:"textures/earthclouds.jpg", - applyTo:"alpha", // Apply to material "alpha" property - flipY:false - } - ], + type: "textureMap", + src: "textures/earthclouds.jpg", + applyTo: "alpha", // Apply to material "alpha" property + flipY: false, - nodes:[ + nodes: [ { - type:"rotate", - y:1, - id:"clouds-rotate", - nodes:[ + type: "rotate", + y: 1, + id: "clouds-rotate", + nodes: [ // Sphere geometry node implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type:"prims/sphere", - latitudeBands:120, - longitudeBands:120 + type: "geometry/sphere", + latitudeBands: 120, + longitudeBands: 120 } ] diff --git a/examples/texture_procedural.html b/examples/texture_procedural.html new file mode 100644 index 00000000..35b88ed6 --- /dev/null +++ b/examples/texture_procedural.html @@ -0,0 +1,82 @@ + + + + SceneJS Example + + + + + + + + + + \ No newline at end of file diff --git a/examples/texture_procedural_alpha.html b/examples/texture_procedural_alpha.html new file mode 100644 index 00000000..470a238f --- /dev/null +++ b/examples/texture_procedural_alpha.html @@ -0,0 +1,130 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/texture_procedural_color.html b/examples/texture_procedural_color.html new file mode 100644 index 00000000..1977842d --- /dev/null +++ b/examples/texture_procedural_color.html @@ -0,0 +1,93 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/texture_procedural_color_mold.html b/examples/texture_procedural_color_mold.html new file mode 100644 index 00000000..2d4fe44e --- /dev/null +++ b/examples/texture_procedural_color_mold.html @@ -0,0 +1,93 @@ + + + + SceneJS Example + + + + + + + + + + \ No newline at end of file diff --git a/examples/texture_procedural_color_water.html b/examples/texture_procedural_color_water.html new file mode 100644 index 00000000..8b47f689 --- /dev/null +++ b/examples/texture_procedural_color_water.html @@ -0,0 +1,83 @@ + + + + SceneJS Example + + + + + + + + + + \ No newline at end of file diff --git a/examples/texture_procedural_emit.html b/examples/texture_procedural_emit.html new file mode 100644 index 00000000..a5255087 --- /dev/null +++ b/examples/texture_procedural_emit.html @@ -0,0 +1,116 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/texture_procedural_specular.html b/examples/texture_procedural_specular.html new file mode 100644 index 00000000..69370450 --- /dev/null +++ b/examples/texture_procedural_specular.html @@ -0,0 +1,118 @@ + + + + SceneJS Example + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/texture_rtt.html b/examples/texture_rtt.html new file mode 100644 index 00000000..16675e55 --- /dev/null +++ b/examples/texture_rtt.html @@ -0,0 +1,168 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/texture_rtt_color.html b/examples/texture_rtt_color.html new file mode 100644 index 00000000..d6aaebe2 --- /dev/null +++ b/examples/texture_rtt_color.html @@ -0,0 +1,167 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/texture_rtt_depth.html b/examples/texture_rtt_depth.html new file mode 100644 index 00000000..1c4d45df --- /dev/null +++ b/examples/texture_rtt_depth.html @@ -0,0 +1,169 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/texture_rtt_depthAndColor.html b/examples/texture_rtt_depthAndColor.html new file mode 100644 index 00000000..35d6e40a --- /dev/null +++ b/examples/texture_rtt_depthAndColor.html @@ -0,0 +1,232 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/texture_rtt_depthAndColor2.html b/examples/texture_rtt_depthAndColor2.html new file mode 100644 index 00000000..fb12ef22 --- /dev/null +++ b/examples/texture_rtt_depthAndColor2.html @@ -0,0 +1,242 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/textures-rtt-heightmap.html b/examples/texture_rtt_heightmap.html similarity index 70% rename from demos/textures-rtt-heightmap.html rename to examples/texture_rtt_heightmap.html index 040de841..07886dde 100644 --- a/demos/textures-rtt-heightmap.html +++ b/examples/texture_rtt_heightmap.html @@ -20,6 +20,16 @@ + + + + + + \ No newline at end of file diff --git a/demos/textures-rtt-shared-texture.html b/examples/texture_rtt_sharedTexture.html similarity index 84% rename from demos/textures-rtt-shared-texture.html rename to examples/texture_rtt_sharedTexture.html index 2fe4e676..874598e6 100644 --- a/demos/textures-rtt-shared-texture.html +++ b/examples/texture_rtt_sharedTexture.html @@ -29,35 +29,27 @@ nodes: [ //------------------------------------------------------------------------------------------- - // First subgraph renders our rotating teapot, with skybox, to a texture. - // - // The subgraph is wrapped in an framebuf node, which captures each frame the subgraph - // renders and makes it available by ID as an image source for the texture node defined in the - // second subgraph, defined further down in this example. - // - // We're also wrapping it in a "layer" node with a low rendering priority to ensure that - // it renders first, so that the framebuf is ready for the textures that need it. - // - // The framebuf captures the frames to a hidden frame buffer, so they will not render by - // themselves and will only be visible via the texture. + // First pass renders our rotating teapot, with skybox, to a texture. + //------------------------------------------------------------------------------------------ { type: "layer", - priority: 0, + priority: 1, + nodes: [ { - type: "framebuf", - id: "myFrameBuf", + type: "colorTarget", + id: "myColorTarget", nodes: [ - // Cloudy sea skybox, implemented by plugin at http://scenejs.org/api/latest/plugins/node/skyboxes/cloudySea.js + // Cloudy sea skybox, implemented by plugin at http://scenejs.org/api/latest/plugins/node/skybox/cloudySea.js // Skybox, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/skyboxes/grimmNight.js + // http://scenejs.org/api/latest/plugins/node/skybox/grimmNight.js { - type: "skyboxes/cloudySea", + type: "skybox/cloudySea", size: 5000 // Box half-size on each axis - default is 5000 }, { @@ -87,9 +79,9 @@ nodes: [ // Node type implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type: "prims/teapot" + type: "geometry/teapot" } ] } @@ -100,19 +92,16 @@ ] } ] - }, //------------------------------------------------------------------------------------------- // The second subgraph renders four geometry primitives, all wrapped with a shared texture - // that is dynamically sourced from the framebuf defined in the subgraph above. - // - // We also wrap the whole subgraph in a "layer" node that has a lower priority than the - // "layer" wrapped around the framebuf's subgraph. + // that is dynamically sourced from the colorTarget defined in the subgraph above. //------------------------------------------------------------------------------------------*/ + { type: "layer", - priority: 1, + priority: 2, nodes: [ @@ -127,11 +116,11 @@ nodes: [ - // Color map texture, sourcing from the framebuf created earlier, + // Color map texture, sourcing from the colorTarget created earlier, // applying to the four geometry primitives in its subgraph { type: "textureMap", - framebuf: "myFrameBuf", + target: "myColorTarget", nodes: [ @@ -153,9 +142,9 @@ nodes: [ // Box primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -187,9 +176,9 @@ nodes: [ // Sphere primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type: "prims/sphere" + type: "geometry/sphere" } ] } @@ -222,9 +211,9 @@ nodes: [ // Torus primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type: "prims/torus" + type: "geometry/torus" } ] } @@ -251,9 +240,9 @@ nodes: [ // Cylinder primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/cylinder.js + // http://scenejs.org/api/latest/plugins/node/geometry/cylinder.js { - type: "prims/cylinder" + type: "geometry/cylinder" } ] } diff --git a/examples/texture_rtt_withVideo.html b/examples/texture_rtt_withVideo.html new file mode 100644 index 00000000..b0a70651 --- /dev/null +++ b/examples/texture_rtt_withVideo.html @@ -0,0 +1,176 @@ + + + + SceneJS Example + + + + + + + + + + + + \ No newline at end of file diff --git a/demos/textures-specularMap.html b/examples/texture_specular.html similarity index 96% rename from demos/textures-specularMap.html rename to examples/texture_specular.html index 0d47717b..2e1529f5 100644 --- a/demos/textures-specularMap.html +++ b/examples/texture_specular.html @@ -82,9 +82,9 @@ nodes: [ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type: "prims/torus" + type: "geometry/torus" } ] } diff --git a/demos/textures-specularMap-add.html b/examples/texture_specular_add.html similarity index 96% rename from demos/textures-specularMap-add.html rename to examples/texture_specular_add.html index 6e1968e5..51676209 100644 --- a/demos/textures-specularMap-add.html +++ b/examples/texture_specular_add.html @@ -83,9 +83,9 @@ nodes:[ // Torus primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type:"prims/torus" + type:"geometry/torus" } ] } diff --git a/demos/textures-specularMap-multiply.html b/examples/texture_specular_multiply.html similarity index 96% rename from demos/textures-specularMap-multiply.html rename to examples/texture_specular_multiply.html index 87505b4c..11904bed 100644 --- a/demos/textures-specularMap-multiply.html +++ b/examples/texture_specular_multiply.html @@ -84,9 +84,9 @@ nodes:[ // Torus primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type:"prims/torus" + type:"geometry/torus" } ] } diff --git a/examples/texture_uvLayers.html b/examples/texture_uvLayers.html new file mode 100644 index 00000000..6210cd51 --- /dev/null +++ b/examples/texture_uvLayers.html @@ -0,0 +1,115 @@ + + + + SceneJS Example + + + + + + + + + + \ No newline at end of file diff --git a/demos/textures-video-alphaMap.html b/examples/texture_video_alpha.html similarity index 91% rename from demos/textures-video-alphaMap.html rename to examples/texture_video_alpha.html index 7b493822..73c32a5b 100644 --- a/demos/textures-video-alphaMap.html +++ b/examples/texture_video_alpha.html @@ -55,18 +55,18 @@ nodes: [ // Video texture, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/textures/video.js + // http://scenejs.org/api/latest/plugins/node/texture/video.js { - type: "textures/video", + type: "texture/video", src: "movies/testVideo.ogv", applyTo: "alpha", nodes: [ // Box primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -88,9 +88,9 @@ nodes: [ // Box primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } diff --git a/demos/textures-video-bumpMap.html b/examples/texture_video_bump.html similarity index 92% rename from demos/textures-video-bumpMap.html rename to examples/texture_video_bump.html index 182f9a0e..a119c325 100644 --- a/demos/textures-video-bumpMap.html +++ b/examples/texture_video_bump.html @@ -63,9 +63,9 @@ nodes: [ // Video texture, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/textures/video.js + // http://scenejs.org/api/latest/plugins/node/texture/video.js { - type: "textures/video", + type: "texture/video", src: "movies/bumpMap.ogg", wrapS: "repeat", wrapT: "repeat", @@ -73,9 +73,9 @@ nodes: [ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } diff --git a/demos/textures-video-colorMap.html b/examples/texture_video_color.html similarity index 91% rename from demos/textures-video-colorMap.html rename to examples/texture_video_color.html index 2a7cd2a8..7662c210 100644 --- a/demos/textures-video-colorMap.html +++ b/examples/texture_video_color.html @@ -39,17 +39,17 @@ nodes: [ // Video texture, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/textures/video.js + // http://scenejs.org/api/latest/plugins/node/texture/video.js { - type: "textures/video", + type: "texture/video", src: "movies/bunny.ogg", nodes: [ // Box primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } diff --git a/demos/textures-video-glowMap.html b/examples/texture_video_emit.html similarity index 93% rename from demos/textures-video-glowMap.html rename to examples/texture_video_emit.html index 94571ce1..3310b729 100644 --- a/demos/textures-video-glowMap.html +++ b/examples/texture_video_emit.html @@ -60,17 +60,17 @@ nodes: [ // Video texture, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/textures/video.js + // http://scenejs.org/api/latest/plugins/node/texture/video.js { - type: "textures/video", + type: "texture/video", src: "movies/testVideo.ogv", applyTo: "emit", nodes: [ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } diff --git a/demos/textures-video-specularMap.html b/examples/texture_video_specular.html similarity index 94% rename from demos/textures-video-specularMap.html rename to examples/texture_video_specular.html index 8fb1a7b6..0d4acae4 100644 --- a/demos/textures-video-specularMap.html +++ b/examples/texture_video_specular.html @@ -76,17 +76,17 @@ nodes: [ // Video texture, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/textures/video.js + // http://scenejs.org/api/latest/plugins/node/texture/video.js { - type: "textures/video", + type: "texture/video", src: "movies/testVideo.ogv", applyTo: "specular", nodes: [ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } diff --git a/demos/textures/BrickWall.jpg b/examples/textures/BrickWall.jpg similarity index 100% rename from demos/textures/BrickWall.jpg rename to examples/textures/BrickWall.jpg diff --git a/demos/textures/MediumCloud.png b/examples/textures/MediumCloud.png similarity index 100% rename from demos/textures/MediumCloud.png rename to examples/textures/MediumCloud.png diff --git a/demos/textures/alphaMap.jpg b/examples/textures/alphaMap.jpg similarity index 100% rename from demos/textures/alphaMap.jpg rename to examples/textures/alphaMap.jpg diff --git a/demos/textures/asteroidBump.jpg b/examples/textures/asteroidBump.jpg similarity index 100% rename from demos/textures/asteroidBump.jpg rename to examples/textures/asteroidBump.jpg diff --git a/demos/textures/asteroidColor.jpg b/examples/textures/asteroidColor.jpg similarity index 100% rename from demos/textures/asteroidColor.jpg rename to examples/textures/asteroidColor.jpg diff --git a/demos/textures/asteroidNormal.jpg b/examples/textures/asteroidNormal.jpg similarity index 100% rename from demos/textures/asteroidNormal.jpg rename to examples/textures/asteroidNormal.jpg diff --git a/demos/textures/chainLinkAlphaMap.jpg b/examples/textures/chainLinkAlphaMap.jpg similarity index 100% rename from demos/textures/chainLinkAlphaMap.jpg rename to examples/textures/chainLinkAlphaMap.jpg diff --git a/demos/textures/city/HighRiseGlass.jpg b/examples/textures/city/HighRiseGlass.jpg similarity index 100% rename from demos/textures/city/HighRiseGlass.jpg rename to examples/textures/city/HighRiseGlass.jpg diff --git a/demos/textures/city/HighRiseGlassSpecular.jpg b/examples/textures/city/HighRiseGlassSpecular.jpg similarity index 100% rename from demos/textures/city/HighRiseGlassSpecular.jpg rename to examples/textures/city/HighRiseGlassSpecular.jpg diff --git a/demos/textures/city/highrise-windows.jpg b/examples/textures/city/highrise-windows.jpg similarity index 100% rename from demos/textures/city/highrise-windows.jpg rename to examples/textures/city/highrise-windows.jpg diff --git a/demos/textures/city/pixelcity_windows7.jpg b/examples/textures/city/pixelcity_windows7.jpg similarity index 100% rename from demos/textures/city/pixelcity_windows7.jpg rename to examples/textures/city/pixelcity_windows7.jpg diff --git a/demos/textures/cloud.jpg b/examples/textures/cloud.jpg similarity index 100% rename from demos/textures/cloud.jpg rename to examples/textures/cloud.jpg diff --git a/demos/textures/cloud.png b/examples/textures/cloud.png similarity index 100% rename from demos/textures/cloud.png rename to examples/textures/cloud.png diff --git a/demos/textures/clouds-box.jpg b/examples/textures/clouds-box.jpg similarity index 100% rename from demos/textures/clouds-box.jpg rename to examples/textures/clouds-box.jpg diff --git a/demos/textures/clouds.jpg b/examples/textures/clouds.jpg similarity index 100% rename from demos/textures/clouds.jpg rename to examples/textures/clouds.jpg diff --git a/demos/textures/cloudsBackground.jpg b/examples/textures/cloudsBackground.jpg similarity index 100% rename from demos/textures/cloudsBackground.jpg rename to examples/textures/cloudsBackground.jpg diff --git a/demos/textures/compressed/test-dxt1.crn b/examples/textures/compressed/test-dxt1.crn similarity index 100% rename from demos/textures/compressed/test-dxt1.crn rename to examples/textures/compressed/test-dxt1.crn diff --git a/demos/textures/compressed/test-dxt1.dds b/examples/textures/compressed/test-dxt1.dds similarity index 100% rename from demos/textures/compressed/test-dxt1.dds rename to examples/textures/compressed/test-dxt1.dds diff --git a/demos/textures/compressed/test-dxt5.crn b/examples/textures/compressed/test-dxt5.crn similarity index 100% rename from demos/textures/compressed/test-dxt5.crn rename to examples/textures/compressed/test-dxt5.crn diff --git a/demos/textures/compressed/test-dxt5.dds b/examples/textures/compressed/test-dxt5.dds similarity index 100% rename from demos/textures/compressed/test-dxt5.dds rename to examples/textures/compressed/test-dxt5.dds diff --git a/demos/textures/compressed/test.bmp b/examples/textures/compressed/test.bmp similarity index 100% rename from demos/textures/compressed/test.bmp rename to examples/textures/compressed/test.bmp diff --git a/demos/textures/compressed/test.gif b/examples/textures/compressed/test.gif similarity index 100% rename from demos/textures/compressed/test.gif rename to examples/textures/compressed/test.gif diff --git a/demos/textures/compressed/test.jpg b/examples/textures/compressed/test.jpg similarity index 100% rename from demos/textures/compressed/test.jpg rename to examples/textures/compressed/test.jpg diff --git a/demos/textures/compressed/test.png b/examples/textures/compressed/test.png similarity index 100% rename from demos/textures/compressed/test.png rename to examples/textures/compressed/test.png diff --git a/demos/textures/compressed/test.tga b/examples/textures/compressed/test.tga similarity index 100% rename from demos/textures/compressed/test.tga rename to examples/textures/compressed/test.tga diff --git a/demos/textures/crossGridSpecularMap.jpg b/examples/textures/crossGridSpecularMap.jpg similarity index 100% rename from demos/textures/crossGridSpecularMap.jpg rename to examples/textures/crossGridSpecularMap.jpg diff --git a/demos/textures/earth-lights.gif b/examples/textures/earth-lights.gif similarity index 100% rename from demos/textures/earth-lights.gif rename to examples/textures/earth-lights.gif diff --git a/demos/textures/earth-specular.gif b/examples/textures/earth-specular.gif similarity index 100% rename from demos/textures/earth-specular.gif rename to examples/textures/earth-specular.gif diff --git a/demos/textures/earth-specular.jpg b/examples/textures/earth-specular.jpg similarity index 100% rename from demos/textures/earth-specular.jpg rename to examples/textures/earth-specular.jpg diff --git a/demos/textures/earth-specular.png b/examples/textures/earth-specular.png similarity index 100% rename from demos/textures/earth-specular.png rename to examples/textures/earth-specular.png diff --git a/demos/textures/earth.jpg b/examples/textures/earth.jpg similarity index 100% rename from demos/textures/earth.jpg rename to examples/textures/earth.jpg diff --git a/demos/textures/earthBump.jpg b/examples/textures/earthBump.jpg similarity index 100% rename from demos/textures/earthBump.jpg rename to examples/textures/earthBump.jpg diff --git a/demos/textures/earthclouds.jpg b/examples/textures/earthclouds.jpg similarity index 100% rename from demos/textures/earthclouds.jpg rename to examples/textures/earthclouds.jpg diff --git a/demos/textures/general-zod.jpg b/examples/textures/general-zod.jpg similarity index 100% rename from demos/textures/general-zod.jpg rename to examples/textures/general-zod.jpg diff --git a/demos/textures/grid.jpg b/examples/textures/grid.jpg similarity index 100% rename from demos/textures/grid.jpg rename to examples/textures/grid.jpg diff --git a/demos/textures/heightMap.jpg b/examples/textures/heightMap.jpg similarity index 100% rename from demos/textures/heightMap.jpg rename to examples/textures/heightMap.jpg diff --git a/demos/textures/heightmap.jpg b/examples/textures/heightmap.jpg similarity index 100% rename from demos/textures/heightmap.jpg rename to examples/textures/heightmap.jpg diff --git a/demos/textures/heightmap.png b/examples/textures/heightmap.png similarity index 100% rename from demos/textures/heightmap.png rename to examples/textures/heightmap.png diff --git a/examples/textures/holodeck/bottom.jpg b/examples/textures/holodeck/bottom.jpg new file mode 100644 index 00000000..5f7358b9 Binary files /dev/null and b/examples/textures/holodeck/bottom.jpg differ diff --git a/examples/textures/holodeck/east.jpg b/examples/textures/holodeck/east.jpg new file mode 100644 index 00000000..fce7f5af Binary files /dev/null and b/examples/textures/holodeck/east.jpg differ diff --git a/examples/textures/holodeck/north.jpg b/examples/textures/holodeck/north.jpg new file mode 100644 index 00000000..5d768d89 Binary files /dev/null and b/examples/textures/holodeck/north.jpg differ diff --git a/examples/textures/holodeck/south.jpg b/examples/textures/holodeck/south.jpg new file mode 100644 index 00000000..fb728e30 Binary files /dev/null and b/examples/textures/holodeck/south.jpg differ diff --git a/examples/textures/holodeck/top.jpg b/examples/textures/holodeck/top.jpg new file mode 100644 index 00000000..facca573 Binary files /dev/null and b/examples/textures/holodeck/top.jpg differ diff --git a/examples/textures/holodeck/west.jpg b/examples/textures/holodeck/west.jpg new file mode 100644 index 00000000..ab2b61b6 Binary files /dev/null and b/examples/textures/holodeck/west.jpg differ diff --git a/demos/textures/leavesAlphaMap.jpg b/examples/textures/leavesAlphaMap.jpg similarity index 100% rename from demos/textures/leavesAlphaMap.jpg rename to examples/textures/leavesAlphaMap.jpg diff --git a/demos/textures/leavesSpecularMap.jpg b/examples/textures/leavesSpecularMap.jpg similarity index 100% rename from demos/textures/leavesSpecularMap.jpg rename to examples/textures/leavesSpecularMap.jpg diff --git a/demos/textures/milky-way.gif b/examples/textures/milky-way.gif similarity index 100% rename from demos/textures/milky-way.gif rename to examples/textures/milky-way.gif diff --git a/examples/textures/normalMap.png b/examples/textures/normalMap.png new file mode 100644 index 00000000..e5b3f454 Binary files /dev/null and b/examples/textures/normalMap.png differ diff --git a/demos/textures/normal_map.jpg b/examples/textures/normal_map.jpg similarity index 100% rename from demos/textures/normal_map.jpg rename to examples/textures/normal_map.jpg diff --git a/demos/textures/oilySheen.jpg b/examples/textures/oilySheen.jpg similarity index 100% rename from demos/textures/oilySheen.jpg rename to examples/textures/oilySheen.jpg diff --git a/demos/textures/pattern.jpg b/examples/textures/pattern.jpg similarity index 100% rename from demos/textures/pattern.jpg rename to examples/textures/pattern.jpg diff --git a/api/latest/plugins/node/reflections/textures/clouds/a.png b/examples/textures/reflection/clouds/a.png similarity index 100% rename from api/latest/plugins/node/reflections/textures/clouds/a.png rename to examples/textures/reflection/clouds/a.png diff --git a/api/latest/plugins/node/reflections/textures/clouds/b.png b/examples/textures/reflection/clouds/b.png similarity index 100% rename from api/latest/plugins/node/reflections/textures/clouds/b.png rename to examples/textures/reflection/clouds/b.png diff --git a/api/latest/plugins/node/reflections/textures/clouds/bottom.png b/examples/textures/reflection/clouds/bottom.png similarity index 100% rename from api/latest/plugins/node/reflections/textures/clouds/bottom.png rename to examples/textures/reflection/clouds/bottom.png diff --git a/api/latest/plugins/node/reflections/textures/clouds/c.png b/examples/textures/reflection/clouds/c.png similarity index 100% rename from api/latest/plugins/node/reflections/textures/clouds/c.png rename to examples/textures/reflection/clouds/c.png diff --git a/api/latest/plugins/node/reflections/textures/clouds/d.png b/examples/textures/reflection/clouds/d.png similarity index 100% rename from api/latest/plugins/node/reflections/textures/clouds/d.png rename to examples/textures/reflection/clouds/d.png diff --git a/api/latest/plugins/node/reflections/textures/clouds/top.png b/examples/textures/reflection/clouds/top.png similarity index 100% rename from api/latest/plugins/node/reflections/textures/clouds/top.png rename to examples/textures/reflection/clouds/top.png diff --git a/api/latest/plugins/node/reflections/textures/london/neg-x.png b/examples/textures/reflection/london/neg-x.png similarity index 100% rename from api/latest/plugins/node/reflections/textures/london/neg-x.png rename to examples/textures/reflection/london/neg-x.png diff --git a/api/latest/plugins/node/reflections/textures/london/neg-y.png b/examples/textures/reflection/london/neg-y.png similarity index 100% rename from api/latest/plugins/node/reflections/textures/london/neg-y.png rename to examples/textures/reflection/london/neg-y.png diff --git a/api/latest/plugins/node/reflections/textures/london/neg-z.png b/examples/textures/reflection/london/neg-z.png similarity index 100% rename from api/latest/plugins/node/reflections/textures/london/neg-z.png rename to examples/textures/reflection/london/neg-z.png diff --git a/api/latest/plugins/node/reflections/textures/london/pos-x.png b/examples/textures/reflection/london/pos-x.png similarity index 100% rename from api/latest/plugins/node/reflections/textures/london/pos-x.png rename to examples/textures/reflection/london/pos-x.png diff --git a/api/latest/plugins/node/reflections/textures/london/pos-y.png b/examples/textures/reflection/london/pos-y.png similarity index 100% rename from api/latest/plugins/node/reflections/textures/london/pos-y.png rename to examples/textures/reflection/london/pos-y.png diff --git a/api/latest/plugins/node/reflections/textures/london/pos-z.png b/examples/textures/reflection/london/pos-z.png similarity index 100% rename from api/latest/plugins/node/reflections/textures/london/pos-z.png rename to examples/textures/reflection/london/pos-z.png diff --git a/demos/textures/reflectionSpecularMap1.jpg b/examples/textures/reflectionSpecularMap1.jpg similarity index 100% rename from demos/textures/reflectionSpecularMap1.jpg rename to examples/textures/reflectionSpecularMap1.jpg diff --git a/demos/textures/reflectionSpecularMap2.jpg b/examples/textures/reflectionSpecularMap2.jpg similarity index 100% rename from demos/textures/reflectionSpecularMap2.jpg rename to examples/textures/reflectionSpecularMap2.jpg diff --git a/demos/textures/reflectionSpecularMap3.jpg b/examples/textures/reflectionSpecularMap3.jpg similarity index 100% rename from demos/textures/reflectionSpecularMap3.jpg rename to examples/textures/reflectionSpecularMap3.jpg diff --git a/demos/textures/sand.jpg b/examples/textures/sand.jpg similarity index 100% rename from demos/textures/sand.jpg rename to examples/textures/sand.jpg diff --git a/demos/textures/superman.jpg b/examples/textures/superman.jpg similarity index 100% rename from demos/textures/superman.jpg rename to examples/textures/superman.jpg diff --git a/demos/textures/texture-atlas.jpg b/examples/textures/texture-atlas.jpg similarity index 100% rename from demos/textures/texture-atlas.jpg rename to examples/textures/texture-atlas.jpg diff --git a/demos/textures/weirdAlphaMap.gif b/examples/textures/weirdAlphaMap.gif similarity index 100% rename from demos/textures/weirdAlphaMap.gif rename to examples/textures/weirdAlphaMap.gif diff --git a/demos/textures/weirdGlowMap.jpg b/examples/textures/weirdGlowMap.jpg similarity index 100% rename from demos/textures/weirdGlowMap.jpg rename to examples/textures/weirdGlowMap.jpg diff --git a/demos/transforms-model-hierarchy.html b/examples/transforms_modelling_hierarchy.html similarity index 95% rename from demos/transforms-model-hierarchy.html rename to examples/transforms_modelling_hierarchy.html index f1943f36..f30baaa7 100644 --- a/demos/transforms-model-hierarchy.html +++ b/examples/transforms_modelling_hierarchy.html @@ -68,9 +68,9 @@ nodes: [ - // Box primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -93,9 +93,9 @@ nodes: [ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -118,9 +118,9 @@ nodes: [ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -143,9 +143,9 @@ nodes: [ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -168,9 +168,9 @@ nodes: [ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type: "prims/box" + type: "geometry/box" } ] } @@ -204,7 +204,7 @@ nodes: [ { - type: "prims/torus" + type: "geometry/torus" } ] } @@ -233,7 +233,7 @@ nodes: [ { - type: "prims/torus" + type: "geometry/torus" } ] } @@ -262,7 +262,7 @@ nodes: [ { - type: "prims/torus" + type: "geometry/torus" } ] } @@ -291,7 +291,7 @@ nodes: [ { - type: "prims/torus" + type: "geometry/torus" } ] } @@ -323,9 +323,9 @@ nodes: [ - // Node type implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // Node type implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type: "prims/teapot" + type: "geometry/teapot" } ] } @@ -356,9 +356,9 @@ nodes: [ - // Sphere geometry node implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // Sphere geometry node implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type: "prims/sphere" + type: "geometry/sphere" } ] } diff --git a/demos/transforms-model-matrix.html b/examples/transforms_modelling_matrix.html similarity index 96% rename from demos/transforms-model-matrix.html rename to examples/transforms_modelling_matrix.html index de26bff4..0ef4b0e3 100644 --- a/demos/transforms-model-matrix.html +++ b/examples/transforms_modelling_matrix.html @@ -57,9 +57,9 @@ nodes:[ - // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/examples/transforms_modelling_quaternion.html b/examples/transforms_modelling_quaternion.html new file mode 100644 index 00000000..5febdd10 --- /dev/null +++ b/examples/transforms_modelling_quaternion.html @@ -0,0 +1,138 @@ + + + + SceneJS Example + + + + + + + + + + \ No newline at end of file diff --git a/demos/transforms-model-rotate.html b/examples/transforms_modelling_rotate.html similarity index 93% rename from demos/transforms-model-rotate.html rename to examples/transforms_modelling_rotate.html index 6df9ced4..e0bfcbf7 100644 --- a/demos/transforms-model-rotate.html +++ b/examples/transforms_modelling_rotate.html @@ -51,9 +51,9 @@ nodes:[ - // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/transforms-model-scale.html b/examples/transforms_modelling_scale.html similarity index 96% rename from demos/transforms-model-scale.html rename to examples/transforms_modelling_scale.html index ed411c0e..97021503 100644 --- a/demos/transforms-model-scale.html +++ b/examples/transforms_modelling_scale.html @@ -53,9 +53,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/transforms-model-translate.html b/examples/transforms_modelling_translate.html similarity index 94% rename from demos/transforms-model-translate.html rename to examples/transforms_modelling_translate.html index 05cc54a6..e025a521 100644 --- a/demos/transforms-model-translate.html +++ b/examples/transforms_modelling_translate.html @@ -52,9 +52,9 @@ nodes:[ - // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // Teapot primitive, implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/transforms-projection-default.html b/examples/transforms_projection_default.html similarity index 95% rename from demos/transforms-projection-default.html rename to examples/transforms_projection_default.html index e9bd4b02..866d7659 100644 --- a/demos/transforms-projection-default.html +++ b/examples/transforms_projection_default.html @@ -55,9 +55,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/transforms-projection-frustum.html b/examples/transforms_projection_frustum.html similarity index 98% rename from demos/transforms-projection-frustum.html rename to examples/transforms_projection_frustum.html index 0580dda6..6df6a9e4 100644 --- a/demos/transforms-projection-frustum.html +++ b/examples/transforms_projection_frustum.html @@ -62,9 +62,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/transforms-projection-ortho.html b/examples/transforms_projection_ortho.html similarity index 96% rename from demos/transforms-projection-ortho.html rename to examples/transforms_projection_ortho.html index 21737175..6efcfeba 100644 --- a/demos/transforms-projection-ortho.html +++ b/examples/transforms_projection_ortho.html @@ -60,9 +60,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/demos/transforms-projection-perspective.html b/examples/transforms_projection_perspective.html similarity index 96% rename from demos/transforms-projection-perspective.html rename to examples/transforms_projection_perspective.html index efae068b..fd0bfeab 100644 --- a/demos/transforms-projection-perspective.html +++ b/examples/transforms_projection_perspective.html @@ -60,9 +60,9 @@ nodes: [ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type: "prims/teapot" + type: "geometry/teapot" } ] } diff --git a/demos/transforms-view.html b/examples/transforms_viewing.html similarity index 98% rename from demos/transforms-view.html rename to examples/transforms_viewing.html index ca032c0c..4411f0fb 100644 --- a/demos/transforms-view.html +++ b/examples/transforms_viewing.html @@ -54,9 +54,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/examplesold/features.json b/examplesold/features.json deleted file mode 100644 index 66be3e43..00000000 --- a/examplesold/features.json +++ /dev/null @@ -1,427 +0,0 @@ -[ - { - "title":"Scene graph", - "nodes":[ - { - "nodes":[ - { - "title":"Transform hierarchies", - "page":"transformHierarchy" - } - ] - }, - { - "nodes":[ - { - "title":"Multiple scenes", - "page":"multipleScenes" - } - ] - }, - { - "nodes":[ - { - "title":"Auto WebGLContextLost recovery", - "page":"webglContextLost" - } - ] - } - ] - }, - { - "title":"Physics", - "status":"alpha", - "nodes":[ - { - "nodes":[ - { - "title":"Rigid body dynamics", - "page":"physicsBouncingSpheres" - } - ] - }, - { - "nodes":[ - { - "title":"Multiple physics systems", - "page":"physicsBouncingSpheresMultiSystems" - } - ] - } - ] - }, - { - "title":"Importers", - "nodes":[ - { - "nodes":[ - { - "title":".OBJ", - "page":"importObj" - }, - { - "title":".3DS", - "page":"import3ds" - }, - { - "title":".MD2", - "page":"importMd2" - } - ] - } - ] - }, - { - "title":"Optimization", - "nodes":[ - { - "nodes":[ - { - "title":"Frustum Culling", - "page":"frustumVisibilityCulling" - } - ] - }, - { - "nodes":[ - { - "title":"Level-of-Detail", - "page":"frustumDetailCulling" - } - ] - }, - { - "nodes":[ - { - "title":"Instancing", - "page":"sharedNodeCores" - } - ] - }, - { - "nodes":[ - { - "title":"Vertex sharing", - "page":"vertexSharing" - } - ] - }, - { - "nodes":[ - { - "title":"Texture atlases", - "page":"textureAtlas" - } - ] - } - ] - }, - { - "title":"Picking", - "nodes":[ - { - "nodes":[ - { - "title":"Object picking", - "page":"namePaths" - } - ] - }, - { - "nodes":[ - { - "title":"3D ray picking", - "page":"rayPicking" - } - ] - } - ] - }, - { - "title":"Unlimited lights", - "nodes":[ - { - "nodes":[ - { - "title":"Ambient", - "page":"ambientLight" - }, - { - "title":"Directional", - "page":"directionalWorldLight" - }, - { - "title":"Point", - "page":"pointWorldLight" - } - ] - } - ] - }, - { - "title":"Cameras", - "nodes":[ - { - "nodes":[ - { - "title":"Orthographic", - "page":"orthoProjection" - }, - { - "title":"Perspective", - "page":"perspectiveProjection" - }, - { - "title":"Frustum", - "page":"frustumProjection" - } - ] - }, - { - "nodes":[ - { - "title":"Orbiting", - "page":"customNodesCameraOrbit" - }, - { - "title":"Pick-Fly-Orbit", - "page":"cameraPickFlyOrbit" - } - ] - } - ] - }, - { - "title":"Geometry", - "nodes":[ - { - "nodes":[ - { - "title":"Triangles", - "page":"customTriangles" - }, - { - "title":"Lines", - "page":"customLines" - }, - { - "title":"Points", - "page":"customPoints" - } - ] - }, - { - "nodes":[ - { - "title":"Plane", - "page":"planeNodePrim" - }, - { - "title":"Box", - "page":"boxNodePrim" - }, - { - "title":"Cylinder", - "page":"cylinderNodePrim" - }, - { - "title":"Sphere", - "page":"sphereNodePrim" - }, - { - "title":"Torus", - "page":"torusNodePrim" - }, - { - "title":"Teapot", - "page":"teapotNodePrim" - } - ] - }, - { - "nodes":[ - { - "title":"Terrain", - "page":"customHeightmap" - } - ] - }, - { - "nodes":[ - { - "title":"Vector text", - "page":"vectorText" - } - ] - }, - { - "nodes":[ - { - "title":"Vertex coloring", - "page":"customVertexColors" - } - ] - }, - { - "nodes":[ - { - "title":"Automatic normals", - "page":"autoNormals" - } - ] - } - ] - }, - { - "title":"Texture", - "nodes":[ - { - "nodes":[ - { - "title":"Color", - "page":"colorMap" - }, - { - "title":"Alpha", - "page":"alphaMap" - }, - { - "title":"Specular", - "page":"specularMap" - }, - { - "title":"Bump", - "page":"bumpMap" - }, - { - "title":"Glow", - "page":"glowMap" - } - ] - }, - { - "nodes":[ - { - "title":"Reflection", - "page":"cubeMap" - } - ] - }, - { - "nodes":[ - { - "title":"Multitexturing", - "page":"multitexturing" - } - ] - }, - { - "nodes":[ - { - "title":"Texture animation", - "page":"colorMapAnimation" - } - ] - }, - { - "nodes":[ - { - "title":"Video texture", - "page":"videoColorMap" - } - ] - }, - { - "nodes":[ - { - "title":"UV layers", - "page":"uvLayers" - } - ] - }, - { - "nodes":[ - { - "title":"Texture plugin API", - "page":"videoAlphaMap" - } - ] - } - ] - }, - { - "title":"Shaders, eg:", - "nodes":[ - { - "nodes":[ - { - "title":"Custom fragment shaders", - "page":"xrayShader" - } - ] - }, - { - "nodes":[ - { - "title":"Custom vertex shaders", - "page":"vertexDisplaceShader" - } - ] - }, - { - "nodes":[ - { - "title":"Transparency sorting", - "page":"transparencySorting" - } - ] - } - ] - }, - { - "title":"Features library, eg:", - "nodes":[ - { - "nodes":[ - { - "title":"Skyboxes", - "page":"customSkybox" - }, - { - "title":"Heightmaps", - "page":"customHeightmap" - } - ] - }, - { - "nodes":[ - { - "title":"City", - "page":"city" - }, - { - "title":"Tank", - "page":"tronTank" - }, - { - "title":"Earth", - "page":"customNodesEarth" - } - ] - } - ] - }, - { - "title":"Utilities", - "nodes":[ - { - "nodes":[ - { - "title":"Canvas image capture", - "page":"canvasCapture" - } - ] - } - ] - } -] \ No newline at end of file diff --git a/examplesold/index.json b/examplesold/index.json index f1f86c54..7e627ca1 100644 --- a/examplesold/index.json +++ b/examplesold/index.json @@ -221,7 +221,7 @@ { "title":"Configuring depth buffer for subgraphs", "tip":"", - "tags":["depthbuf"], + "tags":["depthBuf"], "nodes":[ { "title":"Toggle depth testing", diff --git a/examplesold/pages/configuration/pluginPath.html b/examplesold/pages/configuration/pluginPath.html index 37ae0c23..d17ef50b 100644 --- a/examplesold/pages/configuration/pluginPath.html +++ b/examplesold/pages/configuration/pluginPath.html @@ -53,9 +53,9 @@ nodes:[ // Torus primitive, - // implemented by plugin at ../../../../api/latest/plugins/node/prims/torus.js + // implemented by plugin at ../../../../api/latest/plugins/node/geometry/torus.js { - type:"prims/torus", + type:"geometry/torus", radius:1.0, tube:0.30, segmentsR:60, diff --git a/examplesold/pages/configuration/statusPopups.html b/examplesold/pages/configuration/statusPopups.html index 100fa02a..f6e04cac 100644 --- a/examplesold/pages/configuration/statusPopups.html +++ b/examplesold/pages/configuration/statusPopups.html @@ -53,9 +53,9 @@ nodes:[ // Torus primitive, - // implemented by plugin at ../../../../api/latest/plugins/node/prims/torus.js + // implemented by plugin at ../../../../api/latest/plugins/node/geometry/torus.js { - type:"prims/torus", + type:"geometry/torus", radius:1.0, tube:0.30, segmentsR:60, diff --git a/examplesold/pages/demos/bubbles.html b/examplesold/pages/demos/bubbles.html index 095b77b7..60601a7d 100644 --- a/examplesold/pages/demos/bubbles.html +++ b/examplesold/pages/demos/bubbles.html @@ -73,9 +73,9 @@ nodes:[ // Grid ground, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/grid.js + // http://scenejs.org/api/latest/plugins/node/geometry/grid.js { - type:"prims/grid", + type:"geometry/grid", size:{ x:1000, z:1000 }, xSegments:200, zSegments:200 @@ -84,9 +84,9 @@ }, // Cloudy sea skybox, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/skyboxes/miramarClouds.js + // http://scenejs.org/api/latest/plugins/node/skybox/miramarClouds.js { - type:"skyboxes/cloudySea" + type:"skybox/cloudySea" }, //-------------------------------------------------------------------------------- @@ -266,9 +266,9 @@ angle:0 }); this.rotate.addNode( - // Sphere geometry node implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // Sphere geometry node implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type:"prims/sphere" + type:"geometry/sphere" }); this.angle = 0; this.angleInc = Math.random() - 0.5; diff --git a/examplesold/pages/demos/city.html b/examplesold/pages/demos/city.html index ad1673bb..3f9fc2c5 100644 --- a/examplesold/pages/demos/city.html +++ b/examplesold/pages/demos/city.html @@ -59,15 +59,15 @@ nodes: [ // Clouds skybox, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/skyboxes/clouds.js + // http://scenejs.org/api/latest/plugins/node/skybox/clouds.js { - type: "skyboxes/clouds" + type: "skybox/clouds" }, // Fog effect, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/effects/fog.js + // http://scenejs.org/api/latest/plugins/node/shader/fog.js { - type: "effects/fog", + type: "shader/fog", mode: "exp2", // Quadratic density: 0.1, // Fog density start: 30.0, // Near starting point @@ -81,9 +81,9 @@ nodes: [ // Grid ground, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/object/ground/grid.js + // http://scenejs.org/api/latest/plugins/node/models/ground/grid.js { - type: "prims/grid", + type: "geometry/grid", size: { x: 10000, z: 10000 }, width: 10000, height: 10000, @@ -103,9 +103,9 @@ nodes: [ // City, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/object/buildings/city.js + // http://scenejs.org/api/latest/plugins/node/models/buildings/city.js { - type: "objects/buildings/city", + type: "models/buildings/city", width: 600 } ] diff --git a/examplesold/pages/demos/clouds.html b/examplesold/pages/demos/clouds.html index 7b336e67..3a7985d0 100644 --- a/examplesold/pages/demos/clouds.html +++ b/examplesold/pages/demos/clouds.html @@ -180,9 +180,9 @@ z:scale, nodes:[ - // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/prims/box.js + // Box primitive implemented by plugin at http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } diff --git a/examplesold/pages/demos/earth.html b/examplesold/pages/demos/earth.html index fa0b0ed0..c7f7b706 100644 --- a/examplesold/pages/demos/earth.html +++ b/examplesold/pages/demos/earth.html @@ -53,9 +53,9 @@ nodes:[ // Earth, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/objects/space/planets/earth.js + // http://scenejs.org/api/latest/plugins/node/models/space/planets/earth.js { - type:"objects/space/planets/earth" + type:"models/space/planets/earth" } ] } diff --git a/examplesold/pages/demos/firstExample.html b/examplesold/pages/demos/firstExample.html index 5ab47b88..6f50fc42 100644 --- a/examplesold/pages/demos/firstExample.html +++ b/examplesold/pages/demos/firstExample.html @@ -49,9 +49,9 @@ nodes:[ // Teapot primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } diff --git a/examplesold/pages/demos/ghostTrees.html b/examplesold/pages/demos/ghostTrees.html index 5e1f93ce..ac225cbb 100644 --- a/examplesold/pages/demos/ghostTrees.html +++ b/examplesold/pages/demos/ghostTrees.html @@ -28,7 +28,7 @@ // http://www.chromeexperiments.com/detail/ghost-trees/ // // The tree generation code is wrapped in a custom SceneJS node type defined in: - // http://scenejs.org/api/latest/plugins/node/objects/plants/ghostTree.js + // http://scenejs.org/api/latest/plugins/node/models/plants/ghostTree.js // // All the parameters for the tree generator are exposed as configurations // for the node type. @@ -69,7 +69,7 @@ nodes:[ // Procedurally-generated tree nodes, implemented by plugin at: - // http://scenejs.org/api/latest/plugins/node/objects/plants/ghostTree.js + // http://scenejs.org/api/latest/plugins/node/models/plants/ghostTree.js // // This plugin integrates the Ghost Trees generator from the Chrome Experiment // by Marek Kapolka: http://www.chromeexperiments.com/detail/ghost-trees/ @@ -83,7 +83,7 @@ nodes:[ { - type:"objects/plants/ghostTree", + type:"models/plants/ghostTree", minSegmentLength:1, maxSegmentLength:3, minSegmentAngle:Math.PI / 16, @@ -106,7 +106,7 @@ nodes:[ { - type:"objects/plants/ghostTree", + type:"models/plants/ghostTree", minSegmentLength:1, maxSegmentLength:2, minSegmentAngle:Math.PI / 16, @@ -129,7 +129,7 @@ nodes:[ { - type:"objects/plants/ghostTree", + type:"models/plants/ghostTree", minSegmentLength:1, maxSegmentLength:2, minSegmentAngle:Math.PI / 16, @@ -152,7 +152,7 @@ nodes:[ { - type:"objects/plants/ghostTree", + type:"models/plants/ghostTree", minSegmentLength:1, maxSegmentLength:2, minSegmentAngle:Math.PI / 16, diff --git a/examplesold/pages/demos/orbitPicked.html b/examplesold/pages/demos/orbitPicked.html index d78350f1..beecb35a 100644 --- a/examplesold/pages/demos/orbitPicked.html +++ b/examplesold/pages/demos/orbitPicked.html @@ -56,9 +56,9 @@ // nodes:[ // // // Sphere primitive implemented by plugin at -// // http://scenejs.org/api/latest/plugins/node/prims/sphere.js +// // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js // { -// type:"prims/sphere" +// type:"geometry/sphere" // } // ] // } @@ -92,9 +92,9 @@ // nodes:[ // // // Sphere primitive implemented by plugin at -// // http://scenejs.org/api/latest/plugins/node/prims/sphere.js +// // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js // { -// type:"prims/sphere" +// type:"geometry/sphere" // } // ] // } @@ -137,9 +137,9 @@ nodes:[ // Box primitive, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } @@ -164,9 +164,9 @@ nodes:[ // Box primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } @@ -191,9 +191,9 @@ nodes:[ // Box primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } @@ -218,9 +218,9 @@ nodes:[ // Box primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } @@ -245,9 +245,9 @@ nodes:[ // Box primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/box.js + // http://scenejs.org/api/latest/plugins/node/geometry/box.js { - type:"prims/box" + type:"geometry/box" } ] } @@ -284,9 +284,9 @@ nodes:[ // Torus primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type:"prims/torus" + type:"geometry/torus" } ] } @@ -317,9 +317,9 @@ nodes:[ // Torus primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type:"prims/torus" + type:"geometry/torus" } ] } @@ -350,9 +350,9 @@ nodes:[ // Torus primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type:"prims/torus" + type:"geometry/torus" } ] } @@ -383,9 +383,9 @@ nodes:[ // Torus primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/torus.js + // http://scenejs.org/api/latest/plugins/node/geometry/torus.js { - type:"prims/torus" + type:"geometry/torus" } ] } @@ -418,9 +418,9 @@ nodes:[ // Teapot primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/teapot.js + // http://scenejs.org/api/latest/plugins/node/geometry/teapot.js { - type:"prims/teapot" + type:"geometry/teapot" } ] } @@ -452,9 +452,9 @@ nodes:[ // Sphere primitive implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/prims/sphere.js + // http://scenejs.org/api/latest/plugins/node/geometry/sphere.js { - type:"prims/sphere" + type:"geometry/sphere" } ] } diff --git a/examplesold/pages/demos/physics.html b/examplesold/pages/demos/physics.html index 0f24dc36..b763bc7a 100644 --- a/examplesold/pages/demos/physics.html +++ b/examplesold/pages/demos/physics.html @@ -71,7 +71,7 @@ // Node type implemented by plugin at http://scenejs.org/api/latest/plugins/node/ground/grid.js { - type: "objects/ground/grid", + type: "models/ground/grid", size: { x: 10000, z: 10000 }, xSegments: 100, zSegments: 100 diff --git a/examplesold/pages/demos/pickFlyOrbitCity.html b/examplesold/pages/demos/pickFlyOrbitCity.html index 753019a8..52b6070a 100644 --- a/examplesold/pages/demos/pickFlyOrbitCity.html +++ b/examplesold/pages/demos/pickFlyOrbitCity.html @@ -157,15 +157,15 @@ nodes:[ // Clouds skybox, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/skyboxes/clouds.js + // http://scenejs.org/api/latest/plugins/node/skybox/clouds.js { - type:"skyboxes/clouds" + type:"skybox/clouds" }, // Fog effect, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/effects/fog.js + // http://scenejs.org/api/latest/plugins/node/shader/fog.js { - type:"effects/fog", + type:"shader/fog", mode:"exp2", // Quadratic density:0.1, // Fog density start:30.0, // Near starting point @@ -180,9 +180,9 @@ nodes:[ // Grid ground, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/object/ground/grid.js + // http://scenejs.org/api/latest/plugins/node/models/ground/grid.js { - type:"prims/grid", + type:"geometry/grid", size:{ x:10000, z:10000 }, width:10000, height:10000, @@ -203,9 +203,9 @@ nodes:[ // Solid green surface under the grid, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/object/ground/grid.js + // http://scenejs.org/api/latest/plugins/node/models/ground/grid.js { - type:"prims/grid", + type:"geometry/grid", size:{ x:10000, z:10000 }, width:10000, height:10000, @@ -228,9 +228,9 @@ nodes:[ // City, implemented by plugin at - // http://scenejs.org/api/latest/plugins/node/object/buildings/city.js + // http://scenejs.org/api/latest/plugins/node/models/buildings/city.js { - type:"objects/buildings/city", + type:"models/buildings/city", width:600 } ] diff --git a/examplesold/pages/demos/pickFlyOrbitTerrain.html b/examplesold/pages/demos/pickFlyOrbitTerrain.html index d25bca5c..dabb0806 100644 --- a/examplesold/pages/demos/pickFlyOrbitTerrain.html +++ b/examplesold/pages/demos/pickFlyOrbitTerrain.html @@ -115,7 +115,7 @@