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