Showing
6 changed files
with
55 additions
and
2 deletions
components/qrcodedetector.js
0 → 100644
1 | +import ARCS from '../build/arcs.js'; | ||
2 | + | ||
3 | +let QRCodeDetector; | ||
4 | + | ||
5 | +QRCodeDetector = ARCS.Componenent.create( | ||
6 | + function() { | ||
7 | + let busy = false; | ||
8 | + let dataCache = null; | ||
9 | + const worker = new Worker("../deps/jsqr/worker.js"); | ||
10 | + worker.addEventListener("message", ({data} => { | ||
11 | + busy = false; | ||
12 | + dataCache = data; | ||
13 | + }); | ||
14 | + | ||
15 | + this.detect(imageData) { | ||
16 | + if (!busy) { | ||
17 | + busy = true; | ||
18 | + worker.postMessage(imageData); | ||
19 | + } | ||
20 | + if (dataCache !== null) { | ||
21 | + this.emit('onQRCode', dataCache); | ||
22 | + } | ||
23 | + }; | ||
24 | + }, | ||
25 | + ['detect'], | ||
26 | + ['onQRCode'] | ||
27 | +); | ||
28 | + | ||
29 | + | ||
30 | + | ||
31 | +export default {QRCodeDetector: QRCodeDetector}; |
deps/jsqr/worker.js
0 → 100644
... | @@ -35,7 +35,9 @@ | ... | @@ -35,7 +35,9 @@ |
35 | "js-aruco": ">=0.1", | 35 | "js-aruco": ">=0.1", |
36 | "three": ">=0.131", | 36 | "three": ">=0.131", |
37 | "tracking": ">=1.1.3", | 37 | "tracking": ">=1.1.3", |
38 | - "webpack": "^5.51.1" | 38 | + "webpack": "^5.51.1", |
39 | + "jsqr": "^1.4.0", | ||
40 | + "html2canvas": "^1.3.3" | ||
39 | }, | 41 | }, |
40 | "devDependencies": { | 42 | "devDependencies": { |
41 | "copy-webpack-plugin": "^9.0.1", | 43 | "copy-webpack-plugin": "^9.0.1", | ... | ... |
... | @@ -3,7 +3,7 @@ const path=require('path'); | ... | @@ -3,7 +3,7 @@ const path=require('path'); |
3 | 3 | ||
4 | module.exports = { | 4 | module.exports = { |
5 | entry : './arcsapp.json', | 5 | entry : './arcsapp.json', |
6 | - mode: "none", | 6 | + mode: "production", |
7 | 7 | ||
8 | output: { | 8 | output: { |
9 | path: path.resolve(__dirname, ''), | 9 | path: path.resolve(__dirname, ''), | ... | ... |
... | @@ -89,6 +89,8 @@ module.exports = [ | ... | @@ -89,6 +89,8 @@ module.exports = [ |
89 | plugins: [ | 89 | plugins: [ |
90 | new copy({ | 90 | new copy({ |
91 | patterns: [ | 91 | patterns: [ |
92 | + { from: 'node_modules/html2canvas/dist/html2canvas.min.js', to: '../deps/html2canvas/html2canvas.min.js'}, | ||
93 | + { from: 'node_modules/jsqr/dist/jsQR.js', to: '../deps/jsqr/jsQR.js'}, | ||
92 | { from: 'node_modules/tracking/build/tracking.js', to: '../deps/tracking/tracking.js'}, | 94 | { from: 'node_modules/tracking/build/tracking.js', to: '../deps/tracking/tracking.js'}, |
93 | { from: 'node_modules/three/build/three.module.js', to: '../deps/three.js/index.js'}, | 95 | { from: 'node_modules/three/build/three.module.js', to: '../deps/three.js/index.js'}, |
94 | { | 96 | { |
... | @@ -122,6 +124,16 @@ module.exports = [ | ... | @@ -122,6 +124,16 @@ module.exports = [ |
122 | } | 124 | } |
123 | }, | 125 | }, |
124 | { | 126 | { |
127 | + from: 'node_modules/three/examples/jsm/webxr/ARButton.js', | ||
128 | + to: '../deps/three.js/ARButton.js', | ||
129 | + transform: function(content, path) { | ||
130 | + return Buffer.from(content.toString().replace( | ||
131 | + '../../../build/three.module.js', | ||
132 | + './index.js' | ||
133 | + )); | ||
134 | + } | ||
135 | + }, | ||
136 | + { | ||
125 | from: 'node_modules/js-aruco/src/aruco.js', | 137 | from: 'node_modules/js-aruco/src/aruco.js', |
126 | to: '../deps/aruco/index.js', | 138 | to: '../deps/aruco/index.js', |
127 | transform: function(content, path) { | 139 | transform: function(content, path) { | ... | ... |
-
Please register or login to post a comment