1 | import { IfcContext, IfcManager, IfcGrid, IfcAxes, IfcClipper, DropboxAPI, Edges, SectionFillManager, IfcDimensions, PlanManager } from './components';
|
2 | import { GLTFManager } from './components/import-export/glTF';
|
3 | import { DXFWriter } from './components/import-export/dxf';
|
4 | import { PDFWriter } from './components/import-export/pdf';
|
5 | import { EdgeProjector } from './components/import-export/edges-vectorizer/edge-projection';
|
6 | import { ClippingEdges } from './components/display/clipping-planes/clipping-edges';
|
7 | import { SelectionWindow } from './components/selection/selection-window';
|
8 | export class IfcViewerAPI {
|
9 | constructor(options) {
|
10 | /**
|
11 | * @deprecated Use `IfcViewerAPI.clipper.createPlane()` instead.
|
12 | * Adds a clipping plane on the face pointed to by the cursor.
|
13 | */
|
14 | this.addClippingPlane = () => {
|
15 | this.clipper.createPlane();
|
16 | };
|
17 | /**
|
18 | * @deprecated Use `IfcViewerAPI.clipper.deletePlane()` instead.
|
19 | * Removes the clipping plane pointed by the cursor.
|
20 | */
|
21 | this.removeClippingPlane = () => {
|
22 | this.clipper.deletePlane();
|
23 | };
|
24 | /**
|
25 | * @deprecated Use `IfcViewerAPI.clipper.toggle()` instead.
|
26 | * Turns on / off all clipping planes.
|
27 | */
|
28 | this.toggleClippingPlanes = () => {
|
29 | this.clipper.toggle();
|
30 | };
|
31 | /**
|
32 | * @deprecated Use `IfcViewerAPI.IFC.selector.prePickIfcItem()` instead.
|
33 | * Highlights the item pointed by the cursor.
|
34 | */
|
35 | this.prePickIfcItem = () => {
|
36 | this.IFC.selector.prePickIfcItem();
|
37 | };
|
38 | /**
|
39 | * @deprecated Use `IfcViewerAPI.IFC.selector.pickIfcItem()` instead.
|
40 | * Highlights the item pointed by the cursor and gets is properties.
|
41 | */
|
42 | this.pickIfcItem = () => {
|
43 | return this.IFC.selector.pickIfcItem();
|
44 | };
|
45 | /**
|
46 | * @deprecated Use `IfcViewerAPI.IFC.selector.pickIfcItemsByID()` instead.
|
47 | * Highlights the item with the given ID.
|
48 | * @modelID ID of the IFC model.
|
49 | * @id Express ID of the item.
|
50 | */
|
51 | this.pickIfcItemsByID = (modelID, ids) => {
|
52 | this.IFC.selector.pickIfcItemsByID(modelID, ids);
|
53 | };
|
54 | if (!options.container)
|
55 | throw new Error('Could not get container element!');
|
56 | this.context = new IfcContext(options);
|
57 | this.IFC = new IfcManager(this.context);
|
58 | this.grid = new IfcGrid(this.context);
|
59 | this.axes = new IfcAxes(this.context);
|
60 | this.clipper = new IfcClipper(this.context, this.IFC);
|
61 | this.plans = new PlanManager(this.IFC, this.context, this.clipper);
|
62 | this.filler = new SectionFillManager(this.IFC, this.context);
|
63 | this.dimensions = new IfcDimensions(this.context);
|
64 | this.edges = new Edges(this.context);
|
65 | this.shadowDropper = this.IFC.shadowDropper;
|
66 | this.edgesProjector = new EdgeProjector(this.context);
|
67 | this.dxf = new DXFWriter();
|
68 | this.pdf = new PDFWriter();
|
69 | this.GLTF = new GLTFManager(this.context, this.IFC);
|
70 | this.dropbox = new DropboxAPI(this.context, this.IFC);
|
71 | this.selectionWindow = new SelectionWindow(this.context);
|
72 | ClippingEdges.ifc = this.IFC;
|
73 | ClippingEdges.context = this.context;
|
74 | }
|
75 | /**
|
76 | * @deprecated Use `this.dropbox.loadDropboxIfc()` instead.
|
77 | * Opens a dropbox window where the user can select their IFC models.
|
78 | */
|
79 | openDropboxWindow() {
|
80 | this.dropbox.loadDropboxIfc();
|
81 | }
|
82 | /**
|
83 | * @deprecated Use `IfcViewerAPI.IFC.loadIfc()` instead.
|
84 | * Loads the given IFC in the current scene.
|
85 | * @file IFC as File.
|
86 | * @fitToFrame (optional) if true, brings the perspectiveCamera to the loaded IFC.
|
87 | */
|
88 | async loadIfc(file, fitToFrame = false) {
|
89 | await this.IFC.loadIfc(file, fitToFrame);
|
90 | }
|
91 | /**
|
92 | * @deprecated Use `IfcViewerAPI.grid.setGrid()` instead.
|
93 | * Adds a base [grid](https://threejs.org/docs/#api/en/helpers/GridHelper) to the scene.
|
94 | * @size (optional) Size of the grid.
|
95 | * @divisions (optional) Number of divisions in X and Y.
|
96 | * @ColorCenterLine (optional) Color of the XY central lines of the grid.
|
97 | * @colorGrid (optional) Color of the XY lines of the grid.
|
98 | */
|
99 | addGrid(size, divisions, colorCenterLine, colorGrid) {
|
100 | this.grid.setGrid(size, divisions, colorCenterLine, colorGrid);
|
101 | }
|
102 | /**
|
103 | * @deprecated Use `IfcViewerAPI.axes.setAxes()` instead.
|
104 | * Adds base [axes](https://threejs.org/docs/#api/en/helpers/AxesHelper) to the scene.
|
105 | * @size (optional) Size of the axes.
|
106 | */
|
107 | addAxes(size) {
|
108 | this.axes.setAxes(size);
|
109 | }
|
110 | /**
|
111 | * @deprecated Use `IfcViewerAPI.IFC.loadIfcUrl()` instead.
|
112 | * Loads the given IFC in the current scene.
|
113 | * @file IFC as URL.
|
114 | * @fitToFrame (optional) if true, brings the perspectiveCamera to the loaded IFC.
|
115 | */
|
116 | async loadIfcUrl(url, fitToFrame = false) {
|
117 | await this.IFC.loadIfcUrl(url, fitToFrame);
|
118 | }
|
119 | /**
|
120 | * @deprecated Use `IfcViewerAPI.IFC.setWasmPath()` instead.
|
121 | * Sets the relative path of web-ifc.wasm file in the project.
|
122 | * Beware: you **must** serve this file in your page; this means
|
123 | * that you have to copy this files from *node_modules/web-ifc*
|
124 | * to your deployment directory.
|
125 | *
|
126 | * If you don't use this methods,
|
127 | * IFC.js assumes that you are serving it in the root directory.
|
128 | *
|
129 | * Example if web-ifc.wasm is in dist/wasmDir:
|
130 | * `ifcLoader.setWasmPath("dist/wasmDir/");`
|
131 | *
|
132 | * @path Relative path to web-ifc.wasm.
|
133 | */
|
134 | setWasmPath(path) {
|
135 | this.IFC.setWasmPath(path);
|
136 | }
|
137 | /**
|
138 | * @deprecated Use `IfcViewerAPI.IFC.getSpatialStructure()` instead.
|
139 | * Gets the spatial structure of the specified model.
|
140 | * @modelID ID of the IFC model.
|
141 | */
|
142 | getSpatialStructure(modelID) {
|
143 | return this.IFC.getSpatialStructure(modelID);
|
144 | }
|
145 | /**
|
146 | * @deprecated Use `IfcViewerAPI.IFC.getProperties()` instead.
|
147 | * Gets the properties of the specified item.
|
148 | * @modelID ID of the IFC model.
|
149 | * @id Express ID of the item.
|
150 | * @indirect If true, also returns psets, qsets and type properties.
|
151 | */
|
152 | getProperties(modelID, id, indirect) {
|
153 | return this.IFC.getProperties(modelID, id, indirect);
|
154 | }
|
155 | /**
|
156 | * @deprecated Use `IfcViewerAPI.IFC.getModelID()` instead.
|
157 | * Gets the ID of the model pointed by the cursor.
|
158 | */
|
159 | getModelID() {
|
160 | return this.IFC.getModelID();
|
161 | }
|
162 | /**
|
163 | * @deprecated Use `IfcViewerAPI.IFC.getAllItemsOfType()` instead.
|
164 | * Gets all the items of the specified type in the specified IFC model.
|
165 | * @modelID ID of the IFC model.
|
166 | * @type type of element. You can import the type from web-ifc.
|
167 | * @verbose If true, also gets the properties for all the elements.
|
168 | */
|
169 | getAllItemsOfType(modelID, type, verbose = false) {
|
170 | return this.IFC.getAllItemsOfType(modelID, type, verbose);
|
171 | }
|
172 | /**
|
173 | * Releases all the memory allocated by IFC.js.
|
174 | * Use this only when deleting the ifcViewerAPI instance.
|
175 | * This is especially important when using libraries and frameworks that handle the lifecycle
|
176 | * of objects automatically (e.g. React, Angular, etc). If you are using one of these and are
|
177 | * instantiating webIfcViewer inside a component, make sure you use this method in the component
|
178 | * destruction event.
|
179 | */
|
180 | async dispose() {
|
181 | this.grid.dispose();
|
182 | this.grid = null;
|
183 | this.axes.dispose();
|
184 | this.axes = null;
|
185 | this.context.dispose();
|
186 | this.context = null;
|
187 | this.clipper.dispose();
|
188 | this.clipper = null;
|
189 | this.plans.dispose();
|
190 | this.plans = null;
|
191 | this.filler.dispose();
|
192 | this.filler = null;
|
193 | this.dimensions.dispose();
|
194 | this.dimensions = null;
|
195 | this.edges.dispose();
|
196 | this.edges = null;
|
197 | this.shadowDropper.dispose();
|
198 | this.shadowDropper = null;
|
199 | this.dxf.dispose();
|
200 | this.dxf = null;
|
201 | this.pdf.dispose();
|
202 | this.pdf = null;
|
203 | this.edgesProjector.dispose();
|
204 | this.edgesProjector = null;
|
205 | this.dropbox = null;
|
206 | this.GLTF.dispose();
|
207 | this.GLTF = null;
|
208 | await this.IFC.dispose();
|
209 | this.IFC = null;
|
210 | }
|
211 | }
|
212 | //# sourceMappingURL=ifc-viewer-api.js.map |
\ | No newline at end of file |