-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathframe3d.html
165 lines (147 loc) · 5.57 KB
/
frame3d.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
<!DOCTYPE html>
<html>
<head>
<title>frame3d</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/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/frame3D_planars.json',
'./assets/config/layer/3DTiles_Lyon.json',
'./assets/config/layer/base_maps.json',
'./assets/config/layer/elevation.json',
'./assets/config/layer/geoJSONs.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 frame3DPlanar = new udviz.frame3d.Planar(
extent,
configs['frame3D_planars'][1]
);
// eslint-disable-next-line no-constant-condition
if ('RUN_MODE' == 'production')
loadingScreen(frame3DPlanar.itownsView, [
'UD-VIZ',
'UDVIZ_VERSION',
]);
// add layers
frame3DPlanar.itownsView.addLayer(
new udviz.itowns.ColorLayer(configs['base_maps'][0]['name'], {
updateStrategy: {
type: udviz.itowns.STRATEGY_DICHOTOMY,
options: {},
},
source: new udviz.itowns.WMSSource({
extent: extent,
name: configs['base_maps'][0].source['name'],
url: configs['base_maps'][0].source['url'],
version: configs['base_maps'][0].source['version'],
crs: extent.crs,
format: configs['base_maps'][0].source['format'],
}),
transparent: true,
})
);
const isTextureFormat =
configs['elevation']['format'] == 'image/jpeg' ||
configs['elevation']['format'] == 'image/png';
frame3DPlanar.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'],
}),
}
)
);
configs['3DTiles_Lyon'].forEach((layerConfig) => {
udviz.itowns.View.prototype.addLayer.call(
frame3DPlanar.itownsView,
new udviz.itowns.C3DTilesLayer(
layerConfig['id'],
{
name: layerConfig['id'],
source: new udviz.itowns.C3DTilesSource({
url: layerConfig['url'],
}),
},
frame3DPlanar.itownsView
)
);
});
configs['geoJSONs'].forEach((layerConfig) => {
frame3DPlanar.itownsView.addLayer(
new udviz.itowns.ColorLayer(layerConfig.id, {
name: layerConfig.id,
transparent: true,
source: new udviz.itowns.FileSource({
url: layerConfig.url,
crs: extent.crs,
format: 'application/json',
}),
style: new udviz.itowns.Style(layerConfig.style),
})
);
});
const center = extent.center();
const iframe = document.createElement('iframe');
iframe.src = './assets/html/billboard.html';
const domElement3D = new udviz.frame3d.DomElement3D(iframe);
domElement3D.rotation.set(Math.PI * 0.5, 0, 0);
domElement3D.position.set(center.x, center.y, 600);
frame3DPlanar.appendDomElement3D(domElement3D);
const process = new udviz.RequestAnimationFrameProcess();
let currentDt = 0;
const duration = 10000;
process.start((dt) => {
currentDt += dt;
currentDt %= duration;
const ratio = currentDt / duration;
let size = -1;
if (ratio < 0.5) {
size = 50 * ratio + 2000 * (1 - ratio);
} else {
size = 2000 * ratio + 50 * (1 - ratio);
}
domElement3D.scale.set(size, size, size);
domElement3D.updateMatrixWorld();
frame3DPlanar.itownsView.notifyChange();
});
});
</script>
SCRIPT_TAG_RELOAD
</body>
</html>