three实现三维血管内穿梭动画效果代码

代码语言:html

所属分类:三维

代码描述:three实现三维血管内穿梭动画效果代码

代码标签: three 三维 血管 穿梭 动画

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

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">


</head>
<body>
<script type="importmap">
  {
    "imports": {
      "three": "//repo.bfw.wiki/bfwrepo/js/module/three/build/169/three.module.js",
      "three/addons/": "//repo.bfw.wiki/bfwrepo/js/module/three/examples/164/jsm/"
    }
  }
</script>


  <script type="module" >
      import * as THREE from 'https://threejs.org/build/three.module.js';
import { OrbitControls } from 'https://threejs.org/examples/jsm/controls/OrbitControls.js';
import { ConvexGeometry } from 'https://threejs.org/examples/jsm/geometries/ConvexGeometry.js';
import { EffectComposer } from 'https://threejs.org/examples/jsm/postprocessing/EffectComposer.js';
import { RenderPass } from 'https://threejs.org/examples/jsm/postprocessing/RenderPass.js';
import { ShaderPass } from 'https://threejs.org/examples/jsm/postprocessing/ShaderPass.js';
import { CopyShader } from 'https://threejs.org/examples/jsm/shaders/CopyShader.js';
import { LuminosityHighPassShader } from 'three/addons/shaders/LuminosityHighPassShader.js';
import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';

var CONTAINER, RENDERER, SCENE, CAMERA, CONTROLS, COMPOSER, path, path2, tt, pointLight;
var clock = new THREE.Clock();
let gu = {
  time: {value: 0}
}
let TIME = 0.0;
init();
animate();
initComposer();

function init() {
    RENDERER = new THREE.WebGLRenderer({antialias: true, alpha:true});
    RENDERER.setSize(window.innerWidth, window.innerHeight);
    CONTAINER = document.createElement('div');
    document.body.appendChild(CONTAINER);
    CONTAINER.appendChild(RENDERER.domElement);

    SCENE = new THREE.Scene();
    CAMERA = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
    CAMERA.position.set(0, 0,30);
    CAMERA.lookAt(SCENE.position);
  
    pointLight = new THREE.PointLight( 0xffffff, Math.PI * 2 );
    SCENE.add(pointLight);
    
    CONTROLS = new OrbitControls(CAMERA, RENDERER.domElement);
    CONTROLS.mouseButtons = {LEFT: THREE.MOUSE.ROTATE}
    CONTROLS.maxPolarAngle = Math.PI-Math.PI/6.0;
    CONTROLS.minPolarAngle =Math.PI/6.0;
    CONTROLS.enableDamping = true;
  
    initComposer();

    window.addEventListener('resize', onWindowResize, false); 
    
    
    class CustomSinCurve extends THREE.Curve {
      constructor( scale ) {
        super();
        this.scale = scale;
      }
      getPoint( t ) {    
        const tx = Math.sin( 4 * Math.PI * t );
        const ty = Math.sin( 2.0 * Math.PI * t) ;
        const tz = Math.cos( 2 * Math.PI * t )*3;
        return new THREE.Vector3( tx, ty, tz ).multiplyScalar( this.scale );
      }
    }

    path = new CustomSinCurve( 3.1416 );
    const tubularSegments =  512;  
    const radius =  0.5;  
    const radialSegments =  64;  

    const closed = true;  
    const geometry = new THREE.TubeGeometry(path, tubularSegme.........完整代码请登录后点击上方下载按钮下载查看

网友评论0