diff options
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/MeshManager.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/MeshManager.js | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/MeshManager.js b/js/helper-classes/RDGE/src/core/script/MeshManager.js index 81359fc4..1fff19c5 100755 --- a/js/helper-classes/RDGE/src/core/script/MeshManager.js +++ b/js/helper-classes/RDGE/src/core/script/MeshManager.js | |||
@@ -73,7 +73,7 @@ RDGE.MeshManager.prototype.loadMesh = function (meshStump, tempMesh) { | |||
73 | 73 | ||
74 | // add the temp mesh to the map of loaded meshes | 74 | // add the temp mesh to the map of loaded meshes |
75 | this.modelMap[meshStump.name] = tempMesh; | 75 | this.modelMap[meshStump.name] = tempMesh; |
76 | 76 | ||
77 | // update the request counter - we now have one more mesh to load | 77 | // update the request counter - we now have one more mesh to load |
78 | this.requestCounter++; | 78 | this.requestCounter++; |
79 | 79 | ||
@@ -87,7 +87,7 @@ RDGE.MeshManager.prototype.loadMesh = function (meshStump, tempMesh) { | |||
87 | */ | 87 | */ |
88 | RDGE.MeshManager.prototype.deleteMesh = function (name) { | 88 | RDGE.MeshManager.prototype.deleteMesh = function (name) { |
89 | var model = this.modelMap[name]; | 89 | var model = this.modelMap[name]; |
90 | 90 | ||
91 | if (model) { | 91 | if (model) { |
92 | RDGE.globals.engine.ctxMan.forEach(function (context) { | 92 | RDGE.globals.engine.ctxMan.forEach(function (context) { |
93 | context.renderer.deletePrimitive(model.primitive); | 93 | context.renderer.deletePrimitive(model.primitive); |
@@ -113,20 +113,20 @@ RDGE.MeshManager.prototype.getModelNames = function () { | |||
113 | 113 | ||
114 | RDGE.MeshManager.prototype.processMeshData = function () { | 114 | RDGE.MeshManager.prototype.processMeshData = function () { |
115 | var renderer = RDGE.globals.engine.getContext().renderer; | 115 | var renderer = RDGE.globals.engine.getContext().renderer; |
116 | 116 | ||
117 | // loop through meshes and load ready data | 117 | // loop through meshes and load ready data |
118 | for (var index in this.readyList) { | 118 | for (var index in this.readyList) { |
119 | // if item is ready load it | 119 | // if item is ready load it |
120 | if (this.readyList[index] && this.readyList[index].ready && renderer.id === this.readyList[index].ctxID) { | 120 | if (this.readyList[index] && this.readyList[index].ready && renderer.id === this.readyList[index].ctxID) { |
121 | 121 | ||
122 | 122 | ||
123 | // pop the item | 123 | // pop the item |
124 | var model = this.readyList[index]; | 124 | var model = this.readyList[index]; |
125 | this.readyList.splice(index, 1); | 125 | this.readyList.splice(index, 1); |
126 | 126 | ||
127 | var primset = new RDGE.rdgePrimitiveDefinition(); | 127 | var primset = new RDGE.rdgePrimitiveDefinition(); |
128 | 128 | ||
129 | primset.vertexDefinition = | 129 | primset.vertexDefinition = |
130 | { | 130 | { |
131 | // this shows two ways to map this data to an attribute | 131 | // this shows two ways to map this data to an attribute |
132 | "vert": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, | 132 | "vert": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, |
@@ -139,27 +139,27 @@ RDGE.MeshManager.prototype.processMeshData = function () { | |||
139 | "a_texcoords": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, | 139 | "a_texcoords": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, |
140 | "a_uv": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC } | 140 | "a_uv": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC } |
141 | }; | 141 | }; |
142 | 142 | ||
143 | primset.bufferStreams = | 143 | primset.bufferStreams = |
144 | [ | 144 | [ |
145 | model.root.data.coords, | 145 | model.root.data.coords, |
146 | model.root.data.normals, | 146 | model.root.data.normals, |
147 | model.root.data.uvs | 147 | model.root.data.uvs |
148 | ]; | 148 | ]; |
149 | 149 | ||
150 | primset.streamUsage = | 150 | primset.streamUsage = |
151 | [ | 151 | [ |
152 | RDGE.rdgeConstants.BUFFER_STATIC, | 152 | RDGE.rdgeConstants.BUFFER_STATIC, |
153 | RDGE.rdgeConstants.BUFFER_STATIC, | 153 | RDGE.rdgeConstants.BUFFER_STATIC, |
154 | RDGE.rdgeConstants.BUFFER_STATIC | 154 | RDGE.rdgeConstants.BUFFER_STATIC |
155 | ]; | 155 | ]; |
156 | 156 | ||
157 | primset.indexUsage = RDGE.rdgeConstants.BUFFER_STREAM; | 157 | primset.indexUsage = RDGE.rdgeConstants.BUFFER_STREAM; |
158 | 158 | ||
159 | primset.indexBuffer = model.root.data.indices; | 159 | primset.indexBuffer = model.root.data.indices; |
160 | 160 | ||
161 | renderer.createPrimitive( primset ); | 161 | renderer.createPrimitive( primset ); |
162 | 162 | ||
163 | model.root.primitive = primset; | 163 | model.root.primitive = primset; |
164 | 164 | ||
165 | // generate a bounding box for this mesh | 165 | // generate a bounding box for this mesh |
@@ -173,10 +173,10 @@ RDGE.MeshManager.prototype.processMeshData = function () { | |||
173 | } | 173 | } |
174 | 174 | ||
175 | this.modelMap[model.root.attribs.name] = model.root; | 175 | this.modelMap[model.root.attribs.name] = model.root; |
176 | 176 | ||
177 | // now that the model is load reduce the request count | 177 | // now that the model is load reduce the request count |
178 | this.requestCounter--; | 178 | this.requestCounter--; |
179 | 179 | ||
180 | this.onLoaded(model.root.attribs.name); | 180 | this.onLoaded(model.root.attribs.name); |
181 | //break; | 181 | //break; |
182 | } | 182 | } |
@@ -185,7 +185,7 @@ RDGE.MeshManager.prototype.processMeshData = function () { | |||
185 | }; | 185 | }; |
186 | 186 | ||
187 | RDGE.MeshManager.prototype.isReady = function () { | 187 | RDGE.MeshManager.prototype.isReady = function () { |
188 | return this.readyList.length == 0; | 188 | return this.readyList.length == 0; |
189 | }; | 189 | }; |
190 | 190 | ||
191 | RDGE.MeshManager.prototype.addOnLoadedCallback = function (callback) { | 191 | RDGE.MeshManager.prototype.addOnLoadedCallback = function (callback) { |
@@ -203,14 +203,14 @@ RDGE.MeshManager.prototype.exportJSON = function () { | |||
203 | for (var m in this.modelMap) { | 203 | for (var m in this.modelMap) { |
204 | this.modelMap[m].primitive.built = false; | 204 | this.modelMap[m].primitive.built = false; |
205 | } | 205 | } |
206 | 206 | ||
207 | return JSON.stringify(this.modelMap); | 207 | return JSON.stringify(this.modelMap); |
208 | }; | 208 | }; |
209 | 209 | ||
210 | RDGE.MeshManager.prototype.importJSON = function (jsonMeshExport) { | 210 | RDGE.MeshManager.prototype.importJSON = function (jsonMeshExport) { |
211 | try { | 211 | try { |
212 | var tempModelMap = JSON.parse(jsonMeshExport); | 212 | var tempModelMap = JSON.parse(jsonMeshExport); |
213 | 213 | ||
214 | for (var m in tempModelMap) { | 214 | for (var m in tempModelMap) { |
215 | if (!this.modelMap[m]) { | 215 | if (!this.modelMap[m]) { |
216 | this.modelMap[m] = tempModelMap[m]; | 216 | this.modelMap[m] = tempModelMap[m]; |
@@ -218,13 +218,13 @@ RDGE.MeshManager.prototype.importJSON = function (jsonMeshExport) { | |||
218 | } | 218 | } |
219 | window.console.log("meshes imported"); | 219 | window.console.log("meshes imported"); |
220 | } catch (e) { | 220 | } catch (e) { |
221 | window.console.error("error importing meshes: " + e.description ); | 221 | window.console.error("error importing meshes: " + e.description ); |
222 | } | 222 | } |
223 | }; | 223 | }; |
224 | 224 | ||
225 | /* | 225 | /* |
226 | * global function for the mesh manager to make mesh file requests | 226 | * global function for the mesh manager to make mesh file requests |
227 | */ | 227 | */ |
228 | RDGE.requestMesh = function (mesh) { | 228 | RDGE.requestMesh = function (mesh) { |
229 | var request = new XMLHttpRequest(); | 229 | var request = new XMLHttpRequest(); |
230 | request.mesh = mesh; | 230 | request.mesh = mesh; |