@buerli.io/headless 1.0.1 → 1.1.0-beta.8

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.
@@ -1,524 +1,524 @@
1
- import { ObjectID } from '@buerli.io/classcad';
2
- import { BuerliState, DrawingID, DrawingState } from '@buerli.io/core';
3
- import { BufferGeometry, Scene, Vector3 } from 'three';
4
- /**
5
- * @deprecated replaced by @see BuerliCadFacade in buerli.io/classcad
6
- *
7
- * A simple and intuitive javascript based api that incorporates solid operations like
8
- * shapes, booleans (unions, subtracts, intersections), extrusions, revolves, blends,
9
- * chamfers, slices, arrays, patterns, offsets, etc. The api is compatible with THREEJS
10
- * and understands some of its primitives like curves and paths.
11
- *
12
- * ```sh
13
- * npm install @buerli.io/headless
14
- * ```
15
- *
16
- * ```js
17
- * import { init, Solid } from '@buerli.io/headless'
18
- *
19
- * init('ws://localhost:9091')
20
- * const cad = new Solid()
21
- * cad.init(async api => {
22
- * // Your code goes here
23
- * })
24
- * ```
25
- */
26
- export declare type ApiNoHistory = {
27
- /**
28
- * Returns the drawing id of the current headless-session
29
- * @returns DrawingID
30
- * @example
31
- * const drawingId = api.getDrawingId()
32
- */
33
- getDrawingId: () => DrawingID;
34
- /**
35
- * Returns the drawing of the current headless-session
36
- * @returns DrawingState
37
- * @example
38
- * const drawing = api.getDrawing()
39
- * // Get all graphic containers
40
- * const containers = Object.values(drawing.graphic.containers)
41
- * containers.forEach(container => {
42
- * // Get all surfaces
43
- * const surfaces = container.meshes.map(mesh => mesh.properties.surface)
44
- * // Filter non cylindric
45
- * const cylinders = surfaces.filter(surface => surface.type === 'cylinder')
46
- * // Check if all cylinders have a radius greater than 4
47
- * cylinders.forEach(meta => expect(meta.radius).toBeGreaterThanOrEqual(4))
48
- * })
49
- */
50
- getDrawing: () => DrawingState;
51
- /**
52
- * Returns the state tree of the current headless-session
53
- * @returns BuerliState
54
- * @example
55
- * const state = api.getState()
56
- */
57
- getState: () => BuerliState;
58
- /**
59
- * Sets the global faceting parameters that will stick for this drawing.
60
- * This defines how detailed solids will be displayed and can yield smaller payloads.
61
- * @param distanceTol distance tolerance
62
- * @param angleTol angle tolerance
63
- * @returns void
64
- * @example
65
- * api.setFacetingParameters(0.1, 0)
66
- */
67
- setFacetingParameters: (distanceTol: number, angleTol: number) => Promise<void>;
68
- /**
69
- * Creates a simple box.
70
- * @param length length of the box (x-axis)
71
- * @param width width of the box (y-axis)
72
- * @param height height of the box (z-axis)
73
- * @example
74
- * // Creates a box with length = 10, width = 25 and height = 15
75
- * const boxId = api.box(10,25,15)
76
- * const geom = await api.createBufferGeometry(boxId)
77
- * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
78
- * @image /doc/assets/solid/box.jpg
79
- */
80
- box: (length: number, width: number, height: number) => ID;
81
- /**
82
- * Clears all existing solids in the drawing.
83
- * @example
84
- * // Clears all solids
85
- * const boxId = api.box(10,25,15)
86
- * const coneId = api.cone(50,20,10)
87
- * api.clearSolids()
88
- * @image // tbd
89
- */
90
- clearSolids: () => Promise<void>;
91
- /**
92
- * Clears the target solid in the drawing.
93
- * @param solidId id of the solid to be deleted
94
- * @example
95
- * // Clear a specific solid
96
- * const boxId = api.box(10,25,15)
97
- * const coneId = api.cone(50,20,10)
98
- * api.clearSolid(boxId)
99
- * const geom = await api.createBufferGeometry(coneId)
100
- * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
101
- * @image // tbd
102
- */
103
- clearSolid: (solidId: VID) => Promise<void>;
104
- /**
105
- * Creates a simple cone.
106
- * @param height height of the cone (z-axis)
107
- * @param diameter1 diameter at the bottom of the cone
108
- * @param diameter2 diameter at the top of the cone
109
- * @example
110
- * // Creates a cone with height = 50, diameter1 = 20 and diameter2 = 10
111
- * const coneId = api.cone(50,20,10)
112
- * const geom = await api.createBufferGeometry(coneId)
113
- * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
114
- * @image /doc/assets/solid/cone.jpg
115
- */
116
- cone: (height: number, diameter1: number, diameter2: number) => ID;
117
- /**
118
- * Creates a copy of the solid.
119
- * @param solidId id of the solid to create a copy from
120
- * @example
121
- * // Creates a copy of a solid
122
- * const coneId = api.cone(50,20,10)
123
- * const copyId = api.copy(coneId)
124
- * api.rotateTo(copyId, [Math.PI / 2, 0, 0])
125
- * const unionId = api.union(coneId, false, copyId)
126
- * const geom = await api.createBufferGeometry(unionId)
127
- * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
128
- * @image /doc/assets/solid/copy.jpg
129
- */
130
- copy: (solidId: VID) => ID;
131
- /**
132
- * Creates the buffer geometry of the solid.
133
- * @param solidId id of the solid to create buffer geometry from
134
- * @example
135
- * // Creates the buffer geometry
136
- * const coneId = api.cone(50,20,10)
137
- * const boxId = api.box(10,25,15)
138
- * const unionId = api.union(coneId, false, boxId)
139
- * const geom = await api.createBufferGeometry(coneId)
140
- * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
141
- * @image // tbd
142
- */
143
- createBufferGeometry: (solidId: VID) => Promise<BufferGeometry | undefined>;
144
- /**
145
- * Creates ThreeJS scene from the given solids.
146
- * @param solids ids of the solids to create scene from
147
- * @param options optional object to define different settings.
148
- * @param meshPerGeometry boolean flag to define if the solids will have a mesh for each geometry element
149
- * or if the geometries will be combined to one mesh
150
- * @example // tbd
151
- * @image // tbd
152
- */
153
- createScene: (solids: VID[], options?: {
154
- meshPerGeometry?: boolean;
155
- }) => Promise<{
156
- scene: Scene;
157
- part: THREE.Group;
158
- solids: THREE.Group[];
159
- meshes: THREE.Mesh[];
160
- }>;
161
- /**
162
- * Creates a simple cylinder.
163
- * @param height height of the cylinder (z-axis)
164
- * @param diameter diamter of the cylinder
165
- * @example
166
- * // Creates a cylinder with height = 50 and diameter = 10
167
- * const cylinderId = api.cylinder(50,10)
168
- * const geom = await api.createBufferGeometry(cylinderId)
169
- * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
170
- * @image /doc/assets/solid/cylinder.jpg
171
- */
172
- cylinder: (height: number, diameter: number) => ID;
173
- /**
174
- * Returns all adjacent edges of a face or vertex
175
- * @param breps face or vertex ids to get the adjacent edges from
176
- * @example
177
- * // Returns all edges from the top surface of box and adds a fillet on them
178
- * const boxId = api.box(10, 25, 15)
179
- * const surface = api.pick(boxId, 'face', [0, 0, 7.5])
180
- * const edges = api.edgeLoops(surface)
181
- * api.fillet(2, edges)
182
- * const geom = await api.createBufferGeometry(boxId)
183
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
184
- * @image /doc/assets/solid/edgeLoops.jpg
185
- */
186
- edgeLoops: (breps: VIDs) => IDs;
187
- /**
188
- * Writes the current solid or specific solids to a stream in stp data format
189
- * and returns the data.
190
- * @param solidIds [optional] specific solidIds to write to stream
191
- * @example
192
- * // Writes the unified solid to stream
193
- * const coneId = api.cone(50,20,10)
194
- * const boxId = api.box(10,25,15)
195
- * const unionId = api.union(coneId, false, boxId)
196
- * const data = api.export()
197
- * const geom = await api.createBufferGeometry(coneId)
198
- * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
199
- * @image // tbd
200
- */
201
- export: (solidIds?: VIDs) => Promise<Uint8Array | null>;
202
- /**
203
- * The solid is extended at the defined plane with a solid created by extruding the section defined by the plane.
204
- * @param solidId id of the solid which will be extended
205
- * @param point position of plane
206
- * @param normal normal vector of plane
207
- * @param distance distance of extension
208
- * @example
209
- * // Extends the sphere in its center
210
- * const sphereId = api.sphere(10)
211
- * api.extendSolidAtPlane(sphereId, [0, 0, 0], [0, 1, 1], 50)
212
- * const geom = await api.createBufferGeometry(sphereId)
213
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
214
- * @image /doc/assets/solid/extendSolidAtPlane.jpg
215
- */
216
- extendSolidAtPlane: (target: VID, point: Vec, normal: Vec, distance: number) => Promise<void>;
217
- /**
218
- * Creates an extrusion.
219
- * @param height height of extrusion
220
- * @param region region which will be extruded, defined by Polyline or THREE.Shape
221
- * @example
222
- * // Extrudes a heart from THREE shape
223
- * const shape = new THREE.Shape()
224
- * shape.moveTo(25, 25)
225
- * shape.bezierCurveTo(25, 25, 20, 0, 0, 0)
226
- * shape.bezierCurveTo(-30, 0, -30, 35, -30, 35)
227
- * shape.bezierCurveTo(-30, 55, -10, 77, 25, 95)
228
- * shape.bezierCurveTo(60, 77, 80, 55, 80, 35)
229
- * shape.bezierCurveTo(80, 35, 80, 0, 50, 0)
230
- * shape.bezierCurveTo(35, 0, 25, 25, 25, 25)
231
- * const heartId = api.extrude([0, 0, 5], shape)
232
- * api.rotateTo(heartId, [Math.PI, 0, 0])
233
- * const geom = await api.createBufferGeometry(heartId)
234
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
235
- * @image /doc/assets/solid/extrude.jpg
236
- */
237
- extrude: (height: Vec, region: Polyline | THREE.Shape) => ID;
238
- /**
239
- * Creates a fillet at the given edges
240
- * @param radius radius of the fillet
241
- * @param edges edges to create fillets on
242
- * @example
243
- * // Creates a fillet with radius = 2 at the given edge
244
- * const boxId = api.box(10, 25, 15)
245
- * const edge = api.pick(boxId, 'edge', [5, 0, 7.5])
246
- * api.fillet(2, edge)
247
- * const geom = await api.createBufferGeometry(boxId)
248
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
249
- * @image /doc/assets/solid/fillet.jpg
250
- */
251
- fillet: (radius: number, edges: VIDs) => ID;
252
- /**
253
- * Loads an arraybuffer in stp file format. All solids existing
254
- * in stp data will be returned in an array. Current drawing will not
255
- * be overwritten, imports will just be added.
256
- * @param data data as arraybuffer in stp format
257
- * @example
258
- * // Imports a stp file
259
- * const importIds = await api.import(arraybuffer)
260
- * const geom = await api.createBufferGeometry(importIds[0])
261
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
262
- * @image // tbd
263
- */
264
- import: (data: ArrayBuffer) => IDs;
265
- /**
266
- * Creates an intersection between solid and bodies.
267
- * @param solidId id of the solid to intersect
268
- * @param keepSolid if true, the solid will be kept and can be used again
269
- * @param bodies bodies to intersect with the solid
270
- * @example
271
- * // Creates an intersection between a sphere and a cylinder
272
- * const sphereId = api.sphere(20)
273
- * const cylinderId = api.cylinder(50, 30)
274
- * const intersectId = api.intersect(sphereId, false, cylinderId)
275
- * const geom = await api.createBufferGeometry(intersectId)
276
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
277
- * @image /doc/assets/solid/intersect.jpg
278
- */
279
- intersect: (solidId: VID, keepSolid: boolean, ...bodies: VID[]) => ID;
280
- /**
281
- * Loads an arraybuffer in native file format. Native file format
282
- * is 'ofb', if you want to load 'stp' file formats, use import function.
283
- * Current drawing will be overwritten by loaded data.
284
- * @param data data as arraybuffer in ofb format
285
- * @example // tbd
286
- * @image // tbd
287
- */
288
- load: (data: ArrayBuffer) => IDs;
289
- /**
290
- * Mirrors the solid at the specified plane.
291
- * @param point position of the mirror plane
292
- * @param normal normal vector of the mirror plane
293
- * @example
294
- * // Mirrors the cone at its bottom surface
295
- * const coneId1 = api.cone(50, 20, 0)
296
- * api.mirror(coneId1, [0, 0, -25], [0, 0, 1])
297
- * const coneId2 = api.cone(50, 20, 0)
298
- * const unionId = api.union(coneId1, false, coneId2)
299
- * const geom = await api.createBufferGeometry(unionId)
300
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
301
- * @image /doc/assets/solid/mirror.jpg
302
- */
303
- mirror: (solidId: VID, point: Vec, normal: Vec) => Promise<void>;
304
- /**
305
- * Moves the solid to the given position.
306
- * @param solidId id of the solid which will be moved
307
- * @param position position to move the solid to
308
- * @example
309
- * // Moves the second box to the first box's corner
310
- * const boxId1 = api.box(20, 20, 20)
311
- * const boxId2 = api.box(20, 20, 20)
312
- * api.moveTo(boxId1, [10, 10, 10])
313
- * const unionId = api.union(boxId1, false, boxId2)
314
- * const geom = await api.createBufferGeometry(unionId)
315
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
316
- * @image /doc/assets/solid/moveTo.jpg
317
- */
318
- moveTo: (solidId: VID, position: Vec) => Promise<void>;
319
- /**
320
- * Creates an offset of the solid.
321
- * @param solidId solid which becomes an offset
322
- * @param offsetDistance distance of offset
323
- * @example
324
- * // Creates an offset on the box
325
- * const boxId1 = api.box(20, 20, 20)
326
- * api.offset(boxId1, 2)
327
- * const geom = await api.createBufferGeometry(boxId1)
328
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
329
- * @image /doc/assets/solid/offset.jpg
330
- */
331
- offset: (solidId: VID, offsetDistance: number) => ID;
332
- /**
333
- * Returns all edges or faces depending on type which matches the points.
334
- * @param solidId id of the solid to look for edges and faces
335
- * @param type type of geometry to look for --> 'edge' or 'face'
336
- * @param points points where edges and faces will be expected
337
- * @example
338
- * // Pick does look for an edge at point [5,0,7.5] and adds a fillet on it if found the edge
339
- * const boxId = api.box(10, 25, 15)
340
- * const edge = api.pick(boxId, 'edge', [5, 0, 7.5])
341
- * api.fillet(2, edge)
342
- * const geom = await api.createBufferGeometry(boxId)
343
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
344
- * @image /doc/assets/solid/pick.jpg
345
- */
346
- pick: (solidId: VID, type: 'vertex' | 'edge' | 'face', ...points: Vec[]) => IDs;
347
- /**
348
- * Revolves the given region.
349
- * @param position position of rotation axis
350
- * @param direction direction of rotation axis
351
- * @param angle angle of rotation in rad
352
- * @param region region which will be revolved, defined by Polyline or THREE.Shape
353
- * @example
354
- * // Creates a closed polyline from three points and revolves it
355
- * const fp0 = { point: new THREE.Vector3(20, 20, 0), radius: 4 }
356
- * const fp1 = { point: new THREE.Vector3(40, 0, 0), radius: 2 }
357
- * const fp2 = { point: new THREE.Vector3(0, 0, 0), radius: 2 }
358
- * const polyline = createPolyline([fp0, fp1, fp2])
359
- * const revolveId = api.revolve([-10, 0, 0], [0, 1, 0], 2 * Math.PI, polyline)
360
- * const geom = await api.createBufferGeometry(revolveId)
361
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
362
- * @image /doc/assets/solid/revolve.jpg
363
- */
364
- revolve: (position: Vec, direction: Vec, angle: number, region: Polyline | THREE.Shape) => ID;
365
- /**
366
- * Rotates the given solid.
367
- * @param solidId id of the solid to rotate
368
- * @param rotationVec vector of rotation around x-, y- and z-axis
369
- * @example
370
- * // Creates a box and rotates it around its x- and z-axis
371
- * const boxId = api.box(10, 10, 10)
372
- * api.rotateTo(boxId, [Math.PI / 4, 0, Math.PI / 4])
373
- * const geom = await api.createBufferGeometry(boxId)
374
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
375
- * @image /doc/assets/solid/rotateTo.jpg
376
- */
377
- rotateTo: (solidId: VID, rotationVec: Vec) => Promise<void>;
378
- /**
379
- * Writes the current drawing as native file format to a stream and returns the data.
380
- * Native file is 'ofb', for 'stp' file format use export method.
381
- *
382
- * Important notes about the ofb format:
383
- * - It contains binary geometry blocks.
384
- * - Do not try to convert it to text, the geometry blocks will get damaged!
385
- *
386
- * @example
387
- * // Creates a rotated box and gets the ofb data.
388
- * const boxId = api.box(10, 10, 10)
389
- * api.rotateTo(boxId, [Math.PI / 4, 0, Math.PI / 4])
390
- * const data = api.save()
391
- *
392
- * @image // tbd
393
- */
394
- save: () => Promise<Uint8Array | null>;
395
- /**
396
- * Scales the solid in all or specified axis.
397
- * @param solidId id of the solid to scale
398
- * @param vectorOrFactor if factor is defined, the solid will be scaled in all direction with same scale value. Otherwise in the given x, y and z direction of the vector.
399
- * @example
400
- * // Creates a box and scales it in x-axis
401
- * const boxId = api.box(10, 10, 10)
402
- * api.scale(boxId, [2, 1, 1])
403
- * const geom = await api.createBufferGeometry(boxId)
404
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
405
- * @image /doc/assets/solid/scale.jpg
406
- */
407
- scale: (solidId: VID, vectorOrFactor: Vec | number) => Promise<void>;
408
- /**
409
- * Sets the faceting parameters of graphic objects. This defines how detailed solids will be displayed.
410
- * @param distanceTol tolerated distance between theoretic and tesselated arc
411
- * @param angleTol tolerated angle between normal vectors of faces which build an arc
412
- * @example
413
- * // Creates a cylinder with low tessellation
414
- * api.setFacetingParams(0.5, 0)
415
- * const cylinderId = api.cylinder(50, 20)
416
- * const geom = await api.createBufferGeometry(cylinderId)
417
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
418
- * @image /doc/assets/solid/setFacetingParams.jpg
419
- */
420
- setFacetingParams: (distanceTol: number, angleTol: number) => ID;
421
- /**
422
- * Slices the solid at specified plane. Part of solid which is on the positive side of defined plane will be removed.
423
- * @param solidId id of solid to slice
424
- * @param point position of plane
425
- * @param normal normal vector of plane
426
- * @example
427
- * // Creates a sphere and slice it
428
- * const sphereId = api.sphere(20)
429
- * api.slice(sphereId, [10, 10, 0], [1, 1, 0])
430
- * const geom = await api.createBufferGeometry(sphereId)
431
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
432
- * @image /doc/assets/solid/slice.jpg
433
- */
434
- slice: (solidId: VID, point: Vec, normal: Vec) => Promise<void>;
435
- /**
436
- * Creates a simple sphere.
437
- * @param radius radius of the sphere
438
- * @example
439
- * // Creates a sphere with radius = 10
440
- * const sphereId = api.sphere(10)
441
- * const geom = await api.createBufferGeometry(sphereId)
442
- * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
443
- * @image /doc/assets/solid/sphere.jpg
444
- */
445
- sphere: (radius: number) => ID;
446
- /**
447
- * Creates a subtraction between solid and bodies.
448
- * @param solidId id of the solid to subtract
449
- * @param keepSolid if true, the solid will be kept and can be used again
450
- * @param bodies bodies to subtract from the solid
451
- * @example
452
- * // Subtracts a box from sphere after
453
- * const sphereId = api.sphere(20)
454
- * const boxId = api.box(20, 20, 20)
455
- * api.moveTo(boxId, [10, 10, 10])
456
- * const subId = api.subtract(sphereId, false, boxId)
457
- * const geom = await api.createBufferGeometry(subId)
458
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
459
- * @image /doc/assets/solid/subtract.jpg
460
- */
461
- subtract: (solidId: VID, keepSolid: boolean, ...bodies: VID[]) => ID;
462
- /**
463
- * Creates an union between solid and bodies.
464
- * @param solidId id of the solid to unify
465
- * @param keepSolid if true, the solid will be kept and can be used again
466
- * @param bodies bodies to unify with the solid
467
- * @example
468
- * // Unifies a sphere with a cone
469
- * const sphereId = api.sphere(20)
470
- * const coneId = api.cone(50, 40, 0)
471
- * api.moveTo(coneId, [0, 0, 25])
472
- * const unionId = api.union(sphereId, false, coneId)
473
- * const geom = await api.createBufferGeometry(unionId)
474
- * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
475
- * @image /doc/assets/solid/union.jpg
476
- */
477
- union: (solidId: VID, keepSolid: boolean, ...bodies: VID[]) => ID;
478
- };
479
- /**
480
- * Creates a polyline from the given fillet points
481
- * @param fPts points of the polyline with its associated fillet radius
482
- * @example
483
- * // Creates a polyline with three points
484
- * const fp0 = { point: new THREE.Vector3(20, 20, 0), radius: 4 }
485
- * const fp1 = { point: new THREE.Vector3(40, 0, 0), radius: 2 }
486
- * const fp2 = { point: new THREE.Vector3(0, 0, 0), radius: 2 }
487
- * const polyline = createPolyline([fp0, fp1, fp2])
488
- */
489
- export declare function createPolyline(fPts: FilletPoint[]): Polyline;
490
- export declare class Solid {
491
- drawingId: DrawingID | null;
492
- queue: Promise<number>;
493
- constructor();
494
- resolve(callback: (...results: any) => Promise<any>, ...args: any[]): Promise<any>;
495
- init(callback: (api: ApiNoHistory) => void): () => Promise<void>;
496
- destroy(): void;
497
- }
498
- export declare class solid extends Solid {
499
- constructor();
500
- }
501
- declare type VID = ObjectID | Promise<ObjectID>;
502
- declare type VIDs = ObjectID[] | Promise<ObjectID[]>;
503
- declare type ID = Promise<ObjectID>;
504
- declare type IDs = Promise<ObjectID[]>;
505
- declare type Vec = number[] | THREE.Vector3 | THREE.Euler;
506
- /**
507
- * Point definition where the fillet will be added with a specified radius.
508
- */
509
- export declare type FilletPoint = {
510
- /** Point where the corner of the polyline will be. */
511
- point: Vector3;
512
- /** Radius of the fillet at the position of point. */
513
- radius: number;
514
- };
515
- /**
516
- * Polyline of points and bulges. Bulges define the arc between the current and the next point.
517
- */
518
- export declare type Polyline = {
519
- /** Points where the corners of the polyline will be. */
520
- points: Vector3[];
521
- /** Bulges which define the arcs. */
522
- bulges: number[];
523
- };
524
- export {};
1
+ import { ObjectID } from '@buerli.io/classcad';
2
+ import { BuerliState, DrawingID, DrawingState } from '@buerli.io/core';
3
+ import { BufferGeometry, Scene, Vector3 } from 'three';
4
+ /**
5
+ * @deprecated replaced by @see BuerliCadFacade in buerli.io/classcad
6
+ *
7
+ * A simple and intuitive javascript based api that incorporates solid operations like
8
+ * shapes, booleans (unions, subtracts, intersections), extrusions, revolves, blends,
9
+ * chamfers, slices, arrays, patterns, offsets, etc. The api is compatible with THREEJS
10
+ * and understands some of its primitives like curves and paths.
11
+ *
12
+ * ```sh
13
+ * npm install @buerli.io/headless
14
+ * ```
15
+ *
16
+ * ```js
17
+ * import { init, Solid } from '@buerli.io/headless'
18
+ *
19
+ * init('ws://localhost:9091')
20
+ * const cad = new Solid()
21
+ * cad.init(async api => {
22
+ * // Your code goes here
23
+ * })
24
+ * ```
25
+ */
26
+ export declare type ApiNoHistory = {
27
+ /**
28
+ * Returns the drawing id of the current headless-session
29
+ * @returns DrawingID
30
+ * @example
31
+ * const drawingId = api.getDrawingId()
32
+ */
33
+ getDrawingId: () => DrawingID;
34
+ /**
35
+ * Returns the drawing of the current headless-session
36
+ * @returns DrawingState
37
+ * @example
38
+ * const drawing = api.getDrawing()
39
+ * // Get all graphic containers
40
+ * const containers = Object.values(drawing.graphic.containers)
41
+ * containers.forEach(container => {
42
+ * // Get all surfaces
43
+ * const surfaces = container.meshes.map(mesh => mesh.properties.surface)
44
+ * // Filter non cylindric
45
+ * const cylinders = surfaces.filter(surface => surface.type === 'cylinder')
46
+ * // Check if all cylinders have a radius greater than 4
47
+ * cylinders.forEach(meta => expect(meta.radius).toBeGreaterThanOrEqual(4))
48
+ * })
49
+ */
50
+ getDrawing: () => DrawingState;
51
+ /**
52
+ * Returns the state tree of the current headless-session
53
+ * @returns BuerliState
54
+ * @example
55
+ * const state = api.getState()
56
+ */
57
+ getState: () => BuerliState;
58
+ /**
59
+ * Sets the global faceting parameters that will stick for this drawing.
60
+ * This defines how detailed solids will be displayed and can yield smaller payloads.
61
+ * @param distanceTol distance tolerance
62
+ * @param angleTol angle tolerance
63
+ * @returns void
64
+ * @example
65
+ * api.setFacetingParameters(0.1, 0)
66
+ */
67
+ setFacetingParameters: (distanceTol: number, angleTol: number) => Promise<void>;
68
+ /**
69
+ * Creates a simple box.
70
+ * @param length length of the box (x-axis)
71
+ * @param width width of the box (y-axis)
72
+ * @param height height of the box (z-axis)
73
+ * @example
74
+ * // Creates a box with length = 10, width = 25 and height = 15
75
+ * const boxId = api.box(10,25,15)
76
+ * const geom = await api.createBufferGeometry(boxId)
77
+ * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
78
+ * @image /doc/assets/solid/box.jpg
79
+ */
80
+ box: (length: number, width: number, height: number) => ID;
81
+ /**
82
+ * Clears all existing solids in the drawing.
83
+ * @example
84
+ * // Clears all solids
85
+ * const boxId = api.box(10,25,15)
86
+ * const coneId = api.cone(50,20,10)
87
+ * api.clearSolids()
88
+ * @image // tbd
89
+ */
90
+ clearSolids: () => Promise<void>;
91
+ /**
92
+ * Clears the target solid in the drawing.
93
+ * @param solidId id of the solid to be deleted
94
+ * @example
95
+ * // Clear a specific solid
96
+ * const boxId = api.box(10,25,15)
97
+ * const coneId = api.cone(50,20,10)
98
+ * api.clearSolid(boxId)
99
+ * const geom = await api.createBufferGeometry(coneId)
100
+ * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
101
+ * @image // tbd
102
+ */
103
+ clearSolid: (solidId: VID) => Promise<void>;
104
+ /**
105
+ * Creates a simple cone.
106
+ * @param height height of the cone (z-axis)
107
+ * @param diameter1 diameter at the bottom of the cone
108
+ * @param diameter2 diameter at the top of the cone
109
+ * @example
110
+ * // Creates a cone with height = 50, diameter1 = 20 and diameter2 = 10
111
+ * const coneId = api.cone(50,20,10)
112
+ * const geom = await api.createBufferGeometry(coneId)
113
+ * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
114
+ * @image /doc/assets/solid/cone.jpg
115
+ */
116
+ cone: (height: number, diameter1: number, diameter2: number) => ID;
117
+ /**
118
+ * Creates a copy of the solid.
119
+ * @param solidId id of the solid to create a copy from
120
+ * @example
121
+ * // Creates a copy of a solid
122
+ * const coneId = api.cone(50,20,10)
123
+ * const copyId = api.copy(coneId)
124
+ * api.rotateTo(copyId, [Math.PI / 2, 0, 0])
125
+ * const unionId = api.union(coneId, false, copyId)
126
+ * const geom = await api.createBufferGeometry(unionId)
127
+ * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
128
+ * @image /doc/assets/solid/copy.jpg
129
+ */
130
+ copy: (solidId: VID) => ID;
131
+ /**
132
+ * Creates the buffer geometry of the solid.
133
+ * @param solidId id of the solid to create buffer geometry from
134
+ * @example
135
+ * // Creates the buffer geometry
136
+ * const coneId = api.cone(50,20,10)
137
+ * const boxId = api.box(10,25,15)
138
+ * const unionId = api.union(coneId, false, boxId)
139
+ * const geom = await api.createBufferGeometry(coneId)
140
+ * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
141
+ * @image // tbd
142
+ */
143
+ createBufferGeometry: (solidId: VID) => Promise<BufferGeometry | undefined>;
144
+ /**
145
+ * Creates ThreeJS scene from the given solids.
146
+ * @param solids ids of the solids to create scene from
147
+ * @param options optional object to define different settings.
148
+ * @param meshPerGeometry boolean flag to define if the solids will have a mesh for each geometry element
149
+ * or if the geometries will be combined to one mesh
150
+ * @example // tbd
151
+ * @image // tbd
152
+ */
153
+ createScene: (solids: VID[], options?: {
154
+ meshPerGeometry?: boolean;
155
+ }) => Promise<{
156
+ scene: Scene;
157
+ part: THREE.Group;
158
+ solids: THREE.Group[];
159
+ meshes: THREE.Mesh[];
160
+ }>;
161
+ /**
162
+ * Creates a simple cylinder.
163
+ * @param height height of the cylinder (z-axis)
164
+ * @param diameter diamter of the cylinder
165
+ * @example
166
+ * // Creates a cylinder with height = 50 and diameter = 10
167
+ * const cylinderId = api.cylinder(50,10)
168
+ * const geom = await api.createBufferGeometry(cylinderId)
169
+ * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
170
+ * @image /doc/assets/solid/cylinder.jpg
171
+ */
172
+ cylinder: (height: number, diameter: number) => ID;
173
+ /**
174
+ * Returns all adjacent edges of a face or vertex
175
+ * @param breps face or vertex ids to get the adjacent edges from
176
+ * @example
177
+ * // Returns all edges from the top surface of box and adds a fillet on them
178
+ * const boxId = api.box(10, 25, 15)
179
+ * const surface = api.pick(boxId, 'face', [0, 0, 7.5])
180
+ * const edges = api.edgeLoops(surface)
181
+ * api.fillet(2, edges)
182
+ * const geom = await api.createBufferGeometry(boxId)
183
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
184
+ * @image /doc/assets/solid/edgeLoops.jpg
185
+ */
186
+ edgeLoops: (breps: VIDs) => IDs;
187
+ /**
188
+ * Writes the current solid or specific solids to a stream in stp data format
189
+ * and returns the data.
190
+ * @param solidIds [optional] specific solidIds to write to stream
191
+ * @example
192
+ * // Writes the unified solid to stream
193
+ * const coneId = api.cone(50,20,10)
194
+ * const boxId = api.box(10,25,15)
195
+ * const unionId = api.union(coneId, false, boxId)
196
+ * const data = api.export()
197
+ * const geom = await api.createBufferGeometry(coneId)
198
+ * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
199
+ * @image // tbd
200
+ */
201
+ export: (solidIds?: VIDs) => Promise<Uint8Array | null>;
202
+ /**
203
+ * The solid is extended at the defined plane with a solid created by extruding the section defined by the plane.
204
+ * @param solidId id of the solid which will be extended
205
+ * @param point position of plane
206
+ * @param normal normal vector of plane
207
+ * @param distance distance of extension
208
+ * @example
209
+ * // Extends the sphere in its center
210
+ * const sphereId = api.sphere(10)
211
+ * api.extendSolidAtPlane(sphereId, [0, 0, 0], [0, 1, 1], 50)
212
+ * const geom = await api.createBufferGeometry(sphereId)
213
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
214
+ * @image /doc/assets/solid/extendSolidAtPlane.jpg
215
+ */
216
+ extendSolidAtPlane: (target: VID, point: Vec, normal: Vec, distance: number) => Promise<void>;
217
+ /**
218
+ * Creates an extrusion.
219
+ * @param height height of extrusion
220
+ * @param region region which will be extruded, defined by Polyline or THREE.Shape
221
+ * @example
222
+ * // Extrudes a heart from THREE shape
223
+ * const shape = new THREE.Shape()
224
+ * shape.moveTo(25, 25)
225
+ * shape.bezierCurveTo(25, 25, 20, 0, 0, 0)
226
+ * shape.bezierCurveTo(-30, 0, -30, 35, -30, 35)
227
+ * shape.bezierCurveTo(-30, 55, -10, 77, 25, 95)
228
+ * shape.bezierCurveTo(60, 77, 80, 55, 80, 35)
229
+ * shape.bezierCurveTo(80, 35, 80, 0, 50, 0)
230
+ * shape.bezierCurveTo(35, 0, 25, 25, 25, 25)
231
+ * const heartId = api.extrude([0, 0, 5], shape)
232
+ * api.rotateTo(heartId, [Math.PI, 0, 0])
233
+ * const geom = await api.createBufferGeometry(heartId)
234
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
235
+ * @image /doc/assets/solid/extrude.jpg
236
+ */
237
+ extrude: (height: Vec, region: Polyline | THREE.Shape) => ID;
238
+ /**
239
+ * Creates a fillet at the given edges
240
+ * @param radius radius of the fillet
241
+ * @param edges edges to create fillets on
242
+ * @example
243
+ * // Creates a fillet with radius = 2 at the given edge
244
+ * const boxId = api.box(10, 25, 15)
245
+ * const edge = api.pick(boxId, 'edge', [5, 0, 7.5])
246
+ * api.fillet(2, edge)
247
+ * const geom = await api.createBufferGeometry(boxId)
248
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
249
+ * @image /doc/assets/solid/fillet.jpg
250
+ */
251
+ fillet: (radius: number, edges: VIDs) => ID;
252
+ /**
253
+ * Loads an arraybuffer in stp file format. All solids existing
254
+ * in stp data will be returned in an array. Current drawing will not
255
+ * be overwritten, imports will just be added.
256
+ * @param data data as arraybuffer in stp format
257
+ * @example
258
+ * // Imports a stp file
259
+ * const importIds = await api.import(arraybuffer)
260
+ * const geom = await api.createBufferGeometry(importIds[0])
261
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
262
+ * @image // tbd
263
+ */
264
+ import: (data: ArrayBuffer) => IDs;
265
+ /**
266
+ * Creates an intersection between solid and bodies.
267
+ * @param solidId id of the solid to intersect
268
+ * @param keepSolid if true, the solid will be kept and can be used again
269
+ * @param bodies bodies to intersect with the solid
270
+ * @example
271
+ * // Creates an intersection between a sphere and a cylinder
272
+ * const sphereId = api.sphere(20)
273
+ * const cylinderId = api.cylinder(50, 30)
274
+ * const intersectId = api.intersect(sphereId, false, cylinderId)
275
+ * const geom = await api.createBufferGeometry(intersectId)
276
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
277
+ * @image /doc/assets/solid/intersect.jpg
278
+ */
279
+ intersect: (solidId: VID, keepSolid: boolean, ...bodies: VID[]) => ID;
280
+ /**
281
+ * Loads an arraybuffer in native file format. Native file format
282
+ * is 'ofb', if you want to load 'stp' file formats, use import function.
283
+ * Current drawing will be overwritten by loaded data.
284
+ * @param data data as arraybuffer in ofb format
285
+ * @example // tbd
286
+ * @image // tbd
287
+ */
288
+ load: (data: ArrayBuffer) => IDs;
289
+ /**
290
+ * Mirrors the solid at the specified plane.
291
+ * @param point position of the mirror plane
292
+ * @param normal normal vector of the mirror plane
293
+ * @example
294
+ * // Mirrors the cone at its bottom surface
295
+ * const coneId1 = api.cone(50, 20, 0)
296
+ * api.mirror(coneId1, [0, 0, -25], [0, 0, 1])
297
+ * const coneId2 = api.cone(50, 20, 0)
298
+ * const unionId = api.union(coneId1, false, coneId2)
299
+ * const geom = await api.createBufferGeometry(unionId)
300
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
301
+ * @image /doc/assets/solid/mirror.jpg
302
+ */
303
+ mirror: (solidId: VID, point: Vec, normal: Vec) => Promise<void>;
304
+ /**
305
+ * Moves the solid to the given position.
306
+ * @param solidId id of the solid which will be moved
307
+ * @param position position to move the solid to
308
+ * @example
309
+ * // Moves the second box to the first box's corner
310
+ * const boxId1 = api.box(20, 20, 20)
311
+ * const boxId2 = api.box(20, 20, 20)
312
+ * api.moveTo(boxId1, [10, 10, 10])
313
+ * const unionId = api.union(boxId1, false, boxId2)
314
+ * const geom = await api.createBufferGeometry(unionId)
315
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
316
+ * @image /doc/assets/solid/moveTo.jpg
317
+ */
318
+ moveTo: (solidId: VID, position: Vec) => Promise<void>;
319
+ /**
320
+ * Creates an offset of the solid.
321
+ * @param solidId solid which becomes an offset
322
+ * @param offsetDistance distance of offset
323
+ * @example
324
+ * // Creates an offset on the box
325
+ * const boxId1 = api.box(20, 20, 20)
326
+ * api.offset(boxId1, 2)
327
+ * const geom = await api.createBufferGeometry(boxId1)
328
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
329
+ * @image /doc/assets/solid/offset.jpg
330
+ */
331
+ offset: (solidId: VID, offsetDistance: number) => ID;
332
+ /**
333
+ * Returns all edges or faces depending on type which matches the points.
334
+ * @param solidId id of the solid to look for edges and faces
335
+ * @param type type of geometry to look for --> 'edge' or 'face'
336
+ * @param points points where edges and faces will be expected
337
+ * @example
338
+ * // Pick does look for an edge at point [5,0,7.5] and adds a fillet on it if found the edge
339
+ * const boxId = api.box(10, 25, 15)
340
+ * const edge = api.pick(boxId, 'edge', [5, 0, 7.5])
341
+ * api.fillet(2, edge)
342
+ * const geom = await api.createBufferGeometry(boxId)
343
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
344
+ * @image /doc/assets/solid/pick.jpg
345
+ */
346
+ pick: (solidId: VID, type: 'vertex' | 'edge' | 'face', ...points: Vec[]) => IDs;
347
+ /**
348
+ * Revolves the given region.
349
+ * @param position position of rotation axis
350
+ * @param direction direction of rotation axis
351
+ * @param angle angle of rotation in rad
352
+ * @param region region which will be revolved, defined by Polyline or THREE.Shape
353
+ * @example
354
+ * // Creates a closed polyline from three points and revolves it
355
+ * const fp0 = { point: new THREE.Vector3(20, 20, 0), radius: 4 }
356
+ * const fp1 = { point: new THREE.Vector3(40, 0, 0), radius: 2 }
357
+ * const fp2 = { point: new THREE.Vector3(0, 0, 0), radius: 2 }
358
+ * const polyline = createPolyline([fp0, fp1, fp2])
359
+ * const revolveId = api.revolve([-10, 0, 0], [0, 1, 0], 2 * Math.PI, polyline)
360
+ * const geom = await api.createBufferGeometry(revolveId)
361
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
362
+ * @image /doc/assets/solid/revolve.jpg
363
+ */
364
+ revolve: (position: Vec, direction: Vec, angle: number, region: Polyline | THREE.Shape) => ID;
365
+ /**
366
+ * Rotates the given solid.
367
+ * @param solidId id of the solid to rotate
368
+ * @param rotationVec vector of rotation around x-, y- and z-axis
369
+ * @example
370
+ * // Creates a box and rotates it around its x- and z-axis
371
+ * const boxId = api.box(10, 10, 10)
372
+ * api.rotateTo(boxId, [Math.PI / 4, 0, Math.PI / 4])
373
+ * const geom = await api.createBufferGeometry(boxId)
374
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
375
+ * @image /doc/assets/solid/rotateTo.jpg
376
+ */
377
+ rotateTo: (solidId: VID, rotationVec: Vec) => Promise<void>;
378
+ /**
379
+ * Writes the current drawing as native file format to a stream and returns the data.
380
+ * Native file is 'ofb', for 'stp' file format use export method.
381
+ *
382
+ * Important notes about the ofb format:
383
+ * - It contains binary geometry blocks.
384
+ * - Do not try to convert it to text, the geometry blocks will get damaged!
385
+ *
386
+ * @example
387
+ * // Creates a rotated box and gets the ofb data.
388
+ * const boxId = api.box(10, 10, 10)
389
+ * api.rotateTo(boxId, [Math.PI / 4, 0, Math.PI / 4])
390
+ * const data = api.save()
391
+ *
392
+ * @image // tbd
393
+ */
394
+ save: () => Promise<Uint8Array | null>;
395
+ /**
396
+ * Scales the solid in all or specified axis.
397
+ * @param solidId id of the solid to scale
398
+ * @param vectorOrFactor if factor is defined, the solid will be scaled in all direction with same scale value. Otherwise in the given x, y and z direction of the vector.
399
+ * @example
400
+ * // Creates a box and scales it in x-axis
401
+ * const boxId = api.box(10, 10, 10)
402
+ * api.scale(boxId, [2, 1, 1])
403
+ * const geom = await api.createBufferGeometry(boxId)
404
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
405
+ * @image /doc/assets/solid/scale.jpg
406
+ */
407
+ scale: (solidId: VID, vectorOrFactor: Vec | number) => Promise<void>;
408
+ /**
409
+ * Sets the faceting parameters of graphic objects. This defines how detailed solids will be displayed.
410
+ * @param distanceTol tolerated distance between theoretic and tesselated arc
411
+ * @param angleTol tolerated angle between normal vectors of faces which build an arc
412
+ * @example
413
+ * // Creates a cylinder with low tessellation
414
+ * api.setFacetingParams(0.5, 0)
415
+ * const cylinderId = api.cylinder(50, 20)
416
+ * const geom = await api.createBufferGeometry(cylinderId)
417
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
418
+ * @image /doc/assets/solid/setFacetingParams.jpg
419
+ */
420
+ setFacetingParams: (distanceTol: number, angleTol: number) => ID;
421
+ /**
422
+ * Slices the solid at specified plane. Part of solid which is on the positive side of defined plane will be removed.
423
+ * @param solidId id of solid to slice
424
+ * @param point position of plane
425
+ * @param normal normal vector of plane
426
+ * @example
427
+ * // Creates a sphere and slice it
428
+ * const sphereId = api.sphere(20)
429
+ * api.slice(sphereId, [10, 10, 0], [1, 1, 0])
430
+ * const geom = await api.createBufferGeometry(sphereId)
431
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
432
+ * @image /doc/assets/solid/slice.jpg
433
+ */
434
+ slice: (solidId: VID, point: Vec, normal: Vec) => Promise<void>;
435
+ /**
436
+ * Creates a simple sphere.
437
+ * @param radius radius of the sphere
438
+ * @example
439
+ * // Creates a sphere with radius = 10
440
+ * const sphereId = api.sphere(10)
441
+ * const geom = await api.createBufferGeometry(sphereId)
442
+ * const mesh = new THREE.Mesh( geom, new THREE.MeshStandardMaterial({}))
443
+ * @image /doc/assets/solid/sphere.jpg
444
+ */
445
+ sphere: (radius: number) => ID;
446
+ /**
447
+ * Creates a subtraction between solid and bodies.
448
+ * @param solidId id of the solid to subtract
449
+ * @param keepSolid if true, the solid will be kept and can be used again
450
+ * @param bodies bodies to subtract from the solid
451
+ * @example
452
+ * // Subtracts a box from sphere after
453
+ * const sphereId = api.sphere(20)
454
+ * const boxId = api.box(20, 20, 20)
455
+ * api.moveTo(boxId, [10, 10, 10])
456
+ * const subId = api.subtract(sphereId, false, boxId)
457
+ * const geom = await api.createBufferGeometry(subId)
458
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
459
+ * @image /doc/assets/solid/subtract.jpg
460
+ */
461
+ subtract: (solidId: VID, keepSolid: boolean, ...bodies: VID[]) => ID;
462
+ /**
463
+ * Creates an union between solid and bodies.
464
+ * @param solidId id of the solid to unify
465
+ * @param keepSolid if true, the solid will be kept and can be used again
466
+ * @param bodies bodies to unify with the solid
467
+ * @example
468
+ * // Unifies a sphere with a cone
469
+ * const sphereId = api.sphere(20)
470
+ * const coneId = api.cone(50, 40, 0)
471
+ * api.moveTo(coneId, [0, 0, 25])
472
+ * const unionId = api.union(sphereId, false, coneId)
473
+ * const geom = await api.createBufferGeometry(unionId)
474
+ * const mesh = new THREE.Mesh(geom, new THREE.MeshStandardMaterial({}))
475
+ * @image /doc/assets/solid/union.jpg
476
+ */
477
+ union: (solidId: VID, keepSolid: boolean, ...bodies: VID[]) => ID;
478
+ };
479
+ /**
480
+ * Creates a polyline from the given fillet points
481
+ * @param fPts points of the polyline with its associated fillet radius
482
+ * @example
483
+ * // Creates a polyline with three points
484
+ * const fp0 = { point: new THREE.Vector3(20, 20, 0), radius: 4 }
485
+ * const fp1 = { point: new THREE.Vector3(40, 0, 0), radius: 2 }
486
+ * const fp2 = { point: new THREE.Vector3(0, 0, 0), radius: 2 }
487
+ * const polyline = createPolyline([fp0, fp1, fp2])
488
+ */
489
+ export declare function createPolyline(fPts: FilletPoint[]): Polyline;
490
+ export declare class Solid {
491
+ drawingId: DrawingID | null;
492
+ queue: Promise<number>;
493
+ constructor();
494
+ resolve(callback: (...results: any) => Promise<any>, ...args: any[]): Promise<any>;
495
+ init(callback: (api: ApiNoHistory) => void): () => Promise<void>;
496
+ destroy(): void;
497
+ }
498
+ export declare class solid extends Solid {
499
+ constructor();
500
+ }
501
+ declare type VID = ObjectID | Promise<ObjectID>;
502
+ declare type VIDs = ObjectID[] | Promise<ObjectID[]>;
503
+ declare type ID = Promise<ObjectID>;
504
+ declare type IDs = Promise<ObjectID[]>;
505
+ declare type Vec = number[] | THREE.Vector3 | THREE.Euler;
506
+ /**
507
+ * Point definition where the fillet will be added with a specified radius.
508
+ */
509
+ export declare type FilletPoint = {
510
+ /** Point where the corner of the polyline will be. */
511
+ point: Vector3;
512
+ /** Radius of the fillet at the position of point. */
513
+ radius: number;
514
+ };
515
+ /**
516
+ * Polyline of points and bulges. Bulges define the arc between the current and the next point.
517
+ */
518
+ export declare type Polyline = {
519
+ /** Points where the corners of the polyline will be. */
520
+ points: Vector3[];
521
+ /** Bulges which define the arcs. */
522
+ bulges: number[];
523
+ };
524
+ export {};