Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cqiang1993
AR.js
提交
fa2c8ee3
A
AR.js
项目概览
cqiang1993
/
AR.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
AR.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fa2c8ee3
编写于
2月 25, 2020
作者:
N
nicolo.carpignoli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed hide objects when minDistance is set
上级
f78d99a7
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
15 deletion
+57
-15
aframe/build/aframe-ar.js
aframe/build/aframe-ar.js
+28
-7
aframe/build/aframe-ar.min.js
aframe/build/aframe-ar.min.js
+1
-1
aframe/src/location-based/gps-camera.js
aframe/src/location-based/gps-camera.js
+4
-4
aframe/src/location-based/gps-entity-place.js
aframe/src/location-based/gps-entity-place.js
+24
-3
未找到文件。
aframe/build/aframe-ar.js
浏览文件 @
fa2c8ee3
...
@@ -5686,8 +5686,8 @@ AFRAME.registerComponent('gps-camera', {
...
@@ -5686,8 +5686,8 @@ AFRAME.registerComponent('gps-camera', {
else {
else {
this.currentCoords = position.coords;
this.currentCoords = position.coords;
}
}
this._updatePosition();
this._updatePosition();
}.bind(this));
}.bind(this));
},
},
...
@@ -5838,7 +5838,7 @@ AFRAME.registerComponent('gps-camera', {
...
@@ -5838,7 +5838,7 @@ AFRAME.registerComponent('gps-camera', {
* @param {Position} dest
* @param {Position} dest
* @param {Boolean} isPlace
* @param {Boolean} isPlace
*
*
* @returns {number} distance
* @returns {number} distance
| Number.MAX_SAFE_INTEGER
*/
*/
computeDistanceMeters: function (src, dest, isPlace) {
computeDistanceMeters: function (src, dest, isPlace) {
var dlongitude = THREE.Math.degToRad(dest.longitude - src.longitude);
var dlongitude = THREE.Math.degToRad(dest.longitude - src.longitude);
...
@@ -5849,7 +5849,7 @@ AFRAME.registerComponent('gps-camera', {
...
@@ -5849,7 +5849,7 @@ AFRAME.registerComponent('gps-camera', {
var distance = angle * 6378160;
var distance = angle * 6378160;
// if function has been called for a place, and if it's too near and a min distance has been set,
// if function has been called for a place, and if it's too near and a min distance has been set,
//
set a very high distance to hide the object
//
return max distance possible - to be handled by the method caller
if (isPlace && this.data.minDistance && this.data.minDistance > 0 && distance < this.data.minDistance) {
if (isPlace && this.data.minDistance && this.data.minDistance > 0 && distance < this.data.minDistance) {
return Number.MAX_SAFE_INTEGER;
return Number.MAX_SAFE_INTEGER;
}
}
...
@@ -5973,7 +5973,8 @@ AFRAME.registerComponent('gps-entity-place', {
...
@@ -5973,7 +5973,8 @@ AFRAME.registerComponent('gps-entity-place', {
latitude: this.data.latitude,
latitude: this.data.latitude,
};
};
var distance = this._cameraGps.computeDistanceMeters(ev.detail.position, dstCoords, true);
// it's actually a 'distance place', but we don't call it with last param, because we want to retrieve distance even if it's < minDistance property
var distance = this._cameraGps.computeDistanceMeters(ev.detail.position, dstCoords);
this.el.setAttribute('distance', distance);
this.el.setAttribute('distance', distance);
this.el.setAttribute('distanceMsg', formatDistance(distance));
this.el.setAttribute('distanceMsg', formatDistance(distance));
...
@@ -5999,6 +6000,7 @@ AFRAME.registerComponent('gps-entity-place', {
...
@@ -5999,6 +6000,7 @@ AFRAME.registerComponent('gps-entity-place', {
*/
*/
_updatePosition: function () {
_updatePosition: function () {
var position = { x: 0, y: this.el.getAttribute('position').y || 0, z: 0 }
var position = { x: 0, y: this.el.getAttribute('position').y || 0, z: 0 }
var hideEntity = false;
// update position.x
// update position.x
var dstCoords = {
var dstCoords = {
...
@@ -6007,6 +6009,12 @@ AFRAME.registerComponent('gps-entity-place', {
...
@@ -6007,6 +6009,12 @@ AFRAME.registerComponent('gps-entity-place', {
};
};
position.x = this._cameraGps.computeDistanceMeters(this._cameraGps.originCoords, dstCoords, true);
position.x = this._cameraGps.computeDistanceMeters(this._cameraGps.originCoords, dstCoords, true);
// place has to be hide
if (position.x === Number.MAX_SAFE_INTEGER) {
hideEntity = true;
}
this._positionXDebug = position.x;
this._positionXDebug = position.x;
position.x *= this.data.longitude > this._cameraGps.originCoords.longitude ? 1 : -1;
position.x *= this.data.longitude > this._cameraGps.originCoords.longitude ? 1 : -1;
...
@@ -6018,11 +6026,24 @@ AFRAME.registerComponent('gps-entity-place', {
...
@@ -6018,11 +6026,24 @@ AFRAME.registerComponent('gps-entity-place', {
};
};
position.z = this._cameraGps.computeDistanceMeters(this._cameraGps.originCoords, dstCoords, true);
position.z = this._cameraGps.computeDistanceMeters(this._cameraGps.originCoords, dstCoords, true);
// place has to be hide
if (position.z === Number.MAX_SAFE_INTEGER) {
hideEntity = true;
}
position.z *= this.data.latitude > this._cameraGps.originCoords.latitude ? -1 : 1;
position.z *= this.data.latitude > this._cameraGps.originCoords.latitude ? -1 : 1;
if(position.y !== 0) {
if (position.y !== 0) {
position.y = position.y - this._cameraGps.originCoords.altitude;
position.y = position.y - this._cameraGps.originCoords.altitude;
}
}
if (hideEntity) {
this.el.setAttribute('visible', false);
} else {
this.el.setAttribute('visible', true);
}
// update element's position in 3D world
// update element's position in 3D world
this.el.setAttribute('position', position);
this.el.setAttribute('position', position);
},
},
...
...
aframe/build/aframe-ar.min.js
浏览文件 @
fa2c8ee3
此差异已折叠。
点击以展开。
aframe/src/location-based/gps-camera.js
浏览文件 @
fa2c8ee3
...
@@ -93,8 +93,8 @@ AFRAME.registerComponent('gps-camera', {
...
@@ -93,8 +93,8 @@ AFRAME.registerComponent('gps-camera', {
else
{
else
{
this
.
currentCoords
=
position
.
coords
;
this
.
currentCoords
=
position
.
coords
;
}
}
this
.
_updatePosition
();
this
.
_updatePosition
();
}.
bind
(
this
));
}.
bind
(
this
));
},
},
...
@@ -245,7 +245,7 @@ AFRAME.registerComponent('gps-camera', {
...
@@ -245,7 +245,7 @@ AFRAME.registerComponent('gps-camera', {
* @param {Position} dest
* @param {Position} dest
* @param {Boolean} isPlace
* @param {Boolean} isPlace
*
*
* @returns {number} distance
* @returns {number} distance
| Number.MAX_SAFE_INTEGER
*/
*/
computeDistanceMeters
:
function
(
src
,
dest
,
isPlace
)
{
computeDistanceMeters
:
function
(
src
,
dest
,
isPlace
)
{
var
dlongitude
=
THREE
.
Math
.
degToRad
(
dest
.
longitude
-
src
.
longitude
);
var
dlongitude
=
THREE
.
Math
.
degToRad
(
dest
.
longitude
-
src
.
longitude
);
...
@@ -256,7 +256,7 @@ AFRAME.registerComponent('gps-camera', {
...
@@ -256,7 +256,7 @@ AFRAME.registerComponent('gps-camera', {
var
distance
=
angle
*
6378160
;
var
distance
=
angle
*
6378160
;
// if function has been called for a place, and if it's too near and a min distance has been set,
// if function has been called for a place, and if it's too near and a min distance has been set,
//
set a very high distance to hide the object
//
return max distance possible - to be handled by the method caller
if
(
isPlace
&&
this
.
data
.
minDistance
&&
this
.
data
.
minDistance
>
0
&&
distance
<
this
.
data
.
minDistance
)
{
if
(
isPlace
&&
this
.
data
.
minDistance
&&
this
.
data
.
minDistance
>
0
&&
distance
<
this
.
data
.
minDistance
)
{
return
Number
.
MAX_SAFE_INTEGER
;
return
Number
.
MAX_SAFE_INTEGER
;
}
}
...
...
aframe/src/location-based/gps-entity-place.js
浏览文件 @
fa2c8ee3
...
@@ -34,7 +34,8 @@ AFRAME.registerComponent('gps-entity-place', {
...
@@ -34,7 +34,8 @@ AFRAME.registerComponent('gps-entity-place', {
latitude
:
this
.
data
.
latitude
,
latitude
:
this
.
data
.
latitude
,
};
};
var
distance
=
this
.
_cameraGps
.
computeDistanceMeters
(
ev
.
detail
.
position
,
dstCoords
,
true
);
// it's actually a 'distance place', but we don't call it with last param, because we want to retrieve distance even if it's < minDistance property
var
distance
=
this
.
_cameraGps
.
computeDistanceMeters
(
ev
.
detail
.
position
,
dstCoords
);
this
.
el
.
setAttribute
(
'
distance
'
,
distance
);
this
.
el
.
setAttribute
(
'
distance
'
,
distance
);
this
.
el
.
setAttribute
(
'
distanceMsg
'
,
formatDistance
(
distance
));
this
.
el
.
setAttribute
(
'
distanceMsg
'
,
formatDistance
(
distance
));
...
@@ -60,6 +61,7 @@ AFRAME.registerComponent('gps-entity-place', {
...
@@ -60,6 +61,7 @@ AFRAME.registerComponent('gps-entity-place', {
*/
*/
_updatePosition
:
function
()
{
_updatePosition
:
function
()
{
var
position
=
{
x
:
0
,
y
:
this
.
el
.
getAttribute
(
'
position
'
).
y
||
0
,
z
:
0
}
var
position
=
{
x
:
0
,
y
:
this
.
el
.
getAttribute
(
'
position
'
).
y
||
0
,
z
:
0
}
var
hideEntity
=
false
;
// update position.x
// update position.x
var
dstCoords
=
{
var
dstCoords
=
{
...
@@ -68,6 +70,12 @@ AFRAME.registerComponent('gps-entity-place', {
...
@@ -68,6 +70,12 @@ AFRAME.registerComponent('gps-entity-place', {
};
};
position
.
x
=
this
.
_cameraGps
.
computeDistanceMeters
(
this
.
_cameraGps
.
originCoords
,
dstCoords
,
true
);
position
.
x
=
this
.
_cameraGps
.
computeDistanceMeters
(
this
.
_cameraGps
.
originCoords
,
dstCoords
,
true
);
// place has to be hide
if
(
position
.
x
===
Number
.
MAX_SAFE_INTEGER
)
{
hideEntity
=
true
;
}
this
.
_positionXDebug
=
position
.
x
;
this
.
_positionXDebug
=
position
.
x
;
position
.
x
*=
this
.
data
.
longitude
>
this
.
_cameraGps
.
originCoords
.
longitude
?
1
:
-
1
;
position
.
x
*=
this
.
data
.
longitude
>
this
.
_cameraGps
.
originCoords
.
longitude
?
1
:
-
1
;
...
@@ -79,11 +87,24 @@ AFRAME.registerComponent('gps-entity-place', {
...
@@ -79,11 +87,24 @@ AFRAME.registerComponent('gps-entity-place', {
};
};
position
.
z
=
this
.
_cameraGps
.
computeDistanceMeters
(
this
.
_cameraGps
.
originCoords
,
dstCoords
,
true
);
position
.
z
=
this
.
_cameraGps
.
computeDistanceMeters
(
this
.
_cameraGps
.
originCoords
,
dstCoords
,
true
);
// place has to be hide
if
(
position
.
z
===
Number
.
MAX_SAFE_INTEGER
)
{
hideEntity
=
true
;
}
position
.
z
*=
this
.
data
.
latitude
>
this
.
_cameraGps
.
originCoords
.
latitude
?
-
1
:
1
;
position
.
z
*=
this
.
data
.
latitude
>
this
.
_cameraGps
.
originCoords
.
latitude
?
-
1
:
1
;
if
(
position
.
y
!==
0
)
{
if
(
position
.
y
!==
0
)
{
position
.
y
=
position
.
y
-
this
.
_cameraGps
.
originCoords
.
altitude
;
position
.
y
=
position
.
y
-
this
.
_cameraGps
.
originCoords
.
altitude
;
}
}
if
(
hideEntity
)
{
this
.
el
.
setAttribute
(
'
visible
'
,
false
);
}
else
{
this
.
el
.
setAttribute
(
'
visible
'
,
true
);
}
// update element's position in 3D world
// update element's position in 3D world
this
.
el
.
setAttribute
(
'
position
'
,
position
);
this
.
el
.
setAttribute
(
'
position
'
,
position
);
},
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录