@jscad/web 2.5.11 → 2.5.12

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/jscad-web.min.js +62 -59
  3. package/examples/CHANGELOG.md +11 -0
  4. package/examples/README.md +0 -4
  5. package/examples/package.json +1 -1
  6. package/package.json +7 -7
  7. package/postInstall.js +0 -1
  8. package/src/sideEffects/worker/index.js +7 -8
  9. package/src/ui/flow/design.js +10 -305
  10. package/src/ui/flow/reducers.js +304 -0
  11. package/examples/old/benchmark-cag.jscad +0 -27
  12. package/examples/old/benchmark-csg.jscad +0 -29
  13. package/examples/old/benchmark.jscad +0 -25
  14. package/examples/old/bunch-cubes.jscad +0 -17
  15. package/examples/old/complex/example001.jscad +0 -31
  16. package/examples/old/complex/example002.jscad +0 -25
  17. package/examples/old/complex/example003.jscad +0 -25
  18. package/examples/old/complex/example004.jscad +0 -16
  19. package/examples/old/complex/example005.jscad +0 -27
  20. package/examples/old/complex/globe.js +0 -235
  21. package/examples/old/complex/iphone4-case.js +0 -213
  22. package/examples/old/complex/umbilical_torus.js +0 -43
  23. package/examples/old/complex/umbilical_torus.scad +0 -37
  24. package/examples/old/core/cncCutout.js +0 -16
  25. package/examples/old/core/connectors/servo.js +0 -185
  26. package/examples/old/core/extrusions/extrudeLinear.js +0 -24
  27. package/examples/old/core/extrusions/extrudeRectangular.js +0 -21
  28. package/examples/old/core/extrusions/extrudeRotate.js +0 -43
  29. package/examples/old/core/extrusions/slices/four2three-round.js +0 -62
  30. package/examples/old/core/extrusions/slices/four2three.js +0 -53
  31. package/examples/old/core/extrusions/slices/jar-barrel.js +0 -60
  32. package/examples/old/core/extrusions/slices/jar.js +0 -69
  33. package/examples/old/core/extrusions/slices/non-aff.js +0 -72
  34. package/examples/old/core/extrusions/slices/rose.js +0 -52
  35. package/examples/old/core/extrusions/slices/screw.js +0 -34
  36. package/examples/old/core/extrusions/slices/screwDouble.js +0 -34
  37. package/examples/old/core/extrusions/slices/slices.js +0 -43
  38. package/examples/old/core/extrusions/slices/spring.js +0 -41
  39. package/examples/old/core/extrusions/slices/three2four.js +0 -42
  40. package/examples/old/core/extrusions/slices/tor.js +0 -30
  41. package/examples/old/core/hulls/hullChain.js +0 -58
  42. package/examples/old/core/lookup.js +0 -19
  43. package/examples/old/core/platonics/main.jscad +0 -42
  44. package/examples/old/core/platonics/maths_geodesic.jscad +0 -192
  45. package/examples/old/core/platonics/origv07/dualdodeca_difference.stl +0 -1962
  46. package/examples/old/core/platonics/origv07/dualdodeca_intersection.stl +0 -1374
  47. package/examples/old/core/platonics/origv07/dualdodeca_union.stl +0 -1822
  48. package/examples/old/core/platonics/origv07/maths_geodesic.scad +0 -162
  49. package/examples/old/core/platonics/origv07/platonic.scad +0 -483
  50. package/examples/old/core/platonics/origv07/test_platonic.scad +0 -616
  51. package/examples/old/core/platonics/platonic.jscad +0 -528
  52. package/examples/old/core/text/textSimplex.js +0 -625
  53. package/examples/old/core/transforms/transformations.js +0 -29
  54. package/examples/old/echo.jscad +0 -7
  55. package/examples/old/formats/scad/example001.scad +0 -26
  56. package/examples/old/formats/scad/example002.scad +0 -23
  57. package/examples/old/formats/scad/example003.scad +0 -20
  58. package/examples/old/formats/scad/example004.scad +0 -11
  59. package/examples/old/formats/scad/example005.scad +0 -20
  60. package/examples/old/json_logo.json +0 -1
  61. package/examples/old/parameters/axis-coupler.js +0 -149
  62. package/examples/old/parameters/celtic-knot-ring.js +0 -300
  63. package/examples/old/parameters/grille.js +0 -257
  64. package/examples/old/parameters/lamp-shade.js +0 -369
  65. package/examples/old/parameters/name-plate.js +0 -46
  66. package/examples/old/parameters/s-hook.js +0 -131
  67. package/examples/old/parameters/stepper-motor.js +0 -127
  68. package/examples/old/various/logo.js +0 -32
  69. package/examples/old/voxel.json +0 -1
@@ -1,616 +0,0 @@
1
- include <platonic.scad>
2
-
3
- //test_duals();
4
- test_wireframes();
5
- //test_polyhedron();
6
-
7
- //=======================================
8
- // WIREFRAMES
9
- //=======================================
10
- module test_wireframes()
11
- {
12
- //rotate(v=[-1,1,0], a=54.7356)
13
- //display_polywireframe(tetrahedron(40), radius=2.5, style=0);
14
-
15
- //display_polywireframe(hexahedron(20), radius=2.5, style=0, smoothness=24);
16
-
17
- //rotate(v=[-1,1,0], a=54.7356)
18
- //display_polywireframe(octahedron(20), radius=2.5, style=0, smoothness=24);
19
-
20
- //rotate(v=[1,0,0], a=plat_dihedral(dodeca_sch)/2) // dihedral
21
- //display_polywireframe(dodecahedron(20), radius=2.5, style=0, smoothness=24);
22
-
23
- rotate(v=[-1,1,0], a=54.7356)
24
- display_polywireframe(icosahedron(30), radius=2.5, style=0);
25
- }
26
-
27
-
28
- //====================================
29
- // Utility functions
30
- //====================================
31
- function VMAG(v) = sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]);
32
-
33
- function LineRotations(v) = [
34
- atan2(sqrt(v[0]*v[0]+v[1]*v[1]), v[2]),
35
- 0,
36
- atan2(v[1], v[0])+90];
37
-
38
- function parseSeg(seg) = [
39
- seg[0],
40
- LineRotations(seg[1]-seg[0]),
41
- VMAG(seg[1]-seg[0])
42
- ];
43
-
44
-
45
- module PlaceLine(seg, radius=0.025, style=1, smoothness=24)
46
- {
47
- $fn=smoothness;
48
- diameter = radius*2;
49
- side = sqrt((diameter*diameter)/2);
50
-
51
-
52
- params = parseSeg(seg);
53
-
54
- origin = params[0];
55
- rot = params[1];
56
- len = params[2];
57
-
58
- translate(origin)
59
- rotate(rot)
60
- {
61
- if (style == 0) // cylinders, with no end caps
62
- {
63
- cylinder(r=radius, h=len);
64
- } else if (style == 1) // cylinders with rounded end caps
65
- {
66
- cylinder(r=radius, h=len);
67
-
68
- // Cap with spheres
69
- sphere(r=radius);
70
-
71
- translate([0,0,len])
72
- sphere(r=radius);
73
- } else // Second style is experimental
74
- {
75
- // translate([-side/2, -side/2,0])
76
- // cube(size=[side, side, len]);
77
- //
78
- // translate([-side/2, -side/2, -side/2])
79
- // cube(size=[side, side, side]);
80
- //
81
- // translate([-side/2, -side/2, (-side/2)+len])
82
- // cube(size=[side, side, side]);
83
- }
84
- }
85
- }
86
-
87
- module display_polywireframe(poly, radius=0.025, style=1, smoothness=24)
88
- {
89
-
90
- // For each edge
91
- // Draw the wireframe
92
- for (edge = poly[2])
93
- {
94
- PlaceLine([poly[0][edge[0]], poly[0][edge[1]]],
95
- radius=radius,
96
- style = style,
97
- smoothness=smoothness);
98
- }
99
-
100
- display_poly_verts(poly[0], radius, $fn=smoothness);
101
- }
102
-
103
- module display_polyhedron(poly)
104
- {
105
- polyhedron(points = poly[0], triangles = poly[1]);
106
- }
107
-
108
- module display_platonics(rad=1)
109
- {
110
- // At the center, the self dual tetrahedron
111
- display_polyhedron(tetrahedron(rad));
112
-
113
-
114
- translate(rad*[3, 3, 0])
115
- display_polyhedron(icosahedron(rad));
116
-
117
- translate(rad*[-3, -3, 0])
118
- display_polyhedron(dodecahedron(rad));
119
-
120
-
121
- translate(rad*[-3, 3, 0])
122
- display_polyhedron(hexahedron(rad));
123
- translate(rad*[3,-3,0])
124
- display_polyhedron(octahedron(rad));
125
-
126
-
127
- }
128
-
129
- module print_spherical_to_cartesian(sverts)
130
- {
131
- for (vert = sverts)
132
- {
133
- echo(sph_to_cart(vert));
134
- }
135
- }
136
-
137
- module print_cartesian_to_spherical(cverts)
138
- {
139
- for (vert = cverts)
140
- {
141
- echo(sph_from_cart(vert));
142
- }
143
- }
144
-
145
- module display_verts(verts, indices, numverts, radius=0.1)
146
- {
147
- //echo(verts);
148
-
149
- for (i = [0:numverts-1])
150
- {
151
- //color([i/numverts, i/numverts, i/numverts])
152
- color([(i+1)/(numverts), (i+1)/(numverts), (i+1)/(numverts)])
153
- translate(verts[indices[i]])
154
- sphere(r=radius, $fn=24);
155
- }
156
- }
157
-
158
- module display_poly_verts(verts, radius=0.1)
159
- {
160
- //echo(verts);
161
-
162
- for (vert = verts)
163
- {
164
- translate(vert)
165
- sphere(r=radius, $fn=24);
166
- }
167
- }
168
-
169
- //=======================================
170
- // POLYHEDRON
171
- //=======================================
172
- module test_polyhedron()
173
- {
174
- //test_polyhedron(tetrahedron(1));
175
- //test_polyhedron(hexahedron(1));
176
- //test_polyhedron(octahedron(1));
177
- //test_polyhedron(dodecahedron(1));
178
- //test_polyhedron(icosahedron(1));
179
- //test_dodeca();
180
- //test_icosa();
181
-
182
-
183
- //display_platonics(20);
184
-
185
- //rotate(v=[-1,1,0], a=54.7356)
186
- //display_polyhedron(tetrahedron(20));
187
-
188
- //display_polyhedron(hexahedron(20));
189
-
190
- //rotate(v=[-1,1,0], a=54.7356)
191
- //display_polyhedron(octahedron(20));
192
-
193
- rotate(v=[-1,1,0], a=54.7356)
194
- test_polyhedron_too(octahedron(20), circumradius=20, wireframe=true);
195
-
196
- //rotate(v=[-1,1,0], a=54.7356)
197
- //display_polyhedron(icosahedron(20));
198
-
199
- //echo("dihedral: ", plat_dihedral(dodeca_sch));
200
- //echo("dihedral: ", plat_dihedral(hexa_sch));
201
-
202
- //rotate(v=[1,0,0], a=plat_dihedral(dodeca_sch)/2) // dihedral
203
- //display_polyhedron(dodecahedron(20));
204
- }
205
-
206
- module test_polyhedron_too(poly, circumradius=1, wireradius=1, wireframe=false)
207
- {
208
- display_poly_verts(poly[0]);
209
-
210
- if (wireframe)
211
- {
212
- display_polywireframe(poly, radius=wireradius);
213
- } else
214
- {
215
- display_polyhedron(poly);
216
- }
217
-
218
- color([0.5, 0.5, 0.5, 0.4])
219
- sphere(r=circumradius, $fn=24);
220
-
221
- }
222
-
223
- //=======================================
224
- // COMPOUNDS
225
- //=======================================
226
- module test_dual()
227
- {
228
- difference()
229
- {
230
- display_polyhedron(dodecahedron(1));
231
- display_polyhedron(icosahedron(1));
232
- }
233
- }
234
-
235
- module test_duals()
236
- {
237
- //test_dual();
238
- //test_dual_cube1(20);
239
- //test_dual_cube2(20);
240
- //test_dual_cube3(20);
241
-
242
- test_dual_dodeca(20);
243
- }
244
-
245
- module test_dual_cube1(rad=1)
246
- {
247
- // Union
248
- display_polyhedron(hexahedron(rad));
249
- display_polyhedron(octahedron(rad));
250
- }
251
-
252
- module test_dual_cube2(rad=1)
253
- {
254
- // Difference
255
- difference()
256
- {
257
- display_polyhedron(hexahedron(rad));
258
- display_polyhedron(octahedron(rad));
259
- }
260
- }
261
-
262
- module test_dual_cube3(rad=1)
263
- {
264
- // Intersection, for truncation
265
- intersection()
266
- {
267
- display_polyhedron(hexahedron(rad));
268
- display_polyhedron(octahedron(rad));
269
- }
270
- }
271
-
272
- // Calculated by doing trig on a icosahedron with radius 1
273
- // calculate the distance between any two vertices
274
- // then use that to find the angles between them
275
- icosaangle = 63.43;
276
-
277
-
278
- function icosasph(rad=1) = [
279
- sph(0,0,rad), // top
280
-
281
- // Top lesser circle
282
- sph(72*0, icosaangle, rad), // top
283
- sph(72*1, icosaangle, rad), // top
284
- sph(72*2, icosaangle, rad), // top
285
- sph(72*3, icosaangle, rad), // top
286
- sph(72*4, icosaangle, rad), // top
287
-
288
- // Bottom lesser circle
289
- sph((72*0)+36, 180-icosaangle,rad), // top
290
- sph((72*1)+36, 180-icosaangle,rad), // top
291
- sph((72*2)+36, 180-icosaangle,rad), // top
292
- sph((72*3)+36, 180-icosaangle,rad), // top
293
- sph((72*4)+36, 180-icosaangle,rad), // top
294
-
295
- sph(0,0,-rad), // bottom
296
- ];
297
-
298
- function icosacart(rad=1) = [
299
- sph_to_cart(icosasph(rad)[0]),
300
- sph_to_cart(icosasph(rad)[1]),
301
-
302
- sph_to_cart(icosasph(rad)[2]),
303
- sph_to_cart(icosasph(rad)[3]),
304
- sph_to_cart(icosasph(rad)[4]),
305
- sph_to_cart(icosasph(rad)[5]),
306
- sph_to_cart(icosasph(rad)[6]),
307
-
308
- sph_to_cart(icosasph(rad)[7]),
309
- sph_to_cart(icosasph(rad)[8]),
310
- sph_to_cart(icosasph(rad)[9]),
311
- sph_to_cart(icosasph(rad)[10]),
312
- sph_to_cart(icosasph(rad)[11]),
313
- ];
314
-
315
- icosaedges = [
316
- // Top
317
- [0,1],
318
- [0,2],
319
- [0,3],
320
- [0,4],
321
- [0,5],
322
-
323
- [1,2],
324
- [2,3],
325
- [3,4],
326
- [4,5],
327
- [5,1],
328
-
329
- // Bottom
330
- [11,6],
331
- [11,7],
332
- [11,8],
333
- [11,9],
334
- [11,10],
335
-
336
- [6,7],
337
- [7,8],
338
- [8,9],
339
- [9,10],
340
- [10,6],
341
-
342
- // antiprism
343
- [1,6],
344
- [2,6],
345
-
346
- [2,7],
347
- [3,7],
348
-
349
- [3,8],
350
- [4,8],
351
-
352
- [4,9],
353
- [5,9],
354
-
355
- [5,10],
356
- [6,10],
357
- [1,10]
358
- ];
359
-
360
- // clockwise winding
361
- icosafaces = [
362
- // top
363
- [0,2,1],
364
- [0,3,2],
365
- [0,4,3],
366
- [0,5,4],
367
- [0,1,5],
368
-
369
- // antiprism
370
- [1,2,6],
371
- [2,7,6],
372
- [2,3,7],
373
- [3,8,7],
374
- [3,4,8],
375
- [4,9,8],
376
- [4,5,9],
377
- [5,10,9],
378
- [1,10,5],
379
- [1,6,10],
380
-
381
- // bottom
382
- [11,6,7],
383
- [11,7,8],
384
- [11,8,9],
385
- [11,9,10],
386
- [11,10,6],
387
- ];
388
-
389
-
390
- function icosaplat(rad=1) = [icosacart(rad), icosafaces, icosaedges];
391
-
392
- module test_dual_dodeca(rad=1)
393
- {
394
- inradius = plat_inradius(dodeca_sch, rad);
395
-
396
- // echo("rad, inrad: ", rad, inradius);
397
- echo("Dihedral Icosa: ", plat_dihedral(icosa_sch));
398
-
399
- mycosasph = icosasph(inradius);
400
- mycosacart = [
401
- sph_to_cart(mycosasph[0]),
402
-
403
- sph_to_cart(mycosasph[1]),
404
- sph_to_cart(mycosasph[2]),
405
- sph_to_cart(mycosasph[3]),
406
- sph_to_cart(mycosasph[4]),
407
- sph_to_cart(mycosasph[5]),
408
-
409
- sph_to_cart(mycosasph[6]),
410
- sph_to_cart(mycosasph[7]),
411
- sph_to_cart(mycosasph[8]),
412
- sph_to_cart(mycosasph[9]),
413
- sph_to_cart(mycosasph[10]),
414
-
415
- sph_to_cart(mycosasph[11]),
416
- ];
417
-
418
- //mycosa=[mycosacart, ccw_icosafaces, icosaedges];
419
- mycosa=[mycosacart, icosafaces, icosaedges];
420
-
421
-
422
- //display_poly_verts(icosacart(20), 2.5);
423
- //display_polywireframe(icosaplat(20), radius=2.5, style=1);
424
-
425
- intersection()
426
- {
427
- rotate(v=[1,0,0], a=plat_dihedral(dodeca_sch)/2)
428
- display_polyhedron(dodecahedron(inradius));
429
-
430
- //color([0.5,0.5,0.5,0.5])
431
- rotate(v=[0,0,1], a=90)
432
- display_polyhedron(mycosa);
433
- }
434
- }
435
-
436
-
437
- module test_degrees()
438
- {
439
- d1 = deg(25, 17, 16);
440
- d2 = deg(18,34);
441
-
442
- echo("deg: ", d1, " decimal: ", deg_to_dec(d1));
443
- echo("deg: ", d2, " decimal: ", deg_to_dec(d2));
444
- }
445
-
446
-
447
-
448
-
449
- module test_dodeca()
450
- {
451
- echo("TEST_DODECA");
452
- poly = dodecahedron(20);
453
-
454
- //echo(poly);
455
-
456
- //verts = poly[0];
457
- verts = dodeca_cart;
458
- faces = poly[1];
459
-
460
- // difference()
461
- // {
462
- // display_polyhedron(poly);
463
- //
464
- // cylinder(r=0.5, h=2, center=true, $fn=24);
465
- // }
466
-
467
-
468
- // display_poly_verts(verts, radius=1);
469
- //
470
- color([0/5, 0/5, 0/5, 1])
471
- polyhedron(points=verts,
472
- triangles=[
473
- [0,1,2,3],
474
- ]);
475
-
476
- color([2/5, 2/5, 2/5, 1])
477
- polyhedron(points=verts,
478
- triangles=[
479
- [4,5,6,7],
480
- ]);
481
-
482
- color([3/5, 3/5, 3/5, 1])
483
- polyhedron(points=verts,
484
- triangles=[
485
- [8,9,10,11],
486
- ]);
487
-
488
- color([4/5, 4/5, 4/5, 1])
489
- polyhedron(points=verts,
490
- triangles=[
491
- [12,13,14,15],
492
- ]);
493
-
494
- color([5/5, 5/5, 5/5, 1])
495
- polyhedron(points=verts,
496
- triangles=[
497
- [16,17,18,19]
498
- ]);
499
-
500
- vertradius = 0.1;
501
- //display_verts(verts,[0,17,1,9,8], numverts=5, radius=vertradius);
502
- //display_verts(verts,[1,14,15,2,9], numverts=5, radius=vertradius);
503
- display_verts(verts,[9,2,16,3,8], numverts=5, radius=vertradius);
504
- //display_verts(verts,[0,8,3,12,13], numverts=5, radius=vertradius);
505
- //display_verts(verts,[0,13,4,18,17], numverts=5, radius=vertradius);
506
- //display_verts(verts,[1,17,18,7,14], numverts=5, radius=1);
507
- //display_verts(verts,[15,14,7,10,6], numverts=5, radius=1);
508
- //display_verts(verts,[2,15,6,19,16], numverts=5, radius=1);
509
- //display_verts(verts,[16,19,5,12,3], numverts=5, radius=1);
510
- //display_verts(verts,[12,5,11,4,13], numverts=5, radius=1);
511
- //display_verts(verts,[18,4,11,10,7], numverts=5, radius=1);
512
- //display_verts(verts,[19,6,10,11,5], numverts=5, radius=1);
513
-
514
- // Can't use pentagons directly as they won't
515
- // have enough precision to be coplanar
516
- // which will cause CGAL to fail
517
- color([0.5,0.5,0.5,0.5])
518
- polyhedron(points=verts,
519
- triangles=[
520
- [1,9,8,0,17],
521
- [9,1,14,15,2],
522
- [9,2,16,3,8],
523
- [8,3,12,13,0],
524
- [0,13,4,18,17],
525
- [1,17,18,7,14],
526
- [15,14,7,10,6],
527
- [2,15,6,19,16],
528
- [16,19,5,12,3],
529
- [12,5,11,4,13],
530
- [18,4,11,10,7],
531
- [19,6,10,11,5]
532
- ]);
533
- }
534
-
535
-
536
- //==========================================
537
- // ICOSAHEDRON
538
- //==========================================
539
- module test_icosa()
540
- {
541
- poly = icosahedron(10);
542
-
543
- verts = poly[0];
544
- faces = poly[1];
545
-
546
- vert1 = verts[faces[0][0]];
547
- vert2 = verts[faces[0][1]];
548
- svert1 = sph_from_cart(vert1);
549
- svert2 = sph_from_cart(vert2);
550
- distance = sph_dist(svert1, svert2);
551
-
552
- echo("vertex1: ", vert1);
553
- echo("vertex2: ", vert2);
554
- echo("spherical 1: ", svert1);
555
- echo("spherical 2: ", svert2);
556
-
557
- echo("vertex distance: ", distance);
558
- icosadihedral = plat_dihedral(icosa_sch);
559
- echo("Dihedral: ", icosadihedral, 180-icosadihedral);
560
- echo("Deficiency: ", plat_deficiency(icosa_sch));
561
-
562
- // difference()
563
- // {
564
- // display_polyhedron(poly);
565
- //
566
- // cylinder(r=0.5, h=2, center=true, $fn=24);
567
- // }
568
-
569
- //display_poly_verts(verts);
570
-
571
- color([0/5, 0/5, 0/5, 1])
572
- polyhedron(points=verts,
573
- triangles=[
574
- [0,1,2,3],
575
- ]);
576
-
577
- color([2/5, 2/5, 2/5, 1])
578
- polyhedron(points=verts,
579
- triangles=[
580
- [4,5,6,7],
581
- ]);
582
-
583
- color([3/5, 3/5, 3/5, 1])
584
- polyhedron(points=verts,
585
- triangles=[
586
- [8,9,10,11],
587
- ]);
588
-
589
- vertradius = .1;
590
- //display_verts(verts, [3,0,4], 3, radius = vertradius);
591
-
592
- polyhedron(points=verts,
593
- triangles=[
594
- [3,0,4],
595
- [3,4,9],
596
- [3,9,10],
597
- [3,10,7],
598
- [3,7,0],
599
- [0,8,4],
600
- [0,7,11],
601
- [0,11,8],
602
- [4,8,5],
603
- [4,5,9],
604
- [7,10,6],
605
- [7,6,11],
606
- [9,5,2],
607
- [9,2,10],
608
- [2,6,10],
609
- [1,5,8],
610
- [1,8,11],
611
- [1,11,6],
612
- [5,1,2],
613
- [2,1,6]
614
- ]);
615
- }
616
-