venue-js 1.2.0-next.1 → 1.2.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.js CHANGED
@@ -670,6 +670,7 @@ var getDataClient = (options) => {
670
670
 
671
671
  // src/IndoorMap/IndoorMap.ts
672
672
  var import_maptalks_gl = require("maptalks-gl");
673
+ var import_transcoders = require("@maptalks/transcoders.draco");
673
674
  var import_tween2 = __toESM(require("@tweenjs/tween.js"));
674
675
  var import_lodash7 = __toESM(require("lodash"));
675
676
 
@@ -751,133 +752,8 @@ function isNumber(num) {
751
752
  // src/IndoorMap/IndoorMap.ts
752
753
  var import_distance = __toESM(require("@turf/distance"));
753
754
  var import_center4 = __toESM(require("@turf/center"));
754
-
755
- // ../../node_modules/@turf/meta/dist/esm/index.js
756
- function coordEach(geojson, callback, excludeWrapCoord) {
757
- if (geojson === null) return;
758
- var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
759
- for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
760
- geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
761
- isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
762
- stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
763
- for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
764
- var multiFeatureIndex = 0;
765
- var geometryIndex = 0;
766
- geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
767
- if (geometry === null) continue;
768
- coords = geometry.coordinates;
769
- var geomType = geometry.type;
770
- wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
771
- switch (geomType) {
772
- case null:
773
- break;
774
- case "Point":
775
- if (callback(
776
- coords,
777
- coordIndex,
778
- featureIndex,
779
- multiFeatureIndex,
780
- geometryIndex
781
- ) === false)
782
- return false;
783
- coordIndex++;
784
- multiFeatureIndex++;
785
- break;
786
- case "LineString":
787
- case "MultiPoint":
788
- for (j = 0; j < coords.length; j++) {
789
- if (callback(
790
- coords[j],
791
- coordIndex,
792
- featureIndex,
793
- multiFeatureIndex,
794
- geometryIndex
795
- ) === false)
796
- return false;
797
- coordIndex++;
798
- if (geomType === "MultiPoint") multiFeatureIndex++;
799
- }
800
- if (geomType === "LineString") multiFeatureIndex++;
801
- break;
802
- case "Polygon":
803
- case "MultiLineString":
804
- for (j = 0; j < coords.length; j++) {
805
- for (k = 0; k < coords[j].length - wrapShrink; k++) {
806
- if (callback(
807
- coords[j][k],
808
- coordIndex,
809
- featureIndex,
810
- multiFeatureIndex,
811
- geometryIndex
812
- ) === false)
813
- return false;
814
- coordIndex++;
815
- }
816
- if (geomType === "MultiLineString") multiFeatureIndex++;
817
- if (geomType === "Polygon") geometryIndex++;
818
- }
819
- if (geomType === "Polygon") multiFeatureIndex++;
820
- break;
821
- case "MultiPolygon":
822
- for (j = 0; j < coords.length; j++) {
823
- geometryIndex = 0;
824
- for (k = 0; k < coords[j].length; k++) {
825
- for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
826
- if (callback(
827
- coords[j][k][l],
828
- coordIndex,
829
- featureIndex,
830
- multiFeatureIndex,
831
- geometryIndex
832
- ) === false)
833
- return false;
834
- coordIndex++;
835
- }
836
- geometryIndex++;
837
- }
838
- multiFeatureIndex++;
839
- }
840
- break;
841
- case "GeometryCollection":
842
- for (j = 0; j < geometry.geometries.length; j++)
843
- if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
844
- return false;
845
- break;
846
- default:
847
- throw new Error("Unknown Geometry Type");
848
- }
849
- }
850
- }
851
- }
852
-
853
- // ../../node_modules/@turf/bbox/dist/esm/index.js
854
- function bbox(geojson, options = {}) {
855
- if (geojson.bbox != null && true !== options.recompute) {
856
- return geojson.bbox;
857
- }
858
- const result = [Infinity, Infinity, -Infinity, -Infinity];
859
- coordEach(geojson, (coord) => {
860
- if (result[0] > coord[0]) {
861
- result[0] = coord[0];
862
- }
863
- if (result[1] > coord[1]) {
864
- result[1] = coord[1];
865
- }
866
- if (result[2] < coord[0]) {
867
- result[2] = coord[0];
868
- }
869
- if (result[3] < coord[1]) {
870
- result[3] = coord[1];
871
- }
872
- });
873
- return result;
874
- }
875
- var index_default = bbox;
876
-
877
- // src/IndoorMap/IndoorMap.ts
878
- var import_transform_scale = __toESM(require("@turf/transform-scale"));
879
- var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
880
755
  var import_three8 = require("three");
756
+ var import_maptalks9 = require("maptalks.three");
881
757
 
882
758
  // src/IndoorMap/constants.ts
883
759
  var defaultLayerOption = { enableAltitude: true };
@@ -3056,8 +2932,133 @@ var createHighlighExtrudeObjectController = (obj, { color }) => {
3056
2932
  };
3057
2933
 
3058
2934
  // src/IndoorMap/camera/CameraManager.ts
3059
- var ZOOM_OUT_LEVEL = 21;
3060
- var ZOOM_IN_LEVEL = 24;
2935
+ var import_maptalks6 = require("maptalks");
2936
+
2937
+ // ../../node_modules/@turf/meta/dist/esm/index.js
2938
+ function coordEach(geojson, callback, excludeWrapCoord) {
2939
+ if (geojson === null) return;
2940
+ var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
2941
+ for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
2942
+ geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
2943
+ isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
2944
+ stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
2945
+ for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
2946
+ var multiFeatureIndex = 0;
2947
+ var geometryIndex = 0;
2948
+ geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
2949
+ if (geometry === null) continue;
2950
+ coords = geometry.coordinates;
2951
+ var geomType = geometry.type;
2952
+ wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
2953
+ switch (geomType) {
2954
+ case null:
2955
+ break;
2956
+ case "Point":
2957
+ if (callback(
2958
+ coords,
2959
+ coordIndex,
2960
+ featureIndex,
2961
+ multiFeatureIndex,
2962
+ geometryIndex
2963
+ ) === false)
2964
+ return false;
2965
+ coordIndex++;
2966
+ multiFeatureIndex++;
2967
+ break;
2968
+ case "LineString":
2969
+ case "MultiPoint":
2970
+ for (j = 0; j < coords.length; j++) {
2971
+ if (callback(
2972
+ coords[j],
2973
+ coordIndex,
2974
+ featureIndex,
2975
+ multiFeatureIndex,
2976
+ geometryIndex
2977
+ ) === false)
2978
+ return false;
2979
+ coordIndex++;
2980
+ if (geomType === "MultiPoint") multiFeatureIndex++;
2981
+ }
2982
+ if (geomType === "LineString") multiFeatureIndex++;
2983
+ break;
2984
+ case "Polygon":
2985
+ case "MultiLineString":
2986
+ for (j = 0; j < coords.length; j++) {
2987
+ for (k = 0; k < coords[j].length - wrapShrink; k++) {
2988
+ if (callback(
2989
+ coords[j][k],
2990
+ coordIndex,
2991
+ featureIndex,
2992
+ multiFeatureIndex,
2993
+ geometryIndex
2994
+ ) === false)
2995
+ return false;
2996
+ coordIndex++;
2997
+ }
2998
+ if (geomType === "MultiLineString") multiFeatureIndex++;
2999
+ if (geomType === "Polygon") geometryIndex++;
3000
+ }
3001
+ if (geomType === "Polygon") multiFeatureIndex++;
3002
+ break;
3003
+ case "MultiPolygon":
3004
+ for (j = 0; j < coords.length; j++) {
3005
+ geometryIndex = 0;
3006
+ for (k = 0; k < coords[j].length; k++) {
3007
+ for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
3008
+ if (callback(
3009
+ coords[j][k][l],
3010
+ coordIndex,
3011
+ featureIndex,
3012
+ multiFeatureIndex,
3013
+ geometryIndex
3014
+ ) === false)
3015
+ return false;
3016
+ coordIndex++;
3017
+ }
3018
+ geometryIndex++;
3019
+ }
3020
+ multiFeatureIndex++;
3021
+ }
3022
+ break;
3023
+ case "GeometryCollection":
3024
+ for (j = 0; j < geometry.geometries.length; j++)
3025
+ if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
3026
+ return false;
3027
+ break;
3028
+ default:
3029
+ throw new Error("Unknown Geometry Type");
3030
+ }
3031
+ }
3032
+ }
3033
+ }
3034
+
3035
+ // ../../node_modules/@turf/bbox/dist/esm/index.js
3036
+ function bbox(geojson, options = {}) {
3037
+ if (geojson.bbox != null && true !== options.recompute) {
3038
+ return geojson.bbox;
3039
+ }
3040
+ const result = [Infinity, Infinity, -Infinity, -Infinity];
3041
+ coordEach(geojson, (coord) => {
3042
+ if (result[0] > coord[0]) {
3043
+ result[0] = coord[0];
3044
+ }
3045
+ if (result[1] > coord[1]) {
3046
+ result[1] = coord[1];
3047
+ }
3048
+ if (result[2] < coord[0]) {
3049
+ result[2] = coord[0];
3050
+ }
3051
+ if (result[3] < coord[1]) {
3052
+ result[3] = coord[1];
3053
+ }
3054
+ });
3055
+ return result;
3056
+ }
3057
+ var index_default = bbox;
3058
+
3059
+ // src/IndoorMap/camera/CameraManager.ts
3060
+ var import_transform_scale = __toESM(require("@turf/transform-scale"));
3061
+ var import_bbox_polygon = __toESM(require("@turf/bbox-polygon"));
3061
3062
  var CameraManager = class {
3062
3063
  map;
3063
3064
  constructor(map, options) {
@@ -3066,80 +3067,65 @@ var CameraManager = class {
3066
3067
  this.setView(options?.defaultView);
3067
3068
  }
3068
3069
  }
3069
- /** Private method */
3070
- #animateflyTo(viewOptions = {}, options = {}, callbackOption = () => {
3071
- }) {
3072
- const { start, end } = {
3073
- start: (frame) => {
3074
- },
3075
- end: (frame) => {
3076
- },
3077
- ...callbackOption
3078
- };
3079
- this.map.flyTo(viewOptions, options, (frame) => {
3080
- if (frame.state.playState === "running" && frame.state.progress === 0)
3081
- start(frame);
3082
- if (frame.state.playState === "finished") end(frame);
3083
- });
3084
- }
3085
3070
  /** Public methods */
3086
3071
  getView = () => {
3087
3072
  return this.map.getView();
3088
3073
  };
3089
- getZoom = () => {
3090
- return this.map.getView().zoom;
3091
- };
3092
3074
  setView = (value) => {
3093
3075
  this.map.setView(value);
3094
3076
  };
3095
- flyTo = (center2, options = {}) => {
3096
- const currentView = this.getView();
3097
- const {
3098
- zoom = ZOOM_OUT_LEVEL,
3099
- pitch = 60,
3100
- duration = 600,
3101
- easing = "out",
3102
- bearing = currentView.bearing
3103
- } = options;
3104
- this.#animateflyTo(
3105
- {
3106
- center: center2,
3107
- zoom,
3108
- pitch,
3109
- bearing
3110
- },
3111
- { duration, easing }
3112
- );
3077
+ animateTo = (view, options = {}, step) => {
3078
+ this.map.animateTo(view, options, step);
3113
3079
  };
3114
- flyToAndZoomIn = (centerPoint, options = {}) => {
3115
- const {
3116
- zoom = ZOOM_IN_LEVEL,
3117
- pitch = 60,
3118
- duration = 600,
3119
- easing = "out"
3120
- } = options;
3121
- this.#animateflyTo(
3122
- {
3123
- center: centerPoint,
3124
- zoom,
3125
- pitch
3126
- },
3127
- { duration, easing }
3080
+ setMaxExtent(extent) {
3081
+ return this.map.setMaxExtent(extent);
3082
+ }
3083
+ getFeatureExtent = (feature2, scaleFactor = 1) => {
3084
+ const [minX, minY, maxX, maxY] = index_default(
3085
+ (0, import_transform_scale.default)((0, import_bbox_polygon.default)(index_default(feature2)), scaleFactor)
3128
3086
  );
3087
+ return new import_maptalks6.Extent(minX, minY, maxX, maxY);
3088
+ };
3089
+ getExtentZoom = (extent, options = {
3090
+ isFraction: false,
3091
+ padding: {
3092
+ paddingLeft: 0,
3093
+ paddingRight: 0,
3094
+ paddingTop: 0,
3095
+ paddingBottom: 0
3096
+ }
3097
+ }) => {
3098
+ const { isFraction = false, padding } = options;
3099
+ return this.map.getFitZoom(extent, isFraction, padding);
3129
3100
  };
3101
+ set maxZoom(value) {
3102
+ this.map.setMaxZoom(value);
3103
+ const spatialReference = {
3104
+ projection: "EPSG:3857",
3105
+ resolutions: (function() {
3106
+ const resolutions = [];
3107
+ const d = 2 * 6378137 * Math.PI;
3108
+ for (let i = 0; i < value; i++) {
3109
+ resolutions[i] = d / (256 * Math.pow(2, i));
3110
+ }
3111
+ return resolutions;
3112
+ })()
3113
+ };
3114
+ this.map.setSpatialReference(spatialReference);
3115
+ }
3116
+ set minZoom(value) {
3117
+ this.map.setMinZoom(value);
3118
+ }
3130
3119
  };
3131
3120
 
3132
3121
  // src/IndoorMap/renderer/RendererManager.ts
3133
3122
  var import_min = __toESM(require("lodash/min"));
3134
3123
  var import_center3 = require("@turf/center");
3135
- var import_maptalks8 = require("maptalks.three");
3136
3124
  var THREE3 = __toESM(require("three"));
3137
3125
 
3138
3126
  // src/IndoorMap/renderer/3d/Element3DRenderer.ts
3139
- var maptalks4 = __toESM(require("maptalks"));
3127
+ var maptalks4 = __toESM(require("maptalks-gl"));
3140
3128
  var THREE2 = __toESM(require("three"));
3141
- var import_GLTFLoader2 = require("three/examples/jsm/loaders/GLTFLoader");
3142
- var import_DRACOLoader = require("three/examples/jsm/loaders/DRACOLoader");
3143
3129
  var import_buffer2 = __toESM(require("@turf/buffer"));
3144
3130
 
3145
3131
  // src/IndoorMap/renderer/3d/element3DRendererOptions.ts
@@ -3168,9 +3154,9 @@ var element3DRendererOptions = {
3168
3154
  };
3169
3155
 
3170
3156
  // src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
3171
- var import_maptalks6 = require("maptalks");
3157
+ var import_maptalks7 = require("maptalks");
3172
3158
  var THREE = __toESM(require("three"));
3173
- var import_maptalks7 = require("maptalks.three");
3159
+ var import_maptalks8 = require("maptalks.three");
3174
3160
  var import_lodash6 = require("lodash");
3175
3161
 
3176
3162
  // src/IndoorMap/renderer/utils/interpolateStops.ts
@@ -3208,12 +3194,12 @@ var OPTIONS4 = {
3208
3194
  altitude: 0,
3209
3195
  opacity: 1
3210
3196
  };
3211
- var TextSpriteMarker = class extends import_maptalks7.BaseObject {
3197
+ var TextSpriteMarker = class extends import_maptalks8.BaseObject {
3212
3198
  #altitudeOffset = 0;
3213
3199
  constructor(coordinate, options, layer, properties = {}) {
3214
- options = import_maptalks6.Util.extend({}, OPTIONS4, options, { layer });
3200
+ options = import_maptalks7.Util.extend({}, OPTIONS4, options, { layer });
3215
3201
  super();
3216
- this._coordinate = new import_maptalks6.Coordinate(coordinate);
3202
+ this._coordinate = new import_maptalks7.Coordinate(coordinate);
3217
3203
  this._initOptions(options);
3218
3204
  this._createGroup();
3219
3205
  this.properties = { ...properties };
@@ -3384,21 +3370,22 @@ var getGeometryOption = (feature2, options) => {
3384
3370
  var Element3DRenderer = class extends EventTarget {
3385
3371
  options;
3386
3372
  map;
3373
+ gltfLayer;
3387
3374
  threeLayer;
3388
- dracoLoader;
3375
+ // private dracoLoader: DRACOLoader
3389
3376
  lineMaterial;
3390
3377
  materialByColorMap;
3391
3378
  markerRenderer;
3392
3379
  // Renderer is Ready
3393
3380
  isReady = false;
3394
- constructor(map, options, layer) {
3381
+ constructor(map, options) {
3395
3382
  super();
3396
3383
  this.options = options;
3397
3384
  this.map = map;
3398
- this.dracoLoader = new import_DRACOLoader.DRACOLoader();
3399
- this.dracoLoader.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.7/");
3385
+ const groupLayer = this.map.getLayer("group");
3386
+ this.threeLayer = groupLayer.getLayer("three");
3387
+ this.gltfLayer = groupLayer.getLayer("gltf");
3400
3388
  this.lineMaterial = new THREE2.LineBasicMaterial({ color: "#000" });
3401
- this.threeLayer = layer;
3402
3389
  this.render();
3403
3390
  }
3404
3391
  animation() {
@@ -3428,41 +3415,45 @@ var Element3DRenderer = class extends EventTarget {
3428
3415
  } = getGeometryOption(feature2, this.options);
3429
3416
  const _this = this;
3430
3417
  const createPolygon = (geometry, feature3) => {
3431
- const [outerRing, ...innerRings] = geometry.coordinates;
3432
- const offsetFeature = offset !== 0 ? (0, import_buffer2.default)(geometry, offset, { units: "meters" }) : feature3;
3433
- const color = feature3.properties.style.polygonFill ?? colorOptions ?? "#ffffff";
3434
- if (color === "transparent") return;
3435
- const material = this.getOrCreateMaterialByColor(color);
3436
- const altitude = feature3.properties.ordinal * HEIGHT_METER;
3437
- const height = feature3.properties.height ?? heightOptions ?? HEIGHT_METER;
3438
- const bottomHeight = feature3.properties.bottomHeight ?? bottomHeightOptions ?? 0;
3439
- const extrudedPolygon = this.threeLayer.toExtrudePolygon(
3440
- offsetFeature,
3441
- { asynchronous: true, ...options, height, bottomHeight, altitude },
3442
- material
3443
- );
3444
- extrudedPolygon.on("click", (e) => {
3445
- console.log(e.target.options.polygon.id);
3446
- });
3447
- const topLineStrings = [
3448
- new maptalks4.LineString(outerRing),
3449
- ...innerRings.map((innerRing) => new maptalks4.LineString(innerRing))
3450
- ];
3451
- const topLines = this.threeLayer.toLines(
3452
- topLineStrings,
3453
- { altitude, bottomHeight: bottomHeight + height + 1e-3, interactive: false },
3454
- this.lineMaterial
3455
- );
3456
- const bottomLineStrings = [
3457
- new maptalks4.LineString(outerRing),
3458
- ...innerRings.map((innerRing) => new maptalks4.LineString(innerRing))
3459
- ];
3460
- const bottomLines = this.threeLayer.toLines(
3461
- bottomLineStrings,
3462
- { altitude, bottomHeight, interactive: false },
3463
- this.lineMaterial
3464
- );
3465
- return [extrudedPolygon, topLines, bottomLines];
3418
+ try {
3419
+ const [outerRing, ...innerRings] = geometry.coordinates;
3420
+ const offsetFeature = offset !== 0 ? (0, import_buffer2.default)(geometry, offset, { units: "meters" }) : feature3;
3421
+ const color = feature3.properties.style.polygonFill ?? colorOptions ?? "#ffffff";
3422
+ if (color === "transparent") return;
3423
+ const material = this.getOrCreateMaterialByColor(color);
3424
+ const altitude = feature3.properties.ordinal * HEIGHT_METER;
3425
+ const height = feature3.properties.height ?? heightOptions ?? HEIGHT_METER;
3426
+ const bottomHeight = feature3.properties.bottomHeight ?? bottomHeightOptions ?? 0;
3427
+ const extrudedPolygon = this.threeLayer.toExtrudePolygon(
3428
+ offsetFeature,
3429
+ { asynchronous: true, ...options, height, bottomHeight, altitude },
3430
+ material
3431
+ );
3432
+ extrudedPolygon.on("click", (e) => {
3433
+ console.log(e.target.options.polygon.id);
3434
+ });
3435
+ const topLineStrings = [
3436
+ new maptalks4.LineString(outerRing),
3437
+ ...innerRings.map((innerRing) => new maptalks4.LineString(innerRing))
3438
+ ];
3439
+ const topLines = this.threeLayer.toLines(
3440
+ topLineStrings,
3441
+ { altitude, bottomHeight: bottomHeight + height + 1e-3, interactive: false },
3442
+ this.lineMaterial
3443
+ );
3444
+ const bottomLineStrings = [
3445
+ new maptalks4.LineString(outerRing),
3446
+ ...innerRings.map((innerRing) => new maptalks4.LineString(innerRing))
3447
+ ];
3448
+ const bottomLines = this.threeLayer.toLines(
3449
+ bottomLineStrings,
3450
+ { altitude, bottomHeight, interactive: false },
3451
+ this.lineMaterial
3452
+ );
3453
+ return [extrudedPolygon, topLines, bottomLines];
3454
+ } catch (err) {
3455
+ throw new Error(`Cannot create polygon, ${err.message}`);
3456
+ }
3466
3457
  };
3467
3458
  try {
3468
3459
  switch (feature2.geometry.type) {
@@ -3482,64 +3473,36 @@ var Element3DRenderer = class extends EventTarget {
3482
3473
  }
3483
3474
  }
3484
3475
  } catch (err) {
3485
- console.log(`error createGeometry`, { feature: feature2, options });
3476
+ console.log(`error createGeometry`, err, { feature: feature2, options });
3486
3477
  }
3487
3478
  };
3488
3479
  async createEscalator(f, coordinate, options) {
3480
+ const model = {
3481
+ url: "https://cdn.venue.in.th/static/glb/escalator.glb",
3482
+ size: 4.4
3483
+ };
3489
3484
  const { direction: dir, angle } = options;
3490
- const model = await this.loadModel3d({
3491
- url: "https://dashboard.situm.com/uploads/3dmodels/demoaccount/new_escalator.glb",
3492
- properties: {
3493
- rotation: {
3494
- x: 0.5 * Math.PI,
3495
- // Rotate the model up (new_escalator.glb)
3496
- y: 0,
3497
- z: 0
3498
- },
3499
- position: { x: 0, y: 0, z: 0 },
3500
- scale: 0.01
3485
+ const rotationZ = dir === "up" ? 180 + angle : angle;
3486
+ var escalatorMarker = new maptalks4.GLTFMarker(coordinate, {
3487
+ symbol: {
3488
+ url: model.url,
3489
+ rotationZ,
3490
+ translationX: dir === "up" ? 0 : model.size * Math.cos(Math.PI * rotationZ / 180),
3491
+ translationY: dir === "up" ? 0 : model.size * Math.sin(Math.PI * rotationZ / 180),
3492
+ translationZ: dir === "up" ? -0.05 * model.size : -0.5 * model.size
3501
3493
  }
3502
3494
  });
3503
- model.rotation.y += dir === "up" ? Math.PI + angle : angle;
3504
- const box = new THREE2.Box3().setFromObject(model);
3505
- const pivotPoint = dir === "up" ? new THREE2.Vector3(0, 0, 0) : new THREE2.Vector3(
3506
- 1 * (box.min.x + box.max.x),
3507
- 1 * (box.min.y + box.max.y),
3508
- 0.6 * box.max.z
3509
- );
3510
- const pivot = new THREE2.Group();
3511
- pivot.add(model);
3512
- model.position.sub(pivotPoint);
3513
- model.updateMatrixWorld(true);
3514
- const altitude = f.properties.ordinal * HEIGHT_METER;
3515
- const baseObjectModel = this.threeLayer.toModel(pivot, {
3516
- coordinate,
3517
- altitude
3518
- });
3519
- this.threeLayer.addMesh(baseObjectModel);
3520
- return baseObjectModel;
3495
+ escalatorMarker.addTo(this.gltfLayer);
3496
+ return escalatorMarker;
3521
3497
  }
3522
3498
  async createTree(coordinate, ordinal) {
3523
- const model = await this.loadModel3d({
3524
- url: "https://dashboard.situm.com/uploads/3dmodels/demoaccount/arbol.glb",
3525
- properties: {
3526
- rotation: {
3527
- x: 0.5 * Math.PI,
3528
- // Rotate the model up (new_escalator.glb)
3529
- y: 0,
3530
- z: 0
3531
- },
3532
- position: { x: 0, y: 0, z: 0 },
3533
- scale: 0.01
3499
+ const treeMarker = new maptalks4.GLTFMarker(coordinate, {
3500
+ symbol: {
3501
+ url: "https://dashboard.situm.com/uploads/3dmodels/demoaccount/new_escalator.glb"
3534
3502
  }
3535
3503
  });
3536
- const altitude = ordinal * HEIGHT_METER;
3537
- const baseObjectModel = this.threeLayer.toModel(model, {
3538
- coordinate,
3539
- altitude
3540
- });
3541
- this.threeLayer.addMesh(baseObjectModel);
3542
- return baseObjectModel;
3504
+ treeMarker.addTo(this.gltfLayer);
3505
+ return treeMarker;
3543
3506
  }
3544
3507
  createElement(f) {
3545
3508
  switch (f.feature_type) {
@@ -3562,21 +3525,6 @@ var Element3DRenderer = class extends EventTarget {
3562
3525
  }
3563
3526
  });
3564
3527
  }
3565
- async loadModel3d(model3d) {
3566
- const loader = new import_GLTFLoader2.GLTFLoader();
3567
- loader.setDRACOLoader(this.dracoLoader);
3568
- const { url, properties: modelProperties } = model3d;
3569
- const gltf = await loader.loadAsync(url);
3570
- const model = gltf.scene;
3571
- model.rotation.x = modelProperties.rotation.x;
3572
- model.rotation.y = modelProperties.rotation.y;
3573
- model.position.x = modelProperties.position.x;
3574
- model.position.y = modelProperties.position.y;
3575
- model.position.z = modelProperties.position.z;
3576
- const scale2 = modelProperties.scale;
3577
- model.scale.set(scale2, scale2, scale2);
3578
- return model;
3579
- }
3580
3528
  createMarker = (coordinates, ordinal, text) => {
3581
3529
  const options = {
3582
3530
  // scale: 0.05,
@@ -3942,12 +3890,10 @@ var RendererManager = class extends EventTarget {
3942
3890
  this.markersMap = /* @__PURE__ */ new Map();
3943
3891
  this.markersByOrdinal = /* @__PURE__ */ new Map();
3944
3892
  this.#dataClient = dataClient;
3893
+ const _this = this;
3945
3894
  if (options.type === "3D") {
3946
- const threeLayer = new import_maptalks8.ThreeLayer("elements", {
3947
- forceRenderOnMoving: true,
3948
- forceRenderOnRotating: true
3949
- });
3950
- const _this = this;
3895
+ const groupLayer = this.map.getLayer("group");
3896
+ const threeLayer = groupLayer.getLayer("three");
3951
3897
  threeLayer.prepareToDraw = function(gl, scene, camera) {
3952
3898
  const ambientLight = new THREE3.AmbientLight(16777215, 0.3);
3953
3899
  scene.add(ambientLight);
@@ -3957,14 +3903,13 @@ var RendererManager = class extends EventTarget {
3957
3903
  scene.add(dllight);
3958
3904
  const hemi = new THREE3.HemisphereLight(16777215, 4473924, 0.4);
3959
3905
  scene.add(hemi);
3960
- _this.elementRenderer = new Element3DRenderer(map, options.elements, threeLayer);
3906
+ _this.elementRenderer = new Element3DRenderer(map, options.elements);
3961
3907
  _this.markerRenderer = new Marker3DRenderer(map, {}, threeLayer);
3962
3908
  if (typeof options.onRendererReady === "function") {
3963
3909
  options.onRendererReady();
3964
3910
  }
3965
3911
  _this.#createElements();
3966
3912
  };
3967
- threeLayer.addTo(this.map);
3968
3913
  } else {
3969
3914
  this.elementRenderer = new Element2DRenderer(map, options.elements);
3970
3915
  this.markerRenderer = new Marker2DRenderer(map);
@@ -4052,13 +3997,15 @@ var RendererManager = class extends EventTarget {
4052
3997
  }
4053
3998
  const thisOrdinal = escalator.properties.ordinal;
4054
3999
  const relationship = escalatorRelationships[0];
4000
+ if (!relationship.properties.origin?.id) throw new Error(`relationship (id=${relationship.id}) - origin not exists`);
4001
+ if (!relationship.properties.destination?.id) throw new Error(`relationship (id=${relationship.id}) - destination not exists`);
4055
4002
  const bothOpeningIds = [relationship.properties.origin.id, relationship.properties.destination.id];
4056
4003
  const bothOpenings = await Promise.all(
4057
4004
  bothOpeningIds.map((id) => this.#dataClient.findById("opening", id, { populate: true }))
4058
4005
  );
4059
4006
  const thisLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal === thisOrdinal);
4060
4007
  const thatLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal !== thisOrdinal);
4061
- const angle = angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
4008
+ const angle = 180 * (1 / Math.PI) * angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
4062
4009
  const direction = thisOrdinal < thatLevelOpening.properties.ordinal ? "up" : "down";
4063
4010
  const escalatorEntryPoint = (0, import_center3.center)(thisLevelOpening).geometry.coordinates;
4064
4011
  const element = await this.elementRenderer.createEscalator(escalator, escalatorEntryPoint, { direction, angle });
@@ -4067,7 +4014,7 @@ var RendererManager = class extends EventTarget {
4067
4014
  this.addElementsToManager(escalator.id, _elements, escalator.properties.ordinal);
4068
4015
  }
4069
4016
  } catch (err) {
4070
- console.log(`cannot create escalator`, err);
4017
+ console.log(`cannot create escalator`, err.message);
4071
4018
  }
4072
4019
  }
4073
4020
  this.changeLevelByOrdinal(this.currentOrdinals);
@@ -4128,6 +4075,7 @@ var defaultOptions = {
4128
4075
  locale: DEFAULT_LOCALE
4129
4076
  };
4130
4077
  var IndoorMap = class extends EventTarget {
4078
+ options;
4131
4079
  //TODO: refac functions; let them do only 1 thing in a function
4132
4080
  /** Note: "#" means private variables */
4133
4081
  #styler = null;
@@ -4179,14 +4127,18 @@ var IndoorMap = class extends EventTarget {
4179
4127
  };
4180
4128
  constructor(elementId, options) {
4181
4129
  super();
4130
+ const combinedOptions = import_lodash7.default.merge({}, defaultOptions, options);
4131
+ this.options = options;
4182
4132
  const {
4183
4133
  onMapReady,
4184
4134
  onMapLoading,
4185
4135
  pixelRatio,
4186
4136
  locale
4187
- } = import_lodash7.default.merge({}, defaultOptions, options);
4137
+ } = combinedOptions;
4188
4138
  this.map = new import_maptalks_gl.Map(elementId, {
4189
4139
  attribution: false,
4140
+ // Temporart set, not really default view
4141
+ // Default view is set in camera manager
4190
4142
  center: INITIAL_CENTER,
4191
4143
  zoom: INITIAL_ZOOM,
4192
4144
  clickTimeThreshold: 600,
@@ -4202,8 +4154,16 @@ var IndoorMap = class extends EventTarget {
4202
4154
  }),
4203
4155
  layers: []
4204
4156
  });
4157
+ const groupLayer = new import_maptalks_gl.GroupGLLayer("group", [], {}).addTo(this.map);
4158
+ const threeLayer = new import_maptalks9.ThreeLayer("three", {
4159
+ forceRenderOnMoving: true,
4160
+ forceRenderOnRotating: true
4161
+ });
4162
+ groupLayer.addLayer(threeLayer);
4163
+ const gltfLayer = new import_maptalks_gl.GLTFLayer("gltf");
4164
+ groupLayer.addLayer(gltfLayer);
4205
4165
  this.rendererManager = new RendererManager(this.map, options.dataClient, options.renderer);
4206
- this.camera = new CameraManager(this.map);
4166
+ this.camera = new CameraManager(this.map, options.camera);
4207
4167
  this.locale = locale;
4208
4168
  this.pixelRatio = pixelRatio;
4209
4169
  this.onMapReady = onMapReady;
@@ -4214,19 +4174,21 @@ var IndoorMap = class extends EventTarget {
4214
4174
  }
4215
4175
  set dataClient(value) {
4216
4176
  this.#dataClient = value;
4217
- this.#dataClient.filterByType("venue").then((venues) => {
4218
- const venueCenters = (0, import_center4.default)(featureCollection(venues));
4219
- const [x, y] = venueCenters.geometry.coordinates;
4220
- const center2 = new import_maptalks_gl.Coordinate(x, y);
4221
- this.camera.setView({ center: center2, pitch: 60, zoom: 19 });
4222
- });
4223
- }
4224
- on(eventName, handler) {
4225
- this.map.on(eventName, handler);
4177
+ if (!this.options.camera.defaultView.center) {
4178
+ this.#dataClient.filterByType("venue").then((venues) => {
4179
+ const venueCenters = (0, import_center4.default)(featureCollection(venues));
4180
+ const [x, y] = venueCenters.geometry.coordinates;
4181
+ const center2 = new import_maptalks_gl.Coordinate(x, y);
4182
+ this.camera.setView({ center: center2, pitch: 60, zoom: 19 });
4183
+ });
4184
+ }
4226
4185
  }
4227
4186
  /**
4228
4187
  * Events
4229
4188
  */
4189
+ on(eventName, handler) {
4190
+ this.map.on(eventName, handler);
4191
+ }
4230
4192
  handleMapClick = ({ coordinate }) => {
4231
4193
  const { x, y } = coordinate;
4232
4194
  console.log(
@@ -4282,40 +4244,12 @@ var IndoorMap = class extends EventTarget {
4282
4244
  this.map.off("moveend", this.#findAndSetVenueInView);
4283
4245
  }
4284
4246
  }
4285
- get ordinals() {
4286
- return this.#ordinals || [];
4287
- }
4288
- set ordinals(value) {
4289
- if (!Array.isArray(value)) throw new Error("ordinals must be Array");
4290
- this.#ordinals = value;
4291
- }
4292
4247
  set billboards(value) {
4293
4248
  this.#billboards = value;
4294
4249
  }
4295
- set mapConfig(value) {
4296
- this.#mapConfig = value;
4297
- }
4298
4250
  set mapDecorations(value) {
4299
4251
  this.#mapDecorations = value;
4300
4252
  }
4301
- set maxZoom(value) {
4302
- this.map.setMaxZoom(value);
4303
- const spatialReference = {
4304
- projection: "EPSG:3857",
4305
- resolutions: (function() {
4306
- const resolutions = [];
4307
- const d = 2 * 6378137 * Math.PI;
4308
- for (let i = 0; i < value; i++) {
4309
- resolutions[i] = d / (256 * Math.pow(2, i));
4310
- }
4311
- return resolutions;
4312
- })()
4313
- };
4314
- this.map.setSpatialReference(spatialReference);
4315
- }
4316
- set minZoom(value) {
4317
- this.map.setMinZoom(value);
4318
- }
4319
4253
  set groundLabels(value) {
4320
4254
  this.#groundLabels = value;
4321
4255
  }
@@ -4351,9 +4285,6 @@ var IndoorMap = class extends EventTarget {
4351
4285
  this.#onClickElement(e);
4352
4286
  this.#isClicked = false;
4353
4287
  };
4354
- setCenter(center2, padding) {
4355
- this.map.setCenter(center2, padding);
4356
- }
4357
4288
  async #legacy_createElements() {
4358
4289
  const {
4359
4290
  // 2D
@@ -4575,7 +4506,7 @@ var IndoorMap = class extends EventTarget {
4575
4506
  const {
4576
4507
  geometry: { coordinates }
4577
4508
  } = (0, import_center4.default)(feature2);
4578
- this.camera.flyToAndZoomIn(coordinates, { pitch: 45 });
4509
+ this.camera.animateTo({ center: coordinates, pitch: 45 });
4579
4510
  });
4580
4511
  object3ds.push(object);
4581
4512
  this.#objects.push(object);
@@ -4658,27 +4589,6 @@ var IndoorMap = class extends EventTarget {
4658
4589
  changeLevelByOrdinal(ordinal) {
4659
4590
  this.rendererManager.changeLevelByOrdinal(ordinal);
4660
4591
  }
4661
- getFeatureExtent = (feature2, scaleFactor = 1) => {
4662
- const [minX, minY, maxX, maxY] = index_default(
4663
- (0, import_transform_scale.default)((0, import_bbox_polygon.default)(index_default(feature2)), scaleFactor)
4664
- );
4665
- return new import_maptalks_gl.Extent(minX, minY, maxX, maxY);
4666
- };
4667
- getExtentCenter = (extent) => {
4668
- return extent.getCenter();
4669
- };
4670
- getExtentZoom = (extent, options = {
4671
- isFraction: false,
4672
- padding: {
4673
- paddingLeft: 0,
4674
- paddingRight: 0,
4675
- paddingTop: 0,
4676
- paddingBottom: 0
4677
- }
4678
- }) => {
4679
- const { isFraction = false, padding } = options;
4680
- return this.map.getFitZoom(extent, isFraction, padding);
4681
- };
4682
4592
  findVenueInView = () => {
4683
4593
  const mapCenter = this.map.getCenter();
4684
4594
  const result = this.#venues.reduce((closest, venue) => {
@@ -4691,9 +4601,6 @@ var IndoorMap = class extends EventTarget {
4691
4601
  }, null);
4692
4602
  return result;
4693
4603
  };
4694
- flyTo = (center2, options) => {
4695
- this.camera.flyTo(center2, options);
4696
- };
4697
4604
  getLineStringBearing = (feature2) => {
4698
4605
  const { geometry } = feature2;
4699
4606
  const path = new import_maptalks_gl.LineString(geometry.coordinates);
@@ -5209,33 +5116,6 @@ var IndoorMap = class extends EventTarget {
5209
5116
  /**
5210
5117
  * render (frame)
5211
5118
  */
5212
- getTargetViewCenter = (targetView, options = { offset: { top: 0, left: 0, right: 0, bottom: 0 } }) => {
5213
- const map = this.map;
5214
- const { offset } = options;
5215
- const { top = 0, left = 0, right = 0, bottom = 0 } = offset;
5216
- const originalState = {
5217
- bearing: map.getBearing(),
5218
- center: map.getCenter(),
5219
- pitch: map.getPitch(),
5220
- zoom: map.getZoom()
5221
- };
5222
- const finalView = {
5223
- bearing: import_lodash7.default.isNil(targetView.bearing) ? map.getBearing() : targetView.bearing,
5224
- center: import_lodash7.default.isNil(targetView.center) ? map.getCenter() : targetView.center,
5225
- pitch: import_lodash7.default.isNil(targetView.pitch) ? map.getPitch() : targetView.pitch,
5226
- zoom: import_lodash7.default.isNil(targetView.zoom) ? map.getZoom() : targetView.zoom
5227
- };
5228
- map.setView(finalView);
5229
- const projectedTargetCenter = map.coordinateToContainerPoint(finalView.center).add(right / 2 - left / 2, bottom / 2 - top / 2);
5230
- const adjustedTargetCenter = map.containerPointToCoordinate(
5231
- projectedTargetCenter
5232
- );
5233
- map.setView(originalState);
5234
- return adjustedTargetCenter;
5235
- };
5236
- setMaxExtent(extent) {
5237
- return this.map.setMaxExtent(extent);
5238
- }
5239
5119
  render() {
5240
5120
  const view = this.map.getView();
5241
5121
  const currBearing = view.bearing;
@@ -5244,7 +5124,8 @@ var IndoorMap = class extends EventTarget {
5244
5124
  this.threeLayer.redraw();
5245
5125
  }
5246
5126
  if (this.threeLayer) {
5247
- const objectOpacity = import_lodash7.default.clamp(38 - 2 * this.camera.getZoom(), 0, 1);
5127
+ const currentView = this.camera.getView();
5128
+ const objectOpacity = import_lodash7.default.clamp(38 - 2 * currentView.zoom, 0, 1);
5248
5129
  this.#objects.forEach((object) => {
5249
5130
  object.getObject3d().traverse((child) => {
5250
5131
  if (child.isMesh) child.material.opacity = objectOpacity;
@@ -5255,7 +5136,7 @@ var IndoorMap = class extends EventTarget {
5255
5136
  if (this.#billboardObjects) {
5256
5137
  this.#billboardObjects.forEach((object) => {
5257
5138
  const objectScale = import_lodash7.default.clamp(
5258
- 20 - 1 * this.camera.getZoom(),
5139
+ 20 - 1 * currentView.zoom,
5259
5140
  1,
5260
5141
  1.05
5261
5142
  );