@buerli.io/headless 0.5.0-beta.2 → 0.5.0-beta.3
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 +665 -165
- package/build/cjs/solid.js +70 -15
- package/build/esm/history.js +665 -165
- package/build/esm/solid.js +71 -16
- package/build/types/history.d.ts +323 -212
- package/build/types/index.d.ts +8 -1
- package/build/types/solid.d.ts +13 -3
- package/package.json +2 -2
package/build/cjs/solid.js
CHANGED
|
@@ -22,6 +22,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
26
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
27
|
+
var m = o[Symbol.asyncIterator], i;
|
|
28
|
+
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);
|
|
29
|
+
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); }); }; }
|
|
30
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
31
|
+
};
|
|
25
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
33
|
exports.createPolyline = void 0;
|
|
27
34
|
/* eslint-disable max-lines */
|
|
@@ -258,25 +265,73 @@ class CAD {
|
|
|
258
265
|
return BufferGeometryUtils.mergeBufferGeometries(entity.meshes.map(m => m.geometry));
|
|
259
266
|
}
|
|
260
267
|
},
|
|
261
|
-
createScene: async (
|
|
268
|
+
createScene: async (solids, options) => {
|
|
269
|
+
var e_1, _a;
|
|
262
270
|
await this.queue;
|
|
263
271
|
this.queue = Promise.resolve(0);
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
for (
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
272
|
+
const scene = new three_1.Scene();
|
|
273
|
+
scene.name = 'Scene'; // Default name for the scene
|
|
274
|
+
const part = new three_1.Group();
|
|
275
|
+
part.name = 'Part'; // Default name for the part
|
|
276
|
+
const _solids = [];
|
|
277
|
+
const meshes = [];
|
|
278
|
+
try {
|
|
279
|
+
for (var solids_1 = __asyncValues(solids), solids_1_1; solids_1_1 = await solids_1.next(), !solids_1_1.done;) {
|
|
280
|
+
const solid = solids_1_1.value;
|
|
281
|
+
await classcad_1.ccAPI.baseModeler.requestVisualisationOfObject(drawingId, solid);
|
|
282
|
+
const cDrawing = (0, core_1.getDrawing)(drawingId);
|
|
283
|
+
const solidObject = cDrawing.structure.tree[solid];
|
|
284
|
+
if (solidObject) {
|
|
285
|
+
const _solid = new three_1.Group();
|
|
286
|
+
_solid.name = solidObject.name;
|
|
287
|
+
_solid.userData = { id: solidObject.id }; // add solid id to the userData
|
|
288
|
+
const entities = solidObject.geometryIdList;
|
|
289
|
+
if (entities && entities.length > 0) {
|
|
290
|
+
const entity = cDrawing.geometry.cache[entities[0]];
|
|
291
|
+
if (entity && entity.meshes.length > 0) {
|
|
292
|
+
if (options === null || options === void 0 ? void 0 : options.meshPerGeometry) {
|
|
293
|
+
// Create a mesh for each geometry element
|
|
294
|
+
entity.meshes.forEach(m => {
|
|
295
|
+
const mesh = new three_1.Mesh();
|
|
296
|
+
mesh.userData = { id: m.graphicId }; // add graphic id to the userData
|
|
297
|
+
mesh.geometry = m.geometry;
|
|
298
|
+
mesh.material = new three_1.MeshStandardMaterial({
|
|
299
|
+
color: m.color,
|
|
300
|
+
transparent: m.opacity < 1,
|
|
301
|
+
opacity: m.opacity,
|
|
302
|
+
});
|
|
303
|
+
_solid.add(mesh);
|
|
304
|
+
meshes.push(mesh);
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
// Merge all geometries into one mesh
|
|
309
|
+
const mesh = new three_1.Mesh();
|
|
310
|
+
mesh.geometry = BufferGeometryUtils.mergeBufferGeometries(entity.meshes.map(m => m.geometry));
|
|
311
|
+
mesh.material = new three_1.MeshStandardMaterial({
|
|
312
|
+
color: entity.meshes[0].color,
|
|
313
|
+
transparent: entity.meshes[0].opacity < 1,
|
|
314
|
+
opacity: entity.meshes[0].opacity,
|
|
315
|
+
});
|
|
316
|
+
_solid.add(mesh); // Add mesh to solid of the scene
|
|
317
|
+
meshes.push(mesh); // Collect mesh to return later
|
|
318
|
+
}
|
|
319
|
+
part.add(_solid); // Add solid to part of the scene
|
|
320
|
+
_solids.push(_solid); // Collect solid to return later
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
327
|
+
finally {
|
|
328
|
+
try {
|
|
329
|
+
if (solids_1_1 && !solids_1_1.done && (_a = solids_1.return)) await _a.call(solids_1);
|
|
277
330
|
}
|
|
331
|
+
finally { if (e_1) throw e_1.error; }
|
|
278
332
|
}
|
|
279
|
-
|
|
333
|
+
scene.add(part); // Add part to the scene
|
|
334
|
+
return { scene, part, solids: _solids, meshes };
|
|
280
335
|
},
|
|
281
336
|
cylinder: (length, diameter) => {
|
|
282
337
|
return this.resolve(async () => {
|