Skip to content

Repository files navigation

@gui-chat-plugin/present3d

npm version

3D shape presentation plugin using ShapeScript for GUI Chat applications. Create interactive 3D visualizations with a powerful DSL.

Screenshot

Features

  • Full ShapeScript language support (variables, expressions, control flow)
  • Interactive 3D viewport with camera controls
  • Wireframe and grid toggle
  • CSG operations (union, difference, intersection)
  • Built-in math and trigonometric functions
  • Inline script editing

Installation

yarn add @gui-chat-plugin/present3d gui-chat-protocol

gui-chat-protocol is a peer dependency — install it alongside the plugin; the host application provides the runtime and this plugin only declares the compatible range.

Usage

Vue Integration

// In src/tools/index.ts
import Present3DPlugin from "@gui-chat-plugin/present3d/vue";

const pluginList = [
  // ... other plugins
  Present3DPlugin,
];

// In src/main.ts
import "@gui-chat-plugin/present3d/style.css";

Core-only Usage

import { executePresent3D, TOOL_DEFINITION } from "@gui-chat-plugin/present3d";

// Create a 3D visualization
const result = await executePresent3D(context, {
  title: "Circular Pattern",
  script: `
define count 12
for i in 1 to count {
    define angle ((i / count) * 6.283)
    cube {
        position (cos(angle) * 3) 0 (sin(angle) * 3)
        color (i / count) 0.5 (1 - i / count)
        size 0.5
    }
}
  `,
});

API

Present3DArgs

interface Present3DArgs {
  title: string;   // Title for the visualization
  script: string;  // ShapeScript code
}

Present3DToolData

interface Present3DToolData {
  script: string;  // The ShapeScript source code
}

ShapeScript Language

Primitives

  • cube, sphere, cylinder, cone, torus

Properties

  • position X Y Z - 3D position
  • rotation X Y Z - Rotation in half-turns
  • size X Y Z - Scale
  • color R G B - RGB color (0-1)
  • opacity - Transparency (0-1)

Variables & Expressions

define radius 2
define red (1 0 0)
sphere { size radius color red }

Control Flow

for i in 1 to 5 {
    cube { position (i * 2) 0 0 }
}

if condition {
    sphere
} else {
    cube
}

CSG Operations

difference {
    sphere { size 2 }
    cube { size 1.5 }
}

Built-in Functions

  • Math: round, floor, ceil, abs, sqrt, pow, min, max
  • Trig: sin, cos, tan, asin, acos, atan, atan2

Development

# Install dependencies
yarn install

# Run demo
yarn dev

# Build
yarn build

# Lint
yarn lint

Test Prompts

Try these prompts to test the plugin:

  1. "Create a 3D visualization of a simple house with a roof"
  2. "Show me a 3D spiral staircase"
  3. "Generate a 3D model of the solar system with planets orbiting the sun"

License

MIT

Related

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages