three打造照三维粒子分解动画效果代码

代码语言:html

所属分类:粒子

代码描述:three打造照三维粒子分解动画效果代码

代码标签: 三维 粒子 分解 动画 效果

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

<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">
  

  
  
<style>
canvas {
    display:block; width:100%; height:100vh; cursor: -webkit-grab; cursor: grab;
}
</style>


</head>

<body  >
  
 
  
      <script  type="module">
import * as $ from '//cdn.skypack.dev/three@0.124.0/build/three.module.js?min'
import { OrbitControls } from '//cdn.skypack.dev/three@0.124.0/examples/jsm/controls/OrbitControls.js?min'
//// Boot

const renderer = new $.WebGLRenderer({});
const scene = new $.Scene();
const camera = new $.PerspectiveCamera(105, 2, 40, 2000);
const controls = new OrbitControls(camera, renderer.domElement);
window.addEventListener('resize', () => {
    const { clientWidth, clientHeight } = renderer.domElement;
    renderer.setSize(clientWidth, clientHeight, false);
    renderer.setPixelRatio(window.devicePixelRatio);
    camera.aspect = clientWidth / clientHeight;
    camera.updateProjectionMatrix();
});
document.body.prepend(renderer.domElement);
window.dispatchEvent(new Event('resize'));

//// Setup

camera.position.set(-20, -20, -120);
scene.background = new $.Color('lightgray');
scene.add(new $.AmbientLight('white', 1));
controls.autoRotate = true;
controls.autoRotateSpeed = 1;
controls.enableDamping = true;

//// Make Meshes
//https://unsplash.com/photos/URwKHne9Pq8 https://unsplash.com/photos/xcjlPPsopw8
const loader = new $.TextureLoader();
const tex0 = loader.load('//repo.bfw.wiki/bfwrepo/image/6010ac31a2a49.png',
    (tex) => mesh.scale.x = tex.image.width / tex.image.height);
const tex1 = loader.load('//repo.bfw.wiki/bfwrepo/image/6010ac12533c7.png');
const nInst = new $.Vector2(300, 300);

const mat0 = f();
const mesh = new $.InstancedMesh(new $.PlaneGeometry(1, 1), mat0, nInst.x * nInst.y);

for (let i = 0; i < nInst.y; ++i) {
    for (let j.........完整代码请登录后点击上方下载按钮下载查看

网友评论0