@jscad/web 2.5.8 → 2.5.11
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.
- package/CHANGELOG.md +32 -0
- package/README.md +7 -7
- package/css/demo.css +36 -34
- package/demo.html +3 -1
- package/dist/jscad-web.min.js +906 -2089
- package/examples/CHANGELOG.md +27 -0
- package/examples/README.md +4 -4
- package/examples/core/extrusions/nutsAndBolts.js +94 -0
- package/examples/examples.json +1 -1
- package/examples/package.json +2 -1
- package/examples/parameters/gear.js +1 -1
- package/locales/de.json +0 -6
- package/locales/en.json +0 -6
- package/locales/fr.json +0 -6
- package/locales/hr.json +0 -6
- package/locales/ja.json +0 -6
- package/package.json +9 -8
- package/src/sideEffects/worker/index.js +9 -5
- package/src/ui/flow/design.js +13 -3
- package/src/ui/views/options.js +0 -14
- package/src/ui/views/parameterControls.js +3 -3
- package/src/ui/views/status.js +21 -14
- package/src/ui/views/toolbar.js +3 -3
- package/css/big.css +0 -107
- package/css/min.css +0 -107
- package/css/openjscad.css +0 -135
package/examples/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.4.0](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/examples@2.3.4...@jscad/examples@2.4.0) (2022-05-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **examples:** new Nuts and Bolts example ([#1081](https://github.com/jscad/OpenJSCAD.org/issues/1081)) ([cd78003](https://github.com/jscad/OpenJSCAD.org/commit/cd7800351e56f7cd75f0add07cf068df328b7839))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [2.3.4](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/examples@2.3.3...@jscad/examples@2.3.4) (2022-04-24)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @jscad/examples
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [2.3.3](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/examples@2.3.2...@jscad/examples@2.3.3) (2022-04-03)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package @jscad/examples
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
## [2.3.2](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/examples@2.3.1...@jscad/examples@2.3.2) (2022-02-19)
|
|
7
34
|
|
|
8
35
|
**Note:** Version bump only for package @jscad/examples
|
package/examples/README.md
CHANGED
|
@@ -32,8 +32,8 @@ Install this package if you need access to the various examples.
|
|
|
32
32
|
|
|
33
33
|
## Documentation
|
|
34
34
|
|
|
35
|
-
- [JSCAD User Guide](https://
|
|
36
|
-
- [JSCAD API Reference](https://
|
|
35
|
+
- [JSCAD User Guide](https://openjscad.xyz/guide.html)
|
|
36
|
+
- [JSCAD API Reference](https://openjscad.xyz/docs/)
|
|
37
37
|
|
|
38
38
|
## Contributing
|
|
39
39
|
|
|
@@ -42,11 +42,11 @@ We welcome and encourage anyone to pitch in but please take a moment to read the
|
|
|
42
42
|
|
|
43
43
|
* If you want to submit a bug report please make sure to follow the [Reporting Issues](https://github.com/jscad/OpenJSCAD.org/wiki/Reporting-Issues) guide. Bug reports are accepted as [Issues](https://github.com/jscad/OpenJSCAD.org/issues/) via GitHub.
|
|
44
44
|
|
|
45
|
-
* If you want to submit a change or a patch, please read the [Contributing Guide](../../CONTRIBUTING.md)
|
|
45
|
+
* If you want to submit a change or a patch, please read the [Contributing Guide](../../CONTRIBUTING.md). New contributions are accepted as [Pull Requests](https://github.com/jscad/OpenJSCAD.org/pulls/) via GitHub.
|
|
46
46
|
|
|
47
47
|
* We only accept bug reports and pull requests on **GitHub**.
|
|
48
48
|
|
|
49
|
-
* If you have a question about how to use JSCAD, then please start a conversation at the [JSCAD User Group](https://openjscad.xyz/forum.html). You might find the answer in the [JSCAD User Guide](https://
|
|
49
|
+
* If you have a question about how to use JSCAD, then please start a conversation at the [JSCAD User Group](https://openjscad.xyz/forum.html). You might find the answer in the [JSCAD User Guide](https://openjscad.xyz/guide.html).
|
|
50
50
|
|
|
51
51
|
* If you have a change or new feature in mind, please start a conversation with the [Core Developers](https://openjscad.xyz/forum.html) and start contributing changes.
|
|
52
52
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nuts and Bolts
|
|
3
|
+
* @category Creating Shapes
|
|
4
|
+
* @skillLevel 8
|
|
5
|
+
* @description Demonstrating the advanced extrusion using slices to generate screw threads.
|
|
6
|
+
* @tags extrude, slice, slices, extrudefromslices, callback
|
|
7
|
+
* @authors platypii
|
|
8
|
+
* @licence MIT License
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const jscad = require('@jscad/modeling')
|
|
12
|
+
const { cylinder } = jscad.primitives
|
|
13
|
+
const { subtract, union } = jscad.booleans
|
|
14
|
+
const { colorize } = jscad.colors
|
|
15
|
+
const { extrudeFromSlices, slice } = jscad.extrusions
|
|
16
|
+
const { translate } = jscad.transforms
|
|
17
|
+
|
|
18
|
+
const options = {
|
|
19
|
+
hexWidth: 10,
|
|
20
|
+
hexHeight: 8,
|
|
21
|
+
threadLength: 32,
|
|
22
|
+
threadSize: 4,
|
|
23
|
+
innerRadius: 4,
|
|
24
|
+
outerRadius: 5.6,
|
|
25
|
+
slicesPerRevolution: 12,
|
|
26
|
+
segments: 32
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const main = () => {
|
|
30
|
+
return [
|
|
31
|
+
colorize([0.9, 0.6, 0.2], bolt(options)),
|
|
32
|
+
colorize([0.4, 0.4, 0.4], translate([30, 0, 0], nut(options)))
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// generate bolt by attaching threads to a hex head
|
|
37
|
+
const bolt = (options) => {
|
|
38
|
+
return union(
|
|
39
|
+
translate([0, 0, options.threadLength], hex(options)),
|
|
40
|
+
threads(options)
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// generate nut by subtracting threads from a hex block
|
|
45
|
+
const nut = (options) => {
|
|
46
|
+
return subtract(
|
|
47
|
+
hex(options),
|
|
48
|
+
threads({ ...options, threadLength: options.hexHeight })
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// generate hexagonal block
|
|
53
|
+
const hex = (options) => {
|
|
54
|
+
const radius = options.hexWidth * 1.1547005 // hexagon outer radius
|
|
55
|
+
const height = options.hexHeight
|
|
56
|
+
return cylinder({ center: [0, 0, height / 2], height, radius, segments: 6 })
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// generate a threaded shaft using extrudeFromSlices
|
|
60
|
+
const threads = (options) => {
|
|
61
|
+
const { innerRadius, outerRadius, segments, threadLength } = options
|
|
62
|
+
const revolutions = threadLength / options.threadSize
|
|
63
|
+
const numberOfSlices = options.slicesPerRevolution * revolutions
|
|
64
|
+
return extrudeFromSlices({
|
|
65
|
+
numberOfSlices,
|
|
66
|
+
callback: (progress, index, base) => {
|
|
67
|
+
// generate each slice manually
|
|
68
|
+
const points = []
|
|
69
|
+
for (let i = 0; i < segments; i++) {
|
|
70
|
+
const pointAngle = Math.PI * 2 * i / segments
|
|
71
|
+
const threadAngle = (2 * Math.PI * revolutions * progress) % (Math.PI * 2)
|
|
72
|
+
|
|
73
|
+
// define the shape of the threads
|
|
74
|
+
const phase = angleDiff(threadAngle, pointAngle) / Math.PI
|
|
75
|
+
const radius = lerp(innerRadius, outerRadius, 1.4 * phase - 0.2)
|
|
76
|
+
|
|
77
|
+
const x = radius * Math.cos(pointAngle)
|
|
78
|
+
const y = radius * Math.sin(pointAngle)
|
|
79
|
+
points.push([x, y, threadLength * progress])
|
|
80
|
+
}
|
|
81
|
+
return slice.fromPoints(points)
|
|
82
|
+
}
|
|
83
|
+
}, {})
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// linear interpolation with bounding
|
|
87
|
+
const lerp = (a, b, t) => Math.max(a, Math.min(b, a + (b - a) * t))
|
|
88
|
+
|
|
89
|
+
const angleDiff = (angle1, angle2) => {
|
|
90
|
+
const diff = Math.abs((angle1 - angle2) % (Math.PI * 2))
|
|
91
|
+
return diff > Math.PI ? Math.PI * 2 - diff : diff
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
module.exports = { main }
|
package/examples/examples.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"Creating Shapes":[{"title":"2D Primitives Demonstration","filePath":"examples/core/primitives/primitives2D.js","sort":1,"description":"Demonstrating the basics of a variety of 2D primitives"},{"title":"3D Primitives Demonstration","filePath":"examples/core/primitives/primitives3D.js","sort":1,"description":"Demonstrating the basics of a variety of 3D primitives"},{"title":"Rounded Cuboid","filePath":"examples/core/primitives/roundedCuboid.js","sort":1,"description":"Demonstrating the roundedCuboid() functiom"},{"title":"Spheres of all sorts","filePath":"examples/core/primitives/sphere.js","sort":1,"description":"Demonstrating the sphere() and geodesicSphere() functions"},{"title":"Building a Dodecahedron","filePath":"examples/core/primitives/dodecahedron.js","sort":2,"description":"building dodecahedron() from cuboids"},{"title":"Torus Variety","filePath":"examples/core/primitives/torus.js","sort":2,"description":"Demonstrating the capabilities and variations of the torus() primitive"},{"title":"Building a Polyhedron from scratch","filePath":"examples/core/primitives/polyhedron.js","sort":4,"description":"Demonstrating the polyhedron() function"},{"title":"Basic Extrude Functions","filePath":"examples/core/extrusions/basicExtrusions.js","sort":5,"description":"Demonstrating the basic types of extrusions, and the variety of objects they can create."},{"title":"Extrude Along a Bezier Path","filePath":"examples/core/curves/bezier/extrudeAlongPath.js","sort":5,"description":"Using a 3D bezier path to create a solid tube"},{"title":"Extrude From Slices","filePath":"examples/core/extrusions/extrudeFromSlices.js","sort":5,"description":"Demonstrating the advanced extrusion using slices with varying numbers of points."},{"title":"Simple Bezier Extrude","filePath":"examples/core/curves/bezier/simpleExtrude.js","sort":5,"description":"Using a 1D bezier function to create a non-uniform extrusion"},{"title":"Hull and HullChain 2D example","filePath":"examples/core/hulls/hull2D.js","sort":8,"description":"Demonstrating the basics of Hulls in two dimensions"},{"title":"Hull and HullChain 3D example","filePath":"examples/core/hulls/hull3D.js","sort":8,"description":"Demonstrating the basics of Hulls in three dimensions"},{"title":"Basic Text Creation","filePath":"examples/core/text/text.js","sort":10,"description":"Demonstrating methods of building 3D text"}],"Manipulating Shapes":[{"title":"Basic Booleans Demonstration","filePath":"examples/core/booleans/basicBooleans.js","sort":2,"description":"Demonstrating the basics of boolean shape combinations"},{"title":"Align function demonstration","filePath":"examples/core/transforms/align.js","sort":3,"description":"Demonstrating aligning shapes using the align function"},{"title":"Expanding 2D and 3D Shapes","filePath":"examples/core/expansions/expand.js","sort":5,"description":"Exploring the expand() function on 2D and 3D geometries"},{"title":"Offsetting 2D Shapes","filePath":"examples/core/expansions/offset.js","sort":5,"description":"Demonstrating the offset() function. Moves all points in a 2d path or 2D geometry perpendicular to the line's tangent."},{"title":"Center function demonstration","filePath":"examples/core/transforms/center.js","sort":10,"description":"Using center() to translate objects"},{"title":"Measure Aggregate Bounding Box","filePath":"examples/core/measurements/measureAggregateBounds.js","sort":10,"description":"Examples of measureAggregateBoundingBox function"},{"title":"Measure Area and Volume","filePath":"examples/core/measurements/measureAreaAndVolume.js","sort":10,"description":"Examples of measureArea() and measureVolume() function"},{"title":"Measure Bounding Box","filePath":"examples/core/measurements/measureBounds.js","sort":10,"description":"Examples of measureBoundingBox function"}],"Colors":[{"title":"Basic Colors","filePath":"examples/core/colors/basicColors.js","sort":1,"description":"showing various color functions"},{"title":"Color Cube","filePath":"examples/core/colors/colorCube.js","sort":2,"description":"looking at the different ways to specify a color"},{"title":"Transparency","filePath":"examples/core/colors/transparency.js","sort":2,"description":"showing transparent objects"}],"Parameters":[{"title":"All Parameter Types Demo","filePath":"examples/parameters/allParamTypes.js","sort":1,"description":"Example of interactive parameters"},{"title":"Birthday Balloons","filePath":"examples/parameters/balloons.js","sort":1,"description":"Example of building models from interactive parameters"},{"title":"Parametric Involute Gear","filePath":"examples/parameters/gear.js","sort":1,"description":"Build a proper involute gear, demonstrating parameters, and how they can be used in complex math."}],"Other":[{"title":"Coordinate system and Rotation demonstration","filePath":"examples/core/other/orientation.js","sort":1,"description":"Demonstrating rotation about the three axes."}]}
|
|
1
|
+
{"Creating Shapes":[{"title":"2D Primitives Demonstration","filePath":"examples/core/primitives/primitives2D.js","sort":1,"description":"Demonstrating the basics of a variety of 2D primitives"},{"title":"3D Primitives Demonstration","filePath":"examples/core/primitives/primitives3D.js","sort":1,"description":"Demonstrating the basics of a variety of 3D primitives"},{"title":"Rounded Cuboid","filePath":"examples/core/primitives/roundedCuboid.js","sort":1,"description":"Demonstrating the roundedCuboid() functiom"},{"title":"Spheres of all sorts","filePath":"examples/core/primitives/sphere.js","sort":1,"description":"Demonstrating the sphere() and geodesicSphere() functions"},{"title":"Building a Dodecahedron","filePath":"examples/core/primitives/dodecahedron.js","sort":2,"description":"building dodecahedron() from cuboids"},{"title":"Torus Variety","filePath":"examples/core/primitives/torus.js","sort":2,"description":"Demonstrating the capabilities and variations of the torus() primitive"},{"title":"Building a Polyhedron from scratch","filePath":"examples/core/primitives/polyhedron.js","sort":4,"description":"Demonstrating the polyhedron() function"},{"title":"Basic Extrude Functions","filePath":"examples/core/extrusions/basicExtrusions.js","sort":5,"description":"Demonstrating the basic types of extrusions, and the variety of objects they can create."},{"title":"Extrude Along a Bezier Path","filePath":"examples/core/curves/bezier/extrudeAlongPath.js","sort":5,"description":"Using a 3D bezier path to create a solid tube"},{"title":"Extrude From Slices","filePath":"examples/core/extrusions/extrudeFromSlices.js","sort":5,"description":"Demonstrating the advanced extrusion using slices with varying numbers of points."},{"title":"Simple Bezier Extrude","filePath":"examples/core/curves/bezier/simpleExtrude.js","sort":5,"description":"Using a 1D bezier function to create a non-uniform extrusion"},{"title":"Hull and HullChain 2D example","filePath":"examples/core/hulls/hull2D.js","sort":8,"description":"Demonstrating the basics of Hulls in two dimensions"},{"title":"Hull and HullChain 3D example","filePath":"examples/core/hulls/hull3D.js","sort":8,"description":"Demonstrating the basics of Hulls in three dimensions"},{"title":"Nuts and Bolts","filePath":"examples/core/extrusions/nutsAndBolts.js","sort":8,"description":"Demonstrating the advanced extrusion using slices to generate screw threads."},{"title":"Basic Text Creation","filePath":"examples/core/text/text.js","sort":10,"description":"Demonstrating methods of building 3D text"}],"Manipulating Shapes":[{"title":"Basic Booleans Demonstration","filePath":"examples/core/booleans/basicBooleans.js","sort":2,"description":"Demonstrating the basics of boolean shape combinations"},{"title":"Align function demonstration","filePath":"examples/core/transforms/align.js","sort":3,"description":"Demonstrating aligning shapes using the align function"},{"title":"Expanding 2D and 3D Shapes","filePath":"examples/core/expansions/expand.js","sort":5,"description":"Exploring the expand() function on 2D and 3D geometries"},{"title":"Offsetting 2D Shapes","filePath":"examples/core/expansions/offset.js","sort":5,"description":"Demonstrating the offset() function. Moves all points in a 2d path or 2D geometry perpendicular to the line's tangent."},{"title":"Center function demonstration","filePath":"examples/core/transforms/center.js","sort":10,"description":"Using center() to translate objects"},{"title":"Measure Aggregate Bounding Box","filePath":"examples/core/measurements/measureAggregateBounds.js","sort":10,"description":"Examples of measureAggregateBoundingBox function"},{"title":"Measure Area and Volume","filePath":"examples/core/measurements/measureAreaAndVolume.js","sort":10,"description":"Examples of measureArea() and measureVolume() function"},{"title":"Measure Bounding Box","filePath":"examples/core/measurements/measureBounds.js","sort":10,"description":"Examples of measureBoundingBox function"}],"Colors":[{"title":"Basic Colors","filePath":"examples/core/colors/basicColors.js","sort":1,"description":"showing various color functions"},{"title":"Color Cube","filePath":"examples/core/colors/colorCube.js","sort":2,"description":"looking at the different ways to specify a color"},{"title":"Transparency","filePath":"examples/core/colors/transparency.js","sort":2,"description":"showing transparent objects"}],"Parameters":[{"title":"All Parameter Types Demo","filePath":"examples/parameters/allParamTypes.js","sort":1,"description":"Example of interactive parameters"},{"title":"Birthday Balloons","filePath":"examples/parameters/balloons.js","sort":1,"description":"Example of building models from interactive parameters"},{"title":"Parametric Involute Gear","filePath":"examples/parameters/gear.js","sort":1,"description":"Build a proper involute gear, demonstrating parameters, and how they can be used in complex math."}],"Other":[{"title":"Coordinate system and Rotation demonstration","filePath":"examples/core/other/orientation.js","sort":1,"description":"Demonstrating rotation about the three axes."}]}
|
package/examples/package.json
CHANGED
|
@@ -50,7 +50,7 @@ const createSingleToothPolygon = (maxAngle, baseRadius, angularToothWidthAtBase)
|
|
|
50
50
|
const points = [[0, 0]]
|
|
51
51
|
for (let i = 0; i <= toothCurveResolution; i++) {
|
|
52
52
|
// first side of the tooth:
|
|
53
|
-
const angle = maxAngle * i / toothCurveResolution
|
|
53
|
+
const angle = maxAngle * Math.pow(i / toothCurveResolution, 2 / 3)
|
|
54
54
|
const tanLength = angle * baseRadius
|
|
55
55
|
let radiantVector = vec2.fromAngleRadians(vec2.create(), angle)
|
|
56
56
|
let tangentVector = vec2.scale(vec2.create(), vec2.normal(vec2.create(), radiantVector), -tanLength)
|
package/locales/de.json
CHANGED
|
@@ -14,12 +14,6 @@
|
|
|
14
14
|
"enable geometry caching":"Experimenteles caching von Geometrie,",
|
|
15
15
|
"timeout for generation":"Abfallzeit für generieren von Soliden (ms)",
|
|
16
16
|
|
|
17
|
-
"Storage":"Speicher",
|
|
18
|
-
"settings storage path":"Dateipfad für Einstellungen",
|
|
19
|
-
|
|
20
|
-
"File Handling":"File Handling",
|
|
21
|
-
"enable conversion to scripts":"Convert external formats to JSCAD scripts",
|
|
22
|
-
|
|
23
17
|
"Shortcuts":"Tastenkombinationen",
|
|
24
18
|
|
|
25
19
|
"Command":"Befehl",
|
package/locales/en.json
CHANGED
|
@@ -14,12 +14,6 @@
|
|
|
14
14
|
"enable geometry caching":"Enable Experimental Geometry Caching, ",
|
|
15
15
|
"timeout for generation":"Timeout for Solid Generation (ms)",
|
|
16
16
|
|
|
17
|
-
"Storage": "Storage",
|
|
18
|
-
"settings storage path":"Storage path of settings",
|
|
19
|
-
|
|
20
|
-
"File Handling": "File Handling",
|
|
21
|
-
"enable conversion to scripts":"Convert external formats to JSCAD scripts",
|
|
22
|
-
|
|
23
17
|
"Shortcuts":"Keyboard Shortcuts",
|
|
24
18
|
|
|
25
19
|
"Command":"Command",
|
package/locales/fr.json
CHANGED
|
@@ -14,12 +14,6 @@
|
|
|
14
14
|
"enable geometry caching":"Systeme de cache experimental de la geometrie",
|
|
15
15
|
"timeout for generation": "Timeout génération de solides (ms)",
|
|
16
16
|
|
|
17
|
-
"Storage":"Stockage",
|
|
18
|
-
"settings storage path":"Chemin de stockage des paramètres",
|
|
19
|
-
|
|
20
|
-
"File Handling": "File Handling",
|
|
21
|
-
"enable conversion to scripts":"Convert external formats to JSCAD scripts",
|
|
22
|
-
|
|
23
17
|
"Shortcuts":"Racourcis Clavier",
|
|
24
18
|
|
|
25
19
|
"Command":"Commande",
|
package/locales/hr.json
CHANGED
|
@@ -14,12 +14,6 @@
|
|
|
14
14
|
"enable geometry caching":"Omogući eksperimentalno cachiranje geometrije, ",
|
|
15
15
|
"timeout for generation":"Timeout za generiranje modela (ms)",
|
|
16
16
|
|
|
17
|
-
"Storage": "Spremanje",
|
|
18
|
-
"settings storage path":"Putanja za spremanje postavki",
|
|
19
|
-
|
|
20
|
-
"File Handling": "Obrada datoteka",
|
|
21
|
-
"enable conversion to scripts":"Prevedi vanjske formate u JSCAD skripte",
|
|
22
|
-
|
|
23
17
|
"Shortcuts":"Kratice za tipkovnicu",
|
|
24
18
|
|
|
25
19
|
"Command":"Komanda",
|
package/locales/ja.json
CHANGED
|
@@ -14,12 +14,6 @@
|
|
|
14
14
|
"enable geometry caching":"experimental geometry caching",
|
|
15
15
|
"timeout for generation":"図形の生成タイムアウト",
|
|
16
16
|
|
|
17
|
-
"Storage": "ストレージ",
|
|
18
|
-
"settings storage path":"ストレージ パス",
|
|
19
|
-
|
|
20
|
-
"File Handling":"ファイル処理",
|
|
21
|
-
"enable conversion to scripts":"外部形式をスクリプトに変換",
|
|
22
|
-
|
|
23
17
|
"Shortcuts":"キーボード ショートカット",
|
|
24
18
|
|
|
25
19
|
"Command":"コマンド",
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jscad/web",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.11",
|
|
4
4
|
"description": "Web Application for JSCAD",
|
|
5
|
+
"homepage": "https://openjscad.xyz/",
|
|
5
6
|
"repository": "https://github.com/jscad/OpenJSCAD.org",
|
|
6
7
|
"main": "src/index.js",
|
|
7
8
|
"unpkg": "dist/jscad-web.min.js",
|
|
@@ -34,12 +35,12 @@
|
|
|
34
35
|
],
|
|
35
36
|
"license": "MIT",
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"@jscad/array-utils": "2.1.
|
|
38
|
-
"@jscad/core": "2.
|
|
39
|
-
"@jscad/examples": "2.
|
|
40
|
-
"@jscad/io": "2.
|
|
41
|
-
"@jscad/modeling": "2.9.
|
|
42
|
-
"@jscad/regl-renderer": "2.
|
|
38
|
+
"@jscad/array-utils": "2.1.4",
|
|
39
|
+
"@jscad/core": "2.6.1",
|
|
40
|
+
"@jscad/examples": "2.4.1",
|
|
41
|
+
"@jscad/io": "2.4.0",
|
|
42
|
+
"@jscad/modeling": "2.9.5",
|
|
43
|
+
"@jscad/regl-renderer": "2.6.1",
|
|
43
44
|
"@most/create": "2.0.1",
|
|
44
45
|
"brace": "0.11.1",
|
|
45
46
|
"codemirror": "5.65.2",
|
|
@@ -66,5 +67,5 @@
|
|
|
66
67
|
"url": "https://opencollective.com/openjscad",
|
|
67
68
|
"logo": "https://opencollective.com/openjscad/logo.txt"
|
|
68
69
|
},
|
|
69
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "225b034db0d94f748992da72b269833954a2e212"
|
|
70
71
|
}
|
|
@@ -3,24 +3,28 @@ const WebWorkify = require('webworkify')
|
|
|
3
3
|
const callBackToStream = require('../../most-utils/callbackToObservable')
|
|
4
4
|
|
|
5
5
|
const makeWorkerEffect = (workerPath) => {
|
|
6
|
+
const workerEventsCb = callBackToStream()
|
|
7
|
+
|
|
6
8
|
let _worker = WebWorkify(workerPath)
|
|
7
9
|
_worker.onerror = (error) => workerEventsCb.callback({ error })
|
|
8
10
|
_worker.onmessage = (message) => workerEventsCb.callback(message)
|
|
9
|
-
const workerEventsCb = callBackToStream()
|
|
10
11
|
|
|
11
12
|
const workerSink = (outToWorker$) => {
|
|
12
13
|
// cancel whatever is going on in the worker by terminating it
|
|
13
14
|
outToWorker$.filter(({ cmd }) => cmd === 'cancel')
|
|
14
15
|
.forEach((_) => _worker.terminate())
|
|
16
|
+
|
|
15
17
|
// send other messages to the worker
|
|
16
18
|
outToWorker$
|
|
17
19
|
.filter(({ cmd }) => cmd !== 'cancel')
|
|
18
|
-
.forEach((
|
|
19
|
-
|
|
20
|
-
_worker
|
|
20
|
+
.forEach((task) => {
|
|
21
|
+
// FIXME: sub optimal ! worker recreation is SLOW and should not be systematic
|
|
22
|
+
_worker.terminate()
|
|
23
|
+
_worker = WebWorkify(workerPath)
|
|
21
24
|
_worker.onerror = (error) => workerEventsCb.callback({ error })
|
|
22
25
|
_worker.onmessage = (message) => workerEventsCb.callback(message)
|
|
23
|
-
|
|
26
|
+
// do the task
|
|
27
|
+
_worker.postMessage(task)
|
|
24
28
|
})
|
|
25
29
|
}
|
|
26
30
|
|
package/src/ui/flow/design.js
CHANGED
|
@@ -50,9 +50,6 @@ const reducers = {
|
|
|
50
50
|
// code
|
|
51
51
|
instantUpdate: false,
|
|
52
52
|
autoReload: false,
|
|
53
|
-
// if set to true, will overwrite existing code with the converted imput
|
|
54
|
-
// if set to false, will create a script with an import of the input
|
|
55
|
-
convertSupportedTypes: false,
|
|
56
53
|
// parameters
|
|
57
54
|
parameterDefinitions: [],
|
|
58
55
|
parameterValues: {},
|
|
@@ -578,6 +575,17 @@ const actions = ({ sources }) => {
|
|
|
578
575
|
.multicast()
|
|
579
576
|
.delay(10) // needed , why ?
|
|
580
577
|
|
|
578
|
+
// errors retrieved from worker
|
|
579
|
+
const errorsFromWorker$ = sources.solidWorker
|
|
580
|
+
.filter((event) => event.data instanceof Object && event.data.type === 'errors')
|
|
581
|
+
.map(({ data }) => ({ error: data, origin: 'worker' }))
|
|
582
|
+
|
|
583
|
+
const reportErrorsFromWorker$ = most.mergeArray([
|
|
584
|
+
errorsFromWorker$
|
|
585
|
+
])
|
|
586
|
+
.skipRepeatsWith(jsonCompare)
|
|
587
|
+
.tap((x) => console.log('errors', x))
|
|
588
|
+
|
|
581
589
|
// ui/toggles
|
|
582
590
|
const toggleAutoReload$ = most.mergeArray([
|
|
583
591
|
sources.dom.select('#toggleAutoReload').events('click')
|
|
@@ -618,6 +626,8 @@ const actions = ({ sources }) => {
|
|
|
618
626
|
setDesignParameterDefinitions$,
|
|
619
627
|
setDesignParameterValues$,
|
|
620
628
|
|
|
629
|
+
reportErrorsFromWorker$,
|
|
630
|
+
|
|
621
631
|
requestGeometryRecompute$,
|
|
622
632
|
timeoutGeometryRecompute$,
|
|
623
633
|
cancelGeometryRecompute$,
|
package/src/ui/views/options.js
CHANGED
|
@@ -38,20 +38,6 @@ const options = (state, i18n) => {
|
|
|
38
38
|
</label>
|
|
39
39
|
</fieldset>
|
|
40
40
|
|
|
41
|
-
<fieldset>
|
|
42
|
-
<legend> <h3> ${i18n`Storage`} </h3> </legend>
|
|
43
|
-
<label>${i18n`settings storage path`} ${i18n`not settable`}
|
|
44
|
-
<input type='text' disabled value='${state.storage.path}' disabled />
|
|
45
|
-
</label>
|
|
46
|
-
</fieldset>
|
|
47
|
-
|
|
48
|
-
<fieldset>
|
|
49
|
-
<legend> <h3> ${i18n`File Handling`} </h3> </legend>
|
|
50
|
-
<label>${i18n`enable conversion to scripts`}
|
|
51
|
-
<input type='checkbox' checked=false id='design-convertSupportedTypes' checked=${state.design.convertSupportedTypes}/>
|
|
52
|
-
</label>
|
|
53
|
-
</fieldset>
|
|
54
|
-
|
|
55
41
|
${shortcuts}
|
|
56
42
|
|
|
57
43
|
</section>`
|
|
@@ -263,19 +263,19 @@ const createInputControl = (definition, prevValue) => {
|
|
|
263
263
|
|
|
264
264
|
// check for required parameters
|
|
265
265
|
if (!('type' in definition)) {
|
|
266
|
-
throw new Error(
|
|
266
|
+
throw new Error(`Parameter definition (${definition.name}) must include a 'type' parameter`)
|
|
267
267
|
}
|
|
268
268
|
let typeData = controlList.filter((x) => definition.type === x.type)
|
|
269
269
|
typeData = (typeData && typeData.length > 0) ? typeData[0] : undefined
|
|
270
270
|
if (!typeData) {
|
|
271
|
-
throw new Error(
|
|
271
|
+
throw new Error(`Parameter definition (${definition.name}), invalid type "${definition.type}"`)
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
// validate fields
|
|
275
275
|
const definitionFields = Object.keys(definition)
|
|
276
276
|
typeData.required.forEach((requiredField) => {
|
|
277
277
|
if (!definitionFields.includes(requiredField)) {
|
|
278
|
-
throw new Error(`Parameter definition
|
|
278
|
+
throw new Error(`Parameter definition of type "${definition.type}" must include a "${requiredField}" parameter`)
|
|
279
279
|
}
|
|
280
280
|
})
|
|
281
281
|
|
package/src/ui/views/status.js
CHANGED
|
@@ -3,29 +3,36 @@ const html = require('nanohtml')
|
|
|
3
3
|
// status display
|
|
4
4
|
const status = (state, paramsCallbacktoStream) => {
|
|
5
5
|
const status = state.status
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
let errorWhere = ''
|
|
7
|
+
let errorMessage = ''
|
|
8
|
+
let errorStack = ''
|
|
9
|
+
if (status.error) {
|
|
10
|
+
if (status.error.fileName && !status.error.fileName.startsWith('blob')) {
|
|
11
|
+
// syntax errors provide file name, line, and column number
|
|
12
|
+
errorWhere = `${status.error.fileName}:${status.error.lineNumber}:${status.error.columnNumber}`
|
|
13
|
+
}
|
|
14
|
+
errorMessage = `${status.error.name}: ${status.error.message}`
|
|
15
|
+
if (status.error.stack) {
|
|
16
|
+
errorStack = status.error.stack.trim().split('\n').map((s) => html`<ul>${s}</ul>`)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
9
19
|
|
|
10
20
|
const statusMessage = status.error !== undefined
|
|
11
21
|
? html`<span>
|
|
12
|
-
<div>
|
|
13
|
-
|
|
22
|
+
<div id='errormessage'>
|
|
23
|
+
<p>
|
|
24
|
+
${errorWhere}
|
|
25
|
+
</p>
|
|
26
|
+
<p>
|
|
27
|
+
${errorMessage}
|
|
28
|
+
</p>
|
|
14
29
|
</div>
|
|
15
|
-
<div>
|
|
16
|
-
${errorMessage}
|
|
17
|
-
</div>
|
|
18
|
-
<div>
|
|
19
|
-
${errorLine}
|
|
20
|
-
</div>
|
|
21
|
-
<div>
|
|
30
|
+
<div id='stacktrace'>
|
|
22
31
|
${errorStack}
|
|
23
32
|
</div>
|
|
24
33
|
</span>`
|
|
25
34
|
: ''
|
|
26
35
|
|
|
27
|
-
// ? `Error: ${status.error.message} line: ${status.error.lineno}, filename:${status.error.filename} stack: ${status.error.stack}` : ''
|
|
28
|
-
// ${statusMessage}
|
|
29
36
|
const busy = status.busy
|
|
30
37
|
return html`
|
|
31
38
|
<span id='status'>
|
package/src/ui/views/toolbar.js
CHANGED
|
@@ -6,13 +6,13 @@ const toolbar = (state, i18n) => {
|
|
|
6
6
|
const helpIcon = html`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-help-circle"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12" y2="17"/></svg>`
|
|
7
7
|
|
|
8
8
|
return html`<span id='toolbar'>
|
|
9
|
-
<button id='toggleOptions'>
|
|
9
|
+
<button id='toggleOptions' aria-label='options'>
|
|
10
10
|
${optionsIcon}
|
|
11
11
|
</button>
|
|
12
|
-
<button id='toggleEditor'>
|
|
12
|
+
<button id='toggleEditor' aria-label='editor'>
|
|
13
13
|
${editorIcon}
|
|
14
14
|
</button>
|
|
15
|
-
<button id='toggleHelp'>
|
|
15
|
+
<button id='toggleHelp' aria-label='help'>
|
|
16
16
|
${helpIcon}
|
|
17
17
|
</button>
|
|
18
18
|
</span>`
|
package/css/big.css
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* min.css for OpenJSCAD.org viewer
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
.jscad-container {
|
|
6
|
-
margin: 5px 15px 5px 5px; /* not inherited */
|
|
7
|
-
padding: 20px; /* not inherited */
|
|
8
|
-
color: Black;
|
|
9
|
-
font-weight: bold;
|
|
10
|
-
font-family: Helvetica, Arial, Sans;
|
|
11
|
-
border: thin solid black;
|
|
12
|
-
min-width: 410px;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
#header {
|
|
16
|
-
margin: 5px; /* not inherited */
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
#viewerContext {
|
|
20
|
-
margin: 5px; /* not inherited */
|
|
21
|
-
border: thin solid gray; /* not inherited */
|
|
22
|
-
padding: 0px; /* not inherited */
|
|
23
|
-
|
|
24
|
-
background: white;
|
|
25
|
-
width: 1200px;
|
|
26
|
-
height: 900px;
|
|
27
|
-
|
|
28
|
-
top: 0px;
|
|
29
|
-
bottom: 0px;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
canvas {
|
|
33
|
-
margin: 0px; /* not inherited */
|
|
34
|
-
border: 0px none gray; /* not inherited */
|
|
35
|
-
padding: 0px; /* not inherited */
|
|
36
|
-
|
|
37
|
-
width: 100%;
|
|
38
|
-
height: 100%;
|
|
39
|
-
|
|
40
|
-
cursor: move;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
#parametersdiv {
|
|
44
|
-
margin: 5px; /* not inherited */
|
|
45
|
-
border: thin solid rgb(200,200,200);
|
|
46
|
-
border-radius: 1em;
|
|
47
|
-
padding: 10px;
|
|
48
|
-
|
|
49
|
-
background: white;
|
|
50
|
-
opacity: 0.8;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
#parametersdiv table {
|
|
54
|
-
margin-bottom: 5px;
|
|
55
|
-
|
|
56
|
-
text-align: left;
|
|
57
|
-
font-size: 0.8em;
|
|
58
|
-
font-weight: normal;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
#parametersdiv th {
|
|
62
|
-
margin: 0px; /* not inherited */
|
|
63
|
-
border: 0px none gray; /* not inherited */
|
|
64
|
-
padding: 5px; /* not inherited */
|
|
65
|
-
|
|
66
|
-
font-weight: bold;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
#parametersdiv th.caption {
|
|
70
|
-
text-decoration: underline;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
#parametersdiv td.caption {
|
|
74
|
-
text-align: right;
|
|
75
|
-
font-weight: bold;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
#parametersdiv td {
|
|
79
|
-
margin: 0px; /* not inherited */
|
|
80
|
-
border: 0px none gray; /* not inherited */
|
|
81
|
-
padding: 0px; /* not inherited */
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
#parametersdiv input, #parametersdiv textarea, #parametersdiv select {
|
|
85
|
-
font-size: 0.9em;
|
|
86
|
-
background: #fea;
|
|
87
|
-
border: none;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
#updateButton {
|
|
91
|
-
margin: 5px; /* not inherited */
|
|
92
|
-
border: thin solid Black; /* not inherited */
|
|
93
|
-
padding: 2px; /* not inherited */
|
|
94
|
-
border-radius: 4px;
|
|
95
|
-
background: white;
|
|
96
|
-
|
|
97
|
-
margin-left: 1em;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
#tail {
|
|
101
|
-
margin: 5px; /* not inherited */
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
#busy {
|
|
105
|
-
vertical-align: middle;
|
|
106
|
-
}
|
|
107
|
-
|