68 lines
1.3 KiB
JavaScript
68 lines
1.3 KiB
JavaScript
/**
|
|
* R3.Box3
|
|
* @param apiComponent
|
|
* @constructor
|
|
*/
|
|
R3.Box3 = function(
|
|
apiComponent
|
|
) {
|
|
|
|
__RUNTIME_COMPONENT__;
|
|
|
|
__UPGRADE_TO_RUNTIME__;
|
|
};
|
|
|
|
R3.Box3.prototype = Object.create(R3.Component.prototype);
|
|
R3.Box3.prototype.constructor = R3.Box3;
|
|
|
|
/**
|
|
* Creates an instance R3.Box3
|
|
* @returns {*}
|
|
*/
|
|
R3.Box3.prototype.createInstance = function() {
|
|
|
|
switch (this.parent.runtime) {
|
|
case R3.Runtime.GRAPHICS :
|
|
this.instance = this.graphics.Box3(
|
|
this.min,
|
|
this.max
|
|
);
|
|
break;
|
|
case R3.Runtime.PHYSICS :
|
|
this.instance = this.physics.Box3(
|
|
this.min,
|
|
this.max
|
|
);
|
|
break;
|
|
default:
|
|
throw new Error('unhandled component runtime: ' + this.componentRuntime);
|
|
}
|
|
|
|
__CREATE_INSTANCE__;
|
|
|
|
};
|
|
|
|
/**
|
|
* Updates R3.Box3 instance
|
|
* @param property
|
|
*/
|
|
R3.Box3.prototype.updateInstance = function(property) {
|
|
|
|
if (property === 'min') {
|
|
this.instance.min.x = this.min.x;
|
|
this.instance.min.y = this.min.y;
|
|
this.instance.min.z = this.min.z;
|
|
return;
|
|
}
|
|
|
|
if (property === 'max') {
|
|
this.instance.max.x = this.max.x;
|
|
this.instance.max.y = this.max.y;
|
|
this.instance.max.z = this.max.z;
|
|
return;
|
|
}
|
|
|
|
__UPDATE_INSTANCE__;
|
|
|
|
};
|