selva-compute
v1.1.2
Published
TypeScript library for Rhino Compute Server - Grasshopper and RhinoCommon
Maintainers
Readme
selva-compute
An intermediate-level TypeScript framework for building web applications with Rhino Compute and Grasshopper.
selva-compute simplifies the process of communicating with Rhino Compute, handling Grasshopper definitions, and visualizing results in the browser with Three.js.
Installation
npm install selva-compute three(Note: three is a peer dependency if you use the visualization features)
Why this project exists
selva-compute provides a type-safe, production-ready foundation for building with Rhino Compute:
- Type-safe API – Full TypeScript support with advanced error handling for stability
- High-level abstractions – Use
GrasshopperClientandGrasshopperResponseProcessorto get started quickly - Ready-to-use visualization – Integrated Three.js setup with
initScene()and configurable rendering options
Whether you're building a simple solver or a complex web application, selva-compute handles the complexity so you can focus on your Grasshopper definitions.
Note: The library currently focuses on the Grasshopper endpoint but is designed to support other Rhino Compute endpoints in future releases.
Example with GrasshopperClient
// Configuration
const DEFINITION_FILE = 'my-definition.gh';
const COMPUTE_SERVER = 'http://localhost:6500';
const API_KEY = 'your-api-key';
const config = {
serverUrl: COMPUTE_SERVER,
apiKey: API_KEY
} as GrasshopperComputeConfig;
let client: GrasshopperClient | null = null;
// Step 1: Create and initialize the client
client = await GrasshopperClient.create(config);
// Step 2: Get definition inputs and outputs
const io = await client.getIO(DEFINITION_FILE);
// Step 3: Build input data tree from definition parameters
const inputTree = TreeBuilder.fromInputParams(io.inputs);
// Step 4: Run the computation
const result = await client.solve(DEFINITION_FILE, inputTree);
// Step 5: Process and display results
const processor = new GrasshopperResponseProcessor(result);
const { values } = processor.getValues();Requirements
Core Requirements
- Node.js >= 20
- three >= 0.179.0 (required for visualization features)
Rhino Compute Compatibility
selva-compute works with both standard Rhino Compute and enhanced versions:
Standard Rhino Compute – The official McNeel repository works for basic Grasshopper solving with core features.
Enhanced Setup (Recommended) – Unlock advanced features:
- Selva Rhino Plugin – Grasshopper plugin that simplifies building Three.js visualizations and exporting results directly from Grasshopper. Download from Food4Rhino. Detailed documentation will be available when the Selva project is open-sourced.
- Custom Compute Server – Our custom branch enables:
- Input Grouping – Organize inputs with the
groupNameproperty - Persistent IDs – Uniquely identify inputs across definition changes using Grasshopper object GUIDs
- Input Grouping – Organize inputs with the
Features requiring the enhanced setup will be clearly marked in the documentation.
Acknowledgement
This library is built on production experience and draws from several official McNeel repositories. Where code has been adapted, it is clearly marked in the relevant files.
Key References:
- compute.rhino3d.appserver – Server implementation reference
- IO/Schema.cs – Grasshopper API structure
- GrasshopperDefinition.cs – Definition parsing logic
- computeclient_js – JavaScript client implementation
License
MIT
