venue-js 1.2.0-next.2 → 1.2.0-next.4
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +61 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -94
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -3,12 +3,12 @@ export { QueryObserver } from '@tanstack/query-core';
|
|
|
3
3
|
import * as geojson from 'geojson';
|
|
4
4
|
import { Position, Geometry, GeoJsonProperties, Feature, Point, Polygon, MultiPolygon, LineString, GeometryCollection } from 'geojson';
|
|
5
5
|
import * as maptalks_dist_core_Class from 'maptalks/dist/core/Class';
|
|
6
|
+
import * as maptalks from 'maptalks-gl';
|
|
6
7
|
import { Map } from 'maptalks-gl';
|
|
7
8
|
import { BaseObject, ThreeLayer } from 'maptalks.three';
|
|
8
9
|
import { ExtrudePolygonOptionType } from 'maptalks.three/dist/type';
|
|
9
10
|
import { PolygonOptionsType } from 'maptalks/dist/geometry/Polygon';
|
|
10
11
|
import { LineStringOptionsType } from 'maptalks/dist/geometry/LineString';
|
|
11
|
-
import * as maptalks from 'maptalks';
|
|
12
12
|
import { Extent, Marker, ui, LineString as LineString$1, Polygon as Polygon$1, MultiPolygon as MultiPolygon$1, MultiLineString } from 'maptalks';
|
|
13
13
|
import { MapViewType, MapAnimationOptionsType, MapPaddingType } from 'maptalks/dist/map/Map';
|
|
14
14
|
import { SpriteMaterial, AmbientLight, DirectionalLight } from 'three';
|
|
@@ -817,6 +817,7 @@ interface ISetHighlightElementIdsOptions {
|
|
|
817
817
|
|
|
818
818
|
declare class IndoorMap extends EventTarget {
|
|
819
819
|
#private;
|
|
820
|
+
options: IndoorMapOptions;
|
|
820
821
|
map: Map | null;
|
|
821
822
|
camera: CameraManager;
|
|
822
823
|
rendererManager: RendererManager;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,12 @@ export { QueryObserver } from '@tanstack/query-core';
|
|
|
3
3
|
import * as geojson from 'geojson';
|
|
4
4
|
import { Position, Geometry, GeoJsonProperties, Feature, Point, Polygon, MultiPolygon, LineString, GeometryCollection } from 'geojson';
|
|
5
5
|
import * as maptalks_dist_core_Class from 'maptalks/dist/core/Class';
|
|
6
|
+
import * as maptalks from 'maptalks-gl';
|
|
6
7
|
import { Map } from 'maptalks-gl';
|
|
7
8
|
import { BaseObject, ThreeLayer } from 'maptalks.three';
|
|
8
9
|
import { ExtrudePolygonOptionType } from 'maptalks.three/dist/type';
|
|
9
10
|
import { PolygonOptionsType } from 'maptalks/dist/geometry/Polygon';
|
|
10
11
|
import { LineStringOptionsType } from 'maptalks/dist/geometry/LineString';
|
|
11
|
-
import * as maptalks from 'maptalks';
|
|
12
12
|
import { Extent, Marker, ui, LineString as LineString$1, Polygon as Polygon$1, MultiPolygon as MultiPolygon$1, MultiLineString } from 'maptalks';
|
|
13
13
|
import { MapViewType, MapAnimationOptionsType, MapPaddingType } from 'maptalks/dist/map/Map';
|
|
14
14
|
import { SpriteMaterial, AmbientLight, DirectionalLight } from 'three';
|
|
@@ -817,6 +817,7 @@ interface ISetHighlightElementIdsOptions {
|
|
|
817
817
|
|
|
818
818
|
declare class IndoorMap extends EventTarget {
|
|
819
819
|
#private;
|
|
820
|
+
options: IndoorMapOptions;
|
|
820
821
|
map: Map | null;
|
|
821
822
|
camera: CameraManager;
|
|
822
823
|
rendererManager: RendererManager;
|
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
|
|
|
@@ -752,6 +753,7 @@ function isNumber(num) {
|
|
|
752
753
|
var import_distance = __toESM(require("@turf/distance"));
|
|
753
754
|
var import_center4 = __toESM(require("@turf/center"));
|
|
754
755
|
var import_three8 = require("three");
|
|
756
|
+
var import_maptalks9 = require("maptalks.three");
|
|
755
757
|
|
|
756
758
|
// src/IndoorMap/constants.ts
|
|
757
759
|
var defaultLayerOption = { enableAltitude: true };
|
|
@@ -3070,7 +3072,9 @@ var CameraManager = class {
|
|
|
3070
3072
|
return this.map.getView();
|
|
3071
3073
|
};
|
|
3072
3074
|
setView = (value) => {
|
|
3073
|
-
this.map
|
|
3075
|
+
if (this.map) {
|
|
3076
|
+
this.map.setView(value);
|
|
3077
|
+
}
|
|
3074
3078
|
};
|
|
3075
3079
|
animateTo = (view, options = {}, step) => {
|
|
3076
3080
|
this.map.animateTo(view, options, step);
|
|
@@ -3119,14 +3123,11 @@ var CameraManager = class {
|
|
|
3119
3123
|
// src/IndoorMap/renderer/RendererManager.ts
|
|
3120
3124
|
var import_min = __toESM(require("lodash/min"));
|
|
3121
3125
|
var import_center3 = require("@turf/center");
|
|
3122
|
-
var import_maptalks9 = require("maptalks.three");
|
|
3123
3126
|
var THREE3 = __toESM(require("three"));
|
|
3124
3127
|
|
|
3125
3128
|
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
3126
|
-
var maptalks4 = __toESM(require("maptalks"));
|
|
3129
|
+
var maptalks4 = __toESM(require("maptalks-gl"));
|
|
3127
3130
|
var THREE2 = __toESM(require("three"));
|
|
3128
|
-
var import_GLTFLoader2 = require("three/examples/jsm/loaders/GLTFLoader");
|
|
3129
|
-
var import_DRACOLoader = require("three/examples/jsm/loaders/DRACOLoader");
|
|
3130
3131
|
var import_buffer2 = __toESM(require("@turf/buffer"));
|
|
3131
3132
|
|
|
3132
3133
|
// src/IndoorMap/renderer/3d/element3DRendererOptions.ts
|
|
@@ -3371,21 +3372,22 @@ var getGeometryOption = (feature2, options) => {
|
|
|
3371
3372
|
var Element3DRenderer = class extends EventTarget {
|
|
3372
3373
|
options;
|
|
3373
3374
|
map;
|
|
3375
|
+
gltfLayer;
|
|
3374
3376
|
threeLayer;
|
|
3375
|
-
dracoLoader
|
|
3377
|
+
// private dracoLoader: DRACOLoader
|
|
3376
3378
|
lineMaterial;
|
|
3377
3379
|
materialByColorMap;
|
|
3378
3380
|
markerRenderer;
|
|
3379
3381
|
// Renderer is Ready
|
|
3380
3382
|
isReady = false;
|
|
3381
|
-
constructor(map, options
|
|
3383
|
+
constructor(map, options) {
|
|
3382
3384
|
super();
|
|
3383
3385
|
this.options = options;
|
|
3384
3386
|
this.map = map;
|
|
3385
|
-
|
|
3386
|
-
this.
|
|
3387
|
+
const groupLayer = this.map.getLayer("group");
|
|
3388
|
+
this.threeLayer = groupLayer.getLayer("three");
|
|
3389
|
+
this.gltfLayer = groupLayer.getLayer("gltf");
|
|
3387
3390
|
this.lineMaterial = new THREE2.LineBasicMaterial({ color: "#000" });
|
|
3388
|
-
this.threeLayer = layer;
|
|
3389
3391
|
this.render();
|
|
3390
3392
|
}
|
|
3391
3393
|
animation() {
|
|
@@ -3421,7 +3423,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3421
3423
|
const color = feature3.properties.style.polygonFill ?? colorOptions ?? "#ffffff";
|
|
3422
3424
|
if (color === "transparent") return;
|
|
3423
3425
|
const material = this.getOrCreateMaterialByColor(color);
|
|
3424
|
-
const altitude =
|
|
3426
|
+
const altitude = 0;
|
|
3425
3427
|
const height = feature3.properties.height ?? heightOptions ?? HEIGHT_METER;
|
|
3426
3428
|
const bottomHeight = feature3.properties.bottomHeight ?? bottomHeightOptions ?? 0;
|
|
3427
3429
|
const extrudedPolygon = this.threeLayer.toExtrudePolygon(
|
|
@@ -3429,9 +3431,6 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3429
3431
|
{ asynchronous: true, ...options, height, bottomHeight, altitude },
|
|
3430
3432
|
material
|
|
3431
3433
|
);
|
|
3432
|
-
extrudedPolygon.on("click", (e) => {
|
|
3433
|
-
console.log(e.target.options.polygon.id);
|
|
3434
|
-
});
|
|
3435
3434
|
const topLineStrings = [
|
|
3436
3435
|
new maptalks4.LineString(outerRing),
|
|
3437
3436
|
...innerRings.map((innerRing) => new maptalks4.LineString(innerRing))
|
|
@@ -3452,7 +3451,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3452
3451
|
);
|
|
3453
3452
|
return [extrudedPolygon, topLines, bottomLines];
|
|
3454
3453
|
} catch (err) {
|
|
3455
|
-
|
|
3454
|
+
return [];
|
|
3456
3455
|
}
|
|
3457
3456
|
};
|
|
3458
3457
|
try {
|
|
@@ -3477,60 +3476,32 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3477
3476
|
}
|
|
3478
3477
|
};
|
|
3479
3478
|
async createEscalator(f, coordinate, options) {
|
|
3479
|
+
const model = {
|
|
3480
|
+
url: "https://cdn.venue.in.th/static/glb/escalator.glb",
|
|
3481
|
+
size: 4.4
|
|
3482
|
+
};
|
|
3480
3483
|
const { direction: dir, angle } = options;
|
|
3481
|
-
const
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
},
|
|
3490
|
-
position: { x: 0, y: 0, z: 0 },
|
|
3491
|
-
scale: 0.01
|
|
3484
|
+
const rotationZ = dir === "up" ? 180 + angle : angle;
|
|
3485
|
+
var escalatorMarker = new maptalks4.GLTFMarker(coordinate, {
|
|
3486
|
+
symbol: {
|
|
3487
|
+
url: model.url,
|
|
3488
|
+
rotationZ,
|
|
3489
|
+
translationX: dir === "up" ? 0 : model.size * Math.cos(Math.PI * rotationZ / 180),
|
|
3490
|
+
translationY: dir === "up" ? 0 : model.size * Math.sin(Math.PI * rotationZ / 180),
|
|
3491
|
+
translationZ: dir === "up" ? -0.05 * model.size : -0.5 * model.size
|
|
3492
3492
|
}
|
|
3493
3493
|
});
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
const pivotPoint = dir === "up" ? new THREE2.Vector3(0, 0, 0) : new THREE2.Vector3(
|
|
3497
|
-
1 * (box.min.x + box.max.x),
|
|
3498
|
-
1 * (box.min.y + box.max.y),
|
|
3499
|
-
0.6 * box.max.z
|
|
3500
|
-
);
|
|
3501
|
-
const pivot = new THREE2.Group();
|
|
3502
|
-
pivot.add(model);
|
|
3503
|
-
model.position.sub(pivotPoint);
|
|
3504
|
-
model.updateMatrixWorld(true);
|
|
3505
|
-
const altitude = f.properties.ordinal * HEIGHT_METER;
|
|
3506
|
-
const baseObjectModel = this.threeLayer.toModel(pivot, {
|
|
3507
|
-
coordinate,
|
|
3508
|
-
altitude
|
|
3509
|
-
});
|
|
3510
|
-
this.threeLayer.addMesh(baseObjectModel);
|
|
3511
|
-
return baseObjectModel;
|
|
3494
|
+
escalatorMarker.addTo(this.gltfLayer);
|
|
3495
|
+
return escalatorMarker;
|
|
3512
3496
|
}
|
|
3513
3497
|
async createTree(coordinate, ordinal) {
|
|
3514
|
-
const
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
rotation: {
|
|
3518
|
-
x: 0.5 * Math.PI,
|
|
3519
|
-
// Rotate the model up (new_escalator.glb)
|
|
3520
|
-
y: 0,
|
|
3521
|
-
z: 0
|
|
3522
|
-
},
|
|
3523
|
-
position: { x: 0, y: 0, z: 0 },
|
|
3524
|
-
scale: 0.01
|
|
3498
|
+
const treeMarker = new maptalks4.GLTFMarker(coordinate, {
|
|
3499
|
+
symbol: {
|
|
3500
|
+
url: "https://dashboard.situm.com/uploads/3dmodels/demoaccount/new_escalator.glb"
|
|
3525
3501
|
}
|
|
3526
3502
|
});
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
coordinate,
|
|
3530
|
-
altitude
|
|
3531
|
-
});
|
|
3532
|
-
this.threeLayer.addMesh(baseObjectModel);
|
|
3533
|
-
return baseObjectModel;
|
|
3503
|
+
treeMarker.addTo(this.gltfLayer);
|
|
3504
|
+
return treeMarker;
|
|
3534
3505
|
}
|
|
3535
3506
|
createElement(f) {
|
|
3536
3507
|
switch (f.feature_type) {
|
|
@@ -3553,21 +3524,6 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3553
3524
|
}
|
|
3554
3525
|
});
|
|
3555
3526
|
}
|
|
3556
|
-
async loadModel3d(model3d) {
|
|
3557
|
-
const loader = new import_GLTFLoader2.GLTFLoader();
|
|
3558
|
-
loader.setDRACOLoader(this.dracoLoader);
|
|
3559
|
-
const { url, properties: modelProperties } = model3d;
|
|
3560
|
-
const gltf = await loader.loadAsync(url);
|
|
3561
|
-
const model = gltf.scene;
|
|
3562
|
-
model.rotation.x = modelProperties.rotation.x;
|
|
3563
|
-
model.rotation.y = modelProperties.rotation.y;
|
|
3564
|
-
model.position.x = modelProperties.position.x;
|
|
3565
|
-
model.position.y = modelProperties.position.y;
|
|
3566
|
-
model.position.z = modelProperties.position.z;
|
|
3567
|
-
const scale2 = modelProperties.scale;
|
|
3568
|
-
model.scale.set(scale2, scale2, scale2);
|
|
3569
|
-
return model;
|
|
3570
|
-
}
|
|
3571
3527
|
createMarker = (coordinates, ordinal, text) => {
|
|
3572
3528
|
const options = {
|
|
3573
3529
|
// scale: 0.05,
|
|
@@ -3933,12 +3889,10 @@ var RendererManager = class extends EventTarget {
|
|
|
3933
3889
|
this.markersMap = /* @__PURE__ */ new Map();
|
|
3934
3890
|
this.markersByOrdinal = /* @__PURE__ */ new Map();
|
|
3935
3891
|
this.#dataClient = dataClient;
|
|
3892
|
+
const _this = this;
|
|
3936
3893
|
if (options.type === "3D") {
|
|
3937
|
-
const
|
|
3938
|
-
|
|
3939
|
-
forceRenderOnRotating: true
|
|
3940
|
-
});
|
|
3941
|
-
const _this = this;
|
|
3894
|
+
const groupLayer = this.map.getLayer("group");
|
|
3895
|
+
const threeLayer = groupLayer.getLayer("three");
|
|
3942
3896
|
threeLayer.prepareToDraw = function(gl, scene, camera) {
|
|
3943
3897
|
const ambientLight = new THREE3.AmbientLight(16777215, 0.3);
|
|
3944
3898
|
scene.add(ambientLight);
|
|
@@ -3948,14 +3902,13 @@ var RendererManager = class extends EventTarget {
|
|
|
3948
3902
|
scene.add(dllight);
|
|
3949
3903
|
const hemi = new THREE3.HemisphereLight(16777215, 4473924, 0.4);
|
|
3950
3904
|
scene.add(hemi);
|
|
3951
|
-
_this.elementRenderer = new Element3DRenderer(map, options.elements
|
|
3905
|
+
_this.elementRenderer = new Element3DRenderer(map, options.elements);
|
|
3952
3906
|
_this.markerRenderer = new Marker3DRenderer(map, {}, threeLayer);
|
|
3953
3907
|
if (typeof options.onRendererReady === "function") {
|
|
3954
3908
|
options.onRendererReady();
|
|
3955
3909
|
}
|
|
3956
3910
|
_this.#createElements();
|
|
3957
3911
|
};
|
|
3958
|
-
threeLayer.addTo(this.map);
|
|
3959
3912
|
} else {
|
|
3960
3913
|
this.elementRenderer = new Element2DRenderer(map, options.elements);
|
|
3961
3914
|
this.markerRenderer = new Marker2DRenderer(map);
|
|
@@ -4051,7 +4004,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4051
4004
|
);
|
|
4052
4005
|
const thisLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal === thisOrdinal);
|
|
4053
4006
|
const thatLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal !== thisOrdinal);
|
|
4054
|
-
const angle = angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
|
|
4007
|
+
const angle = 180 * (1 / Math.PI) * angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
|
|
4055
4008
|
const direction = thisOrdinal < thatLevelOpening.properties.ordinal ? "up" : "down";
|
|
4056
4009
|
const escalatorEntryPoint = (0, import_center3.center)(thisLevelOpening).geometry.coordinates;
|
|
4057
4010
|
const element = await this.elementRenderer.createEscalator(escalator, escalatorEntryPoint, { direction, angle });
|
|
@@ -4060,7 +4013,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4060
4013
|
this.addElementsToManager(escalator.id, _elements, escalator.properties.ordinal);
|
|
4061
4014
|
}
|
|
4062
4015
|
} catch (err) {
|
|
4063
|
-
console.
|
|
4016
|
+
console.warn(`cannot create escalator`, err.message);
|
|
4064
4017
|
}
|
|
4065
4018
|
}
|
|
4066
4019
|
this.changeLevelByOrdinal(this.currentOrdinals);
|
|
@@ -4121,6 +4074,7 @@ var defaultOptions = {
|
|
|
4121
4074
|
locale: DEFAULT_LOCALE
|
|
4122
4075
|
};
|
|
4123
4076
|
var IndoorMap = class extends EventTarget {
|
|
4077
|
+
options;
|
|
4124
4078
|
//TODO: refac functions; let them do only 1 thing in a function
|
|
4125
4079
|
/** Note: "#" means private variables */
|
|
4126
4080
|
#styler = null;
|
|
@@ -4172,14 +4126,18 @@ var IndoorMap = class extends EventTarget {
|
|
|
4172
4126
|
};
|
|
4173
4127
|
constructor(elementId, options) {
|
|
4174
4128
|
super();
|
|
4129
|
+
const combinedOptions = import_lodash7.default.merge({}, defaultOptions, options);
|
|
4130
|
+
this.options = options;
|
|
4175
4131
|
const {
|
|
4176
4132
|
onMapReady,
|
|
4177
4133
|
onMapLoading,
|
|
4178
4134
|
pixelRatio,
|
|
4179
4135
|
locale
|
|
4180
|
-
} =
|
|
4136
|
+
} = combinedOptions;
|
|
4181
4137
|
this.map = new import_maptalks_gl.Map(elementId, {
|
|
4182
4138
|
attribution: false,
|
|
4139
|
+
// Temporart set, not really default view
|
|
4140
|
+
// Default view is set in camera manager
|
|
4183
4141
|
center: INITIAL_CENTER,
|
|
4184
4142
|
zoom: INITIAL_ZOOM,
|
|
4185
4143
|
clickTimeThreshold: 600,
|
|
@@ -4195,6 +4153,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
4195
4153
|
}),
|
|
4196
4154
|
layers: []
|
|
4197
4155
|
});
|
|
4156
|
+
const groupLayer = new import_maptalks_gl.GroupGLLayer("group", [], {}).addTo(this.map);
|
|
4157
|
+
const threeLayer = new import_maptalks9.ThreeLayer("three", {
|
|
4158
|
+
forceRenderOnMoving: true,
|
|
4159
|
+
forceRenderOnRotating: true
|
|
4160
|
+
});
|
|
4161
|
+
groupLayer.addLayer(threeLayer);
|
|
4162
|
+
const gltfLayer = new import_maptalks_gl.GLTFLayer("gltf");
|
|
4163
|
+
groupLayer.addLayer(gltfLayer);
|
|
4198
4164
|
this.rendererManager = new RendererManager(this.map, options.dataClient, options.renderer);
|
|
4199
4165
|
this.camera = new CameraManager(this.map, options.camera);
|
|
4200
4166
|
this.locale = locale;
|
|
@@ -4207,12 +4173,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
4207
4173
|
}
|
|
4208
4174
|
set dataClient(value) {
|
|
4209
4175
|
this.#dataClient = value;
|
|
4210
|
-
this
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4176
|
+
if (!this.options.camera.defaultView.center) {
|
|
4177
|
+
this.#dataClient.filterByType("venue").then((venues) => {
|
|
4178
|
+
const venueCenters = (0, import_center4.default)(featureCollection(venues));
|
|
4179
|
+
const [x, y] = venueCenters.geometry.coordinates;
|
|
4180
|
+
const center2 = new import_maptalks_gl.Coordinate(x, y);
|
|
4181
|
+
this.camera.setView({ center: center2, pitch: 60, zoom: 19 });
|
|
4182
|
+
});
|
|
4183
|
+
}
|
|
4216
4184
|
}
|
|
4217
4185
|
/**
|
|
4218
4186
|
* Events
|