forked from altizure/experimental-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
polycylinder-limittest.html
170 lines (157 loc) · 5.41 KB
/
polycylinder-limittest.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
<html lang="en">
<head>
<meta charset="utf-8">
<title> Performance Test </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="./css/style.css">
<script type="text/javascript" src="https://beta.altizure.com/sdk"></script>
<script type="text/javascript" src="./js/timeline.js"></script>
</head>
<body>
<div id="root">
<div class="hud">
<div class="component">
<div class="componentLabel">Item #:</div>
<input type="number" id="itemNumInput" class="numberInput" value='100'></input>
</div>
<div class="component">
<div class="componentLabel">Points number for eath marker #:</div>
<input type="number" id="pointsNumInput" class="numberInput" value='7'></input>
<button class="button button1" id="generateButton">Generate</button>
</div>
<div class="component">
<div class="componentLabel">Camera</div>
<button class="button button1" id="orbitbutton">Orbit</button>
</div>
<div class="component">
<div class="componentLabel">Hint:</div>
<div class="componentText" id="hintText"> Type a number and click generate PolyCylinderLineMarker to fill the scene </div>
</div>
</div>
<div id="page-content"></div>
</div>
<script>
function onPageLoaded () {
let projects = [
{pid: '58428f1d97b73e0b090675cd', text: ''}
]
const center = {
lat:22.335975,
lng:114.263718,
alt:1020
}
let options = {
altizureApi:{
key: '7MkQf8UggsPaadvrlKALspJWZejZAJOLHn3cnIy'
},
camera: {
poseTo: { alt:1200,
lat: center.lat,
lng: center.lng
},
flyTo: { alt: center.alt,
lat: center.lat,
lng: center.lng,
north: -27.271585092584015,
tilt: 74.7023627906978
}
},
renderItems: {
earth: true,
earthUseTexture: false,
featureInView: false,
orbitRing: false
}
}
let sandbox = new altizure.Sandbox('page-content', options)
let pagecontent = document.getElementById("page-content")
// camera orbit animation
let orbitButton = document.getElementById("orbitbutton")
let orbitAnimation = null
orbitButton.innerHTML = 'Orbit'
orbitButton.addEventListener("click", () => {
if (orbitButton.innerHTML === 'Orbit') {
if (orbitAnimation) {
clearInterval(orbitAnimation)
}
orbitAnimation = setInterval(function() {
let currentPos = sandbox.camera.pose
currentPos.north += 10
sandbox.camera.pose = currentPos
}, 500)
orbitButton.innerHTML = 'Stop'
} else {
if (orbitAnimation) {
clearInterval(orbitAnimation)
}
orbitButton.innerHTML = 'Orbit'
}
})
// UI stuffs
let itemNumInput = document.getElementById('itemNumInput')
let pointsNumInput = document.getElementById('pointsNumInput')
let generateButton = document.getElementById('generateButton')
let markers = []
function createMarkers(num, pointNum, sandbox, buttonLeft, topRight) {
let newMarkers = []
for (let i = 0; i < num; ++i) {
let points = []
for (let i = 0; i < pointNum; ++i) {
const labelPosition = {
lat: Math.random() * (topRight.lat - buttonLeft.lat) + buttonLeft.lat,
lng: Math.random() * (topRight.lng - buttonLeft.lng) + buttonLeft.lng,
alt: Math.random() * (1500 - 0)
}
points.push(labelPosition)
}
let lineMarker = new altizure.PolyCylinderLineMarker({
// scene
sandbox: sandbox,
points: points,
color: 0xb73026,
lineWidth: 1, // line width of the linemarker
labelsVisible: false, // whether to show labels
visible: true
})
newMarkers.push(lineMarker)
}
return newMarkers
}
setTimeout(() => {
markers = createMarkers(itemNumInput.value, pointsNumInput.value, sandbox,
{
lat: 22.324247,
lng: 114.254293
},
{
lat: 22.344809,
lng: 114.272569
}
)
generateButton.addEventListener('click', () => {
console.log(itemNumInput.value)
if (markers) {
for (let i = 0; i < markers.length; ++i) {
let m = markers[i]
m.destruct()
m = null
}
markers = null
markers = createMarkers(itemNumInput.value, pointsNumInput.value, sandbox,
{
lat: 22.324247,
lng: 114.254293
},
{
lat: 22.344809,
lng: 114.272569
}
)
}
})
}, 3000)
}
document.addEventListener("DOMContentLoaded", onPageLoaded)
</script>
</body>
</html>