@neurodyn/core-ar 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @license React
3
+ * react-reconciler.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+
11
+ /**
12
+ * @license React
13
+ * react-reconciler.development.js
14
+ *
15
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
16
+ *
17
+ * This source code is licensed under the MIT license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ */
20
+
21
+ /**
22
+ * @license React
23
+ * react-reconciler-constants.production.js
24
+ *
25
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
26
+ *
27
+ * This source code is licensed under the MIT license found in the
28
+ * LICENSE file in the root directory of this source tree.
29
+ */
30
+
31
+ /**
32
+ * @license React
33
+ * scheduler.production.js
34
+ *
35
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
36
+ *
37
+ * This source code is licensed under the MIT license found in the
38
+ * LICENSE file in the root directory of this source tree.
39
+ */
40
+
41
+ /**
42
+ * @license React
43
+ * use-sync-external-store-shim/with-selector.production.js
44
+ *
45
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
46
+ *
47
+ * This source code is licensed under the MIT license found in the
48
+ * LICENSE file in the root directory of this source tree.
49
+ */
50
+
51
+ /**
52
+ * @license lucide-react v0.553.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */
57
+
58
+ /**
59
+ * @license lucide-react v0.561.0 - ISC
60
+ *
61
+ * This source code is licensed under the ISC license.
62
+ * See the LICENSE file in the root directory of this source tree.
63
+ */
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_neurodyn_core_ar=self.webpackChunk_neurodyn_core_ar||[]).push([["343"],{7026(e,t,i){i.d(t,{VU:()=>f,loadEighthWallEngine:()=>m});var n=i(2585),o=i(1519),r=i(557),s=i(5807);let a=Object.freeze({x:0,y:1,z:0});function l(e){let t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}function h(e,t){return e.x*t.x+e.y*t.y+e.z*t.z}function d(e,t){let i=2*(t.y*e.z-t.z*e.y),n=2*(t.z*e.x-t.x*e.z),o=2*(t.x*e.y-t.y*e.x);return{x:e.x+t.w*i+t.y*o-t.z*n,y:e.y+t.w*n+t.z*i-t.x*o,z:e.z+t.w*o+t.x*n-t.y*i}}function c(e){return l(d({x:0,y:0,z:-1},e))}function u(e){let t=Math.hypot(e.x,e.y,e.z,e.w)||1;return{w:e.w/t,x:e.x/t,y:e.y/t,z:e.z/t}}let p="https://8wall.vizbl.com/external/xr/xr.js",v=["FEATURE_POINT","ESTIMATED_SURFACE","DETECTED_SURFACE"],g=null;function y(){return"u"<typeof window?p:window.XR8_ENGINE_URL??p}function m(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:y(),t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e4;if("u"<typeof window)return Promise.reject(Error("The 8th Wall engine needs a browser."));let i=window;return i.XR8?Promise.resolve(i.XR8):g||(g=new Promise((n,o)=>{let r=e=>{g=null,o(Error(e))},s=setTimeout(()=>r("The 8th Wall engine timed out while loading."),t);window.addEventListener("xrloaded",()=>{clearTimeout(s),i.XR8?n(i.XR8):r("The 8th Wall engine loaded without registering itself.")},{once:!0});let a=document.createElement("script");a.src=e,a.async=!0,a.crossOrigin="anonymous",a.dataset.preloadChunks="slam",a.onerror=()=>{clearTimeout(s),r("The 8th Wall engine failed to load.")},document.head.appendChild(a)}))}class w{setMechanic(e){this.mechanic=e}get renderBridge(){return this.bridge}async attachRenderer(e){if(this.hostRenderer=e,"function"==typeof e.render){var t=this;this.hostRender=e.render.bind(e),e.render=function(){for(var e,i=arguments.length,n=Array(i),o=0;o<i;o++)n[o]=arguments[o];t.stopped&&(null==(e=t.hostRender)||e.call(t,...n))}}}engage(){if(this.engaged)return!0;let e=this.nativeSession.Threejs.xrScene();return!!(null==e?void 0:e.camera)&&!!e.scene&&(this.threeScene=e,e.camera.position.set(0,1.6,0),this.nativeSession.XrController.updateCameraProjectionMatrix({cam:{farClipPlane:100,nearClipPlane:.01},facing:e.camera.quaternion,origin:e.camera.position}),this.bridge={camera:e.camera,canvas:this.canvas,onFrame:e=>(this.frameListeners.add(e),()=>this.frameListeners.delete(e)),renderer:e.renderer,sceneRoot:e.scene},this.engaged=!0,!0)}handleUpdate(e){if(!this.engage()||!this.threeScene)return;let t=this.threeScene.camera;t.updateMatrixWorld(!0),this.tracking="LIMITED"!==e;let i=[];try{i=this.nativeSession.XrController.hitTest(.5,.5,v)??[]}catch{i=[]}let n=function(e){var t,i;let n=e.mechanic??"all",o=e.minWallHeight??.35,r=e.groundY,p=null;for(let t of e.hits)if(null==t?void 0:t.position){p=function(e){let t=e.rotation??{w:1,x:0,y:0,z:0},i=l(d(a,t));return{kind:(0,s.Q3)(i),nativeHit:e,normal:i,pose:{orientation:t,position:{...e.position}}}}(t);break}if(p){let s=p.pose.position.y-r;if("floor"===p.kind&&s<=o)r=Math.min(r,p.pose.position.y);else{let r,d;"wall"!==p.kind&&("all"===n||"wall"===n)&&s>o&&!(c(e.camera.orientation).y<-.2)&&(t=p,d=l(.001>Math.hypot((r={x:(i=e.camera.position).x-t.pose.position.x,y:0,z:i.z-t.pose.position.z}).x,r.z)?{x:0,y:0,z:1}:r),p={kind:"wall",nativeHit:t.nativeHit,normal:d,pose:{orientation:function(e,t){let i=h(e,t)+1;if(i<1e-6)return Math.abs(e.x)>Math.abs(e.z)?u({w:0,x:-e.y,y:e.x,z:0}):u({w:0,x:0,y:-e.z,z:e.y});let n={x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x};return u({w:i,x:n.x,y:n.y,z:n.z})}(a,d),position:{...t.pose.position}}})}return{groundY:r,hit:p}}if("ceiling"===n||"wall"===n)return{groundY:r,hit:null};let v=function(e,t,i,n){let o=h(t,n);if(1e-6>Math.abs(o))return null;let r=h({x:i.x-e.x,y:i.y-e.y,z:i.z-e.z},n)/o;return r<0?null:{x:e.x+t.x*r,y:e.y+t.y*r,z:e.z+t.z*r}}(e.camera.position,c(e.camera.orientation),{x:0,y:r,z:0},a);return v?{groundY:r,hit:{kind:"floor",normal:{...a},pose:{orientation:{w:1,x:0,y:0,z:0},position:v}}}:{groundY:r,hit:null}}({camera:{orientation:{w:t.quaternion.w,x:t.quaternion.x,y:t.quaternion.y,z:t.quaternion.z},position:{x:t.position.x,y:t.position.y,z:t.position.z}},groundY:this.groundY,hits:i,mechanic:this.mechanic});this.groundY=n.groundY,this.centerHit=n.hit;let o="u"<typeof performance?0:performance.now(),r=this.lastFrameTime?(o-this.lastFrameTime)/1e3:0;this.lastFrameTime=o,this.frameListeners.forEach(e=>{try{e({delta:r,time:o,tracking:this.tracking})}catch{}})}getCenterHit(e){return this.centerHit}isTracking(e){return this.engaged&&this.tracking}async createAnchor(e){return(0,s.em)(e.pose)}captureGlobalThree(e,t){this.hadGlobalThree=e,this.previousGlobalThree=t}async end(){if(this.stopped)return;this.stopped=!0,this.engaged=!1,this.bridge=null,this.threeScene=null,this.centerHit=null,this.frameListeners.clear();try{this.nativeSession.stop(),this.nativeSession.clearCameraPipelineModules()}catch{}window.removeEventListener("resize",this.onResize),window.removeEventListener("orientationchange",this.onResize),this.hostRenderer&&this.hostRender&&(this.hostRenderer.render=this.hostRender,this.hostRender=null),this.canvas.remove();let e=window;this.hadGlobalThree?e.THREE=this.previousGlobalThree:delete e.THREE}constructor(e,t,i,o){(0,n._)(this,"nativeSession",void 0),(0,n._)(this,"canvas",void 0),(0,n._)(this,"mechanic",void 0),(0,n._)(this,"onResize",void 0),(0,n._)(this,"centerHit",void 0),(0,n._)(this,"engaged",void 0),(0,n._)(this,"frameListeners",void 0),(0,n._)(this,"groundY",void 0),(0,n._)(this,"hadGlobalThree",void 0),(0,n._)(this,"hostRender",void 0),(0,n._)(this,"hostRenderer",void 0),(0,n._)(this,"lastFrameTime",void 0),(0,n._)(this,"previousGlobalThree",void 0),(0,n._)(this,"stopped",void 0),(0,n._)(this,"threeScene",void 0),(0,n._)(this,"tracking",void 0),(0,n._)(this,"bridge",void 0),(0,n._)(this,"guessesWalls",void 0),this.nativeSession=e,this.canvas=t,this.mechanic=i,this.onResize=o,this.centerHit=null,this.engaged=!1,this.frameListeners=new Set,this.groundY=0,this.hadGlobalThree=!1,this.hostRender=null,this.hostRenderer=null,this.lastFrameTime=0,this.stopped=!1,this.threeScene=null,this.tracking=!1,this.bridge=null,this.guessesWalls=!0}}class f{async isSupported(){var e,t;return!("u"<typeof window||"u"<typeof WebAssembly)&&!!window.isSecureContext&&"desktop"!==(0,r.U_)()&&!!(null==(t=navigator)||null==(e=t.mediaDevices)?void 0:e.getUserMedia)}async startSession(){var e,t,i,n;let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=window,a=this.options.loadEngine??m,l=await a(this.options.engineUrl??y());if(await (null==(e=l.loadChunk)?void 0:e.call(l,"slam").catch(()=>void 0)),!(null==(t=l.Threejs)?void 0:t.pipelineModule))throw Error("The 8th Wall build is missing its three.js module.");let h="THREE"in s,d=s.THREE;s.THREE=o;let c=r.overlayRoot instanceof HTMLElement?r.overlayRoot:null,u=document.createElement("canvas");u.dataset.testid="ar-camera-feed",u.style.cssText=c?"position:absolute;inset:0;width:100%;height:100%;z-index:0;background:#000;touch-action:none;display:block;":"position:fixed;inset:0;width:100vw;height:100vh;z-index:2147482000;background:#000;touch-action:none;display:block;",(c??document.body).appendChild(u);let p=()=>{u.width=(null==c?void 0:c.clientWidth)||window.innerWidth,u.height=(null==c?void 0:c.clientHeight)||window.innerHeight};p();let v=()=>window.setTimeout(p,60);window.addEventListener("resize",v),window.addEventListener("orientationchange",v);let g=new w(l,u,r.mechanic??"all",v);g.captureGlobalThree(h,d);try{l.XrController.configure({disableWorldTracking:!1,scale:"responsive"});let e=[l.GlTextureRenderer.pipelineModule(),l.Threejs.pipelineModule(),l.XrController.pipelineModule()];(null==(i=l.CanvasScreenshot)?void 0:i.pipelineModule)&&e.push(l.CanvasScreenshot.pipelineModule()),e.push({name:"vizbl-react-ar",onAttach:()=>void g.engage(),onStart:()=>void g.engage(),onUpdate:e=>{let{processCpuResult:t}=e;(null==t?void 0:t.reality)&&g.handleUpdate(t.reality.trackingStatus)}}),l.clearCameraPipelineModules(),l.addCameraPipelineModules(e),l.run({allowedDevices:null==(n=l.XrConfig)?void 0:n.device().ANY,canvas:u})}catch(e){throw await g.end(),e}return g}constructor(e={}){(0,n._)(this,"options",void 0),this.options=e}}},5807(e,t,i){function n(e){let t={orientation:{...e.orientation},position:{...e.position}};return{delete:()=>void 0,getPose:()=>t,pose:t}}function o(e,t){var i;return(null==(i=e.isDetached)?void 0:i.call(e))?(e.delete(),n(t??e.pose)):null}function r(e){return(null==e?void 0:e.kind)==="wall"&&.25>=Math.abs(e.normal.y)}function s(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.75;return e.y>=t?"floor":e.y<=-t?"ceiling":"wall"}i.d(t,{Q3:()=>s,aq:()=>r,em:()=>n,gD:()=>o})}}]);