Skip to content

Commit

Permalink
Merge pull request mrdoob#12631 from WestLangley/dev-reflector_geometry
Browse files Browse the repository at this point in the history
Generalize Reflector geometry
  • Loading branch information
mrdoob authored Nov 12, 2017
2 parents e4cb0f3 + 1663e81 commit 820c61a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 21 deletions.
22 changes: 11 additions & 11 deletions examples/js/objects/Reflector.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* @author Slayvin / http://slayvin.net
*/

THREE.Reflector = function ( width, height, options ) {
THREE.Reflector = function ( geometry, options ) {

THREE.Mesh.call( this, new THREE.PlaneBufferGeometry( width, height ) );
THREE.Mesh.call( this, geometry );

this.type = 'Reflector';

Expand Down Expand Up @@ -65,15 +65,15 @@ THREE.Reflector = function ( width, height, options ) {

this.material = material;

this.onBeforeRender = function ( renderer, scene, camera ) {

if ( 'recursion' in camera.userData ) {

if ( camera.userData.recursion === recursion ) return;

camera.userData.recursion ++;

}
this.onBeforeRender = function ( renderer, scene, camera ) {

if ( 'recursion' in camera.userData ) {

if ( camera.userData.recursion === recursion ) return;

camera.userData.recursion ++;

}

reflectorWorldPosition.setFromMatrixPosition( scope.matrixWorld );
cameraWorldPosition.setFromMatrixPosition( camera.matrixWorld );
Expand Down
4 changes: 2 additions & 2 deletions examples/js/objects/ReflectorRTT.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
THREE.ReflectorRTT = function ( width, height, options ) {
THREE.ReflectorRTT = function ( geometry, options ) {

THREE.Reflector.call( this, width, height, options );
THREE.Reflector.call( this, geometry, options );

this.geometry.setDrawRange( 0, 0 ); // avoid rendering geometry

Expand Down
4 changes: 2 additions & 2 deletions examples/js/objects/Refractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
*
*/

THREE.Refractor = function ( width, height, options ) {
THREE.Refractor = function ( geometry, options ) {

THREE.Mesh.call( this, new THREE.PlaneBufferGeometry( width, height ) );
THREE.Mesh.call( this, geometry );

this.type = 'Refractor';

Expand Down
10 changes: 6 additions & 4 deletions examples/webgl_mirror.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@

var planeGeo = new THREE.PlaneBufferGeometry( 100.1, 100.1 );

// reflector/mirror planes
// reflectors/mirrors

var groundMirror = new THREE.Reflector( 100, 100, {
var geometry = new THREE.PlaneBufferGeometry( 100, 100 );
var groundMirror = new THREE.Reflector( geometry, {
clipBias: 0.003,
textureWidth: WIDTH * window.devicePixelRatio,
textureHeight: HEIGHT * window.devicePixelRatio,
Expand All @@ -98,14 +99,15 @@
groundMirror.rotateX( - Math.PI / 2 );
scene.add( groundMirror );

var verticalMirror = new THREE.Reflector( 60, 60, {
var geometry = new THREE.CircleBufferGeometry( 40, 6 );
var verticalMirror = new THREE.Reflector( geometry, {
clipBias: 0.003,
textureWidth: WIDTH * window.devicePixelRatio,
textureHeight: HEIGHT * window.devicePixelRatio,
color: 0x889999,
recursion: 1
} );
verticalMirror.position.y = 35;
verticalMirror.position.y = 50;
verticalMirror.position.z = -45;
scene.add( verticalMirror );

Expand Down
3 changes: 2 additions & 1 deletion examples/webgl_mirror_nodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@
var planeGeo = new THREE.PlaneBufferGeometry( 100.1, 100.1 );

// reflector/mirror plane
var groundMirror = new THREE.ReflectorRTT( 100, 100, { clipBias: 0.003, textureWidth: WIDTH, textureHeight: HEIGHT } );
var geometry = new THREE.PlaneBufferGeometry( 100, 100 );
var groundMirror = new THREE.ReflectorRTT( geometry, { clipBias: 0.003, textureWidth: WIDTH, textureHeight: HEIGHT } );

var mask = new THREE.SwitchNode( new THREE.TextureNode( decalDiffuse ), 'w' );
var maskFlip = new THREE.Math1Node( mask, THREE.Math1Node.INVERT );
Expand Down
3 changes: 2 additions & 1 deletion examples/webvr_sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@

//

reflector = new THREE.Reflector( 1.4, 1.4, {
var geometry = new THREE.PlaneBufferGeometry( 1.4, 1.4 );
reflector = new THREE.Reflector( geometry, {
textureWidth: window.innerWidth * window.devicePixelRatio,
textureHeight: window.innerHeight * window.devicePixelRatio
} );
Expand Down

0 comments on commit 820c61a

Please sign in to comment.