提交 bf0bf3bb 编写于 作者: N nicolo.carpignoli

Last commit before release

上级 f0c88f82
# 2.0.6
# 2.0.7
- Fixed bug on location-based while added places via HTML
- Added example of location-based using only HTML
......
......@@ -127,7 +127,7 @@ You can also use GeoAR.js **without** the script, adding `gps-entity-place` enti
<!doctype HTML>
<html>
<script src="https://aframe.io/releases/0.9.2/aframe.min.js"></script>
<script src="https://raw.githack.com/jeromeetienne/AR.js/2.0.6/aframe/build/aframe-ar.js"></script>
<script src="https://raw.githack.com/jeromeetienne/AR.js/2.0.7/aframe/build/aframe-ar.js"></script>
<body style='margin : 0px; overflow: hidden;'>
<a-scene embedded arjs>
<a-marker preset="hiro">
......
......@@ -5308,7 +5308,7 @@ Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype );
// ARjs.Context.baseURL = '../'
// default to github page
ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/'
ARjs.Context.REVISION = '2.0.6';
ARjs.Context.REVISION = '2.0.7';
/**
* Create a default camera for this trackingBackend
......@@ -8737,22 +8737,10 @@ AFRAME.registerComponent('gps-camera', {
},
init: function () {
if (this.el.components['look-controls'] === undefined) {
if (!this.el.components['look-controls']) {
return;
}
this._watchPositionId = this._initWatchGPS(function (position) {
if (!this.currentCoords) {
this.currentCoords = position.coords;
this._updatePosition();
window.dispatchEvent(new CustomEvent('gps-camera-ready'));
console.debug('gps-camera-ready');
} else {
this.currentCoords = position.coords;
this._updatePosition();
}
}.bind(this));
this.lookControls = this.el.components['look-controls'];
// listen to deviceorientation event
......@@ -8783,6 +8771,11 @@ AFRAME.registerComponent('gps-camera', {
}
window.addEventListener(eventName, this._onDeviceOrientation, false);
this._watchPositionId = this._initWatchGPS(function (position) {
this.currentCoords = position.coords;
this._updatePosition();
}.bind(this));
},
tick: function () {
......@@ -9027,27 +9020,33 @@ AFRAME.registerComponent('gps-entity-place', {
},
},
init: function () {
this._positionXDebug = 0;
console.debug('gps-camera-entity-added');
setTimeout(function() {
this._positionXDebug = 0;
this.debugUIAddedHandler = function () {
this.setDebugData(this.el);
window.removeEventListener('debug-ui-added', this.debugUIAddedHandler.bind(this));
};
this.debugUIAddedHandler = function () {
this.setDebugData(this.el);
window.removeEventListener('debug-ui-added', this.debugUIAddedHandler.bind(this));
};
window.addEventListener('debug-ui-added', this.debugUIAddedHandler.bind(this));
window.addEventListener('debug-ui-added', this.debugUIAddedHandler.bind(this));
window.addEventListener('gps-camera-ready', function() {
if (this._cameraGps === null) {
var camera = document.querySelector('a-camera, [camera]');
if (!this._cameraGps) {
var camera = document.querySelector('[gps-camera]');
if (camera.components['gps-camera'] === undefined) {
console.error('gps-camera not found')
return;
}
this._cameraGps = camera.components['gps-camera'];
}
if (!this._cameraGps.originCoords && !this._cameraGps.currentCoords) {
console.error('gps-camera not initialized')
return;
}
this._updatePosition();
}.bind(this));
}.bind(this), 2000);
},
/**
......@@ -9057,28 +9056,26 @@ AFRAME.registerComponent('gps-entity-place', {
_updatePosition: function () {
var position = { x: 0, y: 0, z: 0 }
if (this._cameraGps.originCoords === null) {
return;
}
var cameraCoords = this._cameraGps.originCoords || this._cameraGps.currentCoords;
// update position.x
var dstCoords = {
longitude: this.data.longitude,
latitude: this._cameraGps.originCoords.latitude,
latitude: cameraCoords.latitude,
};
position.x = this._cameraGps.computeDistanceMeters(this._cameraGps.originCoords, dstCoords, true);
position.x = this._cameraGps.computeDistanceMeters(cameraCoords, dstCoords, true);
this._positionXDebug = position.x;
position.x *= this.data.longitude > this._cameraGps.originCoords.longitude ? 1 : -1;
position.x *= this.data.longitude > cameraCoords.longitude ? 1 : -1;
// update position.z
var dstCoords = {
longitude: this._cameraGps.originCoords.longitude,
longitude: cameraCoords.longitude,
latitude: this.data.latitude,
};
position.z = this._cameraGps.computeDistanceMeters(this._cameraGps.originCoords, dstCoords, true);
position.z *= this.data.latitude > this._cameraGps.originCoords.latitude ? -1 : 1;
position.z = this._cameraGps.computeDistanceMeters(cameraCoords, dstCoords, true);
position.z *= this.data.latitude > cameraCoords.latitude ? -1 : 1;
// update element's position in 3D world
this.el.setAttribute('position', position);
......@@ -9090,7 +9087,7 @@ AFRAME.registerComponent('gps-entity-place', {
*/
setDebugData: function (element) {
var elements = document.querySelectorAll('.debug-distance');
elements.forEach(function(el) {
elements.forEach(function (el) {
var distance = formatDistance(this._positionXDebug);
if (element.getAttribute('value') == el.getAttribute('value')) {
el.innerHTML = el.getAttribute('value') + ': ' + distance + 'far';
此差异已折叠。
......@@ -53,7 +53,7 @@ function staticLoadPlaces() {
function dynamicLoadPlaces(position) {
let params = {
radius: 300, // search places not farther than this value (in meters)
clientId: '', // add your credentials here
clientId: 'HZIJGI4COHQ4AI45QXKCDFJWFJ1SFHYDFCCWKPIJDWHLVQVZ', // add your credentials here
clientSecret: '', // add your credentials here
version: '20300101', // foursquare versioning, required but unuseful for this demo
};
......
......@@ -17,7 +17,7 @@
embedded
arjs='sourceType: webcam; sourceWidth:1280; sourceHeight:960; displayWidth: 1280; displayHeight: 960; debugUIEnabled: false;'>
<a-box color="tomato" scale="20 20 20" gps-entity-place="latitude: your-latitude; longitude: your-longitude;"></a-box>
<a-box color="yellow" scale="5 5 5" gps-entity-place="latitude: 44.493271; longitude: 11.326040;"></a-box>
<a-camera gps-camera rotation-reader>
</a-camera>
</a-scene>
......
......@@ -34,7 +34,7 @@ function staticLoadPlaces() {
{
name: "Your place name",
location: {
lat: 44.493270, // change here latitude if using static data
lat: 44.493271, // change here latitude if using static data
lng: 11.326040, // change here longitude if using static data
}
},
......@@ -85,7 +85,7 @@ function renderPlaces(places) {
text.setAttribute('gps-entity-place', `latitude: ${latitude}; longitude: ${longitude};`);
text.setAttribute('title', place.name);
text.setAttribute('href', 'http://www.example.com/');
text.setAttribute('scale', '20 20 20');
text.setAttribute('scale', '5 5 5');
text.addEventListener('loaded', () => {
window.dispatchEvent(new CustomEvent('gps-entity-place-loaded'))
......
......@@ -21,22 +21,10 @@ AFRAME.registerComponent('gps-camera', {
},
init: function () {
if (this.el.components['look-controls'] === undefined) {
if (!this.el.components['look-controls']) {
return;
}
this._watchPositionId = this._initWatchGPS(function (position) {
if (!this.currentCoords) {
this.currentCoords = position.coords;
this._updatePosition();
window.dispatchEvent(new CustomEvent('gps-camera-ready'));
console.debug('gps-camera-ready');
} else {
this.currentCoords = position.coords;
this._updatePosition();
}
}.bind(this));
this.lookControls = this.el.components['look-controls'];
// listen to deviceorientation event
......@@ -67,6 +55,11 @@ AFRAME.registerComponent('gps-camera', {
}
window.addEventListener(eventName, this._onDeviceOrientation, false);
this._watchPositionId = this._initWatchGPS(function (position) {
this.currentCoords = position.coords;
this._updatePosition();
}.bind(this));
},
tick: function () {
......
......@@ -11,27 +11,33 @@ AFRAME.registerComponent('gps-entity-place', {
},
},
init: function () {
this._positionXDebug = 0;
console.debug('gps-camera-entity-added');
setTimeout(function() {
this._positionXDebug = 0;
this.debugUIAddedHandler = function () {
this.setDebugData(this.el);
window.removeEventListener('debug-ui-added', this.debugUIAddedHandler.bind(this));
};
this.debugUIAddedHandler = function () {
this.setDebugData(this.el);
window.removeEventListener('debug-ui-added', this.debugUIAddedHandler.bind(this));
};
window.addEventListener('debug-ui-added', this.debugUIAddedHandler.bind(this));
window.addEventListener('debug-ui-added', this.debugUIAddedHandler.bind(this));
window.addEventListener('gps-camera-ready', function() {
if (this._cameraGps === null) {
var camera = document.querySelector('a-camera, [camera]');
if (!this._cameraGps) {
var camera = document.querySelector('[gps-camera]');
if (camera.components['gps-camera'] === undefined) {
console.error('gps-camera not found')
return;
}
this._cameraGps = camera.components['gps-camera'];
}
if (!this._cameraGps.originCoords && !this._cameraGps.currentCoords) {
console.error('gps-camera not initialized')
return;
}
this._updatePosition();
}.bind(this));
}.bind(this), 2000);
},
/**
......@@ -41,28 +47,26 @@ AFRAME.registerComponent('gps-entity-place', {
_updatePosition: function () {
var position = { x: 0, y: 0, z: 0 }
if (this._cameraGps.originCoords === null) {
return;
}
var cameraCoords = this._cameraGps.originCoords || this._cameraGps.currentCoords;
// update position.x
var dstCoords = {
longitude: this.data.longitude,
latitude: this._cameraGps.originCoords.latitude,
latitude: cameraCoords.latitude,
};
position.x = this._cameraGps.computeDistanceMeters(this._cameraGps.originCoords, dstCoords, true);
position.x = this._cameraGps.computeDistanceMeters(cameraCoords, dstCoords, true);
this._positionXDebug = position.x;
position.x *= this.data.longitude > this._cameraGps.originCoords.longitude ? 1 : -1;
position.x *= this.data.longitude > cameraCoords.longitude ? 1 : -1;
// update position.z
var dstCoords = {
longitude: this._cameraGps.originCoords.longitude,
longitude: cameraCoords.longitude,
latitude: this.data.latitude,
};
position.z = this._cameraGps.computeDistanceMeters(this._cameraGps.originCoords, dstCoords, true);
position.z *= this.data.latitude > this._cameraGps.originCoords.latitude ? -1 : 1;
position.z = this._cameraGps.computeDistanceMeters(cameraCoords, dstCoords, true);
position.z *= this.data.latitude > cameraCoords.latitude ? -1 : 1;
// update element's position in 3D world
this.el.setAttribute('position', position);
......@@ -74,7 +78,7 @@ AFRAME.registerComponent('gps-entity-place', {
*/
setDebugData: function (element) {
var elements = document.querySelectorAll('.debug-distance');
elements.forEach(function(el) {
elements.forEach(function (el) {
var distance = formatDistance(this._positionXDebug);
if (element.getAttribute('value') == el.getAttribute('value')) {
el.innerHTML = el.getAttribute('value') + ': ' + distance + 'far';
......
{
"name": "ar.js",
"version": "2.0.6",
"version": "2.0.7",
"description": "Efficient Augmented Reality for the Web",
"main": "",
"scripts": {
......
......@@ -5308,7 +5308,7 @@ Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype );
// ARjs.Context.baseURL = '../'
// default to github page
ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/'
ARjs.Context.REVISION = '2.0.6';
ARjs.Context.REVISION = '2.0.7';
/**
* Create a default camera for this trackingBackend
......@@ -2574,7 +2574,7 @@ Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype );
// ARjs.Context.baseURL = '../'
// default to github page
ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/'
ARjs.Context.REVISION = '2.0.6';
ARjs.Context.REVISION = '2.0.7';
/**
* Create a default camera for this trackingBackend
......
此差异已折叠。
此差异已折叠。
......@@ -76,7 +76,7 @@ Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype );
// ARjs.Context.baseURL = '../'
// default to github page
ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/'
ARjs.Context.REVISION = '2.0.6';
ARjs.Context.REVISION = '2.0.7';
/**
* Create a default camera for this trackingBackend
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册