From 77476652d21f88312bae40d0b67a10022ac54298 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Mon, 29 Mar 2021 14:40:34 -0400 Subject: [PATCH] new serve module and demo structure --- CHANGELOG.md | 1 + demo/{faces.json => facematch-faces.json} | 0 demo/facematch.js | 2 +- demo/favicon.ico | Bin 0 -> 5063 bytes demo/{ => helpers}/gl-bench.js | 0 demo/{ => helpers}/menu.js | 82 ++++++++++-------- demo/{worker.js => index-worker.js} | 0 demo/index.html | 4 +- demo/{browser.js => index.js} | 10 +-- .../manifest.webmanifest | 0 package.json | 6 +- src/config.ts | 4 +- tsconfig.json | 2 +- wiki | 2 +- 14 files changed, 62 insertions(+), 51 deletions(-) rename demo/{faces.json => facematch-faces.json} (100%) create mode 100644 demo/favicon.ico rename demo/{ => helpers}/gl-bench.js (100%) rename demo/{ => helpers}/menu.js (83%) rename demo/{worker.js => index-worker.js} (100%) rename demo/{browser.js => index.js} (99%) rename manifest.webmanifest => demo/manifest.webmanifest (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed100625..1e17eced 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Repository: **** ### **HEAD -> main** 2021/03/28 mandic00@live.com +- minor rotation calculation fix - remove debug output - new face rotation calculations - cleanup diff --git a/demo/faces.json b/demo/facematch-faces.json similarity index 100% rename from demo/faces.json rename to demo/facematch-faces.json diff --git a/demo/facematch.js b/demo/facematch.js index 875b6024..68f7a8e4 100644 --- a/demo/facematch.js +++ b/demo/facematch.js @@ -43,7 +43,7 @@ function log(...msg) { async function getFaceDB() { // download db with known faces try { - const res = await fetch('/demo/faces.json'); + const res = await fetch('/demo/facematch-faces.json'); db = (res && res.ok) ? await res.json() : []; for (const rec of db) { rec.embedding = rec.embedding.map((a) => parseFloat(a.toFixed(4))); diff --git a/demo/favicon.ico b/demo/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..1cbc04490dd7488fa515a98e243c113ac220d2f6 GIT binary patch liter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*?Q9+4xj+A!#RobP(O2bvuV@AXL#xR;S)88SI8| zlcO_(^QWK3%#JoOX-nIZJqv#99qE^FoTasshtRy2yS9^3po=j3teqt{=yPH1rO{_{H0@fRwA0>woTDgG@tMkI`MSguVmF+--nG>U%!wSYOvTvDX$cCOBI`k zNJ96yGkMO~GjYc<1oAi>Ew*+x;!9^D4LWIcVIC#B@19lF=L-JJ*^jvbRbeZm>@d9Z z4CoP>eF}k6S|DG{#Pk5y5iQkQ5fdEtAHbSZbfBZbnFn*46-D}aLOKGO;7oZGqBzsG ziFQ$vBs2=>6Do!ied4%dO%RuLA0|!eXwb9Y`3={^6LXPf@2yANFn{Z20D;gxh_~%` z4PPU%C#&){$4A4nm8RieR!@ae(;+%kyQ%ZZZD? D<0%g1 literal 0 HcmV?d00001 diff --git a/demo/gl-bench.js b/demo/helpers/gl-bench.js similarity index 100% rename from demo/gl-bench.js rename to demo/helpers/gl-bench.js diff --git a/demo/menu.js b/demo/helpers/menu.js similarity index 83% rename from demo/menu.js rename to demo/helpers/menu.js index bb68ee7d..999a1053 100644 --- a/demo/menu.js +++ b/demo/helpers/menu.js @@ -1,3 +1,5 @@ +// @ts-nocheck + let instance = 0; let CSScreated = false; @@ -80,7 +82,7 @@ class Menu { this.instance = instance; instance++; this._maxFPS = 0; - this.hidden = 0; + this.hidden = false; } createMenu(parent, title = '', position = { top: null, left: null, bottom: null, right: null }) { @@ -109,9 +111,11 @@ class Menu { if (title) elTitle.innerHTML = `${title}${svg}`; this.menu.appendChild(elTitle); elTitle.addEventListener('click', () => { - this.container.classList.toggle('menu-container-fadeout'); - this.container.classList.toggle('menu-container-fadein'); - this.menu.style.borderStyle = this.container.classList.contains('menu-container-fadeout') ? 'none' : 'solid'; + if (this.container && this.menu) { + this.container.classList.toggle('menu-container-fadeout'); + this.container.classList.toggle('menu-container-fadein'); + this.menu.style.borderStyle = this.container.classList.contains('menu-container-fadeout') ? 'none' : 'solid'; + } }); this.menu.appendChild(this.container); @@ -129,40 +133,42 @@ class Menu { } get width() { - return this.menu.offsetWidth; + return this.menu?.offsetWidth || 0; } get height() { - return this.menu.offsetHeight; + return this.menu?.offsetHeight || 0; } hide() { - if (this.container.classList.contains('menu-container-fadein')) { + if (this.container && this.container.classList.contains('menu-container-fadein')) { this.container.classList.toggle('menu-container-fadeout'); this.container.classList.toggle('menu-container-fadein'); } } visible() { - return (this.container.classList.contains('menu-container-fadein')); + return (this.container ? this.container.classList.contains('menu-container-fadein') : false); } toggle(evt) { - this.container.classList.toggle('menu-container-fadeout'); - this.container.classList.toggle('menu-container-fadein'); - if (this.container.classList.contains('menu-container-fadein') && evt) { - const x = evt.x || (evt.touches && evt.touches[0] ? evt.touches[0].pageX : null); - // const y = evt.y || (evt.touches && evt.touches[0] ? evt.touches[0].pageY : null); - if (x) this.menu.style.left = `${x - (this.menu.offsetWidth / 2)}px`; - // if (y) this.menu.style.top = '5.5rem'; // `${evt.y + 55}px`; - if (this.menu.offsetLeft < 0) this.menu.style.left = 0; - if ((this.menu.offsetLeft + this.menu.offsetWidth) > window.innerWidth) { - this.menu.style.left = null; - this.menu.style.right = 0; + if (this.container && this.menu) { + this.container.classList.toggle('menu-container-fadeout'); + this.container.classList.toggle('menu-container-fadein'); + if (this.container.classList.contains('menu-container-fadein') && evt) { + const x = evt.x || (evt.touches && evt.touches[0] ? evt.touches[0].pageX : null); + // const y = evt.y || (evt.touches && evt.touches[0] ? evt.touches[0].pageY : null); + if (x) this.menu.style.left = `${x - (this.menu.offsetWidth / 2)}px`; + // if (y) this.menu.style.top = '5.5rem'; // `${evt.y + 55}px`; + if (this.menu.offsetLeft < 0) this.menu.style.left = '0'; + if ((this.menu.offsetLeft + this.menu.offsetWidth) > window.innerWidth) { + this.menu.style.left = ''; + this.menu.style.right = '0'; + } + this.menu.style.borderStyle = 'solid'; + } else { + this.menu.style.borderStyle = 'none'; } - this.menu.style.borderStyle = 'solid'; - } else { - this.menu.style.borderStyle = 'none'; } } @@ -171,7 +177,7 @@ class Menu { el.className = 'menu-title'; el.id = this.newID; el.innerHTML = title; - this.menu.appendChild(el); + if (this.menu) this.menu.appendChild(el); el.addEventListener('click', () => { this.hidden = !this.hidden; const all = document.getElementsByClassName('menu'); @@ -187,7 +193,7 @@ class Menu { el.className = 'menu-item menu-label'; el.id = this.newID; el.innerHTML = title; - this.container.appendChild(el); + if (this.container) this.container.appendChild(el); return el; } @@ -195,10 +201,10 @@ class Menu { const el = document.createElement('div'); el.className = 'menu-item'; el.innerHTML = `${title}`; - this.container.appendChild(el); + if (this.container) this.container.appendChild(el); el.addEventListener('change', (evt) => { - object[variable] = evt.target.checked; - if (callback) callback(evt.target.checked); + object[variable] = evt.target?.checked; + if (callback) callback(evt.target?.checked); }); return el; } @@ -215,9 +221,9 @@ class Menu { el.style.fontFamily = document.body.style.fontFamily; el.style.fontSize = document.body.style.fontSize; el.style.fontVariant = document.body.style.fontVariant; - this.container.appendChild(el); + if (this.container) this.container.appendChild(el); el.addEventListener('change', (evt) => { - if (callback) callback(items[evt.target.selectedIndex]); + if (callback) callback(items[evt.target?.selectedIndex]); }); return el; } @@ -226,11 +232,13 @@ class Menu { const el = document.createElement('div'); el.className = 'menu-item'; el.innerHTML = `${title}`; - this.container.appendChild(el); + if (this.container) this.container.appendChild(el); el.addEventListener('change', (evt) => { - object[variable] = parseInt(evt.target.value) === parseFloat(evt.target.value) ? parseInt(evt.target.value) : parseFloat(evt.target.value); - evt.target.setAttribute('value', evt.target.value); - if (callback) callback(evt.target.value); + if (evt.target) { + object[variable] = parseInt(evt.target?.value) === parseFloat(evt.target?.value) ? parseInt(evt.target?.value) : parseFloat(evt.target?.value); + evt.target.setAttribute('value', evt.target.value); + if (callback) callback(evt.target?.value); + } }); el.input = el.children[0]; return el; @@ -241,7 +249,7 @@ class Menu { el.className = 'menu-item'; el.id = this.newID; if (html) el.innerHTML = html; - this.container.appendChild(el); + if (this.container) this.container.appendChild(el); return el; } @@ -254,7 +262,7 @@ class Menu { el.type = 'button'; el.id = this.newID; el.innerText = titleOn; - this.container.appendChild(el); + if (this.container) this.container.appendChild(el); el.addEventListener('click', () => { if (el.innerText === titleOn) el.innerText = titleOff; else el.innerText = titleOn; @@ -268,7 +276,7 @@ class Menu { el.className = 'menu-item'; el.id = `menu-val-${title}`; el.innerText = `${title}: ${val}${suffix}`; - this.container.appendChild(el); + if (this.container) this.container.appendChild(el); return el; } @@ -285,7 +293,7 @@ class Menu { el.className = 'menu-item menu-chart-title'; el.id = this.newID; el.innerHTML = `${title}`; - this.container.appendChild(el); + if (this.container) this.container.appendChild(el); return el; } diff --git a/demo/worker.js b/demo/index-worker.js similarity index 100% rename from demo/worker.js rename to demo/index-worker.js diff --git a/demo/index.html b/demo/index.html index 507d334c..6f4821c4 100644 --- a/demo/index.html +++ b/demo/index.html @@ -14,9 +14,9 @@ - + - +