提交 83e615d3 编写于 作者: J Jerome Etienne

added credits + removd emitevens option + cameraTransformMatrix

上级 4fb07fa5
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
## aframe-ar.js ## aframe-ar.js
- aframe-ar.js - `<a-marker>` elements will emit `markerFound` and `markerLost` events, if they have `emitevents='true'` set. - aframe-ar.js - `<a-marker>` elements will emit `markerFound` and `markerLost` events - PR #333 thanks @nikolaymihaylov
## Demos ## Demos
......
...@@ -8364,10 +8364,21 @@ AFRAME.registerComponent('arjs-anchor', { ...@@ -8364,10 +8364,21 @@ AFRAME.registerComponent('arjs-anchor', {
// honor visibility // honor visibility
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
if( _this._arAnchor.parameters.changeMatrixMode === 'modelViewMatrix' ){ if( _this._arAnchor.parameters.changeMatrixMode === 'modelViewMatrix' ){
var wasVisible = _this.el.object3D.visible
_this.el.object3D.visible = this._arAnchor.object3d.visible _this.el.object3D.visible = this._arAnchor.object3d.visible
}else if( _this._arAnchor.parameters.changeMatrixMode === 'cameraTransformMatrix' ){ }else if( _this._arAnchor.parameters.changeMatrixMode === 'cameraTransformMatrix' ){
var wasVisible = _this.el.sceneEl.object3D.visible
_this.el.sceneEl.object3D.visible = this._arAnchor.object3d.visible _this.el.sceneEl.object3D.visible = this._arAnchor.object3d.visible
}else console.assert(false) }else console.assert(false)
// emit markerFound markerLost
if( _this._arAnchor.object3d.visible === true && wasVisible === false ){
_this.el.emit('markerFound')
}else if( _this._arAnchor.object3d.visible === false && wasVisible === true ){
_this.el.emit('markerLost')
}
} }
}) })
...@@ -8,9 +8,6 @@ ...@@ -8,9 +8,6 @@
init: function () { init: function () {
var marker = this.el; var marker = this.el;
// Make the element emit events when found and when lost.
marker.setAttribute('emitevents', 'true');
marker.addEventListener('markerFound', function() { marker.addEventListener('markerFound', function() {
var markerId = marker.id; var markerId = marker.id;
console.log('markerFound', markerId); console.log('markerFound', markerId);
......
...@@ -34,12 +34,6 @@ AFRAME.registerComponent('arjs-anchor', { ...@@ -34,12 +34,6 @@ AFRAME.registerComponent('arjs-anchor', {
type: 'number', type: 'number',
default: 0.6, default: 0.6,
}, },
// Whether to emit events when the element is found or lost.
emitevents: {
type: 'boolean',
default: false,
}
}, },
init: function () { init: function () {
var _this = this var _this = this
...@@ -163,17 +157,19 @@ AFRAME.registerComponent('arjs-anchor', { ...@@ -163,17 +157,19 @@ AFRAME.registerComponent('arjs-anchor', {
if( _this._arAnchor.parameters.changeMatrixMode === 'modelViewMatrix' ){ if( _this._arAnchor.parameters.changeMatrixMode === 'modelViewMatrix' ){
var wasVisible = _this.el.object3D.visible var wasVisible = _this.el.object3D.visible
_this.el.object3D.visible = this._arAnchor.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' ){ }else if( _this._arAnchor.parameters.changeMatrixMode === 'cameraTransformMatrix' ){
var wasVisible = _this.el.sceneEl.object3D.visible
_this.el.sceneEl.object3D.visible = this._arAnchor.object3d.visible _this.el.sceneEl.object3D.visible = this._arAnchor.object3d.visible
}else console.assert(false) }else console.assert(false)
// emit markerFound markerLost
if( _this._arAnchor.object3d.visible === true && wasVisible === false ){
_this.el.emit('markerFound')
}else if( _this._arAnchor.object3d.visible === false && wasVisible === true ){
_this.el.emit('markerLost')
}
} }
}) })
...@@ -227,7 +223,6 @@ AFRAME.registerPrimitive('a-marker', AFRAME.utils.extendDeep({}, AFRAME.primitiv ...@@ -227,7 +223,6 @@ AFRAME.registerPrimitive('a-marker', AFRAME.utils.extendDeep({}, AFRAME.primitiv
'preset': 'arjs-anchor.preset', 'preset': 'arjs-anchor.preset',
'minConfidence': 'arjs-anchor.minConfidence', 'minConfidence': 'arjs-anchor.minConfidence',
'markerhelpers': 'arjs-anchor.markerhelpers', 'markerhelpers': 'arjs-anchor.markerhelpers',
'emitevents': 'arjs-anchor.emitevents',
'hit-testing-renderDebug': 'arjs-hit-testing.renderDebug', 'hit-testing-renderDebug': 'arjs-hit-testing.renderDebug',
'hit-testing-enabled': 'arjs-hit-testing.enabled', 'hit-testing-enabled': 'arjs-hit-testing.enabled',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册