Skip to content

Commit

Permalink
Merge pull request #199 from HoyosJuan/194-uimanager-bug
Browse files Browse the repository at this point in the history
fix(components): 194 - Fixed LengthMeasurement bug while UI Disabled.
  • Loading branch information
HoyosJuan authored Dec 1, 2023
2 parents b6b8c52 + 6c3bffb commit 76bc216
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 25 deletions.
31 changes: 19 additions & 12 deletions resources/openbim-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -9715,12 +9715,14 @@ class VertexPicker extends Component {
return new THREE$1.Vector3(vertices.getX(index), vertices.getY(index), vertices.getZ(index));
}
setupEvents(active) {
const container = this._components.ui.viewerContainer;
const container = this.components.renderer.get().domElement.parentElement;
if (!container)
return;
if (active) {
container.addEventListener("mousemove", this.update);
}
else {
container.addEventListener("mousemove", this.update);
container.removeEventListener("mousemove", this.update);
}
}
}
Expand Down Expand Up @@ -23332,7 +23334,8 @@ class OrthoPerspectiveCamera extends SimpleCamera {
this.toggleEvents(true);
this._projectionManager = new ProjectionManager(components, this);
components.onInitialized.add(() => {
this.setUI();
if (components.uiEnabled)
this.setUI();
});
this.onAspectUpdated.add(() => this.setOrthoCameraAspect());
}
Expand Down Expand Up @@ -101580,23 +101583,25 @@ class IfcPropertiesProcessor extends Component {
});
}
async cleanPropertiesList() {
if (this._propertiesManager) {
const button = this._propertiesManager.uiElement.get("exportButton");
button.removeFromParent();
this._currentUI = {};
if (this.components.uiEnabled) {
if (this._propertiesManager) {
const button = this._propertiesManager.uiElement.get("exportButton");
button.removeFromParent();
}
const propsList = this.uiElement.get("propsList");
await propsList.dispose(true);
const propsWindow = this.uiElement.get("propertiesWindow");
propsWindow.description = null;
propsList.children = [];
}
const propsList = this.uiElement.get("propsList");
await propsList.dispose(true);
// for (const child of this._propsList.children) {
// if (child instanceof TreeView) {
// this._entityUIPool.return(child);
// continue;
// }
// child.dispose();
// }
const propsWindow = this.uiElement.get("propertiesWindow");
propsWindow.description = null;
propsList.children = [];
this._currentUI = {};
}
get() {
return this._indexMap;
Expand Down Expand Up @@ -101624,6 +101629,8 @@ class IfcPropertiesProcessor extends Component {
}
}
async renderProperties(model, expressID) {
if (!this.components.uiEnabled)
return;
await this.cleanPropertiesList();
const topToolbar = this.uiElement.get("topToolbar");
const propsList = this.uiElement.get("propsList");
Expand Down
23 changes: 13 additions & 10 deletions src/ifc/IfcPropertiesProcessor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,24 +222,26 @@ export class IfcPropertiesProcessor
}

async cleanPropertiesList() {
if (this._propertiesManager) {
const button = this._propertiesManager.uiElement.get("exportButton");
button.removeFromParent();
this._currentUI = {};
if (this.components.uiEnabled) {
if (this._propertiesManager) {
const button = this._propertiesManager.uiElement.get("exportButton");
button.removeFromParent();
}
const propsList = this.uiElement.get("propsList");
await propsList.dispose(true);
const propsWindow =
this.uiElement.get<FloatingWindow>("propertiesWindow");
propsWindow.description = null;
propsList.children = [];
}

const propsList = this.uiElement.get("propsList");
await propsList.dispose(true);
// for (const child of this._propsList.children) {
// if (child instanceof TreeView) {
// this._entityUIPool.return(child);
// continue;
// }
// child.dispose();
// }
const propsWindow = this.uiElement.get<FloatingWindow>("propertiesWindow");
propsWindow.description = null;
propsList.children = [];
this._currentUI = {};
}

get(): IndexMap {
Expand Down Expand Up @@ -273,6 +275,7 @@ export class IfcPropertiesProcessor
}

async renderProperties(model: FragmentsGroup, expressID: number) {
if (!this.components.uiEnabled) return;
await this.cleanPropertiesList();
const topToolbar = this.uiElement.get("topToolbar");
const propsList = this.uiElement.get("propsList");
Expand Down
2 changes: 1 addition & 1 deletion src/navigation/OrthoPerspectiveCamera/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class OrthoPerspectiveCamera extends SimpleCamera implements UI {
this._projectionManager = new ProjectionManager(components, this);

components.onInitialized.add(() => {
this.setUI();
if (components.uiEnabled) this.setUI();
});

this.onAspectUpdated.add(() => this.setOrthoCameraAspect());
Expand Down
5 changes: 3 additions & 2 deletions src/utils/VertexPicker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,12 @@ export class VertexPicker
}

private setupEvents(active: boolean) {
const container = this._components.ui.viewerContainer;
const container = this.components.renderer.get().domElement.parentElement;
if (!container) return;
if (active) {
container.addEventListener("mousemove", this.update);
} else {
container.addEventListener("mousemove", this.update);
container.removeEventListener("mousemove", this.update);
}
}
}

0 comments on commit 76bc216

Please sign in to comment.