@particle-academy/fancy-3d 0.4.0 → 0.4.2
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 +36 -20
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# @particle-academy/fancy-3d
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**An engine-agnostic core for blending 3D engines and 2D web components into Mixed Reality UX.** fancy-3d is the bridge layer where react-fancy components, *any* 3D engine, and 2D pan/zoom canvases compose into a single authoring surface — designed for humans and agents to build rich, data-driven 3D and MR applications without picking sides.
|
|
4
|
+
|
|
5
|
+
> **fancy-3d bundles no WebGL engine and has no Babylon (or three.js) dependency.** The core ships JSON-friendly `Scene` types, the engine-pluggable `<Canvas>` with a built-in DOM/CSS-3D renderer, and shape/layout helpers — all framework-light. WebGL engines plug in via **optional sibling adapter packages** that mirror each other's API: [`@particle-academy/fancy-3d-babylon`](https://www.npmjs.com/package/@particle-academy/fancy-3d-babylon) (Babylon) and [`@particle-academy/fancy-3d-three`](https://www.npmjs.com/package/@particle-academy/fancy-3d-three) (three.js). Use one, both, or neither.
|
|
4
6
|
|
|
5
7
|
## What's inside
|
|
6
8
|
|
|
7
|
-
- **`<Canvas
|
|
8
|
-
-
|
|
9
|
-
- **`<
|
|
10
|
-
- **Shape primitives, layout helpers, JSON-friendly Scene types** — terse, agent-authorable scene descriptions
|
|
9
|
+
- **`<Canvas>`** — engine-pluggable 2D pan/zoom surface. **Defaults to `engine="dom"`** (CSS3D matrix projection, no WebGL dependency). Opt into a WebGL backend by passing an adapter engine — `babylonEngine` from `@particle-academy/fancy-3d-babylon/engine` or `threeEngine` from `@particle-academy/fancy-3d-three/engine` — or any object implementing `CanvasEngine` (native canvas / WebXR / your own). The 2D node graph and the 3D scene root live alongside each other; this is the foundation for hybrid 2D-in-3D and MR scenes.
|
|
10
|
+
- **Shape primitives, layout helpers, JSON-friendly Scene types** — terse, agent-authorable scene descriptions; engine-agnostic.
|
|
11
|
+
- **`<Stage>` / `<Monitor>` / `<Card3D>`** — the 3D scene primitives + 3D-native widgets ship from the **adapter packages** (`@particle-academy/fancy-3d-babylon/react`, `@particle-academy/fancy-3d-three/react`), *not* from fancy-3d core, since they need a concrete WebGL engine. (`<Monitor>` was `<Screen>` before v0.3.0.)
|
|
11
12
|
|
|
12
13
|
## Why fancy-3d exists
|
|
13
14
|
|
|
@@ -16,17 +17,21 @@ Most 3D libraries force a choice between immersive engines and DOM productivity.
|
|
|
16
17
|
## Installation
|
|
17
18
|
|
|
18
19
|
```bash
|
|
19
|
-
#
|
|
20
|
+
# core — engine-agnostic: Scene types, <Canvas>, DOM/CSS-3D renderer
|
|
20
21
|
npm install @particle-academy/fancy-3d
|
|
21
22
|
|
|
22
|
-
#
|
|
23
|
-
npm install @particle-academy/react-fancy
|
|
24
|
-
|
|
23
|
+
# optional — react-fancy for the DOM adapter / 2D widgets
|
|
24
|
+
npm install @particle-academy/react-fancy
|
|
25
|
+
|
|
26
|
+
# optional — a WebGL engine adapter (sibling packages, NOT bundled by fancy-3d).
|
|
27
|
+
# Pick whichever engine you target; install neither to stay DOM-only:
|
|
28
|
+
npm install @particle-academy/fancy-3d-babylon @babylonjs/core # Babylon
|
|
29
|
+
npm install @particle-academy/fancy-3d-three three # three.js
|
|
25
30
|
```
|
|
26
31
|
|
|
27
|
-
**
|
|
32
|
+
**fancy-3d's own peer dependencies (all optional):** `react >= 18`, `react-dom >= 18`, `@particle-academy/react-fancy`. **fancy-3d has no WebGL-engine dependency** — `@babylonjs/core` / `three` are peers of their respective *adapter* packages, never of fancy-3d itself.
|
|
28
33
|
|
|
29
|
-
Install only the engines you target —
|
|
34
|
+
Install only the engines you target — fancy-3d and each adapter are split into subpath imports so unused engines never pull into your bundle.
|
|
30
35
|
|
|
31
36
|
## Quick Start — the engine-pluggable Canvas
|
|
32
37
|
|
|
@@ -45,11 +50,14 @@ export function Dashboard() {
|
|
|
45
50
|
);
|
|
46
51
|
}
|
|
47
52
|
|
|
48
|
-
// Same JSX, Babylon scene mounted alongside
|
|
49
|
-
// useCanvas().engine.root (the live BABYLON.Scene)
|
|
53
|
+
// Same JSX, a Babylon scene mounted alongside via the optional adapter package.
|
|
54
|
+
// 3D meshes can register against useCanvas().engine.root (the live BABYLON.Scene)
|
|
55
|
+
// and share the 2D viewport. Swap to threeEngine from fancy-3d-three to use three.js.
|
|
56
|
+
import { babylonEngine } from "@particle-academy/fancy-3d-babylon/engine";
|
|
57
|
+
|
|
50
58
|
export function MixedRealityDashboard() {
|
|
51
59
|
return (
|
|
52
|
-
<Canvas engine=
|
|
60
|
+
<Canvas engine={babylonEngine} className="h-96 w-full">
|
|
53
61
|
{/* Children render as 2D DOM nodes;
|
|
54
62
|
a sibling component reads useCanvas().engine to add 3D meshes. */}
|
|
55
63
|
</Canvas>
|
|
@@ -89,7 +97,7 @@ export function Dashboard() {
|
|
|
89
97
|
To render the same scene in 3D:
|
|
90
98
|
|
|
91
99
|
```tsx
|
|
92
|
-
import { createBabylonAdapter, createBillboard, placeOnCylinder, sceneBounds } from "@particle-academy/fancy-3d
|
|
100
|
+
import { createBabylonAdapter, createBillboard, placeOnCylinder, sceneBounds } from "@particle-academy/fancy-3d-babylon";
|
|
93
101
|
|
|
94
102
|
const adapter = createBabylonAdapter({ scene3D: bjScene, sizeFor: (s) => ({ w: 300, h: 200 }) });
|
|
95
103
|
const bounds = sceneBounds(scene);
|
|
@@ -109,13 +117,21 @@ scene.nodes.forEach((node) => {
|
|
|
109
117
|
| **Mount** | Host a live React tree on a 3D mesh via DOM overlay + `matrix3d` projection — fully interactive, keyboard accessible. | Anywhere you want the actual interactive UI inside a 3D scene. Shipped today via `<Stage>` + `<Monitor>`. |
|
|
110
118
|
| **Bump-out / Puffy** | Extruded 3D interpretations of 2D components — buttons that physically protrude, cards with depth, embossed badges. Each interactive subregion is its own pickable mesh. | Spatial / mixed-reality UIs where the interface IS the geometry. Planned. |
|
|
111
119
|
|
|
112
|
-
The data layer underneath is engine-agnostic — same `Scene` JSON renders
|
|
120
|
+
The data layer underneath is engine-agnostic — the same `Scene` JSON renders via the built-in DOM/CSS-3D renderer or any WebGL engine through an adapter package (Babylon and three.js ship today). Subpath imports keep the bundle minimal:
|
|
113
121
|
|
|
114
122
|
```
|
|
123
|
+
# fancy-3d core (engine-agnostic — no WebGL dependency)
|
|
115
124
|
@particle-academy/fancy-3d Scene types (Scene, WidgetSpec, WidgetAdapter)
|
|
116
|
-
@particle-academy/fancy-3d/dom DOM adapter — renders to react-fancy components
|
|
117
|
-
@particle-academy/fancy-3d/
|
|
118
|
-
|
|
125
|
+
@particle-academy/fancy-3d/dom DOM adapter — renders Scene to react-fancy components
|
|
126
|
+
@particle-academy/fancy-3d/canvas the engine-pluggable <Canvas> surface
|
|
127
|
+
|
|
128
|
+
# WebGL engines + <Stage>/<Monitor>/<Card3D> live in OPTIONAL sibling adapter packages:
|
|
129
|
+
@particle-academy/fancy-3d-babylon Babylon adapter + 3D shape primitives
|
|
130
|
+
@particle-academy/fancy-3d-babylon/react <Stage> + <Monitor> (Babylon)
|
|
131
|
+
@particle-academy/fancy-3d-babylon/engine babylonEngine for <Canvas engine={…}>
|
|
132
|
+
@particle-academy/fancy-3d-three three.js adapter + 3D shape primitives
|
|
133
|
+
@particle-academy/fancy-3d-three/react <Stage> + <Monitor> (three.js)
|
|
134
|
+
@particle-academy/fancy-3d-three/engine threeEngine for <Canvas engine={…}>
|
|
119
135
|
```
|
|
120
136
|
|
|
121
137
|
`react-fancy` is a peer dependency by design: this package exists *to put react-fancy in 3D*, so consumers always install both — the peer relationship just lets you pin the react-fancy version.
|
|
@@ -130,7 +146,7 @@ The data layer underneath is engine-agnostic — same `Scene` JSON renders acros
|
|
|
130
146
|
|
|
131
147
|
## Inertia.js integration
|
|
132
148
|
|
|
133
|
-
fancy-3d is **not SSR-safe** —
|
|
149
|
+
fancy-3d is **not SSR-safe** — WebGL engines need `window` and DOM/CSS3D positioning needs layout measurement. In an Inertia app, wrap every `<Stage>` / `<Monitor>` / `<Card3D>` / `<Canvas engine={babylonEngine}>` in [`<FancyClientOnly>`](https://github.com/Particle-Academy/fancy-inertia/blob/main/docs/USAGE.md#fancyclientonly) from `@particle-academy/fancy-inertia`:
|
|
134
150
|
|
|
135
151
|
```tsx
|
|
136
152
|
import { FancyClientOnly } from "@particle-academy/fancy-inertia";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@particle-academy/fancy-3d",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Engine-agnostic 3D core for Particle Academy — Scene types, the <Canvas> surface, and a DOM/CSS-3D renderer. WebGL renderers (Babylon, three.js, …) ship as separate `@particle-academy/fancy-3d-<engine>` packages.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"engine-agnostic"
|
|
66
66
|
],
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@particle-academy/react-fancy": "
|
|
68
|
+
"@particle-academy/react-fancy": ">=3",
|
|
69
69
|
"react": "^18.0.0 || ^19.0.0",
|
|
70
70
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
71
71
|
},
|