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