@expofp/renderer 3.34.2 → 3.35.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.
- package/dist/Renderer.d.ts +14 -0
- package/dist/Renderer.js +16 -4
- package/dist/core/SquareDataTexture.d.ts +2 -2
- package/dist/core/SquareDataTexture.js +2 -2
- package/dist/core/batch/BatchedMesh.d.ts +3 -3
- package/dist/core/batch/BatchedMesh.js +3 -3
- package/dist/core/instanced/InstancedMesh.d.ts +7 -7
- package/dist/core/instanced/InstancedMesh.js +4 -4
- package/dist/core/instanced/instanced-material.js +1 -1
- package/dist/core/lines/BatchedLines.d.ts +4 -4
- package/dist/core/lines/BatchedLines.js +4 -4
- package/dist/core/shader-source.d.ts +20 -0
- package/dist/core/shader-source.js +26 -0
- package/dist/core/text/BatchedText.d.ts +14 -14
- package/dist/core/text/BatchedText.js +9 -9
- package/dist/core/text/MemberTexture.d.ts +2 -2
- package/dist/core/text/Text.d.ts +5 -5
- package/dist/core/text/Text.js +4 -4
- package/dist/core/text/glyph-packing.d.ts +2 -2
- package/dist/debug/components/Gui.d.ts +2 -0
- package/dist/debug/components/Gui.js +11 -1
- package/dist/events/layout-targets.d.ts +7 -3
- package/dist/events/layout-targets.js +13 -1
- package/dist/external/ExternalCanvas.js +5 -6
- package/dist/external/external-camera.js +26 -11
- package/dist/index.d.ts +1 -0
- package/dist/objects/Background.js +1 -1
- package/dist/objects/containers/SlotContainer.d.ts +27 -2
- package/dist/objects/containers/SlotContainer.js +36 -1
- package/dist/objects/containers/hooks.js +1 -1
- package/dist/objects/containers/mesh-writes.d.ts +1 -1
- package/dist/objects/containers/props.d.ts +10 -0
- package/dist/objects/images/Images.js +10 -3
- package/dist/objects/images/image-container.d.ts +5 -5
- package/dist/objects/images/image-container.js +2 -2
- package/dist/objects/layer/Layer.js +10 -10
- package/dist/objects/layer/mount-scheduler.d.ts +83 -54
- package/dist/objects/layer/mount-scheduler.js +204 -60
- package/dist/objects/lighting/Lighting.d.ts +92 -0
- package/dist/objects/lighting/Lighting.js +385 -0
- package/dist/objects/lighting/OcclusionPasses.d.ts +23 -0
- package/dist/objects/lighting/OcclusionPasses.js +271 -0
- package/dist/objects/lighting/index.d.ts +11 -0
- package/dist/objects/lighting/index.js +10 -0
- package/dist/objects/lighting/lighting-gui.d.ts +24 -0
- package/dist/objects/lighting/lighting-gui.js +114 -0
- package/dist/objects/lighting/occluder.d.ts +34 -0
- package/dist/objects/lighting/occluder.js +62 -0
- package/dist/objects/lighting/occlusion-targets.d.ts +143 -0
- package/dist/objects/lighting/occlusion-targets.js +276 -0
- package/dist/objects/lines/Lines.js +3 -1
- package/dist/objects/lines/line-container.d.ts +4 -4
- package/dist/objects/materials/ColorMaterial.d.ts +58 -51
- package/dist/objects/materials/ColorMaterial.js +74 -52
- package/dist/objects/materials/LineMaterial.d.ts +1 -1
- package/dist/objects/materials/LineMaterial.js +1 -1
- package/dist/objects/materials/ModelMaterial.d.ts +30 -18
- package/dist/objects/materials/ModelMaterial.js +68 -41
- package/dist/objects/materials/TextureMaterial.js +1 -1
- package/dist/objects/materials/effects/ao/ambient-occlusion-pass.d.ts +77 -0
- package/dist/objects/materials/effects/ao/ambient-occlusion-pass.js +296 -0
- package/dist/objects/materials/effects/ao/ambient-occlusion-patch.d.ts +29 -0
- package/dist/objects/materials/effects/ao/ambient-occlusion-patch.js +115 -0
- package/dist/objects/materials/effects/ao/blur-pass.d.ts +61 -0
- package/dist/objects/materials/effects/ao/blur-pass.js +101 -0
- package/dist/objects/materials/effects/ao/index.d.ts +129 -0
- package/dist/objects/materials/effects/ao/index.js +72 -0
- package/dist/objects/materials/{dim.d.ts → effects/color-dim.d.ts} +5 -5
- package/dist/objects/materials/{dim.js → effects/color-dim.js} +7 -25
- package/dist/objects/materials/effects/contact-shadow.d.ts +100 -0
- package/dist/objects/materials/effects/contact-shadow.js +167 -0
- package/dist/objects/materials/effects/effects-context.d.ts +52 -0
- package/dist/objects/materials/effects/effects-context.js +24 -0
- package/dist/objects/models/Models.js +20 -4
- package/dist/objects/models/model-container.d.ts +4 -20
- package/dist/objects/models/model-container.js +2 -22
- package/dist/objects/shapes/Shapes.js +20 -2
- package/dist/objects/shapes/shape-container.d.ts +3 -20
- package/dist/objects/shapes/shape-container.js +0 -21
- package/dist/objects/text/Texts.js +3 -1
- package/dist/objects/text/text-container.d.ts +6 -6
- package/dist/objects/text/text-container.js +4 -4
- package/dist/objects/text/text-layout.d.ts +2 -2
- package/dist/space/Scene.d.ts +3 -0
- package/dist/space/Scene.js +17 -5
- package/package.json +2 -2
- package/dist/objects/Lighting.d.ts +0 -20
- package/dist/objects/Lighting.js +0 -85
package/dist/Renderer.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { type Box } from '@expofp/geometry';
|
|
|
2
2
|
import { type HTMLAttributes, type ReactNode, type Ref } from 'react';
|
|
3
3
|
import { type ControlsConfig } from './controls';
|
|
4
4
|
import { type ExternalCanvasProps } from './external/ExternalCanvas';
|
|
5
|
+
import { type LightingProps } from './objects/lighting';
|
|
5
6
|
import { type CameraProps } from './space/Camera';
|
|
6
7
|
import { type SceneDef } from './types/defs';
|
|
7
8
|
import { type PointerMissedEventData } from './types/events';
|
|
@@ -60,6 +61,19 @@ export interface RendererProps extends HTMLAttributes<HTMLDivElement>, CameraPro
|
|
|
60
61
|
* without taking a gesture away.
|
|
61
62
|
*/
|
|
62
63
|
controls?: ControlsConfig;
|
|
64
|
+
/**
|
|
65
|
+
* The scene's lighting, and the darkening that rides with it: the rig's contrast and three
|
|
66
|
+
* colors, and a `shadow` object holding the shade both darkening terms blend toward and each
|
|
67
|
+
* term's own numbers. See {@link LightingProps}.
|
|
68
|
+
*
|
|
69
|
+
* Every value is optional and every omitted one keeps the design's own default, so a caller sets
|
|
70
|
+
* the one number a plan needs and nothing else. Where the key light points is not here: that is
|
|
71
|
+
* the design's decision, and the debug GUI keeps it.
|
|
72
|
+
*
|
|
73
|
+
* Changing a value moves a mounted scene with no remount and no shader recompile. It lands on a
|
|
74
|
+
* uniform or on a field the frame reads, and asks for a redraw.
|
|
75
|
+
*/
|
|
76
|
+
lighting?: LightingProps;
|
|
63
77
|
/**
|
|
64
78
|
* The part of the canvas the plan should be framed inside, in css pixels from its top-left
|
|
65
79
|
* corner — for a host whose own header, sheet or panel covers the rest.
|
package/dist/Renderer.js
CHANGED
|
@@ -24,12 +24,12 @@ export function Renderer(props) {
|
|
|
24
24
|
// attributes — which is what React warns about, and the reason every member of `CameraProps` has
|
|
25
25
|
// to be named here as well as reassembled below. They are passed on untouched: what an omitted
|
|
26
26
|
// one means is `Camera`'s to say, and it is the only place that says it.
|
|
27
|
-
const { debug, scene, memoryLimit, minZoom, maxZoom, minPitch, maxPitch, bounds, smoothTime, controls, visibleRect, onPointerMissed, gl, requestFrame, onFrame, children, ...canvasProps } = props;
|
|
27
|
+
const { debug, scene, memoryLimit, minZoom, maxZoom, minPitch, maxPitch, bounds, smoothTime, controls, lighting, visibleRect, onPointerMissed, gl, requestFrame, onFrame, children, ...canvasProps } = props;
|
|
28
28
|
const cameraProps = { minZoom, maxZoom, minPitch, maxPitch, bounds, smoothTime };
|
|
29
29
|
const external = gl !== undefined;
|
|
30
30
|
// The one tree, whichever canvas it lands on. The mount decides nothing about it; the tree
|
|
31
31
|
// leaves out what external mode has no object for — the controls here, the camera inside Scene.
|
|
32
|
-
const tree = (_jsx(DebugOverlay, { enabled: debug, children: _jsxs(Scene, { sceneDef: scene, external: external, memoryLimit: memoryLimit, visibleRect: visibleRect, ...cameraProps, children: [!external && _jsx(Controls, { config: controls }), _jsx(PointerMissed, { onPointerMissed: onPointerMissed }), children] }) }));
|
|
32
|
+
const tree = (_jsx(DebugOverlay, { enabled: debug, children: _jsxs(Scene, { sceneDef: scene, external: external, memoryLimit: memoryLimit, lighting: lighting, visibleRect: visibleRect, ...cameraProps, children: [!external && _jsx(Controls, { config: controls }), _jsx(PointerMissed, { onPointerMissed: onPointerMissed }), children] }) }));
|
|
33
33
|
// The host's context arriving is what selects external mode. The mount swap is an element-type
|
|
34
34
|
// change, so flipping modes at runtime remounts — like `debug`, both are fixed for a renderer's
|
|
35
35
|
// lifetime in practice.
|
|
@@ -43,11 +43,23 @@ export function Renderer(props) {
|
|
|
43
43
|
return (_jsx(ExternalCanvas, { gl: gl, requestFrame: requestFrame, onFrame: onFrame, children: tree }));
|
|
44
44
|
}
|
|
45
45
|
return (_jsx(StrictMode, { children: _jsx(Suspense, { fallback: null, children: _jsx(CanvasWithDebug, { ...canvasProps, debugEnabled: debug,
|
|
46
|
-
//
|
|
46
|
+
// R3F force-writes ACES filmic tone mapping onto a fresh renderer unless `flat` is set,
|
|
47
|
+
// which lands it on three's own default, `NoToneMapping`, instead. This renderer does not
|
|
48
|
+
// tone map: `Lighting` keeps the rig's light sum in range by construction, rather than
|
|
49
|
+
// compressing an unbounded one back into range afterward.
|
|
47
50
|
flat: true,
|
|
48
51
|
// three leaves the stencil buffer off by default. Line layers need one: it is how they keep
|
|
49
52
|
// translucent lines from darkening where they overlap (see `LineMaterial`), and without the
|
|
50
53
|
// buffer the stencil settings silently do nothing. In the MapLibre embed the context is the
|
|
51
54
|
// map's own, which already has one.
|
|
52
|
-
gl: { stencil: true },
|
|
55
|
+
gl: { stencil: true },
|
|
56
|
+
// three reads a program's info log straight after linking it, and that read blocks until
|
|
57
|
+
// the driver has finished linking. Left to itself the driver links in the background,
|
|
58
|
+
// because `KHR_parallel_shader_compile` is there, so the check is the whole of what makes
|
|
59
|
+
// a compile synchronous: 17 programs cost 64 ms of main thread on a large scene, in
|
|
60
|
+
// blocks of up to 12 ms, and they land in the frames where the layers are still mounting.
|
|
61
|
+
// Debug keeps the check, because a broken shader has to report itself somewhere.
|
|
62
|
+
onCreated: (state) => {
|
|
63
|
+
state.gl.debug.checkShaderErrors = debug ?? false;
|
|
64
|
+
}, frameloop: debug ? 'always' : 'demand', resize: { debounce: 50 }, children: tree }) }) }));
|
|
53
65
|
}
|
|
@@ -91,8 +91,8 @@ export declare function getSquareTextureInfo(arrayType: TypedArrayConstructor, c
|
|
|
91
91
|
* 2. **The index varying is always `float`**, so `getUniformsGLSL` no longer takes an index type.
|
|
92
92
|
* It follows from the first: GLSL ES 3.00 requires integer varyings to be `flat`, so an index
|
|
93
93
|
* that is not float could not have the qualifier removed. **Callers must therefore hand it a float
|
|
94
|
-
* index** — `
|
|
95
|
-
* `
|
|
94
|
+
* index** — `BatchedMeshImpl` does, from three's own `getIndirectIndex( gl_DrawID )`, and
|
|
95
|
+
* `InstancedMeshImpl` does, from the float index texture that replaced upstream's `uint` attribute.
|
|
96
96
|
* 3. **`clone` and `copy` produce an independent texture.** See each method.
|
|
97
97
|
*/
|
|
98
98
|
export declare class SquareDataTexture extends DataTexture {
|
|
@@ -68,8 +68,8 @@ export function getSquareTextureInfo(arrayType, channels, pixelsPerInstance, cap
|
|
|
68
68
|
* 2. **The index varying is always `float`**, so `getUniformsGLSL` no longer takes an index type.
|
|
69
69
|
* It follows from the first: GLSL ES 3.00 requires integer varyings to be `flat`, so an index
|
|
70
70
|
* that is not float could not have the qualifier removed. **Callers must therefore hand it a float
|
|
71
|
-
* index** — `
|
|
72
|
-
* `
|
|
71
|
+
* index** — `BatchedMeshImpl` does, from three's own `getIndirectIndex( gl_DrawID )`, and
|
|
72
|
+
* `InstancedMeshImpl` does, from the float index texture that replaced upstream's `uint` attribute.
|
|
73
73
|
* 3. **`clone` and `copy` produce an independent texture.** See each method.
|
|
74
74
|
*/
|
|
75
75
|
export class SquareDataTexture extends DataTexture {
|
|
@@ -19,8 +19,8 @@ import { type UniformValue, type UniformValueObj } from '../SquareDataTexture';
|
|
|
19
19
|
* - **Bounds invalidate themselves.** Every mutation that can move the mesh's extents nulls the
|
|
20
20
|
* cached bounds, so callers cannot forget; three's frustum test recomputes a null one on demand.
|
|
21
21
|
*/
|
|
22
|
-
export declare class
|
|
23
|
-
/** Per-instance uniform store, shared with {@link
|
|
22
|
+
export declare class BatchedMeshImpl extends BatchedMeshBase {
|
|
23
|
+
/** Per-instance uniform store, shared with {@link InstancedMeshImpl}. */
|
|
24
24
|
private readonly uniforms;
|
|
25
25
|
/** The material whose `onBeforeCompile` is already wrapped, so it is wrapped exactly once. */
|
|
26
26
|
private patchedMaterial;
|
|
@@ -70,5 +70,5 @@ export declare class BatchedMeshExt extends BatchedMeshBase {
|
|
|
70
70
|
* Registers the class as an R3F element, by value so the generated key cannot collide with the
|
|
71
71
|
* `BatchedMesh` three already puts in the catalog when the canvas mounts.
|
|
72
72
|
*/
|
|
73
|
-
export declare const BatchedMesh: import("react").ExoticComponent<import("@react-three/fiber/dist/declarations/src/core/utils").Mutable<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<Partial<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<
|
|
73
|
+
export declare const BatchedMesh: import("react").ExoticComponent<import("@react-three/fiber/dist/declarations/src/core/utils").Mutable<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<Partial<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<BatchedMeshImpl, import("@react-three/fiber").MathProps<BatchedMeshImpl> & import("@react-three/fiber").ReactProps<BatchedMeshImpl> & Partial<import("@react-three/fiber").EventHandlers>>>, Omit<import("@react-three/fiber").InstanceProps<BatchedMeshImpl, typeof BatchedMeshImpl>, "object">>>>;
|
|
74
74
|
//# sourceMappingURL=BatchedMesh.d.ts.map
|
|
@@ -20,8 +20,8 @@ import { openMain } from '../shader-source';
|
|
|
20
20
|
* - **Bounds invalidate themselves.** Every mutation that can move the mesh's extents nulls the
|
|
21
21
|
* cached bounds, so callers cannot forget; three's frustum test recomputes a null one on demand.
|
|
22
22
|
*/
|
|
23
|
-
export class
|
|
24
|
-
/** Per-instance uniform store, shared with {@link
|
|
23
|
+
export class BatchedMeshImpl extends BatchedMeshBase {
|
|
24
|
+
/** Per-instance uniform store, shared with {@link InstancedMeshImpl}. */
|
|
25
25
|
uniforms = new InstanceUniforms();
|
|
26
26
|
/** The material whose `onBeforeCompile` is already wrapped, so it is wrapped exactly once. */
|
|
27
27
|
patchedMaterial = null;
|
|
@@ -146,4 +146,4 @@ export class BatchedMeshExt extends BatchedMeshBase {
|
|
|
146
146
|
* Registers the class as an R3F element, by value so the generated key cannot collide with the
|
|
147
147
|
* `BatchedMesh` three already puts in the catalog when the canvas mounts.
|
|
148
148
|
*/
|
|
149
|
-
export const BatchedMesh = extend(
|
|
149
|
+
export const BatchedMesh = extend(BatchedMeshImpl);
|
|
@@ -3,8 +3,8 @@ import { type UniformSchemaShader } from '../InstanceUniforms';
|
|
|
3
3
|
import { type UniformValue, type UniformValueObj } from '../SquareDataTexture';
|
|
4
4
|
import { FrustumCulling } from './FrustumCulling';
|
|
5
5
|
import { Raycasting } from './Raycasting';
|
|
6
|
-
/** Constructor options for {@link
|
|
7
|
-
export interface
|
|
6
|
+
/** Constructor options for {@link InstancedMeshImpl}. */
|
|
7
|
+
export interface InstancedMeshImplParams {
|
|
8
8
|
/** Initial instance capacity; the buffers grow past it on demand. */
|
|
9
9
|
capacity?: number;
|
|
10
10
|
}
|
|
@@ -34,10 +34,10 @@ export type CustomSortFn = (list: InstancedRenderItem[]) => void;
|
|
|
34
34
|
* - **Batched-style texture handling.** The data textures bind as ordinary shader uniforms and
|
|
35
35
|
* flush through {@link SquareDataTexture.update}, so there is no manual texture-unit binding,
|
|
36
36
|
* `updateTextures`/`bindTextures` split, or `PropertiesOverride` — the vendored texture already
|
|
37
|
-
* works this way for `
|
|
37
|
+
* works this way for `BatchedMeshImpl`.
|
|
38
38
|
* - **The draw list is a texture, not a vertex attribute.** Upstream stamps a `uint` index attribute
|
|
39
39
|
* onto whatever geometry it is handed; this fetches the instance id by `gl_InstanceID` from a texture of
|
|
40
|
-
* its own, the way `
|
|
40
|
+
* its own, the way `BatchedMeshImpl` resolves `gl_DrawID`. So the mesh never writes to a geometry it
|
|
41
41
|
* does not own — several may draw one cached geometry — and the cull list flushes through
|
|
42
42
|
* {@link SquareDataTexture.update} in `onBeforeRender` like every other per-instance buffer, rather
|
|
43
43
|
* than needing an attribute that owns its GL buffer to beat three's upload in `projectObject`. It
|
|
@@ -53,7 +53,7 @@ export type CustomSortFn = (list: InstancedRenderItem[]) => void;
|
|
|
53
53
|
*
|
|
54
54
|
* Render it with {@link InstancedMesh}.
|
|
55
55
|
*/
|
|
56
|
-
export declare class
|
|
56
|
+
export declare class InstancedMeshImpl extends Mesh<BufferGeometry, Material | Material[], Object3DEventMap & {
|
|
57
57
|
dispose: object;
|
|
58
58
|
}> {
|
|
59
59
|
/**
|
|
@@ -110,7 +110,7 @@ export declare class InstancedMeshExt extends Mesh<BufferGeometry, Material | Ma
|
|
|
110
110
|
private drawList;
|
|
111
111
|
/** Puts back what {@link patchInstancedMaterial} wrapped; null between draws. */
|
|
112
112
|
private _unpatchMaterial;
|
|
113
|
-
constructor(params?:
|
|
113
|
+
constructor(params?: InstancedMeshImplParams);
|
|
114
114
|
/**
|
|
115
115
|
* The instance capacity the textures currently hold.
|
|
116
116
|
*/
|
|
@@ -298,5 +298,5 @@ export declare class InstancedMeshExt extends Mesh<BufferGeometry, Material | Ma
|
|
|
298
298
|
* Registers the class as an R3F element, by value so the generated key cannot collide with the
|
|
299
299
|
* `InstancedMesh` three already puts in the catalog when the canvas mounts.
|
|
300
300
|
*/
|
|
301
|
-
export declare const InstancedMesh: import("react").ExoticComponent<import("@react-three/fiber/dist/declarations/src/core/utils").Mutable<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<Partial<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<
|
|
301
|
+
export declare const InstancedMesh: import("react").ExoticComponent<import("@react-three/fiber/dist/declarations/src/core/utils").Mutable<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<Partial<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<InstancedMeshImpl, import("@react-three/fiber").MathProps<InstancedMeshImpl> & import("@react-three/fiber").ReactProps<InstancedMeshImpl> & Partial<import("@react-three/fiber").EventHandlers>>>, Omit<import("@react-three/fiber").InstanceProps<InstancedMeshImpl, typeof InstancedMeshImpl>, "object">>>>;
|
|
302
302
|
//# sourceMappingURL=InstancedMesh.d.ts.map
|
|
@@ -26,10 +26,10 @@ patchInstancedShaderChunks();
|
|
|
26
26
|
* - **Batched-style texture handling.** The data textures bind as ordinary shader uniforms and
|
|
27
27
|
* flush through {@link SquareDataTexture.update}, so there is no manual texture-unit binding,
|
|
28
28
|
* `updateTextures`/`bindTextures` split, or `PropertiesOverride` — the vendored texture already
|
|
29
|
-
* works this way for `
|
|
29
|
+
* works this way for `BatchedMeshImpl`.
|
|
30
30
|
* - **The draw list is a texture, not a vertex attribute.** Upstream stamps a `uint` index attribute
|
|
31
31
|
* onto whatever geometry it is handed; this fetches the instance id by `gl_InstanceID` from a texture of
|
|
32
|
-
* its own, the way `
|
|
32
|
+
* its own, the way `BatchedMeshImpl` resolves `gl_DrawID`. So the mesh never writes to a geometry it
|
|
33
33
|
* does not own — several may draw one cached geometry — and the cull list flushes through
|
|
34
34
|
* {@link SquareDataTexture.update} in `onBeforeRender` like every other per-instance buffer, rather
|
|
35
35
|
* than needing an attribute that owns its GL buffer to beat three's upload in `projectObject`. It
|
|
@@ -45,7 +45,7 @@ patchInstancedShaderChunks();
|
|
|
45
45
|
*
|
|
46
46
|
* Render it with {@link InstancedMesh}.
|
|
47
47
|
*/
|
|
48
|
-
export class
|
|
48
|
+
export class InstancedMeshImpl extends Mesh {
|
|
49
49
|
/**
|
|
50
50
|
* The number of instances rendered in the last frame.
|
|
51
51
|
* @default 0
|
|
@@ -489,7 +489,7 @@ export class InstancedMeshExt extends Mesh {
|
|
|
489
489
|
* Registers the class as an R3F element, by value so the generated key cannot collide with the
|
|
490
490
|
* `InstancedMesh` three already puts in the catalog when the canvas mounts.
|
|
491
491
|
*/
|
|
492
|
-
export const InstancedMesh = extend(
|
|
492
|
+
export const InstancedMesh = extend(InstancedMeshImpl);
|
|
493
493
|
const DEFAULT_CAPACITY = 1000;
|
|
494
494
|
const _matrix = new Matrix4();
|
|
495
495
|
const _color = new Color();
|
|
@@ -55,7 +55,7 @@ const INSTANCED_DECLARATIONS = /* glsl */ `
|
|
|
55
55
|
* The matrix is declared here rather than where the transform chunks use it, so it lands in `main`
|
|
56
56
|
* whether or not the material includes those chunks. It shadows the `attribute mat4 instanceMatrix`
|
|
57
57
|
* three declares for any `isInstancedMesh` object — which is what the placeholder attribute on
|
|
58
|
-
* `
|
|
58
|
+
* `InstancedMeshImpl` exists to satisfy — and a material doing its own transform simply never reads
|
|
59
59
|
* it.
|
|
60
60
|
*/
|
|
61
61
|
const INSTANCED_RESOLVE = /* glsl */ `
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Box3, type BufferGeometry, type Camera, type Group, type Material, type Scene, type Sphere, Vector3, type Vector3Like, type WebGLRenderer } from 'three';
|
|
2
2
|
import { LineMaterial } from 'three/addons/lines/LineMaterial.js';
|
|
3
3
|
import { LineSegmentsGeometry } from 'three/addons/lines/LineSegmentsGeometry.js';
|
|
4
|
-
import {
|
|
4
|
+
import { InstancedMeshImpl, type InstancedMeshImplParams } from '../instanced/InstancedMesh';
|
|
5
5
|
import { FrustumCulling } from './FrustumCulling';
|
|
6
6
|
import { Raycasting } from './Raycasting';
|
|
7
7
|
/**
|
|
@@ -31,7 +31,7 @@ import { Raycasting } from './Raycasting';
|
|
|
31
31
|
*
|
|
32
32
|
* Render it with {@link BatchedLines}.
|
|
33
33
|
*/
|
|
34
|
-
export declare class
|
|
34
|
+
export declare class BatchedLinesImpl extends InstancedMeshImpl {
|
|
35
35
|
/**
|
|
36
36
|
* The segment template every member is drawn from, and the whole of what the geometry carries: the
|
|
37
37
|
* per-instance data three would put in instanced attributes is in the uniforms instead.
|
|
@@ -58,7 +58,7 @@ export declare class BatchedLinesExt extends InstancedMeshExt {
|
|
|
58
58
|
/**
|
|
59
59
|
* @param params - Instance capacity; the buffers grow past it on demand.
|
|
60
60
|
*/
|
|
61
|
-
constructor(params?:
|
|
61
|
+
constructor(params?: InstancedMeshImplParams);
|
|
62
62
|
/**
|
|
63
63
|
* Reads a member's endpoints.
|
|
64
64
|
* @param id - The member to read.
|
|
@@ -131,5 +131,5 @@ export declare class BatchedLinesExt extends InstancedMeshExt {
|
|
|
131
131
|
* Registers the class as an R3F element, by value so the generated key cannot collide with anything
|
|
132
132
|
* three puts in the catalog when the canvas mounts.
|
|
133
133
|
*/
|
|
134
|
-
export declare const BatchedLines: import("react").ExoticComponent<import("@react-three/fiber/dist/declarations/src/core/utils").Mutable<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<Partial<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<
|
|
134
|
+
export declare const BatchedLines: import("react").ExoticComponent<import("@react-three/fiber/dist/declarations/src/core/utils").Mutable<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<Partial<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<BatchedLinesImpl, import("@react-three/fiber").MathProps<BatchedLinesImpl> & import("@react-three/fiber").ReactProps<BatchedLinesImpl> & Partial<import("@react-three/fiber").EventHandlers>>>, Omit<import("@react-three/fiber").InstanceProps<BatchedLinesImpl, typeof BatchedLinesImpl>, "object">>>>;
|
|
135
135
|
//# sourceMappingURL=BatchedLines.d.ts.map
|
|
@@ -2,7 +2,7 @@ import { extend } from '@react-three/fiber';
|
|
|
2
2
|
import { Vector3, Vector4, } from 'three';
|
|
3
3
|
import { LineMaterial } from 'three/addons/lines/LineMaterial.js';
|
|
4
4
|
import { LineSegmentsGeometry } from 'three/addons/lines/LineSegmentsGeometry.js';
|
|
5
|
-
import {
|
|
5
|
+
import { InstancedMeshImpl } from '../instanced/InstancedMesh';
|
|
6
6
|
import { FrustumCulling } from './FrustumCulling';
|
|
7
7
|
import { END_UNIFORM, patchLineMaterial, START_UNIFORM, WIDTH_UNIFORM } from './lines-material';
|
|
8
8
|
import { Raycasting } from './Raycasting';
|
|
@@ -33,7 +33,7 @@ import { Raycasting } from './Raycasting';
|
|
|
33
33
|
*
|
|
34
34
|
* Render it with {@link BatchedLines}.
|
|
35
35
|
*/
|
|
36
|
-
export class
|
|
36
|
+
export class BatchedLinesImpl extends InstancedMeshImpl {
|
|
37
37
|
/**
|
|
38
38
|
* The segment template every member is drawn from, and the whole of what the geometry carries: the
|
|
39
39
|
* per-instance data three would put in instanced attributes is in the uniforms instead.
|
|
@@ -188,7 +188,7 @@ export class BatchedLinesExt extends InstancedMeshExt {
|
|
|
188
188
|
* Registers the class as an R3F element, by value so the generated key cannot collide with anything
|
|
189
189
|
* three puts in the catalog when the canvas mounts.
|
|
190
190
|
*/
|
|
191
|
-
export const BatchedLines = extend(
|
|
191
|
+
export const BatchedLines = extend(BatchedLinesImpl);
|
|
192
192
|
/**
|
|
193
193
|
* Whether a material is one three's line shader compiles from.
|
|
194
194
|
* @param material - The material three is about to draw with.
|
|
@@ -199,7 +199,7 @@ function isLineMaterial(material) {
|
|
|
199
199
|
}
|
|
200
200
|
/**
|
|
201
201
|
* The width a member starts at: negative, which is how "none of its own" is marked, so it draws at
|
|
202
|
-
* the material's. See {@link
|
|
202
|
+
* the material's. See {@link BatchedLinesImpl.setWidthAt} for why the marker is a negative value and
|
|
203
203
|
* not zero.
|
|
204
204
|
*/
|
|
205
205
|
const MATERIAL_WIDTH = -1;
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
* Both helpers throw when they cannot find it, for the same reason: what reaches the driver
|
|
12
12
|
* otherwise is a compile error naming an undeclared identifier, a long way from the patch that
|
|
13
13
|
* failed to declare it.
|
|
14
|
+
*
|
|
15
|
+
* {@link sceneColorAnchor} is not about `main`, but it answers the same kind of question: where in a
|
|
16
|
+
* shader's own text a patch belongs.
|
|
14
17
|
*/
|
|
15
18
|
/**
|
|
16
19
|
* Declares GLSL above `main`, where file-scope declarations belong — samplers, varyings, functions.
|
|
@@ -47,4 +50,21 @@ export declare function openMain(source: string, glsl: string): string;
|
|
|
47
50
|
* @throws {Error} If the source does not contain the anchor.
|
|
48
51
|
*/
|
|
49
52
|
export declare function replaceAnchor(source: string, anchor: string, glsl: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Where the fragment's **scene** color is final: the line a patch that changes the scene must land
|
|
55
|
+
* in front of.
|
|
56
|
+
*
|
|
57
|
+
* `<opaque_fragment>` writes the scene color, and three's output chain follows it — tone mapping,
|
|
58
|
+
* the colorspace conversion, fog, dithering. This returns the first of those. A patch below any of
|
|
59
|
+
* them would edit a value the chain already transformed, so its strength would depend on how bright
|
|
60
|
+
* the pixel already was.
|
|
61
|
+
*
|
|
62
|
+
* Two spellings, because three resolves `#include` after every `onBeforeCompile` while troika
|
|
63
|
+
* resolves it earlier, in its own rebuild of `main`. The expanded spelling is the `#if` line rather
|
|
64
|
+
* than the tone-mapping line inside it: the renderer pins `NoToneMapping`, which leaves
|
|
65
|
+
* `TONE_MAPPING` undefined, and the preprocessor then strips that block and anything put in it.
|
|
66
|
+
* @param fragmentShader - The shader to search.
|
|
67
|
+
* @returns The anchor found, or `undefined` if the shader has no output chain.
|
|
68
|
+
*/
|
|
69
|
+
export declare function sceneColorAnchor(fragmentShader: string): string | undefined;
|
|
50
70
|
//# sourceMappingURL=shader-source.d.ts.map
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
* Both helpers throw when they cannot find it, for the same reason: what reaches the driver
|
|
12
12
|
* otherwise is a compile error naming an undeclared identifier, a long way from the patch that
|
|
13
13
|
* failed to declare it.
|
|
14
|
+
*
|
|
15
|
+
* {@link sceneColorAnchor} is not about `main`, but it answers the same kind of question: where in a
|
|
16
|
+
* shader's own text a patch belongs.
|
|
14
17
|
*/
|
|
15
18
|
/**
|
|
16
19
|
* Declares GLSL above `main`, where file-scope declarations belong — samplers, varyings, functions.
|
|
@@ -56,6 +59,29 @@ export function replaceAnchor(source, anchor, glsl) {
|
|
|
56
59
|
throw new Error(`shader-source: the shader has no "${anchor}" to rewrite.`);
|
|
57
60
|
return source.slice(0, at) + glsl + source.slice(at + anchor.length);
|
|
58
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Where the fragment's **scene** color is final: the line a patch that changes the scene must land
|
|
64
|
+
* in front of.
|
|
65
|
+
*
|
|
66
|
+
* `<opaque_fragment>` writes the scene color, and three's output chain follows it — tone mapping,
|
|
67
|
+
* the colorspace conversion, fog, dithering. This returns the first of those. A patch below any of
|
|
68
|
+
* them would edit a value the chain already transformed, so its strength would depend on how bright
|
|
69
|
+
* the pixel already was.
|
|
70
|
+
*
|
|
71
|
+
* Two spellings, because three resolves `#include` after every `onBeforeCompile` while troika
|
|
72
|
+
* resolves it earlier, in its own rebuild of `main`. The expanded spelling is the `#if` line rather
|
|
73
|
+
* than the tone-mapping line inside it: the renderer pins `NoToneMapping`, which leaves
|
|
74
|
+
* `TONE_MAPPING` undefined, and the preprocessor then strips that block and anything put in it.
|
|
75
|
+
* @param fragmentShader - The shader to search.
|
|
76
|
+
* @returns The anchor found, or `undefined` if the shader has no output chain.
|
|
77
|
+
*/
|
|
78
|
+
export function sceneColorAnchor(fragmentShader) {
|
|
79
|
+
const include = /*glsl*/ `#include <tonemapping_fragment>`;
|
|
80
|
+
const expanded = /*glsl*/ `#if defined( TONE_MAPPING )`;
|
|
81
|
+
if (fragmentShader.includes(include))
|
|
82
|
+
return include;
|
|
83
|
+
return fragmentShader.includes(expanded) ? expanded : undefined;
|
|
84
|
+
}
|
|
59
85
|
/**
|
|
60
86
|
* Rewrites the first opening of `main`, splicing rather than replacing — so a `$` in the injected
|
|
61
87
|
* GLSL cannot be read as a replacement pattern.
|
|
@@ -2,7 +2,7 @@ import { type BufferGeometry, type Camera, type Intersection, type Material, typ
|
|
|
2
2
|
import { BatchedText as TroikaBatchedText, type TextMaterial } from 'troika-three-text';
|
|
3
3
|
import { type UniformSchemaShader } from '../InstanceUniforms';
|
|
4
4
|
import { type UniformValue, type UniformValueObj } from '../SquareDataTexture';
|
|
5
|
-
import { type
|
|
5
|
+
import { type TextImpl } from './Text';
|
|
6
6
|
/**
|
|
7
7
|
* troika's `BatchedText` with stable member ids, explicit paint order, and per-instance uniforms.
|
|
8
8
|
*
|
|
@@ -24,7 +24,7 @@ import { type TextExt } from './Text';
|
|
|
24
24
|
* Other departures from upstream:
|
|
25
25
|
*
|
|
26
26
|
* - **Sync is flag-driven, not scanned.** Members report property writes through
|
|
27
|
-
* `
|
|
27
|
+
* `TextImpl._batchParent`, so an idle frame costs nothing instead of walking every member.
|
|
28
28
|
* - **Per-member frustum culling and visibility**, by zeroing a hidden member's matrix so its glyphs
|
|
29
29
|
* collapse to a degenerate triangle. See {@link MemberTexture}.
|
|
30
30
|
* - **Bounds are cached**, recomputed only when {@link invalidateBounds} says they moved, where
|
|
@@ -34,7 +34,7 @@ import { type TextExt } from './Text';
|
|
|
34
34
|
* - **The derived material inherits the base's `transparent`**, rather than troika forcing it true.
|
|
35
35
|
* See {@link configureDerivedMaterial}.
|
|
36
36
|
*
|
|
37
|
-
* **Not built on {@link
|
|
37
|
+
* **Not built on {@link InstancedMeshImpl}'s machinery**, despite the family resemblance. That mesh
|
|
38
38
|
* draws one shared geometry through a per-frame list of instance ids, so it culls and sorts by
|
|
39
39
|
* rewriting the list; here draw order *is* the order glyph runs sit in the attributes, so a reorder
|
|
40
40
|
* costs a repack and culling collapses a matrix row instead. Its members are real objects carrying
|
|
@@ -42,14 +42,14 @@ import { type TextExt } from './Text';
|
|
|
42
42
|
* per member rather than in bulk by count, and visibility rides on the member's own `visible`. What
|
|
43
43
|
* the two genuinely share is {@link InstanceUniforms}.
|
|
44
44
|
*
|
|
45
|
-
* Members must be {@link
|
|
45
|
+
* Members must be {@link TextImpl}, and are assumed to agree on `orientation` and `sdfGlyphSize`:
|
|
46
46
|
* both feed uniforms that are batch-wide rather than per-member, so mixing them across a batch
|
|
47
47
|
* leaves whichever member was written last in charge.
|
|
48
48
|
*
|
|
49
49
|
* Render it with {@link BatchedText}.
|
|
50
50
|
*/
|
|
51
|
-
export declare class
|
|
52
|
-
/** Per-instance uniform store, shared with {@link
|
|
51
|
+
export declare class BatchedTextImpl extends TroikaBatchedText {
|
|
52
|
+
/** Per-instance uniform store, shared with {@link BatchedMeshImpl} and {@link InstancedMeshImpl}. */
|
|
53
53
|
private readonly uniforms;
|
|
54
54
|
/** The per-member transform and style rows the batch's shader draws from. */
|
|
55
55
|
private readonly memberTexture;
|
|
@@ -76,7 +76,7 @@ export declare class BatchedTextExt extends TroikaBatchedText {
|
|
|
76
76
|
* hole.
|
|
77
77
|
*
|
|
78
78
|
* **A pure high-water mark: removing a member never pulls it back in**, unlike `Instances`, the
|
|
79
|
-
* equivalent for {@link
|
|
79
|
+
* equivalent for {@link InstancedMeshImpl}, which shrinks past trailing dead ids. Converting either
|
|
80
80
|
* to the other buys nothing. A dead row costs the sweeps here one array read and a `continue`; and
|
|
81
81
|
* this same number also sizes both textures, where `Instances` has a separate `capacity` for that
|
|
82
82
|
* — so shrinking it would reallocate the matrix and uniform textures every time the last member
|
|
@@ -85,10 +85,10 @@ export declare class BatchedTextExt extends TroikaBatchedText {
|
|
|
85
85
|
get addedMembersCount(): number;
|
|
86
86
|
/** The material whose `onBeforeCompile` is already wrapped, so it is wrapped exactly once. */
|
|
87
87
|
private patchedMaterial;
|
|
88
|
-
/** Marks the batch as needing a sync pass. Members call this through `
|
|
88
|
+
/** Marks the batch as needing a sync pass. Members call this through `TextImpl._batchParent`. */
|
|
89
89
|
requestSync(): void;
|
|
90
90
|
/**
|
|
91
|
-
* Marks the batch's bounds as stale. Members call this through `
|
|
91
|
+
* Marks the batch's bounds as stale. Members call this through `TextImpl._batchParent` whenever
|
|
92
92
|
* their transform changes, so no caller has to remember to.
|
|
93
93
|
*/
|
|
94
94
|
invalidateBounds(): void;
|
|
@@ -97,7 +97,7 @@ export declare class BatchedTextExt extends TroikaBatchedText {
|
|
|
97
97
|
* @param memberId - The member to read.
|
|
98
98
|
* @returns The member, or `undefined` when the id holds none.
|
|
99
99
|
*/
|
|
100
|
-
getText(memberId: number):
|
|
100
|
+
getText(memberId: number): TextImpl | undefined;
|
|
101
101
|
/**
|
|
102
102
|
* Shows or hides a member. A hidden member keeps its id and its glyphs; it is collapsed at draw
|
|
103
103
|
* time rather than repacked out, so hiding costs no repack.
|
|
@@ -119,7 +119,7 @@ export declare class BatchedTextExt extends TroikaBatchedText {
|
|
|
119
119
|
* @param texts - Every member, in paint order. Members missing from it are not drawn, and anything
|
|
120
120
|
* that is not a member is dropped.
|
|
121
121
|
*/
|
|
122
|
-
setOrder(texts: readonly
|
|
122
|
+
setOrder(texts: readonly TextImpl[]): void;
|
|
123
123
|
/**
|
|
124
124
|
* Declares per-instance uniforms, merging with any already declared and rebuilding the backing
|
|
125
125
|
* texture (existing values carried across). See {@link InstanceUniforms.add}.
|
|
@@ -147,8 +147,8 @@ export declare class BatchedTextExt extends TroikaBatchedText {
|
|
|
147
147
|
* @returns The member’s id — stable for as long as it stays in the batch, and the index every
|
|
148
148
|
* other method here takes.
|
|
149
149
|
*/
|
|
150
|
-
addText(text:
|
|
151
|
-
removeText(text:
|
|
150
|
+
addText(text: TextImpl): number;
|
|
151
|
+
removeText(text: TextImpl): void;
|
|
152
152
|
/**
|
|
153
153
|
* Copies the text-level properties, and deliberately not the membership.
|
|
154
154
|
*
|
|
@@ -223,5 +223,5 @@ export declare class BatchedTextExt extends TroikaBatchedText {
|
|
|
223
223
|
* Registers the class as an R3F element, by value so the generated key cannot collide with anything
|
|
224
224
|
* three puts in the catalog when the canvas mounts.
|
|
225
225
|
*/
|
|
226
|
-
export declare const BatchedText: import("react").ExoticComponent<import("@react-three/fiber/dist/declarations/src/core/utils").Mutable<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<Partial<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<
|
|
226
|
+
export declare const BatchedText: import("react").ExoticComponent<import("@react-three/fiber/dist/declarations/src/core/utils").Mutable<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<Partial<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<BatchedTextImpl, import("@react-three/fiber").MathProps<BatchedTextImpl> & import("@react-three/fiber").ReactProps<BatchedTextImpl> & Partial<import("@react-three/fiber").EventHandlers>>>, Omit<import("@react-three/fiber").InstanceProps<BatchedTextImpl, typeof BatchedTextImpl>, "object">>>>;
|
|
227
227
|
//# sourceMappingURL=BatchedText.d.ts.map
|
|
@@ -26,7 +26,7 @@ import { MemberTexture } from './MemberTexture';
|
|
|
26
26
|
* Other departures from upstream:
|
|
27
27
|
*
|
|
28
28
|
* - **Sync is flag-driven, not scanned.** Members report property writes through
|
|
29
|
-
* `
|
|
29
|
+
* `TextImpl._batchParent`, so an idle frame costs nothing instead of walking every member.
|
|
30
30
|
* - **Per-member frustum culling and visibility**, by zeroing a hidden member's matrix so its glyphs
|
|
31
31
|
* collapse to a degenerate triangle. See {@link MemberTexture}.
|
|
32
32
|
* - **Bounds are cached**, recomputed only when {@link invalidateBounds} says they moved, where
|
|
@@ -36,7 +36,7 @@ import { MemberTexture } from './MemberTexture';
|
|
|
36
36
|
* - **The derived material inherits the base's `transparent`**, rather than troika forcing it true.
|
|
37
37
|
* See {@link configureDerivedMaterial}.
|
|
38
38
|
*
|
|
39
|
-
* **Not built on {@link
|
|
39
|
+
* **Not built on {@link InstancedMeshImpl}'s machinery**, despite the family resemblance. That mesh
|
|
40
40
|
* draws one shared geometry through a per-frame list of instance ids, so it culls and sorts by
|
|
41
41
|
* rewriting the list; here draw order *is* the order glyph runs sit in the attributes, so a reorder
|
|
42
42
|
* costs a repack and culling collapses a matrix row instead. Its members are real objects carrying
|
|
@@ -44,14 +44,14 @@ import { MemberTexture } from './MemberTexture';
|
|
|
44
44
|
* per member rather than in bulk by count, and visibility rides on the member's own `visible`. What
|
|
45
45
|
* the two genuinely share is {@link InstanceUniforms}.
|
|
46
46
|
*
|
|
47
|
-
* Members must be {@link
|
|
47
|
+
* Members must be {@link TextImpl}, and are assumed to agree on `orientation` and `sdfGlyphSize`:
|
|
48
48
|
* both feed uniforms that are batch-wide rather than per-member, so mixing them across a batch
|
|
49
49
|
* leaves whichever member was written last in charge.
|
|
50
50
|
*
|
|
51
51
|
* Render it with {@link BatchedText}.
|
|
52
52
|
*/
|
|
53
|
-
export class
|
|
54
|
-
/** Per-instance uniform store, shared with {@link
|
|
53
|
+
export class BatchedTextImpl extends TroikaBatchedText {
|
|
54
|
+
/** Per-instance uniform store, shared with {@link BatchedMeshImpl} and {@link InstancedMeshImpl}. */
|
|
55
55
|
uniforms = new InstanceUniforms();
|
|
56
56
|
/** The per-member transform and style rows the batch's shader draws from. */
|
|
57
57
|
memberTexture = new MemberTexture();
|
|
@@ -85,7 +85,7 @@ export class BatchedTextExt extends TroikaBatchedText {
|
|
|
85
85
|
* hole.
|
|
86
86
|
*
|
|
87
87
|
* **A pure high-water mark: removing a member never pulls it back in**, unlike `Instances`, the
|
|
88
|
-
* equivalent for {@link
|
|
88
|
+
* equivalent for {@link InstancedMeshImpl}, which shrinks past trailing dead ids. Converting either
|
|
89
89
|
* to the other buys nothing. A dead row costs the sweeps here one array read and a `continue`; and
|
|
90
90
|
* this same number also sizes both textures, where `Instances` has a separate `capacity` for that
|
|
91
91
|
* — so shrinking it would reallocate the matrix and uniform textures every time the last member
|
|
@@ -96,12 +96,12 @@ export class BatchedTextExt extends TroikaBatchedText {
|
|
|
96
96
|
}
|
|
97
97
|
/** The material whose `onBeforeCompile` is already wrapped, so it is wrapped exactly once. */
|
|
98
98
|
patchedMaterial = null;
|
|
99
|
-
/** Marks the batch as needing a sync pass. Members call this through `
|
|
99
|
+
/** Marks the batch as needing a sync pass. Members call this through `TextImpl._batchParent`. */
|
|
100
100
|
requestSync() {
|
|
101
101
|
this.batchNeedsSync = true;
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
|
-
* Marks the batch's bounds as stale. Members call this through `
|
|
104
|
+
* Marks the batch's bounds as stale. Members call this through `TextImpl._batchParent` whenever
|
|
105
105
|
* their transform changes, so no caller has to remember to.
|
|
106
106
|
*/
|
|
107
107
|
invalidateBounds() {
|
|
@@ -456,7 +456,7 @@ export class BatchedTextExt extends TroikaBatchedText {
|
|
|
456
456
|
* Registers the class as an R3F element, by value so the generated key cannot collide with anything
|
|
457
457
|
* three puts in the catalog when the canvas mounts.
|
|
458
458
|
*/
|
|
459
|
-
export const BatchedText = extend(
|
|
459
|
+
export const BatchedText = extend(BatchedTextImpl);
|
|
460
460
|
// Reused rather than built per dispatch: three's `dispatchEvent` stamps `target` on the object it
|
|
461
461
|
// is handed, so these are one allocation for the batch's lifetime instead of one per event.
|
|
462
462
|
const syncStartEvent = { type: 'syncstart' };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Camera, type ColorRepresentation, Matrix4 } from 'three';
|
|
2
2
|
import { type BatchTextMaterial } from 'troika-three-text';
|
|
3
|
-
import { type
|
|
3
|
+
import { type TextImpl } from './Text';
|
|
4
4
|
/** What {@link MemberTexture} reads off the batch it fills for. */
|
|
5
5
|
export interface MemberTextureHost {
|
|
6
6
|
/**
|
|
@@ -18,7 +18,7 @@ export interface MemberTextureHost {
|
|
|
18
18
|
* @param memberId - The member to read.
|
|
19
19
|
* @returns The member, or `undefined` when the id holds none.
|
|
20
20
|
*/
|
|
21
|
-
getText(memberId: number):
|
|
21
|
+
getText(memberId: number): TextImpl | undefined;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* The data texture a batch's shader reads each member's transform and style from: one 32-float row
|
package/dist/core/text/Text.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Matrix4 } from 'three';
|
|
2
2
|
import { Text as TroikaText, type TextMaterial } from 'troika-three-text';
|
|
3
|
-
import { type
|
|
3
|
+
import { type BatchedTextImpl } from './BatchedText';
|
|
4
4
|
/**
|
|
5
5
|
* troika's `Text` with the deviations a batched, 2D-painter renderer needs.
|
|
6
6
|
*
|
|
@@ -30,13 +30,13 @@ import { type BatchedTextExt } from './BatchedText';
|
|
|
30
30
|
*
|
|
31
31
|
* Render it with {@link Text}.
|
|
32
32
|
*/
|
|
33
|
-
export declare class
|
|
33
|
+
export declare class TextImpl extends TroikaText {
|
|
34
34
|
/**
|
|
35
|
-
* The batch this text belongs to, set by {@link
|
|
35
|
+
* The batch this text belongs to, set by {@link BatchedTextImpl.addText}. It is how a member
|
|
36
36
|
* reaches its batch without the batch scanning for changes: property writes invalidate the sync
|
|
37
37
|
* through it, and transform writes invalidate the bounds.
|
|
38
38
|
*/
|
|
39
|
-
_batchParent:
|
|
39
|
+
_batchParent: BatchedTextImpl | undefined;
|
|
40
40
|
/**
|
|
41
41
|
* Backing store for the `_needsSync` accessor installed on the prototype below.
|
|
42
42
|
*
|
|
@@ -69,5 +69,5 @@ export declare class TextExt extends TroikaText {
|
|
|
69
69
|
* Registers the class as an R3F element, by value so the generated key cannot collide with anything
|
|
70
70
|
* three puts in the catalog when the canvas mounts.
|
|
71
71
|
*/
|
|
72
|
-
export declare const Text: import("react").ExoticComponent<import("@react-three/fiber/dist/declarations/src/core/utils").Mutable<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<Partial<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<
|
|
72
|
+
export declare const Text: import("react").ExoticComponent<import("@react-three/fiber/dist/declarations/src/core/utils").Mutable<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<Partial<import("@react-three/fiber/dist/declarations/src/core/utils").Overwrite<TextImpl, import("@react-three/fiber").MathProps<TextImpl> & import("@react-three/fiber").ReactProps<TextImpl> & Partial<import("@react-three/fiber").EventHandlers>>>, Omit<import("@react-three/fiber").InstanceProps<TextImpl, typeof TextImpl>, "object">>>>;
|
|
73
73
|
//# sourceMappingURL=Text.d.ts.map
|
package/dist/core/text/Text.js
CHANGED
|
@@ -30,9 +30,9 @@ import { Text as TroikaText } from 'troika-three-text';
|
|
|
30
30
|
*
|
|
31
31
|
* Render it with {@link Text}.
|
|
32
32
|
*/
|
|
33
|
-
export class
|
|
33
|
+
export class TextImpl extends TroikaText {
|
|
34
34
|
/**
|
|
35
|
-
* The batch this text belongs to, set by {@link
|
|
35
|
+
* The batch this text belongs to, set by {@link BatchedTextImpl.addText}. It is how a member
|
|
36
36
|
* reaches its batch without the batch scanning for changes: property writes invalidate the sync
|
|
37
37
|
* through it, and transform writes invalidate the bounds.
|
|
38
38
|
*/
|
|
@@ -189,7 +189,7 @@ export class TextExt extends TroikaText {
|
|
|
189
189
|
* Runs during `super()` — the base constructor seeds the syncable properties — at which point the
|
|
190
190
|
* `_batchParent` field initializer has not run yet, so the optional call is doing real work.
|
|
191
191
|
*/
|
|
192
|
-
Object.defineProperty(
|
|
192
|
+
Object.defineProperty(TextImpl.prototype, '_needsSync', {
|
|
193
193
|
configurable: true,
|
|
194
194
|
get() {
|
|
195
195
|
return this._syncFlag;
|
|
@@ -206,7 +206,7 @@ Object.defineProperty(TextExt.prototype, '_needsSync', {
|
|
|
206
206
|
* Registers the class as an R3F element, by value so the generated key cannot collide with anything
|
|
207
207
|
* three puts in the catalog when the canvas mounts.
|
|
208
208
|
*/
|
|
209
|
-
export const Text = extend(
|
|
209
|
+
export const Text = extend(TextImpl);
|
|
210
210
|
// Scratch reused across calls, each filled and consumed within a single synchronous block.
|
|
211
211
|
const _matrix = new Matrix4();
|
|
212
212
|
const _horizontal = new Vector3();
|