浏览代码

Tweaks

customisations
alemart 6 个月前
父节点
当前提交
0be041ebc5
共有 2 个文件被更改,包括 8 次插入5 次删除
  1. 3
    3
      src/core/session.ts
  2. 5
    2
      src/geometry/pnp.ts

+ 3
- 3
src/core/session.ts 查看文件

282
             if(!Session.isSupported())
282
             if(!Session.isSupported())
283
                 throw new NotSupportedError('You need a browser/device compatible with WebGL2 and WebAssembly in order to experience Augmented Reality with encantar.js');
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
             if(mode !== 'inline' && Session.count > 0)
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
             // dev build? work-in-progress
289
             // dev build? work-in-progress
290
             const isStableBuild = /^\d+\.\d+(\.\d+)*$/.test(AR.version);
290
             const isStableBuild = /^\d+\.\d+(\.\d+)*$/.test(AR.version);
291
             if(!isStableBuild) {
291
             if(!isStableBuild) {
292
                 if(!(['localhost', '127.0.0.1', '[::1]', '', 'encantar.dev', 'alemart.github.io'].includes(location.hostname))) {
292
                 if(!(['localhost', '127.0.0.1', '[::1]', '', 'encantar.dev', 'alemart.github.io'].includes(location.hostname))) {
293
                     if(!(location.hostname.startsWith('192.168.') || location.hostname.startsWith('10.') || /^172\.(1[6-9]|2[0-9]|3[01])\./.test(location.hostname))) {
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
                         Utils.warning(message);
295
                         Utils.warning(message);
296
                         if(!confirm(message + '\n\nAre you sure you want to continue?'))
296
                         if(!confirm(message + '\n\nAre you sure you want to continue?'))
297
                             throw new AccessDeniedError('Aborted');
297
                             throw new AccessDeniedError('Aborted');

+ 5
- 2
src/geometry/pnp.ts 查看文件

445
 /** Whether or not to use a normal vector to find the relative distances between the points */
445
 /** Whether or not to use a normal vector to find the relative distances between the points */
446
 const USE_NORMAL_VECTOR = false;
446
 const USE_NORMAL_VECTOR = false;
447
 
447
 
448
+/** Small number */
449
+const EPSILON = 1e-8;
450
+
448
 /** Debug flag */
451
 /** Debug flag */
449
 const DEBUG = false;
452
 const DEBUG = false;
450
 
453
 
1407
 
1410
 
1408
     // find (ai, aj) such that wk = ai wi + aj wj
1411
     // find (ai, aj) such that wk = ai wi + aj wj
1409
     const det2 = wi[0] * wj[1] - wi[1] * wj[0];
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
         return vec3(Number.NaN);
1414
         return vec3(Number.NaN);
1412
 
1415
 
1413
     const ai = (wj[1] * wk[0] - wj[0] * wk[1]) / det2;
1416
     const ai = (wj[1] * wk[0] - wj[0] * wk[1]) / det2;
1618
 
1621
 
1619
     // determinant of A
1622
     // determinant of A
1620
     const det = A[0] * m0 - A[1] * m1 + A[2] * m2;
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
         return B.fill(Number.NaN);
1625
         return B.fill(Number.NaN);
1623
 
1626
 
1624
     // invert via cofactor expansion
1627
     // invert via cofactor expansion

正在加载...
取消
保存