@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
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { WebGLRenderer, type WebGLRendererParameters } from 'three';
|
|
2
|
+
import { type ThreeCanvasFrame, type ThreeCanvasFrameloop, type ThreeCanvasHandle, type ThreeCanvasObjectEvent, type ThreeWebCanvasProps } from './web-surface.tsx';
|
|
3
|
+
export type { ThreeCanvasFrame, ThreeCanvasFrameloop, ThreeCanvasHandle, ThreeCanvasObjectEvent };
|
|
4
|
+
export type ThreeWebGLRendererFactory = (canvas: HTMLCanvasElement, options: Omit<WebGLRendererParameters, 'canvas'>) => WebGLRenderer;
|
|
5
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
6
|
+
export type ThreeCanvasProps = DistributiveOmit<ThreeWebCanvasProps<WebGLRenderer>, 'createRaycaster' | 'createRenderer' | 'onCreated'> & {
|
|
7
|
+
/** Creates the owned renderer. Primarily useful for custom renderer subclasses and tests. */
|
|
8
|
+
createRenderer?: ThreeWebGLRendererFactory;
|
|
9
|
+
onCreated?: (renderer: WebGLRenderer) => void;
|
|
10
|
+
rendererOptions?: Omit<WebGLRendererParameters, 'canvas'>;
|
|
11
|
+
};
|
|
12
|
+
/** A Web-only Three.js surface backed by the classic `WebGLRenderer`. */
|
|
13
|
+
export declare function ThreeCanvas({ createRenderer, onCreated, rendererOptions, ...props }: ThreeCanvasProps): import("react").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=webgl-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgl-renderer.d.ts","sourceRoot":"","sources":["../src/webgl-renderer.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,aAAa,EAAE,KAAK,uBAAuB,EAAE,MAAM,OAAO,CAAA;AAE9E,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAE3B,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAA;AAE1B,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,CAAA;AAEjG,MAAM,MAAM,yBAAyB,GAAG,CACtC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,IAAI,CAAC,uBAAuB,EAAE,QAAQ,CAAC,KAC7C,aAAa,CAAA;AAElB,KAAK,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,IAAI,CAAC,SAAS,OAAO,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAA;AAExF,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAC7C,mBAAmB,CAAC,aAAa,CAAC,EAClC,iBAAiB,GAAG,gBAAgB,GAAG,WAAW,CACnD,GAAG;IACF,6FAA6F;IAC7F,cAAc,CAAC,EAAE,yBAAyB,CAAA;IAC1C,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAA;IAC7C,eAAe,CAAC,EAAE,IAAI,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAA;CAC1D,CAAA;AAMD,yEAAyE;AACzE,wBAAgB,WAAW,CAAC,EAC1B,cAAsC,EACtC,SAAS,EACT,eAAoB,EACpB,GAAG,KAAK,EACT,EAAE,gBAAgB,+BAclB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useRef } from 'react';
|
|
3
|
+
import { Raycaster, WebGLRenderer } from 'three';
|
|
4
|
+
import { ThreeWebCanvas, } from './web-surface.js';
|
|
5
|
+
const defaultCreateRenderer = (canvas, options) => new WebGLRenderer({ ...options, canvas });
|
|
6
|
+
const createRaycaster = () => new Raycaster();
|
|
7
|
+
/** A Web-only Three.js surface backed by the classic `WebGLRenderer`. */
|
|
8
|
+
export function ThreeCanvas({ createRenderer = defaultCreateRenderer, onCreated, rendererOptions = {}, ...props }) {
|
|
9
|
+
const creationOptions = useRef(rendererOptions);
|
|
10
|
+
const create = useCallback((canvas) => createRenderer(canvas, creationOptions.current), [createRenderer]);
|
|
11
|
+
return (_jsx(ThreeWebCanvas, { ...props, createRaycaster: createRaycaster, createRenderer: create, onCreated: onCreated }));
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=webgl-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgl-renderer.js","sourceRoot":"","sources":["../src/webgl-renderer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAgC,MAAM,OAAO,CAAA;AAE9E,OAAO,EAKL,cAAc,GAEf,MAAM,kBAAmB,CAAA;AAqB1B,MAAM,qBAAqB,GAA8B,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAC3E,IAAI,aAAa,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;AAC3C,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,IAAI,SAAS,EAAE,CAAA;AAE7C,yEAAyE;AACzE,MAAM,UAAU,WAAW,CAAC,EAC1B,cAAc,GAAG,qBAAqB,EACtC,SAAS,EACT,eAAe,GAAG,EAAE,EACpB,GAAG,KAAK,EACS;IACjB,MAAM,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC,CAAA;IAC/C,MAAM,MAAM,GAAG,WAAW,CACxB,CAAC,MAAyB,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,EAC9E,CAAC,cAAc,CAAC,CACjB,CAAA;IACD,OAAO,CACL,KAAC,cAAc,OACT,KAAK,EACT,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,SAAS,GACpB,CACH,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ThreeCanvasProps } from './webgpu.tsx';
|
|
2
|
+
export type { ThreeCanvasFrame, ThreeCanvasFrameloop, ThreeCanvasHandle, ThreeCanvasObjectEvent, ThreeCanvasProps, ThreeWebGPURendererFactory, } from './webgpu.tsx';
|
|
3
|
+
/** The browser WebGPU renderer has no implicit React Native surface host. */
|
|
4
|
+
export declare function ThreeCanvas(_props: ThreeCanvasProps): never;
|
|
5
|
+
//# sourceMappingURL=webgpu-react-native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-react-native.d.ts","sourceRoot":"","sources":["../src/webgpu-react-native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAEpD,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,0BAA0B,GAC3B,MAAM,cAAc,CAAA;AAErB,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,MAAM,EAAE,gBAAgB,GAAG,KAAK,CAI3D"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The browser WebGPU renderer has no implicit React Native surface host. */
|
|
2
|
+
export function ThreeCanvas(_props) {
|
|
3
|
+
throw new Error('@hozo/three/webgpu is not available on React Native. Use the portable @hozo/three surface or an explicit Native GPU host.');
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=webgpu-react-native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu-react-native.js","sourceRoot":"","sources":["../src/webgpu-react-native.tsx"],"names":[],"mappings":"AAWA,6EAA6E;AAC7E,MAAM,UAAU,WAAW,CAAC,MAAwB;IAClD,MAAM,IAAI,KAAK,CACb,2HAA2H,CAC5H,CAAA;AACH,CAAC"}
|
package/dist/webgpu.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { WebGPURendererParameters } from 'three/src/renderers/webgpu/WebGPURenderer.js';
|
|
2
|
+
import { type WebGPURenderer } from 'three/webgpu';
|
|
3
|
+
import { type ThreeCanvasFrame, type ThreeCanvasFrameloop, type ThreeCanvasHandle, type ThreeCanvasObjectEvent, type ThreeWebCanvasProps } from './web-surface.tsx';
|
|
4
|
+
export type { ThreeCanvasFrame, ThreeCanvasFrameloop, ThreeCanvasHandle, ThreeCanvasObjectEvent };
|
|
5
|
+
export type ThreeWebGPURendererFactory = (canvas: HTMLCanvasElement, options: Omit<WebGPURendererParameters, 'canvas'>) => Promise<WebGPURenderer> | WebGPURenderer;
|
|
6
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
7
|
+
export type ThreeCanvasProps = DistributiveOmit<ThreeWebCanvasProps<WebGPURenderer>, 'createRaycaster' | 'createRenderer' | 'onCreated'> & {
|
|
8
|
+
/** Creates the owned modern renderer. Hozo awaits `init()` before drawing. */
|
|
9
|
+
createRenderer?: ThreeWebGPURendererFactory;
|
|
10
|
+
onCreated?: (renderer: WebGPURenderer) => void;
|
|
11
|
+
rendererOptions?: Omit<WebGPURendererParameters, 'canvas'>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The modern Three.js renderer family. Three chooses WebGPU by default and
|
|
15
|
+
* falls back to its own WebGL 2 backend unless `rendererOptions` says otherwise.
|
|
16
|
+
*/
|
|
17
|
+
export declare function ThreeCanvas({ createRenderer, onCreated, rendererOptions, ...props }: ThreeCanvasProps): import("react").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=webgpu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu.d.ts","sourceRoot":"","sources":["../src/webgpu.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAA;AAC5F,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7D,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAE3B,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAA;AAE1B,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,CAAA;AAEjG,MAAM,MAAM,0BAA0B,GAAG,CACvC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,IAAI,CAAC,wBAAwB,EAAE,QAAQ,CAAC,KAC9C,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAAA;AAE7C,KAAK,gBAAgB,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,IAAI,CAAC,SAAS,OAAO,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAA;AAExF,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAC7C,mBAAmB,CAAC,cAAc,CAAC,EACnC,iBAAiB,GAAG,gBAAgB,GAAG,WAAW,CACnD,GAAG;IACF,8EAA8E;IAC9E,cAAc,CAAC,EAAE,0BAA0B,CAAA;IAC3C,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAA;IAC9C,eAAe,CAAC,EAAE,IAAI,CAAC,wBAAwB,EAAE,QAAQ,CAAC,CAAA;CAC3D,CAAA;AAQD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAC1B,cAAsC,EACtC,SAAS,EACT,eAAoB,EACpB,GAAG,KAAK,EACT,EAAE,gBAAgB,+BAuBlB"}
|
package/dist/webgpu.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useRef } from 'react';
|
|
3
|
+
import { Raycaster } from 'three/webgpu';
|
|
4
|
+
import { ThreeWebCanvas, } from './web-surface.js';
|
|
5
|
+
const defaultCreateRenderer = async (canvas, options) => {
|
|
6
|
+
const { WebGPURenderer } = await import('three/webgpu');
|
|
7
|
+
return new WebGPURenderer({ ...options, canvas });
|
|
8
|
+
};
|
|
9
|
+
const createRaycaster = () => new Raycaster();
|
|
10
|
+
/**
|
|
11
|
+
* The modern Three.js renderer family. Three chooses WebGPU by default and
|
|
12
|
+
* falls back to its own WebGL 2 backend unless `rendererOptions` says otherwise.
|
|
13
|
+
*/
|
|
14
|
+
export function ThreeCanvas({ createRenderer = defaultCreateRenderer, onCreated, rendererOptions = {}, ...props }) {
|
|
15
|
+
const creationOptions = useRef(rendererOptions);
|
|
16
|
+
const create = useCallback(async (canvas) => {
|
|
17
|
+
const renderer = await createRenderer(canvas, creationOptions.current);
|
|
18
|
+
try {
|
|
19
|
+
await renderer.init();
|
|
20
|
+
return renderer;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
renderer.dispose();
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}, [createRenderer]);
|
|
27
|
+
return (_jsx(ThreeWebCanvas, { ...props, createRaycaster: createRaycaster, createRenderer: create, onCreated: onCreated }));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=webgpu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu.js","sourceRoot":"","sources":["../src/webgpu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,SAAS,EAAuB,MAAM,cAAc,CAAA;AAE7D,OAAO,EAKL,cAAc,GAEf,MAAM,kBAAmB,CAAA;AAqB1B,MAAM,qBAAqB,GAA+B,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;IAClF,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAA;IACvD,OAAO,IAAI,cAAc,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;AACnD,CAAC,CAAA;AACD,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,IAAI,SAAS,EAAE,CAAA;AAE7C;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,EAC1B,cAAc,GAAG,qBAAqB,EACtC,SAAS,EACT,eAAe,GAAG,EAAE,EACpB,GAAG,KAAK,EACS;IACjB,MAAM,eAAe,GAAG,MAAM,CAAC,eAAe,CAAC,CAAA;IAC/C,MAAM,MAAM,GAAG,WAAW,CACxB,KAAK,EAAE,MAAyB,EAAE,EAAE;QAClC,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,CAAA;QACtE,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;YACrB,OAAO,QAAQ,CAAA;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,QAAQ,CAAC,OAAO,EAAE,CAAA;YAClB,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC,EACD,CAAC,cAAc,CAAC,CACjB,CAAA;IACD,OAAO,CACL,KAAC,cAAc,OACT,KAAK,EACT,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,SAAS,GACpB,CACH,CAAA;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hozo/three",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Projects Three.js scenes into portable Hozo Canvas scenes.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react-native",
|
|
7
|
+
"three.js",
|
|
8
|
+
"3d",
|
|
9
|
+
"canvas",
|
|
10
|
+
"graphics"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/iray-tno/hozo.git",
|
|
16
|
+
"directory": "packages/three"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://iray-tno.github.io/hozo/",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/iray-tno/hozo/issues"
|
|
21
|
+
},
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./conformance-scenes": {
|
|
32
|
+
"types": "./dist/conformance-scenes.d.ts",
|
|
33
|
+
"default": "./dist/conformance-scenes.js"
|
|
34
|
+
},
|
|
35
|
+
"./r3f": {
|
|
36
|
+
"react-native": {
|
|
37
|
+
"types": "./dist/r3f-react-native.d.ts",
|
|
38
|
+
"default": "./dist/r3f-react-native.js"
|
|
39
|
+
},
|
|
40
|
+
"types": "./dist/r3f.d.ts",
|
|
41
|
+
"default": "./dist/r3f.js"
|
|
42
|
+
},
|
|
43
|
+
"./r3f-native": {
|
|
44
|
+
"react-native": {
|
|
45
|
+
"types": "./dist/r3f-native.d.ts",
|
|
46
|
+
"default": "./dist/r3f-native.js"
|
|
47
|
+
},
|
|
48
|
+
"types": "./dist/r3f-native-unavailable.d.ts",
|
|
49
|
+
"default": "./dist/r3f-native-unavailable.js"
|
|
50
|
+
},
|
|
51
|
+
"./scene-conformance.json": "./scene-conformance.json",
|
|
52
|
+
"./webgl": {
|
|
53
|
+
"react-native": {
|
|
54
|
+
"types": "./dist/webgl-react-native.d.ts",
|
|
55
|
+
"default": "./dist/webgl-react-native.js"
|
|
56
|
+
},
|
|
57
|
+
"types": "./dist/webgl-renderer.d.ts",
|
|
58
|
+
"default": "./dist/webgl-renderer.js"
|
|
59
|
+
},
|
|
60
|
+
"./webgpu": {
|
|
61
|
+
"react-native": {
|
|
62
|
+
"types": "./dist/webgpu-react-native.d.ts",
|
|
63
|
+
"default": "./dist/webgpu-react-native.js"
|
|
64
|
+
},
|
|
65
|
+
"types": "./dist/webgpu.d.ts",
|
|
66
|
+
"default": "./dist/webgpu.js"
|
|
67
|
+
},
|
|
68
|
+
"./package.json": "./package.json"
|
|
69
|
+
},
|
|
70
|
+
"files": [
|
|
71
|
+
"conformance.md",
|
|
72
|
+
"dist",
|
|
73
|
+
"scene-conformance.json",
|
|
74
|
+
"scene-conformance.md",
|
|
75
|
+
"src",
|
|
76
|
+
"!src/**/*.test.ts",
|
|
77
|
+
"!src/**/*.test.tsx",
|
|
78
|
+
"!src/**/*.bench.ts"
|
|
79
|
+
],
|
|
80
|
+
"publishConfig": {
|
|
81
|
+
"access": "public",
|
|
82
|
+
"provenance": true
|
|
83
|
+
},
|
|
84
|
+
"dependencies": {
|
|
85
|
+
"@hozo/canvas": "^0.1.0",
|
|
86
|
+
"@hozo/engine": "^0.1.0"
|
|
87
|
+
},
|
|
88
|
+
"peerDependencies": {
|
|
89
|
+
"@react-three/fiber": ">=9",
|
|
90
|
+
"react": "^19.0.0",
|
|
91
|
+
"react-native": ">=0.86",
|
|
92
|
+
"three": ">=0.170"
|
|
93
|
+
},
|
|
94
|
+
"peerDependenciesMeta": {
|
|
95
|
+
"@react-three/fiber": {
|
|
96
|
+
"optional": true
|
|
97
|
+
},
|
|
98
|
+
"react-native": {
|
|
99
|
+
"optional": true
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"devDependencies": {
|
|
103
|
+
"@react-three/fiber": "^9.8.1",
|
|
104
|
+
"@types/react": "^19.2.18",
|
|
105
|
+
"@types/react-dom": "^19.2.5",
|
|
106
|
+
"@types/three": "^0.180.0",
|
|
107
|
+
"esbuild": "0.28.2",
|
|
108
|
+
"playwright-core": "1.63.0",
|
|
109
|
+
"react": "^19.2.8",
|
|
110
|
+
"react-dom": "^19.2.8",
|
|
111
|
+
"react-native": "^0.87.1",
|
|
112
|
+
"react-test-renderer": "^19.2.8",
|
|
113
|
+
"three": "^0.180.0"
|
|
114
|
+
},
|
|
115
|
+
"scripts": {
|
|
116
|
+
"build": "node ../../scripts/clean-package-dist.mjs && tsc -p .",
|
|
117
|
+
"report": "node scripts/report.ts",
|
|
118
|
+
"test:gpu": "node scripts/check-gpu.mjs",
|
|
119
|
+
"typecheck": "tsc -p . --noEmit",
|
|
120
|
+
"test": "node -e \"require('node:fs').rmSync('.test-build', { recursive: true, force: true })\" && tsc -p tsconfig.test.json && node --test .test-build/*.test.js && node --test scripts/conformance.test.ts scripts/renderer-entrypoints.test.ts scripts/scene-corpus.test.ts && node scripts/report-conformance.ts --check && node scripts/report-scenes.ts --check"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
{
|
|
2
|
+
"fixtures": [
|
|
3
|
+
{
|
|
4
|
+
"archetype": "flat diagram / labelled interaction",
|
|
5
|
+
"exercises": [
|
|
6
|
+
"orthographic camera",
|
|
7
|
+
"flat meshes",
|
|
8
|
+
"line segments",
|
|
9
|
+
"named interaction targets"
|
|
10
|
+
],
|
|
11
|
+
"families": {
|
|
12
|
+
"classic-webgl": {
|
|
13
|
+
"reason": "classic-webgl result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
14
|
+
"status": "not-run"
|
|
15
|
+
},
|
|
16
|
+
"modern-webgpu": {
|
|
17
|
+
"reason": "modern-webgpu result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
18
|
+
"status": "not-run"
|
|
19
|
+
},
|
|
20
|
+
"native-host": {
|
|
21
|
+
"reason": "native-host result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
22
|
+
"status": "not-run"
|
|
23
|
+
},
|
|
24
|
+
"portable": {
|
|
25
|
+
"status": "useful"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"id": "flat-labelled-diagram",
|
|
29
|
+
"portableObservation": {
|
|
30
|
+
"diagnosticCodes": [],
|
|
31
|
+
"namedObjects": 3,
|
|
32
|
+
"outputNodes": 4
|
|
33
|
+
},
|
|
34
|
+
"source": {
|
|
35
|
+
"location": "src/conformance-scenes.ts#flatDiagram",
|
|
36
|
+
"version": "corpus-v1 / Three.js r180"
|
|
37
|
+
},
|
|
38
|
+
"verified": true
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"archetype": "wireframe or CAD-like scene",
|
|
42
|
+
"exercises": [
|
|
43
|
+
"box geometry",
|
|
44
|
+
"world rotation",
|
|
45
|
+
"wireframe material",
|
|
46
|
+
"depth ordering"
|
|
47
|
+
],
|
|
48
|
+
"families": {
|
|
49
|
+
"classic-webgl": {
|
|
50
|
+
"reason": "classic-webgl result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
51
|
+
"status": "not-run"
|
|
52
|
+
},
|
|
53
|
+
"modern-webgpu": {
|
|
54
|
+
"reason": "modern-webgpu result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
55
|
+
"status": "not-run"
|
|
56
|
+
},
|
|
57
|
+
"native-host": {
|
|
58
|
+
"reason": "native-host result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
59
|
+
"status": "not-run"
|
|
60
|
+
},
|
|
61
|
+
"portable": {
|
|
62
|
+
"status": "useful"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"id": "wireframe-cad",
|
|
66
|
+
"portableObservation": {
|
|
67
|
+
"diagnosticCodes": [],
|
|
68
|
+
"namedObjects": 1,
|
|
69
|
+
"outputNodes": 36
|
|
70
|
+
},
|
|
71
|
+
"source": {
|
|
72
|
+
"location": "src/conformance-scenes.ts#wireframeCad",
|
|
73
|
+
"version": "corpus-v1 / Three.js r180"
|
|
74
|
+
},
|
|
75
|
+
"verified": true
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"archetype": "points / sprite scene",
|
|
79
|
+
"exercises": [
|
|
80
|
+
"points",
|
|
81
|
+
"fixed screen-space point size",
|
|
82
|
+
"sprite billboard",
|
|
83
|
+
"named targets"
|
|
84
|
+
],
|
|
85
|
+
"families": {
|
|
86
|
+
"classic-webgl": {
|
|
87
|
+
"reason": "classic-webgl result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
88
|
+
"status": "not-run"
|
|
89
|
+
},
|
|
90
|
+
"modern-webgpu": {
|
|
91
|
+
"reason": "modern-webgpu result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
92
|
+
"status": "not-run"
|
|
93
|
+
},
|
|
94
|
+
"native-host": {
|
|
95
|
+
"reason": "native-host result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
96
|
+
"status": "not-run"
|
|
97
|
+
},
|
|
98
|
+
"portable": {
|
|
99
|
+
"status": "useful"
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"id": "points-and-sprite",
|
|
103
|
+
"portableObservation": {
|
|
104
|
+
"diagnosticCodes": [],
|
|
105
|
+
"namedObjects": 2,
|
|
106
|
+
"outputNodes": 4
|
|
107
|
+
},
|
|
108
|
+
"source": {
|
|
109
|
+
"location": "src/conformance-scenes.ts#pointsAndSprite",
|
|
110
|
+
"version": "corpus-v1 / Three.js r180"
|
|
111
|
+
},
|
|
112
|
+
"verified": true
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"archetype": "instancing plus morph with a portable material",
|
|
116
|
+
"exercises": [
|
|
117
|
+
"instanced mesh",
|
|
118
|
+
"instance transforms",
|
|
119
|
+
"relative morph targets",
|
|
120
|
+
"MeshBasicMaterial"
|
|
121
|
+
],
|
|
122
|
+
"families": {
|
|
123
|
+
"classic-webgl": {
|
|
124
|
+
"reason": "classic-webgl result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
125
|
+
"status": "not-run"
|
|
126
|
+
},
|
|
127
|
+
"modern-webgpu": {
|
|
128
|
+
"reason": "modern-webgpu result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
129
|
+
"status": "not-run"
|
|
130
|
+
},
|
|
131
|
+
"native-host": {
|
|
132
|
+
"reason": "native-host result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
133
|
+
"status": "not-run"
|
|
134
|
+
},
|
|
135
|
+
"portable": {
|
|
136
|
+
"status": "useful"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
"id": "instancing-and-morph",
|
|
140
|
+
"portableObservation": {
|
|
141
|
+
"diagnosticCodes": [],
|
|
142
|
+
"namedObjects": 1,
|
|
143
|
+
"outputNodes": 2
|
|
144
|
+
},
|
|
145
|
+
"source": {
|
|
146
|
+
"location": "src/conformance-scenes.ts#instancingAndMorph",
|
|
147
|
+
"version": "corpus-v1 / Three.js r180"
|
|
148
|
+
},
|
|
149
|
+
"verified": true
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"archetype": "animated textured glTF product viewer",
|
|
153
|
+
"exercises": [
|
|
154
|
+
"glTF 2.0 node hierarchy",
|
|
155
|
+
"PBR materials",
|
|
156
|
+
"UV-mapped texture / GPU host PNG decoding",
|
|
157
|
+
"punctual light",
|
|
158
|
+
"sampled animation pose / GPU frame-loop playback"
|
|
159
|
+
],
|
|
160
|
+
"families": {
|
|
161
|
+
"classic-webgl": {
|
|
162
|
+
"reason": "classic-webgl result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
163
|
+
"status": "not-run"
|
|
164
|
+
},
|
|
165
|
+
"modern-webgpu": {
|
|
166
|
+
"reason": "modern-webgpu result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
167
|
+
"status": "not-run"
|
|
168
|
+
},
|
|
169
|
+
"native-host": {
|
|
170
|
+
"reason": "native-host result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
171
|
+
"status": "not-run"
|
|
172
|
+
},
|
|
173
|
+
"portable": {
|
|
174
|
+
"status": "diagnostic"
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"id": "product-viewer-gltf",
|
|
178
|
+
"portableObservation": {
|
|
179
|
+
"diagnosticCodes": [
|
|
180
|
+
"UNSUPPORTED_MATERIAL",
|
|
181
|
+
"UNSUPPORTED_MATERIAL"
|
|
182
|
+
],
|
|
183
|
+
"namedObjects": 0,
|
|
184
|
+
"outputNodes": 0
|
|
185
|
+
},
|
|
186
|
+
"source": {
|
|
187
|
+
"location": "src/conformance-scenes.ts#productViewer",
|
|
188
|
+
"version": "corpus-v1 / Three.js r180"
|
|
189
|
+
},
|
|
190
|
+
"verified": true
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"archetype": "ordinary glTF/PBR scene",
|
|
194
|
+
"exercises": [
|
|
195
|
+
"glTF 2.0 loader",
|
|
196
|
+
"asset graph",
|
|
197
|
+
"MeshStandardMaterial",
|
|
198
|
+
"PBR factors"
|
|
199
|
+
],
|
|
200
|
+
"families": {
|
|
201
|
+
"classic-webgl": {
|
|
202
|
+
"reason": "classic-webgl result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
203
|
+
"status": "not-run"
|
|
204
|
+
},
|
|
205
|
+
"modern-webgpu": {
|
|
206
|
+
"reason": "modern-webgpu result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
207
|
+
"status": "not-run"
|
|
208
|
+
},
|
|
209
|
+
"native-host": {
|
|
210
|
+
"reason": "native-host result is emitted by its environment workflow and is not baked into this deterministic report",
|
|
211
|
+
"status": "not-run"
|
|
212
|
+
},
|
|
213
|
+
"portable": {
|
|
214
|
+
"status": "diagnostic"
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
"id": "gltf-pbr",
|
|
218
|
+
"portableObservation": {
|
|
219
|
+
"diagnosticCodes": [
|
|
220
|
+
"UNSUPPORTED_MATERIAL"
|
|
221
|
+
],
|
|
222
|
+
"namedObjects": 0,
|
|
223
|
+
"outputNodes": 0
|
|
224
|
+
},
|
|
225
|
+
"source": {
|
|
226
|
+
"location": "fixtures/minimal-pbr.gltf",
|
|
227
|
+
"version": "glTF 2.0 / Three.js r180"
|
|
228
|
+
},
|
|
229
|
+
"verified": true
|
|
230
|
+
}
|
|
231
|
+
],
|
|
232
|
+
"generatedAgainst": "Three.js r180",
|
|
233
|
+
"schemaVersion": 1,
|
|
234
|
+
"summary": {
|
|
235
|
+
"diagnostic": 2,
|
|
236
|
+
"failed": 0,
|
|
237
|
+
"notRunByFamily": {
|
|
238
|
+
"classic-webgl": 6,
|
|
239
|
+
"modern-webgpu": 6,
|
|
240
|
+
"native-host": 6
|
|
241
|
+
},
|
|
242
|
+
"useful": 4
|
|
243
|
+
}
|
|
244
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Three.js real-scene coverage
|
|
2
|
+
|
|
3
|
+
Generated against Three.js r180. The machine-readable form is [scene-conformance.json](./scene-conformance.json).
|
|
4
|
+
|
|
5
|
+
This report executes representative, version-pinned scenes instead of treating an API inventory as an application success rate. A fixture is verified when its observed output and diagnostics match its pinned expectation. Renderer families are reported separately: **not-run is unknown, not success**.
|
|
6
|
+
|
|
7
|
+
## Summary
|
|
8
|
+
|
|
9
|
+
- Portable: **4 useful**, **2 safely diagnostic**, **0 failed** across 6 fixtures.
|
|
10
|
+
- Classic WebGL: **6 not run**.
|
|
11
|
+
- Modern WebGPU-family: **6 not run**.
|
|
12
|
+
- Native host: **6 not run**.
|
|
13
|
+
|
|
14
|
+
The checked-in report remains deterministic and therefore leaves driver-backed families as not-run. The separate `test:gpu` artifact executes these exact fixtures in Classic WebGL, Modern forced-WebGL 2, and native WebGPU when available on main, weekly, and on demand; its result is environment evidence rather than a value copied into this file.
|
|
15
|
+
|
|
16
|
+
Both glTF/PBR fixtures demonstrate the current portable boundary: their assets load through Three.js's GLTFLoader, then MeshStandardMaterial is rejected with an explicit diagnostic. The product-viewer fixture adds a node hierarchy, UVs, a punctual light, and an animation clip. This deterministic Node report uses pinned raw pixels and a sampled pose. The browser and Expo GL GPU probes instead decode the embedded PNG with their host TextureLoader and advance AnimationMixer from their frame loops. Their environment reports require texture allocation, multiple animation frames, and a measured rotation change. This covers the small embedded PNG fixture; external image files, compressed textures, and arbitrary glTF assets need their own evidence.
|
|
17
|
+
|
|
18
|
+
## Fixtures
|
|
19
|
+
|
|
20
|
+
| Fixture | Source/version | Exercises | Portable | Classic WebGL | Modern WebGPU-family | Native host | Observation |
|
|
21
|
+
| --- | --- | --- | --- | --- | --- | --- | --- |
|
|
22
|
+
| flat diagram / labelled interaction | src/conformance-scenes.ts#flatDiagram (corpus-v1 / Three.js r180) | orthographic camera, flat meshes, line segments, named interaction targets | useful | not-run — classic-webgl result is emitted by its environment workflow and is not baked into this deterministic report | not-run — modern-webgpu result is emitted by its environment workflow and is not baked into this deterministic report | not-run — native-host result is emitted by its environment workflow and is not baked into this deterministic report | 4 nodes; 3 named objects; diagnostics: none |
|
|
23
|
+
| wireframe or CAD-like scene | src/conformance-scenes.ts#wireframeCad (corpus-v1 / Three.js r180) | box geometry, world rotation, wireframe material, depth ordering | useful | not-run — classic-webgl result is emitted by its environment workflow and is not baked into this deterministic report | not-run — modern-webgpu result is emitted by its environment workflow and is not baked into this deterministic report | not-run — native-host result is emitted by its environment workflow and is not baked into this deterministic report | 36 nodes; 1 named objects; diagnostics: none |
|
|
24
|
+
| points / sprite scene | src/conformance-scenes.ts#pointsAndSprite (corpus-v1 / Three.js r180) | points, fixed screen-space point size, sprite billboard, named targets | useful | not-run — classic-webgl result is emitted by its environment workflow and is not baked into this deterministic report | not-run — modern-webgpu result is emitted by its environment workflow and is not baked into this deterministic report | not-run — native-host result is emitted by its environment workflow and is not baked into this deterministic report | 4 nodes; 2 named objects; diagnostics: none |
|
|
25
|
+
| instancing plus morph with a portable material | src/conformance-scenes.ts#instancingAndMorph (corpus-v1 / Three.js r180) | instanced mesh, instance transforms, relative morph targets, MeshBasicMaterial | useful | not-run — classic-webgl result is emitted by its environment workflow and is not baked into this deterministic report | not-run — modern-webgpu result is emitted by its environment workflow and is not baked into this deterministic report | not-run — native-host result is emitted by its environment workflow and is not baked into this deterministic report | 2 nodes; 1 named objects; diagnostics: none |
|
|
26
|
+
| animated textured glTF product viewer | src/conformance-scenes.ts#productViewer (corpus-v1 / Three.js r180) | glTF 2.0 node hierarchy, PBR materials, UV-mapped texture / GPU host PNG decoding, punctual light, sampled animation pose / GPU frame-loop playback | diagnostic | not-run — classic-webgl result is emitted by its environment workflow and is not baked into this deterministic report | not-run — modern-webgpu result is emitted by its environment workflow and is not baked into this deterministic report | not-run — native-host result is emitted by its environment workflow and is not baked into this deterministic report | 0 nodes; 0 named objects; diagnostics: UNSUPPORTED_MATERIAL, UNSUPPORTED_MATERIAL |
|
|
27
|
+
| ordinary glTF/PBR scene | fixtures/minimal-pbr.gltf (glTF 2.0 / Three.js r180) | glTF 2.0 loader, asset graph, MeshStandardMaterial, PBR factors | diagnostic | not-run — classic-webgl result is emitted by its environment workflow and is not baked into this deterministic report | not-run — modern-webgpu result is emitted by its environment workflow and is not baked into this deterministic report | not-run — native-host result is emitted by its environment workflow and is not baked into this deterministic report | 0 nodes; 0 named objects; diagnostics: UNSUPPORTED_MATERIAL |
|
|
28
|
+
|
|
29
|
+
## Interpretation
|
|
30
|
+
|
|
31
|
+
This corpus establishes the portable runner and six scenario contracts. It does not yet claim GPU or Native-host scene compatibility. Environment workflows run these same fixtures; their results should drive implementation work rather than a larger row percentage.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { CSSProperties, FocusEvent } from 'react'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The two states of the control strip that stands in for a canvas.
|
|
5
|
+
*
|
|
6
|
+
* A canvas has no accessible children, so both Web surfaces build one real DOM
|
|
7
|
+
* control per registered object and park them off-screen. That half was right
|
|
8
|
+
* and is what a screen reader reads. What was missing is the other half: those
|
|
9
|
+
* controls are in the tab order, so a **sighted** keyboard user lands on them,
|
|
10
|
+
* and `clip: rect(0, 0, 0, 0)` means there is nothing to see when they do.
|
|
11
|
+
*
|
|
12
|
+
* Measured before it was fixed (#689), with `check-appearance.mjs`'s harness:
|
|
13
|
+
* the host is 1 by 1 with the clip above, and the button inside it is 136 by 24
|
|
14
|
+
* and carries Chrome's own focus ring -- `outline-style: auto` -- which is
|
|
15
|
+
* clipped away with everything else. So the ring existed and could not be seen,
|
|
16
|
+
* which is WCAG 2.4.7 rather than a missing style.
|
|
17
|
+
*
|
|
18
|
+
* Hidden-until-focused is the established answer, and it is what a skip link
|
|
19
|
+
* does. The strip stays clipped at rest and is revealed while focus is inside
|
|
20
|
+
* it.
|
|
21
|
+
*/
|
|
22
|
+
export const accessibleOnlyStyle: CSSProperties = {
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
width: 1,
|
|
25
|
+
height: 1,
|
|
26
|
+
padding: 0,
|
|
27
|
+
margin: -1,
|
|
28
|
+
overflow: 'hidden',
|
|
29
|
+
clip: 'rect(0, 0, 0, 0)',
|
|
30
|
+
whiteSpace: 'nowrap',
|
|
31
|
+
border: 0,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The same strip, visible, over the canvas's leading corner.
|
|
36
|
+
*
|
|
37
|
+
* System colours rather than a palette, which is not a shortcut: this package
|
|
38
|
+
* ships no CSS and has no theme to read, and `Canvas`/`CanvasText` are the two
|
|
39
|
+
* colours a user agent guarantees contrast between -- including in forced-colors
|
|
40
|
+
* mode, where a hard-coded pair would be overridden anyway. An application that
|
|
41
|
+
* wants its own look passes `controlClassName`.
|
|
42
|
+
*
|
|
43
|
+
* Over the scene rather than beside it, because the alternative is a strip that
|
|
44
|
+
* reflows the page the moment focus enters it: a control that moves what is
|
|
45
|
+
* under the pointer as it appears is worse than one that covers a corner of a
|
|
46
|
+
* picture.
|
|
47
|
+
*/
|
|
48
|
+
export const revealedControlsStyle: CSSProperties = {
|
|
49
|
+
position: 'absolute',
|
|
50
|
+
insetInlineStart: 0,
|
|
51
|
+
insetBlockStart: 0,
|
|
52
|
+
zIndex: 1,
|
|
53
|
+
display: 'flex',
|
|
54
|
+
flexDirection: 'row',
|
|
55
|
+
flexWrap: 'wrap',
|
|
56
|
+
gap: 4,
|
|
57
|
+
padding: 4,
|
|
58
|
+
maxWidth: '100%',
|
|
59
|
+
background: 'Canvas',
|
|
60
|
+
color: 'CanvasText',
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Whether focus has left the strip entirely, rather than moved within it.
|
|
65
|
+
*
|
|
66
|
+
* `blur` fires on every hop between two controls in the same strip, so hiding on
|
|
67
|
+
* any blur makes the strip flicker away under the second Tab -- and a strip that
|
|
68
|
+
* disappears while you are still inside it is worse than one that never showed.
|
|
69
|
+
* `relatedTarget` is where focus is going; if the strip still contains it,
|
|
70
|
+
* nothing has left.
|
|
71
|
+
*
|
|
72
|
+
* `relatedTarget` is `null` when focus leaves the document, which is a real
|
|
73
|
+
* departure and hides it correctly.
|
|
74
|
+
*
|
|
75
|
+
* Duck-typed rather than `instanceof Node`, which reads better and needs a DOM
|
|
76
|
+
* global: this function then throws `ReferenceError: Node is not defined` the
|
|
77
|
+
* moment anything outside a browser calls it, which its own test did first. A
|
|
78
|
+
* `nodeType` is what `contains` needs and is the thing being asked about.
|
|
79
|
+
*/
|
|
80
|
+
export function focusLeft(event: FocusEvent<HTMLElement>): boolean {
|
|
81
|
+
const next = event.relatedTarget as Node | null
|
|
82
|
+
if (!next || typeof next.nodeType !== 'number') return true
|
|
83
|
+
return !event.currentTarget.contains(next)
|
|
84
|
+
}
|