浏览代码

Reflector/Refractor: Expose virtual camera as a property. (#23890)

* expose reflector camera as a property

* clean up

* Expose Refractor camera property
LR17 3 年之前
父节点
当前提交
211ca7f393
共有 2 个文件被更改,包括 4 次插入2 次删除
  1. 2 1
      examples/jsm/objects/Reflector.js
  2. 2 1
      examples/jsm/objects/Refractor.js

+ 2 - 1
examples/jsm/objects/Reflector.js

@@ -18,6 +18,7 @@ class Reflector extends Mesh {
 		super( geometry );
 
 		this.type = 'Reflector';
+		this.camera = new PerspectiveCamera();
 
 		const scope = this;
 
@@ -43,7 +44,7 @@ class Reflector extends Mesh {
 		const q = new Vector4();
 
 		const textureMatrix = new Matrix4();
-		const virtualCamera = new PerspectiveCamera();
+		const virtualCamera = this.camera;
 
 		const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight, { samples: multisample } );
 

+ 2 - 1
examples/jsm/objects/Refractor.js

@@ -19,6 +19,7 @@ class Refractor extends Mesh {
 		super( geometry );
 
 		this.type = 'Refractor';
+		this.camera = new PerspectiveCamera();
 
 		const scope = this;
 
@@ -31,7 +32,7 @@ class Refractor extends Mesh {
 
 		//
 
-		const virtualCamera = new PerspectiveCamera();
+		const virtualCamera = this.camera;
 		virtualCamera.matrixAutoUpdate = false;
 		virtualCamera.userData.refractor = true;