diff options
author | hwc487 | 2012-03-23 13:46:40 -0700 |
---|---|---|
committer | hwc487 | 2012-03-23 13:46:40 -0700 |
commit | 8fa51b9d8c37896dfd13a5b238cf990fcbdb0c96 (patch) | |
tree | 6ff6213ca640084961d5a5974bc4b6fe0ace1760 /js/lib/rdge/materials | |
parent | e927e4702d7dbd4a878f6979b3f56b46758f93de (diff) | |
download | ninja-8fa51b9d8c37896dfd13a5b238cf990fcbdb0c96.tar.gz |
textures
Diffstat (limited to 'js/lib/rdge/materials')
-rwxr-xr-x | js/lib/rdge/materials/bump-metal-material.js | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/js/lib/rdge/materials/bump-metal-material.js b/js/lib/rdge/materials/bump-metal-material.js index ccd8e3ca..9c9a189a 100755 --- a/js/lib/rdge/materials/bump-metal-material.js +++ b/js/lib/rdge/materials/bump-metal-material.js | |||
@@ -20,10 +20,13 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
20 | this._shaderName = "bumpMetal"; | 20 | this._shaderName = "bumpMetal"; |
21 | 21 | ||
22 | this._lightDiff = [0.3, 0.3, 0.3, 1.0]; | 22 | this._lightDiff = [0.3, 0.3, 0.3, 1.0]; |
23 | //this._diffuseTexture = "assets/images/metal.png"; | 23 | |
24 | //this._diffuseTexture = "assets/images/metal.png"; | ||
24 | this._diffuseTexture = "texture"; | 25 | this._diffuseTexture = "texture"; |
25 | this._diffuseWorld = null; // the world that the texture is derived from (if there is one). | 26 | this._diffuseWorld = null; // the world that the texture is derived from (if there is one). |
26 | this._specularTexture = "assets/images/silver.png"; | 27 | this._diffuseTextureObj = null; |
28 | |||
29 | this._specularTexture = "assets/images/silver.png"; | ||
27 | this._normalTexture = "assets/images/normalMap.png"; | 30 | this._normalTexture = "assets/images/normalMap.png"; |
28 | 31 | ||
29 | /////////////////////////////////////////////////////////////////////// | 32 | /////////////////////////////////////////////////////////////////////// |
@@ -138,13 +141,20 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
138 | var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; | 141 | var viewUtils = require("js/helper-classes/3D/view-utils").ViewUtils; |
139 | var root = viewUtils.application.ninja.currentDocument.documentRoot; | 142 | var root = viewUtils.application.ninja.currentDocument.documentRoot; |
140 | this._diffuseWorld = this.findWorld( this._diffuseTexture, root ); | 143 | this._diffuseWorld = this.findWorld( this._diffuseTexture, root ); |
144 | if (this._diffuseWorld) | ||
145 | { | ||
146 | var world = this.getWorld(); | ||
147 | var tex = new Texture( world ); | ||
148 | this._diffuseTextureObj = tex; | ||
149 | tex.loadFromCanvas( world.getCanvas() ); | ||
150 | } | ||
141 | } | 151 | } |
142 | 152 | ||
143 | this.findWorld = function( id, elt ) | 153 | this.findWorld = function( id, elt ) |
144 | { | 154 | { |
145 | if (elt.id && elt.id === id) | 155 | if (elt.id && elt.id === id) |
146 | { | 156 | { |
147 | if (elt.eltModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) | 157 | if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) |
148 | { | 158 | { |
149 | var world = elt.elementModel.shapeModel.GLWorld; | 159 | var world = elt.elementModel.shapeModel.GLWorld; |
150 | return world; | 160 | return world; |
@@ -174,7 +184,11 @@ var BumpMetalMaterial = function BumpMetalMaterial() { | |||
174 | { | 184 | { |
175 | var texMapName = this._propValues[this._propNames[index]]; | 185 | var texMapName = this._propValues[this._propNames[index]]; |
176 | var wrap = 'REPEAT', mips = true; | 186 | var wrap = 'REPEAT', mips = true; |
177 | var tex = this.loadTexture( texMapName, wrap, mips ); | 187 | var tex; |
188 | if ((index === 1) && this._diffuseTextureObj) | ||
189 | tex = this._diffuseTextureObj.getTexture(); | ||
190 | else | ||
191 | tex = this.loadTexture( texMapName, wrap, mips ); | ||
178 | 192 | ||
179 | if (tex) | 193 | if (tex) |
180 | { | 194 | { |