-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathvisualizer.html
176 lines (162 loc) · 6.03 KB
/
visualizer.html
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<!DOCTYPE html>
<html>
<head>
<title>Point cloud visualizer</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./assets/css/examples.css" />
<link rel="stylesheet" href="./assets/css/point_cloud_visualizer.css" />
<link rel="stylesheet" href="./assets/css/widget_layer_choice.css" />
<link rel="stylesheet" href="./assets/css/widget_bookmark.css" />
<link rel="stylesheet" href="./assets/css/loading_screen.css" />
</head>
<body>
<script src="../dist/RUN_MODE/bundle.js"></script>
<script src="./assets/js/loadingScreen.js"></script>
<script type="text/javascript">
const udviz = window.udviz;
udviz
.loadMultipleJSON([
'./assets/config/extents.json',
'./assets/config/crs.json',
'./assets/config/layer/3DTiles_point_cloud.json',
'./assets/config/layer/elevation.json',
'./assets/config/layer/base_maps.json',
])
.then((configs) => {
udviz.proj4.default.defs(
configs['crs'][0].name,
configs['crs'][0].transform
);
const extent = new udviz.itowns.Extent(
configs['extents'][0].name,
parseInt(configs['extents'][0].west),
parseInt(configs['extents'][0].east),
parseInt(configs['extents'][0].south),
parseInt(configs['extents'][0].north)
);
const DEFAULT_POINT_SIZE = 0.1;
const app = new udviz.visualizer.Visualizer(
extent,
configs['3DTiles_point_cloud'],
{
parentDomElement: document.body,
domElementClass: 'full_screen',
defaultPointCloudSize: DEFAULT_POINT_SIZE,
c3DTilesLoadingDomElementClasses: ['centered', 'loading'],
camera: {
default: {
position: {
x: 1844753,
y: 5174961,
z: 1000,
},
},
},
measure: true,
}
);
// add elevation layer
const isTextureFormat =
configs['elevation']['format'] == 'image/jpeg' ||
configs['elevation']['format'] == 'image/png';
app.itownsView.addLayer(
new udviz.itowns.ElevationLayer(
configs['elevation']['layer_name'],
{
useColorTextureElevation: isTextureFormat,
colorTextureElevationMinZ: isTextureFormat
? configs['elevation']['colorTextureElevationMinZ']
: null,
colorTextureElevationMaxZ: isTextureFormat
? configs['elevation']['colorTextureElevationMaxZ']
: null,
source: new udviz.itowns.WMSSource({
extent: extent,
url: configs['elevation']['url'],
name: configs['elevation']['name'],
crs: extent.crs,
heightMapWidth: 256,
format: configs['elevation']['format'],
}),
}
)
);
// add basemaps
configs['base_maps'].forEach((baseMapConfig) => {
app.itownsView.addLayer(
new udviz.itowns.ColorLayer(baseMapConfig.name, {
updateStrategy: {
type: udviz.itowns.STRATEGY_DICHOTOMY,
options: {},
},
name: baseMapConfig.name,
source: new udviz.itowns.WMSSource({
extent: extent,
name: baseMapConfig.source.name,
url: baseMapConfig.source.url,
version: baseMapConfig.source.version,
crs: extent.crs,
format: baseMapConfig.source.format,
}),
transparent: true,
})
);
});
// build ui
const ui = document.createElement('div');
ui.classList.add('ui');
document.body.appendChild(ui);
// speed controls
ui.appendChild(app.domElementSpeedControls);
// drag element
app.domElementTargetDragElement.classList.add('drag_element');
ui.appendChild(app.domElementTargetDragElement);
// measure
ui.appendChild(app.measureDomElement);
// camera near far
ui.appendChild(app.clippingPlaneDetails);
// widget layer choice
const layerParams = [];
app.itownsView.getLayers().forEach((layer) => {
if (
layer.id == 'planar' ||
layer.isElevationLayer ||
layer.isColorLayer
) {
layerParams.push({ layer: layer });
}
});
app.layers.forEach((layer) => {
if (layer.isPointCloud) {
layerParams.push({
isPointCloud: true,
layer: layer,
defaultPointCloudSize: DEFAULT_POINT_SIZE,
});
} else {
layerParams.push({ layer: layer });
}
});
const widgetLayerChoice = new udviz.widgetLayerChoice.LayerChoice(
app.itownsView,
layerParams
);
widgetLayerChoice.domElement.classList.add('widget_layer_choice');
ui.appendChild(widgetLayerChoice.domElement);
// widget bookmark
const widget = new udviz.widgetBookmark.Bookmark(app.itownsView, {
parentElement: ui,
});
widget.domElement.classList.add('widget_bookmark');
// eslint-disable-next-line no-constant-condition
if ('RUN_MODE' == 'production')
loadingScreen(app.itownsView, ['UD-VIZ', 'UDVIZ_VERSION']);
window.addEventListener('keydown', (event) => {
if (event.key == 'p') console.log(app);
});
});
</script>
SCRIPT_TAG_RELOAD
</body>
</html>