@octanejs/three 0.1.28 → 0.1.29
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 +7 -0
- package/UPSTREAM.md +1 -0
- package/package.json +6 -6
- package/src/core/driver.ts +23 -0
- package/src/testing.ts +43 -0
- package/src/web/DOMRegion.ts +24 -3
- package/src/web/dom-region.ts +2 -0
package/README.md
CHANGED
|
@@ -163,6 +163,13 @@ public `advance()` loop as an application. Its awaitable `fireEvent()` helper
|
|
|
163
163
|
directly invokes the latest committed handler and settles scheduled work when
|
|
164
164
|
raycasting itself is not under test.
|
|
165
165
|
|
|
166
|
+
Renderer bindings that project opaque component children into an ordered host
|
|
167
|
+
array can set `__octaneAutoAttachArray` on the parent host object to that array's
|
|
168
|
+
property name. Unattached child host objects are then assigned to indexed slots
|
|
169
|
+
in authored order. This is the universal-renderer equivalent of React bindings
|
|
170
|
+
that clone opaque children to add `attach="passes-N"`; authored `attach` props
|
|
171
|
+
still take precedence.
|
|
172
|
+
|
|
166
173
|
`Canvas` installs the default web event manager. Use `eventSource` to subscribe
|
|
167
174
|
through another element and `eventPrefix` (`offset`, `client`, `page`, `layer`,
|
|
168
175
|
or `screen`) to choose the coordinate pair. Programmatic roots can supply a
|
package/UPSTREAM.md
CHANGED
|
@@ -5,6 +5,7 @@ This port targets the immutable React Three Fiber release `v9.6.1`:
|
|
|
5
5
|
- repository: `https://github.com/pmndrs/react-three-fiber`;
|
|
6
6
|
- tag commit: `2a528745e9aa7c9e6cca41e404b59d45cf0d0cc7`;
|
|
7
7
|
- package: `@react-three/fiber@9.6.1`;
|
|
8
|
+
- source archive SHA-256: `01177da508a5551b38908e3da7ce51601f140fd35497e3b3daf73af58f75e67c`;
|
|
8
9
|
- exact Three behavior and type oracle: `three@0.172.0` and
|
|
9
10
|
`@types/three@0.172.0`.
|
|
10
11
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/three",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"@types/three": ">=0.156.0",
|
|
53
53
|
"three": ">=0.156.0",
|
|
54
|
-
"octane": "0.1.
|
|
54
|
+
"octane": "0.1.36"
|
|
55
55
|
},
|
|
56
56
|
"peerDependenciesMeta": {
|
|
57
57
|
"@types/three": {
|
|
@@ -72,10 +72,10 @@
|
|
|
72
72
|
"typescript": "^5.9.3",
|
|
73
73
|
"vite": "^8.1.5",
|
|
74
74
|
"vitest": "^4.1.10",
|
|
75
|
-
"@octanejs/rsbuild-plugin": "0.1.
|
|
76
|
-
"@octanejs/rspack-plugin": "0.1.
|
|
77
|
-
"
|
|
78
|
-
"
|
|
75
|
+
"@octanejs/rsbuild-plugin": "0.1.31",
|
|
76
|
+
"@octanejs/rspack-plugin": "0.1.31",
|
|
77
|
+
"@octanejs/vite-plugin": "0.1.36",
|
|
78
|
+
"octane": "0.1.36"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"test": "pnpm upstream:check && vitest run --root ../.. --project three",
|
package/src/core/driver.ts
CHANGED
|
@@ -1510,6 +1510,29 @@ function desiredAttachment(
|
|
|
1510
1510
|
if (typeof path === 'string') {
|
|
1511
1511
|
return instance.visible ? { kind: 'attachment', parent, path } : { kind: 'none' };
|
|
1512
1512
|
}
|
|
1513
|
+
const autoAttachArray = (parent as { __octaneAutoAttachArray?: unknown }).__octaneAutoAttachArray;
|
|
1514
|
+
if (typeof autoAttachArray === 'string' && autoAttachArray.length > 0 && instance.visible) {
|
|
1515
|
+
let index = 0;
|
|
1516
|
+
for (const sibling of state.instances.values()) {
|
|
1517
|
+
if (sibling.id === instance.id) break;
|
|
1518
|
+
if (
|
|
1519
|
+
sibling.parent !== instance.parent ||
|
|
1520
|
+
destroyed.has(sibling.id) ||
|
|
1521
|
+
!sibling.visible ||
|
|
1522
|
+
sibling.localCallbacks.has('attach')
|
|
1523
|
+
) {
|
|
1524
|
+
continue;
|
|
1525
|
+
}
|
|
1526
|
+
const siblingPath = getEffectiveAttachment(
|
|
1527
|
+
sibling.object,
|
|
1528
|
+
sibling.props.attach as string | null | undefined,
|
|
1529
|
+
);
|
|
1530
|
+
if (typeof siblingPath !== 'string' || siblingPath.startsWith(`${autoAttachArray}-`)) {
|
|
1531
|
+
index++;
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
return { kind: 'attachment', parent, path: `${autoAttachArray}-${index}` };
|
|
1535
|
+
}
|
|
1513
1536
|
if (isObject3D(parent) && isObject3D(instance.object)) {
|
|
1514
1537
|
return { kind: 'object3d', parent };
|
|
1515
1538
|
}
|
package/src/testing.ts
CHANGED
|
@@ -25,6 +25,8 @@ export interface CreateThreeTestRendererOptions {
|
|
|
25
25
|
readonly width?: number;
|
|
26
26
|
/** Logical canvas height. Defaults to 800. */
|
|
27
27
|
readonly height?: number;
|
|
28
|
+
/** Optional camera used by the configured root. Defaults to a perspective camera. */
|
|
29
|
+
readonly camera?: THREE.Camera;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
/** Renderer recorder injected into a deterministic Three test root. */
|
|
@@ -37,6 +39,14 @@ export interface TestingRenderer extends Renderer {
|
|
|
37
39
|
readonly lastCamera: THREE.Camera | null;
|
|
38
40
|
/** Whether root teardown disposed the recorder. */
|
|
39
41
|
readonly disposed: boolean;
|
|
42
|
+
/** The currently selected render target, matching WebGLRenderer state. */
|
|
43
|
+
readonly renderTarget: THREE.WebGLRenderTarget | THREE.WebGLCubeRenderTarget | null;
|
|
44
|
+
/** Scene/camera pairs submitted for eager shader compilation. */
|
|
45
|
+
readonly compileCalls: readonly (readonly [THREE.Object3D, THREE.Camera])[];
|
|
46
|
+
/** Scene/camera pairs submitted for rendering. */
|
|
47
|
+
readonly renderCalls: readonly (readonly [THREE.Scene, THREE.Camera])[];
|
|
48
|
+
/** WebGLRenderer-compatible automatic clearing flag. */
|
|
49
|
+
autoClear: boolean;
|
|
40
50
|
}
|
|
41
51
|
|
|
42
52
|
/** Additional values copied onto a directly-fired testing event. */
|
|
@@ -75,10 +85,20 @@ export interface ThreeTestRenderer {
|
|
|
75
85
|
class FrameRecorder implements TestingRenderer {
|
|
76
86
|
readonly domElement: CanvasLike;
|
|
77
87
|
readonly renderLists = { dispose() {} };
|
|
88
|
+
readonly shadowMap: NonNullable<Renderer['shadowMap']> = {
|
|
89
|
+
enabled: false,
|
|
90
|
+
type: 1 as THREE.ShadowMapType,
|
|
91
|
+
autoUpdate: true,
|
|
92
|
+
needsUpdate: false,
|
|
93
|
+
};
|
|
78
94
|
#frameCount = 0;
|
|
79
95
|
#lastScene: THREE.Scene | null = null;
|
|
80
96
|
#lastCamera: THREE.Camera | null = null;
|
|
81
97
|
#disposed = false;
|
|
98
|
+
#renderTarget: THREE.WebGLRenderTarget | THREE.WebGLCubeRenderTarget | null = null;
|
|
99
|
+
readonly compileCalls: Array<readonly [THREE.Object3D, THREE.Camera]> = [];
|
|
100
|
+
readonly renderCalls: Array<readonly [THREE.Scene, THREE.Camera]> = [];
|
|
101
|
+
autoClear = true;
|
|
82
102
|
|
|
83
103
|
constructor(canvas: CanvasLike) {
|
|
84
104
|
this.domElement = canvas;
|
|
@@ -100,16 +120,38 @@ class FrameRecorder implements TestingRenderer {
|
|
|
100
120
|
return this.#disposed;
|
|
101
121
|
}
|
|
102
122
|
|
|
123
|
+
get renderTarget(): THREE.WebGLRenderTarget | THREE.WebGLCubeRenderTarget | null {
|
|
124
|
+
return this.#renderTarget;
|
|
125
|
+
}
|
|
126
|
+
|
|
103
127
|
render(scene: THREE.Scene, camera: THREE.Camera): void {
|
|
104
128
|
this.#frameCount++;
|
|
105
129
|
this.#lastScene = scene;
|
|
106
130
|
this.#lastCamera = camera;
|
|
131
|
+
this.renderCalls.push([scene, camera]);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
compile(scene: THREE.Object3D, camera: THREE.Camera): void {
|
|
135
|
+
this.compileCalls.push([scene, camera]);
|
|
107
136
|
}
|
|
108
137
|
|
|
109
138
|
setPixelRatio(_dpr: number): void {}
|
|
110
139
|
|
|
111
140
|
setSize(_width: number, _height: number, _updateStyle?: boolean): void {}
|
|
112
141
|
|
|
142
|
+
setRenderTarget(target: THREE.WebGLRenderTarget | THREE.WebGLCubeRenderTarget | null): void {
|
|
143
|
+
this.#renderTarget = target;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
getRenderTarget(): THREE.WebGLRenderTarget | THREE.WebGLCubeRenderTarget | null {
|
|
147
|
+
return this.#renderTarget;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
clearDepth(): void {}
|
|
151
|
+
|
|
152
|
+
/** Mirrors WebGLRenderer's eager texture-upload hook for loader integrations. */
|
|
153
|
+
initTexture(_texture: THREE.Texture): void {}
|
|
154
|
+
|
|
113
155
|
forceContextLoss(): void {}
|
|
114
156
|
|
|
115
157
|
dispose(): void {
|
|
@@ -205,6 +247,7 @@ export async function createThreeTestRenderer<P>(
|
|
|
205
247
|
try {
|
|
206
248
|
await root.configure({
|
|
207
249
|
gl: renderer,
|
|
250
|
+
camera: options.camera,
|
|
208
251
|
size: { width, height, top: 0, left: 0 },
|
|
209
252
|
dpr: 1,
|
|
210
253
|
frameloop: 'never',
|
package/src/web/DOMRegion.ts
CHANGED
|
@@ -17,6 +17,10 @@ export interface DOMRegionProps {
|
|
|
17
17
|
target: DOMRegionTarget;
|
|
18
18
|
/** Compiler-owned DOM renderer region. Application JSX is lowered into this payload. */
|
|
19
19
|
children?: RendererRegion;
|
|
20
|
+
/** A renderer region that was already lowered by an outer component boundary. */
|
|
21
|
+
region?: RendererRegion;
|
|
22
|
+
/** Receives the stable DOM container owned by this region. */
|
|
23
|
+
containerRef?: { current: HTMLDivElement | null } | ((value: HTMLDivElement | null) => void);
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
class DOMRegionSentinel extends Object3D {
|
|
@@ -32,6 +36,15 @@ const DOM_REGION_BINDING = Symbol('octane.three.dom-region.binding');
|
|
|
32
36
|
const DOM_REGION_SENTINEL = Symbol('octane.three.dom-region.sentinel');
|
|
33
37
|
const DOM_REGION_LIFETIME = Symbol('octane.three.dom-region.lifetime');
|
|
34
38
|
const DOM_REGION_COMMIT = Symbol('octane.three.dom-region.commit');
|
|
39
|
+
const DOM_REGION_CONTAINER_REF = Symbol('octane.three.dom-region.container-ref');
|
|
40
|
+
|
|
41
|
+
function assignContainerRef(
|
|
42
|
+
ref: DOMRegionProps['containerRef'],
|
|
43
|
+
value: HTMLDivElement | null,
|
|
44
|
+
): void {
|
|
45
|
+
if (typeof ref === 'function') ref(value);
|
|
46
|
+
else if (ref) ref.current = value;
|
|
47
|
+
}
|
|
35
48
|
|
|
36
49
|
/**
|
|
37
50
|
* Low-level Three-to-DOM renderer boundary.
|
|
@@ -43,8 +56,16 @@ export const DOMRegion = defineUniversalComponent<DOMRegionProps>('three', (prop
|
|
|
43
56
|
const sentinel = useMemo(() => new DOMRegionSentinel(), [], DOM_REGION_SENTINEL);
|
|
44
57
|
useLayoutEffect(() => binding.attach(), [binding], DOM_REGION_LIFETIME);
|
|
45
58
|
useLayoutEffect(
|
|
46
|
-
() =>
|
|
47
|
-
|
|
59
|
+
() => {
|
|
60
|
+
assignContainerRef(props.containerRef, binding.container);
|
|
61
|
+
return () => assignContainerRef(props.containerRef, null);
|
|
62
|
+
},
|
|
63
|
+
[binding, props.containerRef],
|
|
64
|
+
DOM_REGION_CONTAINER_REF,
|
|
65
|
+
);
|
|
66
|
+
useLayoutEffect(
|
|
67
|
+
() => binding.commit(props.target, props.region ?? props.children),
|
|
68
|
+
[binding, props.target, props.region, props.children],
|
|
48
69
|
DOM_REGION_COMMIT,
|
|
49
70
|
);
|
|
50
71
|
|
|
@@ -52,7 +73,7 @@ export const DOMRegion = defineUniversalComponent<DOMRegionProps>('three', (prop
|
|
|
52
73
|
universalProps([
|
|
53
74
|
['set', 'object', sentinel],
|
|
54
75
|
['set', 'dispose', null],
|
|
55
|
-
['set', 'region', props.children],
|
|
76
|
+
['set', 'region', props.region ?? props.children],
|
|
56
77
|
]),
|
|
57
78
|
]);
|
|
58
79
|
});
|
package/src/web/dom-region.ts
CHANGED
|
@@ -27,6 +27,7 @@ function resolveTarget(target: DOMRegionTarget): HTMLElement | null {
|
|
|
27
27
|
|
|
28
28
|
/** Package-private owner for the one DOM root materialized by a DOMRegion. */
|
|
29
29
|
export interface DOMRegionBinding {
|
|
30
|
+
readonly container: HTMLDivElement;
|
|
30
31
|
attach(): () => void;
|
|
31
32
|
commit(target: DOMRegionTarget, region: RendererRegion | undefined): void;
|
|
32
33
|
}
|
|
@@ -73,6 +74,7 @@ export function createDOMRegionBinding(): DOMRegionBinding {
|
|
|
73
74
|
};
|
|
74
75
|
|
|
75
76
|
return {
|
|
77
|
+
container: host,
|
|
76
78
|
attach() {
|
|
77
79
|
attached = true;
|
|
78
80
|
let active = true;
|