@buerli.io/headless 0.13.1-beta.1 → 0.13.1-beta.11
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 +156 -144
- package/build/cjs/index.js +8 -8
- package/build/cjs/solid.js +36 -36
- package/build/esm/history.js +157 -145
- package/build/esm/index.js +1 -1
- package/build/esm/solid.js +37 -37
- package/build/types/history.d.ts +25 -5
- package/build/types/index.d.ts +1 -1
- package/build/types/solid.d.ts +4 -1
- package/package.json +2 -2
package/build/cjs/index.js
CHANGED
|
@@ -25,12 +25,12 @@ Object.defineProperty(exports, "OrientationType", { enumerable: true, get: funct
|
|
|
25
25
|
Object.defineProperty(exports, "ExtrusionType", { enumerable: true, get: function () { return classcad_1.ExtrusionType; } });
|
|
26
26
|
Object.defineProperty(exports, "SVGModusType", { enumerable: true, get: function () { return classcad_1.SVGModusType; } });
|
|
27
27
|
// Re-export types form @buerli.io/core for easier usage
|
|
28
|
-
var
|
|
29
|
-
Object.defineProperty(exports, "GraphicType", { enumerable: true, get: function () { return
|
|
30
|
-
Object.defineProperty(exports, "ContainerType", { enumerable: true, get: function () { return
|
|
31
|
-
Object.defineProperty(exports, "MeshTypes", { enumerable: true, get: function () { return
|
|
32
|
-
Object.defineProperty(exports, "EdgeTypes", { enumerable: true, get: function () { return
|
|
33
|
-
Object.defineProperty(exports, "CurveTypes", { enumerable: true, get: function () { return
|
|
34
|
-
Object.defineProperty(exports, "EntityTypes", { enumerable: true, get: function () { return
|
|
35
|
-
Object.defineProperty(exports, "PointTypes", { enumerable: true, get: function () { return
|
|
28
|
+
var classcad_2 = require("@buerli.io/classcad");
|
|
29
|
+
Object.defineProperty(exports, "GraphicType", { enumerable: true, get: function () { return classcad_2.GraphicType; } });
|
|
30
|
+
Object.defineProperty(exports, "ContainerType", { enumerable: true, get: function () { return classcad_2.ContainerType; } });
|
|
31
|
+
Object.defineProperty(exports, "MeshTypes", { enumerable: true, get: function () { return classcad_2.MeshTypes; } });
|
|
32
|
+
Object.defineProperty(exports, "EdgeTypes", { enumerable: true, get: function () { return classcad_2.EdgeTypes; } });
|
|
33
|
+
Object.defineProperty(exports, "CurveTypes", { enumerable: true, get: function () { return classcad_2.CurveTypes; } });
|
|
34
|
+
Object.defineProperty(exports, "EntityTypes", { enumerable: true, get: function () { return classcad_2.EntityTypes; } });
|
|
35
|
+
Object.defineProperty(exports, "PointTypes", { enumerable: true, get: function () { return classcad_2.PointTypes; } });
|
|
36
36
|
//#endregion Re-export type definitions
|
package/build/cjs/solid.js
CHANGED
|
@@ -15,7 +15,6 @@ const three_1 = require("three");
|
|
|
15
15
|
const three_stdlib_1 = require("three-stdlib");
|
|
16
16
|
const meshes_1 = require("./utils/meshes");
|
|
17
17
|
const isShape = (entity) => entity && entity.type === 'Shape';
|
|
18
|
-
const solidAPI = classcad_1.ccAPI.solid;
|
|
19
18
|
const toCCVec = (args) => ({ x: args[0], y: args[1], z: args[2] });
|
|
20
19
|
const toCCNbrVec = (args) => ({ x: args[0], y: args[1], z: args[2] });
|
|
21
20
|
const toArray = (v) => (Array.isArray(v) ? v : v.toArray());
|
|
@@ -199,46 +198,47 @@ class Solid {
|
|
|
199
198
|
}
|
|
200
199
|
init(callback) {
|
|
201
200
|
const promise = new Promise(async (resolve, reject) => {
|
|
202
|
-
const drawingId = await classcad_1.
|
|
201
|
+
const drawingId = await classcad_1.BuerliCadFacade.utils.connect('solid');
|
|
203
202
|
if (!drawingId)
|
|
204
|
-
throw new Error('Drawing could not be created');
|
|
203
|
+
throw new Error('Connection/Drawing could not be created');
|
|
205
204
|
this.drawingId = drawingId;
|
|
206
|
-
|
|
205
|
+
const { solid: solidAPI, baseModeler: baseModelerAPI, common: commonAPI } = (0, classcad_1.createApi)(drawingId).v0;
|
|
206
|
+
await solidAPI.init();
|
|
207
207
|
const publicApi = {
|
|
208
208
|
getDrawingId: () => drawingId,
|
|
209
209
|
getDrawing: () => (0, core_1.getDrawing)(drawingId),
|
|
210
210
|
getState: () => core_1.api.getState(),
|
|
211
|
-
setFacetingParameters: (distanceTol, angleTol) => this.resolve(async () =>
|
|
211
|
+
setFacetingParameters: (distanceTol, angleTol) => this.resolve(async () => commonAPI.setFacetingParameters(distanceTol, angleTol)),
|
|
212
212
|
box: (length, width, height) => {
|
|
213
213
|
return this.resolve(async () => {
|
|
214
|
-
return solidAPI.createBox(
|
|
214
|
+
return solidAPI.createBox(length, width, height);
|
|
215
215
|
});
|
|
216
216
|
},
|
|
217
217
|
clearSolids: () => {
|
|
218
218
|
return this.resolve(async () => {
|
|
219
|
-
return solidAPI.clearSolids(
|
|
219
|
+
return solidAPI.clearSolids();
|
|
220
220
|
});
|
|
221
221
|
},
|
|
222
222
|
clearSolid: (target) => {
|
|
223
223
|
return this.resolve(async ([rTarget]) => {
|
|
224
|
-
return solidAPI.clearSolid(
|
|
224
|
+
return solidAPI.clearSolid(rTarget);
|
|
225
225
|
}, target);
|
|
226
226
|
},
|
|
227
227
|
cone: (length, diameter1, diameter2) => {
|
|
228
228
|
return this.resolve(async () => {
|
|
229
|
-
return solidAPI.createCone(
|
|
229
|
+
return solidAPI.createCone(length, diameter1, diameter2);
|
|
230
230
|
});
|
|
231
231
|
},
|
|
232
232
|
copy: (target) => {
|
|
233
233
|
return this.resolve(async ([rTarget]) => {
|
|
234
|
-
return solidAPI.copy(
|
|
234
|
+
return solidAPI.copy(rTarget);
|
|
235
235
|
}, target);
|
|
236
236
|
},
|
|
237
237
|
createBufferGeometry: async (_solid) => {
|
|
238
238
|
await this.queue;
|
|
239
239
|
this.queue = Promise.resolve(0);
|
|
240
240
|
const rSolid = await _solid;
|
|
241
|
-
await
|
|
241
|
+
await baseModelerAPI.requestVisualisationOfObject(rSolid);
|
|
242
242
|
const entity = await getEntity(drawingId, rSolid);
|
|
243
243
|
if (entity != null) {
|
|
244
244
|
return (0, three_stdlib_1.mergeBufferGeometries)(entity.meshes.map(m => m.geometry));
|
|
@@ -257,7 +257,7 @@ class Solid {
|
|
|
257
257
|
try {
|
|
258
258
|
for (var solids_1 = __asyncValues(solids), solids_1_1; solids_1_1 = await solids_1.next(), !solids_1_1.done;) {
|
|
259
259
|
const _solid = solids_1_1.value;
|
|
260
|
-
await
|
|
260
|
+
await baseModelerAPI.requestVisualisationOfObject(_solid);
|
|
261
261
|
const cDrawing = (0, core_1.getDrawing)(drawingId);
|
|
262
262
|
const solidObject = cDrawing.structure.tree[_solid];
|
|
263
263
|
if (solidObject) {
|
|
@@ -317,56 +317,56 @@ class Solid {
|
|
|
317
317
|
},
|
|
318
318
|
cylinder: (length, diameter) => {
|
|
319
319
|
return this.resolve(async () => {
|
|
320
|
-
return solidAPI.createCylinder(
|
|
320
|
+
return solidAPI.createCylinder(length, diameter);
|
|
321
321
|
});
|
|
322
322
|
},
|
|
323
323
|
edgeLoops: (breps) => {
|
|
324
324
|
return this.resolve(async ([rBreps]) => {
|
|
325
|
-
return solidAPI.edgeLoops(
|
|
325
|
+
return solidAPI.edgeLoops(rBreps);
|
|
326
326
|
}, breps);
|
|
327
327
|
},
|
|
328
328
|
export: (solidIds) => {
|
|
329
329
|
return this.resolve(async ([rSolidIds]) => {
|
|
330
|
-
return solidAPI.export(
|
|
330
|
+
return solidAPI.export('stp', rSolidIds);
|
|
331
331
|
}, solidIds);
|
|
332
332
|
},
|
|
333
333
|
extendSolidAtPlane: (target, point, normal, distance) => {
|
|
334
334
|
return this.resolve(async ([rTarget]) => {
|
|
335
|
-
return solidAPI.solidExtendAtPlane(
|
|
335
|
+
return solidAPI.solidExtendAtPlane(rTarget, makeNbrVec(point), makeNbrVec(normal), distance);
|
|
336
336
|
}, target);
|
|
337
337
|
},
|
|
338
338
|
extrude: (height, region) => {
|
|
339
339
|
return this.resolve(async () => {
|
|
340
340
|
if (isShape(region)) {
|
|
341
341
|
const curveArray = makeCCData(region.curves);
|
|
342
|
-
return solidAPI.createExtrudeRegion(
|
|
342
|
+
return solidAPI.createExtrudeRegion(makeNbrVec(height), curveArray);
|
|
343
343
|
}
|
|
344
344
|
else {
|
|
345
|
-
return solidAPI.createExtrude(
|
|
345
|
+
return solidAPI.createExtrude(makeNbrVec(height), region.points, region.bulges);
|
|
346
346
|
}
|
|
347
347
|
});
|
|
348
348
|
},
|
|
349
349
|
fillet: (radius, edges) => {
|
|
350
350
|
return this.resolve(async ([rEdges]) => {
|
|
351
|
-
return solidAPI.createFillet(
|
|
351
|
+
return solidAPI.createFillet(radius, rEdges);
|
|
352
352
|
}, edges);
|
|
353
353
|
},
|
|
354
354
|
import: (data) => {
|
|
355
355
|
return this.resolve(async () => {
|
|
356
|
-
return solidAPI.import(
|
|
356
|
+
return solidAPI.import(data, 'stp');
|
|
357
357
|
});
|
|
358
358
|
},
|
|
359
359
|
intersect: (solidId, keepSolid, ...bodies) => {
|
|
360
360
|
return this.resolve(async ([rSolidId, ...rBodies]) => {
|
|
361
361
|
for (const rBody of rBodies) {
|
|
362
|
-
solidAPI.intersect(
|
|
362
|
+
solidAPI.intersect(rSolidId, keepSolid, rBody);
|
|
363
363
|
}
|
|
364
364
|
return rSolidId;
|
|
365
365
|
}, solidId, ...bodies);
|
|
366
366
|
},
|
|
367
367
|
load: (data) => {
|
|
368
368
|
return this.resolve(async () => {
|
|
369
|
-
const productId = await solidAPI.load(
|
|
369
|
+
const productId = await solidAPI.load(data, 'ofb', true);
|
|
370
370
|
if (productId !== null) {
|
|
371
371
|
const drawing = (0, core_1.getDrawing)(drawingId);
|
|
372
372
|
const solids = drawing.structure.tree[productId].solids;
|
|
@@ -379,23 +379,23 @@ class Solid {
|
|
|
379
379
|
},
|
|
380
380
|
mirror: (target, point, normal) => {
|
|
381
381
|
return this.resolve(async ([rTarget]) => {
|
|
382
|
-
return solidAPI.mirror(
|
|
382
|
+
return solidAPI.mirror(rTarget, makeNbrVec(point), makeNbrEuler(normal));
|
|
383
383
|
}, target);
|
|
384
384
|
},
|
|
385
385
|
moveTo: (target, position) => {
|
|
386
386
|
return this.resolve(async ([rTarget]) => {
|
|
387
|
-
return solidAPI.moveTo(
|
|
387
|
+
return solidAPI.moveTo(rTarget, makeNbrVec(position));
|
|
388
388
|
}, target);
|
|
389
389
|
},
|
|
390
390
|
offset: (target, offsetDistance) => {
|
|
391
391
|
return this.resolve(async ([rTarget]) => {
|
|
392
|
-
return solidAPI.offset(
|
|
392
|
+
return solidAPI.offset(rTarget, offsetDistance);
|
|
393
393
|
}, target);
|
|
394
394
|
},
|
|
395
395
|
pick: (target, type, ...points) => {
|
|
396
396
|
return this.resolve(async ([rTarget]) => {
|
|
397
397
|
const pts = points.map(pt => makeNbrVec(pt));
|
|
398
|
-
const breps = await solidAPI.pick(
|
|
398
|
+
const breps = await solidAPI.pick(rTarget, type, ...pts);
|
|
399
399
|
if (breps !== null) {
|
|
400
400
|
return Array.isArray(breps) ? breps : [breps];
|
|
401
401
|
}
|
|
@@ -405,48 +405,48 @@ class Solid {
|
|
|
405
405
|
return this.resolve(async () => {
|
|
406
406
|
if (isShape(region)) {
|
|
407
407
|
const curveArray = makeCCData(region.curves);
|
|
408
|
-
return solidAPI.createRevolveRegion(
|
|
408
|
+
return solidAPI.createRevolveRegion(makeNbrVec(position), makeNbrVec(direction), angle, curveArray);
|
|
409
409
|
}
|
|
410
410
|
else {
|
|
411
|
-
return solidAPI.createRevolve(
|
|
411
|
+
return solidAPI.createRevolve(makeNbrVec(position), makeNbrVec(direction), (angle / Math.PI) * 180, region.points, region.bulges);
|
|
412
412
|
}
|
|
413
413
|
});
|
|
414
414
|
},
|
|
415
415
|
rotateTo: (target, point) => {
|
|
416
416
|
return this.resolve(async ([rTarget]) => {
|
|
417
|
-
return solidAPI.rotateTo(
|
|
417
|
+
return solidAPI.rotateTo(rTarget, makeNbrEuler(point));
|
|
418
418
|
}, target);
|
|
419
419
|
},
|
|
420
420
|
save: () => {
|
|
421
421
|
return this.resolve(async () => {
|
|
422
|
-
return solidAPI.save(
|
|
422
|
+
return solidAPI.save('ofb');
|
|
423
423
|
});
|
|
424
424
|
},
|
|
425
425
|
scale: (target, pointOrFactor) => {
|
|
426
426
|
return this.resolve(async ([rTarget]) => {
|
|
427
427
|
const lPointOrFactor = typeof pointOrFactor === 'number' ? pointOrFactor : makeNbrVec(pointOrFactor);
|
|
428
|
-
return solidAPI.scale(
|
|
428
|
+
return solidAPI.scale(rTarget, lPointOrFactor);
|
|
429
429
|
}, target);
|
|
430
430
|
},
|
|
431
431
|
setFacetingParams: (distanceTol, angleTol) => {
|
|
432
432
|
return this.resolve(async () => {
|
|
433
|
-
return
|
|
433
|
+
return commonAPI.setFacetingParameters(distanceTol, angleTol);
|
|
434
434
|
});
|
|
435
435
|
},
|
|
436
436
|
slice: (target, point, normal) => {
|
|
437
437
|
return this.resolve(async ([rTarget]) => {
|
|
438
|
-
return solidAPI.slice(
|
|
438
|
+
return solidAPI.slice(rTarget, makeNbrVec(point), makeNbrVec(normal));
|
|
439
439
|
}, target);
|
|
440
440
|
},
|
|
441
441
|
sphere: (radius) => {
|
|
442
442
|
return this.resolve(async () => {
|
|
443
|
-
return solidAPI.createSphere(
|
|
443
|
+
return solidAPI.createSphere(radius);
|
|
444
444
|
});
|
|
445
445
|
},
|
|
446
446
|
subtract: (solidId, keepSolid, ...bodies) => {
|
|
447
447
|
return this.resolve(async ([rSolidId, ...rBodies]) => {
|
|
448
448
|
for (const rBody of rBodies) {
|
|
449
|
-
solidAPI.subtract(
|
|
449
|
+
solidAPI.subtract(rSolidId, keepSolid, rBody);
|
|
450
450
|
}
|
|
451
451
|
return rSolidId;
|
|
452
452
|
}, solidId, ...bodies);
|
|
@@ -454,7 +454,7 @@ class Solid {
|
|
|
454
454
|
union: (solidId, keepSolid, ...bodies) => {
|
|
455
455
|
return this.resolve(async ([rSolidId, ...rBodies]) => {
|
|
456
456
|
for (const rBody of rBodies) {
|
|
457
|
-
solidAPI.union(
|
|
457
|
+
solidAPI.union(rSolidId, keepSolid, rBody);
|
|
458
458
|
}
|
|
459
459
|
return rSolidId;
|
|
460
460
|
}, solidId, ...bodies);
|