fix parent mesh in linking

beta.r3js.org
Theunis J. Botha 2017-06-30 12:32:05 +02:00
parent 01fbf4e2ae
commit 9e038c3247
2 changed files with 32 additions and 0 deletions

View File

@ -354,6 +354,16 @@ GameLib.D3.Mesh.prototype.applyBones = function(geometry) {
}; };
GameLib.D3.Mesh.prototype.setParentMesh = function(parentMesh) {
this.parentMesh = parentMesh;
if (parentMesh && parentMesh.loaded) {
this.instance.parent = this.parentMesh.instance;
}
};
GameLib.D3.Mesh.prototype.createInstanceDefaults = function(instance) { GameLib.D3.Mesh.prototype.createInstanceDefaults = function(instance) {
instance.name = this.name; instance.name = this.name;

View File

@ -307,6 +307,28 @@ GameLib.System.Linking.prototype.meshInstanceCreated = function(data) {
} }
}); });
var meshes = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.Mesh);
/**
* Link Parent Meshes
*/
meshes.map(
function(mesh) {
if (mesh === data.mesh) {
return;
}
if (mesh.parentMesh === data.mesh.id) {
mesh.setParentMesh(data.mesh);
}
if (data.mesh.parentMesh === mesh.id) {
data.mesh.setParentMesh(mesh);
}
}.bind(this)
);
}; };
GameLib.System.Linking.prototype.lightInstanceCreated = function(data) { GameLib.System.Linking.prototype.lightInstanceCreated = function(data) {