@navaramap/three 0.0.2 → 0.0.4

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 (45) hide show
  1. package/README.md +7 -7
  2. package/dist/assets/{fontWorker-8oWvyvwL.js → fontWorker-wz61edjR.js} +2 -2
  3. package/dist/assets/{fontWorker-8oWvyvwL.js.map → fontWorker-wz61edjR.js.map} +1 -1
  4. package/dist/assets/{index-D9G7kIEj.js → index-ywHSGImj.js} +3 -3
  5. package/dist/assets/{index-D9G7kIEj.js.map → index-ywHSGImj.js.map} +1 -1
  6. package/dist/assets/{navara_wasm_font_worker_bg-CkZP9l2i.wasm → navara_wasm_font_worker_bg-Du9nb2Pn.wasm} +0 -0
  7. package/dist/assets/{navara_wasm_worker_bg-Q8zrkLCR.wasm → navara_wasm_worker_bg-Xadu67fw.wasm} +0 -0
  8. package/dist/index.d.ts +135 -4
  9. package/dist/index.js +4309 -4288
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.umd.cjs +223 -210
  12. package/dist/index.umd.cjs.map +1 -1
  13. package/package.json +12 -12
  14. package/src/ShadowMapViewers.ts +1 -1
  15. package/src/atmosphere.ts +43 -1
  16. package/src/declutter/DeclutterManager.ts +1 -1
  17. package/src/event/feature.ts +43 -13
  18. package/src/event/features/model.ts +1 -1
  19. package/src/event/features/polygon.ts +2 -1
  20. package/src/event/index.ts +1 -1
  21. package/src/index.iife.ts +3 -3
  22. package/src/index.ts +3 -3
  23. package/src/input.ts +48 -15
  24. package/src/layers/effect/README.md +1 -1
  25. package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/mutates.test.ts +3 -2
  26. package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/mutates.ts +2 -0
  27. package/src/material/enhancer/instancedSprite/instancedSpriteBaseEnhancer/types.ts +2 -0
  28. package/src/material/enhancer/polygon/polygonBaseEnhancer/mutates.ts +2 -0
  29. package/src/material/enhancer/polygon/polygonBaseEnhancer/shader.ts +5 -1
  30. package/src/material/enhancer/polygon/polygonBaseEnhancer/types.ts +2 -0
  31. package/src/material/enhancer/polyline/polylineBaseEnhancer/mutates.ts +2 -0
  32. package/src/material/enhancer/polyline/polylineBaseEnhancer/types.ts +2 -0
  33. package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/mutates.ts +2 -0
  34. package/src/material/enhancer/sdfText/sdfTextBaseEnhancer/types.ts +2 -0
  35. package/src/material/overrideMaterialsForMRT.ts +7 -2
  36. package/src/mesh/batchedSdfText.ts +234 -70
  37. package/src/mesh/instanced.ts +1 -1
  38. package/src/mesh/polygon.ts +11 -4
  39. package/src/mesh/polyline.ts +10 -2
  40. package/src/mesh/rtcRteHelper.ts +1 -1
  41. package/src/mesh/sdfText.ts +7 -2
  42. package/src/mesh/sprite/instancedSprite.ts +1 -1
  43. package/src/solar.test.ts +33 -0
  44. package/src/solar.ts +31 -0
  45. package/src/utils/screen.ts +1 -1
package/dist/index.d.ts CHANGED
@@ -6,10 +6,10 @@ import { BufferAttribute } from 'three';
6
6
  import { BufferGeometry } from 'three';
7
7
  import { BufferGeometryEventMap } from 'three';
8
8
  import { Camera } from 'three';
9
- import { CascadedShadowMaps } from '@navaramap/three_csm';
9
+ import { CascadedShadowMaps } from '@navaramap/three-csm';
10
10
  import { Color as Color_3 } from 'three';
11
11
  import { CopyPass as CopyPass_2 } from 'postprocessing';
12
- import { CSMHelper } from '@navaramap/three_csm';
12
+ import { CSMHelper } from '@navaramap/three-csm';
13
13
  import { CssFontFaceFilter } from '@navaramap/font';
14
14
  import { DataTexture } from 'three';
15
15
  import { DepthCopyPass } from 'postprocessing';
@@ -224,6 +224,40 @@ export declare class Atmosphere extends EventHandler<AtmosphereEvents> {
224
224
  * @returns `true` if the position is on the night side, `false` otherwise.
225
225
  */
226
226
  isAtNight(position: XYZ): boolean;
227
+ /**
228
+ * Returns the sun's elevation angle in degrees above the local horizon at
229
+ * `location` for the current {@link date}. Positive is above the horizon,
230
+ * negative below (night); includes atmospheric refraction.
231
+ *
232
+ * @example
233
+ * const elevation = view.atmosphere.getSunElevation(view.camera.positionGeographic);
234
+ * if (elevation < 0) console.log("The sun has set.");
235
+ */
236
+ getSunElevation(location: {
237
+ lat: number;
238
+ lng: number;
239
+ }): number;
240
+ /**
241
+ * Returns the local apparent solar time at `lng` for the current
242
+ * {@link date}, in hours in the range [0, 24) where 12 is solar noon.
243
+ * Accounts for the equation of time.
244
+ *
245
+ * @example
246
+ * const hours = view.atmosphere.getSolarTime({ lng: 139.69 }); // e.g. 6.3 = 06:18
247
+ */
248
+ getSolarTime(location: {
249
+ lng: number;
250
+ }): number;
251
+ /**
252
+ * Sets {@link date} so the local apparent solar time at `lng` equals `hours`
253
+ * (0–24), keeping the same solar day. Inverse of {@link getSolarTime}.
254
+ *
255
+ * @example
256
+ * view.atmosphere.setSolarTime({ lng: 139.69 }, 6.3); // sunrise over Tokyo
257
+ */
258
+ setSolarTime(location: {
259
+ lng: number;
260
+ }, hours: number): void;
227
261
  /**
228
262
  * Gets the current date used for calculating sun/moon positions.
229
263
  */
@@ -881,6 +915,15 @@ export declare class BatchedSdfTextMesh extends InstancedMesh<SDFTextMesh> imple
881
915
  * and must be balanced with unloadFont() on dispose or font change.
882
916
  */
883
917
  private _loadedFaceUrls;
918
+ /** Geometry-extracted anchor data; per-index meshes slice it lazily. */
919
+ private _positions;
920
+ /** Sparse batchIndex → mesh; `allMeshes` holds only created meshes. */
921
+ private _meshByIndex;
922
+ /** Evaluator state received before a feature's mesh exists. */
923
+ private _pending;
924
+ /** Material/transform used when creating meshes lazily. */
925
+ private _material;
926
+ private _transform;
884
927
  constructor(ctx: EventContext, m: TextMesh, fontIdentifier: string, options: InstancedMeshOptions, loadedFaceUrls?: Set<string>);
885
928
  collectDeclutterCandidates(out: DeclutterCandidate[]): void;
886
929
  applyDeclutter(handle: number, hidden: boolean): void;
@@ -898,13 +941,43 @@ export declare class BatchedSdfTextMesh extends InstancedMesh<SDFTextMesh> imple
898
941
  private _revalidateStaleMeshes;
899
942
  get fontIdentifier(): string;
900
943
  get highQuality(): boolean;
944
+ /**
945
+ * A mesh per anchor is expensive (geometry + ShaderMaterial + enhancer
946
+ * mount), and with per-feature texts (MVT) most features never receive a
947
+ * non-empty text — they'd sit invisible while still costing construction and
948
+ * every per-frame loop. So meshes are created lazily by `_ensureMeshAt` on
949
+ * the first non-empty `setTextByBatchIndex`. Only a non-empty material-level
950
+ * default text (single-label sources) renders without the evaluator ever
951
+ * setting text, so only that case creates all meshes eagerly.
952
+ */
901
953
  private initMeshes;
954
+ /** The font-level shared atlas textures for this batch's font+quality (the
955
+ * color atlas is `null` for monochrome fonts). */
956
+ private _sharedTextures;
957
+ /**
958
+ * The feature's mesh, created on first need (see `initMeshes`). `shared`
959
+ * lets a batch creation pass hoist the atlas lookups; when omitted (a single
960
+ * lazy creation) they are fetched here, since the atlas may have been
961
+ * (re)allocated since this batch was constructed.
962
+ */
963
+ private _ensureMeshAt;
964
+ /** Pending-state slot for a feature whose mesh doesn't exist yet. */
965
+ private _pendingAt;
902
966
  _update(m: TextMesh, needRender?: () => void): Promise<void>;
903
967
  private _applyUpdate;
904
968
  onBeforePicking(): void;
905
969
  onAfterPicking(): void;
906
970
  private extractPositions;
907
971
  setTextByBatchIndex(batchIndex: number, text: string): void;
972
+ /**
973
+ * The mesh for a feature's `batchIndex`, or `undefined` if not created yet.
974
+ * Meshes are created lazily and pushed onto `allMeshes` in creation order, so
975
+ * `allMeshes[batchIndex]` (the base-class mapping) does NOT hold here; the
976
+ * batchIndex→mesh mapping lives in `_meshByIndex`. Overriding this one
977
+ * accessor keeps the base-class setters and any external caller (picking,
978
+ * plugins) correct without patching each call site.
979
+ */
980
+ getMeshByBatchIndex(batchIndex: number): SDFTextMesh | undefined;
908
981
  setFeatureColorByBatchIndex(batchIndex: number, color: Color_3): void;
909
982
  setFeatureShowByBatchIndex(batchIndex: number, rawVisible: boolean): void;
910
983
  setFeatureHeightByBatchIndex(batchIndex: number, height: number): void;
@@ -3548,6 +3621,18 @@ declare class GeoJsonLayerDescription {
3548
3621
  get crs(): string | undefined;
3549
3622
  set crs(value: string | null | undefined);
3550
3623
  data: any;
3624
+ /**
3625
+ * Per-layer horizon dynamic-SSE relaxation strength for the tiled render
3626
+ * path (`0.0` off … `1.0` raster-equivalent). Omit for a content-based
3627
+ * default.
3628
+ */
3629
+ get dynamicSseScale(): number | undefined;
3630
+ /**
3631
+ * Per-layer horizon dynamic-SSE relaxation strength for the tiled render
3632
+ * path (`0.0` off … `1.0` raster-equivalent). Omit for a content-based
3633
+ * default.
3634
+ */
3635
+ set dynamicSseScale(value: number | null | undefined);
3551
3636
  get point(): PointMaterial | undefined;
3552
3637
  set point(value: PointMaterial | null | undefined);
3553
3638
  get polygon(): PolygonMaterial | undefined;
@@ -4036,7 +4121,7 @@ export declare class InstancedMesh<M extends Object3D> extends Mesh_2 implements
4036
4121
  addWithBatchIndex(m: M, batchIndex: number): void;
4037
4122
  markVisibility(m: M): void;
4038
4123
  meshes(): M[];
4039
- getMeshByBatchIndex(batchIndex: number): M;
4124
+ getMeshByBatchIndex(batchIndex: number): M | undefined;
4040
4125
  setFeatureColorByBatchIndex(batchIndex: number, color: Color_3): void;
4041
4126
  setFeatureShowByBatchIndex(batchIndex: number, rawVisible: boolean): void;
4042
4127
  setFeatureHeightByBatchIndex(batchIndex: number, height: number): void;
@@ -4215,6 +4300,8 @@ declare type InstancedSpriteBaseRefs = {
4215
4300
  uRTCCenterView: UniformValue<Vector3>;
4216
4301
  uEyeRTELow: UniformValue<Vector3>;
4217
4302
  uEyeRTEHigh: UniformValue<Vector3>;
4303
+ /** Always 1.0 — blocks fast-math reassociation of the RTE recombination. */
4304
+ u_rteOne?: UniformValue<number>;
4218
4305
  uScale: UniformValue<number>;
4219
4306
  uCenter: UniformValue<Vector2>;
4220
4307
  uSizeInMeters: UniformValue<boolean>;
@@ -4642,6 +4729,16 @@ declare class LegacyVectorTileMaterial {
4642
4729
  [Symbol.dispose](): void;
4643
4730
  get castShadow(): boolean | undefined;
4644
4731
  set castShadow(value: boolean | null | undefined);
4732
+ /**
4733
+ * Per-layer horizon dynamic-SSE relaxation strength (`0.0` off … `1.0`
4734
+ * raster-equivalent). Omit for a content-based default.
4735
+ */
4736
+ get dynamicSseScale(): number | undefined;
4737
+ /**
4738
+ * Per-layer horizon dynamic-SSE relaxation strength (`0.0` off … `1.0`
4739
+ * raster-equivalent). Omit for a content-based default.
4740
+ */
4741
+ set dynamicSseScale(value: number | null | undefined);
4645
4742
  /**
4646
4743
  * Sub-layer filter (MapLibre's `source-layer`). This is the only render-side
4647
4744
  * field; the rest is fetch config carried onto the implicit source.
@@ -4656,6 +4753,8 @@ declare class LegacyVectorTileMaterial {
4656
4753
  set maxSse(value: number | null | undefined);
4657
4754
  get maxZoom(): number | undefined;
4658
4755
  set maxZoom(value: number | null | undefined);
4756
+ get minZoom(): number | undefined;
4757
+ set minZoom(value: number | null | undefined);
4659
4758
  get overscaledMaxZoom(): number | undefined;
4660
4759
  set overscaledMaxZoom(value: number | null | undefined);
4661
4760
  get receiveShadow(): boolean | undefined;
@@ -6532,6 +6631,8 @@ declare type PolygonBaseRefs = {
6532
6631
  modelViewMatrixRTE?: UniformValue<Matrix4>;
6533
6632
  u_cameraPositionHigh?: UniformValue<Vector3>;
6534
6633
  u_cameraPositionLow?: UniformValue<Vector3>;
6634
+ /** Always 1.0 — blocks fast-math reassociation of the RTE recombination. */
6635
+ u_rteOne?: UniformValue<number>;
6535
6636
  };
6536
6637
 
6537
6638
  /**
@@ -7027,6 +7128,8 @@ declare type PolylineBaseRefs = {
7027
7128
  modelViewMatrixRTE?: UniformValue<Matrix4>;
7028
7129
  u_cameraPositionHigh?: UniformValue<Vector3>;
7029
7130
  u_cameraPositionLow?: UniformValue<Vector3>;
7131
+ /** Always 1.0 — blocks fast-math reassociation of the RTE recombination. */
7132
+ u_rteOne?: UniformValue<number>;
7030
7133
  };
7031
7134
 
7032
7135
  /**
@@ -7761,6 +7864,20 @@ declare class ReturnedTransferablePolylineBatchedFeature {
7761
7864
  material: PolylineMaterial;
7762
7865
  }
7763
7866
 
7867
+ /**
7868
+ * Shared `u_rteOne` uniform for RTE vertex shaders. Always 1.0.
7869
+ *
7870
+ * Multiplying the high-order difference by a uniform the shader compiler
7871
+ * cannot constant-fold blocks fast-math reassociation of
7872
+ * `(high - camHigh) + (low - camLow)` into `(high + low) - (camHigh + camLow)`,
7873
+ * which would collapse the math to absolute-ECEF f32 precision and make
7874
+ * geometry freeze/snap in ~0.25-0.5 m steps as the camera moves
7875
+ * (observed on ANGLE Metal). One frozen object is shared by every material.
7876
+ */
7877
+ export declare const RTE_ONE_UNIFORM: {
7878
+ readonly value: number;
7879
+ };
7880
+
7764
7881
  /**
7765
7882
  * Interface for objects that need RTE (Relative-To-Eye) rendering support
7766
7883
  */
@@ -7900,6 +8017,8 @@ declare type SdfTextBaseRefs = {
7900
8017
  uRTCCenterView: UniformValue<Vector3>;
7901
8018
  uEyeRTELow: UniformValue<Vector3>;
7902
8019
  uEyeRTEHigh: UniformValue<Vector3>;
8020
+ /** Always 1.0 — blocks fast-math reassociation of the RTE recombination. */
8021
+ u_rteOne?: UniformValue<number>;
7903
8022
  nvr_uBatchId: UniformValue<number>;
7904
8023
  nvr_uPickable: UniformValue<number>;
7905
8024
  uAtlas: UniformValue<DataTexture | null>;
@@ -8007,7 +8126,7 @@ export declare class SDFTextMesh extends Mesh_2<InstancedBufferGeometry, ShaderM
8007
8126
  constructor(position: Float32Array | {
8008
8127
  high: Float32Array;
8009
8128
  low: Float32Array;
8010
- }, material: TextMaterial, transform: Transform_2, fontManager: FontManager, fontUrl: string, batchId: number | undefined, RTE: boolean);
8129
+ }, material: TextMaterial, transform: Transform_2, fontManager: FontManager, fontUrl: string, batchId: number | undefined, RTE: boolean, highQuality: boolean);
8011
8130
  /** The text this mesh currently renders (its baked glyph string). */
8012
8131
  get text(): string;
8013
8132
  /**
@@ -10330,10 +10449,22 @@ export declare class UnknownTypeError extends Error {
10330
10449
  [Symbol.dispose](): void;
10331
10450
  get crs(): string | undefined;
10332
10451
  set crs(value: string | null | undefined);
10452
+ /**
10453
+ * Per-layer horizon dynamic-SSE relaxation strength (`0.0` off … `1.0`
10454
+ * raster-equivalent). Omit for a content-based default.
10455
+ */
10456
+ get dynamicSseScale(): number | undefined;
10457
+ /**
10458
+ * Per-layer horizon dynamic-SSE relaxation strength (`0.0` off … `1.0`
10459
+ * raster-equivalent). Omit for a content-based default.
10460
+ */
10461
+ set dynamicSseScale(value: number | null | undefined);
10333
10462
  get maxSse(): number | undefined;
10334
10463
  set maxSse(value: number | null | undefined);
10335
10464
  get maxZoom(): number | undefined;
10336
10465
  set maxZoom(value: number | null | undefined);
10466
+ get minZoom(): number | undefined;
10467
+ set minZoom(value: number | null | undefined);
10337
10468
  get overscaledMaxZoom(): number | undefined;
10338
10469
  set overscaledMaxZoom(value: number | null | undefined);
10339
10470
  get type(): string | undefined;