// 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
* 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
\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
\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
\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