Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cqiang1993
AR.js
提交
0f7a1f90
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,发现更多精彩内容 >>
提交
0f7a1f90
编写于
7月 11, 2017
作者:
J
Jerome Etienne
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more work
上级
815f52f0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
20 addition
and
151 deletion
+20
-151
TODO.md
TODO.md
+1
-1
docs/misc/EXAMPLES.md
docs/misc/EXAMPLES.md
+2
-2
three.js/examples/trackingbackend-switch.html
three.js/examples/trackingbackend-switch.html
+17
-18
three.js/threex-arsmoothedcontrols-old.js
three.js/threex-arsmoothedcontrols-old.js
+0
-130
未找到文件。
TODO.md
浏览文件 @
0f7a1f90
...
...
@@ -49,7 +49,7 @@
-
maybe cached in a ARtoolkit specific function
-
projectionAxisTransformMatrix renamed as artoolkitprojectionAxisTransformMatrix
-
simple, no risk and make it clear it is artoolkit -
-
DONE in
ar
backend-switch put the backend in hash. and offer to switch
-
DONE in
tracking
backend-switch put the backend in hash. and offer to switch
-
good for testing
-
DONE all this testing about aruco or jsartoolkit it crappy
-
in artoolkitContext.backend === 'aruco' || 'artoolkit'
...
...
docs/misc/EXAMPLES.md
浏览文件 @
0f7a1f90
...
...
@@ -48,9 +48,9 @@
-
[
parameters-tunning
](
https://jeromeetienne.github.io/AR.js/three.js/examples/parameters-tunning.html
)
:
three.js example for parameters-tunning
(
[
source
](
https://github.com/jeromeetienne/AR.js/blob/master/three.js/examples/parameters-tunning.html
)
)
-
[
backend switcher
](
https://jeromeetienne.github.io/AR.js/three.js/examples/
ar
backend-switch.html
)
:
-
[
backend switcher
](
https://jeromeetienne.github.io/AR.js/three.js/examples/
tracking
backend-switch.html
)
:
Show to easily switch between arBackend 'aruco' or 'jsartoolkit'
(
[
source
](
https://github.com/jeromeetienne/AR.js/blob/master/three.js/examples/
ar
backend-switch.html
)
)
(
[
source
](
https://github.com/jeromeetienne/AR.js/blob/master/three.js/examples/
tracking
backend-switch.html
)
)
-
[
multi-markers
](
https://jeromeetienne.github.io/AR.js/three.js/examples/multi-markers/examples/player.html
)
:
multi markers examples - it shows how to dynamically learn a multi markers and then how to use it.
learner.html is a example of dynamic learning of a multi markers configuration. It has been designed
...
...
three.js/examples/
ar
backend-switch.html
→
three.js/examples/
tracking
backend-switch.html
浏览文件 @
0f7a1f90
...
...
@@ -21,7 +21,6 @@
<script
src=
'../threex-arsmoothedcontrols.js'
></script>
<script>
THREEx
.
ArToolkitContext
.
baseURL
=
'
../
'
</script>
<body
style=
'margin : 0px; overflow: hidden; font-family: Monospace;'
><div
style=
'position: absolute; top: 10px; width:100%; text-align: center; z-index: 1;'
>
<a
href=
"https://github.com/jeromeetienne/AR.js/"
target=
"_blank"
>
AR.js
</a>
- switching between backend
by
<a
href=
'https://twitter.com/jerome_etienne'
target=
'_blank'
>
@jerome_etienne
</a>
...
...
@@ -31,7 +30,7 @@
/
<a
href=
'../../../three.js/threex/threex-aruco/examples/images/1001.png'
target=
'_blank'
>
1001 for aruco
</a>
<br/>
<strong>
Backend:
</strong>
<strong>
Tracking
Backend:
</strong>
switch to :
<a
href=
'#artoolkit'
onclick=
'location.reload()'
>
artoolkit
</a>
/
...
...
@@ -41,8 +40,8 @@
-
current :
<span
id=
'currentArBackend'
>
unknown
</a>
</div><script>
var
ar
Backend
=
location
.
hash
.
substring
(
1
)
?
location
.
hash
.
substring
(
1
)
:
'
artoolkit
'
document
.
querySelector
(
'
#currentArBackend
'
).
innerHTML
=
ar
Backend
var
tracking
Backend
=
location
.
hash
.
substring
(
1
)
?
location
.
hash
.
substring
(
1
)
:
'
artoolkit
'
document
.
querySelector
(
'
#currentArBackend
'
).
innerHTML
=
tracking
Backend
var
changeMatrixMode
=
'
cameraTransformMatrix
'
// var changeMatrixMode = 'modelViewMatrix'
...
...
@@ -74,13 +73,13 @@
//////////////////////////////////////////////////////////////////////////////////
// Create a camera
if
(
ar
Backend
===
'
artoolkit
'
){
if
(
tracking
Backend
===
'
artoolkit
'
){
var
camera
=
new
THREE
.
Camera
();
}
else
if
(
ar
Backend
===
'
aruco
'
){
}
else
if
(
tracking
Backend
===
'
aruco
'
){
var
camera
=
new
THREE
.
PerspectiveCamera
(
42
,
renderer
.
domElement
.
width
/
renderer
.
domElement
.
height
,
0.01
,
100
);
}
else
if
(
ar
Backend
===
'
tango
'
){
}
else
if
(
tracking
Backend
===
'
tango
'
){
var
camera
=
new
THREE
.
PerspectiveCamera
(
42
,
renderer
.
domElement
.
width
/
renderer
.
domElement
.
height
,
0.01
,
1000
);
console
.
log
(
'
TODO here init tango
ar
Backend
'
)
console
.
log
(
'
TODO here init tango
tracking
Backend
'
)
}
else
console
.
assert
(
false
)
scene
.
add
(
camera
);
...
...
@@ -88,13 +87,13 @@
// handle arToolkitSource
////////////////////////////////////////////////////////////////////////////////
if
(
ar
Backend
===
'
artoolkit
'
){
if
(
tracking
Backend
===
'
artoolkit
'
){
var
sourceParameters
=
{
// to read from an image
sourceType
:
'
image
'
,
sourceUrl
:
THREEx
.
ArToolkitContext
.
baseURL
+
'
../data/images/img.jpg
'
,
}
}
else
if
(
ar
Backend
===
'
aruco
'
){
}
else
if
(
tracking
Backend
===
'
aruco
'
){
var
sourceParameters
=
{
// to read from an image
sourceType
:
'
image
'
,
...
...
@@ -114,16 +113,16 @@
function
onResize
(){
arToolkitSource
.
onResize
()
arToolkitSource
.
copySizeTo
(
renderer
.
domElement
)
if
(
ar
Backend
===
'
artoolkit
'
){
if
(
tracking
Backend
===
'
artoolkit
'
){
if
(
arToolkitContext
.
arController
!==
null
){
arToolkitSource
.
copySizeTo
(
arToolkitContext
.
arController
.
canvas
)
}
}
else
if
(
ar
Backend
===
'
aruco
'
){
}
else
if
(
tracking
Backend
===
'
aruco
'
){
arToolkitSource
.
copySizeTo
(
arToolkitContext
.
arucoContext
.
canvas
)
camera
.
aspect
=
renderer
.
domElement
.
width
/
renderer
.
domElement
.
height
;
camera
.
updateProjectionMatrix
();
}
else
if
(
ar
Backend
===
'
tango
'
){
}
else
if
(
tracking
Backend
===
'
tango
'
){
// console.log('here resize for tango')
camera
.
aspect
=
renderer
.
domElement
.
width
/
renderer
.
domElement
.
height
;
camera
.
updateProjectionMatrix
();
...
...
@@ -139,13 +138,13 @@
var
arToolkitContext
=
new
THREEx
.
ArToolkitContext
({
cameraParametersUrl
:
THREEx
.
ArToolkitContext
.
baseURL
+
'
../data/data/camera_para.dat
'
,
detectionMode
:
'
mono
'
,
arBackend
:
ar
Backend
,
trackingBackend
:
tracking
Backend
,
})
// initialize it
arToolkitContext
.
init
(
function
onCompleted
(){
// if artoolkit, copy projection matrix to camera
if
(
arToolkitContext
.
parameters
.
ar
Backend
===
'
artoolkit
'
){
if
(
arToolkitContext
.
parameters
.
tracking
Backend
===
'
artoolkit
'
){
camera
.
projectionMatrix
.
copy
(
arToolkitContext
.
getProjectionMatrix
()
);
}
})
...
...
@@ -166,13 +165,13 @@
// as we controls the camera, set changeMatrixMode: 'cameraTransformMatrix'
changeMatrixMode
:
changeMatrixMode
}
if
(
arToolkitContext
.
parameters
.
ar
Backend
===
'
artoolkit
'
){
if
(
arToolkitContext
.
parameters
.
tracking
Backend
===
'
artoolkit
'
){
controlsParameters
.
type
=
'
pattern
'
controlsParameters
.
patternUrl
=
THREEx
.
ArToolkitContext
.
baseURL
+
'
../data/data/patt.hiro
'
}
else
if
(
arToolkitContext
.
parameters
.
ar
Backend
===
'
aruco
'
){
}
else
if
(
arToolkitContext
.
parameters
.
tracking
Backend
===
'
aruco
'
){
controlsParameters
.
type
=
'
barcode
'
controlsParameters
.
barcodeValue
=
1001
}
else
if
(
arToolkitContext
.
parameters
.
ar
Backend
===
'
tango
'
){
}
else
if
(
arToolkitContext
.
parameters
.
tracking
Backend
===
'
tango
'
){
controlsParameters
.
type
=
'
barcode
'
controlsParameters
.
barcodeValue
=
1001
}
else
console
.
assert
(
false
)
...
...
three.js/threex-arsmoothedcontrols-old.js
已删除
100644 → 0
浏览文件 @
815f52f0
var
THREEx
=
THREEx
||
{}
/**
* - lerp position/quaternino/scale
* - minDelayDetected
* - minDelayUndetected
* @param {[type]} object3d [description]
* @param {[type]} parameters [description]
*/
THREEx
.
ArSmoothedControls
=
function
(
object3d
,
parameters
){
var
_this
=
this
THREEx
.
ArBaseControls
.
call
(
this
,
object3d
)
// copy parameters
this
.
object3d
.
visible
=
false
this
.
_lastLerpStepAt
=
null
this
.
_visibleStartedAt
=
null
this
.
_unvisibleStartedAt
=
null
// handle default parameters
parameters
=
parameters
||
{}
this
.
parameters
=
{
// lerp coeficient for the position - between [0,1] - default to 1
lerpPosition
:
parameters
.
lerpPosition
!==
undefined
?
parameters
.
lerpPosition
:
0.8
,
// lerp coeficient for the quaternion - between [0,1] - default to 1
lerpQuaternion
:
parameters
.
lerpQuaternion
!==
undefined
?
parameters
.
lerpQuaternion
:
0.2
,
// lerp coeficient for the scale - between [0,1] - default to 1
lerpScale
:
parameters
.
lerpScale
!==
undefined
?
parameters
.
lerpScale
:
0.7
,
// delay for lerp fixed steps - in seconds - default to 1/120
lerpStepDelay
:
parameters
.
fixStepDelay
!==
undefined
?
parameters
.
fixStepDelay
:
1
/
60
,
// minimum delay the sub-control must be visible before this controls become visible - default to 0 seconds
minVisibleDelay
:
parameters
.
minVisibleDelay
!==
undefined
?
parameters
.
minVisibleDelay
:
0.0
,
// minimum delay the sub-control must be unvisible before this controls become unvisible - default to 0 seconds
minUnvisibleDelay
:
parameters
.
minUnvisibleDelay
!==
undefined
?
parameters
.
minUnvisibleDelay
:
0.2
,
}
}
THREEx
.
ArSmoothedControls
.
prototype
=
Object
.
create
(
THREEx
.
ArBaseControls
.
prototype
);
THREEx
.
ArSmoothedControls
.
prototype
.
constructor
=
THREEx
.
ArSmoothedControls
;
//////////////////////////////////////////////////////////////////////////////
// update function
//////////////////////////////////////////////////////////////////////////////
THREEx
.
ArSmoothedControls
.
prototype
.
update
=
function
(
targetObject3d
){
var
object3d
=
this
.
object3d
var
parameters
=
this
.
parameters
var
wasVisible
=
object3d
.
visible
var
present
=
performance
.
now
()
/
1000
//////////////////////////////////////////////////////////////////////////////
// handle object3d.visible with minVisibleDelay/minUnvisibleDelay
//////////////////////////////////////////////////////////////////////////////
if
(
targetObject3d
.
visible
===
false
)
this
.
_visibleStartedAt
=
null
if
(
targetObject3d
.
visible
===
true
)
this
.
_unvisibleStartedAt
=
null
if
(
wasVisible
===
false
&&
targetObject3d
.
visible
===
true
){
if
(
this
.
_visibleStartedAt
===
null
)
this
.
_visibleStartedAt
=
present
var
visibleFor
=
present
-
this
.
_visibleStartedAt
if
(
visibleFor
>=
this
.
parameters
.
minVisibleDelay
){
object3d
.
visible
=
true
this
.
_visibleStartedAt
=
null
}
console
.
log
(
'
visibleFor
'
,
visibleFor
)
}
if
(
wasVisible
===
true
&&
targetObject3d
.
visible
===
false
){
if
(
this
.
_unvisibleStartedAt
===
null
)
this
.
_unvisibleStartedAt
=
present
var
unvisibleFor
=
present
-
this
.
_unvisibleStartedAt
if
(
unvisibleFor
>=
this
.
parameters
.
minUnvisibleDelay
){
object3d
.
visible
=
false
}
// console.log('unvisibleFor', unvisibleFor)
}
// disabled minVisibleDelay+minUnvisibleDelay
// if( true ){
// object3d.visible = targetObject3d.visible
// }
//////////////////////////////////////////////////////////////////////////////
// apply lerp on positon/quaternion/scale
//////////////////////////////////////////////////////////////////////////////
// apply lerp steps - require fix time steps to behave the same no matter the fps
if
(
this
.
_lastLerpStepAt
===
null
){
applyOneSlepStep
()
this
.
_lastLerpStepAt
=
present
}
else
{
var
nStepsToDo
=
Math
.
floor
(
(
present
-
this
.
_lastLerpStepAt
)
/
this
.
parameters
.
lerpStepDelay
)
for
(
var
i
=
0
;
i
<
nStepsToDo
;
i
++
){
applyOneSlepStep
()
this
.
_lastLerpStepAt
+=
this
.
parameters
.
lerpStepDelay
}
}
// update the matrix
this
.
object3d
.
updateMatrix
()
// disable the lerp by directly copying targetObject3d position/quaternion/scale
if
(
false
){
this
.
object3d
.
position
.
copy
(
targetObject3d
.
position
)
this
.
object3d
.
quaternion
.
copy
(
targetObject3d
.
quaternion
)
this
.
object3d
.
scale
.
copy
(
targetObject3d
.
scale
)
this
.
object3d
.
updateMatrix
()
}
//////////////////////////////////////////////////////////////////////////////
// honor becameVisible/becameUnVisible event
//////////////////////////////////////////////////////////////////////////////
// honor becameVisible event
if
(
wasVisible
===
false
&&
object3d
.
visible
===
true
){
this
.
dispatchEvent
({
type
:
'
becameVisible
'
})
}
// honor becameUnVisible event
if
(
wasVisible
===
true
&&
object3d
.
visible
===
false
){
this
.
dispatchEvent
({
type
:
'
becameUnVisible
'
})
}
return
function
applyOneSlepStep
(){
object3d
.
position
.
lerp
(
targetObject3d
.
position
,
parameters
.
lerpPosition
)
object3d
.
quaternion
.
slerp
(
targetObject3d
.
quaternion
,
parameters
.
lerpQuaternion
)
object3d
.
scale
.
lerp
(
targetObject3d
.
scale
,
parameters
.
lerpScale
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录