three+gsap实现交互三维空间粒子运动效果代码

代码语言:html

所属分类:粒子

代码描述:three+gsap实现交互三维空间粒子运动效果代码

代码标签: three gsap 三维 粒子

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

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

<head>

    <meta charset="UTF-8">





</head>

<body>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.9.1.js"></script>
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.128.js"></script>
    <script>
        let camera;
        let scene;
        let renderer;
        let material;
        let mouseX = 0;
        let mouseY = 0;
        let windowHalfX = window.innerWidth / 2;
        let windowHalfY = window.innerHeight / 2;
        
        init();
        animate();
        
        function init() {
          camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 5, 2000);
          camera.position.z = 500;
        
          scene = new THREE.Scene();
          scene.fog = new THREE.FogExp2(0x0000ff, 0.001);
        
          const geometry = new THREE.BufferGeometry();
          const vertices = [];
          const size = 2000;
        
          for (let i = 0; i < 20000; i++) {
            const x = (Math.random() * size + Math.random() * size) / 2 - size / 2;
            const y = (Math.random() * size + Math.random() * size) / 2 - size / 2;
            const z = (Math.random() * size + Math.random() * size) / 2 - size / 2;
        
            vertices.push(x, y, z);
          }
        
          geometry.setAttribute('position', new THREE.Float32BufferAttribute(vertices, 3));
        
          material = new THREE.PointsMaterial({
            s.........完整代码请登录后点击上方下载按钮下载查看

网友评论0