scad-gltf 0.1.4 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -3
- package/bevy/README.md +46 -0
- package/bevy/examples/LICENSE +21 -0
- package/bevy/examples/README.md +58 -0
- package/bevy/examples/package.json +5 -0
- package/bevy/examples/packman_3d.js +2415 -0
- package/bin/scad-bevy.js +74 -0
- package/bin/scad-gen.js +25 -0
- package/bin/scad-godot.js +65 -222
- package/bin/scad-mcp.js +641 -2
- package/bin/scad-play.js +172 -0
- package/bin/scad-web.js +14 -166
- package/package.json +7 -2
- package/src/cli-utils.js +792 -0
- package/src/godot-utils.js +179 -0
package/README.md
CHANGED
|
@@ -22,7 +22,8 @@ The C++ source code for this custom OpenSCAD version is included directly in thi
|
|
|
22
22
|
- **CLI Converter:** Bundled `scad-convert` CLI utility for single file and batch compiling `.scad` files with smart dependency hashing.
|
|
23
23
|
- **MCP Server for AI Agents:** Bundled `scad-mcp` server enables MCP clients to iteratively design, compile, and **visually inspect** 3D models via multi-angle headless rendering and animation frame evaluation.
|
|
24
24
|
- **AI Studio Extension:** Chrome extension to natively preview, prompt, take chat snapshots, open in Scadify, and locally save AI-generated 3D models directly inside Google AI Studio.
|
|
25
|
-
- **Godot 4
|
|
25
|
+
- **Godot 4, Rust Bevy & Web Integration:** Native Godot 4 importer addon, Rust Bevy compile-time `build.rs` integration, and prebuilt AI-generated game examples for Godot and Bevy.
|
|
26
|
+
- **Automated AI Generation:** Pass an OpenAI-compatible base URL (and optional API key) to the `scad-godot`, `scad-bevy`, or `scad-web` CLI to automatically spawn a local MCP server, query the LLM via standard endpoints, allow it to visually iterate, and output a ready-to-run project generator script.
|
|
26
27
|
|
|
27
28
|
---
|
|
28
29
|
|
|
@@ -260,6 +261,7 @@ Instead of generating code blindly, the AI can compile its script, render the 3D
|
|
|
260
261
|
|
|
261
262
|
- `get_scad_prompt`: Injects the custom OpenSCAD syntax rules (PBR, animations, baking) into the AI's context.
|
|
262
263
|
- `render_scad_model`: Compiles the generated `.scad` code to GLB and returns base64 images from requested camera angles (front, back, left, right, top, bottom, isometric) and specific animation keyframes.
|
|
264
|
+
- `compile_bevy_project` / `test_godot_project`: Tests the generated game projects for compilation and runtime errors.
|
|
263
265
|
|
|
264
266
|
### Setup
|
|
265
267
|
|
|
@@ -295,6 +297,53 @@ Try prebuilt AI-generated Godot games directly in your browser: [https://iliagri
|
|
|
295
297
|
|
|
296
298
|
---
|
|
297
299
|
|
|
300
|
+
### Automated AI Generation (OpenAI-Compatible API)
|
|
301
|
+
|
|
302
|
+
By default, `scad-godot`, `scad-bevy`, and `scad-web` copy a heavily engineered system prompt to your clipboard to paste into an LLM. However, if you provide a **Base URL** (and optional **API Key**), the CLI will fully automate this process. It will automatically spin up the `scad-mcp` server in the background, connect it to your LLM, and allow the AI to _visually evaluate and fix_ its 3D models in real-time before saving the final `generate_project.js` script to your disk.
|
|
303
|
+
|
|
304
|
+
**Option 1: Using OpenAI (GPT-4o)**
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
export OPENAI_BASE_URL="https://api.openai.com/v1"
|
|
308
|
+
export OPENAI_API_KEY="sk-..."
|
|
309
|
+
export OPENAI_MODEL="gpt-4o"
|
|
310
|
+
scad-bevy "A 3D spaceship shooter game"
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
**Option 2: Using Google Gemini (via OpenAI compatibility)**
|
|
314
|
+
Because Gemini provides an official OpenAI-compatible endpoint, you can configure it using standard OpenAI variables:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
export OPENAI_API_KEY="AIzaSy..."
|
|
318
|
+
export OPENAI_BASE_URL="https://generativelanguage.googleapis.com/v1beta/openai/"
|
|
319
|
+
export OPENAI_MODEL="gemini-3.8-flash"
|
|
320
|
+
scad-godot "A fast-paced 3D hovercraft racing game"
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
**Option 3: Using Local Server**
|
|
324
|
+
You can use completely local, uncensored, or fine-tuned vision models by overriding the OpenAI Base URL to point to a local inference server (like `llama.cpp`'s API server).
|
|
325
|
+
|
|
326
|
+
```bash
|
|
327
|
+
export OPENAI_BASE_URL="http://127.0.0.1:8080/v1"
|
|
328
|
+
export OPENAI_MODEL="llama-3" # Or whatever model name you've loaded
|
|
329
|
+
scad-web "A 3D configurator app"
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
**Passing Parameters via JSON**
|
|
333
|
+
You can also pass credentials inline as a JSON string argument instead of modifying environment variables:
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
scad-godot "A futuristic tank game" '{"openaiBaseUrl": "http://127.0.0.1:8080/v1", "openaiModel": "llama-3"}'
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
_Once the automated process completes, simply run the generated Node.js script to assemble your complete Godot, Bevy, or Vite project structure with all assets and code!_
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
node generate_godot_project.js
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
298
347
|
## Extended OpenSCAD Syntax
|
|
299
348
|
|
|
300
349
|
This custom fork introduces new syntax not found in standard OpenSCAD.
|
|
@@ -421,8 +470,6 @@ const promptContext = generatePrompt(description, {
|
|
|
421
470
|
console.log(promptContext);
|
|
422
471
|
```
|
|
423
472
|
|
|
424
|
-
---
|
|
425
|
-
|
|
426
473
|
### Workflow
|
|
427
474
|
|
|
428
475
|
Once connected, an AI assistant can use the server to execute the following loop:
|
package/bevy/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# OpenSCAD GLTF Integration for Rust Bevy
|
|
2
|
+
|
|
3
|
+
This folder contains resources and examples for integrating procedural OpenSCAD (`.scad`) 3D assets natively into the [Bevy](https://bevyengine.org/) game engine using the `scad-gltf` compiler.
|
|
4
|
+
|
|
5
|
+
Unlike Godot (which uses a native editor plugin), Bevy integration is achieved programmatically at compile-time using a custom `build.rs` script. This script automatically watches your `.scad` files and compiles them into binary `.glb` meshes in your `assets/models` folder before the game compiles and runs.
|
|
6
|
+
|
|
7
|
+
## 🛠️ How It Works
|
|
8
|
+
|
|
9
|
+
To use OpenSCAD files in your Bevy project, ensure you have the CLI compiler installed globally on your machine:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g scad-gltf
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then, add a `build.rs` script to the root of your Bevy project (next to `Cargo.toml`):
|
|
16
|
+
|
|
17
|
+
```rust
|
|
18
|
+
use std::process::Command;
|
|
19
|
+
|
|
20
|
+
fn main() {
|
|
21
|
+
// Tell Cargo to re-run this script only if the 'scad' directory changes
|
|
22
|
+
println!("cargo::rerun-if-changed=scad");
|
|
23
|
+
|
|
24
|
+
// Ensure cross-platform compatibility for npm global binaries
|
|
25
|
+
let cmd = if cfg!(target_os = "windows") {
|
|
26
|
+
"scad-convert.cmd"
|
|
27
|
+
} else {
|
|
28
|
+
"scad-convert"
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
let status = Command::new(cmd)
|
|
32
|
+
.args(["./scad", "./assets/models", "--cache"])
|
|
33
|
+
.status()
|
|
34
|
+
.expect("Failed to execute scad-convert. Is scad-gltf installed globally?");
|
|
35
|
+
|
|
36
|
+
if !status.success() {
|
|
37
|
+
panic!("scad-convert failed with status: {}", status);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Now, any `.scad` files placed in your `scad/` directory will automatically be converted to `.glb` when you run `cargo build` or `cargo run`. They can then be loaded natively in Bevy via the Asset Server:
|
|
43
|
+
|
|
44
|
+
```rust
|
|
45
|
+
let my_model = asset_server.load("models/my_model.glb#Scene0");
|
|
46
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ilia Grigorev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# AI-Generated Bevy Examples
|
|
2
|
+
|
|
3
|
+
This folder contains a collection of **all-in-one Node.js scripts**, each representing a complete, playable 3D Rust Bevy game generated entirely by AI using the `scad-bevy` CLI tool.
|
|
4
|
+
|
|
5
|
+
Instead of committing messy project folders, each example is bundled into a single, self-extracting JavaScript file. These scripts contain the generated OpenSCAD (`.scad`) 3D assets, Rust source code (`main.rs`), and the required `build.rs` and `Cargo.toml` configurations.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🚀 How to Play the Examples
|
|
10
|
+
|
|
11
|
+
To test out an example, you need to extract it and run it using Cargo.
|
|
12
|
+
|
|
13
|
+
### Prerequisites
|
|
14
|
+
|
|
15
|
+
- **Node.js** installed on your system.
|
|
16
|
+
- **Rust and Cargo** installed on your system.
|
|
17
|
+
- **scad-gltf** installed globally: `npm install -g scad-gltf`
|
|
18
|
+
|
|
19
|
+
### Step 1: Extract the Project
|
|
20
|
+
|
|
21
|
+
Open your terminal in this folder and execute the desired example script using Node.js:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
node packman_3d.js
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
_The script will automatically create a new folder (e.g., `./packman_3d`) containing the full Bevy project directory structure, saving all the assets and Rust files to disk._
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
### Step 2: Compile & Play
|
|
32
|
+
|
|
33
|
+
Navigate into the newly extracted project folder and use Cargo to run the game:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
cd packman_3d
|
|
37
|
+
cargo run
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
_The `build.rs` script will automatically invoke `scad-convert` to compile the OpenSCAD assets into `.glb` format before Bevy boots up._
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 🛠️ How were these generated?
|
|
45
|
+
|
|
46
|
+
These files were created using this repository's built-in AI prompt pipeline. By running the `scad-bevy` CLI command, the system instructs an LLM (like Claude, Gemini, or ChatGPT) to generate procedural OpenSCAD geometry, gameplay logic, and scene configurations, outputting them as a single JS extractor script.
|
|
47
|
+
|
|
48
|
+
If you want to generate your own games, run:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
scad-bevy "A simple 3D platformer where you control a rolling ball collecting coins"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
_(See the main repository documentation for full details on generating your own AI projects)._
|
|
55
|
+
|
|
56
|
+
## 📜 License
|
|
57
|
+
|
|
58
|
+
These examples are licensed under the [MIT License](LICENSE).
|