|
@ -158,7 +158,15 @@ class PhysicsEngine extends PhysicsBase { |
|
|
*/ |
|
|
*/ |
|
|
initEmbeddedPhysics() { |
|
|
initEmbeddedPhysics() { |
|
|
this.positionUpdateHandler = () => {}; |
|
|
this.positionUpdateHandler = () => {}; |
|
|
this.physicsUpdateHandler = () => {}; |
|
|
|
|
|
|
|
|
this.physicsUpdateHandler = (properties) => { |
|
|
|
|
|
if (properties.options.physics !== undefined) { |
|
|
|
|
|
// we've received a node that has changed physics state
|
|
|
|
|
|
// so rebuild physicsBody
|
|
|
|
|
|
this.initPhysicsData(); |
|
|
|
|
|
} |
|
|
|
|
|
// else we're accessing the information directly out of the node
|
|
|
|
|
|
// so no need to do anything.
|
|
|
|
|
|
}; |
|
|
if (this.physicsWorker) { |
|
|
if (this.physicsWorker) { |
|
|
this.options.useWorker = false; |
|
|
this.options.useWorker = false; |
|
|
this.physicsWorker.terminate(); |
|
|
this.physicsWorker.terminate(); |
|
@ -172,11 +180,13 @@ class PhysicsEngine extends PhysicsBase { |
|
|
if (!this.physicsWorker) { |
|
|
if (!this.physicsWorker) { |
|
|
// setup path to webworker javascript file
|
|
|
// setup path to webworker javascript file
|
|
|
if (!__webpack_public_path__) { |
|
|
if (!__webpack_public_path__) { |
|
|
|
|
|
// search for element with id of 'visjs'
|
|
|
let parentScript = document.getElementById('visjs'); |
|
|
let parentScript = document.getElementById('visjs'); |
|
|
if (parentScript) { |
|
|
if (parentScript) { |
|
|
let src = parentScript.getAttribute('src') |
|
|
let src = parentScript.getAttribute('src') |
|
|
__webpack_public_path__ = src.substr(0, src.lastIndexOf('/') + 1); |
|
|
__webpack_public_path__ = src.substr(0, src.lastIndexOf('/') + 1); |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
// search all scripts for 'vis.js'
|
|
|
let scripts = document.getElementsByTagName('script'); |
|
|
let scripts = document.getElementsByTagName('script'); |
|
|
for (let i = 0; i < scripts.length; i++) { |
|
|
for (let i = 0; i < scripts.length; i++) { |
|
|
let src = scripts[i].getAttribute('src'); |
|
|
let src = scripts[i].getAttribute('src'); |
|
@ -383,7 +393,6 @@ class PhysicsEngine extends PhysicsBase { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// TODO determine when startedStabilization needs to be propogated from the worker
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* trigger the stabilized event. |
|
|
* trigger the stabilized event. |
|
|
* @private |
|
|
* @private |
|
|