Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌈 Colorful Playground #37

Merged
merged 117 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
3c1ef25
glb (color-assimp2 branch) + model-viewer
ochafik Jun 15, 2024
f40e2d6
color support + customizable output format
ochafik Jun 16, 2024
be77477
cleanup
ochafik Jun 16, 2024
866adeb
disable monaco on iOS
ochafik Jun 16, 2024
e6f8eba
reinstate STL viewer when output is stl
ochafik Jun 16, 2024
b6e061c
default to stl
ochafik Jun 16, 2024
797e296
fix iOS editor
ochafik Jun 16, 2024
065d9db
script to build openscad-wasm from a branch / local repo
ochafik Jun 17, 2024
e50d62b
update fork link + build instructions
ochafik Jun 17, 2024
5fb9593
Update build-openscad-wasm.sh
ochafik Jun 17, 2024
5f6fb03
Update initial-state.ts
ochafik Jun 21, 2024
1a78714
Merge branch 'compress-state' into color-assimp2
ochafik Jun 21, 2024
20fd42d
Merge remote-tracking branch 'origin/main' into color-assimp2
ochafik Jun 21, 2024
bd67af9
update openscad3 refs
ochafik Jun 21, 2024
5c62a45
update wasm build script
ochafik Jun 22, 2024
10cb16a
Update Dockerfile.wasm
ochafik Jun 22, 2024
149d4e6
add jszip dep
ochafik Jun 22, 2024
d8274d5
multimaterial: color conversion + 3MF face painting
ochafik Jun 22, 2024
f0aaf5a
ignore ts error about compression apis
ochafik Jun 22, 2024
27d0786
Update tsconfig.json
ochafik Jun 22, 2024
45ff3d9
multimaterial support w/ extruder colors input component
ochafik Jun 22, 2024
dd28e83
Merge remote-tracking branch 'origin/main' into color-assimp2
ochafik Jun 29, 2024
c8061a9
fix wasm build script
ochafik Jun 29, 2024
48031f4
symlinks for openscad.{js,wasm} under src
ochafik Jul 1, 2024
ed17c40
fix error line shift for bundled files
ochafik Jul 1, 2024
28f9c84
remove obsolete build script
ochafik Jul 1, 2024
1475dad
set OPENSCADPATH env var
ochafik Jul 1, 2024
1284720
render-colors feature renamed
ochafik Jul 1, 2024
1ae5de2
Merge remote-tracking branch 'origin/main' into color-assimp2
ochafik Jul 1, 2024
525a83f
Customizer + prepare Multi-asset support
ochafik Jul 1, 2024
a6a38bb
hide customizer button if unselected, hide it if no params,
ochafik Jul 1, 2024
711d478
Create build-openscad-wasm.sh
ochafik Jul 2, 2024
0c5f445
update build script
ochafik Jul 2, 2024
839d620
complete sound
ochafik Jul 2, 2024
72716ab
fetchSource util
ochafik Jul 2, 2024
c0a20f9
wider rotation allowance
ochafik Jul 2, 2024
5134545
use CSG-modules.scad as default
ochafik Jul 2, 2024
492baaa
Update CustomizerPanel.tsx
ochafik Jul 2, 2024
36d8573
Update index.html
ochafik Jul 2, 2024
58ff519
capture save, allow Ctrl+Shift+Save to save project
ochafik Jul 2, 2024
fe987ae
customizer: fieldsets are better than accordion
ochafik Jul 2, 2024
7cf863f
expand customizer tabs by default
ochafik Jul 2, 2024
937dd01
tooltip for reset buttons
ochafik Jul 2, 2024
37c812d
pretty c++ exceptions
ochafik Jul 2, 2024
9f9161a
Delete inline-openscad-worker.ts
ochafik Jul 2, 2024
42e93a5
shuffle ux
ochafik Jul 2, 2024
9e75346
use uzip instead of jszip for 3mf materialization
ochafik Jul 6, 2024
13a6133
handle legacy links
ochafik Jul 6, 2024
57a6981
update links to fork
ochafik Jul 6, 2024
620582d
use render-modifiers feature from color-assimp2 in preview mode
ochafik Jul 7, 2024
7812c21
include NopSCADlib's STL files in archive
ochafik Jul 7, 2024
815c006
bind global f5 / f6
ochafik Jul 7, 2024
256419a
update homepage back to openscad2
ochafik Jul 7, 2024
f80ccf0
styling fixes (editor alpha, customizer margins)
ochafik Jul 7, 2024
ee7dcb8
Add help link for customizer
ochafik Jul 7, 2024
ecb9995
fix customizer sliders (also need to show value input)
ochafik Jul 7, 2024
8b153d6
fix vector customizer component
ochafik Jul 7, 2024
b136836
style fallback editor
ochafik Jul 7, 2024
082a0de
shorter logs button
ochafik Jul 7, 2024
44ba866
customizer: rm reset button tooltip
ochafik Jul 7, 2024
0a898d9
customizer: allow dnd on viewer below, tweak background
ochafik Jul 7, 2024
79fa45d
add lights to modelviewer using an env image (gltf lights hard to plu…
ochafik Jul 7, 2024
feec25b
update customizer styles
ochafik Jul 7, 2024
bd68f22
Update .gitignore
ochafik Jul 7, 2024
408ca5d
add license for UZIP.js (MIT)
ochafik Jul 8, 2024
a927613
Update skybox-lights.jpg
ochafik Jul 8, 2024
7b23cd9
Merge remote-tracking branch 'origin/main' into color-assimp2
ochafik Jul 8, 2024
de8038b
Update actions.ts
ochafik Jul 8, 2024
c1e77bd
Merge remote-tracking branch 'origin/main' into color-assimp2
ochafik Jul 8, 2024
213f726
Merge remote-tracking branch 'origin/main' into color-assimp2
ochafik Jul 8, 2024
9c68401
include NopSCADlib's STLs
ochafik Jul 8, 2024
9596a6c
Update LICENSE.md
ochafik Jul 8, 2024
1d73b43
include YAPP_Box examples
ochafik Jul 8, 2024
e99e983
limit customizer height
ochafik Jul 8, 2024
6995173
Update skybox-lights.jpg
ochafik Jul 8, 2024
d1994ca
Update skybox-lights.jpg
ochafik Jul 8, 2024
b15a0d3
Update openscad-worker.ts
ochafik Jul 12, 2024
e966926
Merge branch 'fonts' into color-assimp2
ochafik Jul 13, 2024
f8f4cbd
Merge branch 'fonts' into color-assimp2
ochafik Jul 13, 2024
c58aa44
Merge remote-tracking branch 'origin/main' into color-assimp2
ochafik Jul 14, 2024
921ced5
Merge remote-tracking branch 'origin/main' into color-assimp2
ochafik Jul 17, 2024
bdcf1de
build-openscad-wasm.sh fix: docker won't mount files outside home dir…
ochafik Jul 17, 2024
3cc0090
Use Google CDN instead of unpkg for modelviewer
ochafik Oct 23, 2024
99bf102
Merge branch 'main' into color-assimp2
ochafik Oct 23, 2024
c94740c
Merge branch 'main' into color-assimp2
ochafik Oct 23, 2024
efc9ee2
tmp updates before merge
ochafik Oct 23, 2024
4396ed4
Merge branch 'color-assimp2-tmp-updates' into color-assimp2
ochafik Oct 23, 2024
e6e9c8d
Add ccache support to build-openscad-wasm.sh
ochafik Dec 18, 2024
3cd9e06
Fix makefile
ochafik Dec 18, 2024
368cbde
Update README.md
ochafik Dec 18, 2024
ed258da
Fix ts imports
ochafik Dec 18, 2024
977a1f7
Delete build-openscad-wasm.sh
ochafik Dec 22, 2024
6e56c5e
Crude off -> glb converter
ochafik Dec 22, 2024
9dfedb1
Remove assimp related code
ochafik Dec 22, 2024
0d1dc95
gltf diffs
ochafik Dec 22, 2024
fc5686f
Build using head openscad
ochafik Dec 22, 2024
49b4d89
Merge remote-tracking branch 'origin/main' into color2-assimp
ochafik Dec 22, 2024
65a08dd
readme: Update build prerequisites
ochafik Dec 22, 2024
d730f0c
make: attempt to build wasm binary in parallel first
ochafik Dec 22, 2024
25347a9
Remove 3mf extruder color mapping & fix render / export flows (render…
ochafik Dec 22, 2024
0523664
off2glb: triangulate faces + add default color
ochafik Dec 22, 2024
4291cdd
Add simple e2e puppeteer test
ochafik Dec 22, 2024
a613ae2
ci: update pinned build to master output artefact
ochafik Dec 22, 2024
04d3b1d
Update Makefile
ochafik Dec 22, 2024
5e14ca2
Update test.yml
ochafik Dec 22, 2024
69aeafe
Update test.yml
ochafik Dec 22, 2024
705c570
Update test.yml
ochafik Dec 22, 2024
6691380
Update test.yml
ochafik Dec 22, 2024
3c454e6
ci: use relative node version names
ochafik Dec 22, 2024
60f067b
Update test.yml
ochafik Dec 22, 2024
eaac4a6
state: Remove renderFormat, introduce is2D
ochafik Dec 22, 2024
729cffd
disable service worker in devel mode
ochafik Dec 22, 2024
f57904e
remove dead code
ochafik Dec 22, 2024
beb4be7
build: fix NODE_ENV define
ochafik Dec 22, 2024
435aa6c
ci: simplify env vars
ochafik Dec 22, 2024
3e889a6
cleanups
ochafik Dec 22, 2024
dee1508
Update README.md
ochafik Dec 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,29 @@ jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [ 18, 20, 22 ]
name: Node${{ matrix.node }}
node: [
{"name": "LTS", "version": "lts/-2"},
{"name": "latest", "version": "latest"}
]
name: Node ${{ matrix.node.name }}
env:
CI: true
steps:
- uses: actions/checkout@v4
- name: Setup node ${{ matrix.node }}
- name: Setup node ${{ matrix.node.name }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
node-version: ${{ matrix.node.version }}
- run: npm install
- run: make public
- run: npm run build
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: dist-node${{ matrix.node }}
name: dist-node-${{ matrix.node.name }}
path: dist
retention-days: 30
- run: NODE_ENV=development npm run test:e2e
- run: NODE_ENV=production npm run test:e2e
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ The WASM build was made possible by https://github.com/DSchroer/openscad-wasm.
* [GNU MP](#gnu-mp)
* [OpenSCAD](#openscad)
* [CGAL](#cgal)
* [JSZip](#jszip)
* [Manifold](#manifold)
* [Eigen](#eigen)
* [glib2](#glib2)
Expand Down Expand Up @@ -59,6 +60,12 @@ https://github.com/elalish/manifold

Licensed under the [Apache 2.0](#apache2) license.

## JSZip

https://github.com/Stuk/jszip

Licensed under the [GPLv3](#gplv3) (actually dual-licensed under MIT, but we're picking this one here for brevity).

## PrimeReact

https://github.com/primefaces/primereact
Expand Down
21 changes: 15 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Pinning WASM build to last good revision (https://github.com/openscad/openscad-playground/issues/60)
WASM_BUILD_URL=https://files.openscad.org/snapshots/OpenSCAD-2024.09.27.wasm20596-WebAssembly.zip
# Pin WASM build to a version known to work
WASM_BUILD_URL=https://output.circle-artifacts.com/output/job/fdf49786-06c1-4775-aaa3-15dc089efc12/artifacts/0/wasm/OpenSCAD-2024.12.22.wasm21804-WebAssembly-web.zip
# WASM_SNAPSHOT_JS_URL=https://files.openscad.org/snapshots/.snapshot_wasm.js
# WASM_BUILD_URL=$(shell curl ${WASM_SNAPSHOT_JS_URL} 2>/dev/null | grep https | sed -E "s/.*(https:[^']+)'.*/\1/" )

Expand Down Expand Up @@ -47,13 +47,21 @@ clean:
dist/index.js: public
npm run build

dist/openscad-worker.js: src/openscad-worker.ts
dist/openscad-worker.js: src/openscad-worker.ts src/wasm/openscad.js
npx rollup -c

src/wasm: libs/openscad-wasm
rm -f src/wasm
ln -sf "$(shell pwd)/libs/openscad-wasm" src/wasm

# libs/openscad/build/openscad.js: libs/openscad
# ( cd libs/openscad && ./scripts/wasm-base-docker-run.sh emcmake cmake -B build -DCMAKE_BUILD_TYPE=Release -DEXPERIMENTAL=1 )
# ( cd libs/openscad && ./scripts/wasm-base-docker-run.sh /bin/bash -c "cmake --build build -j || cmake --build build -j2 || cmake --build build" )

# libs/openscad-wasm: libs/openscad/build/openscad.js
# mkdir -p libs/openscad-wasm
# cp libs/openscad/build/openscad.* libs/openscad-wasm/

libs/openscad-wasm:
mkdir -p libs/openscad-wasm
wget ${WASM_BUILD_URL} -O libs/openscad-wasm.zip
Expand Down Expand Up @@ -116,7 +124,8 @@ NOTO_FONTS=\
# libs/noto/NotoSansCJKtc-Regular.otf

public/libraries/fonts.zip: $(NOTO_FONTS) libs/liberation
zip -r $@ -j fonts.conf libs/noto/{*.ttf,*.otf} libs/liberation/{*.ttf,LICENSE,AUTHORS}
mkdir -p public/libraries
zip -r $@ -j fonts.conf libs/noto/*.ttf libs/liberation/{*.ttf,LICENSE,AUTHORS}

libs/noto/%.ttf:
mkdir -p libs/noto
Expand All @@ -130,7 +139,7 @@ libs/liberation:
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} $@
git clone --recurse https://github.com/openscad/openscad.git ${SHALLOW} ${SINGLE_BRANCH} $@

public/libraries/openscad.zip: libs/openscad
mkdir -p public/libraries
Expand Down Expand Up @@ -176,7 +185,7 @@ libs/YAPP_Box:

public/libraries/YAPP_Box.zip: libs/YAPP_Box
mkdir -p public/libraries
( cd libs/YAPP_Box ; zip -r ../../public/libraries/YAPP_Box.zip *.scad LICENSE )
( cd libs/YAPP_Box ; zip -r ../../public/libraries/YAPP_Box.zip `find . -name '*.scad'` LICENSE )

libs/MCAD:
git clone --recurse https://github.com/openscad/MCAD.git ${SHALLOW} ${SINGLE_BRANCH} $@
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,17 @@ Prerequisites:
* wget
* GNU make
* npm
* Docker able to run amd64 containers. If running on a different platform (including Silicon Mac), you can add support for amd64 images through QEMU with:

```bash
docker run --privileged --rm tonistiigi/binfmt --install all
```

Local dev:

```bash
make public
npm install
npm start
# http://localhost:4000/
```
Expand All @@ -60,6 +66,7 @@ Local prod (test both the different inlining and serving under a prefix):

```bash
make public
npm install
npm run start:prod
# http://localhost:3000/dist/
```
Expand All @@ -68,7 +75,8 @@ Deployment (edit "homepage" in `package.json` to match your deployment root!):

```bash
make public
npm run build
npm install
NODE_ENV=production npm run build

rm -fR ../ochafik.github.io/openscad2 && cp -R dist ../ochafik.github.io/openscad2
# Now commit and push changes, wait for site update and enjoy!
Expand Down
25 changes: 0 additions & 25 deletions build-openscad-wasm.sh

This file was deleted.

10 changes: 10 additions & 0 deletions jest-puppeteer.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
launch: {
headless: process.env.CI === "true",
},
server: {
command: `npm run start:${process.env.NODE_ENV}`,
port: process.env.NODE_ENV === 'production' ? 3000 : 4000,
launchTimeout: 180000,
},
};
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
preset: "jest-puppeteer",
testMatch: [
"**/tests/**/*.js",
],
};
17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"private": true,
"homepage": "https://ochafik.com/openscad2/",
"dependencies": {
"@gltf-transform/core": "^4.1.1",
"@gltf-transform/extensions": "^4.1.1",
"@monaco-editor/loader": "^1.3.2",
"@monaco-editor/react": "^4.4.6",
"@testing-library/jest-dom": "^5.16.5",
Expand All @@ -14,18 +16,20 @@
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"debug": "^4.3.4",
"jszip": "^3.10.1",
"monaco-editor": "^0.36.1",
"primeflex": "^3.3.1",
"primeicons": "^6.0.1",
"primereact": "9.3.x",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-stl-viewer": "^2.2.5",
"react-widgets": "^5.8.4"
"react-stl-viewer": "^2.2.5"
},
"scripts": {
"start": "concurrently 'npx webpack serve --mode=development' 'NODE_ENV=development npx rollup --config openscad-worker.rollup.config.js --watch'",
"start:prod": "PUBLIC_URL=http://localhost:3000/dist/ npm run build && npx serve",
"test:e2e": "jest",
"start:development": "concurrently 'npx webpack serve --mode=development' 'NODE_ENV=development npx rollup --config openscad-worker.rollup.config.js --watch'",
"start:production": "NODE_ENV=production PUBLIC_URL=http://localhost:3000/dist/ npm run build && npx serve",
"start": "npm run start:development",
"build": "NODE_ENV=production npx rollup --config openscad-worker.rollup.config.js && webpack --mode=production"
},
"eslintConfig": {
Expand Down Expand Up @@ -57,7 +61,10 @@
"concurrently": "^7.6.0",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.8.1",
"jest": "^29.7.0",
"jest-puppeteer": "^11.0.0",
"livereload": "^0.9.3",
"puppeteer": "^23.11.1",
"rollup": "^2.79.1",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-css": "^1.0.0",
Expand All @@ -68,7 +75,7 @@
"serve": "^14.2.0",
"style-loader": "^3.3.3",
"ts-loader": "^9.4.2",
"tslib": "^2.5.0",
"tslib": "^2.6.3",
"webpack": "^5.76.3",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.2",
Expand Down
Binary file added public/skybox-lights.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ import { ConfirmDialog } from 'primereact/confirmdialog';
import CustomizerPanel from './CustomizerPanel';


// import "primereact/resources/themes/lara-light-indigo/theme.css";
// import "primereact/resources/primereact.min.css";
// import "primeicons/primeicons.css";

export function App({initialState, statePersister, fs}: {initialState: State, statePersister: StatePersister, fs: FS}) {
const [state, setState] = useState(initialState);

Expand Down
15 changes: 2 additions & 13 deletions src/components/CustomizerPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.

import { CSSProperties, useContext } from 'react';
import { ModelContext, FSContext } from './contexts';
import { ModelContext } from './contexts';

import { Dropdown } from 'primereact/dropdown';
import { Slider } from 'primereact/slider';
Expand Down Expand Up @@ -48,6 +48,7 @@ export default function CustomizerPanel({className, style}: {className?: string,
style={{
display: 'flex',
flexDirection: 'column',
maxHeight: '80vh',
overflow: 'scroll',
...style,
bottom: 'unset',
Expand Down Expand Up @@ -81,8 +82,6 @@ export default function CustomizerPanel({className, style}: {className?: string,
function ParameterInput({param, value, className, style, handleChange}: {param: Parameter, value: any, className?: string, style?: CSSProperties, handleChange: (key: string, value: any) => void}) {
return (
<div
// ref={ref}
// onClick={state.view.layout.mode === 'single' ? handleClick : undefined}
style={{
flex: 1,
...style,
Expand All @@ -99,7 +98,6 @@ function ParameterInput({param, value, className, style, handleChange}: {param:
justifyContent: 'space-between',
}}>
<div
// onClick={swallowClick}
style={{
flex: 1,
display: 'flex',
Expand All @@ -109,10 +107,7 @@ function ParameterInput({param, value, className, style, handleChange}: {param:
<div>{param.caption}</div>
</div>
<div
// onClick={swallowClick}
style={{
// flex: 1,
// margin: '10px',
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
Expand All @@ -130,7 +125,6 @@ function ParameterInput({param, value, className, style, handleChange}: {param:
)}
{param.type === 'string' && param.options && (
<Dropdown
// style={{flex: 1}}
value={value || param.initial}
options={param.options}
onChange={(e) => handleChange(param.name, e.value)}
Expand All @@ -140,18 +134,15 @@ function ParameterInput({param, value, className, style, handleChange}: {param:
)}
{param.type === 'boolean' && (
<Checkbox
// style={{flex: 1}}
checked={value ?? param.initial}
onChange={(e) => handleChange(param.name, e.checked)}
/>
)}
{!Array.isArray(param.initial) && param.type === 'number' && !('options' in param) && (
<InputNumber
// style={{flex: 1}}
value={value || param.initial}
showButtons
size={5}
// buttonLayout='horizontal'
onValueChange={(e) => handleChange(param.name, e.value)}
/>
)}
Expand All @@ -176,7 +167,6 @@ function ParameterInput({param, value, className, style, handleChange}: {param:
min={param.min}
max={param.max}
showButtons
// buttonLayout='horizontal'
size={5}
step={param.step}
onValueChange={(e) => {
Expand All @@ -194,7 +184,6 @@ function ParameterInput({param, value, className, style, handleChange}: {param:
marginRight: '0',
visibility: value === undefined || (JSON.stringify(value) === JSON.stringify(param.initial)) ? 'hidden' : 'visible',
}}
// tooltip={`Reset to default value (${JSON.stringify(param.initial)})`}
tooltipOptions={{position: 'left'}}
icon='pi pi-refresh'
className='p-button-text'/>
Expand Down
Loading
Loading