three+ammo实现雪地中三维雪人下雪动画效果代码

代码语言:html

所属分类:三维

代码描述:three+ammo实现雪地中三维雪人下雪动画效果代码

代码标签: three ammo 雪地 三维 雪人 下雪 动画

下面为部分代码预览,完整代码请点击下载或在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;
}
canvas {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  margin: 0;
  padding: 0;
}
</style>



</head>

<body  >
  <!-- using three.js -->
<!-- using ammo.js -->
<canvas id="colorMap"></canvas>
<canvas id="alphaMap"></canvas>

<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/three.145.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/ammo.wasm.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/BufferGeometryUtils.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/ConvexHull.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/ConvexGeometry.145.js"></script>
      <script type="module">
let amount = 8;

async function AmmoPhysics() {
  if ("Ammo" in window == !1) return void console.error("AmmoPhysics: Couldn't find Ammo.js");
  let e;
  const t = await Ammo(),o = new t.btDefaultCollisionConfiguration(),n = new t.btCollisionDispatcher(o),a = new t.btDbvtBroadphase(),r = new t.btSequentialImpulseConstraintSolver(),s = new t.btDiscreteDynamicsWorld(n, a, r, o);
  s.setGravity(new t.btVector3(0, -6, 0));
  let i = new t.btTransform();
  const l = new t.btTransform();
  let d,c = new t.btVector3(0, 0, 0),h = new t.btQuaternion(0, 0, 0, 0);
  function E(e) {
    let t = null;
    c.setValue(0, 0, 0);
    let o = e.attributes.position.array;
    t = new Ammo.btConvexHullShape();
    for (let e = 0, n = o.length; e < n; e += 3) {
      c.setValue(o[e], o[e + 1], o[e + 2]);
      const a = e >= n - 3;
      t.addPoint(c, a);
    }
    return t && t.setMargin(0), t || console.error("AmmoPhysics: Shape error."), t;
  }
  let w = [],u = new WeakMap();
  let p = null,m = "";
  function f(e, o, n) {
    d = e.position, h = e.quaternion, i.setIdentity(), c.setValue(d.x, d.y, d.z), i.setOrigin(c),
    i.setRotation(new t.btQuaternion(h.x, h.y, h.z, h.w));
    const a = e.scale;
    c.setValue(a.x, a.y, a.z), n.setLocalScaling(c), c.setValue(0, 0, 0);
    const r = new t.btDefaultMotionState(i),l = c;
    o > 0 && n.calculateLocalInertia(o, l);
    const E = new t.btRigidBodyConstructionInfo(o, r, n, l),p = new t.btRigidBody(E).........完整代码请登录后点击上方下载按钮下载查看

网友评论0