@buerli.io/headless 0.13.1-beta.4 → 0.13.1-beta.7.apiversion
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 +145 -142
- package/build/cjs/index.js +8 -8
- package/build/cjs/solid.js +36 -36
- package/build/esm/history.js +146 -143
- package/build/esm/index.js +1 -1
- package/build/esm/solid.js +37 -37
- package/build/types/history.d.ts +2 -2
- package/build/types/index.d.ts +1 -1
- package/build/types/solid.d.ts +2 -1
- package/package.json +2 -2
package/build/esm/index.js
CHANGED
|
@@ -4,5 +4,5 @@ export { Solid, solid, History, history, createPolyline };
|
|
|
4
4
|
// Re-export types form @buerli.io/classcad for easier usage
|
|
5
5
|
export { init, BooleanOperationType, ChamferType, DataType, FlipType, ReorientedType, WorkAxisType, WorkCoordSystemType, WorkPlaneType, WorkPointType, ViewType, OrientationType, ExtrusionType, SVGModusType, } from '@buerli.io/classcad';
|
|
6
6
|
// Re-export types form @buerli.io/core for easier usage
|
|
7
|
-
export { GraphicType, ContainerType, MeshTypes, EdgeTypes, CurveTypes, EntityTypes, PointTypes } from '@buerli.io/
|
|
7
|
+
export { GraphicType, ContainerType, MeshTypes, EdgeTypes, CurveTypes, EntityTypes, PointTypes, } from '@buerli.io/classcad';
|
|
8
8
|
//#endregion Re-export type definitions
|
package/build/esm/solid.js
CHANGED
|
@@ -6,13 +6,12 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
6
6
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
7
7
|
};
|
|
8
8
|
/* eslint-disable max-lines */
|
|
9
|
-
import {
|
|
9
|
+
import { api as ccApi, Connection } from '@buerli.io/classcad';
|
|
10
10
|
import { api, getDrawing } from '@buerli.io/core';
|
|
11
11
|
import { Group, Mesh, MeshStandardMaterial, Scene } from 'three';
|
|
12
12
|
import { mergeBufferGeometries } from 'three-stdlib';
|
|
13
13
|
import { getDifferentColoredMeshesFromEntity } from './utils/meshes';
|
|
14
14
|
const isShape = (entity) => entity && entity.type === 'Shape';
|
|
15
|
-
const solidAPI = ccAPI.solid;
|
|
16
15
|
const toCCVec = (args) => ({ x: args[0], y: args[1], z: args[2] });
|
|
17
16
|
const toCCNbrVec = (args) => ({ x: args[0], y: args[1], z: args[2] });
|
|
18
17
|
const toArray = (v) => (Array.isArray(v) ? v : v.toArray());
|
|
@@ -195,46 +194,47 @@ export class Solid {
|
|
|
195
194
|
}
|
|
196
195
|
init(callback) {
|
|
197
196
|
const promise = new Promise(async (resolve, reject) => {
|
|
198
|
-
const drawingId = await
|
|
197
|
+
const drawingId = await Connection.create('solid');
|
|
199
198
|
if (!drawingId)
|
|
200
|
-
throw new Error('Drawing could not be created');
|
|
199
|
+
throw new Error('Connection/Drawing could not be created');
|
|
201
200
|
this.drawingId = drawingId;
|
|
202
|
-
|
|
201
|
+
const { solid: solidAPI, baseModeler: baseModelerAPI, common: commonAPI } = ccApi(drawingId).v0;
|
|
202
|
+
await solidAPI.init();
|
|
203
203
|
const publicApi = {
|
|
204
204
|
getDrawingId: () => drawingId,
|
|
205
205
|
getDrawing: () => getDrawing(drawingId),
|
|
206
206
|
getState: () => api.getState(),
|
|
207
|
-
setFacetingParameters: (distanceTol, angleTol) => this.resolve(async () =>
|
|
207
|
+
setFacetingParameters: (distanceTol, angleTol) => this.resolve(async () => commonAPI.setFacetingParameters(distanceTol, angleTol)),
|
|
208
208
|
box: (length, width, height) => {
|
|
209
209
|
return this.resolve(async () => {
|
|
210
|
-
return solidAPI.createBox(
|
|
210
|
+
return solidAPI.createBox(length, width, height);
|
|
211
211
|
});
|
|
212
212
|
},
|
|
213
213
|
clearSolids: () => {
|
|
214
214
|
return this.resolve(async () => {
|
|
215
|
-
return solidAPI.clearSolids(
|
|
215
|
+
return solidAPI.clearSolids();
|
|
216
216
|
});
|
|
217
217
|
},
|
|
218
218
|
clearSolid: (target) => {
|
|
219
219
|
return this.resolve(async ([rTarget]) => {
|
|
220
|
-
return solidAPI.clearSolid(
|
|
220
|
+
return solidAPI.clearSolid(rTarget);
|
|
221
221
|
}, target);
|
|
222
222
|
},
|
|
223
223
|
cone: (length, diameter1, diameter2) => {
|
|
224
224
|
return this.resolve(async () => {
|
|
225
|
-
return solidAPI.createCone(
|
|
225
|
+
return solidAPI.createCone(length, diameter1, diameter2);
|
|
226
226
|
});
|
|
227
227
|
},
|
|
228
228
|
copy: (target) => {
|
|
229
229
|
return this.resolve(async ([rTarget]) => {
|
|
230
|
-
return solidAPI.copy(
|
|
230
|
+
return solidAPI.copy(rTarget);
|
|
231
231
|
}, target);
|
|
232
232
|
},
|
|
233
233
|
createBufferGeometry: async (_solid) => {
|
|
234
234
|
await this.queue;
|
|
235
235
|
this.queue = Promise.resolve(0);
|
|
236
236
|
const rSolid = await _solid;
|
|
237
|
-
await
|
|
237
|
+
await baseModelerAPI.requestVisualisationOfObject(rSolid);
|
|
238
238
|
const entity = await getEntity(drawingId, rSolid);
|
|
239
239
|
if (entity != null) {
|
|
240
240
|
return mergeBufferGeometries(entity.meshes.map(m => m.geometry));
|
|
@@ -253,7 +253,7 @@ export class Solid {
|
|
|
253
253
|
try {
|
|
254
254
|
for (var solids_1 = __asyncValues(solids), solids_1_1; solids_1_1 = await solids_1.next(), !solids_1_1.done;) {
|
|
255
255
|
const _solid = solids_1_1.value;
|
|
256
|
-
await
|
|
256
|
+
await baseModelerAPI.requestVisualisationOfObject(_solid);
|
|
257
257
|
const cDrawing = getDrawing(drawingId);
|
|
258
258
|
const solidObject = cDrawing.structure.tree[_solid];
|
|
259
259
|
if (solidObject) {
|
|
@@ -313,56 +313,56 @@ export class Solid {
|
|
|
313
313
|
},
|
|
314
314
|
cylinder: (length, diameter) => {
|
|
315
315
|
return this.resolve(async () => {
|
|
316
|
-
return solidAPI.createCylinder(
|
|
316
|
+
return solidAPI.createCylinder(length, diameter);
|
|
317
317
|
});
|
|
318
318
|
},
|
|
319
319
|
edgeLoops: (breps) => {
|
|
320
320
|
return this.resolve(async ([rBreps]) => {
|
|
321
|
-
return solidAPI.edgeLoops(
|
|
321
|
+
return solidAPI.edgeLoops(rBreps);
|
|
322
322
|
}, breps);
|
|
323
323
|
},
|
|
324
324
|
export: (solidIds) => {
|
|
325
325
|
return this.resolve(async ([rSolidIds]) => {
|
|
326
|
-
return solidAPI.export(
|
|
326
|
+
return solidAPI.export('stp', rSolidIds);
|
|
327
327
|
}, solidIds);
|
|
328
328
|
},
|
|
329
329
|
extendSolidAtPlane: (target, point, normal, distance) => {
|
|
330
330
|
return this.resolve(async ([rTarget]) => {
|
|
331
|
-
return solidAPI.solidExtendAtPlane(
|
|
331
|
+
return solidAPI.solidExtendAtPlane(rTarget, makeNbrVec(point), makeNbrVec(normal), distance);
|
|
332
332
|
}, target);
|
|
333
333
|
},
|
|
334
334
|
extrude: (height, region) => {
|
|
335
335
|
return this.resolve(async () => {
|
|
336
336
|
if (isShape(region)) {
|
|
337
337
|
const curveArray = makeCCData(region.curves);
|
|
338
|
-
return solidAPI.createExtrudeRegion(
|
|
338
|
+
return solidAPI.createExtrudeRegion(makeNbrVec(height), curveArray);
|
|
339
339
|
}
|
|
340
340
|
else {
|
|
341
|
-
return solidAPI.createExtrude(
|
|
341
|
+
return solidAPI.createExtrude(makeNbrVec(height), region.points, region.bulges);
|
|
342
342
|
}
|
|
343
343
|
});
|
|
344
344
|
},
|
|
345
345
|
fillet: (radius, edges) => {
|
|
346
346
|
return this.resolve(async ([rEdges]) => {
|
|
347
|
-
return solidAPI.createFillet(
|
|
347
|
+
return solidAPI.createFillet(radius, rEdges);
|
|
348
348
|
}, edges);
|
|
349
349
|
},
|
|
350
350
|
import: (data) => {
|
|
351
351
|
return this.resolve(async () => {
|
|
352
|
-
return solidAPI.import(
|
|
352
|
+
return solidAPI.import(data, 'stp');
|
|
353
353
|
});
|
|
354
354
|
},
|
|
355
355
|
intersect: (solidId, keepSolid, ...bodies) => {
|
|
356
356
|
return this.resolve(async ([rSolidId, ...rBodies]) => {
|
|
357
357
|
for (const rBody of rBodies) {
|
|
358
|
-
solidAPI.intersect(
|
|
358
|
+
solidAPI.intersect(rSolidId, keepSolid, rBody);
|
|
359
359
|
}
|
|
360
360
|
return rSolidId;
|
|
361
361
|
}, solidId, ...bodies);
|
|
362
362
|
},
|
|
363
363
|
load: (data) => {
|
|
364
364
|
return this.resolve(async () => {
|
|
365
|
-
const productId = await solidAPI.load(
|
|
365
|
+
const productId = await solidAPI.load(data, 'ofb', true);
|
|
366
366
|
if (productId !== null) {
|
|
367
367
|
const drawing = getDrawing(drawingId);
|
|
368
368
|
const solids = drawing.structure.tree[productId].solids;
|
|
@@ -375,23 +375,23 @@ export class Solid {
|
|
|
375
375
|
},
|
|
376
376
|
mirror: (target, point, normal) => {
|
|
377
377
|
return this.resolve(async ([rTarget]) => {
|
|
378
|
-
return solidAPI.mirror(
|
|
378
|
+
return solidAPI.mirror(rTarget, makeNbrVec(point), makeNbrEuler(normal));
|
|
379
379
|
}, target);
|
|
380
380
|
},
|
|
381
381
|
moveTo: (target, position) => {
|
|
382
382
|
return this.resolve(async ([rTarget]) => {
|
|
383
|
-
return solidAPI.moveTo(
|
|
383
|
+
return solidAPI.moveTo(rTarget, makeNbrVec(position));
|
|
384
384
|
}, target);
|
|
385
385
|
},
|
|
386
386
|
offset: (target, offsetDistance) => {
|
|
387
387
|
return this.resolve(async ([rTarget]) => {
|
|
388
|
-
return solidAPI.offset(
|
|
388
|
+
return solidAPI.offset(rTarget, offsetDistance);
|
|
389
389
|
}, target);
|
|
390
390
|
},
|
|
391
391
|
pick: (target, type, ...points) => {
|
|
392
392
|
return this.resolve(async ([rTarget]) => {
|
|
393
393
|
const pts = points.map(pt => makeNbrVec(pt));
|
|
394
|
-
const breps = await solidAPI.pick(
|
|
394
|
+
const breps = await solidAPI.pick(rTarget, type, ...pts);
|
|
395
395
|
if (breps !== null) {
|
|
396
396
|
return Array.isArray(breps) ? breps : [breps];
|
|
397
397
|
}
|
|
@@ -401,48 +401,48 @@ export class Solid {
|
|
|
401
401
|
return this.resolve(async () => {
|
|
402
402
|
if (isShape(region)) {
|
|
403
403
|
const curveArray = makeCCData(region.curves);
|
|
404
|
-
return solidAPI.createRevolveRegion(
|
|
404
|
+
return solidAPI.createRevolveRegion(makeNbrVec(position), makeNbrVec(direction), angle, curveArray);
|
|
405
405
|
}
|
|
406
406
|
else {
|
|
407
|
-
return solidAPI.createRevolve(
|
|
407
|
+
return solidAPI.createRevolve(makeNbrVec(position), makeNbrVec(direction), (angle / Math.PI) * 180, region.points, region.bulges);
|
|
408
408
|
}
|
|
409
409
|
});
|
|
410
410
|
},
|
|
411
411
|
rotateTo: (target, point) => {
|
|
412
412
|
return this.resolve(async ([rTarget]) => {
|
|
413
|
-
return solidAPI.rotateTo(
|
|
413
|
+
return solidAPI.rotateTo(rTarget, makeNbrEuler(point));
|
|
414
414
|
}, target);
|
|
415
415
|
},
|
|
416
416
|
save: () => {
|
|
417
417
|
return this.resolve(async () => {
|
|
418
|
-
return solidAPI.save(
|
|
418
|
+
return solidAPI.save('ofb');
|
|
419
419
|
});
|
|
420
420
|
},
|
|
421
421
|
scale: (target, pointOrFactor) => {
|
|
422
422
|
return this.resolve(async ([rTarget]) => {
|
|
423
423
|
const lPointOrFactor = typeof pointOrFactor === 'number' ? pointOrFactor : makeNbrVec(pointOrFactor);
|
|
424
|
-
return solidAPI.scale(
|
|
424
|
+
return solidAPI.scale(rTarget, lPointOrFactor);
|
|
425
425
|
}, target);
|
|
426
426
|
},
|
|
427
427
|
setFacetingParams: (distanceTol, angleTol) => {
|
|
428
428
|
return this.resolve(async () => {
|
|
429
|
-
return
|
|
429
|
+
return commonAPI.setFacetingParameters(distanceTol, angleTol);
|
|
430
430
|
});
|
|
431
431
|
},
|
|
432
432
|
slice: (target, point, normal) => {
|
|
433
433
|
return this.resolve(async ([rTarget]) => {
|
|
434
|
-
return solidAPI.slice(
|
|
434
|
+
return solidAPI.slice(rTarget, makeNbrVec(point), makeNbrVec(normal));
|
|
435
435
|
}, target);
|
|
436
436
|
},
|
|
437
437
|
sphere: (radius) => {
|
|
438
438
|
return this.resolve(async () => {
|
|
439
|
-
return solidAPI.createSphere(
|
|
439
|
+
return solidAPI.createSphere(radius);
|
|
440
440
|
});
|
|
441
441
|
},
|
|
442
442
|
subtract: (solidId, keepSolid, ...bodies) => {
|
|
443
443
|
return this.resolve(async ([rSolidId, ...rBodies]) => {
|
|
444
444
|
for (const rBody of rBodies) {
|
|
445
|
-
solidAPI.subtract(
|
|
445
|
+
solidAPI.subtract(rSolidId, keepSolid, rBody);
|
|
446
446
|
}
|
|
447
447
|
return rSolidId;
|
|
448
448
|
}, solidId, ...bodies);
|
|
@@ -450,7 +450,7 @@ export class Solid {
|
|
|
450
450
|
union: (solidId, keepSolid, ...bodies) => {
|
|
451
451
|
return this.resolve(async ([rSolidId, ...rBodies]) => {
|
|
452
452
|
for (const rBody of rBodies) {
|
|
453
|
-
solidAPI.union(
|
|
453
|
+
solidAPI.union(rSolidId, keepSolid, rBody);
|
|
454
454
|
}
|
|
455
455
|
return rSolidId;
|
|
456
456
|
}, solidId, ...bodies);
|
package/build/types/history.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BooleanOperationType, ChamferType, FlipType, ReorientedType, WorkAxisType, WorkCoordSystemType, WorkPlaneType, WorkPointType, ViewType, ExtrusionType, WorkGeomType, SVGModusType, LimitsParam, DimensionParam, LimitedValue } from '@buerli.io/classcad';
|
|
2
|
-
import { DrawingID,
|
|
1
|
+
import { BooleanOperationType, ChamferType, FlipType, ReorientedType, WorkAxisType, WorkCoordSystemType, WorkPlaneType, WorkPointType, ViewType, ExtrusionType, WorkGeomType, SVGModusType, LimitsParam, DimensionParam, LimitedValue, GraphicType, ObjectID, ObjectIdent } from '@buerli.io/classcad';
|
|
2
|
+
import { DrawingID, InteractionInfo, GeometryElement, DrawingState, BuerliState } from '@buerli.io/core';
|
|
3
3
|
import { BufferGeometry, Material, Object3D, Scene } from 'three';
|
|
4
4
|
/**
|
|
5
5
|
* History based modeling is similar to solid modeling, but it is non-destructive and
|
package/build/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { History, history } from './history';
|
|
|
2
2
|
import { Solid, solid, createPolyline } from './solid';
|
|
3
3
|
export { Solid, solid, History, history, createPolyline };
|
|
4
4
|
export { init, BooleanOperationType, ChamferType, DataType, FlipType, ReorientedType, WorkAxisType, WorkCoordSystemType, WorkPlaneType, WorkPointType, ViewType, OrientationType, ExtrusionType, SVGModusType, } from '@buerli.io/classcad';
|
|
5
|
-
export { GraphicType, ContainerType, MeshTypes, EdgeTypes, CurveTypes, EntityTypes, PointTypes } from '@buerli.io/
|
|
5
|
+
export { GraphicType, ContainerType, MeshTypes, EdgeTypes, CurveTypes, EntityTypes, PointTypes, } from '@buerli.io/classcad';
|
|
6
6
|
/**
|
|
7
7
|
* Because babel typescript tools can not handle the type definitions
|
|
8
8
|
* in an other way, they have to be re-exported as you can see in this code region.
|
package/build/types/solid.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ObjectID } from '@buerli.io/classcad';
|
|
2
|
+
import { BuerliState, DrawingID, DrawingState } from '@buerli.io/core';
|
|
2
3
|
import { BufferGeometry, Scene, Vector3 } from 'three';
|
|
3
4
|
/**
|
|
4
5
|
* A simple and intuitive javascript based api that incorporates solid operations like
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buerli.io/headless",
|
|
3
|
-
"version": "0.13.1-beta.
|
|
3
|
+
"version": "0.13.1-beta.7.apiversion",
|
|
4
4
|
"description": "A non-manifold CAD workflow for the web",
|
|
5
5
|
"author": "AWV Informatik AG <info@awv-informatik.ch>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"three-stdlib": ">=2.11.0"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@buerli.io/classcad": "0.13.1-beta.
|
|
35
|
+
"@buerli.io/classcad": "0.13.1-beta.7.apiversion",
|
|
36
36
|
"flat-promise": "^1.0.3"
|
|
37
37
|
}
|
|
38
38
|
}
|