@hozo/three 0.1.0
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/LICENSE +21 -0
- package/README.md +389 -0
- package/conformance.md +335 -0
- package/dist/accessible-controls.d.ts +55 -0
- package/dist/accessible-controls.d.ts.map +1 -0
- package/dist/accessible-controls.js +82 -0
- package/dist/accessible-controls.js.map +1 -0
- package/dist/conformance-scenes.d.ts +39 -0
- package/dist/conformance-scenes.d.ts.map +1 -0
- package/dist/conformance-scenes.js +443 -0
- package/dist/conformance-scenes.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/line-gradient.d.ts +13 -0
- package/dist/line-gradient.d.ts.map +1 -0
- package/dist/line-gradient.js +104 -0
- package/dist/line-gradient.js.map +1 -0
- package/dist/project.d.ts +23 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +2298 -0
- package/dist/project.js.map +1 -0
- package/dist/r3f-accessibility.d.ts +30 -0
- package/dist/r3f-accessibility.d.ts.map +1 -0
- package/dist/r3f-accessibility.js +4 -0
- package/dist/r3f-accessibility.js.map +1 -0
- package/dist/r3f-native-unavailable.d.ts +5 -0
- package/dist/r3f-native-unavailable.d.ts.map +1 -0
- package/dist/r3f-native-unavailable.js +5 -0
- package/dist/r3f-native-unavailable.js.map +1 -0
- package/dist/r3f-native.d.ts +23 -0
- package/dist/r3f-native.d.ts.map +1 -0
- package/dist/r3f-native.js +66 -0
- package/dist/r3f-native.js.map +1 -0
- package/dist/r3f-react-native.d.ts +5 -0
- package/dist/r3f-react-native.d.ts.map +1 -0
- package/dist/r3f-react-native.js +5 -0
- package/dist/r3f-react-native.js.map +1 -0
- package/dist/r3f.d.ts +39 -0
- package/dist/r3f.d.ts.map +1 -0
- package/dist/r3f.js +41 -0
- package/dist/r3f.js.map +1 -0
- package/dist/surface.d.ts +81 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +79 -0
- package/dist/surface.js.map +1 -0
- package/dist/three-canvas.d.ts +42 -0
- package/dist/three-canvas.d.ts.map +1 -0
- package/dist/three-canvas.js +91 -0
- package/dist/three-canvas.js.map +1 -0
- package/dist/web-surface.d.ts +55 -0
- package/dist/web-surface.d.ts.map +1 -0
- package/dist/web-surface.js +285 -0
- package/dist/web-surface.js.map +1 -0
- package/dist/webgl-react-native.d.ts +5 -0
- package/dist/webgl-react-native.d.ts.map +1 -0
- package/dist/webgl-react-native.js +5 -0
- package/dist/webgl-react-native.js.map +1 -0
- package/dist/webgl-renderer.d.ts +14 -0
- package/dist/webgl-renderer.d.ts.map +1 -0
- package/dist/webgl-renderer.js +13 -0
- package/dist/webgl-renderer.js.map +1 -0
- package/dist/webgpu-react-native.d.ts +5 -0
- package/dist/webgpu-react-native.d.ts.map +1 -0
- package/dist/webgpu-react-native.js +5 -0
- package/dist/webgpu-react-native.js.map +1 -0
- package/dist/webgpu.d.ts +18 -0
- package/dist/webgpu.d.ts.map +1 -0
- package/dist/webgpu.js +29 -0
- package/dist/webgpu.js.map +1 -0
- package/package.json +122 -0
- package/scene-conformance.json +244 -0
- package/scene-conformance.md +31 -0
- package/src/accessible-controls.ts +84 -0
- package/src/conformance-scenes.ts +529 -0
- package/src/index.ts +24 -0
- package/src/line-gradient.ts +134 -0
- package/src/project.ts +2742 -0
- package/src/r3f-accessibility.ts +37 -0
- package/src/r3f-native-unavailable.tsx +15 -0
- package/src/r3f-native.tsx +187 -0
- package/src/r3f-react-native.tsx +17 -0
- package/src/r3f.tsx +159 -0
- package/src/surface.ts +178 -0
- package/src/three-canvas.tsx +215 -0
- package/src/web-surface.tsx +475 -0
- package/src/webgl-react-native.tsx +17 -0
- package/src/webgl-renderer.tsx +56 -0
- package/src/webgpu-react-native.tsx +17 -0
- package/src/webgpu.tsx +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hozo contributors
|
|
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
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
# @hozo/three
|
|
2
|
+
|
|
3
|
+
Projects a documented subset of an ordinary Three.js scene into a portable
|
|
4
|
+
`@hozo/canvas` scene. It is useful for flat 3D diagrams, data visualisations,
|
|
5
|
+
and a deterministic fallback where a GPU renderer is unavailable.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { projectThreeScene } from '@hozo/three'
|
|
9
|
+
import { BoxGeometry, Mesh, MeshBasicMaterial, PerspectiveCamera, Scene } from 'three'
|
|
10
|
+
|
|
11
|
+
const scene = new Scene()
|
|
12
|
+
scene.add(new Mesh(new BoxGeometry(), new MeshBasicMaterial({ color: '#2563eb' })))
|
|
13
|
+
|
|
14
|
+
const camera = new PerspectiveCamera(50, 16 / 9, 0.1, 100)
|
|
15
|
+
camera.position.z = 4
|
|
16
|
+
|
|
17
|
+
const projected = projectThreeScene(scene, camera, { width: 320, height: 180 })
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
For React, the same boundary is available as a universal Canvas component:
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { ThreeCanvas } from '@hozo/three'
|
|
24
|
+
|
|
25
|
+
<ThreeCanvas
|
|
26
|
+
decorative
|
|
27
|
+
scene={scene}
|
|
28
|
+
camera={camera}
|
|
29
|
+
width={320}
|
|
30
|
+
height={180}
|
|
31
|
+
/>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
`width` and `height` are optional. When either is omitted, the Web renderer
|
|
35
|
+
families follow a `ResizeObserver`, while the portable surface uses the same
|
|
36
|
+
measurement on Web and `onLayout` on Native. The server-rendered fallback is
|
|
37
|
+
300 by 150, and `onResize` reports the resolved layout size and pixel ratio.
|
|
38
|
+
Give the surface a responsive CSS or Native layout size, for example
|
|
39
|
+
`style={{ width: '100%', height: '100%' }}`; without one it keeps the stable
|
|
40
|
+
300-by-150 fallback.
|
|
41
|
+
|
|
42
|
+
Perspective cameras follow the resolved aspect ratio by default. Use
|
|
43
|
+
`cameraResize="manual"` when the application owns its projection. Orthographic
|
|
44
|
+
cameras are always application-owned because resizing their frustum has no
|
|
45
|
+
single correct policy.
|
|
46
|
+
|
|
47
|
+
Rendering is demand-driven by default. Change the `revision` prop or call
|
|
48
|
+
`invalidate()` through a ref after imperative scene mutations. Animated scenes
|
|
49
|
+
can opt into `frameloop="always"` and mutate their Three objects in `onFrame`.
|
|
50
|
+
GPU surfaces render those continuous frames directly rather than scheduling a
|
|
51
|
+
React update. If an `onFrame` mutation changes semantic structure such as an
|
|
52
|
+
object's name, visibility, or layer, also change `revision` when that semantic
|
|
53
|
+
change occurs so its keyboard and screen-reader controls are rebuilt.
|
|
54
|
+
|
|
55
|
+
## Classic WebGL renderer
|
|
56
|
+
|
|
57
|
+
Web applications that need Three.js lighting, shader materials, depth, or the
|
|
58
|
+
established `WebGLRenderer` ecosystem can select the classic renderer family
|
|
59
|
+
explicitly:
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import { ThreeCanvas } from '@hozo/three/webgl'
|
|
63
|
+
|
|
64
|
+
<ThreeCanvas
|
|
65
|
+
accessibilityLabel="Interactive product model"
|
|
66
|
+
scene={scene}
|
|
67
|
+
camera={camera}
|
|
68
|
+
width={640}
|
|
69
|
+
height={360}
|
|
70
|
+
/>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
This entry point owns renderer creation, sizing, drawing, and disposal while
|
|
74
|
+
sharing the portable surface's demand/continuous frame-loop contract. It is
|
|
75
|
+
currently Web-only; importing it on React Native fails explicitly because Hozo
|
|
76
|
+
does not yet provide a Native WebGL context host. It never silently falls back
|
|
77
|
+
to the portable renderer. The modern `WebGPURenderer` family will use a
|
|
78
|
+
separate `@hozo/three/webgpu` entry point.
|
|
79
|
+
|
|
80
|
+
`onObjectPress` raycasts the classic WebGL scene and preserves the source
|
|
81
|
+
`Object3D` and its intersections. Named interactive meshes, lines, points, and
|
|
82
|
+
sprites also receive real off-screen buttons, so the same object can be reached
|
|
83
|
+
with a pointer, keyboard, or screen reader. `getAccessibilityLabel` can supply
|
|
84
|
+
those names without mutating `object.name`.
|
|
85
|
+
|
|
86
|
+
## Modern WebGPU renderer family
|
|
87
|
+
|
|
88
|
+
New Web applications can select Three.js's modern renderer family explicitly:
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import { ThreeCanvas } from '@hozo/three/webgpu'
|
|
92
|
+
|
|
93
|
+
<ThreeCanvas
|
|
94
|
+
accessibilityLabel="Interactive product model"
|
|
95
|
+
scene={scene}
|
|
96
|
+
camera={camera}
|
|
97
|
+
width={640}
|
|
98
|
+
height={360}
|
|
99
|
+
/>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Hozo loads `three/webgpu` lazily and awaits `WebGPURenderer.init()` before the
|
|
103
|
+
first draw. Three.js chooses WebGPU when available and otherwise uses its own
|
|
104
|
+
modern WebGL 2 backend; pass `rendererOptions={{ forceWebGL: true }}` to force
|
|
105
|
+
that backend for testing. This is distinct from the classic
|
|
106
|
+
`@hozo/three/webgl` renderer and shares its DOM interaction and accessibility
|
|
107
|
+
contract rather than its material or post-processing extension points.
|
|
108
|
+
|
|
109
|
+
Pass `onObjectPress` to receive the projected Three object and its raycast
|
|
110
|
+
intersections. Set `object.name`, or provide `getAccessibilityLabel`, to expose
|
|
111
|
+
one keyboard and screen-reader control per object even when it projects into
|
|
112
|
+
many triangles.
|
|
113
|
+
|
|
114
|
+
`onObjectActiveChange` reports the same object-level state for mouse or pen
|
|
115
|
+
hover, keyboard focus, and touch hold. Moving across triangle boundaries inside
|
|
116
|
+
one object does not emit a false leave and re-entry.
|
|
117
|
+
|
|
118
|
+
## React Three Fiber authoring
|
|
119
|
+
|
|
120
|
+
Applications that author scenes with React Three Fiber can opt into a separate
|
|
121
|
+
entry point. R3F continues to own its reconciler, renderer, frame loop, and
|
|
122
|
+
pointer-event system; Hozo supplies the responsive container and the same
|
|
123
|
+
label, fallback, or decorative accessibility choice as its direct surfaces.
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import { ThreeCanvas } from '@hozo/three/r3f'
|
|
127
|
+
|
|
128
|
+
<ThreeCanvas
|
|
129
|
+
accessibilityLabel="Rotating product preview"
|
|
130
|
+
style={{ width: '100%', height: 360 }}
|
|
131
|
+
camera={{ position: [0, 2, 5] }}
|
|
132
|
+
>
|
|
133
|
+
<ambientLight intensity={0.5} />
|
|
134
|
+
<mesh>
|
|
135
|
+
<boxGeometry />
|
|
136
|
+
<meshStandardMaterial color="orange" />
|
|
137
|
+
</mesh>
|
|
138
|
+
</ThreeCanvas>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`@react-three/fiber` is an optional peer and is retained only by this entry
|
|
142
|
+
point. Object-level keyboard activation uses an explicit list rather than
|
|
143
|
+
R3F's private instance metadata:
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
const product = useRef<THREE.Mesh>(null)
|
|
147
|
+
|
|
148
|
+
<ThreeCanvas
|
|
149
|
+
accessibilityLabel="Product preview"
|
|
150
|
+
accessibleObjects={[
|
|
151
|
+
{
|
|
152
|
+
id: 'product',
|
|
153
|
+
label: 'Inspect product',
|
|
154
|
+
object: product,
|
|
155
|
+
onPress: () => openInspector(),
|
|
156
|
+
},
|
|
157
|
+
]}
|
|
158
|
+
>
|
|
159
|
+
<mesh ref={product} onClick={() => openInspector()}>
|
|
160
|
+
<boxGeometry />
|
|
161
|
+
<meshStandardMaterial color="orange" />
|
|
162
|
+
</mesh>
|
|
163
|
+
</ThreeCanvas>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
The native control handles keyboard and screen-reader activation. The mesh keeps
|
|
167
|
+
its ordinary R3F pointer handler, so Hozo does not synthesize or double-dispatch
|
|
168
|
+
pointer events. A registered object with `href` becomes a real anchor instead,
|
|
169
|
+
preserving modifier-click and application-router integration.
|
|
170
|
+
|
|
171
|
+
**Hidden until focus reaches it.** The controls sit off-screen while nothing is
|
|
172
|
+
focused — a canvas should not carry a row of buttons on every scene — and the
|
|
173
|
+
strip is revealed as soon as focus enters it, in the user agent's own
|
|
174
|
+
`Canvas`/`CanvasText` colours. It was clipped in both states until
|
|
175
|
+
[#689](https://github.com/iray-tno/hozo/issues/689), which meant a sighted
|
|
176
|
+
keyboard user tabbed onto a control they could not see anywhere: measured at 1×1
|
|
177
|
+
with `clip: rect(0, 0, 0, 0)` around a 136×24 button that had Chrome's focus ring
|
|
178
|
+
on it, clipped away with everything else. WCAG 2.4.7, and invisible to every
|
|
179
|
+
other check here — axe reads the accessibility tree, where the control was
|
|
180
|
+
correct.
|
|
181
|
+
|
|
182
|
+
`controlClassName` dresses each control for applications that want their own
|
|
183
|
+
look; the package's two colours are the two a user agent guarantees contrast
|
|
184
|
+
between, and nothing more.
|
|
185
|
+
|
|
186
|
+
### R3F with WebGPU
|
|
187
|
+
|
|
188
|
+
R3F also accepts an asynchronous renderer factory. Keep the factory stable and
|
|
189
|
+
initialize Three's modern renderer before returning it:
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import type { R3FRendererFactoryProps } from '@hozo/three/r3f'
|
|
193
|
+
|
|
194
|
+
const createWebGPURenderer = async ({ canvas }: R3FRendererFactoryProps) => {
|
|
195
|
+
const { WebGPURenderer } = await import('three/webgpu')
|
|
196
|
+
const renderer = new WebGPURenderer({
|
|
197
|
+
canvas: canvas as HTMLCanvasElement,
|
|
198
|
+
antialias: true,
|
|
199
|
+
})
|
|
200
|
+
await renderer.init()
|
|
201
|
+
return renderer
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
<ThreeCanvas accessibilityLabel="Product preview" gl={createWebGPURenderer}>
|
|
205
|
+
{/* ordinary R3F scene */}
|
|
206
|
+
</ThreeCanvas>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
The dynamic import keeps Three's modern renderer out of applications that use
|
|
210
|
+
the default R3F WebGL path. Hozo passes the factory through; R3F owns awaiting,
|
|
211
|
+
configuration, frame scheduling, error propagation, and disposal. Runtime GPU
|
|
212
|
+
availability still belongs to the browser and should be covered by an
|
|
213
|
+
application-level fallback or error boundary.
|
|
214
|
+
|
|
215
|
+
### Experimental R3F Native host
|
|
216
|
+
|
|
217
|
+
Expo prebuild applications can opt into the Native GPU host explicitly:
|
|
218
|
+
|
|
219
|
+
```tsx
|
|
220
|
+
import { ThreeCanvas } from '@hozo/three/r3f-native'
|
|
221
|
+
|
|
222
|
+
<ThreeCanvas
|
|
223
|
+
accessibilityLabel="Rotating product preview"
|
|
224
|
+
style={{ flex: 1 }}
|
|
225
|
+
camera={{ position: [0, 2, 5] }}
|
|
226
|
+
>
|
|
227
|
+
<ambientLight intensity={0.5} />
|
|
228
|
+
<mesh>
|
|
229
|
+
<boxGeometry />
|
|
230
|
+
<meshStandardMaterial color="orange" />
|
|
231
|
+
</mesh>
|
|
232
|
+
</ThreeCanvas>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Install `@react-three/fiber` and `three`, then use `npx expo install expo-gl
|
|
236
|
+
expo-asset expo-file-system` so the GL host matches the Expo SDK. This entry is
|
|
237
|
+
experimental and separate from `@hozo/three/r3f`: R3F Native owns its Expo GL
|
|
238
|
+
context, frame loop, and touch raycasting, while Hozo supplies the same
|
|
239
|
+
label/fallback/decorative choice and explicit semantic object controls.
|
|
240
|
+
|
|
241
|
+
Keep one Three instance in Metro: R3F Native patches the CJS `TextureLoader`
|
|
242
|
+
for Expo image uploads, while ESM imports can otherwise select a second Three
|
|
243
|
+
build with a DOM-only image loader. Resolve bare `three` requests to
|
|
244
|
+
`require.resolve('three')` for both application and addon imports, as in the
|
|
245
|
+
[probe's Metro configuration](../../examples/three-native-probe/metro.config.js).
|
|
246
|
+
|
|
247
|
+
The measured support claim is Expo prebuild on Android and iOS. Android has
|
|
248
|
+
release evidence for touch, TalkBack, Activity resume, frame sampling, and
|
|
249
|
+
teardown. The iOS Simulator has release evidence for initialization,
|
|
250
|
+
background/resume, frame sampling, and teardown; trusted pointer and VoiceOver
|
|
251
|
+
operation still need device evidence. Expo Go, bare React Native setup, and
|
|
252
|
+
forced driver/OS context loss are not yet claimed.
|
|
253
|
+
|
|
254
|
+
## Portable projection details
|
|
255
|
+
|
|
256
|
+
The result is a retained `CanvasScene`, with world transforms and camera
|
|
257
|
+
projection already baked into its paths. Indexed and non-indexed triangle
|
|
258
|
+
`BufferGeometry`, perspective and orthographic cameras, clipping, face sides,
|
|
259
|
+
and flat `MeshBasicMaterial` colours are supported. Normal alpha transparency
|
|
260
|
+
maps to Canvas opacity and paints after opaque primitives. `ArrayCamera`
|
|
261
|
+
projects each child camera into its declared bottom-left viewport. `Line`,
|
|
262
|
+
`LineSegments`, and `LineLoop` with `LineBasicMaterial` are projected
|
|
263
|
+
with their declared colour and width. Solid and dashed lines interpolate RGB
|
|
264
|
+
vertex colours through portable Canvas gradients, including clipped endpoints.
|
|
265
|
+
Opaque RGB lines and `MeshBasicMaterial` wireframe edges approximate linear-RGB
|
|
266
|
+
and perspective-correct interpolation with adaptive encoded colour stops. Each
|
|
267
|
+
edge still emits one primitive, capped at 32 stops; short projected edges have
|
|
268
|
+
smaller budgets. Set `lineColorInterpolation="endpoints"` on `ThreeCanvas`, or
|
|
269
|
+
pass the same option to `projectThreeScene`, to keep the cheaper two-stop path
|
|
270
|
+
for large animated scenes. Uniform colours use two stops. Transparency, fog,
|
|
271
|
+
normal-derived gradients and non-default Three colour-management configurations
|
|
272
|
+
retain their existing approximation. The cache holds at most 256 gradient
|
|
273
|
+
conditions; many unique animated depths can miss it on every frame.
|
|
274
|
+
Solid meshes likewise preserve RGB vertex attributes and interpolate colours
|
|
275
|
+
across clipped triangles. RGBA attributes also preserve per-vertex alpha when
|
|
276
|
+
the material opts into transparency; opaque RGBA and alpha-tested gradients
|
|
277
|
+
remain diagnostic because Canvas source-over would change WebGL blend
|
|
278
|
+
semantics. The portable mesh interpolation is screen-space; perspective-correct
|
|
279
|
+
interpolation remains a GPU-backend concern.
|
|
280
|
+
Primary `MeshBasicMaterial.map` colour textures also project when they use
|
|
281
|
+
`SRGBColorSpace`, clamp, repeat, or mirrored wrapping on either axis, a URL/URI or Native
|
|
282
|
+
asset source, and complete two-component UVs. Texture transforms and `flipY`
|
|
283
|
+
are preserved, including UVs created by clipping. Sampling is affine in screen
|
|
284
|
+
space and has no mipmaps. Mesh, point, and sprite material colours multiply the
|
|
285
|
+
map's linear RGB while preserving its alpha. Web caches up to eight processed
|
|
286
|
+
colours per decoded image (fewer for large images); non-white tints require same-origin or CORS-enabled
|
|
287
|
+
images, and continuously animated tints should use a GPU renderer instead.
|
|
288
|
+
Native composes Skia's decode, colour matrix, and encode filters. Vertex-colour/fog modulation,
|
|
289
|
+
and per-pixel alpha tests stay diagnostic instead of being silently
|
|
290
|
+
approximated.
|
|
291
|
+
Solid `Scene.background` colours and constrained 2D colour textures fill the
|
|
292
|
+
portable viewport without creating an interactive object. Cube/equirectangular
|
|
293
|
+
environment backgrounds remain diagnostic. Ordinary 2D texture backgrounds
|
|
294
|
+
support linear-RGB intensity; `backgroundBlurriness` is a no-op, matching Three.js.
|
|
295
|
+
`Fog` and `FogExp2` blend supported meshes, wireframes, lines, points, and
|
|
296
|
+
sprites in the same working colour space as Three.js, while respecting each
|
|
297
|
+
material's `fog` opt-out. Constant-depth shapes and individual points match
|
|
298
|
+
the shader formula; varying-depth portable gradients evaluate fog at their
|
|
299
|
+
vertices or endpoints rather than per fragment.
|
|
300
|
+
Uniform `alphaTest` is preserved for the untextured subset by omitting a whole
|
|
301
|
+
primitive when its material opacity is below the threshold. Per-vertex alpha,
|
|
302
|
+
alpha hashing, MSAA alpha-to-coverage, and dithering are diagnosed rather than
|
|
303
|
+
silently flattened into ordinary opacity.
|
|
304
|
+
`LineDashedMaterial` uses Three's
|
|
305
|
+
`lineDistance`, dash size, gap size, and scale to emit portable segments before
|
|
306
|
+
projection. `PointsMaterial` projects untextured points as circles and the
|
|
307
|
+
constrained colour-map subset as screen-aligned point-sprite quads, including
|
|
308
|
+
perspective size attenuation. Per-point RGB colours remain available for the
|
|
309
|
+
untextured path. Wireframe `MeshBasicMaterial` is
|
|
310
|
+
projected through the same line pipeline, including uniform or per-vertex RGB
|
|
311
|
+
colour and `wireframeLinewidth`. Default world-space material clipping planes cut meshes
|
|
312
|
+
and lines and discard clipped points. `clipIntersection` preserves the union of
|
|
313
|
+
material half-spaces for meshes, lines, points, and sprites.
|
|
314
|
+
Mesh material arrays
|
|
315
|
+
and `BufferGeometry` groups preserve each group's material and intersect with
|
|
316
|
+
the geometry's draw range just as they do in Three.js. `Scene.overrideMaterial`
|
|
317
|
+
replaces supported render-list materials while preserving source visibility and
|
|
318
|
+
`allowOverride`. `LOD` selects its active
|
|
319
|
+
level from the camera distance. `SpriteMaterial` billboards preserve their
|
|
320
|
+
centre, rotation, scale, and size attenuation for solid colours and the same
|
|
321
|
+
constrained affine colour-map subset as meshes.
|
|
322
|
+
`InstancedMesh` applies each instance transform, colour, and morph weight.
|
|
323
|
+
`BatchedMesh` projects its geometry ranges, sparse instance IDs, visibility,
|
|
324
|
+
transforms, and optional instance colours through public Three.js APIs. Position
|
|
325
|
+
morph targets are evaluated for meshes, points, and lines, including relative
|
|
326
|
+
morph geometry. `SkinnedMesh` uses Three's public CPU vertex evaluation so morphs,
|
|
327
|
+
bind matrices, bone weights, and the current skeleton pose remain aligned.
|
|
328
|
+
|
|
329
|
+
This is deliberately not a software WebGL implementation. General GPU texture
|
|
330
|
+
sampling, lighting, custom blending, shaders, post-processing, and XR need a GPU
|
|
331
|
+
backend. Unsupported inputs are omitted and returned as diagnostics rather
|
|
332
|
+
than rendered misleadingly.
|
|
333
|
+
|
|
334
|
+
`MeshNormalMaterial` is the first non-basic portable mesh material: smooth and
|
|
335
|
+
flat view-space normals become Canvas vertex colours for ordinary and instanced
|
|
336
|
+
meshes, while wireframes become normal-coloured Canvas gradients. Each instance
|
|
337
|
+
uses its own normal matrix, and ordinary meshes blend absolute or relative
|
|
338
|
+
position and normal morph targets before projection. Skinned meshes apply those
|
|
339
|
+
morphs before the weighted bone and bind-matrix transforms used by Three.js.
|
|
340
|
+
Texture-perturbed normals and instanced morph textures remain diagnostic rather
|
|
341
|
+
than receiving an inaccurate approximation.
|
|
342
|
+
|
|
343
|
+
The version-pinned [Three.js coverage report](./conformance.md) separates
|
|
344
|
+
atomic portable capabilities from class-level Three.js surface classification;
|
|
345
|
+
both link every claim back to executable tests. Every current portable surface
|
|
346
|
+
category now has an independently owned capability inventory, so the report can
|
|
347
|
+
publish an overall portable ceiling without presenting it as real-scene success.
|
|
348
|
+
The separate [real-scene report](./scene-conformance.md) runs six
|
|
349
|
+
version-pinned archetypes and publishes the same observations as
|
|
350
|
+
[machine-readable JSON](./scene-conformance.json). Portable results are
|
|
351
|
+
measured deterministically; environment-dependent renderer families remain
|
|
352
|
+
explicitly `not-run` in that checked-in report rather than being inferred from
|
|
353
|
+
their API surface.
|
|
354
|
+
|
|
355
|
+
GPU renderer conformance is environment-dependent and is therefore measured on
|
|
356
|
+
main, weekly, and on demand rather than folded into the portable percentage.
|
|
357
|
+
Run `pnpm --filter @hozo/three test:gpu` to produce JSON and Markdown reports
|
|
358
|
+
for classic WebGL, the modern renderer's automatic backend choice, and its
|
|
359
|
+
forced WebGL 2 backend. A missing native WebGPU backend is recorded as
|
|
360
|
+
`unavailable`; classic WebGL and modern forced-WebGL 2 remain required to draw
|
|
361
|
+
and expose working semantic controls. Every available renderer mode also
|
|
362
|
+
executes the same six real-scene fixtures and requires useful draws, semantic
|
|
363
|
+
controls, and activation for every scene. This makes forced WebGL 2 the stable
|
|
364
|
+
Modern-family baseline while native WebGPU remains separately observable.
|
|
365
|
+
|
|
366
|
+
The product-viewer glTF fixture also decodes an embedded 4x4 PNG through the
|
|
367
|
+
browser's `TextureLoader` and advances its `AnimationMixer` using the surface's
|
|
368
|
+
`onFrame` callback. The browser probe waits for real frames, records the rotation
|
|
369
|
+
change, and requires a GPU texture allocation. The Expo GL probe exercises the
|
|
370
|
+
same image and clip through R3F Native's image loader and `useFrame`; Android and
|
|
371
|
+
iOS results are emitted by the Native GPU workflow. The deterministic Node report
|
|
372
|
+
uses pinned pixels and a sampled pose. External image URLs, compressed textures,
|
|
373
|
+
and larger glTF assets remain separate integration cases.
|
|
374
|
+
|
|
375
|
+
The weekly/on-demand Native workflow executes those same fixtures through the
|
|
376
|
+
portable `ThreeCanvas` entry on React Native Android and the Skia Canvas host.
|
|
377
|
+
It uploads screenshots, accessibility trees, and `three-native-corpus.json`:
|
|
378
|
+
the four portable archetypes must draw, expose named Android controls, and
|
|
379
|
+
activate; the ordinary glTF/PBR fixture must stop with the documented
|
|
380
|
+
`UNSUPPORTED_MATERIAL` diagnostic. This is Native-host evidence, not a claim
|
|
381
|
+
that the separately tracked Native GPU backend is available.
|
|
382
|
+
|
|
383
|
+
<!-- generated: package-footer -->
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
Part of [Hozo](https://iray-tno.github.io/hozo/), a Rust-powered universal UI compiler and accessibility-first layer for React Native. Most applications install [`@hozo/core`](https://www.npmjs.com/package/@hozo/core) and one build integration; see [Getting started](https://github.com/iray-tno/hozo#getting-started). Source and issues: [github.com/iray-tno/hozo](https://github.com/iray-tno/hozo).
|
|
388
|
+
|
|
389
|
+
<!-- /generated: package-footer -->
|