groups and winding order2
parent
6196c77605
commit
c1749c7482
|
@ -1982,6 +1982,13 @@ GameLib.Component.ConstructFromObject = function(rawComponentObject) {
|
||||||
|
|
||||||
var runtimeComponent = null;
|
var runtimeComponent = null;
|
||||||
|
|
||||||
|
// if (
|
||||||
|
// rawComponentObject.componentType === 34 &&
|
||||||
|
// rawComponentObject.name.indexOf('Mesh') !== -1
|
||||||
|
// ) {
|
||||||
|
// rawComponentObject.componentType = 7;
|
||||||
|
// }
|
||||||
|
|
||||||
var info = GameLib.Component.GetComponentInfo(rawComponentObject.componentType);
|
var info = GameLib.Component.GetComponentInfo(rawComponentObject.componentType);
|
||||||
|
|
||||||
var runtime = GameLib.Component.GetRuntimeObject(info.runtime);
|
var runtime = GameLib.Component.GetRuntimeObject(info.runtime);
|
||||||
|
|
|
@ -44,6 +44,19 @@ GameLib.D3.API.Mesh = function(
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(geometry)) {
|
if (GameLib.Utils.UndefinedOrNull(geometry)) {
|
||||||
geometry = null;
|
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;
|
this.geometry = geometry;
|
||||||
|
|
||||||
|
|
|
@ -38,15 +38,11 @@ GameLib.D3.Geometry.Buffer = function(
|
||||||
|
|
||||||
this.groups = this.groups.map(
|
this.groups = this.groups.map(
|
||||||
function(group) {
|
function(group) {
|
||||||
if (group instanceof GameLib.API.Group) {
|
|
||||||
return new GameLib.Group(
|
return new GameLib.Group(
|
||||||
this.graphics,
|
this.graphics,
|
||||||
group,
|
group,
|
||||||
this
|
this
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
return group;
|
|
||||||
}
|
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -460,7 +456,15 @@ GameLib.D3.Geometry.Buffer.prototype.toSingleMaterial = function() {
|
||||||
0
|
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 {
|
} else {
|
||||||
console.warn('this is not an indexed buffer geometry or geometry not loaded');
|
console.warn('this is not an indexed buffer geometry or geometry not loaded');
|
||||||
|
|
|
@ -143,8 +143,9 @@ GameLib.D3.Geometry.Normal.prototype.createInstance = function() {
|
||||||
this.applyToInstance('vertices');
|
this.applyToInstance('vertices');
|
||||||
|
|
||||||
//TODO: Below is actually for blender data - fix this server side and then remove this eventually
|
//TODO: Below is actually for blender data - fix this server side and then remove this eventually
|
||||||
//this.instance.computeFaceNormals();
|
this.invertWindingOrder();
|
||||||
//this.instance.computeVertexNormals();
|
this.computeFaceNormals();
|
||||||
|
this.computeVertexNormals();
|
||||||
|
|
||||||
GameLib.D3.Geometry.prototype.createInstance.call(this);
|
GameLib.D3.Geometry.prototype.createInstance.call(this);
|
||||||
};
|
};
|
||||||
|
@ -470,6 +471,14 @@ GameLib.D3.Geometry.Normal.prototype.computeVertexNormals = function() {
|
||||||
this.instance.computeVertexNormals();
|
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
|
* Invert winding order
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -594,7 +594,7 @@ GameLib.System.Linking.prototype.instanceCreated = function(data) {
|
||||||
*/
|
*/
|
||||||
GameLib.EntityManager.Instance.queryComponents(GameLib.Component.TEXTURE_IMAGE).map(
|
GameLib.EntityManager.Instance.queryComponents(GameLib.Component.TEXTURE_IMAGE).map(
|
||||||
function(texture) {
|
function(texture) {
|
||||||
if (texture.image === data.component) {
|
if (texture.instance && texture.image === data.component) {
|
||||||
texture.updateInstance('image');
|
texture.updateInstance('image');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -602,7 +602,7 @@ GameLib.System.Linking.prototype.instanceCreated = function(data) {
|
||||||
|
|
||||||
GameLib.EntityManager.Instance.queryComponents(GameLib.Component.TEXTURE_CUBE).map(
|
GameLib.EntityManager.Instance.queryComponents(GameLib.Component.TEXTURE_CUBE).map(
|
||||||
function(texture) {
|
function(texture) {
|
||||||
if (texture.images.indexOf(data.component) !== -1) {
|
if (texture.instance && texture.images.indexOf(data.component) !== -1) {
|
||||||
texture.updateInstance('images');
|
texture.updateInstance('images');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue