@geometra/renderer-three 0.2.0 → 1.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 (39) hide show
  1. package/dist/host-css-coerce.d.ts +39 -0
  2. package/dist/host-css-coerce.d.ts.map +1 -0
  3. package/dist/host-css-coerce.js +69 -0
  4. package/dist/host-css-coerce.js.map +1 -0
  5. package/dist/host-layout-plain.d.ts +164 -0
  6. package/dist/host-layout-plain.d.ts.map +1 -0
  7. package/dist/host-layout-plain.js +255 -0
  8. package/dist/host-layout-plain.js.map +1 -0
  9. package/dist/index.d.ts +42 -5
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +41 -5
  12. package/dist/index.js.map +1 -1
  13. package/dist/layout-sync.d.ts +51 -0
  14. package/dist/layout-sync.d.ts.map +1 -0
  15. package/dist/layout-sync.js +59 -0
  16. package/dist/layout-sync.js.map +1 -0
  17. package/dist/scene3d-manager.d.ts +29 -0
  18. package/dist/scene3d-manager.d.ts.map +1 -0
  19. package/dist/scene3d-manager.js +339 -0
  20. package/dist/scene3d-manager.js.map +1 -0
  21. package/dist/split-host.d.ts +48 -9
  22. package/dist/split-host.d.ts.map +1 -1
  23. package/dist/split-host.js +74 -39
  24. package/dist/split-host.js.map +1 -1
  25. package/dist/stacked-host.d.ts +64 -14
  26. package/dist/stacked-host.d.ts.map +1 -1
  27. package/dist/stacked-host.js +77 -41
  28. package/dist/stacked-host.js.map +1 -1
  29. package/dist/three-scene-basics.d.ts +313 -2
  30. package/dist/three-scene-basics.d.ts.map +1 -1
  31. package/dist/three-scene-basics.js +418 -1
  32. package/dist/three-scene-basics.js.map +1 -1
  33. package/dist/utils.d.ts +156 -0
  34. package/dist/utils.d.ts.map +1 -1
  35. package/dist/utils.js +207 -6
  36. package/dist/utils.js.map +1 -1
  37. package/package.json +15 -18
  38. package/LICENSE +0 -21
  39. package/README.md +0 -111
package/dist/utils.js CHANGED
@@ -1,26 +1,227 @@
1
+ /** Floor to a positive integer; non-finite and values below 1 become 1 (avoids NaN in WebGL sizing). */
2
+ function normalizeLayoutPixels(n) {
3
+ if (!Number.isFinite(n))
4
+ return 1;
5
+ const floored = Math.floor(n);
6
+ return floored >= 1 ? floored : 1;
7
+ }
8
+ /**
9
+ * Same integer flooring and minimum size as {@link createThreeGeometraSplitHost} and
10
+ * {@link createThreeGeometraStackedHost} use for CSS layout sizes and drawing-buffer dimensions.
11
+ *
12
+ * Use in custom or headless `WebGLRenderer` setups so width/height math stays aligned with those hosts.
13
+ *
14
+ * @returns A positive integer width or height in layout pixels (at least 1).
15
+ */
16
+ export function normalizeGeometraLayoutPixels(n) {
17
+ return normalizeLayoutPixels(n);
18
+ }
19
+ function normalizedCssLayoutDimensions(cssWidth, cssHeight) {
20
+ return {
21
+ w: normalizeLayoutPixels(cssWidth),
22
+ h: normalizeLayoutPixels(cssHeight),
23
+ };
24
+ }
25
+ /**
26
+ * Perspective `aspect` value for the same CSS layout → camera path as
27
+ * {@link resizeGeometraThreePerspectiveView} and the built-in split/stacked hosts
28
+ * (`setPixelRatio` + `setSize` with layout pixels, not raw drawing-buffer dimensions).
29
+ *
30
+ * Use in headless or custom renderers when you resize the drawing buffer yourself but want
31
+ * projection to stay aligned with {@link createThreeGeometraSplitHost} /
32
+ * {@link createThreeGeometraStackedHost}. For buffer-sized projection, use
33
+ * {@link syncGeometraThreePerspectiveFromBuffer} instead — flooring differs when width and height
34
+ * are scaled to physical pixels separately.
35
+ */
36
+ export function geometraHostPerspectiveAspectFromCss(cssWidth, cssHeight) {
37
+ const { w, h } = normalizedCssLayoutDimensions(cssWidth, cssHeight);
38
+ return w / h;
39
+ }
40
+ /**
41
+ * Device pixel ratio for split/stacked hosts and custom renderers: full raw ratio, optionally capped.
42
+ * Use with {@link resizeGeometraThreePerspectiveView} or {@link setWebGLDrawingBufferSize} so headless
43
+ * or offscreen setups match the same `maxDevicePixelRatio` behavior as {@link createThreeGeometraSplitHost}
44
+ * and {@link createThreeGeometraStackedHost}.
45
+ *
46
+ * @returns A finite positive ratio, capped when `maxDevicePixelRatio` is a finite positive number.
47
+ */
48
+ export function resolveHostDevicePixelRatio(rawDevicePixelRatio, maxDevicePixelRatio) {
49
+ const raw = rawDevicePixelRatio > 0 && Number.isFinite(rawDevicePixelRatio) ? rawDevicePixelRatio : 1;
50
+ if (maxDevicePixelRatio === undefined ||
51
+ !Number.isFinite(maxDevicePixelRatio) ||
52
+ maxDevicePixelRatio <= 0) {
53
+ return raw;
54
+ }
55
+ return Math.min(raw, maxDevicePixelRatio);
56
+ }
57
+ /**
58
+ * Raw device pixel ratio used by headless / no-`window` helpers that mirror browser hosts where
59
+ * `win.devicePixelRatio || 1` would apply, but the baseline is fixed at **1** (see
60
+ * {@link resolveHeadlessHostDevicePixelRatio}, {@link toPlainGeometraThreeViewSizingStateHeadless},
61
+ * {@link createGeometraThreePerspectiveResizeHandlerHeadless}). Prefer this export over a bare `1`
62
+ * in agent payloads, tests, or custom hosts so the baseline stays grep-stable and documented.
63
+ */
64
+ export const GEOMETRA_HEADLESS_RAW_DEVICE_PIXEL_RATIO = 1;
65
+ /**
66
+ * Same optional {@link maxDevicePixelRatio} cap as {@link createThreeGeometraSplitHost} and
67
+ * {@link createThreeGeometraStackedHost}, but with raw ratio **1** for environments without a
68
+ * browser `window` (headless WebGL, Node, tests).
69
+ *
70
+ * Equivalent to
71
+ * `resolveHostDevicePixelRatio(GEOMETRA_HEADLESS_RAW_DEVICE_PIXEL_RATIO, maxDevicePixelRatio)`.
72
+ */
73
+ export function resolveHeadlessHostDevicePixelRatio(maxDevicePixelRatio) {
74
+ return resolveHostDevicePixelRatio(GEOMETRA_HEADLESS_RAW_DEVICE_PIXEL_RATIO, maxDevicePixelRatio);
75
+ }
76
+ /**
77
+ * Coerce CSS layout size and DPR into the same integers the built-in hosts use for perspective resize
78
+ * and nominal buffer dimensions (floored layout × effective DPR per axis).
79
+ */
80
+ export function toPlainGeometraThreeViewSizingState(cssWidth, cssHeight, rawDevicePixelRatio, maxDevicePixelRatio) {
81
+ const layoutWidth = normalizeGeometraLayoutPixels(cssWidth);
82
+ const layoutHeight = normalizeGeometraLayoutPixels(cssHeight);
83
+ const sanitizedRawDevicePixelRatio = rawDevicePixelRatio > 0 && Number.isFinite(rawDevicePixelRatio) ? rawDevicePixelRatio : 1;
84
+ const effectiveDevicePixelRatio = resolveHostDevicePixelRatio(sanitizedRawDevicePixelRatio, maxDevicePixelRatio);
85
+ return {
86
+ layoutWidth,
87
+ layoutHeight,
88
+ perspectiveAspect: layoutWidth / layoutHeight,
89
+ sanitizedRawDevicePixelRatio,
90
+ effectiveDevicePixelRatio,
91
+ drawingBufferWidth: normalizeGeometraLayoutPixels(layoutWidth * effectiveDevicePixelRatio),
92
+ drawingBufferHeight: normalizeGeometraLayoutPixels(layoutHeight * effectiveDevicePixelRatio),
93
+ };
94
+ }
95
+ /**
96
+ * Same plain viewport sizing as {@link toPlainGeometraThreeViewSizingState} with raw device pixel ratio
97
+ * fixed at **1** — parity with {@link resolveHeadlessHostDevicePixelRatio},
98
+ * {@link toPlainGeometraThreeHostSnapshotHeadless}, and {@link resizeGeometraThreeWebGLWithSceneBasicsViewHeadless}
99
+ * for headless GL, Node, tests, or agent payloads without a browser `window`.
100
+ *
101
+ * Equivalent to
102
+ * `toPlainGeometraThreeViewSizingState(cssWidth, cssHeight, GEOMETRA_HEADLESS_RAW_DEVICE_PIXEL_RATIO, maxDevicePixelRatio)`.
103
+ */
104
+ export function toPlainGeometraThreeViewSizingStateHeadless(cssWidth, cssHeight, maxDevicePixelRatio) {
105
+ return toPlainGeometraThreeViewSizingState(cssWidth, cssHeight, GEOMETRA_HEADLESS_RAW_DEVICE_PIXEL_RATIO, maxDevicePixelRatio);
106
+ }
107
+ function isFinitePositiveNumber(value) {
108
+ return typeof value === 'number' && Number.isFinite(value) && value > 0;
109
+ }
110
+ /**
111
+ * Narrow `unknown` (e.g. `JSON.parse`) to {@link PlainGeometraThreeViewSizingState} when the object has the
112
+ * viewport fields produced by {@link toPlainGeometraThreeViewSizingState} and
113
+ * {@link toPlainGeometraThreeViewSizingStateHeadless}. Extra keys are allowed. Objects that also include scene
114
+ * fields may satisfy this guard; for the full viewport + scene shape use `isPlainGeometraThreeHostSnapshot`
115
+ * from this package’s entry (re-exported next to the host snapshot helpers).
116
+ */
117
+ export function isPlainGeometraThreeViewSizingState(value) {
118
+ if (value === null || typeof value !== 'object')
119
+ return false;
120
+ const o = value;
121
+ return (isFinitePositiveNumber(o.layoutWidth) &&
122
+ isFinitePositiveNumber(o.layoutHeight) &&
123
+ isFinitePositiveNumber(o.perspectiveAspect) &&
124
+ isFinitePositiveNumber(o.sanitizedRawDevicePixelRatio) &&
125
+ isFinitePositiveNumber(o.effectiveDevicePixelRatio) &&
126
+ isFinitePositiveNumber(o.drawingBufferWidth) &&
127
+ isFinitePositiveNumber(o.drawingBufferHeight));
128
+ }
1
129
  /**
2
130
  * Resize drawing buffer to match CSS pixel size × device pixel ratio.
3
131
  * Use when you manage your own canvas layout (no `renderer.setSize`).
132
+ * Non-finite CSS sizes or products fall back to 1; non-finite or non-positive `pixelRatio` becomes 1.
4
133
  */
5
134
  export function setWebGLDrawingBufferSize(renderer, cssWidth, cssHeight, pixelRatio) {
6
- const pr = pixelRatio ?? (typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1);
7
- const w = Math.max(1, Math.floor(cssWidth * pr));
8
- const h = Math.max(1, Math.floor(cssHeight * pr));
135
+ const rawPr = pixelRatio ?? (typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1);
136
+ const pr = rawPr > 0 && Number.isFinite(rawPr) ? rawPr : 1;
137
+ const w = normalizeLayoutPixels(cssWidth * pr);
138
+ const h = normalizeLayoutPixels(cssHeight * pr);
9
139
  renderer.setDrawingBufferSize(w, h, pr);
10
140
  }
141
+ /**
142
+ * Size the WebGL drawing buffer from CSS layout × pixel ratio and update the perspective camera aspect
143
+ * to match, in one step.
144
+ *
145
+ * Use this on the **drawing-buffer** path (with {@link setWebGLDrawingBufferSize}) instead of
146
+ * {@link resizeGeometraThreePerspectiveView} when you do not use `setPixelRatio` + `setSize` on the
147
+ * renderer — for example headless GL, offscreen canvas, or custom buffer management. Equivalent to calling
148
+ * {@link setWebGLDrawingBufferSize} then {@link syncGeometraThreePerspectiveFromBuffer} with the
149
+ * resulting buffer dimensions (read from {@link WebGLRenderer.domElement} after resize).
150
+ */
151
+ export function resizeGeometraThreeDrawingBufferView(renderer, camera, cssWidth, cssHeight, pixelRatio) {
152
+ setWebGLDrawingBufferSize(renderer, cssWidth, cssHeight, pixelRatio);
153
+ syncGeometraThreePerspectiveFromBuffer(camera, renderer.domElement.width, renderer.domElement.height);
154
+ }
155
+ /**
156
+ * Same as {@link resizeGeometraThreeDrawingBufferView} with pixel ratio from
157
+ * {@link resolveHeadlessHostDevicePixelRatio} — raw ratio **1** and the same optional
158
+ * `maxDevicePixelRatio` cap as split/stacked hosts.
159
+ *
160
+ * Parity with {@link resizeGeometraThreeWebGLWithSceneBasicsViewHeadless} for the
161
+ * {@link setWebGLDrawingBufferSize} / drawing-buffer path (headless GL, offscreen canvas, Node tests).
162
+ *
163
+ * Equivalent to calling {@link resizeGeometraThreeDrawingBufferView} with
164
+ * `resolveHeadlessHostDevicePixelRatio(maxDevicePixelRatio)` as the pixel ratio argument.
165
+ */
166
+ export function resizeGeometraThreeDrawingBufferViewHeadless(renderer, camera, cssWidth, cssHeight, maxDevicePixelRatio) {
167
+ resizeGeometraThreeDrawingBufferView(renderer, camera, cssWidth, cssHeight, resolveHeadlessHostDevicePixelRatio(maxDevicePixelRatio));
168
+ }
11
169
  /**
12
170
  * Apply the same CSS-size → aspect ratio → WebGL buffer sizing path as
13
171
  * {@link createThreeGeometraSplitHost} and {@link createThreeGeometraStackedHost}.
14
172
  *
15
173
  * Use with {@link createGeometraThreeSceneBasics} when you own the `WebGLRenderer` (headless GL,
16
174
  * offscreen canvas, tests) but want buffer dimensions and projection to stay aligned with those hosts.
175
+ * Non-finite or non-positive CSS sizes (including negative values) normalize to at least 1 layout
176
+ * pixel each, matching {@link normalizeGeometraLayoutPixels}; non-finite or non-positive `pixelRatio`
177
+ * becomes 1.
17
178
  */
18
179
  export function resizeGeometraThreePerspectiveView(renderer, camera, cssWidth, cssHeight, pixelRatio) {
19
- renderer.setPixelRatio(pixelRatio);
20
- const w = Math.max(1, Math.floor(cssWidth));
21
- const h = Math.max(1, Math.floor(cssHeight));
180
+ const pr = pixelRatio > 0 && Number.isFinite(pixelRatio) ? pixelRatio : 1;
181
+ renderer.setPixelRatio(pr);
182
+ const { w, h } = normalizedCssLayoutDimensions(cssWidth, cssHeight);
22
183
  camera.aspect = w / h;
23
184
  camera.updateProjectionMatrix();
24
185
  renderer.setSize(w, h, false);
25
186
  }
187
+ /**
188
+ * Build a resize callback that applies the same CSS layout → DPR → `setPixelRatio` / `setSize` path as
189
+ * {@link createThreeGeometraSplitHost} and {@link createThreeGeometraStackedHost}.
190
+ *
191
+ * Use in headless GL, offscreen canvas, tests, or custom hosts where you resize on a timer or explicit
192
+ * layout pass instead of the built-in `ResizeObserver`, but want {@link resolveHostDevicePixelRatio}
193
+ * capping and layout-pixel normalization without duplicating that wiring at every call site.
194
+ *
195
+ * @param getRawDevicePixelRatio - e.g. `() => win.devicePixelRatio || 1` or `() => 1` when no `window`.
196
+ */
197
+ export function createGeometraThreePerspectiveResizeHandler(renderer, camera, getRawDevicePixelRatio, maxDevicePixelRatio) {
198
+ return (cssWidth, cssHeight) => {
199
+ resizeGeometraThreePerspectiveView(renderer, camera, cssWidth, cssHeight, resolveHostDevicePixelRatio(getRawDevicePixelRatio(), maxDevicePixelRatio));
200
+ };
201
+ }
202
+ /**
203
+ * Same as {@link createGeometraThreePerspectiveResizeHandler} with raw device pixel ratio fixed at **1** —
204
+ * parity with {@link resolveHeadlessHostDevicePixelRatio}, {@link resizeGeometraThreeWebGLWithSceneBasicsViewHeadless},
205
+ * {@link toPlainGeometraThreeViewSizingStateHeadless}, and {@link toPlainGeometraThreeHostSnapshotHeadless} for headless GL, Node, tests, or agent loops without a browser
206
+ * `window`.
207
+ *
208
+ * Equivalent to `createGeometraThreePerspectiveResizeHandler(renderer, camera, () => 1, maxDevicePixelRatio)`.
209
+ */
210
+ export function createGeometraThreePerspectiveResizeHandlerHeadless(renderer, camera, maxDevicePixelRatio) {
211
+ return createGeometraThreePerspectiveResizeHandler(renderer, camera, () => GEOMETRA_HEADLESS_RAW_DEVICE_PIXEL_RATIO, maxDevicePixelRatio);
212
+ }
213
+ /**
214
+ * Update perspective projection from **drawing-buffer** pixel dimensions (physical pixels), not CSS size.
215
+ *
216
+ * Use when you size WebGL with {@link setWebGLDrawingBufferSize} or `renderer.setDrawingBufferSize` directly
217
+ * (headless GL, offscreen canvas, tests) and still want the same aspect handling as
218
+ * {@link resizeGeometraThreePerspectiveView}. Does not touch the renderer — only the camera.
219
+ * Non-finite buffer dimensions fall back to 1.
220
+ */
221
+ export function syncGeometraThreePerspectiveFromBuffer(camera, drawingBufferWidth, drawingBufferHeight) {
222
+ const w = normalizeLayoutPixels(drawingBufferWidth);
223
+ const h = normalizeLayoutPixels(drawingBufferHeight);
224
+ camera.aspect = w / h;
225
+ camera.updateProjectionMatrix();
226
+ }
26
227
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAuB,EACvB,QAAgB,EAChB,SAAiB,EACjB,UAAmB;IAEnB,MAAM,EAAE,GAAG,UAAU,IAAI,CAAC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3F,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,EAA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CACpD,MAAyB,EACzB,kBAA0B,EAC1B,mBAA2B;IAE3B,MAAM,CAAC,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,CAAA;IACnD,MAAM,CAAC,GAAG,qBAAqB,CAAC,mBAAmB,CAAC,CAAA;IACpD,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAA;IACrB,MAAM,CAAC,sBAAsB,EAAE,CAAA;AACjC,CAAC"}
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "@geometra/renderer-three",
3
- "version": "0.2.0",
4
- "description": "Three.js render target helpers for Geometra — stack WebGL with the geometry-streamed canvas client",
3
+ "version": "1.3.1",
4
+ "description": "Three.js render target helpers for Geometra — stack WebGL with the geometry-streamed canvas client, declarative scene3d element rendering",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/razroo/geometra-renderer-three"
9
+ "url": "https://github.com/razroo/geometra",
10
+ "directory": "packages/renderer-three"
10
11
  },
12
+ "homepage": "https://razroo.github.io/geometra",
11
13
  "keywords": [
12
14
  "geometra",
13
15
  "three",
@@ -15,7 +17,8 @@
15
17
  "webgl",
16
18
  "renderer",
17
19
  "dom-free",
18
- "websocket"
20
+ "websocket",
21
+ "scene3d"
19
22
  ],
20
23
  "main": "./dist/index.js",
21
24
  "types": "./dist/index.d.ts",
@@ -26,28 +29,22 @@
26
29
  }
27
30
  },
28
31
  "files": [
29
- "dist",
30
- "README.md",
31
- "LICENSE"
32
+ "dist"
32
33
  ],
33
34
  "scripts": {
34
35
  "build": "rm -rf dist && tsc -p tsconfig.build.json",
35
- "check": "tsc --noEmit -p tsconfig.json",
36
- "verify:exports": "node scripts/verify-exports.mjs",
37
- "verify:utils": "node scripts/verify-utils.mjs",
38
- "release:gate": "npm run check && npm run build && npm run verify:exports && npm run verify:utils",
39
- "prepare": "npm run build",
40
- "prepublishOnly": "npm run build"
36
+ "check": "tsc --noEmit"
37
+ },
38
+ "dependencies": {
39
+ "@geometra/client": "^1.3.1",
40
+ "@geometra/core": "^1.3.1",
41
+ "@geometra/renderer-canvas": "^1.3.1"
41
42
  },
42
43
  "peerDependencies": {
43
- "@geometra/renderer-canvas": "^1.2.2",
44
44
  "three": ">=0.160.0 <0.180.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@geometra/client": "^1.2.2",
48
- "@geometra/renderer-canvas": "^1.2.2",
49
47
  "@types/three": "^0.170.0",
50
- "three": "^0.170.0",
51
- "typescript": "^6.0.2"
48
+ "three": "^0.170.0"
52
49
  }
53
50
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Razroo
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/README.md DELETED
@@ -1,111 +0,0 @@
1
- # @geometra/renderer-three
2
-
3
- **Three.js helpers alongside Geometra** — not a replacement for `@geometra/renderer-canvas`. Geometra’s WebSocket geometry protocol still drives the 2D canvas; Three.js owns WebGL for meshes, scenes, and cameras.
4
-
5
- This package ships the **split-view host** pattern (Three.js pane + Geometra pane) and a **stacked HUD** host (full-viewport WebGL + corner Geometra overlay) as bootstrap helpers, plus small WebGL sizing utilities.
6
-
7
- For the long-term goal — Three.js and Geometra in one **native**, protocol-first, DOM-free space — see [docs/GEOMETRA_NATIVE_SPACE.md](docs/GEOMETRA_NATIVE_SPACE.md). To drive the Cursor Agent CLI in a loop (like the main Geometra repo), use [`scripts/cursor-agent-loop.sh`](scripts/cursor-agent-loop.sh) after installing the [`agent` CLI](https://cursor.com/install); each iteration should pass `npm run release:gate`.
8
-
9
- ## Install
10
-
11
- Peer dependencies (your app must install them):
12
-
13
- ```bash
14
- npm install three @geometra/renderer-canvas @geometra/client @geometra/core
15
- npm install @geometra/renderer-three
16
- ```
17
-
18
- ## Usage
19
-
20
- ```ts
21
- import * as THREE from 'three'
22
- import { createThreeGeometraSplitHost } from '@geometra/renderer-three'
23
-
24
- const host = createThreeGeometraSplitHost({
25
- container: document.getElementById('app')!,
26
- geometraWidth: 420,
27
- url: 'ws://localhost:8080/geometra-ws',
28
- binaryFraming: true,
29
- autoFocus: true,
30
- threeBackground: 0x07131f,
31
- onThreeReady: ({ scene, camera }) => {
32
- scene.add(new THREE.AmbientLight(0xffffff, 0.6))
33
- camera.position.set(0, 2, 8)
34
- },
35
- onThreeFrame: ({ scene, camera, delta }) => {
36
- // animate meshes, controls.update(), etc.
37
- },
38
- })
39
-
40
- // later
41
- host.destroy()
42
- ```
43
-
44
- ### Stacked HUD (WebGL + overlay)
45
-
46
- ```ts
47
- import * as THREE from 'three'
48
- import { createThreeGeometraStackedHost } from '@geometra/renderer-three'
49
-
50
- const stacked = createThreeGeometraStackedHost({
51
- container: document.getElementById('app')!,
52
- geometraHudWidth: 400,
53
- geometraHudHeight: 280,
54
- geometraHudPlacement: 'bottom-right',
55
- geometraHudMargin: 16,
56
- url: 'ws://localhost:8080/geometra-ws',
57
- binaryFraming: true,
58
- onThreeReady: ({ scene, camera }) => {
59
- scene.add(new THREE.AmbientLight(0xffffff, 0.55))
60
- camera.position.set(0, 1.5, 6)
61
- },
62
- })
63
- stacked.destroy()
64
- ```
65
-
66
- Use `geometraHudPointerEvents` (CSS `pointer-events`, default `'auto'`) when you want the HUD to ignore input — for example `'none'` so pointer events reach the full-viewport Three.js canvas underneath.
67
-
68
- `createThreeGeometraSplitHost` and `createThreeGeometraStackedHost` each forward all [`createBrowserCanvasClient`](https://github.com/razroo/geometra/tree/main/packages/renderer-canvas) options except `canvas` (the host creates the Geometra canvas for you).
69
-
70
- ### Geometra resize
71
-
72
- The Geometra thin client listens to `window` resize by default. When only the Geometra column changes size, this host dispatches a synthetic `window` `resize` after layout so server layout width/height stay in sync.
73
-
74
- ### Shared scene / camera defaults (headless-friendly)
75
-
76
- `createGeometraThreeSceneBasics` builds a `Scene`, `PerspectiveCamera`, and `Clock` with the same defaults as the split and stacked hosts. Pair it with your own `WebGLRenderer` (or a headless GL context) and `resizeGeometraThreePerspectiveView` so buffer size and camera aspect match those hosts, or use `setWebGLDrawingBufferSize` alone when you already manage aspect and `setPixelRatio` yourself.
77
-
78
- ## Roadmap (not in v0)
79
-
80
- - Optional **scene-graph extension** to the GEOM protocol (headless + WebGL from the same JSON).
81
- - **Stacked** overlay: v0 ships a corner HUD layout; richer stacking (custom regions, explicit `pointer-events` policies) may follow.
82
- - **Node / headless Three** helpers for parity with “AI talks the same protocol” stories (`createGeometraThreeSceneBasics` is a small shared baseline; richer helpers may follow).
83
-
84
- ## Releasing (GitHub + npm)
85
-
86
- Same pattern as [`geometra-auth`](https://github.com/razroo/geometra-auth): publishing runs when a **GitHub Release is published**, not on every tag push.
87
-
88
- 1. **Repository secret:** add **`NPM_TOKEN`** (automation token with publish rights for `@geometra/renderer-three`) under **Settings → Secrets and variables → Actions**.
89
-
90
- 2. **Version:** set `"version"` in `package.json` to the release you want (e.g. `0.2.0`), commit, and push to `main`.
91
-
92
- 3. **Tag** must match that version with a `v` prefix:
93
-
94
- ```bash
95
- git tag v0.2.0
96
- git push origin v0.2.0
97
- ```
98
-
99
- 4. **Create the GitHub release** (triggers [`.github/workflows/release.yml`](.github/workflows/release.yml)):
100
-
101
- ```bash
102
- gh release create v0.2.0 --repo razroo/geometra-renderer-three --title "v0.2.0" --generate-notes
103
- ```
104
-
105
- Or publish a **draft** release from the web UI, then **Publish release** when ready.
106
-
107
- The workflow checks that `v$TAG` matches `package.json`, runs `npm ci` / `npm run build`, then **`npm publish --provenance --access public`**.
108
-
109
- ## License
110
-
111
- MIT