Skip to content

Commit

Permalink
Merge pull request #1748 from xeokit/XEOK-169-fix-undefined-entity-model
Browse files Browse the repository at this point in the history
XEOK-169 Fix undefined this._entity.model
  • Loading branch information
xeolabs authored Nov 28, 2024
2 parents b18fb36 + 7fbbbea commit 12ecb79
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions src/viewer/scene/marker/Marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,25 +191,10 @@ class Marker extends Component {
* @type {Entity}
*/
set entity(entity) {
if (this._entity) {
if (this._entity === entity) {
return;
}
if (this._onEntityDestroyed !== null) {
if (this._entity.model) {
this._entity.model.off(this._onEntityDestroyed);
} else {
this._entity.off(this._onEntityDestroyed);
}
this._onEntityDestroyed = null;
}
if (this._onEntityModelDestroyed !== null) {
if (this._entity.model) {
this._entity.model.off(this._onEntityModelDestroyed);
}
this._onEntityModelDestroyed = null;
}
if (this._entity === entity) {
return;
}
this._cleanupDestroyedHandlers();
this._entity = entity;
if (this._entity) {
if (this._entity.isSceneModelEntity) {
Expand Down Expand Up @@ -374,16 +359,28 @@ class Marker extends Component {
this.fire("destroyed", true);
this.scene.camera.off(this._onCameraViewMatrix);
this.scene.camera.off(this._onCameraProjMatrix);
this._cleanupDestroyedHandlers();
this._renderer.removeMarker(this);
super.destroy();
}

_cleanupDestroyedHandlers() {
if (this._entity) {
if (this._onEntityDestroyed !== null) {
this._entity.model.off(this._onEntityDestroyed);
if (this._entity.model) {
this._entity.model.off(this._onEntityDestroyed);
} else {
this._entity.off(this._onEntityDestroyed);
}
this._onEntityDestroyed = null;
}
if (this._onEntityModelDestroyed !== null) {
this._entity.model.off(this._onEntityModelDestroyed);
if (this._entity.model) {
this._entity.model.off(this._onEntityModelDestroyed);
}
this._onEntityModelDestroyed = null;
}
}
this._renderer.removeMarker(this);
super.destroy();
}
}

Expand Down

0 comments on commit 12ecb79

Please sign in to comment.