venue-js 1.0.0-next.2 → 1.0.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -693,7 +693,7 @@ type Element2DRendererOptions = {
693
693
  unit?: TypeRenderOptions<maptalks.PolygonOptionsType>;
694
694
  kiosk?: TypeRenderOptions<maptalks.PolygonOptionsType>;
695
695
  door?: TypeRenderOptions<maptalks.LineStringOptionsType>;
696
- occupant?: TypeRenderOptions<maptalks.UIMarkerOptionsType>;
696
+ fixture?: TypeRenderOptions<maptalks.PolygonOptionsType>;
697
697
  };
698
698
  /** 3D */
699
699
  type CreateExtrudePolygonOptionType = ExtrudePolygonOptionType & {
@@ -726,7 +726,11 @@ declare class RendererManager extends EventTarget {
726
726
  set dataClient(value: any);
727
727
  getElementsByOrdinal: (ordinal: number) => any[];
728
728
  changeLevelByOrdinal(targetOrdinal: null | number | number[]): void;
729
- createMarker(coordinate: Position, ordinal: number, label: string): void;
729
+ /**
730
+ * ========================================================================
731
+ * Markers
732
+ * ======================================================================== */
733
+ createMarker(coordinate: Position, ordinal: number, markerSymbol: any): void;
730
734
  }
731
735
 
732
736
  interface IndoorMapOptions {
@@ -879,7 +883,7 @@ declare class IndoorMap extends EventTarget {
879
883
  /**
880
884
  * Change Level & animate to path / geometry / view / etc.
881
885
  * ================================== */
882
- changeLevelByOrdinal(ordinal: number | number[]): void;
886
+ changeLevelByOrdinal(ordinal: null | number | number[]): void;
883
887
  getFeatureExtent: (feature: any, scaleFactor?: number) => any;
884
888
  getExtentCenter: (extent: Extent) => any;
885
889
  getExtentZoom: (extent: Extent, options?: {
package/dist/index.d.ts CHANGED
@@ -693,7 +693,7 @@ type Element2DRendererOptions = {
693
693
  unit?: TypeRenderOptions<maptalks.PolygonOptionsType>;
694
694
  kiosk?: TypeRenderOptions<maptalks.PolygonOptionsType>;
695
695
  door?: TypeRenderOptions<maptalks.LineStringOptionsType>;
696
- occupant?: TypeRenderOptions<maptalks.UIMarkerOptionsType>;
696
+ fixture?: TypeRenderOptions<maptalks.PolygonOptionsType>;
697
697
  };
698
698
  /** 3D */
699
699
  type CreateExtrudePolygonOptionType = ExtrudePolygonOptionType & {
@@ -726,7 +726,11 @@ declare class RendererManager extends EventTarget {
726
726
  set dataClient(value: any);
727
727
  getElementsByOrdinal: (ordinal: number) => any[];
728
728
  changeLevelByOrdinal(targetOrdinal: null | number | number[]): void;
729
- createMarker(coordinate: Position, ordinal: number, label: string): void;
729
+ /**
730
+ * ========================================================================
731
+ * Markers
732
+ * ======================================================================== */
733
+ createMarker(coordinate: Position, ordinal: number, markerSymbol: any): void;
730
734
  }
731
735
 
732
736
  interface IndoorMapOptions {
@@ -879,7 +883,7 @@ declare class IndoorMap extends EventTarget {
879
883
  /**
880
884
  * Change Level & animate to path / geometry / view / etc.
881
885
  * ================================== */
882
- changeLevelByOrdinal(ordinal: number | number[]): void;
886
+ changeLevelByOrdinal(ordinal: null | number | number[]): void;
883
887
  getFeatureExtent: (feature: any, scaleFactor?: number) => any;
884
888
  getExtentCenter: (extent: Extent) => any;
885
889
  getExtentZoom: (extent: Extent, options?: {
package/dist/index.js CHANGED
@@ -790,7 +790,7 @@ var turf_bbox_default = bbox;
790
790
  // src/IndoorMap/IndoorMap.ts
791
791
  var import_transform_scale = __toESM(require("@turf/transform-scale"));
792
792
  var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
793
- var import_three9 = require("three");
793
+ var import_three8 = require("three");
794
794
  var import_maptalks9 = require("maptalks.three");
795
795
 
796
796
  // src/IndoorMap/constants.ts
@@ -3281,12 +3281,15 @@ var CameraManager = class {
3281
3281
  };
3282
3282
  };
3283
3283
 
3284
+ // src/IndoorMap/renderer/RendererManager.ts
3285
+ var import_min = __toESM(require("lodash/min"));
3286
+ var import_partition = __toESM(require("lodash/partition"));
3287
+
3284
3288
  // src/IndoorMap/renderer/Element3DRenderer.ts
3285
3289
  var maptalks5 = __toESM(require("maptalks"));
3286
3290
  var THREE2 = __toESM(require("three"));
3287
3291
  var import_maptalks7 = require("maptalks.three");
3288
3292
  var import_buffer2 = __toESM(require("@turf/buffer"));
3289
- var import_three8 = require("three");
3290
3293
 
3291
3294
  // src/IndoorMap/object3d/Escalator.ts
3292
3295
  var maptalks4 = __toESM(require("maptalks"));
@@ -3373,6 +3376,31 @@ var Escalator = class extends import_maptalks6.BaseObject {
3373
3376
  }
3374
3377
  };
3375
3378
 
3379
+ // src/IndoorMap/renderer/default/element3DRendererOptions.ts
3380
+ var element3DRendererOptions = {
3381
+ unit: {
3382
+ default: { color: "#ffffff", height: 4 },
3383
+ byCategory: {
3384
+ walkway: { color: "#cccccc", height: 0.1 },
3385
+ terrace: { color: "#cccccc", height: 0.1 },
3386
+ unenclosedarea: { color: "#cccccc", height: 0.2 },
3387
+ nonpublic: { color: "#999999", height: 0.3 },
3388
+ escalator: { height: 0.2 },
3389
+ room: { color: "#ffffff", height: 4, bottomHeight: 0.12 }
3390
+ }
3391
+ },
3392
+ kiosk: {
3393
+ default: { color: "#666666", height: 0.6, bottomHeight: 0.12 }
3394
+ },
3395
+ fixture: {
3396
+ default: { color: "#ffffff", height: 0.5 },
3397
+ byCategory: {
3398
+ water: { color: "#ACD7EC", height: 0.5 },
3399
+ vegetation: { color: "#91C499", height: 0.5 }
3400
+ }
3401
+ }
3402
+ };
3403
+
3376
3404
  // src/IndoorMap/renderer/Element3DRenderer/utils/svg2material.ts
3377
3405
  var import_three7 = require("three");
3378
3406
  var svgToDataURL = (svgString, scaleFactor = 1) => {
@@ -3447,9 +3475,10 @@ var DEFAULT_POLYGON_OPTION = {
3447
3475
  altitude: 0
3448
3476
  };
3449
3477
  var HEIGHT_METER = 4;
3478
+ var MULTIORDINAL_HEIGHT_METER = 10;
3450
3479
  var getGeometryOption = (feature2, options) => {
3451
3480
  try {
3452
- const option = options[feature2.feature_type];
3481
+ const option = options[feature2.feature_type] ?? element3DRendererOptions[feature2.feature_type];
3453
3482
  const category = feature2.properties.category;
3454
3483
  return (category && option.byCategory?.[category]) ?? option?.default ?? DEFAULT_POLYGON_OPTION;
3455
3484
  } catch (err) {
@@ -3502,45 +3531,11 @@ var Element3DRenderer = class extends EventTarget {
3502
3531
  if (!this.materialByColorMap) this.materialByColorMap = /* @__PURE__ */ new Map();
3503
3532
  const existingMaterial = this.materialByColorMap.get(color);
3504
3533
  if (existingMaterial) return existingMaterial;
3505
- const created = new import_three8.MeshLambertMaterial({ color, transparent: true });
3534
+ const created = new THREE2.MeshLambertMaterial({ color, transparent: true });
3506
3535
  created.toneMapped = false;
3507
3536
  this.materialByColorMap.set(color, created);
3508
3537
  return created;
3509
3538
  }
3510
- getOrCreateIconMaterial(key) {
3511
- if (!this.materialByKey) this.materialByKey = /* @__PURE__ */ new Map();
3512
- const existingMaterial = this.materialByKey.get(key);
3513
- if (existingMaterial) return existingMaterial;
3514
- const baseSymbol = {
3515
- markerType: "path",
3516
- markerPath: [
3517
- {
3518
- path: "M20.775 1.2H1.225V20.35H8.215L11.3 22.8L14.385 20.35H20.775V1.2Z",
3519
- fill: "#ff0000"
3520
- }
3521
- ],
3522
- markerPathWidth: 24,
3523
- markerPathHeight: 24
3524
- };
3525
- const markerSymbol = {
3526
- markerType: "path",
3527
- markerPath: [],
3528
- // TODO: Get Path by featureType.category
3529
- // markerPath: [{ fill: "#FFFFFF", path: "M 19 3 H 5 c -1.1 0 -2 0.9 -2 2 v 14 c 0 1.1 0.9 2 2 2 h 14 c 1.1 0 2 -0.9 2 -2 V 5 c 0 -1.1 -0.9 -2 -2 -2 Z m -2 6 h -1.7 l -5 9 H 7 c -0.83 0 -1.5 -0.67 -1.5 -1.5 S 6.17 15 7 15 h 1.7 l 5 -9 H 17 c 0.83 0 1.5 0.67 1.5 1.5 S 17.83 9 17 9 Z" }],
3530
- markerPathWidth: 24,
3531
- markerPathHeight: 24,
3532
- markerWidth: 24,
3533
- markerHeight: 24,
3534
- markerDy: 1.5,
3535
- markerDx: 1.5
3536
- };
3537
- const created = createSpriteMaterialByLabelSymbol2([
3538
- baseSymbol,
3539
- markerSymbol
3540
- ]);
3541
- this.materialByKey.set(key, created);
3542
- return created;
3543
- }
3544
3539
  createGeometry = (feature2) => {
3545
3540
  const options = getGeometryOption(feature2, this.options);
3546
3541
  const offset = options?.offset ?? 0;
@@ -3563,7 +3558,7 @@ var Element3DRenderer = class extends EventTarget {
3563
3558
  ];
3564
3559
  const topLines = this.threeLayer.toLines(
3565
3560
  topLineStrings,
3566
- { altitude: altitude + options.height + 1e-3, bottomHeight, interactive: false },
3561
+ { altitude, bottomHeight: bottomHeight + options.height + 1e-3, interactive: false },
3567
3562
  this.lineMaterial
3568
3563
  );
3569
3564
  const bottomLineStrings = [
@@ -3598,6 +3593,41 @@ var Element3DRenderer = class extends EventTarget {
3598
3593
  console.log(`error createGeometry`, { feature: feature2, options });
3599
3594
  }
3600
3595
  };
3596
+ /** Marker */
3597
+ getOrCreateIconMaterial(key) {
3598
+ if (!this.materialByKey) this.materialByKey = /* @__PURE__ */ new Map();
3599
+ const existingMaterial = this.materialByKey.get(key);
3600
+ if (existingMaterial) return existingMaterial;
3601
+ const baseSymbol = {
3602
+ markerType: "path",
3603
+ markerPath: [
3604
+ {
3605
+ path: "M20.775 1.2H1.225V20.35H8.215L11.3 22.8L14.385 20.35H20.775V1.2Z",
3606
+ fill: "#ff0000"
3607
+ }
3608
+ ],
3609
+ markerPathWidth: 24,
3610
+ markerPathHeight: 24
3611
+ };
3612
+ const markerSymbol = {
3613
+ markerType: "path",
3614
+ markerPath: [],
3615
+ // TODO: Get Path by featureType.category
3616
+ // markerPath: [{ fill: "#FFFFFF", path: "M 19 3 H 5 c -1.1 0 -2 0.9 -2 2 v 14 c 0 1.1 0.9 2 2 2 h 14 c 1.1 0 2 -0.9 2 -2 V 5 c 0 -1.1 -0.9 -2 -2 -2 Z m -2 6 h -1.7 l -5 9 H 7 c -0.83 0 -1.5 -0.67 -1.5 -1.5 S 6.17 15 7 15 h 1.7 l 5 -9 H 17 c 0.83 0 1.5 0.67 1.5 1.5 S 17.83 9 17 9 Z" }],
3617
+ markerPathWidth: 24,
3618
+ markerPathHeight: 24,
3619
+ markerWidth: 24,
3620
+ markerHeight: 24,
3621
+ markerDy: 1.5,
3622
+ markerDx: 1.5
3623
+ };
3624
+ const created = createSpriteMaterialByLabelSymbol2([
3625
+ baseSymbol,
3626
+ markerSymbol
3627
+ ]);
3628
+ this.materialByKey.set(key, created);
3629
+ return created;
3630
+ }
3601
3631
  createMarker = (coordinates, ordinal, label) => {
3602
3632
  const options = {
3603
3633
  scale: 0.05,
@@ -3641,6 +3671,17 @@ var Element3DRenderer = class extends EventTarget {
3641
3671
  return null;
3642
3672
  }
3643
3673
  }
3674
+ showElements(elements, ordinalDiff = 0) {
3675
+ elements.forEach((element) => {
3676
+ element.setAltitude(ordinalDiff * MULTIORDINAL_HEIGHT_METER);
3677
+ element.show();
3678
+ });
3679
+ }
3680
+ hideElements(elements, ordinalDiff = 0) {
3681
+ elements.forEach((element) => {
3682
+ element.hide();
3683
+ });
3684
+ }
3644
3685
  render() {
3645
3686
  this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate;
3646
3687
  if (this.threeLayer._needsUpdate) {
@@ -3652,7 +3693,32 @@ var Element3DRenderer = class extends EventTarget {
3652
3693
 
3653
3694
  // src/IndoorMap/renderer/Element2DRenderer.ts
3654
3695
  var maptalks6 = __toESM(require("maptalks"));
3655
- var OCCUPANT_TEXT_MARKER_CLASSNAME2 = "mtk-occupant-text-marker";
3696
+
3697
+ // src/IndoorMap/renderer/default/element2DRendererOptions.ts
3698
+ var element2DRendererOptions = {
3699
+ unit: {
3700
+ default: { symbol: { polygonFill: "#cccccc" } },
3701
+ byCategory: {
3702
+ room: { symbol: { polygonFill: "#fff" } },
3703
+ walkway: { symbol: { polygonFill: "#efefef", lineColor: "#dadada", lineWidth: 2 } },
3704
+ terrace: { symbol: { polygonFill: "#efefef" } },
3705
+ unenclosedarea: { symbol: { polygonFill: "#fff" } },
3706
+ nonpublic: { symbol: { polygonFill: "#999999" } }
3707
+ }
3708
+ },
3709
+ kiosk: {
3710
+ default: {}
3711
+ },
3712
+ fixture: {
3713
+ default: { symbol: { polygonFill: "#ffffff" } },
3714
+ byCategory: {
3715
+ water: { symbol: { polygonFill: "#ACD7EC" } },
3716
+ vegetation: { symbol: { polygonFill: "#91C499" } }
3717
+ }
3718
+ }
3719
+ };
3720
+
3721
+ // src/IndoorMap/renderer/Element2DRenderer.ts
3656
3722
  var DEFAULT_POLYGON_OPTION2 = {
3657
3723
  zIndex: 0,
3658
3724
  symbol: {
@@ -3662,6 +3728,7 @@ var DEFAULT_POLYGON_OPTION2 = {
3662
3728
  lineWidth: 2
3663
3729
  }
3664
3730
  };
3731
+ var MULTIORDINAL_HEIGHT_METER2 = 10;
3665
3732
  var getGeometryProperties = (feature2) => ({
3666
3733
  // Core
3667
3734
  type: "Feature",
@@ -3671,11 +3738,11 @@ var getGeometryProperties = (feature2) => ({
3671
3738
  // Extra
3672
3739
  feature_type: feature2.feature_type,
3673
3740
  category: feature2.properties.category,
3674
- name: feature2.properties.name.en
3741
+ name: feature2.properties.name?.en
3675
3742
  });
3676
3743
  var getGeometryOption2 = (feature2, options) => {
3677
3744
  try {
3678
- const option = options[feature2.feature_type];
3745
+ const option = options[feature2.feature_type] ?? element2DRendererOptions[feature2.feature_type];
3679
3746
  const category = feature2.properties.category;
3680
3747
  return (category && option.byCategory?.[category]) ?? option?.default ?? DEFAULT_POLYGON_OPTION2;
3681
3748
  } catch (err) {
@@ -3720,36 +3787,63 @@ var Element2DRenderer = class extends EventTarget {
3720
3787
  return geometry;
3721
3788
  }
3722
3789
  };
3723
- createMarker = (coordinates, ordinal, label) => {
3724
- const createStyledUIMarkerElement2 = ({ style: style2, textContent, className }) => {
3725
- const element = document.createElement("div");
3726
- for (const key in style2) {
3727
- element.style[key] = style2[key];
3728
- }
3729
- element.className = className;
3730
- element.textContent = textContent;
3731
- return element.outerHTML;
3732
- };
3733
- const style = {};
3734
- const marker = new maptalks6.ui.UIMarker(coordinates, {
3735
- content: createStyledUIMarkerElement2({
3736
- style,
3737
- textContent: label,
3738
- className: OCCUPANT_TEXT_MARKER_CLASSNAME2
3739
- }),
3740
- collision: true,
3741
- collisionFadeIn: true
3742
- // altitude: getAltitude(f.properties) + markerHeight,
3743
- });
3744
- marker.addTo(this.map);
3745
- return marker;
3746
- };
3747
3790
  createElement = (imdfFeature) => {
3748
3791
  switch (imdfFeature.feature_type) {
3749
3792
  default:
3750
3793
  return null;
3751
3794
  }
3752
3795
  };
3796
+ showElements(elements, ordinalDiff = 0) {
3797
+ elements.forEach((element) => {
3798
+ element.setAltitude(ordinalDiff * MULTIORDINAL_HEIGHT_METER2);
3799
+ element.show();
3800
+ });
3801
+ }
3802
+ hideElements(elements, ordinalDiff = 0) {
3803
+ elements.forEach((element) => {
3804
+ element.hide();
3805
+ });
3806
+ }
3807
+ // createMarker = (
3808
+ // coordinates: Position,
3809
+ // ordinal: number,
3810
+ // label: string
3811
+ // ): maptalks.ui.UIMarker => {
3812
+ // const createStyledUIMarkerElement = ({ style, textContent, className }) => {
3813
+ // const element = document.createElement("div")
3814
+ // for (const key in style) {
3815
+ // element.style[key] = style[key]
3816
+ // }
3817
+ // element.className = className
3818
+ // element.textContent = textContent
3819
+ // //! Use outerHTML to return HTML string instead of element object to avoid DOM event warnings from Maptalks.js.
3820
+ // return element.outerHTML
3821
+ // }
3822
+ // const style = {}
3823
+ // // const markerHeight = 0
3824
+ // const marker = new maptalks.ui.UIMarker(coordinates, {
3825
+ // content: createStyledUIMarkerElement({
3826
+ // style,
3827
+ // textContent: label,
3828
+ // className: OCCUPANT_TEXT_MARKER_CLASSNAME,
3829
+ // }),
3830
+ // collision: true,
3831
+ // collisionFadeIn: true,
3832
+ // altitude: MULTIORDINAL_HEIGHT_METER * ordinal,
3833
+ // })
3834
+ // marker.addTo(this.map)
3835
+ // return marker
3836
+ // }
3837
+ createMarker = (coordinates, ordinal, content) => {
3838
+ const marker = new maptalks6.ui.UIMarker(coordinates, {
3839
+ content,
3840
+ collision: true,
3841
+ collisionFadeIn: true,
3842
+ altitude: MULTIORDINAL_HEIGHT_METER2 * ordinal
3843
+ });
3844
+ marker.addTo(this.map);
3845
+ return marker;
3846
+ };
3753
3847
  };
3754
3848
 
3755
3849
  // src/IndoorMap/renderer/RendererManager.ts
@@ -3773,6 +3867,7 @@ var RendererManager = class extends EventTarget {
3773
3867
  set dataClient(value) {
3774
3868
  this.#dataClient = value;
3775
3869
  if (this.elementRenderer.isReady) {
3870
+ this.dispatchEvent(new CustomEvent("renderermanager:ready"));
3776
3871
  this.#createElements();
3777
3872
  } else {
3778
3873
  this.elementRenderer.addEventListener("threelayer:ready", (e) => {
@@ -3804,7 +3899,18 @@ var RendererManager = class extends EventTarget {
3804
3899
  const units = await this.#dataClient.filterByType("unit", {
3805
3900
  populate: true
3806
3901
  });
3807
- units.filter(
3902
+ const [walkways, otherUnits] = (0, import_partition.default)(units, (u) => ["walkway"].includes(u.properties.category));
3903
+ walkways.forEach((unit) => {
3904
+ const element = this.elementRenderer.createGeometry(unit);
3905
+ if (element) {
3906
+ const _elements = Array.isArray(element) ? element : [element];
3907
+ _elements.forEach((el) => {
3908
+ this.elementsMap.set(unit.id, el);
3909
+ this.getElementsByOrdinal(unit.properties.level.properties.ordinal).push(el);
3910
+ });
3911
+ }
3912
+ });
3913
+ otherUnits.filter(
3808
3914
  (u) => !["opentobelow", "escalator"].includes(u.properties.category)
3809
3915
  ).forEach((unit) => {
3810
3916
  const element = this.elementRenderer.createGeometry(unit);
@@ -3832,22 +3938,30 @@ var RendererManager = class extends EventTarget {
3832
3938
  this.dispatchEvent(new CustomEvent("renderermanager:elements_created"));
3833
3939
  }
3834
3940
  changeLevelByOrdinal(targetOrdinal) {
3835
- for (const [ordinal, elements] of this.elementsByOrdinal) {
3836
- const inOrdinal = targetOrdinal === null ? true : Array.isArray(targetOrdinal) ? targetOrdinal.includes(ordinal) : ordinal === targetOrdinal;
3837
- if (inOrdinal) {
3838
- elements.forEach((element, i) => {
3839
- element.show();
3840
- });
3841
- } else {
3842
- elements.forEach((element) => {
3843
- element.hide();
3844
- });
3941
+ if (targetOrdinal === null) {
3942
+ const baseOrdinal = 0;
3943
+ for (const [ordinal, elements] of this.elementsByOrdinal) {
3944
+ this.elementRenderer.showElements(elements, ordinal - baseOrdinal);
3945
+ }
3946
+ } else {
3947
+ const baseOrdinal = Array.isArray(targetOrdinal) ? (0, import_min.default)(targetOrdinal) : targetOrdinal;
3948
+ for (const [ordinal, elements] of this.elementsByOrdinal) {
3949
+ const inOrdinal = Array.isArray(targetOrdinal) ? targetOrdinal.includes(ordinal) : ordinal === targetOrdinal;
3950
+ if (inOrdinal) {
3951
+ this.elementRenderer.showElements(elements, ordinal - baseOrdinal);
3952
+ } else {
3953
+ this.elementRenderer.hideElements(elements, ordinal - baseOrdinal);
3954
+ }
3845
3955
  }
3846
3956
  }
3847
3957
  }
3848
- createMarker(coordinate, ordinal, label) {
3849
- const marker = this.elementRenderer.createMarker(coordinate, ordinal, label);
3850
- this.elementsMap.set(label, marker);
3958
+ /**
3959
+ * ========================================================================
3960
+ * Markers
3961
+ * ======================================================================== */
3962
+ createMarker(coordinate, ordinal, markerSymbol) {
3963
+ console.log(`createMarker`, { coordinate, ordinal, markerSymbol });
3964
+ const marker = this.elementRenderer.createMarker(coordinate, ordinal, markerSymbol);
3851
3965
  this.getElementsByOrdinal(ordinal).push(marker);
3852
3966
  }
3853
3967
  };
@@ -4075,7 +4189,7 @@ var IndoorMap = class extends EventTarget {
4075
4189
  const scene = this.threeLayer.getScene();
4076
4190
  if (scene) {
4077
4191
  scene.children = scene.children.filter(
4078
- (children) => children instanceof import_three9.PerspectiveCamera
4192
+ (children) => children instanceof import_three8.PerspectiveCamera
4079
4193
  );
4080
4194
  }
4081
4195
  }