Skip to content

Commit

Permalink
Simplify logic of hightlighting models
Browse files Browse the repository at this point in the history
  • Loading branch information
myshov committed Jun 25, 2023
1 parent c8e4f5a commit edbfc80
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/realtyScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class RealtyScene {
this.plugin.on('click', (ev) => {
if (ev.target.type === 'model') {
const id = ev.target.modelId;
if (this.isFacadeBuilding(id) && id !== undefined) {
if (this.isFacadeBuilding(id)) {
this.buildingClickHandler(scene, id);
}
}
Expand All @@ -169,18 +169,20 @@ export class RealtyScene {

this.plugin.on('mouseover', (ev) => {
if (ev.target.type === 'model') {
if (this.isFacadeBuilding(ev.target.modelId)) {
const id = ev.target.modelId;
if (this.isFacadeBuilding(id)) {
this.container.style.cursor = 'pointer';
this.toggleHighlightModel(ev.target.modelId);
this.toggleHighlightModel(id);
}
}
});

this.plugin.on('mouseout', (ev) => {
if (ev.target.type === 'model') {
if (this.isFacadeBuilding(ev.target.modelId)) {
const id = ev.target.modelId;
if (this.isFacadeBuilding(id)) {
this.container.style.cursor = '';
this.toggleHighlightModel(ev.target.modelId);
this.toggleHighlightModel(id);
}
}
});
Expand Down Expand Up @@ -242,7 +244,7 @@ export class RealtyScene {
}

// checks if the modelId is external facade of the building
private isFacadeBuilding(modelId?: Id) {
private isFacadeBuilding(modelId?: Id): modelId is Id {
if (modelId === undefined) {
return false;
}
Expand Down Expand Up @@ -425,11 +427,7 @@ export class RealtyScene {
}
}

public toggleHighlightModel(modelId?: Id) {
if (modelId === undefined) {
return;
}

public toggleHighlightModel(modelId: Id) {
const model = this.models.get(String(modelId));

if (model === undefined) {
Expand Down

0 comments on commit edbfc80

Please sign in to comment.