@buerli.io/headless 0.0.34 → 0.0.35-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/history.d.ts +31 -4
- package/build/history.js +42 -13
- package/build/index.d.ts +2 -1
- package/package.json +2 -2
package/build/history.d.ts
CHANGED
|
@@ -53,6 +53,18 @@ export declare type ApiHistory = {
|
|
|
53
53
|
* @image /doc/assets/history/addNode.jpg
|
|
54
54
|
*/
|
|
55
55
|
addNode: (productId: VID, ownerId: VID, transformation: Transform, name?: string) => ID;
|
|
56
|
+
/**
|
|
57
|
+
* Adds multiple products as nodes to an existing assembly at once
|
|
58
|
+
* @param nodes array of node parameter objects. See also addNode().
|
|
59
|
+
* @example // tbd
|
|
60
|
+
* @image // tbd
|
|
61
|
+
*/
|
|
62
|
+
addNodes: (...nodes: {
|
|
63
|
+
productId: number;
|
|
64
|
+
ownerId: number;
|
|
65
|
+
transformation: Transform;
|
|
66
|
+
name?: string;
|
|
67
|
+
}[]) => IDs;
|
|
56
68
|
/**
|
|
57
69
|
* Creates a boolean operation.
|
|
58
70
|
* @param partId id of the part where the operation will be created on
|
|
@@ -326,10 +338,15 @@ export declare type ApiHistory = {
|
|
|
326
338
|
/**
|
|
327
339
|
* Creates ThreeJS scene from current product
|
|
328
340
|
* @param productId id of the product to create scene from
|
|
341
|
+
* @param options optional object to define different settings.
|
|
342
|
+
* @param meshPerFace boolean flag to define if a part/solid will have a mesh for each face
|
|
343
|
+
* or if the faces will be combined to one mesh
|
|
329
344
|
* @example // tbd
|
|
330
345
|
* @image // tbd
|
|
331
346
|
*/
|
|
332
|
-
createScene: (productId: VID
|
|
347
|
+
createScene: (productId: VID, options?: {
|
|
348
|
+
meshPerFace?: boolean;
|
|
349
|
+
}) => Promise<Scene>;
|
|
333
350
|
/**
|
|
334
351
|
* Creates one or more expressions.
|
|
335
352
|
* @param partId id of part where to create the expression
|
|
@@ -660,7 +677,7 @@ export declare type ApiHistory = {
|
|
|
660
677
|
* @example // tbd
|
|
661
678
|
* @image // tbd
|
|
662
679
|
*/
|
|
663
|
-
load: (content: ArrayBuffer, type: DataTypes) => Promise<number | null>;
|
|
680
|
+
load: (content: ArrayBuffer, type: DataTypes) => Promise<number[] | null>;
|
|
664
681
|
/**
|
|
665
682
|
* Loads a product into the current drawing.
|
|
666
683
|
* @param content data as arraybuffer
|
|
@@ -672,7 +689,7 @@ export declare type ApiHistory = {
|
|
|
672
689
|
* return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
|
|
673
690
|
* @image // tbd
|
|
674
691
|
*/
|
|
675
|
-
loadProduct: (content: ArrayBuffer, type: DataTypes) => Promise<number | null>;
|
|
692
|
+
loadProduct: (content: ArrayBuffer, type: DataTypes) => Promise<number[] | null>;
|
|
676
693
|
/**
|
|
677
694
|
* Creates a new feature and appends geometry to it. This method can be used to import specific geometry
|
|
678
695
|
* which can be used for further operations like boolean, translations and so on.
|
|
@@ -692,6 +709,16 @@ export declare type ApiHistory = {
|
|
|
692
709
|
* @image // tbd
|
|
693
710
|
*/
|
|
694
711
|
removeNode: (referenceId: ObjectID, ownerId: ObjectID) => Promise<void>;
|
|
712
|
+
/**
|
|
713
|
+
* Removes multiple nodes from an assembly node at once
|
|
714
|
+
* @param nodes array of node parameter objects. See also removeNode().
|
|
715
|
+
* @example // tbd
|
|
716
|
+
* @image // tbd
|
|
717
|
+
*/
|
|
718
|
+
removeNodes: (...nodes: {
|
|
719
|
+
referenceId: number;
|
|
720
|
+
ownerId: number;
|
|
721
|
+
}[]) => Promise<void>;
|
|
695
722
|
/**
|
|
696
723
|
* Translates a feature along a given axis.
|
|
697
724
|
* @param partId id ot the part where features will be translated
|
|
@@ -763,7 +790,7 @@ declare type Point = {
|
|
|
763
790
|
y: number;
|
|
764
791
|
z: number;
|
|
765
792
|
};
|
|
766
|
-
declare type Transform = [Point, Point, Point];
|
|
793
|
+
export declare type Transform = [Point, Point, Point];
|
|
767
794
|
declare type BooleanTypes = 'Union' | 'Subtraction' | 'Intersection';
|
|
768
795
|
declare type WCSTypes = 'XYAxisOrigin' | 'Custom';
|
|
769
796
|
declare type WATypes = 'Custom' | 'WorkPoints' | 'PointAndDirection' | 'SketchLine' | 'Curve' | '2Points' | '2Planes';
|
package/build/history.js
CHANGED
|
@@ -184,7 +184,7 @@ const createRecursiveBufferGeometry = async (object, drawingId, bufferGeomArray)
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
};
|
|
187
|
-
const createRecursiveScene = async (object, drawingId, root) => {
|
|
187
|
+
const createRecursiveScene = async (object, drawingId, root, options) => {
|
|
188
188
|
let cDrawing = getDrawing(drawingId);
|
|
189
189
|
const tree = cDrawing.structure.tree;
|
|
190
190
|
if (object.link || object.solids) {
|
|
@@ -204,15 +204,27 @@ const createRecursiveScene = async (object, drawingId, root) => {
|
|
|
204
204
|
meshes = [...meshes, ...cachedSolid.meshes.map(m => m)];
|
|
205
205
|
}
|
|
206
206
|
if (meshes.length > 0) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
207
|
+
if (options === null || options === void 0 ? void 0 : options.meshPerFace) {
|
|
208
|
+
const part = new Group();
|
|
209
|
+
part.matrix = MathUtils.convertToMatrix4(object.coordinateSystem);
|
|
210
|
+
part.matrixAutoUpdate = false;
|
|
211
|
+
part.userData = { id: object.id };
|
|
212
|
+
part.name = object.name;
|
|
213
|
+
for (const mesh of meshes) {
|
|
214
|
+
part.add(new Mesh(mesh.geometry, new MeshStandardMaterial({ color: mesh.color, transparent: mesh.opacity < 1, opacity: mesh.opacity })));
|
|
215
|
+
}
|
|
216
|
+
root.add(part);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
const mesh = new Mesh();
|
|
220
|
+
mesh.matrix = MathUtils.convertToMatrix4(object.coordinateSystem);
|
|
221
|
+
mesh.matrixAutoUpdate = false;
|
|
222
|
+
mesh.userData = { id: object.id };
|
|
223
|
+
mesh.name = object.name;
|
|
224
|
+
mesh.geometry = BufferGeometryUtils.mergeBufferGeometries(meshes.map(m => m.geometry));
|
|
225
|
+
mesh.material = new MeshStandardMaterial();
|
|
226
|
+
root.add(mesh);
|
|
214
227
|
}
|
|
215
|
-
root.add(part);
|
|
216
228
|
}
|
|
217
229
|
}
|
|
218
230
|
}
|
|
@@ -226,7 +238,7 @@ const createRecursiveScene = async (object, drawingId, root) => {
|
|
|
226
238
|
root.add(assembly);
|
|
227
239
|
for (const child of object.children) {
|
|
228
240
|
if (tree[child].class === CCClasses.CCProductReference || tree[child].class === CCClasses.CCProductReferenceET) {
|
|
229
|
-
await createRecursiveScene(tree[child], drawingId, assembly);
|
|
241
|
+
await createRecursiveScene(tree[child], drawingId, assembly, options);
|
|
230
242
|
}
|
|
231
243
|
}
|
|
232
244
|
}
|
|
@@ -251,10 +263,18 @@ export default class CAD {
|
|
|
251
263
|
const publicApi = {
|
|
252
264
|
addNode: (productId, ownerId, transformation, name) => {
|
|
253
265
|
return this.resolve(async ([rProductId, rOwnerId]) => {
|
|
254
|
-
ccAPI.assemblyBuilder.setCurrentNode(drawingId, rOwnerId);
|
|
255
266
|
return ccAPI.assemblyBuilder.addNode(drawingId, rProductId, rOwnerId, transformation, name);
|
|
256
267
|
}, productId, ownerId);
|
|
257
268
|
},
|
|
269
|
+
addNodes: (...nodes) => {
|
|
270
|
+
return this.resolve(async ([]) => {
|
|
271
|
+
const nodesToAdd = [];
|
|
272
|
+
nodes.forEach(node => {
|
|
273
|
+
nodesToAdd.push([node.productId, node.ownerId, node.transformation, node.name]);
|
|
274
|
+
});
|
|
275
|
+
return ccAPI.assemblyBuilder.addNodes(drawingId, nodesToAdd);
|
|
276
|
+
});
|
|
277
|
+
},
|
|
258
278
|
boolean: (partId, type, entities) => {
|
|
259
279
|
return this.resolve(async ([rPartId, ...rEntities]) => {
|
|
260
280
|
const cDrawing = await getDrawing(drawingId);
|
|
@@ -418,7 +438,7 @@ export default class CAD {
|
|
|
418
438
|
}
|
|
419
439
|
return undefined;
|
|
420
440
|
},
|
|
421
|
-
createScene: async (objectId) => {
|
|
441
|
+
createScene: async (objectId, options) => {
|
|
422
442
|
await this.queue;
|
|
423
443
|
this.queue = Promise.resolve(0);
|
|
424
444
|
const rObjectId = await objectId;
|
|
@@ -427,7 +447,7 @@ export default class CAD {
|
|
|
427
447
|
const scene = new Scene();
|
|
428
448
|
if (rObjectId != null) {
|
|
429
449
|
const rootObj = structureTree[rObjectId];
|
|
430
|
-
await createRecursiveScene(rootObj, drawingId, scene);
|
|
450
|
+
await createRecursiveScene(rootObj, drawingId, scene, options);
|
|
431
451
|
}
|
|
432
452
|
return scene;
|
|
433
453
|
},
|
|
@@ -653,6 +673,15 @@ export default class CAD {
|
|
|
653
673
|
await ccAPI.assemblyBuilder.removeNode(drawingId, rReferenceId, rOwnerId);
|
|
654
674
|
}, referenceId, ownerId);
|
|
655
675
|
},
|
|
676
|
+
removeNodes: (...nodes) => {
|
|
677
|
+
return this.resolve(async ([]) => {
|
|
678
|
+
const nodesToRemove = [];
|
|
679
|
+
nodes.forEach(node => {
|
|
680
|
+
nodesToRemove.push([node.referenceId, node.ownerId]);
|
|
681
|
+
});
|
|
682
|
+
return ccAPI.assemblyBuilder.removeNodes(drawingId, nodesToRemove);
|
|
683
|
+
});
|
|
684
|
+
},
|
|
656
685
|
importFeature: (partId, content, format, name) => {
|
|
657
686
|
return this.resolve(async ([rPartId]) => {
|
|
658
687
|
const featureName = name ? name : 'Import';
|
package/build/index.d.ts
CHANGED
|
@@ -7,9 +7,10 @@ export { solid, history, createPolyline };
|
|
|
7
7
|
*
|
|
8
8
|
* Please have a look at https://github.com/awv-informatik/buerli/pull/129 for more information.
|
|
9
9
|
*/
|
|
10
|
-
import { ApiHistory as ApiHistory1, ConstraintType as ConstraintType1 } from './history';
|
|
10
|
+
import { ApiHistory as ApiHistory1, ConstraintType as ConstraintType1, Transform as Transform1 } from './history';
|
|
11
11
|
export declare type ApiHistory = ApiHistory1;
|
|
12
12
|
export declare type ConstraintType = ConstraintType1;
|
|
13
|
+
export declare type Transform = Transform1;
|
|
13
14
|
import { ApiNoHistory as ApiNoHistory1, FilletPoint as FilletPoint1, Polyline as Polyline1 } from './solid';
|
|
14
15
|
export declare type ApiNoHistory = ApiNoHistory1;
|
|
15
16
|
export declare type Polyline = Polyline1;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buerli.io/headless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35-beta.3",
|
|
4
4
|
"description": "A non-manifold CAD workflow for the web",
|
|
5
5
|
"author": "AWV Informatik AG <info@awv-informatik.ch>",
|
|
6
6
|
"repository": {},
|
|
@@ -51,6 +51,6 @@
|
|
|
51
51
|
"three": ">=0.128"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@buerli.io/classcad": "0.0.
|
|
54
|
+
"@buerli.io/classcad": "0.0.35-beta.3"
|
|
55
55
|
}
|
|
56
56
|
}
|