X-Git-Url: https://gitweb.ps.run/cloth_sim/blobdiff_plain/fcfb3d929c2fefdfdcb6cb9351bcdd0d2d14f9f2..e05a5c0a7aa891179af219eff0df34647acc8eb3:/Scripts/main.js diff --git a/Scripts/main.js b/Scripts/main.js index a0387ac..5ed1866 100644 --- a/Scripts/main.js +++ b/Scripts/main.js @@ -57,7 +57,8 @@ document.body.onload = init; function init() { let mousePos = new Point(); - + let previousClothSimulation; + /** * Space left empty under canvas * for UI elements @@ -74,6 +75,11 @@ function init() { const material = new THREE.MeshBasicMaterial({ color: 0x0000ff }); const mesh = new THREE.Mesh(cloth.geometry, material); + //const mesh = new THREE.WireframeGeometry(cloth.geometry); + //const line = new THREE.LineSegments(mesh); + //line.material.depthTest = false; + //line.material.opacity = 0.25; + //line.material.transparent = true; scene.add(mesh); /** @@ -81,7 +87,12 @@ function init() { * @param {number} dt - time passed since last frame */ function animate(dt) { - requestAnimationFrame(animate); + + cloth.simulate(dt); + + setTimeout(() => { + animate(2000); + }, 2000); renderer.render(scene, camera); }