From 9866c25fe964b215e0e491638ee541bdf8d29f56 Mon Sep 17 00:00:00 2001 From: Ramtin Naraghi Date: Fri, 22 Jan 2021 15:14:28 +0100 Subject: [PATCH 1/1] Adjusting parameters --- Scripts/cloth.js | 17 ++++++++++------- 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; } diff --git a/index.html b/index.html index 402b1b9..8f0eeb1 100644 --- a/index.html +++ b/index.html @@ -16,6 +16,7 @@
+
\ No newline at end of file -- 2.50.1