scad-gltf 0.3.2 → 0.4.0

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 CHANGED
@@ -24,6 +24,7 @@ The C++ source code for this custom OpenSCAD version is included directly in thi
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
25
  - **Godot 4, Rust Bevy & Web Integration:** Native Godot 4 importer addon and Rust Bevy compile-time `build.rs` integration.
26
26
  - **Automated AI Generation:** Pass an OpenAI-compatible base URL (and optional API key) to the `scad-gltf gen` CLI tool to automatically spawn a local MCP server, query the LLM via standard endpoints, allow it to visually iterate, and output a ready-to-run game project or raw 3D asset script.
27
+ - **Project Runner:** Bundled `scad-gltf play` CLI utility to safely unpack, build, and launch generated game projects in isolated temporary environments.
27
28
 
28
29
  ---
29
30
 
@@ -251,7 +252,7 @@ When asking an LLM (like Gemini) to generate OpenSCAD code, the extension automa
251
252
 
252
253
  ---
253
254
 
254
- ## 🤖 Model Context Protocol (MCP) Server
255
+ ## 🤖 Model Context Protocol Server (`scad-gltf mcp`)
255
256
 
256
257
  This package includes a native [MCP Server](https://modelcontextprotocol.io/) (`scad-gltf mcp`) designed to give AI assistants **visual feedback** during the 3D modeling process.
257
258
 
@@ -294,15 +295,16 @@ The addon allows you to drag-and-drop `.scad` files directly into your Godot pro
294
295
 
295
296
  ---
296
297
 
297
- ### Automated AI Generation (OpenAI-Compatible API)
298
+ ## Automated AI Generation (`scad-gltf gen`)
298
299
 
299
300
  By default, the `scad-gltf gen` utility copies 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-gltf mcp` server in the background, connect it to your LLM, and allow the AI to _visually evaluate and fix_ its code in real-time before saving the final `generate_project.js` script to your disk.
300
301
 
301
302
  **Supported Generation Types:**
302
303
 
303
- - `gen`: Generate a single raw `.scad` asset file.
304
+ - `scad`: Generate a single raw `.scad` asset file.
304
305
  - `godot`: Generate a fully packaged Godot 4 game project containing generated assets and GDScript logic.
305
306
  - `bevy`: Generate a Rust Bevy game project.
307
+ - `wgpu`: Generate a Rust wgpu graphics project.
306
308
  - `web`: Generate a Vite-based Web3D app (Three.js/Babylon).
307
309
 
308
310
  **Option 1: Using OpenAI (GPT-4o)**
@@ -340,7 +342,20 @@ You can also pass credentials inline as a JSON string argument instead of modify
340
342
  scad-gltf gen godot "A futuristic tank game" '{"openaiBaseUrl": "http://127.0.0.1:8080/v1", "openaiModel": "llama-3"}'
341
343
  ```
342
344
 
343
- _Once the automated process completes for full game projects, simply run the generated Node.js script to assemble your complete Godot, Bevy, or Vite project structure with all assets and code!_
345
+ **Providing Existing SCAD Files (`scadFiles`)**
346
+ You can inject your own local `.scad` files into the AI's context using the `scadFiles` JSON option. The AI will embed them into the generated project or use them as a foundation.
347
+
348
+ ```bash
349
+ scad-gltf gen godot "A game using the provided player model" '{"scadFiles": ["./player.scad"]}'
350
+ ```
351
+
352
+ _Once the automated process completes for full game projects, you can test it instantly using the `play` command:_
353
+
354
+ ```bash
355
+ scad-gltf play generate_godot_project.js
356
+ ```
357
+
358
+ _Alternatively, to extract the final project permanently into your current directory, just run the script with Node:_
344
359
 
345
360
  ```bash
346
361
  node generate_godot_project.js
@@ -348,6 +363,18 @@ node generate_godot_project.js
348
363
 
349
364
  ---
350
365
 
366
+ ## Testing Generated Projects (`scad-gltf play`)
367
+
368
+ The `scad-gltf play` utility is designed to quickly test the single-file Node.js scripts produced by the `gen` command. Instead of cluttering your working directory, it unpacks the project into a temporary folder, automatically installs dependencies or builds the project (Godot, Rust Bevy, or Vite), and launches it. Once you close the application, the temporary folder is automatically cleaned up.
369
+
370
+ **Usage:**
371
+
372
+ ```bash
373
+ scad-gltf play <path_to_generated_script.js>
374
+ ```
375
+
376
+ ---
377
+
351
378
  ## Extended OpenSCAD Syntax
352
379
 
353
380
  This custom fork introduces new syntax not found in standard OpenSCAD.
package/bin/gen.js CHANGED
@@ -3,7 +3,7 @@
3
3
  import { runCliApp } from "../src/cli-utils.js";
4
4
  import { getProjectPrompts } from "../src/project-prompts.js";
5
5
 
6
- const VALID_TYPES = ["scad", "bevy", "web", "godot"];
6
+ const VALID_TYPES = ["scad", "bevy", "wgpu", "web", "godot"];
7
7
 
8
8
  async function main() {
9
9
  const projectType = process.argv[2];
@@ -14,7 +14,7 @@ async function main() {
14
14
  `Usage: scad-gltf gen <${VALID_TYPES.join("|")}> "<description>" [options_json]`,
15
15
  );
16
16
  console.error(
17
- `Example: scad-gltf gen godot "A 3D racing game" '{"openaiModel": "gpt-4o"}'`,
17
+ `Example: scad-gltf gen godot "A 3D physics simulation" '{"openaiModel": "gpt-4o", "scadFiles": ["./player.scad"]}'`,
18
18
  );
19
19
  process.exit(1);
20
20
  }
package/bin/mcp.js CHANGED
@@ -201,7 +201,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
201
201
  {
202
202
  name: "test_godot_project",
203
203
  description:
204
- "Runs a specified Godot project for a short duration to detect script errors, missing resources, or runtime crashes. Returns the console output logs and a visual screenshot of the gameplay.",
204
+ "Runs a specified Godot project for a short duration to detect script errors, missing resources, or runtime crashes. Returns the console output logs and a visual screenshot of the running project.",
205
205
  inputSchema: {
206
206
  type: "object",
207
207
  properties: {
@@ -793,7 +793,7 @@ func _ready():
793
793
  }
794
794
  fs.writeFileSync(projectGodotPath, tempProjectGodot, "utf8");
795
795
 
796
- // 2. Play Game Step
796
+ // 2. Run Project Step
797
797
  // Always try windowed first to get the screenshot.
798
798
  // If the environment lacks a display server, we'll catch the error and fallback.
799
799
  let playArgs = [
package/bin/play.js CHANGED
@@ -62,7 +62,7 @@ function main() {
62
62
 
63
63
  // 3. Find the resulting project folder and determine its type
64
64
  let projectDir = null;
65
- let projectType = null; // 'godot' | 'web' | 'bevy'
65
+ let projectType = null; // 'godot' | 'web' | 'rust'
66
66
  let latestTime = 0;
67
67
 
68
68
  const items = fs.readdirSync(tempDir);
@@ -71,14 +71,14 @@ function main() {
71
71
  if (fs.statSync(itemPath).isDirectory()) {
72
72
  const isGodot = fs.existsSync(path.join(itemPath, "project.godot"));
73
73
  const isWeb = fs.existsSync(path.join(itemPath, "package.json"));
74
- const isBevy = fs.existsSync(path.join(itemPath, "Cargo.toml"));
74
+ const isRust = fs.existsSync(path.join(itemPath, "Cargo.toml"));
75
75
 
76
- if (isGodot || isWeb || isBevy) {
76
+ if (isGodot || isWeb || isRust) {
77
77
  const mtime = fs.statSync(itemPath).mtimeMs;
78
78
  if (mtime > latestTime) {
79
79
  latestTime = mtime;
80
80
  projectDir = itemPath;
81
- projectType = isGodot ? "godot" : isBevy ? "bevy" : "web";
81
+ projectType = isGodot ? "godot" : isRust ? "rust" : "web";
82
82
  }
83
83
  }
84
84
  }
@@ -87,7 +87,7 @@ function main() {
87
87
  if (!projectDir || !projectType) {
88
88
  console.error("\n❌ Error: Could not find a valid generated project.");
89
89
  console.error(
90
- "The script did not produce a folder containing 'project.godot' or 'package.json'.",
90
+ "The script did not produce a folder containing 'project.godot', 'package.json', or 'Cargo.toml'.",
91
91
  );
92
92
  cleanup();
93
93
  process.exit(1);
@@ -103,7 +103,7 @@ function main() {
103
103
 
104
104
  console.log(`\n⚙️ Importing Godot assets (this may take a moment)...`);
105
105
  try {
106
- // Force Godot to build the .godot/imported cache before attempting to run the game
106
+ // Force Godot to build the .godot/imported cache before attempting to run the project
107
107
  execSync(`"${godotBin}" --headless --editor --quit`, {
108
108
  cwd: projectDir,
109
109
  stdio: "inherit",
@@ -137,9 +137,9 @@ function main() {
137
137
  cwd: projectDir,
138
138
  stdio: "inherit",
139
139
  });
140
- } else if (projectType === "bevy") {
140
+ } else if (projectType === "rust") {
141
141
  console.log(
142
- `\n🦀 Compiling and starting Rust Bevy game (this may take a moment)...`,
142
+ `\n🦀 Compiling and starting Rust project (this may take a moment)...`,
143
143
  );
144
144
  const cargoCmd = process.platform === "win32" ? "cargo.exe" : "cargo";
145
145
  appProcess = spawn(cargoCmd, ["run"], {
package/bin/scad-gltf.js CHANGED
@@ -17,7 +17,7 @@ if (!command || !commands[command]) {
17
17
  console.error(" serve Start local API server and Web Editor");
18
18
  console.error(" mcp Start the Model Context Protocol (MCP) server");
19
19
  console.error(
20
- " gen Automated AI generation of 3D models and game projects",
20
+ " gen Automated AI generation of 3D models, simulations, and interactive projects",
21
21
  );
22
22
  console.error(" play Test and launch generated Node.js scripts");
23
23
  process.exit(1);