@threenative/core 0.2.0 → 0.3.1

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 (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +55 -0
  3. package/capabilities.json +5292 -0
  4. package/dist/assets-kyoF7JlJ.d.ts +103 -0
  5. package/dist/audio-BFiGneTL.d.ts +156 -0
  6. package/dist/canvas-layer-BLVijiUJ.d.ts +62 -0
  7. package/dist/game-XGrTzapq.d.ts +1166 -0
  8. package/dist/gpu-readback-D2iRvoe9.d.ts +112 -0
  9. package/dist/hot.d.ts +20 -2
  10. package/dist/hot.js +14 -2
  11. package/dist/index.d.ts +2108 -55
  12. package/dist/index.js +15645 -2222
  13. package/dist/net.d.ts +65 -0
  14. package/dist/net.js +643 -0
  15. package/dist/playtest.d.ts +37 -4
  16. package/dist/playtest.js +246 -546
  17. package/dist/react.d.ts +177 -0
  18. package/dist/react.js +635 -0
  19. package/dist/renderer-C6hqZpoG.d.ts +770 -0
  20. package/dist/ui-layer.d.ts +306 -0
  21. package/dist/ui-layer.js +425 -0
  22. package/dist/world.d.ts +254 -0
  23. package/dist/world.js +2686 -0
  24. package/gpl/LICENSE.GPL +117 -0
  25. package/gpl/convert.py +192 -0
  26. package/gpl/recipes/_common.py +169 -0
  27. package/gpl/recipes/bake_ao.py +111 -0
  28. package/gpl/recipes/decimate.py +64 -0
  29. package/gpl/recipes/retarget.py +131 -0
  30. package/gpl/recipes/unwrap.py +71 -0
  31. package/mcp/assets.mjs +5 -0
  32. package/mcp/blender-server.mjs +632 -0
  33. package/mcp/blender.mjs +27 -0
  34. package/mcp/engine-server.mjs +501 -0
  35. package/mcp/engine.mjs +31 -0
  36. package/mcp/install.d.mts +37 -0
  37. package/mcp/install.mjs +145 -0
  38. package/mcp/launch.mjs +72 -0
  39. package/mcp/sculpt.mjs +5 -0
  40. package/mcp/servers.d.mts +34 -0
  41. package/mcp/servers.mjs +160 -0
  42. package/package.json +76 -6
  43. package/patches/three@0.185.1.patch +522 -0
  44. package/scripts/apply-three-patch.mjs +297 -0
  45. package/scripts/ensure-mcp.mjs +43 -0
  46. package/scripts/postinstall.mjs +6 -0
  47. package/dist/audio-CEAw0w5y.d.ts +0 -35
  48. package/dist/game-DRt1Qhq3.d.ts +0 -429
@@ -0,0 +1,177 @@
1
+ import { ReactNode } from 'react';
2
+ import { C as CanvasLayer } from './canvas-layer-BLVijiUJ.js';
3
+ import 'three';
4
+ import './renderer-C6hqZpoG.js';
5
+ import 'three/webgpu';
6
+
7
+ /**
8
+ * Every character this glyph set can draw, for error messages and for the templates' AGENTS.md.
9
+ * @situation discover which characters a native React HUD can draw
10
+ * @example supportedGlyphs().includes("A")
11
+ */
12
+ declare function supportedGlyphs(): string;
13
+
14
+ /**
15
+ * The layout model behind the native React overlay: pure TypeScript, no WASM, no Yoga, no CSS
16
+ * parser. `TN_NATIVE_WASM_ON_MOBILE` refuses WebAssembly in mobile bundles, which rules out Yoga;
17
+ * writing a CSS engine here would be writing a browser, one ticket at a time.
18
+ *
19
+ * That last clause used to read "which is the thing this whole path exists to avoid", and PRD-217
20
+ * corrected it: the thing to avoid is *shipping* a browser, and every platform already provides
21
+ * one at the composition layer for free. So `ui.renderer: "web"` is now the default — the same
22
+ * React DOM, Tailwind, CSS and SVG on every target — and this renderer is the opt-in for a UI that
23
+ * is part of the rendered frame, a target with no web view, or zero extra processes. Growing this
24
+ * vocabulary toward CSS is still the wrong move; a game that needs CSS should ask for the web
25
+ * renderer instead.
26
+ *
27
+ * **The supported subset is exactly the fields on {@link IOverlayStyle} and nothing else.** A style
28
+ * key that is not on that interface is not "ignored for now" — {@link assertKnownStyle} throws
29
+ * `TN_REACT_UNKNOWN_STYLE` naming the key, because a convention discovered by failure is worse than
30
+ * one that does not exist.
31
+ *
32
+ * Units are screen pixels throughout, matching `CanvasLayer`'s orthographic camera. The origin is
33
+ * the top-left of the parent's content box, y increasing downwards, like a screen and unlike Three.
34
+ */
35
+ /** `#rrggbb`, `#rgb`, or a packed `0xrrggbb` number. Alpha is `opacity`, kept separate on purpose. */
36
+ type OverlayColor = string | number;
37
+ interface IOverlayStyle {
38
+ /** Distance from the parent's left content edge. Ignored when the parent lays out in flow. */
39
+ left?: number;
40
+ /** Distance from the parent's right content edge. Applied only when `left` is absent. */
41
+ right?: number;
42
+ /** Distance from the parent's top content edge. Ignored when the parent lays out in flow. */
43
+ top?: number;
44
+ /** Distance from the parent's bottom content edge. Applied only when `top` is absent. */
45
+ bottom?: number;
46
+ /** Centre horizontally in the parent's content box. Wins over `left`/`right`. */
47
+ centerX?: boolean;
48
+ /** Centre vertically in the parent's content box. Wins over `top`/`bottom`. */
49
+ centerY?: boolean;
50
+ /** Fixed width. Without one, a box shrink-wraps its children and text measures its glyphs. */
51
+ width?: number;
52
+ /** Fixed height. Without one, a box shrink-wraps its children and text is one line tall. */
53
+ height?: number;
54
+ /** Uniform inset between this box's edges and its content box. */
55
+ padding?: number;
56
+ /** Lay children out in flow along this axis. Absent means children are placed absolutely. */
57
+ direction?: "row" | "column";
58
+ /** Space between flow children, in pixels. Only meaningful with `direction`. */
59
+ gap?: number;
60
+ /** Cross-axis placement of flow children. */
61
+ align?: "start" | "center" | "end";
62
+ /** Fill colour. Absent means the box draws nothing and only positions its children. */
63
+ background?: OverlayColor;
64
+ /** Glyph colour on a `text` element. */
65
+ color?: OverlayColor;
66
+ /** 0-1, multiplied into whatever this element draws. Children carry their own. */
67
+ opacity?: number;
68
+ /** Cell height of one glyph in pixels; the 5x7 grid scales to it. Inherited by descendants. */
69
+ fontSize?: number;
70
+ /** Extra pixels between glyph cells, on top of the 5x7 grid's one-column gap. */
71
+ letterSpacing?: number;
72
+ /** Horizontal placement of the glyph run inside a `text` box that has a `width`. */
73
+ textAlign?: "left" | "center" | "right";
74
+ /** Paint order among siblings. Higher paints later. Ties fall back to tree order. */
75
+ zIndex?: number;
76
+ }
77
+ /**
78
+ * Every style key the overlay implements, for the templates' AGENTS.md and for error messages.
79
+ * @situation discover which React HUD style properties work on native
80
+ * @example supportedStyleKeys().includes("centerX")
81
+ */
82
+ declare function supportedStyleKeys(): readonly string[];
83
+ /** A resolved rectangle in screen pixels, origin top-left of the framebuffer. */
84
+ interface IOverlayBox {
85
+ x: number;
86
+ y: number;
87
+ width: number;
88
+ height: number;
89
+ }
90
+ /**
91
+ * Width in pixels of a glyph run at a given cell height.
92
+ * @situation measure native React HUD text before laying it out
93
+ * @example const scoreWidth = measureText("SCORE 10", 24)
94
+ */
95
+ declare function measureText(text: string, fontSize: number, letterSpacing?: number): number;
96
+
97
+ /**
98
+ * A React renderer that commits to `CanvasLayer` instead of the DOM.
99
+ *
100
+ * `react` is the component model and has no DOM in it; `react-dom` is one renderer among several,
101
+ * and `react-reconciler` is the supported way to write another. The native host has no DOM to
102
+ * render into and no rasteriser to paint one with, so this maps React elements straight onto
103
+ * Three.js objects inside the orthographic, screen-pixel `CanvasLayer` that `renderOverlay` already
104
+ * draws on every platform. Nothing here imports `react-dom`, which is what keeps
105
+ * `TN_NATIVE_WEB_ONLY_UI` satisfied on a native bundle.
106
+ *
107
+ * There are exactly two element types, and that is the whole vocabulary:
108
+ *
109
+ * - `<view>` — a rectangle. Draws when it has a `background`; otherwise it only positions children.
110
+ * - `<text>` — a run of bitmap glyphs. Its children must be strings or numbers.
111
+ *
112
+ * Anything else throws `TN_REACT_UNKNOWN_ELEMENT` naming the tag. Tailwind class names cannot cross
113
+ * — they are CSS — so styling is the `style` prop, whose supported keys are named exhaustively on
114
+ * `IOverlayStyle` and enforced by `assertKnownStyle`.
115
+ */
116
+ /** The two host element types, as strings React sees. Namespaced so no DOM or SVG tag can collide. */
117
+ declare const VIEW_ELEMENT = "tn-view";
118
+ /** @see VIEW_ELEMENT */
119
+ declare const TEXT_ELEMENT = "tn-text";
120
+ interface IReactOverlayOptions {
121
+ /** Where the tree is drawn. `ctx.canvasLayer` in a game. */
122
+ canvasLayer: Pick<CanvasLayer, "scene" | "camera" | "onResize">;
123
+ /**
124
+ * Called with any error React could not recover from, before the overlay draws its own named
125
+ * failure banner. The default logs it; nothing swallows it, because a blank HUD and a broken HUD
126
+ * must never look the same.
127
+ */
128
+ onError?: (error: Error) => void;
129
+ }
130
+ interface IReactOverlay {
131
+ /** Mount or update the tree. Synchronous, so a caller can assert on the result immediately. */
132
+ render(element: ReactNode): void;
133
+ /** Re-run layout — call after a resize. Cheap and idempotent; it no-ops when nothing moved. */
134
+ refresh(): void;
135
+ /** Unmount the tree and release every Three.js object it created. */
136
+ dispose(): void;
137
+ /** How many Three.js objects the last commit produced. For budgets and tests. */
138
+ readonly objectCount: number;
139
+ /** Number of hook/store updates that changed host nodes during `refresh()`. */
140
+ readonly commitCount: number;
141
+ /** Flush plus draw cost of the latest state-changing `refresh()`, in milliseconds. */
142
+ readonly lastCommitMs: number | undefined;
143
+ }
144
+ /**
145
+ * Mount React into a `CanvasLayer`.
146
+ *
147
+ * @situation show a React HUD on Android, iOS or desktop native
148
+ * @situation render the same React component on web and on a phone without a WebView
149
+ * @constraint import `react`, never `react-dom`, from a native entry
150
+ * @example const overlay = createReactOverlay({ canvasLayer: ctx.canvasLayer });
151
+ */
152
+ declare function createReactOverlay(options: IReactOverlayOptions): IReactOverlay;
153
+
154
+ interface IViewProps {
155
+ style?: IOverlayStyle;
156
+ children?: ReactNode;
157
+ }
158
+ interface ITextProps {
159
+ style?: IOverlayStyle;
160
+ /** Strings and numbers only. Nesting an element inside `Text` has nothing to draw it with. */
161
+ children?: ReactNode;
162
+ }
163
+ /**
164
+ * A rectangle. Paints when its style has a `background`; otherwise it only positions children.
165
+ * @situation group and position native React HUD elements
166
+ * @example <View style={{ centerX: true, top: 24 }}><Text>READY</Text></View>
167
+ */
168
+ declare function View(props: IViewProps): ReactNode;
169
+ /**
170
+ * A run of bitmap glyphs, drawn as one instanced quad per lit pixel.
171
+ * @situation show text in a native React HUD without a DOM
172
+ * @alias objective panel journal
173
+ * @example <Text style={{ color: "#ffffff", fontSize: 24 }}>SCORE 10</Text>
174
+ */
175
+ declare function Text(props: ITextProps): ReactNode;
176
+
177
+ export { type IOverlayBox, type IOverlayStyle, type IReactOverlay, type IReactOverlayOptions, type ITextProps, type IViewProps, type OverlayColor, TEXT_ELEMENT, Text, VIEW_ELEMENT, View, createReactOverlay, measureText, supportedGlyphs, supportedStyleKeys };