|
@@ -732,7 +732,7 @@ Object.assign( Vector2.prototype, {
|
|
|
|
|
|
clamp: function ( min, max ) {
|
|
|
|
|
|
- // This function assumes min < max, if this assumption isn't true it will not operate correctly
|
|
|
+ // assumes min < max, componentwise
|
|
|
|
|
|
this.x = Math.max( min.x, Math.min( max.x, this.x ) );
|
|
|
this.y = Math.max( min.y, Math.min( max.y, this.y ) );
|
|
@@ -761,7 +761,7 @@ Object.assign( Vector2.prototype, {
|
|
|
|
|
|
var length = this.length();
|
|
|
|
|
|
- return this.multiplyScalar( Math.max( min, Math.min( max, length ) ) / length );
|
|
|
+ return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -836,7 +836,7 @@ Object.assign( Vector2.prototype, {
|
|
|
|
|
|
normalize: function () {
|
|
|
|
|
|
- return this.divideScalar( this.length() );
|
|
|
+ return this.divideScalar( this.length() || 1 );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -873,7 +873,7 @@ Object.assign( Vector2.prototype, {
|
|
|
|
|
|
setLength: function ( length ) {
|
|
|
|
|
|
- return this.multiplyScalar( length / this.length() );
|
|
|
+ return this.normalize().multiplyScalar( length );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -1664,7 +1664,7 @@ Object.assign( Vector4.prototype, {
|
|
|
|
|
|
clamp: function ( min, max ) {
|
|
|
|
|
|
- // This function assumes min < max, if this assumption isn't true it will not operate correctly
|
|
|
+ // assumes min < max, componentwise
|
|
|
|
|
|
this.x = Math.max( min.x, Math.min( max.x, this.x ) );
|
|
|
this.y = Math.max( min.y, Math.min( max.y, this.y ) );
|
|
@@ -1677,11 +1677,17 @@ Object.assign( Vector4.prototype, {
|
|
|
|
|
|
clampScalar: function () {
|
|
|
|
|
|
- var min = new Vector4();
|
|
|
- var max = new Vector4();
|
|
|
+ var min, max;
|
|
|
|
|
|
return function clampScalar( minVal, maxVal ) {
|
|
|
|
|
|
+ if ( min === undefined ) {
|
|
|
+
|
|
|
+ min = new Vector4();
|
|
|
+ max = new Vector4();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
min.set( minVal, minVal, minVal, minVal );
|
|
|
max.set( maxVal, maxVal, maxVal, maxVal );
|
|
|
|
|
@@ -1691,6 +1697,14 @@ Object.assign( Vector4.prototype, {
|
|
|
|
|
|
}(),
|
|
|
|
|
|
+ clampLength: function ( min, max ) {
|
|
|
+
|
|
|
+ var length = this.length();
|
|
|
+
|
|
|
+ return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
floor: function () {
|
|
|
|
|
|
this.x = Math.floor( this.x );
|
|
@@ -1772,13 +1786,13 @@ Object.assign( Vector4.prototype, {
|
|
|
|
|
|
normalize: function () {
|
|
|
|
|
|
- return this.divideScalar( this.length() );
|
|
|
+ return this.divideScalar( this.length() || 1 );
|
|
|
|
|
|
},
|
|
|
|
|
|
setLength: function ( length ) {
|
|
|
|
|
|
- return this.multiplyScalar( length / this.length() );
|
|
|
+ return this.normalize().multiplyScalar( length );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -2839,12 +2853,13 @@ Object.assign( Vector3.prototype, {
|
|
|
var x = this.x, y = this.y, z = this.z;
|
|
|
var e = m.elements;
|
|
|
|
|
|
- this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ];
|
|
|
- this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ];
|
|
|
- this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ];
|
|
|
- var w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ];
|
|
|
+ var w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] );
|
|
|
+
|
|
|
+ this.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w;
|
|
|
+ this.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w;
|
|
|
+ this.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w;
|
|
|
|
|
|
- return this.divideScalar( w );
|
|
|
+ return this;
|
|
|
|
|
|
},
|
|
|
|
|
@@ -2950,7 +2965,7 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
clamp: function ( min, max ) {
|
|
|
|
|
|
- // This function assumes min < max, if this assumption isn't true it will not operate correctly
|
|
|
+ // assumes min < max, componentwise
|
|
|
|
|
|
this.x = Math.max( min.x, Math.min( max.x, this.x ) );
|
|
|
this.y = Math.max( min.y, Math.min( max.y, this.y ) );
|
|
@@ -2980,7 +2995,7 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
var length = this.length();
|
|
|
|
|
|
- return this.multiplyScalar( Math.max( min, Math.min( max, length ) ) / length );
|
|
|
+ return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -3062,13 +3077,13 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
normalize: function () {
|
|
|
|
|
|
- return this.divideScalar( this.length() );
|
|
|
+ return this.divideScalar( this.length() || 1 );
|
|
|
|
|
|
},
|
|
|
|
|
|
setLength: function ( length ) {
|
|
|
|
|
|
- return this.multiplyScalar( length / this.length() );
|
|
|
+ return this.normalize().multiplyScalar( length );
|
|
|
|
|
|
},
|
|
|
|
|
@@ -3211,7 +3226,13 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
setFromMatrixPosition: function ( m ) {
|
|
|
|
|
|
- return this.setFromMatrixColumn( m, 3 );
|
|
|
+ var e = m.elements;
|
|
|
+
|
|
|
+ this.x = e[ 12 ];
|
|
|
+ this.y = e[ 13 ];
|
|
|
+ this.z = e[ 14 ];
|
|
|
+
|
|
|
+ return this;
|
|
|
|
|
|
},
|
|
|
|
|
@@ -3231,7 +3252,6 @@ Object.assign( Vector3.prototype, {
|
|
|
|
|
|
setFromMatrixColumn: function ( m, index ) {
|
|
|
|
|
|
-
|
|
|
return this.fromArray( m.elements, index * 4 );
|
|
|
|
|
|
},
|
|
@@ -19695,6 +19715,11 @@ function WebVRManager( renderer ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ var matrixWorldInverse = new THREE.Matrix4();
|
|
|
+
|
|
|
+ var standingMatrix = new THREE.Matrix4();
|
|
|
+ var standingMatrixInverse = new THREE.Matrix4();
|
|
|
+
|
|
|
var cameraL = new THREE.PerspectiveCamera();
|
|
|
cameraL.bounds = new THREE.Vector4( 0.0, 0.0, 0.5, 1.0 );
|
|
|
cameraL.layers.enable( 1 );
|
|
@@ -19737,6 +19762,7 @@ function WebVRManager( renderer ) {
|
|
|
//
|
|
|
|
|
|
this.enabled = false;
|
|
|
+ this.standing = false;
|
|
|
|
|
|
this.getDevice = function () {
|
|
|
|
|
@@ -19781,6 +19807,18 @@ function WebVRManager( renderer ) {
|
|
|
|
|
|
camera.updateMatrixWorld();
|
|
|
|
|
|
+ var stageParameters = device.stageParameters;
|
|
|
+
|
|
|
+ if ( this.standing && stageParameters ) {
|
|
|
+
|
|
|
+ standingMatrix.fromArray( stageParameters.sittingToStandingTransform );
|
|
|
+ standingMatrixInverse.getInverse( standingMatrix );
|
|
|
+
|
|
|
+ camera.matrixWorld.multiply( standingMatrix );
|
|
|
+ camera.matrixWorldInverse.multiply( standingMatrixInverse );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
if ( device.isPresenting === false ) return camera;
|
|
|
|
|
|
//
|
|
@@ -19791,12 +19829,21 @@ function WebVRManager( renderer ) {
|
|
|
cameraL.matrixWorldInverse.fromArray( frameData.leftViewMatrix );
|
|
|
cameraR.matrixWorldInverse.fromArray( frameData.rightViewMatrix );
|
|
|
|
|
|
+ if ( this.standing && stageParameters ) {
|
|
|
+
|
|
|
+ cameraL.matrixWorldInverse.multiply( standingMatrixInverse );
|
|
|
+ cameraR.matrixWorldInverse.multiply( standingMatrixInverse );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
var parent = camera.parent;
|
|
|
|
|
|
if ( parent !== null ) {
|
|
|
|
|
|
- cameraL.matrixWorldInverse.multiply( parent.matrixWorldInverse );
|
|
|
- cameraR.matrixWorldInverse.multiply( parent.matrixWorldInverse );
|
|
|
+ matrixWorldInverse.getInverse( parent.matrixWorld );
|
|
|
+
|
|
|
+ cameraL.matrixWorldInverse.multiply( matrixWorldInverse );
|
|
|
+ cameraR.matrixWorldInverse.multiply( matrixWorldInverse );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -19834,6 +19881,18 @@ function WebVRManager( renderer ) {
|
|
|
|
|
|
};
|
|
|
|
|
|
+ this.getStandingMatrix = function () {
|
|
|
+
|
|
|
+ return standingMatrix;
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ this.submitFrame = function () {
|
|
|
+
|
|
|
+ if ( device && device.isPresenting ) device.submitFrame();
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -21142,8 +21201,6 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
// update camera matrices and frustum
|
|
|
|
|
|
- camera.onBeforeRender( _this );
|
|
|
-
|
|
|
if ( camera.parent === null ) camera.updateMatrixWorld();
|
|
|
|
|
|
if ( vr.enabled ) {
|
|
@@ -21279,27 +21336,33 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- //
|
|
|
+ // render scene
|
|
|
|
|
|
- var opaqueObjects = currentRenderList.opaque;
|
|
|
- var transparentObjects = currentRenderList.transparent;
|
|
|
+ if ( camera.isArrayCamera ) {
|
|
|
|
|
|
- if ( scene.overrideMaterial ) {
|
|
|
+ var cameras = camera.cameras;
|
|
|
|
|
|
- var overrideMaterial = scene.overrideMaterial;
|
|
|
+ for ( var j = 0, jl = cameras.length; j < jl; j ++ ) {
|
|
|
|
|
|
- if ( opaqueObjects.length ) renderObjects( opaqueObjects, scene, camera, overrideMaterial );
|
|
|
- if ( transparentObjects.length ) renderObjects( transparentObjects, scene, camera, overrideMaterial );
|
|
|
+ var camera2 = cameras[ j ];
|
|
|
+ var bounds = camera2.bounds;
|
|
|
|
|
|
- } else {
|
|
|
+ var x = bounds.x * _width;
|
|
|
+ var y = bounds.y * _height;
|
|
|
+ var width = bounds.z * _width;
|
|
|
+ var height = bounds.w * _height;
|
|
|
|
|
|
- // opaque pass (front-to-back order)
|
|
|
+ _this.setViewport( x, y, width, height );
|
|
|
+ _this.setScissor( x, y, width, height );
|
|
|
+ _this.setScissorTest( true );
|
|
|
|
|
|
- if ( opaqueObjects.length ) renderObjects( opaqueObjects, scene, camera );
|
|
|
+ renderScene( currentRenderList, scene, camera2 );
|
|
|
|
|
|
- // transparent pass (back-to-front order)
|
|
|
+ }
|
|
|
|
|
|
- if ( transparentObjects.length ) renderObjects( transparentObjects, scene, camera );
|
|
|
+ } else {
|
|
|
+
|
|
|
+ renderScene( currentRenderList, scene, camera );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -21328,7 +21391,11 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- camera.onAfterRender( _this );
|
|
|
+ if ( vr.enabled ) {
|
|
|
+
|
|
|
+ vr.submitFrame();
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
// _gl.finish();
|
|
|
|
|
@@ -21483,46 +21550,46 @@ function WebGLRenderer( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- function renderObjects( renderList, scene, camera, overrideMaterial ) {
|
|
|
+ function renderScene( renderList, scene, camera ) {
|
|
|
|
|
|
- for ( var i = 0, l = renderList.length; i < l; i ++ ) {
|
|
|
+ var opaqueObjects = renderList.opaque;
|
|
|
+ var transparentObjects = renderList.transparent;
|
|
|
|
|
|
- var renderItem = renderList[ i ];
|
|
|
+ if ( scene.overrideMaterial ) {
|
|
|
|
|
|
- var object = renderItem.object;
|
|
|
- var geometry = renderItem.geometry;
|
|
|
- var material = overrideMaterial === undefined ? renderItem.material : overrideMaterial;
|
|
|
- var group = renderItem.group;
|
|
|
+ var overrideMaterial = scene.overrideMaterial;
|
|
|
|
|
|
- object.onBeforeRender( _this, scene, camera, geometry, material, group );
|
|
|
+ if ( opaqueObjects.length ) renderObjects( opaqueObjects, scene, camera, overrideMaterial );
|
|
|
+ if ( transparentObjects.length ) renderObjects( transparentObjects, scene, camera, overrideMaterial );
|
|
|
|
|
|
- if ( camera.isArrayCamera ) {
|
|
|
+ } else {
|
|
|
|
|
|
- var cameras = camera.cameras;
|
|
|
+ // opaque pass (front-to-back order)
|
|
|
|
|
|
- for ( var j = 0, jl = cameras.length; j < jl; j ++ ) {
|
|
|
+ if ( opaqueObjects.length ) renderObjects( opaqueObjects, scene, camera );
|
|
|
|
|
|
- var camera2 = cameras[ j ];
|
|
|
- var bounds = camera2.bounds;
|
|
|
+ // transparent pass (back-to-front order)
|
|
|
|
|
|
- var x = bounds.x * _width;
|
|
|
- var y = bounds.y * _height;
|
|
|
- var width = bounds.z * _width;
|
|
|
- var height = bounds.w * _height;
|
|
|
+ if ( transparentObjects.length ) renderObjects( transparentObjects, scene, camera );
|
|
|
|
|
|
- _this.setViewport( x, y, width, height );
|
|
|
- _this.setScissor( x, y, width, height );
|
|
|
- _this.setScissorTest( true );
|
|
|
+ }
|
|
|
|
|
|
- renderObject( object, scene, camera2, geometry, material, group );
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ function renderObjects( renderItems, scene, camera, overrideMaterial ) {
|
|
|
|
|
|
- } else {
|
|
|
+ for ( var i = 0, l = renderItems.length; i < l; i ++ ) {
|
|
|
|
|
|
- renderObject( object, scene, camera, geometry, material, group );
|
|
|
+ var renderItem = renderItems[ i ];
|
|
|
|
|
|
- }
|
|
|
+ var object = renderItem.object;
|
|
|
+ var geometry = renderItem.geometry;
|
|
|
+ var material = overrideMaterial === undefined ? renderItem.material : overrideMaterial;
|
|
|
+ var group = renderItem.group;
|
|
|
+
|
|
|
+ object.onBeforeRender( _this, scene, camera, geometry, material, group );
|
|
|
+
|
|
|
+ renderObject( object, scene, camera, geometry, material, group );
|
|
|
|
|
|
object.onAfterRender( _this, scene, camera, geometry, material, group );
|
|
|
|