From fb0a659c9ca3479fd6799325498b11f074689936 Mon Sep 17 00:00:00 2001
From: John Mayhew
Date: Mon, 2 Apr 2012 14:57:31 -0700
Subject: -Namespaced all RDGE javascript.
-Removed the following unused files from the build script
/core/script/fx/blur.js
/core/script/fx/ssao.js
/core/script/animation.js
- Fully removed the following from the build and from source control as they are unused or no longer needed
/core/script/util/dbgpanel.js
/core/script/util/fpsTracker.js
/core/script/util/statTracker.js
/core/script/input.js
/core/script/TextureManager.js
/core/script/ubershader.js
---
js/lib/drawing/world.js | 58 +++++++++++------------
js/lib/geom/circle.js | 6 +--
js/lib/geom/line.js | 4 +-
js/lib/geom/rectangle.js | 8 ++--
js/lib/geom/shape-primitive.js | 4 +-
js/lib/rdge/materials/bump-metal-material.js | 6 +--
js/lib/rdge/materials/deform-material.js | 4 +-
js/lib/rdge/materials/flat-material.js | 4 +-
js/lib/rdge/materials/fly-material.js | 4 +-
js/lib/rdge/materials/julia-material.js | 6 +--
js/lib/rdge/materials/keleidoscope-material.js | 6 +--
js/lib/rdge/materials/linear-gradient-material.js | 4 +-
js/lib/rdge/materials/mandel-material.js | 6 +--
js/lib/rdge/materials/plasma-material.js | 4 +-
js/lib/rdge/materials/pulse-material.js | 10 ++--
js/lib/rdge/materials/radial-blur-material.js | 10 ++--
js/lib/rdge/materials/radial-gradient-material.js | 4 +-
js/lib/rdge/materials/relief-tunnel-material.js | 4 +-
js/lib/rdge/materials/square-tunnel-material.js | 4 +-
js/lib/rdge/materials/star-material.js | 4 +-
js/lib/rdge/materials/taper-material.js | 4 +-
js/lib/rdge/materials/tunnel-material.js | 4 +-
js/lib/rdge/materials/twist-material.js | 6 +--
js/lib/rdge/materials/twist-vert-material.js | 6 +--
js/lib/rdge/materials/uber-material.js | 16 +++----
js/lib/rdge/materials/water-material.js | 4 +-
js/lib/rdge/materials/z-invert-material.js | 6 +--
27 files changed, 103 insertions(+), 103 deletions(-)
(limited to 'js/lib')
diff --git a/js/lib/drawing/world.js b/js/lib/drawing/world.js
index 3d6c6fc4..7c5fb136 100755
--- a/js/lib/drawing/world.js
+++ b/js/lib/drawing/world.js
@@ -141,45 +141,45 @@ var World = function GLWorld( canvas, use3D ) {
// post-load processing of the scene
this.init = function() {
- var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle),
- ctx2 = g_Engine.getContext();
+ var ctx1 = RDGE.globals.engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle),
+ ctx2 = RDGE.globals.engine.getContext();
if (ctx1 != ctx2) console.log( "***** different contexts *****" );
this.renderer = ctx1.renderer;
this.renderer._world = this;
// create a camera, set its perspective, and then point it at the origin
- var cam = new camera();
+ var cam = new RDGE.camera();
this._camera = cam;
cam.setPerspective(this.getFOV(), this.getAspect(), this.getZNear(), this.getZFar());
- cam.setLookAt([0, 0, this.getViewDistance()], [0, 0, 0], vec3.up());
+ cam.setLookAt([0, 0, this.getViewDistance()], [0, 0, 0], RDGE.vec3.up());
// make this camera the active camera
this.renderer.cameraManager().setActiveCamera(cam);
// change clear color
- //this.renderer.setClearFlags(g_Engine.getContext().DEPTH_BUFFER_BIT);
+ //this.renderer.setClearFlags(RDGE.globals.engine.getContext().DEPTH_BUFFER_BIT);
this.renderer.setClearColor([0.0, 0.0, 0.0, 0.0]);
//this.renderer.NinjaWorld = this;
// create an empty scene graph
- this.myScene = new SceneGraph();
+ this.myScene = new RDGE.SceneGraph();
// create some lights
// light 1
- this.light = createLightNode("myLight");
+ this.light = RDGE.createLightNode("myLight");
this.light.setPosition([0,0,1.2]);
this.light.setDiffuseColor([0.75,0.9,1.0,1.0]);
// light 2
- this.light2 = createLightNode("myLight2");
+ this.light2 = RDGE.createLightNode("myLight2");
this.light2.setPosition([-0.5,0,1.2]);
this.light2.setDiffuseColor([1.0,0.9,0.75,1.0]);
// create a light transform
- var lightTr = createTransformNode("lightTr");
+ var lightTr = RDGE.createTransformNode("lightTr");
// create and attach a material - materials hold the light data
- lightTr.attachMaterial(createMaterialNode("lights"));
+ lightTr.attachMaterial(RDGE.createMaterialNode("lights"));
// enable light channels 1, 2 - channel 0 is used by the default shader
lightTr.materialNode.enableLightChannel(1, this.light);
@@ -192,9 +192,9 @@ var World = function GLWorld( canvas, use3D ) {
this.myScene.addNode(lightTr);
// Add the scene to the engine - necessary if you want the engine to draw for you
- //g_Engine.AddScene("myScene" + this._canvas.id, this.myScene);
+ //RDGE.globals.engine.AddScene("myScene" + this._canvas.id, this.myScene);
var name = this._canvas.getAttribute( "data-RDGE-id" );
- g_Engine.AddScene("myScene" + name, this.myScene);
+ RDGE.globals.engine.AddScene("myScene" + name, this.myScene);
};
// main code for handling user interaction and updating the scene
@@ -206,7 +206,7 @@ var World = function GLWorld( canvas, use3D ) {
if (this._useWebGL) {
// changed the global position uniform of light 0, another way to change behavior of a light
- rdgeGlobalParameters.u_light0Pos.set( [5*Math.cos(this.elapsed), 5*Math.sin(this.elapsed), 20]);
+ RDGE.rdgeGlobalParameters.u_light0Pos.set([5 * Math.cos(this.elapsed), 5 * Math.sin(this.elapsed), 20]);
// orbit the light nodes around the boxes
this.light.setPosition([1.2*Math.cos(this.elapsed*2.0), 1.2*Math.sin(this.elapsed*2.0), 1.2*Math.cos(this.elapsed*2.0)]);
@@ -223,8 +223,8 @@ var World = function GLWorld( canvas, use3D ) {
// defining the draw function to control how the scene is rendered
this.draw = function() {
if (this._useWebGL) {
- g_Engine.setContext( this._canvas.rdgeid );
- var ctx = g_Engine.getContext();
+ RDGE.globals.engine.setContext( this._canvas.rdgeid );
+ var ctx = RDGE.globals.engine.getContext();
var renderer = ctx.renderer;
if (renderer.unloadedTextureCount <= 0) {
renderer.disableCulling();
@@ -361,8 +361,8 @@ var World = function GLWorld( canvas, use3D ) {
rdgeStarted = true;
var id = this._canvas.getAttribute( "data-RDGE-id" );
this._canvas.rdgeid = id;
- g_Engine.registerCanvas(this._canvas, this);
- RDGEStart( this._canvas );
+ RDGE.globals.engine.registerCanvas(this._canvas, this);
+ RDGE.RDGEStart( this._canvas );
this._canvas.task.stop()
}
};
@@ -391,13 +391,13 @@ World.prototype.updateObject = function (obj) {
if (nPrims > 0) {
ctrTrNode = obj.getTransformNode();
if (ctrTrNode == null) {
- ctrTrNode = createTransformNode("objRootNode_" + nodeCounter++);
+ ctrTrNode = RDGE.createTransformNode("objRootNode_" + nodeCounter++);
this._rootNode.insertAsChild( ctrTrNode );
obj.setTransformNode( ctrTrNode );
}
ctrTrNode.meshes.forEach(function(thisMesh) {
- g_meshMan.deleteMesh(thisMesh.mesh.name);
+ RDGE.globals.meshMan.deleteMesh(thisMesh.mesh.name);
});
ctrTrNode.meshes = [];
@@ -416,11 +416,11 @@ World.prototype.updateObject = function (obj) {
childTrNode = children[i-1].transformNode;
childTrNode.meshes.forEach(function(thisMesh) {
- g_meshMan.deleteMesh(thisMesh.mesh.name);
+ RDGE.globals.meshMan.deleteMesh(thisMesh.mesh.name);
});
childTrNode.meshes = [];
} else {
- childTrNode = createTransformNode("objNode_" + nodeCounter++);
+ childTrNode = RDGE.createTransformNode("objNode_" + nodeCounter++);
ctrTrNode.insertAsChild(childTrNode);
}
@@ -522,7 +522,7 @@ World.prototype.clearTree = function() {
if (this._useWebGL) {
var root = this._rootNode;
root.children = new Array();
- g_Engine.unregisterCanvas( this._canvas.rdgeid )
+ RDGE.globals.engine.unregisterCanvas( this._canvas.rdgeid )
this.update( 0 );
this.draw();
@@ -657,9 +657,9 @@ World.prototype.setMVMatrix = function() {
gl.uniformMatrix4fv(this._shaderProgram.mvMatrixUniform, false, new Float32Array(mvMatrix));
var normalMatrix = mat3.create();
- // mat4.toInverseMat3(mvMatrix, normalMatrix);
- // mat4.toInverseMat3(new Float32Array(mvMatrix.flatten()), normalMatrix);
- mat4.toInverseMat3(new Float32Array(mvMatrix), normalMatrix);
+ // RDGE.mat4.toInverseMat3(mvMatrix, normalMatrix);
+ // RDGE.mat4.toInverseMat3(new Float32Array(mvMatrix.flatten()), normalMatrix);
+ RDGE.mat4.toInverseMat3(new Float32Array(mvMatrix), normalMatrix);
mat3.transpose(normalMatrix);
gl.uniformMatrix3fv(this._shaderProgram.nMatrixUniform, false, normalMatrix);
}
@@ -680,7 +680,7 @@ World.prototype.render = function() {
var root = this.getGeomRoot();
this.hRender( root );
} else {
- g_Engine.setContext( this._canvas.rdgeId );
+ RDGE.globals.engine.setContext( this._canvas.rdgeId );
//this.draw();
this.restartRenderLoop();
}
@@ -895,16 +895,16 @@ World.prototype.importSubObject = function( objStr, parentNode ) {
i0 += 10;
var matText = objStr.substr( i0, i1 - i0 );
var shaderDef = JSON.parse( matText );
- var shader = new jshader();
+ var shader = new RDGE.jshader();
shader.def = shaderDef;
shader.init();
// set the shader for this material
- var matNode = createMaterialNode("objMat")
+ var matNode = RDGE.createMaterialNode("objMat")
matNode.setShader(shader);
// create the transformation node
- var trNode = createTransformNode("subObjNode_" );
+ var trNode = RDGE.createTransformNode("subObjNode_");
trNode.attachMeshNode(this.renderer.id + "_prim_", meshObj);
trNode.attachMaterial(matNode);
parentNode.insertAsChild(trNode);
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index dd82a4cc..52c2d449 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -176,7 +176,7 @@ var Circle = function GLCircle() {
if (!world._useWebGL) return;
// make sure RDGE has the correct context
- g_Engine.setContext( world.getCanvas().rdgeid );
+ RDGE.globals.engine.setContext( world.getCanvas().rdgeid );
// create the gl buffer
var gl = world.getGLContext();
@@ -348,7 +348,7 @@ var Circle = function GLCircle() {
this.recalcTexMapCoords( vrts, uvs );
- return ShapePrimitive.create(vrts, nrms, uvs, indices, g_Engine.getContext().renderer.TRIANGLES, index);
+ return ShapePrimitive.create(vrts, nrms, uvs, indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, index);
};
this.generateOvalRing = function(xOff, yOff, rotationMat, innerScaleMat, outerScaleMat, nTriangles) {
@@ -405,7 +405,7 @@ var Circle = function GLCircle() {
this.recalcTexMapCoords( vrts, uvs );
- return ShapePrimitive.create(vrts, nrms, uvs, indices, g_Engine.getContext().renderer.TRIANGLE_STRIP, indices.length);
+ return ShapePrimitive.create(vrts, nrms, uvs, indices, RDGE.globals.engine.getContext().renderer.TRIANGLE_STRIP, indices.length);
};
this.render = function() {
diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js
index da63b21c..e8d967f0 100755
--- a/js/lib/geom/line.js
+++ b/js/lib/geom/line.js
@@ -167,7 +167,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok
if (!world._useWebGL) return;
// make sure RDGE has the correct context
- g_Engine.setContext( world.getCanvas().rdgeid );
+ RDGE.globals.engine.setContext( world.getCanvas().rdgeid );
// create the gl buffer
var gl = world.getGLContext();
@@ -328,7 +328,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok
indices.push( index ); index++;
}
- var prim = ShapePrimitive.create(strokeVertices, strokeNormals, strokeTextures, indices, g_Engine.getContext().renderer.TRIANGLES, indices.length);
+ var prim = ShapePrimitive.create(strokeVertices, strokeNormals, strokeTextures, indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, indices.length);
var strokeMaterial = this.makeStrokeMaterial();
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js
index 81b385b3..98621a98 100755
--- a/js/lib/geom/rectangle.js
+++ b/js/lib/geom/rectangle.js
@@ -276,7 +276,7 @@ var Rectangle = function GLRectangle() {
if (!world._useWebGL) return;
// make sure RDGE has the correct context
- g_Engine.setContext( world.getCanvas().rdgeid );
+ RDGE.globals.engine.setContext( world.getCanvas().rdgeid );
// create the gl buffer
var gl = world.getGLContext();
@@ -826,7 +826,7 @@ RectangleFill.create = function( rectCtr, width, height, tlRad, blRad, brRad,
// }
// create the RDGE primitive
- return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices);
+ return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
};
RectangleFill.pushVertex = function( x, y, z ) {
@@ -1058,7 +1058,7 @@ RectangleStroke.create = function( rectCtr, width, height, strokeWidth, tlRad,
// }
// create the RDGE primitive
- return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices);
+ return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
};
RectangleStroke.getRoundedCorner = function( ctr, insidePt, outsidePt ) {
@@ -1144,7 +1144,7 @@ RectangleGeometry.create = function( ctr, width, height, material ) {
// }
// create the RDGE primitive
- return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices);
+ return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
};
RectangleGeometry.pushVertex = RectangleFill.pushVertex;
diff --git a/js/lib/geom/shape-primitive.js b/js/lib/geom/shape-primitive.js
index bf0087b2..97873d32 100644
--- a/js/lib/geom/shape-primitive.js
+++ b/js/lib/geom/shape-primitive.js
@@ -8,11 +8,11 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
var ShapePrimitive = {};
ShapePrimitive.create = function(coords, normals, uvs, indices, primType, vertexCount) {
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
// to setup a primitive you must define it
// create a new primitive definition here to then fill out
- var prim = new rdgePrimitiveDefinition();
+ var prim = new RDGE.rdgePrimitiveDefinition();
// the vertex definition declares how the data will be delivered to the shader
// the position of an element in array determines which attribute in a shader the
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js
index 61126952..e0ca8d4a 100755
--- a/js/lib/rdge/materials/bump-metal-material.js
+++ b/js/lib/rdge/materials/bump-metal-material.js
@@ -110,13 +110,13 @@ var BumpMetalMaterial = function BumpMetalMaterial() {
if (world) this.setWorld( world );
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = bumpMetalMaterialDef;
this._shader.init();
this._shader['default'].u_light0Diff.set( this.getLightDiff() );
// set up the material node
- this._materialNode = createMaterialNode( this.getShaderName() );
+ this._materialNode = RDGE.createMaterialNode(this.getShaderName());
this._materialNode.setShader(this._shader);
// set some image maps
@@ -131,7 +131,7 @@ var BumpMetalMaterial = function BumpMetalMaterial() {
if (material)
{
var technique = material.shaderProgram['default'];
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique)
{
var texMapName = this._propValues[this._propNames[index]];
diff --git a/js/lib/rdge/materials/deform-material.js b/js/lib/rdge/materials/deform-material.js
index 1e6af6ac..4c6e06b1 100644
--- a/js/lib/rdge/materials/deform-material.js
+++ b/js/lib/rdge/materials/deform-material.js
@@ -55,12 +55,12 @@ var DeformMaterial = function DeformMaterial() {
if (world) this.setWorld( world );
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = deformMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode("deformMaterial");
+ this._materialNode = RDGE.createMaterialNode("deformMaterial");
this._materialNode.setShader(this._shader);
this._time = 0;
diff --git a/js/lib/rdge/materials/flat-material.js b/js/lib/rdge/materials/flat-material.js
index be8bf2b8..bc612476 100755
--- a/js/lib/rdge/materials/flat-material.js
+++ b/js/lib/rdge/materials/flat-material.js
@@ -39,7 +39,7 @@ var FlatMaterial = function FlatMaterial() {
this.init = function()
{
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = flatShaderDef;
this._shader.init();
@@ -47,7 +47,7 @@ var FlatMaterial = function FlatMaterial() {
this._shader.colorMe.color.set( this.getColor() );
// set up the material node
- this._materialNode = createMaterialNode("flatMaterial");
+ this._materialNode = RDGE.createMaterialNode("flatMaterial");
this._materialNode.setShader(this._shader);
};
diff --git a/js/lib/rdge/materials/fly-material.js b/js/lib/rdge/materials/fly-material.js
index 8eadb3ab..09dae536 100644
--- a/js/lib/rdge/materials/fly-material.js
+++ b/js/lib/rdge/materials/fly-material.js
@@ -48,12 +48,12 @@ var FlyMaterial = function FlyMaterial() {
if (world) this.setWorld( world );
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = flyMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode("flyMaterial");
+ this._materialNode = RDGE.createMaterialNode("flyMaterial");
this._materialNode.setShader(this._shader);
this._time = 0;
diff --git a/js/lib/rdge/materials/julia-material.js b/js/lib/rdge/materials/julia-material.js
index 07536f33..77d9bb3a 100644
--- a/js/lib/rdge/materials/julia-material.js
+++ b/js/lib/rdge/materials/julia-material.js
@@ -50,12 +50,12 @@ var JuliaMaterial = function JuliaMaterial() {
if (world) this.setWorld( world );
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = JuliaMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode("juliaMaterial");
+ this._materialNode = RDGE.createMaterialNode("juliaMaterial");
this._materialNode.setShader(this._shader);
this._time = 0;
@@ -72,7 +72,7 @@ var JuliaMaterial = function JuliaMaterial() {
var material = this._materialNode;
if (material) {
var technique = material.shaderProgram['default'];
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique) {
if (this._shader && this._shader['default']) {
this._shader['default'].u_time.set( [this._time] );
diff --git a/js/lib/rdge/materials/keleidoscope-material.js b/js/lib/rdge/materials/keleidoscope-material.js
index 3ef5d613..e1f4841f 100644
--- a/js/lib/rdge/materials/keleidoscope-material.js
+++ b/js/lib/rdge/materials/keleidoscope-material.js
@@ -55,12 +55,12 @@ var KeleidoscopeMaterial = function KeleidoscopeMaterial() {
if (world) this.setWorld( world );
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = keleidoscopeMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode("keleidoscopeMaterial");
+ this._materialNode = RDGE.createMaterialNode("keleidoscopeMaterial");
this._materialNode.setShader(this._shader);
this._time = 0;
@@ -80,7 +80,7 @@ var KeleidoscopeMaterial = function KeleidoscopeMaterial() {
if (material)
{
var technique = material.shaderProgram['default'];
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique)
{
if (this._shader && this._shader['default']) {
diff --git a/js/lib/rdge/materials/linear-gradient-material.js b/js/lib/rdge/materials/linear-gradient-material.js
index 2c52c67d..d9307274 100755
--- a/js/lib/rdge/materials/linear-gradient-material.js
+++ b/js/lib/rdge/materials/linear-gradient-material.js
@@ -207,12 +207,12 @@ var LinearGradientMaterial = function LinearGradientMaterial() {
this.setWorld( world );
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = linearGradientMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode( this.getShaderName() );
+ this._materialNode = RDGE.createMaterialNode(this.getShaderName());
this._materialNode.setShader(this._shader);
// send the current values to the shader
diff --git a/js/lib/rdge/materials/mandel-material.js b/js/lib/rdge/materials/mandel-material.js
index 07e009a2..c4d5bf6f 100644
--- a/js/lib/rdge/materials/mandel-material.js
+++ b/js/lib/rdge/materials/mandel-material.js
@@ -61,12 +61,12 @@ var MandelMaterial = function MandelMaterial() {
if (world) this.setWorld( world );
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = MandelMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode("mandelMaterial");
+ this._materialNode = RDGE.createMaterialNode("mandelMaterial");
this._materialNode.setShader(this._shader);
this._time = 0;
@@ -83,7 +83,7 @@ var MandelMaterial = function MandelMaterial() {
var material = this._materialNode;
if (material) {
var technique = material.shaderProgram['default'];
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique) {
if (this._shader && this._shader['default'])
this._shader['default'].u_time.set( [this._time] );
diff --git a/js/lib/rdge/materials/plasma-material.js b/js/lib/rdge/materials/plasma-material.js
index 9ecc2b48..d52f4b88 100644
--- a/js/lib/rdge/materials/plasma-material.js
+++ b/js/lib/rdge/materials/plasma-material.js
@@ -56,7 +56,7 @@ var PlasmaMaterial = function PlasmaMaterial() {
this.init = function() {
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = plasmaShaderDef;
this._shader.init();
@@ -66,7 +66,7 @@ var PlasmaMaterial = function PlasmaMaterial() {
this.setProperty( "color", [this._time, 0, 0, 1] );
// set up the material node
- this._materialNode = createMaterialNode("plasmaMaterial");
+ this._materialNode = RDGE.createMaterialNode("plasmaMaterial");
this._materialNode.setShader(this._shader);
};
diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js
index 63cab2f4..89cbaea4 100644
--- a/js/lib/rdge/materials/pulse-material.js
+++ b/js/lib/rdge/materials/pulse-material.js
@@ -96,12 +96,12 @@ var PulseMaterial = function PulseMaterial() {
this._dTime = 0.01;
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = pulseMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode("pulseMaterial");
+ this._materialNode = RDGE.createMaterialNode("pulseMaterial");
this._materialNode.setShader(this._shader);
this._time = 0;
@@ -120,7 +120,7 @@ var PulseMaterial = function PulseMaterial() {
var material = this._materialNode;
if (material) {
var technique = material.shaderProgram['default'];
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique) {
var texMapName = this._propValues[this._propNames[0]];
var wrap = 'REPEAT', mips = true;
@@ -151,7 +151,7 @@ var PulseMaterial = function PulseMaterial() {
if (material)
{
var technique = material.shaderProgram['default'];
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique) {
if (this._shader && this._shader['default']) {
this._shader['default'].u_time.set( [this._time] );
@@ -167,7 +167,7 @@ var PulseMaterial = function PulseMaterial() {
var material = this._materialNode;
if (material) {
var technique = material.shaderProgram['default'];
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique) {
technique.u_resolution.set( res );
}
diff --git a/js/lib/rdge/materials/radial-blur-material.js b/js/lib/rdge/materials/radial-blur-material.js
index 41e68182..3adb6bb5 100644
--- a/js/lib/rdge/materials/radial-blur-material.js
+++ b/js/lib/rdge/materials/radial-blur-material.js
@@ -89,12 +89,12 @@ var RadialBlurMaterial = function RadialBlurMaterial() {
if (world) this.setWorld( world );
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = radialBlurMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode("radialBlurMaterial");
+ this._materialNode = RDGE.createMaterialNode("radialBlurMaterial");
this._materialNode.setShader(this._shader);
this._time = 0;
@@ -112,7 +112,7 @@ var RadialBlurMaterial = function RadialBlurMaterial() {
var material = this._materialNode;
if (material) {
var technique = material.shaderProgram['default'];
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique) {
var texMapName = this._propValues[this._propNames[0]];
var tex = renderer.getTextureByName(texMapName, 'REPEAT');
@@ -130,7 +130,7 @@ var RadialBlurMaterial = function RadialBlurMaterial() {
var material = this._materialNode;
if (material) {
var technique = material.shaderProgram['default'];
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique) {
if (this._shader && this._shader['default']) {
this._shader['default'].u_time.set( [this._time] );
@@ -150,7 +150,7 @@ var RadialBlurMaterial = function RadialBlurMaterial() {
if (material)
{
var technique = material.shaderProgram['default'];
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique) {
technique.u_resolution.set( res );
}
diff --git a/js/lib/rdge/materials/radial-gradient-material.js b/js/lib/rdge/materials/radial-gradient-material.js
index 13be50f5..faac7f1b 100755
--- a/js/lib/rdge/materials/radial-gradient-material.js
+++ b/js/lib/rdge/materials/radial-gradient-material.js
@@ -195,12 +195,12 @@ var RadialGradientMaterial = function RadialGradientMaterial() {
this.init = function() {
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = radialGradientMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode("radialGradientMaterial");
+ this._materialNode = RDGE.createMaterialNode("radialGradientMaterial");
this._materialNode.setShader(this._shader);
// set the shader values in the shader
diff --git a/js/lib/rdge/materials/relief-tunnel-material.js b/js/lib/rdge/materials/relief-tunnel-material.js
index 20290895..7bf780fe 100644
--- a/js/lib/rdge/materials/relief-tunnel-material.js
+++ b/js/lib/rdge/materials/relief-tunnel-material.js
@@ -49,12 +49,12 @@ var ReliefTunnelMaterial = function ReliefTunnelMaterial() {
if (world) this.setWorld( world );
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = reliefTunnelMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode("reliefTunnelMaterial");
+ this._materialNode = RDGE.createMaterialNode("reliefTunnelMaterial");
this._materialNode.setShader(this._shader);
this._time = 0;
diff --git a/js/lib/rdge/materials/square-tunnel-material.js b/js/lib/rdge/materials/square-tunnel-material.js
index b5cbff30..23b0db03 100644
--- a/js/lib/rdge/materials/square-tunnel-material.js
+++ b/js/lib/rdge/materials/square-tunnel-material.js
@@ -50,12 +50,12 @@ var SquareTunnelMaterial = function SquareTunnelMaterial() {
if (world) this.setWorld( world );
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = squareTunnelMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode("squareTunnelMaterial");
+ this._materialNode = RDGE.createMaterialNode("squareTunnelMaterial");
this._materialNode.setShader(this._shader);
this._time = 0;
diff --git a/js/lib/rdge/materials/star-material.js b/js/lib/rdge/materials/star-material.js
index 9c0f3172..cec93301 100644
--- a/js/lib/rdge/materials/star-material.js
+++ b/js/lib/rdge/materials/star-material.js
@@ -50,12 +50,12 @@ var StarMaterial = function StarMaterial() {
if (world) this.setWorld( world );
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = starMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode("starMaterial");
+ this._materialNode = RDGE.createMaterialNode("starMaterial");
this._materialNode.setShader(this._shader);
this._time = 0;
diff --git a/js/lib/rdge/materials/taper-material.js b/js/lib/rdge/materials/taper-material.js
index eeb08aec..7feea79a 100644
--- a/js/lib/rdge/materials/taper-material.js
+++ b/js/lib/rdge/materials/taper-material.js
@@ -45,7 +45,7 @@ function TaperMaterial()
this.init = function()
{
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = taperShaderDef;
this._shader.init();
@@ -53,7 +53,7 @@ function TaperMaterial()
this._shader.colorMe.color.set( this.getColor() );
// set up the material node
- this._materialNode = createMaterialNode("taperMaterial");
+ this._materialNode = RDGE.createMaterialNode("taperMaterial");
this._materialNode.setShader(this._shader);
// initialize the taper properties
diff --git a/js/lib/rdge/materials/tunnel-material.js b/js/lib/rdge/materials/tunnel-material.js
index fe787d16..53a2d4f2 100644
--- a/js/lib/rdge/materials/tunnel-material.js
+++ b/js/lib/rdge/materials/tunnel-material.js
@@ -51,12 +51,12 @@ var TunnelMaterial = function TunnelMaterial() {
if (world) this.setWorld( world );
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = tunnelMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode("tunnelMaterial");
+ this._materialNode = RDGE.createMaterialNode("tunnelMaterial");
this._materialNode.setShader(this._shader);
this._time = 0;
diff --git a/js/lib/rdge/materials/twist-material.js b/js/lib/rdge/materials/twist-material.js
index eb562e99..8648d60b 100644
--- a/js/lib/rdge/materials/twist-material.js
+++ b/js/lib/rdge/materials/twist-material.js
@@ -51,12 +51,12 @@ var TwistMaterial = function TwistMaterial() {
if (world) this.setWorld( world );
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = twistMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode("twistMaterial");
+ this._materialNode = RDGE.createMaterialNode("twistMaterial");
this._materialNode.setShader(this._shader);
this._time = 0;
@@ -75,7 +75,7 @@ var TwistMaterial = function TwistMaterial() {
if (material)
{
var technique = material.shaderProgram['default'];
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique) {
if (this._shader && this._shader['default'])
this._shader['default'].u_time.set( [this._time] );
diff --git a/js/lib/rdge/materials/twist-vert-material.js b/js/lib/rdge/materials/twist-vert-material.js
index c2573071..1f7b06b1 100644
--- a/js/lib/rdge/materials/twist-vert-material.js
+++ b/js/lib/rdge/materials/twist-vert-material.js
@@ -49,7 +49,7 @@ function TwistVertMaterial()
this.init = function()
{
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = twistVertShaderDef;
this._shader.init();
@@ -57,7 +57,7 @@ function TwistVertMaterial()
this._shader.twistMe.color.set( this.getColor() );
// set up the material node
- this._materialNode = createMaterialNode("twistVertMaterial");
+ this._materialNode = RDGE.createMaterialNode("twistVertMaterial");
this._materialNode.setShader(this._shader);
// initialize the twist vert properties
@@ -189,7 +189,7 @@ function TwistVertMaterial()
if (material)
{
var technique = material.shaderProgram['default'];
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique)
{
var texMapName = this._propValues[this._propNames[5]];
diff --git a/js/lib/rdge/materials/uber-material.js b/js/lib/rdge/materials/uber-material.js
index 6bc35d51..e2f86511 100755
--- a/js/lib/rdge/materials/uber-material.js
+++ b/js/lib/rdge/materials/uber-material.js
@@ -237,7 +237,7 @@ var UberMaterial = function UberMaterial() {
var material = this._materialNode;
if (material) {
var technique = material.shaderProgram.defaultTechnique;
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique) {
var tex = renderer.getTextureByName(value, caps.environmentMap.wrap);
this.registerTexture( tex );
@@ -265,7 +265,7 @@ var UberMaterial = function UberMaterial() {
var material = this._materialNode;
if (material) {
var technique = material.shaderProgram.defaultTechnique;
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique) {
var tex = renderer.getTextureByName(value, caps.diffuseMap.wrap);
this.registerTexture( tex );
@@ -293,7 +293,7 @@ var UberMaterial = function UberMaterial() {
var material = this._materialNode;
if (material) {
var technique = material.shaderProgram.defaultTechnique;
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique) {
var tex = renderer.getTextureByName(value, caps.specularMap.wrap);
this.registerTexture( tex );
@@ -321,7 +321,7 @@ var UberMaterial = function UberMaterial() {
var material = this._materialNode;
if (material) {
var technique = material.shaderProgram.defaultTechnique;
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if (renderer && technique) {
var tex = renderer.getTextureByName(value, caps.normalMap.wrap);
this.registerTexture( tex );
@@ -363,7 +363,7 @@ var UberMaterial = function UberMaterial() {
this._shader = this.buildUberShader( this._ubershaderCaps );
// set up the material node
- this._materialNode = createMaterialNode("uberMaterial");
+ this._materialNode = RDGE.createMaterialNode("uberMaterial");
this._materialNode.setShader(this._shader);
};
@@ -450,7 +450,7 @@ var UberMaterial = function UberMaterial() {
var fshader = preproc + uberFShader;
// build output jshader
- var uberJShader = new jshader();
+ var uberJShader = new RDGE.jshader();
uberJShader.def = {
'shaders': {
'defaultVShader': vshader,
@@ -517,9 +517,9 @@ var UberMaterial = function UberMaterial() {
}
}
}
- technique.u_uvMatrix.set(caps.uvTransform || mat4.identity());
+ technique.u_uvMatrix.set(caps.uvTransform || RDGE.mat4.identity());
- var renderer = g_Engine.getContext().renderer;
+ var renderer = RDGE.globals.engine.getContext().renderer;
if(this._useDiffuseMap) {
var tex = renderer.getTextureByName(caps.diffuseMap.texture, caps.diffuseMap.wrap, caps.diffuseMap.mips);
this.registerTexture( tex );
diff --git a/js/lib/rdge/materials/water-material.js b/js/lib/rdge/materials/water-material.js
index 92b96b18..0c7badf5 100644
--- a/js/lib/rdge/materials/water-material.js
+++ b/js/lib/rdge/materials/water-material.js
@@ -52,12 +52,12 @@ var WaterMaterial = function WaterMaterial() {
if (world) this.setWorld( world );
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = waterMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode("waterMaterial");
+ this._materialNode = RDGE.createMaterialNode("waterMaterial");
this._materialNode.setShader(this._shader);
this._time = 0;
diff --git a/js/lib/rdge/materials/z-invert-material.js b/js/lib/rdge/materials/z-invert-material.js
index 051b724f..fff01a15 100644
--- a/js/lib/rdge/materials/z-invert-material.js
+++ b/js/lib/rdge/materials/z-invert-material.js
@@ -29,7 +29,7 @@ var ZInvertMaterial = function ZInvertMaterial() {
///////////////////////////////////////////////////////////////////////
// Methods
///////////////////////////////////////////////////////////////////////
- // duplcate method requirde
+ // duplicate method required
this.dup = function( world ) {
// allocate a new uber material
var newMat = new ZInvertMaterial();
@@ -50,12 +50,12 @@ var ZInvertMaterial = function ZInvertMaterial() {
if (world) this.setWorld( world );
// set up the shader
- this._shader = new jshader();
+ this._shader = new RDGE.jshader();
this._shader.def = zInvertMaterialDef;
this._shader.init();
// set up the material node
- this._materialNode = createMaterialNode("zInvertMaterial");
+ this._materialNode = RDGE.createMaterialNode("zInvertMaterial");
this._materialNode.setShader(this._shader);
this._time = 0;
--
cgit v1.2.3
From 8d1cc709340da845d76f84220fe92c11e6217ff3 Mon Sep 17 00:00:00 2001
From: John Mayhew
Date: Tue, 3 Apr 2012 09:36:14 -0700
Subject: Made use of semicolons consistent and updated new files to use the
new RDGE namespace
---
js/lib/rdge/materials/cloud-material.js | 390 +++--
js/lib/rdge/materials/deform-material.js | 88 +-
js/lib/rdge/materials/flat-material.js | 151 +-
js/lib/rdge/materials/fly-material.js | 5 +-
js/lib/rdge/materials/julia-material.js | 2 +-
js/lib/rdge/materials/keleidoscope-material.js | 2 +-
js/lib/rdge/materials/linear-gradient-material.js | 489 +++---
js/lib/rdge/materials/mandel-material.js | 2 +-
js/lib/rdge/materials/material-parser.js | 81 +-
js/lib/rdge/materials/pulse-material.js | 10 +-
js/lib/rdge/materials/radial-blur-material.js | 446 +++---
js/lib/rdge/materials/radial-gradient-material.js | 495 +++---
js/lib/rdge/materials/relief-tunnel-material.js | 132 +-
js/lib/rdge/materials/square-tunnel-material.js | 133 +-
js/lib/rdge/materials/star-material.js | 133 +-
js/lib/rdge/materials/taper-material.js | 439 +++---
js/lib/rdge/materials/tunnel-material.js | 79 +-
js/lib/rdge/materials/twist-material.js | 161 +-
js/lib/rdge/materials/twist-vert-material.js | 486 +++---
js/lib/rdge/materials/uber-material.js | 1721 ++++++++++-----------
js/lib/rdge/materials/water-material.js | 275 ++--
js/lib/rdge/materials/z-invert-material.js | 132 +-
22 files changed, 2857 insertions(+), 2995 deletions(-)
(limited to 'js/lib')
diff --git a/js/lib/rdge/materials/cloud-material.js b/js/lib/rdge/materials/cloud-material.js
index 85088f91..092553ce 100644
--- a/js/lib/rdge/materials/cloud-material.js
+++ b/js/lib/rdge/materials/cloud-material.js
@@ -1,8 +1,8 @@
/*
- This file contains proprietary software owned by Motorola Mobility, Inc.
- No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
- (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
- */
+This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
+ */
var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser;
var Material = require("js/lib/rdge/materials/material").Material;
@@ -14,275 +14,263 @@ var CloudMaterial = function CloudMaterial() {
///////////////////////////////////////////////////////////////////////
// Instance variables
///////////////////////////////////////////////////////////////////////
- this._name = "CloudMaterial";
- this._shaderName = "cloud";
+ this._name = "CloudMaterial";
+ this._shaderName = "cloud";
- this._texMap = 'assets/images/cloud2.jpg';
- this._diffuseColor = [0.5, 0.5, 0.5, 0.5];
+ this._texMap = 'assets/images/cloud2.jpg';
+ this._diffuseColor = [0.5, 0.5, 0.5, 0.5];
- this._time = 0.0;
- this._dTime = 0.01;
+ this._time = 0.0;
+ this._dTime = 0.01;
///////////////////////////////////////////////////////////////////////
// Property Accessors
///////////////////////////////////////////////////////////////////////
- this.getName = function() { return this._name; };
- this.getShaderName = function() { return this._shaderName; };
+ this.getName = function () { return this._name; };
+ this.getShaderName = function () { return this._shaderName; };
- this.getTextureMap = function() { return this._propValues[this._propNames[0]] ? this._propValues[this._propNames[0]].slice() : null };
- this.setTextureMap = function(m) { this._propValues[this._propNames[0]] = m ? m.slice(0) : null; this.updateTexture(); };
+ this.getTextureMap = function () { return this._propValues[this._propNames[0]] ? this._propValues[this._propNames[0]].slice() : null };
+ this.setTextureMap = function (m) { this._propValues[this._propNames[0]] = m ? m.slice(0) : null; this.updateTexture(); };
- this.setDiffuseColor = function(c) { this._propValues[this._propNames[1]] = c.slice(0); this.updateColor(); };
- this.getDiffuseColor = function() { return this._propValues[this._propNames[1]] ? this._propValues[this._propNames[1]].slice() : null; };
+ this.setDiffuseColor = function (c) { this._propValues[this._propNames[1]] = c.slice(0); this.updateColor(); };
+ this.getDiffuseColor = function () { return this._propValues[this._propNames[1]] ? this._propValues[this._propNames[1]].slice() : null; };
- this.isAnimated = function() { return true; };
+ this.isAnimated = function () { return true; };
///////////////////////////////////////////////////////////////////////
// Material Property Accessors
///////////////////////////////////////////////////////////////////////
- this._propNames = ["texmap", "diffusecolor"];
- this._propLabels = ["Texture map", "Diffuse Color"];
- this._propTypes = ["file", "color"];
- this._propValues = [];
+ this._propNames = ["texmap", "diffusecolor"];
+ this._propLabels = ["Texture map", "Diffuse Color"];
+ this._propTypes = ["file", "color"];
+ this._propValues = [];
- this._propValues[ this._propNames[0] ] = this._texMap.slice(0);
- this._propValues[ this._propNames[1] ] = this._diffuseColor.slice();
+ this._propValues[this._propNames[0]] = this._texMap.slice(0);
+ this._propValues[this._propNames[1]] = this._diffuseColor.slice();
- this.setProperty = function( prop, value )
- {
- if (prop === 'color') prop = 'diffusecolor';
+ this.setProperty = function (prop, value) {
+ if (prop === 'color') prop = 'diffusecolor';
- // make sure we have legitimate imput
- var ok = this.validateProperty( prop, value );
- if (!ok) {
- console.log( "invalid property in Radial Gradient Material:" + prop + " : " + value );
+ // make sure we have legitimate imput
+ var ok = this.validateProperty(prop, value);
+ if (!ok) {
+ console.log("invalid property in Radial Gradient Material:" + prop + " : " + value);
}
- switch (prop)
- {
- case "texmap":
- this.setTextureMap(value);
- break;
-
- case "diffusecolor":
- this.setDiffuseColor( value );
- break;
-
- case "color":
- break;
- }
- };
+ switch (prop) {
+ case "texmap":
+ this.setTextureMap(value);
+ break;
+
+ case "diffusecolor":
+ this.setDiffuseColor(value);
+ break;
+
+ case "color":
+ break;
+ }
+ };
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
// Methods
///////////////////////////////////////////////////////////////////////
- // duplcate method requirde
- this.dup = function( world )
- {
- // save the world
- if (world) this.setWorld( world );
-
- // allocate a new uber material
- var newMat = new CloudMaterial();
-
- // copy over the current values;
- var propNames = [], propValues = [], propTypes = [], propLabels = [];
- this.getAllProperties( propNames, propValues, propTypes, propLabels);
- var n = propNames.length;
- for (var i=0; i 200.0) this._time = 0.0;
- }
- }
- };
+ if (this._time > 200.0) this._time = 0.0;
+ }
+ }
+ };
- // JSON export
- this.exportJSON = function()
- {
- var jObj =
+ // JSON export
+ this.exportJSON = function () {
+ var jObj =
{
- 'material' : this.getShaderName(),
- 'name' : this.getName(),
- 'texture' : this._propValues[this._propNames[0]]
+ 'material': this.getShaderName(),
+ 'name': this.getName(),
+ 'texture': this._propValues[this._propNames[0]]
};
- return jObj;
- };
+ return jObj;
+ };
- this.importJSON = function( jObj )
- {
- if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" );
- this.setName( jObj.name );
+ this.importJSON = function (jObj) {
+ if (this.getShaderName() != jObj.material) throw new Error("ill-formed material");
+ this.setName(jObj.name);
try {
- this._propValues[this._propNames[0]] = jObj.texture;
+ this._propValues[this._propNames[0]] = jObj.texture;
}
- catch (e)
- {
- throw new Error( "could not import material: " + jObj );
+ catch (e) {
+ throw new Error("could not import material: " + jObj);
}
- }
+ };
+
+ this.export = function () {
+ // every material needs the base type and instance name
+ var exportStr = "material: " + this.getShaderName() + "\n";
+ exportStr += "name: " + this.getName() + "\n";
- this.export = function() {
- // every material needs the base type and instance name
- var exportStr = "material: " + this.getShaderName() + "\n";
- exportStr += "name: " + this.getName() + "\n";
+ var world = this.getWorld();
+ if (!world)
+ throw new Error("no world in material.export, " + this.getName());
- var world = this.getWorld();
- if (!world)
- throw new Error( "no world in material.export, " + this.getName() );
+ var texMapName = this._propValues[this._propNames[0]];
+ exportStr += "texture: " + texMapName + "\n";
- var texMapName = this._propValues[this._propNames[0]];
- exportStr += "texture: " +texMapName + "\n";
-
- // every material needs to terminate like this
- exportStr += "endMaterial\n";
+ // every material needs to terminate like this
+ exportStr += "endMaterial\n";
- return exportStr;
- };
+ return exportStr;
+ };
- this.import = function( importStr ) {
- var pu = new MaterialParser( importStr );
- var material = pu.nextValue( "material: " );
- if (material != this.getShaderName()) throw new Error( "ill-formed material" );
- this.setName( pu.nextValue( "name: ") );
+ this.import = function (importStr) {
+ var pu = new MaterialParser(importStr);
+ var material = pu.nextValue("material: ");
+ if (material != this.getShaderName()) throw new Error("ill-formed material");
+ this.setName(pu.nextValue("name: "));
- var rtnStr;
+ var rtnStr;
try {
- this._propValues[this._propNames[0]] = pu.nextValue( "texture: " );
+ this._propValues[this._propNames[0]] = pu.nextValue("texture: ");
var endKey = "endMaterial\n";
- var index = importStr.indexOf( endKey );
+ var index = importStr.indexOf(endKey);
index += endKey.length;
- rtnStr = importStr.substr( index );
+ rtnStr = importStr.substr(index);
}
- catch (e)
- {
- throw new Error( "could not import material: " + importStr );
+ catch (e) {
+ throw new Error("could not import material: " + importStr);
}
- return rtnStr;
- }
+ return rtnStr;
+ };
};
///////////////////////////////////////////////////////////////////////////////////////
// RDGE shader
-
+
// shader spec (can also be loaded from a .JSON file, or constructed at runtime)
var cloudMaterialDef =
-{'shaders':
+{ 'shaders':
{
- 'defaultVShader':"assets/shaders/Cloud.vert.glsl",
- 'defaultFShader':"assets/shaders/Cloud.frag.glsl"
+ 'defaultVShader': "assets/shaders/Cloud.vert.glsl",
+ 'defaultFShader': "assets/shaders/Cloud.frag.glsl"
},
- 'techniques':
- {
- 'default':
+ 'techniques':
+ {
+ 'default':
[
{
- 'vshader' : 'defaultVShader',
- 'fshader' : 'defaultFShader',
- // attributes
- 'attributes' :
+ 'vshader': 'defaultVShader',
+ 'fshader': 'defaultFShader',
+ // attributes
+ 'attributes':
{
- 'vert' : { 'type' : 'vec3' },
- 'normal' : { 'type' : 'vec3' },
- 'texcoord' : { 'type' : 'vec2' }
+ 'vert': { 'type': 'vec3' },
+ 'normal': { 'type': 'vec3' },
+ 'texcoord': { 'type': 'vec2' }
},
- // parameters
- 'params' :
+ // parameters
+ 'params':
{
- 'u_tex0': { 'type' : 'tex2d' },
- 'u_time' : { 'type' : 'float' },
- 'u_DiffuseColor' : { 'type' : 'vec4' }
+ 'u_tex0': { 'type': 'tex2d' },
+ 'u_time': { 'type': 'float' },
+ 'u_DiffuseColor': { 'type': 'vec4' }
},
- // render states
- 'states' :
+ // render states
+ 'states':
{
- 'depthEnable' : true,
- 'offset':[1.0, 0.1]
+ 'depthEnable': true,
+ 'offset': [1.0, 0.1]
}
}
]
diff --git a/js/lib/rdge/materials/deform-material.js b/js/lib/rdge/materials/deform-material.js
index 8746bb47..328330bf 100644
--- a/js/lib/rdge/materials/deform-material.js
+++ b/js/lib/rdge/materials/deform-material.js
@@ -10,20 +10,20 @@ var DeformMaterial = function DeformMaterial() {
///////////////////////////////////////////////////////////////////////
// Instance variables
///////////////////////////////////////////////////////////////////////
- this._name = "DeformMaterial";
- this._shaderName = "deform";
+ this._name = "DeformMaterial";
+ this._shaderName = "deform";
- this._texMap = 'assets/images/rocky-normal.jpg';
+ this._texMap = 'assets/images/rocky-normal.jpg';
- this._time = 0.0;
- this._dTime = 0.01;
+ this._time = 0.0;
+ this._dTime = 0.01;
///////////////////////////////////////////////////////////////////////
// Properties
///////////////////////////////////////////////////////////////////////
- // all defined in parent PulseMaterial.js
- // load the local default value
- this._propValues[ this._propNames[0] ] = this._texMap.slice(0);
+ // all defined in parent PulseMaterial.js
+ // load the local default value
+ this._propValues[this._propNames[0]] = this._texMap.slice(0);
///////////////////////////////////////////////////////////////////////
// Material Property Accessors
@@ -35,44 +35,44 @@ var DeformMaterial = function DeformMaterial() {
///////////////////////////////////////////////////////////////////////
// Methods
///////////////////////////////////////////////////////////////////////
- // duplcate method requirde
- this.dup = function( world ) {
- // allocate a new uber material
- var newMat = new DeformMaterial();
-
- // copy over the current values;
- var propNames = [], propValues = [], propTypes = [], propLabels = [];
- this.getAllProperties( propNames, propValues, propTypes, propLabels);
- var n = propNames.length;
- for (var i=0; i