three+SimplexNoise实现三维山脉沙盘流体流动动画效果代码
代码语言:html
所属分类:三维
代码描述:three+SimplexNoise实现三维山脉沙盘流体流动动画效果代码
代码标签: three SimplexNoise 三维 山脉 沙盘 流体 流动 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { overflow: hidden; margin: 0; } </style> </head> <body > <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/es-module-shims.1.6.2.js"></script> <script type="importmap"> { "imports": { "three": "//repo.bfw.wiki/bfwrepo/js/module/three/build/155/three.module.js", "three/addons/": "//repo.bfw.wiki/bfwrepo/js/module/three/examples/155/jsm/" } } </script> <script type="module"> // https://discourse.threejs.org/t/creating-white-breezy-effect-seeking-guidance-and-insights/55552 import * as THREE from "three"; import { OrbitControls } from "three/addons/controls/OrbitControls.js"; import { SimplexNoise } from "three/addons/math/SimplexNoise.js"; // general setup, boring, skip to the next comment console.clear( ); var scene = new THREE.Scene(); scene.background = new THREE.Color( 'deepskyblue' ); var camera = new THREE.PerspectiveCamera( 30, innerWidth/innerHeight ); camera.position.set( 0, 2.5, 8 ); camera.lookAt( scene.position ); var renderer = new THREE.WebGLRenderer( {antialias: true} ); renderer.setSize( innerWidth, innerHeight ); renderer.setAnimationLoop( animationLoop ); document.body.appendChild( renderer.domElement ); window.addEventListener( "resize", (event) => { camera.aspect = innerWidth/innerHeight; camera.updateProjectionMatrix( ); renderer.setSize( innerWidth, innerHeight ); }); var controls = new OrbitControls( camera, renderer.domElement ); controls.enableDamping = true; controls.autoRotate = true; controls.autoRotateSpeed = 0.5; var light = new THREE.DirectionalLight( 'white' ); light.position.set( 1, 1, 1 ); scene.add( light ); // next comment function elevation( x, y ) { if( x*x > 24.9 ) return -1; if( y*y > 24.9 ) return -1; var major = 0.6*simplex.noise( 0.1*x, 0.1*y ), minor = 0.2*simplex.noise( 0.3*x, 0.3*y ); return major .........完整代码请登录后点击上方下载按钮下载查看
网友评论0