提交 160f925b 编写于 作者: J Jerome Etienne

more work

上级 6fa0e41d
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
// to keep backward compatibility with deprecated code
// AFRAME.registerComponent('arjs', buildSystemParameter())
// AFRAME.registerComponent('artoolkit', buildSystemParameter())
// function buildSystemParameter(){ return {
// AFRAME.registerSystem('arjs', {
AFRAME.registerSystem('arjs', {
schema: {
trackingBackend : {
type: 'string',
default: 'artoolkit',
},
areaLearningButton : {
type: 'boolean',
default: true,
},
performanceProfile : {
type: 'string',
default: 'default',
},
// old parameters
debug : {
type: 'boolean',
default: false
},
detectionMode : {
type: 'string',
default: '',
},
matrixCodeType : {
type: 'string',
default: '',
},
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
},
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 = new THREEx.ArToolkitProfile()
arProfile.sourceWebcam()
arProfile.trackingBackend(this.data.trackingBackend)
arProfile.performance(this.data.performanceProfile)
// FIXME temporary placeholder - to reevaluate later
if( this.data.trackingBackend === 'tango' ){
arProfile.sourceImage(THREEx.ArToolkitContext.baseURL + '../data/images/img.jpg')
}
//////////////////////////////////////////////////////////////////////////////
// honor this.data
//////////////////////////////////////////////////////////////////////////////
// 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.cameraParametersUrl !== '' ) arProfile.contextParameters.cameraParametersUrl = this.data.cameraParametersUrl
if( this.data.maxDetectionRate !== -1 ) arProfile.contextParameters.maxDetectionRate = this.data.maxDetectionRate
if( this.data.sourceType !== '' ) arProfile.contextParameters.sourceType = this.data.sourceType
if( this.data.sourceUrl !== '' ) arProfile.contextParameters.sourceUrl = this.data.sourceUrl
if( this.data.sourceWidth !== -1 ) arProfile.contextParameters.sourceWidth = this.data.sourceWidth
if( this.data.sourceHeight !== -1 ) arProfile.contextParameters.sourceHeight = this.data.sourceHeight
if( this.data.displayWidth !== -1 ) arProfile.contextParameters.displayWidth = this.data.displayWidth
if( this.data.displayHeight !== -1 ) arProfile.contextParameters.displayHeight = this.data.displayHeight
if( this.data.canvasWidth !== -1 ) arProfile.contextParameters.canvasWidth = this.data.canvasWidth
if( this.data.canvasHeight !== -1 ) arProfile.contextParameters.canvasHeight = this.data.canvasHeight
////////////////////////////////////////////////////////////////////////////////
// handle arSource
////////////////////////////////////////////////////////////////////////////////
var arSource = new THREEx.ArToolkitSource(arProfile.sourceParameters)
this.arSource = arSource
arSource.init(function onReady(){
// handle resize of renderer
onResize()
// kludge to write a 'resize' event - use exponentialBackoff delay
var startedAt = Date.now()
var exponentialBackoffDelay = 1000/60
setTimeout(function callback(){
if( Date.now() - startedAt > 5*1000 ) return
// update delay
exponentialBackoffDelay *= 1.5;
exponentialBackoffDelay = Math.min(exponentialBackoffDelay, 1*1000)
setTimeout(callback, exponentialBackoffDelay)
// trigger a resize
window.dispatchEvent(new Event('resize'));
}, exponentialBackoffDelay)
})
// handle resize
window.addEventListener('resize', onResize)
function onResize(){
// console.log(_this.el.sceneEl.camera)
var camera = _this.el.sceneEl.camera
var renderer = _this.el.sceneEl.renderer
arSource.onResize2(arContext, renderer, camera)
// ugly kludge to get resize on aframe... not even sure it works
arSource.copyElementSizeTo(document.body)
// change css of 'enter-vr' button
var buttonElement = document.querySelector('.a-enter-vr')
if( buttonElement ) buttonElement.style.position = 'fixed'
}
////////////////////////////////////////////////////////////////////////////////
// initialize arContext
////////////////////////////////////////////////////////////////////////////////
// create atToolkitContext
var arContext = new THREEx.ArToolkitContext(arProfile.contextParameters)
this.arContext = arContext
// initialize it
arContext.init()
arContext.addEventListener('initialized', function(event){
onResize()
})
// tango only - init cameraMesh
arContext.addEventListener('initialized', function(event){
if( _this.data.trackingBackend !== 'tango' ) return
var vrDisplay = arContext._tangoContext.vrDisplay
console.assert(vrDisplay, 'vrDisplay MUST be defined')
// special case for trackingBackend tango
if( arContext.parameters.trackingBackend !== 'tango' ) return
// if vrDisplay isnt for tango do nothing
if( vrDisplay.displayName !== "Tango VR Device" ) return
// init videoPlane
var videoPlane = THREE.WebAR.createVRSeeThroughCameraMesh(vrDisplay)
sceneOrtho.add(videoPlane)
onRenderFcts.push(function(){
// Make sure that the camera is correctly displayed depending on the device and camera orientations.
THREE.WebAR.updateCameraMeshOrientation(vrDisplay, videoPlane)
})
})
//////////////////////////////////////////////////////////////////////////////
// area learning
//////////////////////////////////////////////////////////////////////////////
// export function to navigateToLearnerPage
this.navigateToLearnerPage = function(){
var learnerURL = THREEx.ArToolkitContext.baseURL + 'examples/multi-markers/examples/learner.html'
THREEx.ArMultiMarkerUtils.navigateToLearnerPage(learnerURL, _this.data.trackingBackend)
}
// export function to initAreaLearningButton
this.initAreaLearningButton = function(){
// honor arjsSystem.data.areaLearningButton
if( this.data.areaLearningButton === false ) return
// if there is already a button, do nothing
if( document.querySelector('#arjsAreaLearningButton') !== null ) return
// create the img
var imgElement = document.createElement('img')
imgElement.id = 'arjsAreaLearningButton'
imgElement.style.position = 'fixed'
imgElement.style.bottom = '16px'
imgElement.style.left = '16px'
imgElement.style.width = '48px'
imgElement.style.height = '48px'
imgElement.style.zIndex = 1
imgElement.src = THREEx.ArToolkitContext.baseURL + "examples/multi-markers/examples/images/record-start.png"
document.body.appendChild(imgElement)
imgElement.addEventListener('click', function(){
_this.navigateToLearnerPage()
})
}
},
tick : function(now, delta){
if( this.arSource.ready === false ) return
// copy projection matrix to camera
var camera = this.el.sceneEl.camera
var renderer = this.el.sceneEl.renderer
this.arSource.onResize2(this.arContext, renderer, camera)
// update arContext
this.arContext.update( this.arSource.domElement )
},
})
//////////////////////////////////////////////////////////////////////////////
// arjsmarker
//////////////////////////////////////////////////////////////////////////////
AFRAME.registerComponent('arjsmarker', {
dependencies: ['arjs', 'artoolkit'],
schema: {
preset: {
type: 'string',
},
markerhelpers : { // IIF preset === 'area'
type: 'boolean',
default: false,
},
// controls parameters
size: {
type: 'number',
default: 1
},
type: {
type: 'string',
},
patternUrl: {
type: 'string',
},
barcodeValue: {
type: 'number'
},
changeMatrixMode: {
type: 'string',
default : 'modelViewMatrix',
},
minConfidence: {
type: 'number',
default: 0.6,
},
},
init: function () {
var _this = this
// actually init arMarkerControls
var arjsSystem = this.el.sceneEl.systems.arjs || this.el.sceneEl.systems.artoolkit
var artoolkitContext = arjsSystem.arContext
var scene = this.el.sceneEl.object3D
// honor this.data.preset
if( this.data.preset === 'hiro' ){
this.data.type = 'pattern'
this.data.patternUrl = THREEx.ArToolkitContext.baseURL+'examples/marker-training/examples/pattern-files/pattern-hiro.patt'
}else if( this.data.preset === 'kanji' ){
this.data.type = 'pattern'
this.data.patternUrl = THREEx.ArToolkitContext.baseURL+'examples/marker-training/examples/pattern-files/pattern-kanji.patt'
}else if( this.data.preset === 'area' ){
this.data.type = 'area'
}else {
console.assert( this.data.preset === '', 'illegal preset value '+this.data.preset)
}
// build a smoothedControls
this._markerRoot = new THREE.Group()
scene.add(this._markerRoot)
this._arMarkerControls = null
this._multiMarkerControls = null
// create the controls
if( this.data.type === 'area' ){
// if no localStorage.ARjsMultiMarkerFile, then write one with default marker
if( localStorage.getItem('ARjsMultiMarkerFile') === null ){
THREEx.ArMultiMarkerUtils.storeDefaultMultiMarkerFile(arjsSystem.data.trackingBackend)
}
// get multiMarkerFile from localStorage
console.assert( localStorage.getItem('ARjsMultiMarkerFile') !== null )
var multiMarkerFile = localStorage.getItem('ARjsMultiMarkerFile')
// create ArMultiMarkerControls
this._multiMarkerControls = THREEx.ArMultiMarkerControls.fromJSON(artoolkitContext, scene, this._markerRoot, multiMarkerFile, {
changeMatrixMode : this.data.changeMatrixMode
})
// display THREEx.ArMarkerHelper if needed - useful to debug
if( this.data.markerhelpers === true ){
this._multiMarkerControls.subMarkersControls.forEach(function(subMarkerControls){
// add an helper to visuable each sub-marker
var markerHelper = new THREEx.ArMarkerHelper(subMarkerControls)
scene.add( markerHelper.object3d )
})
}
}else if( this.data.type === 'pattern' || this.data.type === 'barcode' || this.data.type === 'unknown' ){
this._arMarkerControls = new THREEx.ArMarkerControls(artoolkitContext, this._markerRoot, this.data)
}else console.assert(false)
// build a smoothedControls
this.arSmoothedControls = new THREEx.ArSmoothedControls(this.el.object3D)
// honor arjsSystem.data.areaLearningButton
if( this.data.type === 'area' ) arjsSystem.initAreaLearningButton()
},
remove : function(){
// this._arMarkerControls.dispose()
},
update: function () {
// FIXME this mean to change the recode in trackBarcodeMarkerId ?
// var markerRoot = this.el.object3D;
// markerRoot.userData.size = this.data.size;
},
tick: function(){
if( this.data.changeMatrixMode === 'cameraTransformMatrix' ){
this.el.sceneEl.object3D.visible = this.el.object3D.visible;
}
if( this._multiMarkerControls !== null ){
// update smoothedControls parameters depending on how many markers are visible in multiMarkerControls
this._multiMarkerControls.updateSmoothedControls(this.arSmoothedControls)
}
// update smoothedControls position
this.arSmoothedControls.update(this._markerRoot)
}
});
//////////////////////////////////////////////////////////////////////////////
// define some primitives shortcuts
//////////////////////////////////////////////////////////////////////////////
AFRAME.registerPrimitive('a-marker', AFRAME.utils.extendDeep({}, AFRAME.primitives.getMeshMixin(), {
defaultComponents: {
'arjsmarker': {},
},
mappings: {
'type': 'arjsmarker.type',
'size': 'arjsmarker.size',
'url': 'arjsmarker.patternUrl',
'value': 'arjsmarker.barcodeValue',
'preset': 'arjsmarker.preset',
'minConfidence': 'arjsmarker.minConfidence',
'markerhelpers': 'arjsmarker.markerhelpers',
}
}));
AFRAME.registerPrimitive('a-marker-camera', AFRAME.utils.extendDeep({}, AFRAME.primitives.getMeshMixin(), {
defaultComponents: {
'arjsmarker': {
changeMatrixMode: 'cameraTransformMatrix'
},
'camera': true,
},
mappings: {
'type': 'arjsmarker.type',
'size': 'arjsmarker.size',
'url': 'arjsmarker.patternUrl',
'value': 'arjsmarker.barcodeValue',
'preset': 'arjsmarker.preset',
'minConfidence': 'arjsmarker.minConfidence',
'markerhelpers': 'arjsmarker.markerhelpers',
}
}));
//////////////////////////////////////////////////////////////////////////////
// Code Separator
//////////////////////////////////////////////////////////////////////////////
// to keep backward compatibility with deprecated code
// AFRAME.registerComponent('arjs', buildSystemParameter())
// AFRAME.registerComponent('artoolkit', buildSystemParameter())
// function buildSystemParameter(){ return {
// AFRAME.registerSystem('arjs', {
AFRAME.registerSystem('arjs', {
schema: {
trackingBackend : {
type: 'string',
default: 'artoolkit',
},
areaLearningButton : {
type: 'boolean',
default: true,
},
performanceProfile : {
type: 'string',
default: 'default',
},
// old parameters
debug : {
type: 'boolean',
default: false
},
detectionMode : {
type: 'string',
default: '',
},
matrixCodeType : {
type: 'string',
default: '',
},
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
},
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 artoolkitProfile
var artoolkitProfile = new THREEx.ArToolkitProfile()
artoolkitProfile.sourceWebcam()
artoolkitProfile.trackingBackend(this.data.trackingBackend)
artoolkitProfile.performance(this.data.performanceProfile)
//////////////////////////////////////////////////////////////////////////////
// honor this.data
//////////////////////////////////////////////////////////////////////////////
// honor this.data and push what has been modified into artoolkitProfile
if( this.data.debug !== false ) artoolkitProfile.contextParameters.debug = this.data.debug
if( this.data.detectionMode !== '' ) artoolkitProfile.contextParameters.detectionMode = this.data.detectionMode
if( this.data.matrixCodeType !== '' ) artoolkitProfile.contextParameters.matrixCodeType = this.data.matrixCodeType
if( this.data.cameraParametersUrl !== '' ) artoolkitProfile.contextParameters.cameraParametersUrl = this.data.cameraParametersUrl
if( this.data.maxDetectionRate !== -1 ) artoolkitProfile.contextParameters.maxDetectionRate = this.data.maxDetectionRate
if( this.data.sourceType !== '' ) artoolkitProfile.contextParameters.sourceType = this.data.sourceType
if( this.data.sourceUrl !== '' ) artoolkitProfile.contextParameters.sourceUrl = this.data.sourceUrl
if( this.data.sourceWidth !== -1 ) artoolkitProfile.contextParameters.sourceWidth = this.data.sourceWidth
if( this.data.sourceHeight !== -1 ) artoolkitProfile.contextParameters.sourceHeight = this.data.sourceHeight
if( this.data.displayWidth !== -1 ) artoolkitProfile.contextParameters.displayWidth = this.data.displayWidth
if( this.data.displayHeight !== -1 ) artoolkitProfile.contextParameters.displayHeight = this.data.displayHeight
if( this.data.canvasWidth !== -1 ) artoolkitProfile.contextParameters.canvasWidth = this.data.canvasWidth
if( this.data.canvasHeight !== -1 ) artoolkitProfile.contextParameters.canvasHeight = this.data.canvasHeight
////////////////////////////////////////////////////////////////////////////////
// handle arToolkitSource
////////////////////////////////////////////////////////////////////////////////
var arToolkitSource = new THREEx.ArToolkitSource(artoolkitProfile.sourceParameters)
this.arToolkitSource = arToolkitSource
arToolkitSource.init(function onReady(){
// handle resize of renderer
onResize()
// TODO this is crappy - code an exponential backoff - max 1 seconds
// kludge to write a 'resize' event
var startedAt = Date.now()
var timerId = setInterval(function(){
if( Date.now() - startedAt > 10*1000 ){
clearInterval(timerId)
return
}
// onResize()
window.dispatchEvent(new Event('resize'));
}, 1000/30)
})
// handle resize
window.addEventListener('resize', onResize)
function onResize(){
// ugly kludge to get resize on aframe... not even sure it works
arToolkitSource.onResizeElement()
arToolkitSource.copyElementSizeTo(document.body)
var buttonElement = document.querySelector('.a-enter-vr')
if( buttonElement ){
buttonElement.style.position = 'fixed'
}
}
////////////////////////////////////////////////////////////////////////////////
// initialize arToolkitContext
////////////////////////////////////////////////////////////////////////////////
// create atToolkitContext
var arToolkitContext = new THREEx.ArToolkitContext(artoolkitProfile.contextParameters)
this.arToolkitContext = arToolkitContext
// initialize it
arToolkitContext.init(function onCompleted(){
// // copy projection matrix to camera
// var projectionMatrixArr = arToolkitContext.arController.getCameraMatrix();
// _this.sceneEl.camera.projectionMatrix.fromArray(projprojectionMatrixArrectionMatrix);
})
//////////////////////////////////////////////////////////////////////////////
// area learning
//////////////////////////////////////////////////////////////////////////////
// export function to navigateToLearnerPage
this.navigateToLearnerPage = function(){
var learnerURL = THREEx.ArToolkitContext.baseURL + 'examples/multi-markers/examples/learner.html'
THREEx.ArMultiMarkerUtils.navigateToLearnerPage(learnerURL, _this.data.trackingBackend)
}
// export function to initAreaLearningButton
this.initAreaLearningButton = function(){
// honor arjsSystem.data.areaLearningButton
if( this.data.areaLearningButton === false ) return
// if there is already a button, do nothing
if( document.querySelector('#arjsAreaLearningButton') !== null ) return
// create the img
var imgElement = document.createElement('img')
imgElement.id = 'arjsAreaLearningButton'
imgElement.style.position = 'fixed'
imgElement.style.bottom = '16px'
imgElement.style.left = '16px'
imgElement.style.width = '48px'
imgElement.style.height = '48px'
imgElement.style.zIndex = 1
imgElement.src = THREEx.ArToolkitContext.baseURL + "examples/multi-markers/examples/images/record-start.png"
document.body.appendChild(imgElement)
imgElement.addEventListener('click', function(){
_this.navigateToLearnerPage()
})
}
},
tick : function(now, delta){
if( this.arToolkitSource.ready === false ) return
// copy projection matrix to camera
if( this.arToolkitContext.arController !== null ){
this.el.sceneEl.camera.projectionMatrix.copy( this.arToolkitContext.getProjectionMatrix() );
}
this.arToolkitContext.update( this.arToolkitSource.domElement )
},
})
//////////////////////////////////////////////////////////////////////////////
// arjsmarker
//////////////////////////////////////////////////////////////////////////////
AFRAME.registerComponent('arjsmarker', {
dependencies: ['arjs', 'artoolkit'],
schema: {
preset: {
type: 'string',
},
markerhelpers : { // IIF preset === 'area'
type: 'boolean',
default: false,
},
// controls parameters
size: {
type: 'number',
default: 1
},
type: {
type: 'string',
},
patternUrl: {
type: 'string',
},
barcodeValue: {
type: 'number'
},
changeMatrixMode: {
type: 'string',
default : 'modelViewMatrix',
},
minConfidence: {
type: 'number',
default: 0.6,
},
},
init: function () {
var _this = this
// actually init arMarkerControls
var arjsSystem = this.el.sceneEl.systems.arjs || this.el.sceneEl.systems.artoolkit
var artoolkitContext = arjsSystem.arToolkitContext
var scene = this.el.sceneEl.object3D
// honor this.data.preset
if( this.data.preset === 'hiro' ){
this.data.type = 'pattern'
this.data.patternUrl = THREEx.ArToolkitContext.baseURL+'examples/marker-training/examples/pattern-files/pattern-hiro.patt'
}else if( this.data.preset === 'kanji' ){
this.data.type = 'pattern'
this.data.patternUrl = THREEx.ArToolkitContext.baseURL+'examples/marker-training/examples/pattern-files/pattern-kanji.patt'
}else if( this.data.preset === 'area' ){
this.data.type = 'area'
}else {
console.assert( this.data.preset === '', 'illegal preset value '+this.data.preset)
}
// build a smoothedControls
this._markerRoot = new THREE.Group()
scene.add(this._markerRoot)
this._arMarkerControls = null
this._multiMarkerControls = null
// create the controls
if( this.data.type === 'area' ){
// if no localStorage.ARjsMultiMarkerFile, then write one with default marker
if( localStorage.getItem('ARjsMultiMarkerFile') === null ){
THREEx.ArMultiMarkerUtils.storeDefaultMultiMarkerFile(arjsSystem.data.trackingBackend)
}
// get multiMarkerFile from localStorage
console.assert( localStorage.getItem('ARjsMultiMarkerFile') !== null )
var multiMarkerFile = localStorage.getItem('ARjsMultiMarkerFile')
// create ArMultiMarkerControls
this._multiMarkerControls = THREEx.ArMultiMarkerControls.fromJSON(artoolkitContext, scene, this._markerRoot, multiMarkerFile, {
changeMatrixMode : this.data.changeMatrixMode
})
console.log('this.data.markerhelpers', this.data.markerhelpers)
// display THREEx.ArMarkerHelper if needed - useful to debug
if( this.data.markerhelpers === true ){
this._multiMarkerControls.subMarkersControls.forEach(function(subMarkerControls){
// add an helper to visuable each sub-marker
var markerHelper = new THREEx.ArMarkerHelper(subMarkerControls)
scene.add( markerHelper.object3d )
})
}
}else if( this.data.type === 'pattern' || this.data.type === 'barcode' || this.data.type === 'unknown' ){
this._arMarkerControls = new THREEx.ArMarkerControls(artoolkitContext, this._markerRoot, this.data)
}else console.assert(false)
// build a smoothedControls
this.arSmoothedControls = new THREEx.ArSmoothedControls(this.el.object3D,{
lerpPosition : 0.1,
lerpQuaternion : 0.1,
lerpScale : 0.1,
// minVisibleDelay: 0,
// minUnvisibleDelay: 0,
})
// honor arjsSystem.data.areaLearningButton
if( this.data.type === 'area' ) arjsSystem.initAreaLearningButton()
},
remove : function(){
// this._arMarkerControls.dispose()
},
update: function () {
// FIXME this mean to change the recode in trackBarcodeMarkerId ?
// var markerRoot = this.el.object3D;
// markerRoot.userData.size = this.data.size;
},
tick: function(){
if( this.data.changeMatrixMode === 'cameraTransformMatrix' ){
this.el.sceneEl.object3D.visible = this.el.object3D.visible;
}
if( this._multiMarkerControls !== null ){
// update smoothedControls parameters depending on how many markers are visible in multiMarkerControls
this._multiMarkerControls.updateSmoothedControls(this.arSmoothedControls)
}
// update smoothedControls position
this.arSmoothedControls.update(this._markerRoot)
}
});
//////////////////////////////////////////////////////////////////////////////
// define some primitives shortcuts
//////////////////////////////////////////////////////////////////////////////
AFRAME.registerPrimitive('a-marker', AFRAME.utils.extendDeep({}, AFRAME.primitives.getMeshMixin(), {
defaultComponents: {
'arjsmarker': {},
},
mappings: {
'type': 'arjsmarker.type',
'size': 'arjsmarker.size',
'url': 'arjsmarker.patternUrl',
'value': 'arjsmarker.barcodeValue',
'preset': 'arjsmarker.preset',
'minConfidence': 'arjsmarker.minConfidence',
'markerhelpers': 'arjsmarker.markerhelpers',
}
}));
AFRAME.registerPrimitive('a-marker-camera', AFRAME.utils.extendDeep({}, AFRAME.primitives.getMeshMixin(), {
defaultComponents: {
'arjsmarker': {
changeMatrixMode: 'cameraTransformMatrix'
},
'camera': true,
},
mappings: {
'type': 'arjsmarker.type',
'size': 'arjsmarker.size',
'url': 'arjsmarker.patternUrl',
'value': 'arjsmarker.barcodeValue',
'preset': 'arjsmarker.preset',
'minConfidence': 'arjsmarker.minConfidence',
'markerhelpers': 'arjsmarker.markerhelpers',
}
}));
......@@ -351,17 +351,17 @@ THREEx.ArMarkerControls = function(context, object3d, parameters){
// handle default parameters
this.parameters = {
// size of the marker in meter
size : parameters.size !== undefined ? parameters.size : 1,
size : 1,
// type of marker - ['pattern', 'barcode', 'unknown' ]
type : parameters.type !== undefined ? parameters.type : 'unknown',
type : 'unknown',
// url of the pattern - IIF type='pattern'
patternUrl : parameters.patternUrl !== undefined ? parameters.patternUrl : null,
patternUrl : null,
// value of the barcode - IIF type='barcode'
barcodeValue : parameters.barcodeValue !== undefined ? parameters.barcodeValue : null,
barcodeValue : null,
// change matrix mode - [modelViewMatrix, cameraTransformMatrix]
changeMatrixMode : parameters.changeMatrixMode !== undefined ? parameters.changeMatrixMode : 'modelViewMatrix',
changeMatrixMode : 'modelViewMatrix',
// minimal confidence in the marke recognition - between [0, 1] - default to 1
minConfidence: parameters.minConfidence !== undefined ? parameters.minConfidence : 0.6,
minConfidence: 0.6,
}
// sanity check
......@@ -375,6 +375,31 @@ THREEx.ArMarkerControls = function(context, object3d, parameters){
this.object3d = object3d
this.object3d.matrixAutoUpdate = false;
this.object3d.visible = false
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters(parameters)
function setParameters(parameters){
if( parameters === undefined ) return
for( var key in parameters ){
var newValue = parameters[ key ]
if( newValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." )
continue
}
var currentValue = _this.parameters[ key ]
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." )
continue
}
_this.parameters[ key ] = newValue
}
}
// add this marker to artoolkitsystem
// TODO rename that .addMarkerControls
......@@ -620,17 +645,42 @@ THREEx.ArSmoothedControls = function(object3d, parameters){
parameters = parameters || {}
this.parameters = {
// lerp coeficient for the position - between [0,1] - default to 1
lerpPosition: parameters.lerpPosition !== undefined ? parameters.lerpPosition : 0.8,
lerpPosition: 0.8,
// lerp coeficient for the quaternion - between [0,1] - default to 1
lerpQuaternion: parameters.lerpQuaternion !== undefined ? parameters.lerpQuaternion : 0.2,
lerpQuaternion: 0.2,
// lerp coeficient for the scale - between [0,1] - default to 1
lerpScale: parameters.lerpScale !== undefined ? parameters.lerpScale : 0.7,
lerpScale: 0.7,
// delay for lerp fixed steps - in seconds - default to 1/120
lerpStepDelay: parameters.fixStepDelay !== undefined ? parameters.fixStepDelay : 1/60,
lerpStepDelay: 1/60,
// minimum delay the sub-control must be visible before this controls become visible - default to 0 seconds
minVisibleDelay: parameters.minVisibleDelay !== undefined ? parameters.minVisibleDelay : 0.0,
minVisibleDelay: 0.0,
// minimum delay the sub-control must be unvisible before this controls become unvisible - default to 0 seconds
minUnvisibleDelay: parameters.minUnvisibleDelay !== undefined ? parameters.minUnvisibleDelay : 0.2,
minUnvisibleDelay: 0.2,
}
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters(parameters)
function setParameters(parameters){
if( parameters === undefined ) return
for( var key in parameters ){
var newValue = parameters[ key ]
if( newValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." )
continue
}
var currentValue = _this.parameters[ key ]
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." )
continue
}
_this.parameters[ key ] = newValue
}
}
}
......@@ -765,7 +815,30 @@ THREEx.ArToolkitContext = function(parameters){
this._arMarkersControls = []
this._setParameters(parameters)
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters(parameters)
function setParameters(parameters){
if( parameters === undefined ) return
for( var key in parameters ){
var newValue = parameters[ key ]
if( newValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." )
continue
}
var currentValue = _this.parameters[ key ]
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." )
continue
}
_this.parameters[ key ] = newValue
}
}
}
Object.assign( THREEx.ArToolkitContext.prototype, THREE.EventDispatcher.prototype );
......@@ -776,32 +849,6 @@ THREEx.ArToolkitContext.baseURL = 'https://jeromeetienne.github.io/AR.js/three.j
THREEx.ArToolkitContext.REVISION = '1.0.1-dev'
/**
* set parameters
* @param {[type]} values [description]
* @return {[type]} [description]
*/
THREEx.ArToolkitContext.prototype._setParameters = function (values){
if ( values === undefined ) return;
for( var key in values ){
var newValue = values[ key ];
if( newValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." );
continue;
}
var currentValue = this.parameters[ key ];
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." );
continue;
}
this.parameters[ key ] = newValue;
}
};
/**
* Create a default camera for this trackingBackend
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -6,7 +6,25 @@
<!-- jsartookit -->
<script src="../../three.js/vendor/jsartoolkit5/build/artoolkit.min.js"></script>
<script src="../../three.js/vendor/jsartoolkit5/js/artoolkit.api.js"></script>
<!-- include ar.js -->
<!-- include for artoolkit trackingBackend -->
<script src='../../three.js/vendor/jsartoolkit5/build/artoolkit.min.js'></script>
<script src='../../three.js/vendor/jsartoolkit5/js/artoolkit.api.js'></script>
<!-- include for aruco trackingBackend -->
<script src='../../three.js/vendor/js-aruco/src/svd.js'></script>
<script src='../../three.js/vendor/js-aruco/src/posit1.js'></script>
<script src='../../three.js/vendor/js-aruco/src/cv.js'></script>
<script src='../../three.js/vendor/js-aruco/src/aruco.js'></script>
<script src='../../three.js/threex/threex-aruco/threex-arucocontext.js'></script>
<script src='../../three.js/threex/threex-aruco/threex-arucodebug.js'></script>
<!-- include for tango trackingBackend -->
<script src='../../three.js/vendor/chromium-tango/THREE.WebAR.js'></script>
<!-- include ar.js itself -->
<script src='../../three.js/arjs-utils.js'></script>
<script src='../../three.js/src/newAPI/arjs-session.js'></script>
<script src='../../three.js/src/newAPI/arjs-anchor.js'></script>
<script src='../../three.js/src/newAPI/arjs-hittester.js'></script>
<script src='../../three.js/src/newAPI/arjs-tangovideomesh.js'></script>
<script src='../../three.js/src/newAPI/arjs-tangopointcloud.js'></script>
<script src="../../three.js/threex-artoolkitcontext.js"></script>
<script src="../../three.js/threex-artoolkitsource.js"></script>
<script src='../../three.js/threex-artoolkitprofile.js'></script>
......@@ -14,8 +32,11 @@
<script src="../../three.js/threex-armarkercontrols.js"></script>
<script src="../../three.js/threex-armarkerhelper.js"></script>
<script src="../../three.js/threex-arsmoothedcontrols.js"></script>
<!-- include for tango trackingBackend -->
<script src='../../three.js/vendor/chromium-tango/THREE.WebAR.js'></script>
<!-- include ar.js markers area -->
<script src='../../three.js/examples/multi-markers/threex-armultimarkerutils.js'></script>
<script src='../../three.js/examples/multi-markers/threex-armultimarkercontrols.js'></script>
<script src='../../three.js/examples/multi-markers/threex-armultimarkerlearning.js'></script>
<body style='margin : 0px; overflow: hidden; font-family: Monospace;'><div style='position: fixed; top: 10px; width:inherit; text-align: center; z-index: 1;'>
<a href="https://github.com/jeromeetienne/AR.js/" target="_blank">AR.js</a> - tango example for a-frame by <a href='https://twitter.com/jerome_etienne' target='_blank'>@jerome_etienne</a>
......@@ -27,7 +48,7 @@
<a-animation attribute="rotation" to="360 0 0" dur="3000" easing='linear' repeat="indefinite"></a-animation>
</a-torus-knot>
</a-box>
<a-marker-camera preset='area'></a-marker-camera>
<a-marker-camera preset='hiro'></a-marker-camera>
</a-scene>
<!-- <a-scene embedded arjs='sourceType: webcam; trackingBackend: tango;'>
......
......@@ -1968,17 +1968,17 @@ THREEx.ArMarkerControls = function(context, object3d, parameters){
// handle default parameters
this.parameters = {
// size of the marker in meter
size : parameters.size !== undefined ? parameters.size : 1,
size : 1,
// type of marker - ['pattern', 'barcode', 'unknown' ]
type : parameters.type !== undefined ? parameters.type : 'unknown',
type : 'unknown',
// url of the pattern - IIF type='pattern'
patternUrl : parameters.patternUrl !== undefined ? parameters.patternUrl : null,
patternUrl : null,
// value of the barcode - IIF type='barcode'
barcodeValue : parameters.barcodeValue !== undefined ? parameters.barcodeValue : null,
barcodeValue : null,
// change matrix mode - [modelViewMatrix, cameraTransformMatrix]
changeMatrixMode : parameters.changeMatrixMode !== undefined ? parameters.changeMatrixMode : 'modelViewMatrix',
changeMatrixMode : 'modelViewMatrix',
// minimal confidence in the marke recognition - between [0, 1] - default to 1
minConfidence: parameters.minConfidence !== undefined ? parameters.minConfidence : 0.6,
minConfidence: 0.6,
}
// sanity check
......@@ -1992,6 +1992,31 @@ THREEx.ArMarkerControls = function(context, object3d, parameters){
this.object3d = object3d
this.object3d.matrixAutoUpdate = false;
this.object3d.visible = false
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters(parameters)
function setParameters(parameters){
if( parameters === undefined ) return
for( var key in parameters ){
var newValue = parameters[ key ]
if( newValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." )
continue
}
var currentValue = _this.parameters[ key ]
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." )
continue
}
_this.parameters[ key ] = newValue
}
}
// add this marker to artoolkitsystem
// TODO rename that .addMarkerControls
......@@ -2237,17 +2262,42 @@ THREEx.ArSmoothedControls = function(object3d, parameters){
parameters = parameters || {}
this.parameters = {
// lerp coeficient for the position - between [0,1] - default to 1
lerpPosition: parameters.lerpPosition !== undefined ? parameters.lerpPosition : 0.8,
lerpPosition: 0.8,
// lerp coeficient for the quaternion - between [0,1] - default to 1
lerpQuaternion: parameters.lerpQuaternion !== undefined ? parameters.lerpQuaternion : 0.2,
lerpQuaternion: 0.2,
// lerp coeficient for the scale - between [0,1] - default to 1
lerpScale: parameters.lerpScale !== undefined ? parameters.lerpScale : 0.7,
lerpScale: 0.7,
// delay for lerp fixed steps - in seconds - default to 1/120
lerpStepDelay: parameters.fixStepDelay !== undefined ? parameters.fixStepDelay : 1/60,
lerpStepDelay: 1/60,
// minimum delay the sub-control must be visible before this controls become visible - default to 0 seconds
minVisibleDelay: parameters.minVisibleDelay !== undefined ? parameters.minVisibleDelay : 0.0,
minVisibleDelay: 0.0,
// minimum delay the sub-control must be unvisible before this controls become unvisible - default to 0 seconds
minUnvisibleDelay: parameters.minUnvisibleDelay !== undefined ? parameters.minUnvisibleDelay : 0.2,
minUnvisibleDelay: 0.2,
}
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters(parameters)
function setParameters(parameters){
if( parameters === undefined ) return
for( var key in parameters ){
var newValue = parameters[ key ]
if( newValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." )
continue
}
var currentValue = _this.parameters[ key ]
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." )
continue
}
_this.parameters[ key ] = newValue
}
}
}
......@@ -2382,7 +2432,30 @@ THREEx.ArToolkitContext = function(parameters){
this._arMarkersControls = []
this._setParameters(parameters)
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters(parameters)
function setParameters(parameters){
if( parameters === undefined ) return
for( var key in parameters ){
var newValue = parameters[ key ]
if( newValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." )
continue
}
var currentValue = _this.parameters[ key ]
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." )
continue
}
_this.parameters[ key ] = newValue
}
}
}
Object.assign( THREEx.ArToolkitContext.prototype, THREE.EventDispatcher.prototype );
......@@ -2393,32 +2466,6 @@ THREEx.ArToolkitContext.baseURL = 'https://jeromeetienne.github.io/AR.js/three.j
THREEx.ArToolkitContext.REVISION = '1.0.1-dev'
/**
* set parameters
* @param {[type]} values [description]
* @return {[type]} [description]
*/
THREEx.ArToolkitContext.prototype._setParameters = function (values){
if ( values === undefined ) return;
for( var key in values ){
var newValue = values[ key ];
if( newValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." );
continue;
}
var currentValue = this.parameters[ key ];
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." );
continue;
}
this.parameters[ key ] = newValue;
}
};
/**
* Create a default camera for this trackingBackend
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -9,17 +9,17 @@ THREEx.ArMarkerControls = function(context, object3d, parameters){
// handle default parameters
this.parameters = {
// size of the marker in meter
size : parameters.size !== undefined ? parameters.size : 1,
size : 1,
// type of marker - ['pattern', 'barcode', 'unknown' ]
type : parameters.type !== undefined ? parameters.type : 'unknown',
type : 'unknown',
// url of the pattern - IIF type='pattern'
patternUrl : parameters.patternUrl !== undefined ? parameters.patternUrl : null,
patternUrl : null,
// value of the barcode - IIF type='barcode'
barcodeValue : parameters.barcodeValue !== undefined ? parameters.barcodeValue : null,
barcodeValue : null,
// change matrix mode - [modelViewMatrix, cameraTransformMatrix]
changeMatrixMode : parameters.changeMatrixMode !== undefined ? parameters.changeMatrixMode : 'modelViewMatrix',
changeMatrixMode : 'modelViewMatrix',
// minimal confidence in the marke recognition - between [0, 1] - default to 1
minConfidence: parameters.minConfidence !== undefined ? parameters.minConfidence : 0.6,
minConfidence: 0.6,
}
// sanity check
......@@ -33,6 +33,31 @@ THREEx.ArMarkerControls = function(context, object3d, parameters){
this.object3d = object3d
this.object3d.matrixAutoUpdate = false;
this.object3d.visible = false
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters(parameters)
function setParameters(parameters){
if( parameters === undefined ) return
for( var key in parameters ){
var newValue = parameters[ key ]
if( newValue === undefined ){
console.warn( "THREEx.ArMarkerControls: '" + key + "' parameter is undefined." )
continue
}
var currentValue = _this.parameters[ key ]
if( currentValue === undefined ){
console.warn( "THREEx.ArMarkerControls: '" + key + "' is not a property of this material." )
continue
}
_this.parameters[ key ] = newValue
}
}
// add this marker to artoolkitsystem
// TODO rename that .addMarkerControls
......
......@@ -23,17 +23,42 @@ THREEx.ArSmoothedControls = function(object3d, parameters){
parameters = parameters || {}
this.parameters = {
// lerp coeficient for the position - between [0,1] - default to 1
lerpPosition: parameters.lerpPosition !== undefined ? parameters.lerpPosition : 0.8,
lerpPosition: 0.8,
// lerp coeficient for the quaternion - between [0,1] - default to 1
lerpQuaternion: parameters.lerpQuaternion !== undefined ? parameters.lerpQuaternion : 0.2,
lerpQuaternion: 0.2,
// lerp coeficient for the scale - between [0,1] - default to 1
lerpScale: parameters.lerpScale !== undefined ? parameters.lerpScale : 0.7,
lerpScale: 0.7,
// delay for lerp fixed steps - in seconds - default to 1/120
lerpStepDelay: parameters.fixStepDelay !== undefined ? parameters.fixStepDelay : 1/60,
lerpStepDelay: 1/60,
// minimum delay the sub-control must be visible before this controls become visible - default to 0 seconds
minVisibleDelay: parameters.minVisibleDelay !== undefined ? parameters.minVisibleDelay : 0.0,
minVisibleDelay: 0.0,
// minimum delay the sub-control must be unvisible before this controls become unvisible - default to 0 seconds
minUnvisibleDelay: parameters.minUnvisibleDelay !== undefined ? parameters.minUnvisibleDelay : 0.2,
minUnvisibleDelay: 0.2,
}
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters(parameters)
function setParameters(parameters){
if( parameters === undefined ) return
for( var key in parameters ){
var newValue = parameters[ key ]
if( newValue === undefined ){
console.warn( "THREEx.ArSmoothedControls: '" + key + "' parameter is undefined." )
continue
}
var currentValue = _this.parameters[ key ]
if( currentValue === undefined ){
console.warn( "THREEx.ArSmoothedControls: '" + key + "' is not a property of this material." )
continue
}
_this.parameters[ key ] = newValue
}
}
}
......
......@@ -41,7 +41,30 @@ THREEx.ArToolkitContext = function(parameters){
this._arMarkersControls = []
this._setParameters(parameters)
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters(parameters)
function setParameters(parameters){
if( parameters === undefined ) return
for( var key in parameters ){
var newValue = parameters[ key ]
if( newValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." )
continue
}
var currentValue = _this.parameters[ key ]
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." )
continue
}
_this.parameters[ key ] = newValue
}
}
}
Object.assign( THREEx.ArToolkitContext.prototype, THREE.EventDispatcher.prototype );
......@@ -52,32 +75,6 @@ THREEx.ArToolkitContext.baseURL = 'https://jeromeetienne.github.io/AR.js/three.j
THREEx.ArToolkitContext.REVISION = '1.0.1-dev'
/**
* set parameters
* @param {[type]} values [description]
* @return {[type]} [description]
*/
THREEx.ArToolkitContext.prototype._setParameters = function (values){
if ( values === undefined ) return;
for( var key in values ){
var newValue = values[ key ];
if( newValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." );
continue;
}
var currentValue = this.parameters[ key ];
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." );
continue;
}
this.parameters[ key ] = newValue;
}
};
/**
* Create a default camera for this trackingBackend
......
......@@ -1968,17 +1968,17 @@ THREEx.ArMarkerControls = function(context, object3d, parameters){
// handle default parameters
this.parameters = {
// size of the marker in meter
size : parameters.size !== undefined ? parameters.size : 1,
size : 1,
// type of marker - ['pattern', 'barcode', 'unknown' ]
type : parameters.type !== undefined ? parameters.type : 'unknown',
type : 'unknown',
// url of the pattern - IIF type='pattern'
patternUrl : parameters.patternUrl !== undefined ? parameters.patternUrl : null,
patternUrl : null,
// value of the barcode - IIF type='barcode'
barcodeValue : parameters.barcodeValue !== undefined ? parameters.barcodeValue : null,
barcodeValue : null,
// change matrix mode - [modelViewMatrix, cameraTransformMatrix]
changeMatrixMode : parameters.changeMatrixMode !== undefined ? parameters.changeMatrixMode : 'modelViewMatrix',
changeMatrixMode : 'modelViewMatrix',
// minimal confidence in the marke recognition - between [0, 1] - default to 1
minConfidence: parameters.minConfidence !== undefined ? parameters.minConfidence : 0.6,
minConfidence: 0.6,
}
// sanity check
......@@ -1992,6 +1992,31 @@ THREEx.ArMarkerControls = function(context, object3d, parameters){
this.object3d = object3d
this.object3d.matrixAutoUpdate = false;
this.object3d.visible = false
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters(parameters)
function setParameters(parameters){
if( parameters === undefined ) return
for( var key in parameters ){
var newValue = parameters[ key ]
if( newValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." )
continue
}
var currentValue = _this.parameters[ key ]
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." )
continue
}
_this.parameters[ key ] = newValue
}
}
// add this marker to artoolkitsystem
// TODO rename that .addMarkerControls
......@@ -2237,17 +2262,42 @@ THREEx.ArSmoothedControls = function(object3d, parameters){
parameters = parameters || {}
this.parameters = {
// lerp coeficient for the position - between [0,1] - default to 1
lerpPosition: parameters.lerpPosition !== undefined ? parameters.lerpPosition : 0.8,
lerpPosition: 0.8,
// lerp coeficient for the quaternion - between [0,1] - default to 1
lerpQuaternion: parameters.lerpQuaternion !== undefined ? parameters.lerpQuaternion : 0.2,
lerpQuaternion: 0.2,
// lerp coeficient for the scale - between [0,1] - default to 1
lerpScale: parameters.lerpScale !== undefined ? parameters.lerpScale : 0.7,
lerpScale: 0.7,
// delay for lerp fixed steps - in seconds - default to 1/120
lerpStepDelay: parameters.fixStepDelay !== undefined ? parameters.fixStepDelay : 1/60,
lerpStepDelay: 1/60,
// minimum delay the sub-control must be visible before this controls become visible - default to 0 seconds
minVisibleDelay: parameters.minVisibleDelay !== undefined ? parameters.minVisibleDelay : 0.0,
minVisibleDelay: 0.0,
// minimum delay the sub-control must be unvisible before this controls become unvisible - default to 0 seconds
minUnvisibleDelay: parameters.minUnvisibleDelay !== undefined ? parameters.minUnvisibleDelay : 0.2,
minUnvisibleDelay: 0.2,
}
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters(parameters)
function setParameters(parameters){
if( parameters === undefined ) return
for( var key in parameters ){
var newValue = parameters[ key ]
if( newValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." )
continue
}
var currentValue = _this.parameters[ key ]
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." )
continue
}
_this.parameters[ key ] = newValue
}
}
}
......@@ -2382,7 +2432,30 @@ THREEx.ArToolkitContext = function(parameters){
this._arMarkersControls = []
this._setParameters(parameters)
//////////////////////////////////////////////////////////////////////////////
// setParameters
//////////////////////////////////////////////////////////////////////////////
setParameters(parameters)
function setParameters(parameters){
if( parameters === undefined ) return
for( var key in parameters ){
var newValue = parameters[ key ]
if( newValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." )
continue
}
var currentValue = _this.parameters[ key ]
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." )
continue
}
_this.parameters[ key ] = newValue
}
}
}
Object.assign( THREEx.ArToolkitContext.prototype, THREE.EventDispatcher.prototype );
......@@ -2393,32 +2466,6 @@ THREEx.ArToolkitContext.baseURL = 'https://jeromeetienne.github.io/AR.js/three.j
THREEx.ArToolkitContext.REVISION = '1.0.1-dev'
/**
* set parameters
* @param {[type]} values [description]
* @return {[type]} [description]
*/
THREEx.ArToolkitContext.prototype._setParameters = function (values){
if ( values === undefined ) return;
for( var key in values ){
var newValue = values[ key ];
if( newValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' parameter is undefined." );
continue;
}
var currentValue = this.parameters[ key ];
if( currentValue === undefined ){
console.warn( "THREEx.ArToolkitContext: '" + key + "' is not a property of this material." );
continue;
}
this.parameters[ key ] = newValue;
}
};
/**
* Create a default camera for this trackingBackend
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册