bimatter-viewer-react 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +84 -89
  2. package/package.json +3 -1
package/README.md CHANGED
@@ -30,18 +30,26 @@ Install the viewer:
30
30
  npm install bimatter-viewer-react
31
31
  ```
32
32
 
33
- `react` and `react-dom` come with the Vite React template. Three.js, React Three Fiber, Drei, and BVH support are installed with `bimatter-viewer-react`.
34
-
35
33
  ## Basic Usage
36
34
 
37
35
  Put your `.bmt` or `.ifc` files in `public/models`:
38
36
 
39
37
  ```text
40
38
  public/
41
- models/
39
+ models/
42
40
  architecture.bmt
43
41
  structure.bmt
44
- architecture.ifc
42
+ ```
43
+
44
+ Replace `src/index.css` or add global sizing:
45
+
46
+ ```css
47
+ html,
48
+ body,
49
+ #root {
50
+ height: 100%;
51
+ margin: 0;
52
+ }
45
53
  ```
46
54
 
47
55
  Then replace `src/App.tsx`:
@@ -60,17 +68,6 @@ function App() {
60
68
  export default App;
61
69
  ```
62
70
 
63
- Replace `src/index.css` or add global sizing:
64
-
65
- ```css
66
- html,
67
- body,
68
- #root {
69
- height: 100%;
70
- margin: 0;
71
- }
72
- ```
73
-
74
71
  Run the app:
75
72
 
76
73
  ```bash
@@ -81,14 +78,12 @@ npm run dev
81
78
 
82
79
  ```text
83
80
  public/
84
- ifc-parser.wasm
85
- models/
81
+ ifc-parser.wasm
82
+ models/
86
83
  architecture.ifc
87
84
  ```
88
85
 
89
- For Vite apps, files in `public` are served from the app root, so `public/ifc-parser.wasm` is available as `/ifc-parser.wasm`.
90
-
91
- The package includes this WASM file. Copy it into your app public folder:
86
+ For loading ifc files you need to copy ifc parser wasm file into your public folder, you can take it from bimatter-viewer-react/public/ifc-parser.wasm or by command:
92
87
 
93
88
  ```bash
94
89
  cp node_modules/bimatter-viewer-react/public/ifc-parser.wasm public/ifc-parser.wasm
@@ -144,45 +139,61 @@ await loader.loadModel(["/models/model.bmt", "/models/model.ifc"]);
144
139
  await loader.loadModel(files);
145
140
  ```
146
141
 
147
- # Viewer API
148
-
149
- Use `ref` to call viewer actions:
142
+ ## File Upload Example
150
143
 
151
144
  ```tsx
152
- import { useRef } from "react";
153
- import { Viewer, type ViewerApi } from "bimatter-viewer-react";
145
+ import { useState } from "react";
146
+ import { Viewer, loader, type ViewerLoadedModels } from "bimatter-viewer-react";
154
147
 
155
148
  function App() {
156
- const viewerRef = useRef<ViewerApi>(null);
149
+ const [modelsData, setModelsData] = useState<ViewerLoadedModels>();
150
+
151
+ async function onFilesChange(files: FileList | null) {
152
+ if (!files?.length) return;
153
+ setModelsData(await loader.loadModel(Array.from(files)));
154
+ }
157
155
 
158
156
  return (
159
157
  <>
160
- <button onClick={() => viewerRef.current?.camera.fitCamera()}>
161
- Fit
162
- </button>
163
- <button
164
- onClick={() => viewerRef.current?.geometryUtils.hideSelected()}
165
- >
166
- Hide selected
167
- </button>
168
- <button
169
- onClick={() =>
170
- viewerRef.current?.geometryUtils.isolateSelected()
171
- }
172
- >
173
- Isolate selected
174
- </button>
175
- <button onClick={() => viewerRef.current?.geometryUtils.showAll()}>
176
- Show all
177
- </button>
178
-
179
- <Viewer ref={viewerRef} modelUrls={["/models/model.bmt"]} />
158
+ <input
159
+ accept=".bmt,.ifc"
160
+ multiple
161
+ type="file"
162
+ onChange={(event) => onFilesChange(event.target.files)}
163
+ />
164
+ {modelsData && <Viewer modelsData={modelsData} />}
180
165
  </>
181
166
  );
182
167
  }
183
168
  ```
184
169
 
185
- ## Available API groups:
170
+ ## HotKeys
171
+
172
+ ### Selection
173
+
174
+ `Left Click` - Select element
175
+
176
+ `Shift + Left Click` - Multi-select element
177
+
178
+ `Ctrl + Left Click` - Unselect element
179
+
180
+ `Shift + Drag Right` - Select elements fully inside rectangle
181
+
182
+ `Shift + Drag Left` - Select elements intersected by rectangle
183
+
184
+ `Ctrl + Drag Right` - Unselect elements fully inside rectangle
185
+
186
+ `Ctrl + Drag Left` - Unselect elements intersected by rectangle
187
+
188
+ ### Visibility
189
+
190
+ `C` - Clear hidden / isolated elements
191
+
192
+ `H` - Hide selected elements
193
+
194
+ `I` - Isolate selected elements
195
+
196
+ # Viewer API:
186
197
 
187
198
  ```ts
188
199
  viewerRef.current?.camera.fitCamera();
@@ -218,29 +229,39 @@ viewerRef.current?.utils.setGridAxesVisibility({ top: false, bottom: true });
218
229
  viewerRef.current?.utils.setGridAxisVisibility("left", false);
219
230
  ```
220
231
 
221
- ## File Upload Example
232
+ ## Geometry Utils
233
+
234
+ Use `ref` to call viewer actions:
222
235
 
223
236
  ```tsx
224
- import { useState } from "react";
225
- import { Viewer, loader, type ViewerLoadedModels } from "bimatter-viewer-react";
237
+ import { useRef } from "react";
238
+ import { Viewer, type ViewerApi } from "bimatter-viewer-react";
226
239
 
227
240
  function App() {
228
- const [modelsData, setModelsData] = useState<ViewerLoadedModels>();
229
-
230
- async function onFilesChange(files: FileList | null) {
231
- if (!files?.length) return;
232
- setModelsData(await loader.loadModel(Array.from(files)));
233
- }
241
+ const viewerRef = useRef<ViewerApi>(null);
234
242
 
235
243
  return (
236
244
  <>
237
- <input
238
- accept=".bmt,.ifc"
239
- multiple
240
- type="file"
241
- onChange={(event) => onFilesChange(event.target.files)}
242
- />
243
- {modelsData && <Viewer modelsData={modelsData} />}
245
+ <button onClick={() => viewerRef.current?.camera.fitCamera()}>
246
+ Fit
247
+ </button>
248
+ <button
249
+ onClick={() => viewerRef.current?.geometryUtils.hideSelected()}
250
+ >
251
+ Hide selected
252
+ </button>
253
+ <button
254
+ onClick={() =>
255
+ viewerRef.current?.geometryUtils.isolateSelected()
256
+ }
257
+ >
258
+ Isolate selected
259
+ </button>
260
+ <button onClick={() => viewerRef.current?.geometryUtils.showAll()}>
261
+ Show all
262
+ </button>
263
+
264
+ <Viewer ref={viewerRef} modelUrls={["/models/model.bmt"]} />
244
265
  </>
245
266
  );
246
267
  }
@@ -319,29 +340,3 @@ viewerRef.current?.utils.setGridAxesVisibility({
319
340
  top: false,
320
341
  });
321
342
  ```
322
-
323
- ## HotKeys
324
-
325
- ### Selection
326
-
327
- `Left Click` - Select element
328
-
329
- `Shift + Left Click` - Multi-select element
330
-
331
- `Ctrl + Left Click` - Unselect element
332
-
333
- `Shift + Drag Right` - Select elements fully inside rectangle
334
-
335
- `Shift + Drag Left` - Select elements intersected by rectangle
336
-
337
- `Ctrl + Drag Right` - Unselect elements fully inside rectangle
338
-
339
- `Ctrl + Drag Left` - Unselect elements intersected by rectangle
340
-
341
- ### Visibility
342
-
343
- `C` - Clear hidden / isolated elements
344
-
345
- `H` - Hide selected elements
346
-
347
- `I` - Isolate selected elements
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bimatter-viewer-react",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "license": "PolyForm-Noncommercial-1.0.0",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -14,6 +14,8 @@
14
14
  "./ifc-parser.wasm": "./public/ifc-parser.wasm"
15
15
  },
16
16
  "files": [
17
+ "README.md",
18
+ "LICENSE.md",
17
19
  "lib",
18
20
  "public/ifc-parser.wasm"
19
21
  ],