3D Dataset
ここでは、 Mapray Cloud にアップロードした 3D Dataset を表示する例を示します。
3D Dataset とは、 glTF や obj などのメッシュで構成された 3D モデルを表します。
Mapray Cloud へのアップロード
詳細は Mapray Cloud ドキュメント を参照してください。
サンプルコード
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 | <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="https://resource.mapray.com/mapray-js/v0.9.6/mapray.min.js"></script>
<script src="https://resource.mapray.com/ui/v0.9.6/maprayui.min.js"></script>
<link rel="stylesheet" href="https://resource.mapray.com/styles/v1/mapray.css">
<style>
html, body, div#mapray-container { margin: 0; padding: 0; height: 100%; }
</style>
</head>
<body>
<div id="mapray-container"></div>
</body>
</html>
<script>
async function main() {
// Set up your apikey, which can be created in Mapray Cloud.
const apikey = "<YOUR_MAPRAY_API_KEY>";
// The StandardUIViewer in the ui package includes mouse-based camera manipulation.
const uiviewer = new maprayui.StandardUIViewer( "mapray-container", apikey);
// Wait for the initialization process to complete.
await uiviewer.viewer.init_promise;
const maprayApi = new mapray.cloud.CloudApiV2({
tokenType: mapray.cloud.CloudApi.TokenType.API_KEY,
token: apikey
});
const datasetId = "5127466347659264";
const resource = maprayApi.get3DDatasetAsResource( datasetId );
const loader = new mapray.SceneLoader( uiviewer.viewer.scene, resource, {
onEntity: ( loader, entity, feature ) => {
// Since the resource is a 3D dataset, the entity will be an instance of the ModelEntity class.
// When onEntity is specified, you need to manually add the entity.
uiviewer.addEntity( entity );
// Move the camera to the model's location.
const bounds = entity.getBounds();
const length = bounds.getLatitudeDistance();
uiviewer.startFlyCamera({
time: 3.0,
iscs_end: bounds.getCenter(),
end_altitude: 15,
end_from_lookat: 40
});
}
} );
await loader.load();
}
main();
</script>
|
Info
datasetIdは、あなたがアップロードしたデータセットのIDに置き換えて下さい。