runtime vectors
parent
87d327cb4a
commit
296d7ca836
|
@ -419,10 +419,10 @@ GameLib.D3.Mesh.prototype.createInstance = function(update) {
|
||||||
instance.scale.y = this.scale.y;
|
instance.scale.y = this.scale.y;
|
||||||
instance.scale.z = this.scale.z;
|
instance.scale.z = this.scale.z;
|
||||||
|
|
||||||
instance.quaternion.x = this.quaternion.x;
|
// instance.quaternion.x = this.quaternion.x;
|
||||||
instance.quaternion.y = this.quaternion.y;
|
// instance.quaternion.y = this.quaternion.y;
|
||||||
instance.quaternion.z = this.quaternion.z;
|
// instance.quaternion.z = this.quaternion.z;
|
||||||
instance.quaternion.w = this.quaternion.w;
|
// instance.quaternion.w = this.quaternion.w;
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
|
@ -500,6 +500,24 @@ GameLib.D3.Scene.LoadScene = function(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
gameLibMesh.position = new GameLib.D3.Vector3.Runtime(
|
||||||
|
graphics,
|
||||||
|
gameLibMesh,
|
||||||
|
gameLibMesh.position
|
||||||
|
);
|
||||||
|
|
||||||
|
gameLibMesh.rotation = new GameLib.D3.Vector3.Runtime(
|
||||||
|
graphics,
|
||||||
|
gameLibMesh,
|
||||||
|
gameLibMesh.rotation
|
||||||
|
);
|
||||||
|
|
||||||
|
gameLibMesh.scale = new GameLib.D3.Vector3.Runtime(
|
||||||
|
graphics,
|
||||||
|
gameLibMesh,
|
||||||
|
gameLibMesh.scale
|
||||||
|
);
|
||||||
|
|
||||||
gameLibMeshes.push(gameLibMesh);
|
gameLibMeshes.push(gameLibMesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,50 @@ GameLib.D3.Vector3 = function Vector3(x, y, z) {
|
||||||
this.z = z || 0;
|
this.z = z || 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runtime vector for updating instance objects
|
||||||
|
* @param graphics GameLib.D3.Graphics
|
||||||
|
* @param parentObject GameLib.D3.*
|
||||||
|
* @param apiVector GameLib.D3.Vector3
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
GameLib.D3.Vector3.Runtime = function RuntimeVector3(graphics, parentObject, apiVector) {
|
||||||
|
|
||||||
|
for (var property in apiVector) {
|
||||||
|
if (apiVector.hasOwnProperty(property)) {
|
||||||
|
this[property] = apiVector[property];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.apiVector = apiVector;
|
||||||
|
|
||||||
|
this.graphics = graphics;
|
||||||
|
|
||||||
|
this.graphics.isNotThreeThrow();
|
||||||
|
|
||||||
|
this.parentObject = parentObject;
|
||||||
|
|
||||||
|
this.instance = this.createInstance();
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Vector3.Runtime.prototype.createInstance = function() {
|
||||||
|
return this.graphics.instance.Vector3(this.x, this.y, this.z);
|
||||||
|
};
|
||||||
|
|
||||||
|
GameLib.D3.Vector3.Runtime.prototype.updateInstance = function() {
|
||||||
|
|
||||||
|
if (this.parentObject.updateInstance) {
|
||||||
|
this.parentObject.updateInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.apiVector.x = this.x;
|
||||||
|
this.apiVector.y = this.y;
|
||||||
|
this.apiVector.z = this.z;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GameLib.D3.Vector3.prototype.subtract = function (v) {
|
GameLib.D3.Vector3.prototype.subtract = function (v) {
|
||||||
return new GameLib.D3.Vector3(
|
return new GameLib.D3.Vector3(
|
||||||
this.x - v.x,
|
this.x - v.x,
|
||||||
|
|
Loading…
Reference in New Issue