three实现三维不同材质布料切换飘动动画效果代码
代码语言:html
所属分类:三维
代码描述:three实现三维不同材质布料切换飘动动画效果代码
代码标签: three 三维 不同 材质 布料 切换 飘动 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> html, body { padding: 0; margin: 0; } .container { position: fixed; top: 0; left: 0; width: 100%; height: 93%; } canvas { display: block; } .matcap-previews { position: fixed; left: 0; bottom: 10vh; width: 100%; display: flex; justify-content: center; pointer-events: none; } .matcap-previews > div { max-width: 10vh; cursor: pointer; border-radius: 2px; pointer-events: auto; border: 1px solid transparent; box-shadow: rgba(14, 63, 126, 0.04) 0 0 0 1px, rgba(42, 51, 69, 0.04) 0 1px 1px -0.5px, rgba(42, 51, 70, 0.04) 0 3px 3px -1.5px, rgba(42, 51, 70, 0.04) 0 6px 6px -3px, rgba(14, 63, 126, 0.04) 0 12px 12px -6px, rgba(14, 63, 126, 0.04) 0 24px 24px -12px; } .matcap-previews canvas { width: 100%; border-radius: 50%; } .matcap-previews > div.active { box-shadow: rgba(14, 63, 126, 0.04) 0 0 0 1px, rgba(42, 51, 69, 0.9) 0 3px 1px -0.5px, rgba(42, 51, 70, 0.04) 0 3px 3px -1.5px, rgba(42, 51, 70, 0.04) 0 6px 6px -3px, rgba(14, 63, 126, 0.04) 0 12px 12px -6px, rgba(14, 63, 126, 0.04) 0 24px 24px -12px; } .lil-gui { --width: 400px; max-width: 90%; --widget-height: 20px; font-size: 15px; --input-font-size: 15px; --padding: 10px; --spacing: 10px; --slider-knob-width: 5px; --background-color: rgba(5, 0, 15, .8); --widget-color: rgba(255, 255, 255, .3); --focus-color: rgba(255, 255, 255, .4); --hover-color: rgba(255, 255, 255, .5); --font-family: monospace; z-index: 1; } </style> </head> <body translate="no"> <div class="container"> <canvas id="canvas-3d"></canvas> </div> <div class="matcap-previews"> </div> <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.min.js", "three/addons/": "//repo.bfw.wiki/bfwrepo/js/module/three/examples/164/jsm/" } } </script> <script type="module"> import * as THREE from "three"; import { OrbitControls } from "three/addons/controls/OrbitControls.js"; import { ImprovedNoise } from "three/addons/math/ImprovedNoise.js"; import { GUI } from "three/addons/libs/lil-gui.module.min.js"; const containerEl = document.querySelector(".container"); const canvasEl = document.querySelector("#canvas-3d"); const previewsContainer = document.querySelector(".matcap-previews"); let renderer, scene, camera, orbit, material, geometry; // no need to use a 3d noise here, // keeping ImprovedNoise() just for code simplicity const perlin = new ImprovedNoise(); const params = { resolution: 12, previewPadding: 3, amplitude: 1 }; const texturesURL = [ "//repo.bfw.wiki/bfwrepo/images/sphere/1.png", "//repo.bfw.wiki/bfwrepo/images/sphere/2.png", "//repo.bfw.wiki/bfwrepo/images/sphere/3.png", "//repo.bfw.wiki/bfwrepo/images/sphere/4.png", "//repo.bfw.wiki/bfwrepo/images/sphere/5.png", "//repo.bfw.wiki/bfwrepo/images/sphere/6.png", "//repo.bfw.wiki.........完整代码请登录后点击上方下载按钮下载查看
网友评论0