2
0
Эх сурвалжийг харах

PositionalAudio: Honor "hasPlaybackControl" in updateMatrixWorld().

Mugen87 6 жил өмнө
parent
commit
23e09a70c5

+ 23 - 17
examples/webaudio_orientation.html

@@ -127,27 +127,31 @@
 
 		//
 
-		var light = new THREE.HemisphereLight( 0xffffff, 0x444444 );
-		light.position.set( 0, 200, 0 );
-		scene.add( light );
-
-		light = new THREE.DirectionalLight( 0xffffff );
-		light.position.set( 0, 200, 100 );
-		light.castShadow = true;
-		light.shadow.camera.top = 180;
-		light.shadow.camera.bottom = - 100;
-		light.shadow.camera.left = - 120;
-		light.shadow.camera.right = 120;
-		scene.add( light );
+		var hemiLight = new THREE.HemisphereLight( 0xffffff, 0x444444 );
+		hemiLight.position.set( 0, 20, 0 );
+		scene.add( hemiLight );
+
+		var dirLight = new THREE.DirectionalLight( 0xffffff );
+		dirLight.position.set( 5, 5, 0 );
+		dirLight.castShadow = true;
+		dirLight.shadow.camera.top = 1;
+		dirLight.shadow.camera.bottom = - 1;
+		dirLight.shadow.camera.left = - 1;
+		dirLight.shadow.camera.right = 1;
+		dirLight.shadow.camera.near = 0.1;
+		dirLight.shadow.camera.far = 20;
+		scene.add( dirLight );
+
+		// scene.add( new THREE.CameraHelper( dirLight.shadow.camera ) );
 
 		//
 
-		var mesh = new THREE.Mesh( new THREE.PlaneBufferGeometry( 20, 20 ), new THREE.MeshPhongMaterial( { color: 0x999999, depthWrite: false } ) );
+		var mesh = new THREE.Mesh( new THREE.PlaneBufferGeometry( 50, 50 ), new THREE.MeshPhongMaterial( { color: 0x999999, depthWrite: false } ) );
 		mesh.rotation.x = - Math.PI / 2;
 		mesh.receiveShadow = true;
 		scene.add( mesh );
 
-		var grid = new THREE.GridHelper( 20, 20, 0x000000, 0x000000 );
+		var grid = new THREE.GridHelper( 50, 50, 0x000000, 0x000000 );
 		grid.material.opacity = 0.2;
 		grid.material.transparent = true;
 		scene.add( grid );
@@ -180,6 +184,7 @@
 
 					object.material.envMap = reflectionCube;
 					object.geometry.rotateY( - Math.PI );
+					object.castShadow = true;
 
 				}
 
@@ -194,7 +199,7 @@
 		// sound is damped behind this wall
 
 		var wallGeometry = new THREE.BoxBufferGeometry( 2, 1, 0.1 );
-		var wallMaterial = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );
+		var wallMaterial = new THREE.MeshBasicMaterial( { color: 0xff0000, transparent: true, opacity: 0.5 } );
 
 		var wall = new THREE.Mesh( wallGeometry, wallMaterial );
 		wall.position.set( 0, 0.5, - 0.5 );
@@ -206,9 +211,10 @@
 		renderer = new THREE.WebGLRenderer( { antialias: true } );
 		renderer.setSize( window.innerWidth, window.innerHeight );
 		renderer.setPixelRatio( window.devicePixelRatio );
-		container.appendChild( renderer.domElement );
-
 		renderer.gammaOutput = true;
+		renderer.gammaFactor = 2.2;
+		renderer.shadowMap.enabled = true;
+		container.appendChild( renderer.domElement );
 
 		//
 

+ 1 - 1
src/audio/PositionalAudio.js

@@ -104,7 +104,7 @@ PositionalAudio.prototype = Object.assign( Object.create( Audio.prototype ), {
 
 			Object3D.prototype.updateMatrixWorld.call( this, force );
 
-			if ( this.isPlaying === false ) return;
+			if ( this.hasPlaybackControl === true && this.isPlaying === false ) return;
 
 			this.matrixWorld.decompose( position, quaternion, scale );