@@ -15,6 +15,7 @@ export class ClothParticle {
1515 this . mass = mass ;
1616 this . pinned = false ;
1717 this . pinPosition = { x, y, z } ;
18+ this . onSphere = false ;
1819 }
1920
2021 addForce ( fx , fy , fz ) {
@@ -32,9 +33,11 @@ export class ClothParticle {
3233 return ;
3334 }
3435
35- const vx = ( this . x - this . oldX ) * damping ;
36- const vy = ( this . y - this . oldY ) * damping ;
37- const vz = ( this . z - this . oldZ ) * damping ;
36+ const effectiveDamping = this . onSphere ? damping * 0.7 : damping ;
37+
38+ const vx = ( this . x - this . oldX ) * effectiveDamping ;
39+ const vy = ( this . y - this . oldY ) * effectiveDamping ;
40+ const vz = ( this . z - this . oldZ ) * effectiveDamping ;
3841
3942 this . oldX = this . x ;
4043 this . oldY = this . y ;
@@ -120,7 +123,7 @@ export class ClothSimulator {
120123 this . mouseWind = { x : 0 , y : 0 , z : 0 } ;
121124
122125 this . sphereEnabled = true ;
123- this . sphereRadius = 1.8 ;
126+ this . sphereRadius = 1.3 ;
124127 this . spherePos = { x : 0 , y : - 1.2 , z : 1.2 } ;
125128
126129 this . floorEnabled = true ;
@@ -285,6 +288,7 @@ export class ClothSimulator {
285288 particle . x = currentSpherePos . x + nx * effectiveRadius ;
286289 particle . y = currentSpherePos . y + ny * effectiveRadius ;
287290 particle . z = currentSpherePos . z + nz * effectiveRadius ;
291+ particle . onSphere = true ;
288292 }
289293 }
290294
@@ -304,6 +308,10 @@ export class ClothSimulator {
304308 }
305309
306310 step ( dt , timeSec = 0 ) {
311+ for ( let p of this . particles ) {
312+ p . onSphere = false ;
313+ }
314+
307315 const rad = ( this . windAngle * Math . PI ) / 180 ;
308316 const windDirX = Math . cos ( rad ) ;
309317 const windDirZ = Math . sin ( rad ) ;
0 commit comments