@buerli.io/headless 0.5.0-beta.2 → 0.5.0-beta.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.
- package/build/cjs/history.js +671 -188
- package/build/cjs/solid.js +70 -15
- package/build/esm/history.js +671 -188
- package/build/esm/solid.js +71 -16
- package/build/types/history.d.ts +328 -233
- package/build/types/index.d.ts +8 -1
- package/build/types/solid.d.ts +13 -3
- package/package.json +2 -2
package/build/esm/solid.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
2
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
3
|
+
var m = o[Symbol.asyncIterator], i;
|
|
4
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
5
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
6
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
7
|
+
};
|
|
1
8
|
/* eslint-disable max-lines */
|
|
2
9
|
import { ccAPI } from '@buerli.io/classcad';
|
|
3
10
|
import { api, getDrawing } from '@buerli.io/core';
|
|
4
|
-
import { Mesh, MeshStandardMaterial, Scene, Shape } from 'three';
|
|
11
|
+
import { Group, Mesh, MeshStandardMaterial, Scene, Shape } from 'three';
|
|
5
12
|
import * as BufferGeometryUtils_ from 'three/examples/jsm/utils/BufferGeometryUtils';
|
|
6
13
|
const solidAPI = ccAPI.solid;
|
|
7
14
|
let BufferGeometryUtils = BufferGeometryUtils_;
|
|
@@ -231,25 +238,73 @@ export default class CAD {
|
|
|
231
238
|
return BufferGeometryUtils.mergeBufferGeometries(entity.meshes.map(m => m.geometry));
|
|
232
239
|
}
|
|
233
240
|
},
|
|
234
|
-
createScene: async (
|
|
241
|
+
createScene: async (solids, options) => {
|
|
242
|
+
var e_1, _a;
|
|
235
243
|
await this.queue;
|
|
236
244
|
this.queue = Promise.resolve(0);
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
for (
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
245
|
+
const scene = new Scene();
|
|
246
|
+
scene.name = 'Scene'; // Default name for the scene
|
|
247
|
+
const part = new Group();
|
|
248
|
+
part.name = 'Part'; // Default name for the part
|
|
249
|
+
const _solids = [];
|
|
250
|
+
const meshes = [];
|
|
251
|
+
try {
|
|
252
|
+
for (var solids_1 = __asyncValues(solids), solids_1_1; solids_1_1 = await solids_1.next(), !solids_1_1.done;) {
|
|
253
|
+
const solid = solids_1_1.value;
|
|
254
|
+
await ccAPI.baseModeler.requestVisualisationOfObject(drawingId, solid);
|
|
255
|
+
const cDrawing = getDrawing(drawingId);
|
|
256
|
+
const solidObject = cDrawing.structure.tree[solid];
|
|
257
|
+
if (solidObject) {
|
|
258
|
+
const _solid = new Group();
|
|
259
|
+
_solid.name = solidObject.name;
|
|
260
|
+
_solid.userData = { id: solidObject.id }; // add solid id to the userData
|
|
261
|
+
const entities = solidObject.geometryIdList;
|
|
262
|
+
if (entities && entities.length > 0) {
|
|
263
|
+
const entity = cDrawing.geometry.cache[entities[0]];
|
|
264
|
+
if (entity && entity.meshes.length > 0) {
|
|
265
|
+
if (options === null || options === void 0 ? void 0 : options.meshPerGeometry) {
|
|
266
|
+
// Create a mesh for each geometry element
|
|
267
|
+
entity.meshes.forEach(m => {
|
|
268
|
+
const mesh = new Mesh();
|
|
269
|
+
mesh.userData = { id: m.graphicId }; // add graphic id to the userData
|
|
270
|
+
mesh.geometry = m.geometry;
|
|
271
|
+
mesh.material = new MeshStandardMaterial({
|
|
272
|
+
color: m.color,
|
|
273
|
+
transparent: m.opacity < 1,
|
|
274
|
+
opacity: m.opacity,
|
|
275
|
+
});
|
|
276
|
+
_solid.add(mesh);
|
|
277
|
+
meshes.push(mesh);
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
// Merge all geometries into one mesh
|
|
282
|
+
const mesh = new Mesh();
|
|
283
|
+
mesh.geometry = BufferGeometryUtils.mergeBufferGeometries(entity.meshes.map(m => m.geometry));
|
|
284
|
+
mesh.material = new MeshStandardMaterial({
|
|
285
|
+
color: entity.meshes[0].color,
|
|
286
|
+
transparent: entity.meshes[0].opacity < 1,
|
|
287
|
+
opacity: entity.meshes[0].opacity,
|
|
288
|
+
});
|
|
289
|
+
_solid.add(mesh); // Add mesh to solid of the scene
|
|
290
|
+
meshes.push(mesh); // Collect mesh to return later
|
|
291
|
+
}
|
|
292
|
+
part.add(_solid); // Add solid to part of the scene
|
|
293
|
+
_solids.push(_solid); // Collect solid to return later
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
300
|
+
finally {
|
|
301
|
+
try {
|
|
302
|
+
if (solids_1_1 && !solids_1_1.done && (_a = solids_1.return)) await _a.call(solids_1);
|
|
250
303
|
}
|
|
304
|
+
finally { if (e_1) throw e_1.error; }
|
|
251
305
|
}
|
|
252
|
-
|
|
306
|
+
scene.add(part); // Add part to the scene
|
|
307
|
+
return { scene, part, solids: _solids, meshes };
|
|
253
308
|
},
|
|
254
309
|
cylinder: (length, diameter) => {
|
|
255
310
|
return this.resolve(async () => {
|