Skip to content

Commit

Permalink
feat: improve vertical alignment style
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed Mar 27, 2024
1 parent 7d4ed39 commit bc9bd41
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 6 deletions.
21 changes: 19 additions & 2 deletions resources/openbim-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -12847,6 +12847,11 @@ class Drawer extends SimpleUIComponent {
this.domElement.style.height = height;
this.domElement.style.width = width;
}
get containerSize() {
const height = this.domElement.clientHeight;
const width = this.domElement.clientWidth;
return { height, width };
}
set alignment(value) {
const classes = this.domElement.classList;
this._type = value;
Expand Down Expand Up @@ -120432,7 +120437,14 @@ class RoadNavigator extends Component {
}
}
}
await this.scene.controls.fitToBox(totalBBox, false);
const scaledBbox = new THREE$1.Box3();
const size = new THREE$1.Vector3();
const center = new THREE$1.Vector3();
totalBBox.getCenter(center);
totalBBox.getSize(size);
size.multiplyScalar(1.2);
scaledBbox.setFromCenterAndSize(center, size);
await this.scene.controls.fitToBox(scaledBbox, false);
}
setupEvents() {
const mousePositionSphere = new THREE$1.Mesh(new THREE$1.SphereGeometry(0.5), new THREE$1.MeshBasicMaterial({ color: 0xff0000 }));
Expand Down Expand Up @@ -120625,7 +120637,8 @@ CurveHighlighter.settings = {
LINE: [213 / 255, 0 / 255, 255 / 255],
CIRCULARARC: [0 / 255, 46, 255 / 255],
CLOTHOID: [0 / 255, 255 / 255, 0 / 255],
PARABOLIC: [0 / 255, 255 / 255, 72 / 255],
PARABOLICARC: [0 / 255, 255 / 255, 72 / 255],
CONSTANTGRADIENT: [213 / 255, 0 / 255, 255 / 255],
},
};

Expand Down Expand Up @@ -120846,6 +120859,10 @@ class RoadElevationNavigator extends RoadNavigator {
const height = this.scene.size.y;
this.scene.setSize(height, width);
});
drawer.onResized.add(() => {
const { width, height } = drawer.containerSize;
this.scene.setSize(height, width);
});
if (this.components.renderer.isUpdateable()) {
this.components.renderer.onAfterUpdate.add(async () => {
if (drawer.visible) {
Expand Down
5 changes: 5 additions & 0 deletions src/civil/RoadElevationNavigator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ export class RoadElevationNavigator extends RoadNavigator implements UI {
this.scene.setSize(height, width);
});

drawer.onResized.add(() => {
const { width, height } = drawer.containerSize;
this.scene.setSize(height, width);
});

if (this.components.renderer.isUpdateable()) {
this.components.renderer.onAfterUpdate.add(async () => {
if (drawer.visible) {
Expand Down
10 changes: 9 additions & 1 deletion src/civil/RoadNavigator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@ export abstract class RoadNavigator extends Component<any> {
}
}

await this.scene.controls.fitToBox(totalBBox, false);
const scaledBbox = new THREE.Box3();
const size = new THREE.Vector3();
const center = new THREE.Vector3();
totalBBox.getCenter(center);
totalBBox.getSize(size);
size.multiplyScalar(1.2);
scaledBbox.setFromCenterAndSize(center, size);

await this.scene.controls.fitToBox(scaledBbox, false);
}

setupEvents() {
Expand Down
3 changes: 2 additions & 1 deletion src/civil/RoadNavigator/src/curve-highlighter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export class CurveHighlighter {
LINE: [213 / 255, 0 / 255, 255 / 255],
CIRCULARARC: [0 / 255, 46, 255 / 255],
CLOTHOID: [0 / 255, 255 / 255, 0 / 255],
PARABOLIC: [0 / 255, 255 / 255, 72 / 255],
PARABOLICARC: [0 / 255, 255 / 255, 72 / 255],
CONSTANTGRADIENT: [213 / 255, 0 / 255, 255 / 255],
} as { [curve: string]: number[] },
};

Expand Down
23 changes: 21 additions & 2 deletions src/civil/RoadPlanNavigator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
fragmentIfcLoader.settings.webIfc.COORDINATE_TO_ORIGIN = true;
fragmentIfcLoader.settings.webIfc.OPTIMIZE_PROFILES = true;

const file = await fetch("../../../resources/asdf.frag");
const file = await fetch("../../../resources/asdf2.frag");
const data = await file.arrayBuffer();
const buffer = new Uint8Array(data);
const model = await fragments.load(buffer);
Expand Down Expand Up @@ -117,9 +117,28 @@
const drawer = elevationNavigator.uiElement.get("drawer");
drawer.visible = true;



const navigator3D = new OBC.Road3DNavigator(components);
navigator3D.draw(model);
navigator3D.setup();

navigator3D.highlighter.hoverCurve.material.color.set(1, 1, 1);
navigator3D.highlighter.hoverPoints.material.color.set(1, 1, 1);

const sphere = new THREE.Sphere(undefined, 20);

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

const index = mesh.curve.index;
const curve3d = mesh.curve.alignment.absolute[index];
curve3d.mesh.geometry.computeBoundingSphere();
components.camera.controls.fitToSphere(curve3d.mesh.geometry.boundingSphere, true);

})


Expand Down
6 changes: 6 additions & 0 deletions src/ui/Drawer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ export class Drawer extends SimpleUIComponent<HTMLDivElement> {
this.domElement.style.width = width;
}

get containerSize() {
const height = this.domElement.clientHeight;
const width = this.domElement.clientWidth;
return { height, width };
}

set alignment(value: typeof Drawer.prototype._type) {
const classes = this.domElement.classList;

Expand Down

0 comments on commit bc9bd41

Please sign in to comment.