@needle-tools/engine
Version:
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in
134 lines (125 loc) • 1.22 MB
JavaScript
var gS=Object.defineProperty,fS=(n,t,i)=>t in n?gS(n,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[t]=i,a=(n,t,i)=>(fS(n,typeof t!="symbol"?t+"":t,i),i),om=(n,t,i)=>{if(!t.has(n))throw TypeError("Cannot "+i)},fe=(n,t,i)=>(om(n,t,"read from private field"),i?i.call(n):t.get(n)),pn=(n,t,i)=>{if(t.has(n))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(n):t.set(n,i)},Dn=(n,t,i,s)=>(om(n,t,"write to private field"),s?s.call(n,i):t.set(n,i),i),od=(n,t,i)=>(om(n,t,"access private method"),i);import{Vector2 as re,Vector3 as x,Vector4 as ye,Quaternion as V,PlaneGeometry as Bn,PerspectiveCamera as xe,Scene as wi,ShaderMaterial as mn,Uniform$1 as so,Mesh as X,WebGLRenderer as rr,Texture as De,Euler as Bt,Box3 as xi,MeshStandardMaterial as Ft,Color as ce,ShadowMaterial as Vy,Box3Helper as Hy,GridHelper as rm,Material as ke,Matrix3 as $y,Matrix4 as se,Layers as oo,Object3D as j,Ray as ro,MathUtils as ms,AxesHelper as Si,MeshBasicMaterial as Re,DoubleSide as Ci,BufferGeometry as gs,Group as ao,SphereGeometry as rd,BoxGeometry as ma,SpriteMaterial as yS,Sprite as vS,Shape as bS,ExtrudeGeometry as _S,Fog as Gy,DirectionalLight as am,PointLight as lm,Line as ql,BufferAttribute as yt,CylinderGeometry as wS,EdgesGeometry as xS,LineSegments as qy,LineBasicMaterial as Xy,Sphere as ad,Plane as ar,Raycaster as ld,ArrayCamera as SS,SkinnedMesh as fs,InterleavedBufferAttribute as Qy,Skeleton as CS,Bone as OS,Source as PS,WebGLCubeRenderTarget as kS,CubeCamera as MS,AnimationClip as lo,TextureLoader as ga,PropertyBinding as fa,LinearSRGBColorSpace as ys,ShaderChunk as qt,UniformsLib as RS,FileLoader as Yy,DataTexture as cm,RGBAFormat as cd,EquirectangularReflectionMapping as vs,SRGBColorSpace as bs,Clock as TS,NoToneMapping as ya,PCFSoftShadowMap$1 as ES,BasicNodeLibrary as AS,WebGLRenderTarget as _s,DepthTexture as IS,NearestFilter as hd,LoopRepeat as jS,LoopOnce as hm,AnimationMixer as dm,CompressedTexture as LS,FrontSide as co,Frustum as Zy,OrthographicCamera as um,AudioListener as DS,PositionalAudio as BS,AudioLoader as pm,EventDispatcher as mm,BackSide as dd,MeshDepthMaterial as FS,CustomBlending as zS,MaxEquation as US,AmbientLight as NS,HemisphereLight as WS,InvertStencilOp as VS,DecrementWrapStencilOp as HS,IncrementWrapStencilOp as $S,DecrementStencilOp as GS,IncrementStencilOp as qS,ReplaceStencilOp as XS,ZeroStencilOp as QS,KeepStencilOp as YS,AlwaysStencilFunc as ZS,GreaterEqualStencilFunc as KS,NotEqualStencilFunc as JS,GreaterStencilFunc as eC,LessEqualStencilFunc as tC,EqualStencilFunc as iC,LessStencilFunc as nC,NeverStencilFunc as Ky,RawShaderMaterial as Jy,GLSL3 as sC,AlwaysDepth as oC,GreaterEqualDepth as rC,GreaterDepth as aC,LessEqualDepth as lC,LessDepth as cC,NotEqualDepth as hC,EqualDepth as dC,BatchedMesh as ev,MeshPhysicalMaterial as gm,UnsignedByteType as uC,LinearFilter as tv,RingGeometry as pC,Line3 as mC,AdditiveBlending as iv,BoxHelper as gC,SpotLight as fC,DirectionalLightHelper as yC,CameraHelper as vC,LOD as bC,Triangle as _C,NormalBlending as wC,NeutralToneMapping as Xl,AgXToneMapping as ud,ACESFilmicToneMapping as fm,ReinhardToneMapping as ym,LinearToneMapping as pd,HalfFloatType as xC,VideoTexture as SC,CubeTexture as CC,CompressedCubeTexture as OC,EquirectangularRefractionMapping as PC,VectorKeyframeTrack as kC,QuaternionKeyframeTrack as MC,Audio as RC,MirroredRepeatWrapping as nv,UniformsUtils as sv,ShaderLib as md,MeshNormalMaterial as TC,AudioContext as EC,PMREMGenerator$1 as AC}from"./three.min.js";import{createLoaders as vm,getRaycastMesh as ov,LODsManager as va,NEEDLE_progressive as it,addDracoAndKTX2Loaders as IC,configureLoader as jC,setDracoDecoderLocation as LC,setKTX2TranscoderLocation as DC}from"./gltf-progressive.min.js";import{GroundedSkybox as ba,Font as BC,TextGeometry as FC,FontLoader as zC,GLTFLoader as lr,TransformControlsGizmo as rv,EXRLoader as gd,RGBELoader as bm,Stats as UC,nodeFrame as NC,OrbitControls as av,PositionalAudioHelper as WC,HorizontalBlurShader as VC,VerticalBlurShader as HC,GLTFExporter as lv,strToU8 as cv,zipSync as $C,XRControllerModelFactory as GC,XRHandMeshModel as qC,Line2 as XC,LineGeometry as QC,LineMaterial as YC,KTX2Loader as ZC,TransformControls as KC,InteractiveGroup as JC,HTMLMesh as eO,VertexNormalsHelper as tO,OBJLoader as _m,FBXLoader as hv,mergeVertices as iO}from"./three-examples.min.js";import{fetchProfile as nO,MotionController as sO,$70d766613f57b014$export$2e2bcd8739ae039 as dv,ByteBuffer as oO,v5 as uv,md5 as pv,SIZE_PREFIX_LENGTH as mv,Builder as wm,createNoise4D as rO,Matrix4 as xm,BatchedParticleRenderer as aO,ParticleSystem as lO,RenderMode as ws,TrailParticle as gv,ConstantColor as cO,Vector4 as hO,ConstantValue as dO,WorkerBase as uO,MeshBVH as pO}from"./vendor.min.js";import{__webpack_exports__default as Te,__webpack_exports__Text as fv,__webpack_exports__Block as yv,__webpack_exports__update as mO,SimpleStateBehavior as gO,__webpack_exports__Inline as Sm,__webpack_exports__FontLibrary as vv,ThreeMeshUI as bv}from"./three-mesh-ui.min.js";let _v,wv=null;function gn(){return _v}function Cm(n){if(n==null){console.warn("Oh no: someone tried registering a non-existend gltf-loader. When you see this log it might mean that needle-engine is being imported multiple times. Please check your project setup.");return}wv!==n&&(wv=n,_v=new n)}const Om=new Map;function Xt(n=(t=>(t=globalThis.location)==null?void 0:t.hostname)()){if(Om.has(n))return Om.get(n);const t=/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|localhost/.test(n);return Om.set(n,t),t===!0}function xv(){return window.location.hostname.includes("glitch.me")}const Sv=typeof window!==void 0?window.location.search.includes("debugcontext"):!1;var me=(n=>(n.ContextRegistered="ContextRegistered",n.ContextCreationStart="ContextCreationStart",n.ContextCreated="ContextCreated",n.ContextFirstFrameRendered="ContextFirstFrameRendered",n.ContextDestroying="ContextDestroying",n.ContextDestroyed="ContextDestroyed",n.MissingCamera="MissingCamera",n.ContextClearing="ContextClearing",n.ContextCleared="ContextCleared",n))(me||{});class pe{static get Current(){return globalThis["NeedleEngine.Context.Current"]}static set Current(t){globalThis["NeedleEngine.Context.Current"]=t}static get All(){return this.Registered}static register(t){this.Registered.indexOf(t)===-1&&(Sv&&console.warn("Registering context"),this.Registered.push(t),this.dispatchCallback("ContextRegistered",t))}static unregister(t){const i=this.Registered.indexOf(t);i!==-1&&(Sv&&console.warn("Unregistering context"),this.Registered.splice(i,1))}static registerCallback(t,i){this._callbacks[t]||(this._callbacks[t]=[]),this._callbacks[t].push(i)}static unregisterCallback(t,i){if(!this._callbacks[t])return;const s=this._callbacks[t].indexOf(i);s!==-1&&this._callbacks[t].splice(s,1)}static dispatchCallback(t,i,s){if(!this._callbacks[t])return!0;const o={event:t,context:i};if(s)for(const l in s)o[l]=s[l];const r=new Array;return this._callbacks[t].forEach(l=>{const c=l(o);c instanceof Promise&&r.push(c)}),Promise.all(r)}static addContextCreatedCallback(t){this.registerCallback("ContextCreated",t)}static addContextDestroyedCallback(t){this.registerCallback("ContextDestroyed",t)}}a(pe,"Registered",[]),a(pe,"_callbacks",{});const Cv=()=>n=>n;function fO(n){return Cv()(n)}function yO(){return!!C("debug")}class Oi{constructor(t,i){a(this,"_factory"),a(this,"_cache",[]),a(this,"_maxSize"),a(this,"_index",0),this._factory=t,this._maxSize=i}get(){const t=this._index%this._maxSize;return this._index++,this._cache.length<=t&&(this._cache[t]=this._factory()),this._cache[t]}}let cr=!1;const Pm=new Array;typeof window<"u"&&setTimeout(()=>{if(cr){const n={},t=new URL(window.location.href),i=new URL(t);i.searchParams.append("console","");const s=i.toString().replace(/=$|=(?=&)/g,"");for(const r of Pm){const l=new URL(t);l.searchParams.append(r,""),n[r]=l.toString().replace(/=$|=(?=&)/g,"")}console.log(`\u{1F335} ?help: Debug Options for Needle Engine.
Append any of these parameters to the URL to enable specific debug options.
Example: ${s} will show an onscreen console window.`);const o=cr===!0?"":` (containing "${cr}")`;console.group("Available URL parameters:"+o);for(const r of Object.keys(n).sort())typeof cr=="string"&&!r.toLowerCase().includes(cr.toLowerCase())||(console.groupCollapsed(r),console.log("Reload with this flag enabled:"),console.log(n[r]),console.groupEnd());console.groupEnd()}},100);function Ql(){var n;return new URLSearchParams((n=globalThis.location)==null?void 0:n.search)}function C(n){cr&&!Pm.includes(n)&&Pm.push(n);const t=Ql();if(t.has(n)){const i=t.get(n);if(i){const s=Number(i);return isNaN(s)?i:s}else return!0}return!1}cr=C("help");function vO(n,t){const i=Ql();i.has(n)?i.set(n,t):i.append(n,t),document.location.search=i.toString()}function Yl(n,t,i=!0){const s=Ql();s.has(n)?t===null?s.delete(n):s.set(n,t):t!==null&&s.append(n,t),i?Ov(n,s):Mm(n,s)}function km(n,t,i){n.has(t)?n.set(t,i.toString()):n.append(t,i.toString())}function Ov(n,t,i){window.history.pushState(i,n,"?"+t.toString())}function Mm(n,t,i){window.history.replaceState(i,n,"?"+t.toString())}function bO(n){for(var t="",i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s=i.length,o=0;o<n;o++)t+=i.charAt(Math.floor(Math.random()*s));return t}function _O(n,t){return Math.floor(Math.random()*(t-n+1))+n}const Pv=["smol","tiny","giant","interesting","smart","bright","dull","extreme","beautiful","pretty","dark","epic","salty","silly","funny","lame","lazy","loud","lucky","mad","mean","mighty","mysterious","nasty","odd","old","powerful","quiet","rapid","scary","shiny","shy","silly","smooth","sour","spicy","stupid","sweet","tasty","terrible","ugly","unusual","vast","wet","wild","witty","wrong","zany","zealous","zippy","zombie","zorro"],kv=["cat","dog","mouse","pig","cow","horse","sheep","chicken","duck","goat","panda","tiger","lion","elephant","monkey","bird","fish","snake","frog","turtle","hamster","penguin","kangaroo","whale","dolphin","crocodile","snail","ant","bee","beetle","butterfly","dragon","eagle","fish","giraffe","lizard","panda","penguin","rabbit","snake","spider","tiger","zebra"];function Mv(){const n=Pv[Math.floor(Math.random()*Pv.length)],t=kv[Math.floor(Math.random()*kv.length)];return n+"_"+t}function Rv(n){return n=n.replace(/[^a-z0-9áéíóúñü \.,_-]/gim,""),n.trim()}function _a(n,t,i=!0,s=!1){var o;if(t==null)return null;if(t.userData&&t.userData.guid===n||t.guid==n)return t;if(s&&(o=t.userData)!=null&&o.components){for(const r of t.userData.components)if(r.guid===n)return r}if(i){if(t.scenes)for(const r in t.scenes){const l=t.scenes[r],c=_a(n,l,i,s);if(c)return c}if(t.children)for(const r in t.children){const l=t.children[r],c=_a(n,l,i,s);if(c)return c}}}function Zl(n,t){if(n!=null&&typeof n=="object"){let i;Array.isArray(n)?i=[]:(i=Object.create(n),Object.assign(i,n));for(const s of Object.keys(n)){const o=n[s];t&&!t(n,s,o)?i[s]=o:o?.clone!==void 0&&typeof o.clone=="function"?i[s]=o.clone():i[s]=Zl(o,t)}return i}return n}function fn(n){return new Promise((t,i)=>{setTimeout(t,n)})}function Kl(n,t){if(n<=0)return Promise.resolve();if(t||(t=pe.Current),!t)return Promise.reject("No context");const i=t.time.frameCount+n;return new Promise((s,o)=>{if(!t)return o("No context");const r=()=>{t.time.frameCount>=i&&(t.pre_update_callbacks.splice(t.pre_update_callbacks.indexOf(r),1),s())};t.pre_update_callbacks.push(r)})}const fd=C("debugresolveurl"),Tv="rel:";function wO(n,t){return ho(n,t)}function ho(n,t){if(t===void 0)return fd&&console.warn("getPath: uri is undefined, returning uri",t),t;if(t.startsWith("./"))return t;if(t.startsWith("http"))return fd&&console.warn("getPath: uri is absolute, returning uri",t),t;if(n===void 0)return fd&&console.warn("getPath: source is undefined, returning uri",t),t;t.startsWith(Tv)&&(t=t.substring(4));const i=n.lastIndexOf("/");if(i>=0){const s=n.substring(0,i+1);for(;s.endsWith("/")&&t.startsWith("/");)t=t.substring(1);const o=s+t;return fd&&console.log("source:",n,`changed uri
from`,t,`
to `,o,`
basePath: `+s),o}return t}class xO{constructor(t,i){a(this,"writeCallbacks",[]),a(this,"_applied",!1),a(this,"_object"),a(this,"_prop"),a(this,"_wrapperProp"),this._object=t,this._prop=i,this._wrapperProp=Symbol("$"+i),this.apply()}subscribeWrite(t){this.writeCallbacks.push(t)}unsubscribeWrite(t){const i=this.writeCallbacks.indexOf(t);i!==-1&&this.writeCallbacks.splice(i,1)}apply(){if(this._applied||!this._object)return;const t=this._object,i=this._prop;if(t[i]===void 0)return;this._applied=!0,t[this._wrapperProp]!==void 0&&console.warn("Watcher is being applied to an object that already has a wrapper property. This is not (yet) supported");const s=t[i];t[this._wrapperProp]=s,Object.defineProperty(t,i,{get:()=>t[this._wrapperProp],set:o=>{t[this._wrapperProp]=o;for(const r of this.writeCallbacks)r(o,this._prop)}})}revoke(){if(!this._applied||!this._object)return;this._applied=!1;const t=this._object,i=this._prop;Reflect.deleteProperty(t,i);const s=t[this._wrapperProp];t[i]=s,Reflect.deleteProperty(t,this._wrapperProp)}dispose(){this.revoke(),this.writeCallbacks.length=0,this._object=null}}class io{constructor(t,i){if(a(this,"_watches",[]),Array.isArray(i))for(const s of i)this._watches.push(new io(t,s));else this._watches.push(new xO(t,i))}subscribeWrite(t){for(const i of this._watches)i.subscribeWrite(t)}unsubscribeWrite(t){for(const i of this._watches)i.unsubscribeWrite(t)}apply(){for(const t of this._watches)t.apply()}revoke(){for(const t of this._watches)t.revoke()}dispose(){for(const t of this._watches)t.dispose();this._watches.length=0}}const wa=Symbol("needle:watches");function yd(n,t){if(!n[wa])if(n instanceof re)n[wa]=new io(n,["x","y"]);else if(n instanceof x)n[wa]=new io(n,["x","y","z"]);else if(n instanceof ye||n instanceof V)n[wa]=new io(n,["x","y","z","w"]);else return!1;return n[wa].subscribeWrite(t),!0}function Rm(n,t){if(!n)return;const i=n[wa];i&&i.unsubscribeWrite(t)}var Q;(n=>{let t;function i(){if(t!==void 0)return t;const z=window.navigator.userAgent,H=/Windows|MacOS|Mac OS/.test(z),ie=/Windows NT/.test(z)&&/Edg/.test(z)&&!/Win64/.test(z);return t=H&&!ie&&!_()}n.isDesktop=i;let s;function o(){return s!==void 0?s:typeof window.orientation<"u"||navigator.userAgent.indexOf("IEMobile")!==-1?s=!0:s=/iPhone|iPad|iPod|Android|IEMobile/i.test(navigator.userAgent)}n.isMobileDevice=o;function r(){return c()}n.isIPad=r;let l;function c(){return l!==void 0?l:l=/iPad/.test(navigator.userAgent)}n.isiPad=c;let h;function d(){return h!==void 0?h:h=/Android/.test(navigator.userAgent)}n.isAndroidDevice=d;let u;function p(){return u!==void 0?u:u=/WebXRViewer\//i.test(navigator.userAgent)}n.isMozillaXR=p;let g;function y(){if(g!==void 0)return g;if(navigator.userAgentData)return g=navigator.userAgentData.platform==="macOS";{const z=navigator.userAgent.toLowerCase();return g=z.includes("mac os x")||z.includes("macintosh")}}n.isMacOS=y;let f;function v(){return f!==void 0?f:f=y()&&"xr"in navigator}n.isVisionOS=v;let b;const w=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"];function _(){return b!==void 0?b:b=w.includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}n.isiOS=_;let S;function R(){return S!==void 0||(S=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)),S}n.isSafari=R;let M;function T(){return M!==void 0?M:M=navigator.userAgent.includes("OculusBrowser")}n.isQuest=T;let L;function D(){return L!==void 0||(L=document.createElement("a").relList.supports("ar")),L}n.supportsQuickLookAR=D;async function U(){try{return(await navigator.permissions.query({name:"microphone"})).state!=="denied"}catch(z){return console.error("Error querying `microphone` permissions.",z),!1}}n.microphonePermissionsGranted=U;let B;function Y(){if(B!==void 0)return B;const z=navigator.userAgent.match(/iPhone OS (\d+_\d+)/);if(z&&(B=z[1].replace("_",".")),!B){const H=navigator.userAgent.match(/(?:\(Macintosh;|iPhone;|iPad;).*Version\/(\d+\.\d+)/);H&&(B=H[1])}return B||(B=null),B}n.getiOSVersion=Y;let $;function E(){if($!==void 0)return $;const z=navigator.userAgent.match(/(?:CriOS|Chrome)\/(\d+\.\d+\.\d+\.\d+)/);return z?$=z[1].replace("_","."):$=null,$}n.getChromeVersion=E})(Q||(Q={}));function SO(){return Q.isDesktop()}function CO(){return Q.isMobileDevice()}function OO(){return Q.isiPad()}function PO(){return Q.isiPad()}function kO(){return Q.isAndroidDevice()}function MO(){return Q.isMozillaXR()}function RO(){return Q.isMacOS()}function TO(){return Q.isiOS()}function EO(){return Q.isSafari()}function AO(){return Q.isQuest()}async function IO(){return Q.microphonePermissionsGranted()}const jO=/ip=(?<ip>.+?)\n/s;async function LO(){const n=await(await fetch("https://www.cloudflare.com/cdn-cgi/trace")).text(),t=jO.exec(n);return t?t[1]:null}async function DO(){const n=await fetch("https://api.db-ip.com/v2/free/self").catch(()=>null);return n?(await n.json()).ipAddress:void 0}async function BO(){const n=await fetch("https://api.db-ip.com/v2/free/self").catch(()=>null);return n?await n.json():void 0}const uo=new WeakMap;function Ev(n,t,i){if(!uo.get(n)){const o=new MutationObserver(r=>{FO(n,r)});uo.set(n,{observer:o,attributeChangedListeners:new Map}),o.observe(n,{attributes:!0})}const s=uo.get(n).attributeChangedListeners;s.has(t)||s.set(t,[]),s.get(t).push(i)}function Av(n,t,i){if(!uo.get(n))return;const s=uo.get(n).attributeChangedListeners;if(!s.has(t))return;const o=s.get(t),r=o.indexOf(i);if(r!==-1&&(o.splice(r,1),o.length<=0)){s.delete(t);const l=uo.get(n);l?.observer.disconnect(),uo.delete(n)}}function FO(n,t){const i=uo.get(n).attributeChangedListeners;for(const s of t)if(s.type==="attributes"){const o=s.attributeName,r=n.getAttribute(o);if(i.has(o))for(const l of i.get(o))l(r)}}class Tm{constructor(t){a(this,"reason"),this.reason=t}}async function Em(n){const t=await Promise.allSettled(n).catch(o=>[new Tm(o.message)]);let i=!1;const s=t.map(o=>"value"in o?o.value:(i=!0,new Tm(o.reason)));return{anyFailed:i,results:s}}async function Iv(n){if(!globalThis.QRCode){const s="https://cdn.rawgit.com/davidshimjs/qrcodejs/gh-pages/qrcode.min.js";let o=document.head.querySelector(`script[src="${s}"]`);o||(o=document.createElement("script"),o.src=s,document.head.appendChild(o)),await new Promise((r,l)=>{o.addEventListener("load",()=>{r(!0)})})}const t=globalThis.QRCode,i=n.domElement??document.createElement("div");return new t(i,{width:n.width??256,height:n.height??256,colorDark:"#000000",colorLight:"#ffffff",correctLevel:t.CorrectLevel.M,...n}),i}const jv=C("debugdebug");let Jl=!1;(C("noerrors")||C("nooverlaymessages"))&&(Jl=!0);const Am="needle_engine_global_error_container";var Pi=(n=>(n[n.Log=0]="Log",n[n.Warn=1]="Warn",n[n.Error=2]="Error",n))(Pi||{});function Im(){return Fv}const jm=new Array;function zO(n){jm.push(n)}let Lm=!1;function UO(...n){if(!Lm){Lm=!0;try{for(let t=0;t<jm.length;t++)jm[t](...n)}catch(t){console.error(t)}Lm=!1}}const Lv=console.error,Dv=function(...n){Lv.apply(console,n),VO(n),Fn(2,n),Dm(...n)};function Bv(n){Jl=!n,n?console.error=Dv:console.error=Lv}function NO(n){return Bv(n)}function WO(){Jl||(jv&&console.warn("Patch console",window.location.hostname),console.error=Dv,window.addEventListener("error",n=>{if(!n)return;const t=n.error;if(t===void 0){Xt()&&console.warn("Received unknown error",n,n.target);return}Fn(2,t,n.filename,n.lineno),Dm(n)},!0),window.addEventListener("unhandledrejection",n=>{Jl||n&&(n.reason?Fn(2,n.reason.message,n.reason.stack):Fn(2,"unhandled rejection"),Dm(n))}))}let Fv=0;function Dm(...n){Fv+=1,UO(...n)}function VO(n){if(Array.isArray(n))for(let t=0;t<n.length;t++){const i=n[t];typeof i=="string"&&i.startsWith("THREE.PropertyBinding: Trying to update node for track:")&&(n[t]="Some animated objects couldn't be found: see console for details")}}function Fn(n,t,i,s){if(Jl)return;const o=pe.Current,r=o?.domElement??document.querySelector("needle-engine");if(r){if(Array.isArray(t)){let l="";for(let c=0;c<t.length;c++){let h=t[c];h instanceof Error&&(h=h.message),typeof h!="object"&&(c>0&&(l+=" "),l+=h)}t=l}!t||t.length<=0||HO(n,r,t)}}const ec=new Map;function HO(n,t,i){if(i==null)return;const s=qO(t);if(s.childElementCount>=20){const c=s.lastElementChild;Uv(c)}i.length>400&&(i=i.substring(0,400)+"...");const o=i;if(ec.has(o))return;const r=XO(n,i);s.prepend(r);const l=()=>{ec.delete(o),Uv(r)};ec.set(o,l),setTimeout(l,1e4)}function $O(){jv&&console.log("Clearing messages");for(const n of ec.values())n?.call(n);ec.clear()}const GO=`
@import url('https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap');
div[data-needle_engine_debug_overlay] {
font-family: 'Roboto Flex', sans-serif;
font-weight: 400;
font-size: 16px;
}
div[data-needle_engine_debug_overlay] strong {
font-weight: 700;
}
div[data-needle_engine_debug_overlay] a {
color: white;
text-decoration: none;
border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}
div[data-needle_engine_debug_overlay] a:hover {
text-decoration: none;
border: none;
}
div[data-needle_engine_debug_overlay] .log strong {
color: rgba(200,200,200,.9);
}
div[data-needle_engine_debug_overlay] .warn strong {
color: rgba(255,255,230, 1);
}
div[data-needle_engine_debug_overlay] .error strong {
color: rgba(255,100,120, 1);
}
`;function qO(n){globalThis[Am]||(globalThis[Am]=new Map);const t=globalThis[Am];if(t.has(n))return t.get(n);{const i=document.createElement("div");t.set(n,i),i.setAttribute("data-needle_engine_debug_overlay",""),i.classList.add("debug-container"),i.style.cssText=`
position: absolute;
top: 0;
right: 5px;
padding-top: 0px;
max-width: 70%;
max-height: calc(100% - 5px);
z-index: 9999999999;
pointer-events: scroll;
display: flex;
align-items: end;
flex-direction: column;
color: white;
overflow: auto;
word-break: break-word;
`,n.shadowRoot?n.shadowRoot.appendChild(i):n.appendChild(i);const s=document.createElement("style");return s.innerHTML=GO,i.appendChild(s),i}}const zv=Symbol("logtype"),vd=new Map;function Uv(n){n.remove();const t=n[zv],i=vd.get(t)??[];i.push(n),vd.set(t,i)}function XO(n,t){if(vd.has(n)){const s=vd.get(n);if(s.length>0){const o=s.pop();return o.innerHTML=t,o}}const i=document.createElement("div");switch(i.setAttribute("data-id","__needle_engine_debug_overlay"),i.style.marginRight="5px",i.style.padding=".5em",i.style.backgroundColor="rgba(0,0,0,.9)",i.style.marginTop="5px",i.style.marginBottom="3px",i.style.borderRadius="8px",i.style.pointerEvents="all",i.style.userSelect="text",i.style.maxWidth="250px",i.style.whiteSpace="pre-wrap",i.style["backdrop-filter"]="blur(10px)",i.style["-webkit-backdrop-filter"]="blur(10px)",i.style.backgroundColor="rgba(20,20,20,.8)",i.style.boxShadow="inset 0 0 80px rgba(0,0,0,.2), 0 0 5px rgba(0,0,0,.2)",i.style.border="1px solid rgba(160,160,160,.2)",i[zv]=n,n){case 0:i.classList.add("log"),i.style.color="rgba(200,200,200,.7)",i.style.backgroundColor="rgba(40,40,40,.7)";break;case 1:i.classList.add("warn"),i.style.color="rgb(255, 255, 150)",i.style.backgroundColor="rgba(50,50,20,.8)";break;case 2:i.classList.add("error"),i.style.color="rgb(255, 50, 50",i.style.backgroundColor="rgba(50,20,20,.8)";break}return i.title="Open the browser console (F12) for more information",i.innerHTML=t,i}class QO{constructor(){a(this,"Rad2Deg",180/Math.PI),a(this,"Deg2Rad",Math.PI/180),a(this,"Epsilon",1e-5)}random(t,i){return Array.isArray(t)?t.length<=0?null:t[Math.floor(Math.random()*t.length)]:t!==void 0&&i!==void 0?Math.random()*(i-t)+t:Math.random()}randomVector3(t,i=0,s=1){t.x=this.random(i,s),t.y=this.random(i,s),t.z=this.random(i,s)}clamp(t,i,s){return t<i?i:t>s?s:t}clamp01(t){return this.clamp(t,0,1)}lerp(t,i,s){return s=s<0?0:s,s=s>1?1:s,t+(i-t)*s}inverseLerp(t,i,s){return(s-t)/(i-t)}remap(t,i,s,o,r){return o+(r-o)*(t-i)/(s-i)}moveTowards(t,i,s){return t+=s,(s<0&&t<i||s>0&&t>i)&&(t=i),t}toDegrees(t){return t*180/Math.PI}toRadians(t){return t*Math.PI/180}tan(t){return Math.tan(t)}gammaToLinear(t){return Math.pow(t,2.2)}linearToGamma(t){return Math.pow(t,1/2.2)}approximately(t,i,s=Number.EPSILON){for(const o of YO){const r=t[o],l=i[o];if(r===void 0||l===void 0)break;if(Math.abs(r-l)>s)return!1}return!0}easeInOutCubic(t){return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2}}const YO=["x","y","z","w"],W=new QO;class Nv{constructor(t){a(this,"y"),a(this,"s"),a(this,"alpha",0),this.setAlpha(t),this.y=null,this.s=null}setAlpha(t){if(t<=0||t>1)throw new Error;this.alpha=t}filter(t,i){i&&this.setAlpha(i);let s;return this.y?s=this.alpha*t+(1-this.alpha)*this.s:s=t,this.y=t,this.s=s,s}lastValue(){return this.y}reset(t){this.y=t,this.s=t}}class bd{constructor(t,i=1,s=0,o=1){if(a(this,"freq"),a(this,"minCutOff"),a(this,"beta"),a(this,"dCutOff"),a(this,"x"),a(this,"dx"),a(this,"lasttime"),t<=0||i<=0||o<=0)throw new Error;this.freq=t,this.minCutOff=i,this.beta=s,this.dCutOff=o,this.x=new Nv(this.alpha(this.minCutOff)),this.dx=new Nv(this.alpha(this.dCutOff)),this.lasttime=null}alpha(t){const i=1/this.freq;return 1/(1+1/(2*Math.PI*t)/i)}filter(t,i=null){this.lasttime&&i&&(this.freq=1/(i-this.lasttime)),this.lasttime=i;const s=this.x.lastValue(),o=s?(t-s)*this.freq:0,r=this.dx.filter(o,this.alpha(this.dCutOff)),l=this.minCutOff+this.beta*Math.abs(r);return this.x.filter(t,this.alpha(l))}reset(t){t!=null&&this.x.reset(t),this.x.alpha=this.alpha(this.minCutOff),this.dx.alpha=this.alpha(this.dCutOff),this.lasttime=null}}class Bm{constructor(t,i=1,s=0,o=1){a(this,"x"),a(this,"y"),a(this,"z"),this.x=new bd(t,i,s,o),this.y=new bd(t,i,s,o),this.z=new bd(t,i,s,o)}filter(t,i,s=null){i.x=this.x.filter(t.x,s),i.y=this.y.filter(t.y,s),i.z=this.z.filter(t.z,s)}reset(t){this.x.reset(t?.x),this.y.reset(t?.y),this.z.reset(t?.z)}}const _d="needle:cameraController";function Wv(n){return n[_d]}function Fm(n,t,i){i?n[_d]=t:n[_d]===t&&(n[_d]=null)}const zm="needle:autofit";function Vv(n){return n[zm]===void 0?!0:n[zm]!==!1}function wd(n,t){n[zm]=t}function ZO(n,t,i){const s=n.length(),o=t.length(),r=W.lerp(s,o,i);return n.lerp(t,i).normalize().multiplyScalar(r)}const Um=new V,Hv=new V().setFromAxisAngle(new x(0,1,0),Math.PI);function KO(n,t){n.lookAt(t),n.quaternion.multiply(Hv)}function tc(n,t,i=!0,s=!1){if(n===t)return;Um.copy(n.quaternion);const o=te(t),r=te(n);if(s){if(Vi(n,Ce(t)),i){const l=r.y,c=r.sub(Qv(n));c.y=l,n.lookAt(c),n.quaternion.multiply(Hv)}Number.isNaN(n.quaternion.x)&&n.quaternion.copy(Um);return}i&&(o.y=r.y),n.lookAt(o),Number.isNaN(n.quaternion.x)&&n.quaternion.copy(Um)}function JO(n,t,i,s=1){if(i){const o=q(0,0,0),r=t.x/window.innerWidth*2-1,l=-(t.y/window.innerHeight)*2+1;o.set(r,l,0),o.unproject(i);const c=i.worldPosition,h=n.worldPosition.distanceTo(c),d=o.sub(c);d.multiplyScalar(s*3.6*h);const u=i.worldPosition.add(d);return n.lookAt(u),u}return null}const eP=new Oi(()=>new x,100);function q(n,t,i){const s=eP.get();return s.set(0,0,0),n instanceof x?s.copy(n):Array.isArray(n)?s.set(n[0],n[1],n[2]):n instanceof DOMPointReadOnly?s.set(n.x,n.y,n.z):typeof n=="number"?(s.x=n,s.y=t!==void 0?t:s.x,s.z=i!==void 0?i:s.x):typeof n=="object"&&(s.x=n.x,s.y=n.y,s.z=n.z),s}const tP=new Oi(()=>new ce,30);function $v(n){const t=tP.get();return n?t.copy(n):t.set(0,0,0),t}const iP=new Oi(()=>new V,100);function yn(n){const t=iP.get();return t.identity(),n instanceof V?t.copy(n):n instanceof DOMPointReadOnly&&t.set(n.x,n.y,n.z,n.w),t}const Nm=new Oi(()=>new x,100),Gv=Symbol("lastMatrixWorldUpdateKey");function te(n,t=null,i=!0){const s=t??Nm.get();return n?n.parent?(i&&n.updateWorldMatrix(!0,!1),n.matrixWorldNeedsUpdate&&n[Gv]!==Date.now()&&(n[Gv]=Date.now(),n.updateMatrixWorld()),s.setFromMatrixPosition(n.matrixWorld),s):s.copy(n.position):s.set(0,0,0)}function dt(n,t){if(!n)return n;const i=Nm.get();return t!==i&&i.copy(t),(n?.parent??n).worldToLocal(i),n.position.set(i.x,i.y,i.z),n}function hr(n,t,i,s){const o=Nm.get();return o.set(t,i,s),dt(n,o),n}const xd=new Oi(()=>new V,100),dr=new V,Wm=new V;function Ce(n,t=null){if(!n)return xd.get().identity();const i=t??xd.get();return n.parent?(n.getWorldQuaternion(i),i):i.copy(n.quaternion)}function Vi(n,t){if(!n)return;t!==dr&&dr.copy(t);const i=dr,s=n?.parent;s?.getWorldQuaternion(Wm),Wm.invert();const o=Wm.multiply(i);n.quaternion.set(o.x,o.y,o.z,o.w)}function Vm(n,t,i,s,o){dr.set(t,i,s,o),Vi(n,dr)}const nP=new Oi(()=>new x,100),sP=new x;function Ye(n,t=null){return t||(t=nP.get()),n?n.parent?(n.getWorldScale(t),t):t.copy(n.scale):t.set(0,0,0)}function xa(n,t){if(!n)return;if(!n.parent){n.scale.copy(t);return}const i=sP;n.parent.getWorldScale(i),n.scale.copy(t),n.scale.divide(i)}const oP=new x,qv=new V;function rP(n){return Ce(n,qv),oP.set(0,0,1).applyQuaternion(qv)}const aP=new Oi(()=>new x,100),Xv=new V;function Qv(n,t){return t||(t=aP.get().set(0,0,1)),Ce(n,Xv),t.applyQuaternion(Xv)}const Yv=new Bt,Zv=new Bt,lP=new x;function Hm(n){const t=xd.get();return n.getWorldQuaternion(t),Zv.setFromQuaternion(t),Zv}function $m(n,t){const i=xd.get();Vi(n,i.setFromEuler(t))}function ic(n){const t=Hm(n),i=lP;return i.set(t.x,t.y,t.z),i.x=W.toDegrees(i.x),i.y=W.toDegrees(i.y),i.z=W.toDegrees(i.z),i}function Gm(n,t){nc(n,t.x,t.y,t.z,!0)}function nc(n,t,i,s,o=!0){o&&(t=W.toRadians(t),i=W.toRadians(i),s=W.toRadians(s)),Yv.set(t,i,s),dr.setFromEuler(Yv),Vi(n,dr)}function Sd(n,t=!0){n&&(t?function i(s){console.groupCollapsed((s.name?s.name:"(no name : "+s.type+")")+" %o",s),s.children.forEach(i),console.groupEnd()}(n):n.traverse(function(i){for(var s="|___",o=i;o.parent!==null;)s=" "+s,o=o.parent;console.log(s+i.name+" <"+i.type+">")}))}function cP(n){let t=n?.name||"";if(!n)return t;let i=n.parent;for(;i;)t=i.name+"/"+t,i=i.parent;return t}function Kv(n){if(n){const t=n;return t.blendMode!==void 0&&t.clampWhenFinished!==void 0&&t.enabled!==void 0&&t.fadeIn!==void 0&&t.getClip!==void 0}return!1}class Hi{static createBlitMaterial(t){return new mn({uniforms:{map:new so(null)},vertexShader:this.vertex,fragmentShader:t})}static copyTexture(t,i){this.blitMaterial||(this.blitMaterial=new mn({uniforms:{map:new so(null)},vertexShader:this.vertex,fragmentShader:this.fragment}));const s=i||this.blitMaterial;s.uniforms.map.value=t,s.needsUpdate=!0,s.uniformsNeedUpdate=!0;const o=s.vertexShader;s.vertexShader=this.vertex,this.mesh||(this.mesh=new X(this.planeGeometry,this.blitMaterial));const r=this.mesh;r.material=s,r.frustumCulled=!1,this.scene.children.length=0,this.scene.add(r),this.renderer||(this.renderer=new rr({antialias:!1})),this.renderer.setSize(t.image.width,t.image.height),this.renderer.clear(),this.renderer.render(this.scene,this.perspectiveCam);const l=new De(this.renderer.domElement);return l.name="Copy",l.needsUpdate=!0,s.vertexShader=o,l}static textureToCanvas(t,i=!1){if(!t)return null;(i===!0||t.isCompressedTexture===!0)&&(t=Jv(t));const s=t.image;if(dP(s)){const o=document.createElement("canvas");o.width=s.width,o.height=s.height;const r=o.getContext("2d");return r?(r.drawImage(s,0,0,s.width,s.height,0,0,o.width,o.height),o):(console.error("Failed getting canvas 2d context"),null)}return null}}a(Hi,"planeGeometry",new Bn(2,2,1,1)),a(Hi,"renderer"),a(Hi,"perspectiveCam",new xe),a(Hi,"scene",new wi),a(Hi,"vertex",`
varying vec2 vUv;
void main(){
vUv = uv;
gl_Position = vec4(position.xy * 1.0,0.,.999999);
}`),a(Hi,"fragment",`
uniform sampler2D map;
varying vec2 vUv;
void main(){
vec2 uv = vUv;
uv.y = 1.0 - uv.y;
gl_FragColor = texture2D( map, uv);
// gl_FragColor = vec4(uv.xy, 0, 1);
}`),a(Hi,"blitMaterial"),a(Hi,"mesh");function Jv(n){return Hi.copyTexture(n)}function hP(n,t=!1){return Hi.textureToCanvas(n,t)}function dP(n){return typeof HTMLImageElement<"u"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&n instanceof ImageBitmap}function uP(n){const t=n.type;return t==="Mesh"||t==="SkinnedMesh"}function qm(n,t){t?n["needle:rendercustomshadow"]=!0:n["needle:rendercustomshadow"]=!1}function eb(n){return!!(n&&(n["needle:rendercustomshadow"]===!0||n["needle:rendercustomshadow"]==null))}function oi(n,t=void 0,i=void 0,s=void 0){const o=s||new xi;o.makeEmpty();const r=[];function l(h){let d=!0;if(h.visible&&Vv(h)!==!1&&!(h.type==="TransformControlsGizmo"||h.type==="TransformControlsPlane")){if(h instanceof Hy&&(d=!1),h instanceof rm&&(d=!1),h instanceof ba&&(d=!1),h.isGizmo===!0&&(d=!1),h.material instanceof Vy&&(d=!1),uP(h)||(d=!1),i&&h.layers.test(i)===!1&&(d=!1),d&&(t&&Array.isArray(t)&&t!=null&&t.includes(h)||typeof t=="function"&&t(h)===!0))return;if(h.isUI!==!0){if(d){const u=h.children;h.children=r;const p=h.position,g=h.scale;if(Number.isNaN(p.x)||Number.isNaN(p.y)||Number.isNaN(p.z)){console.warn(`Object "${h.name}" has NaN values in position or scale.... will ignore it`,p,g);return}o.expandByObject(h,!0),h.children=u}for(const u of h.children)l(u)}}}let c=!1;Array.isArray(n)||(n=[n]);for(const h of n)h&&(c=!0,h.updateMatrixWorld(),l(h));return c||console.warn("No objects to fit camera to..."),o}function tb(n,t,i){const s=oi([n],i?.ignore),o=new x;s.getSize(o);const r=new x;s.getCenter(r);const l=new x;t.getSize(l);const c=new x;t.getCenter(c);const h=new x;h.set(l.x/o.x,l.y/o.y,l.z/o.z);const d=Math.min(h.x,h.y,h.z),u=i?.scale!==!1;if(u&&xa(n,Ye(n).multiplyScalar(d)),i?.position!==!1){const p=new x;s.getCenter(p),p.y=s.min.y;const g=new x;t.getCenter(g),g.y=t.min.y;const y=g.clone().sub(p);u&&y.multiplyScalar(d),dt(n,te(n).add(y))}return{boundsBefore:s,scale:h}}function ib(n,t){const i=oi([n]),s=new x;i.getCenter(s),s.y=i.min.y;const o=t.clone().sub(s),r=te(n);return dt(n,r.add(o)),{offset:o,bounds:i}}function Xm(n,t,i,s){if(Array.isArray(t)){let l=!0;for(let c=0;c<t.length;c++)Xm(n,t[c],c,t)||(l=!1);return l}if(t.type==="MeshStandardMaterial"||t.type==="MeshBasicMaterial")return!1;if(t["material:fbx"]!=null)return!0;const o=new Ft;o["material:fbx"]=t;const r=t;return r&&(r.map?o.color.set(1,1,1):o.color.copyLinearToSRGB(r.color),o.emissive.copyLinearToSRGB(r.emissive),o.emissiveIntensity=r.emissiveIntensity,o.opacity=r.opacity,o.displacementScale=r.displacementScale,o.transparent=r.transparent,o.bumpMap=r.bumpMap,o.aoMap=r.aoMap,o.map=r.map,o.displacementMap=r.displacementMap,o.emissiveMap=r.emissiveMap,o.normalMap=r.normalMap,o.envMap=r.envMap,o.alphaMap=r.alphaMap,o.metalness=r.reflectivity,o.vertexColors=r.vertexColors,r.shininess&&(o.roughness=1-Math.sqrt(r.shininess)/10),o.needsUpdate=!0),i===void 0?n.material=o:s[i]=o,!0}let Cd=!1;zO((...n)=>{var t;F()&&(t=pe.Current)!=null&&t.isInXR&&(ur(!0),nb("error",...n))});function ur(n){if(n){if(Cd)return;Cd=!0,mP()}else{if(!Cd)return;Cd=!1,gP()}}const sc={log:void 0,warn:void 0,error:void 0};class pP{constructor(){a(this,"familyName","needle-xr"),a(this,"root",null),a(this,"context",null),a(this,"defaultFontSize",.06),a(this,"targetObject",new j),a(this,"userForwardViewPoint",new x),a(this,"oneEuroFilter",new Bm(90,.8)),a(this,"_lastElementRemoveTime",0),a(this,"onBeforeRender",()=>{var t,i;const s=(t=this.context)==null?void 0:t.mainCamera;if(this.context&&s instanceof xe){const o=this.getRoot();Number.isNaN(o.position.x)&&o.position.set(0,0,0),Number.isNaN(o.quaternion.x)&&o.quaternion.set(0,0,0,1),this.context.scene.add(this.targetObject);const r=((i=this.context.xr)==null?void 0:i.rigScale)??1,l=3.5*r,c=s.worldForward;c.y=0,c.normalize().multiplyScalar(l),this.userForwardViewPoint.copy(s.worldPosition).sub(c),this.targetObject.position.distanceTo(this.userForwardViewPoint)>2*r&&(this.targetObject.position.copy(this.userForwardViewPoint),tc(this.targetObject,s,!0,!0),this.targetObject.rotateY(Math.PI)),this.oneEuroFilter.filter(this.targetObject.position,o.position,this.context.time.time);const h=this.context.time.deltaTime;if(o.quaternion.slerp(this.targetObject.quaternion,h*5),o.scale.setScalar(r),this.targetObject.removeFromParent(),this.context.scene.add(o),this.context.time.time-this._lastElementRemoveTime>.1){this._lastElementRemoveTime=this.context.time.time;const d=Date.now();for(let u=0;u<this._activeTexts.length;u++){const p=this._activeTexts[u];if(p instanceof Te.Text&&d-p._activatedTime>2e4){p.removeFromParent(),this._textBuffer.push(p),this._activeTexts.splice(u,1);break}}}}}),a(this,"textOptions",{fontSize:this.defaultFontSize,fontFamily:this.familyName,padding:.03,margin:.005,color:0,backgroundColor:16777215,backgroundOpacity:.4,borderRadius:.03,offset:.025}),a(this,"_textBuffer",[]),a(this,"_activeTexts",[]),this.ensureFont()}onEnable(){this.context=pe.Current||pe.All[0],this.context.pre_render_callbacks.push(this.onBeforeRender)}onDisable(){var t,i,s;(i=this.context)==null||i.pre_render_callbacks.splice((t=this.context)==null?void 0:t.pre_render_callbacks.indexOf(this.onBeforeRender),1),(s=this.root)==null||s.removeFromParent()}addLog(t,i){const s=this.getRoot(),o=this.getText();let r=16777215,l=0;switch(t){case"log":r=16777215,l=0;break;case"warn":r=16772761,l=4465152;break;case"error":r=16755370,l=7798784;break}i.length>1e3&&(i=i.substring(0,1e3)+"...");const c=new Date().toISOString().split("T")[1].split(".")[0];o.textContent="["+c+"] "+i,o.visible=!0,o._activatedTime=Date.now(),s.add(o),this._activeTexts.push(o),this.context&&this.context.scene.add(s),o.set({backgroundColor:r,color:l}),Te.update()}ensureFont(){let t=Te.FontLibrary.getFontFamily(this.familyName);if(!t){t=Te.FontLibrary.addFontFamily(this.familyName);const i=t.addVariant("normal","normal","./include/needle/arial-msdf.json","./include/needle/arial.png");i?.addEventListener("ready",()=>{Te.update()})}}getText(){const t=this.getRoot();if(this._textBuffer.length>0){const s=this._textBuffer.pop();return s.visible=!0,setTimeout(()=>this.disableDepthTestRecursive(s),100),s}if(t.children.length>20&&this._activeTexts.length>0)return this._activeTexts.shift();const i=new Te.Text(this.textOptions);return setTimeout(()=>this.disableDepthTestRecursive(i),500),setTimeout(()=>this.disableDepthTestRecursive(i),1500),i}disableDepthTestRecursive(t,i=0){for(let o=0;o<t.children.length;o++){const r=t.children[o];r instanceof j&&this.disableDepthTestRecursive(r,i+1)}t.renderOrder=10*i,t.layers.set(2);const s=t.material;s&&(s.depthWrite=!1,s.depthTest=!1,s.transparent=!0),i===0&&Te.update()}getRoot(){if(this.root)return this.root;const t=this.defaultFontSize,i={boxSizing:"border-box",fontFamily:this.familyName,width:"2.6",fontSize:t,color:0,lineHeight:1,backgroundColor:16777215,backgroundOpacity:0,whiteSpace:"pre-wrap",flexDirection:"column-reverse"};return this.root=new Te.Block(i),this.root}}let vn=null;function mP(){vn||(vn=new pP),vn.onEnable();for(const n in sc){sc[n]=console[n];let t=!1;console[n]=function(){var i;if((i=sc[n])==null||i.apply(console,arguments),!t)try{t=!0,nb(n,...arguments)}finally{t=!1}}}}function gP(){vn?.onDisable();for(const n in sc)console[n]=sc[n]}const oc=new Map;function nb(n,...t){try{switch(oc.clear(),n){case"log":vn?.addLog("log",i());break;case"warn":vn?.addLog("warn",i());break;case"error":vn?.addLog("error",i());break}}catch(r){console.error("Error in spatial console",r)}finally{oc.clear()}function i(){let r="";for(let l=0;l<t.length;l++){const c=t[l];r+=s(c),l<t.length-1&&(r+=", ")}return r}function s(r,l=0){if(typeof r=="string")return'"'+r+'"';if(typeof r=="number"){if(r%1!==0){const c=r.toFixed(5),h=c.indexOf(".");let d=c.length-1;for(;d>h&&c[d]==="0";)d--;return c.substring(0,d+1)}return r.toString()}else if(Array.isArray(r)){let c="[";for(let h=0;h<r.length;h++){const d=r[h];c+=s(d,l+1),h<r.length-1&&(c+=", ")}return c+="]",c}else{if(r===null)return"null";if(r===void 0)return"undefined";if(typeof r=="function")return r.name+"()"}if(r instanceof re)return`(${s(r.x)}, ${s(r.y)})`;if(r instanceof x)return`(${s(r.x)}, ${s(r.y)}, ${s(r.z)})`;if(r instanceof ye)return`(${s(r.x)}, ${s(r.y)}, ${s(r.z)}, ${s(r.w)})`;if(r instanceof V)return`(${s(r.x)}, ${s(r.y)}, ${s(r.z)}, ${s(r.w)})`;if(r instanceof ke||r instanceof De)return r.name;if(r instanceof $y)return`[${r.elements.join(", ")}]`;if(r instanceof se)return`[${r.elements.join(", ")}]`;if(r instanceof oo)return r.mask.toString();if(typeof r=="object"){if(oc.has(r))return"*";let c=`{
`;c+=o(l);const h=Object.keys(r);let d="";for(let u=0;u<h.length;u++){const p=h[u],g=r[p];if(oc.has(g)){d+="";continue}oc.set(g,!0),d+=p+":"+s(g,l+1),u<h.length-1&&(d+=", "),d.length>=60&&(d+=`
`,d+=o(l),c+=d,d="")}return c+=d,c+=`
}`,c}return r}function o(r){let l="";for(let c=0;c<r;c++)l+=" ";return l}}const fP=C("nodevlogs");function Be(n,t=Pi.Log){Fn(t,n)}function _e(n){Be(n,Pi.Warn)}function rc(n){Be(n,Pi.Error)}let Qm,Ym;function F(){if(fP)return!1;if(Qm!==void 0)return Qm;if(Ym!==void 0)return Ym;let n=Xt();return n||(n=window.location.hostname.endsWith(".local-credentialless.webcontainer.io")),Ym=n,n}function yP(n){Qm=n}let ri,$i=null,zn=null,ac=!1,sb=null;const ob="terminal",lc=C("console"),vP=C("noerrors")||C("noconsole")||window.crossOriginIsolated;if(lc&&Km(),!vP&&(lc||Xt())){if(Xt()&&!lc){const t=new URL(window.location.href);t.searchParams.set("console","1"),console.log('\u{1F335} Tip: You can add the "?console" query parameter to the url to show the debug console (on mobile it will automatically open in the bottom right corner when your get errors during development. In VR a spatial console will appear.)',`
Open this page to get the console: `+t.toString())}const n=Q.isMobileDevice()||Q.isQuest()&&F();if((n||lc)&&(WO(),ab(),cb(!0),n)){const t=document.querySelector("needle-engine");t?.addEventListener("enter-ar",()=>{(lc||ri||Im()>0)&&C("noerrors")}),t?.addEventListener("exit-ar",()=>{xP()})}}const Zm=Symbol("consoleParent");function Km(){if(ri){ri.showSwitch();return}cb()}function rb(){ri&&(ri.hide(),ri.hideSwitch())}function ab(){sb||(sb=setInterval(bP,500))}let lb=0;function bP(){const n=Im(),t=n!==lb;lb=n,t&&_P()}function _P(){Km(),zn&&(zn.setAttribute("error","true"),zn.innerText="\u{1F92C}")}function wP(){zn&&(zn.removeAttribute("error"),zn.innerText=ob)}function xP(){$i&&$i[Zm]&&$i[Zm].appendChild($i)}function cb(n=!1){if(ri!==void 0||ac)return;ac=!0;const t=document.createElement("script");t.onload=()=>{if(!globalThis.VConsole){console.warn("\u{1F335} Debug console failed to load."),ac=!1,ri=null;return}ac=!1,ab(),ri=new VConsole({pluginOrder:["default","needle-console"]});const i=globalThis["needle:codegen_files"];if(i&&i.length>0&&ri.addPlugin(SP()),$i=OP(),$i&&($i[Zm]=$i.parentElement,$i.style.position="absolute",$i.style.zIndex=Number.MAX_SAFE_INTEGER.toString()),ri.setSwitchPosition(20,30),zn=CP(),zn){zn.innerText=ob,zn.addEventListener("click",wP);const s=document.createElement("style"),o=40;s.innerHTML=`
#__vconsole .vc-switch {
border: 1px solid rgba(255, 255, 255, .1);
border-radius: 50%;
width: ${o}px;
height: ${o}px;
padding: 0;
line-height: ${o}px;
font-size: ${o*.4}px;
text-align: center;
background: #ffffff5c;
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
user-select: none;
pointer-events: auto;
transition: transform .2s ease-in-out;
box-shadow: 0px 7px 0.5rem 0px rgb(0 0 0 / 6%), inset 0px 0px 1.3rem rgba(0,0,0,.05);
font-family: 'Material Symbols Outlined';
color: black;
font-size: 2.3em;
font-weight: 100;
}
#__vconsole .vc-switch:hover {
cursor: pointer;
transform: scale(1.1);
transition: transform .1s ease-in-out, background .1s linear;
background: rgba(245, 245, 245, .8);
outline: rgba(0, 0, 0, .05) 1px solid;
}
#__vconsole .vc-switch[error] {
background: rgba(255,0,0,.2);
animation: vconsole-notify 1s ease-in-out;
line-height: 35px;
}
@keyframes vconsole-notify {
from {
transform: scale(1, 1);
}
10% {
transform: scale(1.3, 1.3);
}
70% {
transform: scale(1.4, 1.4);
}
to {
transform: scale(1, 1);
}
}
#__vconsole .vc-panel {
font-family: monospace;
font-size: 11px;
}
#__vconsole .vc-plugin-box.vc-actived {
height: 100%;
}
#__vconsole .vc-mask {
overflow: hidden;
}
`,$i?.prepend(s),n===!0&&Im()<=0&&rb(),console.log("\u{1F335} Debug console has loaded")}},t.onerror=()=>{console.warn("\u{1F335} Debug console failed to load."+(window.crossOriginIsolated?"This page is using cross-origin isolation, so external scripts can't be loaded.":"")),ac=!1,ri=null},t.src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js",document.body.appendChild(t)}function SP(){if(!globalThis.VConsole)return;const n=new VConsole.VConsolePlugin("needle-console","\u{1F335} Inspect glTF"),t=()=>document.querySelector("#__vc_plug_"+n._id+" iframe");return n.on("renderTab",function(i){const s=globalThis["needle:codegen_files"];if(!s||s.length===0)return;let o=globalThis["needle:codegen_files"][0];const r=o.indexOf("?");r>-1&&(o=o.substring(0,r));const l=location.protocol+"//"+location.host+location.pathname+"/"+o,c=encodeURIComponent(l);n.fullUrl="https://viewer.needle.tools?inspect&file="+c;var h='<iframe src="" style="width: 100%; height: 99%; border: none;"></iframe>';i(h)}),n.on("show",function(){const i=t();i&&i.src!==n.fullUrl&&(i.src=n.fullUrl)}),n.on("hide",function(){const i=t();i&&(i.src="")}),n.on("addTopBar",function(i){var s=new Array;s.push({name:"Open in new window \u2197",onClick:function(o){window.open(n.fullUrl,"_blank"),ri?.hide()}}),s.push({name:"Reload",onClick:function(o){const r=t();r&&(r.src=n.fullUrl)}}),s.push({name:"Fullscreen",onClick:function(o){const r=t();r.requestFullscreen?r.requestFullscreen():r.webkitRequestFullscreen instanceof Function&&r.webkitRequestFullscreen()}}),i(s)}),n}function CP(){return document.querySelector("#__vconsole .vc-switch")||null}function OP(){return document.querySelector("#__vconsole")||null}const hb=C("debugdefines");po('if(!globalThis[""4.4.0-beta.8""]) globalThis[""4.4.0-beta.8""] = "0.0.0";'),po('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),po('if(!globalThis[""Mon Apr 14 2025 15:10:11 GMT+0200 (Central European Summer Time)""]) globalThis[""Mon Apr 14 2025 15:10:11 GMT+0200 (Central European Summer Time)""] = "unknown";'),po('if(!globalThis[""npk_0b7230d0d7c94c5ef23003726b2e2ccfc5ec0f20d26de8f0bda29e63698f9006""]) globalThis[""npk_0b7230d0d7c94c5ef23003726b2e2ccfc5ec0f20d26de8f0bda29e63698f9006""] = "unknown";'),po('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.4.0-beta.8";'),po('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),po('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Mon Apr 14 2025 15:10:11 GMT+0200 (Central European Summer Time)";'),po('globalThis["__NEEDLE_PUBLIC_KEY__"] = "npk_0b7230d0d7c94c5ef23003726b2e2ccfc5ec0f20d26de8f0bda29e63698f9006";');const bn="4.4.0-beta.8",Od="undefined",Jm="Mon Apr 14 2025 15:10:11 GMT+0200 (Central European Summer Time)";hb&&console.log(`Engine version: ${bn} (generator: ${Od})
Project built at ${Jm}`);const cc="npk_0b7230d0d7c94c5ef23003726b2e2ccfc5ec0f20d26de8f0bda29e63698f9006",xs="needle_isActiveInHierarchy",pr="builtin_components",hc="needle_editor_guid";function po(n){try{(0,eval)(n)}catch(t){hb&&console.error(t)}}const PP='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 160 187.74"><defs><linearGradient id="a" x1="89.64" y1="184.81" x2="90.48" y2="21.85" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#62d399"/><stop offset=".51" stop-color="#acd842"/><stop offset=".9" stop-color="#d7db0a"/></linearGradient><linearGradient id="b" x1="69.68" y1="178.9" x2="68.08" y2="16.77" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0ba398"/><stop offset=".5" stop-color="#4ca352"/><stop offset="1" stop-color="#76a30a"/></linearGradient><linearGradient id="c" x1="36.6" y1="152.17" x2="34.7" y2="84.19" gradientUnits="userSpaceOnUse"><stop offset=".19" stop-color="#36a382"/><stop offset=".54" stop-color="#49a459"/><stop offset="1" stop-color="#76a30b"/></linearGradient><linearGradient id="d" x1="15.82" y1="153.24" x2="18" y2="90.86" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#267880"/><stop offset=".51" stop-color="#457a5c"/><stop offset="1" stop-color="#717516"/></linearGradient><linearGradient id="e" x1="135.08" y1="135.43" x2="148.93" y2="63.47" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#b0d939"/><stop offset="1" stop-color="#eadb04"/></linearGradient><linearGradient id="f" x1="-4163.25" y1="2285.12" x2="-4160.81" y2="2215.34" gradientTransform="rotate(20 4088.49 13316.712)" gradientUnits="userSpaceOnUse"><stop offset=".17" stop-color="#74af52"/><stop offset=".48" stop-color="#99be32"/><stop offset="1" stop-color="#c0c40a"/></linearGradient><symbol id="g" viewBox="0 0 160 187.74"><path style="fill:url(#a)" d="M79.32 36.98v150.76L95 174.54l6.59-156.31-22.27 18.75z"/><path style="fill:url(#b)" d="M79.3