Skip to content

Commit 0005a67

Browse files
authored
Merge pull request #15742 from Mugen87/dev26
PositionalAudio: Honor "hasPlaybackControl" in updateMatrixWorld().
2 parents fcff7a4 + 23e09a7 commit 0005a67

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

examples/webaudio_orientation.html

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -127,27 +127,31 @@
127127

128128
//
129129

130-
var light = new THREE.HemisphereLight( 0xffffff, 0x444444 );
131-
light.position.set( 0, 200, 0 );
132-
scene.add( light );
133-
134-
light = new THREE.DirectionalLight( 0xffffff );
135-
light.position.set( 0, 200, 100 );
136-
light.castShadow = true;
137-
light.shadow.camera.top = 180;
138-
light.shadow.camera.bottom = - 100;
139-
light.shadow.camera.left = - 120;
140-
light.shadow.camera.right = 120;
141-
scene.add( light );
130+
var hemiLight = new THREE.HemisphereLight( 0xffffff, 0x444444 );
131+
hemiLight.position.set( 0, 20, 0 );
132+
scene.add( hemiLight );
133+
134+
var dirLight = new THREE.DirectionalLight( 0xffffff );
135+
dirLight.position.set( 5, 5, 0 );
136+
dirLight.castShadow = true;
137+
dirLight.shadow.camera.top = 1;
138+
dirLight.shadow.camera.bottom = - 1;
139+
dirLight.shadow.camera.left = - 1;
140+
dirLight.shadow.camera.right = 1;
141+
dirLight.shadow.camera.near = 0.1;
142+
dirLight.shadow.camera.far = 20;
143+
scene.add( dirLight );
144+
145+
// scene.add( new THREE.CameraHelper( dirLight.shadow.camera ) );
142146

143147
//
144148

145-
var mesh = new THREE.Mesh( new THREE.PlaneBufferGeometry( 20, 20 ), new THREE.MeshPhongMaterial( { color: 0x999999, depthWrite: false } ) );
149+
var mesh = new THREE.Mesh( new THREE.PlaneBufferGeometry( 50, 50 ), new THREE.MeshPhongMaterial( { color: 0x999999, depthWrite: false } ) );
146150
mesh.rotation.x = - Math.PI / 2;
147151
mesh.receiveShadow = true;
148152
scene.add( mesh );
149153

150-
var grid = new THREE.GridHelper( 20, 20, 0x000000, 0x000000 );
154+
var grid = new THREE.GridHelper( 50, 50, 0x000000, 0x000000 );
151155
grid.material.opacity = 0.2;
152156
grid.material.transparent = true;
153157
scene.add( grid );
@@ -180,6 +184,7 @@
180184

181185
object.material.envMap = reflectionCube;
182186
object.geometry.rotateY( - Math.PI );
187+
object.castShadow = true;
183188

184189
}
185190

@@ -194,7 +199,7 @@
194199
// sound is damped behind this wall
195200

196201
var wallGeometry = new THREE.BoxBufferGeometry( 2, 1, 0.1 );
197-
var wallMaterial = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } );
202+
var wallMaterial = new THREE.MeshBasicMaterial( { color: 0xff0000, transparent: true, opacity: 0.5 } );
198203

199204
var wall = new THREE.Mesh( wallGeometry, wallMaterial );
200205
wall.position.set( 0, 0.5, - 0.5 );
@@ -206,9 +211,10 @@
206211
renderer = new THREE.WebGLRenderer( { antialias: true } );
207212
renderer.setSize( window.innerWidth, window.innerHeight );
208213
renderer.setPixelRatio( window.devicePixelRatio );
209-
container.appendChild( renderer.domElement );
210-
211214
renderer.gammaOutput = true;
215+
renderer.gammaFactor = 2.2;
216+
renderer.shadowMap.enabled = true;
217+
container.appendChild( renderer.domElement );
212218

213219
//
214220

src/audio/PositionalAudio.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ PositionalAudio.prototype = Object.assign( Object.create( Audio.prototype ), {
104104

105105
Object3D.prototype.updateMatrixWorld.call( this, force );
106106

107-
if ( this.isPlaying === false ) return;
107+
if ( this.hasPlaybackControl === true && this.isPlaying === false ) return;
108108

109109
this.matrixWorld.decompose( position, quaternion, scale );
110110

0 commit comments

Comments
 (0)