@buerli.io/headless 0.13.1-beta.8.apiversion → 1.0.0

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