Skip to content

Commit

Permalink
XEOK-169 Fix undefined this._entity.model
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalDybizbanskiCreoox committed Nov 28, 2024
1 parent b18fb36 commit 7fbbbea
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 7fbbbea

Please sign in to comment.