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.d.mts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.js +204 -227
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +206 -229
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -736,14 +736,16 @@ type Element3DRendererOptions = {
|
|
|
736
736
|
unit?: TypeRenderOptions<CreateExtrudePolygonOptionType>;
|
|
737
737
|
};
|
|
738
738
|
/** RendererManager */
|
|
739
|
-
type
|
|
739
|
+
type BaseRenderManagerOptions = {
|
|
740
|
+
delayBeforeCreateElements?: number;
|
|
741
|
+
onRendererReady?: () => void;
|
|
742
|
+
};
|
|
743
|
+
type RendererManagerOptions = BaseRenderManagerOptions & {
|
|
740
744
|
type: "2D";
|
|
741
745
|
elements: Element2DRendererOptions;
|
|
742
|
-
|
|
743
|
-
} | {
|
|
746
|
+
} | BaseRenderManagerOptions & {
|
|
744
747
|
type: "3D";
|
|
745
748
|
elements: Element3DRendererOptions;
|
|
746
|
-
onRendererReady?: () => void;
|
|
747
749
|
};
|
|
748
750
|
|
|
749
751
|
declare class RendererManager extends EventTarget {
|
package/dist/index.d.ts
CHANGED
|
@@ -736,14 +736,16 @@ type Element3DRendererOptions = {
|
|
|
736
736
|
unit?: TypeRenderOptions<CreateExtrudePolygonOptionType>;
|
|
737
737
|
};
|
|
738
738
|
/** RendererManager */
|
|
739
|
-
type
|
|
739
|
+
type BaseRenderManagerOptions = {
|
|
740
|
+
delayBeforeCreateElements?: number;
|
|
741
|
+
onRendererReady?: () => void;
|
|
742
|
+
};
|
|
743
|
+
type RendererManagerOptions = BaseRenderManagerOptions & {
|
|
740
744
|
type: "2D";
|
|
741
745
|
elements: Element2DRendererOptions;
|
|
742
|
-
|
|
743
|
-
} | {
|
|
746
|
+
} | BaseRenderManagerOptions & {
|
|
744
747
|
type: "3D";
|
|
745
748
|
elements: Element3DRendererOptions;
|
|
746
|
-
onRendererReady?: () => void;
|
|
747
749
|
};
|
|
748
750
|
|
|
749
751
|
declare class RendererManager extends EventTarget {
|
package/dist/index.js
CHANGED
|
@@ -3127,7 +3127,7 @@ var THREE3 = __toESM(require("three"));
|
|
|
3127
3127
|
|
|
3128
3128
|
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
3129
3129
|
var maptalks4 = __toESM(require("maptalks-gl"));
|
|
3130
|
-
var
|
|
3130
|
+
var THREE = __toESM(require("three"));
|
|
3131
3131
|
var import_buffer2 = __toESM(require("@turf/buffer"));
|
|
3132
3132
|
|
|
3133
3133
|
// src/IndoorMap/renderer/3d/element3DRendererOptions.ts
|
|
@@ -3155,203 +3155,6 @@ var element3DRendererOptions = {
|
|
|
3155
3155
|
}
|
|
3156
3156
|
};
|
|
3157
3157
|
|
|
3158
|
-
// src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
|
|
3159
|
-
var import_maptalks7 = require("maptalks");
|
|
3160
|
-
var THREE = __toESM(require("three"));
|
|
3161
|
-
var import_maptalks8 = require("maptalks.three");
|
|
3162
|
-
var import_lodash6 = require("lodash");
|
|
3163
|
-
|
|
3164
|
-
// src/IndoorMap/renderer/utils/interpolateStops.ts
|
|
3165
|
-
var interpolateStops = ({ stops }, zoom) => {
|
|
3166
|
-
if (zoom <= stops[0][0]) return stops[0][1];
|
|
3167
|
-
if (zoom >= stops[stops.length - 1][0]) return stops[stops.length - 1][1];
|
|
3168
|
-
for (let i = 0; i < stops.length - 1; i++) {
|
|
3169
|
-
const [z1, v1] = stops[i];
|
|
3170
|
-
const [z2, v2] = stops[i + 1];
|
|
3171
|
-
if (zoom >= z1 && zoom <= z2) {
|
|
3172
|
-
const t = (zoom - z1) / (z2 - z1);
|
|
3173
|
-
return v1 + t * (v2 - v1);
|
|
3174
|
-
}
|
|
3175
|
-
}
|
|
3176
|
-
};
|
|
3177
|
-
|
|
3178
|
-
// src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
|
|
3179
|
-
var OPTIONS4 = {
|
|
3180
|
-
// Texture options
|
|
3181
|
-
text: "",
|
|
3182
|
-
textAlign: "center",
|
|
3183
|
-
color: "#ffffff",
|
|
3184
|
-
fontFamily: "sans-serif",
|
|
3185
|
-
fontSize: 28,
|
|
3186
|
-
fontWeight: 400,
|
|
3187
|
-
background: "rgba(0, 0, 0, 0.2)",
|
|
3188
|
-
lineHeight: 32,
|
|
3189
|
-
padding: 8,
|
|
3190
|
-
strokeColor: "#000000",
|
|
3191
|
-
strokeWidth: 6,
|
|
3192
|
-
strokeStyle: "round",
|
|
3193
|
-
// Sprite options
|
|
3194
|
-
/* Overall scale multiplier */
|
|
3195
|
-
scale: 1,
|
|
3196
|
-
altitude: 0,
|
|
3197
|
-
opacity: 1
|
|
3198
|
-
};
|
|
3199
|
-
var TextSpriteMarker = class extends import_maptalks8.BaseObject {
|
|
3200
|
-
#altitudeOffset = 0;
|
|
3201
|
-
constructor(coordinate, options, layer, properties = {}) {
|
|
3202
|
-
options = import_maptalks7.Util.extend({}, OPTIONS4, options, { layer });
|
|
3203
|
-
super();
|
|
3204
|
-
this._coordinate = new import_maptalks7.Coordinate(coordinate);
|
|
3205
|
-
this._initOptions(options);
|
|
3206
|
-
this._createGroup();
|
|
3207
|
-
this.properties = { ...properties };
|
|
3208
|
-
const sprite = this._createSprite();
|
|
3209
|
-
this.getObject3d().add(sprite);
|
|
3210
|
-
this._updatePosition();
|
|
3211
|
-
this.type = "TextSpriteMarker";
|
|
3212
|
-
}
|
|
3213
|
-
getOptions() {
|
|
3214
|
-
return super.getOptions();
|
|
3215
|
-
}
|
|
3216
|
-
_createSprite() {
|
|
3217
|
-
const options = this.getOptions();
|
|
3218
|
-
const texture = this._createTextTexture(options.text, options);
|
|
3219
|
-
const material = new THREE.SpriteMaterial({
|
|
3220
|
-
map: texture,
|
|
3221
|
-
transparent: true,
|
|
3222
|
-
alphaTest: 0.1
|
|
3223
|
-
});
|
|
3224
|
-
const sprite = new THREE.Sprite(material);
|
|
3225
|
-
const w = texture.image.width;
|
|
3226
|
-
const h = texture.image.height;
|
|
3227
|
-
const base = 1 / 16;
|
|
3228
|
-
const normalizedScale = options.scale / this.getMap().getGLRes();
|
|
3229
|
-
sprite.scale.set(w * base * normalizedScale, h * base * normalizedScale, 1);
|
|
3230
|
-
this.#altitudeOffset = Math.max(
|
|
3231
|
-
h * base * options.scale * 0.5,
|
|
3232
|
-
0.05
|
|
3233
|
-
// minimum lift in world units
|
|
3234
|
-
);
|
|
3235
|
-
return sprite;
|
|
3236
|
-
}
|
|
3237
|
-
_createTextTexture(text, options = {}) {
|
|
3238
|
-
const {
|
|
3239
|
-
padding,
|
|
3240
|
-
fontSize,
|
|
3241
|
-
fontFamily,
|
|
3242
|
-
fontWeight,
|
|
3243
|
-
lineHeight,
|
|
3244
|
-
background,
|
|
3245
|
-
color,
|
|
3246
|
-
textAlign,
|
|
3247
|
-
strokeColor,
|
|
3248
|
-
strokeWidth,
|
|
3249
|
-
maxWidth
|
|
3250
|
-
} = options || {};
|
|
3251
|
-
const canvas = document.createElement("canvas");
|
|
3252
|
-
const ctx = canvas.getContext("2d");
|
|
3253
|
-
ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
3254
|
-
const paragraphs = String(text).split("\n");
|
|
3255
|
-
const wrappedLines = [];
|
|
3256
|
-
paragraphs.forEach((paragraph) => {
|
|
3257
|
-
if ((0, import_lodash6.isNil)(maxWidth) || isNaN(maxWidth)) {
|
|
3258
|
-
wrappedLines.push(paragraph);
|
|
3259
|
-
return;
|
|
3260
|
-
}
|
|
3261
|
-
const words = paragraph.split(/\s+/);
|
|
3262
|
-
let currentLine = "";
|
|
3263
|
-
words.forEach((word) => {
|
|
3264
|
-
const testLine = currentLine ? currentLine + " " + word : word;
|
|
3265
|
-
const testWidth = ctx.measureText(testLine).width;
|
|
3266
|
-
if (testWidth > maxWidth && currentLine) {
|
|
3267
|
-
wrappedLines.push(currentLine);
|
|
3268
|
-
currentLine = word;
|
|
3269
|
-
} else {
|
|
3270
|
-
currentLine = testLine;
|
|
3271
|
-
}
|
|
3272
|
-
});
|
|
3273
|
-
if (currentLine) {
|
|
3274
|
-
wrappedLines.push(currentLine);
|
|
3275
|
-
}
|
|
3276
|
-
});
|
|
3277
|
-
const lines = wrappedLines.length ? wrappedLines : [""];
|
|
3278
|
-
const widest = Math.max(...lines.map((l) => ctx.measureText(l).width), 0);
|
|
3279
|
-
const finalWidth = (maxWidth ? Math.min(widest, maxWidth) : widest) + padding * 2;
|
|
3280
|
-
const finalHeight = lineHeight * lines.length + padding * 2;
|
|
3281
|
-
canvas.width = finalWidth;
|
|
3282
|
-
canvas.height = finalHeight;
|
|
3283
|
-
const ctx2 = canvas.getContext("2d");
|
|
3284
|
-
ctx2.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
3285
|
-
ctx2.textAlign = textAlign;
|
|
3286
|
-
if (background && background !== "transparent") {
|
|
3287
|
-
ctx2.fillStyle = background;
|
|
3288
|
-
ctx2.fillRect(0, 0, canvas.width, canvas.height);
|
|
3289
|
-
}
|
|
3290
|
-
lines.forEach((line, i) => {
|
|
3291
|
-
const y = padding + lineHeight * (i + 0.8);
|
|
3292
|
-
let x = padding;
|
|
3293
|
-
if (textAlign === "center") x = canvas.width / 2;
|
|
3294
|
-
if (textAlign === "right" || textAlign === "end")
|
|
3295
|
-
x = canvas.width - padding;
|
|
3296
|
-
if (strokeWidth > 0) {
|
|
3297
|
-
ctx2.lineWidth = strokeWidth;
|
|
3298
|
-
ctx2.lineJoin = "round";
|
|
3299
|
-
ctx2.miterLimit = 2;
|
|
3300
|
-
ctx2.strokeStyle = strokeColor;
|
|
3301
|
-
ctx2.strokeText(line, x, y);
|
|
3302
|
-
}
|
|
3303
|
-
ctx2.fillStyle = color;
|
|
3304
|
-
ctx2.fillText(line, x, y);
|
|
3305
|
-
});
|
|
3306
|
-
const texture = new THREE.CanvasTexture(canvas);
|
|
3307
|
-
texture.needsUpdate = true;
|
|
3308
|
-
texture.minFilter = THREE.LinearFilter;
|
|
3309
|
-
return texture;
|
|
3310
|
-
}
|
|
3311
|
-
_updatePosition() {
|
|
3312
|
-
const options = this.getOptions();
|
|
3313
|
-
const layer = options.layer;
|
|
3314
|
-
if (!layer) return;
|
|
3315
|
-
const altitude = (options.altitude || 0) + this.#altitudeOffset;
|
|
3316
|
-
const z = layer.altitudeToVector3(altitude, altitude).x;
|
|
3317
|
-
const position = layer.coordinateToVector3(this._coordinate, z);
|
|
3318
|
-
(0, import_lodash6.set)(this.properties, "default.position", position);
|
|
3319
|
-
this.getObject3d().position.copy(position);
|
|
3320
|
-
}
|
|
3321
|
-
_animation() {
|
|
3322
|
-
const layer = this.getLayer();
|
|
3323
|
-
if (!this.isAdd || !layer) return;
|
|
3324
|
-
if (this._visible === true) {
|
|
3325
|
-
const zoom = layer.map.getZoom();
|
|
3326
|
-
const object3d = this.getObject3d();
|
|
3327
|
-
const { opacity } = this.getOptions();
|
|
3328
|
-
let opacityValue;
|
|
3329
|
-
if (typeof opacity === "number") {
|
|
3330
|
-
opacityValue = opacity ?? 1;
|
|
3331
|
-
} else if (Array.isArray(opacity.stops)) {
|
|
3332
|
-
opacityValue = interpolateStops(opacity, zoom);
|
|
3333
|
-
} else {
|
|
3334
|
-
throw new Error(`Unknown opacity value ${opacity}`);
|
|
3335
|
-
}
|
|
3336
|
-
const visible = opacityValue > 0.5;
|
|
3337
|
-
object3d.visible = visible;
|
|
3338
|
-
}
|
|
3339
|
-
}
|
|
3340
|
-
setText(text) {
|
|
3341
|
-
const options = this.getOptions();
|
|
3342
|
-
options.text = text;
|
|
3343
|
-
const newSprite = this._createSprite();
|
|
3344
|
-
const group = this.getObject3d();
|
|
3345
|
-
group.children.forEach((child) => group.remove(child));
|
|
3346
|
-
group.add(newSprite);
|
|
3347
|
-
this._updatePosition();
|
|
3348
|
-
}
|
|
3349
|
-
setAltitude(altitude) {
|
|
3350
|
-
const bottomHeight = this.options.bottomHeight ?? 0;
|
|
3351
|
-
return super.setAltitude(altitude + bottomHeight + this.#altitudeOffset);
|
|
3352
|
-
}
|
|
3353
|
-
};
|
|
3354
|
-
|
|
3355
3158
|
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
3356
3159
|
var DEFAULT_POLYGON_OPTION = {
|
|
3357
3160
|
color: "#FFFFFF",
|
|
@@ -3377,7 +3180,6 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3377
3180
|
// private dracoLoader: DRACOLoader
|
|
3378
3181
|
lineMaterial;
|
|
3379
3182
|
materialByColorMap;
|
|
3380
|
-
markerRenderer;
|
|
3381
3183
|
// Renderer is Ready
|
|
3382
3184
|
isReady = false;
|
|
3383
3185
|
constructor(map, options) {
|
|
@@ -3387,7 +3189,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3387
3189
|
const groupLayer = this.map.getLayer("group");
|
|
3388
3190
|
this.threeLayer = groupLayer.getLayer("three");
|
|
3389
3191
|
this.gltfLayer = groupLayer.getLayer("gltf");
|
|
3390
|
-
this.lineMaterial = new
|
|
3192
|
+
this.lineMaterial = new THREE.LineBasicMaterial({ color: "#000" });
|
|
3391
3193
|
this.render();
|
|
3392
3194
|
}
|
|
3393
3195
|
animation() {
|
|
@@ -3402,7 +3204,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3402
3204
|
if (!this.materialByColorMap) this.materialByColorMap = /* @__PURE__ */ new Map();
|
|
3403
3205
|
const existingMaterial = this.materialByColorMap.get(color);
|
|
3404
3206
|
if (existingMaterial) return existingMaterial;
|
|
3405
|
-
const created = new
|
|
3207
|
+
const created = new THREE.MeshLambertMaterial({ color, transparent: true });
|
|
3406
3208
|
created.toneMapped = false;
|
|
3407
3209
|
this.materialByColorMap.set(color, created);
|
|
3408
3210
|
return created;
|
|
@@ -3527,19 +3329,6 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3527
3329
|
}
|
|
3528
3330
|
});
|
|
3529
3331
|
}
|
|
3530
|
-
createMarker = (coordinates, ordinal, text) => {
|
|
3531
|
-
const options = {
|
|
3532
|
-
// scale: 0.05,
|
|
3533
|
-
// altitude: ordinal * HEIGHT_METER,
|
|
3534
|
-
text
|
|
3535
|
-
// interactive: true,
|
|
3536
|
-
};
|
|
3537
|
-
const marker = new TextSpriteMarker(coordinates, options, this.threeLayer);
|
|
3538
|
-
this.threeLayer.addMesh([marker]);
|
|
3539
|
-
return marker;
|
|
3540
|
-
};
|
|
3541
|
-
removeMarker = () => {
|
|
3542
|
-
};
|
|
3543
3332
|
render() {
|
|
3544
3333
|
this.threeLayer._needsUpdate = !this.threeLayer._needsUpdate;
|
|
3545
3334
|
if (this.threeLayer._needsUpdate) {
|
|
@@ -3767,6 +3556,203 @@ var createSpriteMaterialByLabelSymbol2 = (labelSymbol) => {
|
|
|
3767
3556
|
return material;
|
|
3768
3557
|
};
|
|
3769
3558
|
|
|
3559
|
+
// src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
|
|
3560
|
+
var import_maptalks7 = require("maptalks");
|
|
3561
|
+
var THREE2 = __toESM(require("three"));
|
|
3562
|
+
var import_maptalks8 = require("maptalks.three");
|
|
3563
|
+
var import_lodash6 = require("lodash");
|
|
3564
|
+
|
|
3565
|
+
// src/IndoorMap/renderer/utils/interpolateStops.ts
|
|
3566
|
+
var interpolateStops = ({ stops }, zoom) => {
|
|
3567
|
+
if (zoom <= stops[0][0]) return stops[0][1];
|
|
3568
|
+
if (zoom >= stops[stops.length - 1][0]) return stops[stops.length - 1][1];
|
|
3569
|
+
for (let i = 0; i < stops.length - 1; i++) {
|
|
3570
|
+
const [z1, v1] = stops[i];
|
|
3571
|
+
const [z2, v2] = stops[i + 1];
|
|
3572
|
+
if (zoom >= z1 && zoom <= z2) {
|
|
3573
|
+
const t = (zoom - z1) / (z2 - z1);
|
|
3574
|
+
return v1 + t * (v2 - v1);
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
};
|
|
3578
|
+
|
|
3579
|
+
// src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
|
|
3580
|
+
var OPTIONS4 = {
|
|
3581
|
+
// Texture options
|
|
3582
|
+
text: "",
|
|
3583
|
+
textAlign: "center",
|
|
3584
|
+
color: "#ffffff",
|
|
3585
|
+
fontFamily: "sans-serif",
|
|
3586
|
+
fontSize: 28,
|
|
3587
|
+
fontWeight: 400,
|
|
3588
|
+
background: "rgba(0, 0, 0, 0.2)",
|
|
3589
|
+
lineHeight: 32,
|
|
3590
|
+
padding: 8,
|
|
3591
|
+
strokeColor: "#000000",
|
|
3592
|
+
strokeWidth: 6,
|
|
3593
|
+
strokeStyle: "round",
|
|
3594
|
+
// Sprite options
|
|
3595
|
+
/* Overall scale multiplier */
|
|
3596
|
+
scale: 1,
|
|
3597
|
+
altitude: 0,
|
|
3598
|
+
opacity: 1
|
|
3599
|
+
};
|
|
3600
|
+
var TextSpriteMarker = class extends import_maptalks8.BaseObject {
|
|
3601
|
+
#altitudeOffset = 0;
|
|
3602
|
+
constructor(coordinate, options, layer, properties = {}) {
|
|
3603
|
+
options = import_maptalks7.Util.extend({}, OPTIONS4, options, { layer });
|
|
3604
|
+
super();
|
|
3605
|
+
this._coordinate = new import_maptalks7.Coordinate(coordinate);
|
|
3606
|
+
this._initOptions(options);
|
|
3607
|
+
this._createGroup();
|
|
3608
|
+
this.properties = { ...properties };
|
|
3609
|
+
const sprite = this._createSprite();
|
|
3610
|
+
this.getObject3d().add(sprite);
|
|
3611
|
+
this._updatePosition();
|
|
3612
|
+
this.type = "TextSpriteMarker";
|
|
3613
|
+
}
|
|
3614
|
+
getOptions() {
|
|
3615
|
+
return super.getOptions();
|
|
3616
|
+
}
|
|
3617
|
+
_createSprite() {
|
|
3618
|
+
const options = this.getOptions();
|
|
3619
|
+
const texture = this._createTextTexture(options.text, options);
|
|
3620
|
+
const material = new THREE2.SpriteMaterial({
|
|
3621
|
+
map: texture,
|
|
3622
|
+
transparent: true,
|
|
3623
|
+
alphaTest: 0.1
|
|
3624
|
+
});
|
|
3625
|
+
const sprite = new THREE2.Sprite(material);
|
|
3626
|
+
const w = texture.image.width;
|
|
3627
|
+
const h = texture.image.height;
|
|
3628
|
+
const base = 1 / 16;
|
|
3629
|
+
const normalizedScale = options.scale / this.getMap().getGLRes();
|
|
3630
|
+
sprite.scale.set(w * base * normalizedScale, h * base * normalizedScale, 1);
|
|
3631
|
+
this.#altitudeOffset = Math.max(
|
|
3632
|
+
h * base * options.scale * 0.5,
|
|
3633
|
+
0.05
|
|
3634
|
+
// minimum lift in world units
|
|
3635
|
+
);
|
|
3636
|
+
return sprite;
|
|
3637
|
+
}
|
|
3638
|
+
_createTextTexture(text, options = {}) {
|
|
3639
|
+
const {
|
|
3640
|
+
padding,
|
|
3641
|
+
fontSize,
|
|
3642
|
+
fontFamily,
|
|
3643
|
+
fontWeight,
|
|
3644
|
+
lineHeight,
|
|
3645
|
+
background,
|
|
3646
|
+
color,
|
|
3647
|
+
textAlign,
|
|
3648
|
+
strokeColor,
|
|
3649
|
+
strokeWidth,
|
|
3650
|
+
maxWidth
|
|
3651
|
+
} = options || {};
|
|
3652
|
+
const canvas = document.createElement("canvas");
|
|
3653
|
+
const ctx = canvas.getContext("2d");
|
|
3654
|
+
ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
3655
|
+
const paragraphs = String(text).split("\n");
|
|
3656
|
+
const wrappedLines = [];
|
|
3657
|
+
paragraphs.forEach((paragraph) => {
|
|
3658
|
+
if ((0, import_lodash6.isNil)(maxWidth) || isNaN(maxWidth)) {
|
|
3659
|
+
wrappedLines.push(paragraph);
|
|
3660
|
+
return;
|
|
3661
|
+
}
|
|
3662
|
+
const words = paragraph.split(/\s+/);
|
|
3663
|
+
let currentLine = "";
|
|
3664
|
+
words.forEach((word) => {
|
|
3665
|
+
const testLine = currentLine ? currentLine + " " + word : word;
|
|
3666
|
+
const testWidth = ctx.measureText(testLine).width;
|
|
3667
|
+
if (testWidth > maxWidth && currentLine) {
|
|
3668
|
+
wrappedLines.push(currentLine);
|
|
3669
|
+
currentLine = word;
|
|
3670
|
+
} else {
|
|
3671
|
+
currentLine = testLine;
|
|
3672
|
+
}
|
|
3673
|
+
});
|
|
3674
|
+
if (currentLine) {
|
|
3675
|
+
wrappedLines.push(currentLine);
|
|
3676
|
+
}
|
|
3677
|
+
});
|
|
3678
|
+
const lines = wrappedLines.length ? wrappedLines : [""];
|
|
3679
|
+
const widest = Math.max(...lines.map((l) => ctx.measureText(l).width), 0);
|
|
3680
|
+
const finalWidth = (maxWidth ? Math.min(widest, maxWidth) : widest) + padding * 2;
|
|
3681
|
+
const finalHeight = lineHeight * lines.length + padding * 2;
|
|
3682
|
+
canvas.width = finalWidth;
|
|
3683
|
+
canvas.height = finalHeight;
|
|
3684
|
+
const ctx2 = canvas.getContext("2d");
|
|
3685
|
+
ctx2.font = `${fontWeight} ${fontSize}px ${fontFamily}`;
|
|
3686
|
+
ctx2.textAlign = textAlign;
|
|
3687
|
+
if (background && background !== "transparent") {
|
|
3688
|
+
ctx2.fillStyle = background;
|
|
3689
|
+
ctx2.fillRect(0, 0, canvas.width, canvas.height);
|
|
3690
|
+
}
|
|
3691
|
+
lines.forEach((line, i) => {
|
|
3692
|
+
const y = padding + lineHeight * (i + 0.8);
|
|
3693
|
+
let x = padding;
|
|
3694
|
+
if (textAlign === "center") x = canvas.width / 2;
|
|
3695
|
+
if (textAlign === "right" || textAlign === "end")
|
|
3696
|
+
x = canvas.width - padding;
|
|
3697
|
+
if (strokeWidth > 0) {
|
|
3698
|
+
ctx2.lineWidth = strokeWidth;
|
|
3699
|
+
ctx2.lineJoin = "round";
|
|
3700
|
+
ctx2.miterLimit = 2;
|
|
3701
|
+
ctx2.strokeStyle = strokeColor;
|
|
3702
|
+
ctx2.strokeText(line, x, y);
|
|
3703
|
+
}
|
|
3704
|
+
ctx2.fillStyle = color;
|
|
3705
|
+
ctx2.fillText(line, x, y);
|
|
3706
|
+
});
|
|
3707
|
+
const texture = new THREE2.CanvasTexture(canvas);
|
|
3708
|
+
texture.needsUpdate = true;
|
|
3709
|
+
texture.minFilter = THREE2.LinearFilter;
|
|
3710
|
+
return texture;
|
|
3711
|
+
}
|
|
3712
|
+
_updatePosition() {
|
|
3713
|
+
const options = this.getOptions();
|
|
3714
|
+
const layer = options.layer;
|
|
3715
|
+
if (!layer) return;
|
|
3716
|
+
const altitude = (options.altitude || 0) + this.#altitudeOffset;
|
|
3717
|
+
const z = layer.altitudeToVector3(altitude, altitude).x;
|
|
3718
|
+
const position = layer.coordinateToVector3(this._coordinate, z);
|
|
3719
|
+
(0, import_lodash6.set)(this.properties, "default.position", position);
|
|
3720
|
+
this.getObject3d().position.copy(position);
|
|
3721
|
+
}
|
|
3722
|
+
_animation() {
|
|
3723
|
+
const layer = this.getLayer();
|
|
3724
|
+
if (!this.isAdd || !layer) return;
|
|
3725
|
+
if (this._visible === true) {
|
|
3726
|
+
const zoom = layer.map.getZoom();
|
|
3727
|
+
const object3d = this.getObject3d();
|
|
3728
|
+
const { opacity } = this.getOptions();
|
|
3729
|
+
let opacityValue;
|
|
3730
|
+
if (typeof opacity === "number") {
|
|
3731
|
+
opacityValue = opacity ?? 1;
|
|
3732
|
+
} else if (Array.isArray(opacity.stops)) {
|
|
3733
|
+
opacityValue = interpolateStops(opacity, zoom);
|
|
3734
|
+
} else {
|
|
3735
|
+
throw new Error(`Unknown opacity value ${opacity}`);
|
|
3736
|
+
}
|
|
3737
|
+
const visible = opacityValue > 0.5;
|
|
3738
|
+
object3d.visible = visible;
|
|
3739
|
+
}
|
|
3740
|
+
}
|
|
3741
|
+
setText(text) {
|
|
3742
|
+
const options = this.getOptions();
|
|
3743
|
+
options.text = text;
|
|
3744
|
+
const newSprite = this._createSprite();
|
|
3745
|
+
const group = this.getObject3d();
|
|
3746
|
+
group.children.forEach((child) => group.remove(child));
|
|
3747
|
+
group.add(newSprite);
|
|
3748
|
+
this._updatePosition();
|
|
3749
|
+
}
|
|
3750
|
+
setAltitude(altitude) {
|
|
3751
|
+
const bottomHeight = this.options.bottomHeight ?? 0;
|
|
3752
|
+
return super.setAltitude(altitude + bottomHeight + this.#altitudeOffset);
|
|
3753
|
+
}
|
|
3754
|
+
};
|
|
3755
|
+
|
|
3770
3756
|
// src/IndoorMap/renderer/3d/Marker3DRenderer.ts
|
|
3771
3757
|
var HEIGHT_METER2 = 4;
|
|
3772
3758
|
var MULTIORDINAL_HEIGHT_METER3 = 9;
|
|
@@ -3870,6 +3856,9 @@ var angleBetweenLineStrings = (line1, line2) => {
|
|
|
3870
3856
|
};
|
|
3871
3857
|
|
|
3872
3858
|
// src/IndoorMap/renderer/RendererManager.ts
|
|
3859
|
+
function delay(ms) {
|
|
3860
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
3861
|
+
}
|
|
3873
3862
|
var RendererManager = class extends EventTarget {
|
|
3874
3863
|
map;
|
|
3875
3864
|
options;
|
|
@@ -3953,6 +3942,7 @@ var RendererManager = class extends EventTarget {
|
|
|
3953
3942
|
}
|
|
3954
3943
|
};
|
|
3955
3944
|
async #createElements() {
|
|
3945
|
+
await delay(this.options.delayBeforeCreateElements ?? 0);
|
|
3956
3946
|
const levels = await this.#dataClient.filterByType("level", {
|
|
3957
3947
|
populate: true
|
|
3958
3948
|
});
|
|
@@ -4314,19 +4304,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4314
4304
|
let elements = {};
|
|
4315
4305
|
let object3ds = [];
|
|
4316
4306
|
const scene = this.threeLayer.getScene();
|
|
4317
|
-
if (scene) {
|
|
4318
|
-
const {
|
|
4319
|
-
ambientLight: ambientLightConfig = {},
|
|
4320
|
-
directionalLight: directionalLightConfig = {}
|
|
4321
|
-
} = import_lodash7.default.get(this.#mapConfig, "light", {
|
|
4322
|
-
ambientLight: {},
|
|
4323
|
-
directionalLight: {}
|
|
4324
|
-
});
|
|
4325
|
-
const ambientLight = createAmbientLight(ambientLightConfig);
|
|
4326
|
-
scene.add(ambientLight);
|
|
4327
|
-
const light = createDirectionalLight(directionalLightConfig);
|
|
4328
|
-
scene.add(light);
|
|
4329
|
-
}
|
|
4330
4307
|
for (const feature2 of this.#features) {
|
|
4331
4308
|
try {
|
|
4332
4309
|
const { feature_type: featureType, properties, id } = feature2;
|