Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into issue#111
Browse files Browse the repository at this point in the history
  • Loading branch information
kfarr authored Feb 9, 2023
2 parents 70e955c + 0e77ca9 commit b5e4dd5
Show file tree
Hide file tree
Showing 11 changed files with 539 additions and 90 deletions.
22 changes: 14 additions & 8 deletions dist/3dstreet-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6205,6 +6205,18 @@ var Toolbar = /*#__PURE__*/function (_Component) {
isSaveActionActive: false,
isCapturingScreen: false
});
_defineProperty(_assertThisInitialized(_this), "convertToObject", function () {
var entity = document.getElementById('street-container');
var data = convertDOMElToObject(entity);
var jsonString = "data:text/json;chatset=utf-8,".concat(encodeURIComponent(
//JSON.stringify(data)
filterJSONstreet(removeProps, renameProps, data)));
var link = document.createElement('a');
link.href = jsonString;
link.download = 'data.json';
link.click();
link.remove();
});
_defineProperty(_assertThisInitialized(_this), "makeScreenshot", function (component) {
return new Promise(function (resolve) {
var sceneElem = AFRAME.scenes[0];
Expand Down Expand Up @@ -6331,14 +6343,8 @@ var Toolbar = /*#__PURE__*/function (_Component) {
onClick: this.exportSceneToGLTF,
children: "glTF 3D Model"
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, {
onClick: function onClick() {
return _this2.setState(function (prevState) {
return _objectSpread(_objectSpread({}, prevState), {}, {
isCapturingScreen: true
});
});
},
children: "PNG Screenshot"
onClick: this.convertToObject,
children: "3DStreet JSON"
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_components__WEBPACK_IMPORTED_MODULE_1__.Button, {
className: 'closeButton',
onClick: this.toggleSaveActionState.bind(this),
Expand Down
2 changes: 1 addition & 1 deletion dist/3dstreet-editor.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/3dstreet-editor.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/3dstreet-editor.min.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions index-3dtiles-cesium.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
<a-assets>
</a-assets>

<a-entity id="cameraRig" cursor-teleport="cameraRig: #cameraRig; cameraHead: #camera;" look-controls="reverseMouseDrag: true" wasd-controls="enabled: true">
<a-entity id="cameraRig" data-layer-name="Viewer" cursor-teleport="cameraRig: #cameraRig; cameraHead: #camera;" look-controls="reverseMouseDrag: true" wasd-controls="enabled: true">
<a-entity id="camera" camera="near: 1; far: 1000" position="0 1.6 0"></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 id="leftHand" hand-controls="hand: left; handModelStyle: lowPoly; color: #ffccff" teleport-controls="cameraRig: #cameraRig; button: trigger"></a-entity>
<a-entity id="rightHand" hand-controls="hand: right; handModelStyle: lowPoly; color: #ffccff" teleport-controls="cameraRig: #cameraRig; button: trigger"></a-entity>
</a-entity>

<a-entity street-environment="preset: day;"></a-entity>
<a-entity id="environment" data-layer-name="Environment" street-environment="preset: day;"></a-entity>

<a-entity id="streets" data-layer-name="Street Segments" data-layer-show-children>
<a-entity id="street-container" data-layer-name="3D Street Layers" data-layer-show-children>
<a-entity
data-layer-name="16th Street West of SVN"
position="-96.980 0 -4.17918"
Expand Down
242 changes: 242 additions & 0 deletions index-mapbox-intersection.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
<!DOCTYPE html>
<html>
<head>
<!-- aframe -->
<script src="https://aframe.io/releases/1.3.0/aframe.min.js"></script>

<!-- 3dstreet -->
<script src="https://github.3dstreet.org/dist/aframe-street-component.js"></script>

<!-- user controls - vr teleport -->
<script src="https://raw.githack.com/fernandojsg/aframe-teleport-controls/master/dist/aframe-teleport-controls.min.js"></script>

<!-- user controls - cursor teleport -->
<script src="./dist/aframe-cursor-teleport-component.min.js"></script>

<!-- gltf-animation -->
<script src="//cdn.8thwall.com/web/aframe/aframe-extras-6.1.1.min.js"></script>

<!-- mapbox -->
<script src="https://unpkg.com/aframe-mapbox-component/dist/aframe-mapbox-component.min.js"></script>

<!-- save / load -->
<script src="https://github.3dstreet.org/src/json-utils.js"></script>

<!-- ocean -->
<script src="https://github.3dstreet.org/src/components/ocean-plane.js"></script>

<title>3DStreet</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/x-icon" href="assets/ui_assets/favicon.ico">
<link rel="stylesheet" href="//github.3dstreet.org/src/viewer-styles.css">
</head>

<body>
<!-- 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="./assets/3DStreet-Viewer-Start-Editor.svg">
</button>
</div>

<div class="right-fixed">
<ul class="right-menu">
<li onclick="screenshot()"> <a class="camera" href="#"> <span> Capture image as PNG </span> <img src="//github.3dstreet.org/ui_assets/camera-icon.svg"> </a></li>
<li onclick="inputStreetmix()"> <a class="load" href="#"> <span> Load Streetmix URL </span> <img src="//github.3dstreet.org/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="//github.3dstreet.org/ui_assets/upload-icon.svg"></label></a></li>
<li> <a id="custom-enter-vr-button" class="vr" href="#"> <span class="vr">Enter VR mode</span> <img src="//github.3dstreet.org/ui_assets/vr-icon.svg"> </a></li>
</ul>
</div>

<a-scene
vr-mode-ui="enterVRButton: #custom-enter-vr-button;"
vr-mode-ui-if-headset
renderer="colorManagement: true; physicallyCorrectLights: true;"
gltf-model="dracoDecoderPath: https://www.gstatic.com/draco/versioned/decoders/1.4.3/"
inspector="url: ./dist/3dstreet-editor.js"
timed-inspector="2"
>
<a-assets>
<!-- you can specify a custom asset path using below syntax -->
<!-- <streetmix-assets url="./assets/"></streetmix-assets> -->
</a-assets>

<a-entity id="cameraRig" data-layer-name="Viewer" cursor-teleport="cameraRig: #cameraRig; cameraHead: #camera;" look-controls="reverseMouseDrag: true" wasd-controls="enabled: true">
<a-entity id="camera" camera="near: 1; far: 1000" position="0 1.6 0"></a-entity>
<a-entity id="leftHand" hand-controls="hand: left; handModelStyle: lowPoly; color: #ffccff" teleport-controls="cameraRig: #cameraRig; button: trigger"></a-entity>
<a-entity id="rightHand" hand-controls="hand: right; handModelStyle: lowPoly; color: #ffccff" teleport-controls="cameraRig: #cameraRig; button: trigger"></a-entity>
</a-entity>

<a-entity id="environment" data-layer-name="Environment" street-environment="preset: day;"></a-entity>

<a-entity id="street-container" data-layer-name="3D Street Layers" data-layer-show-children>
<a-entity
data-layer-name="16th Street West of SVN"
position="-96.980 0 -4.17918"
rotation="0 90 0"
id="east_street"
street="length: 150"
streetmix-loader="streetmixStreetURL: https://streetmix.net/kfarr/82/16th-st-harrison-st-sf-ca; showBuildings: false;"
></a-entity>
<a-entity
data-layer-name="16th Street East of SVN"
position="78.165 0 -4.17918"
rotation="0 90 0"
id="west_street"
street="length: 150"
streetmix-loader="streetmixStreetURL: https://streetmix.net/kfarr/82/16th-st-harrison-st-sf-ca; showBuildings: false;"
></a-entity>

<a-entity data-layer-name="16th & Harrison St Intersection" id="intersection" position="-9.917 0 -4.057">
<a-entity
intersection="dimensions: 27.5 24.384;northeastcurb: 4.572 4.572;southwestcurb: 4.572 4.572;southeastcurb: 4.572 4.572;northwestcurb: 4.572 4.572;trafficsignal: 1 1 1 1;crosswalk: 1 1 1 1"
></a-entity>
</a-entity>

<a-entity
data-layer-name="SVN North of 16th St"
position="-9.23383 0 -31.340"
rotation="0 0 0"
id="south_street"
street="length: 30"
streetmix-loader="streetmixStreetURL: https://streetmix.net/scott/31/south-van-ness-idea-short-term; showBuildings: false;"
></a-entity>

<a-entity
data-layer-name="SVN South of 16th St"
position="-9.23383 0 23.009"
rotation="0 180 0"
id="north_street"
street="length: 30"
streetmix-loader="streetmixStreetURL: https://streetmix.net/scott/31/south-van-ness-idea-short-term; showBuildings: false;"
></a-entity>

</a-entity>

<a-entity id="layers-2d" data-layer-name="2D Street Layers" data-layer-show-children>
<a-entity
data-layer-name="Mapbox Satellite Streets"
geometry="primitive: plane; width: 512; height: 512;"
material="color: #ffffff; shader: flat; side: both; transparent: true;"
mapbox="center: -122.417490, 37.765190; zoom: 18;
accessToken: pk.eyJ1IjoibWF0dHJlIiwiYSI6IjRpa3ItcWcifQ.s0AGgKi0ai23K5OJvkEFnA;
style: mapbox://styles/mapbox/satellite-streets-v11;
pxToWorldRatio: 4;"
position="-7 -1 -2"
rotation="-90 -4.25 0"
></a-entity>
</a-entity>
</a-scene>
</body>
<script>
// only show VR button if headset connected
AFRAME.registerComponent('vr-mode-ui-if-headset', {
dependencies: ['vr-mode-ui'],
init: function () {
if (!AFRAME.utils.device.checkHeadsetConnected()) {
this.el.setAttribute('vr-mode-ui', 'enabled', false);
}
}
})

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);
// }
}
});

function screenshot() {
AFRAME.scenes[0].setAttribute('screenshot','width',AFRAME.scenes[0].canvas.width)
AFRAME.scenes[0].setAttribute('screenshot','height',AFRAME.scenes[0].canvas.height)
document.querySelector('a-scene').components.screenshot.capture('perspective');
}

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)
}
});

function inputStreetmix() {
streetmixURL = prompt("Please enter a Streetmix URL", "https://streetmix.net/kfarr/3/example-street");
setTimeout(function() { window.location.hash = streetmixURL; });
streetContainerEl = document.getElementById('street-container');
while (streetContainerEl.firstChild) {
streetContainerEl.removeChild(streetContainerEl.lastChild);
}
streetContainerEl.innerHTML = '<a-entity street streetmix-loader="streetmixStreetURL: '+streetmixURL+'""></a-entity>';
}

// JSON loading starts here
function getValidJSON(stringJSON) {
// Preserve newlines, etc. - use valid JSON
// Remove non-printable and other non-valid JSON characters
return stringJSON.replace(/\'/g, "")
.replace(/\n/g, "")
.replace(/[\u0000-\u0019]+/g,"");
}

function createElementsFromJSON(streetJSONString) {
const validJSONString = getValidJSON(streetJSONString);
streetContainerEl = document.getElementById('street-container');
while (streetContainerEl.firstChild) {
streetContainerEl.removeChild(streetContainerEl.lastChild);
}
var streetObject = JSON.parse(validJSONString);
createEntities(streetObject.data, streetContainerEl);
}

function inputJSON() {
const stringJSON = prompt("Please paste 3DStreet JSON string");
if (stringJSON) {
createElementsFromJSON(stringJSON);
}
}

function fileJSON() {
let reader=new FileReader();
reader.onload=function(){
createElementsFromJSON(reader.result);
}
reader.readAsText(this.files[0]);
}

document.getElementById('inputfile')
.addEventListener('change', fileJSON);
</script>
<!-- <script src="./dist/3dstreet-editor.js"></script> -->

<!-- Google Analytics - Global site tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-T65XPDLZ3F"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-T65XPDLZ3F');

gtag('event', 'ga_init');
</script>
</html>
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,16 @@
streetContainerEl.removeChild(streetContainerEl.lastChild);
}
var streetObject = JSON.parse(validJSONString);
createEntities(streetObject.data, streetContainerEl);
createEntities(streetObject.data[0].children, streetContainerEl);
}

/*
function inputJSON() {
const stringJSON = prompt("Please paste 3DStreet JSON string");
if (stringJSON) {
createElementsFromJSON(stringJSON);
}
}

*/
function fileJSON() {
let reader=new FileReader();
reader.onload=function(){
Expand Down
Loading

0 comments on commit b5e4dd5

Please sign in to comment.