Bundle OpenSCAD examples + update default model
This commit is contained in:
parent
4ade6017c4
commit
5ec86067ca
6 changed files with 75 additions and 28 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -2,5 +2,7 @@ node_modules
|
||||||
libs
|
libs
|
||||||
dist
|
dist
|
||||||
public/libraries
|
public/libraries
|
||||||
|
public/openscad.js
|
||||||
|
public/openscad.wasm
|
||||||
src/wasm
|
src/wasm
|
||||||
package-lock.json
|
package-lock.json
|
||||||
30
Makefile
30
Makefile
|
|
@ -8,10 +8,11 @@ all: public
|
||||||
|
|
||||||
.PHONY: public
|
.PHONY: public
|
||||||
public: \
|
public: \
|
||||||
libs/openscad \
|
libs/openscad-wasm \
|
||||||
public/openscad.js \
|
public/openscad.js \
|
||||||
public/openscad.wasm \
|
public/openscad.wasm \
|
||||||
public/libraries/fonts.zip \
|
public/libraries/fonts.zip \
|
||||||
|
public/libraries/openscad.zip \
|
||||||
public/libraries/NopSCADlib.zip \
|
public/libraries/NopSCADlib.zip \
|
||||||
public/libraries/BOSL.zip \
|
public/libraries/BOSL.zip \
|
||||||
public/libraries/BOSL2.zip \
|
public/libraries/BOSL2.zip \
|
||||||
|
|
@ -40,19 +41,19 @@ dist/index.js: public
|
||||||
dist/openscad-worker.js: src/openscad-worker.ts
|
dist/openscad-worker.js: src/openscad-worker.ts
|
||||||
npx rollup -c
|
npx rollup -c
|
||||||
|
|
||||||
libs/openscad:
|
libs/openscad-wasm:
|
||||||
mkdir -p libs/openscad
|
mkdir -p libs/openscad-wasm
|
||||||
wget ${WASM_BUILD_URL} -O libs/openscad.zip
|
wget ${WASM_BUILD_URL} -O libs/openscad-wasm.zip
|
||||||
( cd libs/openscad && unzip ../openscad.zip )
|
( cd libs/openscad-wasm && unzip ../openscad-wasm.zip )
|
||||||
rm libs/openscad.zip
|
rm libs/openscad-wasm.zip
|
||||||
rm -f src/wasm
|
rm -f src/wasm
|
||||||
ln -sf $(shell pwd)/libs/openscad src/wasm
|
ln -sf $(shell pwd)/libs/openscad-wasm src/wasm
|
||||||
|
|
||||||
public/openscad.js: libs/openscad libs/openscad/openscad.js
|
public/openscad.js: libs/openscad-wasm
|
||||||
cp libs/openscad/openscad.{js,wasm} public
|
cp libs/openscad-wasm/openscad.{js,wasm} public
|
||||||
|
|
||||||
public/openscad.wasm: libs/openscad libs/openscad/openscad.wasm
|
public/openscad.wasm: libs/openscad-wasm
|
||||||
cp libs/openscad/openscad.wasm public
|
cp libs/openscad-wasm/openscad.wasm public
|
||||||
|
|
||||||
public/libraries/fonts.zip: libs/liberation
|
public/libraries/fonts.zip: libs/liberation
|
||||||
mkdir -p public/libraries
|
mkdir -p public/libraries
|
||||||
|
|
@ -62,6 +63,13 @@ public/libraries/fonts.zip: libs/liberation
|
||||||
libs/liberation:
|
libs/liberation:
|
||||||
git clone --recurse https://github.com/shantigilbert/liberation-fonts-ttf.git ${SHALLOW} ${SINGLE_BRANCH} $@
|
git clone --recurse https://github.com/shantigilbert/liberation-fonts-ttf.git ${SHALLOW} ${SINGLE_BRANCH} $@
|
||||||
|
|
||||||
|
libs/openscad:
|
||||||
|
git clone https://github.com/openscad/openscad.git ${SHALLOW} ${SINGLE_BRANCH} $@
|
||||||
|
|
||||||
|
public/libraries/openscad.zip: libs/openscad
|
||||||
|
mkdir -p public/libraries
|
||||||
|
( cd libs/openscad ; zip -r ../../public/libraries/openscad.zip `find examples -name '*.scad' | grep -v tests` )
|
||||||
|
|
||||||
libs/BOSL2:
|
libs/BOSL2:
|
||||||
git clone --recurse https://github.com/revarbat/BOSL2.git ${SHALLOW} ${SINGLE_BRANCH} $@
|
git clone --recurse https://github.com/revarbat/BOSL2.git ${SHALLOW} ${SINGLE_BRANCH} $@
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, user-scalable=no" />
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||||
|
|
||||||
<link rel="prefetch" href="openscad.wasm">
|
<link rel="prefetch" href="openscad.wasm">
|
||||||
<link rel="prefetch" href="openscad-worker.js">
|
<link rel="prefetch" href="openscad-worker.js">
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@ import { join } from '../fs/filesystem';
|
||||||
import { defaultSourcePath } from '../state/initial-state';
|
import { defaultSourcePath } from '../state/initial-state';
|
||||||
import { zipArchives } from '../fs/zip-archives';
|
import { zipArchives } from '../fs/zip-archives';
|
||||||
|
|
||||||
|
const biasedCompare = (a: string, b: string) =>
|
||||||
|
a === 'openscad' ? -1 : b === 'openscad' ? 1 : a.localeCompare(b);
|
||||||
|
|
||||||
function listFilesAsNodes(fs: FS, path: string, accept?: (path: string) => boolean): TreeNode[] {
|
function listFilesAsNodes(fs: FS, path: string, accept?: (path: string) => boolean): TreeNode[] {
|
||||||
const files: [string, string][] = []
|
const files: [string, string][] = []
|
||||||
const dirs: [string, string][] = []
|
const dirs: [string, string][] = []
|
||||||
|
|
@ -27,7 +30,7 @@ function listFilesAsNodes(fs: FS, path: string, accept?: (path: string) => boole
|
||||||
}
|
}
|
||||||
(isDirectory ? dirs : files).push([name, childPath]);
|
(isDirectory ? dirs : files).push([name, childPath]);
|
||||||
}
|
}
|
||||||
[files, dirs].forEach(arr => arr.sort(([a], [b]) => a.localeCompare(b)));
|
[files, dirs].forEach(arr => arr.sort(([a], [b]) => biasedCompare(a, b)));
|
||||||
|
|
||||||
const nodes: TreeNode[] = []
|
const nodes: TreeNode[] = []
|
||||||
for (const [arr, isDirectory] of [[files, false], [dirs, true]] as [[string, string][], boolean][]) {
|
for (const [arr, isDirectory] of [[files, false], [dirs, true]] as [[string, string][], boolean][]) {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,14 @@ export type ZipArchives = {
|
||||||
|
|
||||||
export const zipArchives: ZipArchives = {
|
export const zipArchives: ZipArchives = {
|
||||||
'fonts': {},
|
'fonts': {},
|
||||||
|
'openscad': {
|
||||||
|
description: 'OpenSCAD',
|
||||||
|
gitOrigin: {
|
||||||
|
branch: 'master',
|
||||||
|
repoUrl: 'https://github.com/openscad/openscad',
|
||||||
|
include: [{glob: ['examples/*.scad', 'LICENSE']}],
|
||||||
|
},
|
||||||
|
},
|
||||||
'MCAD': {
|
'MCAD': {
|
||||||
description: 'OpenSCAD Parametric CAD Library',
|
description: 'OpenSCAD Parametric CAD Library',
|
||||||
gitOrigin: {
|
gitOrigin: {
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,45 @@
|
||||||
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
|
||||||
|
|
||||||
export default `
|
export default `/*
|
||||||
rotate([90, 0, 0]) {
|
Hello there!
|
||||||
translate([-50, 0, 50])
|
|
||||||
linear_extrude(10)
|
|
||||||
text("hello world!");
|
|
||||||
|
|
||||||
}
|
|
||||||
cube(40, center=true);
|
|
||||||
translate([10, 10, 10])
|
|
||||||
cube(40, center=true);
|
|
||||||
|
|
||||||
// This demo includes many libraries:
|
If you're new to OpenSCAD, please learn the basics here:
|
||||||
//
|
https://openscad.org/documentation.html
|
||||||
// include <BOSL2/std.scad>
|
|
||||||
// translate([-100, 0, 0])
|
There are lots of amazing libraries in the OpenSCAD ecosystem
|
||||||
// spheroid(d=100, style="icosa", $fn=20);
|
(see this list: https://openscad.org/libraries.html).
|
||||||
|
|
||||||
|
Some of these libraries are bundled with this playground
|
||||||
|
(search for "demo" or "example" in the file explorer above)
|
||||||
|
and can be included directly from your models.
|
||||||
|
|
||||||
|
Any bugs (this is an Alpha!) or ideas of features?
|
||||||
|
https://github.com/openscad/openscad-playground/issues/new
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Click on Render or hit F6 to do a fine-grained rendering.
|
||||||
|
$fn=$preview ? 20 : 100;
|
||||||
|
|
||||||
|
translate([-24,0,0]) {
|
||||||
|
union() {
|
||||||
|
cube(15, center=true);
|
||||||
|
sphere(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
intersection() {
|
||||||
|
cube(15, center=true);
|
||||||
|
sphere(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
translate([24,0,0]) {
|
||||||
|
difference() {
|
||||||
|
cube(15, center=true);
|
||||||
|
sphere(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
translate([0, -30, -12])
|
||||||
|
linear_extrude(1)
|
||||||
|
text("OpenSCAD Playground", halign="center", valign="center");
|
||||||
`
|
`
|
||||||
Loading…
Reference in a new issue