@equinor/videx-3d 1.1.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +120 -120
  2. package/dist/chunk-61X6qE5N.js +981 -0
  3. package/dist/chunk-ChG5d4HC.js +675 -0
  4. package/dist/{chunk-BlPg4RjP.js → chunk-M-Pcc_Yg.js} +19 -19
  5. package/dist/generators.js +271 -260
  6. package/dist/main.js +4919 -3344
  7. package/dist/sdk.js +92 -90
  8. package/dist/shaderLib/oit.glsl +106 -0
  9. package/dist/types/components/Annotations/AutoUpdate.d.ts +1 -1
  10. package/dist/types/components/Annotations/index.d.ts +2 -2
  11. package/dist/types/components/Annotations/types.d.ts +3 -1
  12. package/dist/types/components/Annotations/update-annotations.d.ts +10 -0
  13. package/dist/types/components/EventEmitter/picking-helper.d.ts +23 -1
  14. package/dist/types/components/Surfaces/Surface.d.ts +8 -1
  15. package/dist/types/components/Surfaces/SurfaceMaterial.d.ts +3 -0
  16. package/dist/types/components/Surfaces/surface-defs.d.ts +1 -0
  17. package/dist/types/generators/surface-generator.d.ts +1 -1
  18. package/dist/types/layers/layers.d.ts +4 -0
  19. package/dist/types/rendering/OitMaterial.d.ts +59 -0
  20. package/dist/types/rendering/Pass.d.ts +7 -0
  21. package/dist/types/rendering/RenderingPipeline.d.ts +37 -0
  22. package/dist/types/rendering/fullscreen-renderer.d.ts +1 -0
  23. package/dist/types/rendering/gpu-timer.d.ts +46 -0
  24. package/dist/types/rendering/index.d.ts +7 -1
  25. package/dist/types/rendering/oit-material.d.ts +122 -0
  26. package/dist/types/{components/Annotations/annotations-renderer.d.ts → rendering/passes/AnnotationsPass.d.ts} +13 -4
  27. package/dist/types/rendering/passes/FXAAPass.d.ts +12 -0
  28. package/dist/types/rendering/passes/OITRenderPass.d.ts +282 -0
  29. package/dist/types/rendering/passes/OutputPass.d.ts +10 -0
  30. package/dist/types/rendering/passes/RenderPass.d.ts +8 -0
  31. package/dist/types/rendering/passes/SMAAPass.d.ts +40 -0
  32. package/dist/types/rendering/passes/TAAPass.d.ts +94 -0
  33. package/dist/types/rendering/passes/index.d.ts +6 -0
  34. package/dist/types/rendering/rendering-state.d.ts +59 -0
  35. package/dist/types/sdk/utils/elevation-map.d.ts +23 -0
  36. package/dist/types/sdk/utils/trigonometry.d.ts +4 -1
  37. package/package.json +1 -1
  38. package/dist/chunk-CnY6Tmof.js +0 -358
  39. package/dist/chunk-iY0wQ9Z6.js +0 -887
  40. package/dist/types/rendering/render-passes.d.ts +0 -16
package/dist/sdk.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { wrap as Y } from "comlink";
2
2
  import R from "p-limit";
3
- import { d as K } from "./chunk-iY0wQ9Z6.js";
4
- import { x as xt, D as bt, P as vt, b as Mt, a as Ct, c as Et, T as Bt, y as At, z as zt, A as Ft, B as It, p as St, E as Lt, F as Vt, G as Tt, H as Pt, I as Dt, J as Gt, K as qt, L as jt, M as kt, e as Nt, N as Ot, o as Qt, O as Ut, Q as Wt, R as Ht, i as Zt, S as $t, U as Jt, V as Kt, X as Xt, g as Yt, Y as Rt, Z as te, _ as ee, $ as se, h as ie, m as ne, a0 as re, a1 as ae, a2 as oe, n as le, a3 as he, f as ce, a4 as fe, a5 as ue, a6 as de, a7 as ge, a8 as me, a9 as pe, aa as ye, ab as _e, ac as we, ad as xe, ae as be, af as ve, ag as Me, s as Ce, ah as Ee, ai as Be, aj as Ae, u as ze, ak as Fe } from "./chunk-iY0wQ9Z6.js";
5
- import { C as Se, T as Le, c as Ve, b as Te, a as Pe, d as De, e as Ge, g as qe, f as je, t as ke, h as Ne, w as Oe } from "./chunk-CnY6Tmof.js";
6
- import { D as Ue, c as We, a as He, b as Ze, d as $e, m as Je, t as Ke, e as Xe, f as Ye } from "./chunk-BlPg4RjP.js";
3
+ import { d as K } from "./chunk-61X6qE5N.js";
4
+ import { y as xt, D as bt, P as vt, b as Mt, a as Ct, c as Et, T as Bt, z as At, A as zt, B as Ft, E as St, q as It, F as Lt, G as Vt, i as Tt, H as Pt, j as qt, I as Dt, J as Gt, K as jt, L as kt, M as Nt, N as Ot, O as Qt, Q as Ut, e as Wt, R as Ht, S as Zt, p as $t, U as Jt, V as Kt, X as Xt, h as Yt, Y as Rt, Z as te, _ as ee, $ as se, g as ie, a0 as ne, a1 as re, a2 as ae, a3 as oe, m as le, a4 as he, a5 as ce, a6 as fe, a7 as ue, n as de, a8 as ge, f as me, a9 as pe, aa as ye, ab as _e, ac as we, ad as xe, ae as be, af as ve, ag as Me, ah as Ce, ai as Ee, aj as Be, ak as Ae, al as ze, s as Fe, am as Se, an as Ie, ao as Le, ap as Ve, u as Te, aq as Pe } from "./chunk-61X6qE5N.js";
5
+ import { C as De, T as Ge, c as je, b as ke, g as Ne, e as Oe, t as Qe, w as Ue } from "./chunk-ChG5d4HC.js";
6
+ import { D as He, c as Ze, a as $e, b as Je, d as Ke, m as Xe, t as Ye, e as Re, f as ts } from "./chunk-M-Pcc_Yg.js";
7
7
  import { Vector2 as N, Shape as tt, Path as et } from "three";
8
8
  const st = 10, it = 25;
9
9
  class lt {
@@ -308,12 +308,12 @@ class $ extends W {
308
308
  function ct(u, t, e = 1, s = 1, i = (r) => r) {
309
309
  console.time("triangulate");
310
310
  const r = [], n = [], a = [], c = [], h = u.length / t;
311
- let o, l, d, g, b, y, _, v, C, A, x, z, M, E, B, G, f, O, V, T, P, m, w, Q, X = 0, U = 0, J = 0, I = new Array(t).fill(null), q = new Array(t).fill(null);
311
+ let o, l, d, g, b, y, _, v, C, A, x, z, M, E, B, D, f, O, V, T, P, m, w, Q, X = 0, U = 0, J = 0, S = new Array(t).fill(null), G = new Array(t).fill(null);
312
312
  const p = new Array(t - 1).fill(null);
313
- function j(F, L, D) {
314
- return r.push({ x: F * e, y: D, z: L * s, edge: null }), a.push(F / (t - 1), 1 - L / (h - 1)), X++;
313
+ function j(F, L, q) {
314
+ return r.push({ x: F * e, y: q, z: L * s, edge: null }), a.push(F / (t - 1), 1 - L / (h - 1)), X++;
315
315
  }
316
- function S(F, L, D) {
316
+ function I(F, L, q) {
317
317
  V = {
318
318
  index: U++,
319
319
  tail: F,
@@ -324,24 +324,24 @@ function ct(u, t, e = 1, s = 1, i = (r) => r) {
324
324
  }, T = {
325
325
  index: U++,
326
326
  tail: L,
327
- head: D,
327
+ head: q,
328
328
  twin: null,
329
329
  prev: null,
330
330
  next: null
331
331
  }, P = {
332
332
  index: U++,
333
- tail: D,
333
+ tail: q,
334
334
  head: F,
335
335
  twin: null,
336
336
  prev: null,
337
337
  next: null
338
- }, V.next = T, T.next = P, P.next = V, V.prev = P, T.prev = V, P.prev = T, r[F].edge || (r[F].edge = V), r[L].edge || (r[L].edge = T), r[D].edge || (r[D].edge = P), n.push(V, T, P), c.push(F, L, D);
338
+ }, V.next = T, T.next = P, P.next = V, V.prev = P, T.prev = V, P.prev = T, r[F].edge || (r[F].edge = V), r[L].edge || (r[L].edge = T), r[q].edge || (r[q].edge = P), n.push(V, T, P), c.push(F, L, q);
339
339
  }
340
- for (G = 1; G < h - 1; G++) {
340
+ for (D = 1; D < h - 1; D++) {
341
341
  Q = !1;
342
- const F = I;
343
- for (I = q, q = F.fill(null), m = null, O = G - 1, J += t, B = 1; B < t - 1; B++)
344
- f = B - 1, A = J + B, C = A - 1, v = A - t, _ = v - 1, x = i(u[_]), z = i(u[v]), M = i(u[C]), E = i(u[A]), x !== null && z !== null && M !== null && E !== null ? w = 1 : x !== null && z !== null && M !== null ? w = 2 : x !== null && z !== null && E !== null ? w = 3 : x !== null && M !== null && E !== null ? w = 4 : z !== null && M !== null && E !== null ? w = 5 : w = 0, d = null, g = null, w !== 0 ? (Q ? (o = I[f], d = q[f]) : (w !== 5 && (I[f] === null ? (o = j(f, O, x), I[f] = o) : o = I[f]), w !== 3 && (d = j(f, G, M)), q[f] = d), w !== 4 && (I[B] === null ? (l = j(B, O, z), I[B] = l) : l = I[B]), w !== 2 && (g = j(B, G, E)), w === 1 ? (b = Math.abs(r[o].y - r[g].y), y = Math.abs(r[l].y - r[d].y), b < y ? (S(o, d, g), m !== null && (n[n.length - 3].twin = m, m.twin = n[n.length - 3]), S(g, l, o), p[f] !== null && (n[n.length - 2].twin = p[f], p[f].twin = n[n.length - 2]), n[n.length - 4].twin = n[n.length - 1], n[n.length - 1].twin = n[n.length - 4], p[f] = n[n.length - 5], m = n[n.length - 3]) : (S(o, d, l), p[f] !== null && (n[n.length - 1].twin = p[f], p[f].twin = n[n.length - 1]), m !== null && (n[n.length - 3].twin = m, m.twin = n[n.length - 3]), S(l, d, g), n[n.length - 5].twin = n[n.length - 3], n[n.length - 3].twin = n[n.length - 5], p[f] = n[n.length - 2], m = n[n.length - 1])) : w === 2 ? (S(o, d, l), p[f] !== null && (n[n.length - 1].twin = p[f], p[f].twin = n[n.length - 1]), m !== null && (n[n.length - 3].twin = m, m.twin = n[n.length - 3]), p[f] = null, m = null) : w === 5 ? (S(l, d, g), p[f] = n[n.length - 2], m = n[n.length - 1]) : w === 3 ? (S(l, o, g), p[f] !== null && (n[n.length - 3].twin = p[f], p[f].twin = n[n.length - 3]), p[f] = null, m = n[n.length - 1]) : (S(o, d, g), m !== null && (n[n.length - 3].twin = m, m.twin = n[n.length - 3]), p[f] = n[n.length - 2], m = null)) : (p[f] = null, m = null), q[B] = g, Q = !!w;
342
+ const F = S;
343
+ for (S = G, G = F.fill(null), m = null, O = D - 1, J += t, B = 1; B < t - 1; B++)
344
+ f = B - 1, A = J + B, C = A - 1, v = A - t, _ = v - 1, x = i(u[_]), z = i(u[v]), M = i(u[C]), E = i(u[A]), x !== null && z !== null && M !== null && E !== null ? w = 1 : x !== null && z !== null && M !== null ? w = 2 : x !== null && z !== null && E !== null ? w = 3 : x !== null && M !== null && E !== null ? w = 4 : z !== null && M !== null && E !== null ? w = 5 : w = 0, d = null, g = null, w !== 0 ? (Q ? (o = S[f], d = G[f]) : (w !== 5 && (S[f] === null ? (o = j(f, O, x), S[f] = o) : o = S[f]), w !== 3 && (d = j(f, D, M)), G[f] = d), w !== 4 && (S[B] === null ? (l = j(B, O, z), S[B] = l) : l = S[B]), w !== 2 && (g = j(B, D, E)), w === 1 ? (b = Math.abs(r[o].y - r[g].y), y = Math.abs(r[l].y - r[d].y), b < y ? (I(o, d, g), m !== null && (n[n.length - 3].twin = m, m.twin = n[n.length - 3]), I(g, l, o), p[f] !== null && (n[n.length - 2].twin = p[f], p[f].twin = n[n.length - 2]), n[n.length - 4].twin = n[n.length - 1], n[n.length - 1].twin = n[n.length - 4], p[f] = n[n.length - 5], m = n[n.length - 3]) : (I(o, d, l), p[f] !== null && (n[n.length - 1].twin = p[f], p[f].twin = n[n.length - 1]), m !== null && (n[n.length - 3].twin = m, m.twin = n[n.length - 3]), I(l, d, g), n[n.length - 5].twin = n[n.length - 3], n[n.length - 3].twin = n[n.length - 5], p[f] = n[n.length - 2], m = n[n.length - 1])) : w === 2 ? (I(o, d, l), p[f] !== null && (n[n.length - 1].twin = p[f], p[f].twin = n[n.length - 1]), m !== null && (n[n.length - 3].twin = m, m.twin = n[n.length - 3]), p[f] = null, m = null) : w === 5 ? (I(l, d, g), p[f] = n[n.length - 2], m = n[n.length - 1]) : w === 3 ? (I(l, o, g), p[f] !== null && (n[n.length - 3].twin = p[f], p[f].twin = n[n.length - 3]), p[f] = null, m = n[n.length - 1]) : (I(o, d, g), m !== null && (n[n.length - 3].twin = m, m.twin = n[n.length - 3]), p[f] = n[n.length - 2], m = null)) : (p[f] = null, m = null), G[B] = g, Q = !!w;
345
345
  }
346
346
  return console.timeEnd("triangulate"), console.log(c.length / 3), { vertices: r, indices: c, uvs: a, edges: n };
347
347
  }
@@ -681,10 +681,10 @@ function yt(u) {
681
681
  return t;
682
682
  }
683
683
  export {
684
- Se as CRS,
684
+ De as CRS,
685
685
  xt as CameraManager,
686
686
  lt as DataLoader,
687
- Ue as Delatin,
687
+ He as Delatin,
688
688
  bt as DepthReadMaterial,
689
689
  ht as GeneratorRegistry,
690
690
  vt as PI,
@@ -696,90 +696,92 @@ export {
696
696
  H as PlanarPointGeometry,
697
697
  $ as PlanarPolygonGeometry,
698
698
  Bt as TAU,
699
- Le as TubeMaterial,
699
+ Ge as TubeMaterial,
700
700
  k as Typed2DArray,
701
701
  At as WellboreManager,
702
702
  zt as addVec2,
703
703
  Ft as addVec3,
704
- It as angleVec3,
705
- St as calculateFrenetFrames,
706
- We as calculateHashValue,
707
- Ve as calculateWellSegments,
704
+ St as angleVec3,
705
+ It as calculateFrenetFrames,
706
+ Ze as calculateHashValue,
707
+ je as calculateWellSegments,
708
708
  K as clamp,
709
- Lt as copyVec3,
710
- Te as createConfig,
711
- Pe as createElevationTexture,
712
- He as createFenceGeometry,
713
- De as createNormalTexture,
714
- Ze as createTubeGeometries,
715
- $e as createTubeGeometry,
716
- Vt as crossVec3,
717
- Tt as degreesToRadians,
718
- Pt as directionVec2,
719
- Dt as directionVec3,
720
- Gt as distanceVec2,
721
- qt as distanceVec3,
722
- jt as dotVec2,
723
- kt as dotVec3,
724
- Nt as edgeOfRectangle,
725
- Ge as elevationMapNormalsToRGBA,
726
- Ot as feetToMeters,
727
- Qt as getCurvePositions,
728
- Ut as getFormationMarkers,
709
+ Lt as computeSurfaceNormalsRG,
710
+ Vt as copyVec3,
711
+ ke as createConfig,
712
+ Tt as createElevationTexture,
713
+ $e as createFenceGeometry,
714
+ Pt as createNormalTexture,
715
+ qt as createPackedNormalTexture,
716
+ Je as createTubeGeometries,
717
+ Ke as createTubeGeometry,
718
+ Dt as crossVec3,
719
+ Gt as degreesToRadians,
720
+ jt as directionVec2,
721
+ kt as directionVec3,
722
+ Nt as distanceVec2,
723
+ Ot as distanceVec3,
724
+ Qt as dotVec2,
725
+ Ut as dotVec3,
726
+ Wt as edgeOfRectangle,
727
+ Ht as elevationMapNormalsToRGBA,
728
+ Zt as feetToMeters,
729
+ $t as getCurvePositions,
730
+ Jt as getFormationMarkers,
729
731
  pt as getObjectByCustomProperty,
730
- Wt as getProjectedTrajectory,
731
- qe as getProjectionDefFromUtmZone,
732
- Ht as getSplineCurve,
733
- Zt as getTrajectory,
734
- $t as getTypedArrayFromBuffer,
735
- Jt as getTypedArrayType,
736
- je as getUtmZoneFromLatLng,
737
- Kt as getVec2,
738
- Xt as getVec3,
739
- Yt as getWellboreFormations,
732
+ Kt as getProjectedTrajectory,
733
+ Ne as getProjectionDefFromUtmZone,
734
+ Xt as getSplineCurve,
735
+ Yt as getTrajectory,
736
+ Rt as getTypedArrayFromBuffer,
737
+ te as getTypedArrayType,
738
+ Oe as getUtmZoneFromLatLng,
739
+ ee as getVec2,
740
+ se as getVec3,
741
+ ie as getWellboreFormations,
740
742
  ft as idToHexColor,
741
- Rt as inverseLerp,
742
- te as lengthVec2,
743
- ee as lengthVec3,
744
- se as lerp,
745
- ie as mergeFormationIntervals,
746
- Je as mergeGeometries,
747
- ne as mixVec2,
748
- re as mixVec3,
743
+ ne as inverseLerp,
744
+ re as lengthVec2,
745
+ ae as lengthVec3,
746
+ oe as lerp,
747
+ le as mergeFormationIntervals,
748
+ Xe as mergeGeometries,
749
+ he as mixVec2,
750
+ ce as mixVec3,
749
751
  mt as multiply,
750
752
  gt as negate,
751
- ae as negateVec2,
752
- oe as negateVec3,
753
- le as normalizeVec2,
754
- he as normalizeVec3,
755
- ce as normalizedDeviceToScreen,
756
- fe as packAttribute,
757
- ue as packBufferGeometries,
758
- de as packBufferGeometry,
759
- ge as packBufferGeometryLike,
753
+ fe as negateVec2,
754
+ ue as negateVec3,
755
+ de as normalizeVec2,
756
+ ge as normalizeVec3,
757
+ me as normalizedDeviceToScreen,
758
+ pe as packAttribute,
759
+ ye as packBufferGeometries,
760
+ _e as packBufferGeometry,
761
+ we as packBufferGeometryLike,
760
762
  dt as parseIrapbin,
761
763
  ut as randomColor,
762
- me as readDepth,
763
- pe as remap,
764
- ye as rotateVec3,
765
- _e as scaleVec2,
766
- we as scaleVec3,
767
- xe as screenToNormalizedDevice,
768
- be as setVec2,
769
- ve as setVec3,
770
- Me as simplifyCurve2D,
771
- Ce as subVec2,
772
- Ee as subVec3,
773
- Ke as titleCase,
774
- Xe as toBufferGeometry,
764
+ xe as readDepth,
765
+ be as remap,
766
+ ve as rotateVec3,
767
+ Me as scaleVec2,
768
+ Ce as scaleVec3,
769
+ Ee as screenToNormalizedDevice,
770
+ Be as setVec2,
771
+ Ae as setVec3,
772
+ ze as simplifyCurve2D,
773
+ Fe as subVec2,
774
+ Se as subVec3,
775
+ Ye as titleCase,
776
+ Re as toBufferGeometry,
775
777
  yt as toFloat32Array,
776
- Be as toRGB,
777
- ke as toSegments,
778
- Ne as triangleNormal,
778
+ Ie as toRGB,
779
+ Qe as toSegments,
780
+ Le as triangleNormal,
779
781
  ct as triangulateGrid,
780
- Ye as triangulateGridDelaunay,
781
- Ae as unpackBufferGeometries,
782
- ze as unpackBufferGeometry,
783
- Fe as uvMaterial,
784
- Oe as wgs84Def
782
+ ts as triangulateGridDelaunay,
783
+ Ve as unpackBufferGeometries,
784
+ Te as unpackBufferGeometry,
785
+ Pe as uvMaterial,
786
+ Ue as wgs84Def
785
787
  };
@@ -0,0 +1,106 @@
1
+ // Order-independent transparency (OIT) shared shader chunk.
2
+ //
3
+ // Provides the uniforms and the per-pass output logic used by the OITRenderPass
4
+ // hybrid pipeline (exact depth-peeled front layer + weighted-blended OIT tail).
5
+ //
6
+ // Usage (library ShaderMaterials, GLSL1 / gl_FragColor):
7
+ // #include <this file> // brings uniforms + oitProcess()
8
+ // ...
9
+ // gl_FragColor = ...; // compute final straight (non-premultiplied) color
10
+ // #ifdef USE_OIT
11
+ // gl_FragColor = oitProcess(gl_FragColor);
12
+ // #endif
13
+ //
14
+ // The fragment shader must have `vViewPosition` (view-space position) available.
15
+ //
16
+ // Pass selection is driven by defines set on the per-pass variant materials:
17
+ // USE_OIT enables the whole block
18
+ // OIT_DEPTH_PASS min-depth pre-pass (writes linear view-space depth)
19
+ // OIT_FRONT_PASS exact front layer (alpha-over, discards tail fragments)
20
+ // (none of the above, USE_OIT only) => single-buffer weighted-blended OIT tail
21
+ //
22
+ // The WBOIT tail uses a single RGBA16F accumulation target with optical-depth
23
+ // weighting: each fragment contributes weight b = -ln(1 - alpha), so
24
+ // accum.rgb = sum(rgb * b), accum.a = sum(b).
25
+ // The composite recovers the weighted-average colour as accum.rgb / accum.a and the
26
+ // coverage as 1 - exp(-accum.a) = 1 - prod(1 - alpha) -- identical to a separate
27
+ // (ZERO, ONE_MINUS_SRC_COLOR) reveal pass, but without the extra rasterisation.
28
+ //
29
+ // The `oitSkipFront` uniform (1) disables front peeling so the tail pass keeps the
30
+ // front fragments too (debug: everything resolved through WBOIT).
31
+
32
+ #ifdef USE_OIT
33
+
34
+ uniform float oitDepthFar; // normalisation factor for view-space depth
35
+ uniform vec2 oitScreenSize; // render target size in pixels
36
+ uniform sampler2D oitMinDepthTexture; // per-pixel min linear depth (front layer)
37
+ uniform int oitSkipFront; // 1 = disable front peeling (debug: all WBOIT)
38
+ uniform float oitOcclusionThreshold; // occlusion-stamp pass: min alpha to write depth
39
+
40
+ // Process the straight (non-premultiplied) fragment color for the active pass.
41
+ vec4 oitProcess(vec4 color) {
42
+ #ifdef OIT_OCCLUSION_PASS
43
+ // Occlusion depth stamp: write depth only where this surface is opaque enough
44
+ // (its own alpha clears the threshold). Colour writes are disabled on the
45
+ // variant, so the returned colour is ignored; discarding skips the depth write.
46
+ // Lets sufficiently-opaque transparent surfaces occlude annotation labels even
47
+ // though they don't write depth in the regular OIT passes.
48
+ if(color.a < oitOcclusionThreshold)
49
+ discard;
50
+ return color;
51
+ #endif
52
+
53
+ // View-space linear depth, normalised. Independent of the (logarithmic) depth
54
+ // buffer encoding, so the partition is correct at any camera scale.
55
+ float linZ = abs(vViewPosition.z) / oitDepthFar;
56
+
57
+ #ifdef OIT_DEPTH_PASS
58
+
59
+ // Written into an R32F target with MinEquation blending => per-pixel minimum.
60
+ return vec4(linZ, 0.0, 0.0, 1.0);
61
+
62
+ #else
63
+
64
+ // Gradient-relative tolerance: only the surface that produced the per-pixel
65
+ // minimum qualifies as "front". A fixed epsilon would form a depth slab and let
66
+ // distinct surfaces grazing within it bleed into each other.
67
+ vec2 uv = gl_FragCoord.xy / oitScreenSize;
68
+ float minZ = texture2D(oitMinDepthTexture, uv).r;
69
+ // Depth-relative tolerance. The min-depth pre-pass and this pass rasterise the
70
+ // SAME geometry with the SAME vertex transform, so the genuine front fragment's
71
+ // linZ matches the stored minZ to near bit-exactness; a tiny epsilon suffices.
72
+ // Avoid fwidth(linZ) here: at self-overlap silhouettes the 2x2 derivative quads
73
+ // straddle the depth discontinuity between layers, so fwidth spikes and inflates
74
+ // the tolerance, misclassifying back-layer fragments as front (visible edges).
75
+ float tol = minZ * 1e-3 + 1e-6;
76
+ bool isFront = (linZ - minZ) <= tol;
77
+
78
+ #ifdef OIT_FRONT_PASS
79
+
80
+ // Exact front layer: keep only the nearest fragment, blended alpha-over.
81
+ if(!isFront)
82
+ discard;
83
+ return color;
84
+
85
+ #else
86
+
87
+ // Tail pass: exclude the front fragment (handled exactly by the front pass),
88
+ // unless front peeling is disabled (debug: every fragment goes through WBOIT).
89
+ if(isFront && oitSkipFront == 0)
90
+ discard;
91
+
92
+ float alpha = color.a;
93
+
94
+ // Optical-depth weight b = -ln(1 - alpha). Additive (ONE, ONE) blending then gives
95
+ // accum.rgb = sum(rgb * b), accum.a = sum(b). The composite reconstructs both the
96
+ // weighted-average colour (accum.rgb / accum.a) and the coverage
97
+ // (1 - exp(-accum.a) = 1 - prod(1 - alpha)) from this single buffer, so no separate
98
+ // reveal pass is needed. alpha is clamped below 1 to keep b finite.
99
+ float b = -log(1.0 - clamp(alpha, 0.0, 0.9999));
100
+ return vec4(color.rgb * b, b);
101
+
102
+ #endif // OIT_FRONT_PASS
103
+ #endif // OIT_DEPTH_PASS
104
+ }
105
+
106
+ #endif // USE_OIT
@@ -1,3 +1,3 @@
1
1
  export declare const AutoUpdate: ({ maxVisible }: {
2
2
  maxVisible: number;
3
- }) => null;
3
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import { Vec3 } from '../../sdk';
2
2
  import { AnnotationProps } from './types';
3
+ export * from '../../rendering/passes/AnnotationsPass';
3
4
  export * from './Annotations';
4
- export * from './annotations-renderer';
5
5
  export * from './annotations-state';
6
6
  export * from './AnnotationsLayer';
7
7
  export * from './types';
8
- export declare const getAnnotationPosition: (annotation: AnnotationProps) => Vec3;
8
+ export declare const getAnnotationPosition: (annotation: AnnotationProps, target?: Vec3) => Vec3;
@@ -55,7 +55,7 @@ export type AnnotationInstanceState = {
55
55
  kill?: boolean;
56
56
  cooldown?: number;
57
57
  opacity?: number;
58
- labelWidht: number;
58
+ labelWidth: number;
59
59
  labelHeight: number;
60
60
  labelX?: number;
61
61
  labelY?: number;
@@ -68,6 +68,8 @@ export type AnnotationInstanceState = {
68
68
  _zIndex?: string;
69
69
  _transform?: string;
70
70
  _needsUpdate?: boolean;
71
+ _connPrevX?: number;
72
+ _connPrevY?: number;
71
73
  };
72
74
  export type AnnotationInstance = {
73
75
  id: string;
@@ -1,6 +1,16 @@
1
1
  import { Clock, PerspectiveCamera } from 'three';
2
2
  import { Vec2 } from '../../sdk';
3
3
  import { AnnotationInstance } from './types';
4
+ /**
5
+ * Activity flags updated by preprocessInstances each frame. Used by
6
+ * AnnotationsPass to skip the expensive post-process/overlay work when the
7
+ * scene is settled (camera static and no animations in progress).
8
+ */
9
+ export declare const annotationsActivity: {
10
+ animating: boolean;
11
+ positionChanged: boolean;
12
+ deltaTime: number;
13
+ };
4
14
  /**
5
15
  * PRE-PROCESS INSTANCES
6
16
  */
@@ -19,10 +19,26 @@ export declare class PickingHelper {
19
19
  private _radius;
20
20
  private _pbo;
21
21
  private _buffer;
22
+ private _prevClearColor;
22
23
  private _material;
24
+ /**
25
+ * Dedicated camera used for the picking render so the shared scene camera is
26
+ * never mutated. `setViewOffset` rebuilds a camera's projection (it remaps the
27
+ * frustum to the tiny patch under the cursor), and that mutation would clobber
28
+ * any external modification of the real camera's projection — e.g. the
29
+ * sub-pixel jitter a TAA pass bakes in. Each pick this camera is `copy()`d from
30
+ * the real camera (which faithfully mirrors `matrixWorld`,
31
+ * `matrixWorldInverse`, the projection and all intrinsics) and the view offset
32
+ * is applied here instead. `matrixWorldAutoUpdate` is disabled so the renderer
33
+ * uses the copied world matrix verbatim rather than recomputing it.
34
+ */
35
+ private _camera;
23
36
  private _listeners;
24
37
  private _emitters;
25
- private _currentObjectMap;
38
+ private _mapStarts;
39
+ private _mapObjectIds;
40
+ private _objectMapLength;
41
+ private _objectMapCount;
26
42
  constructor(options?: {});
27
43
  private traverseObject;
28
44
  updateListeners: () => void;
@@ -30,6 +46,12 @@ export declare class PickingHelper {
30
46
  getListener: (id: number) => Listener | undefined;
31
47
  removeListener: (id: number) => void;
32
48
  render(pointer: Vector2, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera): Promise<PickResult>;
49
+ /**
50
+ * Locate the emitter owning a flat id via binary search. Emitter ranges are
51
+ * contiguous and sorted by start, so the owner is the rightmost entry whose
52
+ * start is `<= flatId`.
53
+ */
54
+ private findEmitterIndex;
33
55
  private pick;
34
56
  dispose(): void;
35
57
  }
@@ -28,6 +28,13 @@ export type SurfaceProps = CommonComponentProps & PointerEvents & {
28
28
  wireframe?: boolean;
29
29
  normalMap?: Texture;
30
30
  normalScale?: Vec2;
31
+ /**
32
+ * Precompute the surface normals into a compact texture instead of deriving
33
+ * them per-fragment from the elevation map. This skips the normal recompute
34
+ * the shader otherwise repeats across the order-independent transparency
35
+ * passes, at the cost of a little extra texture memory. Defaults to `false`.
36
+ */
37
+ precomputeNormals?: boolean;
31
38
  debug?: boolean;
32
39
  };
33
40
  /**
@@ -43,4 +50,4 @@ export type SurfaceProps = CommonComponentProps & PointerEvents & {
43
50
  *
44
51
  * @group Components
45
52
  */
46
- export declare const Surface: ({ meta, color, colorRamp, rampMin, rampMax, reverseRamp, useColorRamp, showContours, contoursInterval, contoursColorMode, contoursColorModeFactor, contoursThickness, contoursColor, opacity, priority, maxError, doubleSide, wireframe, normalMap, normalScale, name, userData, receiveShadow, castShadow, layers, position, renderOrder, visible, debug, onPointerClick, onPointerEnter, onPointerLeave, onPointerMove, }: SurfaceProps) => import("react/jsx-runtime").JSX.Element | null;
53
+ export declare const Surface: ({ meta, color, colorRamp, rampMin, rampMax, reverseRamp, useColorRamp, showContours, contoursInterval, contoursColorMode, contoursColorModeFactor, contoursThickness, contoursColor, opacity, priority, maxError, doubleSide, wireframe, normalMap, normalScale, precomputeNormals, name, userData, receiveShadow, castShadow, layers, position, renderOrder, visible, debug, onPointerClick, onPointerEnter, onPointerLeave, onPointerMove, }: SurfaceProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -20,6 +20,7 @@ export type SurfaceMaterialParameters = ShaderMaterialParameters & MeshLambertMa
20
20
  contoursColor?: string | number | Color;
21
21
  elevationTexture?: Texture;
22
22
  normalTexture?: Texture;
23
+ usePrecomputedNormals?: boolean;
23
24
  debug?: boolean;
24
25
  };
25
26
  /**
@@ -48,6 +49,8 @@ export declare class SurfaceMaterial extends ShaderMaterial {
48
49
  set showContours(value: any);
49
50
  get debug(): any;
50
51
  set debug(value: any);
52
+ get usePrecomputedNormals(): any;
53
+ set usePrecomputedNormals(value: any);
51
54
  dispose(): void;
52
55
  onBeforeCompile(): void;
53
56
  }
@@ -4,4 +4,5 @@ export declare const surfaceTextures = "surfaceTextures";
4
4
  export type SurfaceGeometryResponse = PackedBufferGeometry;
5
5
  export type SurfaceTexturesResponse = {
6
6
  elevationImageBuffer: Float32Array;
7
+ normalImageBuffer?: Uint8Array;
7
8
  };
@@ -1,4 +1,4 @@
1
1
  import { SurfaceTexturesResponse } from '../main';
2
2
  import { PackedBufferGeometry, ReadonlyStore } from '../sdk';
3
- export declare function generateSurfaceTexturesData(this: ReadonlyStore, id: string): Promise<SurfaceTexturesResponse | null>;
3
+ export declare function generateSurfaceTexturesData(this: ReadonlyStore, id: string, computeNormals?: boolean): Promise<SurfaceTexturesResponse | null>;
4
4
  export declare function generateSurfaceGeometry(this: ReadonlyStore, id: string, maxError?: number): Promise<PackedBufferGeometry | null>;
@@ -1,5 +1,9 @@
1
1
  import { Layers } from 'three';
2
2
  export declare const LAYERS: {
3
+ OIT_EXCLUDED: number;
4
+ FORCE_OPAQUE: number;
5
+ OVERLAY: number;
6
+ EMISSIVE: number;
3
7
  NOT_EMITTER: number;
4
8
  EMITTER: number;
5
9
  };
@@ -0,0 +1,59 @@
1
+ import { Side } from 'three';
2
+ /**
3
+ * Props for {@link OitMaterial}.
4
+ * @expand
5
+ */
6
+ export type OitMaterialProps = {
7
+ /**
8
+ * Force a specific `side` on the OIT variants (e.g. `DoubleSide`). Defaults to
9
+ * the material's own side.
10
+ */
11
+ side?: Side;
12
+ /**
13
+ * Names of custom uniform-container properties on the material to share by
14
+ * reference with the per-pass variants. Only needed for non-`ShaderMaterial`
15
+ * materials that read a custom uniforms object in `onBeforeCompile`.
16
+ */
17
+ shareUniforms?: string[];
18
+ /**
19
+ * Names of value properties (e.g. `color`, `metalness`) to keep live on the
20
+ * per-pass variants of a cloned built-in material. See
21
+ * {@link OitMaterialOptions.syncProperties}. Ignored for `ShaderMaterial`s
22
+ * (already live via shared uniforms).
23
+ */
24
+ syncProperties?: string[];
25
+ /**
26
+ * - `inject` (default): patch the material's shaders at compile time (stock or
27
+ * inline materials whose shader does not already include `oit.glsl`).
28
+ * - `attach`: the material's shader already `#include`s `oit.glsl` and calls
29
+ * `oitProcess` (library materials); only wire up the variant machinery.
30
+ */
31
+ mode?: 'inject' | 'attach';
32
+ };
33
+ /**
34
+ * A declarative helper that makes the material of its parent `mesh` participate in
35
+ * the {@link OITRenderPass} pipeline, so transparent inline materials are resolved
36
+ * order-independently instead of being treated as opaque occluders.
37
+ *
38
+ * Drop it in as a sibling of the material, inside the `mesh`:
39
+ *
40
+ * ```tsx
41
+ * <mesh geometry={geometry}>
42
+ * <shaderMaterial
43
+ * uniforms={uniforms}
44
+ * vertexShader={vertexShader}
45
+ * fragmentShader={fragmentShader}
46
+ * transparent
47
+ * />
48
+ * <OitMaterial side={DoubleSide} />
49
+ * </mesh>
50
+ * ```
51
+ *
52
+ * It renders an invisible, empty `object3D` purely to locate the parent mesh; the
53
+ * wiring is idempotent and a no-op outside the OIT pipeline.
54
+ *
55
+ * @group Rendering
56
+ * @see {@link makeOitCompatible}
57
+ * @see {@link attachOitVariants}
58
+ */
59
+ export declare function OitMaterial({ side, shareUniforms, syncProperties, mode, }: OitMaterialProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { WebGLRenderer, WebGLRenderTarget } from 'three';
2
+ export declare abstract class Pass {
3
+ writeToScreen: boolean;
4
+ setSize?(width: number, height: number, pixelRatio: number): void;
5
+ dispose?(): void;
6
+ abstract render(renderer: WebGLRenderer, buffer: WebGLRenderTarget): void;
7
+ }
@@ -0,0 +1,37 @@
1
+ import { Pass } from './Pass';
2
+ /**
3
+ * Props for the {@link RenderingPipeline} component.
4
+ * @expand
5
+ */
6
+ export type RenderingPipelineProps = {
7
+ /** Ordered list of passes to execute every frame. */
8
+ passes: Pass[];
9
+ /** Multisample count for the main render target. Defaults to 0. */
10
+ samples?: number;
11
+ /** Render target supersampling factor. Defaults to 1. */
12
+ supersample?: number;
13
+ /** Frame priority (passed to `useFrame`). Defaults to 1. */
14
+ priority?: number;
15
+ };
16
+ /**
17
+ * Generic render pipeline component that runs an ordered list of {@link Pass} objects
18
+ * against a shared `WebGLRenderTarget` (color + depth texture). Use it to compose
19
+ * custom rendering pipelines — e.g. a {@link OITRenderPass} based pipeline for
20
+ * order-independent transparency.
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * const passes = useMemo(
25
+ * () => [new OITRenderPass(scene, camera), new OutputPass()],
26
+ * [scene, camera],
27
+ * );
28
+ * return <RenderingPipeline passes={passes} />;
29
+ * ```
30
+ *
31
+ * @group Components
32
+ * @category Rendering
33
+ * @see {@link Pass}
34
+ * @see {@link OITRenderPass}
35
+ * @see {@link OutputPass}
36
+ */
37
+ export declare const RenderingPipeline: ({ passes, samples, supersample, priority, }: RenderingPipelineProps) => null;
@@ -4,6 +4,7 @@ export declare class FullscreenRenderer {
4
4
  mesh: Mesh;
5
5
  copyMaterial: RawShaderMaterial;
6
6
  constructor();
7
+ dispose(): void;
7
8
  renderMaterial(renderer: WebGLRenderer, buffer: WebGLRenderTarget | null, material: Material): void;
8
9
  renderTexture(renderer: WebGLRenderer, buffer: WebGLRenderTarget | null, texture: Texture, opacity?: number): void;
9
10
  }