venue-js 1.2.0-next.2 → 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.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +55 -86
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -87
- 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 };
|
|
@@ -3119,14 +3121,11 @@ var CameraManager = class {
|
|
|
3119
3121
|
// src/IndoorMap/renderer/RendererManager.ts
|
|
3120
3122
|
var import_min = __toESM(require("lodash/min"));
|
|
3121
3123
|
var import_center3 = require("@turf/center");
|
|
3122
|
-
var import_maptalks9 = require("maptalks.three");
|
|
3123
3124
|
var THREE3 = __toESM(require("three"));
|
|
3124
3125
|
|
|
3125
3126
|
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
3126
|
-
var maptalks4 = __toESM(require("maptalks"));
|
|
3127
|
+
var maptalks4 = __toESM(require("maptalks-gl"));
|
|
3127
3128
|
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
3129
|
var import_buffer2 = __toESM(require("@turf/buffer"));
|
|
3131
3130
|
|
|
3132
3131
|
// src/IndoorMap/renderer/3d/element3DRendererOptions.ts
|
|
@@ -3371,21 +3370,22 @@ var getGeometryOption = (feature2, options) => {
|
|
|
3371
3370
|
var Element3DRenderer = class extends EventTarget {
|
|
3372
3371
|
options;
|
|
3373
3372
|
map;
|
|
3373
|
+
gltfLayer;
|
|
3374
3374
|
threeLayer;
|
|
3375
|
-
dracoLoader
|
|
3375
|
+
// private dracoLoader: DRACOLoader
|
|
3376
3376
|
lineMaterial;
|
|
3377
3377
|
materialByColorMap;
|
|
3378
3378
|
markerRenderer;
|
|
3379
3379
|
// Renderer is Ready
|
|
3380
3380
|
isReady = false;
|
|
3381
|
-
constructor(map, options
|
|
3381
|
+
constructor(map, options) {
|
|
3382
3382
|
super();
|
|
3383
3383
|
this.options = options;
|
|
3384
3384
|
this.map = map;
|
|
3385
|
-
|
|
3386
|
-
this.
|
|
3385
|
+
const groupLayer = this.map.getLayer("group");
|
|
3386
|
+
this.threeLayer = groupLayer.getLayer("three");
|
|
3387
|
+
this.gltfLayer = groupLayer.getLayer("gltf");
|
|
3387
3388
|
this.lineMaterial = new THREE2.LineBasicMaterial({ color: "#000" });
|
|
3388
|
-
this.threeLayer = layer;
|
|
3389
3389
|
this.render();
|
|
3390
3390
|
}
|
|
3391
3391
|
animation() {
|
|
@@ -3477,60 +3477,32 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3477
3477
|
}
|
|
3478
3478
|
};
|
|
3479
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
|
+
};
|
|
3480
3484
|
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
|
|
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
|
|
3492
3493
|
}
|
|
3493
3494
|
});
|
|
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;
|
|
3495
|
+
escalatorMarker.addTo(this.gltfLayer);
|
|
3496
|
+
return escalatorMarker;
|
|
3512
3497
|
}
|
|
3513
3498
|
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
|
|
3499
|
+
const treeMarker = new maptalks4.GLTFMarker(coordinate, {
|
|
3500
|
+
symbol: {
|
|
3501
|
+
url: "https://dashboard.situm.com/uploads/3dmodels/demoaccount/new_escalator.glb"
|
|
3525
3502
|
}
|
|
3526
3503
|
});
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
coordinate,
|
|
3530
|
-
altitude
|
|
3531
|
-
});
|
|
3532
|
-
this.threeLayer.addMesh(baseObjectModel);
|
|
3533
|
-
return baseObjectModel;
|
|
3504
|
+
treeMarker.addTo(this.gltfLayer);
|
|
3505
|
+
return treeMarker;
|
|
3534
3506
|
}
|
|
3535
3507
|
createElement(f) {
|
|
3536
3508
|
switch (f.feature_type) {
|
|
@@ -3553,21 +3525,6 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3553
3525
|
}
|
|
3554
3526
|
});
|
|
3555
3527
|
}
|
|
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
3528
|
createMarker = (coordinates, ordinal, text) => {
|
|
3572
3529
|
const options = {
|
|
3573
3530
|
// scale: 0.05,
|
|
@@ -3933,12 +3890,10 @@ var RendererManager = class extends EventTarget {
|
|
|
3933
3890
|
this.markersMap = /* @__PURE__ */ new Map();
|
|
3934
3891
|
this.markersByOrdinal = /* @__PURE__ */ new Map();
|
|
3935
3892
|
this.#dataClient = dataClient;
|
|
3893
|
+
const _this = this;
|
|
3936
3894
|
if (options.type === "3D") {
|
|
3937
|
-
const
|
|
3938
|
-
|
|
3939
|
-
forceRenderOnRotating: true
|
|
3940
|
-
});
|
|
3941
|
-
const _this = this;
|
|
3895
|
+
const groupLayer = this.map.getLayer("group");
|
|
3896
|
+
const threeLayer = groupLayer.getLayer("three");
|
|
3942
3897
|
threeLayer.prepareToDraw = function(gl, scene, camera) {
|
|
3943
3898
|
const ambientLight = new THREE3.AmbientLight(16777215, 0.3);
|
|
3944
3899
|
scene.add(ambientLight);
|
|
@@ -3948,14 +3903,13 @@ var RendererManager = class extends EventTarget {
|
|
|
3948
3903
|
scene.add(dllight);
|
|
3949
3904
|
const hemi = new THREE3.HemisphereLight(16777215, 4473924, 0.4);
|
|
3950
3905
|
scene.add(hemi);
|
|
3951
|
-
_this.elementRenderer = new Element3DRenderer(map, options.elements
|
|
3906
|
+
_this.elementRenderer = new Element3DRenderer(map, options.elements);
|
|
3952
3907
|
_this.markerRenderer = new Marker3DRenderer(map, {}, threeLayer);
|
|
3953
3908
|
if (typeof options.onRendererReady === "function") {
|
|
3954
3909
|
options.onRendererReady();
|
|
3955
3910
|
}
|
|
3956
3911
|
_this.#createElements();
|
|
3957
3912
|
};
|
|
3958
|
-
threeLayer.addTo(this.map);
|
|
3959
3913
|
} else {
|
|
3960
3914
|
this.elementRenderer = new Element2DRenderer(map, options.elements);
|
|
3961
3915
|
this.markerRenderer = new Marker2DRenderer(map);
|
|
@@ -4051,7 +4005,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4051
4005
|
);
|
|
4052
4006
|
const thisLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal === thisOrdinal);
|
|
4053
4007
|
const thatLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal !== thisOrdinal);
|
|
4054
|
-
const angle = angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
|
|
4008
|
+
const angle = 180 * (1 / Math.PI) * angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
|
|
4055
4009
|
const direction = thisOrdinal < thatLevelOpening.properties.ordinal ? "up" : "down";
|
|
4056
4010
|
const escalatorEntryPoint = (0, import_center3.center)(thisLevelOpening).geometry.coordinates;
|
|
4057
4011
|
const element = await this.elementRenderer.createEscalator(escalator, escalatorEntryPoint, { direction, angle });
|
|
@@ -4121,6 +4075,7 @@ var defaultOptions = {
|
|
|
4121
4075
|
locale: DEFAULT_LOCALE
|
|
4122
4076
|
};
|
|
4123
4077
|
var IndoorMap = class extends EventTarget {
|
|
4078
|
+
options;
|
|
4124
4079
|
//TODO: refac functions; let them do only 1 thing in a function
|
|
4125
4080
|
/** Note: "#" means private variables */
|
|
4126
4081
|
#styler = null;
|
|
@@ -4172,14 +4127,18 @@ var IndoorMap = class extends EventTarget {
|
|
|
4172
4127
|
};
|
|
4173
4128
|
constructor(elementId, options) {
|
|
4174
4129
|
super();
|
|
4130
|
+
const combinedOptions = import_lodash7.default.merge({}, defaultOptions, options);
|
|
4131
|
+
this.options = options;
|
|
4175
4132
|
const {
|
|
4176
4133
|
onMapReady,
|
|
4177
4134
|
onMapLoading,
|
|
4178
4135
|
pixelRatio,
|
|
4179
4136
|
locale
|
|
4180
|
-
} =
|
|
4137
|
+
} = combinedOptions;
|
|
4181
4138
|
this.map = new import_maptalks_gl.Map(elementId, {
|
|
4182
4139
|
attribution: false,
|
|
4140
|
+
// Temporart set, not really default view
|
|
4141
|
+
// Default view is set in camera manager
|
|
4183
4142
|
center: INITIAL_CENTER,
|
|
4184
4143
|
zoom: INITIAL_ZOOM,
|
|
4185
4144
|
clickTimeThreshold: 600,
|
|
@@ -4195,6 +4154,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
4195
4154
|
}),
|
|
4196
4155
|
layers: []
|
|
4197
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);
|
|
4198
4165
|
this.rendererManager = new RendererManager(this.map, options.dataClient, options.renderer);
|
|
4199
4166
|
this.camera = new CameraManager(this.map, options.camera);
|
|
4200
4167
|
this.locale = locale;
|
|
@@ -4207,12 +4174,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
4207
4174
|
}
|
|
4208
4175
|
set dataClient(value) {
|
|
4209
4176
|
this.#dataClient = value;
|
|
4210
|
-
this
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
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
|
+
}
|
|
4216
4185
|
}
|
|
4217
4186
|
/**
|
|
4218
4187
|
* Events
|