Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cqiang1993
AR.js
提交
e7c92df1
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,发现更多精彩内容 >>
提交
e7c92df1
编写于
7月 31, 2017
作者:
J
Jerome Etienne
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more work
上级
0ce0aae4
变更
15
展开全部
隐藏空白更改
内联
并排
Showing
15 changed file
with
7052 addition
and
6956 deletion
+7052
-6956
TODO.md
TODO.md
+25
-5
aframe/examples/aframe-session-base.html
aframe/examples/aframe-session-base.html
+8
-64
aframe/examples/aframe-session.html
aframe/examples/aframe-session.html
+7
-5
aframe/src/component-hit-testing.js
aframe/src/component-hit-testing.js
+9
-9
three.js/Makefile
three.js/Makefile
+10
-9
three.js/build/ar.js
three.js/build/ar.js
+6864
-6802
three.js/build/ar.min.js
three.js/build/ar.min.js
+2
-2
three.js/examples/arjs-session.html
three.js/examples/arjs-session.html
+22
-16
three.js/src/new-api/arjs-anchor.js
three.js/src/new-api/arjs-anchor.js
+3
-3
three.js/src/new-api/arjs-hittesting.js
three.js/src/new-api/arjs-hittesting.js
+31
-21
three.js/src/new-api/arjs-session.js
three.js/src/new-api/arjs-session.js
+56
-8
three.js/src/threex/threex-arclickability.js
three.js/src/threex/threex-arclickability.js
+3
-3
three.js/src/threex/threex-armarkercontrols.js
three.js/src/threex/threex-armarkercontrols.js
+3
-0
three.js/src/threex/threex-hittesting-plane.js
three.js/src/threex/threex-hittesting-plane.js
+6
-6
three.js/src/threex/threex-hittesting-tango.js
three.js/src/threex/threex-hittesting-tango.js
+3
-3
未找到文件。
TODO.md
浏览文件 @
e7c92df1
## New API - aframe
-
buttons aframe doesnt work
-
how to create the scene dynamically in aframe
-
handle that with a reload
-
rename HitTester into HitTesting
-
do a button - display-hittester-plane
-
in three.js and in aframe.js
-
maybe a class arjs-session-debugui.js
-
create the UI
-
let user attach it to the dom
-
rename arjsmarker aframe component into arjs-anchor
-
with backward compatibility ? no need
-
implement working build
-
apparently some issue if artoolkit is included in the build
-
it worked in aframe before... what is happening
-
what if i change the order of the scripts
-
implement picking in aframe
-
first make it works
-
then find a good API
-
<ar-hittester
enabled=
'true'
renderDebug=
'false'
>
inside the controlled object
-
buttons aframe doesnt work
-
how to create the scene dynamically in aframe
-
handle that with a reload
-
better handling of the area stuff in trackingMethod
-
-
FIXME in aframe, i define .initialised but aframe defined .initialized..!?!?! super error prone
-
rename as in isReady ? better than nothing. good for now
-
honor marker preset
-
hiro + kanji and area
-
old issue with the same markers ?? deep in jsartoolkit
...
...
@@ -26,6 +44,7 @@
-
<ar-anchor>
-
REFACTOR trackingMethod - should i put changeMatrixMode into trackingMethod ?
-
should just drop it ? ??? why insit. it seems trouble
-
it is needed for all the test and all
-
what is trackingMethod ? it is unclear and messy
-
trackingMethod = trackingBackend + defaultAnchorDefinition
...
...
@@ -53,6 +72,7 @@
-
this is not a threex
-
in arjs.session.js - TODO change that to a usual this.parameters
-
do emulation layer with display
-
LATER aruco got perspective issue - likely camera init
...
...
aframe/examples/aframe-session-base.html
浏览文件 @
e7c92df1
<!DOCTYPE html>
<!-- include a-frame -->
<!-- <script src="vendor/aframe.js"></script> -->
<script
src=
"vendor/aframe-v0.6.1-three-r86.js"
></script>
<!-- include for artoolkit trackingBackend -->
<script
src=
'../../three.js/vendor/jsartoolkit5/build/artoolkit.min.js'
></script>
<script
src=
'../../three.js/vendor/jsartoolkit5/js/artoolkit.api.js'
></script>
<!-- include for aruco trackingBackend -->
<script
src=
'../../three.js/vendor/js-aruco/src/svd.js'
></script>
<script
src=
'../../three.js/vendor/js-aruco/src/posit1.js'
></script>
<script
src=
'../../three.js/vendor/js-aruco/src/cv.js'
></script>
<script
src=
'../../three.js/vendor/js-aruco/src/aruco.js'
></script>
<script
src=
'../../three.js/src/threex/threex-aruco/threex-arucocontext.js'
></script>
<script
src=
'../../three.js/src/threex/threex-aruco/threex-arucodebug.js'
></script>
<!-- include for tango trackingBackend -->
<script
src=
'../../three.js/vendor/chromium-tango/THREE.WebAR.js'
></script>
<!-- include ar.js -->
<script
src=
'../../three.js/src/threex/threex-artoolkitprofile.js'
></script>
<script
src=
'../../three.js/src/threex/threex-artoolkitsource.js'
></script>
<script
src=
'../../three.js/src/threex/threex-artoolkitcontext.js'
></script>
<script
src=
'../../three.js/src/threex/threex-arbasecontrols.js'
></script>
<script
src=
'../../three.js/src/threex/threex-armarkercontrols.js'
></script>
<script
src=
'../../three.js/src/threex/threex-arsmoothedcontrols.js'
></script>
<script
src=
'../../three.js/src/threex/threex-hittester-plane.js'
></script>
<script
src=
'../../three.js/src/threex/threex-hittester-tango.js'
></script>
<script
src=
'../../three.js/src/threex/threex-armarkerhelper.js'
></script>
<script
src=
'../../three.js/src/new-api/arjs-utils.js'
></script>
<script
src=
'../../three.js/src/new-api/arjs-session.js'
></script>
<script
src=
'../../three.js/src/new-api/arjs-anchor.js'
></script>
<script
src=
'../../three.js/src/new-api/arjs-hittester.js'
></script>
<script
src=
'../../three.js/src/new-api/arjs-tangovideomesh.js'
></script>
<script
src=
'../../three.js/src/new-api/arjs-tangopointcloud.js'
></script>
<script
src=
'../../three.js/src/markers-area/threex-armultimarkerutils.js'
></script>
<script
src=
'../../three.js/src/markers-area/threex-armultimarkercontrols.js'
></script>
<script
src=
'../../three.js/src/markers-area/threex-armultimarkerlearning.js'
></script>
<!-- include aframe-ar.js -->
<script
src=
"../src/system-ar-session.js"
></script>
<script
src=
"../src/component-anchor.js"
></script>
<script
src=
"../src/component-hit-tester.js"
></script>
<!-- include ar.js for aframe -->
<script
src=
"../build/aframe-ar.js"
></script>
<script>
ARjs
.
Context
.
baseURL
=
'
../../three.js/
'
</script>
<body
style=
'margin : 0px; overflow: hidden; font-family: Monospace; background-color: black;'
>
<div
style=
'position: fixed; top: 10px; width:inherit; text-align: center; z-index: 1;'
>
<a
href=
"https://github.com/jeromeetienne/AR.js/"
target=
"_blank"
>
AR.js
</a>
- tango example for a-frame by
<a
href=
'https://twitter.com/jerome_etienne'
target=
'_blank'
>
@jerome_etienne
</a>
<br/>
<strong>
Tracking Method:
</strong>
<span
id=
'trackingMethod'
>
unknown
</span>
-
Switch to :
<a
href=
'#artoolkit'
onclick=
'location.reload()'
>
artoolkit
</a>
/
<a
href=
'#aruco'
onclick=
'location.reload()'
>
aruco
</a>
/
<a
href=
'#area-artoolkit'
onclick=
'location.reload()'
>
area artoolkit
</a>
/
<a
href=
'#area-aruco'
onclick=
'location.reload()'
>
area aruco
</a>
/
<a
href=
'#tango'
onclick=
'location.reload()'
>
tango
</a>
/
<a
href=
'#best'
onclick=
'location.reload()'
>
best
</a>
<br/>
<a
href=
'javascript:void(0)'
id=
'buttonTangoTogglePointCloud'
>
toggle-point-cloud
</a>
<a
href=
'javascript:void(0)'
id=
'buttonToggleMarkerHelpers'
>
toggle-marker-helper
</a>
<a
href=
'javascript:void(0)'
id=
'buttonMarkersAreaLearner'
>
Learn-new-marker-area
</a>
<a
href=
'javascript:void(0)'
id=
'buttonMarkersAreaReset'
>
Reset-marker-area
</a>
</div>
<body
style=
'margin : 0px; overflow: hidden;'
>
<!-- Define your scene -->
<a-scene
embedded
arjs=
'trackingMethod: best'
>
<a-entity
arjsmarker
arjs-hit-tester
>
<!-- Create a anchor to attach your augmented reality -->
<a-entity
arjsmarker
arjs-hit-testing
>
<!-- Add your augmented reality here -->
<a-box
position=
'0 0.5 0'
material=
'color:red'
></a-box>
</a-entity>
<!-- Define a static camera -->
<a-camera-static/>
</a-scene>
</body>
</html>
aframe/examples/aframe-session.html
浏览文件 @
e7c92df1
...
...
@@ -21,13 +21,13 @@
<script
src=
'../../three.js/src/threex/threex-arbasecontrols.js'
></script>
<script
src=
'../../three.js/src/threex/threex-armarkercontrols.js'
></script>
<script
src=
'../../three.js/src/threex/threex-arsmoothedcontrols.js'
></script>
<script
src=
'../../three.js/src/threex/threex-hittest
er
-plane.js'
></script>
<script
src=
'../../three.js/src/threex/threex-hittest
er
-tango.js'
></script>
<script
src=
'../../three.js/src/threex/threex-hittest
ing
-plane.js'
></script>
<script
src=
'../../three.js/src/threex/threex-hittest
ing
-tango.js'
></script>
<script
src=
'../../three.js/src/threex/threex-armarkerhelper.js'
></script>
<script
src=
'../../three.js/src/new-api/arjs-utils.js'
></script>
<script
src=
'../../three.js/src/new-api/arjs-session.js'
></script>
<script
src=
'../../three.js/src/new-api/arjs-anchor.js'
></script>
<script
src=
'../../three.js/src/new-api/arjs-hittest
er
.js'
></script>
<script
src=
'../../three.js/src/new-api/arjs-hittest
ing
.js'
></script>
<script
src=
'../../three.js/src/new-api/arjs-tangovideomesh.js'
></script>
<script
src=
'../../three.js/src/new-api/arjs-tangopointcloud.js'
></script>
<script
src=
'../../three.js/src/markers-area/threex-armultimarkerutils.js'
></script>
...
...
@@ -36,7 +36,7 @@
<!-- include aframe-ar.js -->
<script
src=
"../src/system-ar-session.js"
></script>
<script
src=
"../src/component-anchor.js"
></script>
<script
src=
"../src/component-hit-test
er
.js"
></script>
<script
src=
"../src/component-hit-test
ing
.js"
></script>
<script>
ARjs
.
Context
.
baseURL
=
'
../../three.js/
'
</script>
...
...
@@ -66,9 +66,11 @@
</div>
<a-scene
embedded
arjs=
'trackingMethod: best; debugUIEnabled: true;'
>
<a-entity
arjsmarker
arjs-hit-tester
>
<a-entity
arjsmarker
arjs-hit-testing
>
<a-box
position=
'0 0.5 0'
material=
'opacity: 0.5; side:double; color:red;'
></a-box>
</a-entity>
<a-entity
camera
></a-entity>
...
...
aframe/src/component-hit-test
er
.js
→
aframe/src/component-hit-test
ing
.js
浏览文件 @
e7c92df1
//////////////////////////////////////////////////////////////////////////////
// arjsmarker
//////////////////////////////////////////////////////////////////////////////
AFRAME
.
registerComponent
(
'
arjs-hit-test
er
'
,
{
AFRAME
.
registerComponent
(
'
arjs-hit-test
ing
'
,
{
dependencies
:
[
'
arjs
'
,
'
artoolkit
'
],
schema
:
{
enabled
:
{
...
...
@@ -21,7 +21,7 @@ AFRAME.registerComponent('arjs-hit-tester', {
//
_this
.
initialised
=
false
_this
.
_arAnchor
=
null
_this
.
_arHitTest
er
=
null
_this
.
_arHitTest
ing
=
null
// trick to wait until arjsSystem is initialised
var
startedAt
=
Date
.
now
()
...
...
@@ -40,7 +40,7 @@ AFRAME.registerComponent('arjs-hit-tester', {
var
arSession
=
arjsSystem
.
_arSession
var
renderer
=
arSession
.
renderer
var
hitTester
=
_this
.
_arHitTest
er
=
new
ARjs
.
HitTester
(
arSession
)
var
hitTester
=
_this
.
_arHitTest
ing
=
new
ARjs
.
HitTesting
(
arSession
)
// tango only - picking to set object position
renderer
.
domElement
.
addEventListener
(
"
click
"
,
function
(
domEvent
){
...
...
@@ -71,8 +71,8 @@ AFRAME.registerComponent('arjs-hit-tester', {
var
arAnchor
=
arjsMarker
.
_arAnchor
var
hitTester
=
this
.
_arHitTest
er
var
camera
=
arSession
.
camera
var
hitTester
=
this
.
_arHitTest
ing
var
camera
=
arSession
.
parameters
.
camera
// console.log(camera.position)
hitTester
.
update
(
camera
,
arAnchor
.
object3d
,
arAnchor
.
parameters
.
changeMatrixMode
)
}
...
...
@@ -82,12 +82,12 @@ AFRAME.registerComponent('arjs-hit-tester', {
// define some primitives shortcuts
//////////////////////////////////////////////////////////////////////////////
AFRAME
.
registerPrimitive
(
'
a-hit-test
er
'
,
AFRAME
.
utils
.
extendDeep
({},
AFRAME
.
primitives
.
getMeshMixin
(),
{
AFRAME
.
registerPrimitive
(
'
a-hit-test
ing
'
,
AFRAME
.
utils
.
extendDeep
({},
AFRAME
.
primitives
.
getMeshMixin
(),
{
defaultComponents
:
{
'
arjs-hit-test
er
'
:
{},
'
arjs-hit-test
ing
'
:
{},
},
mappings
:
{
'
enabled
'
:
'
arjs-hit-test
er
.enabled
'
,
'
renderDebug
'
:
'
arjs-hit-test
er
.renderDebug
'
,
'
enabled
'
:
'
arjs-hit-test
ing
.enabled
'
,
'
renderDebug
'
:
'
arjs-hit-test
ing
.renderDebug
'
,
}
}));
three.js/Makefile
浏览文件 @
e7c92df1
watch
:
build
fswatch
-0
three.js
/
*
.js | xargs
-0
-n
1
-I
{}
make build
fswatch
-0
src/
*
/
*
.js | xargs
-0
-n
1
-I
{}
make build
.PHONY
:
build
build
:
(
cd
src/threex/threex-aruco
&&
make build
)
cat
vendor/jsartoolkit5/build/artoolkit.min.js
\
vendor/jsartoolkit5/js/artoolkit.api.js
\
src/threex/threex-aruco/build/threex-aruco.js
\
vendor/chromium-tango/THREE.WebAR.js
\
src/threex/
*
.js
\
echo
>
build/ar.js
cat
src/threex/
*
.js
\
src/new-api/
*
.js
\
src/markers-area/
*
.js
\
>
build/ar.js
src/markers-area/
*
.js
>>
build/ar.js
cat
vendor/jsartoolkit5/build/artoolkit.min.js
\
vendor/jsartoolkit5/js/artoolkit.api.js
>>
build/ar.js
cat
src/threex/threex-aruco/build/threex-aruco.js
>>
build/ar.js
cat
vendor/chromium-tango/THREE.WebAR.js
>>
build/ar.js
.PHONY
:
build
minify
:
build
uglifyjs build/ar.js
>
build/ar.min.js
...
...
three.js/build/ar.js
浏览文件 @
e7c92df1
此差异已折叠。
点击以展开。
three.js/build/ar.min.js
浏览文件 @
e7c92df1
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
three.js/examples/arjs-session.html
浏览文件 @
e7c92df1
...
...
@@ -6,11 +6,11 @@
<script
src=
'../vendor/jsartoolkit5/build/artoolkit.min.js'
></script>
<script
src=
'../vendor/jsartoolkit5/js/artoolkit.api.js'
></script>
<!-- include for aruco trackingBackend -->
<script
src=
'../vendor/js-aruco/src/svd.js'
></script>
<script
src=
'../vendor/js-aruco/src/posit1.js'
></script>
<script
src=
'../vendor/js-aruco/src/cv.js'
></script>
<script
src=
'../vendor/js-aruco/src/aruco.js'
></script>
<script
src=
'../src/threex/threex-aruco/threex-arucocontext.js'
></script>
<script
src=
'../vendor/js-aruco/src/svd.js'
></script>
<script
src=
'../vendor/js-aruco/src/posit1.js'
></script>
<script
src=
'../vendor/js-aruco/src/cv.js'
></script>
<script
src=
'../vendor/js-aruco/src/aruco.js'
></script>
<script
src=
'../src/threex/threex-aruco/threex-arucocontext.js'
></script>
<script
src=
'../src/threex/threex-aruco/threex-arucodebug.js'
></script>
<!-- include for tango trackingBackend -->
<script
src=
'../vendor/chromium-tango/THREE.WebAR.js'
></script>
...
...
@@ -22,17 +22,19 @@
<script
src=
'../src/threex/threex-armarkercontrols.js'
></script>
<script
src=
'../src/threex/threex-armarkerhelper.js'
></script>
<script
src=
'../src/threex/threex-arsmoothedcontrols.js'
></script>
<script
src=
'../src/threex/threex-hittest
er
-plane.js'
></script>
<script
src=
'../src/threex/threex-hittest
er
-tango.js'
></script>
<script
src=
'../src/threex/threex-hittest
ing
-plane.js'
></script>
<script
src=
'../src/threex/threex-hittest
ing
-tango.js'
></script>
<script
src=
'../src/new-api/arjs-utils.js'
></script>
<script
src=
'../src/new-api/arjs-session.js'
></script>
<script
src=
'../src/new-api/arjs-anchor.js'
></script>
<script
src=
'../src/new-api/arjs-hittest
er
.js'
></script>
<script
src=
'../src/new-api/arjs-hittest
ing
.js'
></script>
<script
src=
'../src/new-api/arjs-tangovideomesh.js'
></script>
<script
src=
'../src/new-api/arjs-tangopointcloud.js'
></script>
<script
src=
'../src/markers-area/threex-armultimarkerutils.js'
></script>
<script
src=
'../src/markers-area/threex-armultimarkercontrols.js'
></script>
<script
src=
'../src/markers-area/threex-armultimarkerlearning.js'
></script>
<script>
ARjs
.
Context
.
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;'
>
...
...
@@ -63,6 +65,7 @@
<a
href=
'javascript:void(0)'
id=
'buttonToggleMarkerHelpers'
>
toggle-marker-helper
</a>
<a
href=
'javascript:void(0)'
id=
'buttonMarkersAreaLearner'
>
Learn-new-marker-area
</a>
<a
href=
'javascript:void(0)'
id=
'buttonMarkersAreaReset'
>
Reset-marker-area
</a>
<a
href=
'javascript:void(0)'
id=
'displayHittestingPlane'
>
Display-hit-testing-plane
</a>
</div><script>
;(
function
(){
// get tracking method from location.hash
...
...
@@ -145,14 +148,14 @@
// handle Hit Tester
//////////////////////////////////////////////////////////////////////////////
var
hitTest
er
=
new
ARjs
.
HitTester
(
arSession
)
var
hitTest
ing
=
new
ARjs
.
HitTesting
(
arSession
)
onRenderFcts
.
push
(
function
(){
hitTest
er
.
update
(
camera
,
arAnchor
.
object3d
,
arAnchor
.
parameters
.
changeMatrixMode
)
hitTest
ing
.
update
(
camera
,
arAnchor
.
object3d
,
arAnchor
.
parameters
.
changeMatrixMode
)
})
// tango only - picking to set object position
renderer
.
domElement
.
addEventListener
(
"
click
"
,
function
(
domEvent
){
var
hitTestResults
=
hitTest
er
.
testDomEvent
(
domEvent
)
var
hitTestResults
=
hitTest
ing
.
testDomEvent
(
domEvent
)
if
(
hitTestResults
.
length
===
0
)
return
var
hitTestResult
=
hitTestResults
[
0
]
...
...
@@ -169,6 +172,9 @@
onRenderFcts
.
push
(
function
(){
tangoVideoMesh
.
update
()
})
}
if
(
arProfile
.
contextParameters
.
trackingBackend
===
'
tango
'
){
// init tangoPointCloud
var
tangoPointCloud
=
new
ARjs
.
TangoPointCloud
(
arSession
)
scene
.
add
(
tangoPointCloud
.
object3d
)
...
...
@@ -238,7 +244,7 @@
var
learnerBaseURL
=
THREEx
.
ArToolkitContext
.
baseURL
+
'
examples/multi-markers/examples/learner.html
'
var
trackingBackend
=
arProfile
.
contextParameters
.
trackingBackend
ARjs
.
MarkersAreaUtils
.
navigateToLearnerPage
(
learnerBaseURL
,
trackingBackend
)
})
})
}
else
{
document
.
querySelector
(
'
#buttonToggleMarkerHelpers
'
).
style
.
display
=
'
none
'
document
.
querySelector
(
'
#buttonMarkersAreaReset
'
).
style
.
display
=
'
none
'
...
...
@@ -259,10 +265,10 @@
tangoVideoMesh
.
render
()
}
// render hitTest
er
pickingPlane - for debug
var
renderHitTest
er
PickingPlane
=
true
if
(
renderHitTest
erPickingPlane
&&
hitTester
.
_hitTester
Plane
){
hitTest
er
.
_hitTester
Plane
.
renderDebug
(
renderer
)
// render hitTest
ing
pickingPlane - for debug
var
renderHitTest
ing
PickingPlane
=
true
if
(
renderHitTest
ingPickingPlane
&&
hitTesting
.
_hitTesting
Plane
){
hitTest
ing
.
_hitTesting
Plane
.
renderDebug
(
renderer
)
}
renderer
.
render
(
scene
,
camera
);
...
...
three.js/src/new-api/arjs-anchor.js
浏览文件 @
e7c92df1
...
...
@@ -13,8 +13,8 @@ var ARjs = ARjs || {}
ARjs
.
Anchor
=
function
(
arSession
,
markerParameters
){
var
_this
=
this
var
arContext
=
arSession
.
arContext
var
scene
=
arSession
.
scene
var
camera
=
arSession
.
camera
var
scene
=
arSession
.
parameters
.
scene
var
camera
=
arSession
.
parameters
.
camera
this
.
parameters
=
markerParameters
...
...
@@ -124,7 +124,7 @@ ARjs.Anchor = function(arSession, markerParameters){
/**
* Apply ARjs.Session.HitTestResult to the controlled object3d
*
* @param {ARjs.HitTest
er
.Result} hitTestResult - the result to apply
* @param {ARjs.HitTest
ing
.Result} hitTestResult - the result to apply
*/
ARjs
.
Anchor
.
prototype
.
applyHitTestResult
=
function
(
hitTestResult
){
...
...
three.js/src/new-api/arjs-hittest
er
.js
→
three.js/src/new-api/arjs-hittest
ing
.js
浏览文件 @
e7c92df1
...
...
@@ -7,19 +7,20 @@ var ARjs = ARjs || {}
* @param {ARjs.Session} arSession - the session on which we create the anchor
* @param {Object} markerParameters - parameter of this anchor
*/
ARjs
.
HitTest
er
=
function
(
arSession
){
ARjs
.
HitTest
ing
=
function
(
arSession
){
var
_this
=
this
var
arContext
=
arSession
.
arContext
var
trackingBackend
=
arContext
.
parameters
.
trackingBackend
this
.
enabled
=
true
this
.
_arSession
=
arSession
this
.
_hitTest
er
Plane
=
null
this
.
_hitTest
er
Tango
=
null
this
.
_hitTest
ing
Plane
=
null
this
.
_hitTest
ing
Tango
=
null
if
(
trackingBackend
===
'
tango
'
){
_this
.
_hitTest
erTango
=
new
THREEx
.
HitTester
Tango
(
arContext
)
_this
.
_hitTest
ingTango
=
new
THREEx
.
HitTesting
Tango
(
arContext
)
}
else
{
_this
.
_hitTest
erPlane
=
new
THREEx
.
HitTester
Plane
(
arSession
.
arSource
.
domElement
)
_this
.
_hitTest
ingPlane
=
new
THREEx
.
HitTesting
Plane
(
arSession
.
arSource
.
domElement
)
}
}
...
...
@@ -32,11 +33,14 @@ ARjs.HitTester = function(arSession){
* @param {THREE.Camera} camera - the camera to use
* @param {THREE.Object3D} object3d -
*/
ARjs
.
HitTester
.
prototype
.
update
=
function
(
camera
,
pickingRoot
,
changeMatrixMode
)
{
if
(
this
.
_hitTesterTango
!==
null
){
this
.
_hitTesterTango
.
update
()
}
else
if
(
this
.
_hitTesterPlane
!==
null
){
this
.
_hitTesterPlane
.
update
(
camera
,
pickingRoot
,
changeMatrixMode
)
ARjs
.
HitTesting
.
prototype
.
update
=
function
(
camera
,
pickingRoot
,
changeMatrixMode
)
{
// if it isnt enabled, do nothing
if
(
this
.
enabled
===
false
)
return
if
(
this
.
_hitTestingTango
!==
null
){
this
.
_hitTestingTango
.
update
()
}
else
if
(
this
.
_hitTestingPlane
!==
null
){
this
.
_hitTestingPlane
.
update
(
camera
,
pickingRoot
,
changeMatrixMode
)
}
else
console
.
assert
(
false
)
}
...
...
@@ -49,11 +53,14 @@ ARjs.HitTester.prototype.update = function (camera, pickingRoot, changeMatrixMod
*
* @param {Number} mouseX - position X of the hit [-1, +1]
* @param {Number} mouseY - position Y of the hit [-1, +1]
* @return {[ARjs.HitTest
er
.Result]} - array of result
* @return {[ARjs.HitTest
ing
.Result]} - array of result
*/
ARjs
.
HitTest
er
.
prototype
.
testDomEvent
=
function
(
domEvent
){
ARjs
.
HitTest
ing
.
prototype
.
testDomEvent
=
function
(
domEvent
){
var
trackingBackend
=
this
.
_arSession
.
arContext
.
parameters
.
trackingBackend
var
arSource
=
this
.
_arSession
.
arSource
// if it isnt enabled, do nothing
if
(
this
.
enabled
===
false
)
return
if
(
trackingBackend
===
'
tango
'
){
var
mouseX
=
domEvent
.
pageX
/
window
.
innerWidth
...
...
@@ -72,41 +79,44 @@ ARjs.HitTester.prototype.testDomEvent = function(domEvent){
*
* @param {Number} mouseX - position X of the hit [0, +1]
* @param {Number} mouseY - position Y of the hit [0, +1]
* @return {[ARjs.HitTest
er
.Result]} - array of result
* @return {[ARjs.HitTest
ing
.Result]} - array of result
*/
ARjs
.
HitTest
er
.
prototype
.
test
=
function
(
mouseX
,
mouseY
){
ARjs
.
HitTest
ing
.
prototype
.
test
=
function
(
mouseX
,
mouseY
){
var
arContext
=
this
.
_arSession
.
arContext
var
trackingBackend
=
arContext
.
parameters
.
trackingBackend
var
hitTestResults
=
[]
// if it isnt enabled, do nothing
if
(
this
.
enabled
===
false
)
return
var
result
=
null
if
(
trackingBackend
===
'
tango
'
){
var
result
=
this
.
_hitTest
er
Tango
.
test
(
mouseX
,
mouseY
)
var
result
=
this
.
_hitTest
ing
Tango
.
test
(
mouseX
,
mouseY
)
}
else
{
var
result
=
this
.
_hitTest
er
Plane
.
test
(
mouseX
,
mouseY
)
var
result
=
this
.
_hitTest
ing
Plane
.
test
(
mouseX
,
mouseY
)
}
// if no result is found, return now
if
(
result
===
null
)
return
hitTestResults
// build a ARjs.HitTest
er
.Result
var
hitTestResult
=
new
ARjs
.
HitTest
er
.
Result
(
result
.
position
,
result
.
quaternion
,
result
.
scale
)
// build a ARjs.HitTest
ing
.Result
var
hitTestResult
=
new
ARjs
.
HitTest
ing
.
Result
(
result
.
position
,
result
.
quaternion
,
result
.
scale
)
hitTestResults
.
push
(
hitTestResult
)
return
hitTestResults
}
//////////////////////////////////////////////////////////////////////////////
// ARjs.HitTest
er
.Result
// ARjs.HitTest
ing
.Result
//////////////////////////////////////////////////////////////////////////////
/**
* Contains the result of ARjs.HitTest
er
.test()
* Contains the result of ARjs.HitTest
ing
.test()
*
* @param {THREE.Vector3} position - position to use
* @param {THREE.Quaternion} quaternion - quaternion to use
* @param {THREE.Vector3} scale - scale
*/
ARjs
.
HitTest
er
.
Result
=
function
(
position
,
quaternion
,
scale
){
ARjs
.
HitTest
ing
.
Result
=
function
(
position
,
quaternion
,
scale
){
this
.
position
=
position
this
.
quaternion
=
quaternion
this
.
scale
=
scale
...
...
three.js/src/new-api/arjs-session.js
浏览文件 @
e7c92df1
...
...
@@ -7,11 +7,59 @@ var ARjs = ARjs || {}
*/
ARjs
.
Session
=
function
(
parameters
){
var
_this
=
this
// handle default parameters
this
.
parameters
=
{
renderer
:
null
,
camera
:
null
,
scene
:
null
,
sourceParameters
:
{},
contextParameters
:
{},
}
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters
(
parameters
)
function
setParameters
(
parameters
){
if
(
parameters
===
undefined
)
return
for
(
var
key
in
parameters
){
var
newValue
=
parameters
[
key
]
if
(
newValue
===
undefined
){
console
.
warn
(
"
THREEx.Session: '
"
+
key
+
"
' parameter is undefined.
"
)
continue
}
var
currentValue
=
_this
.
parameters
[
key
]
if
(
currentValue
===
undefined
){
console
.
warn
(
"
THREEx.Session: '
"
+
key
+
"
' is not a property of this material.
"
)
continue
}
_this
.
parameters
[
key
]
=
newValue
}
}
// sanity check
console
.
assert
(
this
.
parameters
.
renderer
instanceof
THREE
.
WebGLRenderer
)
console
.
assert
(
this
.
parameters
.
camera
instanceof
THREE
.
Camera
)
console
.
assert
(
this
.
parameters
.
scene
instanceof
THREE
.
Scene
)
// backward emulation
Object
.
defineProperty
(
this
,
'
renderer
'
,
{
get
:
function
(){
console
.
warn
(
'
use .parameters.renderer renderer
'
)
return
this
.
parameters
.
renderer
;
}});
Object
.
defineProperty
(
this
,
'
camera
'
,
{
get
:
function
(){
console
.
warn
(
'
use .parameters.camera instead
'
)
return
this
.
parameters
.
camera
;
}});
Object
.
defineProperty
(
this
,
'
scene
'
,
{
get
:
function
(){
console
.
warn
(
'
use .parameters.scene instead
'
)
return
this
.
parameters
.
scene
;
}});
// TODO change that to a usual this.parameters
this
.
renderer
=
parameters
.
renderer
this
.
camera
=
parameters
.
camera
this
.
scene
=
parameters
.
scene
// log the version
console
.
log
(
'
AR.js
'
,
ARjs
.
Context
.
REVISION
,
'
- trackingBackend:
'
,
parameters
.
contextParameters
.
trackingBackend
)
...
...
@@ -22,12 +70,12 @@ ARjs.Session = function(parameters){
var
arSource
=
_this
.
arSource
=
new
ARjs
.
Source
(
parameters
.
sourceParameters
)
arSource
.
init
(
function
onReady
(){
arSource
.
onResize
(
arContext
,
_this
.
renderer
,
_thi
s
.
camera
)
arSource
.
onResize
(
arContext
,
_this
.
parameters
.
renderer
,
_this
.
parameter
s
.
camera
)
})
// handle resize
window
.
addEventListener
(
'
resize
'
,
function
(){
arSource
.
onResize
(
arContext
,
_this
.
renderer
,
_thi
s
.
camera
)
arSource
.
onResize
(
arContext
,
_this
.
parameters
.
renderer
,
_this
.
parameter
s
.
camera
)
})
//////////////////////////////////////////////////////////////////////////////
...
...
@@ -41,7 +89,7 @@ ARjs.Session = function(parameters){
_this
.
arContext
.
init
()
arContext
.
addEventListener
(
'
initialized
'
,
function
(
event
){
arSource
.
onResize
(
arContext
,
_this
.
renderer
,
_thi
s
.
camera
)
arSource
.
onResize
(
arContext
,
_this
.
parameters
.
renderer
,
_this
.
parameter
s
.
camera
)
})
//////////////////////////////////////////////////////////////////////////////
...
...
@@ -56,5 +104,5 @@ ARjs.Session = function(parameters){
}
ARjs
.
Session
.
prototype
.
onResize
=
function
()
{
this
.
arSource
.
onResize
(
this
.
arContext
,
this
.
renderer
,
thi
s
.
camera
)
this
.
arSource
.
onResize
(
this
.
arContext
,
this
.
parameters
.
renderer
,
this
.
parameter
s
.
camera
)
};
three.js/src/threex/threex-arclickability.js
浏览文件 @
e7c92df1
var
THREEx
=
THREEx
||
{}
// TODO this is useless - prefere arjs-
hittester
.js
// TODO this is useless - prefere arjs-
HitTesting
.js
/**
* - maybe support .onClickFcts in each object3d
...
...
@@ -15,7 +15,7 @@ THREEx.ARClickability = function(sourceElement){
this
.
_cameraPicking
=
new
THREE
.
PerspectiveCamera
(
42
,
fullWidth
/
fullHeight
,
0.1
,
100
);
console
.
warn
(
'
THREEx.ARClickability works only in modelViewMatrix
'
)
console
.
warn
(
'
OBSOLETE OBSOLETE! instead use THREEx.HitTest
erPlane or THREEx.HitTester
Tango
'
)
console
.
warn
(
'
OBSOLETE OBSOLETE! instead use THREEx.HitTest
ingPlane or THREEx.HitTesting
Tango
'
)
}
THREEx
.
ARClickability
.
prototype
.
onResize
=
function
(){
...
...
@@ -55,7 +55,7 @@ THREEx.ARClickability.prototype.update = function(){
THREEx
.
ARClickability
.
tangoPickingPointCloud
=
function
(
artoolkitContext
,
mouseX
,
mouseY
){
// THIS IS CRAP!!!! use THREEx.HitTest
er
Tango
// THIS IS CRAP!!!! use THREEx.HitTest
ing
Tango
var
vrDisplay
=
artoolkitContext
.
_tangoContext
.
vrDisplay
if
(
vrDisplay
===
null
)
return
null
...
...
three.js/src/threex/threex-armarkercontrols.js
浏览文件 @
e7c92df1
...
...
@@ -59,6 +59,9 @@ THREEx.ArMarkerControls = function(context, object3d, parameters){
}
}
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
// add this marker to artoolkitsystem
// TODO rename that .addMarkerControls
context
.
addMarker
(
this
)
...
...
three.js/src/threex/threex-hittest
er
-plane.js
→
three.js/src/threex/threex-hittest
ing
-plane.js
浏览文件 @
e7c92df1
var
THREEx
=
THREEx
||
{}
// TODO this is useless - prefere arjs-
hittester
.js
// TODO this is useless - prefere arjs-
HitTesting
.js
/**
* - maybe support .onClickFcts in each object3d
* - seems an easy light layer for clickable object
* - up to
*/
THREEx
.
HitTest
er
Plane
=
function
(
sourceElement
){
THREEx
.
HitTest
ing
Plane
=
function
(
sourceElement
){
this
.
_sourceElement
=
sourceElement
// create _pickingScene
...
...
@@ -36,7 +36,7 @@ THREEx.HitTesterPlane = function(sourceElement){
// update function
//////////////////////////////////////////////////////////////////////////////
THREEx
.
HitTest
er
Plane
.
prototype
.
update
=
function
(
camera
,
pickingRoot
,
changeMatrixMode
){
THREEx
.
HitTest
ing
Plane
.
prototype
.
update
=
function
(
camera
,
pickingRoot
,
changeMatrixMode
){
this
.
onResize
()
...
...
@@ -69,7 +69,7 @@ THREEx.HitTesterPlane.prototype.update = function(camera, pickingRoot, changeMat
// resize camera
//////////////////////////////////////////////////////////////////////////////
THREEx
.
HitTest
er
Plane
.
prototype
.
onResize
=
function
(){
THREEx
.
HitTest
ing
Plane
.
prototype
.
onResize
=
function
(){
var
sourceElement
=
this
.
_sourceElement
var
pickingCamera
=
this
.
_pickingCamera
...
...
@@ -85,7 +85,7 @@ THREEx.HitTesterPlane.prototype.onResize = function(){
//////////////////////////////////////////////////////////////////////////////
// Perform test
//////////////////////////////////////////////////////////////////////////////
THREEx
.
HitTest
er
Plane
.
prototype
.
test
=
function
(
mouseX
,
mouseY
){
THREEx
.
HitTest
ing
Plane
.
prototype
.
test
=
function
(
mouseX
,
mouseY
){
// convert mouseX, mouseY to [-1, +1]
mouseX
=
(
mouseX
-
0.5
)
*
2
mouseY
=-
(
mouseY
-
0.5
)
*
2
...
...
@@ -117,7 +117,7 @@ THREEx.HitTesterPlane.prototype.test = function(mouseX, mouseY){
// render the pickingPlane for debug
//////////////////////////////////////////////////////////////////////////////
THREEx
.
HitTest
er
Plane
.
prototype
.
renderDebug
=
function
(
renderer
){
THREEx
.
HitTest
ing
Plane
.
prototype
.
renderDebug
=
function
(
renderer
){
// render sceneOrtho
renderer
.
render
(
this
.
_pickingScene
,
this
.
_pickingCamera
)
}
three.js/src/threex/threex-hittest
er
-tango.js
→
three.js/src/threex/threex-hittest
ing
-tango.js
浏览文件 @
e7c92df1
...
...
@@ -5,7 +5,7 @@ var THREEx = THREEx || {}
*
* @return {[type]} [description]
*/
THREEx
.
HitTest
er
Tango
=
function
(
arContext
){
THREEx
.
HitTest
ing
Tango
=
function
(
arContext
){
this
.
_arContext
=
arContext
// seems to be the object bounding sphere for picking
this
.
boundingSphereRadius
=
0.01
...
...
@@ -17,7 +17,7 @@ THREEx.HitTesterTango = function(arContext){
// update function
//////////////////////////////////////////////////////////////////////////////
THREEx
.
HitTest
er
Tango
.
prototype
.
update
=
function
(){
THREEx
.
HitTest
ing
Tango
.
prototype
.
update
=
function
(){
}
//////////////////////////////////////////////////////////////////////////////
...
...
@@ -31,7 +31,7 @@ THREEx.HitTesterTango.prototype.update = function(){
* @param {Numer} mouseY - mouse y coordinate in [0, 1]
* @return {Object} - result
*/
THREEx
.
HitTest
er
Tango
.
prototype
.
test
=
function
(
mouseX
,
mouseY
){
THREEx
.
HitTest
ing
Tango
.
prototype
.
test
=
function
(
mouseX
,
mouseY
){
var
vrDisplay
=
this
.
_arContext
.
_tangoContext
.
vrDisplay
if
(
vrDisplay
===
null
)
return
null
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录