threefiz
Version:
Implementation of a physics engine based on the [Three.js](https://github.com/mrdoob/three.js) library.
2 lines (1 loc) • 934 B
JavaScript
import{c as s,B as b,M as a,D as n,C as r,b as i,T as y,V as t,s as d,d as x,e as c,r as M}from"./init-BHUQqx8w.js";import{g}from"./lil-gui.module.min-Vka56b52.js";s.position.set(0,20,50);const p=new b(20,20,20),B=new a({color:new r("hsl(200, 100%, 80%)"),transparent:!0,opacity:.5,side:n}),u=new i(p,B),S=new a({color:new r("hsl(0, 100%, 80%)"),transparent:!0,opacity:.5,side:n}),w=new i(p,S),e=new y({scene:d,gravity:new t(0,0,0)});e.addBox({mesh:u,position:new t(15,0,0),velocity:new t(-30,0,0),restitution:1});e.addBox({mesh:w,position:new t(-15,0,0),restitution:1});e.init();u.castShadow=!0;w.castShadow=!0;const o=new x;o.dom.style.setProperty("position","absolute");o.dom.style.setProperty("top","0");const m={start:()=>e.resume(),pause:()=>e.pause()},l=new g;l.add(m,"start");l.add(m,"pause");document.body.appendChild(o.dom);c.update();const h=()=>{c.update(),o.update(),e.step(),M.render(d,s),requestAnimationFrame(h)};h();