Skip to content

Commit

Permalink
fix: improve simple renderer resize event
Browse files Browse the repository at this point in the history
  • Loading branch information
agviegas committed May 7, 2024
1 parent e44e32a commit d5b4f59
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/components-front/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@thatopen/components-front",
"description": "Collection of frontend tools to author BIM apps.",
"version": "2.0.0-alpha.6",
"version": "2.0.0-alpha.7",
"author": "That Open Company",
"contributors": [
"Antonio Gonzalez Viegas (https://github.com/agviegas)",
Expand Down Expand Up @@ -45,7 +45,7 @@
"web-ifc": "0.0.53"
},
"dependencies": {
"@thatopen/components": "2.0.0-alpha.6",
"@thatopen/components": "2.0.0-alpha.7",
"camera-controls": "2.7.3",
"dexie": "^4.0.4",
"earcut": "^2.2.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@
"three": "^0.160.1",
"web-ifc": "0.0.53"
}
}
}
8 changes: 6 additions & 2 deletions packages/components/src/core/Worlds/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ world.camera = new OBC.SimpleCamera(components);

components.init();

const cube = new THREE.Mesh(new THREE.BoxGeometry());
const material = new THREE.MeshLambertMaterial({color: "#6528D7"});
const geometry = new THREE.BoxGeometry();
const cube = new THREE.Mesh(geometry, material);
world.scene.three.add(cube);

world.camera.controls.setLookAt(13, 13, 13, 0, 0, 0);
world.scene.setup();

world.camera.controls.setLookAt(3, 3, 3, 0, 0, 0);
9 changes: 8 additions & 1 deletion packages/components/src/core/Worlds/src/simple-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,18 @@ export class SimpleRenderer extends BaseRenderer {
}

if (active) {
this._resizeObserver = new ResizeObserver(() => this.resize());
this._resizeObserver = new ResizeObserver(this.resizeEvent);
this._resizeObserver.observe(dom);
this._resizeObserver.observe(document.body);

window.addEventListener("resize", this.resizeEvent);
}
}

private resizeEvent = () => {
this.resize();
};

private setupRenderer() {
this.three.localClippingEnabled = true;
if (this.container) {
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@thatopen/components-front@workspace:packages/components-front"
dependencies:
"@thatopen/components": 2.0.0-alpha.6
"@thatopen/components": 2.0.0-alpha.7
"@thatopen/fragments": 2.0.0-alpha.1
"@types/earcut": ^2.1.4
"@types/three": ^0.160.0
Expand All @@ -1260,7 +1260,7 @@ __metadata:
languageName: unknown
linkType: soft

"@thatopen/[email protected].6, @thatopen/components@workspace:packages/components":
"@thatopen/[email protected].7, @thatopen/components@workspace:packages/components":
version: 0.0.0-use.local
resolution: "@thatopen/components@workspace:packages/components"
dependencies:
Expand Down

0 comments on commit d5b4f59

Please sign in to comment.