three.js: Control gui or play sound

2021-03-05 03:28

阅读:658

YPE html>

标签:download   xhr   mes   sse   rac   监听   date   --   声音   

 

Control gui

  

 

//

				const listener = new THREE.AudioListener();

				const audio = new THREE.Audio( listener );
				const file = ‘./sounds/376737_Skullbeatz___Bad_Cat_Maste.mp3‘;

				if ( /(iPad|iPhone|iPod)/g.test( navigator.userAgent ) ) {

					const loader = new THREE.AudioLoader();
					loader.load( file, function ( buffer ) {

						audio.setBuffer( buffer );
						audio.play();

					} );

				} else {

					const mediaElement = new Audio( file );
					mediaElement.play();

					audio.setMediaElementSource( mediaElement );

				}

				analyser = new THREE.AudioAnalyser( audio, fftSize );

				//

				const format = ( renderer.capabilities.isWebGL2 ) ? THREE.RedFormat : THREE.LuminanceFormat;

				uniforms = {

					tAudioData: { value: new THREE.DataTexture( analyser.data, fftSize / 2, 1, format ) }

				};

  

three.js: Control gui or play sound

标签:download   xhr   mes   sse   rac   监听   date   --   声音   

原文地址:https://www.cnblogs.com/geovindu/p/14479229.html


评论


亲,登录后才可以留言!