@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 pS=Object.defineProperty,mS=(n,t,i)=>t in n?pS(n,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[t]=i,a=(n,t,i)=>(mS(n,typeof t!="symbol"?t+"":t,i),i),nm=(n,t,i)=>{if(!t.has(n))throw TypeError("Cannot "+i)},fe=(n,t,i)=>(nm(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)},Bn=(n,t,i,s)=>(nm(n,t,"write to private field"),s?s.call(n,i):t.set(n,i),i),sd=(n,t,i)=>(nm(n,t,"access private method"),i);import{Vector2 as re,Vector3 as x,Vector4 as ye,Quaternion as V,PlaneGeometry as Fn,PerspectiveCamera as xe,Scene as wi,ShaderMaterial as mn,Uniform$1 as io,Mesh as X,WebGLRenderer as or,Texture as De,Euler as Bt,Box3 as xi,MeshStandardMaterial as Ft,Color as ce,ShadowMaterial as Uy,Box3Helper as Ny,GridHelper as sm,Material as ke,Matrix3 as Wy,Matrix4 as se,Layers as no,Object3D as j,Ray as so,MathUtils as ps,AxesHelper as Si,MeshBasicMaterial as Re,DoubleSide as Ci,BufferGeometry as ms,Group as oo,SphereGeometry as od,BoxGeometry as ma,SpriteMaterial as gS,Sprite as fS,Shape as yS,ExtrudeGeometry as vS,Fog as Vy,DirectionalLight as om,PointLight as rm,Line as ql,BufferAttribute as yt,CylinderGeometry as bS,EdgesGeometry as _S,LineSegments as Hy,LineBasicMaterial as $y,Sphere as rd,Plane as rr,Raycaster as ad,ArrayCamera as wS,SkinnedMesh as gs,InterleavedBufferAttribute as Gy,Skeleton as xS,Bone as SS,Source as CS,WebGLCubeRenderTarget as OS,CubeCamera as PS,AnimationClip as ro,TextureLoader as ga,PropertyBinding as fa,LinearSRGBColorSpace as fs,ShaderChunk as qt,UniformsLib as kS,FileLoader as qy,DataTexture as am,RGBAFormat as ld,EquirectangularReflectionMapping as ys,SRGBColorSpace as vs,Clock as MS,NoToneMapping as ya,PCFSoftShadowMap$1 as RS,BasicNodeLibrary as TS,WebGLRenderTarget as bs,DepthTexture as ES,NearestFilter as cd,LoopRepeat as AS,LoopOnce as lm,AnimationMixer as cm,CompressedTexture as IS,FrontSide as ao,Frustum as Xy,OrthographicCamera as hm,AudioListener as jS,PositionalAudio as LS,AudioLoader as dm,EventDispatcher as um,BackSide as hd,MeshDepthMaterial as DS,CustomBlending as BS,MaxEquation as FS,AmbientLight as zS,HemisphereLight as US,InvertStencilOp as NS,DecrementWrapStencilOp as WS,IncrementWrapStencilOp as VS,DecrementStencilOp as HS,IncrementStencilOp as $S,ReplaceStencilOp as GS,ZeroStencilOp as qS,KeepStencilOp as XS,AlwaysStencilFunc as QS,GreaterEqualStencilFunc as YS,NotEqualStencilFunc as ZS,GreaterStencilFunc as KS,LessEqualStencilFunc as JS,EqualStencilFunc as eC,LessStencilFunc as tC,NeverStencilFunc as Qy,RawShaderMaterial as Yy,GLSL3 as iC,AlwaysDepth as nC,GreaterEqualDepth as sC,GreaterDepth as oC,LessEqualDepth as rC,LessDepth as aC,NotEqualDepth as lC,EqualDepth as cC,BatchedMesh as Zy,MeshPhysicalMaterial as pm,UnsignedByteType as hC,LinearFilter as Ky,RingGeometry as dC,Line3 as uC,AdditiveBlending as Jy,BoxHelper as pC,SpotLight as mC,DirectionalLightHelper as gC,CameraHelper as fC,LOD as yC,Triangle as vC,NormalBlending as bC,NeutralToneMapping as Xl,AgXToneMapping as dd,ACESFilmicToneMapping as mm,ReinhardToneMapping as gm,LinearToneMapping as ud,HalfFloatType as _C,VideoTexture as wC,CubeTexture as xC,CompressedCubeTexture as SC,EquirectangularRefractionMapping as CC,VectorKeyframeTrack as OC,QuaternionKeyframeTrack as PC,Audio as kC,MirroredRepeatWrapping as ev,UniformsUtils as tv,ShaderLib as pd,MeshNormalMaterial as MC,AudioContext as RC,PMREMGenerator$1 as TC}from"./three.min.js";import{createLoaders as fm,getRaycastMesh as iv,LODsManager as va,NEEDLE_progressive as it,addDracoAndKTX2Loaders as EC,configureLoader as AC,setDracoDecoderLocation as IC,setKTX2TranscoderLocation as jC}from"./gltf-progressive.min.js";import{GroundedSkybox as ba,Font as LC,TextGeometry as DC,FontLoader as BC,GLTFLoader as ar,TransformControlsGizmo as nv,EXRLoader as md,RGBELoader as ym,Stats as FC,nodeFrame as zC,OrbitControls as sv,PositionalAudioHelper as UC,HorizontalBlurShader as NC,VerticalBlurShader as WC,GLTFExporter as ov,strToU8 as rv,zipSync as VC,XRControllerModelFactory as HC,XRHandMeshModel as $C,Line2 as GC,LineGeometry as qC,LineMaterial as XC,KTX2Loader as QC,TransformControls as YC,InteractiveGroup as ZC,HTMLMesh as KC,VertexNormalsHelper as JC,OBJLoader as vm,FBXLoader as av,mergeVertices as eO}from"./three-examples.min.js";import{fetchProfile as tO,MotionController as iO,$70d766613f57b014$export$2e2bcd8739ae039 as lv,ByteBuffer as nO,v5 as cv,md5 as hv,SIZE_PREFIX_LENGTH as dv,Builder as bm,createNoise4D as sO,Matrix4 as _m,BatchedParticleRenderer as oO,ParticleSystem as rO,RenderMode as _s,TrailParticle as uv,ConstantColor as aO,Vector4 as lO,ConstantValue as cO,WorkerBase as hO,WorkerWrapper as dO,MeshBVH as uO}from"./vendor.min.js";import{__webpack_exports__default as Te,__webpack_exports__Text as pv,__webpack_exports__Block as mv,__webpack_exports__update as pO,SimpleStateBehavior as mO,__webpack_exports__Inline as wm,__webpack_exports__FontLibrary as gv,ThreeMeshUI as fv}from"./three-mesh-ui.min.js";let yv,vv=null;function gn(){return yv}function xm(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}vv!==n&&(vv=n,yv=new n)}const Sm=new Map;function Xt(n=(t=>(t=globalThis.location)==null?void 0:t.hostname)()){if(Sm.has(n))return Sm.get(n);const t=/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|localhost/.test(n);return Sm.set(n,t),t===!0}function bv(){return window.location.hostname.includes("glitch.me")}const _v=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&&(_v&&console.warn("Registering context"),this.Registered.push(t),this.dispatchCallback("ContextRegistered",t))}static unregister(t){const i=this.Registered.indexOf(t);i!==-1&&(_v&&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 wv=()=>n=>n;function gO(n){return wv()(n)}function fO(){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 lr=!1;const Cm=new Array;typeof window<"u"&&setTimeout(()=>{if(lr){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 Cm){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=lr===!0?"":` (containing "${lr}")`;console.group("Available URL parameters:"+o);for(const r of Object.keys(n).sort())typeof lr=="string"&&!r.toLowerCase().includes(lr.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){lr&&!Cm.includes(n)&&Cm.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}lr=C("help");function yO(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?xv(n,s):Pm(n,s)}function Om(n,t,i){n.has(t)?n.set(t,i.toString()):n.append(t,i.toString())}function xv(n,t,i){window.history.pushState(i,n,"?"+t.toString())}function Pm(n,t,i){window.history.replaceState(i,n,"?"+t.toString())}function vO(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 bO(n,t){return Math.floor(Math.random()*(t-n+1))+n}const Sv=["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"],Cv=["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 Ov(){const n=Sv[Math.floor(Math.random()*Sv.length)],t=Cv[Math.floor(Math.random()*Cv.length)];return n+"_"+t}function Pv(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 gd=C("debugresolveurl"),kv="rel:";function _O(n,t){return lo(n,t)}function lo(n,t){if(t===void 0)return gd&&console.warn("getPath: uri is undefined, returning uri",t),t;if(t.startsWith("./"))return t;if(t.startsWith("http"))return gd&&console.warn("getPath: uri is absolute, returning uri",t),t;if(n===void 0)return gd&&console.warn("getPath: source is undefined, returning uri",t),t;t.startsWith(kv)&&(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 gd&&console.log("source:",n,`changed uri
from`,t,`
to `,o,`
basePath: `+s),o}return t}class wO{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 eo{constructor(t,i){if(a(this,"_watches",[]),Array.isArray(i))for(const s of i)this._watches.push(new eo(t,s));else this._watches.push(new wO(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 fd(n,t){if(!n[wa])if(n instanceof re)n[wa]=new eo(n,["x","y"]);else if(n instanceof x)n[wa]=new eo(n,["x","y","z"]);else if(n instanceof ye||n instanceof V)n[wa]=new eo(n,["x","y","z","w"]);else return!1;return n[wa].subscribeWrite(t),!0}function km(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 xO(){return Q.isDesktop()}function SO(){return Q.isMobileDevice()}function CO(){return Q.isiPad()}function OO(){return Q.isiPad()}function PO(){return Q.isAndroidDevice()}function kO(){return Q.isMozillaXR()}function MO(){return Q.isMacOS()}function RO(){return Q.isiOS()}function TO(){return Q.isSafari()}function EO(){return Q.isQuest()}async function AO(){return Q.microphonePermissionsGranted()}const IO=/ip=(?<ip>.+?)\n/s;async function jO(){const n=await(await fetch("https://www.cloudflare.com/cdn-cgi/trace")).text(),t=IO.exec(n);return t?t[1]:null}async function LO(){const n=await fetch("https://api.db-ip.com/v2/free/self").catch(()=>null);return n?(await n.json()).ipAddress:void 0}async function DO(){const n=await fetch("https://api.db-ip.com/v2/free/self").catch(()=>null);return n?await n.json():void 0}const co=new WeakMap;function Mv(n,t,i){if(!co.get(n)){const o=new MutationObserver(r=>{BO(n,r)});co.set(n,{observer:o,attributeChangedListeners:new Map}),o.observe(n,{attributes:!0})}const s=co.get(n).attributeChangedListeners;s.has(t)||s.set(t,[]),s.get(t).push(i)}function Rv(n,t,i){if(!co.get(n))return;const s=co.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=co.get(n);l?.observer.disconnect(),co.delete(n)}}function BO(n,t){const i=co.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 Mm{constructor(t){a(this,"reason"),this.reason=t}}async function Rm(n){const t=await Promise.allSettled(n).catch(o=>[new Mm(o.message)]);let i=!1;const s=t.map(o=>"value"in o?o.value:(i=!0,new Mm(o.reason)));return{anyFailed:i,results:s}}async function Tv(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 Ev=C("debugdebug");let Jl=!1;(C("noerrors")||C("nooverlaymessages"))&&(Jl=!0);const Tm="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 Em(){return Lv}const Am=new Array;function FO(n){Am.push(n)}let Im=!1;function zO(...n){if(!Im){Im=!0;try{for(let t=0;t<Am.length;t++)Am[t](...n)}catch(t){console.error(t)}Im=!1}}const Av=console.error,Iv=function(...n){Av.apply(console,n),WO(n),zn(2,n),jm(...n)};function jv(n){Jl=!n,n?console.error=Iv:console.error=Av}function UO(n){return jv(n)}function NO(){Jl||(Ev&&console.warn("Patch console",window.location.hostname),console.error=Iv,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}zn(2,t,n.filename,n.lineno),jm(n)},!0),window.addEventListener("unhandledrejection",n=>{Jl||n&&(n.reason?zn(2,n.reason.message,n.reason.stack):zn(2,"unhandled rejection"),jm(n))}))}let Lv=0;function jm(...n){Lv+=1,zO(...n)}function WO(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 zn(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||VO(n,r,t)}}const ec=new Map;function VO(n,t,i){if(i==null)return;const s=GO(t);if(s.childElementCount>=20){const c=s.lastElementChild;Bv(c)}i.length>400&&(i=i.substring(0,400)+"...");const o=i;if(ec.has(o))return;const r=qO(n,i);s.prepend(r);const l=()=>{ec.delete(o),Bv(r)};ec.set(o,l),setTimeout(l,1e4)}function HO(){Ev&&console.log("Clearing messages");for(const n of ec.values())n?.call(n);ec.clear()}const $O=`
@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 GO(n){globalThis[Tm]||(globalThis[Tm]=new Map);const t=globalThis[Tm];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=$O,i.appendChild(s),i}}const Dv=Symbol("logtype"),yd=new Map;function Bv(n){n.remove();const t=n[Dv],i=yd.get(t)??[];i.push(n),yd.set(t,i)}function qO(n,t){if(yd.has(n)){const s=yd.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[Dv]=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 XO{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 QO){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 QO=["x","y","z","w"],W=new XO;class Fv{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 vd{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 Fv(this.alpha(this.minCutOff)),this.dx=new Fv(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 Lm{constructor(t,i=1,s=0,o=1){a(this,"x"),a(this,"y"),a(this,"z"),this.x=new vd(t,i,s,o),this.y=new vd(t,i,s,o),this.z=new vd(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 bd="needle:cameraController";function zv(n){return n[bd]}function Dm(n,t,i){i?n[bd]=t:n[bd]===t&&(n[bd]=null)}const Bm="needle:autofit";function Uv(n){return n[Bm]===void 0?!0:n[Bm]!==!1}function _d(n,t){n[Bm]=t}function YO(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 Fm=new V,Nv=new V().setFromAxisAngle(new x(0,1,0),Math.PI);function ZO(n,t){n.lookAt(t),n.quaternion.multiply(Nv)}function tc(n,t,i=!0,s=!1){if(n===t)return;Fm.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(Gv(n));c.y=l,n.lookAt(c),n.quaternion.multiply(Nv)}Number.isNaN(n.quaternion.x)&&n.quaternion.copy(Fm);return}i&&(o.y=r.y),n.lookAt(o),Number.isNaN(n.quaternion.x)&&n.quaternion.copy(Fm)}function KO(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 JO=new Oi(()=>new x,100);function q(n,t,i){const s=JO.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 eP=new Oi(()=>new ce,30);function Wv(n){const t=eP.get();return n?t.copy(n):t.set(0,0,0),t}const tP=new Oi(()=>new V,100);function yn(n){const t=tP.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 zm=new Oi(()=>new x,100),Vv=Symbol("lastMatrixWorldUpdateKey");function te(n,t=null,i=!0){const s=t??zm.get();return n?n.parent?(i&&n.updateWorldMatrix(!0,!1),n.matrixWorldNeedsUpdate&&n[Vv]!==Date.now()&&(n[Vv]=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=zm.get();return t!==i&&i.copy(t),(n?.parent??n).worldToLocal(i),n.position.set(i.x,i.y,i.z),n}function cr(n,t,i,s){const o=zm.get();return o.set(t,i,s),dt(n,o),n}const wd=new Oi(()=>new V,100),hr=new V,Um=new V;function Ce(n,t=null){if(!n)return wd.get().identity();const i=t??wd.get();return n.parent?(n.getWorldQuaternion(i),i):i.copy(n.quaternion)}function Vi(n,t){if(!n)return;t!==hr&&hr.copy(t);const i=hr,s=n?.parent;s?.getWorldQuaternion(Um),Um.invert();const o=Um.multiply(i);n.quaternion.set(o.x,o.y,o.z,o.w)}function Nm(n,t,i,s,o){hr.set(t,i,s,o),Vi(n,hr)}const iP=new Oi(()=>new x,100),nP=new x;function Ye(n,t=null){return t||(t=iP.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=nP;n.parent.getWorldScale(i),n.scale.copy(t),n.scale.divide(i)}const sP=new x,Hv=new V;function oP(n){return Ce(n,Hv),sP.set(0,0,1).applyQuaternion(Hv)}const rP=new Oi(()=>new x,100),$v=new V;function Gv(n,t){return t||(t=rP.get().set(0,0,1)),Ce(n,$v),t.applyQuaternion($v)}const qv=new Bt,Xv=new Bt,aP=new x;function Wm(n){const t=wd.get();return n.getWorldQuaternion(t),Xv.setFromQuaternion(t),Xv}function Vm(n,t){const i=wd.get();Vi(n,i.setFromEuler(t))}function ic(n){const t=Wm(n),i=aP;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 Hm(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)),qv.set(t,i,s),hr.setFromEuler(qv),Vi(n,hr)}function xd(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 lP(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 Qv(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 io(null)},vertexShader:this.vertex,fragmentShader:t})}static copyTexture(t,i){this.blitMaterial||(this.blitMaterial=new mn({uniforms:{map:new io(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 or({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=Yv(t));const s=t.image;if(hP(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 Fn(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 Yv(n){return Hi.copyTexture(n)}function cP(n,t=!1){return Hi.textureToCanvas(n,t)}function hP(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 dP(n){const t=n.type;return t==="Mesh"||t==="SkinnedMesh"}function $m(n,t){t?n["needle:rendercustomshadow"]=!0:n["needle:rendercustomshadow"]=!1}function Zv(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&&Uv(h)!==!1&&!(h.type==="TransformControlsGizmo"||h.type==="TransformControlsPlane")){if(h instanceof Ny&&(d=!1),h instanceof sm&&(d=!1),h instanceof ba&&(d=!1),h.isGizmo===!0&&(d=!1),h.material instanceof Uy&&(d=!1),dP(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 Kv(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 Jv(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 Gm(n,t,i,s){if(Array.isArray(t)){let l=!0;for(let c=0;c<t.length;c++)Gm(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 Sd=!1;FO((...n)=>{var t;F()&&(t=pe.Current)!=null&&t.isInXR&&(dr(!0),eb("error",...n))});function dr(n){if(n){if(Sd)return;Sd=!0,pP()}else{if(!Sd)return;Sd=!1,mP()}}const sc={log:void 0,warn:void 0,error:void 0};class uP{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 Lm(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 pP(){vn||(vn=new uP),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,eb(n,...arguments)}finally{t=!1}}}}function mP(){vn?.onDisable();for(const n in sc)console[n]=sc[n]}const oc=new Map;function eb(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 Wy)return`[${r.elements.join(", ")}]`;if(r instanceof se)return`[${r.elements.join(", ")}]`;if(r instanceof no)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 gP=C("nodevlogs");function Be(n,t=Pi.Log){zn(t,n)}function _e(n){Be(n,Pi.Warn)}function rc(n){Be(n,Pi.Error)}let qm,Xm;function F(){if(gP)return!1;if(qm!==void 0)return qm;if(Xm!==void 0)return Xm;let n=Xt();return n||(n=window.location.hostname.endsWith(".local-credentialless.webcontainer.io")),Xm=n,n}function fP(n){qm=n}let ri,$i=null,Un=null,ac=!1,tb=null;const ib="terminal",lc=C("console"),yP=C("noerrors")||C("noconsole")||window.crossOriginIsolated;if(lc&&Ym(),!yP&&(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)&&(NO(),sb(),rb(!0),n)){const t=document.querySelector("needle-engine");t?.addEventListener("enter-ar",()=>{(lc||ri||Em()>0)&&C("noerrors")}),t?.addEventListener("exit-ar",()=>{wP()})}}const Qm=Symbol("consoleParent");function Ym(){if(ri){ri.showSwitch();return}rb()}function nb(){ri&&(ri.hide(),ri.hideSwitch())}function sb(){tb||(tb=setInterval(vP,500))}let ob=0;function vP(){const n=Em(),t=n!==ob;ob=n,t&&bP()}function bP(){Ym(),Un&&(Un.setAttribute("error","true"),Un.innerText="\u{1F92C}")}function _P(){Un&&(Un.removeAttribute("error"),Un.innerText=ib)}function wP(){$i&&$i[Qm]&&$i[Qm].appendChild($i)}function rb(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,sb(),ri=new VConsole({pluginOrder:["default","needle-console"]});const i=globalThis["needle:codegen_files"];if(i&&i.length>0&&ri.addPlugin(xP()),$i=CP(),$i&&($i[Qm]=$i.parentElement,$i.style.position="absolute",$i.style.zIndex=Number.MAX_SAFE_INTEGER.toString()),ri.setSwitchPosition(20,30),Un=SP(),Un){Un.innerText=ib,Un.addEventListener("click",_P);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&&Em()<=0&&nb(),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 xP(){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 SP(){return document.querySelector("#__vconsole .vc-switch")||null}function CP(){return document.querySelector("#__vconsole")||null}const ab=C("debugdefines");ho('if(!globalThis[""4.4.0-beta.5""]) globalThis[""4.4.0-beta.5""] = "0.0.0";'),ho('if(!globalThis[""undefined""]) globalThis[""undefined""] = "unknown";'),ho('if(!globalThis[""Tue Apr 08 2025 18:42:52 GMT+0200 (Central European Summer Time)""]) globalThis[""Tue Apr 08 2025 18:42:52 GMT+0200 (Central European Summer Time)""] = "unknown";'),ho('if(!globalThis[""npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9""]) globalThis[""npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9""] = "unknown";'),ho('globalThis["__NEEDLE_ENGINE_VERSION__"] = "4.4.0-beta.5";'),ho('globalThis["__NEEDLE_ENGINE_GENERATOR__"] = "undefined";'),ho('globalThis["__NEEDLE_PROJECT_BUILD_TIME__"] = "Tue Apr 08 2025 18:42:52 GMT+0200 (Central European Summer Time)";'),ho('globalThis["__NEEDLE_PUBLIC_KEY__"] = "npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9";');const bn="4.4.0-beta.5",Cd="undefined",Zm="Tue Apr 08 2025 18:42:52 GMT+0200 (Central European Summer Time)";ab&&console.log(`Engine version: ${bn} (generator: ${Cd})
Project built at ${Zm}`);const cc="npk_74222a9fbd1b42572cdd3bf7f639eeb17a07d07f40a6185fac5f722e8fd34df9",ws="needle_isActiveInHierarchy",ur="builtin_components",hc="needle_editor_guid";function ho(n){try{(0,eval)(n)}catch(t){ab&&console.error(t)}}const OP='<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="fi