Bundle OpenSCAD examples + update default model

This commit is contained in:
ochafik 2023-03-27 22:38:22 +01:00
commit 5ec86067ca
6 changed files with 75 additions and 28 deletions

View file

@ -9,6 +9,9 @@ import { join } from '../fs/filesystem';
import { defaultSourcePath } from '../state/initial-state';
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[] {
const files: [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]);
}
[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[] = []
for (const [arr, isDirectory] of [[files, false], [dirs, true]] as [[string, string][], boolean][]) {

View file

@ -22,6 +22,14 @@ export type ZipArchives = {
export const zipArchives: ZipArchives = {
'fonts': {},
'openscad': {
description: 'OpenSCAD',
gitOrigin: {
branch: 'master',
repoUrl: 'https://github.com/openscad/openscad',
include: [{glob: ['examples/*.scad', 'LICENSE']}],
},
},
'MCAD': {
description: 'OpenSCAD Parametric CAD Library',
gitOrigin: {

View file

@ -1,19 +1,45 @@
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
export default `
rotate([90, 0, 0]) {
translate([-50, 0, 50])
linear_extrude(10)
text("hello world!");
}
cube(40, center=true);
translate([10, 10, 10])
cube(40, center=true);
export default `/*
Hello there!
// This demo includes many libraries:
//
// include <BOSL2/std.scad>
// translate([-100, 0, 0])
// spheroid(d=100, style="icosa", $fn=20);
If you're new to OpenSCAD, please learn the basics here:
https://openscad.org/documentation.html
There are lots of amazing libraries in the OpenSCAD ecosystem
(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");
`