diff options
| -rw-r--r-- | Scripts/cloth.js | 17 | ||||
| -rw-r--r-- | index.html | 1 |
2 files changed, 11 insertions, 7 deletions
diff --git a/Scripts/cloth.js b/Scripts/cloth.js index 1497583..f1ac682 100644 --- a/Scripts/cloth.js +++ b/Scripts/cloth.js @@ -371,7 +371,7 @@ getAcceleration(vertexIndex, dt) { // constant gravity
let g = new THREE.Vector3(0, -9.8, 0);
// stiffness
- let k = 1000;
+ let k = 500;
// Wind vector
let fWind = new THREE.Vector3(
@@ -386,7 +386,7 @@ getAcceleration(vertexIndex, dt) { * achievement of cloth effects through try out
* */
let a = 0.01;
-
+
let velocity = new THREE.Vector3(
(this.previousPositions[vertexIndex].x - vertex.x) / dt,
(this.previousPositions[vertexIndex].y - vertex.y) / dt,
@@ -395,8 +395,8 @@ getAcceleration(vertexIndex, dt) { //console.log(velocity, vertex, this.previousPositions[vertexIndex]);
- let fAirResistance = velocity.cross(velocity).multiplyScalar(-a);
-
+ let fAirResistance = velocity.multiply(velocity).multiplyScalar(-a);
+
let springSum = new THREE.Vector3(0, 0, 0);
// Get the bounding springs and add them to the needed springs
@@ -412,8 +412,9 @@ getAcceleration(vertexIndex, dt) { if (this.faces[i].springs[j].index1 == vertexIndex)
springDirection.multiplyScalar(-1);
-
+
springSum.add(springDirection.multiplyScalar(k * (spring.restLength - spring.currentLength)));
+
}
}
}
@@ -421,8 +422,10 @@ getAcceleration(vertexIndex, dt) { let result = new THREE.Vector3(1, 1, 1);
- result.multiplyScalar(M).multiply(g).add(fWind).add(fAirResistance).sub(springSum);
-
+ let temp = result.multiplyScalar(M).multiply(g).add(fWind).add(fAirResistance).clone();
+ result.sub(springSum);
+ document.getElementById("Output").innerText = "SpringSum: " + Math.floor(springSum.y) + "\nTemp: " + Math.floor(temp.y);
+
return result;
}
@@ -16,6 +16,7 @@ <body>
<div id="threejscontainer"></div>
+ <div id="Output"></div>
</body>
</html>
\ No newline at end of file |
