Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cqiang1993
AR.js
提交
63955108
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(gitcode.net)2024年7月9日维护升级公告
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
63955108
编写于
8月 26, 2019
作者:
N
nicolo.carpignoli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Last commit before release
上级
17479281
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
499 addition
and
525 deletion
+499
-525
CHANGELOG.md
CHANGELOG.md
+4
-0
README.md
README.md
+1
-1
aframe/build/aframe-ar.js
aframe/build/aframe-ar.js
+226
-241
aframe/build/aframe-ar.min.js
aframe/build/aframe-ar.min.js
+1
-1
aframe/src/system-arjs.js
aframe/src/system-arjs.js
+259
-274
package.json
package.json
+1
-1
three.js/build/ar.js
three.js/build/ar.js
+1
-1
three.js/build/ar.lean.js
three.js/build/ar.lean.js
+1
-1
three.js/build/ar.lean.min.js
three.js/build/ar.lean.min.js
+1
-1
three.js/build/ar.min.js
three.js/build/ar.min.js
+1
-1
three.js/contribs/portableAR.js/build/portable-ar.js
three.js/contribs/portableAR.js/build/portable-ar.js
+1
-1
three.js/contribs/portableAR.js/build/portable-ar.min.js
three.js/contribs/portableAR.js/build/portable-ar.min.js
+1
-1
three.js/src/threex/threex-artoolkitcontext.js
three.js/src/threex/threex-artoolkitcontext.js
+1
-1
未找到文件。
CHANGELOG.md
浏览文件 @
63955108
# 1.7.8
-
removed massive 'resize' event dispatch
# 1.7.7
-
added event when camera video stream has been appended to the DOM tree (
`arjs-video-loaded`
)
...
...
README.md
浏览文件 @
63955108
...
...
@@ -79,7 +79,7 @@ More details about markers:
<!doctype HTML>
<html>
<script
src=
"https://aframe.io/releases/0.9.2/aframe.min.js"
></script>
<script
src=
"https://cdn.rawgit.com/jeromeetienne/AR.js/1.7.
7
/aframe/build/aframe-ar.js"
></script>
<script
src=
"https://cdn.rawgit.com/jeromeetienne/AR.js/1.7.
8
/aframe/build/aframe-ar.js"
></script>
<body
style=
'margin : 0px; overflow: hidden;'
>
<a-scene
embedded
arjs
>
<a-marker
preset=
"hiro"
>
...
...
aframe/build/aframe-ar.js
浏览文件 @
63955108
...
...
@@ -5308,7 +5308,7 @@ Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype );
// ARjs.Context.baseURL = '../'
// default to github page
ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/'
ARjs.Context.REVISION = '1.7.
7
';
ARjs.Context.REVISION = '1.7.
8
';
/**
* Create a default camera for this trackingBackend
...
...
@@ -8601,278 +8601,263 @@ AFRAME.registerComponent('arjs-hit-testing', {
}
});
AFRAME.registerSystem('arjs', {
schema: {
trackingMethod : {
type: 'string',
default: 'best',
},
debugUIEnabled :{
type: 'boolean',
default: true,
},
areaLearningButton : {
type: 'boolean',
default: true,
},
performanceProfile : {
type: 'string',
default: 'default',
},
tangoPointCloudEnabled : {
type: 'boolean',
default: false,
},
// old parameters
debug : {
type: 'boolean',
default: false
},
detectionMode : {
type: 'string',
default: '',
},
matrixCodeType : {
type: 'string',
default: '',
},
patternRatio : {
type: 'number',
default: -1,
},
cameraParametersUrl : {
type: 'string',
default: '',
},
maxDetectionRate : {
type: 'number',
default: -1
},
sourceType : {
type: 'string',
default: '',
},
sourceUrl : {
type: 'string',
default: '',
},
sourceWidth : {
type: 'number',
default: -1
},
sourceHeight : {
type: 'number',
default: -1
},
deviceId : {
type: 'string',
default: ''
},
displayWidth : {
type: 'number',
default: -1
},
displayHeight : {
type: 'number',
default: -1
},
canvasWidth : {
type: 'number',
default: -1
},
canvasHeight : {
type: 'number',
default: -1
},
},
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
schema: {
trackingMethod: {
type: 'string',
default: 'best',
},
debugUIEnabled: {
type: 'boolean',
default: true,
},
areaLearningButton: {
type: 'boolean',
default: true,
},
performanceProfile: {
type: 'string',
default: 'default',
},
tangoPointCloudEnabled: {
type: 'boolean',
default: false,
},
init: function () {
var _this = this
// old parameters
debug: {
type: 'boolean',
default: false
},
detectionMode: {
type: 'string',
default: '',
},
matrixCodeType: {
type: 'string',
default: '',
},
patternRatio: {
type: 'number',
default: -1,
},
cameraParametersUrl: {
type: 'string',
default: '',
},
maxDetectionRate: {
type: 'number',
default: -1
},
sourceType: {
type: 'string',
default: '',
},
sourceUrl: {
type: 'string',
default: '',
},
sourceWidth: {
type: 'number',
default: -1
},
sourceHeight: {
type: 'number',
default: -1
},
deviceId: {
type: 'string',
default: ''
},
displayWidth: {
type: 'number',
default: -1
},
displayHeight: {
type: 'number',
default: -1
},
canvasWidth: {
type: 'number',
default: -1
},
canvasHeight: {
type: 'number',
default: -1
},
},
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// setup arProfile
//////////////////////////////////////////////////////////////////////////////
var arProfile = this._arProfile = new ARjs.Profile()
.trackingMethod(this.data.trackingMethod)
.performance(this.data.performanceProfile)
.defaultMarker()
init: function () {
var _this = this
//////////////////////////////////////////////////////////////////////////////
// setup arProfile
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// honor this.data and setup arProfile with it
//////////////////////////////////////////////////////////////////////////////
var arProfile = this._arProfile = new ARjs.Profile()
.trackingMethod(this.data.trackingMethod)
.performance(this.data.performanceProfile)
.defaultMarker()
// honor this.data and push what has been modified into arProfile
if( this.data.debug !== false ) arProfile.contextParameters.debug = this.data.debug
if( this.data.detectionMode !== '' ) arProfile.contextParameters.detectionMode = this.data.detectionMode
if( this.data.matrixCodeType !== '' ) arProfile.contextParameters.matrixCodeType = this.data.matrixCodeType
if( this.data.patternRatio !== -1 ) arProfile.contextParameters.patternRatio = this.data.patternRatio
if( this.data.cameraParametersUrl !== '' ) arProfile.contextParameters.cameraParametersUrl = this.data.cameraParametersUrl
if( this.data.maxDetectionRate !== -1 ) arProfile.contextParameters.maxDetectionRate = this.data.maxDetectionRate
if( this.data.canvasWidth !== -1 ) arProfile.contextParameters.canvasWidth = this.data.canvasWidth
if( this.data.canvasHeight !== -1 ) arProfile.contextParameters.canvasHeight = this.data.canvasHeight
if( this.data.sourceType !== '' ) arProfile.sourceParameters.sourceType = this.data.sourceType
if( this.data.sourceUrl !== '' ) arProfile.sourceParameters.sourceUrl = this.data.sourceUrl
if( this.data.sourceWidth !== -1 ) arProfile.sourceParameters.sourceWidth = this.data.sourceWidth
if( this.data.sourceHeight !== -1 ) arProfile.sourceParameters.sourceHeight = this.data.sourceHeight
if( this.data.deviceId !== '' ) arProfile.sourceParameters.deviceId = this.data.deviceId
if( this.data.displayWidth !== -1 ) arProfile.sourceParameters.displayWidth = this.data.displayWidth
if( this.data.displayHeight !== -1 ) arProfile.sourceParameters.displayHeight = this.data.displayHeight
arProfile.checkIfValid()
//////////////////////////////////////////////////////////////////////////////
// honor this.data and setup arProfile with it
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
// honor this.data and push what has been modified into arProfile
if (this.data.debug !== false) arProfile.contextParameters.debug = this.data.debug
if (this.data.detectionMode !== '') arProfile.contextParameters.detectionMode = this.data.detectionMode
if (this.data.matrixCodeType !== '') arProfile.contextParameters.matrixCodeType = this.data.matrixCodeType
if (this.data.patternRatio !== -1) arProfile.contextParameters.patternRatio = this.data.patternRatio
if (this.data.cameraParametersUrl !== '') arProfile.contextParameters.cameraParametersUrl = this.data.cameraParametersUrl
if (this.data.maxDetectionRate !== -1) arProfile.contextParameters.maxDetectionRate = this.data.maxDetectionRate
if (this.data.canvasWidth !== -1) arProfile.contextParameters.canvasWidth = this.data.canvasWidth
if (this.data.canvasHeight !== -1) arProfile.contextParameters.canvasHeight = this.data.canvasHeight
if (this.data.sourceType !== '') arProfile.sourceParameters.sourceType = this.data.sourceType
if (this.data.sourceUrl !== '') arProfile.sourceParameters.sourceUrl = this.data.sourceUrl
if (this.data.sourceWidth !== -1) arProfile.sourceParameters.sourceWidth = this.data.sourceWidth
if (this.data.sourceHeight !== -1) arProfile.sourceParameters.sourceHeight = this.data.sourceHeight
if (this.data.deviceId !== '') arProfile.sourceParameters.deviceId = this.data.deviceId
if (this.data.displayWidth !== -1) arProfile.sourceParameters.displayWidth = this.data.displayWidth
if (this.data.displayHeight !== -1) arProfile.sourceParameters.displayHeight = this.data.displayHeight
arProfile.checkIfValid()
this._arSession = null
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
_this.isReady = false
_this.needsOverride = true
this._arSession = null
// wait until the renderer is isReady
this.el.sceneEl.addEventListener('renderstart', function(){
var scene = _this.el.sceneEl.object3D
var camera = _this.el.sceneEl.camera
var renderer = _this.el.sceneEl.renderer
_this.isReady = false
_this.needsOverride = true
//////////////////////////////////////////////////////////////////////////////
// build ARjs.Session
//////////////////////////////////////////////////////////////////////////////
var arSession = _this._arSession = new ARjs.Session({
scene: scene,
renderer: renderer,
camera: camera,
sourceParameters: arProfile.sourceParameters,
contextParameters: arProfile.contextParameters
})
// wait until the renderer is isReady
this.el.sceneEl.addEventListener('renderstart', function () {
var scene = _this.el.sceneEl.object3D
var camera = _this.el.sceneEl.camera
var renderer = _this.el.sceneEl.renderer
//////////////////////////////////////////////////////////////////////////////
// tango specifics - _tangoPointCloud
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// build ARjs.Session
//////////////////////////////////////////////////////////////////////////////
var arSession = _this._arSession = new ARjs.Session({
scene: scene,
renderer: renderer,
camera: camera,
sourceParameters: arProfile.sourceParameters,
contextParameters: arProfile.contextParameters
})
_this._tangoPointCloud = null
if( arProfile.contextParameters.trackingBackend === 'tango' && _this.data.tangoPointCloudEnabled ){
// init tangoPointCloud
var tangoPointCloud = _this._tangoPointCloud = new ARjs.TangoPointCloud(arSession)
scene.add(tangoPointCloud.object3d)
}
//////////////////////////////////////////////////////////////////////////////
// tango specifics - _tangoPointCloud
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// tango specifics - _tangoVideoMesh
//////////////////////////////////////////////////////////////////////////////
_this._tangoPointCloud = null
if (arProfile.contextParameters.trackingBackend === 'tango' && _this.data.tangoPointCloudEnabled) {
// init tangoPointCloud
var tangoPointCloud = _this._tangoPointCloud = new ARjs.TangoPointCloud(arSession)
scene.add(tangoPointCloud.object3d)
}
_this._tangoVideoMesh = null
if( arProfile.contextParameters.trackingBackend === 'tango' ){
// init tangoVideoMesh
var tangoVideoMesh = _this._tangoVideoMesh = new ARjs.TangoVideoMesh(arSession)
// override renderer.render to render tangoVideoMesh
var rendererRenderFct = renderer.render;
renderer.render = function customRender(scene, camera, renderTarget, forceClear) {
renderer.autoClear = false;
// clear it all
renderer.clear()
// render tangoVideoMesh
if( arProfile.contextParameters.trackingBackend === 'tango' ){
// FIXME fails on three.js r84
// render sceneOrtho
rendererRenderFct.call(renderer, tangoVideoMesh._sceneOrtho, tangoVideoMesh._cameraOrtho, renderTarget, forceClear)
// Render the perspective scene
renderer.clearDepth()
}
// render 3d scene
rendererRenderFct.call(renderer, scene, camera, renderTarget, forceClear);
}
}
//////////////////////////////////////////////////////////////////////////////
// tango specifics - _tangoVideoMesh
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
_this._tangoVideoMesh = null
if (arProfile.contextParameters.trackingBackend === 'tango') {
// init tangoVideoMesh
var tangoVideoMesh = _this._tangoVideoMesh = new ARjs.TangoVideoMesh(arSession)
// override renderer.render to render tangoVideoMesh
var rendererRenderFct = renderer.render;
renderer.render = function customRender(scene, camera, renderTarget, forceClear) {
renderer.autoClear = false;
// clear it all
renderer.clear()
// render tangoVideoMesh
if (arProfile.contextParameters.trackingBackend === 'tango') {
// FIXME fails on three.js r84
// render sceneOrtho
rendererRenderFct.call(renderer, tangoVideoMesh._sceneOrtho, tangoVideoMesh._cameraOrtho, renderTarget, forceClear)
// Render the perspective scene
renderer.clearDepth()
}
// render 3d scene
rendererRenderFct.call(renderer, scene, camera, renderTarget, forceClear);
}
}
_this.isReady = true
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// awefull resize trick
//////////////////////////////////////////////////////////////////////////////
// KLUDGE
window.addEventListener('resize', onResize)
function onResize(){
var arSource = _this._arSession.arSource
// ugly kludge to get resize on aframe... not even sure it works
if( arProfile.contextParameters.trackingBackend !== 'tango' ){
arSource.copyElementSizeTo(document.body)
}
_this.isReady = true
// fixing a-frame css
var buttonElement = document.querySelector('.a-enter-vr')
if( buttonElement ){
buttonElement.style.position = 'fixed'
}
}
//////////////////////////////////////////////////////////////////////////////
// awefull resize trick
//////////////////////////////////////////////////////////////////////////////
// KLUDGE
window.addEventListener('resize', onResize)
function onResize() {
var arSource = _this._arSession.arSource
// ugly kludge to get resize on aframe... not even sure it works
if (arProfile.contextParameters.trackingBackend !== 'tango') {
arSource.copyElementSizeTo(document.body)
}
// fixing a-frame css
var buttonElement = document.querySelector('.a-enter-vr')
if (buttonElement) {
buttonElement.style.position = 'fixed'
}
}
//////////////////////////////////////////////////////////////////////////////
// honor .debugUIEnabled
//////////////////////////////////////////////////////////////////////////////
if( _this.data.debugUIEnabled ) initDebugUI()
function initDebugUI(){
// get or create containerElement
var containerElement = document.querySelector('#arjsDebugUIContainer')
if( containerElement === null ){
containerElement = document.createElement('div')
containerElement.id = 'arjsDebugUIContainer'
containerElement.setAttribute('style', 'position: fixed; bottom: 10px; width:100%; text-align: center; z-index: 1;color: grey;')
document.body.appendChild(containerElement)
}
// create sessionDebugUI
var sessionDebugUI = new ARjs.SessionDebugUI(arSession)
containerElement.appendChild(sessionDebugUI.domElement)
}
})
//////////////////////////////////////////////////////////////////////////////
// honor .debugUIEnabled
//////////////////////////////////////////////////////////////////////////////
if (_this.data.debugUIEnabled) initDebugUI()
function initDebugUI() {
// get or create containerElement
var containerElement = document.querySelector('#arjsDebugUIContainer')
if (containerElement === null) {
containerElement = document.createElement('div')
containerElement.id = 'arjsDebugUIContainer'
containerElement.setAttribute('style', 'position: fixed; bottom: 10px; width:100%; text-align: center; z-index: 1;color: grey;')
document.body.appendChild(containerElement)
}
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
// TODO this is crappy - code an exponential backoff - max 1 seconds
// KLUDGE: kludge to write a 'resize' event
var startedAt = Date.now()
var timerId = setInterval(function(){
if( Date.now() - startedAt > 10000*1000 ){
clearInterval(timerId)
return
}
// onResize()
window.dispatchEvent(new Event('resize'));
}, 1000/30)
},
// create sessionDebugUI
var sessionDebugUI = new ARjs.SessionDebugUI(arSession)
containerElement.appendChild(sessionDebugUI.domElement)
}
})
},
tick : function(now, delta)
{
var _this = this
tick: function (now, delta)
{
var _this = this
// skip it if not yet isInitialised
if( this.isReady === false )
return
// skip it if not yet isInitialised
if (this.isReady === false)
return
var arSession = this._arSession
var arSession = this._arSession
// update arSession
this._arSession.update()
// update arSession
this._arSession.update()
if( _this._tangoVideoMesh !== null )
_this._tangoVideoMesh.update()
if (_this._tangoVideoMesh !== null)
_this._tangoVideoMesh.update()
// copy projection matrix to camera
this._arSession.onResize()
},
// copy projection matrix to camera
this._arSession.onResize()
},
})
aframe/build/aframe-ar.min.js
浏览文件 @
63955108
此差异已折叠。
点击以展开。
aframe/src/system-arjs.js
浏览文件 @
63955108
AFRAME
.
registerSystem
(
'
arjs
'
,
{
schema
:
{
trackingMethod
:
{
type
:
'
string
'
,
default
:
'
best
'
,
},
debugUIEnabled
:{
type
:
'
boolean
'
,
default
:
true
,
},
areaLearningButton
:
{
type
:
'
boolean
'
,
default
:
true
,
},
performanceProfile
:
{
type
:
'
string
'
,
default
:
'
default
'
,
},
tangoPointCloudEnabled
:
{
type
:
'
boolean
'
,
default
:
false
,
},
// old parameters
debug
:
{
type
:
'
boolean
'
,
default
:
false
},
detectionMode
:
{
type
:
'
string
'
,
default
:
''
,
},
matrixCodeType
:
{
type
:
'
string
'
,
default
:
''
,
},
patternRatio
:
{
type
:
'
number
'
,
default
:
-
1
,
},
cameraParametersUrl
:
{
type
:
'
string
'
,
default
:
''
,
},
maxDetectionRate
:
{
type
:
'
number
'
,
default
:
-
1
},
sourceType
:
{
type
:
'
string
'
,
default
:
''
,
},
sourceUrl
:
{
type
:
'
string
'
,
default
:
''
,
},
sourceWidth
:
{
type
:
'
number
'
,
default
:
-
1
},
sourceHeight
:
{
type
:
'
number
'
,
default
:
-
1
},
deviceId
:
{
type
:
'
string
'
,
default
:
''
},
displayWidth
:
{
type
:
'
number
'
,
default
:
-
1
},
displayHeight
:
{
type
:
'
number
'
,
default
:
-
1
},
canvasWidth
:
{
type
:
'
number
'
,
default
:
-
1
},
canvasHeight
:
{
type
:
'
number
'
,
default
:
-
1
},
},
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
init
:
function
()
{
var
_this
=
this
//////////////////////////////////////////////////////////////////////////////
// setup arProfile
//////////////////////////////////////////////////////////////////////////////
var
arProfile
=
this
.
_arProfile
=
new
ARjs
.
Profile
()
.
trackingMethod
(
this
.
data
.
trackingMethod
)
.
performance
(
this
.
data
.
performanceProfile
)
.
defaultMarker
()
//////////////////////////////////////////////////////////////////////////////
// honor this.data and setup arProfile with it
//////////////////////////////////////////////////////////////////////////////
// honor this.data and push what has been modified into arProfile
if
(
this
.
data
.
debug
!==
false
)
arProfile
.
contextParameters
.
debug
=
this
.
data
.
debug
if
(
this
.
data
.
detectionMode
!==
''
)
arProfile
.
contextParameters
.
detectionMode
=
this
.
data
.
detectionMode
if
(
this
.
data
.
matrixCodeType
!==
''
)
arProfile
.
contextParameters
.
matrixCodeType
=
this
.
data
.
matrixCodeType
if
(
this
.
data
.
patternRatio
!==
-
1
)
arProfile
.
contextParameters
.
patternRatio
=
this
.
data
.
patternRatio
if
(
this
.
data
.
cameraParametersUrl
!==
''
)
arProfile
.
contextParameters
.
cameraParametersUrl
=
this
.
data
.
cameraParametersUrl
if
(
this
.
data
.
maxDetectionRate
!==
-
1
)
arProfile
.
contextParameters
.
maxDetectionRate
=
this
.
data
.
maxDetectionRate
if
(
this
.
data
.
canvasWidth
!==
-
1
)
arProfile
.
contextParameters
.
canvasWidth
=
this
.
data
.
canvasWidth
if
(
this
.
data
.
canvasHeight
!==
-
1
)
arProfile
.
contextParameters
.
canvasHeight
=
this
.
data
.
canvasHeight
if
(
this
.
data
.
sourceType
!==
''
)
arProfile
.
sourceParameters
.
sourceType
=
this
.
data
.
sourceType
if
(
this
.
data
.
sourceUrl
!==
''
)
arProfile
.
sourceParameters
.
sourceUrl
=
this
.
data
.
sourceUrl
if
(
this
.
data
.
sourceWidth
!==
-
1
)
arProfile
.
sourceParameters
.
sourceWidth
=
this
.
data
.
sourceWidth
if
(
this
.
data
.
sourceHeight
!==
-
1
)
arProfile
.
sourceParameters
.
sourceHeight
=
this
.
data
.
sourceHeight
if
(
this
.
data
.
deviceId
!==
''
)
arProfile
.
sourceParameters
.
deviceId
=
this
.
data
.
deviceId
if
(
this
.
data
.
displayWidth
!==
-
1
)
arProfile
.
sourceParameters
.
displayWidth
=
this
.
data
.
displayWidth
if
(
this
.
data
.
displayHeight
!==
-
1
)
arProfile
.
sourceParameters
.
displayHeight
=
this
.
data
.
displayHeight
arProfile
.
checkIfValid
()
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
this
.
_arSession
=
null
_this
.
isReady
=
false
_this
.
needsOverride
=
true
// wait until the renderer is isReady
this
.
el
.
sceneEl
.
addEventListener
(
'
renderstart
'
,
function
(){
var
scene
=
_this
.
el
.
sceneEl
.
object3D
var
camera
=
_this
.
el
.
sceneEl
.
camera
var
renderer
=
_this
.
el
.
sceneEl
.
renderer
//////////////////////////////////////////////////////////////////////////////
// build ARjs.Session
//////////////////////////////////////////////////////////////////////////////
var
arSession
=
_this
.
_arSession
=
new
ARjs
.
Session
({
scene
:
scene
,
renderer
:
renderer
,
camera
:
camera
,
sourceParameters
:
arProfile
.
sourceParameters
,
contextParameters
:
arProfile
.
contextParameters
})
//////////////////////////////////////////////////////////////////////////////
// tango specifics - _tangoPointCloud
//////////////////////////////////////////////////////////////////////////////
_this
.
_tangoPointCloud
=
null
if
(
arProfile
.
contextParameters
.
trackingBackend
===
'
tango
'
&&
_this
.
data
.
tangoPointCloudEnabled
){
// init tangoPointCloud
var
tangoPointCloud
=
_this
.
_tangoPointCloud
=
new
ARjs
.
TangoPointCloud
(
arSession
)
scene
.
add
(
tangoPointCloud
.
object3d
)
}
//////////////////////////////////////////////////////////////////////////////
// tango specifics - _tangoVideoMesh
//////////////////////////////////////////////////////////////////////////////
_this
.
_tangoVideoMesh
=
null
if
(
arProfile
.
contextParameters
.
trackingBackend
===
'
tango
'
){
// init tangoVideoMesh
var
tangoVideoMesh
=
_this
.
_tangoVideoMesh
=
new
ARjs
.
TangoVideoMesh
(
arSession
)
// override renderer.render to render tangoVideoMesh
var
rendererRenderFct
=
renderer
.
render
;
renderer
.
render
=
function
customRender
(
scene
,
camera
,
renderTarget
,
forceClear
)
{
renderer
.
autoClear
=
false
;
// clear it all
renderer
.
clear
()
// render tangoVideoMesh
if
(
arProfile
.
contextParameters
.
trackingBackend
===
'
tango
'
){
// FIXME fails on three.js r84
// render sceneOrtho
rendererRenderFct
.
call
(
renderer
,
tangoVideoMesh
.
_sceneOrtho
,
tangoVideoMesh
.
_cameraOrtho
,
renderTarget
,
forceClear
)
// Render the perspective scene
renderer
.
clearDepth
()
}
// render 3d scene
rendererRenderFct
.
call
(
renderer
,
scene
,
camera
,
renderTarget
,
forceClear
);
}
}
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
_this
.
isReady
=
true
//////////////////////////////////////////////////////////////////////////////
// awefull resize trick
//////////////////////////////////////////////////////////////////////////////
// KLUDGE
window
.
addEventListener
(
'
resize
'
,
onResize
)
function
onResize
(){
var
arSource
=
_this
.
_arSession
.
arSource
// ugly kludge to get resize on aframe... not even sure it works
if
(
arProfile
.
contextParameters
.
trackingBackend
!==
'
tango
'
){
arSource
.
copyElementSizeTo
(
document
.
body
)
}
// fixing a-frame css
var
buttonElement
=
document
.
querySelector
(
'
.a-enter-vr
'
)
if
(
buttonElement
){
buttonElement
.
style
.
position
=
'
fixed
'
}
}
//////////////////////////////////////////////////////////////////////////////
// honor .debugUIEnabled
//////////////////////////////////////////////////////////////////////////////
if
(
_this
.
data
.
debugUIEnabled
)
initDebugUI
()
function
initDebugUI
(){
// get or create containerElement
var
containerElement
=
document
.
querySelector
(
'
#arjsDebugUIContainer
'
)
if
(
containerElement
===
null
){
containerElement
=
document
.
createElement
(
'
div
'
)
containerElement
.
id
=
'
arjsDebugUIContainer
'
containerElement
.
setAttribute
(
'
style
'
,
'
position: fixed; bottom: 10px; width:100%; text-align: center; z-index: 1;color: grey;
'
)
document
.
body
.
appendChild
(
containerElement
)
}
// create sessionDebugUI
var
sessionDebugUI
=
new
ARjs
.
SessionDebugUI
(
arSession
)
containerElement
.
appendChild
(
sessionDebugUI
.
domElement
)
}
})
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
// TODO this is crappy - code an exponential backoff - max 1 seconds
// KLUDGE: kludge to write a 'resize' event
var
startedAt
=
Date
.
now
()
var
timerId
=
setInterval
(
function
(){
if
(
Date
.
now
()
-
startedAt
>
10000
*
1000
){
clearInterval
(
timerId
)
return
}
// onResize()
window
.
dispatchEvent
(
new
Event
(
'
resize
'
));
},
1000
/
30
)
},
tick
:
function
(
now
,
delta
){
var
_this
=
this
// skip it if not yet isInitialised
if
(
this
.
isReady
===
false
)
return
var
arSession
=
this
.
_arSession
// update arSession
this
.
_arSession
.
update
()
if
(
_this
.
_tangoVideoMesh
!==
null
)
_this
.
_tangoVideoMesh
.
update
()
// copy projection matrix to camera
this
.
_arSession
.
onResize
()
},
schema
:
{
trackingMethod
:
{
type
:
'
string
'
,
default
:
'
best
'
,
},
debugUIEnabled
:
{
type
:
'
boolean
'
,
default
:
true
,
},
areaLearningButton
:
{
type
:
'
boolean
'
,
default
:
true
,
},
performanceProfile
:
{
type
:
'
string
'
,
default
:
'
default
'
,
},
tangoPointCloudEnabled
:
{
type
:
'
boolean
'
,
default
:
false
,
},
// old parameters
debug
:
{
type
:
'
boolean
'
,
default
:
false
},
detectionMode
:
{
type
:
'
string
'
,
default
:
''
,
},
matrixCodeType
:
{
type
:
'
string
'
,
default
:
''
,
},
patternRatio
:
{
type
:
'
number
'
,
default
:
-
1
,
},
cameraParametersUrl
:
{
type
:
'
string
'
,
default
:
''
,
},
maxDetectionRate
:
{
type
:
'
number
'
,
default
:
-
1
},
sourceType
:
{
type
:
'
string
'
,
default
:
''
,
},
sourceUrl
:
{
type
:
'
string
'
,
default
:
''
,
},
sourceWidth
:
{
type
:
'
number
'
,
default
:
-
1
},
sourceHeight
:
{
type
:
'
number
'
,
default
:
-
1
},
deviceId
:
{
type
:
'
string
'
,
default
:
''
},
displayWidth
:
{
type
:
'
number
'
,
default
:
-
1
},
displayHeight
:
{
type
:
'
number
'
,
default
:
-
1
},
canvasWidth
:
{
type
:
'
number
'
,
default
:
-
1
},
canvasHeight
:
{
type
:
'
number
'
,
default
:
-
1
},
},
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
init
:
function
()
{
var
_this
=
this
//////////////////////////////////////////////////////////////////////////////
// setup arProfile
//////////////////////////////////////////////////////////////////////////////
var
arProfile
=
this
.
_arProfile
=
new
ARjs
.
Profile
()
.
trackingMethod
(
this
.
data
.
trackingMethod
)
.
performance
(
this
.
data
.
performanceProfile
)
.
defaultMarker
()
//////////////////////////////////////////////////////////////////////////////
// honor this.data and setup arProfile with it
//////////////////////////////////////////////////////////////////////////////
// honor this.data and push what has been modified into arProfile
if
(
this
.
data
.
debug
!==
false
)
arProfile
.
contextParameters
.
debug
=
this
.
data
.
debug
if
(
this
.
data
.
detectionMode
!==
''
)
arProfile
.
contextParameters
.
detectionMode
=
this
.
data
.
detectionMode
if
(
this
.
data
.
matrixCodeType
!==
''
)
arProfile
.
contextParameters
.
matrixCodeType
=
this
.
data
.
matrixCodeType
if
(
this
.
data
.
patternRatio
!==
-
1
)
arProfile
.
contextParameters
.
patternRatio
=
this
.
data
.
patternRatio
if
(
this
.
data
.
cameraParametersUrl
!==
''
)
arProfile
.
contextParameters
.
cameraParametersUrl
=
this
.
data
.
cameraParametersUrl
if
(
this
.
data
.
maxDetectionRate
!==
-
1
)
arProfile
.
contextParameters
.
maxDetectionRate
=
this
.
data
.
maxDetectionRate
if
(
this
.
data
.
canvasWidth
!==
-
1
)
arProfile
.
contextParameters
.
canvasWidth
=
this
.
data
.
canvasWidth
if
(
this
.
data
.
canvasHeight
!==
-
1
)
arProfile
.
contextParameters
.
canvasHeight
=
this
.
data
.
canvasHeight
if
(
this
.
data
.
sourceType
!==
''
)
arProfile
.
sourceParameters
.
sourceType
=
this
.
data
.
sourceType
if
(
this
.
data
.
sourceUrl
!==
''
)
arProfile
.
sourceParameters
.
sourceUrl
=
this
.
data
.
sourceUrl
if
(
this
.
data
.
sourceWidth
!==
-
1
)
arProfile
.
sourceParameters
.
sourceWidth
=
this
.
data
.
sourceWidth
if
(
this
.
data
.
sourceHeight
!==
-
1
)
arProfile
.
sourceParameters
.
sourceHeight
=
this
.
data
.
sourceHeight
if
(
this
.
data
.
deviceId
!==
''
)
arProfile
.
sourceParameters
.
deviceId
=
this
.
data
.
deviceId
if
(
this
.
data
.
displayWidth
!==
-
1
)
arProfile
.
sourceParameters
.
displayWidth
=
this
.
data
.
displayWidth
if
(
this
.
data
.
displayHeight
!==
-
1
)
arProfile
.
sourceParameters
.
displayHeight
=
this
.
data
.
displayHeight
arProfile
.
checkIfValid
()
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
this
.
_arSession
=
null
_this
.
isReady
=
false
_this
.
needsOverride
=
true
// wait until the renderer is isReady
this
.
el
.
sceneEl
.
addEventListener
(
'
renderstart
'
,
function
()
{
var
scene
=
_this
.
el
.
sceneEl
.
object3D
var
camera
=
_this
.
el
.
sceneEl
.
camera
var
renderer
=
_this
.
el
.
sceneEl
.
renderer
//////////////////////////////////////////////////////////////////////////////
// build ARjs.Session
//////////////////////////////////////////////////////////////////////////////
var
arSession
=
_this
.
_arSession
=
new
ARjs
.
Session
({
scene
:
scene
,
renderer
:
renderer
,
camera
:
camera
,
sourceParameters
:
arProfile
.
sourceParameters
,
contextParameters
:
arProfile
.
contextParameters
})
//////////////////////////////////////////////////////////////////////////////
// tango specifics - _tangoPointCloud
//////////////////////////////////////////////////////////////////////////////
_this
.
_tangoPointCloud
=
null
if
(
arProfile
.
contextParameters
.
trackingBackend
===
'
tango
'
&&
_this
.
data
.
tangoPointCloudEnabled
)
{
// init tangoPointCloud
var
tangoPointCloud
=
_this
.
_tangoPointCloud
=
new
ARjs
.
TangoPointCloud
(
arSession
)
scene
.
add
(
tangoPointCloud
.
object3d
)
}
//////////////////////////////////////////////////////////////////////////////
// tango specifics - _tangoVideoMesh
//////////////////////////////////////////////////////////////////////////////
_this
.
_tangoVideoMesh
=
null
if
(
arProfile
.
contextParameters
.
trackingBackend
===
'
tango
'
)
{
// init tangoVideoMesh
var
tangoVideoMesh
=
_this
.
_tangoVideoMesh
=
new
ARjs
.
TangoVideoMesh
(
arSession
)
// override renderer.render to render tangoVideoMesh
var
rendererRenderFct
=
renderer
.
render
;
renderer
.
render
=
function
customRender
(
scene
,
camera
,
renderTarget
,
forceClear
)
{
renderer
.
autoClear
=
false
;
// clear it all
renderer
.
clear
()
// render tangoVideoMesh
if
(
arProfile
.
contextParameters
.
trackingBackend
===
'
tango
'
)
{
// FIXME fails on three.js r84
// render sceneOrtho
rendererRenderFct
.
call
(
renderer
,
tangoVideoMesh
.
_sceneOrtho
,
tangoVideoMesh
.
_cameraOrtho
,
renderTarget
,
forceClear
)
// Render the perspective scene
renderer
.
clearDepth
()
}
// render 3d scene
rendererRenderFct
.
call
(
renderer
,
scene
,
camera
,
renderTarget
,
forceClear
);
}
}
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
_this
.
isReady
=
true
//////////////////////////////////////////////////////////////////////////////
// awefull resize trick
//////////////////////////////////////////////////////////////////////////////
// KLUDGE
window
.
addEventListener
(
'
resize
'
,
onResize
)
function
onResize
()
{
var
arSource
=
_this
.
_arSession
.
arSource
// ugly kludge to get resize on aframe... not even sure it works
if
(
arProfile
.
contextParameters
.
trackingBackend
!==
'
tango
'
)
{
arSource
.
copyElementSizeTo
(
document
.
body
)
}
// fixing a-frame css
var
buttonElement
=
document
.
querySelector
(
'
.a-enter-vr
'
)
if
(
buttonElement
)
{
buttonElement
.
style
.
position
=
'
fixed
'
}
}
//////////////////////////////////////////////////////////////////////////////
// honor .debugUIEnabled
//////////////////////////////////////////////////////////////////////////////
if
(
_this
.
data
.
debugUIEnabled
)
initDebugUI
()
function
initDebugUI
()
{
// get or create containerElement
var
containerElement
=
document
.
querySelector
(
'
#arjsDebugUIContainer
'
)
if
(
containerElement
===
null
)
{
containerElement
=
document
.
createElement
(
'
div
'
)
containerElement
.
id
=
'
arjsDebugUIContainer
'
containerElement
.
setAttribute
(
'
style
'
,
'
position: fixed; bottom: 10px; width:100%; text-align: center; z-index: 1;color: grey;
'
)
document
.
body
.
appendChild
(
containerElement
)
}
// create sessionDebugUI
var
sessionDebugUI
=
new
ARjs
.
SessionDebugUI
(
arSession
)
containerElement
.
appendChild
(
sessionDebugUI
.
domElement
)
}
})
},
tick
:
function
(
now
,
delta
)
{
var
_this
=
this
// skip it if not yet isInitialised
if
(
this
.
isReady
===
false
)
return
var
arSession
=
this
.
_arSession
// update arSession
this
.
_arSession
.
update
()
if
(
_this
.
_tangoVideoMesh
!==
null
)
_this
.
_tangoVideoMesh
.
update
()
// copy projection matrix to camera
this
.
_arSession
.
onResize
()
},
})
package.json
浏览文件 @
63955108
{
"name"
:
"ar.js"
,
"version"
:
"1.7.
7
"
,
"version"
:
"1.7.
8
"
,
"description"
:
"Efficient Augmented Reality for the Web"
,
"main"
:
""
,
"scripts"
:
{
...
...
three.js/build/ar.js
浏览文件 @
63955108
...
...
@@ -5308,7 +5308,7 @@ Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype );
// ARjs.Context.baseURL = '../'
// default to github page
ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/'
ARjs.Context.REVISION = '1.7.
7
';
ARjs.Context.REVISION = '1.7.
8
';
/**
* Create a default camera for this trackingBackend
three.js/build/ar.lean.js
浏览文件 @
63955108
...
...
@@ -2574,7 +2574,7 @@ Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype );
// ARjs.Context.baseURL = '../'
// default to github page
ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/'
ARjs.Context.REVISION = '1.7.
7
';
ARjs.Context.REVISION = '1.7.
8
';
/**
* Create a default camera for this trackingBackend
...
...
three.js/build/ar.lean.min.js
浏览文件 @
63955108
此差异已折叠。
点击以展开。
three.js/build/ar.min.js
浏览文件 @
63955108
此差异已折叠。
点击以展开。
three.js/contribs/portableAR.js/build/portable-ar.js
浏览文件 @
63955108
...
...
@@ -53806,7 +53806,7 @@ Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype );
// ARjs.Context.baseURL = '../'
// default to github page
ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/'
ARjs.Context.REVISION = '1.7.
7
';
ARjs.Context.REVISION = '1.7.
8
';
/**
* Create a default camera for this trackingBackend
three.js/contribs/portableAR.js/build/portable-ar.min.js
浏览文件 @
63955108
此差异已折叠。
点击以展开。
three.js/src/threex/threex-artoolkitcontext.js
浏览文件 @
63955108
...
...
@@ -76,7 +76,7 @@ Object.assign( ARjs.Context.prototype, THREE.EventDispatcher.prototype );
// ARjs.Context.baseURL = '../'
// default to github page
ARjs
.
Context
.
baseURL
=
'
https://jeromeetienne.github.io/AR.js/three.js/
'
ARjs
.
Context
.
REVISION
=
'
1.7.
7
'
;
ARjs
.
Context
.
REVISION
=
'
1.7.
8
'
;
/**
* Create a default camera for this trackingBackend
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录