delayed instance creation

beta.r3js.org
-=yb4f310 2017-09-02 12:55:43 +02:00
parent c5bb684272
commit 7055891a84
1 changed files with 12 additions and 9 deletions

View File

@ -66,16 +66,19 @@ GameLib.D3.RaycastVehicle.prototype.constructor = GameLib.D3.RaycastVehicle;
*/
GameLib.D3.RaycastVehicle.prototype.createInstance = function() {
var instance = new CANNON.RaycastVehicle({
chassisBody: this.chassis.instance
});
/**
* At this point - even though this component exists - the chassis could maybe not been have assigned, failed to
* register as a dependency, and therefore is not present at the time of createInstance() - we will need to call
* delayedInstance somehow...
* @type {GameLib.D3.RaycastVehicle|GameLib.D3.API.RaycastVehicle|*}
*/
var instance = false;
//TODO: maybe move this into linking system - ALSO - store a reference to the wheel somehow to update the wheel instance?
this.wheels.map(
function(wheel){
instance.addWheel(wheel.instance);
}
);
if (this.chassis && this.chassis.instance) {
var instance = new CANNON.RaycastVehicle({
chassisBody: this.chassis.instance
});
}
return instance;
};