@bitbybit-dev/jscad 1.1.0 → 1.2.0-rc.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.
@@ -7,23 +7,55 @@ export class JSCADShapes {
7
7
  this.math = math;
8
8
  this.jscad = jscad;
9
9
  }
10
+ /**
11
+ * Create a 3D cube shape
12
+ * @param inputs Cube parameters
13
+ * @returns Cube solid
14
+ * @group primitives
15
+ * @shortname cube
16
+ * @drawable true
17
+ */
10
18
  cube(inputs) {
11
19
  return this.jscad.primitives.cube({
12
20
  center: [inputs.center[0], inputs.center[1], inputs.center[2]],
13
21
  size: inputs.size
14
22
  });
15
23
  }
24
+ /**
25
+ * Create a 3D cubes on multiple center points
26
+ * @param inputs Cube with multiple center points parameters
27
+ * @returns List of cube solids
28
+ * @group primitives on centers
29
+ * @shortname cubes
30
+ * @drawable true
31
+ */
16
32
  cubesOnCenterPoints(inputs) {
17
33
  return inputs.centers.map(center => {
18
34
  return this.cube({ center, size: inputs.size });
19
35
  });
20
36
  }
37
+ /**
38
+ * Create a 3D cuboid shape
39
+ * @param inputs Cuboid parameters
40
+ * @returns Cuboid solid
41
+ * @group primitives
42
+ * @shortname cuboid
43
+ * @drawable true
44
+ */
21
45
  cuboid(inputs) {
22
46
  return this.jscad.primitives.cuboid({
23
47
  center: [inputs.center[0], inputs.center[1], inputs.center[2]],
24
48
  size: [inputs.width, inputs.height, inputs.length]
25
49
  });
26
50
  }
51
+ /**
52
+ * Create a 3D cuboids on multiple center points
53
+ * @param inputs Cuboids with multiple center point parameters
54
+ * @returns List of cuboid solids
55
+ * @group primitives on centers
56
+ * @shortname cuboids
57
+ * @drawable true
58
+ */
27
59
  cuboidsOnCenterPoints(inputs) {
28
60
  return inputs.centers.map(center => {
29
61
  return this.cuboid({
@@ -34,6 +66,14 @@ export class JSCADShapes {
34
66
  });
35
67
  });
36
68
  }
69
+ /**
70
+ * Create a 3D elliptic cylinder solid
71
+ * @param inputs Elliptic cylinder parameters
72
+ * @returns Elliptic cylinder solid
73
+ * @group primitives
74
+ * @shortname cylinder elliptic
75
+ * @drawable true
76
+ */
37
77
  cylinderElliptic(inputs) {
38
78
  return this.jscad.primitives.cylinderElliptic({
39
79
  center: [inputs.center[0], inputs.center[1], inputs.center[2]],
@@ -43,6 +83,14 @@ export class JSCADShapes {
43
83
  segments: inputs.segments,
44
84
  });
45
85
  }
86
+ /**
87
+ * Create a 3D elliptic cylinders on multiple center points
88
+ * @param inputs Elliptic cylinders with multiple center point parameters
89
+ * @returns List of elliptic cylinders solids
90
+ * @group primitives on centers
91
+ * @shortname cylinder elliptic
92
+ * @drawable true
93
+ */
46
94
  cylinderEllipticOnCenterPoints(inputs) {
47
95
  return inputs.centers.map(center => {
48
96
  return this.cylinderElliptic({
@@ -54,6 +102,14 @@ export class JSCADShapes {
54
102
  });
55
103
  });
56
104
  }
105
+ /**
106
+ * Create a 3D cylinder solid
107
+ * @param inputs Cylinder parameters
108
+ * @returns Cylinder solid
109
+ * @group primitives
110
+ * @shortname cylinder
111
+ * @drawable true
112
+ */
57
113
  cylinder(inputs) {
58
114
  return this.jscad.primitives.cylinder({
59
115
  center: [inputs.center[0], inputs.center[1], inputs.center[2]],
@@ -62,6 +118,14 @@ export class JSCADShapes {
62
118
  segments: inputs.segments,
63
119
  });
64
120
  }
121
+ /**
122
+ * Create a 3D cylinders on multiple center points
123
+ * @param inputs Cylinders with multiple center point parameters
124
+ * @returns List of cylinder solids
125
+ * @group primitives on centers
126
+ * @shortname cylinder
127
+ * @drawable true
128
+ */
65
129
  cylindersOnCenterPoints(inputs) {
66
130
  return inputs.centers.map(center => {
67
131
  return this.cylinder({
@@ -72,6 +136,14 @@ export class JSCADShapes {
72
136
  });
73
137
  });
74
138
  }
139
+ /**
140
+ * Create a 3D ellipsoid solid
141
+ * @param inputs Ellipsoid parameters
142
+ * @returns Ellipsoid solid
143
+ * @group primitives
144
+ * @shortname ellipsoid
145
+ * @drawable true
146
+ */
75
147
  ellipsoid(inputs) {
76
148
  return this.jscad.primitives.ellipsoid({
77
149
  center: [inputs.center[0], inputs.center[1], inputs.center[2]],
@@ -84,6 +156,14 @@ export class JSCADShapes {
84
156
  ],
85
157
  });
86
158
  }
159
+ /**
160
+ * Create a 3D ellipsoids on multiple center points
161
+ * @param inputs Ellipsoid parameters with multiple center points
162
+ * @returns List of ellipsoid solids
163
+ * @group primitives on centers
164
+ * @shortname ellipsoid
165
+ * @drawable true
166
+ */
87
167
  ellipsoidsOnCenterPoints(inputs) {
88
168
  return inputs.centers.map(center => {
89
169
  return this.ellipsoid({
@@ -93,11 +173,27 @@ export class JSCADShapes {
93
173
  });
94
174
  });
95
175
  }
176
+ /**
177
+ * Create a 3D geodesic sphere solid
178
+ * @param inputs Geodesic sphere parameters
179
+ * @returns Geodesic sphere solid
180
+ * @group primitives
181
+ * @shortname geodesic sphere
182
+ * @drawable true
183
+ */
96
184
  geodesicSphere(inputs) {
97
185
  let sphere = this.jscad.primitives.geodesicSphere({ radius: inputs.radius, frequency: inputs.frequency });
98
186
  sphere = this.jscad.transforms.translate([inputs.center[0], inputs.center[1], inputs.center[2]], sphere);
99
187
  return sphere;
100
188
  }
189
+ /**
190
+ * Create a 3D geodesic spheres on multiple center points
191
+ * @param inputs Geodesic sphere parameters with multiple center points
192
+ * @returns List of geodesic spheres
193
+ * @group primitives on centers
194
+ * @shortname geodesic sphere
195
+ * @drawable true
196
+ */
101
197
  geodesicSpheresOnCenterPoints(inputs) {
102
198
  return inputs.centers.map(center => {
103
199
  return this.geodesicSphere({
@@ -107,6 +203,14 @@ export class JSCADShapes {
107
203
  });
108
204
  });
109
205
  }
206
+ /**
207
+ * Create a 3D rounded cuboid solid
208
+ * @param inputs Rounded cuboid parameters
209
+ * @returns Rounded cuboid solid
210
+ * @group primitives
211
+ * @shortname rounded cuboid
212
+ * @drawable true
213
+ */
110
214
  roundedCuboid(inputs) {
111
215
  return this.jscad.primitives.roundedCuboid({
112
216
  center: [inputs.center[0], inputs.center[1], inputs.center[2]],
@@ -115,6 +219,14 @@ export class JSCADShapes {
115
219
  segments: inputs.segments,
116
220
  });
117
221
  }
222
+ /**
223
+ * Create a 3D rounded cuboids on multiple center points
224
+ * @param inputs Rounded cuboids parameters with multiple center points
225
+ * @returns List of rounded cuboids
226
+ * @group primitives on centers
227
+ * @shortname rounded cuboid
228
+ * @drawable true
229
+ */
118
230
  roundedCuboidsOnCenterPoints(inputs) {
119
231
  return inputs.centers.map(center => {
120
232
  return this.roundedCuboid({
@@ -127,6 +239,14 @@ export class JSCADShapes {
127
239
  });
128
240
  });
129
241
  }
242
+ /**
243
+ * Create a 3D rounded cylinder solid
244
+ * @param inputs Rounded cylinder parameters
245
+ * @returns Rounded cylinder solid
246
+ * @group primitives
247
+ * @shortname rounded cylinder
248
+ * @drawable true
249
+ */
130
250
  roundedCylinder(inputs) {
131
251
  return this.jscad.primitives.roundedCylinder({
132
252
  center: [inputs.center[0], inputs.center[1], inputs.center[2]],
@@ -136,6 +256,14 @@ export class JSCADShapes {
136
256
  segments: inputs.segments,
137
257
  });
138
258
  }
259
+ /**
260
+ * Create a 3D rounded cylinders on multiple center points
261
+ * @param inputs Rounded cylinders parameters with multiple center points
262
+ * @returns List of rounded cylinders
263
+ * @group primitives on centers
264
+ * @shortname rounded cylinder
265
+ * @drawable true
266
+ */
139
267
  roundedCylindersOnCenterPoints(inputs) {
140
268
  return inputs.centers.map(center => {
141
269
  return this.roundedCylinder({
@@ -147,6 +275,14 @@ export class JSCADShapes {
147
275
  });
148
276
  });
149
277
  }
278
+ /**
279
+ * Create a 3D sphere solid
280
+ * @param inputs Sphere parameters
281
+ * @returns Sphere solid
282
+ * @group primitives
283
+ * @shortname sphere
284
+ * @drawable true
285
+ */
150
286
  sphere(inputs) {
151
287
  return this.jscad.primitives.sphere({
152
288
  center: [inputs.center[0], inputs.center[1], inputs.center[2]],
@@ -154,6 +290,14 @@ export class JSCADShapes {
154
290
  segments: inputs.segments
155
291
  });
156
292
  }
293
+ /**
294
+ * Create a 3D sphere on multiple center points
295
+ * @param inputs Sphere parameters with multiple center points
296
+ * @returns List of spheres
297
+ * @group primitives on centers
298
+ * @shortname sphere
299
+ * @drawable true
300
+ */
157
301
  spheresOnCenterPoints(inputs) {
158
302
  return inputs.centers.map(center => {
159
303
  return this.sphere({
@@ -163,9 +307,16 @@ export class JSCADShapes {
163
307
  });
164
308
  });
165
309
  }
310
+ /**
311
+ * Create a 3D torus solid
312
+ * @param inputs Torus parameters
313
+ * @returns Torus solid
314
+ * @group primitives
315
+ * @shortname torus
316
+ * @drawable true
317
+ */
166
318
  torus(inputs) {
167
319
  return this.jscad.primitives.torus({
168
- // center: [inputs.center[0], inputs.center[1], inputs.center[2]],
169
320
  innerRadius: inputs.innerRadius,
170
321
  outerRadius: inputs.outerRadius,
171
322
  innerSegments: inputs.innerSegments,
@@ -175,6 +326,14 @@ export class JSCADShapes {
175
326
  startAngle: this.math.degToRad({ number: inputs.startAngle }),
176
327
  });
177
328
  }
329
+ /**
330
+ * Create a 3D shape from poylgon points that have to be nested arrays of points
331
+ * @param inputs points
332
+ * @returns shape
333
+ * @group shapes
334
+ * @shortname from polygon points
335
+ * @drawable true
336
+ */
178
337
  fromPolygonPoints(inputs) {
179
338
  const pts = inputs.polygonPoints.map(vertices => vertices.reverse());
180
339
  return this.jscad.geometries.geom3.fromPoints(pts);
@@ -1,3 +1,4 @@
1
+ import { Base } from "@bitbybit-dev/base";
1
2
  import * as Inputs from "../inputs/jscad-inputs";
2
3
  import * as JSCAD from "@jscad/modeling";
3
4
  /**
@@ -7,8 +8,32 @@ import * as JSCAD from "@jscad/modeling";
7
8
  export declare class JSCADText {
8
9
  private readonly jscad;
9
10
  constructor(jscad: typeof JSCAD);
11
+ /**
12
+ * Creates a text that is based on chain hulling cylinders
13
+ * @param inputs Cylindrical text parameters
14
+ * @returns List of solids for text
15
+ * @group text
16
+ * @shortname cylindrical
17
+ * @drawable true
18
+ */
10
19
  cylindricalText(inputs: Inputs.JSCAD.CylinderTextDto): Inputs.JSCAD.JSCADEntity[];
20
+ /**
21
+ * Creates a text that is based on chain hulling spheres
22
+ * @param inputs Spherical text parameters
23
+ * @returns List of solids for text
24
+ * @group text
25
+ * @shortname spherical
26
+ * @drawable true
27
+ */
11
28
  sphericalText(inputs: Inputs.JSCAD.SphereTextDto): Inputs.JSCAD.JSCADEntity[];
12
29
  private adjustTextToBeOnCenter;
13
- createVectorText(inputs: Inputs.JSCAD.TextDto): JSCAD.text.VectorText;
30
+ /**
31
+ * Creates a vector text
32
+ * @param inputs Vector text parameters
33
+ * @returns List of polygons
34
+ * @group text
35
+ * @shortname vector
36
+ * @drawable false
37
+ */
38
+ createVectorText(inputs: Inputs.JSCAD.TextDto): Base.Point2[][];
14
39
  }
@@ -6,6 +6,14 @@ export class JSCADText {
6
6
  constructor(jscad) {
7
7
  this.jscad = jscad;
8
8
  }
9
+ /**
10
+ * Creates a text that is based on chain hulling cylinders
11
+ * @param inputs Cylindrical text parameters
12
+ * @returns List of solids for text
13
+ * @group text
14
+ * @shortname cylindrical
15
+ * @drawable true
16
+ */
9
17
  cylindricalText(inputs) {
10
18
  const text = this.createVectorText(inputs);
11
19
  this.adjustTextToBeOnCenter(text);
@@ -21,6 +29,14 @@ export class JSCADText {
21
29
  return this.jscad.hulls.hullChain(...cylinders);
22
30
  });
23
31
  }
32
+ /**
33
+ * Creates a text that is based on chain hulling spheres
34
+ * @param inputs Spherical text parameters
35
+ * @returns List of solids for text
36
+ * @group text
37
+ * @shortname spherical
38
+ * @drawable true
39
+ */
24
40
  sphericalText(inputs) {
25
41
  const text = this.createVectorText(inputs);
26
42
  this.adjustTextToBeOnCenter(text);
@@ -38,7 +54,7 @@ export class JSCADText {
38
54
  adjustTextToBeOnCenter(text) {
39
55
  let maxX = 0;
40
56
  text.forEach(txt => {
41
- txt.forEach(center => {
57
+ txt.forEach((center) => {
42
58
  if (center[0] > maxX) {
43
59
  maxX = center[0];
44
60
  }
@@ -46,13 +62,21 @@ export class JSCADText {
46
62
  });
47
63
  const compensate = maxX / 2;
48
64
  text.forEach(txt => {
49
- txt.forEach(center => {
65
+ txt.forEach((center) => {
50
66
  let z = center[0];
51
67
  z = z - compensate;
52
68
  center[0] = z;
53
69
  });
54
70
  });
55
71
  }
72
+ /**
73
+ * Creates a vector text
74
+ * @param inputs Vector text parameters
75
+ * @returns List of polygons
76
+ * @group text
77
+ * @shortname vector
78
+ * @drawable false
79
+ */
56
80
  createVectorText(inputs) {
57
81
  return this.jscad.text.vectorText({
58
82
  input: inputs.text,
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "@bitbybit-dev/jscad",
3
- "version": "1.1.0",
3
+ "version": "1.2.0-rc.0",
4
4
  "description": "Bit By Bit Developers JSCAD based CAD Library to Program Geometry",
5
+ "homepage": "https://docs.bitbybit.dev/classes/Bit.JSCAD",
5
6
  "main": "index.js",
6
7
  "repository": {
7
8
  "type": "git",
8
- "url": "https://github.com/bitbybit-dev/bitbybit"
9
+ "url": "git+https://github.com/bitbybit-dev/bitbybit.git",
10
+ "directory": "packages/dev/jscad"
9
11
  },
10
12
  "keywords": [
11
13
  "Bit By Bit Developers",
@@ -43,16 +45,6 @@
43
45
  "directories": {
44
46
  "lib": "lib"
45
47
  },
46
- "scripts": {
47
- "build": "tsc -p tsconfig.bitbybit.json",
48
- "build-p": "npm run build && npm run copy-package && npm run copy-readme && npm run delete-coverage",
49
- "copy-package": "shx cp -R ./package.json ./dist",
50
- "copy-readme": "shx cp -R ./README.md ./dist && shx cp -R ./LICENSE ./dist",
51
- "delete-coverage": "shx rm -rf ./dist/coverage || true",
52
- "test": "set NODE_OPTIONS=--experimental-specifier-resolution=node && jest --watchAll=true",
53
- "test-c": "set NODE_OPTIONS=--experimental-specifier-resolution=node && jest --coverage --watchAll=false",
54
- "test-c-l": "set NODE_OPTIONS=--experimental-specifier-resolution=node && jest --coverage --watchAll=true"
55
- },
56
48
  "author": "Bit by bit developers",
57
49
  "license": "MIT",
58
50
  "funding": {
@@ -62,41 +54,11 @@
62
54
  "types": "./index.d.ts",
63
55
  "type": "module",
64
56
  "dependencies": {
65
- "@bitbybit-dev/base": "1.1.0",
57
+ "@bitbybit-dev/base": "1.2.0-rc.0",
66
58
  "@jscad/io-utils": "2.0.28",
67
59
  "@jscad/modeling": "2.12.3",
68
60
  "@jscad/stl-serializer": "2.1.18",
69
61
  "@jscad/dxf-serializer": "2.1.18",
70
62
  "@jscad/3mf-serializer": "2.1.12"
71
- },
72
- "devDependencies": {
73
- "shx": "0.4.0",
74
- "@testing-library/jest-dom": "6.9.1",
75
- "mvdir": "1.0.22",
76
- "jest": "30.2.0",
77
- "ts-node": "10.9.2",
78
- "ts-jest": "29.4.6",
79
- "typescript": "5.9.3",
80
- "@types/jest": "30.0.0",
81
- "babel-jest": "30.2.0",
82
- "@babel/core": "7.28.6",
83
- "@babel/preset-env": "7.28.6",
84
- "@babel/preset-typescript": "7.28.5",
85
- "jest-html-reporters": "3.1.7"
86
- },
87
- "jest": {
88
- "preset": "ts-jest",
89
- "transform": {
90
- "\\.[jt]sx?$": "babel-jest"
91
- },
92
- "extensionsToTreatAsEsm": [
93
- ".ts"
94
- ],
95
- "transformIgnorePatterns": [
96
- "node_modules/(?!@bitbybit-dev)/"
97
- ],
98
- "collectCoverageFrom": [
99
- "lib/api/**/*"
100
- ]
101
63
  }
102
- }
64
+ }
package/babel.config.cjs DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
- module.exports = {
3
- presets: [
4
- [
5
- '@babel/preset-env',
6
- {
7
- targets: {
8
- node: 'current',
9
- },
10
- },
11
- ],
12
- '@babel/preset-typescript'
13
- ],
14
- };
@@ -1,5 +0,0 @@
1
- export let presets: (string | (string | {
2
- targets: {
3
- node: string;
4
- };
5
- })[])[];