generator-jscad 2.1.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/generators/app/index.js +47 -2
- package/generators/app/templates/_gitignore +4 -1
- package/generators/app/templates/_gitlab-ci.yml +3 -0
- package/generators/app/templates/_vitepress/config.mjs +26 -0
- package/generators/app/templates/_vitepress/theme/components/VuepressOpenJscad.vue +17 -0
- package/generators/app/templates/_vitepress/theme/custom.css +6 -0
- package/generators/app/templates/_vitepress/theme/index.js +13 -0
- package/generators/app/templates/gulpfile.js +32 -27
- package/generators/app/templates/main-checkbox.jscad +181 -0
- package/generators/app/templates/main-list.jscad +154 -0
- package/generators/app/templates/main.jscad +14 -6
- package/generators/app/templates/package.json +22 -17
- package/generators/app/templates/prettier.config.js +7 -0
- package/package.json +17 -17
- package/CHANGELOG.md +0 -60
- package/generators/.DS_Store +0 -0
- package/generators/app/templates/_vuepress/components/VuepressOpenJscad.vue +0 -14
- package/generators/app/templates/_vuepress/config.js +0 -10
package/README.md
CHANGED
|
@@ -17,6 +17,14 @@ Then generate your new project:
|
|
|
17
17
|
yo jscad
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
You can select the type of project you want to build. A single object project is the default. You can create a multi object project with selection via a dropdown list or a set of check boxes. These are more complex, but allow you to organize and view a much larger project.
|
|
21
|
+
|
|
22
|
+

|
|
23
|
+
|
|
24
|
+
You can also create a VitePress site with a live viewer.
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+
|
|
20
28
|
## Running
|
|
21
29
|
|
|
22
30
|
The jscad project uses gulp to create a `dist` directory and watch for changes. You can drag the `dist` directory into the drop area on [openjscad.org](http://openjscad.org). Make sure you check `Auto Reload` and any time you save, glup will recreate the `dist` directory files and your model should refresh.
|
|
@@ -27,7 +35,7 @@ The example project uses [jscad-utils](https://www.npmjs.com/package/jscad-utils
|
|
|
27
35
|
|
|
28
36
|
## License
|
|
29
37
|
|
|
30
|
-
MIT © [John Cole](https://
|
|
38
|
+
MIT © [John Cole](https://jwc.dev/)
|
|
31
39
|
|
|
32
40
|
[npm-image]: https://badge.fury.io/js/generator-jscad.svg
|
|
33
41
|
[npm-url]: https://npmjs.org/package/generator-jscad
|
package/generators/app/index.js
CHANGED
|
@@ -35,6 +35,20 @@ module.exports = class extends Generator {
|
|
|
35
35
|
message: 'Description',
|
|
36
36
|
default: this.config.get('description')
|
|
37
37
|
},
|
|
38
|
+
{
|
|
39
|
+
name: 'projectType',
|
|
40
|
+
message: 'What type of project?',
|
|
41
|
+
default: this.config.get('projectType'),
|
|
42
|
+
type: 'list',
|
|
43
|
+
choices: [
|
|
44
|
+
{ name: 'single part', value: 'single' },
|
|
45
|
+
{ name: 'multiple parts choose with a list', value: 'multi-list' },
|
|
46
|
+
{
|
|
47
|
+
name: 'multiple parts choose with a checkbox',
|
|
48
|
+
value: 'multi-checkbox'
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
},
|
|
38
52
|
{
|
|
39
53
|
name: 'author',
|
|
40
54
|
message: 'Author',
|
|
@@ -47,12 +61,13 @@ module.exports = class extends Generator {
|
|
|
47
61
|
}
|
|
48
62
|
];
|
|
49
63
|
|
|
50
|
-
return this.prompt(prompts).then(props => {
|
|
64
|
+
return this.prompt(prompts).then((props) => {
|
|
51
65
|
// To access props later use this.props.someAnswer;
|
|
52
66
|
this.props = props;
|
|
53
67
|
|
|
54
68
|
this.config.set('name', this.props.name);
|
|
55
69
|
this.config.set('description', this.props.description);
|
|
70
|
+
this.config.set('projectType', this.props.projectType);
|
|
56
71
|
this.config.set('author', this.props.author);
|
|
57
72
|
this.config.set('homepage', this.props.homepage);
|
|
58
73
|
});
|
|
@@ -108,8 +123,14 @@ module.exports = class extends Generator {
|
|
|
108
123
|
* Do not overwrite the main code file.
|
|
109
124
|
*/
|
|
110
125
|
if (!this.fs.exists(this.props.name + '.jscad')) {
|
|
126
|
+
var template =
|
|
127
|
+
this.props.projectType == 'single'
|
|
128
|
+
? 'main.jscad'
|
|
129
|
+
: this.props.projectType == 'multi-list'
|
|
130
|
+
? 'main-list.jscad'
|
|
131
|
+
: 'main-checkbox.jscad';
|
|
111
132
|
this.fs.copyTpl(
|
|
112
|
-
this.templatePath(
|
|
133
|
+
this.templatePath(template),
|
|
113
134
|
this.destinationPath(this.props.name + '.jscad'),
|
|
114
135
|
{
|
|
115
136
|
name: this.props.name,
|
|
@@ -135,6 +156,11 @@ module.exports = class extends Generator {
|
|
|
135
156
|
this.templatePath('_gitlab-ci.yml'),
|
|
136
157
|
this.destinationPath('.gitlab-ci.yml')
|
|
137
158
|
);
|
|
159
|
+
|
|
160
|
+
this.fs.copy(
|
|
161
|
+
this.templatePath('prettier.config.js'),
|
|
162
|
+
this.destinationPath('prettier.config.js')
|
|
163
|
+
);
|
|
138
164
|
}
|
|
139
165
|
|
|
140
166
|
install() {
|
|
@@ -144,4 +170,23 @@ module.exports = class extends Generator {
|
|
|
144
170
|
this.composeWith(require.resolve('generator-git-init'), {});
|
|
145
171
|
}
|
|
146
172
|
}
|
|
173
|
+
|
|
174
|
+
end() {
|
|
175
|
+
this.log(`
|
|
176
|
+
|
|
177
|
+
jscad generator is finished.
|
|
178
|
+
|
|
179
|
+
Available scripts:
|
|
180
|
+
|
|
181
|
+
Bundle the '${this.props.name + '.jscad'}' file into the 'dist' directory.
|
|
182
|
+
npm start
|
|
183
|
+
|
|
184
|
+
Run the development VuePress site.
|
|
185
|
+
npm run serve
|
|
186
|
+
|
|
187
|
+
Build the 'dist' directory and the VuePress site.
|
|
188
|
+
npm run build
|
|
189
|
+
|
|
190
|
+
`);
|
|
191
|
+
}
|
|
147
192
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineConfig } from 'vitepress'
|
|
2
|
+
|
|
3
|
+
// https://vitepress.dev/reference/site-config
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
title: "<%= name %>",
|
|
6
|
+
description: "<%= description %>",
|
|
7
|
+
srcDir: '.',
|
|
8
|
+
rewrites: {
|
|
9
|
+
'README.md': 'index.md'
|
|
10
|
+
},
|
|
11
|
+
themeConfig: {
|
|
12
|
+
// https://vitepress.dev/reference/default-theme-config
|
|
13
|
+
nav: [
|
|
14
|
+
{ text: 'Home', link: '/' }
|
|
15
|
+
],
|
|
16
|
+
|
|
17
|
+
socialLinks: [
|
|
18
|
+
{ icon: 'gitlab', link: 'https://gitlab.com/johnwebbcole/<%= name %>' }
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
vite: {
|
|
22
|
+
ssr: {
|
|
23
|
+
noExternal: ['@jwc/vue-openjscad', 'debug']
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<ClientOnly>
|
|
4
|
+
<OpenJscad v-bind="$attrs"></OpenJscad>
|
|
5
|
+
</ClientOnly>
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup>
|
|
10
|
+
import { defineClientComponent } from 'vitepress';
|
|
11
|
+
|
|
12
|
+
const OpenJscad = defineClientComponent(() => {
|
|
13
|
+
return import('@jwc/vue-openjscad/')
|
|
14
|
+
})
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import DefaultTheme from 'vitepress/theme'
|
|
2
|
+
import './custom.css'
|
|
3
|
+
|
|
4
|
+
// Import your custom components
|
|
5
|
+
import VuepressOpenJscad from './components/VuepressOpenJscad.vue'
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
extends: DefaultTheme,
|
|
9
|
+
enhanceApp({ app }) {
|
|
10
|
+
// Register global components
|
|
11
|
+
app.component('VuepressOpenJscad', VuepressOpenJscad)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,28 +1,33 @@
|
|
|
1
|
-
/* globals
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
/* globals import */
|
|
2
|
+
import { deleteSync } from 'del';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import gulp from 'gulp';
|
|
5
|
+
import debug from 'gulp-debug';
|
|
6
|
+
import inject from 'gulp-inject';
|
|
7
|
+
import jscadFiles from 'gulp-jscad-files';
|
|
8
|
+
import { getInjected } from 'gulp-jscad-files/getPackage.js';
|
|
9
|
+
import plumber from 'gulp-plumber';
|
|
10
|
+
import terser from 'gulp-terser';
|
|
11
|
+
import merge2 from 'merge2';
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const pkg = JSON.parse(readFileSync('./package.json', 'utf8'));
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
gulp.task('clean', function (done) {
|
|
17
|
+
const paths = deleteSync(['dist/*'])
|
|
18
|
+
console.log('Deleted files and folders:\n', paths.join('\n')); // eslint-disable-line no-console, no-undef
|
|
19
|
+
done();
|
|
16
20
|
});
|
|
17
21
|
|
|
18
|
-
gulp.task('inject', function() {
|
|
22
|
+
gulp.task('inject', function () {
|
|
19
23
|
return gulp
|
|
20
24
|
.src('<%= name %>.jscad')
|
|
21
25
|
.pipe(plumber())
|
|
26
|
+
.pipe(debug({ title: 'start:' }))
|
|
22
27
|
.pipe(
|
|
23
28
|
inject(
|
|
24
29
|
merge2(
|
|
25
|
-
gulp.src(['*.jscad'], { ignore: ['<%= name %>.jscad'] }),
|
|
30
|
+
gulp.src(['*.jscad'], { ignore: ['<%= name %>.jscad'] }).pipe(debug({ title: 'src:' })),
|
|
26
31
|
gulp
|
|
27
32
|
.src('package.json')
|
|
28
33
|
.pipe(jscadFiles())
|
|
@@ -37,13 +42,13 @@ gulp.task('inject', function() {
|
|
|
37
42
|
max_line_len: 80
|
|
38
43
|
}
|
|
39
44
|
})
|
|
40
|
-
)
|
|
45
|
+
).pipe(debug({ title: 'package.json:' }))
|
|
41
46
|
).pipe(debug({ title: 'injecting:' })),
|
|
42
47
|
{
|
|
43
48
|
relative: true,
|
|
44
49
|
starttag: '// include:js',
|
|
45
50
|
endtag: '// endinject',
|
|
46
|
-
transform: function(filepath, file) {
|
|
51
|
+
transform: function (filepath, file) {
|
|
47
52
|
return '// ' + filepath + '\n' + file.contents.toString('utf8');
|
|
48
53
|
}
|
|
49
54
|
}
|
|
@@ -52,30 +57,30 @@ gulp.task('inject', function() {
|
|
|
52
57
|
.pipe(gulp.dest('dist'));
|
|
53
58
|
});
|
|
54
59
|
|
|
60
|
+
|
|
55
61
|
gulp.task(
|
|
56
|
-
'
|
|
57
|
-
gulp.series(
|
|
62
|
+
'vitepress',
|
|
63
|
+
gulp.series('inject', function () {
|
|
58
64
|
return gulp
|
|
59
65
|
.src('dist/<%= name %>.jscad')
|
|
60
|
-
.pipe(debug({ title: '
|
|
61
|
-
.pipe(gulp.dest('.
|
|
66
|
+
.pipe(debug({ title: 'vitepress:' }))
|
|
67
|
+
.pipe(gulp.dest('.vitepress/public/'));
|
|
62
68
|
})
|
|
63
69
|
);
|
|
64
70
|
|
|
65
71
|
gulp.task(
|
|
66
72
|
'default',
|
|
67
|
-
gulp.series(
|
|
73
|
+
gulp.series('clean', 'inject', function () {
|
|
68
74
|
gulp.watch(
|
|
69
|
-
['**/*.jscad',
|
|
75
|
+
['**/*.jscad', ...getInjected(pkg)],
|
|
70
76
|
{
|
|
71
|
-
verbose: true,
|
|
72
77
|
followSymlinks: true,
|
|
73
78
|
delay: 500,
|
|
74
79
|
queue: false,
|
|
75
80
|
ignoreInitial: false,
|
|
76
|
-
ignored: ['**/*.*~', 'dist/*', '.vuepress/*']
|
|
81
|
+
ignored: ['**/*.*~', 'dist/*', '.vuepress/*', 'public', 'node_modules']
|
|
77
82
|
},
|
|
78
|
-
gulp.series(
|
|
83
|
+
gulp.series('inject')
|
|
79
84
|
);
|
|
80
85
|
})
|
|
81
86
|
);
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// title : <%= nameslug %>
|
|
2
|
+
// author : <%= author %>
|
|
3
|
+
// license : ISC License
|
|
4
|
+
// file : <%= nameslug %>.jscad
|
|
5
|
+
|
|
6
|
+
/* exported main, getParameterDefinitions */
|
|
7
|
+
|
|
8
|
+
/** @type {import('@jwc/jscad-utils')} JscadUtils */
|
|
9
|
+
var util;
|
|
10
|
+
|
|
11
|
+
function getParameterDefinitions() {
|
|
12
|
+
/**
|
|
13
|
+
* Add the keys to the `Parts` object
|
|
14
|
+
* here and they will be listed in the
|
|
15
|
+
* parameters.
|
|
16
|
+
* @type {Record<string, boolean>}
|
|
17
|
+
*/
|
|
18
|
+
var ENABLED = {
|
|
19
|
+
example1: true,
|
|
20
|
+
example2: false
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return [
|
|
24
|
+
{ type: 'group', name: 'Parts' },
|
|
25
|
+
...Object.keys(ENABLED).map((name) => {
|
|
26
|
+
return {
|
|
27
|
+
name,
|
|
28
|
+
type: 'checkbox',
|
|
29
|
+
checked: ENABLED[name]
|
|
30
|
+
};
|
|
31
|
+
}),
|
|
32
|
+
{
|
|
33
|
+
name: 'resolution',
|
|
34
|
+
type: 'choice',
|
|
35
|
+
values: [0, 1, 2, 3, 4],
|
|
36
|
+
captions: [
|
|
37
|
+
'low (8,24)',
|
|
38
|
+
'normal (12,32)',
|
|
39
|
+
'high (24,64)',
|
|
40
|
+
'very high (48,128)',
|
|
41
|
+
'ultra high (96,256)'
|
|
42
|
+
],
|
|
43
|
+
default: 0,
|
|
44
|
+
initial: 0,
|
|
45
|
+
caption: 'Resolution:'
|
|
46
|
+
},
|
|
47
|
+
{ type: 'group', name: 'View' },
|
|
48
|
+
{
|
|
49
|
+
name: 'center',
|
|
50
|
+
type: 'checkbox',
|
|
51
|
+
checked: false
|
|
52
|
+
},
|
|
53
|
+
{ type: 'group', name: 'Cutaway' },
|
|
54
|
+
{
|
|
55
|
+
name: 'cutawayEnable',
|
|
56
|
+
caption: 'Enable:',
|
|
57
|
+
type: 'checkbox',
|
|
58
|
+
checked: false
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'cutawayAxis',
|
|
62
|
+
type: 'choice',
|
|
63
|
+
values: ['x', 'y', 'z'],
|
|
64
|
+
initial: 'y',
|
|
65
|
+
caption: 'Axis:'
|
|
66
|
+
}
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* @param {object} params
|
|
73
|
+
* @param {boolean} params.example1
|
|
74
|
+
* @param {boolean} params.example2
|
|
75
|
+
* @param {"0"|"1"|"2"|"3"|"4"} params.resolution
|
|
76
|
+
* @param {boolean} params.center
|
|
77
|
+
* @param {boolean} params.cutawayEnable
|
|
78
|
+
* @param {'x'|'y'|'z'} params.cutawayAxis
|
|
79
|
+
* @returns {CSG[]}
|
|
80
|
+
*/
|
|
81
|
+
function main(params) {
|
|
82
|
+
var start = performance.now();
|
|
83
|
+
var resolutions = [
|
|
84
|
+
[6, 16],
|
|
85
|
+
[8, 24],
|
|
86
|
+
[12, 32],
|
|
87
|
+
[24, 64],
|
|
88
|
+
[48, 128]
|
|
89
|
+
];
|
|
90
|
+
var [defaultResolution3D, defaultResolution2D] = resolutions[
|
|
91
|
+
parseInt(params.resolution)
|
|
92
|
+
];
|
|
93
|
+
CSG.defaultResolution3D = defaultResolution3D;
|
|
94
|
+
CSG.defaultResolution2D = defaultResolution2D;
|
|
95
|
+
util.init(CSG);
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The `Parts` object needs to contain
|
|
99
|
+
* the values from the `ENABLED` object.
|
|
100
|
+
*/
|
|
101
|
+
var Parts = {
|
|
102
|
+
example1: () => example1(),
|
|
103
|
+
example2: () => example2()
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
var selectedParts = Object.entries(Parts)
|
|
107
|
+
.filter(([key, value]) => {
|
|
108
|
+
return params[key];
|
|
109
|
+
})
|
|
110
|
+
.reduce((parts, [key, value]) => {
|
|
111
|
+
var part = value();
|
|
112
|
+
if (Array.isArray(part)) parts = parts.concat(part);
|
|
113
|
+
else parts.push(part);
|
|
114
|
+
return parts;
|
|
115
|
+
}, []);
|
|
116
|
+
|
|
117
|
+
console.log('selectedParts', selectedParts);
|
|
118
|
+
var parts = selectedParts.length ? selectedParts : [util.unitAxis(20)];
|
|
119
|
+
|
|
120
|
+
if (params.center) parts = [union(parts).Center()];
|
|
121
|
+
if (params.cutawayEnable)
|
|
122
|
+
parts = [util.bisect(union(parts), params.cutawayAxis).parts.positive];
|
|
123
|
+
|
|
124
|
+
console.log('timer', performance.now() - start);
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* If you are using @jwc/jscad-hardware and want
|
|
128
|
+
* a Bill Of Materials (BOM), uncomment this and
|
|
129
|
+
* open the DevTools console to see the BOM
|
|
130
|
+
* list.
|
|
131
|
+
*/
|
|
132
|
+
// console.log(
|
|
133
|
+
// 'BOM\n',
|
|
134
|
+
// Object.entries(Hardware.BOM)
|
|
135
|
+
// .map(([key, value]) => `${key}: ${value}`)
|
|
136
|
+
// .join('\n')
|
|
137
|
+
// );
|
|
138
|
+
|
|
139
|
+
console.log('parts', ...parts);
|
|
140
|
+
|
|
141
|
+
return [...parts];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function example1() {
|
|
145
|
+
var box1 = Parts.Cube([10, 10, 10]).fillet(1, 'z+').color('orange');
|
|
146
|
+
|
|
147
|
+
var box2 = Parts.Cube([5, 5, 5])
|
|
148
|
+
.snap(box1, 'z', 'outside-')
|
|
149
|
+
.align(box1, 'xy');
|
|
150
|
+
|
|
151
|
+
var cyl1 = Parts.Cylinder(5, 10)
|
|
152
|
+
.chamfer(2, 'z+')
|
|
153
|
+
.rotateX(90)
|
|
154
|
+
.snap(box2, 'y', 'outside+')
|
|
155
|
+
.align(box2, 'xz')
|
|
156
|
+
.color('green');
|
|
157
|
+
return box1
|
|
158
|
+
.union([box2.fillet(-1, 'z-').color('blue'), cyl1])
|
|
159
|
+
.translate([0, 10, 0]);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function example2() {
|
|
163
|
+
var box1 = Parts.Cube([10, 10, 10]).fillet(1, 'z+').color('orange');
|
|
164
|
+
|
|
165
|
+
return box1
|
|
166
|
+
.center()
|
|
167
|
+
.wedge(30, -30, 'x')
|
|
168
|
+
.map((part, name) => {
|
|
169
|
+
if (name == 'wedge') return part.translate([0, 5, 0]);
|
|
170
|
+
return part;
|
|
171
|
+
})
|
|
172
|
+
.combine()
|
|
173
|
+
.translate([0, -10, 0]);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// ********************************************************
|
|
177
|
+
// Other jscad libraries are injected here. Do not remove.
|
|
178
|
+
// Install jscad libraries using NPM
|
|
179
|
+
// ********************************************************
|
|
180
|
+
// include:js
|
|
181
|
+
// endinject
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// title : <%= nameslug %>
|
|
2
|
+
// author : <%= author %>
|
|
3
|
+
// license : ISC License
|
|
4
|
+
// file : <%= nameslug %>.jscad
|
|
5
|
+
|
|
6
|
+
/* exported main, getParameterDefinitions */
|
|
7
|
+
|
|
8
|
+
function getParameterDefinitions() {
|
|
9
|
+
/**
|
|
10
|
+
* Add the keys to the `Parts` object
|
|
11
|
+
* here and they will be listed in the
|
|
12
|
+
* parameters.
|
|
13
|
+
*/
|
|
14
|
+
var ENABLED = {
|
|
15
|
+
example1: true,
|
|
16
|
+
example2: false
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
name: 'Parts',
|
|
22
|
+
type: 'choice',
|
|
23
|
+
values: Object.keys(ENABLED),
|
|
24
|
+
captions: Object.keys(ENABLED),
|
|
25
|
+
default: Object.keys(ENABLED)[0],
|
|
26
|
+
initial: Object.entries(ENABLED).find(([name, value]) => value)[0],
|
|
27
|
+
caption: 'Part:'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'resolution',
|
|
31
|
+
type: 'choice',
|
|
32
|
+
values: [0, 1, 2, 3, 4],
|
|
33
|
+
captions: [
|
|
34
|
+
'low (8,24)',
|
|
35
|
+
'normal (12,32)',
|
|
36
|
+
'high (24,64)',
|
|
37
|
+
'very high (48,128)',
|
|
38
|
+
'ultra high (96,256)'
|
|
39
|
+
],
|
|
40
|
+
default: 0,
|
|
41
|
+
initial: 0,
|
|
42
|
+
caption: 'Resolution:'
|
|
43
|
+
},
|
|
44
|
+
{ type: 'group', name: 'View' },
|
|
45
|
+
{
|
|
46
|
+
name: 'center',
|
|
47
|
+
type: 'checkbox',
|
|
48
|
+
checked: false
|
|
49
|
+
},
|
|
50
|
+
{ type: 'group', name: 'Cutaway' },
|
|
51
|
+
{
|
|
52
|
+
name: 'cutawayEnable',
|
|
53
|
+
caption: 'Enable:',
|
|
54
|
+
type: 'checkbox',
|
|
55
|
+
checked: false
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'cutawayAxis',
|
|
59
|
+
type: 'choice',
|
|
60
|
+
values: ['x', 'y', 'z'],
|
|
61
|
+
initial: 'y',
|
|
62
|
+
caption: 'Axis:'
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
function main(params) {
|
|
67
|
+
var start = performance.now();
|
|
68
|
+
var resolutions = [
|
|
69
|
+
[6, 16],
|
|
70
|
+
[8, 24],
|
|
71
|
+
[12, 32],
|
|
72
|
+
[24, 64],
|
|
73
|
+
[48, 128]
|
|
74
|
+
];
|
|
75
|
+
var [defaultResolution3D, defaultResolution2D] = resolutions[
|
|
76
|
+
parseInt(params.resolution)
|
|
77
|
+
];
|
|
78
|
+
CSG.defaultResolution3D = defaultResolution3D;
|
|
79
|
+
CSG.defaultResolution2D = defaultResolution2D;
|
|
80
|
+
util.init(CSG);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The `Parts` object needs to contain
|
|
84
|
+
* the values from the `ENALBED` object.
|
|
85
|
+
*/
|
|
86
|
+
var Parts = {
|
|
87
|
+
example1: () => example1(),
|
|
88
|
+
example2: () => example2()
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
var selectedParts = [Parts[params.Parts]()];
|
|
92
|
+
|
|
93
|
+
console.log('selectedParts', selectedParts);
|
|
94
|
+
var parts = selectedParts.length ? selectedParts : [util.unitAxis(20)];
|
|
95
|
+
|
|
96
|
+
if (params.center) parts = [union(parts).Center()];
|
|
97
|
+
if (params.cutawayEnable)
|
|
98
|
+
parts = [util.bisect(union(parts), params.cutawayAxis).parts.positive];
|
|
99
|
+
|
|
100
|
+
console.log('timer', performance.now() - start);
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* If you are using @jwc/jscad-hardware and want
|
|
104
|
+
* a Bill Of Materials (BOM), uncomment this and
|
|
105
|
+
* open the DevTools console to see the BOM
|
|
106
|
+
* list.
|
|
107
|
+
*/
|
|
108
|
+
// console.log(
|
|
109
|
+
// 'BOM\n',
|
|
110
|
+
// Object.entries(Hardware.BOM)
|
|
111
|
+
// .map(([key, value]) => `${key}: ${value}`)
|
|
112
|
+
// .join('\n')
|
|
113
|
+
// );
|
|
114
|
+
|
|
115
|
+
console.log('parts', ...parts);
|
|
116
|
+
|
|
117
|
+
return [...parts];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function example1() {
|
|
121
|
+
var box1 = Parts.Cube([10, 10, 10]).fillet(1, 'z+').color('orange');
|
|
122
|
+
|
|
123
|
+
var box2 = Parts.Cube([5, 5, 5])
|
|
124
|
+
.snap(box1, 'z', 'outside-')
|
|
125
|
+
.align(box1, 'xy');
|
|
126
|
+
|
|
127
|
+
var cyl1 = Parts.Cylinder(5, 10)
|
|
128
|
+
.chamfer(2, 'z+')
|
|
129
|
+
.rotateX(90)
|
|
130
|
+
.snap(box2, 'y', 'outside+')
|
|
131
|
+
.align(box2, 'xz')
|
|
132
|
+
.color('green');
|
|
133
|
+
return box1.union([box2.fillet(-1, 'z-').color('blue'), cyl1]);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function example2() {
|
|
137
|
+
var box1 = Parts.Cube([10, 10, 10]).fillet(1, 'z+').color('orange');
|
|
138
|
+
|
|
139
|
+
return box1
|
|
140
|
+
.center()
|
|
141
|
+
.wedge(30, -30, 'x')
|
|
142
|
+
.map((part, name) => {
|
|
143
|
+
if (name == 'wedge') return part.translate([0, 5, 0]);
|
|
144
|
+
return part;
|
|
145
|
+
})
|
|
146
|
+
.combine();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ********************************************************
|
|
150
|
+
// Other jscad libraries are injected here. Do not remove.
|
|
151
|
+
// Install jscad libraries using NPM
|
|
152
|
+
// ********************************************************
|
|
153
|
+
// include:js
|
|
154
|
+
// endinject
|
|
@@ -18,6 +18,7 @@ function getParameterDefinitions() {
|
|
|
18
18
|
'high (24,64)',
|
|
19
19
|
'very high (48,128)'
|
|
20
20
|
],
|
|
21
|
+
default: 2,
|
|
21
22
|
initial: 2,
|
|
22
23
|
caption: 'Resolution:'
|
|
23
24
|
}
|
|
@@ -25,14 +26,21 @@ function getParameterDefinitions() {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
function main(params) {
|
|
28
|
-
var resolutions = [
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
var resolutions = [
|
|
30
|
+
[6, 16],
|
|
31
|
+
[8, 24],
|
|
32
|
+
[12, 32],
|
|
33
|
+
[24, 64],
|
|
34
|
+
[48, 128]
|
|
35
|
+
];
|
|
36
|
+
var [defaultResolution3D, defaultResolution2D] = resolutions[
|
|
37
|
+
parseInt(params.resolution)
|
|
38
|
+
];
|
|
39
|
+
CSG.defaultResolution3D = defaultResolution3D;
|
|
40
|
+
CSG.defaultResolution2D = defaultResolution2D;
|
|
31
41
|
util.init(CSG);
|
|
32
42
|
|
|
33
|
-
var box1 = Parts.Cube([10, 10, 10])
|
|
34
|
-
.fillet(1, 'z+')
|
|
35
|
-
.color('orange');
|
|
43
|
+
var box1 = Parts.Cube([10, 10, 10]).fillet(1, 'z+').color('orange');
|
|
36
44
|
|
|
37
45
|
var box2 = Parts.Cube([5, 5, 5])
|
|
38
46
|
.snap(box1, 'z', 'outside-')
|
|
@@ -6,30 +6,35 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"start": "gulp",
|
|
8
8
|
"clean": "gulp clean",
|
|
9
|
-
"
|
|
9
|
+
"build": "gulp inject",
|
|
10
10
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"docs:dev": "vitepress dev",
|
|
12
|
+
"docs:build": "vitepress build",
|
|
13
|
+
"docs:preview": "vitepress preview"
|
|
13
14
|
},
|
|
14
15
|
"author": "<%= author %>",
|
|
15
16
|
"license": "ISC",
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"jscad-utils": "^3.0.0"
|
|
18
|
-
},
|
|
19
17
|
"devDependencies": {
|
|
20
18
|
"@jscad/web": "^1.10.0",
|
|
21
|
-
"@jwc/vue-openjscad": "
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"gulp
|
|
26
|
-
"gulp-
|
|
27
|
-
"gulp-
|
|
28
|
-
"gulp-
|
|
19
|
+
"@jwc/vue-openjscad": "2.0.4",
|
|
20
|
+
"copy-dir": "0.3.0",
|
|
21
|
+
"cross-env": "10.0.0",
|
|
22
|
+
"del": "8.0.1",
|
|
23
|
+
"gulp": "5.0.1",
|
|
24
|
+
"gulp-cli": "3.1.0",
|
|
25
|
+
"gulp-debug": "5.0.1",
|
|
26
|
+
"gulp-inject": "^5.0.4",
|
|
27
|
+
"gulp-jscad-files": "^4.0.0",
|
|
29
28
|
"gulp-plumber": "^1.1.0",
|
|
30
|
-
"gulp-terser": "^
|
|
29
|
+
"gulp-terser": "^2.0.1",
|
|
31
30
|
"gulp-watch": "^5.0.1",
|
|
32
|
-
"merge2": "^1.
|
|
33
|
-
"
|
|
31
|
+
"merge2": "^1.3.0",
|
|
32
|
+
"vitepress": "2.0.0-alpha.12"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@jscad/scad-api": "0.5.1",
|
|
36
|
+
"@jwc/jscad-hardware": "3.3.0",
|
|
37
|
+
"@jwc/jscad-raspberrypi": "3.2.1",
|
|
38
|
+
"@jwc/jscad-utils": "4.9.0"
|
|
34
39
|
}
|
|
35
40
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generator-jscad",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Create a jscad project",
|
|
5
5
|
"homepage": "https://gitlab.com/johnwebbcole/generator-jscad",
|
|
6
6
|
"author": {
|
|
@@ -17,29 +17,29 @@
|
|
|
17
17
|
"yeoman-generator"
|
|
18
18
|
],
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"conventional-changelog-cli": "^2.0.
|
|
21
|
-
"coveralls": "^3.0
|
|
22
|
-
"eslint": "^
|
|
23
|
-
"eslint-config-prettier": "^
|
|
24
|
-
"eslint-config-xo": "^0.
|
|
25
|
-
"eslint-plugin-prettier": "^3.
|
|
26
|
-
"husky": "^
|
|
27
|
-
"jest": "^
|
|
28
|
-
"lint-staged": "^
|
|
29
|
-
"np": "^
|
|
30
|
-
"prettier": "^
|
|
20
|
+
"conventional-changelog-cli": "^2.0.34",
|
|
21
|
+
"coveralls": "^3.1.0",
|
|
22
|
+
"eslint": "^7.3.0",
|
|
23
|
+
"eslint-config-prettier": "^6.11.0",
|
|
24
|
+
"eslint-config-xo": "^0.31.0",
|
|
25
|
+
"eslint-plugin-prettier": "^3.1.4",
|
|
26
|
+
"husky": "^4.2.5",
|
|
27
|
+
"jest": "^26.0.1",
|
|
28
|
+
"lint-staged": "^10.2.11",
|
|
29
|
+
"np": "^6.2.4",
|
|
30
|
+
"prettier": "^2.0.5",
|
|
31
31
|
"yeoman-assert": "^3.1.0",
|
|
32
|
-
"yeoman-test": "^
|
|
32
|
+
"yeoman-test": "^2.6.0"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
35
35
|
"npm": ">= 4.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"chalk": "^
|
|
39
|
-
"command-exists": "^1.2.
|
|
38
|
+
"chalk": "^4.1.0",
|
|
39
|
+
"command-exists": "^1.2.9",
|
|
40
40
|
"generator-git-init": "^1.1.3",
|
|
41
|
-
"lodash": "^4.17.
|
|
42
|
-
"yeoman-generator": "^
|
|
41
|
+
"lodash": "^4.17.15",
|
|
42
|
+
"yeoman-generator": "^4.10.1",
|
|
43
43
|
"yosay": "^2.0.1"
|
|
44
44
|
},
|
|
45
45
|
"jest": {
|
package/CHANGELOG.md
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
## <small>2.1.2 (2019-01-12)</small>
|
|
2
|
-
|
|
3
|
-
* cicd changes ([decc610](https://gitlab.com/johnwebbcole/generator-jscad/commit/decc610))
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## <small>2.1.1 (2019-01-12)</small>
|
|
8
|
-
|
|
9
|
-
* 2.1.1 ([0461e7c](https://gitlab.com/johnwebbcole/generator-jscad/commit/0461e7c))
|
|
10
|
-
* update watch to match v4 ([05d96f1](https://gitlab.com/johnwebbcole/generator-jscad/commit/05d96f1))
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## 2.1.0 (2019-01-06)
|
|
15
|
-
|
|
16
|
-
* 2.1.0 ([d06e677](https://gitlab.com/johnwebbcole/generator-jscad/commit/d06e677))
|
|
17
|
-
* add vuepress and vue-openjscad ([5204f44](https://gitlab.com/johnwebbcole/generator-jscad/commit/5204f44))
|
|
18
|
-
* add vuepress and vue-openjscad ([dac022b](https://gitlab.com/johnwebbcole/generator-jscad/commit/dac022b))
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## <small>2.0.2 (2018-12-24)</small>
|
|
23
|
-
|
|
24
|
-
* 2.0.2 ([7203c0e](https://gitlab.com/johnwebbcole/generator-jscad/commit/7203c0e))
|
|
25
|
-
* renamed dot template files ([d23e7a0](https://gitlab.com/johnwebbcole/generator-jscad/commit/d23e7a0))
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
## <small>2.0.1 (2018-12-24)</small>
|
|
30
|
-
|
|
31
|
-
* 2.0.1 ([5208a2b](https://gitlab.com/johnwebbcole/generator-jscad/commit/5208a2b))
|
|
32
|
-
* add lodash ([e53a8f0](https://gitlab.com/johnwebbcole/generator-jscad/commit/e53a8f0))
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
## 2.0.0 (2018-12-24)
|
|
37
|
-
|
|
38
|
-
* 2.0.0 ([a805277](https://gitlab.com/johnwebbcole/generator-jscad/commit/a805277))
|
|
39
|
-
* add cicd ([d341b77](https://gitlab.com/johnwebbcole/generator-jscad/commit/d341b77))
|
|
40
|
-
* add release script ([e90810a](https://gitlab.com/johnwebbcole/generator-jscad/commit/e90810a))
|
|
41
|
-
* Added `node_modules` to watch list ([20d72d0](https://gitlab.com/johnwebbcole/generator-jscad/commit/20d72d0))
|
|
42
|
-
* Added readme to generator and moved one into the project. Camel cased the name to make it a valid o ([66880e6](https://gitlab.com/johnwebbcole/generator-jscad/commit/66880e6))
|
|
43
|
-
* added yarn files ([8c96cff](https://gitlab.com/johnwebbcole/generator-jscad/commit/8c96cff))
|
|
44
|
-
* changed to use new gulp-jscadfiles plugin ([567183f](https://gitlab.com/johnwebbcole/generator-jscad/commit/567183f))
|
|
45
|
-
* Fix gulp file, it needed to be a template. ([ccab77e](https://gitlab.com/johnwebbcole/generator-jscad/commit/ccab77e))
|
|
46
|
-
* Initial commit ([e43fb5b](https://gitlab.com/johnwebbcole/generator-jscad/commit/e43fb5b))
|
|
47
|
-
* no message ([857331c](https://gitlab.com/johnwebbcole/generator-jscad/commit/857331c))
|
|
48
|
-
* no message ([bb05b43](https://gitlab.com/johnwebbcole/generator-jscad/commit/bb05b43))
|
|
49
|
-
* no message ([9572114](https://gitlab.com/johnwebbcole/generator-jscad/commit/9572114))
|
|
50
|
-
* publish 1.0.1 ([8c26637](https://gitlab.com/johnwebbcole/generator-jscad/commit/8c26637))
|
|
51
|
-
* Rebuit using `generator-generator`. ([d7ea44e](https://gitlab.com/johnwebbcole/generator-jscad/commit/d7ea44e))
|
|
52
|
-
* removed fileExists dependency ([a239839](https://gitlab.com/johnwebbcole/generator-jscad/commit/a239839))
|
|
53
|
-
* reset version ([0932c0e](https://gitlab.com/johnwebbcole/generator-jscad/commit/0932c0e))
|
|
54
|
-
* updated dependencies ([93c19df](https://gitlab.com/johnwebbcole/generator-jscad/commit/93c19df))
|
|
55
|
-
* updated example, added readme from generator. ([b0df213](https://gitlab.com/johnwebbcole/generator-jscad/commit/b0df213))
|
|
56
|
-
* updated to use newer utils ([17b81ea](https://gitlab.com/johnwebbcole/generator-jscad/commit/17b81ea))
|
|
57
|
-
* Updating to use `jscad-utils` 2.0 ([7ca7621](https://gitlab.com/johnwebbcole/generator-jscad/commit/7ca7621))
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
package/generators/.DS_Store
DELETED
|
Binary file
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<open-jscad v-bind="$attrs"></open-jscad>
|
|
4
|
-
</div>
|
|
5
|
-
</template>
|
|
6
|
-
<script>
|
|
7
|
-
import OpenJscad from "@jwc/vue-openjscad";
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
name: "VuepressOpenJscad",
|
|
11
|
-
components: { OpenJscad },
|
|
12
|
-
inheritAttrs: false
|
|
13
|
-
};
|
|
14
|
-
</script>
|