r3-legacy/src/r3-d3-camera-perspective-0.js

97 lines
2.1 KiB
JavaScript

/**
* R3.D3.Camera.Perspective
* @param apiComponent
* @param inherited
* @constructor
*/
R3.D3.Camera.Perspective = function(
apiComponent,
inherited
) {
__INHERIT_AND_INSTANTIATE__
R3.D3.Camera.call(
this,
apiComponent,
true
);
};
R3.D3.Camera.Perspective.prototype = Object.create(R3.D3.Camera.prototype);
R3.D3.Camera.Perspective.prototype.constructor = R3.D3.Camera.Perspective;
/**
* Creates a camera instance
* @returns {*}
*/
R3.D3.Camera.Perspective.prototype.createInstance = function() {
this.instance = this.graphics.PerspectiveCamera(this);
__CREATE_INSTANCE__;
};
/**
* Updates the instance with the current state
*/
R3.D3.Camera.Perspective.prototype.updateInstance = function(property) {
if (property === 'position') {
this.instance.position.set(
this.position.x,
this.position.y,
this.position.z
);
this.instance.updateProjectionMatrix();
return;
}
if (property === 'near') {
this.instance.near = this.near;
this.instance.updateProjectionMatrix();
return;
}
if (property === 'far') {
this.instance.far = this.far;
this.instance.updateProjectionMatrix();
return;
}
if (property === 'fov') {
this.instance.fov = this.fov;
this.instance.updateProjectionMatrix();
return;
}
if (property === 'filmGauge') {
this.instance.filmGauge = this.filmGauge;
this.instance.updateProjectionMatrix();
return;
}
if (property === 'filmOffset') {
this.instance.filmOffset = this.filmOffset;
this.instance.updateProjectionMatrix();
return;
}
if (property === 'focus') {
this.instance.focus = this.focus;
this.instance.updateProjectionMatrix();
return;
}
if (property === 'zoom') {
this.instance.zoom = this.zoom;
this.instance.updateProjectionMatrix();
return;
}
R3.D3.Camera.prototype.updateInstance.call(this, property);
};