abouttreesummaryrefslogcommitdiff
diff options
context:
space:
mode:
authorRamtin Naraghi2021-01-22 15:14:28 +0100
committerRamtin Naraghi2021-01-22 15:14:28 +0100
commit9866c25fe964b215e0e491638ee541bdf8d29f56 (patch)
treeed6cdf600e3376ad8b3e7356c368f23d6a511f11
parent14881afe547086f68764e27bd65c794b21271c63 (diff)
downloadcloth_sim-9866c25fe964b215e0e491638ee541bdf8d29f56.tar.gz
cloth_sim-9866c25fe964b215e0e491638ee541bdf8d29f56.zip
Adjusting parameters
-rw-r--r--Scripts/cloth.js17
-rw-r--r--index.html1
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;
}
diff --git a/index.html b/index.html
index 402b1b9..8f0eeb1 100644
--- a/index.html
+++ b/index.html
@@ -16,6 +16,7 @@
<body>
<div id="threejscontainer"></div>
+ <div id="Output"></div>
</body>
</html> \ No newline at end of file