-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
141 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,106 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>A-Frame 3D Tiles Component - Basic example</title> | ||
<meta name="description" content="Basic example for 3D Tiles component showing google 3d Tiles."></meta> | ||
<!-- aframe --> | ||
<script src="https://aframe.io/releases/1.5.0/aframe.min.js"></script> | ||
|
||
<!-- 3d tiles --> | ||
<!-- 3dstreet --> | ||
<script src="/dist/aframe-street-component.js"></script> | ||
|
||
<!-- mapbox and google tiles --> | ||
<script src="/src/lib/aframe-mapbox-component.min.js"></script> | ||
<script src="/src/lib/aframe-loader-3dtiles-component.js"></script> | ||
|
||
<!-- vr teleport controls --> | ||
<!-- --><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/aframe-blink-controls.min.js"></script> | ||
<style> | ||
#guide { | ||
position: fixed; | ||
top: 0; | ||
right: 0; | ||
width: 300px; | ||
padding: 1rem 2rem; | ||
font-family:'Courier New', Courier, monospace; | ||
line-height: 1.2; | ||
background-color: white; | ||
color: black; | ||
} | ||
<!-- vr teleport controls --> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/aframe-blink-controls.min.js"></script> | ||
|
||
#guide p { | ||
margin-top: 10px; | ||
} | ||
</style> | ||
<script> | ||
// this makes the same camera rig setup work in VR and desktop modes | ||
// this could be a new component, such as "swap desktop and vr controls" and put in init section | ||
window.addEventListener("DOMContentLoaded", function() { | ||
const sceneEl = document.querySelector("a-scene"); | ||
sceneEl.addEventListener("enter-vr", function() { | ||
document.querySelector('#cameraRig').removeAttribute('look-controls') | ||
document.querySelector('#cameraRig').removeAttribute('wasd-controls') | ||
document.querySelector('#cameraRig').removeAttribute('cursor-teleport') | ||
document.querySelector('#cameraRig').setAttribute('position', '0 0 0') | ||
}); | ||
sceneEl.addEventListener("exit-vr", function() { | ||
document.querySelector('#cameraRig').setAttribute('cursor-teleport', "cameraRig: #cameraRig; cameraHead: #camera;") | ||
document.querySelector('#cameraRig').setAttribute('look-controls', "reverseMouseDrag: true;") | ||
document.querySelector('#cameraRig').setAttribute('wasd-controls', "enabled: true") | ||
}); | ||
}) | ||
</script> | ||
<title>3DStreet</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="icon" type="image/x-icon" href="/ui_assets/favicon.ico"> | ||
<link rel="stylesheet" href="/src/viewer-styles.css"> | ||
</head> | ||
|
||
<body> | ||
<a-scene vr-mode-ui="enabled: false" renderer="colorManagement: true;"> | ||
<a-entity camera="fov:45; near:1; far: 1000" look-controls="reverseMouseDrag: true" wasd-controls="enabled: true" id="camera" cursor-teleport="cameraRig: #camera; cameraHead: #camera;"></a-entity> | ||
<a-entity | ||
<!-- loading animation start --> | ||
<div class="loader__wrapper"> | ||
<div class="loader"> | ||
<div class="entities"> | ||
<img src="/ui_assets/loader/entities.svg" alt="entities" /> | ||
</div> | ||
<div class="transport"> | ||
<div class="wrapper__transport"> | ||
<img src="/ui_assets/loader/car.svg" class="car" alt="car" /> | ||
<img src="/ui_assets/loader/bus.svg" class="bus" alt="bus" /> | ||
<img src="/ui_assets/loader/bike.svg" class="bike" alt="bike" /> | ||
</div> | ||
</div> | ||
<div class="road">Loading 3DStreet</div> | ||
</div> | ||
</div> | ||
|
||
<!-- viewer ui start --> | ||
<div class="viewer-header-wrapper"> | ||
<button class="viewer-logo-start-editor-button" onclick="startEditor()"> | ||
<img class="viewer-logo-img" alt="3DStreet Viewer" src="/ui_assets/3DStreet-Viewer-Start-Editor.svg"> | ||
</button> | ||
</div> | ||
|
||
<div class="right-fixed"> | ||
<ul class="right-menu"> | ||
<li onclick="buttonScreenshotTock()"> <a class="camera" href="#"> <span> Capture image as PNG </span> <img src="/ui_assets/camera-icon.svg"> </a></li> | ||
<li onclick="STREET.utils.inputStreetmix()"> <a class="load" href="#"> <span> Load Streetmix URL </span> <img src="/ui_assets/streetmix-logo.svg"> </a></li> | ||
<!-- <li onclick="inputJSON()"> <a class="load" href="#"> <span> Load JSON String </span> <img src="assets/ui_assets/upload-icon.svg"> </a></li> --> | ||
<li><a class="load"> <label for="inputfile" style="display: inherit; align-items: center; cursor: pointer"> <input type="file" id="inputfile" style="display:none" accept=".js, .json, .txt"> <span> Load JSON File </span> <img src="/ui_assets/upload-icon.svg"></label></a></li> | ||
</ul> | ||
</div> | ||
|
||
<a-scene | ||
renderer="colorManagement: true; physicallyCorrectLights: true; anisotropy: 16;" | ||
inspector="url: //3dstreet.app/dist/3dstreet-editor.js" | ||
notify | ||
metadata | ||
scene-title | ||
reflection | ||
> | ||
<a-assets> | ||
<!-- uncomment the line below to load assets from local github submodule --> | ||
<!-- <street-assets url="./assets/"></street-assets> --> | ||
<!-- uncomment the line below to load all possible asset categories --> | ||
<!-- <street-assets categories="sidewalk-props people people-rigged vehicles vehicles-rigged buildings intersection-props segment-textures segment-colors lane-separator stencils vehicles-transit dividers sky grounds"></street-assets> --> | ||
<!-- a reduced set of assets for non-animated streetmix streets without intersections --> | ||
<street-assets categories="loud-bicycle sidewalk-props people vehicles vehicles-rigged buildings segment-textures segment-colors lane-separator stencils vehicles-transit dividers sky grounds"></street-assets> | ||
</a-assets> | ||
|
||
<a-entity id="street-container" data-layer-name="3D Street Layers" data-layer-show-children> | ||
<a-entity id="default-street" street streetmix-loader set-loader-from-hash></a-entity> | ||
</a-entity> | ||
|
||
<a-entity id="cameraRig" position="0 10 30" data-layer-name="Viewer" cursor-teleport="cameraRig: #cameraRig; cameraHead: #camera;" look-controls="reverseMouseDrag: true" wasd-controls="enabled: true"> | ||
<a-entity id="camera" camera="far: 1000" position="0 1.6 0" ></a-entity> | ||
<a-entity id="leftHand" hand-controls="hand: left;" blink-controls="cameraRig: #cameraRig; teleportOrigin: #camera; rotateOnTeleport:false;"></a-entity> | ||
<a-entity id="rightHand" hand-controls="hand: right" blink-controls="cameraRig: #cameraRig; teleportOrigin: #camera; rotateOnTeleport:false;"></a-entity> | ||
<a-entity id="screenshot" class="no-pause" screentock visible="false"></a-entity> | ||
</a-entity> | ||
<a-entity id="reference-layers" data-layer-name="Reference Layers" data-layer-show-children> | ||
<a-entity | ||
id="tileset" | ||
loader-3dtiles=" | ||
url: https://tile.googleapis.com/v1/3dtiles/root.json; | ||
|
@@ -41,45 +109,56 @@ | |
height: -16.5; | ||
googleApiKey: AIzaSyAQshwLVKTpwTfPJxFEkEzOdP_cgmixTCQ; | ||
geoTransform: WGS84Cartesian; | ||
maximumSSE: 48; | ||
maximumSSE: 48; | ||
maximumMem: 400; | ||
cameraEl: #camera" | ||
> | ||
cameraEl: #camera"> | ||
</a-entity> | ||
|
||
</a-entity> | ||
</a-scene> | ||
|
||
<!-- GitHub Corner. --> | ||
<a href="https://github.com/nytimes/aframe-loader-3dtiles-component" class="github-corner"> | ||
<svg width="80" height="80" viewBox="0 0 250 250" style="fill:#222; color:#fff; position: absolute; top: 0; border: 0; right: 0;"> | ||
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path> | ||
</svg> | ||
</a> | ||
<div id="guide"> | ||
<span id="example-desc"> | ||
<b>Google 3D Tiles example.</b> | ||
</span> | ||
<p>Use arrow/WASD keys to move around and click and drag to turn/rotate the camera.</p> | ||
<p> | ||
<u>Available component parameters:</u> | ||
<ul> | ||
<li><b>lat, long</b>: coordinates of Google Map.</li> | ||
<li><b>height</b>: camera height.</li> | ||
<li><b>googleApiKey</b>: Google Api Key.</li> | ||
</ul> | ||
</p> | ||
</div> | ||
<script> | ||
const queryParams = new URLSearchParams(document.location.search); | ||
|
||
if (queryParams.get('tilesetUrl')) { | ||
document.querySelector('#tileset').addEventListener('object3dset', (e) => { | ||
e.target.setAttribute('loader-3dtiles', { | ||
url: queryParams.get('tilesetUrl') | ||
}) | ||
}) | ||
} | ||
</script> | ||
<style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style> | ||
<!-- End GitHub Corner. --> | ||
<a-entity id="environment" data-layer-name="Environment" street-environment="preset: day;"></a-entity> | ||
|
||
|
||
|
||
</a-scene> | ||
</body> | ||
<script> | ||
/* loading animation script */ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
const scene = document.querySelector('a-scene'); | ||
const splash = document.querySelector('.loader__wrapper'); | ||
scene.addEventListener('loaded', function (e) { | ||
setTimeout(() => { | ||
splash.style.display = 'none'; | ||
}, 1000); | ||
}); | ||
}); | ||
</script> | ||
<script> | ||
|
||
document.getElementById('inputfile') | ||
.addEventListener('change', STREET.utils.fileJSON); | ||
|
||
function buttonScreenshotTock() { | ||
const screenshotEl = document.getElementById('screenshot'); | ||
screenshotEl.play(); // double check playing in case we're in editor mode | ||
screenshotEl.setAttribute('screentock', 'type', 'jpg'); | ||
screenshotEl.setAttribute('screentock', 'takeScreenshot', true); | ||
} | ||
|
||
function startEditor() { | ||
var sceneEl = document.querySelector('a-scene'); | ||
sceneEl.components.inspector.openInspector(); | ||
document.querySelector('.viewer-header-wrapper').style.display = 'none'; | ||
} | ||
|
||
AFRAME.registerComponent('timed-inspector', { | ||
init: function() { | ||
setTimeout( function () { | ||
window.postMessage('INJECT_AFRAME_INSPECTOR') | ||
}, this.data * 1000) | ||
} | ||
}); | ||
|
||
</script> | ||
</html> |