提交 63955108 编写于 作者: N nicolo.carpignoli

Last commit before release

上级 17479281
# 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`)
......
......@@ -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">
......
......@@ -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.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()
},
})
{
"name": "ar.js",
"version": "1.7.7",
"version": "1.7.8",
"description": "Efficient Augmented Reality for the Web",
"main": "",
"scripts": {
......
......@@ -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
......@@ -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
......
此差异已折叠。
此差异已折叠。
......@@ -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
......@@ -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.
先完成此消息的编辑!
想要评论请 注册