Skip to content

Commit f31d9ae

Browse files
committed
feat: release
1 parent a0823a5 commit f31d9ae

File tree

55 files changed

+495
-470
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+495
-470
lines changed

packages/core/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@thatopen/components",
33
"description": "Collection of core functionalities to author BIM apps.",
4-
"version": "3.1.6",
4+
"version": "3.2.0",
55
"author": "That Open Company",
66
"contributors": [
77
"Antonio Gonzalez Viegas (https://github.com/agviegas)",
@@ -37,13 +37,13 @@
3737
"access": "public"
3838
},
3939
"devDependencies": {
40-
"@thatopen/fragments": "~3.1.0",
41-
"@thatopen/ui": "~3.1.0",
40+
"@thatopen/fragments": "~3.2.0",
41+
"@thatopen/ui": "~3.2.0",
4242
"@types/convert-units": "2.3.11",
4343
"@types/three": "0.175.0",
4444
"stats.js": "^0.17.0",
4545
"three": "^0.175.0",
46-
"web-ifc": "0.0.71"
46+
"web-ifc": "0.0.72"
4747
},
4848
"dependencies": {
4949
"camera-controls": "^2.9.0",
@@ -52,8 +52,8 @@
5252
"three-mesh-bvh": "0.7.0"
5353
},
5454
"peerDependencies": {
55-
"@thatopen/fragments": "~3.1.0",
55+
"@thatopen/fragments": "~3.2.0",
5656
"three": ">=0.175.0",
57-
"web-ifc": ">=0.0.71"
57+
"web-ifc": ">=0.0.72"
5858
}
5959
}

packages/core/src/core/Clipper/example.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ fragments.list.onItemSet.add(({ value: model }) => {
8888
:::
8989
*/
9090

91-
const fragPaths = [
92-
"https://thatopen.github.io/engine_components/resources/frags/school_arq.frag",
93-
];
91+
const fragPaths = ["/resources/frags/school_arq.frag"];
9492
await Promise.all(
9593
fragPaths.map(async (path) => {
9694
const modelId = path.split("/").pop()?.split(".").shift();

packages/core/src/core/Grids/example.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,8 @@ components.init();
4949
Now, let's configure the FragmentsManager. This will allow us to load models effortlessly and start manipulating them with ease:
5050
*/
5151

52-
const githubUrl =
53-
"https://thatopen.github.io/engine_fragment/resources/worker.mjs";
54-
const fetchedUrl = await fetch(githubUrl);
55-
const workerBlob = await fetchedUrl.blob();
56-
const workerFile = new File([workerBlob], "worker.mjs", {
57-
type: "text/javascript",
58-
});
59-
const workerUrl = URL.createObjectURL(workerFile);
52+
const workerUrl =
53+
"/node_modules/"https://thatopen.github.io/engine_fragment/resources/worker.mjs"/fragments-beta/dist/Worker/worker.mjs";
6054
const fragments = components.get(OBC.FragmentsManager);
6155
fragments.init(workerUrl);
6256

@@ -88,7 +82,7 @@ fragments.list.onItemSet.add(({ value: model }) => {
8882
:::
8983
*/
9084

91-
const fragPaths = ["https://thatopen.github.io/engine_components/resources/frags/school_arq.frag"];
85+
const fragPaths = ["/resources/frags/school_arq.frag"];
9286
const [model] = await Promise.all(
9387
fragPaths.map(async (path) => {
9488
const modelId = path.split("/").pop()?.split(".").shift();

packages/core/src/core/OrthoPerspectiveCamera/example.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,8 @@ const grid = components.get(OBC.Grids).create(world);
5050
Now, let's configure the FragmentsManager. This will allow us to load models effortlessly and start manipulating them with ease:
5151
*/
5252

53-
const githubUrl =
54-
"https://thatopen.github.io/engine_fragment/resources/worker.mjs";
55-
const fetchedUrl = await fetch(githubUrl);
56-
const workerBlob = await fetchedUrl.blob();
57-
const workerFile = new File([workerBlob], "worker.mjs", {
58-
type: "text/javascript",
59-
});
60-
const workerUrl = URL.createObjectURL(workerFile);
53+
const workerUrl =
54+
"/node_modules/"https://thatopen.github.io/engine_fragment/resources/worker.mjs"/fragments-beta/dist/Worker/worker.mjs";
6155
const fragments = components.get(OBC.FragmentsManager);
6256
fragments.init(workerUrl);
6357

@@ -89,7 +83,7 @@ fragments.list.onItemSet.add(({ value: model }) => {
8983
:::
9084
*/
9185

92-
const fragPaths = ["https://thatopen.github.io/engine_components/resources/frags/school_arq.frag"];
86+
const fragPaths = ["/resources/frags/school_arq.frag"];
9387
await Promise.all(
9488
fragPaths.map(async (path) => {
9589
const modelId = path.split("/").pop()?.split(".").shift();

packages/core/src/core/Raycasters/example.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,8 @@ components.init();
4444
Now, let's configure the FragmentsManager. This will allow us to load models effortlessly and start manipulating them with ease:
4545
*/
4646

47-
const githubUrl =
48-
"https://thatopen.github.io/engine_fragment/resources/worker.mjs";
49-
const fetchedUrl = await fetch(githubUrl);
50-
const workerBlob = await fetchedUrl.blob();
51-
const workerFile = new File([workerBlob], "worker.mjs", {
52-
type: "text/javascript",
53-
});
54-
const workerUrl = URL.createObjectURL(workerFile);
47+
const workerUrl =
48+
"/node_modules/"https://thatopen.github.io/engine_fragment/resources/worker.mjs"/fragments-beta/dist/Worker/worker.mjs";
5549
const fragments = components.get(OBC.FragmentsManager);
5650
fragments.init(workerUrl);
5751

@@ -83,7 +77,7 @@ fragments.list.onItemSet.add(({ value: model }) => {
8377
:::
8478
*/
8579

86-
const fragPaths = ["https://thatopen.github.io/engine_components/resources/frags/school_arq.frag"];
80+
const fragPaths = ["/resources/frags/school_arq.frag"];
8781
await Promise.all(
8882
fragPaths.map(async (path) => {
8983
const modelId = path.split("/").pop()?.split(".").shift();

packages/core/src/core/ShadowedScene/example.ts

Lines changed: 76 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
/* MD
2-
### 😎 Adding some cool shadows
2+
### 🚀 Handling BIM models like a boss
33
---
44
5-
In this tutorial, you'll learn how to add some nice looking (yet performant) shadows to your scene.
5+
In this tutorial, you'll learn how to load your BIM models in Fragment format. Fragment is an [open source geometry system](https://github.com/ThatOpen/engine_fragment/) that we created on top of [Three.js](https://threejs.org/) to display BIM models fast, while keeping control over the individual items of the model. The idea is simple: a BIM model is a FragmentsGroup, which is (like the name implies) a collection of fragments. A fragment is a set of identical geometries instantiated around the scene.
6+
7+
:::tip How do I get a BIM model in Fragment format?
8+
9+
The IfcLoader component does exactly that! It converts IFC models to Fragments. Check out that tutorial if you are starting out with IFC files. Of course, you can just use the IfcLoader in your app, but loading fragments is more than x10 faster than loading IFC files. Our recommendation is to convert your IFC files to fragments just once, store the fragment somewhere (frontent of backend) and then load the fragments instead of teh IFC models directly.
10+
11+
:::
612
713
In this tutorial, we will import:
814
915
- `Three.js` to get some 3D entities for our app.
16+
- `@thatopen/ui` to add some simple and cool UI menus.
1017
- `@thatopen/components` to set up the barebone of our app.
1118
- `Stats.js` (optional) to measure the performance of our app.
1219
*/
1320

1421
import * as THREE from "three";
1522
import Stats from "stats.js";
23+
import * as BUI from "@thatopen/ui";
1624
// You have to import * as OBC from "@thatopen/components"
1725
import * as OBC from "../..";
1826

@@ -47,40 +55,20 @@ world.camera.controls.setLookAt(12, 6, 8, 0, 0, -10);
4755
const grids = components.get(OBC.Grids);
4856
const grid = grids.create(world);
4957

50-
/* MD
51-
### 🌎 Loading a model
52-
---
53-
54-
Now we will load a BIM fragments model.
55-
56-
:::tip Fragments?
57-
58-
If you are not familiar with fragments, check out the IfcLoader tutorial!
59-
60-
:::
61-
62-
*/
58+
// Set up fragments
6359

6460
const fragments = components.get(OBC.FragmentsManager);
65-
const githubUrl =
66-
"https://thatopen.github.io/engine_fragment/resources/worker.mjs";
67-
const fetchedUrl = await fetch(githubUrl);
68-
const workerBlob = await fetchedUrl.blob();
69-
const workerFile = new File([workerBlob], "worker.mjs", {
70-
type: "text/javascript",
71-
});
72-
const workerUrl = URL.createObjectURL(workerFile);
73-
fragments.init(workerUrl);
61+
fragments.init(
62+
"/node_modules/"https://thatopen.github.io/engine_fragment/resources/worker.mjs"/fragments-beta/dist/Worker/worker.mjs",
63+
);
7464

7565
world.camera.controls.addEventListener("control", () =>
7666
fragments.core.update(),
7767
);
7868

7969
const modelId = "example";
8070

81-
const file = await fetch(
82-
"https://thatopen.github.io/engine_components/resources/frags/school_arq.frag",
83-
);
71+
const file = await fetch("/resources/frags/school_arq.frag");
8472
const data = await file.arrayBuffer();
8573
const buffer = new Uint8Array(data);
8674
const model = await fragments.core.load(buffer, {
@@ -89,21 +77,77 @@ const model = await fragments.core.load(buffer, {
8977
});
9078
world.scene.three.add(model.object);
9179

80+
// Set up stats
81+
82+
const stats = new Stats();
83+
stats.showPanel(2);
84+
document.body.append(stats.dom);
85+
stats.dom.style.left = "0px";
86+
stats.dom.style.zIndex = "unset";
87+
world.renderer.onBeforeUpdate.add(() => stats.begin());
88+
world.renderer.onAfterUpdate.add(() => stats.end());
89+
9290
/* MD
93-
### ⛱️ Adding shadows
91+
### 🧩 Adding some UI
9492
---
9593
96-
Now we will add shadows. We will start by enabling the shadows in the three.js renderer.
94+
We will use the `@thatopen/ui` library to add some simple and cool UI elements to our app. First, we need to call the `init` method of the `BUI.Manager` class to initialize the library:
9795
9896
*/
9997

100-
world.renderer.three.shadowMap.enabled = true;
101-
world.renderer.three.shadowMap.type = THREE.PCFSoftShadowMap;
98+
BUI.Manager.init();
99+
100+
/* MD
101+
Now we will create a simple panel with a set of buttons that call the previously defined functions. For more information about the UI library, you can check the specific documentation for it!
102+
*/
103+
104+
const panel = BUI.Component.create<BUI.PanelSection>(() => {
105+
return BUI.html`
106+
<bim-panel active label="Shadowed Scene Tutorial" class="options-menu">
107+
<bim-panel-section>
108+
<bim-button icon="solar:sun-bold" label="Toggle Shadows" @click="${() => {
109+
world.scene.shadowsEnabled = !world.scene.shadowsEnabled;
110+
}}">
111+
</bim-button>
112+
</bim-panel-section>
113+
</bim-panel>
114+
`;
115+
});
116+
117+
document.body.append(panel);
118+
119+
/* MD
120+
And we will make some logic that adds a button to the screen when the user is visiting our app from their phone, allowing to show or hide the menu. Otherwise, the menu would make the app unusable.
121+
*/
122+
123+
const button = BUI.Component.create<BUI.PanelSection>(() => {
124+
return BUI.html`
125+
<bim-button class="phone-menu-toggler" icon="solar:settings-bold"
126+
@click="${() => {
127+
if (panel.classList.contains("options-menu-visible")) {
128+
panel.classList.remove("options-menu-visible");
129+
} else {
130+
panel.classList.add("options-menu-visible");
131+
}
132+
}}">
133+
</bim-button>
134+
`;
135+
});
136+
137+
document.body.append(button);
102138

103139
/* MD
104-
Next, we'll set up the scene and exclude the grid from the shadows. The shadows take into account the distance to the farthest visible object to decide a resolution for the shadows. The grid is infinite, so we don't want to take it into account.
140+
### 🎉 Wrap up
141+
---
142+
143+
That's it! Now you know how to load, export and dispose Fragments in your app. Fragments are much faster than raw IFC models, so you should definitely store them in your app if you want your users to have a fast loading experience. For bigger models you can use streaming, but that's another tutorial!
105144
*/
106145

146+
// Adding shadows
147+
148+
world.renderer.three.shadowMap.enabled = true;
149+
world.renderer.three.shadowMap.type = THREE.PCFSoftShadowMap;
150+
107151
world.scene.setup({
108152
shadows: {
109153
cascade: 1,
@@ -113,10 +157,6 @@ world.scene.setup({
113157

114158
world.scene.distanceRenderer.excludedObjects.add(grid.three);
115159

116-
/* MD
117-
We will also need to enable the shadows for the materials and objects used in the fragments model:
118-
*/
119-
120160
model.tiles.onItemSet.add(({ value: mesh }) => {
121161
if ("isMesh" in mesh) {
122162
const mat = mesh.material as THREE.MeshStandardMaterial[];
@@ -132,34 +172,10 @@ for (const child of model.object.children) {
132172
child.receiveShadow = true;
133173
}
134174

135-
/* MD
136-
Finally, we just need to update the shadows every time the camera moves (and a first time to see something even before the user does anything).
137-
*/
138-
139175
await world.scene.updateShadows();
140176

141177
world.camera.controls.addEventListener("rest", async () => {
142178
await world.scene.updateShadows();
143179
});
144180

145181
world.scene.three.background = null;
146-
147-
/* MD
148-
### ⏱️ Measuring the performance (optional)
149-
We'll use the [Stats.js](https://github.com/mrdoob/stats.js) to measure the performance of our app. We will add it to the top left corner of the viewport. This way, we'll make sure that the memory consumption and the FPS of our app are under control.
150-
*/
151-
152-
const stats = new Stats();
153-
stats.showPanel(2);
154-
document.body.append(stats.dom);
155-
stats.dom.style.left = "0px";
156-
stats.dom.style.zIndex = "unset";
157-
world.renderer.onBeforeUpdate.add(() => stats.begin());
158-
world.renderer.onAfterUpdate.add(() => stats.end());
159-
160-
/* MD
161-
### 🎉 Wrap up
162-
---
163-
164-
That's it! Now you know how to add some nice looking shadows to your scene. Congratulations! Keep exploring more tutorials in the documentation to keep learning.
165-
*/

packages/core/src/core/Types/src/base.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
Resizeable,
55
Updateable,
66
Configurable,
7+
Serializable,
78
} from "./interfaces";
89
import { Components } from "../../Components";
910

@@ -39,4 +40,9 @@ export abstract class Base {
3940
isConfigurable = (): this is Configurable<any, any> => {
4041
return "setup" in this && "config" in this && "onSetup" in this;
4142
};
43+
44+
/** Whether is component is {@link Serializable}. */
45+
isSerializable = (): this is Serializable<any> => {
46+
return "import" in this && "export" in this
47+
}
4248
}

packages/core/src/core/Viewpoints/example.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,8 @@ components.init();
4848
Now, let's configure the FragmentsManager. This will allow us to load models effortlessly and start manipulating them with ease:
4949
*/
5050

51-
const githubUrl =
52-
"https://thatopen.github.io/engine_fragment/resources/worker.mjs";
53-
const fetchedUrl = await fetch(githubUrl);
54-
const workerBlob = await fetchedUrl.blob();
55-
const workerFile = new File([workerBlob], "worker.mjs", {
56-
type: "text/javascript",
57-
});
58-
const workerUrl = URL.createObjectURL(workerFile);
51+
const workerUrl =
52+
"/node_modules/"https://thatopen.github.io/engine_fragment/resources/worker.mjs"/fragments-beta/dist/Worker/worker.mjs";
5953
const fragments = components.get(OBC.FragmentsManager);
6054
fragments.init(workerUrl);
6155

@@ -88,8 +82,8 @@ fragments.list.onItemSet.add(({ value: model }) => {
8882
*/
8983

9084
const fragPaths = [
91-
"https://thatopen.github.io/engine_components/resources/frags/school_arq.frag",
92-
"https://thatopen.github.io/engine_components/resources/frags/school_str.frag",
85+
"/resources/frags/school_arq.frag",
86+
"/resources/frags/school_str.frag",
9387
];
9488

9589
await Promise.all(

packages/core/src/core/Viewpoints/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export interface ViewpointComponents {
144144

145145
// https://github.com/buildingSMART/BCF-API/blob/release_3_0/Schemas/Collaboration/Viewpoint/bitmap_GET.json
146146
/**
147-
* Represents a bitmap image associated with a viewpoint. This interface is compliant with the BCF API specifications.
147+
* Represents a bitmap image associated with a viewpoint. This interface is compliant with the BCF API specifications.
148148
*/
149149
export interface ViewpointBitmap {
150150
/**

0 commit comments

Comments
 (0)