three三维钢球钢珠粒子汇聚变形动画效果代码
代码语言:html
所属分类:粒子
代码描述:three三维钢球钢珠粒子汇聚变形动画效果代码
代码标签: three 三维 钢球 钢珠 粒子 汇聚 变形 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> <style> body { background-color: #fff; color: #000; } a { color: #48f; } </style> </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 { TWEEN } from '//repo.bfw.wiki/bfwtool/examples/jsm/libs/tween.module.min.js'; import { TrackballControls } from '//repo.bfw.wiki/bfwtool/examples/jsm/controls/TrackballControls.js'; import { CSS3DRenderer, CSS3DSprite } from '//repo.bfw.wiki/bfwtool/examples/jsm/renderers/CSS3DRenderer.js'; let camera, scene, renderer; let controls; const particlesTotal = 512; const positions = []; const objects = []; let current = 0; init(); animate(); function init() { camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 5000 ); camera.position.set( 600, 400, 1500 ); camera.lookAt( 0, 0, 0 ); scene = new THREE.Scene(); const image = document.createElement( 'img' ); image.addEventListener( 'load', function () { for ( let i = 0; i < particlesTotal; i ++ ) { const object = new CSS3DSprite( image.cloneNode() ); object.position.x = Math.random() * 4000 - 2000, object.position.y = Math.random() * 4000 - 2000, object.position.z = Math.random() * 4000 - 2000; scene.add( object ); objects.push( object ); } transition(); } ); image.src = '//repo.bfw.wiki/bfwtool/examples/textures/sprite.png'; // Plane const amountX = 16; const amountZ = 32; const separationPlane = 150; const offsetX = ( ( amountX - 1 ) * separationPlane ) / 2; const offsetZ = ( ( amountZ - 1 ) * separationPlane ) / 2; for ( let i = 0; i < particlesTotal; i ++ ) { const x = ( i % amountX ) * separationPlane; const z = Math.floor( i / amountX ) * separationPlane; const y = ( Math.sin( x * 0..........完整代码请登录后点击上方下载按钮下载查看
网友评论0