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.mjs CHANGED
@@ -3238,12 +3238,15 @@ var CameraManager = class {
3238
3238
  };
3239
3239
  };
3240
3240
 
3241
+ // src/IndoorMap/renderer/RendererManager.ts
3242
+ import _min from "lodash/min";
3243
+ import _partition from "lodash/partition";
3244
+
3241
3245
  // src/IndoorMap/renderer/Element3DRenderer.ts
3242
3246
  import * as maptalks5 from "maptalks";
3243
3247
  import * as THREE2 from "three";
3244
3248
  import { ThreeLayer as ThreeLayer3 } from "maptalks.three";
3245
3249
  import turfBuffer2 from "@turf/buffer";
3246
- import { MeshLambertMaterial as MeshLambertMaterial3 } from "three";
3247
3250
 
3248
3251
  // src/IndoorMap/object3d/Escalator.ts
3249
3252
  import * as maptalks4 from "maptalks";
@@ -3330,6 +3333,31 @@ var Escalator = class extends BaseObject5 {
3330
3333
  }
3331
3334
  };
3332
3335
 
3336
+ // src/IndoorMap/renderer/default/element3DRendererOptions.ts
3337
+ var element3DRendererOptions = {
3338
+ unit: {
3339
+ default: { color: "#ffffff", height: 4 },
3340
+ byCategory: {
3341
+ walkway: { color: "#cccccc", height: 0.1 },
3342
+ terrace: { color: "#cccccc", height: 0.1 },
3343
+ unenclosedarea: { color: "#cccccc", height: 0.2 },
3344
+ nonpublic: { color: "#999999", height: 0.3 },
3345
+ escalator: { height: 0.2 },
3346
+ room: { color: "#ffffff", height: 4, bottomHeight: 0.12 }
3347
+ }
3348
+ },
3349
+ kiosk: {
3350
+ default: { color: "#666666", height: 0.6, bottomHeight: 0.12 }
3351
+ },
3352
+ fixture: {
3353
+ default: { color: "#ffffff", height: 0.5 },
3354
+ byCategory: {
3355
+ water: { color: "#ACD7EC", height: 0.5 },
3356
+ vegetation: { color: "#91C499", height: 0.5 }
3357
+ }
3358
+ }
3359
+ };
3360
+
3333
3361
  // src/IndoorMap/renderer/Element3DRenderer/utils/svg2material.ts
3334
3362
  import { SpriteMaterial as SpriteMaterial4, TextureLoader as TextureLoader3 } from "three";
3335
3363
  var svgToDataURL = (svgString, scaleFactor = 1) => {
@@ -3404,9 +3432,10 @@ var DEFAULT_POLYGON_OPTION = {
3404
3432
  altitude: 0
3405
3433
  };
3406
3434
  var HEIGHT_METER = 4;
3435
+ var MULTIORDINAL_HEIGHT_METER = 10;
3407
3436
  var getGeometryOption = (feature2, options) => {
3408
3437
  try {
3409
- const option = options[feature2.feature_type];
3438
+ const option = options[feature2.feature_type] ?? element3DRendererOptions[feature2.feature_type];
3410
3439
  const category = feature2.properties.category;
3411
3440
  return (category && option.byCategory?.[category]) ?? option?.default ?? DEFAULT_POLYGON_OPTION;
3412
3441
  } catch (err) {
@@ -3459,45 +3488,11 @@ var Element3DRenderer = class extends EventTarget {
3459
3488
  if (!this.materialByColorMap) this.materialByColorMap = /* @__PURE__ */ new Map();
3460
3489
  const existingMaterial = this.materialByColorMap.get(color);
3461
3490
  if (existingMaterial) return existingMaterial;
3462
- const created = new MeshLambertMaterial3({ color, transparent: true });
3491
+ const created = new THREE2.MeshLambertMaterial({ color, transparent: true });
3463
3492
  created.toneMapped = false;
3464
3493
  this.materialByColorMap.set(color, created);
3465
3494
  return created;
3466
3495
  }
3467
- getOrCreateIconMaterial(key) {
3468
- if (!this.materialByKey) this.materialByKey = /* @__PURE__ */ new Map();
3469
- const existingMaterial = this.materialByKey.get(key);
3470
- if (existingMaterial) return existingMaterial;
3471
- const baseSymbol = {
3472
- markerType: "path",
3473
- markerPath: [
3474
- {
3475
- path: "M20.775 1.2H1.225V20.35H8.215L11.3 22.8L14.385 20.35H20.775V1.2Z",
3476
- fill: "#ff0000"
3477
- }
3478
- ],
3479
- markerPathWidth: 24,
3480
- markerPathHeight: 24
3481
- };
3482
- const markerSymbol = {
3483
- markerType: "path",
3484
- markerPath: [],
3485
- // TODO: Get Path by featureType.category
3486
- // 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" }],
3487
- markerPathWidth: 24,
3488
- markerPathHeight: 24,
3489
- markerWidth: 24,
3490
- markerHeight: 24,
3491
- markerDy: 1.5,
3492
- markerDx: 1.5
3493
- };
3494
- const created = createSpriteMaterialByLabelSymbol2([
3495
- baseSymbol,
3496
- markerSymbol
3497
- ]);
3498
- this.materialByKey.set(key, created);
3499
- return created;
3500
- }
3501
3496
  createGeometry = (feature2) => {
3502
3497
  const options = getGeometryOption(feature2, this.options);
3503
3498
  const offset = options?.offset ?? 0;
@@ -3520,7 +3515,7 @@ var Element3DRenderer = class extends EventTarget {
3520
3515
  ];
3521
3516
  const topLines = this.threeLayer.toLines(
3522
3517
  topLineStrings,
3523
- { altitude: altitude + options.height + 1e-3, bottomHeight, interactive: false },
3518
+ { altitude, bottomHeight: bottomHeight + options.height + 1e-3, interactive: false },
3524
3519
  this.lineMaterial
3525
3520
  );
3526
3521
  const bottomLineStrings = [
@@ -3555,6 +3550,41 @@ var Element3DRenderer = class extends EventTarget {
3555
3550
  console.log(`error createGeometry`, { feature: feature2, options });
3556
3551
  }
3557
3552
  };
3553
+ /** Marker */
3554
+ getOrCreateIconMaterial(key) {
3555
+ if (!this.materialByKey) this.materialByKey = /* @__PURE__ */ new Map();
3556
+ const existingMaterial = this.materialByKey.get(key);
3557
+ if (existingMaterial) return existingMaterial;
3558
+ const baseSymbol = {
3559
+ markerType: "path",
3560
+ markerPath: [
3561
+ {
3562
+ path: "M20.775 1.2H1.225V20.35H8.215L11.3 22.8L14.385 20.35H20.775V1.2Z",
3563
+ fill: "#ff0000"
3564
+ }
3565
+ ],
3566
+ markerPathWidth: 24,
3567
+ markerPathHeight: 24
3568
+ };
3569
+ const markerSymbol = {
3570
+ markerType: "path",
3571
+ markerPath: [],
3572
+ // TODO: Get Path by featureType.category
3573
+ // 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" }],
3574
+ markerPathWidth: 24,
3575
+ markerPathHeight: 24,
3576
+ markerWidth: 24,
3577
+ markerHeight: 24,
3578
+ markerDy: 1.5,
3579
+ markerDx: 1.5
3580
+ };
3581
+ const created = createSpriteMaterialByLabelSymbol2([
3582
+ baseSymbol,
3583
+ markerSymbol
3584
+ ]);
3585
+ this.materialByKey.set(key, created);
3586
+ return created;
3587
+ }
3558
3588
  createMarker = (coordinates, ordinal, label) => {
3559
3589
  const options = {
3560
3590
  scale: 0.05,
@@ -3598,6 +3628,17 @@ var Element3DRenderer = class extends EventTarget {
3598
3628
  return null;
3599
3629
  }
3600
3630
  }
3631
+ showElements(elements, ordinalDiff = 0) {
3632
+ elements.forEach((element) => {
3633
+ element.setAltitude(ordinalDiff * MULTIORDINAL_HEIGHT_METER);
3634
+ element.show();
3635
+ });
3636
+ }
3637
+ hideElements(elements, ordinalDiff = 0) {
3638
+ elements.forEach((element) => {
3639
+ element.hide();
3640
+ });
3641
+ }
3601
3642
  render() {
3602
3643
  this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate;
3603
3644
  if (this.threeLayer._needsUpdate) {
@@ -3609,7 +3650,32 @@ var Element3DRenderer = class extends EventTarget {
3609
3650
 
3610
3651
  // src/IndoorMap/renderer/Element2DRenderer.ts
3611
3652
  import * as maptalks6 from "maptalks";
3612
- var OCCUPANT_TEXT_MARKER_CLASSNAME2 = "mtk-occupant-text-marker";
3653
+
3654
+ // src/IndoorMap/renderer/default/element2DRendererOptions.ts
3655
+ var element2DRendererOptions = {
3656
+ unit: {
3657
+ default: { symbol: { polygonFill: "#cccccc" } },
3658
+ byCategory: {
3659
+ room: { symbol: { polygonFill: "#fff" } },
3660
+ walkway: { symbol: { polygonFill: "#efefef", lineColor: "#dadada", lineWidth: 2 } },
3661
+ terrace: { symbol: { polygonFill: "#efefef" } },
3662
+ unenclosedarea: { symbol: { polygonFill: "#fff" } },
3663
+ nonpublic: { symbol: { polygonFill: "#999999" } }
3664
+ }
3665
+ },
3666
+ kiosk: {
3667
+ default: {}
3668
+ },
3669
+ fixture: {
3670
+ default: { symbol: { polygonFill: "#ffffff" } },
3671
+ byCategory: {
3672
+ water: { symbol: { polygonFill: "#ACD7EC" } },
3673
+ vegetation: { symbol: { polygonFill: "#91C499" } }
3674
+ }
3675
+ }
3676
+ };
3677
+
3678
+ // src/IndoorMap/renderer/Element2DRenderer.ts
3613
3679
  var DEFAULT_POLYGON_OPTION2 = {
3614
3680
  zIndex: 0,
3615
3681
  symbol: {
@@ -3619,6 +3685,7 @@ var DEFAULT_POLYGON_OPTION2 = {
3619
3685
  lineWidth: 2
3620
3686
  }
3621
3687
  };
3688
+ var MULTIORDINAL_HEIGHT_METER2 = 10;
3622
3689
  var getGeometryProperties = (feature2) => ({
3623
3690
  // Core
3624
3691
  type: "Feature",
@@ -3628,11 +3695,11 @@ var getGeometryProperties = (feature2) => ({
3628
3695
  // Extra
3629
3696
  feature_type: feature2.feature_type,
3630
3697
  category: feature2.properties.category,
3631
- name: feature2.properties.name.en
3698
+ name: feature2.properties.name?.en
3632
3699
  });
3633
3700
  var getGeometryOption2 = (feature2, options) => {
3634
3701
  try {
3635
- const option = options[feature2.feature_type];
3702
+ const option = options[feature2.feature_type] ?? element2DRendererOptions[feature2.feature_type];
3636
3703
  const category = feature2.properties.category;
3637
3704
  return (category && option.byCategory?.[category]) ?? option?.default ?? DEFAULT_POLYGON_OPTION2;
3638
3705
  } catch (err) {
@@ -3677,36 +3744,63 @@ var Element2DRenderer = class extends EventTarget {
3677
3744
  return geometry;
3678
3745
  }
3679
3746
  };
3680
- createMarker = (coordinates, ordinal, label) => {
3681
- const createStyledUIMarkerElement2 = ({ style: style2, textContent, className }) => {
3682
- const element = document.createElement("div");
3683
- for (const key in style2) {
3684
- element.style[key] = style2[key];
3685
- }
3686
- element.className = className;
3687
- element.textContent = textContent;
3688
- return element.outerHTML;
3689
- };
3690
- const style = {};
3691
- const marker = new maptalks6.ui.UIMarker(coordinates, {
3692
- content: createStyledUIMarkerElement2({
3693
- style,
3694
- textContent: label,
3695
- className: OCCUPANT_TEXT_MARKER_CLASSNAME2
3696
- }),
3697
- collision: true,
3698
- collisionFadeIn: true
3699
- // altitude: getAltitude(f.properties) + markerHeight,
3700
- });
3701
- marker.addTo(this.map);
3702
- return marker;
3703
- };
3704
3747
  createElement = (imdfFeature) => {
3705
3748
  switch (imdfFeature.feature_type) {
3706
3749
  default:
3707
3750
  return null;
3708
3751
  }
3709
3752
  };
3753
+ showElements(elements, ordinalDiff = 0) {
3754
+ elements.forEach((element) => {
3755
+ element.setAltitude(ordinalDiff * MULTIORDINAL_HEIGHT_METER2);
3756
+ element.show();
3757
+ });
3758
+ }
3759
+ hideElements(elements, ordinalDiff = 0) {
3760
+ elements.forEach((element) => {
3761
+ element.hide();
3762
+ });
3763
+ }
3764
+ // createMarker = (
3765
+ // coordinates: Position,
3766
+ // ordinal: number,
3767
+ // label: string
3768
+ // ): maptalks.ui.UIMarker => {
3769
+ // const createStyledUIMarkerElement = ({ style, textContent, className }) => {
3770
+ // const element = document.createElement("div")
3771
+ // for (const key in style) {
3772
+ // element.style[key] = style[key]
3773
+ // }
3774
+ // element.className = className
3775
+ // element.textContent = textContent
3776
+ // //! Use outerHTML to return HTML string instead of element object to avoid DOM event warnings from Maptalks.js.
3777
+ // return element.outerHTML
3778
+ // }
3779
+ // const style = {}
3780
+ // // const markerHeight = 0
3781
+ // const marker = new maptalks.ui.UIMarker(coordinates, {
3782
+ // content: createStyledUIMarkerElement({
3783
+ // style,
3784
+ // textContent: label,
3785
+ // className: OCCUPANT_TEXT_MARKER_CLASSNAME,
3786
+ // }),
3787
+ // collision: true,
3788
+ // collisionFadeIn: true,
3789
+ // altitude: MULTIORDINAL_HEIGHT_METER * ordinal,
3790
+ // })
3791
+ // marker.addTo(this.map)
3792
+ // return marker
3793
+ // }
3794
+ createMarker = (coordinates, ordinal, content) => {
3795
+ const marker = new maptalks6.ui.UIMarker(coordinates, {
3796
+ content,
3797
+ collision: true,
3798
+ collisionFadeIn: true,
3799
+ altitude: MULTIORDINAL_HEIGHT_METER2 * ordinal
3800
+ });
3801
+ marker.addTo(this.map);
3802
+ return marker;
3803
+ };
3710
3804
  };
3711
3805
 
3712
3806
  // src/IndoorMap/renderer/RendererManager.ts
@@ -3730,6 +3824,7 @@ var RendererManager = class extends EventTarget {
3730
3824
  set dataClient(value) {
3731
3825
  this.#dataClient = value;
3732
3826
  if (this.elementRenderer.isReady) {
3827
+ this.dispatchEvent(new CustomEvent("renderermanager:ready"));
3733
3828
  this.#createElements();
3734
3829
  } else {
3735
3830
  this.elementRenderer.addEventListener("threelayer:ready", (e) => {
@@ -3761,7 +3856,18 @@ var RendererManager = class extends EventTarget {
3761
3856
  const units = await this.#dataClient.filterByType("unit", {
3762
3857
  populate: true
3763
3858
  });
3764
- units.filter(
3859
+ const [walkways, otherUnits] = _partition(units, (u) => ["walkway"].includes(u.properties.category));
3860
+ walkways.forEach((unit) => {
3861
+ const element = this.elementRenderer.createGeometry(unit);
3862
+ if (element) {
3863
+ const _elements = Array.isArray(element) ? element : [element];
3864
+ _elements.forEach((el) => {
3865
+ this.elementsMap.set(unit.id, el);
3866
+ this.getElementsByOrdinal(unit.properties.level.properties.ordinal).push(el);
3867
+ });
3868
+ }
3869
+ });
3870
+ otherUnits.filter(
3765
3871
  (u) => !["opentobelow", "escalator"].includes(u.properties.category)
3766
3872
  ).forEach((unit) => {
3767
3873
  const element = this.elementRenderer.createGeometry(unit);
@@ -3789,22 +3895,30 @@ var RendererManager = class extends EventTarget {
3789
3895
  this.dispatchEvent(new CustomEvent("renderermanager:elements_created"));
3790
3896
  }
3791
3897
  changeLevelByOrdinal(targetOrdinal) {
3792
- for (const [ordinal, elements] of this.elementsByOrdinal) {
3793
- const inOrdinal = targetOrdinal === null ? true : Array.isArray(targetOrdinal) ? targetOrdinal.includes(ordinal) : ordinal === targetOrdinal;
3794
- if (inOrdinal) {
3795
- elements.forEach((element, i) => {
3796
- element.show();
3797
- });
3798
- } else {
3799
- elements.forEach((element) => {
3800
- element.hide();
3801
- });
3898
+ if (targetOrdinal === null) {
3899
+ const baseOrdinal = 0;
3900
+ for (const [ordinal, elements] of this.elementsByOrdinal) {
3901
+ this.elementRenderer.showElements(elements, ordinal - baseOrdinal);
3902
+ }
3903
+ } else {
3904
+ const baseOrdinal = Array.isArray(targetOrdinal) ? _min(targetOrdinal) : targetOrdinal;
3905
+ for (const [ordinal, elements] of this.elementsByOrdinal) {
3906
+ const inOrdinal = Array.isArray(targetOrdinal) ? targetOrdinal.includes(ordinal) : ordinal === targetOrdinal;
3907
+ if (inOrdinal) {
3908
+ this.elementRenderer.showElements(elements, ordinal - baseOrdinal);
3909
+ } else {
3910
+ this.elementRenderer.hideElements(elements, ordinal - baseOrdinal);
3911
+ }
3802
3912
  }
3803
3913
  }
3804
3914
  }
3805
- createMarker(coordinate, ordinal, label) {
3806
- const marker = this.elementRenderer.createMarker(coordinate, ordinal, label);
3807
- this.elementsMap.set(label, marker);
3915
+ /**
3916
+ * ========================================================================
3917
+ * Markers
3918
+ * ======================================================================== */
3919
+ createMarker(coordinate, ordinal, markerSymbol) {
3920
+ console.log(`createMarker`, { coordinate, ordinal, markerSymbol });
3921
+ const marker = this.elementRenderer.createMarker(coordinate, ordinal, markerSymbol);
3808
3922
  this.getElementsByOrdinal(ordinal).push(marker);
3809
3923
  }
3810
3924
  };