]> gitweb.ps.run Git - cloth_sim/blobdiff - Scripts/cloth.js
fix spring force calculation
[cloth_sim] / Scripts / cloth.js
index 266af16a3f1236417b7efd8c0c8805508d508bca..e39b95b9850400cf98cbd7c20f5f3aa1b5d73fbb 100644 (file)
@@ -112,6 +112,9 @@ export class Cloth {
     let vertices = [];\r
     let faces = [];\r
 \r
     let vertices = [];\r
     let faces = [];\r
 \r
+    this.numPointsWidth = numPointsWidth;\r
+    this.numPointsHeight = numPointsHeight;\r
+\r
     /**\r
      * distance between two vertices horizontally/vertically\r
      * divide by the number of points minus one\r
     /**\r
      * distance between two vertices horizontally/vertically\r
      * divide by the number of points minus one\r
@@ -403,8 +406,8 @@ getAcceleration(vertexIndex, dt) {
   // Get the bounding springs and add them to the needed springs\r
   // TODO: optimize\r
 \r
   // Get the bounding springs and add them to the needed springs\r
   // TODO: optimize\r
 \r
-  const numPointsX = 10;\r
-  const numPointsY = 10;\r
+  const numPointsX = this.numPointsWidth;\r
+  const numPointsY = this.numPointsHeight;\r
   const numFacesX = numPointsX - 1;\r
   const numFacesY = numPointsY - 1;\r
 \r
   const numFacesX = numPointsX - 1;\r
   const numFacesY = numPointsY - 1;\r
 \r