Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cqiang1993
AR.js
提交
a952ca59
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,发现更多精彩内容 >>
提交
a952ca59
编写于
2月 25, 2017
作者:
J
Jerome Etienne
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
first version of profile
上级
4d089dcf
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
266 addition
and
79 deletion
+266
-79
README.md
README.md
+3
-0
three.js/examples/dev.html
three.js/examples/dev.html
+7
-1
three.js/examples/profile.html
three.js/examples/profile.html
+164
-0
three.js/threex-artoolkitcontext.js
three.js/threex-artoolkitcontext.js
+1
-1
three.js/threex-artoolkitprofile.js
three.js/threex-artoolkitprofile.js
+91
-77
未找到文件。
README.md
浏览文件 @
a952ca59
...
...
@@ -87,6 +87,9 @@ Three.js Examples:
-
[
mobile-performance
](
https://jeromeetienne.github.io/AR.js/three.js/examples/mobile-performance.html
)
:
three.js example for mobile-performance
(
[
source
](
https://github.com/jeromeetienne/AR.js/blob/master/three.js/examples/mobile-performance.html
)
)
-
[
profile
](
https://jeromeetienne.github.io/AR.js/three.js/examples/profile.html
)
:
three.js example for artoolkit-profile
(
[
source
](
https://github.com/jeromeetienne/AR.js/blob/master/three.js/examples/profile.html
)
)
a-frame Examples:
...
...
three.js/examples/dev.html
浏览文件 @
a952ca59
...
...
@@ -60,7 +60,13 @@
////////////////////////////////////////////////////////////////////////////////
var
artoolkitProfile
=
new
THREEx
.
ArToolkitProfile
(
'
guess
'
)
var
artoolkitProfile
=
new
THREEx
.
ArToolkitProfile
()
// artoolkitProfile.sourceWebcam().hiroMarker();
artoolkitProfile
.
sourceVideo
(
'
../../data/videos/headtracking.mp4
'
).
kanjiMarker
();
// artoolkitProfile.sourceImage('../../data/images/img.jpg').hiroMarker();
artoolkitProfile
.
performance
(
'
slow
'
);
var
arToolkitSource
=
new
THREEx
.
ArToolkitSource
(
artoolkitProfile
.
sourceParameters
)
...
...
three.js/examples/profile.html
0 → 100644
浏览文件 @
a952ca59
<!DOCTYPE html>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
>
<!-- three.js library -->
<script
src=
'vendor/three.js/build/three.js'
></script>
<script
src=
"vendor/three.js/examples/js/libs/stats.min.js"
></script>
<!-- jsartookit -->
<script
src=
"../vendor/jsartoolkit5/build/artoolkit.min.js"
></script>
<script
src=
"../vendor/jsartoolkit5/js/artoolkit.api.js"
></script>
<!-- include threex.artoolkit -->
<script
src=
"../threex-artoolkitsource.js"
></script>
<script
src=
"../threex-artoolkitcontext.js"
></script>
<script
src=
"../threex-artoolkitprofile.js"
></script>
<script
src=
"../threex-armarkercontrols.js"
></script>
<body
style=
'margin : 0px; overflow: hidden;'
><div
style=
'position: absolute; top: 10px; width:100%; text-align: center;'
;
>
<a
href=
"https://github.com/jeromeetienne/AR.js/"
target=
"_blank"
>
AR.js
</a>
- developement playground
<br/>
Contact me any time at
<a
href=
'https://twitter.com/jerome_etienne'
target=
'_blank'
>
@jerome_etienne
</a>
</div><script>
//////////////////////////////////////////////////////////////////////////////////
// Init
//////////////////////////////////////////////////////////////////////////////////
// init renderer
var
renderer
=
new
THREE
.
WebGLRenderer
({
// antialias : true,
alpha
:
true
});
renderer
.
setClearColor
(
new
THREE
.
Color
(
'
lightgrey
'
),
0
)
// renderer.setPixelRatio( 2 );
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
renderer
.
domElement
.
style
.
position
=
'
absolute
'
renderer
.
domElement
.
style
.
top
=
'
0px
'
renderer
.
domElement
.
style
.
left
=
'
0px
'
document
.
body
.
appendChild
(
renderer
.
domElement
);
// array of functions for the rendering loop
var
onRenderFcts
=
[];
// init scene and camera
var
scene
=
new
THREE
.
Scene
();
var
ambient
=
new
THREE
.
AmbientLight
(
0x666666
);
scene
.
add
(
ambient
);
var
directionalLight
=
new
THREE
.
DirectionalLight
(
0x887766
);
directionalLight
.
position
.
set
(
-
1
,
1
,
1
).
normalize
();
scene
.
add
(
directionalLight
);
//////////////////////////////////////////////////////////////////////////////////
// Initialize a basic camera
//////////////////////////////////////////////////////////////////////////////////
// Create a camera
var
camera
=
new
THREE
.
Camera
();
scene
.
add
(
camera
);
////////////////////////////////////////////////////////////////////////////////
// handle arToolkitSource
////////////////////////////////////////////////////////////////////////////////
var
artoolkitProfile
=
new
THREEx
.
ArToolkitProfile
()
artoolkitProfile
.
sourceWebcam
().
hiroMarker
()
artoolkitProfile
.
performance
(
'
desktop-fast
'
)
// artoolkitProfile.sourceVideo('../../data/videos/headtracking.mp4').kanjiMarker();
// artoolkitProfile.sourceImage('../../data/images/img.jpg').hiroMarker()
// artoolkitProfile.discoverPerformance()
// artoolkitProfile.discoverPerformance()
var
arToolkitSource
=
new
THREEx
.
ArToolkitSource
(
artoolkitProfile
.
sourceParameters
)
arToolkitSource
.
init
(
function
onReady
(){
// handle resize of renderer
arToolkitSource
.
onResize
(
renderer
.
domElement
)
})
// handle resize
window
.
addEventListener
(
'
resize
'
,
function
(){
// handle arToolkitSource resize
arToolkitSource
.
onResize
(
renderer
.
domElement
)
})
////////////////////////////////////////////////////////////////////////////////
// initialize arToolkitContext
////////////////////////////////////////////////////////////////////////////////
// create atToolkitContext
var
arToolkitContext
=
new
THREEx
.
ArToolkitContext
(
artoolkitProfile
.
contextParameters
)
// initialize it
arToolkitContext
.
init
(
function
onCompleted
(){
// copy projection matrix to camera
var
projectionMatrix
=
arToolkitContext
.
arController
.
getCameraMatrix
();
camera
.
projectionMatrix
.
fromArray
(
projectionMatrix
);
})
// update artoolkit on every frame
onRenderFcts
.
push
(
function
(){
if
(
arToolkitSource
.
ready
===
false
)
return
arToolkitContext
.
update
(
arToolkitSource
.
domElement
)
})
////////////////////////////////////////////////////////////////////////////////
// Create a ArMarkerControls
////////////////////////////////////////////////////////////////////////////////
var
markerRoot
=
new
THREE
.
Group
scene
.
add
(
markerRoot
)
var
artoolkitMarker
=
new
THREEx
.
ArMarkerControls
(
arToolkitContext
,
markerRoot
,
artoolkitProfile
.
defaultMarkerParameters
)
//////////////////////////////////////////////////////////////////////////////////
// add an object in the scene
//////////////////////////////////////////////////////////////////////////////////
// add a torus knot
var
geometry
=
new
THREE
.
CubeGeometry
(
1
,
1
,
1
);
var
material
=
new
THREE
.
MeshNormalMaterial
({
transparent
:
true
,
opacity
:
0.5
,
side
:
THREE
.
DoubleSide
});
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
position
.
z
=
geometry
.
parameters
.
height
/
2
markerRoot
.
add
(
mesh
);
var
geometry
=
new
THREE
.
TorusKnotGeometry
(
0.3
,
0.1
,
32
,
32
);
var
material
=
new
THREE
.
MeshNormalMaterial
();
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
position
.
z
=
0.5
markerRoot
.
add
(
mesh
);
onRenderFcts
.
push
(
function
(){
mesh
.
rotation
.
x
+=
0.1
})
//////////////////////////////////////////////////////////////////////////////////
// render the whole thing on the page
//////////////////////////////////////////////////////////////////////////////////
var
stats
=
new
Stats
();
document
.
body
.
appendChild
(
stats
.
dom
);
// render the scene
onRenderFcts
.
push
(
function
(){
renderer
.
render
(
scene
,
camera
);
// stats.update();
})
// run the rendering loop
var
lastTimeMsec
=
null
requestAnimationFrame
(
function
animate
(
nowMsec
){
// keep looping
requestAnimationFrame
(
animate
);
// measure time
lastTimeMsec
=
lastTimeMsec
||
nowMsec
-
1000
/
60
var
deltaMsec
=
Math
.
min
(
200
,
nowMsec
-
lastTimeMsec
)
lastTimeMsec
=
nowMsec
// call each update function
onRenderFcts
.
forEach
(
function
(
onRenderFct
){
onRenderFct
(
deltaMsec
/
1000
,
nowMsec
/
1000
)
})
})
</script></body>
three.js/threex-artoolkitcontext.js
浏览文件 @
a952ca59
...
...
@@ -44,7 +44,7 @@ THREEx.ArToolkitContext.prototype.init = function(onCompleted){
var
sourceWidth
=
this
.
parameters
.
sourceWidth
var
sourceHeight
=
this
.
parameters
.
sourceHeight
console
.
log
(
'
ArToolkitContext: _onSourceReady width
'
,
sourceWidth
,
'
height
'
,
sourceHeight
)
//
console.log('ArToolkitContext: _onSourceReady width', sourceWidth, 'height', sourceHeight)
_this
.
_cameraParameters
=
new
ARCameraParam
(
_this
.
parameters
.
cameraParametersUrl
,
function
()
{
// init controller
var
arController
=
new
ARController
(
sourceWidth
,
sourceHeight
,
_this
.
_cameraParameters
);
...
...
three.js/threex-artoolkitprofile.js
浏览文件 @
a952ca59
var
THREEx
=
THREEx
||
{}
/**
* TODO
* - .setMarkerHiro()
* - .setMarkerKanji()
* - .setSourceWebcam()
* - .setSourceVideo(url)
* - .setSourceImage(url)
* - .setPerformance()
*/
THREEx
.
ArToolkitProfile
=
function
(
label
){
if
(
label
===
'
guess
'
)
label
=
this
.
_guessLabel
()
this
.
reset
()
this
.
setProfile
(
label
)
}
THREEx
.
ArToolkitProfile
.
prototype
.
reset
=
function
()
{
this
.
sourceParameters
=
{}
this
.
contextParameters
=
{}
this
.
defaultMarkerParameters
=
{}
};
THREEx
.
ArToolkitProfile
.
prototype
.
_guessLabel
=
function
()
{
// TODO implement this
return
'
desktop
'
};
THREEx
.
ArToolkitProfile
=
function
(){
this
.
reset
().
discoverPerformance
()
}
THREEx
.
ArToolkitProfile
.
prototype
.
setProfile
=
function
(
label
)
{
if
(
'
desktop
'
){
this
.
desktopProfile
()
}
else
if
(
'
mobile
'
){
this
.
mobileProfile
()
}
else
console
.
assert
(
'
false
'
)
};
THREEx
.
ArToolkitProfile
.
prototype
.
desktopProfile
=
function
()
{
THREEx
.
ArToolkitProfile
.
prototype
.
reset
=
function
()
{
this
.
sourceParameters
=
{
// to read from the webcam
sourceType
:
'
webcam
'
,
// to read from an image
// sourceType : 'image',
// sourceUrl : '../../data/images/img.jpg',
// to read from a video
// sourceType : 'video',
// sourceUrl : '../../data/videos/headtracking.mp4',
// sourceWidth: 80*3,
// sourceHeight: 60*3,
//
}
this
.
contextParameters
=
{
cameraParametersUrl
:
THREEx
.
ArToolkitContext
.
baseURL
+
'
../data/data/camera_para.dat
'
,
detectionMode
:
'
mono
'
,
maxDetectionRate
:
30
,
}
this
.
defaultMarkerParameters
=
{
type
:
'
pattern
'
,
// patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.hiro'
patternUrl
:
THREEx
.
ArToolkitContext
.
baseURL
+
'
../data/data/patt.kanji
'
patternUrl
:
THREEx
.
ArToolkitContext
.
baseURL
+
'
../data/data/patt.hiro
'
}
}
return
this
};
THREEx
.
ArToolkitProfile
.
prototype
.
mobileProfile
=
function
()
{
this
.
sourceParameters
=
{
// to read from the webcam
sourceType
:
'
webcam
'
,
// to read from an image
// sourceType : 'image',
// sourceUrl : '../../data/images/img.jpg',
// to read from a video
// sourceType : 'video',
// sourceUrl : '../../data/videos/headtracking.mp4',
sourceWidth
:
80
*
3
,
sourceHeight
:
60
*
3
,
//
}
//////////////////////////////////////////////////////////////////////////////
// Performance
//////////////////////////////////////////////////////////////////////////////
this
.
contextParameters
=
{
cameraParametersUrl
:
THREEx
.
ArToolkitContext
.
baseURL
+
'
../data/data/camera_para.dat
'
,
detectionMode
:
'
mono
'
,
maxDetectionRate
:
30
,
sourceWidth
:
this
.
sourceParameters
.
sourceWidth
,
sourceHeight
:
this
.
sourceParameters
.
sourceHeight
,
THREEx
.
ArToolkitProfile
.
prototype
.
discoverPerformance
=
function
()
{
var
isMobile
=
navigator
.
userAgent
.
match
(
/Android/i
)
||
navigator
.
userAgent
.
match
(
/webOS/i
)
||
navigator
.
userAgent
.
match
(
/iPhone/i
)
||
navigator
.
userAgent
.
match
(
/iPad/i
)
||
navigator
.
userAgent
.
match
(
/iPod/i
)
||
navigator
.
userAgent
.
match
(
/BlackBerry/i
)
||
navigator
.
userAgent
.
match
(
/Windows Phone/i
)
?
true
:
false
if
(
isMobile
===
true
){
this
.
performance
(
'
phone-normal
'
)
}
else
{
this
.
performance
(
'
desktop-normal
'
)
}
this
.
defaultMarkerParameters
=
{
type
:
'
pattern
'
,
// patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.hiro'
patternUrl
:
THREEx
.
ArToolkitContext
.
baseURL
+
'
../data/data/patt.kanji
'
}
THREEx
.
ArToolkitProfile
.
prototype
.
performance
=
function
(
label
)
{
if
(
label
===
'
desktop-fast
'
){
this
.
sourceParameters
.
sourceWidth
=
640
*
2
this
.
sourceParameters
.
sourceWidth
=
480
*
2
this
.
contextParameters
.
maxDetectionRate
=
60
}
else
if
(
label
===
'
desktop-normal
'
){
this
.
sourceParameters
.
sourceWidth
=
640
this
.
sourceParameters
.
sourceWidth
=
480
this
.
contextParameters
.
maxDetectionRate
=
60
}
else
if
(
label
===
'
phone-normal
'
){
this
.
sourceParameters
.
sourceWidth
=
240
this
.
sourceParameters
.
sourceWidth
=
180
this
.
contextParameters
.
maxDetectionRate
=
30
}
else
if
(
label
===
'
phone-slow
'
){
this
.
sourceParameters
.
sourceWidth
=
240
this
.
sourceParameters
.
sourceWidth
=
180
this
.
contextParameters
.
maxDetectionRate
=
15
}
else
{
console
.
assert
(
false
,
'
unknonwn label
'
+
label
)
}
this
.
contextParameters
.
sourceWidth
=
this
.
sourceParameters
.
sourceWidth
this
.
contextParameters
.
sourceHeight
=
this
.
sourceParameters
.
sourceHeight
}
//////////////////////////////////////////////////////////////////////////////
// Marker
//////////////////////////////////////////////////////////////////////////////
THREEx
.
ArToolkitProfile
.
prototype
.
kanjiMarker
=
function
()
{
this
.
contextParameters
.
detectionMode
=
'
mono
'
this
.
defaultMarkerParameters
.
type
=
'
pattern
'
this
.
defaultMarkerParameters
.
patternUrl
=
THREEx
.
ArToolkitContext
.
baseURL
+
'
../data/data/patt.kanji
'
return
this
}
THREEx
.
ArToolkitProfile
.
prototype
.
hiroMarker
=
function
()
{
this
.
contextParameters
.
detectionMode
=
'
mono
'
this
.
defaultMarkerParameters
.
type
=
'
pattern
'
this
.
defaultMarkerParameters
.
patternUrl
=
THREEx
.
ArToolkitContext
.
baseURL
+
'
../data/data/patt.hiro
'
return
this
}
//////////////////////////////////////////////////////////////////////////////
// Source
//////////////////////////////////////////////////////////////////////////////
THREEx
.
ArToolkitProfile
.
prototype
.
sourceWebcam
=
function
()
{
this
.
sourceParameters
.
sourceType
=
'
webcam
'
delete
this
.
sourceParameters
.
sourceUrl
return
this
}
THREEx
.
ArToolkitProfile
.
prototype
.
sourceVideo
=
function
(
url
)
{
this
.
sourceParameters
.
sourceType
=
'
video
'
this
.
sourceParameters
.
sourceUrl
=
url
return
this
}
THREEx
.
ArToolkitProfile
.
prototype
.
sourceImage
=
function
(
url
)
{
this
.
sourceParameters
.
sourceType
=
'
image
'
this
.
sourceParameters
.
sourceUrl
=
url
return
this
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录