@expofp/renderer 0.0.0-experimental.2d6c681
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +145 -0
- package/dist/Renderer.d.ts +102 -0
- package/dist/Renderer.js +96 -0
- package/dist/controls/CameraControls.d.ts +108 -0
- package/dist/controls/CameraControls.js +203 -0
- package/dist/controls/Controls.d.ts +53 -0
- package/dist/controls/Controls.js +54 -0
- package/dist/controls/camera-api.d.ts +226 -0
- package/dist/controls/camera-api.js +179 -0
- package/dist/controls/gestures.d.ts +71 -0
- package/dist/controls/gestures.js +98 -0
- package/dist/controls/handlers/DoubleTapZoom.d.ts +23 -0
- package/dist/controls/handlers/DoubleTapZoom.js +82 -0
- package/dist/controls/handlers/Inertia.d.ts +60 -0
- package/dist/controls/handlers/Inertia.js +222 -0
- package/dist/controls/handlers/Pan.d.ts +23 -0
- package/dist/controls/handlers/Pan.js +212 -0
- package/dist/controls/handlers/Pitch.d.ts +19 -0
- package/dist/controls/handlers/Pitch.js +200 -0
- package/dist/controls/handlers/Roll.d.ts +30 -0
- package/dist/controls/handlers/Roll.js +196 -0
- package/dist/controls/handlers/Zoom.d.ts +28 -0
- package/dist/controls/handlers/Zoom.js +34 -0
- package/dist/controls/hooks.d.ts +136 -0
- package/dist/controls/hooks.js +200 -0
- package/dist/controls/index.d.ts +9 -0
- package/dist/controls/index.js +7 -0
- package/dist/controls/zoom-to.d.ts +89 -0
- package/dist/controls/zoom-to.js +91 -0
- package/dist/core/InstanceUniforms.d.ts +108 -0
- package/dist/core/InstanceUniforms.js +298 -0
- package/dist/core/SquareDataTexture.d.ts +277 -0
- package/dist/core/SquareDataTexture.js +476 -0
- package/dist/core/batch/BatchedMesh.d.ts +74 -0
- package/dist/core/batch/BatchedMesh.js +155 -0
- package/dist/core/instanced/FrustumCulling.d.ts +141 -0
- package/dist/core/instanced/FrustumCulling.js +246 -0
- package/dist/core/instanced/InstancedMesh.d.ts +302 -0
- package/dist/core/instanced/InstancedMesh.js +497 -0
- package/dist/core/instanced/Instances.d.ts +119 -0
- package/dist/core/instanced/Instances.js +230 -0
- package/dist/core/instanced/Raycasting.d.ts +118 -0
- package/dist/core/instanced/Raycasting.js +134 -0
- package/dist/core/instanced/instanced-material.d.ts +77 -0
- package/dist/core/instanced/instanced-material.js +228 -0
- package/dist/core/lines/BatchedLines.d.ts +137 -0
- package/dist/core/lines/BatchedLines.js +215 -0
- package/dist/core/lines/FrustumCullingLines.d.ts +44 -0
- package/dist/core/lines/FrustumCullingLines.js +85 -0
- package/dist/core/lines/RaycastingLines.d.ts +45 -0
- package/dist/core/lines/RaycastingLines.js +91 -0
- package/dist/core/lines/lines-material.d.ts +47 -0
- package/dist/core/lines/lines-material.js +124 -0
- package/dist/core/shader-source.d.ts +70 -0
- package/dist/core/shader-source.js +110 -0
- package/dist/core/sprites/BatchedSprites.d.ts +115 -0
- package/dist/core/sprites/BatchedSprites.js +173 -0
- package/dist/core/sprites/RaycastingSprites.d.ts +41 -0
- package/dist/core/sprites/RaycastingSprites.js +71 -0
- package/dist/core/sprites/sprite-material.d.ts +59 -0
- package/dist/core/sprites/sprite-material.js +192 -0
- package/dist/core/text/BatchedText.d.ts +233 -0
- package/dist/core/text/BatchedText.js +473 -0
- package/dist/core/text/MemberTexture.d.ts +90 -0
- package/dist/core/text/MemberTexture.js +289 -0
- package/dist/core/text/Text.d.ts +88 -0
- package/dist/core/text/Text.js +230 -0
- package/dist/core/text/batched-text-material.d.ts +56 -0
- package/dist/core/text/batched-text-material.js +123 -0
- package/dist/core/text/glyph-packing.d.ts +17 -0
- package/dist/core/text/glyph-packing.js +61 -0
- package/dist/core/typed-array.d.ts +16 -0
- package/dist/core/typed-array.js +20 -0
- package/dist/debug/components/DebugPanelProvider.d.ts +20 -0
- package/dist/debug/components/DebugPanelProvider.js +50 -0
- package/dist/debug/components/DebugTools.d.ts +22 -0
- package/dist/debug/components/DebugTools.js +28 -0
- package/dist/debug/components/Gui.d.ts +22 -0
- package/dist/debug/components/Gui.js +42 -0
- package/dist/debug/components/MemoryInfo.d.ts +22 -0
- package/dist/debug/components/MemoryInfo.js +42 -0
- package/dist/debug/components/Panel.d.ts +31 -0
- package/dist/debug/components/Panel.js +104 -0
- package/dist/debug/components/Stats.d.ts +9 -0
- package/dist/debug/components/Stats.js +24 -0
- package/dist/debug/debug-chunk.d.ts +26 -0
- package/dist/debug/debug-chunk.js +32 -0
- package/dist/debug/debug-context.d.ts +41 -0
- package/dist/debug/debug-context.js +59 -0
- package/dist/debug/index.d.ts +41 -0
- package/dist/debug/index.js +43 -0
- package/dist/events/LayoutDriver.d.ts +36 -0
- package/dist/events/LayoutDriver.js +192 -0
- package/dist/events/PointerMissed.d.ts +23 -0
- package/dist/events/PointerMissed.js +58 -0
- package/dist/events/def-culling.d.ts +46 -0
- package/dist/events/def-culling.js +69 -0
- package/dist/events/layout-targets.d.ts +151 -0
- package/dist/events/layout-targets.js +397 -0
- package/dist/events/placement/box.d.ts +59 -0
- package/dist/events/placement/box.js +96 -0
- package/dist/events/placement/grid.d.ts +161 -0
- package/dist/events/placement/grid.js +235 -0
- package/dist/events/placement/index.d.ts +2 -0
- package/dist/events/placement/index.js +1 -0
- package/dist/events/placement/pass.d.ts +70 -0
- package/dist/events/placement/pass.js +617 -0
- package/dist/events/pointer.d.ts +194 -0
- package/dist/events/pointer.js +356 -0
- package/dist/external/ExternalCanvas.d.ts +56 -0
- package/dist/external/ExternalCanvas.js +177 -0
- package/dist/external/external-camera.d.ts +18 -0
- package/dist/external/external-camera.js +103 -0
- package/dist/external/external-events.d.ts +14 -0
- package/dist/external/external-events.js +33 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +14 -0
- package/dist/objects/Background.d.ts +31 -0
- package/dist/objects/Background.js +37 -0
- package/dist/objects/containers/SlotContainer.d.ts +312 -0
- package/dist/objects/containers/SlotContainer.js +311 -0
- package/dist/objects/containers/hooks.d.ts +61 -0
- package/dist/objects/containers/hooks.js +196 -0
- package/dist/objects/containers/index.d.ts +6 -0
- package/dist/objects/containers/index.js +4 -0
- package/dist/objects/containers/keys.d.ts +10 -0
- package/dist/objects/containers/keys.js +18 -0
- package/dist/objects/containers/mesh-writes.d.ts +106 -0
- package/dist/objects/containers/mesh-writes.js +97 -0
- package/dist/objects/containers/props.d.ts +33 -0
- package/dist/objects/containers/props.js +1 -0
- package/dist/objects/images/ImageInstance.d.ts +29 -0
- package/dist/objects/images/ImageInstance.js +152 -0
- package/dist/objects/images/Images.d.ts +49 -0
- package/dist/objects/images/Images.js +394 -0
- package/dist/objects/images/atlas-packer.d.ts +129 -0
- package/dist/objects/images/atlas-packer.js +287 -0
- package/dist/objects/images/image-container.d.ts +74 -0
- package/dist/objects/images/image-container.js +100 -0
- package/dist/objects/images/index.d.ts +2 -0
- package/dist/objects/images/index.js +1 -0
- package/dist/objects/images/pack-sources.d.ts +190 -0
- package/dist/objects/images/pack-sources.js +272 -0
- package/dist/objects/images/texture-budget.d.ts +120 -0
- package/dist/objects/images/texture-budget.js +215 -0
- package/dist/objects/images/worker/atlas-worker.d.ts +56 -0
- package/dist/objects/images/worker/atlas-worker.js +123 -0
- package/dist/objects/images/worker/client.d.ts +62 -0
- package/dist/objects/images/worker/client.js +249 -0
- package/dist/objects/images/worker/index.d.ts +10 -0
- package/dist/objects/images/worker/index.js +1 -0
- package/dist/objects/layer/Layer.d.ts +28 -0
- package/dist/objects/layer/Layer.js +134 -0
- package/dist/objects/layer/index.d.ts +2 -0
- package/dist/objects/layer/index.js +1 -0
- package/dist/objects/layer/layer-context.d.ts +74 -0
- package/dist/objects/layer/layer-context.js +82 -0
- package/dist/objects/layer/mount-scheduler.d.ts +131 -0
- package/dist/objects/layer/mount-scheduler.js +289 -0
- package/dist/objects/layer/visibility-gui.d.ts +19 -0
- package/dist/objects/layer/visibility-gui.js +93 -0
- package/dist/objects/lighting/Lighting.d.ts +92 -0
- package/dist/objects/lighting/Lighting.js +384 -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/LineInstance.d.ts +21 -0
- package/dist/objects/lines/LineInstance.js +73 -0
- package/dist/objects/lines/Lines.d.ts +17 -0
- package/dist/objects/lines/Lines.js +31 -0
- package/dist/objects/lines/index.d.ts +2 -0
- package/dist/objects/lines/index.js +1 -0
- package/dist/objects/lines/line-container.d.ts +35 -0
- package/dist/objects/lines/line-container.js +40 -0
- package/dist/objects/materials/ColorMaterial.d.ts +92 -0
- package/dist/objects/materials/ColorMaterial.js +124 -0
- package/dist/objects/materials/LineMaterial.d.ts +44 -0
- package/dist/objects/materials/LineMaterial.js +74 -0
- package/dist/objects/materials/ModelMaterial.d.ts +53 -0
- package/dist/objects/materials/ModelMaterial.js +111 -0
- package/dist/objects/materials/TextureMaterial.d.ts +33 -0
- package/dist/objects/materials/TextureMaterial.js +48 -0
- 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/effects/color-dim.d.ts +115 -0
- package/dist/objects/materials/effects/color-dim.js +206 -0
- 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 +53 -0
- package/dist/objects/materials/effects/effects-context.js +24 -0
- package/dist/objects/materials/shared.d.ts +24 -0
- package/dist/objects/materials/shared.js +72 -0
- package/dist/objects/models/ModelInstance.d.ts +22 -0
- package/dist/objects/models/ModelInstance.js +33 -0
- package/dist/objects/models/Models.d.ts +22 -0
- package/dist/objects/models/Models.js +186 -0
- package/dist/objects/models/gltf-cache.d.ts +17 -0
- package/dist/objects/models/gltf-cache.js +50 -0
- package/dist/objects/models/index.d.ts +2 -0
- package/dist/objects/models/index.js +1 -0
- package/dist/objects/models/model-asset.d.ts +48 -0
- package/dist/objects/models/model-asset.js +77 -0
- package/dist/objects/models/model-container.d.ts +123 -0
- package/dist/objects/models/model-container.js +207 -0
- package/dist/objects/shapes/ShapeInstance.d.ts +26 -0
- package/dist/objects/shapes/ShapeInstance.js +39 -0
- package/dist/objects/shapes/Shapes.d.ts +21 -0
- package/dist/objects/shapes/Shapes.js +131 -0
- package/dist/objects/shapes/index.d.ts +2 -0
- package/dist/objects/shapes/index.js +1 -0
- package/dist/objects/shapes/shape-container.d.ts +141 -0
- package/dist/objects/shapes/shape-container.js +242 -0
- package/dist/objects/shapes/shape-geometry.d.ts +27 -0
- package/dist/objects/shapes/shape-geometry.js +94 -0
- package/dist/objects/text/TextInstance.d.ts +22 -0
- package/dist/objects/text/TextInstance.js +95 -0
- package/dist/objects/text/Texts.d.ts +30 -0
- package/dist/objects/text/Texts.js +43 -0
- package/dist/objects/text/index.d.ts +2 -0
- package/dist/objects/text/index.js +1 -0
- package/dist/objects/text/text-container.d.ts +121 -0
- package/dist/objects/text/text-container.js +229 -0
- package/dist/objects/text/text-layout.d.ts +92 -0
- package/dist/objects/text/text-layout.js +180 -0
- package/dist/space/Camera.d.ts +103 -0
- package/dist/space/Camera.js +321 -0
- package/dist/space/Scene.d.ts +47 -0
- package/dist/space/Scene.js +127 -0
- package/dist/space/Space.d.ts +325 -0
- package/dist/space/Space.js +359 -0
- package/dist/space/VisibleRect.d.ts +45 -0
- package/dist/space/VisibleRect.js +129 -0
- package/dist/space/camera-handle.d.ts +67 -0
- package/dist/space/camera-handle.js +63 -0
- package/dist/space/camera-kind.d.ts +26 -0
- package/dist/space/camera-kind.js +30 -0
- package/dist/space/canvas-size.d.ts +24 -0
- package/dist/space/canvas-size.js +20 -0
- package/dist/space/clipping.d.ts +69 -0
- package/dist/space/clipping.js +130 -0
- package/dist/space/layout-measure.d.ts +67 -0
- package/dist/space/layout-measure.js +175 -0
- package/dist/space/viewport.d.ts +112 -0
- package/dist/space/viewport.js +67 -0
- package/dist/types/defs.d.ts +234 -0
- package/dist/types/defs.js +1 -0
- package/dist/types/events.d.ts +198 -0
- package/dist/types/events.js +1 -0
- package/dist/types/guards.d.ts +21 -0
- package/dist/types/guards.js +52 -0
- package/dist/update/index.d.ts +3 -0
- package/dist/update/index.js +2 -0
- package/dist/update/slot-writers.d.ts +30 -0
- package/dist/update/slot-writers.js +76 -0
- package/dist/update/store.d.ts +41 -0
- package/dist/update/store.js +104 -0
- package/dist/utils/arrays.d.ts +13 -0
- package/dist/utils/arrays.js +20 -0
- package/dist/utils/colors.d.ts +19 -0
- package/dist/utils/colors.js +27 -0
- package/dist/utils/hot-state.d.ts +41 -0
- package/dist/utils/hot-state.js +37 -0
- package/dist/utils/logging.d.ts +29 -0
- package/dist/utils/logging.js +55 -0
- package/dist/utils/math.d.ts +52 -0
- package/dist/utils/math.js +76 -0
- package/package.json +79 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { Box3, type BufferGeometry, type Camera, Color, type ColorRepresentation, type Group, InstancedBufferAttribute, type Intersection, type Material, Matrix4, Mesh, type Object3DEventMap, type Raycaster, type Scene, Sphere, type Vector4, type WebGLRenderer } from 'three';
|
|
2
|
+
import { type UniformSchemaShader } from '../InstanceUniforms';
|
|
3
|
+
import { type UniformValue, type UniformValueObj } from '../SquareDataTexture';
|
|
4
|
+
import { FrustumCulling } from './FrustumCulling';
|
|
5
|
+
import { Raycasting } from './Raycasting';
|
|
6
|
+
/** Constructor options for {@link InstancedMeshImpl}. */
|
|
7
|
+
export interface InstancedMeshImplParams {
|
|
8
|
+
/** Initial instance capacity; the buffers grow past it on demand. */
|
|
9
|
+
capacity?: number;
|
|
10
|
+
}
|
|
11
|
+
/** An entry in the sort list: an instance id and its depth along the view direction. */
|
|
12
|
+
export interface InstancedRenderItem {
|
|
13
|
+
/** The instance id. */
|
|
14
|
+
index: number;
|
|
15
|
+
/** Depth along the camera's forward axis. */
|
|
16
|
+
depth: number;
|
|
17
|
+
}
|
|
18
|
+
/** A custom sorting function for render items. */
|
|
19
|
+
export type CustomSortFn = (list: InstancedRenderItem[]) => void;
|
|
20
|
+
/**
|
|
21
|
+
* A texture-backed instanced mesh: three's `InstancedMesh` regime, but with per-instance matrices,
|
|
22
|
+
* colors and uniforms held in data textures instead of vertex attributes — so instances can be
|
|
23
|
+
* added, removed, hidden, sorted and frustum-culled individually, and the buffers grow on demand.
|
|
24
|
+
*
|
|
25
|
+
* Ported from three.ez's instanced-mesh (`InstancedMesh2` and its `feature/*` and `utils/*`
|
|
26
|
+
* modules,
|
|
27
|
+
* {@link https://github.com/agargaro/instanced-mesh/tree/master/src/core | source}) as a plain
|
|
28
|
+
* subclass rather than a re-export of theirs. Only what the 2D layers use is kept: dynamic capacity,
|
|
29
|
+
* add/remove, per-instance visibility, sorting, linear per-instance frustum culling, and uniforms.
|
|
30
|
+
* BVH, LOD, skinning, morphing, and the `InstancedEntity` object layer are all dropped.
|
|
31
|
+
*
|
|
32
|
+
* Departures from upstream:
|
|
33
|
+
*
|
|
34
|
+
* - **Batched-style texture handling.** The data textures bind as ordinary shader uniforms and
|
|
35
|
+
* flush through {@link SquareDataTexture.update}, so there is no manual texture-unit binding,
|
|
36
|
+
* `updateTextures`/`bindTextures` split, or `PropertiesOverride` — the vendored texture already
|
|
37
|
+
* works this way for `BatchedMeshImpl`.
|
|
38
|
+
* - **The draw list is a texture, not a vertex attribute.** Upstream stamps a `uint` index attribute
|
|
39
|
+
* onto whatever geometry it is handed; this fetches the instance id by `gl_InstanceID` from a texture of
|
|
40
|
+
* its own, the way `BatchedMeshImpl` resolves `gl_DrawID`. So the mesh never writes to a geometry it
|
|
41
|
+
* does not own — several may draw one cached geometry — and the cull list flushes through
|
|
42
|
+
* {@link SquareDataTexture.update} in `onBeforeRender` like every other per-instance buffer, rather
|
|
43
|
+
* than needing an attribute that owns its GL buffer to beat three's upload in `projectObject`. It
|
|
44
|
+
* is a float for the same reason `BatchedMesh`'s is: see {@link SquareDataTexture}.
|
|
45
|
+
* - **Merged color/opacity API.** {@link setColorAt}/{@link getColorAt} take and return
|
|
46
|
+
* `Color | Vector4`, alpha in the fourth channel, as `BatchedMesh` does — no separate opacity
|
|
47
|
+
* methods.
|
|
48
|
+
* - **Uniforms are added, not initialized once** ({@link addUniforms}, {@link InstanceUniforms}).
|
|
49
|
+
* - **Bounds invalidate themselves** on every mutation that can move an instance.
|
|
50
|
+
* - **No caller-supplied geometry or material.** Like `BatchedMesh`, the constructor takes only
|
|
51
|
+
* options; it seeds a throwaway geometry and material that R3F's `<planeGeometry>` and
|
|
52
|
+
* `<TextureMaterial>` children replace on mount.
|
|
53
|
+
*
|
|
54
|
+
* Render it with {@link InstancedMesh}.
|
|
55
|
+
*/
|
|
56
|
+
export declare class InstancedMeshImpl extends Mesh<BufferGeometry, Material | Material[], Object3DEventMap & {
|
|
57
|
+
dispose: object;
|
|
58
|
+
}> {
|
|
59
|
+
/**
|
|
60
|
+
* The number of instances rendered in the last frame.
|
|
61
|
+
* @default 0
|
|
62
|
+
*/
|
|
63
|
+
count: number;
|
|
64
|
+
/** Marks this for three's instanced-draw path, which reads {@link count}. */
|
|
65
|
+
readonly isInstancedMesh = true;
|
|
66
|
+
/** Placeholder three's instanced path dereferences; the real matrices live in a texture. */
|
|
67
|
+
readonly instanceMatrix: InstancedBufferAttribute;
|
|
68
|
+
/** Unused; present because three's instanced path reads it. */
|
|
69
|
+
readonly instanceColor: null;
|
|
70
|
+
/**
|
|
71
|
+
* Unused, but must be `null`, not `undefined`: three enables its instanced-morph shader path on
|
|
72
|
+
* `isInstancedMesh && morphTexture !== null`, and an undefined field would satisfy that and emit
|
|
73
|
+
* morph GLSL that references an undeclared `MORPHTARGETS_COUNT`.
|
|
74
|
+
*/
|
|
75
|
+
readonly morphTexture: null;
|
|
76
|
+
/** Sorts the render list into draw order; assigned through the `customSort` JSX prop. */
|
|
77
|
+
customSort: CustomSortFn | null;
|
|
78
|
+
/** Whether each instance is frustum-culled individually. */
|
|
79
|
+
perObjectFrustumCulled: boolean;
|
|
80
|
+
/** Whether instances are depth-sorted (via {@link customSort}) before drawing. */
|
|
81
|
+
sortObjects: boolean;
|
|
82
|
+
/** Bounding box enclosing every instance; nulled on mutation and recomputed on demand. */
|
|
83
|
+
boundingBox: Box3 | null;
|
|
84
|
+
/** Bounding sphere enclosing every instance; nulled on mutation and recomputed on demand. */
|
|
85
|
+
boundingSphere: Sphere | null;
|
|
86
|
+
/**
|
|
87
|
+
* Tests the ray against individual instances. Assigned by a subclass whose instances are placed
|
|
88
|
+
* some other way, to one that knows how; see {@link Raycasting.prepareInstance}.
|
|
89
|
+
*/
|
|
90
|
+
protected raycasting: Raycasting;
|
|
91
|
+
/**
|
|
92
|
+
* Builds the draw list each draw. Assigned by a subclass whose instances cover more than their own
|
|
93
|
+
* bounds; see {@link FrustumCulling.instanceSphere}.
|
|
94
|
+
*/
|
|
95
|
+
protected culling: FrustumCulling;
|
|
96
|
+
/** Indirect rendering texture, for each `gl_InstanceID` stores indices of matrix/color/uniforms textures */
|
|
97
|
+
private indexTexture;
|
|
98
|
+
/**
|
|
99
|
+
* Per-instance transforms: one `mat4` per instance (4 channels × 4 pixels), or `null` until the
|
|
100
|
+
* first {@link setMatrixAt} — a mesh whose instances are placed some other way never allocates it,
|
|
101
|
+
* and the shader reads identity in its absence.
|
|
102
|
+
*/
|
|
103
|
+
private matricesTexture;
|
|
104
|
+
/** Per-instance RGBA colors, or `null` until the first {@link setColorAt}. */
|
|
105
|
+
private colorsTexture;
|
|
106
|
+
private uniforms;
|
|
107
|
+
/** Which instances are live, visible and free to hand out. */
|
|
108
|
+
private instances;
|
|
109
|
+
/** What the last draw culled to, or `null` before the first — what raycasting tests against. */
|
|
110
|
+
private drawList;
|
|
111
|
+
/** Puts back what {@link patchInstancedMaterial} wrapped; null between draws. */
|
|
112
|
+
private _unpatchMaterial;
|
|
113
|
+
constructor(params?: InstancedMeshImplParams);
|
|
114
|
+
/**
|
|
115
|
+
* The instance capacity the textures currently hold.
|
|
116
|
+
*/
|
|
117
|
+
get capacity(): number;
|
|
118
|
+
/**
|
|
119
|
+
* The number of active instances.
|
|
120
|
+
*/
|
|
121
|
+
get instancesCount(): number;
|
|
122
|
+
/**
|
|
123
|
+
* Declares per-instance uniforms, merging with any already declared and rebuilding the backing
|
|
124
|
+
* texture (existing values carried across). See {@link InstanceUniforms.add}.
|
|
125
|
+
* @param schema - The uniforms to add.
|
|
126
|
+
*/
|
|
127
|
+
addUniforms(schema: UniformSchemaShader): void;
|
|
128
|
+
/**
|
|
129
|
+
* Reads one instance's uniform.
|
|
130
|
+
* @param id - The index of instance to read.
|
|
131
|
+
* @param name - The uniform's name.
|
|
132
|
+
* @param target - Receives the result; unused for a `float`, returned directly.
|
|
133
|
+
* @returns The value.
|
|
134
|
+
*/
|
|
135
|
+
getUniformAt(id: number, name: string, target?: UniformValueObj): UniformValue;
|
|
136
|
+
/**
|
|
137
|
+
* Writes one instance's uniform and marks its row for upload.
|
|
138
|
+
* @param id - The index of instance to write.
|
|
139
|
+
* @param name - The uniform's name.
|
|
140
|
+
* @param value - The value to write.
|
|
141
|
+
*/
|
|
142
|
+
setUniformAt(id: number, name: string, value: UniformValue): void;
|
|
143
|
+
/**
|
|
144
|
+
* Adds `count` instances, reusing removed instances first, and reports each new id through
|
|
145
|
+
* `onCreation` so the caller can capture it. New instances start visible at the identity matrix.
|
|
146
|
+
* @param count - How many to add.
|
|
147
|
+
* @param onCreation - Called with each new instance's id.
|
|
148
|
+
* @returns `this`.
|
|
149
|
+
*/
|
|
150
|
+
addInstances(count: number, onCreation?: (id: number) => void): this;
|
|
151
|
+
/**
|
|
152
|
+
* Removes instances by id, freeing their instances for reuse and shrinking the iteration bound past
|
|
153
|
+
* any now-trailing inactive instances.
|
|
154
|
+
* @param ids - The instances to remove.
|
|
155
|
+
* @returns `this`.
|
|
156
|
+
*/
|
|
157
|
+
removeInstances(...ids: number[]): this;
|
|
158
|
+
/**
|
|
159
|
+
* Gets the visibility of a specific instance.
|
|
160
|
+
* @param id - The index of the instance.
|
|
161
|
+
* @returns Whether it is visible.
|
|
162
|
+
*/
|
|
163
|
+
getVisibleAt(id: number): boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Sets the visibility of a specific instance.
|
|
166
|
+
* @param id - The index of the instance.
|
|
167
|
+
* @param visible - Whether it should be visible.
|
|
168
|
+
*/
|
|
169
|
+
setVisibleAt(id: number, visible: boolean): void;
|
|
170
|
+
/**
|
|
171
|
+
* Reads an instance's transform. Tolerates a read before any transform was written — every
|
|
172
|
+
* instance is then untransformed, which is what the shader draws in the same state.
|
|
173
|
+
* @param id - The index of the instance.
|
|
174
|
+
* @param matrix - Target for the result.
|
|
175
|
+
* @returns The transform matrix.
|
|
176
|
+
*/
|
|
177
|
+
getMatrixAt(id: number, matrix?: Matrix4): Matrix4;
|
|
178
|
+
/**
|
|
179
|
+
* Writes an instance's transform.
|
|
180
|
+
* @param id - The index of the instance.
|
|
181
|
+
* @param matrix - The transform matrix.
|
|
182
|
+
* @returns `this`.
|
|
183
|
+
*/
|
|
184
|
+
setMatrixAt(id: number, matrix: Matrix4): this;
|
|
185
|
+
/**
|
|
186
|
+
* Reads an instance's color, filling alpha from the fourth channel when handed a `Vector4`.
|
|
187
|
+
* Tolerates a read before any color was written — an unwritten instance reads opaque white — as
|
|
188
|
+
* `BatchedMesh` does and the compare-and-skip write helpers rely on.
|
|
189
|
+
* @param id - The instance.
|
|
190
|
+
* @param target - Receives the result; pass a `Vector4` to also read alpha.
|
|
191
|
+
* @returns `target`.
|
|
192
|
+
*/
|
|
193
|
+
getColorAt(id: number): Color;
|
|
194
|
+
getColorAt<T extends Color | Vector4>(id: number, target: T): T;
|
|
195
|
+
/**
|
|
196
|
+
* Writes an instance's color, routing a `Vector4`'s alpha to the fourth channel.
|
|
197
|
+
* @param id - The instance.
|
|
198
|
+
* @param color - The color; pass a `Vector4` to also set alpha.
|
|
199
|
+
* @returns `this`.
|
|
200
|
+
*/
|
|
201
|
+
setColorAt(id: number, color: ColorRepresentation | Vector4): this;
|
|
202
|
+
/**
|
|
203
|
+
* Computes the bounding box that encloses all instances, and updates the `boundingBox` attribute.
|
|
204
|
+
*/
|
|
205
|
+
computeBoundingBox(): void;
|
|
206
|
+
/**
|
|
207
|
+
* Computes the bounding sphere that encloses all instances, and updates the `boundingSphere` attribute.
|
|
208
|
+
*/
|
|
209
|
+
computeBoundingSphere(): void;
|
|
210
|
+
/**
|
|
211
|
+
* Encloses one instance, in this mesh's space: the geometry's own sphere, moved onto the
|
|
212
|
+
* instance's transform.
|
|
213
|
+
*
|
|
214
|
+
* The seam frustum culling asks through, so that what encloses an instance is the mesh's business
|
|
215
|
+
* rather than something derived from a matrix every mesh is assumed to have — see
|
|
216
|
+
* {@link CullingHost}. Whole-mesh bounds go through it too, so a subclass placing its instances
|
|
217
|
+
* some other way overrides the one method and both follow.
|
|
218
|
+
* @param id - The instance.
|
|
219
|
+
* @param target - Receives the result.
|
|
220
|
+
* @returns The bounds.
|
|
221
|
+
*/
|
|
222
|
+
getBoundingSphereAt(id: number, target: Sphere): Sphere;
|
|
223
|
+
/**
|
|
224
|
+
* Encloses one instance in a box, in this mesh's space: the geometry's own, moved onto the
|
|
225
|
+
* instance's transform.
|
|
226
|
+
*
|
|
227
|
+
* The seam {@link computeBoundingBox} goes through, for the reason {@link getBoundingSphereAt} is
|
|
228
|
+
* the one culling asks through — a subclass overrides what encloses *one* instance, and every
|
|
229
|
+
* sweep over the set follows.
|
|
230
|
+
* @param id - The instance.
|
|
231
|
+
* @param target - Receives the result.
|
|
232
|
+
* @returns The bounds.
|
|
233
|
+
*/
|
|
234
|
+
getBoundingBoxAt(id: number, target: Box3): Box3;
|
|
235
|
+
/** Frees the data textures, which this mesh allocated rather than three. */
|
|
236
|
+
dispose(): void;
|
|
237
|
+
/**
|
|
238
|
+
* Clears whatever an instance holds, as it is handed out.
|
|
239
|
+
*
|
|
240
|
+
* A new instance may reuse a freed id that still holds the previous tenant's state, and nothing
|
|
241
|
+
* else will clear it: `onCreation` belongs to the caller, which knows what it is about to write
|
|
242
|
+
* and not what was there before. A subclass keeping per-instance state of its own overrides this
|
|
243
|
+
* and clears that too.
|
|
244
|
+
*
|
|
245
|
+
* The matrix only when there is a matrices texture — without one every instance already reads
|
|
246
|
+
* identity, which is exactly what this would write, and writing it would allocate the texture this
|
|
247
|
+
* mesh has so far done without.
|
|
248
|
+
* @param id - The instance being handed out.
|
|
249
|
+
*/
|
|
250
|
+
protected resetInstance(id: number): void;
|
|
251
|
+
/**
|
|
252
|
+
* Patches the material three is about to draw with, so the program it compiles reads this mesh's
|
|
253
|
+
* per-instance state — and hands back the undo.
|
|
254
|
+
*
|
|
255
|
+
* Applied and undone around every draw rather than once per material, because the material three
|
|
256
|
+
* hands over is not always the mesh's own: a scene's `overrideMaterial` is drawn with instead, and
|
|
257
|
+
* one left patched afterwards would carry this mesh's textures into every other object using it.
|
|
258
|
+
*
|
|
259
|
+
* The seam a subclass extends when its members need more of the shader than instancing — it wraps
|
|
260
|
+
* first, so that its own patch runs *inside* this one and finds the prologue already injected.
|
|
261
|
+
* @param material - The material about to draw.
|
|
262
|
+
* @returns Restores the material exactly as it arrived. Called once, after the draw.
|
|
263
|
+
*/
|
|
264
|
+
protected patchMaterial(material: Material): () => void;
|
|
265
|
+
/**
|
|
266
|
+
* Nulls the cached bounds so three's next frustum test recomputes them, and the draw list with
|
|
267
|
+
* them.
|
|
268
|
+
*
|
|
269
|
+
* The draw list describes what the **last frame** drew, and {@link raycast} tests against it — so
|
|
270
|
+
* any mutation that changes what would draw leaves it lying to the next pointer event. Nulling it
|
|
271
|
+
* falls back to sweeping every live instance, which is the honest answer until a frame rebuilds
|
|
272
|
+
* it: an instance added between a mutation and the next draw is otherwise unpickable, which reads
|
|
273
|
+
* as the pointer having left something it is still sitting on.
|
|
274
|
+
*
|
|
275
|
+
* Protected to be *called*, not overridden: a subclass places its instances its own way, so its
|
|
276
|
+
* own writes are the ones this class cannot know have moved something.
|
|
277
|
+
*/
|
|
278
|
+
protected invalidateBounds(): void;
|
|
279
|
+
onBeforeRender(renderer: WebGLRenderer, scene: Scene, camera: Camera, geometry: BufferGeometry, material: Material, group: Group): void;
|
|
280
|
+
onAfterRender(renderer: WebGLRenderer, scene: Scene, camera: Camera, geometry: BufferGeometry, material: Material, group: Group): void;
|
|
281
|
+
onBeforeShadow(renderer: WebGLRenderer, scene: Scene, camera: Camera, shadowCamera: Camera, geometry: BufferGeometry, depthMaterial: Material, group: Group): void;
|
|
282
|
+
onAfterShadow(renderer: WebGLRenderer, scene: Scene, camera: Camera, shadowCamera: Camera, geometry: BufferGeometry, depthMaterial: Material, group: Group): void;
|
|
283
|
+
clone(recursive?: boolean): this;
|
|
284
|
+
copy(source: this, recursive?: boolean): this;
|
|
285
|
+
raycast(raycaster: Raycaster, intersects: Intersection[]): void;
|
|
286
|
+
/**
|
|
287
|
+
* Grows every per-instance texture to a new capacity, keeping what is written. {@link Instances} grows
|
|
288
|
+
* its own store and then calls this, so nothing here tracks capacity itself.
|
|
289
|
+
* @param newCapacity - The new capacity, always larger than the current one.
|
|
290
|
+
*/
|
|
291
|
+
private resizeCapacity;
|
|
292
|
+
private initMatricesTexture;
|
|
293
|
+
private initColorsTexture;
|
|
294
|
+
/** Flags the material(s) for recompilation, e.g. after a texture is added. */
|
|
295
|
+
private materialsNeedUpdate;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Registers the class as an R3F element, by value so the generated key cannot collide with the
|
|
299
|
+
* `InstancedMesh` three already puts in the catalog when the canvas mounts.
|
|
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<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
|
+
//# sourceMappingURL=InstancedMesh.d.ts.map
|