This repository has been archived by the owner on Dec 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
258 lines (223 loc) · 10.8 KB
/
index.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<!DOCTYPE html>
<html>
<head>
<title>3DStreet</title>
<script src="https://cdn.jsdelivr.net/gh/aframevr/aframe@52136de6a863f32d8cb806b65c3c3223f6b0f8a3/dist/aframe-master.min.js"></script>
<script src="https://github.3dstreet.org/dist/aframe-street-component.js"></script>
<script src="https://raw.githack.com/dbradleyfl/aframe-gridhelper/master/dist/aframe-gridhelper-component.min.js"></script>
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<meta name="msapplication-TileColor" content="#47365e">
<meta name="theme-color" content="#47365e">
<!-- tooltip for loader -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css" integrity="sha256-2pUeJf+y0ltRPSbKOeJh09ipQFYxUdct5nTY6GAXswA=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/bulma-tooltip/dist/css/bulma-tooltip.min.css" integrity="sha256-4sEalG00AgYSQIYA/likT3rU/pElCgDfnyHz/mf+j30=" crossorigin="anonymous">
<script src="https://cdn.scaleflex.it/plugins/filerobot-image-editor/3.12.16/filerobot-image-editor.min.js"></script>
<!-- user controls
<script src="https://raw.githack.com/fernandojsg/aframe-teleport-controls/master/dist/aframe-teleport-controls.min.js"></script>
<script src="src/lib/aframe-orbit-controls.min.js"></script> -->
<!-- ocean, ground, sky -->
<!-- <script src="src/components/ocean-plane.js"></script>
<script src="src/lib/aframe-cubemap-component.js"></script> -->
<!-- 2d ui toolbar
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css"> -->
<script>
AFRAME.registerComponent('timed-inspector', {
init: function() {
this.data // seconds
setTimeout( function () {
document.querySelector('#purpleGrid').setAttribute('visible',false);
window.postMessage('INJECT_AFRAME_INSPECTOR')
document.querySelector("#inspector-exists").classList.add("spinner");
}, this.data * 1000)
}
});
</script>
<script>
const captureToEditor = function() {
var config = {
tools: ['filters', 'crop', 'rotate', 'adjust'],
translations: {
en: {'header.image_editor_title': 'Edit Snapshot'}
}
}
const ImageEditor = new FilerobotImageEditor(config);
// consoel.log ()
AFRAME.scenes[0].setAttribute('screenshot','width',AFRAME.scenes[0].canvas.width)
AFRAME.scenes[0].setAttribute('screenshot','height',AFRAME.scenes[0].canvas.height)
const dataURL = AFRAME.scenes[0].components['screenshot'].getCanvas('perspective').toDataURL('image/png', 1.0);
ImageEditor.open(dataURL);
}
</script>
<style>
.rs-base {
left: 20px;
top: 80px;
}
body {
background-color: gray;
}
.logo {
/* color: rgb(201, 0, 201); */
background-image: url("assets/3DStreet.png");
background-size: contain;
height: 70px;
background-repeat: no-repeat;
background-position-x: center;
background-position-y: center;
}
.toggle-edit, .a-inspector-loader {
visibility: hidden;
}
</style>
<style>
.wizard {
z-index: 5;
border-radius: 10px;
position: absolute;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
padding: 1.5em;
color: #FFF;
background: rgba(0, 0, 0, 0.75);
font-family: Source Sans Pro, Helvetica Neue, Helvetica, Arial, sans-serif;
}
.faded-out {
visibility:hidden;
opacity:0;
transition:visibility 0s linear 0.5s,opacity 0.5s linear;
}
.faded-in {
visibility:visible;
opacity:1;
transition-delay:0s;
}
@keyframes spinner {
to {transform: rotate(360deg);}
}
.spinner:before {
content: '';
box-sizing: border-box;
position: absolute;
top: 50%;
left: 50%;
width: 20px;
height: 20px;
margin-top: -10px;
margin-left: -10px;
border-radius: 50%;
border: 2px solid transparent;
border-top-color: #FFFF33;
border-bottom-color: #FFFF33;
animation: spinner .8s ease infinite;
}
</style>
</head>
<body>
<a-scene
renderer="colorManagement: true; highRefreshRate: true; foveationLevel: 3; physicallyCorrectLights: true; logarithmicDepthBuffer: false;"
fogoff="type: linear; color: #D5C69B; far: 200"
gltf-model="dracoDecoderPath: https://www.gstatic.com/draco/versioned/decoders/1.4.3/"
background="color: black"
timed-inspector="3"
inspector="url: dist/3dstreet-editor.js"
loading-screen="dotsColor: #c900c9; backgroundColor: black">
<a-assets>
<!-- <streetmix-assets url="./"></streetmix-assets> -->
<!--
<a-cubemap id="skycube">
<img src="assets/images/skybox/posx.jpg">
<img src="assets/images/skybox/negx.jpg">
<img src="assets/images/skybox/posy.jpg">
<img src="assets/images/skybox/negy.jpg">
<img src="assets/images/skybox/posz.jpg">
<img src="assets/images/skybox/negz.jpg">
</a-cubemap> -->
</a-assets>
<a-entity id="purpleGrid" position="0 2 0" gridhelper="size:1000;divisions:50;colorGrid:#c900c9;colorCenterLine:#c900c9;"></a-entity>
<a-entity id="cameraRig" position="0 500 0" rotation="-90 0 0">
<a-entity id="camera" camera="far: 1000; zoom: 20" wasd-controls="enabled: false"
animation__zoomin="property: camera.zoom; from: 1; to: 22; dur: 6000; easing: easeOutQuad; "
></a-entity>
<a-entity id="leftHand" hand-controls="hand: left; handModelStyle: lowPoly; color: #ccffcc" teleport-controls="cameraRig: #cameraRig; button: trigger"></a-entity>
<a-entity id="rightHand" hand-controls="hand: right; handModelStyle: lowPoly; color: #ccffcc" teleport-controls="cameraRig: #cameraRig; button: trigger"></a-entity>
</a-entity>
<a-entity light="type: ambient; color: #FFF; intensity: 2"></a-entity>
<a-entity light="type: directional; color: #FFF; intensity: 0.6" position="0.5 1 -1"></a-entity>
<!-- <a-ocean-plane height="100" width="100" position="0 -1 0" material="envMap: #skycube;"></a-ocean-plane> -->
<!-- <a-entity id="skybox" cubemap="folder: assets/images/skybox/"></a-entity> -->
<a-entity id="street-parent" street streetmix-loader set-loader-from-hash="defaultURL: https://streetmix.net/kfarr/3"></a-entity>
</a-scene>
<div id="loader" class="wizard content faded-in">
<h1 class="logo image"></h1>
<!-- <figure class="image is-128x128">
<img src="assets/3dstreet.png">
</figure> -->
<p class="tooltip is-tooltip-left" data-tooltip="✅ = AFRAME global variable exists"><span id="app-loaded" class="spinner" style="position: relative;">⏳</span> #1 Load App</p>
<p class="tooltip is-tooltip-left" data-tooltip="✅ = street json has a value"><span id="street-json" class="spinner" style="position: relative;">⏳</span> #2 Import Street from Streetmix</p>
<p class="tooltip is-tooltip-left" data-tooltip="✅ = init scene = true?"><span id="init-scene">⏳</span> #3 Create 3D Scene from Street Segments</p>
<p class="tooltip is-tooltip-left" data-tooltip="✅ = See if AFRAME.INSPECTOR exists"><span id="inspector-exists" style="position: relative;">⏳</span> #4 Load “Plan View” in Editor</p>
<!-- <p><a onclick="AFRAME.scenes[0].components['screenshot'].capture('perspective')" class="button is-primary">Screenshot</a></p>
<p><a onclick="captureToEditor()" class="button is-primary">Screenshot with Editor</a></p> -->
</div>
</body>
<script>
var AFRAMEExistsInterval = setInterval(function(){
if (AFRAME) {
document.querySelector("#app-loaded").textContent = "✅";
document.querySelector("#app-loaded").classList.remove("spinner");
clearInterval(AFRAMEExistsInterval);
}
},500);
//document.getElementById('street-parent').getAttribute('street', 'JSON')
var StreetJSONExistsInterval = setInterval(function(){
// console.log(document.getElementById('street-parent').components['street'].data.JSON)
if (document.getElementById('street-parent').components['street'].data.JSON) {
document.querySelector("#street-json").textContent = "✅";
document.querySelector("#street-json").classList.remove("spinner");
clearInterval(StreetJSONExistsInterval);
}
},500);
document.querySelector('a-scene').addEventListener('loaded', function () {
document.querySelector("#init-scene").textContent = "✅";
});
var AFRAMEINSPECTORExistsInterval = setInterval(function(){
if (AFRAME.INSPECTOR) {
document.querySelector("#inspector-exists").textContent = "✅";
document.querySelector("#inspector-exists").classList.remove("spinner");
clearInterval(AFRAMEINSPECTORExistsInterval);
document.querySelector('#loader').classList.replace("faded-in","faded-out");
}
},500);
// document.querySelector('a-scene').addEventListener('inspectorloaded', function () {
// document.querySelector("#inspector-loaded").textContent = "✅";
// });
// AFRAME.INSPECTOR.on('inspectorloaded', function () {
// document.querySelector("#inspector-loaded").textContent = "✅";
// });
AFRAME.registerComponent('set-loader-from-hash', {
dependencies: ['streetmix-loader'],
schema: {
defaultURL: { type: 'string' }
},
init: function () {
// get hash from window
const streetURL = window.location.hash.substring(1);
if (streetURL !== undefined && streetURL.length > 0) {
console.log('[set-loader-from-hash]','Using URL from hash', streetURL)
this.el.setAttribute('streetmix-loader', 'streetmixStreetURL', streetURL);
} else {
console.log('[set-loader-from-hash]','Using default URL', this.data.defaultURL)
this.el.setAttribute('streetmix-loader', 'streetmixStreetURL', this.data.defaultURL);
}
}
});
window.onload = function () {
if (window.location.hash.substring(1).length === 0) window.location.hash = '#https://streetmix.net/kfarr/3';
// document.querySelector('#inputUrl').value = window.location.hash.substring(1);
}
</script>
</html>