Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cqiang1993
AR.js
提交
63242551
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,发现更多精彩内容 >>
提交
63242551
编写于
7月 29, 2017
作者:
J
Jerome Etienne
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more work
上级
e90356f0
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
848 addition
and
206 deletion
+848
-206
TODO.md
TODO.md
+29
-17
aframe/Makefile
aframe/Makefile
+1
-13
aframe/build/aframe-ar.js
aframe/build/aframe-ar.js
+509
-44
aframe/build/aframe-ar.min.js
aframe/build/aframe-ar.min.js
+4
-4
aframe/examples/aframe-session.html
aframe/examples/aframe-session.html
+6
-6
three.js/build/ar.js
three.js/build/ar.js
+80
-44
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
+11
-12
three.js/src/newAPI/arjs-anchor.js
three.js/src/newAPI/arjs-anchor.js
+10
-3
three.js/src/newAPI/arjs-hittester.js
three.js/src/newAPI/arjs-hittester.js
+30
-15
three.js/threex-hittester-plane.js
three.js/threex-hittester-plane.js
+51
-0
three.js/threex-hittester-tango.js
three.js/threex-hittester-tango.js
+33
-0
webvr-polyfill/build/artoolkit-webvr-polyfill.js
webvr-polyfill/build/artoolkit-webvr-polyfill.js
+80
-44
webvr-polyfill/build/artoolkit-webvr-polyfill.min.js
webvr-polyfill/build/artoolkit-webvr-polyfill.min.js
+2
-2
未找到文件。
TODO.md
浏览文件 @
63242551
## New API - aframe
## New API - aframe
-
honor marker preset
-
honor marker preset
-
artoolkit modelViewMatrix/cameraTransformMatrix works
-
artoolkit modelViewMatrix/cameraTransformMatrix works
-
area-artoolkit fails in cameraTransformMatrix
-
put multi-markers in /src/markers-area
-
wtf ??? so issue upstream ? how to reproduce in three.js
-
/examples/markers-area/ - here all the examples
-
put marker page in this directory too
-
aruco got perspective issue - likely camera init
-
three.js/examples/multi-markers/
\*
.js in /src/markers-area
-
refactor threex-screenasportal as a demo in /examples/markers-area/demo-screen-as-portal
-
this is not a threex
-
tango video fails
-
tango video fails
-
some post processing in aframe.js - https://github.com/wizgrav/aframe-effects/blob/master/systems/effects.js
-
some post processing in aframe.js - https://github.com/wizgrav/aframe-effects/blob/master/systems/effects.js
-
it seems to override renderer.render by its own function... not super clean but if it works ok
-
it seems to override renderer.render by its own function... not super clean but if it works ok
-
it can be changed later
-
it can be changed later
-
tango tracking is working ? i think so
-
tango tracking is working ? i think so
-
test in both mode
-
test in both mode
-
tracking only tho, clearly no video
-
tracking only tho, clearly no video
-
DONE remove arSession.onResize2() - thus the API is cleaner
-
LATER aruco got perspective issue - likely camera init
-
do a onResize with a test on argument.length - if not good number call old stuff
-
DONE put the UI in the plugin
-
do a special function for it, and call this function from javascript
-
or more like a data in the system
## New API
## New API
-
build a aframe version of that to see how it fit
-
clickability works IIF changeMatrixMode === modelViewMatrix
-
when api is stable enougth ?
-
change that
-
when all the bugs are sorted out
-
not a bug, it is just not implemented
-
currently only something about displaying point cloud in tango - very minor
-
arjs-hittester and threex-arclickability are messy
-
clean those 2. no need for 2 class ?
-
which API will remain
-
hittester-plane
-
hittester-tango
-
replace ARClickability with something better and port arjs-hittester on top
-
Check it works on all cases
-
Check it works on all cases
-
no special cases incompatibilities
-
no special cases incompatibilities
-
changeMatrixMode
-
changeMatrixMode
-
tango point cloud fails in cameraTransformMatrix
-
tango point cloud fails in cameraTransformMatrix
-
move three.js/arjs-.js in three.js/src/newApi/
-
later rename file/class
-
later rename file/class
-
move all THREEx for ar.js as ARjs.
-
move all THREEx for ar.js as ARjs.
-
remove artoolkit in the name when it is multi backend
-
remove artoolkit in the name when it is multi backend
...
@@ -53,6 +54,17 @@
...
@@ -53,6 +54,17 @@
-
arkit
-
arkit
-
best
-
best
-
DONE area-artoolkit fails in cameraTransformMatrix
-
wtf ??? so issue upstream ? how to reproduce in three.js
-
is the error in three.js level, or aframe level
-
apparently setting cameraTransformMatrix or modelViewMatrix in changeMatrixMode doesnt change a thing in area-artoolkit
-
area-artoolkit seems to react as if it was always modelViewMatrix
-
DONE remove arSession.onResize2() - thus the API is cleaner
-
do a onResize with a test on argument.length - if not good number call old stuff
-
DONE put the UI in the plugin
-
do a special function for it, and call this function from javascript
-
or more like a data in the system
-
DONE move three.js/arjs-.js in three.js/src/newApi/
-
DONE pick real world with all trackingMethod
-
DONE pick real world with all trackingMethod
-
hit tester with plane
-
hit tester with plane
-
DONE button tangoonly pointcloudtoggle
-
DONE button tangoonly pointcloudtoggle
...
...
aframe/Makefile
浏览文件 @
63242551
...
@@ -5,6 +5,7 @@ watch: build
...
@@ -5,6 +5,7 @@ watch: build
build
:
build
:
cat
../three.js/threex
*
.js
\
cat
../three.js/threex
*
.js
\
../three.js/examples/multi-markers/threex
*
.js
\
../three.js/examples/multi-markers/threex
*
.js
\
../three.js/src/newAPI/
*
.js
\
aframe-ar.js
\
aframe-ar.js
\
../three.js/vendor/jsartoolkit5/build/artoolkit.min.js
\
../three.js/vendor/jsartoolkit5/build/artoolkit.min.js
\
../three.js/vendor/jsartoolkit5/js/artoolkit.api.js
\
../three.js/vendor/jsartoolkit5/js/artoolkit.api.js
\
...
@@ -12,16 +13,3 @@ build:
...
@@ -12,16 +13,3 @@ build:
minify
:
build
minify
:
build
uglifyjs build/aframe-ar.js
>
build/aframe-ar.min.js
uglifyjs build/aframe-ar.js
>
build/aframe-ar.min.js
#####
build0
:
cat
../three.js/threex
*
.js
\
../three.js/examples/multi-markers/threex
*
.js
\
aframe-ar.js
\
../three.js/vendor/jsartoolkit5/build/artoolkit.min.js
\
../three.js/vendor/jsartoolkit5/js/artoolkit.api.js
\
>
build/aframe-ar0.js
minify0
:
build0
uglifyjs build/aframe-ar0.js
>
build/aframe-ar0.min.js
aframe/build/aframe-ar.js
浏览文件 @
63242551
此差异已折叠。
点击以展开。
aframe/build/aframe-ar.min.js
浏览文件 @
63242551
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
aframe/examples/aframe-session.html
浏览文件 @
63242551
...
@@ -62,17 +62,17 @@
...
@@ -62,17 +62,17 @@
</div>
</div>
<!-- artoolkit modelViewMatrix : OK -->
<!-- artoolkit modelViewMatrix : OK -->
<
!-- <
a-scene embedded arjs='trackingMethod: area-artoolkit; debugUIEnabled: true;'>
<a-scene
embedded
arjs=
'trackingMethod: area-artoolkit; debugUIEnabled: true;'
>
<a-marker>
<a-marker
preset=
'area'
>
<a-box
position=
'0 0.5 0'
material=
'opacity: 0.5; side:double; color:red;'
></a-box>
<a-box
position=
'0 0.5 0'
material=
'opacity: 0.5; side:double; color:red;'
></a-box>
</a-marker>
</a-marker>
<a-entity
camera
></a-entity>
<a-entity
camera
></a-entity>
</a-scene>
-->
</a-scene>
<!-- artoolkit cameraTransformMatrix : OK -->
<!-- artoolkit cameraTransformMatrix : OK -->
<!-- <a-scene embedded arjs='trackingMethod: area-artoolkit; debugUIEnabled: true;'>
<!-- <a-scene embedded arjs='trackingMethod: area-artoolkit; debugUIEnabled: true;'>
<a-box position='0 0.5 0' material='opacity: 0.5; side:double; color:red;'></a-box>
<a-box position='0 0.5 0' material='opacity: 0.5; side:double; color:red;'></a-box>
<a-marker-camera preset='
hiro
'></a-marker-camera>
<a-marker-camera preset='
area
'></a-marker-camera>
</a-scene> -->
</a-scene> -->
<!-- artoolkit cameraTransformMatrix : FAILS -->
<!-- artoolkit cameraTransformMatrix : FAILS -->
...
@@ -87,11 +87,11 @@
...
@@ -87,11 +87,11 @@
<a-marker-camera></a-marker-camera>
<a-marker-camera></a-marker-camera>
</a-scene> -->
</a-scene> -->
<a-scene
embedded
arjs=
'trackingMethod: tango'
>
<
!-- <
a-scene embedded arjs='trackingMethod: tango'>
<a-marker>
<a-marker>
<a-box position='0 0.5 0' material='opacity: 0.5; side:double; color:red;'></a-box>
<a-box position='0 0.5 0' material='opacity: 0.5; side:double; color:red;'></a-box>
</a-marker>
</a-marker>
<a-entity camera></a-entity>
<a-entity camera></a-entity>
</a-scene>
</a-scene>
-->
</body>
</body>
</html>
</html>
three.js/build/ar.js
浏览文件 @
63242551
...
@@ -2389,9 +2389,10 @@ THREEx.ArSmoothedControls.prototype.update = function(targetObject3d){
...
@@ -2389,9 +2389,10 @@ THREEx.ArSmoothedControls.prototype.update = function(targetObject3d){
object3d.scale.lerp(targetObject3d.scale, parameters.lerpScale)
object3d.scale.lerp(targetObject3d.scale, parameters.lerpScale)
}
}
}
}
var ARjs = ARjs || {}
var THREEx = THREEx || {}
var THREEx = THREEx || {}
THREEx.ArToolkitContext = function(parameters){
ARjs.Context =
THREEx.ArToolkitContext = function(parameters){
var _this = this
var _this = this
_this._updatedAt = null
_this._updatedAt = null
...
@@ -2408,7 +2409,7 @@ THREEx.ArToolkitContext = function(parameters){
...
@@ -2408,7 +2409,7 @@ THREEx.ArToolkitContext = function(parameters){
matrixCodeType: '3x3',
matrixCodeType: '3x3',
// url of the camera parameters
// url of the camera parameters
cameraParametersUrl:
THREEx.ArToolkit
Context.baseURL + 'parameters/camera_para.dat',
cameraParametersUrl:
ARjs.
Context.baseURL + 'parameters/camera_para.dat',
// tune the maximum rate of pose detection in the source image
// tune the maximum rate of pose detection in the source image
maxDetectionRate: 60,
maxDetectionRate: 60,
...
@@ -2458,12 +2459,12 @@ THREEx.ArToolkitContext = function(parameters){
...
@@ -2458,12 +2459,12 @@ THREEx.ArToolkitContext = function(parameters){
}
}
}
}
Object.assign(
THREEx.ArToolkit
Context.prototype, THREE.EventDispatcher.prototype );
Object.assign(
ARjs.
Context.prototype, THREE.EventDispatcher.prototype );
//
THREEx.ArToolkit
Context.baseURL = '../'
//
ARjs.
Context.baseURL = '../'
// default to github page
// default to github page
THREEx.ArToolkit
Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/'
ARjs.
Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/'
THREEx.ArToolkit
Context.REVISION = '1.0.1-dev'
ARjs.
Context.REVISION = '1.0.1-dev'
...
@@ -2472,7 +2473,7 @@ THREEx.ArToolkitContext.REVISION = '1.0.1-dev'
...
@@ -2472,7 +2473,7 @@ THREEx.ArToolkitContext.REVISION = '1.0.1-dev'
* @param {string} trackingBackend - the tracking to user
* @param {string} trackingBackend - the tracking to user
* @return {THREE.Camera} the created camera
* @return {THREE.Camera} the created camera
*/
*/
THREEx.ArToolkit
Context.createDefaultCamera = function( trackingBackend ){
ARjs.
Context.createDefaultCamera = function( trackingBackend ){
console.assert(false, 'use ARjs.Utils.createDefaultCamera instead')
console.assert(false, 'use ARjs.Utils.createDefaultCamera instead')
// Create a camera
// Create a camera
if( trackingBackend === 'artoolkit' ){
if( trackingBackend === 'artoolkit' ){
...
@@ -2489,7 +2490,7 @@ THREEx.ArToolkitContext.createDefaultCamera = function( trackingBackend ){
...
@@ -2489,7 +2490,7 @@ THREEx.ArToolkitContext.createDefaultCamera = function( trackingBackend ){
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// init functions
// init functions
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Context.prototype.init = function(onCompleted){
ARjs.
Context.prototype.init = function(onCompleted){
var _this = this
var _this = this
if( this.parameters.trackingBackend === 'artoolkit' ){
if( this.parameters.trackingBackend === 'artoolkit' ){
this._initArtoolkit(done)
this._initArtoolkit(done)
...
@@ -2515,7 +2516,7 @@ THREEx.ArToolkitContext.prototype.init = function(onCompleted){
...
@@ -2515,7 +2516,7 @@ THREEx.ArToolkitContext.prototype.init = function(onCompleted){
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// update function
// update function
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Context.prototype.update = function(srcElement){
ARjs.
Context.prototype.update = function(srcElement){
// be sure arController is fully initialized
// be sure arController is fully initialized
if(this.parameters.trackingBackend === 'artoolkit' && this.arController === null) return false;
if(this.parameters.trackingBackend === 'artoolkit' && this.arController === null) return false;
...
@@ -2556,12 +2557,12 @@ THREEx.ArToolkitContext.prototype.update = function(srcElement){
...
@@ -2556,12 +2557,12 @@ THREEx.ArToolkitContext.prototype.update = function(srcElement){
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Add/Remove markerControls
// Add/Remove markerControls
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Context.prototype.addMarker = function(arMarkerControls){
ARjs.
Context.prototype.addMarker = function(arMarkerControls){
console.assert(arMarkerControls instanceof THREEx.ArMarkerControls)
console.assert(arMarkerControls instanceof THREEx.ArMarkerControls)
this._arMarkersControls.push(arMarkerControls)
this._arMarkersControls.push(arMarkerControls)
}
}
THREEx.ArToolkit
Context.prototype.removeMarker = function(arMarkerControls){
ARjs.
Context.prototype.removeMarker = function(arMarkerControls){
console.assert(arMarkerControls instanceof THREEx.ArMarkerControls)
console.assert(arMarkerControls instanceof THREEx.ArMarkerControls)
// console.log('remove marker for', arMarkerControls)
// console.log('remove marker for', arMarkerControls)
var index = this.arMarkerControlss.indexOf(artoolkitMarker);
var index = this.arMarkerControlss.indexOf(artoolkitMarker);
...
@@ -2572,7 +2573,7 @@ THREEx.ArToolkitContext.prototype.removeMarker = function(arMarkerControls){
...
@@ -2572,7 +2573,7 @@ THREEx.ArToolkitContext.prototype.removeMarker = function(arMarkerControls){
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// artoolkit specific
// artoolkit specific
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Context.prototype._initArtoolkit = function(onCompleted){
ARjs.
Context.prototype._initArtoolkit = function(onCompleted){
var _this = this
var _this = this
// set this._artoolkitProjectionAxisTransformMatrix to change artoolkit projection matrix axis to match usual webgl one
// set this._artoolkitProjectionAxisTransformMatrix to change artoolkit projection matrix axis to match usual webgl one
...
@@ -2643,7 +2644,7 @@ THREEx.ArToolkitContext.prototype._initArtoolkit = function(onCompleted){
...
@@ -2643,7 +2644,7 @@ THREEx.ArToolkitContext.prototype._initArtoolkit = function(onCompleted){
/**
/**
* return the projection matrix
* return the projection matrix
*/
*/
THREEx.ArToolkit
Context.prototype.getProjectionMatrix = function(srcElement){
ARjs.
Context.prototype.getProjectionMatrix = function(srcElement){
// FIXME rename this function to say it is artoolkit specific - getArtoolkitProjectMatrix
// FIXME rename this function to say it is artoolkit specific - getArtoolkitProjectMatrix
...
@@ -2666,14 +2667,14 @@ THREEx.ArToolkitContext.prototype.getProjectionMatrix = function(srcElement){
...
@@ -2666,14 +2667,14 @@ THREEx.ArToolkitContext.prototype.getProjectionMatrix = function(srcElement){
return projectionMatrix
return projectionMatrix
}
}
THREEx.ArToolkit
Context.prototype._updateArtoolkit = function(srcElement){
ARjs.
Context.prototype._updateArtoolkit = function(srcElement){
this.arController.process(srcElement)
this.arController.process(srcElement)
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// aruco specific
// aruco specific
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Context.prototype._initAruco = function(onCompleted){
ARjs.
Context.prototype._initAruco = function(onCompleted){
this.arucoContext = new THREEx.ArucoContext()
this.arucoContext = new THREEx.ArucoContext()
// honor this.parameters.canvasWidth/.canvasHeight
// honor this.parameters.canvasWidth/.canvasHeight
...
@@ -2694,7 +2695,7 @@ THREEx.ArToolkitContext.prototype._initAruco = function(onCompleted){
...
@@ -2694,7 +2695,7 @@ THREEx.ArToolkitContext.prototype._initAruco = function(onCompleted){
}
}
THREEx.ArToolkit
Context.prototype._updateAruco = function(srcElement){
ARjs.
Context.prototype._updateAruco = function(srcElement){
// console.log('update aruco here')
// console.log('update aruco here')
var _this = this
var _this = this
var arMarkersControls = this._arMarkersControls
var arMarkersControls = this._arMarkersControls
...
@@ -2722,7 +2723,7 @@ THREEx.ArToolkitContext.prototype._updateAruco = function(srcElement){
...
@@ -2722,7 +2723,7 @@ THREEx.ArToolkitContext.prototype._updateAruco = function(srcElement){
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// tango specific
// tango specific
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Context.prototype._initTango = function(onCompleted){
ARjs.
Context.prototype._initTango = function(onCompleted){
var _this = this
var _this = this
// check webvr is available
// check webvr is available
if (navigator.getVRDisplays){
if (navigator.getVRDisplays){
...
@@ -2765,7 +2766,7 @@ THREEx.ArToolkitContext.prototype._initTango = function(onCompleted){
...
@@ -2765,7 +2766,7 @@ THREEx.ArToolkitContext.prototype._initTango = function(onCompleted){
}
}
THREEx.ArToolkit
Context.prototype._updateTango = function(srcElement){
ARjs.
Context.prototype._updateTango = function(srcElement){
// console.log('update aruco here')
// console.log('update aruco here')
var _this = this
var _this = this
var arMarkersControls = this._arMarkersControls
var arMarkersControls = this._arMarkersControls
...
@@ -2818,7 +2819,6 @@ THREEx.ArToolkitContext.prototype._updateTango = function(srcElement){
...
@@ -2818,7 +2819,6 @@ THREEx.ArToolkitContext.prototype._updateTango = function(srcElement){
}
}
var ARjs = ARjs || {}
var ARjs = ARjs || {}
var THREEx = THREEx || {}
var THREEx = THREEx || {}
/**
/**
...
@@ -2994,32 +2994,59 @@ ARjs.Profile.prototype.checkIfValid = function () {
...
@@ -2994,32 +2994,59 @@ ARjs.Profile.prototype.checkIfValid = function () {
}
}
return this
return this
}
}
var ARjs = ARjs || {}
var THREEx = THREEx || {}
var THREEx = THREEx || {}
THREEx.ArToolkitSource = function(parameters){
ARjs.Source = THREEx.ArToolkitSource = function(parameters){
var _this = this
this.ready = false
this.domElement = null
// handle default parameters
// handle default parameters
this.parameters = {
this.parameters = {
// type of source - ['webcam', 'image', 'video']
// type of source - ['webcam', 'image', 'video']
sourceType :
parameters.sourceType !== undefined ? parameters.sourceType :
'webcam',
sourceType : 'webcam',
// url of the source - valid if sourceType = image|video
// url of the source - valid if sourceType = image|video
sourceUrl :
parameters.sourceUrl !== undefined ? parameters.sourceUrl :
null,
sourceUrl : null,
// resolution of at which we initialize in the source image
// resolution of at which we initialize in the source image
sourceWidth:
parameters.sourceWidth !== undefined ? parameters.sourceWidth :
640,
sourceWidth: 640,
sourceHeight:
parameters.sourceHeight !== undefined ? parameters.sourceHeight :
480,
sourceHeight: 480,
// resolution displayed for the source
// resolution displayed for the source
displayWidth:
parameters.displayWidth !== undefined ? parameters.displayWidth :
640,
displayWidth: 640,
displayHeight:
parameters.displayHeight !== undefined ? parameters.displayHeight :
480,
displayHeight: 480,
}
}
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters(parameters)
function setParameters(parameters){
if( parameters === undefined ) return
for( var key in parameters ){
var newValue = parameters[ key ]
this.ready = false
if( newValue === undefined ){
this.domElement = null
console.warn( "THREEx.ArToolkitSource: '" + key + "' parameter is undefined." )
continue
}
var currentValue = _this.parameters[ key ]
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitSource: '" + key + "' is not a property of this material." )
continue
}
_this.parameters[ key ] = newValue
}
}
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Code Separator
// Code Separator
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Source.prototype.init = function(onReady, onError){
ARjs.
Source.prototype.init = function(onReady, onError){
var _this = this
var _this = this
if( this.parameters.sourceType === 'image' ){
if( this.parameters.sourceType === 'image' ){
...
@@ -3055,7 +3082,7 @@ THREEx.ArToolkitSource.prototype.init = function(onReady, onError){
...
@@ -3055,7 +3082,7 @@ THREEx.ArToolkitSource.prototype.init = function(onReady, onError){
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Source.prototype._initSourceImage = function(onReady) {
ARjs.
Source.prototype._initSourceImage = function(onReady) {
// TODO make it static
// TODO make it static
var domElement = document.createElement('img')
var domElement = document.createElement('img')
domElement.src = this.parameters.sourceUrl
domElement.src = this.parameters.sourceUrl
...
@@ -3080,7 +3107,7 @@ THREEx.ArToolkitSource.prototype._initSourceImage = function(onReady) {
...
@@ -3080,7 +3107,7 @@ THREEx.ArToolkitSource.prototype._initSourceImage = function(onReady) {
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Source.prototype._initSourceVideo = function(onReady) {
ARjs.
Source.prototype._initSourceVideo = function(onReady) {
// TODO make it static
// TODO make it static
var domElement = document.createElement('video');
var domElement = document.createElement('video');
domElement.src = this.parameters.sourceUrl
domElement.src = this.parameters.sourceUrl
...
@@ -3117,12 +3144,12 @@ THREEx.ArToolkitSource.prototype._initSourceVideo = function(onReady) {
...
@@ -3117,12 +3144,12 @@ THREEx.ArToolkitSource.prototype._initSourceVideo = function(onReady) {
// handle webcam source
// handle webcam source
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Source.prototype._initSourceWebcam = function(onReady, onError) {
ARjs.
Source.prototype._initSourceWebcam = function(onReady, onError) {
var _this = this
var _this = this
debugger
// init default value
// init default value
onError = onError || function(error){
onError = onError || function(error){
alert('
Cant init webcam due to
'+error.message)
alert('
Webcam Error\nName: '+error.name + '\nMessage:
'+error.message)
}
}
var domElement = document.createElement('video');
var domElement = document.createElement('video');
...
@@ -3132,13 +3159,18 @@ debugger
...
@@ -3132,13 +3159,18 @@ debugger
domElement.style.width = this.parameters.displayWidth+'px'
domElement.style.width = this.parameters.displayWidth+'px'
domElement.style.height = this.parameters.displayHeight+'px'
domElement.style.height = this.parameters.displayHeight+'px'
// check API is available
if (navigator.mediaDevices === undefined
if (navigator.mediaDevices === undefined
|| navigator.mediaDevices.enumerateDevices === undefined
|| navigator.mediaDevices.enumerateDevices === undefined
|| navigator.mediaDevices.getUserMedia === undefined ){
|| navigator.mediaDevices.getUserMedia === undefined ){
onError("WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser")
onError({
name: '',
message: 'WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser'
})
return
return
}
}
// get available devices
navigator.mediaDevices.enumerateDevices().then(function(devices) {
navigator.mediaDevices.enumerateDevices().then(function(devices) {
var userMediaConstraints = {
var userMediaConstraints = {
audio: false,
audio: false,
...
@@ -3156,6 +3188,7 @@ debugger
...
@@ -3156,6 +3188,7 @@ debugger
}
}
}
}
}
}
// get a device which satisfy the constraints
navigator.mediaDevices.getUserMedia(userMediaConstraints).then(function success(stream) {
navigator.mediaDevices.getUserMedia(userMediaConstraints).then(function success(stream) {
// set the .src of the domElement
// set the .src of the domElement
domElement.srcObject = stream;
domElement.srcObject = stream;
...
@@ -3164,6 +3197,7 @@ debugger
...
@@ -3164,6 +3197,7 @@ debugger
domElement.play();
domElement.play();
})
})
// domElement.play();
// domElement.play();
// TODO listen to loadedmetadata instead
// TODO listen to loadedmetadata instead
// wait until the video stream is ready
// wait until the video stream is ready
var interval = setInterval(function() {
var interval = setInterval(function() {
...
@@ -3173,7 +3207,8 @@ debugger
...
@@ -3173,7 +3207,8 @@ debugger
}, 1000/50);
}, 1000/50);
}).catch(function(error) {
}).catch(function(error) {
onError({
onError({
message: "Can't access user media :()"
name: error.name,
message: error.message
});
});
});
});
}).catch(function(error) {
}).catch(function(error) {
...
@@ -3188,7 +3223,7 @@ debugger
...
@@ -3188,7 +3223,7 @@ debugger
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Handle Mobile Torch
// Handle Mobile Torch
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Source.prototype.hasMobileTorch = function(){
ARjs.
Source.prototype.hasMobileTorch = function(){
var stream = arToolkitSource.domElement.srcObject
var stream = arToolkitSource.domElement.srcObject
if( stream instanceof MediaStream === false ) return false
if( stream instanceof MediaStream === false ) return false
...
@@ -3210,7 +3245,7 @@ THREEx.ArToolkitSource.prototype.hasMobileTorch = function(){
...
@@ -3210,7 +3245,7 @@ THREEx.ArToolkitSource.prototype.hasMobileTorch = function(){
* toggle the flash/torch of the mobile fun if applicable.
* toggle the flash/torch of the mobile fun if applicable.
* Great post about it https://www.oberhofer.co/mediastreamtrack-and-its-capabilities/
* Great post about it https://www.oberhofer.co/mediastreamtrack-and-its-capabilities/
*/
*/
THREEx.ArToolkit
Source.prototype.toggleMobileTorch = function(){
ARjs.
Source.prototype.toggleMobileTorch = function(){
// sanity check
// sanity check
console.assert(this.hasMobileTorch() === true)
console.assert(this.hasMobileTorch() === true)
...
@@ -3246,7 +3281,7 @@ THREEx.ArToolkitSource.prototype.toggleMobileTorch = function(){
...
@@ -3246,7 +3281,7 @@ THREEx.ArToolkitSource.prototype.toggleMobileTorch = function(){
// handle resize
// handle resize
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Source.prototype.onResizeElement = function(mirrorDomElements){
ARjs.
Source.prototype.onResizeElement = function(mirrorDomElements){
var _this = this
var _this = this
var screenWidth = window.innerWidth
var screenWidth = window.innerWidth
var screenHeight = window.innerHeight
var screenHeight = window.innerHeight
...
@@ -3304,7 +3339,7 @@ THREEx.ArToolkitSource.prototype.onResizeElement = function(mirrorDomElements){
...
@@ -3304,7 +3339,7 @@ THREEx.ArToolkitSource.prototype.onResizeElement = function(mirrorDomElements){
})
})
}
}
THREEx.ArToolkit
Source.prototype.copyElementSizeTo = function(otherElement){
ARjs.
Source.prototype.copyElementSizeTo = function(otherElement){
otherElement.style.width = this.domElement.style.width
otherElement.style.width = this.domElement.style.width
otherElement.style.height = this.domElement.style.height
otherElement.style.height = this.domElement.style.height
otherElement.style.marginLeft = this.domElement.style.marginLeft
otherElement.style.marginLeft = this.domElement.style.marginLeft
...
@@ -3315,7 +3350,7 @@ THREEx.ArToolkitSource.prototype.copyElementSizeTo = function(otherElement){
...
@@ -3315,7 +3350,7 @@ THREEx.ArToolkitSource.prototype.copyElementSizeTo = function(otherElement){
// Code Separator
// Code Separator
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Source.prototype.copySizeTo = function(){
ARjs.
Source.prototype.copySizeTo = function(){
console.warn('obsolete function arToolkitSource.copySizeTo. Use arToolkitSource.copyElementSizeTo' )
console.warn('obsolete function arToolkitSource.copySizeTo. Use arToolkitSource.copyElementSizeTo' )
this.copyElementSizeTo.apply(this, arguments)
this.copyElementSizeTo.apply(this, arguments)
}
}
...
@@ -3324,14 +3359,15 @@ THREEx.ArToolkitSource.prototype.copySizeTo = function(){
...
@@ -3324,14 +3359,15 @@ THREEx.ArToolkitSource.prototype.copySizeTo = function(){
// Code Separator
// Code Separator
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkitSource.prototype.onResize = function(arToolkitContext, renderer, camera){
ARjs.Source.prototype.onResize = function(arToolkitContext, renderer, camera){
var trackingBackend = arToolkitContext.parameters.trackingBackend
if( arguments.length !== 3 ){
if( arguments.length !== 3 ){
console.warn('obsolete function arToolkitSource.onResize. Use arToolkitSource.onResizeElement' )
console.warn('obsolete function arToolkitSource.onResize. Use arToolkitSource.onResizeElement' )
return this.onResizeElement.apply(this, arguments)
return this.onResizeElement.apply(this, arguments)
}
}
var trackingBackend = arToolkitContext.parameters.trackingBackend
// RESIZE DOMELEMENT
// RESIZE DOMELEMENT
if( trackingBackend === 'artoolkit' ){
if( trackingBackend === 'artoolkit' ){
...
...
three.js/build/ar.min.js
浏览文件 @
63242551
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
three.js/examples/arjs-session.html
浏览文件 @
63242551
...
@@ -28,7 +28,8 @@
...
@@ -28,7 +28,8 @@
<script
src=
'../threex-armarkercontrols.js'
></script>
<script
src=
'../threex-armarkercontrols.js'
></script>
<script
src=
'../threex-armarkerhelper.js'
></script>
<script
src=
'../threex-armarkerhelper.js'
></script>
<script
src=
'../threex-arsmoothedcontrols.js'
></script>
<script
src=
'../threex-arsmoothedcontrols.js'
></script>
<script
src=
'../threex-arclickability.js'
></script>
<script
src=
'../threex-hittester-plane.js'
></script>
<script
src=
'../threex-hittester-tango.js'
></script>
<script>
THREEx
.
ArToolkitContext
.
baseURL
=
'
../
'
</script>
<script>
THREEx
.
ArToolkitContext
.
baseURL
=
'
../
'
</script>
<script
src=
'multi-markers/threex-armultimarkerutils.js'
></script>
<script
src=
'multi-markers/threex-armultimarkerutils.js'
></script>
...
@@ -37,8 +38,8 @@
...
@@ -37,8 +38,8 @@
<body
style=
'margin : 0px; overflow: hidden; font-family: Monospace;'
><div
style=
'position: absolute; top: 10px; width:100%; text-align: center; z-index: 1;'
>
<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
<a
href=
'https://github.com/jeromeetienne/AR.js/'
target=
'_blank'
>
AR.js
</a>
-
Session API demo with multi tracking and hit testing
by
<a
href=
'https://twitter.com/jerome_etienne'
target=
'_blank'
>
@jerome_etienne
</a>
-
by
<a
href=
'https://twitter.com/jerome_etienne'
target=
'_blank'
>
@jerome_etienne
</a>
<br/>
<br/>
Marker image
Marker image
<a
href=
'../../data/images/hiro.jpg'
target=
'_blank'
>
hiro for artoolkit
</a>
<a
href=
'../../data/images/hiro.jpg'
target=
'_blank'
>
hiro for artoolkit
</a>
...
@@ -65,7 +66,7 @@
...
@@ -65,7 +66,7 @@
<a
href=
'javascript:void(0)'
id=
'buttonMarkersAreaLearner'
>
Learn-new-marker-area
</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=
'buttonMarkersAreaReset'
>
Reset-marker-area
</a>
</div><script>
</div><script>
;(
function
(){
//
;(function(){
// get tracking method from location.hash
// get tracking method from location.hash
var
trackingMethod
=
location
.
hash
.
substring
(
1
)
?
location
.
hash
.
substring
(
1
)
:
'
best
'
var
trackingMethod
=
location
.
hash
.
substring
(
1
)
?
location
.
hash
.
substring
(
1
)
:
'
best
'
...
@@ -107,8 +108,8 @@
...
@@ -107,8 +108,8 @@
var
arProfile
=
new
ARjs
.
Profile
()
var
arProfile
=
new
ARjs
.
Profile
()
.
sourceWebcam
()
.
sourceWebcam
()
.
trackingMethod
(
trackingMethod
)
.
trackingMethod
(
trackingMethod
)
//
.changeMatrixMode('modelViewMatrix')
.
changeMatrixMode
(
'
modelViewMatrix
'
)
.
changeMatrixMode
(
'
cameraTransformMatrix
'
)
//
.changeMatrixMode('cameraTransformMatrix')
.
defaultMarker
()
.
defaultMarker
()
.
checkIfValid
()
.
checkIfValid
()
...
@@ -131,7 +132,6 @@
...
@@ -131,7 +132,6 @@
// Create a ARjs.Anchor
// Create a ARjs.Anchor
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
var
arAnchor
=
new
ARjs
.
Anchor
(
arSession
,
arProfile
.
defaultMarkerParameters
)
var
arAnchor
=
new
ARjs
.
Anchor
(
arSession
,
arProfile
.
defaultMarkerParameters
)
onRenderFcts
.
push
(
function
(){
onRenderFcts
.
push
(
function
(){
arAnchor
.
update
()
arAnchor
.
update
()
...
@@ -140,7 +140,6 @@
...
@@ -140,7 +140,6 @@
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// handle Hit Tester
// handle Hit Tester
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
var
hitTester
=
new
ARjs
.
HitTester
(
arSession
)
var
hitTester
=
new
ARjs
.
HitTester
(
arSession
)
onRenderFcts
.
push
(
function
(){
onRenderFcts
.
push
(
function
(){
...
@@ -195,11 +194,11 @@
...
@@ -195,11 +194,11 @@
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
var
mesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
mesh
.
position
.
y
=
0.5
mesh
.
position
.
y
=
0.5
arWorldRoot
.
add
(
mesh
);
arWorldRoot
.
add
(
mesh
);
onRenderFcts
.
push
(
function
(
delta
){
onRenderFcts
.
push
(
function
(
delta
){
mesh
.
rotation
.
x
+=
Math
.
PI
*
delta
mesh
.
rotation
.
x
+=
Math
.
PI
*
delta
})
})
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Handle UI
// Handle UI
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
...
@@ -216,7 +215,7 @@
...
@@ -216,7 +215,7 @@
}
else
{
}
else
{
document
.
querySelector
(
'
#buttonTangoTogglePointCloud
'
).
style
.
display
=
'
none
'
document
.
querySelector
(
'
#buttonTangoTogglePointCloud
'
).
style
.
display
=
'
none
'
}
}
if
(
arAnchor
.
parameters
.
markersAreaEnabled
){
if
(
arAnchor
.
parameters
.
markersAreaEnabled
){
var
subMarkerHelpersVisible
=
false
var
subMarkerHelpersVisible
=
false
document
.
querySelector
(
'
#buttonToggleMarkerHelpers
'
).
addEventListener
(
'
click
'
,
function
(){
document
.
querySelector
(
'
#buttonToggleMarkerHelpers
'
).
addEventListener
(
'
click
'
,
function
(){
...
@@ -273,5 +272,5 @@
...
@@ -273,5 +272,5 @@
onRenderFct
(
deltaMsec
/
1000
,
nowMsec
/
1000
)
onRenderFct
(
deltaMsec
/
1000
,
nowMsec
/
1000
)
})
})
})
})
})()
//
})()
</script></body>
</script></body>
three.js/src/newAPI/arjs-anchor.js
浏览文件 @
63242551
...
@@ -18,11 +18,14 @@ ARjs.Anchor = function(arSession, markerParameters){
...
@@ -18,11 +18,14 @@ ARjs.Anchor = function(arSession, markerParameters){
this
.
parameters
=
markerParameters
this
.
parameters
=
markerParameters
console
.
log
(
'
ARjs.Anchor -
'
,
'
changeMatrixMode:
'
,
this
.
parameters
.
changeMatrixMode
,
'
markersAreaEnabled:
'
,
markerParameters
.
markersAreaEnabled
)
// log to debug
console
.
log
(
'
ARjs.Anchor -
'
,
'
changeMatrixMode:
'
,
this
.
parameters
.
changeMatrixMode
,
'
/ markersAreaEnabled:
'
,
markerParameters
.
markersAreaEnabled
)
var
markerRoot
=
new
THREE
.
Group
var
markerRoot
=
new
THREE
.
Group
scene
.
add
(
markerRoot
)
scene
.
add
(
markerRoot
)
// set controlledObject depending on changeMatrixMode
if
(
markerParameters
.
changeMatrixMode
===
'
modelViewMatrix
'
){
if
(
markerParameters
.
changeMatrixMode
===
'
modelViewMatrix
'
){
var
controlledObject
=
markerRoot
var
controlledObject
=
markerRoot
}
else
if
(
markerParameters
.
changeMatrixMode
===
'
cameraTransformMatrix
'
){
}
else
if
(
markerParameters
.
changeMatrixMode
===
'
cameraTransformMatrix
'
){
...
@@ -32,7 +35,7 @@ ARjs.Anchor = function(arSession, markerParameters){
...
@@ -32,7 +35,7 @@ ARjs.Anchor = function(arSession, markerParameters){
if
(
markerParameters
.
markersAreaEnabled
===
false
){
if
(
markerParameters
.
markersAreaEnabled
===
false
){
var
markerControls
=
new
THREEx
.
ArMarkerControls
(
arContext
,
controlledObject
,
markerParameters
)
var
markerControls
=
new
THREEx
.
ArMarkerControls
(
arContext
,
controlledObject
,
markerParameters
)
}
else
{
}
else
{
// sanity check
// sanity check
- MUST be a trackingBackend with markers
console
.
assert
(
arContext
.
parameters
.
trackingBackend
===
'
artoolkit
'
||
arContext
.
parameters
.
trackingBackend
===
'
aruco
'
)
console
.
assert
(
arContext
.
parameters
.
trackingBackend
===
'
artoolkit
'
||
arContext
.
parameters
.
trackingBackend
===
'
aruco
'
)
// for multi marker
// for multi marker
if
(
localStorage
.
getItem
(
'
ARjsMultiMarkerFile
'
)
===
null
){
if
(
localStorage
.
getItem
(
'
ARjsMultiMarkerFile
'
)
===
null
){
...
@@ -44,7 +47,10 @@ ARjs.Anchor = function(arSession, markerParameters){
...
@@ -44,7 +47,10 @@ ARjs.Anchor = function(arSession, markerParameters){
var
multiMarkerFile
=
localStorage
.
getItem
(
'
ARjsMultiMarkerFile
'
)
var
multiMarkerFile
=
localStorage
.
getItem
(
'
ARjsMultiMarkerFile
'
)
// build a multiMarkerControls
// build a multiMarkerControls
var
multiMarkerControls
=
THREEx
.
ArMultiMarkerControls
.
fromJSON
(
arContext
,
scene
,
markerRoot
,
multiMarkerFile
)
var
multiMarkerControls
=
THREEx
.
ArMultiMarkerControls
.
fromJSON
(
arContext
,
scene
,
controlledObject
,
multiMarkerFile
)
// honor markerParameters.changeMatrixMode
multiMarkerControls
.
parameters
.
changeMatrixMode
=
markerParameters
.
changeMatrixMode
// create ArMarkerHelper - useful to debug
// create ArMarkerHelper - useful to debug
var
markerHelpers
=
[]
var
markerHelpers
=
[]
...
@@ -56,6 +62,7 @@ ARjs.Anchor = function(arSession, markerParameters){
...
@@ -56,6 +62,7 @@ ARjs.Anchor = function(arSession, markerParameters){
// add it to markerHelpers
// add it to markerHelpers
markerHelpers
.
push
(
markerHelper
)
markerHelpers
.
push
(
markerHelper
)
})
})
// define API specific to markersArea
this
.
markersArea
=
{}
this
.
markersArea
=
{}
this
.
markersArea
.
setSubMarkersVisibility
=
function
(
visible
){
this
.
markersArea
.
setSubMarkersVisibility
=
function
(
visible
){
markerHelpers
.
forEach
(
function
(
markerHelper
){
markerHelpers
.
forEach
(
function
(
markerHelper
){
...
...
three.js/src/newAPI/arjs-hittester.js
浏览文件 @
63242551
...
@@ -9,16 +9,19 @@ var ARjs = ARjs || {}
...
@@ -9,16 +9,19 @@ var ARjs = ARjs || {}
*/
*/
ARjs
.
HitTester
=
function
(
arSession
){
ARjs
.
HitTester
=
function
(
arSession
){
var
_this
=
this
var
_this
=
this
var
arContext
=
arSession
.
arContext
var
trackingBackend
=
arContext
.
parameters
.
trackingBackend
this
.
arSession
=
arSession
this
.
arSession
=
arSession
this
.
_hitTesterPlane
=
null
this
.
_hitTesterTango
=
null
var
arContext
=
this
.
arSession
.
arContext
var
trackingBackend
=
arContext
.
parameters
.
trackingBackend
if
(
trackingBackend
===
'
tango
'
){
if
(
trackingBackend
===
'
tango
'
){
// Do nothing...
_this
.
_hitTesterTango
=
new
THREEx
.
HitTesterTango
()
}
else
{
}
else
{
arContext
.
addEventListener
(
'
initialized
'
,
function
(
event
){
arContext
.
addEventListener
(
'
initialized
'
,
function
(
event
){
_this
.
_
arClickability
=
new
THREEx
.
ARClickability
(
arSession
.
arSource
.
domElement
)
_this
.
_
hitTesterPlane
=
new
THREEx
.
HitTesterPlane
(
arSession
.
arSource
.
domElement
)
_this
.
_pickingScene
=
new
THREE
.
Scene
_this
.
_pickingScene
=
new
THREE
.
Scene
var
geometry
=
new
THREE
.
PlaneGeometry
(
20
,
20
,
19
,
19
).
rotateX
(
-
Math
.
PI
/
2
)
var
geometry
=
new
THREE
.
PlaneGeometry
(
20
,
20
,
19
,
19
).
rotateX
(
-
Math
.
PI
/
2
)
...
@@ -33,24 +36,33 @@ ARjs.HitTester = function(arSession){
...
@@ -33,24 +36,33 @@ ARjs.HitTester = function(arSession){
_this
.
_pickingScene
.
add
(
_this
.
_pickingPlane
)
_this
.
_pickingScene
.
add
(
_this
.
_pickingPlane
)
})
})
}
}
}
}
//////////////////////////////////////////////////////////////////////////////
// update function
//////////////////////////////////////////////////////////////////////////////
/**
* update
*
* @param {THREE.Camera} camera - the camera to use
* @param {THREE.Object3D} object3d -
*/
ARjs
.
HitTester
.
prototype
.
update
=
function
(
camera
,
object3d
)
{
ARjs
.
HitTester
.
prototype
.
update
=
function
(
camera
,
object3d
)
{
var
arContext
=
this
.
arSession
.
arContext
var
arContext
=
this
.
arSession
.
arContext
var
trackingBackend
=
arContext
.
parameters
.
trackingBackend
var
trackingBackend
=
arContext
.
parameters
.
trackingBackend
if
(
trackingBackend
===
'
tango
'
){
if
(
this
.
_hitTesterTango
!==
null
){
// Do nothing...
this
.
_hitTesterTango
.
update
()
}
else
{
}
else
if
(
this
.
_hitTesterPlane
!==
null
){
// TODO put that in a .update
if
(
arContext
.
initialized
===
false
)
return
if
(
arContext
.
initialized
===
false
)
return
this
.
_
arClickability
.
onResize
()
this
.
_
hitTesterPlane
.
onResize
()
// // set cameraPicking position
// // set cameraPicking position
var
cameraPicking
=
this
.
_
arClickability
.
_cameraPicking
var
cameraPicking
=
this
.
_
hitTesterPlane
.
_cameraPicking
// camera.updateMatrixWorld()
// camera.updateMatrixWorld()
// cameraPicking.matrix.copy(object3d.matrixWorld)
// cameraPicking.matrix.copy(object3d.matrixWorld)
// cameraPicking.matrix.decompose(cameraPicking.position, cameraPicking.quaternion, cameraPicking.scale)
// cameraPicking.matrix.decompose(cameraPicking.position, cameraPicking.quaternion, cameraPicking.scale)
...
@@ -70,8 +82,12 @@ ARjs.HitTester.prototype.update = function (camera, object3d) {
...
@@ -70,8 +82,12 @@ ARjs.HitTester.prototype.update = function (camera, object3d) {
}
}
}
}
//////////////////////////////////////////////////////////////////////////////
// actual hit testing
//////////////////////////////////////////////////////////////////////////////
/**
/**
* Test the real world for intersections
.
* Test the real world for intersections
directly from a DomEvent
*
*
* @param {Number} mouseX - position X of the hit [-1, +1]
* @param {Number} mouseX - position X of the hit [-1, +1]
* @param {Number} mouseY - position Y of the hit [-1, +1]
* @param {Number} mouseY - position Y of the hit [-1, +1]
...
@@ -120,7 +136,7 @@ ARjs.HitTester.prototype.test = function(mouseX, mouseY){
...
@@ -120,7 +136,7 @@ ARjs.HitTester.prototype.test = function(mouseX, mouseY){
// compute intersections between mouseVector3 and pickingPlane
// compute intersections between mouseVector3 and pickingPlane
var
raycaster
=
new
THREE
.
Raycaster
();
var
raycaster
=
new
THREE
.
Raycaster
();
var
mouseVector3
=
new
THREE
.
Vector3
(
mouseX
,
mouseY
,
1
);
var
mouseVector3
=
new
THREE
.
Vector3
(
mouseX
,
mouseY
,
1
);
raycaster
.
setFromCamera
(
mouseVector3
,
this
.
_
arClickability
.
_cameraPicking
);
raycaster
.
setFromCamera
(
mouseVector3
,
this
.
_
hitTesterPlane
.
_cameraPicking
);
var
intersects
=
raycaster
.
intersectObjects
(
[
this
.
_pickingPlane
]
)
var
intersects
=
raycaster
.
intersectObjects
(
[
this
.
_pickingPlane
]
)
// if no intersection occurs, return now
// if no intersection occurs, return now
...
@@ -141,7 +157,6 @@ ARjs.HitTester.prototype.test = function(mouseX, mouseY){
...
@@ -141,7 +157,6 @@ ARjs.HitTester.prototype.test = function(mouseX, mouseY){
return
hitTestResults
return
hitTestResults
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// ARjs.HitTester.Result
// ARjs.HitTester.Result
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
...
...
three.js/threex-hittester-plane.js
0 → 100644
浏览文件 @
63242551
var
THREEx
=
THREEx
||
{}
// TODO this is useless - prefere arjs-hittester.js
/**
* - maybe support .onClickFcts in each object3d
* - seems an easy light layer for clickable object
* - up to
*/
THREEx
.
HitTesterPlane
=
function
(
sourceElement
){
this
.
_sourceElement
=
sourceElement
// Create cameraPicking
var
fullWidth
=
parseInt
(
sourceElement
.
style
.
width
)
var
fullHeight
=
parseInt
(
sourceElement
.
style
.
height
)
// TODO hardcoded fov - couch
this
.
_cameraPicking
=
new
THREE
.
PerspectiveCamera
(
42
,
fullWidth
/
fullHeight
,
0.1
,
100
);
console
.
warn
(
'
THREEx.HitTesterPlane works only in modelViewMatrix
'
)
// TODO just push camera in computeIntersects
}
THREEx
.
HitTesterPlane
.
prototype
.
onResize
=
function
(){
var
sourceElement
=
this
.
_sourceElement
var
cameraPicking
=
this
.
_cameraPicking
var
fullWidth
=
parseInt
(
sourceElement
.
style
.
width
)
var
fullHeight
=
parseInt
(
sourceElement
.
style
.
height
)
cameraPicking
.
aspect
=
fullWidth
/
fullHeight
;
cameraPicking
.
updateProjectionMatrix
();
}
THREEx
.
HitTesterPlane
.
prototype
.
computeIntersects
=
function
(
domEvent
,
objects
){
var
sourceElement
=
this
.
_sourceElement
var
cameraPicking
=
this
.
_cameraPicking
// compute mouse coordinatge with [-1,1]
var
eventCoords
=
new
THREE
.
Vector3
();
eventCoords
.
x
=
(
domEvent
.
layerX
/
parseInt
(
sourceElement
.
style
.
width
)
)
*
2
-
1
;
eventCoords
.
y
=
-
(
domEvent
.
layerY
/
parseInt
(
sourceElement
.
style
.
height
)
)
*
2
+
1
;
// compute intersections between eventCoords and pickingPlane
var
raycaster
=
new
THREE
.
Raycaster
();
raycaster
.
setFromCamera
(
eventCoords
,
cameraPicking
);
var
intersects
=
raycaster
.
intersectObjects
(
objects
)
return
intersects
}
THREEx
.
HitTesterPlane
.
prototype
.
update
=
function
(){
}
three.js/threex-hittester-tango.js
0 → 100644
浏览文件 @
63242551
var
THREEx
=
THREEx
||
{}
THREEx
.
HitTesterTango
=
function
(){
}
THREEx
.
HitTesterTango
.
tangoPickingPointCloud
=
function
(
artoolkitContext
,
mouseX
,
mouseY
){
var
vrDisplay
=
artoolkitContext
.
_tangoContext
.
vrDisplay
if
(
vrDisplay
===
null
)
return
null
var
pointAndPlane
=
vrDisplay
.
getPickingPointAndPlaneInPointCloud
(
mouseX
,
mouseY
)
if
(
pointAndPlane
==
null
)
{
console
.
warn
(
'
Could not retrieve the correct point and plane.
'
)
return
null
}
// FIXME not sure what this is
var
boundingSphereRadius
=
0.01
// the bigger the number the likeliest it crash chromium-webar
// Orient and position the model in the picking point according
// to the picking plane. The offset is half of the model size.
var
object3d
=
new
THREE
.
Object3D
THREE
.
WebAR
.
positionAndRotateObject3DWithPickingPointAndPlaneInPointCloud
(
pointAndPlane
,
object3d
,
boundingSphereRadius
)
object3d
.
rotateZ
(
-
Math
.
PI
/
2
)
// return the result
var
result
=
{}
result
.
position
=
object3d
.
position
result
.
quaternion
=
object3d
.
quaternion
return
result
}
webvr-polyfill/build/artoolkit-webvr-polyfill.js
浏览文件 @
63242551
...
@@ -2389,9 +2389,10 @@ THREEx.ArSmoothedControls.prototype.update = function(targetObject3d){
...
@@ -2389,9 +2389,10 @@ THREEx.ArSmoothedControls.prototype.update = function(targetObject3d){
object3d.scale.lerp(targetObject3d.scale, parameters.lerpScale)
object3d.scale.lerp(targetObject3d.scale, parameters.lerpScale)
}
}
}
}
var ARjs = ARjs || {}
var THREEx = THREEx || {}
var THREEx = THREEx || {}
THREEx.ArToolkitContext = function(parameters){
ARjs.Context =
THREEx.ArToolkitContext = function(parameters){
var _this = this
var _this = this
_this._updatedAt = null
_this._updatedAt = null
...
@@ -2408,7 +2409,7 @@ THREEx.ArToolkitContext = function(parameters){
...
@@ -2408,7 +2409,7 @@ THREEx.ArToolkitContext = function(parameters){
matrixCodeType: '3x3',
matrixCodeType: '3x3',
// url of the camera parameters
// url of the camera parameters
cameraParametersUrl:
THREEx.ArToolkit
Context.baseURL + 'parameters/camera_para.dat',
cameraParametersUrl:
ARjs.
Context.baseURL + 'parameters/camera_para.dat',
// tune the maximum rate of pose detection in the source image
// tune the maximum rate of pose detection in the source image
maxDetectionRate: 60,
maxDetectionRate: 60,
...
@@ -2458,12 +2459,12 @@ THREEx.ArToolkitContext = function(parameters){
...
@@ -2458,12 +2459,12 @@ THREEx.ArToolkitContext = function(parameters){
}
}
}
}
Object.assign(
THREEx.ArToolkit
Context.prototype, THREE.EventDispatcher.prototype );
Object.assign(
ARjs.
Context.prototype, THREE.EventDispatcher.prototype );
//
THREEx.ArToolkit
Context.baseURL = '../'
//
ARjs.
Context.baseURL = '../'
// default to github page
// default to github page
THREEx.ArToolkit
Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/'
ARjs.
Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/'
THREEx.ArToolkit
Context.REVISION = '1.0.1-dev'
ARjs.
Context.REVISION = '1.0.1-dev'
...
@@ -2472,7 +2473,7 @@ THREEx.ArToolkitContext.REVISION = '1.0.1-dev'
...
@@ -2472,7 +2473,7 @@ THREEx.ArToolkitContext.REVISION = '1.0.1-dev'
* @param {string} trackingBackend - the tracking to user
* @param {string} trackingBackend - the tracking to user
* @return {THREE.Camera} the created camera
* @return {THREE.Camera} the created camera
*/
*/
THREEx.ArToolkit
Context.createDefaultCamera = function( trackingBackend ){
ARjs.
Context.createDefaultCamera = function( trackingBackend ){
console.assert(false, 'use ARjs.Utils.createDefaultCamera instead')
console.assert(false, 'use ARjs.Utils.createDefaultCamera instead')
// Create a camera
// Create a camera
if( trackingBackend === 'artoolkit' ){
if( trackingBackend === 'artoolkit' ){
...
@@ -2489,7 +2490,7 @@ THREEx.ArToolkitContext.createDefaultCamera = function( trackingBackend ){
...
@@ -2489,7 +2490,7 @@ THREEx.ArToolkitContext.createDefaultCamera = function( trackingBackend ){
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// init functions
// init functions
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Context.prototype.init = function(onCompleted){
ARjs.
Context.prototype.init = function(onCompleted){
var _this = this
var _this = this
if( this.parameters.trackingBackend === 'artoolkit' ){
if( this.parameters.trackingBackend === 'artoolkit' ){
this._initArtoolkit(done)
this._initArtoolkit(done)
...
@@ -2515,7 +2516,7 @@ THREEx.ArToolkitContext.prototype.init = function(onCompleted){
...
@@ -2515,7 +2516,7 @@ THREEx.ArToolkitContext.prototype.init = function(onCompleted){
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// update function
// update function
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Context.prototype.update = function(srcElement){
ARjs.
Context.prototype.update = function(srcElement){
// be sure arController is fully initialized
// be sure arController is fully initialized
if(this.parameters.trackingBackend === 'artoolkit' && this.arController === null) return false;
if(this.parameters.trackingBackend === 'artoolkit' && this.arController === null) return false;
...
@@ -2556,12 +2557,12 @@ THREEx.ArToolkitContext.prototype.update = function(srcElement){
...
@@ -2556,12 +2557,12 @@ THREEx.ArToolkitContext.prototype.update = function(srcElement){
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Add/Remove markerControls
// Add/Remove markerControls
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Context.prototype.addMarker = function(arMarkerControls){
ARjs.
Context.prototype.addMarker = function(arMarkerControls){
console.assert(arMarkerControls instanceof THREEx.ArMarkerControls)
console.assert(arMarkerControls instanceof THREEx.ArMarkerControls)
this._arMarkersControls.push(arMarkerControls)
this._arMarkersControls.push(arMarkerControls)
}
}
THREEx.ArToolkit
Context.prototype.removeMarker = function(arMarkerControls){
ARjs.
Context.prototype.removeMarker = function(arMarkerControls){
console.assert(arMarkerControls instanceof THREEx.ArMarkerControls)
console.assert(arMarkerControls instanceof THREEx.ArMarkerControls)
// console.log('remove marker for', arMarkerControls)
// console.log('remove marker for', arMarkerControls)
var index = this.arMarkerControlss.indexOf(artoolkitMarker);
var index = this.arMarkerControlss.indexOf(artoolkitMarker);
...
@@ -2572,7 +2573,7 @@ THREEx.ArToolkitContext.prototype.removeMarker = function(arMarkerControls){
...
@@ -2572,7 +2573,7 @@ THREEx.ArToolkitContext.prototype.removeMarker = function(arMarkerControls){
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// artoolkit specific
// artoolkit specific
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Context.prototype._initArtoolkit = function(onCompleted){
ARjs.
Context.prototype._initArtoolkit = function(onCompleted){
var _this = this
var _this = this
// set this._artoolkitProjectionAxisTransformMatrix to change artoolkit projection matrix axis to match usual webgl one
// set this._artoolkitProjectionAxisTransformMatrix to change artoolkit projection matrix axis to match usual webgl one
...
@@ -2643,7 +2644,7 @@ THREEx.ArToolkitContext.prototype._initArtoolkit = function(onCompleted){
...
@@ -2643,7 +2644,7 @@ THREEx.ArToolkitContext.prototype._initArtoolkit = function(onCompleted){
/**
/**
* return the projection matrix
* return the projection matrix
*/
*/
THREEx.ArToolkit
Context.prototype.getProjectionMatrix = function(srcElement){
ARjs.
Context.prototype.getProjectionMatrix = function(srcElement){
// FIXME rename this function to say it is artoolkit specific - getArtoolkitProjectMatrix
// FIXME rename this function to say it is artoolkit specific - getArtoolkitProjectMatrix
...
@@ -2666,14 +2667,14 @@ THREEx.ArToolkitContext.prototype.getProjectionMatrix = function(srcElement){
...
@@ -2666,14 +2667,14 @@ THREEx.ArToolkitContext.prototype.getProjectionMatrix = function(srcElement){
return projectionMatrix
return projectionMatrix
}
}
THREEx.ArToolkit
Context.prototype._updateArtoolkit = function(srcElement){
ARjs.
Context.prototype._updateArtoolkit = function(srcElement){
this.arController.process(srcElement)
this.arController.process(srcElement)
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// aruco specific
// aruco specific
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Context.prototype._initAruco = function(onCompleted){
ARjs.
Context.prototype._initAruco = function(onCompleted){
this.arucoContext = new THREEx.ArucoContext()
this.arucoContext = new THREEx.ArucoContext()
// honor this.parameters.canvasWidth/.canvasHeight
// honor this.parameters.canvasWidth/.canvasHeight
...
@@ -2694,7 +2695,7 @@ THREEx.ArToolkitContext.prototype._initAruco = function(onCompleted){
...
@@ -2694,7 +2695,7 @@ THREEx.ArToolkitContext.prototype._initAruco = function(onCompleted){
}
}
THREEx.ArToolkit
Context.prototype._updateAruco = function(srcElement){
ARjs.
Context.prototype._updateAruco = function(srcElement){
// console.log('update aruco here')
// console.log('update aruco here')
var _this = this
var _this = this
var arMarkersControls = this._arMarkersControls
var arMarkersControls = this._arMarkersControls
...
@@ -2722,7 +2723,7 @@ THREEx.ArToolkitContext.prototype._updateAruco = function(srcElement){
...
@@ -2722,7 +2723,7 @@ THREEx.ArToolkitContext.prototype._updateAruco = function(srcElement){
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// tango specific
// tango specific
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Context.prototype._initTango = function(onCompleted){
ARjs.
Context.prototype._initTango = function(onCompleted){
var _this = this
var _this = this
// check webvr is available
// check webvr is available
if (navigator.getVRDisplays){
if (navigator.getVRDisplays){
...
@@ -2765,7 +2766,7 @@ THREEx.ArToolkitContext.prototype._initTango = function(onCompleted){
...
@@ -2765,7 +2766,7 @@ THREEx.ArToolkitContext.prototype._initTango = function(onCompleted){
}
}
THREEx.ArToolkit
Context.prototype._updateTango = function(srcElement){
ARjs.
Context.prototype._updateTango = function(srcElement){
// console.log('update aruco here')
// console.log('update aruco here')
var _this = this
var _this = this
var arMarkersControls = this._arMarkersControls
var arMarkersControls = this._arMarkersControls
...
@@ -2818,7 +2819,6 @@ THREEx.ArToolkitContext.prototype._updateTango = function(srcElement){
...
@@ -2818,7 +2819,6 @@ THREEx.ArToolkitContext.prototype._updateTango = function(srcElement){
}
}
var ARjs = ARjs || {}
var ARjs = ARjs || {}
var THREEx = THREEx || {}
var THREEx = THREEx || {}
/**
/**
...
@@ -2994,32 +2994,59 @@ ARjs.Profile.prototype.checkIfValid = function () {
...
@@ -2994,32 +2994,59 @@ ARjs.Profile.prototype.checkIfValid = function () {
}
}
return this
return this
}
}
var ARjs = ARjs || {}
var THREEx = THREEx || {}
var THREEx = THREEx || {}
THREEx.ArToolkitSource = function(parameters){
ARjs.Source = THREEx.ArToolkitSource = function(parameters){
var _this = this
this.ready = false
this.domElement = null
// handle default parameters
// handle default parameters
this.parameters = {
this.parameters = {
// type of source - ['webcam', 'image', 'video']
// type of source - ['webcam', 'image', 'video']
sourceType :
parameters.sourceType !== undefined ? parameters.sourceType :
'webcam',
sourceType : 'webcam',
// url of the source - valid if sourceType = image|video
// url of the source - valid if sourceType = image|video
sourceUrl :
parameters.sourceUrl !== undefined ? parameters.sourceUrl :
null,
sourceUrl : null,
// resolution of at which we initialize in the source image
// resolution of at which we initialize in the source image
sourceWidth:
parameters.sourceWidth !== undefined ? parameters.sourceWidth :
640,
sourceWidth: 640,
sourceHeight:
parameters.sourceHeight !== undefined ? parameters.sourceHeight :
480,
sourceHeight: 480,
// resolution displayed for the source
// resolution displayed for the source
displayWidth:
parameters.displayWidth !== undefined ? parameters.displayWidth :
640,
displayWidth: 640,
displayHeight:
parameters.displayHeight !== undefined ? parameters.displayHeight :
480,
displayHeight: 480,
}
}
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters(parameters)
function setParameters(parameters){
if( parameters === undefined ) return
for( var key in parameters ){
var newValue = parameters[ key ]
this.ready = false
if( newValue === undefined ){
this.domElement = null
console.warn( "THREEx.ArToolkitSource: '" + key + "' parameter is undefined." )
continue
}
var currentValue = _this.parameters[ key ]
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitSource: '" + key + "' is not a property of this material." )
continue
}
_this.parameters[ key ] = newValue
}
}
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Code Separator
// Code Separator
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Source.prototype.init = function(onReady, onError){
ARjs.
Source.prototype.init = function(onReady, onError){
var _this = this
var _this = this
if( this.parameters.sourceType === 'image' ){
if( this.parameters.sourceType === 'image' ){
...
@@ -3055,7 +3082,7 @@ THREEx.ArToolkitSource.prototype.init = function(onReady, onError){
...
@@ -3055,7 +3082,7 @@ THREEx.ArToolkitSource.prototype.init = function(onReady, onError){
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Source.prototype._initSourceImage = function(onReady) {
ARjs.
Source.prototype._initSourceImage = function(onReady) {
// TODO make it static
// TODO make it static
var domElement = document.createElement('img')
var domElement = document.createElement('img')
domElement.src = this.parameters.sourceUrl
domElement.src = this.parameters.sourceUrl
...
@@ -3080,7 +3107,7 @@ THREEx.ArToolkitSource.prototype._initSourceImage = function(onReady) {
...
@@ -3080,7 +3107,7 @@ THREEx.ArToolkitSource.prototype._initSourceImage = function(onReady) {
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Source.prototype._initSourceVideo = function(onReady) {
ARjs.
Source.prototype._initSourceVideo = function(onReady) {
// TODO make it static
// TODO make it static
var domElement = document.createElement('video');
var domElement = document.createElement('video');
domElement.src = this.parameters.sourceUrl
domElement.src = this.parameters.sourceUrl
...
@@ -3117,12 +3144,12 @@ THREEx.ArToolkitSource.prototype._initSourceVideo = function(onReady) {
...
@@ -3117,12 +3144,12 @@ THREEx.ArToolkitSource.prototype._initSourceVideo = function(onReady) {
// handle webcam source
// handle webcam source
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Source.prototype._initSourceWebcam = function(onReady, onError) {
ARjs.
Source.prototype._initSourceWebcam = function(onReady, onError) {
var _this = this
var _this = this
debugger
// init default value
// init default value
onError = onError || function(error){
onError = onError || function(error){
alert('
Cant init webcam due to
'+error.message)
alert('
Webcam Error\nName: '+error.name + '\nMessage:
'+error.message)
}
}
var domElement = document.createElement('video');
var domElement = document.createElement('video');
...
@@ -3132,13 +3159,18 @@ debugger
...
@@ -3132,13 +3159,18 @@ debugger
domElement.style.width = this.parameters.displayWidth+'px'
domElement.style.width = this.parameters.displayWidth+'px'
domElement.style.height = this.parameters.displayHeight+'px'
domElement.style.height = this.parameters.displayHeight+'px'
// check API is available
if (navigator.mediaDevices === undefined
if (navigator.mediaDevices === undefined
|| navigator.mediaDevices.enumerateDevices === undefined
|| navigator.mediaDevices.enumerateDevices === undefined
|| navigator.mediaDevices.getUserMedia === undefined ){
|| navigator.mediaDevices.getUserMedia === undefined ){
onError("WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser")
onError({
name: '',
message: 'WebRTC issue! navigator.mediaDevices.enumerateDevices not present in your browser'
})
return
return
}
}
// get available devices
navigator.mediaDevices.enumerateDevices().then(function(devices) {
navigator.mediaDevices.enumerateDevices().then(function(devices) {
var userMediaConstraints = {
var userMediaConstraints = {
audio: false,
audio: false,
...
@@ -3156,6 +3188,7 @@ debugger
...
@@ -3156,6 +3188,7 @@ debugger
}
}
}
}
}
}
// get a device which satisfy the constraints
navigator.mediaDevices.getUserMedia(userMediaConstraints).then(function success(stream) {
navigator.mediaDevices.getUserMedia(userMediaConstraints).then(function success(stream) {
// set the .src of the domElement
// set the .src of the domElement
domElement.srcObject = stream;
domElement.srcObject = stream;
...
@@ -3164,6 +3197,7 @@ debugger
...
@@ -3164,6 +3197,7 @@ debugger
domElement.play();
domElement.play();
})
})
// domElement.play();
// domElement.play();
// TODO listen to loadedmetadata instead
// TODO listen to loadedmetadata instead
// wait until the video stream is ready
// wait until the video stream is ready
var interval = setInterval(function() {
var interval = setInterval(function() {
...
@@ -3173,7 +3207,8 @@ debugger
...
@@ -3173,7 +3207,8 @@ debugger
}, 1000/50);
}, 1000/50);
}).catch(function(error) {
}).catch(function(error) {
onError({
onError({
message: "Can't access user media :()"
name: error.name,
message: error.message
});
});
});
});
}).catch(function(error) {
}).catch(function(error) {
...
@@ -3188,7 +3223,7 @@ debugger
...
@@ -3188,7 +3223,7 @@ debugger
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Handle Mobile Torch
// Handle Mobile Torch
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Source.prototype.hasMobileTorch = function(){
ARjs.
Source.prototype.hasMobileTorch = function(){
var stream = arToolkitSource.domElement.srcObject
var stream = arToolkitSource.domElement.srcObject
if( stream instanceof MediaStream === false ) return false
if( stream instanceof MediaStream === false ) return false
...
@@ -3210,7 +3245,7 @@ THREEx.ArToolkitSource.prototype.hasMobileTorch = function(){
...
@@ -3210,7 +3245,7 @@ THREEx.ArToolkitSource.prototype.hasMobileTorch = function(){
* toggle the flash/torch of the mobile fun if applicable.
* toggle the flash/torch of the mobile fun if applicable.
* Great post about it https://www.oberhofer.co/mediastreamtrack-and-its-capabilities/
* Great post about it https://www.oberhofer.co/mediastreamtrack-and-its-capabilities/
*/
*/
THREEx.ArToolkit
Source.prototype.toggleMobileTorch = function(){
ARjs.
Source.prototype.toggleMobileTorch = function(){
// sanity check
// sanity check
console.assert(this.hasMobileTorch() === true)
console.assert(this.hasMobileTorch() === true)
...
@@ -3246,7 +3281,7 @@ THREEx.ArToolkitSource.prototype.toggleMobileTorch = function(){
...
@@ -3246,7 +3281,7 @@ THREEx.ArToolkitSource.prototype.toggleMobileTorch = function(){
// handle resize
// handle resize
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Source.prototype.onResizeElement = function(mirrorDomElements){
ARjs.
Source.prototype.onResizeElement = function(mirrorDomElements){
var _this = this
var _this = this
var screenWidth = window.innerWidth
var screenWidth = window.innerWidth
var screenHeight = window.innerHeight
var screenHeight = window.innerHeight
...
@@ -3304,7 +3339,7 @@ THREEx.ArToolkitSource.prototype.onResizeElement = function(mirrorDomElements){
...
@@ -3304,7 +3339,7 @@ THREEx.ArToolkitSource.prototype.onResizeElement = function(mirrorDomElements){
})
})
}
}
THREEx.ArToolkit
Source.prototype.copyElementSizeTo = function(otherElement){
ARjs.
Source.prototype.copyElementSizeTo = function(otherElement){
otherElement.style.width = this.domElement.style.width
otherElement.style.width = this.domElement.style.width
otherElement.style.height = this.domElement.style.height
otherElement.style.height = this.domElement.style.height
otherElement.style.marginLeft = this.domElement.style.marginLeft
otherElement.style.marginLeft = this.domElement.style.marginLeft
...
@@ -3315,7 +3350,7 @@ THREEx.ArToolkitSource.prototype.copyElementSizeTo = function(otherElement){
...
@@ -3315,7 +3350,7 @@ THREEx.ArToolkitSource.prototype.copyElementSizeTo = function(otherElement){
// Code Separator
// Code Separator
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkit
Source.prototype.copySizeTo = function(){
ARjs.
Source.prototype.copySizeTo = function(){
console.warn('obsolete function arToolkitSource.copySizeTo. Use arToolkitSource.copyElementSizeTo' )
console.warn('obsolete function arToolkitSource.copySizeTo. Use arToolkitSource.copyElementSizeTo' )
this.copyElementSizeTo.apply(this, arguments)
this.copyElementSizeTo.apply(this, arguments)
}
}
...
@@ -3324,14 +3359,15 @@ THREEx.ArToolkitSource.prototype.copySizeTo = function(){
...
@@ -3324,14 +3359,15 @@ THREEx.ArToolkitSource.prototype.copySizeTo = function(){
// Code Separator
// Code Separator
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
THREEx.ArToolkitSource.prototype.onResize = function(arToolkitContext, renderer, camera){
ARjs.Source.prototype.onResize = function(arToolkitContext, renderer, camera){
var trackingBackend = arToolkitContext.parameters.trackingBackend
if( arguments.length !== 3 ){
if( arguments.length !== 3 ){
console.warn('obsolete function arToolkitSource.onResize. Use arToolkitSource.onResizeElement' )
console.warn('obsolete function arToolkitSource.onResize. Use arToolkitSource.onResizeElement' )
return this.onResizeElement.apply(this, arguments)
return this.onResizeElement.apply(this, arguments)
}
}
var trackingBackend = arToolkitContext.parameters.trackingBackend
// RESIZE DOMELEMENT
// RESIZE DOMELEMENT
if( trackingBackend === 'artoolkit' ){
if( trackingBackend === 'artoolkit' ){
...
...
webvr-polyfill/build/artoolkit-webvr-polyfill.min.js
浏览文件 @
63242551
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录