diff --git a/dist/three.ar.js b/dist/three.ar.js
index 18fcd7d..32aacdf 100644
--- a/dist/three.ar.js
+++ b/dist/three.ar.js
@@ -1137,16 +1137,33 @@ exports.default = ARReticle;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
+/*
+ * Copyright 2017 Google Inc. All Rights Reserved.
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* eslint-disable */
(function () {
if (window.webarSpeechRecognitionInstance) {
var addEventHandlingToObject = function addEventHandlingToObject(object) {
object.listeners = {};
object.addEventListener = function (eventType, callback) {
- if (!callback) return this;
+ if (!callback) {
+ return this;
+ }
var listeners = this.listeners[eventType];
if (!listeners) {
- listeners = [];
- this.listeners[eventType] = listeners;
+ this.listeners[eventType] = listeners = [];
}
if (listeners.indexOf(callback) < 0) {
listeners.push(callback);
@@ -1154,7 +1171,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
return this;
};
object.removeEventListener = function (eventType, callback) {
- if (!callback) return this;
+ if (!callback) {
+ return this;
+ }
var listeners = this.listeners[eventType];
if (listeners) {
var i = listeners.indexOf(callback);
@@ -1165,8 +1184,12 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
return this;
};
object.callEventListeners = function (eventType, event) {
- if (!event) event = { target: this };
- if (!event.target) event.target = this;
+ if (!event) {
+ event = { target: this };
+ }
+ if (!event.target) {
+ event.target = this;
+ }
event.type = eventType;
var onEventType = 'on' + eventType;
if (typeof this[onEventType] === 'function') {
@@ -1176,9 +1199,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
if (listeners) {
for (var i = 0; i < listeners.length; i++) {
var typeofListener = _typeof(listeners[i]);
- if (typeofListener === "object") {
+ if (typeofListener === 'object') {
listeners[i].handleEvent(event);
- } else if (typeofListener === "function") {
+ } else if (typeofListener === 'function') {
listeners[i](event);
}
}
diff --git a/dist/three.ar.min.js b/dist/three.ar.min.js
index c15e141..3fcd5f5 100644
--- a/dist/three.ar.min.js
+++ b/dist/three.ar.min.js
@@ -14,4 +14,4 @@
*/
-!function(e){function t(r){if(i[r])return i[r].exports;var n=i[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var i={};t.m=e,t.c=i,t.i=function(e){return e},t.d=function(e,i,r){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=8)}([function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.displayUnsupportedMessage=t.placeObjectAtHit=t.loadBlocksModel=t.getARDisplay=t.isARDisplay=t.isARKit=t.isTango=void 0;var r=i(9);THREE.ARUtils=Object.create(null),THREE.ARUtils.isTango=function(e){return e&&e.displayName.toLowerCase().includes("tango")};var n=t.isTango=THREE.ARUtils.isTango;THREE.ARUtils.isARKit=function(e){return e&&e.displayName.toLowerCase().includes("arkit")};var o=t.isARKit=THREE.ARUtils.isARKit;THREE.ARUtils.isARDisplay=function(e){return o(e)||n(e)};var s=t.isARDisplay=THREE.ARUtils.isARDisplay;THREE.ARUtils.getARDisplay=function(){return new Promise(function(e,t){if(!navigator.getVRDisplays)return void e(null);navigator.getVRDisplays().then(function(t){if(!t&&0===t.length)return void e(null);var i=!0,r=!1,n=void 0;try{for(var o,a=t[Symbol.iterator]();!(i=(o=a.next()).done);i=!0){var l=o.value;if(s(l))return void e(l)}}catch(e){r=!0,n=e}finally{try{!i&&a.return&&a.return()}finally{if(r)throw n}}e(null)})})};t.getARDisplay=THREE.ARUtils.getARDisplay;THREE.ARUtils.loadBlocksModel=function(e,t){return new Promise(function(i,n){if(!THREE.OBJLoader||!THREE.MTLLoader)return void n(new Error("Must include THREE.OBJLoader and THREE.MTLLoader"));var o=Promise.resolve();t&&(o=(0,r.loadMtl)(t)),o.then(function(t){return t&&t.preload(),(0,r.loadObj)(e,t)}).then(function(e){var t=e.children[0];return t.geometry.applyMatrix((new THREE.Matrix4).makeRotationY(THREE.Math.degToRad(-90))),t}).then(i,n)})};var a=(t.loadBlocksModel=THREE.ARUtils.loadBlocksModel,new THREE.Matrix4),l=new THREE.Vector3,u=new THREE.Quaternion,h=new THREE.Vector3;THREE.ARUtils.placeObjectAtHit=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!t||!t.modelMatrix)throw new Error("placeObjectAtHit requires a VRHit object");a.fromArray(t.modelMatrix),a.decompose(l,u,h),1===i?(e.position.copy(l),r&&e.quaternion.copy(u)):(e.position.lerp(l,i),r&&e.quaternion.slerp(u,i))};t.placeObjectAtHit=THREE.ARUtils.placeObjectAtHit;THREE.ARUtils.displayUnsupportedMessage=function(){var e=document.createElement("div");e.id="webgl-error-message",e.style.fontFamily="monospace",e.style.fontSize="13px",e.style.fontWeight="normal",e.style.textAlign="center",e.style.background="#fff",e.style.border="1px solid black",e.style.color="#000",e.style.padding="1.5em",e.style.width="400px",e.style.margin="5em auto 0",e.innerHTML='This augmented reality experience requires\n WebARonARCore or WebARonARKit, experimental browsers from Google \n for Android and iOS. Learn more atdevelopers.google.com.',document.body.appendChild(e)};t.displayUnsupportedMessage=THREE.ARUtils.displayUnsupportedMessage},function(e,t,i){"use strict";function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t,i){var r=void 0,n=void 0;return function(){for(var o=arguments.length,s=Array(o),a=0;a=0&&(clearTimeout(n),n=setTimeout(function(){r=l,e.apply(i,s)},u))}}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){var i=[],r=!0,n=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(r=(s=a.next()).done)&&(i.push(s.value),!t||i.length!==t);r=!0);}catch(e){n=!0,o=e}finally{try{!r&&a.return&&a.return()}finally{if(n)throw o}}return i}return function(t,i){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),l=function(){function e(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:{};o(this,e),this.config=Object.assign({},i,u),this.vrDisplay=t,this._view=new f({open:this.config.open}),this.config.showLastHit&&this.vrDisplay.hitTest&&this._view.addRow("hit-test",new p(t)),this.config.showPoseStatus&&this.vrDisplay.getFrameData&&this._view.addRow("pose-status",new v(t))}return l(e,[{key:"open",value:function(){this._view.open()}},{key:"close",value:function(){this._view.close()}},{key:"getElement",value:function(){return this._view.getElement()}}]),e}(),f=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,e),this.rows=new Map,this.el=document.createElement("div"),this.el.style.backgroundColor="#333",this.el.style.padding="5px",this.el.style.fontFamily="Roboto, Ubuntu, Arial, sans-serif",this.el.style.color="rgb(165, 165, 165)",this.el.style.position="absolute",this.el.style.right="20px",this.el.style.top="0px",this.el.style.width="200px",this.el.style.fontSize="12px",this.el.style.zIndex=9999,this._rowsEl=document.createElement("div"),this._rowsEl.style.transitionProperty="max-height",this._rowsEl.style.transitionDuration="0.5s",this._rowsEl.style.transitionDelay="0s",this._rowsEl.style.transitionTimingFunction="ease-out",this._rowsEl.style.overflow="hidden",this._controls=document.createElement("div"),this._controls.style.fontSize="13px",this._controls.style.fontWeight="bold",this._controls.style.paddingTop="5px",this._controls.style.textAlign="center",this._controls.style.cursor="pointer",this._controls.addEventListener("click",this.toggleControls.bind(this)),t.open?this.open():this.close(),this.el.appendChild(this._rowsEl),this.el.appendChild(this._controls)}return l(e,[{key:"toggleControls",value:function(){this._isOpen?this.close():this.open()}},{key:"open",value:function(){this._rowsEl.style.maxHeight="100px",this._isOpen=!0,this._controls.textContent="Close ARDebug";var e=!0,t=!1,i=void 0;try{for(var r,n=this.rows[Symbol.iterator]();!(e=(r=n.next()).done);e=!0){a(r.value,2)[1].enable()}}catch(e){t=!0,i=e}finally{try{!e&&n.return&&n.return()}finally{if(t)throw i}}}},{key:"close",value:function(){this._rowsEl.style.maxHeight="0px",this._isOpen=!1,this._controls.textContent="Open ARDebug";var e=!0,t=!1,i=void 0;try{for(var r,n=this.rows[Symbol.iterator]();!(e=(r=n.next()).done);e=!0){a(r.value,2)[1].disable()}}catch(e){t=!0,i=e}finally{try{!e&&n.return&&n.return()}finally{if(t)throw i}}}},{key:"getElement",value:function(){return this.el}},{key:"addRow",value:function(e,t){this.rows.set(e,t),this._isOpen&&t.enable(),this._rowsEl.appendChild(t.getElement())}}]),e}(),d=function(){function e(t){o(this,e),this.el=document.createElement("div"),this.el.style.width="100%",this.el.style.borderTop="1px solid rgb(54, 54, 54)",this.el.style.borderBottom="1px solid #14171A",this.el.style.position="relative",this.el.style.padding="3px 0px",this.el.style.overflow="hidden",this._titleEl=document.createElement("span"),this._titleEl.style.fontWeight="bold",this._titleEl.textContent=t,this._dataEl=document.createElement("span"),this._dataEl.style.position="absolute",this._dataEl.style.left="40px",this._dataElText=document.createTextNode(""),this._dataEl.appendChild(this._dataElText),this.el.appendChild(this._titleEl),this.el.appendChild(this._dataEl),this.update=s(this.update,500,this)}return l(e,[{key:"enable",value:function(){throw new Error("Implement in child class")}},{key:"disable",value:function(){throw new Error("Implement in child class")}},{key:"getElement",value:function(){return this.el}},{key:"update",value:function(e,t){this._dataElText.nodeValue=e,this._dataEl.style.color=t?"#00ff00":"#ff0077"}}]),e}(),p=function(e){function t(e){o(this,t);var i=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"Hit"));return i.vrDisplay=e,i._onHitTest=i._onHitTest.bind(i),i._nativeHitTest=h.get("hitTest")||i.vrDisplay.hitTest,h.set("hitTest",i._nativeHitTest),i._didPreviouslyHit=null,i}return n(t,e),l(t,[{key:"enable",value:function(){this.vrDisplay.hitTest=this._onHitTest}},{key:"disable",value:function(){this.vrDisplay.hitTest=this._nativeHitTest}},{key:"_hitToString",value:function(e){var t=e.modelMatrix;return t[12].toFixed(2)+", "+t[13].toFixed(2)+", "+t[14].toFixed(2)}},{key:"_onHitTest",value:function(e,t){var i=this._nativeHitTest.call(this.vrDisplay,e,t),r=(parseInt(performance.now(),10)/1e3).toFixed(1),n=i&&i.length;return this.update((n?this._hitToString(i[0]):"MISS")+" @ "+r+"s",n),this._didPreviouslyHit=n,i}}]),t}(d),v=function(e){function t(e){o(this,t);var i=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"Pose"));return i.vrDisplay=e,i._onGetFrameData=i._onGetFrameData.bind(i),i._nativeGetFrameData=h.get("getFrameData")||i.vrDisplay.getFrameData,h.set("getFrameData",i._nativeGetFrameData),i.update("Looking for position..."),i._initialPose=!1,i}return n(t,e),l(t,[{key:"enable",value:function(){this.vrDisplay.getFrameData=this._onGetFrameData}},{key:"disable",value:function(){this.vrDisplay.getFrameData=this._nativeGetFrameData}},{key:"_poseToString",value:function(e){return e[0].toFixed(2)+", "+e[1].toFixed(2)+", "+e[2].toFixed(2)}},{key:"_onGetFrameData",value:function(e){var t=this._nativeGetFrameData.call(this.vrDisplay,e),i=e&&e.pose&&e.pose.position,r=i&&"number"==typeof i[0]&&"number"==typeof i[1]&&"number"==typeof i[2]&&!(0===i[0]&&0===i[1]&&0===i[2]);return this._initialPose||r?(r?this.update(this._poseToString(i),!0):r||!1===this._lastPoseValid||this.update("Position lost",!1),this._lastPoseValid=r,this._initialPose=!0,t):t}}]),t}(d);THREE.ARDebug=c,t.default=c},function(e,t,i){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:.02,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.05,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16711799,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.25;r(this,t);var l=new THREE.RingGeometry(i,o,36,64),u=new THREE.MeshBasicMaterial({color:s});l.applyMatrix((new THREE.Matrix4).makeRotationX(THREE.Math.degToRad(-90)));var h=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,l,u));return h.visible=!1,h.easing=a,h.applyOrientation=!0,h.vrDisplay=e,h._planeDir=new THREE.Vector3,h}return o(t,e),s(t,[{key:"update",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.5,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5;if(this.vrDisplay&&this.vrDisplay.hitTest){var i=this.vrDisplay.hitTest(e,t);i&&i.length>0&&(this.visible=!0,(0,a.placeObjectAtHit)(this,i[0],this.applyOrientation,this.easing))}}}]),t}(THREE.Mesh);THREE.ARReticle=l,t.default=l},function(e,t,i){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(){if(window.webarSpeechRecognitionInstance){!function(e){e.listeners={},e.addEventListener=function(e,t){if(!t)return this;var i=this.listeners[e];return i||(i=[],this.listeners[e]=i),i.indexOf(t)<0&&i.push(t),this},e.removeEventListener=function(e,t){if(!t)return this;var i=this.listeners[e];if(i){var r=i.indexOf(t);r>=0&&(this.listeners[e]=i.splice(r,1))}return this},e.callEventListeners=function(e,t){t||(t={target:this}),t.target||(t.target=this),t.type=e;var i="on"+e;"function"==typeof this[i]&&this[i](t);var n=this.listeners[e];if(n)for(var o=0;o=2&&n.setTexturePath(o[o.length-2]),n.load(e,t,r,i)})}}]);
\ No newline at end of file
+!function(e){function t(r){if(i[r])return i[r].exports;var n=i[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var i={};t.m=e,t.c=i,t.i=function(e){return e},t.d=function(e,i,r){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=8)}([function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.displayUnsupportedMessage=t.placeObjectAtHit=t.loadBlocksModel=t.getARDisplay=t.isARDisplay=t.isARKit=t.isTango=void 0;var r=i(9);THREE.ARUtils=Object.create(null),THREE.ARUtils.isTango=function(e){return e&&e.displayName.toLowerCase().includes("tango")};var n=t.isTango=THREE.ARUtils.isTango;THREE.ARUtils.isARKit=function(e){return e&&e.displayName.toLowerCase().includes("arkit")};var o=t.isARKit=THREE.ARUtils.isARKit;THREE.ARUtils.isARDisplay=function(e){return o(e)||n(e)};var s=t.isARDisplay=THREE.ARUtils.isARDisplay;THREE.ARUtils.getARDisplay=function(){return new Promise(function(e,t){if(!navigator.getVRDisplays)return void e(null);navigator.getVRDisplays().then(function(t){if(!t&&0===t.length)return void e(null);var i=!0,r=!1,n=void 0;try{for(var o,a=t[Symbol.iterator]();!(i=(o=a.next()).done);i=!0){var l=o.value;if(s(l))return void e(l)}}catch(e){r=!0,n=e}finally{try{!i&&a.return&&a.return()}finally{if(r)throw n}}e(null)})})};t.getARDisplay=THREE.ARUtils.getARDisplay;THREE.ARUtils.loadBlocksModel=function(e,t){return new Promise(function(i,n){if(!THREE.OBJLoader||!THREE.MTLLoader)return void n(new Error("Must include THREE.OBJLoader and THREE.MTLLoader"));var o=Promise.resolve();t&&(o=(0,r.loadMtl)(t)),o.then(function(t){return t&&t.preload(),(0,r.loadObj)(e,t)}).then(function(e){var t=e.children[0];return t.geometry.applyMatrix((new THREE.Matrix4).makeRotationY(THREE.Math.degToRad(-90))),t}).then(i,n)})};var a=(t.loadBlocksModel=THREE.ARUtils.loadBlocksModel,new THREE.Matrix4),l=new THREE.Vector3,u=new THREE.Quaternion,h=new THREE.Vector3;THREE.ARUtils.placeObjectAtHit=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!t||!t.modelMatrix)throw new Error("placeObjectAtHit requires a VRHit object");a.fromArray(t.modelMatrix),a.decompose(l,u,h),1===i?(e.position.copy(l),r&&e.quaternion.copy(u)):(e.position.lerp(l,i),r&&e.quaternion.slerp(u,i))};t.placeObjectAtHit=THREE.ARUtils.placeObjectAtHit;THREE.ARUtils.displayUnsupportedMessage=function(){var e=document.createElement("div");e.id="webgl-error-message",e.style.fontFamily="monospace",e.style.fontSize="13px",e.style.fontWeight="normal",e.style.textAlign="center",e.style.background="#fff",e.style.border="1px solid black",e.style.color="#000",e.style.padding="1.5em",e.style.width="400px",e.style.margin="5em auto 0",e.innerHTML='This augmented reality experience requires\n WebARonARCore or WebARonARKit, experimental browsers from Google \n for Android and iOS. Learn more atdevelopers.google.com.',document.body.appendChild(e)};t.displayUnsupportedMessage=THREE.ARUtils.displayUnsupportedMessage},function(e,t,i){"use strict";function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function s(e,t,i){var r=void 0,n=void 0;return function(){for(var o=arguments.length,s=Array(o),a=0;a=0&&(clearTimeout(n),n=setTimeout(function(){r=l,e.apply(i,s)},u))}}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){var i=[],r=!0,n=!1,o=void 0;try{for(var s,a=e[Symbol.iterator]();!(r=(s=a.next()).done)&&(i.push(s.value),!t||i.length!==t);r=!0);}catch(e){n=!0,o=e}finally{try{!r&&a.return&&a.return()}finally{if(n)throw o}}return i}return function(t,i){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),l=function(){function e(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:{};o(this,e),this.config=Object.assign({},i,u),this.vrDisplay=t,this._view=new f({open:this.config.open}),this.config.showLastHit&&this.vrDisplay.hitTest&&this._view.addRow("hit-test",new p(t)),this.config.showPoseStatus&&this.vrDisplay.getFrameData&&this._view.addRow("pose-status",new v(t))}return l(e,[{key:"open",value:function(){this._view.open()}},{key:"close",value:function(){this._view.close()}},{key:"getElement",value:function(){return this._view.getElement()}}]),e}(),f=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};o(this,e),this.rows=new Map,this.el=document.createElement("div"),this.el.style.backgroundColor="#333",this.el.style.padding="5px",this.el.style.fontFamily="Roboto, Ubuntu, Arial, sans-serif",this.el.style.color="rgb(165, 165, 165)",this.el.style.position="absolute",this.el.style.right="20px",this.el.style.top="0px",this.el.style.width="200px",this.el.style.fontSize="12px",this.el.style.zIndex=9999,this._rowsEl=document.createElement("div"),this._rowsEl.style.transitionProperty="max-height",this._rowsEl.style.transitionDuration="0.5s",this._rowsEl.style.transitionDelay="0s",this._rowsEl.style.transitionTimingFunction="ease-out",this._rowsEl.style.overflow="hidden",this._controls=document.createElement("div"),this._controls.style.fontSize="13px",this._controls.style.fontWeight="bold",this._controls.style.paddingTop="5px",this._controls.style.textAlign="center",this._controls.style.cursor="pointer",this._controls.addEventListener("click",this.toggleControls.bind(this)),t.open?this.open():this.close(),this.el.appendChild(this._rowsEl),this.el.appendChild(this._controls)}return l(e,[{key:"toggleControls",value:function(){this._isOpen?this.close():this.open()}},{key:"open",value:function(){this._rowsEl.style.maxHeight="100px",this._isOpen=!0,this._controls.textContent="Close ARDebug";var e=!0,t=!1,i=void 0;try{for(var r,n=this.rows[Symbol.iterator]();!(e=(r=n.next()).done);e=!0){a(r.value,2)[1].enable()}}catch(e){t=!0,i=e}finally{try{!e&&n.return&&n.return()}finally{if(t)throw i}}}},{key:"close",value:function(){this._rowsEl.style.maxHeight="0px",this._isOpen=!1,this._controls.textContent="Open ARDebug";var e=!0,t=!1,i=void 0;try{for(var r,n=this.rows[Symbol.iterator]();!(e=(r=n.next()).done);e=!0){a(r.value,2)[1].disable()}}catch(e){t=!0,i=e}finally{try{!e&&n.return&&n.return()}finally{if(t)throw i}}}},{key:"getElement",value:function(){return this.el}},{key:"addRow",value:function(e,t){this.rows.set(e,t),this._isOpen&&t.enable(),this._rowsEl.appendChild(t.getElement())}}]),e}(),d=function(){function e(t){o(this,e),this.el=document.createElement("div"),this.el.style.width="100%",this.el.style.borderTop="1px solid rgb(54, 54, 54)",this.el.style.borderBottom="1px solid #14171A",this.el.style.position="relative",this.el.style.padding="3px 0px",this.el.style.overflow="hidden",this._titleEl=document.createElement("span"),this._titleEl.style.fontWeight="bold",this._titleEl.textContent=t,this._dataEl=document.createElement("span"),this._dataEl.style.position="absolute",this._dataEl.style.left="40px",this._dataElText=document.createTextNode(""),this._dataEl.appendChild(this._dataElText),this.el.appendChild(this._titleEl),this.el.appendChild(this._dataEl),this.update=s(this.update,500,this)}return l(e,[{key:"enable",value:function(){throw new Error("Implement in child class")}},{key:"disable",value:function(){throw new Error("Implement in child class")}},{key:"getElement",value:function(){return this.el}},{key:"update",value:function(e,t){this._dataElText.nodeValue=e,this._dataEl.style.color=t?"#00ff00":"#ff0077"}}]),e}(),p=function(e){function t(e){o(this,t);var i=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"Hit"));return i.vrDisplay=e,i._onHitTest=i._onHitTest.bind(i),i._nativeHitTest=h.get("hitTest")||i.vrDisplay.hitTest,h.set("hitTest",i._nativeHitTest),i._didPreviouslyHit=null,i}return n(t,e),l(t,[{key:"enable",value:function(){this.vrDisplay.hitTest=this._onHitTest}},{key:"disable",value:function(){this.vrDisplay.hitTest=this._nativeHitTest}},{key:"_hitToString",value:function(e){var t=e.modelMatrix;return t[12].toFixed(2)+", "+t[13].toFixed(2)+", "+t[14].toFixed(2)}},{key:"_onHitTest",value:function(e,t){var i=this._nativeHitTest.call(this.vrDisplay,e,t),r=(parseInt(performance.now(),10)/1e3).toFixed(1),n=i&&i.length;return this.update((n?this._hitToString(i[0]):"MISS")+" @ "+r+"s",n),this._didPreviouslyHit=n,i}}]),t}(d),v=function(e){function t(e){o(this,t);var i=r(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,"Pose"));return i.vrDisplay=e,i._onGetFrameData=i._onGetFrameData.bind(i),i._nativeGetFrameData=h.get("getFrameData")||i.vrDisplay.getFrameData,h.set("getFrameData",i._nativeGetFrameData),i.update("Looking for position..."),i._initialPose=!1,i}return n(t,e),l(t,[{key:"enable",value:function(){this.vrDisplay.getFrameData=this._onGetFrameData}},{key:"disable",value:function(){this.vrDisplay.getFrameData=this._nativeGetFrameData}},{key:"_poseToString",value:function(e){return e[0].toFixed(2)+", "+e[1].toFixed(2)+", "+e[2].toFixed(2)}},{key:"_onGetFrameData",value:function(e){var t=this._nativeGetFrameData.call(this.vrDisplay,e),i=e&&e.pose&&e.pose.position,r=i&&"number"==typeof i[0]&&"number"==typeof i[1]&&"number"==typeof i[2]&&!(0===i[0]&&0===i[1]&&0===i[2]);return this._initialPose||r?(r?this.update(this._poseToString(i),!0):r||!1===this._lastPoseValid||this.update("Position lost",!1),this._lastPoseValid=r,this._initialPose=!0,t):t}}]),t}(d);THREE.ARDebug=c,t.default=c},function(e,t,i){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var s=function(){function e(e,t){for(var i=0;i1&&void 0!==arguments[1]?arguments[1]:.02,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.05,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:16711799,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:.25;r(this,t);var l=new THREE.RingGeometry(i,o,36,64),u=new THREE.MeshBasicMaterial({color:s});l.applyMatrix((new THREE.Matrix4).makeRotationX(THREE.Math.degToRad(-90)));var h=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,l,u));return h.visible=!1,h.easing=a,h.applyOrientation=!0,h.vrDisplay=e,h._planeDir=new THREE.Vector3,h}return o(t,e),s(t,[{key:"update",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.5,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.5;if(this.vrDisplay&&this.vrDisplay.hitTest){var i=this.vrDisplay.hitTest(e,t);i&&i.length>0&&(this.visible=!0,(0,a.placeObjectAtHit)(this,i[0],this.applyOrientation,this.easing))}}}]),t}(THREE.Mesh);THREE.ARReticle=l,t.default=l},function(e,t,i){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(){if(window.webarSpeechRecognitionInstance){!function(e){e.listeners={},e.addEventListener=function(e,t){if(!t)return this;var i=this.listeners[e];return i||(this.listeners[e]=i=[]),i.indexOf(t)<0&&i.push(t),this},e.removeEventListener=function(e,t){if(!t)return this;var i=this.listeners[e];if(i){var r=i.indexOf(t);r>=0&&(this.listeners[e]=i.splice(r,1))}return this},e.callEventListeners=function(e,t){t||(t={target:this}),t.target||(t.target=this),t.type=e;var i="on"+e;"function"==typeof this[i]&&this[i](t);var n=this.listeners[e];if(n)for(var o=0;o=2&&n.setTexturePath(o[o.length-2]),n.load(e,t,r,i)})}}]);
\ No newline at end of file
diff --git a/src/ARSpeechRecognition.js b/src/ARSpeechRecognition.js
index 100432a..9f5c735 100644
--- a/src/ARSpeechRecognition.js
+++ b/src/ARSpeechRecognition.js
@@ -20,11 +20,12 @@
function addEventHandlingToObject(object) {
object.listeners = { };
object.addEventListener = function(eventType, callback) {
- if (!callback) return this;
+ if (!callback) {
+ return this;
+ }
var listeners = this.listeners[eventType];
if (!listeners) {
- listeners = [];
- this.listeners[eventType] = listeners;
+ this.listeners[eventType] = listeners = [];
}
if (listeners.indexOf(callback) < 0) {
listeners.push(callback);
@@ -32,7 +33,9 @@
return this;
};
object.removeEventListener = function(eventType, callback) {
- if (!callback) return this;
+ if (!callback) {
+ return this;
+ }
var listeners = this.listeners[eventType];
if (listeners) {
var i = listeners.indexOf(callback);
@@ -43,8 +46,12 @@
return this;
};
object.callEventListeners = function(eventType, event) {
- if (!event) event = { target : this };
- if (!event.target) event.target = this;
+ if (!event) {
+ event = { target : this };
+ }
+ if (!event.target) {
+ event.target = this;
+ }
event.type = eventType;
var onEventType = 'on' + eventType;
if (typeof(this[onEventType]) === 'function') {
@@ -54,10 +61,10 @@
if (listeners) {
for (var i = 0; i < listeners.length; i++) {
var typeofListener = typeof(listeners[i]);
- if (typeofListener === "object") {
+ if (typeofListener === 'object') {
listeners[i].handleEvent(event);
}
- else if (typeofListener === "function") {
+ else if (typeofListener === 'function') {
listeners[i](event);
}
}