Loading...
Loading...
Create, edit, render, and snapshot browser-native implicit CAD `.implicit.js` and `.implicit.mjs` files using GLSL signed-distance fields, shader primitives, smooth booleans, TPMS fields, and direct CAD Viewer raymarch rendering. Experimental.
npx skill4agent add earthtojake/text-to-cad implicit-cad.implicit.js.implicit.mjsimplicit.js/0.1.0scripts/packages/implicitjs/src/lib/implicitCad/schema.jsscripts/lib/implicit-cad.mjsSCHEMAexport default {
schema: "implicit.js/0.1.0",
name: "rounded capsule block",
glsl: `
float sdf(vec3 p) {
float sphere = implicit_sphere(p, vec3(0.0), 22.0);
float block = implicit_box_centered(p, vec3(34.0, 18.0, 18.0), vec3(0.0));
return implicit_union_round(sphere, block, 3.0);
}
vec3 color(vec3 p, vec3 normal) {
return mix(vec3(0.20, 0.55, 0.95), vec3(0.95, 0.45, 0.20), smoothstep(-15.0, 20.0, p.z));
}
`,
};numberbooleanenumselectcolorstringbuttonuniformsboundsboundsrender{ ...params, params, animation, animationState, elapsedSec, progress, t }implicit_*implicit_sphereimplicit_box_centeredimplicit_union_roundexport default {
schema: "implicit.js/0.1.0",
name: "breathing orb",
params: {
radius: {
type: "number",
label: "Radius",
min: 12,
max: 34,
default: 22,
unit: "mm",
},
},
animations: {
breathe: {
label: "Breathe",
duration: 3,
update({ progress, set }) {
set("radius", 18 + Math.sin(progress * Math.PI) * 10);
},
},
},
render: { steps: 224, epsilon: 0.004 },
glsl: `
float sdf(vec3 p) {
return length(p) - radius;
}
vec3 color(vec3 p, vec3 normal) {
return mix(vec3(0.10, 0.58, 0.95), vec3(1.0, 0.34, 0.12), smoothstep(-18.0, 18.0, p.z));
}
`,
};scripts/lib/implicit-cad.mjs.implicit.js.implicit.mjs.implicit.js.implicit.mjsscripts/lib/implicit-cad.mjsspherecircleboxCenteredplanelineSegmenttorusaxiscylindercylinderCappedcapsuleconeconeCappedconeCapsuleunionSharpintersectSharpunionRoundintersectRoundunionChamferintersectChamferunionExpintersectExpunionLpNormintersectLpNormunionRvachevintersectRvachevdifferenceshellrotateAxisrepeatCenteredremapCylindricalcubicGridsquareHoneycombsquareHoneycombReinforcedsquareDiagonalHoneycomboctetHoneycombhexagonalHoneycombtriangularHoneycombtpmsGyroidtpmsSchwarztpmsDiamondtpmsLidinoidtpmsNeoviustpmsSplitPtpmsIwpdistanceFunctionfloat sdf(vec3 p)colorFunctionvec3 color(vec3 p, vec3 normal)paramsanimationsvec3 color(vec3 p, vec3 normal)node scripts/export.mjs --input <model.implicit.js> --format glbnode scripts/snapshot.mjs --input models/implicit-cad/<model>.implicit.js --output /tmp/implicit-review/<model>.pngnode scripts/snapshot.mjs --job - <<'JSON'
{
"input": "models/implicit-cad/<model>.implicit.js",
"mode": "view",
"render": { "sizeProfile": "simple", "frameMargin": 1.55 },
"graphics": { "modelColors": true, "detail": 1.2, "shadows": true, "ambientOcclusion": true },
"outputs": [
{ "path": "/tmp/implicit-review/<model>-iso.png", "camera": "iso" },
{ "path": "/tmp/implicit-review/<model>-front.png", "camera": "front" },
{ "path": "/tmp/implicit-review/<model>-top.png", "camera": "top" },
{ "path": "/tmp/implicit-review/<model>-right.png", "camera": "right" }
]
}
JSONimplicitParametersrender.frameMargin1.5boundsnode scripts/snapshot.mjs --job - <<'JSON'
{
"input": "models/implicit-cad/<model>.implicit.js",
"mode": "animate",
"outputs": [{ "path": "/tmp/implicit-review/<model>-animation.gif" }],
"implicitAnimation": { "activeId": "<animation-id>", "durationSeconds": 3, "fps": 12 }
}
JSON.implicit.js.implicit.mjs.glb.stl.3mf$cad-viewer$cad-viewer$cad-viewernode scripts/snapshot.mjs --input <model.implicit.js> --output <snapshot.png>
node scripts/snapshot.mjs --input <model.implicit.js> --output <orbit.gif> --mode orbit
node scripts/snapshot.mjs --job <render-job.json>
node scripts/snapshot.mjs --job - --json
node scripts/snapshot.mjs --helpnode scripts/snapshot.mjs --helpoutputs{ "jobs": [...] }node scripts/export.mjs --input <model.implicit.js> --format glb
node scripts/export.mjs --input <model.implicit.js> --output <mesh.stl> --resolution <resolution>
node scripts/export.mjs --input <model.implicit.js> --format 3mf --params '<parameter-json>' --json
node scripts/export.mjs --helpglbstl3mf--output<model>.glb<model>.implicit.jsnode scripts/export.mjs --help