threejs打造一个多彩波纹线条波动三维效果代码
代码语言:html
所属分类:三维
代码描述:threejs打造一个多彩波纹线条波动三维效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<html lang="en"> <head> <meta charset="UTF-8"> <style> canvas { display: block; width: 100%; height: 100vh; cursor: -webkit-grab; cursor: grab; } </style> </head> <body> <canvas width="887" height="448" style="display: block;"></canvas> <script type="module"> import * as $ from '//cdn.skypack.dev/three@0.125.0/build/three.module.js?min' import { OrbitControls } from '//cdn.skypack.dev/three@0.125.0/examples/jsm/controls/OrbitControls.js?min' import { EffectComposer } from '//cdn.skypack.dev/three@0.125.0/examples/jsm/postprocessing/EffectComposer.js?min' import { RenderPass } from '//cdn.skypack.dev/three@0.125.0/examples/jsm/postprocessing/RenderPass.js?min' import { UnrealBloomPass } from '//cdn.skypack.dev/three@0.125.0/examples/jsm/postprocessing/UnrealBloomPass.js?min' import { gsap } from '//cdn.skypack.dev/gsap?min' //// Boot const renderer = new $.WebGLRenderer({ antialias: true }); const scene = new $.Scene(); const camera = new $.PerspectiveCamera(75, 2, .1, 1000); 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(-2, 8, 2); const light0 = new $.DirectionalLight('white', 1); light0.position.set(2, -2, -2); scene.add(light0); const light1 = new $.DirectionalLight('white', 1); light1.position.set(-2, 2, 2); scene.add(light1); const steps = 1000; const extrudeSteps = 1024 * 2; const extrudeDepth = 0.5; .........完整代码请登录后点击上方下载按钮下载查看
网友评论0