]> gitweb.ps.run Git - cloth_sim/blobdiff - Scripts/cloth.js
Adjusting parameters
[cloth_sim] / Scripts / cloth.js
index 14975839294f6f45356f3e2e2802d94c3c7cb456..f1ac682fa3c9a4841f425ee9412b0b9d523ff159 100644 (file)
@@ -371,7 +371,7 @@ getAcceleration(vertexIndex, dt) {
   // constant gravity\r
   let g = new THREE.Vector3(0, -9.8, 0);\r
   // stiffness\r
-  let k = 1000;\r
+  let k = 500;\r
 \r
   // Wind vector\r
   let fWind = new THREE.Vector3(\r
@@ -386,7 +386,7 @@ getAcceleration(vertexIndex, dt) {
    * achievement of cloth effects through try out\r
    * */\r
   let a = 0.01;\r
-\r
+  \r
   let velocity = new THREE.Vector3(\r
     (this.previousPositions[vertexIndex].x - vertex.x) / dt,\r
     (this.previousPositions[vertexIndex].y - vertex.y) / dt,\r
@@ -395,8 +395,8 @@ getAcceleration(vertexIndex, dt) {
 \r
   //console.log(velocity, vertex, this.previousPositions[vertexIndex]);\r
 \r
-  let fAirResistance = velocity.cross(velocity).multiplyScalar(-a);\r
-\r
+  let fAirResistance = velocity.multiply(velocity).multiplyScalar(-a);\r
+  \r
   let springSum = new THREE.Vector3(0, 0, 0);\r
 \r
   // Get the bounding springs and add them to the needed springs\r
@@ -412,8 +412,9 @@ getAcceleration(vertexIndex, dt) {
 \r
           if (this.faces[i].springs[j].index1 == vertexIndex)\r
             springDirection.multiplyScalar(-1);\r
-\r
+     \r
           springSum.add(springDirection.multiplyScalar(k * (spring.restLength - spring.currentLength)));\r
+\r
         }\r
       }\r
     }\r
@@ -421,8 +422,10 @@ getAcceleration(vertexIndex, dt) {
   \r
   let result = new THREE.Vector3(1, 1, 1);\r
 \r
-  result.multiplyScalar(M).multiply(g).add(fWind).add(fAirResistance).sub(springSum);\r
-  \r
+  let temp = result.multiplyScalar(M).multiply(g).add(fWind).add(fAirResistance).clone();\r
+  result.sub(springSum);\r
+  document.getElementById("Output").innerText = "SpringSum: " + Math.floor(springSum.y) + "\nTemp: " + Math.floor(temp.y);\r
+\r
   return result;\r
 }\r
 \r