-
Notifications
You must be signed in to change notification settings - Fork 925
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
10 changed files
with
100 additions
and
6 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
AFRAME.registerComponent("clicker", { | ||
init: function() { | ||
this.el.addEventListener("click", e=> { | ||
alert(this.el.components["gps-new-entity-place"].distance); | ||
}); | ||
} | ||
}); | ||
*/ |
22 changes: 22 additions & 0 deletions
22
aframe/examples/new-location-based/show-distance/index.html
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>AR.js A-Frame</title> | ||
<script src="https://aframe.io/releases/1.0.4/aframe.min.js"></script> | ||
<!-- Assumes AR.js build is in the 'AR.js' directory --> | ||
<script type='text/javascript' src='../../../../three.js/build/ar-threex-location-only.js'></script> | ||
<script type='text/javascript' src='../../../build/aframe-ar.js'></script> | ||
<script src='index.js'></script> | ||
<script src='clicker.js'></script> | ||
</head> | ||
<body> | ||
<a-scene vr-mode-ui='enabled: false' arjs='sourceType: webcam; videoTexture: true; debugUIEnabled: false' renderer='antialias: true; alpha: true' cursor='rayOrigin: mouse' raycaster='near: 0; far:10000'> | ||
<a-camera gps-new-camera='gpsMinDistance: 5'></a-camera> | ||
</a-scene> | ||
<div id='setloc' style='position:absolute; left: 10px; bottom: 2%; z-index:999; background-color: blue; color: white; padding: 10px'> | ||
Lat:<input id="lat" value="51.049" /> | ||
Lon: <input id="lon" value="-0.723"/> | ||
Min Acc: <input id='minacc' value='1000' /> <input type='button' id='go' value='go' /> | ||
</div> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
AFRAME.registerComponent("clicker", { | ||
init: function() { | ||
this.el.addEventListener("click", e=> { | ||
const dist = this.el.components["gps-new-entity-place"].distance; | ||
alert(dist === undefined ? "Please move to a new location to obtain the distance" : `This object is ${dist} metres away.`); | ||
}); | ||
} | ||
}); | ||
|
||
window.onload = () => { | ||
let testEntitiesAdded = false; | ||
alert('If testing the lat/lon manual input on a mobile device, please turn off your GPS to avoid the real location being detected.'); | ||
const el = document.querySelector("[gps-new-camera]"); | ||
el.addEventListener("gps-camera-update-position", e => { | ||
if(!testEntitiesAdded) { | ||
// Add four boxes to the north (red), south (yellow), west (blue) | ||
// and east (red) of the initial GPS position | ||
const properties = [{ | ||
color: 'red', | ||
latDis: 0.001, | ||
lonDis: 0 | ||
},{ | ||
color: 'yellow', | ||
latDis: -0.001, | ||
lonDis: 0 | ||
},{ | ||
color: 'blue', | ||
latDis: 0, | ||
lonDis: -0.001 | ||
},{ | ||
color: 'green', | ||
latDis: 0, | ||
lonDis: 0.001 | ||
} | ||
]; | ||
for(const prop of properties) { | ||
const entity = document.createElement("a-box"); | ||
entity.setAttribute("scale", { | ||
x: 20, | ||
y: 20, | ||
z: 20 | ||
}); | ||
entity.setAttribute('material', { color: prop.color } ); | ||
entity.setAttribute('gps-new-entity-place', { | ||
latitude: e.detail.position.latitude + prop.latDis, | ||
longitude: e.detail.position.longitude + prop.lonDis | ||
}); | ||
entity.setAttribute('clicker', { }); | ||
document.querySelector("a-scene").appendChild(entity); | ||
} | ||
testEntitiesAdded = true; | ||
} | ||
}); | ||
|
||
document.getElementById("go").addEventListener("click", e=> { | ||
const lat = document.getElementById('lat').value; | ||
const lon = document.getElementById('lon').value; | ||
const minacc = document.getElementById('minacc').value; | ||
|
||
el.setAttribute('gps-new-camera', { simulateLatitude: lat, simulateLongitude: lon, positionMinAccuracy: minacc } ); | ||
}); | ||
}; |
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