提交 8f20fe1c 编写于 作者: S Slayvin

added .clone() method to cameras

上级 25245257
......@@ -32,3 +32,16 @@ THREE.Camera.prototype.lookAt = function () {
};
}();
THREE.Camera.prototype.clone = function (camera) {
if ( camera === undefined ) camera = new THREE.Camera();
THREE.Object3D.prototype.clone.call( this, camera );
camera.matrixWorldInverse.copy(this.matrixWorldInverse);
camera.projectionMatrix.copy(this.projectionMatrix);
camera.projectionMatrixInverse.copy(this.projectionMatrixInverse);
return camera;
};
......@@ -25,3 +25,22 @@ THREE.OrthographicCamera.prototype.updateProjectionMatrix = function () {
this.projectionMatrix.makeOrthographic( this.left, this.right, this.top, this.bottom, this.near, this.far );
};
THREE.OrthographicCamera.prototype.clone = function () {
var camera = new THREE.OrthographicCamera();
THREE.Camera.prototype.clone.call( this, camera );
camera.left = this.left;
camera.right = this.right;
camera.top = this.top;
camera.bottom = this.bottom;
camera.near = this.near;
camera.far = this.far;
camera.updateProjectionMatrix();
return camera;
};
......@@ -114,3 +114,19 @@ THREE.PerspectiveCamera.prototype.updateProjectionMatrix = function () {
}
};
THREE.PerspectiveCamera.prototype.clone = function () {
var camera = new THREE.PerspectiveCamera();
THREE.Camera.prototype.clone.call( this, camera );
camera.fov = this.fov;
camera.aspect = this.aspect;
camera.near = this.near;
camera.far = this.far;
camera.updateProjectionMatrix();
return camera;
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册