diff --git a/src/game-lib-a-component-a.js b/src/game-lib-a-component-a.js index ab7705c..d05e889 100644 --- a/src/game-lib-a-component-a.js +++ b/src/game-lib-a-component-a.js @@ -1982,6 +1982,13 @@ GameLib.Component.ConstructFromObject = function(rawComponentObject) { var runtimeComponent = null; + // if ( + // rawComponentObject.componentType === 34 && + // rawComponentObject.name.indexOf('Mesh') !== -1 + // ) { + // rawComponentObject.componentType = 7; + // } + var info = GameLib.Component.GetComponentInfo(rawComponentObject.componentType); var runtime = GameLib.Component.GetRuntimeObject(info.runtime); diff --git a/src/game-lib-d3-api-mesh-0.js b/src/game-lib-d3-api-mesh-0.js index b7db2b2..cbcbdaf 100644 --- a/src/game-lib-d3-api-mesh-0.js +++ b/src/game-lib-d3-api-mesh-0.js @@ -44,6 +44,19 @@ GameLib.D3.API.Mesh = function( if (GameLib.Utils.UndefinedOrNull(geometry)) { geometry = null; + + /** + * Backwards compatibility + */ + // if (apiD3Object.faces && apiD3Object.vertices) { + // geometry = new GameLib.D3.API.Geometry.Normal( + // { + // faces : apiD3Object.faces, + // vertices : apiD3Object.vertices + // } + // ); + // } + } this.geometry = geometry; diff --git a/src/game-lib-d3-geometry-buffer-a.js b/src/game-lib-d3-geometry-buffer-a.js index b6e4636..b6ec4dc 100644 --- a/src/game-lib-d3-geometry-buffer-a.js +++ b/src/game-lib-d3-geometry-buffer-a.js @@ -38,15 +38,11 @@ GameLib.D3.Geometry.Buffer = function( this.groups = this.groups.map( function(group) { - if (group instanceof GameLib.API.Group) { - return new GameLib.Group( - this.graphics, - group, - this - ) - } else { - return group; - } + return new GameLib.Group( + this.graphics, + group, + this + ) }.bind(this) ); @@ -460,7 +456,15 @@ GameLib.D3.Geometry.Buffer.prototype.toSingleMaterial = function() { 0 ); - this.groups = this.instance.groups; + this.groups = this.instance.groups.map( + function(group) { + return new GameLib.Group( + this.graphics, + group, + this + ) + }.bind(this) + ) } else { console.warn('this is not an indexed buffer geometry or geometry not loaded'); diff --git a/src/game-lib-d3-geometry-normal-a.js b/src/game-lib-d3-geometry-normal-a.js index 5ac9098..0b9c699 100644 --- a/src/game-lib-d3-geometry-normal-a.js +++ b/src/game-lib-d3-geometry-normal-a.js @@ -143,8 +143,9 @@ GameLib.D3.Geometry.Normal.prototype.createInstance = function() { this.applyToInstance('vertices'); //TODO: Below is actually for blender data - fix this server side and then remove this eventually - //this.instance.computeFaceNormals(); - //this.instance.computeVertexNormals(); + this.invertWindingOrder(); + this.computeFaceNormals(); + this.computeVertexNormals(); GameLib.D3.Geometry.prototype.createInstance.call(this); }; @@ -470,6 +471,14 @@ GameLib.D3.Geometry.Normal.prototype.computeVertexNormals = function() { this.instance.computeVertexNormals(); }; +/** + * Re-compute vertex normals + */ +GameLib.D3.Geometry.Normal.prototype.computeFaceNormals = function() { + console.log('re-computing face normals'); + this.instance.computeFaceNormals(); +}; + /** * Invert winding order */ diff --git a/src/game-lib-system-linking.js b/src/game-lib-system-linking.js index fc0383a..e50f04b 100644 --- a/src/game-lib-system-linking.js +++ b/src/game-lib-system-linking.js @@ -594,7 +594,7 @@ GameLib.System.Linking.prototype.instanceCreated = function(data) { */ GameLib.EntityManager.Instance.queryComponents(GameLib.Component.TEXTURE_IMAGE).map( function(texture) { - if (texture.image === data.component) { + if (texture.instance && texture.image === data.component) { texture.updateInstance('image'); } } @@ -602,7 +602,7 @@ GameLib.System.Linking.prototype.instanceCreated = function(data) { GameLib.EntityManager.Instance.queryComponents(GameLib.Component.TEXTURE_CUBE).map( function(texture) { - if (texture.images.indexOf(data.component) !== -1) { + if (texture.instance && texture.images.indexOf(data.component) !== -1) { texture.updateInstance('images'); } }