@particle-academy/fancy-3d 0.4.1 → 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.
Files changed (2) hide show
  1. package/README.md +36 -20
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # @particle-academy/fancy-3d
2
2
 
3
- **A versatile middleware for blending 3D engines and 2D web components into Mixed Reality UX.** fancy-3d is the bridge layer where react-fancy components, Babylon scenes, 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.
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 engine="dom" | "babylon" | CustomEngine>`** — engine-pluggable 2D pan/zoom surface. Default Web3D (CSS3D matrix projection, the same approach used by `Stage` and the DOM adapter), opt into Babylon, or pass any object implementing `CanvasEngine` for three.js / native canvas / WebXR. 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.
8
- - **`<Stage>` / `<Monitor>`** — engine-agnostic 3D scene primitives with a Babylon adapter (`<Monitor>` was `<Screen>` before v0.3.0)
9
- - **`<Card3D>`, `<Decal>`** — 3D-native UI widgets
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
- # npm
20
+ # core — engine-agnostic: Scene types, <Canvas>, DOM/CSS-3D renderer
20
21
  npm install @particle-academy/fancy-3d
21
22
 
22
- # Plus whichever engine you target (both peer deps are optional):
23
- npm install @particle-academy/react-fancy # for the DOM adapter / 2D widgets
24
- npm install @babylonjs/core # for the Babylon engine + adapter
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
- **Peer dependencies (all optional):** `react >= 18`, `react-dom >= 18`, `@particle-academy/react-fancy`, `@babylonjs/core >= 7`
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 — the package is split into subpath imports so unused engines don't pull into your bundle.
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 — 3D meshes can register against
49
- // useCanvas().engine.root (the live BABYLON.Scene) and share the 2D viewport.
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="babylon" className="h-96 w-full">
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/babylon";
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 across DOM, Babylon, and (pluggable) three.js / native canvas. Subpath imports keep the bundle minimal:
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/babylon Babylon adapter + 3D shape primitives
118
- @particle-academy/fancy-3d/react <Stage> + <Monitor> for live React on 3D meshes
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** — Babylon needs `window` and DOM/CSS3D positioning needs layout measurement. In an Inertia app, wrap every `<Stage>` / `<Monitor>` / `<Card3D>` / `<Canvas engine="babylon">` in [`<FancyClientOnly>`](https://github.com/Particle-Academy/fancy-inertia/blob/main/docs/USAGE.md#fancyclientonly) from `@particle-academy/fancy-inertia`:
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.1",
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",