const MASS = 0.1;\r
const GRAVITY = new THREE.Vector3(0, -9.81 * MASS, 0);\r
const K = 1;\r
+const MAX_STRETCH = 1.5;\r
\r
-// Flag Texture\r
+// Explosion am Anfang\r
+// Intersect mit Velocity?\r
+// Wind/Ziehen\r
\r
const options = {\r
wind: true,\r
//const correction = diff.multiplyScalar(1 - (this.restDist / currentDist));\r
const correction = diff.multiplyScalar((currentDist - this.restDist) / currentDist);\r
correction.multiplyScalar(K);\r
- correction.clampLength(0, 1);\r
+ if (currentDist >= this.restDist * MAX_STRETCH) {\r
+\r
+ }\r
+ //correction.clampLength(0, 1);\r
const correctionHalf = correction.multiplyScalar(0.5);\r
\r
let p1movable = this.p1.movable && this.p1.movableTmp;\r
constraint.satisfy();\r
}\r
\r
- this.intersect();\r
+ //this.intersect();\r
}\r
\r
intersect() {\r
continue;\r
\r
let dist = p1.position.distanceTo(p2.position);\r
- const collisionDistance = Math.min(this.width / this.numPointsWidth, this.height / this.numPointsHeight);\r
+ let collisionDistance = Math.min(this.width / this.numPointsWidth, this.height / this.numPointsHeight);\r
+ // collisionDistance /= 2;\r
if (dist < collisionDistance) {\r
// p1.movableTmp = false;\r
// p2.movableTmp = false;\r
- let diff = p1.position.clone().sub(p2.position).normalize();\r
- diff.multiplyScalar((collisionDistance - dist) * 1.001 / 2);\r
+ let diffP2P1 = p1.position.clone().sub(p2.position).normalize();\r
+ diffP2P1.multiplyScalar((collisionDistance - dist) * 1.001 / 2);\r
+ let diffP1P2 = diffP2P1.clone().multiplyScalar(-1);\r
+\r
+ // let v1 = p1.position.clone().sub(p1.previous).normalize();\r
+ // let v2 = p2.position.clone().sub(p2.previous).normalize();\r
+\r
+ // let factor1 = (Math.PI - Math.acos(v1.dot(diffP2P1))) / Math.PI * 2;\r
+ // let factor2 = (Math.PI - Math.acos(v2.dot(diffP1P2))) / Math.PI * 2;\r
+\r
if (p1.movable)\r
- p1.position.add(diff);\r
+ p1.position.add(diffP2P1);\r
+ //p1.position.add(diffP2P1.multiplyScalar(factor1));\r
if (p2.movable)\r
- p2.position.sub(diff);\r
+ p2.position.add(diffP1P2);\r
+ //p2.position.add(diffP1P2.multiplyScalar(factor2));\r
}\r
}\r
}\r
}\r
+ blow(camPos, intersects) {\r
+ let face = intersects[0].face;\r
+ let dir = intersects[0].point.clone().sub(camPos).multiplyScalar(100);\r
+ this.particles[face.a].addForce(dir);\r
+ this.particles[face.b].addForce(dir);\r
+ this.particles[face.c].addForce(dir);\r
+ }\r
+ drag(mousePosWorld, index) {\r
+ let dir = mousePosWorld.clone().sub(this.particles[index].position).multiplyScalar(200);\r
+ this.particles[index].addForce(dir);\r
+ }\r
\r
/**\r
* helper function to calculate index of vertex\r