Skip to content

Commit

Permalink
feat: coordinate elevation view with plan view
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Mar 27, 2024
1 parent 8bc0f54 commit 7d4ed39
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 153 deletions.
22 changes: 12 additions & 10 deletions resources/openbim-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -120402,19 +120402,18 @@ class RoadNavigator extends Component {
get() {
return null;
}
async draw(model, ids) {
async draw(model, filter) {
if (!model.civilData) {
throw new Error("The provided model doesn't have civil data!");
}
const { alignments } = model.civilData;
const allIDs = ids || alignments.keys();
const allAlignments = filter || alignments.values();
const scene = this.scene.get();
const totalBBox = new THREE$1.Box3();
totalBBox.makeEmpty();
totalBBox.min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
totalBBox.max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
for (const id of allIDs) {
const alignment = alignments.get(id);
for (const alignment of allAlignments) {
if (!alignment) {
throw new Error("Alignment not found!");
}
Expand Down Expand Up @@ -120459,9 +120458,9 @@ class RoadNavigator extends Component {
if (intersects) {
const { point, object } = intersects;
mousePositionSphere.position.copy(point);
const curve = object;
this.highlighter.select(curve);
await this.onHighlight.trigger(curve);
const mesh = object;
this.highlighter.select(mesh);
await this.onHighlight.trigger({ mesh, point });
return;
}
this.highlighter.unSelect();
Expand All @@ -120475,9 +120474,12 @@ class RoadNavigator extends Component {
this._curveMeshes = [];
}
clear() {
this.highlighter.unSelect();
this.highlighter.unHover();
for (const mesh of this._curveMeshes) {
mesh.removeFromParent();
}
this._curveMeshes = [];
}
adjustRaycasterOnZoom() {
this.scene.controls.addEventListener("update", () => {
Expand Down Expand Up @@ -120756,9 +120758,9 @@ class RoadPlanNavigator extends RoadNavigator {
this.highlighter = new PlanHighlighter(scene);
this.setUI();
this.components.tools.add(RoadPlanNavigator.uuid, this);
this.onHighlight.add(async (curveMesh) => {
this.highlighter.showCurveInfo(curveMesh);
await this.fitCameraToAlignment(curveMesh);
this.onHighlight.add(({ mesh }) => {
this.highlighter.showCurveInfo(mesh);
this.fitCameraToAlignment(mesh);
});
}
async fitCameraToAlignment(curveMesh) {
Expand Down
132 changes: 0 additions & 132 deletions src/civil/RoadElevationNavigator/index.html

This file was deleted.

21 changes: 13 additions & 8 deletions src/civil/RoadNavigator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export abstract class RoadNavigator extends Component<any> {

abstract highlighter: CurveHighlighter;

readonly onHighlight = new Event<FRAGS.CurveMesh>();
readonly onHighlight = new Event<{
point: THREE.Vector3;
mesh: FRAGS.CurveMesh;
}>();

private _curveMeshes: FRAGS.CurveMesh[] = [];

Expand All @@ -29,12 +32,12 @@ export abstract class RoadNavigator extends Component<any> {
return null as any;
}

async draw(model: FragmentsGroup, ids?: Iterable<number>) {
async draw(model: FragmentsGroup, filter?: Iterable<FRAGS.Alignment>) {
if (!model.civilData) {
throw new Error("The provided model doesn't have civil data!");
}
const { alignments } = model.civilData;
const allIDs = ids || alignments.keys();
const allAlignments = filter || alignments.values();

const scene = this.scene.get();

Expand All @@ -43,8 +46,7 @@ export abstract class RoadNavigator extends Component<any> {
totalBBox.min.set(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
totalBBox.max.set(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);

for (const id of allIDs) {
const alignment = alignments.get(id);
for (const alignment of allAlignments) {
if (!alignment) {
throw new Error("Alignment not found!");
}
Expand Down Expand Up @@ -114,9 +116,9 @@ export abstract class RoadNavigator extends Component<any> {
if (intersects) {
const { point, object } = intersects;
mousePositionSphere.position.copy(point);
const curve = object as FRAGS.CurveMesh;
this.highlighter.select(curve);
await this.onHighlight.trigger(curve);
const mesh = object as FRAGS.CurveMesh;
this.highlighter.select(mesh);
await this.onHighlight.trigger({ mesh, point });
return;
}

Expand All @@ -133,9 +135,12 @@ export abstract class RoadNavigator extends Component<any> {
}

clear() {
this.highlighter.unSelect();
this.highlighter.unHover();
for (const mesh of this._curveMeshes) {
mesh.removeFromParent();
}
this._curveMeshes = [];
}

private adjustRaycasterOnZoom() {
Expand Down
10 changes: 10 additions & 0 deletions src/civil/RoadPlanNavigator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@
horizontalWindow.visible = true;
navigator.draw(model);

const elevationNavigator = new OBC.RoadElevationNavigator(components);
const drawer = elevationNavigator.uiElement.get("drawer");
drawer.visible = true;

navigator.onHighlight.add(({ mesh }) => {
elevationNavigator.clear();
elevationNavigator.draw(model, [mesh.curve.alignment])
})


// const hider = new OBC.FragmentHider(components);
// await hider.loadCached();
// mainToolbar.addChild(hider.uiElement.get("main"));
Expand Down
6 changes: 3 additions & 3 deletions src/civil/RoadPlanNavigator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export class RoadPlanNavigator extends RoadNavigator implements UI {

this.components.tools.add(RoadPlanNavigator.uuid, this);

this.onHighlight.add(async (curveMesh) => {
this.highlighter.showCurveInfo(curveMesh);
await this.fitCameraToAlignment(curveMesh);
this.onHighlight.add(({ mesh }) => {
this.highlighter.showCurveInfo(mesh);
this.fitCameraToAlignment(mesh);
});
}

Expand Down

0 comments on commit 7d4ed39

Please sign in to comment.