threejs打造钟摆波效果
代码语言:html
所属分类:三维
代码描述:threejs打造钟摆波效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Montserrat&display=swap"rel="stylesheet'> <style> * { box-sizing: border-box; margin: 0; padding: 0; } body { width: 100%; height: 100vh; overflow: hidden; } .loading__wrapper { position: fixed; left: 0; top: 0; width: 100%; height: 100%; background: #000; display: flex; justify-content: center; align-items: center; z-index: 1000; } .loading__wrapper span { color: #fff; font-family: "Montserrat"; font-weight: bold; animation: fade-in-out 1.5s linear infinite; } @keyframes fade-in-out { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } } .support { position: absolute; right: 10px; bottom: 10px; padding: 10px; display: flex; } .support a { margin: 0 10px; color: #333333; font-size: 1.8rem; backface-visibility: hidden; transition: all 150ms ease; } .support a:hover { transform: scale(1.1); } </style> </head> <body translate="no"> <script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/gsap.3.2.6.js"></script> <script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/three.110.js"></script> <script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/dat.gui-min.js"></script> <script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/postprocessing.min.js"></script> <script src="http://repo.bfw.wiki/bfwrepo/js/OrbitControls.js"></script> <script type="module"> // Sorry I could not add audio on codepen check -> https://pendulum-waves.netlify.app/ // And also check the github: https://github.com/devloop01/pendulum-waves console.clear(); class Pendulum { constructor(scene, options = {}) { this.scene = scene; this.z = options.z; this.phaseDiff = options.phaseDiff; this.position = options.position; this.startAngle = options.startAngle; this.length = options.length; this.sphereMaterialProps = options.sphereMaterialProps; this.angle = Math.PI; this.angleVelocity = 0; this.angleAcceleration = 0; this.origin = { x: 0, y: this.length }; this.current = { x: 0, y: 0 }; this.create(); } create() { const metalMaterial = new THREE.MeshStan.........完整代码请登录后点击上方下载按钮下载查看
网友评论0