three实现三维玻璃材质菱镜旋转反射动画效果代码
代码语言:html
所属分类:三维
代码描述:three实现三维玻璃材质菱镜旋转反射动画效果代码
代码标签: three 三维 玻璃 材质 菱镜 旋转 反射 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> * { margin: 0; padding: 0; } canvas { position: fixed; width: 100%; height: 100%; top: 0; left: 0; margin: 0; padding: 0; } </style> </head> <body > <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.145.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/RGBELoader.145.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/OrbitControls.145.js"></script> <script > !function () { "use strict"; let e,t,n,o,i,r,a,d,E,l = new THREE.Group(),s = new THREE.Group(),c = 3,w = 1,m = ""; function h() { let e = this.attributes.position; if (null != this.index) return; let t = e.count / 3,n = [],o = new THREE.Triangle(),i = new THREE.Vector3(),r = new THREE.Vector3(),a = new THREE.Vector3(); for (let d = 0; d < t; d++) { i.fromBufferAttribute(e, 3 * d + 0), r.fromBufferAttribute(e, 3 * d + 1), a.fromBufferAttribute(e, 3 * d + 2), o.set(i, r, a); let t = new THREE.Vector3(); o.getMidpoint(t); let E = i.distanceTo(r),l = Math.sqrt(3) / 2 * E * .33,s = t.clone().normalize().setLength(l); t.add(s), n.push(t.clone(), i.clone(), r.clone(), t.clone(), r.clone(), a.clone(), t.clone(), a.clone(), i.clone()); } let d = new THREE.BufferGeometry().setFromPoints(n); return d.computeVertexNormals(), d; } function u(e, t, n, o = "") { i = new THREE.IcosahedronGeometry(t, n); let r = []; for (let e = 0; e < i.attributes.position.count; e++) { let t = new THREE.Vector3(); t.fromBufferAttribute(i.getAttribute("position"), e), r.push([t.x, t.y, t.z]); } r = [...new Set(r.map(JSON.stringify))].map(JSON.parse); for (let t = 0; t < r.length; t++) { let n = new THREE.Vector3(r[t][0], r[t][1], r[t][2]); (a = d.clone()).position.set(n.x, n.y, n.z), "random" == o ? (a.material = d.material.clone(), a.material.color.set(new THREE.Color(16777215 * Math.random()))) : o && (a.material = d.material.clone(), a.material.color.set(new THREE.Color(o))), a.castShadow = !0, a.receiveShadow = !0, e.add(a); } } function R() { .........完整代码请登录后点击上方下载按钮下载查看
网友评论0