Ver código fonte

Tweaks

customisations
alemart 6 meses atrás
pai
commit
0be041ebc5
2 arquivos alterados com 8 adições e 5 exclusões
  1. 3
    3
      src/core/session.ts
  2. 5
    2
      src/geometry/pnp.ts

+ 3
- 3
src/core/session.ts Ver arquivo

@@ -282,16 +282,16 @@ export class Session extends AREventTarget<SessionEventType>
282 282
             if(!Session.isSupported())
283 283
                 throw new NotSupportedError('You need a browser/device compatible with WebGL2 and WebAssembly in order to experience Augmented Reality with encantar.js');
284 284
 
285
-            // block multiple immersive sessions
285
+            // block multiple sessions when requesting the immersive mode
286 286
             if(mode !== 'inline' && Session.count > 0)
287
-                throw new IllegalOperationError(`Can't start more than one immersive session`);
287
+                throw new IllegalOperationError(`Can't start multiple sessions, except in inline mode`);
288 288
 
289 289
             // dev build? work-in-progress
290 290
             const isStableBuild = /^\d+\.\d+(\.\d+)*$/.test(AR.version);
291 291
             if(!isStableBuild) {
292 292
                 if(!(['localhost', '127.0.0.1', '[::1]', '', 'encantar.dev', 'alemart.github.io'].includes(location.hostname))) {
293 293
                     if(!(location.hostname.startsWith('192.168.') || location.hostname.startsWith('10.') || /^172\.(1[6-9]|2[0-9]|3[01])\./.test(location.hostname))) {
294
-                        const message = 'This is a development build (unstable). Do not use it in production.';
294
+                        const message = 'This is a development build (unstable). Do not use it in production. Get a stable release at encantar.dev';
295 295
                         Utils.warning(message);
296 296
                         if(!confirm(message + '\n\nAre you sure you want to continue?'))
297 297
                             throw new AccessDeniedError('Aborted');

+ 5
- 2
src/geometry/pnp.ts Ver arquivo

@@ -445,6 +445,9 @@ const DEFAULT_TARGET_WIDTH_IN_METERS = 20 * 0.01; // 20 cm
445 445
 /** Whether or not to use a normal vector to find the relative distances between the points */
446 446
 const USE_NORMAL_VECTOR = false;
447 447
 
448
+/** Small number */
449
+const EPSILON = 1e-8;
450
+
448 451
 /** Debug flag */
449 452
 const DEBUG = false;
450 453
 
@@ -1407,7 +1410,7 @@ function findRatios(u: TinyMatrix[], v: TinyMatrix[], n: number, o: number, i: n
1407 1410
 
1408 1411
     // find (ai, aj) such that wk = ai wi + aj wj
1409 1412
     const det2 = wi[0] * wj[1] - wi[1] * wj[0];
1410
-    if(Math.abs(det2) < 1e-6) // wi and wj are colinear
1413
+    if(Math.abs(det2) < EPSILON) // wi and wj are colinear
1411 1414
         return vec3(Number.NaN);
1412 1415
 
1413 1416
     const ai = (wj[1] * wk[0] - wj[0] * wk[1]) / det2;
@@ -1618,7 +1621,7 @@ function inverse(B: TinyMatrix, A: TinyMatrix): TinyMatrix
1618 1621
 
1619 1622
     // determinant of A
1620 1623
     const det = A[0] * m0 - A[1] * m1 + A[2] * m2;
1621
-    if(Math.abs(det) < 1e-8)
1624
+    if(Math.abs(det) < EPSILON)
1622 1625
         return B.fill(Number.NaN);
1623 1626
 
1624 1627
     // invert via cofactor expansion

Carregando…
Cancelar
Salvar