Jelajahi Sumber

Merge remote-tracking branch 'remotes/upstream/dev' into dev

webglzhang 5 tahun lalu
induk
melakukan
75fb3aa851

File diff ditekan karena terlalu besar
+ 29 - 48
build/three.js


File diff ditekan karena terlalu besar
+ 185 - 192
build/three.min.js


File diff ditekan karena terlalu besar
+ 29 - 48
build/three.module.js


+ 2 - 1
docs/api/en/math/Box2.html

@@ -174,7 +174,8 @@
 			[page:Vector2 min] - (required ) [page:Vector2] representing the lower (x, y) boundary of the box. <br>
 			[page:Vector2 max]  - (required) [page:Vector2] representing the upper (x, y) boundary of the box. <br /><br />
 
-			Sets the lower and upper (x, y) boundaries of this box.
+			Sets the lower and upper (x, y) boundaries of this box.<br>
+			Please note that this method only copies the values from the given objects.
 		</p>
 
 		<h3>[method:Box2 setFromCenterAndSize]( [param:Vector2 center], [param:Vector2 size] )</h3>

+ 4 - 1
docs/api/en/math/Box3.html

@@ -138,6 +138,7 @@
 
 		Expands the boundaries of this box to include [page:Object3D object] and its children,
 		accounting for the object's, and children's, world transforms.
+		The function may result in a larger box than strictly necessary.
 
 		</p>
 
@@ -247,7 +248,8 @@
 		[page:Vector3 min] - [page:Vector3] representing the lower (x, y, z) boundary of the box.<br />
 		[page:Vector3 max] - [page:Vector3] representing the lower upper (x, y, z) boundary of the box.<br /><br />
 
-		Sets the lower and upper (x, y, z) boundaries of this box.
+		Sets the lower and upper (x, y, z) boundaries of this box.<br>
+		Please note that this method only copies the values from the given objects.
 		</p>
 
 		<h3>[method:Box3 setFromArray]( [param:Array array] ) [param:Box3 this]</h3>
@@ -279,6 +281,7 @@
 
 		Computes the world-axis-aligned bounding box of an [page:Object3D] (including its children),
 		accounting for the object's, and children's, world transforms.
+		The function may result in a larger box than strictly necessary.
 
 		</p>
 

+ 2 - 1
docs/api/en/math/Frustum.html

@@ -91,7 +91,8 @@
 
 		<h3>[method:Frustum set]( [param:Plane p0], [param:Plane p1], [param:Plane p2], [param:Plane p3], [param:Plane p4], [param:Plane p5] )</h3>
 		<p>
-		Sets the current frustum from the passed planes. No plane order is implicitely implied.
+		Sets the current frustum from the passed planes. No plane order is implicitely implied.<br>
+		Please note that this method only copies the values from the given objects.
 		</p>
 
 		<h3>[method:Frustum setFromMatrix]( [param:Matrix4 matrix] )</h3>

+ 1 - 1
docs/api/en/math/Plane.html

@@ -130,7 +130,7 @@
 			[page:Vector3 normal] - a unit length [page:Vector3] defining the normal of the plane.<br />
 			[page:Float constant] - the signed distance from the origin to the plane. Default is *0*.<br /><br />
 
-			 Sets the plane's [page:.normal normal] and [page:.constant constant] properties.
+			Sets this plane's [page:.normal normal] and [page:.constant constant] properties by copying the values from the given normal.
 		</p>
 
 		<h3>[method:Plane setComponents]( [param:Float x], [param:Float y], [param:Float z], [param:Float w] )</h3>

+ 1 - 2
docs/api/en/math/Ray.html

@@ -201,8 +201,7 @@
 		This must be normalized (with [page:Vector3.normalize]) for the methods to operate
 		properly.<br /><br />
 
-		Copy the parameters to the [page:.origin origin] and [page:.direction direction] properties
-		of this ray.
+		Sets this ray's [page:.origin origin] and [page:.direction direction] properties by copying the values from the given objects.
 		</p>
 
 

+ 2 - 1
docs/api/en/math/Sphere.html

@@ -114,7 +114,8 @@
 			[page:Vector3 center] - center of the sphere.<br />
 			[page:Float radius] - radius of the sphere.<br /><br />
 
-		Sets the [page:.center center] and [page:.radius radius] properties of this sphere.
+		Sets the [page:.center center] and [page:.radius radius] properties of this sphere.<br>
+		Please note that this method only copies the values from the given center.
 		</p>
 
 		<h3>[method:Sphere setFromPoints]( [param:Array points], [param:Vector3 optionalCenter] )</h3>

+ 2 - 1
docs/api/en/math/Triangle.html

@@ -123,7 +123,8 @@
 
 		<h3>[method:Triangle set]( [param:Vector3 a], [param:Vector3 b], [param:Vector3 c] ) [param:Triangle this]</h3>
 		<p>
-		Sets the triangle's [page:.a a], [page:.b b] and [page:.c c] properties to the passed [page:vector3 vector3s].
+		Sets the triangle's [page:.a a], [page:.b b] and [page:.c c] properties to the passed [page:vector3 vector3s].<br>
+		Please note that this method only copies the values from the given objects.
 		</p>
 
 		<h3>[method:Triangle setFromPointsAndIndices]( [param:Array points], [param:Integer i0], [param:Integer i1], [param:Integer i2] ) [param:Triangle this]</h3>

+ 13 - 155
examples/js/vr/HelioWebXRPolyfill.js

@@ -2,29 +2,24 @@
  * @author mvilledieu / http://github.com/mvilledieu
  */
 
-if ( /(Helio)/g.test( navigator.userAgent ) && "xr" in navigator && 'isSessionSupported' in navigator.xr === false) {
+if ( /(Helio)/g.test( navigator.userAgent ) && 'xr' in navigator ) {
 
-	console.log( "Helio WebXR Polyfill (Lumin 0.97.0)" );
+	console.log( "Helio WebXR Polyfill (Lumin 0.98.0)" );
 
-	const isHelio96 = navigator.userAgent.includes( "Chrome/73" );
+	if ( 'isSessionSupported' in navigator.xr ) {
 
-	// WebXRManager - XR.supportSession() Polyfill - WebVR.js line 147
+		const tempIsSessionSupported = navigator.xr.isSessionSupported.bind( navigator.xr );
 
-	if (
-		"supportsSession" in navigator.xr === false &&
-	"supportsSessionMode" in navigator.xr
-	) {
-
-		navigator.xr.supportsSession = function ( /*sessionType*/ ) {
+		navigator.xr.isSessionSupported = function ( /*sessionType*/ ) {
 
 			// Force using immersive-ar
-			return navigator.xr.supportsSessionMode( 'immersive-ar' );
+			return tempIsSessionSupported( 'immersive-ar' );
 
 		};
 
 	}
 
-	if ( "requestSession" in navigator.xr ) {
+	if ( 'isSessionSupported' in navigator.xr && 'requestSession' in navigator.xr ) {
 
 		const tempRequestSession = navigator.xr.requestSession.bind( navigator.xr );
 
@@ -32,154 +27,17 @@ if ( /(Helio)/g.test( navigator.userAgent ) && "xr" in navigator && 'isSessionSu
 
 			return new Promise( function ( resolve, reject ) {
 
-				const sessionType = ( isHelio96 ? {
-					mode: 'immersive-ar' // Force using immersive-ar
-				} : 'immersive-ar' );
-
-				tempRequestSession( sessionType )
-					.then( function ( session ) {
-
-						// WebXRManager - xrFrame.getPose() Polyfill - line 279
-
-						const tempRequestAnimationFrame = session.requestAnimationFrame.bind(
-							session
-						);
-
-						session.requestAnimationFrame = function ( callback ) {
-
-							return tempRequestAnimationFrame( function ( time, frame ) {
-
-								// WebXRManager - xrFrame.getViewerPose() Polyfill - line 279
-								// Transforms view.viewMatrix to view.transform.inverse.matrix
-
-								const tempGetViewerPose = frame.getViewerPose.bind( frame );
-
-								frame.getViewerPose = function ( referenceSpace ) {
-
-									const pose = tempGetViewerPose( referenceSpace );
-
-									pose.views.forEach( function ( view ) {
-
-										view.transform = {
-											inverse: {
-												matrix: view.viewMatrix
-											}
-										};
-
-									} );
-
-									return pose;
-
-								};
-
-								// WebXRManager - xrFrame.getPose() Polyfill - line 259
-
-								const tempGetPose = ( isHelio96 ? null : frame.getPose.bind( frame ) );
-
-								frame.getPose = function ( targetRaySpace, referenceSpace ) {
-
-									if ( isHelio96 ) {
-
-										const inputPose = frame.getInputPose(
-											targetRaySpace,
-											referenceSpace
-										);
-
-										inputPose.transform = {
-											matrix: inputPose.targetRay.transformMatrix
-										};
-
-										return inputPose;
-
-									} else {
-
-										return tempGetPose( targetRaySpace.gripSpace, referenceSpace );
-
-									}
-
-								};
-
-								callback( time, frame );
-
-							} );
-
-						};
-
-						// WebXRManager - xrFrame.getPose( inputSource.targetRaySpace, referenceSpace) Polyfill - line 279
-
-						const tempGetInputSources = session.getInputSources.bind( session );
-
-						session.getInputSources = function () {
-
-							const res = tempGetInputSources();
-
-							res.forEach( function ( xrInputSource ) {
-
-								Object.defineProperty( xrInputSource, "targetRaySpace", {
-									get: function () {
-
-										return xrInputSource;
-
-									}
-								} );
-
-							} );
-
-							return res;
-
-						};
-
-						// WebXRManager - xrSession.getInputSources() Polyfill Line 132 - 136
-
-						session.inputSources = Object.defineProperty(
-							session,
-							"inputSources",
-							{
-								get: session.getInputSources
-							}
-						);
-
-						// WebXRManager - xrSession.updateRenderState() Polyfill Line 129
-
-						if ( isHelio96 ) {
-
-							session.updateRenderState = function ( { baseLayer } ) {
-
-								session.baseLayer = baseLayer;
-
-								// WebXRManager - xrSession.renderState.baseLayer Polyfill Line 219
-
-								session.renderState = {
-									baseLayer: baseLayer
-								};
-
-							};
-
-						}
-
-						// WebXRManager - xrSession.requestReferenceSpace() Polyfill Line 130
-
-						const tempRequestReferenceSpace = session.requestReferenceSpace.bind(
-							session
-						);
-
-						session.requestReferenceSpace = function () {
-
-							return tempRequestReferenceSpace( {
-								type: "stationary",
-								subtype: "floor-level"
-							} );
+				var sessionInit = { optionalFeatures: [ 'local-floor', 'bounded-floor' ] };
 
-						};
+				tempRequestSession( 'immersive-ar', sessionInit ).then( function ( session ) {
 
-						resolve( session );
+					resolve( session );
 
-					} )
-					.catch( function ( error ) {
+				} ).catch( function ( error ) {
 
-						return reject( error );
+					return reject( error );
 
-					} );
+				} );
 
 			} );
 

+ 12 - 31
src/math/Box3.js

@@ -10,8 +10,11 @@ var _points = [
 	new Vector3(),
 	new Vector3()
 ];
+
 var _vector = new Vector3();
 
+var _box = new Box3();
+
 // triangle centered vertices
 
 var _v0 = new Vector3();
@@ -41,6 +44,7 @@ function Box3( min, max ) {
 
 }
 
+
 Object.assign( Box3.prototype, {
 
 	isBox3: true,
@@ -240,8 +244,6 @@ Object.assign( Box3.prototype, {
 
 	expandByObject: function ( object ) {
 
-		var i, l;
-
 		// Computes the world-axis-aligned bounding box of an object (including its children),
 		// accounting for both the object's, and children's, world transforms
 
@@ -251,44 +253,23 @@ Object.assign( Box3.prototype, {
 
 		if ( geometry !== undefined ) {
 
-			if ( geometry.isGeometry ) {
-
-				var vertices = geometry.vertices;
-
-				for ( i = 0, l = vertices.length; i < l; i ++ ) {
-
-					_vector.copy( vertices[ i ] );
-					_vector.applyMatrix4( object.matrixWorld );
-
-					this.expandByPoint( _vector );
-
-				}
+			if ( geometry.boundingBox === null ) {
 
-			} else if ( geometry.isBufferGeometry ) {
+				geometry.computeBoundingBox();
 
-				var attribute = geometry.attributes.position;
-
-				if ( attribute !== undefined ) {
-
-					for ( i = 0, l = attribute.count; i < l; i ++ ) {
-
-						_vector.fromBufferAttribute( attribute, i ).applyMatrix4( object.matrixWorld );
-
-						this.expandByPoint( _vector );
-
-					}
+			}
 
-				}
+			_box.copy( geometry.boundingBox );
+			_box.applyMatrix4( object.matrixWorld );
 
-			}
+			this.expandByPoint( _box.min );
+			this.expandByPoint( _box.max );
 
 		}
 
-		//
-
 		var children = object.children;
 
-		for ( i = 0, l = children.length; i < l; i ++ ) {
+		for ( var i = 0, l = children.length; i < l; i ++ ) {
 
 			this.expandByObject( children[ i ] );
 

+ 3 - 4
src/renderers/shaders/ShaderChunk/packing.glsl.js

@@ -22,15 +22,14 @@ vec4 packDepthToRGBA( const in float v ) {
 }
 
 float unpackRGBAToDepth( const in vec4 v ) {
-	return dot( floor( v * 255.0 + 0.5 ) / 255.0, UnpackFactors );
+	return dot( v, UnpackFactors );
 }
 
-vec4 packHalfToRGBA( vec2 v ) {
+vec4 pack2HalfToRGBA( vec2 v ) {
 	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));
 	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);
 }
-vec2 unpackHalfToRGBA( vec4 v ) {
-	v = floor( v * 255.0 + 0.5 ) / 255.0;
+vec2 unpack2HalfToRGBA( vec4 v ) {
 	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
 }
 

+ 1 - 1
src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js

@@ -38,7 +38,7 @@ export default /* glsl */`
 
 	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
 
-		return unpackHalfToRGBA( texture2D( shadow, uv ) );
+		return unpack2HalfToRGBA( texture2D( shadow, uv ) );
 
 	}
 

+ 3 - 3
src/renderers/shaders/ShaderLib/vsm_frag.glsl.js

@@ -17,7 +17,7 @@ void main() {
 
     #ifdef HORIZONAL_PASS
 
-      vec2 distribution = unpackHalfToRGBA ( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );
+      vec2 distribution = unpack2HalfToRGBA ( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );
       mean += distribution.x;
       squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
 
@@ -34,9 +34,9 @@ void main() {
   mean = mean * HALF_SAMPLE_RATE;
   squared_mean = squared_mean * HALF_SAMPLE_RATE;
 
-  float std_dev = pow( squared_mean - mean * mean, 0.5 );
+  float std_dev = sqrt( squared_mean - mean * mean );
 
-  gl_FragColor = packHalfToRGBA( vec2( mean, std_dev ) );
+  gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
 
 }
 `;

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini