three+ammo实现太阳系宇宙月球地球火星冥王星土星木星金星海王星三维行星物理代码

代码语言:html

所属分类:三维

代码描述:three+ammo实现太阳系宇宙月球地球火星冥王星土星木星金星海王星三维行星物理代码,行星碰撞一起物理动画效果代码

代码标签: three ammo 太阳系 宇宙 月球 地球 火星 冥王星 土星 木星 金星 海王星 三维 行星

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">
  

  
  
  
  
<style>
* {
  margin: 0;
  padding: 0;
}
body {
  background: #000000;
}
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.144.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/OrbitControls.144.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/AmmoPhysics.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/MeshSurfaceSampler.js"></script>
      <script>
!function () {
  "use strict";
  let e, t, a, o, n, i, r;
  const s = .5,d = 10;
  function l() {
    e.aspect = window.innerWidth / window.innerHeight, e.updateProjectionMatrix(), a.setSize(window.innerWidth, window.innerHeight);
  }
  function p() {
    requestAnimationFrame(p), o.update(), a.render(t, e);
  }
  !async function () {
    r = await THREE.AmmoPhysics();
    const h = document.createElement("div");
    document.body.appendChild(h), (t = new THREE.Scene()).background = null, (a = new THREE.WebGLRenderer({
      antialias: !0,
      alpha: !0 })).
    setPixelRatio(window.devicePixelRatio), a.setSize(window.innerWidth, window.innerHeight),
    a.setClearColor(0, 0), a.shadowMap.enabled = !0, a.outputEncoding = THREE.sRGBEncoding,
    h.appendChild(a.domElement), (e = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, .1, 1e3 * s)).position.set(0, 4 * s, 8 * s),
    e.lookAt(0, s, 0);
    const m = new THREE.AmbientLight(16777215, .5);
    t.add(m);
    const c = new THREE.DirectionalLight(16777215, .8);
    c.position.set(0, 10 * s, 10 * s), c.target.position.set(0, 0, 0), c.castShadow = !0,
    c.shadow.mapSize.width = 512, c.shadow.mapSize.height = 512, t.add(c);
    n = new THREE.BoxGeometry(15 * s, .1, 15 * s, 1);
    let E = new THREE.Mesh(n, new THREE.MeshLambertMaterial({
      color: 65793 }));

    E.position.y = -.05, E.receiveShadow = !0, t.add(E), r.addMesh(E, 0), n = new THREE.IcosahedronGeometry(s, d);
    const w = new THREE.TextureLoader().load("//repo.bfw.wiki/bfwrepo/icon/633299b8b0c13.jpg");
    i = new THREE.MeshLambertMaterial({
      color: 16767823,
      side: THREE.FrontSide,
      transparent: !0,
      opacity: 1,
      map: w });

    let u = new THREE.Mesh(n, i);
    u.position.y = Math.random() * s * 2 + 2 * s, u.receiveShadow = !0, u.castShadow = !0,
    t.add(u), r.addMesh(u, 8);
    const T = new THREE.TextureLoader().load("//repo.bfw.wiki/bfwrepo/icon/633299aa22e72.jpg");
    let M = u.clone();
    M.material = i.clone(), M.material.map = T, M.material.color.set(12816707), M.position.x = -Math.random() * s * 3,
    M.position.y = Math.random() * s * 2 + 2 * s, t.add(M), r.addMesh(M, 8);
    const g = new THREE.TextureLoader().load("//repo.bfw.wiki/bfwrepo/icon/633.........完整代码请登录后点击上方下载按钮下载查看

网友评论0