@@ -16,6 +16,7 @@ CSG Builder allows you to create 3D meshes using TypeScript code with a React-li
1616- ** Primitive Shapes** - Cubes, cylinders, spheres, cones, and polygon prisms with customizable dimensions
1717- ** Custom Profile Prisms** - Extrude 2D profiles into 3D shapes using points, paths, or Shape API
1818- ** Body of Revolution** - Create rotationally symmetric objects (chess pieces, vases, bottles) by rotating profiles
19+ - ** Import Capabilities** - Import STL files and SVG paths, use them in CSG operations like any primitive
1920- ** Partial Geometries** - Create pie slices, hemispheres, and wedges with CSG-based angle cutting
2021- ** Static CSG Operations** - Immutable SUBTRACT, UNION, INTERSECT, and MERGE operations for complex geometries
2122- ** Grid Arrays** - Create 1D, 2D, and 3D arrays with static GRID_X, GRID_XY, GRID_XYZ methods
@@ -288,6 +289,55 @@ const quarterVase = Solid.revolutionSolidFromPoints(
288289** Profile coords:** X=radius, Y=height. Rotates around Y-axis.
289290** Uses:** Chess pieces, vases, bottles, tableware, architectural elements
290291
292+ ### Example: Import Capabilities
293+
294+ Load external STL files and SVG paths to use in your designs:
295+
296+ ``` typescript
297+ import { Solid } from ' $lib/3d/Solid' ;
298+
299+ // Import STL file using Vite's import syntax
300+ import stlData from ' ./model.stl?raw' ; // ASCII STL
301+ // For binary STL, use ?url and fetch as ArrayBuffer
302+
303+ // 1. STL IMPORT - Load external 3D models
304+ const imported = Solid .fromSTL (stlData , { color: ' blue' });
305+
306+ // Use imported geometry in CSG operations
307+ const cube = Solid .cube (20 , 20 , 20 , { color: ' red' });
308+ const result = Solid .SUBTRACT (cube , imported );
309+
310+ // Transform imported models
311+ const transformed = Solid .fromSTL (stlData , { color: ' green' })
312+ .scale ({ all: 0.5 })
313+ .rotate ({ y: 45 })
314+ .move ({ y: 10 });
315+
316+ // 2. SVG PATH IMPORT - Extrude SVG paths into 3D
317+ const starPath = ' M 10 0 L 12 8 L 20 8 L 14 13 L 16 21 L 10 16 L 4 21 L 6 13 L 0 8 L 8 8 Z' ;
318+ const star = Solid .profilePrismFromSVG (starPath , 3 , { color: ' gold' });
319+
320+ // Curved SVG paths with quadratic bezier curves (Q)
321+ const curvedPath = ' M 0 5 Q 5 0, 10 5 Q 15 10, 20 5 L 20 10 L 0 10 Z' ;
322+ const curved = Solid .profilePrismFromSVG (curvedPath , 8 , { color: ' pink' });
323+
324+ // Use SVG as cutter
325+ const plate = Solid .cube (30 , 20 , 5 , { color: ' gray' });
326+ const cutout = Solid .SUBTRACT (plate , star );
327+
328+ // 3. COMBINE IMPORTS - Mix imported and primitive shapes
329+ const base = Solid .fromSTL (stlData , { color: ' brown' }).align (' bottom' );
330+ const decoration = Solid .profilePrismFromSVG (' M 0 0 L 5 0 L 5 5 L 0 5 Z' , 2 , { color: ' brown' });
331+ const combined = Solid .UNION (base , decoration );
332+ ```
333+
334+ ** Supported formats:**
335+
336+ - ** STL:** Binary and ASCII formats (via Three.js STLLoader)
337+ - ** SVG:** Path data with M, L, C, Q, A commands (via Three.js SVGLoader)
338+ - Works with all CSG operations, transformations, and grids
339+ - No additional dependencies required
340+
291341## Performance Optimization
292342
293343Cache expensive component computations that are called repeatedly:
@@ -322,6 +372,7 @@ const w3 = Wall(30); // Different params, new computation
322372### API Reference
323373
324374** Primitives:** ` cube(w,h,d,opts) ` , ` cylinder(r,h,opts) ` , ` sphere(r,opts) ` , ` cone(r,h,opts) ` , ` prism(sides,r,h,opts) ` , ` trianglePrism(r,h,opts) `
375+ ** Import:** ` fromSTL(data,opts) ` , ` profilePrismFromSVG(svgPathData,height,opts) `
325376** Profiles:** ` profilePrism(h,builder,opts) ` , ` profilePrismFromPoints(h,points,opts) ` , ` profilePrismFromPath(h,segments,opts) `
326377** Revolution:** ` revolutionSolid(builder,opts) ` , ` revolutionSolidFromPoints(points,opts) ` , ` revolutionSolidFromPath(segments,opts) `
327378** Path Factories:** ` straight(length) ` , ` curve(radius,angle) ` - positive=right, negative=left, 0=sharp
@@ -473,16 +524,16 @@ npm run export --silent -- "Brick Wall" > wall.stl
473524
474525## Examples & Learning Resources
475526
476- ** projects/examples/** - Progressive tutorial (A-M ) with inline docs:
527+ ** projects/examples/** - Progressive tutorial (A-N ) with inline docs:
477528
478529- ** A-G:** Primitives, operations, alignment, partials, composition, profiles, revolution
479- - ** H-M :** Scaling, transforms, 3D grids, patterns, optimization, production composition
530+ - ** H-N :** Scaling, transforms, 3D grids, patterns, optimization, production composition, import capabilities
480531
481532** projects/castle/** - Production multi-file architecture: modular structure, caching, cross-file dependencies, advanced CSG
482533
483534** projects/sample/** - Working examples: box, brick wall, window, shapes showcase, chess pieces
484535
485- Start with examples A-G, then explore castle project for production patterns .
536+ Start with examples A-G, then explore H-N for advanced features including STL/SVG imports .
486537
487538## Troubleshooting
488539
0 commit comments