Browse Source

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

* expose reflector camera as a property

* clean up

* Expose Refractor camera property
LR17 3 years ago
parent
commit
211ca7f393
2 changed files with 4 additions and 2 deletions
  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;