提交 3af75a7e 编写于 作者: N Nikolay Mihaylov

Add 'emitevents' property to the arjs-anchor component, which emits events...

Add 'emitevents' property to the arjs-anchor component, which emits events when a marker is found and when it is lost.
上级 f17b518e
......@@ -34,6 +34,12 @@ AFRAME.registerComponent('arjs-anchor', {
type: 'number',
default: 0.6,
},
// Whether to emit events when the element is found or lost.
emitevents: {
type: 'boolean',
default: false,
}
},
init: function () {
var _this = this
......@@ -151,7 +157,16 @@ AFRAME.registerComponent('arjs-anchor', {
// honor visibility
//////////////////////////////////////////////////////////////////////////////
if( _this._arAnchor.parameters.changeMatrixMode === 'modelViewMatrix' ){
var wasVisible = _this.el.object3D.visible
_this.el.object3D.visible = this._arAnchor.object3d.visible
if( _this.data.emitevents ){
if( _this.el.object3D.visible && !wasVisible ){
_this.el.emit('markerFound')
}else if( !_this.el.object3D.visible && wasVisible ){
_this.el.emit('markerLost')
}
}
}else if( _this._arAnchor.parameters.changeMatrixMode === 'cameraTransformMatrix' ){
_this.el.sceneEl.object3D.visible = this._arAnchor.object3d.visible
}else console.assert(false)
......@@ -208,6 +223,7 @@ AFRAME.registerPrimitive('a-marker', AFRAME.utils.extendDeep({}, AFRAME.primitiv
'preset': 'arjs-anchor.preset',
'minConfidence': 'arjs-anchor.minConfidence',
'markerhelpers': 'arjs-anchor.markerhelpers',
'emitevents': 'arjs-anchor.emitevents',
'hit-testing-renderDebug': 'arjs-hit-testing.renderDebug',
'hit-testing-enabled': 'arjs-hit-testing.enabled',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册