three实现360全景沙漠中的环面玻璃材质效果代码
代码语言:html
所属分类:三维
代码描述:three实现360全景沙漠中的环面玻璃材质效果代码
代码标签: three 360 全景 沙漠 环面 玻璃 材质
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> * { -moz-user-select: none; -webkit-user-select: none; -ms-user-select: none; user-select: none; margin: 0; padding: 0; } body { position: relative; width: 100%; height: 100%; text-align: center; } 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/OrbitControls.145.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/ammo.wasm.min.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/ParametricGeometry.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/ParametricGeometries.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/CurveExtras.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/GroundProjectedEnv.js"></script> <script type="module"> async function e() { function e(e, t = { x: 1, y: 1, z: 1 }) { let n = null; u.setValue(0, 0, 0); let o = e.attributes.position.array; n = new Ammo.btConvexHullShape(); for (let e = 0, t = o.length; e < t; e += 3) { u.setValue(o[e], o[e + 1], o[e + 2]); const i = e >= t - 3; n.addPoint(u, i); } return n && (u.setValue(t.x, t.y, t.z), n.setLocalScaling(u), n.setMargin(0)), n; } function n(e, t, n, i = null) { m = e.position, h = e.quaternion, c.setIdentity(), u.setValue(m.x, m.y, m.z), c.setOrigin(u), c.setRotation(new o.btQuaternion(h.x, h.y, h.z, h.w)), u.setValue(0, 0, 0); const a = new o.btDefaultMotionState(c),s = u; t > 0 && n.calculateLocalInertia(t, s); const r = new o.btRigidBodyConstructionInfo(t, a, n, s),d = new o.btRigidBody(r); "ball" == e.name || "sphere_i" == e.name ? (d.setFriction(0), d.setRestitution(0), d.setDamping(0, 0)) : "curve" == e.name ? (d.setFriction(0), d.setRestitution(0), d.setDamping(0, 0)) : "torus" == e.name || "sphere_o" == e.name ? (d.setFriction(.1), d.setRestitution(0), d.setDamping(0, 0)) : "wall" == e.name ? (d.setFriction(10), d.setRollingFriction(1), d.setRestitution(0), d.setDamping(0, 0)) : (d.setFriction(1), d.setRollingFriction(.5), d.setRestitution(0), d.setDamping(0, 0)), "ball" == e.name && i && (u.setValue(i.x, i.y, i.z), d.setLinearVelocity(u)), d.name = e.name, l.addRigidBody(d), t > 0 && (p.push(e), g.set(e, d)); } if ("Ammo" in window == !1) return; const o = await Ammo(),i = new o.btDefaultCollisionConfiguration(),a = new o.btCollisionDispatcher(i),s = new o.btDbvtBroadphase(),r = new o.btSequentialImpulseConstraintSolver(),l = new o.btDiscreteDynamicsWorld(a, s, r, i); l.setGravity(new o.btVector3(0, -10, 0)), Ammo.btGImpactCollisionAlgorithm.prototype.registerAlgorithm(l.getDispatcher()); let c = new o.btTransform(); const d = new o.btTransform(); let m,u = new o.btVector3(0, 0, 0),h = new o.btQuaternion(0, 0, 0, 0),w = (new THREE.Vector3(0, 0, 1).normalize(), null),E = "",p = [],g = new WeakMap(),M = 0; return setInterval(function () { const e = performance.now(); if (M > 0) { const t = (e - M) / 1e3; l.stepSimulation(t, 10); } M = e; for (let e = 0, n = p.length; e < n; e++) { if (!p[e]) continue; let n = p[e]; if (n.isInstancedMesh) { let e = n.instanceMatrix.array; if (!g.has(n)) continue; let o = g.get(n); for (let n = 0; n < o.length; n++) o[n] && (o[n].getMotionState().getWorldTransform(d), m = d.getOrigin(), h = d.getRotation().........完整代码请登录后点击上方下载按钮下载查看
网友评论0