three+gsap实现放射渐变和镜头故障模拟动画效果代码

代码语言:html

所属分类:动画

代码描述:three+gsap实现放射渐变和镜头故障模拟动画效果代码

代码标签: three gsap 放射 渐变 镜头 故障 模拟 动画

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

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

  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>three.js + Radial Gradient</title>
    <style>
      body { margin: 0; overflow: hidden; user-select: none;}
      canvas { display: block; }
    </style>
  </head>
  <body>
      
 <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/es-module-shims.1.6.3.js"></script>
<script type="importmap">
  {
    "imports": {      
      "three": "//repo.bfw.wiki/bfwrepo/js/module/three/build/164/three.module.js",
        "three/addons/": "//repo.bfw.wiki/bfwrepo/js/module/three/examples/164/jsm/"
    }
  }
</script>

<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/gsap.3.12.2.js"></script>
    <script type="module">
      import * as THREE from 'three';
      import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
      import { OBJLoader } from 'three/addons/loaders/OBJLoader.js';
      import { FontLoader } from 'three/addons/loaders/FontLoader.js';
      import { TextGeometry } from 'three/addons/geometries/TextGeometry.js';
      import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
      import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
      import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
      import { GlitchPass } from 'three/addons/postprocessing/GlitchPass.js';
      import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js';


      const scene = new THREE.Scene();
      const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
      const renderer = new THREE.WebGLRenderer();
      renderer.setSize(window.innerWidth, window.innerHeight);
      document.body.appendChild(renderer.domElement);
      const controls = new OrbitControls(camera, renderer.domElement);
      controls.enableDamping = true;

      const vertexShader = `
      varying vec2 vUv;
      void main() {
        vUv = uv;
        gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
      }
      `;

      const fragmentShader = `
      varying vec2 vUv;
      void main() {
        vec2 center = vec2(0.5, 0.5);
        float distance = distance(vUv, center);
        vec3 color = mix(vec3(1.0, 0.0, 0.0), vec3(0.0, 0.0, 1.0), distance);
        gl_FragColor = vec4(color, 1.0);
      }
      `;

      const material = new THREE.ShaderMaterial({
        vertexShader: vertexShader,
        fragmentShader: fragmentShader,
        wireframe: false,
        side: THREE.DoubleSide
      });

.........完整代码请登录后点击上方下载按钮下载查看

网友评论0