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.mjs
CHANGED
|
@@ -595,8 +595,11 @@ import {
|
|
|
595
595
|
TileLayer,
|
|
596
596
|
LineString as LineString3,
|
|
597
597
|
Marker as Marker2,
|
|
598
|
-
Coordinate as Coordinate4
|
|
598
|
+
Coordinate as Coordinate4,
|
|
599
|
+
GroupGLLayer,
|
|
600
|
+
GLTFLayer
|
|
599
601
|
} from "maptalks-gl";
|
|
602
|
+
import "@maptalks/transcoders.draco";
|
|
600
603
|
import TWEEN2 from "@tweenjs/tween.js";
|
|
601
604
|
import _6 from "lodash";
|
|
602
605
|
|
|
@@ -679,6 +682,7 @@ function isNumber(num) {
|
|
|
679
682
|
import turfDistance from "@turf/distance";
|
|
680
683
|
import turfCenter3 from "@turf/center";
|
|
681
684
|
import { PerspectiveCamera } from "three";
|
|
685
|
+
import { ThreeLayer as ThreeLayer3 } from "maptalks.three";
|
|
682
686
|
|
|
683
687
|
// src/IndoorMap/constants.ts
|
|
684
688
|
var defaultLayerOption = { enableAltitude: true };
|
|
@@ -3072,14 +3076,11 @@ var CameraManager = class {
|
|
|
3072
3076
|
// src/IndoorMap/renderer/RendererManager.ts
|
|
3073
3077
|
import _min from "lodash/min";
|
|
3074
3078
|
import { center as turfCenter2 } from "@turf/center";
|
|
3075
|
-
import { ThreeLayer as ThreeLayer3 } from "maptalks.three";
|
|
3076
3079
|
import * as THREE3 from "three";
|
|
3077
3080
|
|
|
3078
3081
|
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
3079
|
-
import * as maptalks4 from "maptalks";
|
|
3082
|
+
import * as maptalks4 from "maptalks-gl";
|
|
3080
3083
|
import * as THREE2 from "three";
|
|
3081
|
-
import { GLTFLoader as GLTFLoader2 } from "three/examples/jsm/loaders/GLTFLoader";
|
|
3082
|
-
import { DRACOLoader } from "three/examples/jsm/loaders/DRACOLoader";
|
|
3083
3084
|
import turfBuffer2 from "@turf/buffer";
|
|
3084
3085
|
|
|
3085
3086
|
// src/IndoorMap/renderer/3d/element3DRendererOptions.ts
|
|
@@ -3324,21 +3325,22 @@ var getGeometryOption = (feature2, options) => {
|
|
|
3324
3325
|
var Element3DRenderer = class extends EventTarget {
|
|
3325
3326
|
options;
|
|
3326
3327
|
map;
|
|
3328
|
+
gltfLayer;
|
|
3327
3329
|
threeLayer;
|
|
3328
|
-
dracoLoader
|
|
3330
|
+
// private dracoLoader: DRACOLoader
|
|
3329
3331
|
lineMaterial;
|
|
3330
3332
|
materialByColorMap;
|
|
3331
3333
|
markerRenderer;
|
|
3332
3334
|
// Renderer is Ready
|
|
3333
3335
|
isReady = false;
|
|
3334
|
-
constructor(map, options
|
|
3336
|
+
constructor(map, options) {
|
|
3335
3337
|
super();
|
|
3336
3338
|
this.options = options;
|
|
3337
3339
|
this.map = map;
|
|
3338
|
-
|
|
3339
|
-
this.
|
|
3340
|
+
const groupLayer = this.map.getLayer("group");
|
|
3341
|
+
this.threeLayer = groupLayer.getLayer("three");
|
|
3342
|
+
this.gltfLayer = groupLayer.getLayer("gltf");
|
|
3340
3343
|
this.lineMaterial = new THREE2.LineBasicMaterial({ color: "#000" });
|
|
3341
|
-
this.threeLayer = layer;
|
|
3342
3344
|
this.render();
|
|
3343
3345
|
}
|
|
3344
3346
|
animation() {
|
|
@@ -3430,60 +3432,32 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3430
3432
|
}
|
|
3431
3433
|
};
|
|
3432
3434
|
async createEscalator(f, coordinate, options) {
|
|
3435
|
+
const model = {
|
|
3436
|
+
url: "https://cdn.venue.in.th/static/glb/escalator.glb",
|
|
3437
|
+
size: 4.4
|
|
3438
|
+
};
|
|
3433
3439
|
const { direction: dir, angle } = options;
|
|
3434
|
-
const
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
},
|
|
3443
|
-
position: { x: 0, y: 0, z: 0 },
|
|
3444
|
-
scale: 0.01
|
|
3440
|
+
const rotationZ = dir === "up" ? 180 + angle : angle;
|
|
3441
|
+
var escalatorMarker = new maptalks4.GLTFMarker(coordinate, {
|
|
3442
|
+
symbol: {
|
|
3443
|
+
url: model.url,
|
|
3444
|
+
rotationZ,
|
|
3445
|
+
translationX: dir === "up" ? 0 : model.size * Math.cos(Math.PI * rotationZ / 180),
|
|
3446
|
+
translationY: dir === "up" ? 0 : model.size * Math.sin(Math.PI * rotationZ / 180),
|
|
3447
|
+
translationZ: dir === "up" ? -0.05 * model.size : -0.5 * model.size
|
|
3445
3448
|
}
|
|
3446
3449
|
});
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
const pivotPoint = dir === "up" ? new THREE2.Vector3(0, 0, 0) : new THREE2.Vector3(
|
|
3450
|
-
1 * (box.min.x + box.max.x),
|
|
3451
|
-
1 * (box.min.y + box.max.y),
|
|
3452
|
-
0.6 * box.max.z
|
|
3453
|
-
);
|
|
3454
|
-
const pivot = new THREE2.Group();
|
|
3455
|
-
pivot.add(model);
|
|
3456
|
-
model.position.sub(pivotPoint);
|
|
3457
|
-
model.updateMatrixWorld(true);
|
|
3458
|
-
const altitude = f.properties.ordinal * HEIGHT_METER;
|
|
3459
|
-
const baseObjectModel = this.threeLayer.toModel(pivot, {
|
|
3460
|
-
coordinate,
|
|
3461
|
-
altitude
|
|
3462
|
-
});
|
|
3463
|
-
this.threeLayer.addMesh(baseObjectModel);
|
|
3464
|
-
return baseObjectModel;
|
|
3450
|
+
escalatorMarker.addTo(this.gltfLayer);
|
|
3451
|
+
return escalatorMarker;
|
|
3465
3452
|
}
|
|
3466
3453
|
async createTree(coordinate, ordinal) {
|
|
3467
|
-
const
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
rotation: {
|
|
3471
|
-
x: 0.5 * Math.PI,
|
|
3472
|
-
// Rotate the model up (new_escalator.glb)
|
|
3473
|
-
y: 0,
|
|
3474
|
-
z: 0
|
|
3475
|
-
},
|
|
3476
|
-
position: { x: 0, y: 0, z: 0 },
|
|
3477
|
-
scale: 0.01
|
|
3454
|
+
const treeMarker = new maptalks4.GLTFMarker(coordinate, {
|
|
3455
|
+
symbol: {
|
|
3456
|
+
url: "https://dashboard.situm.com/uploads/3dmodels/demoaccount/new_escalator.glb"
|
|
3478
3457
|
}
|
|
3479
3458
|
});
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
coordinate,
|
|
3483
|
-
altitude
|
|
3484
|
-
});
|
|
3485
|
-
this.threeLayer.addMesh(baseObjectModel);
|
|
3486
|
-
return baseObjectModel;
|
|
3459
|
+
treeMarker.addTo(this.gltfLayer);
|
|
3460
|
+
return treeMarker;
|
|
3487
3461
|
}
|
|
3488
3462
|
createElement(f) {
|
|
3489
3463
|
switch (f.feature_type) {
|
|
@@ -3506,21 +3480,6 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3506
3480
|
}
|
|
3507
3481
|
});
|
|
3508
3482
|
}
|
|
3509
|
-
async loadModel3d(model3d) {
|
|
3510
|
-
const loader = new GLTFLoader2();
|
|
3511
|
-
loader.setDRACOLoader(this.dracoLoader);
|
|
3512
|
-
const { url, properties: modelProperties } = model3d;
|
|
3513
|
-
const gltf = await loader.loadAsync(url);
|
|
3514
|
-
const model = gltf.scene;
|
|
3515
|
-
model.rotation.x = modelProperties.rotation.x;
|
|
3516
|
-
model.rotation.y = modelProperties.rotation.y;
|
|
3517
|
-
model.position.x = modelProperties.position.x;
|
|
3518
|
-
model.position.y = modelProperties.position.y;
|
|
3519
|
-
model.position.z = modelProperties.position.z;
|
|
3520
|
-
const scale2 = modelProperties.scale;
|
|
3521
|
-
model.scale.set(scale2, scale2, scale2);
|
|
3522
|
-
return model;
|
|
3523
|
-
}
|
|
3524
3483
|
createMarker = (coordinates, ordinal, text) => {
|
|
3525
3484
|
const options = {
|
|
3526
3485
|
// scale: 0.05,
|
|
@@ -3886,12 +3845,10 @@ var RendererManager = class extends EventTarget {
|
|
|
3886
3845
|
this.markersMap = /* @__PURE__ */ new Map();
|
|
3887
3846
|
this.markersByOrdinal = /* @__PURE__ */ new Map();
|
|
3888
3847
|
this.#dataClient = dataClient;
|
|
3848
|
+
const _this = this;
|
|
3889
3849
|
if (options.type === "3D") {
|
|
3890
|
-
const
|
|
3891
|
-
|
|
3892
|
-
forceRenderOnRotating: true
|
|
3893
|
-
});
|
|
3894
|
-
const _this = this;
|
|
3850
|
+
const groupLayer = this.map.getLayer("group");
|
|
3851
|
+
const threeLayer = groupLayer.getLayer("three");
|
|
3895
3852
|
threeLayer.prepareToDraw = function(gl, scene, camera) {
|
|
3896
3853
|
const ambientLight = new THREE3.AmbientLight(16777215, 0.3);
|
|
3897
3854
|
scene.add(ambientLight);
|
|
@@ -3901,14 +3858,13 @@ var RendererManager = class extends EventTarget {
|
|
|
3901
3858
|
scene.add(dllight);
|
|
3902
3859
|
const hemi = new THREE3.HemisphereLight(16777215, 4473924, 0.4);
|
|
3903
3860
|
scene.add(hemi);
|
|
3904
|
-
_this.elementRenderer = new Element3DRenderer(map, options.elements
|
|
3861
|
+
_this.elementRenderer = new Element3DRenderer(map, options.elements);
|
|
3905
3862
|
_this.markerRenderer = new Marker3DRenderer(map, {}, threeLayer);
|
|
3906
3863
|
if (typeof options.onRendererReady === "function") {
|
|
3907
3864
|
options.onRendererReady();
|
|
3908
3865
|
}
|
|
3909
3866
|
_this.#createElements();
|
|
3910
3867
|
};
|
|
3911
|
-
threeLayer.addTo(this.map);
|
|
3912
3868
|
} else {
|
|
3913
3869
|
this.elementRenderer = new Element2DRenderer(map, options.elements);
|
|
3914
3870
|
this.markerRenderer = new Marker2DRenderer(map);
|
|
@@ -4004,7 +3960,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4004
3960
|
);
|
|
4005
3961
|
const thisLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal === thisOrdinal);
|
|
4006
3962
|
const thatLevelOpening = bothOpenings.find((opening) => opening.properties.ordinal !== thisOrdinal);
|
|
4007
|
-
const angle = angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
|
|
3963
|
+
const angle = 180 * (1 / Math.PI) * angleBetweenLineStrings(thisLevelOpening.geometry.coordinates, thatLevelOpening.geometry.coordinates);
|
|
4008
3964
|
const direction = thisOrdinal < thatLevelOpening.properties.ordinal ? "up" : "down";
|
|
4009
3965
|
const escalatorEntryPoint = turfCenter2(thisLevelOpening).geometry.coordinates;
|
|
4010
3966
|
const element = await this.elementRenderer.createEscalator(escalator, escalatorEntryPoint, { direction, angle });
|
|
@@ -4074,6 +4030,7 @@ var defaultOptions = {
|
|
|
4074
4030
|
locale: DEFAULT_LOCALE
|
|
4075
4031
|
};
|
|
4076
4032
|
var IndoorMap = class extends EventTarget {
|
|
4033
|
+
options;
|
|
4077
4034
|
//TODO: refac functions; let them do only 1 thing in a function
|
|
4078
4035
|
/** Note: "#" means private variables */
|
|
4079
4036
|
#styler = null;
|
|
@@ -4125,14 +4082,18 @@ var IndoorMap = class extends EventTarget {
|
|
|
4125
4082
|
};
|
|
4126
4083
|
constructor(elementId, options) {
|
|
4127
4084
|
super();
|
|
4085
|
+
const combinedOptions = _6.merge({}, defaultOptions, options);
|
|
4086
|
+
this.options = options;
|
|
4128
4087
|
const {
|
|
4129
4088
|
onMapReady,
|
|
4130
4089
|
onMapLoading,
|
|
4131
4090
|
pixelRatio,
|
|
4132
4091
|
locale
|
|
4133
|
-
} =
|
|
4092
|
+
} = combinedOptions;
|
|
4134
4093
|
this.map = new Map2(elementId, {
|
|
4135
4094
|
attribution: false,
|
|
4095
|
+
// Temporart set, not really default view
|
|
4096
|
+
// Default view is set in camera manager
|
|
4136
4097
|
center: INITIAL_CENTER,
|
|
4137
4098
|
zoom: INITIAL_ZOOM,
|
|
4138
4099
|
clickTimeThreshold: 600,
|
|
@@ -4148,6 +4109,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
4148
4109
|
}),
|
|
4149
4110
|
layers: []
|
|
4150
4111
|
});
|
|
4112
|
+
const groupLayer = new GroupGLLayer("group", [], {}).addTo(this.map);
|
|
4113
|
+
const threeLayer = new ThreeLayer3("three", {
|
|
4114
|
+
forceRenderOnMoving: true,
|
|
4115
|
+
forceRenderOnRotating: true
|
|
4116
|
+
});
|
|
4117
|
+
groupLayer.addLayer(threeLayer);
|
|
4118
|
+
const gltfLayer = new GLTFLayer("gltf");
|
|
4119
|
+
groupLayer.addLayer(gltfLayer);
|
|
4151
4120
|
this.rendererManager = new RendererManager(this.map, options.dataClient, options.renderer);
|
|
4152
4121
|
this.camera = new CameraManager(this.map, options.camera);
|
|
4153
4122
|
this.locale = locale;
|
|
@@ -4160,12 +4129,14 @@ var IndoorMap = class extends EventTarget {
|
|
|
4160
4129
|
}
|
|
4161
4130
|
set dataClient(value) {
|
|
4162
4131
|
this.#dataClient = value;
|
|
4163
|
-
this
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4132
|
+
if (!this.options.camera.defaultView.center) {
|
|
4133
|
+
this.#dataClient.filterByType("venue").then((venues) => {
|
|
4134
|
+
const venueCenters = turfCenter3(featureCollection(venues));
|
|
4135
|
+
const [x, y] = venueCenters.geometry.coordinates;
|
|
4136
|
+
const center2 = new Coordinate4(x, y);
|
|
4137
|
+
this.camera.setView({ center: center2, pitch: 60, zoom: 19 });
|
|
4138
|
+
});
|
|
4139
|
+
}
|
|
4169
4140
|
}
|
|
4170
4141
|
/**
|
|
4171
4142
|
* Events
|