Browse Source

WebGLRenderer: Do not run window.rAF when in XR. (#21529)

* WebGLRenderer: Do not run window.rAF when in XR.

* WebGLRenderer: Enhance dispose().

* Update builds.
Michael Herzog 4 years ago
parent
commit
c6d8d9b25b
4 changed files with 264 additions and 218 deletions
  1. 204 206
      build/three.js
  2. 0 0
      build/three.min.js
  3. 42 11
      build/three.module.js
  4. 18 1
      src/renderers/WebGLRenderer.js

File diff suppressed because it is too large
+ 204 - 206
build/three.js


File diff suppressed because it is too large
+ 0 - 0
build/three.min.js


+ 42 - 11
build/three.module.js

@@ -17261,8 +17261,7 @@ function WebGLPrograms( renderer, cubemaps, extensions, capabilities, bindingSta
 		'roughnessMap', 'metalnessMap', 'gradientMap',
 		'roughnessMap', 'metalnessMap', 'gradientMap',
 		'alphaMap', 'combine', 'vertexColors', 'vertexTangents', 'vertexUvs', 'uvsVertexOnly', 'fog', 'useFog', 'fogExp2',
 		'alphaMap', 'combine', 'vertexColors', 'vertexTangents', 'vertexUvs', 'uvsVertexOnly', 'fog', 'useFog', 'fogExp2',
 		'flatShading', 'sizeAttenuation', 'logarithmicDepthBuffer', 'skinning',
 		'flatShading', 'sizeAttenuation', 'logarithmicDepthBuffer', 'skinning',
-		'maxBones', 'useVertexTexture', 'morphTargets', 'morphNormals',
-		'maxMorphTargets', 'maxMorphNormals', 'premultipliedAlpha',
+		'maxBones', 'useVertexTexture', 'morphTargets', 'morphNormals', 'premultipliedAlpha',
 		'numDirLights', 'numPointLights', 'numSpotLights', 'numHemiLights', 'numRectAreaLights',
 		'numDirLights', 'numPointLights', 'numSpotLights', 'numHemiLights', 'numRectAreaLights',
 		'numDirLightShadows', 'numPointLightShadows', 'numSpotLightShadows',
 		'numDirLightShadows', 'numPointLightShadows', 'numSpotLightShadows',
 		'shadowMapEnabled', 'shadowMapType', 'toneMapping', 'physicallyCorrectLights',
 		'shadowMapEnabled', 'shadowMapType', 'toneMapping', 'physicallyCorrectLights',
@@ -17448,8 +17447,6 @@ function WebGLPrograms( renderer, cubemaps, extensions, capabilities, bindingSta
 
 
 			morphTargets: material.morphTargets,
 			morphTargets: material.morphTargets,
 			morphNormals: material.morphNormals,
 			morphNormals: material.morphNormals,
-			maxMorphTargets: renderer.maxMorphTargets,
-			maxMorphNormals: renderer.maxMorphNormals,
 
 
 			numDirLights: lights.directional.length,
 			numDirLights: lights.directional.length,
 			numPointLights: lights.point.length,
 			numPointLights: lights.point.length,
@@ -23183,11 +23180,6 @@ function WebGLRenderer( parameters ) {
 	this.toneMapping = NoToneMapping;
 	this.toneMapping = NoToneMapping;
 	this.toneMappingExposure = 1.0;
 	this.toneMappingExposure = 1.0;
 
 
-	// morphs
-
-	this.maxMorphTargets = 8;
-	this.maxMorphNormals = 4;
-
 	// internal properties
 	// internal properties
 
 
 	const _this = this;
 	const _this = this;
@@ -23660,6 +23652,9 @@ function WebGLRenderer( parameters ) {
 
 
 		xr.dispose();
 		xr.dispose();
 
 
+		xr.removeEventListener( 'sessionstart', onXRSessionStart );
+		xr.removeEventListener( 'sessionend', onXRSessionEnd );
+
 		animation.stop();
 		animation.stop();
 
 
 	};
 	};
@@ -24007,11 +24002,22 @@ function WebGLRenderer( parameters ) {
 
 
 	function onAnimationFrame( time ) {
 	function onAnimationFrame( time ) {
 
 
-		if ( xr.isPresenting ) return;
 		if ( onAnimationFrameCallback ) onAnimationFrameCallback( time );
 		if ( onAnimationFrameCallback ) onAnimationFrameCallback( time );
 
 
 	}
 	}
 
 
+	function onXRSessionStart() {
+
+		animation.stop();
+
+	}
+
+	function onXRSessionEnd() {
+
+		animation.start();
+
+	}
+
 	const animation = new WebGLAnimation();
 	const animation = new WebGLAnimation();
 	animation.setAnimationLoop( onAnimationFrame );
 	animation.setAnimationLoop( onAnimationFrame );
 
 
@@ -24026,6 +24032,9 @@ function WebGLRenderer( parameters ) {
 
 
 	};
 	};
 
 
+	xr.addEventListener( 'sessionstart', onXRSessionStart );
+	xr.addEventListener( 'sessionend', onXRSessionEnd );
+
 	// Rendering
 	// Rendering
 
 
 	this.render = function ( scene, camera ) {
 	this.render = function ( scene, camera ) {
@@ -37361,6 +37370,16 @@ class SpotLightShadow extends LightShadow {
 
 
 	}
 	}
 
 
+	copy( source ) {
+
+		super.copy( source );
+
+		this.focus = source.focus;
+
+		return this;
+
+	}
+
 }
 }
 
 
 SpotLightShadow.prototype.isSpotLightShadow = true;
 SpotLightShadow.prototype.isSpotLightShadow = true;
@@ -37483,6 +37502,15 @@ class PointLightShadow extends LightShadow {
 		const camera = this.camera;
 		const camera = this.camera;
 		const shadowMatrix = this.matrix;
 		const shadowMatrix = this.matrix;
 
 
+		const far = light.distance || camera.far;
+
+		if ( far !== camera.far ) {
+
+			camera.far = far;
+			camera.updateProjectionMatrix();
+
+		}
+
 		_lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
 		_lightPositionWorld.setFromMatrixPosition( light.matrixWorld );
 		camera.position.copy( _lightPositionWorld );
 		camera.position.copy( _lightPositionWorld );
 
 
@@ -46153,7 +46181,10 @@ const _axisDirections = [
  * even more filtered 'mips' at the same LOD_MIN resolution, associated with
  * even more filtered 'mips' at the same LOD_MIN resolution, associated with
  * higher roughness levels. In this way we maintain resolution to smoothly
  * higher roughness levels. In this way we maintain resolution to smoothly
  * interpolate diffuse lighting while limiting sampling computation.
  * interpolate diffuse lighting while limiting sampling computation.
- */
+ *
+ * Paper: Fast, Accurate Image-Based Lighting
+ * https://drive.google.com/file/d/15y8r_UpKlU9SvV4ILb0C3qCPecS8pvLz/view
+*/
 
 
 function convertLinearToRGBE( color ) {
 function convertLinearToRGBE( color ) {
 
 

+ 18 - 1
src/renderers/WebGLRenderer.js

@@ -589,6 +589,9 @@ function WebGLRenderer( parameters ) {
 
 
 		xr.dispose();
 		xr.dispose();
 
 
+		xr.removeEventListener( 'sessionstart', onXRSessionStart );
+		xr.removeEventListener( 'sessionend', onXRSessionEnd );
+
 		animation.stop();
 		animation.stop();
 
 
 	};
 	};
@@ -936,11 +939,22 @@ function WebGLRenderer( parameters ) {
 
 
 	function onAnimationFrame( time ) {
 	function onAnimationFrame( time ) {
 
 
-		if ( xr.isPresenting ) return;
 		if ( onAnimationFrameCallback ) onAnimationFrameCallback( time );
 		if ( onAnimationFrameCallback ) onAnimationFrameCallback( time );
 
 
 	}
 	}
 
 
+	function onXRSessionStart() {
+
+		animation.stop();
+
+	}
+
+	function onXRSessionEnd() {
+
+		animation.start();
+
+	}
+
 	const animation = new WebGLAnimation();
 	const animation = new WebGLAnimation();
 	animation.setAnimationLoop( onAnimationFrame );
 	animation.setAnimationLoop( onAnimationFrame );
 
 
@@ -955,6 +969,9 @@ function WebGLRenderer( parameters ) {
 
 
 	};
 	};
 
 
+	xr.addEventListener( 'sessionstart', onXRSessionStart );
+	xr.addEventListener( 'sessionend', onXRSessionEnd );
+
 	// Rendering
 	// Rendering
 
 
 	this.render = function ( scene, camera ) {
 	this.render = function ( scene, camera ) {

Some files were not shown because too many files changed in this diff