From 3e048e7d59a2770601a77ff9c2a97ad49c9c2c9b Mon Sep 17 00:00:00 2001 From: M C Date: Thu, 22 Feb 2018 14:39:05 -0500 Subject: [PATCH] bump dist --- dist/aframe-ar.js | 8 +++++++- dist/aframe-ar.min.js | 2 +- dist/aframe-three-ar.js | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dist/aframe-ar.js b/dist/aframe-ar.js index 6d35c9f..3ebe7e4 100644 --- a/dist/aframe-ar.js +++ b/dist/aframe-ar.js @@ -1133,7 +1133,13 @@ hitAR: function () { var whichar = this.checkWhichAR(); if (!whichar || !whichar.arDisplay) { return []; } - return whichar.hitAR(this.data.x, this.data.y, this.data.el, this.el); + var x = this.data.x; + var y = this.data.y; + if (arguments.length >= 2) { + x = arguments[0]; + y = arguments[1]; + } + return whichar.hitAR(x, y, this.data.el, this.el); }, checkWhichAR: function () { diff --git a/dist/aframe-ar.min.js b/dist/aframe-ar.min.js index db36c06..149abea 100644 --- a/dist/aframe-ar.min.js +++ b/dist/aframe-ar.min.js @@ -1 +1 @@ -!function(e){function t(i){if(a[i])return a[i].exports;var r=a[i]={exports:{},id:i,loaded:!1};return e[i].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var a={};return t.m=e,t.c=a,t.p="",t(0)}([function(e,t,a){a(6),a(5),a(2),a(4),a(1),a(3)},function(e,t){AFRAME.registerComponent("ar-camera",{schema:{enabled:{default:!0}},init:function(){this.wasLookControlsEnabled=this.el.getAttribute("look-controls","enabled")},update:function(e){e&&e.enabled===this.data.enabled||(this.data.enabled?(this.wasLookControlsEnabled=this.el.getAttribute("look-controls","enabled"),this.el.setAttribute("look-controls","enabled",!1)):this.el.setAttribute("look-controls","enabled",this.wasLookControlsEnabled===!0))},tick:function(e,t){if(this.data.enabled){var a=this.checkWhichAR();a&&(this.el.setAttribute("position",a.getPosition()),this.el.setAttribute("rotation",a.getRotation()),this.el.sceneEl.is("vr-mode")||(this.el.components.camera.camera.projectionMatrix=a.getProjectionMatrix()))}},checkWhichAR:function(){if(!this.whichar){var e=this.el.sceneEl.components["three-ar"];if(e&&e.arDisplay||(e=this.el.sceneEl.components["mozilla-xr-ar"]),!e||!e.arDisplay)return;this.whichar=e}return this.whichar}})},function(e,t){AFRAME.registerComponent("ar-planes",{getPlaneSource:function(){var e;return this.planeSource||(e=this.el.sceneEl.components["three-ar"],e&&e.arDisplay&&(this.planeSource=e.arDisplay)),this.planeSource||(e=this.el.sceneEl.components["mozilla-xr-ar"],e&&e.arDisplay&&(this.planeSource=e)),this.planeSource},getPlanes:function(){var e=this.getPlaneSource();if(e&&e.getPlanes)return e.getPlanes()},init:function(){this.planes={},this.anchorsAdded=[],this.anchorsAddedDetail={type:"added",anchors:this.anchorsAdded},this.anchorsUpdated=[],this.anchorsUpdatedDetail={type:"updated",anchors:this.anchorsUpdated},this.anchorsRemoved=[],this.anchorsRemovedDetail={type:"removed",anchors:this.anchorsRemoved}},tick:function(e,t){var a=new THREE.Vector3(1,1,1),i=(new THREE.Vector3,new THREE.Matrix4),r=new THREE.Vector3,n=(new THREE.Vector3,new THREE.Quaternion);new THREE.Euler(0,0,0,"YXZ");return function(e,t){var s=this.getPlanes();if(s){var o,l=[],c=[],h=[],p={};for(o=0;s&&o0&&(this.anchorsAddedDetail.anchors=l,this.el.emit("anchorsadded",this.anchorsAddedDetail)),this.anchorsUpdated=c,c.length>0&&(this.anchorsUpdatedDetail.anchors=c,this.el.emit("anchorsupdated",this.anchorsUpdatedDetail)),this.anchorsRemoved=h,h.length>0&&(this.anchorsRemovedDetail.anchors=h,this.el.emit("anchorsremoved",this.anchorsRemovedDetail))}}}()})},function(e,t){AFRAME.registerComponent("ar-raycaster",{dependencies:["raycaster"],schema:{x:{default:.5},y:{default:.5},el:{type:"selector"}},init:function(){this.raycaster=this.el.components.raycaster.raycaster,this.raycasterIntersectObjects=this.raycaster.intersectObjects.bind(this.raycaster),this.raycaster.intersectObjects=this.intersectObjects.bind(this)},update:function(e){this.data.el||this.el.sceneEl.object3D.el||(this.el.sceneEl.object3D.el=this.el.sceneEl)},intersectObjects:function(e,t){var a=this.raycasterIntersectObjects(e,t);return a.concat(this.hitAR())},hitAR:function(){var e=this.checkWhichAR();return e&&e.arDisplay?e.hitAR(this.data.x,this.data.y,this.data.el,this.el):[]},checkWhichAR:function(){if(!this.whichar){var e=this.el.sceneEl.components["three-ar"];if(e&&e.arDisplay||(e=this.el.sceneEl.components["mozilla-xr-ar"]),!e||!e.arDisplay)return;this.whichar=e}return this.whichar}})},function(e,t){AFRAME.registerComponent("ar",{schema:{takeOverCamera:{default:!0},cameraUserHeight:{default:!1},hideUI:{default:!0}},dependencies:["three-ar","mozilla-xr-ar","ar-planes"],init:function(){this.el.setAttribute("three-ar",{takeOverCamera:this.data.takeOverCamera,cameraUserHeight:this.data.cameraUserHeight}),this.el.setAttribute("mozilla-xr-ar",{takeOverCamera:this.data.takeOverCamera,cameraUserHeight:this.data.cameraUserHeight}),this.data.hideUI&&this.el.sceneEl.setAttribute("vr-mode-ui",{enabled:!1}),document.head.insertAdjacentHTML("beforeend","")}})},function(e,t){AFRAME.registerComponent("mozilla-xr-ar",{schema:{takeOverCamera:{default:!0},cameraUserHeight:{default:!1}},init:function(){this.onInit=this.onInit.bind(this),this.onWatch=this.onWatch.bind(this),this.poseMatrix=new THREE.Matrix4,this.posePosition=new THREE.Vector3,this.poseQuaternion=new THREE.Quaternion,this.poseEuler=new THREE.Euler(0,0,0,"YXZ"),this.poseRotation=new THREE.Vector3,this.projectionMatrix=new THREE.Matrix4,this.viewMatrix=new THREE.Matrix4,this.onceSceneLoaded=this.onceSceneLoaded.bind(this),this.el.sceneEl.hasLoaded?(console.log("mozilla-xr-ar: hasLoaded, setTimeout"),setTimeout(this.onceSceneLoaded)):(console.log("mozilla-xr-ar: !hasLoaded, addEventListener"),this.el.sceneEl.addEventListener("loaded",this.onceSceneLoaded)),this.planes_=new Map,this.anchors_=new Map},takeOverCamera:function(e){this.arCamera=e,e.el.setAttribute("ar-camera","enabled",!0)},onceSceneLoaded:function(){if(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.initAR){setTimeout(function(){var e=AFRAME.scenes[0];e.canvas.style.position="absolute !important",e.canvas.style.width="100% !important",e.canvas.style.height="100% !important",setTimeout(function(){e.resize()})},1e3),window.arkitCallback0=this.onInit,window.arkitCallback1=this.onWatch;var e={options:{ui:{browser:!0,points:!0,focus:!1,rec:!0,rec_time:!0,mic:!1,build:!1,plane:!0,warnings:!0,anchors:!1,debug:!0,statistics:!1}},callback:"arkitCallback0"};window.webkit.messageHandlers.initAR.postMessage(e)}},checkForARDisplay:function(){if(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.watchAR){this.arDisplay=!0;var e={options:{location:!0,camera:!0,objects:!0,light_intensity:!0},callback:"arkitCallback1"};window.arkitWindowResize=function(){setTimeout(function(){AFRAME.scenes[0].resize()},100)},window.webkit.messageHandlers.watchAR.postMessage(e);var t=this,a=t.el.sceneEl;t.data.takeOverCamera&&setTimeout(function(){t.takeOverCamera(a.camera)}),a.renderer.setPixelRatio(1),a.renderer.autoClear=!1,a.renderer.setClearColor("#000",0),a.renderer.alpha=!0}},onInit:function(e){this.checkForARDisplay()},onWatch:function(e){this.frameData=e,this.handleFrame(e)},handleFrame:function(e){this.el.sceneEl;this.poseMatrix.fromArray(e.camera_transform),this.poseMatrix.decompose(this.posePosition,this.poseQuaternion,this.poseRotation),this.poseEuler.setFromQuaternion(this.poseQuaternion),this.poseRotation.set(THREE.Math.RAD2DEG*this.poseEuler.x,THREE.Math.RAD2DEG*this.poseEuler.y,THREE.Math.RAD2DEG*this.poseEuler.z),this.projectionMatrix.fromArray(e.projection_camera),this.viewMatrix.fromArray(e.camera_view),this.arCamera&&this.data.cameraUserHeight&&(this.posePosition.y+=this.arCamera.el.components.camera.data.userHeight);var t=this.posePosition.x||this.posePosition.y||this.posePosition.z||this.poseQuaternion.x||this.poseQuaternion.y||this.poseQuaternion.z;t?this.poseLost!==!1&&(this.poseLost=!1,this.el.emit("poseFound")):this.poseLost!==!0&&(this.poseLost=!0,this.el.emit("poseLost",!1));var a;if(e.newObjects&&e.newObjects.length)for(a=0;a1||n<0||n>1)throw new Error("hitTest - x and y values must be normalized [0,1]!");var s=[],o=this.getPlanes();if(!o||0==o.length)return s;t.rayStart.set(2*r-1,2*(1-n)-1,0),t.rayEnd.set(2*r-1,2*(1-n)-1,1),t.planeMatrix.multiplyMatrices(this.projectionMatrix,this.viewMatrix),t.projViewMatrix.getInverse(t.planeMatrix),t.worldRayStart.copy(t.rayStart).applyMatrix4(t.projViewMatrix),t.worldRayEnd.copy(t.rayEnd).applyMatrix4(t.projViewMatrix),t.worldRayDir.subVectors(t.worldRayEnd,t.worldRayStart).normalize();for(var l=0;lt.planeExtent.x/2+p||Math.abs(t.planeIntersectionLocal.z)>t.planeExtent.z/2+p)){t.planeHit.makeTranslation(t.planeIntersection.x,t.planeIntersection.y,t.planeIntersection.z);for(var d=new e,u=0;u<16;u++)d.modelMatrix[u]=t.planeHit.elements[u];d.i=l,s.push(d)}}}return s.sort(i),s}}(),hitAR:function(){var e=new THREE.Matrix4,t=new THREE.Vector3,a=new THREE.Quaternion,i=new THREE.Vector3,r=new THREE.Vector3;return function(n,s,o,l){if(!this.arDisplay)return[];for(var c=this.hitTestNoAnchor(n,s),h=[],p=0;c&&p0&&(this.anchorsAddedDetail.anchors=l,this.el.emit("anchorsadded",this.anchorsAddedDetail)),this.anchorsUpdated=c,c.length>0&&(this.anchorsUpdatedDetail.anchors=c,this.el.emit("anchorsupdated",this.anchorsUpdatedDetail)),this.anchorsRemoved=h,h.length>0&&(this.anchorsRemovedDetail.anchors=h,this.el.emit("anchorsremoved",this.anchorsRemovedDetail))}}}()})},function(e,t){AFRAME.registerComponent("ar-raycaster",{dependencies:["raycaster"],schema:{x:{default:.5},y:{default:.5},el:{type:"selector"}},init:function(){this.raycaster=this.el.components.raycaster.raycaster,this.raycasterIntersectObjects=this.raycaster.intersectObjects.bind(this.raycaster),this.raycaster.intersectObjects=this.intersectObjects.bind(this)},update:function(e){this.data.el||this.el.sceneEl.object3D.el||(this.el.sceneEl.object3D.el=this.el.sceneEl)},intersectObjects:function(e,t){var a=this.raycasterIntersectObjects(e,t);return a.concat(this.hitAR())},hitAR:function(){var e=this.checkWhichAR();if(!e||!e.arDisplay)return[];var t=this.data.x,a=this.data.y;return arguments.length>=2&&(t=arguments[0],a=arguments[1]),e.hitAR(t,a,this.data.el,this.el)},checkWhichAR:function(){if(!this.whichar){var e=this.el.sceneEl.components["three-ar"];if(e&&e.arDisplay||(e=this.el.sceneEl.components["mozilla-xr-ar"]),!e||!e.arDisplay)return;this.whichar=e}return this.whichar}})},function(e,t){AFRAME.registerComponent("ar",{schema:{takeOverCamera:{default:!0},cameraUserHeight:{default:!1},hideUI:{default:!0}},dependencies:["three-ar","mozilla-xr-ar","ar-planes"],init:function(){this.el.setAttribute("three-ar",{takeOverCamera:this.data.takeOverCamera,cameraUserHeight:this.data.cameraUserHeight}),this.el.setAttribute("mozilla-xr-ar",{takeOverCamera:this.data.takeOverCamera,cameraUserHeight:this.data.cameraUserHeight}),this.data.hideUI&&this.el.sceneEl.setAttribute("vr-mode-ui",{enabled:!1}),document.head.insertAdjacentHTML("beforeend","")}})},function(e,t){AFRAME.registerComponent("mozilla-xr-ar",{schema:{takeOverCamera:{default:!0},cameraUserHeight:{default:!1}},init:function(){this.onInit=this.onInit.bind(this),this.onWatch=this.onWatch.bind(this),this.poseMatrix=new THREE.Matrix4,this.posePosition=new THREE.Vector3,this.poseQuaternion=new THREE.Quaternion,this.poseEuler=new THREE.Euler(0,0,0,"YXZ"),this.poseRotation=new THREE.Vector3,this.projectionMatrix=new THREE.Matrix4,this.viewMatrix=new THREE.Matrix4,this.onceSceneLoaded=this.onceSceneLoaded.bind(this),this.el.sceneEl.hasLoaded?(console.log("mozilla-xr-ar: hasLoaded, setTimeout"),setTimeout(this.onceSceneLoaded)):(console.log("mozilla-xr-ar: !hasLoaded, addEventListener"),this.el.sceneEl.addEventListener("loaded",this.onceSceneLoaded)),this.planes_=new Map,this.anchors_=new Map},takeOverCamera:function(e){this.arCamera=e,e.el.setAttribute("ar-camera","enabled",!0)},onceSceneLoaded:function(){if(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.initAR){setTimeout(function(){var e=AFRAME.scenes[0];e.canvas.style.position="absolute !important",e.canvas.style.width="100% !important",e.canvas.style.height="100% !important",setTimeout(function(){e.resize()})},1e3),window.arkitCallback0=this.onInit,window.arkitCallback1=this.onWatch;var e={options:{ui:{browser:!0,points:!0,focus:!1,rec:!0,rec_time:!0,mic:!1,build:!1,plane:!0,warnings:!0,anchors:!1,debug:!0,statistics:!1}},callback:"arkitCallback0"};window.webkit.messageHandlers.initAR.postMessage(e)}},checkForARDisplay:function(){if(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.watchAR){this.arDisplay=!0;var e={options:{location:!0,camera:!0,objects:!0,light_intensity:!0},callback:"arkitCallback1"};window.arkitWindowResize=function(){setTimeout(function(){AFRAME.scenes[0].resize()},100)},window.webkit.messageHandlers.watchAR.postMessage(e);var t=this,a=t.el.sceneEl;t.data.takeOverCamera&&setTimeout(function(){t.takeOverCamera(a.camera)}),a.renderer.setPixelRatio(1),a.renderer.autoClear=!1,a.renderer.setClearColor("#000",0),a.renderer.alpha=!0}},onInit:function(e){this.checkForARDisplay()},onWatch:function(e){this.frameData=e,this.handleFrame(e)},handleFrame:function(e){this.el.sceneEl;this.poseMatrix.fromArray(e.camera_transform),this.poseMatrix.decompose(this.posePosition,this.poseQuaternion,this.poseRotation),this.poseEuler.setFromQuaternion(this.poseQuaternion),this.poseRotation.set(THREE.Math.RAD2DEG*this.poseEuler.x,THREE.Math.RAD2DEG*this.poseEuler.y,THREE.Math.RAD2DEG*this.poseEuler.z),this.projectionMatrix.fromArray(e.projection_camera),this.viewMatrix.fromArray(e.camera_view),this.arCamera&&this.data.cameraUserHeight&&(this.posePosition.y+=this.arCamera.el.components.camera.data.userHeight);var t=this.posePosition.x||this.posePosition.y||this.posePosition.z||this.poseQuaternion.x||this.poseQuaternion.y||this.poseQuaternion.z;t?this.poseLost!==!1&&(this.poseLost=!1,this.el.emit("poseFound")):this.poseLost!==!0&&(this.poseLost=!0,this.el.emit("poseLost",!1));var a;if(e.newObjects&&e.newObjects.length)for(a=0;a1||n<0||n>1)throw new Error("hitTest - x and y values must be normalized [0,1]!");var s=[],o=this.getPlanes();if(!o||0==o.length)return s;t.rayStart.set(2*r-1,2*(1-n)-1,0),t.rayEnd.set(2*r-1,2*(1-n)-1,1),t.planeMatrix.multiplyMatrices(this.projectionMatrix,this.viewMatrix),t.projViewMatrix.getInverse(t.planeMatrix),t.worldRayStart.copy(t.rayStart).applyMatrix4(t.projViewMatrix),t.worldRayEnd.copy(t.rayEnd).applyMatrix4(t.projViewMatrix),t.worldRayDir.subVectors(t.worldRayEnd,t.worldRayStart).normalize();for(var l=0;lt.planeExtent.x/2+p||Math.abs(t.planeIntersectionLocal.z)>t.planeExtent.z/2+p)){t.planeHit.makeTranslation(t.planeIntersection.x,t.planeIntersection.y,t.planeIntersection.z);for(var d=new e,u=0;u<16;u++)d.modelMatrix[u]=t.planeHit.elements[u];d.i=l,s.push(d)}}}return s.sort(i),s}}(),hitAR:function(){var e=new THREE.Matrix4,t=new THREE.Vector3,a=new THREE.Quaternion,i=new THREE.Vector3,r=new THREE.Vector3;return function(n,s,o,l){if(!this.arDisplay)return[];for(var c=this.hitTestNoAnchor(n,s),h=[],p=0;c&&p= 2) { + x = arguments[0]; + y = arguments[1]; + } + return whichar.hitAR(x, y, this.data.el, this.el); }, checkWhichAR: function () {