diff --git a/dist/ARnft.js b/dist/ARnft.js index e768d05e..859e169c 100644 --- a/dist/ARnft.js +++ b/dist/ARnft.js @@ -419,7 +419,7 @@ eval("\n\n/* eslint-env browser */\n\n/* eslint-disable no-undef, no-use-before- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => /* binding */ ARnft\n/* harmony export */ });\n/* harmony import */ var _utils_Utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils/Utils */ \"./src/utils/Utils.js\");\n/* harmony import */ var _utils_html_Container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils/html/Container */ \"./src/utils/html/Container.js\");\n/* harmony import */ var stats_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! stats.js */ \"./node_modules/stats.js/build/stats.min.js\");\n/* harmony import */ var stats_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(stats_js__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uuid */ \"./node_modules/uuid/dist/esm-browser/v4.js\");\n/* harmony import */ var _renderers_CameraViewRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./renderers/CameraViewRenderer */ \"./src/renderers/CameraViewRenderer.js\");\n\n\n\n\n\n\nclass ARnft {\n constructor (width, height, config) {\n this.width = width\n this.height = height\n this.renderer = null\n this.config = config\n this.listeners = {}\n this.uuid = (0,uuid__WEBPACK_IMPORTED_MODULE_4__.default)()\n this.version = '0.8.7'\n console.log('ARnft ', this.version)\n }\n\n _initialize (markerUrl, stats, camera) {\n console.log('ARnft init() %cstart...', 'color: yellow; background-color: blue; border-radius: 4px; padding: 2px')\n const root = this.root\n const config = this.config\n let data\n if (typeof(config) == 'object') {\n data = _utils_Utils__WEBPACK_IMPORTED_MODULE_0__.default.jsonObjParser(config)\n } else {\n data = _utils_Utils__WEBPACK_IMPORTED_MODULE_0__.default.jsonParser(config)\n }\n\n data.then((configData) => {\n _utils_html_Container__WEBPACK_IMPORTED_MODULE_1__.default.createLoading(configData)\n _utils_html_Container__WEBPACK_IMPORTED_MODULE_1__.default.createStats(stats, configData)\n const containerObj = _utils_html_Container__WEBPACK_IMPORTED_MODULE_1__.default.createContainer(configData)\n const container = containerObj.container\n const canvas = containerObj.canvas\n\n let statsMain, statsWorker\n\n if (stats) {\n statsMain = new (stats_js__WEBPACK_IMPORTED_MODULE_2___default())()\n statsMain.showPanel(0) // 0: fps, 1: ms, 2: mb, 3+: custom\n document.getElementById('stats1').appendChild(statsMain.dom)\n\n statsWorker = new (stats_js__WEBPACK_IMPORTED_MODULE_2___default())()\n statsWorker.showPanel(0) // 0: fps, 1: ms, 2: mb, 3+: custom\n document.getElementById('stats2').appendChild(statsWorker.dom)\n }\n\n const statsObj = {\n statsMain: statsMain,\n statsWorker: statsWorker,\n stats: stats\n }\n\n _renderers_CameraViewRenderer__WEBPACK_IMPORTED_MODULE_3__.default.getUserMedia(configData).then((video) => {\n _utils_Utils__WEBPACK_IMPORTED_MODULE_0__.default._startWorker(\n container,\n markerUrl,\n video,\n video.videoWidth,\n video.videoHeight,\n canvas,\n () => {\n if (statsObj.stats) {\n statsObj.statsMain.update()\n }\n },\n () => {\n if (statsObj.stats) {\n statsObj.statsWorker.update()\n }\n },\n configData,\n this.uuid)\n })\n })\n return this\n }\n\n static async init (width, height, markerUrl, config, stats, camera) {\n const nft = new ARnft(width, height, config)\n return await nft._initialize(markerUrl, stats, camera)\n }\n\n dispatchEvent (event) {\n const listeners = this.listeners[event.name]\n if (listeners) {\n for (let i = 0; i < listeners.length; i++) {\n listeners[i].call(this, event)\n }\n }\n }\n\n addEventListener (name, callback) {\n if (!this.listeners[name]) {\n this.listeners[name] = []\n }\n this.listeners[name].push(callback)\n };\n\n removeEventListener (name, callback) {\n if (this.listeners[name]) {\n const index = this.listeners[name].indexOf(callback)\n if (index > -1) {\n this.listeners[name].splice(index, 1)\n }\n }\n };\n\n _teardownVideo (video) {\n video.srcObject.getVideoTracks()[0].stop()\n video.srcObject = null\n video.src = null\n };\n}\n\n\n//# sourceURL=webpack://ARnft/./src/ARnft.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => /* binding */ ARnft\n/* harmony export */ });\n/* harmony import */ var _utils_Utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils/Utils */ \"./src/utils/Utils.js\");\n/* harmony import */ var _utils_html_Container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils/html/Container */ \"./src/utils/html/Container.js\");\n/* harmony import */ var stats_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! stats.js */ \"./node_modules/stats.js/build/stats.min.js\");\n/* harmony import */ var stats_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(stats_js__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! uuid */ \"./node_modules/uuid/dist/esm-browser/v4.js\");\n/* harmony import */ var _renderers_CameraViewRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./renderers/CameraViewRenderer */ \"./src/renderers/CameraViewRenderer.js\");\n\n\n\n\n\n\nclass ARnft {\n constructor (width, height, config) {\n this.width = width\n this.height = height\n this.config = config\n this.listeners = {}\n this.uuid = (0,uuid__WEBPACK_IMPORTED_MODULE_4__.default)()\n this.version = '0.8.7'\n console.log('ARnft ', this.version)\n }\n\n _initialize (markerUrl, stats, camera) {\n console.log('ARnft init() %cstart...', 'color: yellow; background-color: blue; border-radius: 4px; padding: 2px')\n const root = this.root\n const config = this.config\n let data\n if (typeof(config) == 'object') {\n data = _utils_Utils__WEBPACK_IMPORTED_MODULE_0__.default.jsonObjParser(config)\n } else {\n data = _utils_Utils__WEBPACK_IMPORTED_MODULE_0__.default.jsonParser(config)\n }\n\n data.then((configData) => {\n _utils_html_Container__WEBPACK_IMPORTED_MODULE_1__.default.createLoading(configData)\n _utils_html_Container__WEBPACK_IMPORTED_MODULE_1__.default.createStats(stats, configData)\n const containerObj = _utils_html_Container__WEBPACK_IMPORTED_MODULE_1__.default.createContainer(configData)\n const container = containerObj.container\n const canvas = containerObj.canvas\n\n let statsMain, statsWorker\n\n if (stats) {\n statsMain = new (stats_js__WEBPACK_IMPORTED_MODULE_2___default())()\n statsMain.showPanel(0) // 0: fps, 1: ms, 2: mb, 3+: custom\n document.getElementById('stats1').appendChild(statsMain.dom)\n\n statsWorker = new (stats_js__WEBPACK_IMPORTED_MODULE_2___default())()\n statsWorker.showPanel(0) // 0: fps, 1: ms, 2: mb, 3+: custom\n document.getElementById('stats2').appendChild(statsWorker.dom)\n }\n\n const statsObj = {\n statsMain: statsMain,\n statsWorker: statsWorker,\n stats: stats\n }\n\n _renderers_CameraViewRenderer__WEBPACK_IMPORTED_MODULE_3__.default.getUserMedia(configData).then((video) => {\n _utils_Utils__WEBPACK_IMPORTED_MODULE_0__.default._startWorker(\n container,\n markerUrl,\n video,\n video.videoWidth,\n video.videoHeight,\n canvas,\n () => {\n if (statsObj.stats) {\n statsObj.statsMain.update()\n }\n },\n () => {\n if (statsObj.stats) {\n statsObj.statsWorker.update()\n }\n },\n configData,\n this.uuid)\n })\n })\n return this\n }\n\n static async init (width, height, markerUrl, config, stats, camera) {\n const nft = new ARnft(width, height, config)\n return await nft._initialize(markerUrl, stats, camera)\n }\n\n dispatchEvent (event) {\n const listeners = this.listeners[event.name]\n if (listeners) {\n for (let i = 0; i < listeners.length; i++) {\n listeners[i].call(this, event)\n }\n }\n }\n\n addEventListener (name, callback) {\n if (!this.listeners[name]) {\n this.listeners[name] = []\n }\n this.listeners[name].push(callback)\n };\n\n removeEventListener (name, callback) {\n if (this.listeners[name]) {\n const index = this.listeners[name].indexOf(callback)\n if (index > -1) {\n this.listeners[name].splice(index, 1)\n }\n }\n };\n\n _teardownVideo (video) {\n video.srcObject.getVideoTracks()[0].stop()\n video.srcObject = null\n video.src = null\n };\n}\n\n\n//# sourceURL=webpack://ARnft/./src/ARnft.js?"); /***/ }), diff --git a/src/ARnft.js b/src/ARnft.js index 2011959d..32daa5e1 100644 --- a/src/ARnft.js +++ b/src/ARnft.js @@ -8,7 +8,6 @@ export default class ARnft { constructor (width, height, config) { this.width = width this.height = height - this.renderer = null this.config = config this.listeners = {} this.uuid = uuidv4()