webwaspjs
v0.3.8
Published
JavaScript port of WASP for discrete aggregations (Three.js)
Maintainers
Readme
webwaspjs
webwaspjs is a JavaScript library for loading and growing discrete aggregation systems in the browser.
Install
npm install webwaspjs threethree is a required peer dependency and must be installed by the consuming application.
Quick start
import { createAggregationFromData } from 'webwaspjs';
const aggregation = createAggregationFromData(aggregationData);
const roundtripExport = aggregation.toData();
const lightweightRoundtripExport = aggregation.toData(false);
const fileExport = aggregation.toFileData();
console.log(Object.keys(aggregation.parts));
console.log(aggregation.rules.length);
console.log(JSON.stringify(roundtripExport));
console.log(JSON.stringify(lightweightRoundtripExport));
console.log(JSON.stringify(fileExport));Main entry points:
createAggregationFromData(data)to rebuild an aggregation from serialized dataaggregation.toData()to export the full roundtrip/core aggregation dataaggregation.toData(false)to export roundtrip/core data without per-instance aggregated geometry or collidersaggregation.toFileData()to export the compact placed-parts file formatAggregationfor direct access to the core modelVisualizerfor simple browser rendering
Part attributes
Part.attributes is an optional array of JSON values. The array and its nested values are copied when a part is constructed, copied, transformed, serialized, or deserialized. Placed parts retain their own attributes in both full and lightweight Aggregation.toData() exports. Older data without an attributes field loads with an empty array; a lightweight placed part can inherit attributes from its base part.
The original Python Wasp Part implementation omits attributes from to_data() and ignores them in from_data(). It can read the additional field in a webwaspjs export, but importing and exporting through Python Wasp will discard those attributes. Python Wasp attribute objects that contain Rhino geometry are outside this JSON data format.
Development
Requirements:
- Node.js 18+
- npm 9+
Commands:
npm installnpm run lintnpm testnpm run build
Project layout
src/ library source
src/tests/ vitest suite
src/tests/fixtures/ JSON fixtures used by tests
dist/ build outputRelated repositories
Credits
- Roger Winkler — rogerwinkler.de
- Andrea Rossi — thecomputationalhive.com
Based on the original WASP Grasshopper plug-in by Andrea Rossi.
License
MIT. See LICENSE.txt.
