@particle-academy/fancy-3d 0.1.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 +84 -0
- package/dist/babylon.cjs +773 -0
- package/dist/babylon.cjs.map +1 -0
- package/dist/babylon.d.cts +229 -0
- package/dist/babylon.d.ts +229 -0
- package/dist/babylon.js +754 -0
- package/dist/babylon.js.map +1 -0
- package/dist/dom.cjs +225 -0
- package/dist/dom.cjs.map +1 -0
- package/dist/dom.d.cts +16 -0
- package/dist/dom.d.ts +16 -0
- package/dist/dom.js +223 -0
- package/dist/dom.js.map +1 -0
- package/dist/index.cjs +16 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +188 -0
- package/dist/index.d.ts +188 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +311 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +60 -0
- package/dist/react.d.ts +60 -0
- package/dist/react.js +307 -0
- package/dist/react.js.map +1 -0
- package/docs/babylon-adapter.md +127 -0
- package/docs/dom-adapter.md +97 -0
- package/docs/primitives.md +168 -0
- package/docs/scene.md +122 -0
- package/docs/screen.md +97 -0
- package/package.json +104 -0
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @particle-academy/fancy-3d
|
|
2
|
+
|
|
3
|
+
A UI kit designed to make it easy for humans and agents to create rich, data-driven 3D applications. Describe what you want with engine-agnostic scene data, drop in primitives like `createBuilding` or `createBillboard`, and pick a renderer — DOM (react-fancy) or 3D (BabylonJS today; three.js / native canvas pluggable). Same JSON, two render targets, ergonomic enough that an LLM can author scenes directly.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# npm
|
|
9
|
+
npm install @particle-academy/fancy-3d
|
|
10
|
+
|
|
11
|
+
# Plus whichever engine you target (both peer deps are optional):
|
|
12
|
+
npm install @particle-academy/react-fancy # for the DOM adapter
|
|
13
|
+
npm install @babylonjs/core # for the Babylon adapter
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**Peer dependencies (all optional):** `react >= 18`, `react-dom >= 18`, `@particle-academy/react-fancy`, `@babylonjs/core >= 7`
|
|
17
|
+
|
|
18
|
+
Install only the engines you target — the package is split into subpath imports so unused engines don't pull into your bundle.
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import type { Scene } from "@particle-academy/fancy-3d";
|
|
24
|
+
import { domAdapter } from "@particle-academy/fancy-3d/dom";
|
|
25
|
+
import { Canvas } from "@particle-academy/react-fancy";
|
|
26
|
+
|
|
27
|
+
const scene: Scene = {
|
|
28
|
+
nodes: [
|
|
29
|
+
{ id: "rev", position: { x: 0, y: 0 }, size: { w: 220, h: 110 },
|
|
30
|
+
widget: { kind: "kpi", label: "Revenue", value: "$48k", delta: "+12%", trend: "up" } },
|
|
31
|
+
],
|
|
32
|
+
edges: [],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function Dashboard() {
|
|
36
|
+
return (
|
|
37
|
+
<Canvas showGrid className="h-96 w-full">
|
|
38
|
+
{scene.nodes.map((n) => (
|
|
39
|
+
<Canvas.Node key={n.id} id={n.id} x={n.position.x} y={n.position.y}
|
|
40
|
+
style={{ width: n.size?.w, height: n.size?.h }}>
|
|
41
|
+
{domAdapter.render(n.widget, { nodeId: n.id, selected: false })}
|
|
42
|
+
</Canvas.Node>
|
|
43
|
+
))}
|
|
44
|
+
</Canvas>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
To render the same scene in 3D:
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { createBabylonAdapter, createBillboard, placeOnCylinder, sceneBounds } from "@particle-academy/fancy-3d/babylon";
|
|
53
|
+
|
|
54
|
+
const adapter = createBabylonAdapter({ scene3D: bjScene, sizeFor: (s) => ({ w: 300, h: 200 }) });
|
|
55
|
+
const bounds = sceneBounds(scene);
|
|
56
|
+
scene.nodes.forEach((node) => {
|
|
57
|
+
const mesh = adapter.render(node.widget, { nodeId: node.id, selected: false });
|
|
58
|
+
placeOnCylinder(node, mesh, bounds);
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Architecture
|
|
63
|
+
|
|
64
|
+
`@particle-academy/fancy-3d` is structured around **engine-agnostic scene data + per-engine adapters**:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
@particle-academy/fancy-3d Scene types (Scene, WidgetSpec, WidgetAdapter)
|
|
68
|
+
@particle-academy/fancy-3d/dom DOM adapter — renders to react-fancy components
|
|
69
|
+
@particle-academy/fancy-3d/babylon Babylon adapter + 3D shape primitives
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The same `Scene` JSON renders identically across engines. Add a new engine by writing a `WidgetAdapter<T>` that maps each `WidgetSpec` to that engine's render output (Babylon `Mesh`, three.js `Object3D`, etc.).
|
|
73
|
+
|
|
74
|
+
## Documentation
|
|
75
|
+
|
|
76
|
+
- [Scene types & widget kinds](./docs/scene.md) — the engine-agnostic data model
|
|
77
|
+
- [DOM adapter](./docs/dom-adapter.md) — render Scene as react-fancy components
|
|
78
|
+
- [Babylon adapter](./docs/babylon-adapter.md) — render Scene as Babylon meshes + dynamic textures
|
|
79
|
+
- [Primitives](./docs/primitives.md) — `createPanel`, `createBillboard`, `createBuilding`, `createCylinder`, `createCurvedPanel`, `createWidgetTexture`
|
|
80
|
+
- [Screen widget](./docs/screen.md) — 3D-native widget for hardware-display visuals
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
MIT
|