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() { 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? if (this.chassis && this.chassis.instance) {
this.wheels.map( var instance = new CANNON.RaycastVehicle({
function(wheel){ chassisBody: this.chassis.instance
instance.addWheel(wheel.instance); });
} }
);
return instance; return instance;
}; };