Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cqiang1993
AR.js
提交
61b59f28
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,发现更多精彩内容 >>
提交
61b59f28
编写于
8月 11, 2017
作者:
J
Jerome Etienne
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cleanup + arjs-hittesting cleaner
上级
9ad1b366
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
118 addition
and
43 deletion
+118
-43
TODO.md
TODO.md
+1
-1
aframe/build/aframe-ar.js
aframe/build/aframe-ar.js
+43
-17
aframe/src/component-hit-testing.js
aframe/src/component-hit-testing.js
+1
-1
babylon.js/src/babylon-ar.js
babylon.js/src/babylon-ar.js
+3
-5
three.js/build/ar.js
three.js/build/ar.js
+37
-11
three.js/examples/arjs-session.html
three.js/examples/arjs-session.html
+1
-1
three.js/src/new-api/arjs-anchor.js
three.js/src/new-api/arjs-anchor.js
+8
-7
three.js/src/new-api/arjs-hittesting.js
three.js/src/new-api/arjs-hittesting.js
+24
-0
未找到文件。
TODO.md
浏览文件 @
61b59f28
## New API - aframe
-
port webar-playground on new API
-
once this refactor is done, publish is as AR.js v2.0 with a blog post
-
do a button - display-hittester-plane
...
...
@@ -10,7 +11,6 @@
-
have a source in images and video. in three.js and aframe.js
-
DONE ensure backward compatibility of aframe api
-
it seems works ?
...
...
aframe/build/aframe-ar.js
浏览文件 @
61b59f28
...
...
@@ -6471,6 +6471,7 @@ ARjs.Anchor = function(arSession, markerParameters){
// log to debug
console.log('ARjs.Anchor -', 'changeMatrixMode:', this.parameters.changeMatrixMode, '/ markersAreaEnabled:', markerParameters.markersAreaEnabled)
var markerRoot = new THREE.Group
scene.add(markerRoot)
...
...
@@ -6552,10 +6553,11 @@ ARjs.Anchor = function(arSession, markerParameters){
// Code Separator
//////////////////////////////////////////////////////////////////////////////
this.update = function(){
// update _this.object3d.visible
_this.object3d.visible = _this.object3d.parent.visible
// console.log('controlledObject.visible', _this.object3d.parent.visible)
// update scene.visible if the marker is seen
if( markerParameters.changeMatrixMode === 'cameraTransformMatrix' ){
_this.object3d.visible = controlledObject.visible
}
if( smoothedControls !== undefined ){
// update smoothedControls parameters depending on how many markers are visible in multiMarkerControls
if( multiMarkerControls !== undefined ){
...
...
@@ -6575,13 +6577,13 @@ ARjs.Anchor = function(arSession, markerParameters){
* @param {ARjs.HitTesting.Result} hitTestResult - the result to apply
*/
ARjs.Anchor.prototype.applyHitTestResult = function(hitTestResult){
this.
object3d.position.copy(hitTestResult.position)
this.
object3d.quaternion.copy(hitTestResult.quaternion)
this.
object3d.scale.copy(hitTestResult.scale)
this.
object3d.updateMatrix()
console.warn('obsolete anchro.applyHitTestResult - use hitTestResult.apply(object3d) instead')
hitTestResult.apply(this.object3d)
//
object3d.position.copy(hitTestResult.position)
//
object3d.quaternion.copy(hitTestResult.quaternion)
//
object3d.scale.copy(hitTestResult.scale)
//
//
object3d.updateMatrix()
}
// @namespace
var ARjs = ARjs || {}
...
...
@@ -6879,6 +6881,30 @@ ARjs.HitTesting.Result = function(position, quaternion, scale){
this.quaternion = quaternion
this.scale = scale
}
/**
* Apply to a controlled object3d
*
* @param {THREE.Object3D} object3d - the result to apply
*/
ARjs.HitTesting.Result.prototype.apply = function(object3d){
object3d.position.copy(this.position)
object3d.quaternion.copy(this.quaternion)
object3d.scale.copy(this.scale)
object3d.updateMatrix()
}
/**
* Apply to a controlled object3d
*
* @param {THREE.Object3D} object3d - the result to apply
*/
ARjs.HitTesting.Result.prototype.applyPosition = function(object3d){
object3d.position.copy(this.position)
object3d.updateMatrix()
}
var ARjs = ARjs || {}
/**
...
...
@@ -7367,11 +7393,11 @@ ARjs.MarkersAreaControls.prototype.updateSmoothedControls = function(smoothedCon
// {lerpPosition: 0.5, lerpQuaternion: 0.2, lerpQuaternion: 0.7}
// ]
lerpsValues = [
[0.1, 0.1, 0.3],
[0.
2
, 0.1, 0.4],
[0.
2
, 0.2, 0.5],
[0.
3
, 0.2, 0.7],
[0.
3
, 0.2, 0.7],
[0.
3+.
1, 0.1, 0.3],
[0.
4+.1
, 0.1, 0.4],
[0.
4+.1
, 0.2, 0.5],
[0.
5+.1
, 0.2, 0.7],
[0.
5+.1
, 0.2, 0.7],
]
}
// count how many subMarkersControls are visible
...
...
@@ -8215,7 +8241,7 @@ AFRAME.registerComponent('arjs-hit-testing', {
if( hitTestResults.length === 0 ) return
var hitTestResult = hitTestResults[0]
arAnchor.applyHitTestResult(hitTestResult
)
hitTestResult.apply(arAnchor.object3d
)
})
_this.isReady = true
aframe/src/component-hit-testing.js
浏览文件 @
61b59f28
...
...
@@ -49,7 +49,7 @@ AFRAME.registerComponent('arjs-hit-testing', {
if
(
hitTestResults
.
length
===
0
)
return
var
hitTestResult
=
hitTestResults
[
0
]
arAnchor
.
applyHitTestResult
(
hitTestResult
)
hitTestResult
.
apply
(
arAnchor
.
object3d
)
})
_this
.
isReady
=
true
...
...
babylon.js/src/babylon-ar.js
浏览文件 @
61b59f28
...
...
@@ -4,14 +4,12 @@ var ARjs = ARjs || {}
ARjs
.
Babylon
=
function
(){}
ARjs
.
Babylon
.
createCamera
=
function
(
scene
){
var
babylonCamera
=
new
BABYLON
.
ArcRotateCamera
(
"
GlobalRotativeCamera1
"
,
0
,
0
,
0
,
new
BABYLON
.
Vector3
(
0
,
0
,
-
1
),
scene
);
// arcRotateCamera.setPosition(new BABYLON.Vector3(0, 50, 80));
// arcRotateCamera.setTarget(BABYLON.Vector3.Zero());
// arcRotateCamera.attachControl(canvas, true);
var
babylonCamera
=
new
BABYLON
.
ArcRotateCamera
(
"
blabla
"
,
0
,
0
,
0
,
new
BABYLON
.
Vector3
(
0
,
0
,
-
1
),
scene
);
// hard
// hard
code a fov which is kinda ok
// scene.activeCamera.fovmode = BABYLON.Camera.fovmode_HORIZONTAL_FIXED;
// scene.activeCamera.fov = 2*22 / 180*Math.PI
return
babylonCamera
}
...
...
three.js/build/ar.js
浏览文件 @
61b59f28
...
...
@@ -6471,6 +6471,7 @@ ARjs.Anchor = function(arSession, markerParameters){
// log to debug
console.log('ARjs.Anchor -', 'changeMatrixMode:', this.parameters.changeMatrixMode, '/ markersAreaEnabled:', markerParameters.markersAreaEnabled)
var markerRoot = new THREE.Group
scene.add(markerRoot)
...
...
@@ -6552,10 +6553,11 @@ ARjs.Anchor = function(arSession, markerParameters){
// Code Separator
//////////////////////////////////////////////////////////////////////////////
this.update = function(){
// update _this.object3d.visible
_this.object3d.visible = _this.object3d.parent.visible
// console.log('controlledObject.visible', _this.object3d.parent.visible)
// update scene.visible if the marker is seen
if( markerParameters.changeMatrixMode === 'cameraTransformMatrix' ){
_this.object3d.visible = controlledObject.visible
}
if( smoothedControls !== undefined ){
// update smoothedControls parameters depending on how many markers are visible in multiMarkerControls
if( multiMarkerControls !== undefined ){
...
...
@@ -6575,13 +6577,13 @@ ARjs.Anchor = function(arSession, markerParameters){
* @param {ARjs.HitTesting.Result} hitTestResult - the result to apply
*/
ARjs.Anchor.prototype.applyHitTestResult = function(hitTestResult){
this.
object3d.position.copy(hitTestResult.position)
this.
object3d.quaternion.copy(hitTestResult.quaternion)
this.
object3d.scale.copy(hitTestResult.scale)
this.
object3d.updateMatrix()
console.warn('obsolete anchro.applyHitTestResult - use hitTestResult.apply(object3d) instead')
hitTestResult.apply(this.object3d)
//
object3d.position.copy(hitTestResult.position)
//
object3d.quaternion.copy(hitTestResult.quaternion)
//
object3d.scale.copy(hitTestResult.scale)
//
//
object3d.updateMatrix()
}
// @namespace
var ARjs = ARjs || {}
...
...
@@ -6879,6 +6881,30 @@ ARjs.HitTesting.Result = function(position, quaternion, scale){
this.quaternion = quaternion
this.scale = scale
}
/**
* Apply to a controlled object3d
*
* @param {THREE.Object3D} object3d - the result to apply
*/
ARjs.HitTesting.Result.prototype.apply = function(object3d){
object3d.position.copy(this.position)
object3d.quaternion.copy(this.quaternion)
object3d.scale.copy(this.scale)
object3d.updateMatrix()
}
/**
* Apply to a controlled object3d
*
* @param {THREE.Object3D} object3d - the result to apply
*/
ARjs.HitTesting.Result.prototype.applyPosition = function(object3d){
object3d.position.copy(this.position)
object3d.updateMatrix()
}
var ARjs = ARjs || {}
/**
three.js/examples/arjs-session.html
浏览文件 @
61b59f28
...
...
@@ -151,7 +151,7 @@
if
(
hitTestResults
.
length
===
0
)
return
var
hitTestResult
=
hitTestResults
[
0
]
arAnchor
.
applyHitTestResult
(
hitTestResult
)
hitTestResult
.
apply
(
arAnchor
.
object3d
)
})
//////////////////////////////////////////////////////////////////////////////
...
...
three.js/src/new-api/arjs-anchor.js
浏览文件 @
61b59f28
...
...
@@ -22,6 +22,7 @@ ARjs.Anchor = function(arSession, markerParameters){
// log to debug
console
.
log
(
'
ARjs.Anchor -
'
,
'
changeMatrixMode:
'
,
this
.
parameters
.
changeMatrixMode
,
'
/ markersAreaEnabled:
'
,
markerParameters
.
markersAreaEnabled
)
var
markerRoot
=
new
THREE
.
Group
scene
.
add
(
markerRoot
)
...
...
@@ -126,11 +127,11 @@ ARjs.Anchor = function(arSession, markerParameters){
* @param {ARjs.HitTesting.Result} hitTestResult - the result to apply
*/
ARjs
.
Anchor
.
prototype
.
applyHitTestResult
=
function
(
hitTestResult
){
this
.
object3d
.
position
.
copy
(
hitTestResult
.
position
)
this
.
object3d
.
quaternion
.
copy
(
hitTestResult
.
quaternion
)
this
.
object3d
.
scale
.
copy
(
hitTestResult
.
scale
)
this
.
object3d
.
updateMatrix
()
console
.
warn
(
'
obsolete anchro.applyHitTestResult - use hitTestResult.apply(object3d) instead
'
)
hitTestResult
.
apply
(
this
.
object3d
)
//
object3d.position.copy(hitTestResult.position)
//
object3d.quaternion.copy(hitTestResult.quaternion)
//
object3d.scale.copy(hitTestResult.scale)
//
//
object3d.updateMatrix()
}
three.js/src/new-api/arjs-hittesting.js
浏览文件 @
61b59f28
...
...
@@ -121,3 +121,27 @@ ARjs.HitTesting.Result = function(position, quaternion, scale){
this
.
quaternion
=
quaternion
this
.
scale
=
scale
}
/**
* Apply to a controlled object3d
*
* @param {THREE.Object3D} object3d - the result to apply
*/
ARjs
.
HitTesting
.
Result
.
prototype
.
apply
=
function
(
object3d
){
object3d
.
position
.
copy
(
this
.
position
)
object3d
.
quaternion
.
copy
(
this
.
quaternion
)
object3d
.
scale
.
copy
(
this
.
scale
)
object3d
.
updateMatrix
()
}
/**
* Apply to a controlled object3d
*
* @param {THREE.Object3D} object3d - the result to apply
*/
ARjs
.
HitTesting
.
Result
.
prototype
.
applyPosition
=
function
(
object3d
){
object3d
.
position
.
copy
(
this
.
position
)
object3d
.
updateMatrix
()
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录