Skip to content

Commit

Permalink
Added activemodelchange event
Browse files Browse the repository at this point in the history
  • Loading branch information
alxart committed Sep 24, 2024
1 parent c7b6b46 commit 3e51277
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/realtyScene/realtyScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,29 @@ export class RealtyScene {
}
}

if (prevState.activeModelId !== newState.activeModelId) {
let buildingModelId: string | undefined;
let floorModelId: string | undefined;

if (newState.activeModelId !== undefined) {
const building = this.buildings.get(newState.activeModelId);
if (building) {
buildingModelId = building.modelId;
} else {
const floor = this.floors.get(newState.activeModelId);
if (floor) {
buildingModelId = floor.buildingOptions.modelId;
floorModelId = floor.id;
}
}
}

this.plugin.emit('activemodelchange', {
buildingModelId,
floorModelId,
});
}

this.state = {
buildingVisibility,
activeModelId: newState.activeModelId,
Expand Down
9 changes: 9 additions & 0 deletions src/types/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,13 @@ export interface GltfPluginEventTable {
* Emitted when user moves mouse away from a model or a label.
*/
mouseout: GltfPluginLabelEvent | GltfPluginModelEvent;
/**
* Emitted when an active model has changed on the realty scene.
* @hidden
* @internal
*/
activemodelchange: {
buildingModelId?: string;
floorModelId?: string;
};
}

0 comments on commit 3e51277

Please sign in to comment.