three模拟三维球桌小球上下抨击的声音同步反馈立体声效果代码

代码语言:html

所属分类:多媒体

代码描述:three模拟三维球桌小球上下抨击的声音同步反馈立体声效果代码

代码标签: three 模拟 三维 球桌 小球 上下 抨击 声音 同步 反馈 立体声

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">
	<head>
	
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">

	</head>
<body>

	<div id="overlay">
		<button id="startButton">Play</button>
	</div>
	<div id="container"></div>


	<!-- Import maps polyfill -->
	<!-- Remove this when import maps will be widely supported -->
	<script async type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/es-module-shims.1.3.6.js"></script>


		<script type="importmap">
			{
				"imports": {
					"three": "//repo.bfw.wiki/bfwtool/build/three.module.js"
				}
			}
		</script>

		<script type="module">

			import * as THREE from 'three';

			import Stats from '//repo.bfw.wiki/bfwtool/examples/jsm/libs/stats.module.js';
		import { OrbitControls } from '//repo.bfw.wiki/bfwtool/examples/jsm/controls/OrbitControls.js';

		let scene, camera, renderer, clock;

		const objects = [];

		const speed = 2.5;
		const height = 3;
		const offset = 0.5;

		const startButton = document.getElementById( 'startButton' );
		startButton.addEventListener( 'click', init );

		function init() {

			const overlay = document.getElementById( 'overlay' );
			overlay.remove();

			const container = document.getElementById( 'container' );

			scene = new THREE.Scene();

			clock = new THREE.Clock();

			//

			camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.1, 100 );
			camera.position.set( 7, 3, 7 );

			// lights

			const ambientLight = new THREE.AmbientLight( 0xcccccc, 0.4 );
			scene.add( ambientLight );

			const directionalLight = new THREE.DirectionalLight( 0xffffff, 0.7 );
			directionalLight.position.set( 0, 5, 5 );
			scene.add( directionalLight );

			const d = 5;
			directionalLight.castShadow = true;
			directionalLight.shadow.camera.left = - d;
			directionalLight.shadow.camera.right = d;
			directionalLight.shadow.camera.top = d;
			directionalLight.shadow.camera.bottom = - d;

			directionalLight.shadow.camera.near = 1;
			directionalLight.shadow.camera.far = 20;

			directionalLight.shadow.mapSize.x = 1024;
			directionalLight.shadow.mapSize.y = 1024;

			// audio

			const audioLoader = new THREE.AudioLoader();

			const listener = new THREE.AudioListener();
			camera.add( listener );

			// floor

			const floorGeometry = new THREE.PlaneGeometry( 10.........完整代码请登录后点击上方下载按钮下载查看

网友评论0