+ this.restDist = restDist;\r
+ }\r
+\r
+ satisfy() {\r
+ const diff = this.p2.position.clone().sub(this.p1.position);\r
+ const currentDist = diff.length();\r
+ if (currentDist == 0) return;\r
+ if (currentDist <= this.restDist) return;\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
+ const correctionHalf = correction.multiplyScalar(0.5);\r
+ if (this.p1.movable && this.p2.movable) {\r
+ this.p1.position.add(correctionHalf);\r
+ this.p2.position.sub(correctionHalf);\r
+ } else if (! this.p1.movable && this.p2.movable) {\r
+ this.p2.position.sub(correction);\r
+ } else if (this.p1.movable && ! this.p2.movable) {\r
+ this.p1.position.add(correction);\r
+ }\r