venue-js 1.2.0-next.6 → 1.2.0-next.7

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
@@ -3082,7 +3082,7 @@ import * as THREE3 from "three";
3082
3082
 
3083
3083
  // src/IndoorMap/renderer/3d/Element3DRenderer.ts
3084
3084
  import * as maptalks4 from "maptalks-gl";
3085
- import * as THREE2 from "three";
3085
+ import * as THREE from "three";
3086
3086
  import turfBuffer2 from "@turf/buffer";
3087
3087
 
3088
3088
  // src/IndoorMap/renderer/3d/element3DRendererOptions.ts
@@ -3110,203 +3110,6 @@ var element3DRendererOptions = {
3110
3110
  }
3111
3111
  };
3112
3112
 
3113
- // src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
3114
- import { Coordinate as Coordinate2, Util as Util4 } from "maptalks";
3115
- import * as THREE from "three";
3116
- import { BaseObject as BaseObject5 } from "maptalks.three";
3117
- import { isNil, set } from "lodash";
3118
-
3119
- // src/IndoorMap/renderer/utils/interpolateStops.ts
3120
- var interpolateStops = ({ stops }, zoom) => {
3121
- if (zoom <= stops[0][0]) return stops[0][1];
3122
- if (zoom >= stops[stops.length - 1][0]) return stops[stops.length - 1][1];
3123
- for (let i = 0; i < stops.length - 1; i++) {
3124
- const [z1, v1] = stops[i];
3125
- const [z2, v2] = stops[i + 1];
3126
- if (zoom >= z1 && zoom <= z2) {
3127
- const t = (zoom - z1) / (z2 - z1);
3128
- return v1 + t * (v2 - v1);
3129
- }
3130
- }
3131
- };
3132
-
3133
- // src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
3134
- var OPTIONS4 = {
3135
- // Texture options
3136
- text: "",
3137
- textAlign: "center",
3138
- color: "#ffffff",
3139
- fontFamily: "sans-serif",
3140
- fontSize: 28,
3141
- fontWeight: 400,
3142
- background: "rgba(0, 0, 0, 0.2)",
3143
- lineHeight: 32,
3144
- padding: 8,
3145
- strokeColor: "#000000",
3146
- strokeWidth: 6,
3147
- strokeStyle: "round",
3148
- // Sprite options
3149
- /* Overall scale multiplier */
3150
- scale: 1,
3151
- altitude: 0,
3152
- opacity: 1
3153
- };
3154
- var TextSpriteMarker = class extends BaseObject5 {
3155
- #altitudeOffset = 0;
3156
- constructor(coordinate, options, layer, properties = {}) {
3157
- options = Util4.extend({}, OPTIONS4, options, { layer });
3158
- super();
3159
- this._coordinate = new Coordinate2(coordinate);
3160
- this._initOptions(options);
3161
- this._createGroup();
3162
- this.properties = { ...properties };
3163
- const sprite = this._createSprite();
3164
- this.getObject3d().add(sprite);
3165
- this._updatePosition();
3166
- this.type = "TextSpriteMarker";
3167
- }
3168
- getOptions() {
3169
- return super.getOptions();
3170
- }
3171
- _createSprite() {
3172
- const options = this.getOptions();
3173
- const texture = this._createTextTexture(options.text, options);
3174
- const material = new THREE.SpriteMaterial({
3175
- map: texture,
3176
- transparent: true,
3177
- alphaTest: 0.1
3178
- });
3179
- const sprite = new THREE.Sprite(material);
3180
- const w = texture.image.width;
3181
- const h = texture.image.height;
3182
- const base = 1 / 16;
3183
- const normalizedScale = options.scale / this.getMap().getGLRes();
3184
- sprite.scale.set(w * base * normalizedScale, h * base * normalizedScale, 1);
3185
- this.#altitudeOffset = Math.max(
3186
- h * base * options.scale * 0.5,
3187
- 0.05
3188
- // minimum lift in world units
3189
- );
3190
- return sprite;
3191
- }
3192
- _createTextTexture(text, options = {}) {
3193
- const {
3194
- padding,
3195
- fontSize,
3196
- fontFamily,
3197
- fontWeight,
3198
- lineHeight,
3199
- background,
3200
- color,
3201
- textAlign,
3202
- strokeColor,
3203
- strokeWidth,
3204
- maxWidth
3205
- } = options || {};
3206
- const canvas = document.createElement("canvas");
3207
- const ctx = canvas.getContext("2d");
3208
- ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
3209
- const paragraphs = String(text).split("\n");
3210
- const wrappedLines = [];
3211
- paragraphs.forEach((paragraph) => {
3212
- if (isNil(maxWidth) || isNaN(maxWidth)) {
3213
- wrappedLines.push(paragraph);
3214
- return;
3215
- }
3216
- const words = paragraph.split(/\s+/);
3217
- let currentLine = "";
3218
- words.forEach((word) => {
3219
- const testLine = currentLine ? currentLine + " " + word : word;
3220
- const testWidth = ctx.measureText(testLine).width;
3221
- if (testWidth > maxWidth && currentLine) {
3222
- wrappedLines.push(currentLine);
3223
- currentLine = word;
3224
- } else {
3225
- currentLine = testLine;
3226
- }
3227
- });
3228
- if (currentLine) {
3229
- wrappedLines.push(currentLine);
3230
- }
3231
- });
3232
- const lines = wrappedLines.length ? wrappedLines : [""];
3233
- const widest = Math.max(...lines.map((l) => ctx.measureText(l).width), 0);
3234
- const finalWidth = (maxWidth ? Math.min(widest, maxWidth) : widest) + padding * 2;
3235
- const finalHeight = lineHeight * lines.length + padding * 2;
3236
- canvas.width = finalWidth;
3237
- canvas.height = finalHeight;
3238
- const ctx2 = canvas.getContext("2d");
3239
- ctx2.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
3240
- ctx2.textAlign = textAlign;
3241
- if (background && background !== "transparent") {
3242
- ctx2.fillStyle = background;
3243
- ctx2.fillRect(0, 0, canvas.width, canvas.height);
3244
- }
3245
- lines.forEach((line, i) => {
3246
- const y = padding + lineHeight * (i + 0.8);
3247
- let x = padding;
3248
- if (textAlign === "center") x = canvas.width / 2;
3249
- if (textAlign === "right" || textAlign === "end")
3250
- x = canvas.width - padding;
3251
- if (strokeWidth > 0) {
3252
- ctx2.lineWidth = strokeWidth;
3253
- ctx2.lineJoin = "round";
3254
- ctx2.miterLimit = 2;
3255
- ctx2.strokeStyle = strokeColor;
3256
- ctx2.strokeText(line, x, y);
3257
- }
3258
- ctx2.fillStyle = color;
3259
- ctx2.fillText(line, x, y);
3260
- });
3261
- const texture = new THREE.CanvasTexture(canvas);
3262
- texture.needsUpdate = true;
3263
- texture.minFilter = THREE.LinearFilter;
3264
- return texture;
3265
- }
3266
- _updatePosition() {
3267
- const options = this.getOptions();
3268
- const layer = options.layer;
3269
- if (!layer) return;
3270
- const altitude = (options.altitude || 0) + this.#altitudeOffset;
3271
- const z = layer.altitudeToVector3(altitude, altitude).x;
3272
- const position = layer.coordinateToVector3(this._coordinate, z);
3273
- set(this.properties, "default.position", position);
3274
- this.getObject3d().position.copy(position);
3275
- }
3276
- _animation() {
3277
- const layer = this.getLayer();
3278
- if (!this.isAdd || !layer) return;
3279
- if (this._visible === true) {
3280
- const zoom = layer.map.getZoom();
3281
- const object3d = this.getObject3d();
3282
- const { opacity } = this.getOptions();
3283
- let opacityValue;
3284
- if (typeof opacity === "number") {
3285
- opacityValue = opacity ?? 1;
3286
- } else if (Array.isArray(opacity.stops)) {
3287
- opacityValue = interpolateStops(opacity, zoom);
3288
- } else {
3289
- throw new Error(`Unknown opacity value ${opacity}`);
3290
- }
3291
- const visible = opacityValue > 0.5;
3292
- object3d.visible = visible;
3293
- }
3294
- }
3295
- setText(text) {
3296
- const options = this.getOptions();
3297
- options.text = text;
3298
- const newSprite = this._createSprite();
3299
- const group = this.getObject3d();
3300
- group.children.forEach((child) => group.remove(child));
3301
- group.add(newSprite);
3302
- this._updatePosition();
3303
- }
3304
- setAltitude(altitude) {
3305
- const bottomHeight = this.options.bottomHeight ?? 0;
3306
- return super.setAltitude(altitude + bottomHeight + this.#altitudeOffset);
3307
- }
3308
- };
3309
-
3310
3113
  // src/IndoorMap/renderer/3d/Element3DRenderer.ts
3311
3114
  var DEFAULT_POLYGON_OPTION = {
3312
3115
  color: "#FFFFFF",
@@ -3332,7 +3135,6 @@ var Element3DRenderer = class extends EventTarget {
3332
3135
  // private dracoLoader: DRACOLoader
3333
3136
  lineMaterial;
3334
3137
  materialByColorMap;
3335
- markerRenderer;
3336
3138
  // Renderer is Ready
3337
3139
  isReady = false;
3338
3140
  constructor(map, options) {
@@ -3342,7 +3144,7 @@ var Element3DRenderer = class extends EventTarget {
3342
3144
  const groupLayer = this.map.getLayer("group");
3343
3145
  this.threeLayer = groupLayer.getLayer("three");
3344
3146
  this.gltfLayer = groupLayer.getLayer("gltf");
3345
- this.lineMaterial = new THREE2.LineBasicMaterial({ color: "#000" });
3147
+ this.lineMaterial = new THREE.LineBasicMaterial({ color: "#000" });
3346
3148
  this.render();
3347
3149
  }
3348
3150
  animation() {
@@ -3357,7 +3159,7 @@ var Element3DRenderer = class extends EventTarget {
3357
3159
  if (!this.materialByColorMap) this.materialByColorMap = /* @__PURE__ */ new Map();
3358
3160
  const existingMaterial = this.materialByColorMap.get(color);
3359
3161
  if (existingMaterial) return existingMaterial;
3360
- const created = new THREE2.MeshLambertMaterial({ color, transparent: true });
3162
+ const created = new THREE.MeshLambertMaterial({ color, transparent: true });
3361
3163
  created.toneMapped = false;
3362
3164
  this.materialByColorMap.set(color, created);
3363
3165
  return created;
@@ -3482,19 +3284,6 @@ var Element3DRenderer = class extends EventTarget {
3482
3284
  }
3483
3285
  });
3484
3286
  }
3485
- createMarker = (coordinates, ordinal, text) => {
3486
- const options = {
3487
- // scale: 0.05,
3488
- // altitude: ordinal * HEIGHT_METER,
3489
- text
3490
- // interactive: true,
3491
- };
3492
- const marker = new TextSpriteMarker(coordinates, options, this.threeLayer);
3493
- this.threeLayer.addMesh([marker]);
3494
- return marker;
3495
- };
3496
- removeMarker = () => {
3497
- };
3498
3287
  render() {
3499
3288
  this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate;
3500
3289
  if (this.threeLayer._needsUpdate) {
@@ -3656,7 +3445,7 @@ var Marker2DRenderer = class extends EventTarget {
3656
3445
  import * as maptalks7 from "maptalks";
3657
3446
 
3658
3447
  // src/IndoorMap/renderer/utils/svg2material.ts
3659
- import { SpriteMaterial as SpriteMaterial5, TextureLoader as TextureLoader3 } from "three";
3448
+ import { SpriteMaterial as SpriteMaterial4, TextureLoader as TextureLoader3 } from "three";
3660
3449
  var svgToDataURL = (svgString, scaleFactor = 1) => {
3661
3450
  const svgBlob = new Blob([svgString], { type: "image/svg+xml" });
3662
3451
  const url = URL.createObjectURL(svgBlob);
@@ -3699,7 +3488,7 @@ var createSVGPathFromMarkerSymbol2 = (style) => {
3699
3488
  return `<path d="${markerPath}" style="transform:translate(${markerDx}px, ${markerDy}px) scale(${scale2})" fill="${fill}" />`;
3700
3489
  };
3701
3490
  var createSpriteMaterialByLabelSymbol2 = (labelSymbol) => {
3702
- const material = new SpriteMaterial5();
3491
+ const material = new SpriteMaterial4();
3703
3492
  try {
3704
3493
  const [base, icon] = labelSymbol ?? [{}, {}];
3705
3494
  const { markerWidth: baseWidth = 24 } = base;
@@ -3722,6 +3511,203 @@ var createSpriteMaterialByLabelSymbol2 = (labelSymbol) => {
3722
3511
  return material;
3723
3512
  };
3724
3513
 
3514
+ // src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
3515
+ import { Coordinate as Coordinate2, Util as Util4 } from "maptalks";
3516
+ import * as THREE2 from "three";
3517
+ import { BaseObject as BaseObject5 } from "maptalks.three";
3518
+ import { isNil, set } from "lodash";
3519
+
3520
+ // src/IndoorMap/renderer/utils/interpolateStops.ts
3521
+ var interpolateStops = ({ stops }, zoom) => {
3522
+ if (zoom <= stops[0][0]) return stops[0][1];
3523
+ if (zoom >= stops[stops.length - 1][0]) return stops[stops.length - 1][1];
3524
+ for (let i = 0; i < stops.length - 1; i++) {
3525
+ const [z1, v1] = stops[i];
3526
+ const [z2, v2] = stops[i + 1];
3527
+ if (zoom >= z1 && zoom <= z2) {
3528
+ const t = (zoom - z1) / (z2 - z1);
3529
+ return v1 + t * (v2 - v1);
3530
+ }
3531
+ }
3532
+ };
3533
+
3534
+ // src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
3535
+ var OPTIONS4 = {
3536
+ // Texture options
3537
+ text: "",
3538
+ textAlign: "center",
3539
+ color: "#ffffff",
3540
+ fontFamily: "sans-serif",
3541
+ fontSize: 28,
3542
+ fontWeight: 400,
3543
+ background: "rgba(0, 0, 0, 0.2)",
3544
+ lineHeight: 32,
3545
+ padding: 8,
3546
+ strokeColor: "#000000",
3547
+ strokeWidth: 6,
3548
+ strokeStyle: "round",
3549
+ // Sprite options
3550
+ /* Overall scale multiplier */
3551
+ scale: 1,
3552
+ altitude: 0,
3553
+ opacity: 1
3554
+ };
3555
+ var TextSpriteMarker = class extends BaseObject5 {
3556
+ #altitudeOffset = 0;
3557
+ constructor(coordinate, options, layer, properties = {}) {
3558
+ options = Util4.extend({}, OPTIONS4, options, { layer });
3559
+ super();
3560
+ this._coordinate = new Coordinate2(coordinate);
3561
+ this._initOptions(options);
3562
+ this._createGroup();
3563
+ this.properties = { ...properties };
3564
+ const sprite = this._createSprite();
3565
+ this.getObject3d().add(sprite);
3566
+ this._updatePosition();
3567
+ this.type = "TextSpriteMarker";
3568
+ }
3569
+ getOptions() {
3570
+ return super.getOptions();
3571
+ }
3572
+ _createSprite() {
3573
+ const options = this.getOptions();
3574
+ const texture = this._createTextTexture(options.text, options);
3575
+ const material = new THREE2.SpriteMaterial({
3576
+ map: texture,
3577
+ transparent: true,
3578
+ alphaTest: 0.1
3579
+ });
3580
+ const sprite = new THREE2.Sprite(material);
3581
+ const w = texture.image.width;
3582
+ const h = texture.image.height;
3583
+ const base = 1 / 16;
3584
+ const normalizedScale = options.scale / this.getMap().getGLRes();
3585
+ sprite.scale.set(w * base * normalizedScale, h * base * normalizedScale, 1);
3586
+ this.#altitudeOffset = Math.max(
3587
+ h * base * options.scale * 0.5,
3588
+ 0.05
3589
+ // minimum lift in world units
3590
+ );
3591
+ return sprite;
3592
+ }
3593
+ _createTextTexture(text, options = {}) {
3594
+ const {
3595
+ padding,
3596
+ fontSize,
3597
+ fontFamily,
3598
+ fontWeight,
3599
+ lineHeight,
3600
+ background,
3601
+ color,
3602
+ textAlign,
3603
+ strokeColor,
3604
+ strokeWidth,
3605
+ maxWidth
3606
+ } = options || {};
3607
+ const canvas = document.createElement("canvas");
3608
+ const ctx = canvas.getContext("2d");
3609
+ ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
3610
+ const paragraphs = String(text).split("\n");
3611
+ const wrappedLines = [];
3612
+ paragraphs.forEach((paragraph) => {
3613
+ if (isNil(maxWidth) || isNaN(maxWidth)) {
3614
+ wrappedLines.push(paragraph);
3615
+ return;
3616
+ }
3617
+ const words = paragraph.split(/\s+/);
3618
+ let currentLine = "";
3619
+ words.forEach((word) => {
3620
+ const testLine = currentLine ? currentLine + " " + word : word;
3621
+ const testWidth = ctx.measureText(testLine).width;
3622
+ if (testWidth > maxWidth && currentLine) {
3623
+ wrappedLines.push(currentLine);
3624
+ currentLine = word;
3625
+ } else {
3626
+ currentLine = testLine;
3627
+ }
3628
+ });
3629
+ if (currentLine) {
3630
+ wrappedLines.push(currentLine);
3631
+ }
3632
+ });
3633
+ const lines = wrappedLines.length ? wrappedLines : [""];
3634
+ const widest = Math.max(...lines.map((l) => ctx.measureText(l).width), 0);
3635
+ const finalWidth = (maxWidth ? Math.min(widest, maxWidth) : widest) + padding * 2;
3636
+ const finalHeight = lineHeight * lines.length + padding * 2;
3637
+ canvas.width = finalWidth;
3638
+ canvas.height = finalHeight;
3639
+ const ctx2 = canvas.getContext("2d");
3640
+ ctx2.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
3641
+ ctx2.textAlign = textAlign;
3642
+ if (background && background !== "transparent") {
3643
+ ctx2.fillStyle = background;
3644
+ ctx2.fillRect(0, 0, canvas.width, canvas.height);
3645
+ }
3646
+ lines.forEach((line, i) => {
3647
+ const y = padding + lineHeight * (i + 0.8);
3648
+ let x = padding;
3649
+ if (textAlign === "center") x = canvas.width / 2;
3650
+ if (textAlign === "right" || textAlign === "end")
3651
+ x = canvas.width - padding;
3652
+ if (strokeWidth > 0) {
3653
+ ctx2.lineWidth = strokeWidth;
3654
+ ctx2.lineJoin = "round";
3655
+ ctx2.miterLimit = 2;
3656
+ ctx2.strokeStyle = strokeColor;
3657
+ ctx2.strokeText(line, x, y);
3658
+ }
3659
+ ctx2.fillStyle = color;
3660
+ ctx2.fillText(line, x, y);
3661
+ });
3662
+ const texture = new THREE2.CanvasTexture(canvas);
3663
+ texture.needsUpdate = true;
3664
+ texture.minFilter = THREE2.LinearFilter;
3665
+ return texture;
3666
+ }
3667
+ _updatePosition() {
3668
+ const options = this.getOptions();
3669
+ const layer = options.layer;
3670
+ if (!layer) return;
3671
+ const altitude = (options.altitude || 0) + this.#altitudeOffset;
3672
+ const z = layer.altitudeToVector3(altitude, altitude).x;
3673
+ const position = layer.coordinateToVector3(this._coordinate, z);
3674
+ set(this.properties, "default.position", position);
3675
+ this.getObject3d().position.copy(position);
3676
+ }
3677
+ _animation() {
3678
+ const layer = this.getLayer();
3679
+ if (!this.isAdd || !layer) return;
3680
+ if (this._visible === true) {
3681
+ const zoom = layer.map.getZoom();
3682
+ const object3d = this.getObject3d();
3683
+ const { opacity } = this.getOptions();
3684
+ let opacityValue;
3685
+ if (typeof opacity === "number") {
3686
+ opacityValue = opacity ?? 1;
3687
+ } else if (Array.isArray(opacity.stops)) {
3688
+ opacityValue = interpolateStops(opacity, zoom);
3689
+ } else {
3690
+ throw new Error(`Unknown opacity value ${opacity}`);
3691
+ }
3692
+ const visible = opacityValue > 0.5;
3693
+ object3d.visible = visible;
3694
+ }
3695
+ }
3696
+ setText(text) {
3697
+ const options = this.getOptions();
3698
+ options.text = text;
3699
+ const newSprite = this._createSprite();
3700
+ const group = this.getObject3d();
3701
+ group.children.forEach((child) => group.remove(child));
3702
+ group.add(newSprite);
3703
+ this._updatePosition();
3704
+ }
3705
+ setAltitude(altitude) {
3706
+ const bottomHeight = this.options.bottomHeight ?? 0;
3707
+ return super.setAltitude(altitude + bottomHeight + this.#altitudeOffset);
3708
+ }
3709
+ };
3710
+
3725
3711
  // src/IndoorMap/renderer/3d/Marker3DRenderer.ts
3726
3712
  var HEIGHT_METER2 = 4;
3727
3713
  var MULTIORDINAL_HEIGHT_METER3 = 9;
@@ -3825,6 +3811,9 @@ var angleBetweenLineStrings = (line1, line2) => {
3825
3811
  };
3826
3812
 
3827
3813
  // src/IndoorMap/renderer/RendererManager.ts
3814
+ function delay(ms) {
3815
+ return new Promise((resolve) => setTimeout(resolve, ms));
3816
+ }
3828
3817
  var RendererManager = class extends EventTarget {
3829
3818
  map;
3830
3819
  options;
@@ -3908,6 +3897,7 @@ var RendererManager = class extends EventTarget {
3908
3897
  }
3909
3898
  };
3910
3899
  async #createElements() {
3900
+ await delay(this.options.delayBeforeCreateElements ?? 0);
3911
3901
  const levels = await this.#dataClient.filterByType("level", {
3912
3902
  populate: true
3913
3903
  });
@@ -4269,19 +4259,6 @@ var IndoorMap = class extends EventTarget {
4269
4259
  let elements = {};
4270
4260
  let object3ds = [];
4271
4261
  const scene = this.threeLayer.getScene();
4272
- if (scene) {
4273
- const {
4274
- ambientLight: ambientLightConfig = {},
4275
- directionalLight: directionalLightConfig = {}
4276
- } = _6.get(this.#mapConfig, "light", {
4277
- ambientLight: {},
4278
- directionalLight: {}
4279
- });
4280
- const ambientLight = createAmbientLight(ambientLightConfig);
4281
- scene.add(ambientLight);
4282
- const light = createDirectionalLight(directionalLightConfig);
4283
- scene.add(light);
4284
- }
4285
4262
  for (const feature2 of this.#features) {
4286
4263
  try {
4287
4264
  const { feature_type: featureType, properties, id } = feature2;