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="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 { GUI } from '//repo.bfw.wiki/bfwtool/examples/jsm/libs/lil-gui.module.min.js'; import { OrbitControls } from '//repo.bfw.wiki/bfwtool/examples/jsm/controls/OrbitControls.js'; import { Water } from '//repo.bfw.wiki/bfwtool/examples/jsm/objects/Water.js'; import { Sky } from '//repo.bfw.wiki/bfwtool/examples/jsm/objects/Sky.js'; let container, stats; let camera, scene, renderer; let controls, water, sun, mesh; init(); animate(); function init() { container = document.getElementById( 'container' ); // renderer = new THREE.WebGLRenderer(); renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.toneMapping = THREE.ACESFilmicToneMapping; container.appendChild( renderer.domElement ); // scene = new THREE.Scene(); camera = new THREE.PerspectiveCamera( 55, window.innerWidth / window.innerHeight, 1, 20000 ); camera.position.set( 30, 30, 100 ); // sun = new THREE.Vector3(); // Water const waterGeometry = new THREE.PlaneGeometry( 10000, 10000 ); water = new Water( waterGeometry, { textureWidth: 512, textureHeight: 512, waterNormals: new THREE.TextureLoader().load( '//repo.bfw.wiki/bfwtool/examples/textures/waternormals.jpg', function ( texture ) { texture.wrapS = texture.wrapT = THREE.RepeatWrapping; } ), sunDirection: new THREE.Vector3(), sunColor: 0xffffff, waterColor: 0x001e0f, distortionScale: 3.7, fog: scene.fog !== undefined } ); water.rotation.x = - Math.PI / 2; scene.add( water ); // Skybox const sky = new Sky(); sky.scale.setScalar( 10000 ); scene.add( sky ); const skyUn.........完整代码请登录后点击上方下载按钮下载查看
网友评论0