Couple with AdsumClientApi
AdsumWebMap requires AdsumClientApi in order to load data from Adsum REST API.
3D Elements and Entities
The 3D Elements is linked to Adsum Data Model using:
The AdsumWebMap does not deal with AdsumClientApi entities to keep them decoupled. Only AdsumLoader escapes this rule as it's a loader dedicated to consume AdsumClientApi data to initiate AdsumWebMap.
Place
A Place is the entity used to link the 3D Model to the Data Model. The Place refers to a location on the Map which can be:
- A Building
- A Space
- A point on the Site plane
- A point on a Floor plane
All AdsumObject3D have a placeId
property that matches the AdsumClientApi Place#id property.
Note that the AdsumObject3D, which not created by AdsumLoader, will not be present in AdsumClientApi unless you managed it yourself.
Find a Place from AdsumObject3D
const getPlaceFromAdsumObject = (adsumObject3D) => {
return entityManager.getRepository("Place").get(adsumObject3D.placeId);
};
Find an AdsumObject3D for a given place
const getAdsumObject3DFromPlace = (place) => {
if (place.shape_id !== null) {
// Prefer getSpace over using .spaces as it will return null if not found
return adsumWebMap.objectManager.getSpace(place.shape_id);
} else if (place.building_id === null) {
// Prefer getBuilding over using .building as it will return null if not found
return adsumWebMap.objectManager.getBuilding(place.building_id);
} else if (place.custom_objects.size > 0) {
return adsumWebMap.objectManager.getLabel(place.custom_objects.at(0).value);
}
return null;
};
CustomObject
The CustomObject contains the data used to generate LabelObject, so as CustomObject and LabeloObject are abstract, you will use the following children classes:
- Picto will lead to a LabelImage
- Label will lead to a LabelText
CustomObject is the naming used in AdsumClientApi for the data layer, while LabelObject is used in AdsumWebMap to represent the 3D layer.
Some CustomObject properties have a big impact on the rendering into LabelObject:
- CustomObject#orientation_mode will match with LabelObject#orientationMode property
- CustomObject#autoscale will match with LabelObject#autoScale property
- CustomObject#priority will define the level of details of the LabelObject, the LabelObject will only be visible if the camera is close enough. If priority is equals to 0, then this behavior is disabled
- CustomObject#permanent_display will define if the LabelObject will be visible by default.
Poi
POIs are not directly linked to the map but the Poi#places property will be used to uniquely identify POIs on the map.
Get path to Poi
This can be used for example to draw a path to a Poi.
// sometime a Poi may have multiple places like toilets, we want in that case to go to the closest one !
const getBestPathToPoi = (poi) => {
const places = entityManager.getRepository("Place").getList(poi.places);
const tasks = [];
for(const place of places) {
const path = new AdsumWebMap.Path(null, adsumWebMap.wayfindingManager.locationRepository.get(place.id));
tasks.push(
adsumWebMap.wayfindingManager.computePath(path)
.then(() => {
return path;
})
)
}
return Promise.all(tasks)
.then((paths) => {
let shortestPath = null;
for (const path of paths) {
if (shortestPath === null || shortestPath.getDistance() > path.getDistance()) {
shortestPath = path;
}
}
return shortestPath;
});
}