three实现粒子线条球形喷射动画效果代码
代码语言:html
所属分类:粒子
代码描述: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> <!-- 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'; const SCREEN_WIDTH = window.innerWidth, SCREEN_HEIGHT = window.innerHeight, r = 450; let mouseY = 0, windowHalfY = window.innerHeight / 2, camera, scene, renderer; init(); animate(); function init() { camera = new THREE.PerspectiveCamera( 80, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 3000 ); camera.position.z = 1000; scene = new THREE.Scene(); const parameters = [[ 0.25, 0xff7700, 1 ], [ 0.5, 0xff9900, 1 ], [ 0.75, 0xffaa00, 0.75 ], [ 1, 0xffaa00, 0.5 ], [ 1.25, 0x000833, 0.8 ], [ 3.0, 0xaaaaaa, 0.75 ], [ 3.5, 0xffffff, 0.5 ], [ 4.5, 0xffffff, 0.25 ], [ 5.5, 0xffffff, 0.125 ]]; const geometry = createGeometry(); for ( let i = 0; i < parameters.length; ++ i ) { const p = parameters[ i ]; const material = new THREE.LineBasicMaterial( { color: p[ 1 ], opacity: p[ 2 ] } ); const line = new THREE.LineSegments( geometry, material ); line.scale.x = line.scale.y = line.scale.z = p[ 0 ]; line.userData.originalScale = p[ 0 ]; line.rotation.y = Math.random() * Math.PI; line.updateMatrix(); scene.add( line ); } renderer = new THREE.WebGLRenderer( { antialias: true } ); renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT ); document.body.appendChild( renderer.domElement ); document.body.style.touchAction = .........完整代码请登录后点击上方下载按钮下载查看
网友评论0