@buerli.io/headless 0.13.1-beta.1 → 0.13.1-beta.10

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.
@@ -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 core_1 = require("@buerli.io/core");
29
- Object.defineProperty(exports, "GraphicType", { enumerable: true, get: function () { return core_1.GraphicType; } });
30
- Object.defineProperty(exports, "ContainerType", { enumerable: true, get: function () { return core_1.ContainerType; } });
31
- Object.defineProperty(exports, "MeshTypes", { enumerable: true, get: function () { return core_1.MeshTypes; } });
32
- Object.defineProperty(exports, "EdgeTypes", { enumerable: true, get: function () { return core_1.EdgeTypes; } });
33
- Object.defineProperty(exports, "CurveTypes", { enumerable: true, get: function () { return core_1.CurveTypes; } });
34
- Object.defineProperty(exports, "EntityTypes", { enumerable: true, get: function () { return core_1.EntityTypes; } });
35
- Object.defineProperty(exports, "PointTypes", { enumerable: true, get: function () { return core_1.PointTypes; } });
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
@@ -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.ccAPI.base.createCCDrawing('solid');
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
- await solidAPI.init(drawingId);
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 () => classcad_1.ccAPI.common.setFacetingParameters(drawingId, distanceTol, angleTol)),
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(drawingId, length, width, height);
214
+ return solidAPI.createBox(length, width, height);
215
215
  });
216
216
  },
217
217
  clearSolids: () => {
218
218
  return this.resolve(async () => {
219
- return solidAPI.clearSolids(drawingId);
219
+ return solidAPI.clearSolids();
220
220
  });
221
221
  },
222
222
  clearSolid: (target) => {
223
223
  return this.resolve(async ([rTarget]) => {
224
- return solidAPI.clearSolid(drawingId, rTarget);
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(drawingId, length, diameter1, diameter2);
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(drawingId, rTarget);
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 classcad_1.ccAPI.baseModeler.requestVisualisationOfObject(drawingId, rSolid);
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 classcad_1.ccAPI.baseModeler.requestVisualisationOfObject(drawingId, _solid);
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(drawingId, length, diameter);
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(drawingId, rBreps);
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(drawingId, 'stp', rSolidIds);
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(drawingId, rTarget, makeNbrVec(point), makeNbrVec(normal), distance);
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(drawingId, makeNbrVec(height), curveArray);
342
+ return solidAPI.createExtrudeRegion(makeNbrVec(height), curveArray);
343
343
  }
344
344
  else {
345
- return solidAPI.createExtrude(drawingId, makeNbrVec(height), region.points, region.bulges);
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(drawingId, radius, rEdges);
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(drawingId, data, 'stp');
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(drawingId, rSolidId, keepSolid, rBody);
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(drawingId, data, 'ofb', true);
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(drawingId, rTarget, makeNbrVec(point), makeNbrEuler(normal));
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(drawingId, rTarget, makeNbrVec(position));
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(drawingId, rTarget, offsetDistance);
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(drawingId, rTarget, type, ...pts);
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(drawingId, makeNbrVec(position), makeNbrVec(direction), angle, curveArray);
408
+ return solidAPI.createRevolveRegion(makeNbrVec(position), makeNbrVec(direction), angle, curveArray);
409
409
  }
410
410
  else {
411
- return solidAPI.createRevolve(drawingId, makeNbrVec(position), makeNbrVec(direction), (angle / Math.PI) * 180, region.points, region.bulges);
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(drawingId, rTarget, makeNbrEuler(point));
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(drawingId, 'ofb');
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(drawingId, rTarget, lPointOrFactor);
428
+ return solidAPI.scale(rTarget, lPointOrFactor);
429
429
  }, target);
430
430
  },
431
431
  setFacetingParams: (distanceTol, angleTol) => {
432
432
  return this.resolve(async () => {
433
- return classcad_1.ccAPI.common.setFacetingParameters(drawingId, distanceTol, angleTol);
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(drawingId, rTarget, makeNbrVec(point), makeNbrVec(normal));
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(drawingId, radius);
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(drawingId, rSolidId, keepSolid, rBody);
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(drawingId, rSolidId, keepSolid, rBody);
457
+ solidAPI.union(rSolidId, keepSolid, rBody);
458
458
  }
459
459
  return rSolidId;
460
460
  }, solidId, ...bodies);