@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.
Files changed (280) hide show
  1. package/README.md +145 -0
  2. package/dist/Renderer.d.ts +102 -0
  3. package/dist/Renderer.js +96 -0
  4. package/dist/controls/CameraControls.d.ts +108 -0
  5. package/dist/controls/CameraControls.js +203 -0
  6. package/dist/controls/Controls.d.ts +53 -0
  7. package/dist/controls/Controls.js +54 -0
  8. package/dist/controls/camera-api.d.ts +226 -0
  9. package/dist/controls/camera-api.js +179 -0
  10. package/dist/controls/gestures.d.ts +71 -0
  11. package/dist/controls/gestures.js +98 -0
  12. package/dist/controls/handlers/DoubleTapZoom.d.ts +23 -0
  13. package/dist/controls/handlers/DoubleTapZoom.js +82 -0
  14. package/dist/controls/handlers/Inertia.d.ts +60 -0
  15. package/dist/controls/handlers/Inertia.js +222 -0
  16. package/dist/controls/handlers/Pan.d.ts +23 -0
  17. package/dist/controls/handlers/Pan.js +212 -0
  18. package/dist/controls/handlers/Pitch.d.ts +19 -0
  19. package/dist/controls/handlers/Pitch.js +200 -0
  20. package/dist/controls/handlers/Roll.d.ts +30 -0
  21. package/dist/controls/handlers/Roll.js +196 -0
  22. package/dist/controls/handlers/Zoom.d.ts +28 -0
  23. package/dist/controls/handlers/Zoom.js +34 -0
  24. package/dist/controls/hooks.d.ts +136 -0
  25. package/dist/controls/hooks.js +200 -0
  26. package/dist/controls/index.d.ts +9 -0
  27. package/dist/controls/index.js +7 -0
  28. package/dist/controls/zoom-to.d.ts +89 -0
  29. package/dist/controls/zoom-to.js +91 -0
  30. package/dist/core/InstanceUniforms.d.ts +108 -0
  31. package/dist/core/InstanceUniforms.js +298 -0
  32. package/dist/core/SquareDataTexture.d.ts +277 -0
  33. package/dist/core/SquareDataTexture.js +476 -0
  34. package/dist/core/batch/BatchedMesh.d.ts +74 -0
  35. package/dist/core/batch/BatchedMesh.js +155 -0
  36. package/dist/core/instanced/FrustumCulling.d.ts +141 -0
  37. package/dist/core/instanced/FrustumCulling.js +246 -0
  38. package/dist/core/instanced/InstancedMesh.d.ts +302 -0
  39. package/dist/core/instanced/InstancedMesh.js +497 -0
  40. package/dist/core/instanced/Instances.d.ts +119 -0
  41. package/dist/core/instanced/Instances.js +230 -0
  42. package/dist/core/instanced/Raycasting.d.ts +118 -0
  43. package/dist/core/instanced/Raycasting.js +134 -0
  44. package/dist/core/instanced/instanced-material.d.ts +77 -0
  45. package/dist/core/instanced/instanced-material.js +228 -0
  46. package/dist/core/lines/BatchedLines.d.ts +137 -0
  47. package/dist/core/lines/BatchedLines.js +215 -0
  48. package/dist/core/lines/FrustumCullingLines.d.ts +44 -0
  49. package/dist/core/lines/FrustumCullingLines.js +85 -0
  50. package/dist/core/lines/RaycastingLines.d.ts +45 -0
  51. package/dist/core/lines/RaycastingLines.js +91 -0
  52. package/dist/core/lines/lines-material.d.ts +47 -0
  53. package/dist/core/lines/lines-material.js +124 -0
  54. package/dist/core/shader-source.d.ts +70 -0
  55. package/dist/core/shader-source.js +110 -0
  56. package/dist/core/sprites/BatchedSprites.d.ts +115 -0
  57. package/dist/core/sprites/BatchedSprites.js +173 -0
  58. package/dist/core/sprites/RaycastingSprites.d.ts +41 -0
  59. package/dist/core/sprites/RaycastingSprites.js +71 -0
  60. package/dist/core/sprites/sprite-material.d.ts +59 -0
  61. package/dist/core/sprites/sprite-material.js +192 -0
  62. package/dist/core/text/BatchedText.d.ts +233 -0
  63. package/dist/core/text/BatchedText.js +473 -0
  64. package/dist/core/text/MemberTexture.d.ts +90 -0
  65. package/dist/core/text/MemberTexture.js +289 -0
  66. package/dist/core/text/Text.d.ts +88 -0
  67. package/dist/core/text/Text.js +230 -0
  68. package/dist/core/text/batched-text-material.d.ts +56 -0
  69. package/dist/core/text/batched-text-material.js +123 -0
  70. package/dist/core/text/glyph-packing.d.ts +17 -0
  71. package/dist/core/text/glyph-packing.js +61 -0
  72. package/dist/core/typed-array.d.ts +16 -0
  73. package/dist/core/typed-array.js +20 -0
  74. package/dist/debug/components/DebugPanelProvider.d.ts +20 -0
  75. package/dist/debug/components/DebugPanelProvider.js +50 -0
  76. package/dist/debug/components/DebugTools.d.ts +22 -0
  77. package/dist/debug/components/DebugTools.js +28 -0
  78. package/dist/debug/components/Gui.d.ts +22 -0
  79. package/dist/debug/components/Gui.js +42 -0
  80. package/dist/debug/components/MemoryInfo.d.ts +22 -0
  81. package/dist/debug/components/MemoryInfo.js +42 -0
  82. package/dist/debug/components/Panel.d.ts +31 -0
  83. package/dist/debug/components/Panel.js +104 -0
  84. package/dist/debug/components/Stats.d.ts +9 -0
  85. package/dist/debug/components/Stats.js +24 -0
  86. package/dist/debug/debug-chunk.d.ts +26 -0
  87. package/dist/debug/debug-chunk.js +32 -0
  88. package/dist/debug/debug-context.d.ts +41 -0
  89. package/dist/debug/debug-context.js +59 -0
  90. package/dist/debug/index.d.ts +41 -0
  91. package/dist/debug/index.js +43 -0
  92. package/dist/events/LayoutDriver.d.ts +36 -0
  93. package/dist/events/LayoutDriver.js +192 -0
  94. package/dist/events/PointerMissed.d.ts +23 -0
  95. package/dist/events/PointerMissed.js +58 -0
  96. package/dist/events/def-culling.d.ts +46 -0
  97. package/dist/events/def-culling.js +69 -0
  98. package/dist/events/layout-targets.d.ts +151 -0
  99. package/dist/events/layout-targets.js +397 -0
  100. package/dist/events/placement/box.d.ts +59 -0
  101. package/dist/events/placement/box.js +96 -0
  102. package/dist/events/placement/grid.d.ts +161 -0
  103. package/dist/events/placement/grid.js +235 -0
  104. package/dist/events/placement/index.d.ts +2 -0
  105. package/dist/events/placement/index.js +1 -0
  106. package/dist/events/placement/pass.d.ts +70 -0
  107. package/dist/events/placement/pass.js +617 -0
  108. package/dist/events/pointer.d.ts +194 -0
  109. package/dist/events/pointer.js +356 -0
  110. package/dist/external/ExternalCanvas.d.ts +56 -0
  111. package/dist/external/ExternalCanvas.js +177 -0
  112. package/dist/external/external-camera.d.ts +18 -0
  113. package/dist/external/external-camera.js +103 -0
  114. package/dist/external/external-events.d.ts +14 -0
  115. package/dist/external/external-events.js +33 -0
  116. package/dist/index.d.ts +13 -0
  117. package/dist/index.js +14 -0
  118. package/dist/objects/Background.d.ts +31 -0
  119. package/dist/objects/Background.js +37 -0
  120. package/dist/objects/containers/SlotContainer.d.ts +312 -0
  121. package/dist/objects/containers/SlotContainer.js +311 -0
  122. package/dist/objects/containers/hooks.d.ts +61 -0
  123. package/dist/objects/containers/hooks.js +196 -0
  124. package/dist/objects/containers/index.d.ts +6 -0
  125. package/dist/objects/containers/index.js +4 -0
  126. package/dist/objects/containers/keys.d.ts +10 -0
  127. package/dist/objects/containers/keys.js +18 -0
  128. package/dist/objects/containers/mesh-writes.d.ts +106 -0
  129. package/dist/objects/containers/mesh-writes.js +97 -0
  130. package/dist/objects/containers/props.d.ts +33 -0
  131. package/dist/objects/containers/props.js +1 -0
  132. package/dist/objects/images/ImageInstance.d.ts +29 -0
  133. package/dist/objects/images/ImageInstance.js +152 -0
  134. package/dist/objects/images/Images.d.ts +49 -0
  135. package/dist/objects/images/Images.js +394 -0
  136. package/dist/objects/images/atlas-packer.d.ts +129 -0
  137. package/dist/objects/images/atlas-packer.js +287 -0
  138. package/dist/objects/images/image-container.d.ts +74 -0
  139. package/dist/objects/images/image-container.js +100 -0
  140. package/dist/objects/images/index.d.ts +2 -0
  141. package/dist/objects/images/index.js +1 -0
  142. package/dist/objects/images/pack-sources.d.ts +190 -0
  143. package/dist/objects/images/pack-sources.js +272 -0
  144. package/dist/objects/images/texture-budget.d.ts +120 -0
  145. package/dist/objects/images/texture-budget.js +215 -0
  146. package/dist/objects/images/worker/atlas-worker.d.ts +56 -0
  147. package/dist/objects/images/worker/atlas-worker.js +123 -0
  148. package/dist/objects/images/worker/client.d.ts +62 -0
  149. package/dist/objects/images/worker/client.js +249 -0
  150. package/dist/objects/images/worker/index.d.ts +10 -0
  151. package/dist/objects/images/worker/index.js +1 -0
  152. package/dist/objects/layer/Layer.d.ts +28 -0
  153. package/dist/objects/layer/Layer.js +134 -0
  154. package/dist/objects/layer/index.d.ts +2 -0
  155. package/dist/objects/layer/index.js +1 -0
  156. package/dist/objects/layer/layer-context.d.ts +74 -0
  157. package/dist/objects/layer/layer-context.js +82 -0
  158. package/dist/objects/layer/mount-scheduler.d.ts +131 -0
  159. package/dist/objects/layer/mount-scheduler.js +289 -0
  160. package/dist/objects/layer/visibility-gui.d.ts +19 -0
  161. package/dist/objects/layer/visibility-gui.js +93 -0
  162. package/dist/objects/lighting/Lighting.d.ts +92 -0
  163. package/dist/objects/lighting/Lighting.js +384 -0
  164. package/dist/objects/lighting/OcclusionPasses.d.ts +23 -0
  165. package/dist/objects/lighting/OcclusionPasses.js +271 -0
  166. package/dist/objects/lighting/index.d.ts +11 -0
  167. package/dist/objects/lighting/index.js +10 -0
  168. package/dist/objects/lighting/lighting-gui.d.ts +24 -0
  169. package/dist/objects/lighting/lighting-gui.js +114 -0
  170. package/dist/objects/lighting/occluder.d.ts +34 -0
  171. package/dist/objects/lighting/occluder.js +62 -0
  172. package/dist/objects/lighting/occlusion-targets.d.ts +143 -0
  173. package/dist/objects/lighting/occlusion-targets.js +276 -0
  174. package/dist/objects/lines/LineInstance.d.ts +21 -0
  175. package/dist/objects/lines/LineInstance.js +73 -0
  176. package/dist/objects/lines/Lines.d.ts +17 -0
  177. package/dist/objects/lines/Lines.js +31 -0
  178. package/dist/objects/lines/index.d.ts +2 -0
  179. package/dist/objects/lines/index.js +1 -0
  180. package/dist/objects/lines/line-container.d.ts +35 -0
  181. package/dist/objects/lines/line-container.js +40 -0
  182. package/dist/objects/materials/ColorMaterial.d.ts +92 -0
  183. package/dist/objects/materials/ColorMaterial.js +124 -0
  184. package/dist/objects/materials/LineMaterial.d.ts +44 -0
  185. package/dist/objects/materials/LineMaterial.js +74 -0
  186. package/dist/objects/materials/ModelMaterial.d.ts +53 -0
  187. package/dist/objects/materials/ModelMaterial.js +111 -0
  188. package/dist/objects/materials/TextureMaterial.d.ts +33 -0
  189. package/dist/objects/materials/TextureMaterial.js +48 -0
  190. package/dist/objects/materials/effects/ao/ambient-occlusion-pass.d.ts +77 -0
  191. package/dist/objects/materials/effects/ao/ambient-occlusion-pass.js +296 -0
  192. package/dist/objects/materials/effects/ao/ambient-occlusion-patch.d.ts +29 -0
  193. package/dist/objects/materials/effects/ao/ambient-occlusion-patch.js +115 -0
  194. package/dist/objects/materials/effects/ao/blur-pass.d.ts +61 -0
  195. package/dist/objects/materials/effects/ao/blur-pass.js +101 -0
  196. package/dist/objects/materials/effects/ao/index.d.ts +129 -0
  197. package/dist/objects/materials/effects/ao/index.js +72 -0
  198. package/dist/objects/materials/effects/color-dim.d.ts +115 -0
  199. package/dist/objects/materials/effects/color-dim.js +206 -0
  200. package/dist/objects/materials/effects/contact-shadow.d.ts +100 -0
  201. package/dist/objects/materials/effects/contact-shadow.js +167 -0
  202. package/dist/objects/materials/effects/effects-context.d.ts +53 -0
  203. package/dist/objects/materials/effects/effects-context.js +24 -0
  204. package/dist/objects/materials/shared.d.ts +24 -0
  205. package/dist/objects/materials/shared.js +72 -0
  206. package/dist/objects/models/ModelInstance.d.ts +22 -0
  207. package/dist/objects/models/ModelInstance.js +33 -0
  208. package/dist/objects/models/Models.d.ts +22 -0
  209. package/dist/objects/models/Models.js +186 -0
  210. package/dist/objects/models/gltf-cache.d.ts +17 -0
  211. package/dist/objects/models/gltf-cache.js +50 -0
  212. package/dist/objects/models/index.d.ts +2 -0
  213. package/dist/objects/models/index.js +1 -0
  214. package/dist/objects/models/model-asset.d.ts +48 -0
  215. package/dist/objects/models/model-asset.js +77 -0
  216. package/dist/objects/models/model-container.d.ts +123 -0
  217. package/dist/objects/models/model-container.js +207 -0
  218. package/dist/objects/shapes/ShapeInstance.d.ts +26 -0
  219. package/dist/objects/shapes/ShapeInstance.js +39 -0
  220. package/dist/objects/shapes/Shapes.d.ts +21 -0
  221. package/dist/objects/shapes/Shapes.js +131 -0
  222. package/dist/objects/shapes/index.d.ts +2 -0
  223. package/dist/objects/shapes/index.js +1 -0
  224. package/dist/objects/shapes/shape-container.d.ts +141 -0
  225. package/dist/objects/shapes/shape-container.js +242 -0
  226. package/dist/objects/shapes/shape-geometry.d.ts +27 -0
  227. package/dist/objects/shapes/shape-geometry.js +94 -0
  228. package/dist/objects/text/TextInstance.d.ts +22 -0
  229. package/dist/objects/text/TextInstance.js +95 -0
  230. package/dist/objects/text/Texts.d.ts +30 -0
  231. package/dist/objects/text/Texts.js +43 -0
  232. package/dist/objects/text/index.d.ts +2 -0
  233. package/dist/objects/text/index.js +1 -0
  234. package/dist/objects/text/text-container.d.ts +121 -0
  235. package/dist/objects/text/text-container.js +229 -0
  236. package/dist/objects/text/text-layout.d.ts +92 -0
  237. package/dist/objects/text/text-layout.js +180 -0
  238. package/dist/space/Camera.d.ts +103 -0
  239. package/dist/space/Camera.js +321 -0
  240. package/dist/space/Scene.d.ts +47 -0
  241. package/dist/space/Scene.js +127 -0
  242. package/dist/space/Space.d.ts +325 -0
  243. package/dist/space/Space.js +359 -0
  244. package/dist/space/VisibleRect.d.ts +45 -0
  245. package/dist/space/VisibleRect.js +129 -0
  246. package/dist/space/camera-handle.d.ts +67 -0
  247. package/dist/space/camera-handle.js +63 -0
  248. package/dist/space/camera-kind.d.ts +26 -0
  249. package/dist/space/camera-kind.js +30 -0
  250. package/dist/space/canvas-size.d.ts +24 -0
  251. package/dist/space/canvas-size.js +20 -0
  252. package/dist/space/clipping.d.ts +69 -0
  253. package/dist/space/clipping.js +130 -0
  254. package/dist/space/layout-measure.d.ts +67 -0
  255. package/dist/space/layout-measure.js +175 -0
  256. package/dist/space/viewport.d.ts +112 -0
  257. package/dist/space/viewport.js +67 -0
  258. package/dist/types/defs.d.ts +234 -0
  259. package/dist/types/defs.js +1 -0
  260. package/dist/types/events.d.ts +198 -0
  261. package/dist/types/events.js +1 -0
  262. package/dist/types/guards.d.ts +21 -0
  263. package/dist/types/guards.js +52 -0
  264. package/dist/update/index.d.ts +3 -0
  265. package/dist/update/index.js +2 -0
  266. package/dist/update/slot-writers.d.ts +30 -0
  267. package/dist/update/slot-writers.js +76 -0
  268. package/dist/update/store.d.ts +41 -0
  269. package/dist/update/store.js +104 -0
  270. package/dist/utils/arrays.d.ts +13 -0
  271. package/dist/utils/arrays.js +20 -0
  272. package/dist/utils/colors.d.ts +19 -0
  273. package/dist/utils/colors.js +27 -0
  274. package/dist/utils/hot-state.d.ts +41 -0
  275. package/dist/utils/hot-state.js +37 -0
  276. package/dist/utils/logging.d.ts +29 -0
  277. package/dist/utils/logging.js +55 -0
  278. package/dist/utils/math.d.ts +52 -0
  279. package/dist/utils/math.js +76 -0
  280. package/package.json +79 -0
@@ -0,0 +1,325 @@
1
+ import { type Box, Point, type Point2Like, type PointLike } from '@expofp/geometry';
2
+ import { type Camera, Matrix4, Ray, Raycaster, Vector2, type Vector2Like, Vector3, type Vector3Like } from 'three';
3
+ /**
4
+ * A point in **plan space**: the plan's own coordinates, the ones every def is authored in. Reads x
5
+ * right, y down and z **up**, so an elevation is a positive number.
6
+ *
7
+ * Plan points are `@expofp/geometry` points because plan space crosses the public API — a pointer
8
+ * event reports where it landed as one, and floorplan authors its defs in the same type. So does
9
+ * {@link CanvasPoint}, for the same reason: those two are what a caller converts between.
10
+ */
11
+ export type PlanPoint = Point & {
12
+ __space: 'plan';
13
+ };
14
+ /**
15
+ * A plain object in plan space — what a caller may pass in.
16
+ *
17
+ * The brand is required rather than optional, so a bare `{ x, y }` is assignable to no space at all
18
+ * and crossing into one is an explicit `as`. An optional brand would make every plain object
19
+ * assignable to *every* space, which is the mistake these types exist to catch.
20
+ */
21
+ export type PlanPointLike = PointLike & {
22
+ __space: 'plan';
23
+ };
24
+ /**
25
+ * A point in **world space**: three's own space, the one the camera is placed in. Right-handed, so
26
+ * world z grows *away* from the viewer — which is why {@link Space} mirrors the plan's z.
27
+ *
28
+ * World and NDC points are three's vectors instead of `@expofp/geometry`: neither is part of the
29
+ * public API, and both exist only to be multiplied by matrices and unprojected through cameras.
30
+ */
31
+ export type WorldPoint = Vector3 & {
32
+ __space: 'world';
33
+ };
34
+ /** A plain object point in world space. */
35
+ export type WorldPointLike = Vector3Like & {
36
+ __space: 'world';
37
+ };
38
+ /**
39
+ * A point in **canvas space**: css pixels from the canvas's top-left corner, x right and y **down**,
40
+ * the coordinates a DOM pointer event reports.
41
+ *
42
+ * Two dimensions and no more, unlike a plan point: what is drawn at a canvas position has a height,
43
+ * but the position itself does not — which is why {@link Space.ndcToCanvas} writes a zero `z` rather
44
+ * than carrying one through.
45
+ *
46
+ * Canvas and plan points are the pair most easily confused — both are 2D `{ x, y }` over comparable
47
+ * ranges, and both read as "where on screen" — so this is the brand that earns its keep most.
48
+ */
49
+ export type CanvasPoint = Point & {
50
+ __space: 'canvas';
51
+ };
52
+ /** A plain object point in canvas space — what a caller reading a DOM event may pass in. */
53
+ export type CanvasPointLike = Point2Like & {
54
+ __space: 'canvas';
55
+ };
56
+ /**
57
+ * A point in **normalized device coordinates**: where something sits on the canvas irrespective of
58
+ * its size, `[-1, 1]` on both axes with the origin at the centre and y growing upward.
59
+ */
60
+ export type NDCPoint = Vector2 & {
61
+ __space: 'ndc';
62
+ };
63
+ /** A plain object point in normalized device coordinates. */
64
+ export type NDCPointLike = Vector2Like & {
65
+ __space: 'ndc';
66
+ };
67
+ /** How a {@link Space} maps the plan onto the canvas. */
68
+ export interface SpaceOptions {
69
+ /** The scene's viewbox, in plan units — the region the fit frames. */
70
+ viewbox: Box;
71
+ /** The canvas width in css pixels. */
72
+ width: number;
73
+ /** The canvas height in css pixels. */
74
+ height: number;
75
+ /**
76
+ * The device pixel ratio the canvas draws at.
77
+ *
78
+ * Separate rather than pre-multiplied into css pixels because both are needed: the fit measures the buffer pixels,
79
+ * while canvas coordinates arrive from DOM events in css pixels. Passing the buffer size instead would just move the
80
+ * division to the other side.
81
+ */
82
+ dpr: number;
83
+ /**
84
+ * A caller-supplied plan → world matrix, 16 elements column-major, in the host's own coordinates.
85
+ * When present it *replaces* the viewbox fit rather than composing with it; the z mirror both
86
+ * paths end with is not the caller's to supply (see {@link HANDEDNESS_FLIP}).
87
+ */
88
+ staticTransform?: number[];
89
+ }
90
+ /**
91
+ * The scene's space.
92
+ * @returns The space {@link Scene} published, or the identity one when rendered outside a scene.
93
+ */
94
+ export declare function useSpace(): Space;
95
+ /**
96
+ * The mapping between the plan's own coordinates and the world the camera is placed in, and the
97
+ * conversions that ride on it.
98
+ *
99
+ * The mapping is one matrix. Without a `staticTransform` it is the **viewbox fit**: centre the
100
+ * viewbox on the world origin and scale it uniformly to best fill the drawing buffer. That fit is
101
+ * what makes one world unit one device pixel when the plan exactly fills the canvas, which in turn
102
+ * is what lets the camera's zoom math be written without reference to the scene at all — see
103
+ * {@link Camera}.
104
+ *
105
+ * With a `staticTransform` the matrix is whatever the caller supplied, and the fit is not computed:
106
+ * a host like maplibre places the plan itself, in its own space.
107
+ *
108
+ * Either way the matrix ends with {@link HANDEDNESS_FLIP}, which is what makes the space three's
109
+ * rather than the plan's or a host's — a positive elevation then lands nearer the camera.
110
+ *
111
+ * **Stable for the scene's lifetime.** A resize does not build a new space — {@link Scene} refits
112
+ * this one in place — so every holder reads the current fit through the same object and none of
113
+ * them re-render for it. What makes that safe is a reading discipline: render output must never be
114
+ * derived from these fields, because no render follows a refit. Read them at the moment of use —
115
+ * in event handlers, effects and the frame loop, which always run against the current fit. `Scene`
116
+ * itself is the one exception, and it re-applies the world matrix from the same effect that refits.
117
+ */
118
+ export declare class Space {
119
+ /** Plan → world. */
120
+ readonly matrix: Matrix4;
121
+ /** World → plan. */
122
+ readonly matrixInverse: Matrix4;
123
+ private _scale;
124
+ private _isExternal;
125
+ /** The canvas width in css pixels, which the canvas conversions measure against. */
126
+ private width;
127
+ /** The canvas height in css pixels. */
128
+ private height;
129
+ /**
130
+ * @param options - How to map the plan onto the canvas. Omit them entirely for the identity
131
+ * space, in which world coordinates already read as plan coordinates; the individual fields are
132
+ * not separately optional, because a fit needs all of them.
133
+ */
134
+ constructor(options?: SpaceOptions);
135
+ /**
136
+ * World units per plan unit: the geometric mean of the two transformed axes, rather than the
137
+ * length of one of them.
138
+ *
139
+ * Both paths that build a matrix produce a similarity — the fit scales x and y alike, and the
140
+ * maplibre solver forces uniform scale and no shear — so the two axes agree and the mean is
141
+ * simply their common length. It differs only for a transform this renderer does not produce, and
142
+ * there no single number is right anyway: an anisotropic plan covers different amounts of plan per
143
+ * pixel along each axis, and the mean is the one that preserves area.
144
+ */
145
+ get scale(): number;
146
+ /**
147
+ * Whether an external host placed the plan itself, by supplying a valid `staticTransform`,
148
+ * rather than this renderer fitting the viewbox to the canvas — external mode, where the host
149
+ * owns the canvas, the camera and the frames.
150
+ */
151
+ get isExternal(): boolean;
152
+ /**
153
+ * Refits the plan onto the canvas in place, leaving every held reference reading the new fit.
154
+ * @param options - How to map the plan onto the canvas.
155
+ */
156
+ refit(options: SpaceOptions): void;
157
+ /**
158
+ * Converts a point from plan to world coordinates.
159
+ * @param point - The plan-space point; a missing `z` is read as `0`.
160
+ * @param out - Where to write the result.
161
+ * @returns The world-space point.
162
+ */
163
+ planToWorld(point: PlanPointLike, out?: WorldPoint): WorldPoint;
164
+ /**
165
+ * Converts a point from world to plan coordinates.
166
+ * @param point - The world-space point.
167
+ * @param out - Where to write the result.
168
+ * @returns The plan-space point.
169
+ */
170
+ worldToPlan(point: WorldPointLike, out?: PlanPoint): PlanPoint;
171
+ /**
172
+ * Converts a point on the canvas — css pixels from its top-left corner — to normalized device
173
+ * coordinates, clamped to the canvas.
174
+ * @param point - The canvas-space point.
175
+ * @param out - Where to write the result.
176
+ * @returns The point in normalized device coordinates.
177
+ */
178
+ canvasToNdc(point: CanvasPointLike, out?: NDCPoint): NDCPoint;
179
+ /**
180
+ * Where a point in normalized device coordinates lands on the canvas, in css pixels from its
181
+ * top-left corner.
182
+ *
183
+ * **Unclamped, where {@link canvasToNdc} clamps**, and the asymmetry is the point: clamping on the
184
+ * way in keeps a pointer event on the canvas it was dispatched from, while clamping on the way out
185
+ * would erase the one thing a caller asking about an off-screen point wants to know.
186
+ *
187
+ * No guard on a canvas with no size either, where `canvasToNdc` needs one — this multiplies by the
188
+ * size where that divides by it, so an unsized canvas gives an honest zero rather than a `NaN`.
189
+ * @param ndc - The point in normalized device coordinates.
190
+ * @param out - Where to write the result.
191
+ * @returns The canvas-space point.
192
+ */
193
+ ndcToCanvas(ndc: NDCPointLike, out?: CanvasPoint): CanvasPoint;
194
+ /**
195
+ * Where a ray crosses the plan, in plan units.
196
+ *
197
+ * The ray is taken into plan space and crossed with plan `z = 0` there, rather than crossed with
198
+ * the plan's image in world space and converted back. Both agree for the viewbox fit; only this
199
+ * one stays correct for a `staticTransform` that rotates or lifts the plan off world `z = 0`.
200
+ * @param ray - The ray, in world space.
201
+ * @param out - Where to write the result.
202
+ * @returns The crossing, or `undefined` when the ray runs parallel to the plan.
203
+ */
204
+ rayToPlan(ray: Ray, out?: PlanPoint): PlanPoint | undefined;
205
+ /**
206
+ * Where a point in normalized device coordinates lands on the plan.
207
+ * @param ndc - The point in normalized device coordinates.
208
+ * @param camera - The camera the canvas is drawn through.
209
+ * @param out - Where to write the result.
210
+ * @returns The plan position, or `undefined` when the camera never meets the plan.
211
+ */
212
+ ndcToPlan(ndc: NDCPointLike, camera: Camera, out?: PlanPoint): PlanPoint | undefined;
213
+ /**
214
+ * Where a point on the plan lands in normalized device coordinates — the inverse of
215
+ * {@link ndcToPlan}, and the projection every question about "where is this on screen" is built
216
+ * from.
217
+ *
218
+ * Carried through **clip space** rather than through three's `Vector3.project`, which divides by
219
+ * `w` without looking at its sign: a point behind the camera comes back mirrored through the
220
+ * origin, and so lands inside the canvas as convincingly as a point in front of it. Reading `w`
221
+ * first is what separates the two.
222
+ *
223
+ * The camera's view offset rides in `projectionMatrix`, so a scene framed inside a `visibleRect`
224
+ * projects through this with no seam — the same way picking and culling follow it.
225
+ * @param point - The plan-space point; a missing `z` is read as `0`.
226
+ * @param camera - The camera the canvas is drawn through.
227
+ * @param out - Where to write the result.
228
+ * @returns The point in normalized device coordinates, unclamped, or `undefined` when it sits
229
+ * behind the camera and has no image on the canvas at all.
230
+ */
231
+ planToNdc(point: PlanPointLike, camera: Camera, out?: NDCPoint): NDCPoint | undefined;
232
+ /**
233
+ * Where a point on the canvas — css pixels from its top-left corner — lands on the plan.
234
+ * @param point - The canvas-space point.
235
+ * @param camera - The camera the canvas is drawn through.
236
+ * @param out - Where to write the result.
237
+ * @returns The plan position, or `undefined` when the camera never meets the plan.
238
+ */
239
+ canvasToPlan(point: CanvasPointLike, camera: Camera, out?: PlanPoint): PlanPoint | undefined;
240
+ /**
241
+ * Where a point on the plan lands on the canvas, in css pixels from its top-left corner — the
242
+ * inverse of {@link canvasToPlan}, composed from the same two halves the other way round.
243
+ * @param point - The plan-space point; a missing `z` is read as `0`.
244
+ * @param camera - The camera the canvas is drawn through.
245
+ * @param out - Where to write the result.
246
+ * @returns The canvas position, unclamped, or `undefined` when the point sits behind the camera.
247
+ */
248
+ planToCanvas(point: PlanPointLike, camera: Camera, out?: CanvasPoint): CanvasPoint | undefined;
249
+ /**
250
+ * Whether a caller supplied a usable plan → world matrix, warning when they supplied an unusable
251
+ * one rather than silently falling back.
252
+ * @param staticTransform - What the caller supplied, if anything.
253
+ * @returns Whether it should be used as the matrix.
254
+ */
255
+ private validateStaticTransform;
256
+ }
257
+ /**
258
+ * The scale that fits a viewbox inside a drawing buffer, contain-style: the constraining axis fills
259
+ * and the other one keeps slack.
260
+ *
261
+ * Exported because it is also what tells a caller how large the plan is drawn: `VisibleRect` needs
262
+ * the plan's footprint in device pixels, and deriving it from this rather than from `Space.scale`
263
+ * keeps it free of the commit-ordering hazard the class documents — the fit is a function of the
264
+ * props it already holds.
265
+ * @param viewbox - The region to frame, in plan units.
266
+ * @param bufferWidth - The drawing buffer's width in device pixels.
267
+ * @param bufferHeight - The drawing buffer's height in device pixels.
268
+ * @returns World units per plan unit, or `1` while either is degenerate.
269
+ */
270
+ export declare function fitScale(viewbox: Box, bufferWidth: number, bufferHeight: number): number;
271
+ /**
272
+ * The scene's space, published by {@link Scene}. The default is the identity space, so a component
273
+ * rendered without one still converts — it just converts nothing.
274
+ */
275
+ export declare const SpaceContext: import("react").Context<Space>;
276
+ /**
277
+ * Points a raycaster from a camera through a point in normalized device coordinates.
278
+ *
279
+ * The fallback is for a camera whose projection was handed to it rather than derived from a frustum
280
+ * — an external host like maplibre supplies one — which three's own `setFromCamera` refuses. It unprojects the
281
+ * same screen point on the near and far planes; both lie on the true ray whatever the matrix folds,
282
+ * where anchoring the origin at the eye would need a camera transform such a camera does not carry.
283
+ *
284
+ * Exported for the external event system, which must aim R3F's raycaster the same way; the space's own
285
+ * conversions go through the module's private raycaster.
286
+ * @param raycaster - The raycaster to aim.
287
+ * @param ndc - The point in normalized device coordinates.
288
+ * @param camera - The camera to cast from.
289
+ */
290
+ export declare function castRay(raycaster: Raycaster, ndc: NDCPointLike, camera: Camera): void;
291
+ /**
292
+ * The last step of both paths into world space: mirror z.
293
+ *
294
+ * Plan space is left-handed — x right, y **down**, z up — where three's world is right-handed, so
295
+ * one axis has to flip and z is it: the plan's up is world `-z`, the side the camera is on.
296
+ *
297
+ * The flip belongs in the plan → world matrix and nowhere else. three reads a face's winding from
298
+ * that matrix's determinant alone (`matrixWorld.determinantAffine() < 0`) and never from the
299
+ * projection, so a reflection anywhere else is invisible to it: every `DoubleSide` lit surface
300
+ * negates its normal and shades from behind.
301
+ *
302
+ * **Assumes a host's world shares the plan's handedness**, which mercator does — x east, y south,
303
+ * z up — resolving the clash inside its own projection instead (`MercatorTransform._calcMatrices`
304
+ * scales by `[1, -1, 1]`). So the same flip serves both paths, and external mode undoes it on the
305
+ * host's own matrix (`setExternalCameraProjection`). A host with a right-handed world would
306
+ * need it skipped on both — a `leftHandedWorld` flag on the external contract is where that choice
307
+ * would go.
308
+ */
309
+ export declare const HANDEDNESS_FLIP: Matrix4;
310
+ /**
311
+ * The plan's y-down convention, mirrored for a consumer that reads y as up.
312
+ *
313
+ * One value, two unrelated roles. In `ImageInstance.tsx` it is the plan-to-view y mirror composed
314
+ * into a screen-space quad's own 2D linear map, so the quad's offset reads correctly once the
315
+ * shader plants it in the view basis. In `MemberTexture.ts` it is the camera's own rest pose
316
+ * relative to the plan. Its job there is to stop that pose being applied twice, once baked into a
317
+ * member's own matrix and once more by the ordinary view transform at draw time. That role does
318
+ * not depend on the sign of a member's own `scale.y`. The requirement is that the billboard matrix
319
+ * equal the flat matrix at the rest pose, and the scale cancels from both sides of that equality.
320
+ *
321
+ * The two roles share a value by coincidence of geometry, not by a shared derivation. Check both
322
+ * call sites before changing this constant for either reason.
323
+ */
324
+ export declare const Y_DOWN_FLIP: Matrix4;
325
+ //# sourceMappingURL=Space.d.ts.map