1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- /**
- * @author mikael emtinger / http://gomo.se/
- */
- THREE.SoundRenderer = function() {
-
- this.volume = 1;
- this.domElement = document.createElement( "div" );
- this.domElement.id = "THREESound";
-
- this.cameraPosition = new THREE.Vector3();
- this.soundPosition = new THREE.Vector3();
-
- /*
- * Render
- */
-
- this.render = function( scene, camera, callSceneUpdate ) {
-
- if( callSceneUpdate )
- scene.update( undefined, false, camera );
-
-
- // loop through all sounds
-
- var sound;
- var sounds = scene.sounds;
- var s, l = sounds.length;
-
- //camera.globalMatrix.extractPositionVector( this.cameraPosition );
-
- for( s = 0; s < l; s++ ) {
-
- sound = sounds[ s ];
-
- sound.globalMatrix.extractPositionVector( this.soundPosition );
- this.soundPosition.subSelf( camera.position );
-
- if( sound.isPlaying && sound.isLoaded ) {
-
- if( !sound.isAddedToDOM )
- sound.addToDOM( this.domElement );
-
- sound.calculateVolumeAndPan( this.soundPosition );
- }
- }
- }
- }
|