|
|
@ -22,6 +22,7 @@ class PhysicsWorker extends PhysicsBase { |
|
|
|
var msg = event.data; |
|
|
|
switch (msg.type) { |
|
|
|
case 'physicsTick': |
|
|
|
this.processRemovals(); |
|
|
|
this.physicsTick(); |
|
|
|
this.sendPositions(); |
|
|
|
break; |
|
|
@ -57,24 +58,6 @@ class PhysicsWorker extends PhysicsBase { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// physicsTick() {
|
|
|
|
// if(this.physicsTimeout) {
|
|
|
|
// // cancel any outstanding requests to prevent manipulation of data while iterating
|
|
|
|
// // and we're going to handle it next anyways.
|
|
|
|
// clearTimeout(this.physicsTimeout);
|
|
|
|
// }
|
|
|
|
// this.processRemovals();
|
|
|
|
// if (this.options.enabled) {
|
|
|
|
// this.calculateForces();
|
|
|
|
// this.moveNodes();
|
|
|
|
// // Handle the case where physics was enabled, data was removed
|
|
|
|
// // but this physics tick was longer than the timeout and during that delta
|
|
|
|
// // physics was disabled.
|
|
|
|
// this.processRemovals();
|
|
|
|
// }
|
|
|
|
// this.stabilizationIterations++;
|
|
|
|
// }
|
|
|
|
|
|
|
|
sendPositions() { |
|
|
|
let nodeIndices = this.physicsBody.physicsNodeIndices; |
|
|
|
let positions = {}; |
|
|
@ -182,17 +165,9 @@ class PhysicsWorker extends PhysicsBase { |
|
|
|
this.toRemove.nodeIds.push.apply(this.toRemove.nodeIds, data.nodeIds); |
|
|
|
this.toRemove.edgeIds.push.apply(this.toRemove.edgeIds, data.edgeIds); |
|
|
|
// Handle case where physics is disabled.
|
|
|
|
if(this.physicsTimeout) { |
|
|
|
// don't schedule more than one physicsTick
|
|
|
|
clearTimeout(this.physicsTimeout); |
|
|
|
if (!this.options.enabled) { |
|
|
|
this.processRemovals(); |
|
|
|
} |
|
|
|
this.physicsTimeout = setTimeout(()=> { |
|
|
|
// if physics is still enabled, the next tick will handle removeElements
|
|
|
|
if (!this.options.enabled) { |
|
|
|
this.physicsTimeout = null; |
|
|
|
this.physicsTick(); |
|
|
|
} |
|
|
|
}, 250); |
|
|
|
} |
|
|
|
|
|
|
|
processRemovals() { |
|
|
|