// constant gravity\r
let g = new THREE.Vector3(0, -9.8, 0);\r
// stiffness\r
- let k = 500;\r
+ let k = 1000;\r
\r
// Wind vector\r
let fWind = new THREE.Vector3(\r
Math.cos(vertex.z * this.time),\r
Math.sin(Math.cos(5 * vertex.x * vertex.y * vertex.z))\r
);\r
- fWind.set(0, 0, 0);\r
\r
/**\r
* constant determined by the properties of the surrounding fluids (air)\r
* achievement of cloth effects through try out\r
* */\r
- let a = 0.01;\r
+ let a = 0.1;\r
\r
let velocity = new THREE.Vector3(\r
(this.previousPositions[vertexIndex].x - vertex.x) / dt,\r
// next position = 2 * current Position - previous position + acceleration * (passed time)^2\r
// acceleration (dv/dt) = F(net)\r
// Dependency for one vertex: gravity, fluids/air, springs\r
-\r
+ const DRAG = 0.97;\r
let nextPosition = new THREE.Vector3(\r
- (2 * currentPosition.x) - previousPosition.x + acceleration.x * (passedTime * passedTime),\r
- (2 * currentPosition.y) - previousPosition.y + acceleration.y * (passedTime * passedTime),\r
- (2 * currentPosition.z) - previousPosition.z + acceleration.z * (passedTime * passedTime),\r
+ (currentPosition.x - previousPosition.x) * DRAG + currentPosition.x + acceleration.x * (passedTime * passedTime),\r
+ (currentPosition.y - previousPosition.y) * DRAG + currentPosition.y + acceleration.y * (passedTime * passedTime),\r
+ (currentPosition.z - previousPosition.z) * DRAG + currentPosition.z + acceleration.z * (passedTime * passedTime),\r
);\r
\r
+ // let nextPosition = new THREE.Vector3(\r
+ // (2 * currentPosition.x) - previousPosition.x + acceleration.x * (passedTime * passedTime),\r
+ // (2 * currentPosition.y) - previousPosition.y + acceleration.y * (passedTime * passedTime),\r
+ // (2 * currentPosition.z) - previousPosition.z + acceleration.z * (passedTime * passedTime),\r
+ // );\r
+\r
return nextPosition;\r
}\r
\r
return nextPosition;\r
}\r
\r
+wind(intersects) {\r
+ let intersect = intersects[0];\r
+ this.geometry.vertices[intersect.face.a].z -= 0.05;\r
+ this.geometry.vertices[intersect.face.b].z -= 0.05;\r
+ this.geometry.vertices[intersect.face.c].z -= 0.05;\r
+}\r
+\r
}\r
\r