@liveroom-tech/react-immersive 6.1.3 → 6.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/DownloadedEnvironment-NHM4U2LJ.mjs +1 -0
  2. package/dist/{SequencesTab-66VBWTO5.mjs → SequencesTab-VZKEKAUG.mjs} +1 -1
  3. package/dist/StreamingTilesModel-6Z7SIC2J.mjs +16 -0
  4. package/dist/binding-builder.css +1 -1
  5. package/dist/binding-builder.d.mts +3 -3
  6. package/dist/binding-builder.d.ts +3 -3
  7. package/dist/binding-builder.js +59 -58
  8. package/dist/binding-builder.mjs +1 -1
  9. package/dist/chunk-25WC5KDO.mjs +50 -0
  10. package/dist/chunk-2AJK643D.mjs +1 -0
  11. package/dist/chunk-3OCHN3CA.mjs +1 -0
  12. package/dist/chunk-7OVEHDDE.mjs +1 -0
  13. package/dist/chunk-KFLS7GI6.mjs +1 -0
  14. package/dist/{chunk-B75URXOE.mjs → chunk-KYXJG3TX.mjs} +1 -1
  15. package/dist/chunk-LD7QWHB4.mjs +3 -0
  16. package/dist/{chunk-LKKH4PO7.mjs → chunk-NMRTI3NQ.mjs} +1 -1
  17. package/dist/chunk-RKDATTUM.mjs +1 -0
  18. package/dist/chunk-RXZ4Q7CY.mjs +1 -0
  19. package/dist/chunk-TUYVYSN5.mjs +1 -0
  20. package/dist/chunk-UAZ6I25Y.mjs +1 -0
  21. package/dist/chunk-UCD76KQ6.mjs +1 -0
  22. package/dist/chunk-UHRJ2RBF.mjs +1 -0
  23. package/dist/chunk-UTVFRMYW.mjs +47 -0
  24. package/dist/chunk-YKDDNX2D.mjs +69 -0
  25. package/dist/exportSceneMesh-YJFOLFHS.mjs +1 -0
  26. package/dist/hosted.css +1 -1
  27. package/dist/hosted.d.mts +4 -4
  28. package/dist/hosted.d.ts +4 -4
  29. package/dist/hosted.js +58 -57
  30. package/dist/hosted.mjs +1 -1
  31. package/dist/index.css +1 -1
  32. package/dist/index.d.mts +4 -4
  33. package/dist/index.d.ts +4 -4
  34. package/dist/index.js +52 -51
  35. package/dist/index.mjs +1 -1
  36. package/dist/meshFormats-4C6NHYOA.mjs +1 -0
  37. package/dist/{modelViewerProps-Bo48RDq6.d.ts → modelFileResolver-CVmON8hg.d.mts} +459 -895
  38. package/dist/{modelViewerProps-DkvYb1GH.d.mts → modelFileResolver-CVmON8hg.d.ts} +459 -895
  39. package/dist/modelViewerProps-BBnZTFO-.d.ts +949 -0
  40. package/dist/modelViewerProps-CIY4nsNY.d.mts +949 -0
  41. package/dist/{publicProps-DJSccx3b.d.ts → publicProps-BARVwXu7.d.ts} +2 -1
  42. package/dist/{publicProps-DN0-8tBm.d.mts → publicProps-n0Yvr_Km.d.mts} +2 -1
  43. package/dist/simple-model-viewer.css +1 -1
  44. package/dist/simple-model-viewer.d.mts +35 -4
  45. package/dist/simple-model-viewer.d.ts +35 -4
  46. package/dist/simple-model-viewer.js +5 -5
  47. package/dist/simple-model-viewer.mjs +1 -1
  48. package/dist/utils.d.mts +4 -4
  49. package/dist/utils.d.ts +4 -4
  50. package/dist/utils.js +3 -3
  51. package/dist/utils.mjs +1 -1
  52. package/dist/xrRuntime-5S7KYUVB.mjs +1 -0
  53. package/package.json +7 -4
  54. package/dist/chunk-4RYMXBK6.mjs +0 -47
  55. package/dist/chunk-5P7ETEAN.mjs +0 -50
  56. package/dist/chunk-6Q6YZ7O5.mjs +0 -1
  57. package/dist/chunk-EC542N4J.mjs +0 -1
  58. package/dist/chunk-JK7GRGRG.mjs +0 -1
  59. package/dist/chunk-U3BQMOC3.mjs +0 -83
  60. package/dist/chunk-VMYNX63T.mjs +0 -3
  61. package/dist/modelFileResolver-B2B3F3d1.d.mts +0 -464
  62. package/dist/modelFileResolver-B2B3F3d1.d.ts +0 -464
@@ -0,0 +1 @@
1
+ import"./chunk-JR557W27.mjs";import{Environment as n}from"@react-three/drei";import{jsx as r}from"react/jsx-runtime";function t(o){return r(n,{...o})}export{t as default};
@@ -1 +1 @@
1
- import{e as ce}from"./chunk-AL6UIGWP.mjs";import{a as re,b as ne}from"./chunk-B75URXOE.mjs";import{e as U,f as se,h as oe,i as le}from"./chunk-FGAJ2UT7.mjs";import"./chunk-LKKH4PO7.mjs";import{a as ee,b as te,c as $,d as ae,e as L,g as ie}from"./chunk-LX3GXQNU.mjs";import"./chunk-EC542N4J.mjs";import"./chunk-JR557W27.mjs";import{useEffect as be,useMemo as Te,useRef as we,useState as S}from"react";import{Copy as je,DiamondPlus as Ie,Plus as _,ScanLine as Ee,Trash2 as G}from"lucide-react";import{useEffect as de,useState as pe}from"react";import{Fragment as ue,jsx as g,jsxs as T}from"react/jsx-runtime";function j({label:p,value:o,onChange:r,min:l,max:u,step:f=.1,disabled:q=!1}){let[y,d]=pe(String(Number(o.toFixed(5))));return de(()=>d(String(Number(o.toFixed(5)))),[o]),T("label",{className:"sq-field",children:[g("span",{children:p}),g("input",{type:"number","aria-label":p,value:y,step:f,min:l,max:u,disabled:q,onChange:m=>d(m.target.value),onBlur:()=>{let m=y.trim()?Number(y):NaN;Number.isFinite(m)&&(l===void 0||m>=l)&&(u===void 0||m<=u)&&m!==o&&r(m),d(String(Number(o.toFixed(5))))},onKeyDown:m=>{m.stopPropagation(),m.key==="Enter"&&m.currentTarget.blur(),m.key==="Escape"&&(m.preventDefault(),d(String(o)))}})]})}function X({label:p,value:o,onChange:r}){let[l,u]=pe(o);return de(()=>u(o),[o]),T("label",{className:"sq-field",children:[g("span",{children:p}),g("input",{"aria-label":p,value:l,maxLength:256,onChange:f=>u(f.target.value),onBlur:()=>{l.trim()&&l.trim()!==o?r(l.trim()):u(o)},onKeyDown:f=>{f.stopPropagation(),f.key==="Enter"&&f.currentTarget.blur()}})]})}function H({label:p,value:o,onChange:r,degrees:l=!1}){return T("fieldset",{className:"sq-vector",children:[T("legend",{children:[p,l?" (\xB0)":""]}),g("div",{children:o.map((u,f)=>g(j,{label:["X","Y","Z"][f],value:l?u*180/Math.PI:u,onChange:q=>r(o.map((y,d)=>f===d?l?q*Math.PI/180:q:y))},f))})]})}function me({target:p,value:o,onChange:r}){if(p.kind==="camera"){let l=o;return T(ue,{children:[g(H,{label:"Camera position",value:l.position,onChange:u=>r({...l,position:u})}),g(H,{label:"Camera target",value:l.target,onChange:u=>r({...l,target:u})}),T(ue,{children:[l.fov!==null&&g(j,{label:"FOV (\xB0)",min:1,max:179,value:l.fov,onChange:u=>r({...l,fov:u})}),g(j,{label:"Zoom",min:.001,value:l.zoom,onChange:u=>r({...l,zoom:u})})]})]})}return Array.isArray(o)?g(H,{label:p.kind==="object"?p.property[0].toUpperCase()+p.property.slice(1):"Value",value:o,degrees:p.kind==="object"&&p.property==="rotation",onChange:r}):typeof o=="boolean"?T("label",{className:"sq-check",children:[g("input",{type:"checkbox",checked:o,onChange:l=>r(l.target.checked)}),"Visible"]}):typeof o=="string"?T("label",{className:"sq-field sq-color",children:[g("span",{children:"Color"}),g("input",{type:"color","aria-label":"Keyframe color",value:o,onChange:l=>r(l.target.value)}),g("code",{children:o})]}):g(j,{label:p.kind==="clip"?"Clip time (s)":"Value",min:0,max:p.kind==="object"&&p.property!=="emissiveIntensity"?1:void 0,step:.01,value:o,onChange:r})}import{Fragment as fe,jsx as t,jsxs as s}from"react/jsx-runtime";var I=()=>crypto.randomUUID(),ge={position:"Position",rotation:"Rotation",scale:"Scale",visible:"Visibility",baseColor:"Color",emissive:"Emissive color",opacity:"Opacity",roughness:"Roughness",metalness:"Metalness",emissiveIntensity:"Emissive intensity"},Pe={linear:"Linear","ease-in":"Ease in","ease-out":"Ease out","ease-in-out":"Ease in / out",step:"Hold / step"};function Ae({config:p,onChange:o,controls:r,bindings:l,clipDetails:u}){let{tier:f}=oe(),q=re(r),y=Te(()=>{try{return{sequences:L(p.sequences??[]),error:""}}catch(e){return{sequences:[],error:e instanceof Error?e.message:"Invalid sequence data."}}},[p.sequences]),d=y.sequences,[Q,m]=S(null),[qe,N]=S(null),[ke,x]=S(null),[w,he]=S("object"),[ve,ye]=S(""),[V,xe]=S("position"),[Y,Se]=S(""),[Z,P]=S(""),[D,K]=S(null),A=we(null),i=d.find(e=>e.id===Q)??d[0],c=i?.tracks.find(e=>e.id===qe)??i?.tracks[0],h=c?.keyframes.find(e=>e.id===ke)??c?.keyframes[0],B=Object.values(l).filter((e,a,k)=>!e.removed&&k.findIndex(n=>n.modelObjectId===e.modelObjectId)===a),M=B.find(e=>e.modelObjectId===ve)??B[0],R=u.some(e=>e.sourceName===Y)?Y:u[0]?.sourceName;be(()=>{i&&r&&q.sequenceId!==i.id&&r.select(i.id)},[r,i?.id,q]),be(()=>()=>r?.stop(),[r]);let O=e=>{try{let a=L(e);o({...p,sequences:a}),P("")}catch(a){P(a instanceof Error?a.message:"Invalid sequence.")}},E=e=>O(d.map(a=>a.id===e.id?e:a)),z=e=>{i&&E({...i,tracks:i.tracks.map(a=>a.id===e.id?e:a)})},C=(e,a)=>{if(!i||!ae(a.value,e.target)){P("Use a valid value; scale components must be nonzero.");return}z(ie(e,{...a,time:Math.max(0,Math.min(i.duration,a.time))})),N(e.id),x(a.id),r?.pause(),r?.seek(a.time)},J=()=>{if(d.length>=64)return;let e={id:I(),name:`Sequence ${d.length+1}`,duration:5,loop:!1,autoPlay:!1,tracks:[]};O([...d,e]),m(e.id),N(null),x(null)},v=w==="camera"?{kind:"camera"}:w==="clip"?R?{kind:"clip",clip:R}:null:M?{kind:"object",objectId:M.modelObjectId,property:V}:null,F=!!v&&i?.tracks.some(e=>$(e.target)===$(v)),Ne=()=>{if(!i||!v||F)return;let e=r?.capture(v);if(e==null){P("That target is not ready. Wait for the model, or choose another object/clip.");return}let a=v.kind==="clip"?Math.min(i.duration,u.find(n=>n.sourceName===v.clip)?.duration??i.duration):structuredClone(e),k={id:I(),name:v.kind==="camera"?"Camera":v.kind==="clip"?v.clip:`${M?.label||M?.modelObjectId} \xB7 ${ge[V]}`,target:v,keyframes:[{id:I(),time:0,value:e,easing:V==="visible"&&w==="object"?"step":"ease-in-out"},{id:I(),time:i.duration,value:a}]};E({...i,tracks:[...i.tracks,k]}),N(k.id),x(k.keyframes[1].id),r?.seek(i.duration)},Ce=()=>{if(!c||!i||c.keyframes.length>=2048)return;let e=r?.capture(c.target);if(e==null){P("The selected target is unavailable.");return}let a={id:I(),time:Math.min(q.time,i.duration),value:e,easing:"ease-in-out"};C(c,a)};return s("section",{className:"sq-editor","aria-label":"Visual sequence authoring",children:[y.error&&t("p",{role:"alert",className:"sq-error",children:y.error}),U(f,"sequences",d.length)?null:t(le,{requiredTier:se("sequences",d.length),feature:"More sequences"}),i?s(fe,{children:[s("div",{className:"sq-toolbar",children:[t("select",{className:"se-select sq-toolbarPicker","aria-label":"Authored sequence",value:i.id,onChange:e=>{m(e.target.value),N(null),x(null),r?.select(e.target.value)},children:d.map(e=>t("option",{value:e.id,children:e.name},e.id))}),t("button",{type:"button",className:"se-iconButton",title:"Add sequence","aria-label":"Add sequence",disabled:d.length>=64||!U(f,"sequences",d.length),onClick:J,children:t(_,{size:14})}),t("button",{type:"button",className:"se-iconButton",title:"Duplicate sequence","aria-label":"Duplicate sequence",disabled:d.length>=64,onClick:()=>{let e={...structuredClone(i),id:I(),name:`${i.name} copy`.slice(0,256),autoPlay:!1};O([...d,e]),m(e.id)},children:t(je,{size:13})}),t("button",{type:"button",className:"se-iconButton",title:"Delete sequence","aria-label":"Delete sequence",onClick:()=>{r?.stop(),O(d.filter(e=>e.id!==i.id)),m(null)},children:t(G,{size:13})}),t("span",{className:"sq-toolbarDivider"}),t(X,{label:"Name",value:i.name,onChange:e=>E({...i,name:e})}),t(j,{label:"Duration",min:.1,max:3600,value:i.duration,onChange:e=>E({...i,duration:e,tracks:i.tracks.map(a=>({...a,keyframes:a.keyframes.map(k=>({...k,time:k.time/i.duration*e}))}))})}),s("label",{className:"sq-check",children:[t("input",{type:"checkbox",checked:i.loop,onChange:e=>E({...i,loop:e.target.checked})}),"Loop"]}),s("label",{className:"sq-check",children:[t("input",{type:"checkbox",checked:i.autoPlay,onChange:e=>O(d.map(a=>({...a,autoPlay:a.id===i.id?e.target.checked:!1})))}),"Autoplay"]})]}),s("div",{className:"sq-body",children:[s("div",{className:"sq-main",children:[t(ne,{controls:r,duration:i.duration,hasTracks:i.tracks.some(e=>!e.muted&&e.keyframes.length>0)}),s("div",{className:"sq-timeline","aria-label":"Sequence timeline",title:"Drag keys to retime. Arrow keys move 0.1s; Shift moves 0.01s. A key at the same time is replaced.",children:[s("div",{className:"sq-ruler",children:[t("span",{className:"sq-rulerTitle",children:"Tracks"}),t("div",{className:"sq-rulerScale",children:[0,.25,.5,.75,1].map(e=>s("span",{children:[(i.duration*e).toFixed(1),"s"]},e))})]}),!i.tracks.length&&t("p",{className:"sq-hint",children:"Add a track to create its start and end keyframes."}),i.tracks.map(e=>s("div",{className:`sq-track ${c?.id===e.id?"sq-track--active":""}`,children:[s("div",{className:"sq-trackLabel",children:[t("button",{type:"button",title:e.name,onClick:()=>{N(e.id),x(e.keyframes[0]?.id??null)},children:e.name}),s("label",{title:"Mute track",children:[t("input",{"aria-label":`Mute ${e.name}`,type:"checkbox",checked:!!e.muted,onChange:a=>z({...e,muted:a.target.checked})}),"Mute"]})]}),s("div",{className:"sq-lane",role:"group","aria-label":`${e.name} keyframes`,onDoubleClick:a=>{if(a.target!==a.currentTarget)return;let k=a.currentTarget.getBoundingClientRect(),n=Math.round(Math.max(0,Math.min(1,(a.clientX-k.left)/k.width))*i.duration*100)/100,b=r?.capture(e.target);b!=null&&C(e,{id:I(),time:n,value:b})},children:[t("span",{className:"sq-playhead",style:{left:`${q.time/i.duration*100}%`}}),e.keyframes.map(a=>{let k=D?.frameId===a.id&&D.trackId===e.id?D.time:a.time;return t("button",{type:"button",className:`sq-key ${h?.id===a.id&&c?.id===e.id?"sq-key--active":""}`,style:{left:`${k/i.duration*100}%`},"aria-label":`${e.name} keyframe at ${k.toFixed(2)} seconds`,"aria-pressed":h?.id===a.id&&c?.id===e.id,onClick:n=>{n.detail===0&&(N(e.id),x(a.id),r?.pause(),r?.seek(a.time))},onPointerDown:n=>{if(n.button!==0)return;n.preventDefault(),n.stopPropagation(),n.currentTarget.focus(),n.currentTarget.setPointerCapture(n.pointerId);let b=n.currentTarget.parentElement.getBoundingClientRect();A.current={track:e,frame:a,left:b.left,width:b.width,time:a.time},N(e.id),x(a.id),r?.pause(),r?.seek(a.time)},onPointerMove:n=>{let b=A.current;if(!b||b.frame.id!==a.id||b.track.id!==e.id)return;let W=n.shiftKey?.01:.1;b.time=Math.min(i.duration,Math.max(0,Math.round((n.clientX-b.left)/b.width*i.duration/W)*W)),K({trackId:e.id,frameId:a.id,time:b.time}),r?.seek(b.time)},onPointerUp:()=>{let n=A.current;n&&(n.time!==n.frame.time&&C(n.track,{...n.frame,time:n.time}),A.current=null,K(null))},onPointerCancel:()=>{A.current=null,K(null),r?.seek(a.time)},onKeyDown:n=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(n.key))return;n.preventDefault(),n.stopPropagation();let b=n.key==="Home"?0:n.key==="End"?i.duration:a.time+(n.key==="ArrowLeft"?-1:1)*(n.shiftKey?.01:.1);C(e,{...a,time:b})}},a.id)})]})]},e.id))]})]}),s("aside",{className:"sq-side",children:[s(ce,{title:"Add track",children:[s("label",{className:"sq-field",children:[t("span",{children:"Type"}),s("select",{"aria-label":"Track type",value:w,onChange:e=>he(e.target.value),children:[t("option",{value:"object",children:"Object"}),t("option",{value:"camera",children:"Camera"}),t("option",{value:"clip",children:"Animation clip"})]})]}),w==="object"&&s("label",{className:"sq-field",children:[t("span",{children:"Property"}),t("select",{"aria-label":"Track property",value:V,onChange:e=>xe(e.target.value),children:ee.map(e=>t("option",{value:e,children:ge[e]},e))})]}),w==="object"&&s("label",{className:"sq-field",children:[t("span",{children:"Object"}),t("select",{"aria-label":"Track object",value:M?.modelObjectId??"",onChange:e=>ye(e.target.value),children:B.map(e=>t("option",{value:e.modelObjectId,children:e.label||e.modelObjectId},e.modelObjectId))})]}),w==="clip"&&s("label",{className:"sq-field",children:[t("span",{children:"Clip"}),t("select",{"aria-label":"Track animation clip",value:R??"",onChange:e=>Se(e.target.value),children:u.map(e=>t("option",{value:e.sourceName,children:e.sourceName},e.sourceName))}),!u.length&&t("small",{children:"This model has no animation clips."})]}),t("div",{className:"rui-actions",children:s("button",{type:"button",className:"bb-button",onClick:Ne,disabled:!v||!q.ready||F||i.tracks.length>=128,children:[t(_,{size:13,"aria-hidden":"true"}),"Add track"]})}),F&&t("p",{className:"rui-note",children:"That property already has a track."})]}),c&&s("section",{className:"sq-inspector","aria-label":"Selected track and keyframe",children:[s("div",{className:"rui-groupHeader",children:[t("span",{children:"Selected track"}),t("button",{type:"button",className:"se-iconButton",title:"Delete track","aria-label":"Delete track",onClick:()=>{E({...i,tracks:i.tracks.filter(e=>e.id!==c.id)}),N(null),x(null)},children:t(G,{size:13})})]}),t(X,{label:"Name",value:c.name,onChange:e=>z({...c,name:e})}),t("div",{className:"rui-actions",children:s("button",{type:"button",className:"bb-button",disabled:!q.ready||c.keyframes.length>=2048,onClick:Ce,children:[t(Ie,{size:13,"aria-hidden":"true"}),"Add keyframe at playhead"]})}),h&&s(fe,{children:[s("div",{className:"rui-groupHeader",children:[t("span",{children:"Keyframe"}),t("button",{type:"button",className:"se-iconButton",title:"Delete keyframe","aria-label":"Delete keyframe",onClick:()=>{z({...c,keyframes:c.keyframes.filter(e=>e.id!==h.id)}),x(null)},children:t(G,{size:14})})]}),t(j,{label:"Time",min:0,max:i.duration,value:h.time,step:.01,onChange:e=>C(c,{...h,time:e})}),s("label",{className:"sq-field",children:[t("span",{children:"Easing"}),t("select",{"aria-label":"Keyframe easing",value:c.target.kind==="object"&&c.target.property==="visible"?"step":h.easing??"ease-in-out",disabled:c.target.kind==="object"&&c.target.property==="visible",onChange:e=>C(c,{...h,easing:e.target.value}),children:te.map(e=>t("option",{value:e,children:Pe[e]},e))})]}),t(me,{target:c.target,value:h.value,onChange:e=>C(c,{...h,value:e})}),t("div",{className:"rui-actions",children:s("button",{type:"button",className:"bb-button",disabled:!q.ready,onClick:()=>{let e=r?.capture(c.target);e!=null&&C(c,{...h,value:e})},children:[t(Ee,{size:13,"aria-hidden":"true"}),"Capture current value"]})})]})]})]})]})]}):s("div",{className:"sq-empty",children:[t("p",{children:"Add a sequence, then add tracks and capture keyframes on the timeline."}),s("button",{type:"button",className:"bb-button bb-button--primary",onClick:J,children:[t(_,{size:13,"aria-hidden":"true"}),"Create sequence"]})]}),(Z||q.issues.length>0)&&t("div",{role:"status",className:"sq-error",children:Z||q.issues.join(" ")})]})}export{Ae as default};
1
+ import{e as ce}from"./chunk-AL6UIGWP.mjs";import{a as re,b as ne}from"./chunk-KYXJG3TX.mjs";import{e as U,f as se,h as oe,i as le}from"./chunk-FGAJ2UT7.mjs";import"./chunk-NMRTI3NQ.mjs";import{a as ee,b as te,c as $,d as ae,e as L,g as ie}from"./chunk-LX3GXQNU.mjs";import"./chunk-UAZ6I25Y.mjs";import"./chunk-JR557W27.mjs";import{useEffect as be,useMemo as Te,useRef as we,useState as S}from"react";import{Copy as je,DiamondPlus as Ie,Plus as _,ScanLine as Ee,Trash2 as G}from"lucide-react";import{useEffect as de,useState as pe}from"react";import{Fragment as ue,jsx as g,jsxs as T}from"react/jsx-runtime";function j({label:p,value:o,onChange:r,min:l,max:u,step:f=.1,disabled:q=!1}){let[y,d]=pe(String(Number(o.toFixed(5))));return de(()=>d(String(Number(o.toFixed(5)))),[o]),T("label",{className:"sq-field",children:[g("span",{children:p}),g("input",{type:"number","aria-label":p,value:y,step:f,min:l,max:u,disabled:q,onChange:m=>d(m.target.value),onBlur:()=>{let m=y.trim()?Number(y):NaN;Number.isFinite(m)&&(l===void 0||m>=l)&&(u===void 0||m<=u)&&m!==o&&r(m),d(String(Number(o.toFixed(5))))},onKeyDown:m=>{m.stopPropagation(),m.key==="Enter"&&m.currentTarget.blur(),m.key==="Escape"&&(m.preventDefault(),d(String(o)))}})]})}function X({label:p,value:o,onChange:r}){let[l,u]=pe(o);return de(()=>u(o),[o]),T("label",{className:"sq-field",children:[g("span",{children:p}),g("input",{"aria-label":p,value:l,maxLength:256,onChange:f=>u(f.target.value),onBlur:()=>{l.trim()&&l.trim()!==o?r(l.trim()):u(o)},onKeyDown:f=>{f.stopPropagation(),f.key==="Enter"&&f.currentTarget.blur()}})]})}function H({label:p,value:o,onChange:r,degrees:l=!1}){return T("fieldset",{className:"sq-vector",children:[T("legend",{children:[p,l?" (\xB0)":""]}),g("div",{children:o.map((u,f)=>g(j,{label:["X","Y","Z"][f],value:l?u*180/Math.PI:u,onChange:q=>r(o.map((y,d)=>f===d?l?q*Math.PI/180:q:y))},f))})]})}function me({target:p,value:o,onChange:r}){if(p.kind==="camera"){let l=o;return T(ue,{children:[g(H,{label:"Camera position",value:l.position,onChange:u=>r({...l,position:u})}),g(H,{label:"Camera target",value:l.target,onChange:u=>r({...l,target:u})}),T(ue,{children:[l.fov!==null&&g(j,{label:"FOV (\xB0)",min:1,max:179,value:l.fov,onChange:u=>r({...l,fov:u})}),g(j,{label:"Zoom",min:.001,value:l.zoom,onChange:u=>r({...l,zoom:u})})]})]})}return Array.isArray(o)?g(H,{label:p.kind==="object"?p.property[0].toUpperCase()+p.property.slice(1):"Value",value:o,degrees:p.kind==="object"&&p.property==="rotation",onChange:r}):typeof o=="boolean"?T("label",{className:"sq-check",children:[g("input",{type:"checkbox",checked:o,onChange:l=>r(l.target.checked)}),"Visible"]}):typeof o=="string"?T("label",{className:"sq-field sq-color",children:[g("span",{children:"Color"}),g("input",{type:"color","aria-label":"Keyframe color",value:o,onChange:l=>r(l.target.value)}),g("code",{children:o})]}):g(j,{label:p.kind==="clip"?"Clip time (s)":"Value",min:0,max:p.kind==="object"&&p.property!=="emissiveIntensity"?1:void 0,step:.01,value:o,onChange:r})}import{Fragment as fe,jsx as t,jsxs as s}from"react/jsx-runtime";var I=()=>crypto.randomUUID(),ge={position:"Position",rotation:"Rotation",scale:"Scale",visible:"Visibility",baseColor:"Color",emissive:"Emissive color",opacity:"Opacity",roughness:"Roughness",metalness:"Metalness",emissiveIntensity:"Emissive intensity"},Pe={linear:"Linear","ease-in":"Ease in","ease-out":"Ease out","ease-in-out":"Ease in / out",step:"Hold / step"};function Ae({config:p,onChange:o,controls:r,bindings:l,clipDetails:u}){let{tier:f}=oe(),q=re(r),y=Te(()=>{try{return{sequences:L(p.sequences??[]),error:""}}catch(e){return{sequences:[],error:e instanceof Error?e.message:"Invalid sequence data."}}},[p.sequences]),d=y.sequences,[Q,m]=S(null),[qe,N]=S(null),[ke,x]=S(null),[w,he]=S("object"),[ve,ye]=S(""),[V,xe]=S("position"),[Y,Se]=S(""),[Z,P]=S(""),[D,K]=S(null),A=we(null),i=d.find(e=>e.id===Q)??d[0],c=i?.tracks.find(e=>e.id===qe)??i?.tracks[0],h=c?.keyframes.find(e=>e.id===ke)??c?.keyframes[0],B=Object.values(l).filter((e,a,k)=>!e.removed&&k.findIndex(n=>n.modelObjectId===e.modelObjectId)===a),M=B.find(e=>e.modelObjectId===ve)??B[0],R=u.some(e=>e.sourceName===Y)?Y:u[0]?.sourceName;be(()=>{i&&r&&q.sequenceId!==i.id&&r.select(i.id)},[r,i?.id,q]),be(()=>()=>r?.stop(),[r]);let O=e=>{try{let a=L(e);o({...p,sequences:a}),P("")}catch(a){P(a instanceof Error?a.message:"Invalid sequence.")}},E=e=>O(d.map(a=>a.id===e.id?e:a)),z=e=>{i&&E({...i,tracks:i.tracks.map(a=>a.id===e.id?e:a)})},C=(e,a)=>{if(!i||!ae(a.value,e.target)){P("Use a valid value; scale components must be nonzero.");return}z(ie(e,{...a,time:Math.max(0,Math.min(i.duration,a.time))})),N(e.id),x(a.id),r?.pause(),r?.seek(a.time)},J=()=>{if(d.length>=64)return;let e={id:I(),name:`Sequence ${d.length+1}`,duration:5,loop:!1,autoPlay:!1,tracks:[]};O([...d,e]),m(e.id),N(null),x(null)},v=w==="camera"?{kind:"camera"}:w==="clip"?R?{kind:"clip",clip:R}:null:M?{kind:"object",objectId:M.modelObjectId,property:V}:null,F=!!v&&i?.tracks.some(e=>$(e.target)===$(v)),Ne=()=>{if(!i||!v||F)return;let e=r?.capture(v);if(e==null){P("That target is not ready. Wait for the model, or choose another object/clip.");return}let a=v.kind==="clip"?Math.min(i.duration,u.find(n=>n.sourceName===v.clip)?.duration??i.duration):structuredClone(e),k={id:I(),name:v.kind==="camera"?"Camera":v.kind==="clip"?v.clip:`${M?.label||M?.modelObjectId} \xB7 ${ge[V]}`,target:v,keyframes:[{id:I(),time:0,value:e,easing:V==="visible"&&w==="object"?"step":"ease-in-out"},{id:I(),time:i.duration,value:a}]};E({...i,tracks:[...i.tracks,k]}),N(k.id),x(k.keyframes[1].id),r?.seek(i.duration)},Ce=()=>{if(!c||!i||c.keyframes.length>=2048)return;let e=r?.capture(c.target);if(e==null){P("The selected target is unavailable.");return}let a={id:I(),time:Math.min(q.time,i.duration),value:e,easing:"ease-in-out"};C(c,a)};return s("section",{className:"sq-editor","aria-label":"Visual sequence authoring",children:[y.error&&t("p",{role:"alert",className:"sq-error",children:y.error}),U(f,"sequences",d.length)?null:t(le,{requiredTier:se("sequences",d.length),feature:"More sequences"}),i?s(fe,{children:[s("div",{className:"sq-toolbar",children:[t("select",{className:"se-select sq-toolbarPicker","aria-label":"Authored sequence",value:i.id,onChange:e=>{m(e.target.value),N(null),x(null),r?.select(e.target.value)},children:d.map(e=>t("option",{value:e.id,children:e.name},e.id))}),t("button",{type:"button",className:"se-iconButton",title:"Add sequence","aria-label":"Add sequence",disabled:d.length>=64||!U(f,"sequences",d.length),onClick:J,children:t(_,{size:14})}),t("button",{type:"button",className:"se-iconButton",title:"Duplicate sequence","aria-label":"Duplicate sequence",disabled:d.length>=64,onClick:()=>{let e={...structuredClone(i),id:I(),name:`${i.name} copy`.slice(0,256),autoPlay:!1};O([...d,e]),m(e.id)},children:t(je,{size:13})}),t("button",{type:"button",className:"se-iconButton",title:"Delete sequence","aria-label":"Delete sequence",onClick:()=>{r?.stop(),O(d.filter(e=>e.id!==i.id)),m(null)},children:t(G,{size:13})}),t("span",{className:"sq-toolbarDivider"}),t(X,{label:"Name",value:i.name,onChange:e=>E({...i,name:e})}),t(j,{label:"Duration",min:.1,max:3600,value:i.duration,onChange:e=>E({...i,duration:e,tracks:i.tracks.map(a=>({...a,keyframes:a.keyframes.map(k=>({...k,time:k.time/i.duration*e}))}))})}),s("label",{className:"sq-check",children:[t("input",{type:"checkbox",checked:i.loop,onChange:e=>E({...i,loop:e.target.checked})}),"Loop"]}),s("label",{className:"sq-check",children:[t("input",{type:"checkbox",checked:i.autoPlay,onChange:e=>O(d.map(a=>({...a,autoPlay:a.id===i.id?e.target.checked:!1})))}),"Autoplay"]})]}),s("div",{className:"sq-body",children:[s("div",{className:"sq-main",children:[t(ne,{controls:r,duration:i.duration,hasTracks:i.tracks.some(e=>!e.muted&&e.keyframes.length>0)}),s("div",{className:"sq-timeline","aria-label":"Sequence timeline",title:"Drag keys to retime. Arrow keys move 0.1s; Shift moves 0.01s. A key at the same time is replaced.",children:[s("div",{className:"sq-ruler",children:[t("span",{className:"sq-rulerTitle",children:"Tracks"}),t("div",{className:"sq-rulerScale",children:[0,.25,.5,.75,1].map(e=>s("span",{children:[(i.duration*e).toFixed(1),"s"]},e))})]}),!i.tracks.length&&t("p",{className:"sq-hint",children:"Add a track to create its start and end keyframes."}),i.tracks.map(e=>s("div",{className:`sq-track ${c?.id===e.id?"sq-track--active":""}`,children:[s("div",{className:"sq-trackLabel",children:[t("button",{type:"button",title:e.name,onClick:()=>{N(e.id),x(e.keyframes[0]?.id??null)},children:e.name}),s("label",{title:"Mute track",children:[t("input",{"aria-label":`Mute ${e.name}`,type:"checkbox",checked:!!e.muted,onChange:a=>z({...e,muted:a.target.checked})}),"Mute"]})]}),s("div",{className:"sq-lane",role:"group","aria-label":`${e.name} keyframes`,onDoubleClick:a=>{if(a.target!==a.currentTarget)return;let k=a.currentTarget.getBoundingClientRect(),n=Math.round(Math.max(0,Math.min(1,(a.clientX-k.left)/k.width))*i.duration*100)/100,b=r?.capture(e.target);b!=null&&C(e,{id:I(),time:n,value:b})},children:[t("span",{className:"sq-playhead",style:{left:`${q.time/i.duration*100}%`}}),e.keyframes.map(a=>{let k=D?.frameId===a.id&&D.trackId===e.id?D.time:a.time;return t("button",{type:"button",className:`sq-key ${h?.id===a.id&&c?.id===e.id?"sq-key--active":""}`,style:{left:`${k/i.duration*100}%`},"aria-label":`${e.name} keyframe at ${k.toFixed(2)} seconds`,"aria-pressed":h?.id===a.id&&c?.id===e.id,onClick:n=>{n.detail===0&&(N(e.id),x(a.id),r?.pause(),r?.seek(a.time))},onPointerDown:n=>{if(n.button!==0)return;n.preventDefault(),n.stopPropagation(),n.currentTarget.focus(),n.currentTarget.setPointerCapture(n.pointerId);let b=n.currentTarget.parentElement.getBoundingClientRect();A.current={track:e,frame:a,left:b.left,width:b.width,time:a.time},N(e.id),x(a.id),r?.pause(),r?.seek(a.time)},onPointerMove:n=>{let b=A.current;if(!b||b.frame.id!==a.id||b.track.id!==e.id)return;let W=n.shiftKey?.01:.1;b.time=Math.min(i.duration,Math.max(0,Math.round((n.clientX-b.left)/b.width*i.duration/W)*W)),K({trackId:e.id,frameId:a.id,time:b.time}),r?.seek(b.time)},onPointerUp:()=>{let n=A.current;n&&(n.time!==n.frame.time&&C(n.track,{...n.frame,time:n.time}),A.current=null,K(null))},onPointerCancel:()=>{A.current=null,K(null),r?.seek(a.time)},onKeyDown:n=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(n.key))return;n.preventDefault(),n.stopPropagation();let b=n.key==="Home"?0:n.key==="End"?i.duration:a.time+(n.key==="ArrowLeft"?-1:1)*(n.shiftKey?.01:.1);C(e,{...a,time:b})}},a.id)})]})]},e.id))]})]}),s("aside",{className:"sq-side",children:[s(ce,{title:"Add track",children:[s("label",{className:"sq-field",children:[t("span",{children:"Type"}),s("select",{"aria-label":"Track type",value:w,onChange:e=>he(e.target.value),children:[t("option",{value:"object",children:"Object"}),t("option",{value:"camera",children:"Camera"}),t("option",{value:"clip",children:"Animation clip"})]})]}),w==="object"&&s("label",{className:"sq-field",children:[t("span",{children:"Property"}),t("select",{"aria-label":"Track property",value:V,onChange:e=>xe(e.target.value),children:ee.map(e=>t("option",{value:e,children:ge[e]},e))})]}),w==="object"&&s("label",{className:"sq-field",children:[t("span",{children:"Object"}),t("select",{"aria-label":"Track object",value:M?.modelObjectId??"",onChange:e=>ye(e.target.value),children:B.map(e=>t("option",{value:e.modelObjectId,children:e.label||e.modelObjectId},e.modelObjectId))})]}),w==="clip"&&s("label",{className:"sq-field",children:[t("span",{children:"Clip"}),t("select",{"aria-label":"Track animation clip",value:R??"",onChange:e=>Se(e.target.value),children:u.map(e=>t("option",{value:e.sourceName,children:e.sourceName},e.sourceName))}),!u.length&&t("small",{children:"This model has no animation clips."})]}),t("div",{className:"rui-actions",children:s("button",{type:"button",className:"bb-button",onClick:Ne,disabled:!v||!q.ready||F||i.tracks.length>=128,children:[t(_,{size:13,"aria-hidden":"true"}),"Add track"]})}),F&&t("p",{className:"rui-note",children:"That property already has a track."})]}),c&&s("section",{className:"sq-inspector","aria-label":"Selected track and keyframe",children:[s("div",{className:"rui-groupHeader",children:[t("span",{children:"Selected track"}),t("button",{type:"button",className:"se-iconButton",title:"Delete track","aria-label":"Delete track",onClick:()=>{E({...i,tracks:i.tracks.filter(e=>e.id!==c.id)}),N(null),x(null)},children:t(G,{size:13})})]}),t(X,{label:"Name",value:c.name,onChange:e=>z({...c,name:e})}),t("div",{className:"rui-actions",children:s("button",{type:"button",className:"bb-button",disabled:!q.ready||c.keyframes.length>=2048,onClick:Ce,children:[t(Ie,{size:13,"aria-hidden":"true"}),"Add keyframe at playhead"]})}),h&&s(fe,{children:[s("div",{className:"rui-groupHeader",children:[t("span",{children:"Keyframe"}),t("button",{type:"button",className:"se-iconButton",title:"Delete keyframe","aria-label":"Delete keyframe",onClick:()=>{z({...c,keyframes:c.keyframes.filter(e=>e.id!==h.id)}),x(null)},children:t(G,{size:14})})]}),t(j,{label:"Time",min:0,max:i.duration,value:h.time,step:.01,onChange:e=>C(c,{...h,time:e})}),s("label",{className:"sq-field",children:[t("span",{children:"Easing"}),t("select",{"aria-label":"Keyframe easing",value:c.target.kind==="object"&&c.target.property==="visible"?"step":h.easing??"ease-in-out",disabled:c.target.kind==="object"&&c.target.property==="visible",onChange:e=>C(c,{...h,easing:e.target.value}),children:te.map(e=>t("option",{value:e,children:Pe[e]},e))})]}),t(me,{target:c.target,value:h.value,onChange:e=>C(c,{...h,value:e})}),t("div",{className:"rui-actions",children:s("button",{type:"button",className:"bb-button",disabled:!q.ready,onClick:()=>{let e=r?.capture(c.target);e!=null&&C(c,{...h,value:e})},children:[t(Ee,{size:13,"aria-hidden":"true"}),"Capture current value"]})})]})]})]})]})]}):s("div",{className:"sq-empty",children:[t("p",{children:"Add a sequence, then add tracks and capture keyframes on the timeline."}),s("button",{type:"button",className:"bb-button bb-button--primary",onClick:J,children:[t(_,{size:13,"aria-hidden":"true"}),"Create sequence"]})]}),(Z||q.issues.length>0)&&t("div",{role:"status",className:"sq-error",children:Z||q.issues.join(" ")})]})}export{Ae as default};
@@ -0,0 +1,16 @@
1
+ import{a as fr,c as yr,g as hi,i as Mr,j as ui,k as We,l as Ge}from"./chunk-3OCHN3CA.mjs";import{d as gr,e as li,f as br,g as xr,h as vr,j as _r,k as Tr,l as wr}from"./chunk-RKDATTUM.mjs";import{a as lr,b as ai,e as hr,f as ur,g as cr,m as dr,n as si,r as pr}from"./chunk-UHRJ2RBF.mjs";import{d as yt,e as ni,g as oi,h as mr}from"./chunk-UCD76KQ6.mjs";import{a as ri}from"./chunk-JR557W27.mjs";import{useCallback as xe,useEffect as ve,useMemo as Mo,useRef as z,useState as tr}from"react";import{useFrame as So,useThree as Co}from"@react-three/fiber";import{Box3 as Ur,BoxGeometry as As,Group as Rr,Matrix4 as Br,Mesh as Ls,MeshBasicMaterial as Is,Vector3 as se}from"three";import{Euler as ds,Matrix4 as Me,MeshBasicMaterial as ps,MeshMatcapMaterial as ms,MeshNormalMaterial as gs,MeshStandardMaterial as fs,Quaternion as ys,Vector3 as He}from"three";function Pr(e){let t={};for(let[i,r]of Object.entries(e))t[r.modelObjectId??i]=i;return t}function pi(e){let t=e,i=null;for(;t;){let r=t.userData?.ri_name;if(typeof r=="string"&&r)return r;!i&&t.name&&(i=t.name),t=t.parent}return i}function Ar(e,t){return e||(t?t.modelObjectId??t.id:null)}function mi(e,t){let i=pi(e);if(!i)return null;let r=t.keyByModelObject[i]??i,a=t.objectBindings[r];return a?{key:r,binding:a}:null}function gi(e,t,i){if(!br(e))return null;let r=mi(e,t);return!r||r.binding.visible===!1||(i==="select"?r.binding.selectable:r.binding.hoverable)===!1?null:r}function Lr(e,t,i,r){for(let a of e){if(a.eventObject!==t)continue;let s=gi(a.object,i,r);if(s)return s}return null}var Re=new He,ci=new He,bs=new Me,Sr=new Me,qe=new Me,xs=new Me,bt=new Me,vs=new Me,_s=new Me,Cr=new He,Er=new He,pe=new He,di=new ys,Ts=new ds;function ws(e,t,i,r,a){let s=!!(i?.position||i?.rotation||i?.scale||i?.shear),n=!!(a&&a.factor>0&&a.radius>0);if(!s&&!n){e.matrixAutoUpdate=!0,e.position.copy(t.position),e.rotation.copy(t.rotation),e.scale.copy(t.scale),e.updateMatrix(),e.updateWorldMatrix(!0,!1);return}Sr.compose(t.position,di.setFromEuler(t.rotation),t.scale);let o=i?.rotation;qe.compose(Cr.fromArray(hi(i?.position??[0,0,0],o??[0,0,0],i?.scale??[1,1,1],i?.pivot,"XYZ",i?.shear)),di.setFromEuler(Ts.set(o?.[0]??0,o?.[1]??0,o?.[2]??0)),Er.fromArray(i?.scale??[1,1,1])),i?.shear&&qe.makeRotationFromQuaternion(di).multiply(lr(i.shear)).scale(Er).setPosition(Cr),qe.premultiply(r).multiply(xs.copy(r).invert()),e.parent?.updateWorldMatrix(!0,!1);let l=e.parent?.matrixWorld??bs;if(bt.multiplyMatrices(l,Sr).premultiply(qe),n&&a){let u=e;for(;u.parent&&!u.userData.ri_name;)u=u.parent;let c=u.userData.ri_center;Array.isArray(c)&&c.length===3?pe.fromArray(c).applyMatrix4(r).applyMatrix4(qe):pe.setFromMatrixPosition(bt),pe.sub(a.centre),pe.lengthSq()>1e-8&&(pe.normalize().multiplyScalar(a.factor*a.radius),bt.premultiply(_s.makeTranslation(pe.x,pe.y,pe.z)))}e.matrixAutoUpdate=!1,e.matrix.multiplyMatrices(vs.copy(l).invert(),bt),e.matrixWorldNeedsUpdate=!0,e.updateWorldMatrix(!1,!1)}function xt(e,t){if(!yt(e)&&!e.userData.riLogicalObject)return;let i=mi(e,t);if(!i)return;let r=Ir(e);if(r.rest??(r.rest={position:e.position.clone(),rotation:e.rotation.clone(),scale:e.scale.clone()}),t.suspendTransforms)return;if(t.placementFrame&&!e.userData.riLogicalObject){ws(e,r.rest,i.binding.transform,t.placementFrame,t.explode);return}let a=r.rest,s=i.binding.transform;s?.position?e.position.fromArray(s.position):e.position.copy(a.position),s?.rotation?e.rotation.set(s.rotation[0],s.rotation[1],s.rotation[2],a.rotation.order):e.rotation.copy(a.rotation),s?.scale?e.scale.fromArray(s.scale):e.scale.copy(a.scale),e.position.fromArray(hi(e.position.toArray(),[e.rotation.x,e.rotation.y,e.rotation.z],e.scale.toArray(),s?.pivot,a.rotation.order,s?.shear)),ai(e,s?.shear);let n=t.explode;if(n&&n.factor>0&&n.radius>0){e.updateWorldMatrix(!0,!1),ci.setFromMatrixPosition(e.matrixWorld);let o=e;for(;o.parent&&!o.userData.ri_name;)o=o.parent;let l=o.userData.ri_center;Array.isArray(l)&&l.length===3?Re.fromArray(l).applyMatrix4(e.matrixWorld).sub(n.centre):Re.copy(ci).sub(n.centre),Re.lengthSq()>1e-8&&(Re.normalize().multiplyScalar(n.factor*n.radius).add(ci),e.parent&&e.parent.worldToLocal(Re),e.position.copy(Re))}ai(e,s?.shear),e.updateWorldMatrix(!0,!1)}function Oe(e,t){e.traverse(i=>xt(i,t))}function Ir(e){var t;return(t=e.userData).riVisuals??(t.riVisuals={}),e.userData.riVisuals}function Ms(e,t,i,r){return JSON.stringify([e?.style?.material??null,t??null,i.shadingMode,i.rendererMode,r])}function Ss(e){if(e.textures){for(let t of ni){let i=e.textures[t];i&&si(i,oi(t))}e.textures=void 0}}function Cs(e,t,i){let r=e.textures??{};for(let a of ni){let s=mr(t,a),n=r[a];if(n===s)continue;let o=oi(a);n&&si(n,o),s?(dr(s,o,i),r[a]=s):delete r[a]}e.textures=Object.keys(r).length>0?r:void 0}function Es(e,t){if(t.shadingMode==="normals")return We(e,()=>new gs);if(t.shadingMode==="unlit")return We(e,i=>{let r=new ps;return r.color.copy(i.color),r.map=i.map,r.vertexColors=i.vertexColors,r.alphaMap=i.alphaMap,r.alphaTest=i.alphaTest,r.transparent=i.transparent,r.opacity=i.opacity,r.side=i.side,r});if(t.rendererMode==="matcap"){let i=pr();return We(e,r=>{let a=new ms;return a.matcap=i,a.color.copy(r.color),a.vertexColors=r.vertexColors,a.alphaMap=r.alphaMap,a.alphaTest=r.alphaTest,a.side=r.side,a})}return e}function Ps(e,t){if(!yt(e))return;let r=Ir(e);r.original??(r.original=ui(e));let a=mi(e,t);if(!a){r.original&&(e.material=r.original),e.visible=!0;return}let{key:s,binding:n}=a;e.visible=n.visible!==!1,xt(e,t);let o=t.itemMaterials?.[s]?.hex??t.itemMaterials?.[n.modelObjectId??s]?.hex,l=t.highlightOnHover!==!1&&s===t.hoveredKey,u=Ms(n,o,t,l);if(r.signature===u&&r.display){e.material=r.display;return}let c=n.style?.material;if(Cs(r,c,t.invalidate),!r.physical){let h=r.original??ui(e);if(!h)return;r.physical=We(h,m=>{let d=_r(m),p=Tr(d??new fs);return wr(p),p})}Ge(r.physical,h=>{Mr(h,c,o??c?.baseColor),l&&(h.emissive.add(hr),h.color.lerp(ur,cr)),h.needsUpdate=!0}),r.display&&r.display!==r.physical&&Ge(r.display,h=>h.dispose()),r.display=Es(r.physical,t),r.signature=u,e.material=r.display}function Dr(e,t){e.traverse(i=>Ps(i,t))}function fi(e){e.traverse(t=>{if(!yt(t))return;let i=t.userData.riVisuals;i&&(i.rest&&(t.matrixAutoUpdate=!0,t.position.copy(i.rest.position),t.rotation.copy(i.rest.rotation),t.scale.copy(i.rest.scale),t.updateMatrix()),i.original&&(t.material=i.original),i.display&&i.display!==i.physical&&Ge(i.display,r=>r.dispose()),i.physical&&Ge(i.physical,r=>r.dispose()),Ss(i),delete t.userData.riVisuals)})}var kr=new Br().makeRotationX(Math.PI/2),Or=kr.clone().invert();function Ds(e){let t=new se(e[0],e[1],e[2]),i=new se(Math.abs(e[3])+Math.abs(e[6])+Math.abs(e[9]),Math.abs(e[4])+Math.abs(e[7])+Math.abs(e[10]),Math.abs(e[5])+Math.abs(e[8])+Math.abs(e[11]));return new Ur(t.clone().sub(i),t.clone().add(i))}function Rs(e){let t=e.getCenter(new se),i=e.getSize(new se).multiplyScalar(.5);return[t.x,t.y,t.z,i.x,0,0,0,i.y,0,0,0,i.z]}var vt=class{constructor(){this.group=new Rr;this.objects=new Map;this.geometry=new As(1,1,1);this.material=new Is;this.originalBounds=new WeakMap;this.signature="";this.lastContext=null;this.lastEffective=null;this.lastDragging=!1;this.version=0;this.tileVersions=new WeakMap;this.transforms=new Map}setCatalog(t){this.group.clear(),this.objects.clear();for(let i of t){let r=new Ur(new se(...i.minimum),new se(...i.maximum)).applyMatrix4(Or),a=new Rr;a.name=i.name,a.userData.ri_name=i.name,a.userData.riLogicalObject=!0,a.userData.ri_center=r.getCenter(new se).toArray();let s=new Ls(this.geometry,this.material);s.visible=!1,s.raycast=()=>{},s.position.copy(r.getCenter(new se)),s.scale.copy(r.getSize(new se)),a.add(s),this.group.add(a),this.objects.set(i.name,a)}this.signature="",this.lastContext=null}nodesByBinding(t){let i={};for(let[r,a]of this.objects){let s=t.keyByModelObject[r]??r;t.objectBindings[s]&&(i[s]=a)}return i}sync(t,i,r=!1){if(!r&&!this.lastDragging&&t===this.lastContext&&this.lastEffective)return this.lastEffective;this.lastContext=t,this.lastDragging=r;let a={...t,suspendTransforms:!1},s=i?t.objectBindings[i]:void 0,n=s?this.objects.get(s.modelObjectId??i):void 0;r&&n&&s&&(a={...a,objectBindings:{...t.objectBindings,[i]:{...s,transform:{position:n.position.toArray(),rotation:[n.rotation.x,n.rotation.y,n.rotation.z],scale:n.scale.toArray()}}}});for(let l of this.objects.values())r&&l===n||xt(l,a);this.group.updateWorldMatrix(!0,!0);let o=[...this.objects].map(([l,u])=>`${l}:${u.matrix.elements.join(",")}`).join(";");if(o!==this.signature){this.signature=o,this.version++,this.transforms.clear();for(let[l,u]of this.objects)u.matrix.equals(new Br)||this.transforms.set(l,kr.clone().multiply(u.matrix).multiply(Or))}return this.lastEffective=a,a}updateBounds(t){if(!t)return;let i=r=>{if(this.tileVersions.get(r)!==this.version){if(r.boundingVolume.box&&this.tileVersions.get(r)!==this.version){let a=this.originalBounds.get(r);a||(a={box:[...r.boundingVolume.box],error:r.geometricError},this.originalBounds.set(r,a));let s=Ds(a.box),n=s.clone(),o=1;for(let u of r.extras?.featureIds??[]){let c=this.transforms.get(u);c&&(n.union(s.clone().applyMatrix4(c)),o=Math.max(o,c.getMaxScaleOnAxis()))}let l=Rs(n);r.boundingVolume.box=l,r.geometricError=a.error*o,r.engineData?.boundingVolume?.setObbData(l,r.engineData.transform),this.tileVersions.set(r,this.version)}r.children?.forEach(i)}};i(t)}dispose(){this.group.clear(),this.objects.clear(),this.geometry.dispose(),this.material.dispose()}};var yi=Object.freeze({factor:1,loosened:!1,tooFine:0,raisedAt:-1/0,changedAt:-1/0}),Ye=16,bi=1.25,Os=1.5,Us=1.25,Bs=500,ks=3e3,Fr=5e3,Vr=2e3,Fs=.9;function zr(e){return e.full&&(e.wanting||e.usage>1)}function Nr(e){return e.loosened?ks:Bs}function jr(e){let t=e.factor/Us;return t<=1+1e-6?1:t}function Wr(e,t){return e.factor>1&&!e.loosened&&!t.full&&!t.wanting&&t.usage<Fs&&jr(e)>e.tooFine}function Gr(e,t){let{now:i}=t,r=t.moved&&e.tooFine>0?{...e,tooFine:0}:e;if(zr(t)){if(i-r.changedAt<Nr(r))return r;let a=Math.max(r.tooFine,r.factor);return r.factor>=Ye?r.loosened&&r.tooFine===a?r:{...r,loosened:!0,tooFine:a,changedAt:i}:{factor:Math.min(Ye,r.factor*Os),loosened:!0,tooFine:a,raisedAt:i,changedAt:i}}return r.loosened&&!t.wanting?{...r,loosened:!1,changedAt:i}:Wr(r,t)&&i-r.raisedAt>=Fr&&i-r.changedAt>=Vr?{...r,factor:jr(r),changedAt:i}:r}function qr(e,t){let{now:i}=t;return zr(t)?e.factor>=Ye&&e.loosened?null:Math.max(0,Nr(e)-(i-e.changedAt)):e.loosened&&!t.wanting?0:Wr(e,t)?Math.max(0,Fr-(i-e.raisedAt),Vr-(i-e.changedAt)):null}function Qr(e){try{let t=typeof location<"u"?location.href:void 0;return new URL(e,t).origin}catch{return null}}function xi(e){if(!e)return null;let t=e.length,i=e.indexOf("?"),r=e.indexOf("#");i!==-1&&(t=Math.min(t,i)),r!==-1&&(t=Math.min(t,r));let a=e.lastIndexOf(".",t),s=e.lastIndexOf("/",t),n=e.indexOf("://");return n!==-1&&n+2===s||a===-1||a<s?null:e.substring(a+1,t)||null}var Tt,Xe=(Tt=class{static setXRSession(e){e!==this.session&&(this.flushPending(),this.session=e)}static requestAnimationFrame(e){let{session:t,pending:i}=this,r,a=()=>{i.delete(r),e()};return r=t?t.requestAnimationFrame(a):requestAnimationFrame(a),i.set(r,e),r}static cancelAnimationFrame(e){let{pending:t,session:i}=this;t.delete(e),i?i.cancelAnimationFrame(e):cancelAnimationFrame(e)}static flushPending(){this.pending.forEach((e,t)=>{e(),this.cancelAnimationFrame(t)})}},ri(Tt,"pending",new Map),ri(Tt,"session",null),Tt),Hr=2**30,Ze=class{get unloadPriorityCallback(){return this._unloadPriorityCallback}set unloadPriorityCallback(e){e.length===1?(console.warn('LRUCache: "unloadPriorityCallback" function has been changed to take two arguments.'),this._unloadPriorityCallback=(t,i)=>{let r=e(t),a=e(i);return r<a?-1:+(r>a)}):this._unloadPriorityCallback=e}constructor(){this.minSize=6e3,this.maxSize=8e3,this.minBytesSize=.3*Hr,this.maxBytesSize=.4*Hr,this.unloadPercent=.05,this.autoMarkUnused=!0,this.cachedBytes=0,this.itemSet=new Map,this.itemList=[],this.usedSet=new Set,this.callbacks=new Map,this.unloadingHandle=-1,this.bytesMap=new Map,this.loadedSet=new Set,this._unloadPriorityCallback=null;let e=this.itemSet;this.defaultPriorityCallback=t=>e.get(t)}isFull(){return this.itemSet.size>=this.maxSize||this.cachedBytes>=this.maxBytesSize}getMemoryUsage(e){return this.bytesMap.get(e)||0}setMemoryUsage(e,t){let{bytesMap:i,itemSet:r}=this;r.has(e)&&(this.cachedBytes-=i.get(e)||0,i.set(e,t),this.cachedBytes+=t)}add(e,t){let i=this.itemSet;if(i.has(e)||this.isFull())return!1;let r=this.usedSet,a=this.itemList,s=this.callbacks;return a.push(e),r.add(e),i.set(e,Date.now()),s.set(e,t),!0}has(e){return this.itemSet.has(e)}remove(e){let t=this.usedSet,i=this.itemSet,r=this.itemList,a=this.bytesMap,s=this.callbacks,n=this.loadedSet;if(i.has(e)){this.cachedBytes-=a.get(e)||0,a.delete(e),s.get(e)(e);let o=r.indexOf(e);return r.splice(o,1),t.delete(e),i.delete(e),s.delete(e),n.delete(e),!0}return!1}setLoaded(e,t){let{itemSet:i,loadedSet:r}=this;i.has(e)&&(t===!0?r.add(e):r.delete(e))}markUsed(e){let t=this.itemSet,i=this.usedSet;t.has(e)&&!i.has(e)&&(t.set(e,Date.now()),i.add(e))}markUnused(e){this.usedSet.delete(e)}markAllUnused(){this.usedSet.clear()}isUsed(e){return this.usedSet.has(e)}unloadUnusedContent(){let{unloadPercent:e,minSize:t,maxSize:i,itemList:r,itemSet:a,usedSet:s,loadedSet:n,callbacks:o,bytesMap:l,minBytesSize:u,maxBytesSize:c}=this,h=r.length-s.size,m=r.length-n.size,d=Math.max(Math.min(r.length-t,h),0),p=this.cachedBytes-u,y=this.unloadPriorityCallback||this.defaultPriorityCallback,M=!1,_=d>0&&h>0||m&&r.length>i;if(h&&this.cachedBytes>u||m&&this.cachedBytes>c||_){r.sort((w,U)=>{let O=s.has(w);if(O===s.has(U)){let V=n.has(w);return V===n.has(U)?-y(w,U):V?1:-1}else return O?1:-1});let C=Math.max(t*e,d*e),g=Math.ceil(Math.min(C,h,d)),P=Math.max(e*p,e*u),S=Math.min(P,p),v=0,L=0;for(;this.cachedBytes-L>c||r.length-v>i;){let w=r[v],U=l.get(w)||0;if(s.has(w)&&n.has(w)||this.cachedBytes-L-U<c&&r.length-v<=i)break;L+=U,v++}for(;L<S||v<g;){let w=r[v],U=l.get(w)||0;if(s.has(w)||this.cachedBytes-L-U<u&&v>=g)break;L+=U,v++}r.splice(0,v).forEach(w=>{this.cachedBytes-=l.get(w)||0,o.get(w)(w),l.delete(w),a.delete(w),o.delete(w),n.delete(w),s.delete(w)}),M=v<d||L<p&&v<h,M&&(M=v>0)}M&&(this.unloadingHandle=Xe.requestAnimationFrame(()=>this.scheduleUnload()))}scheduleUnload(){Xe.cancelAnimationFrame(this.unloadingHandle),this.scheduled||(this.scheduled=!0,queueMicrotask(()=>{this.scheduled=!1,this.unloadUnusedContent()}))}},Vs=class extends DOMException{constructor(){super("PriorityQueue: Item removed","AbortError")}},ie=class{get running(){return this.items.length!==0||this.currJobs!==0}constructor(){this.maxJobs=6,this.items=[],this.callbacks=new Map,this.currJobs=0,this.scheduled=!1,this.autoUpdate=!0,this.priorityCallback=null,this._schedulingCallback=e=>{Xe.requestAnimationFrame(e)},this._runjobs=()=>{this.scheduled=!1,this.tryRunJobs()}}sort(){let e=this.priorityCallback,t=this.items;e!==null&&t.sort(e)}has(e){return this.callbacks.has(e)}add(e,t){let i={callback:t,reject:null,resolve:null,promise:null};return i.promise=new Promise((r,a)=>{let s=this.items,n=this.callbacks;i.resolve=r,i.reject=a,s.unshift(e),n.set(e,i),this.autoUpdate&&this.scheduleJobRun()}),i.promise}remove(e){let t=this.items,i=this.callbacks,r=t.indexOf(e);if(r!==-1){let a=i.get(e);a.promise.catch(s=>{if(s.name!=="AbortError")throw s}),a.reject(new Vs),t.splice(r,1),i.delete(e)}}removeByFilter(e){let{items:t}=this;for(let i=0;i<t.length;i++){let r=t[i];e(r)&&(this.remove(r),i--)}}tryRunJobs(){this.sort();let e=this.items,t=this.callbacks,i=this.maxJobs,r=0,a=()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()};for(;i>this.currJobs&&e.length>0&&r<i;){this.currJobs++,r++;let s=e.pop(),{callback:n,resolve:o,reject:l}=t.get(s);t.delete(s);let u;try{u=n(s)}catch(c){l(c),a();continue}u instanceof Promise?u.then(o).catch(l).finally(a):(o(u),a())}}flush(e){let{items:t,callbacks:i}=this,r=t.indexOf(e);if(!i.has(e))return;let{callback:a,resolve:s,reject:n}=i.get(e);i.delete(e),t.splice(r,1);let o;try{o=a(e)}catch(l){n(l);return}return o instanceof Promise?o.then(s).catch(n):s(o),o}scheduleJobRun(){this.scheduled||(this.scheduled=(this._schedulingCallback(this._runjobs),!0))}},Ct=class{get running(){for(let e of this.originQueues.values())if(e.running)return!0;return!1}get maxJobsPerOrigin(){return this._maxJobsPerOrigin}set maxJobsPerOrigin(e){this._maxJobsPerOrigin=e,this.originQueues.forEach(t=>t.maxJobs=e)}get maxJobs(){return this.maxJobsPerOrigin}set maxJobs(e){console.warn('DownloadPriorityQueue: "maxJobs" is no longer valid and limits jobs per server origin. Use "maxJobsPerOrigin", instead.'),this.maxJobsPerOrigin=e}get priorityCallback(){return this._priorityCallback}set priorityCallback(e){this._priorityCallback=e,this.originQueues.forEach(t=>t.priorityCallback=e)}constructor(){this.originQueues=new Map,this._itemQueues=new WeakMap,this._maxJobsPerOrigin=6,this._priorityCallback=null}add(e,t,i,r=null){this.originQueues.forEach((l,u)=>{l.running||this.originQueues.delete(u)});let a=e===null?null:Qr(e),s=this.originQueues.get(a);s||(s=new ie,s.maxJobs=this._maxJobsPerOrigin,s.priorityCallback=this._priorityCallback,this.originQueues.set(a,s));let n=this._itemQueues.get(t);if(n&&n!==s&&n.has(t))throw Error("DownloadPriorityQueue: Item is already queued with a different url origin.");this._itemQueues.set(t,s);let o=s.add(t,i);return r!==null&&(r.aborted?this.remove(t):r.addEventListener("abort",()=>this.remove(t),{once:!0})),o}remove(e){let t=this._itemQueues.get(e);t&&(t.remove(e),this._itemQueues.delete(e))}has(e){let t=this._itemQueues.get(e);return!!(t&&t.has(e))}};var Ee=6378137,zs=1/298.257223563,_i=6356752314245179e-9,_t={inView:!1,error:1/0,distanceFromCamera:1/0};function Et(e){return e===4||e===-1}function ne(e,t){return Pt(e)&&e.traversal.lastFrameVisited===t&&e.traversal.used}function Pt(e){return!!e.traversal}function Je(e){let{children:t}=e,i=t.length===0||Pt(t[t.length-1]),r=!e.internal.hasUnrenderableContent||Et(e.internal.loadingState);return i&&r}function Se(e){return e.traversal.unconditionallyRefine}function Qe(e,t){if(Pt(e)&&(t.ensureChildrenArePreprocessed(e),e.traversal.lastFrameVisited!==t.frameCount&&(e.traversal.wasInFrustum=e.traversal.inFrustum,e.traversal.wasSetActive=e.traversal.active,e.traversal.wasSetVisible=e.traversal.visible,e.traversal.usedLastFrame=e.traversal.used,e.traversal.lastFrameVisited=t.frameCount,e.traversal.used=!1,e.traversal.inFrustum=!1,e.traversal.isLeaf=!1,e.traversal.visible=!1,e.traversal.active=!1,e.traversal.error=1/0,e.traversal.distanceFromCamera=1/0,e.traversal.allChildrenReady=!1,e.traversal.allChildrenLoaded=!1,e.traversal.kicked=!1,e.traversal.allUsedChildrenProcessed=!1,t.calculateTileViewErrorWithPlugin(e,_t),e.traversal.inFrustum=_t.inView,e.traversal.error=_t.error,e.traversal.distanceFromCamera=_t.distanceFromCamera,e.traversal.unconditionallyRefine=e.internal.hasUnrenderableContent,!e.traversal.unconditionallyRefine))){let i=e.parent;for(;i&&i.traversal.unconditionallyRefine;)i=i.parent;i&&i.geometricError<=e.geometricError&&(e.traversal.unconditionallyRefine=!0)}}function vi(e,t,i=!1){if(Qe(e,t),i?t.markTileUsed(e):wt(e),Se(e)&&Je(e)){let r=e.children;for(let a=0,s=r.length;a<s;a++)vi(r[a],t,i)}}function $r(e,t){if(Qe(e,t),e.traversal.usedLastFrame&&(wt(e),e.traversal.wasSetActive&&(e.traversal.active=!0),(!e.traversal.active||Se(e))&&Je(e))){let i=e.children;for(let r=0,a=i.length;r<a;r++)$r(i[r],t)}}function wt(e){e.traversal.used=!0}function Ns(e,t){return!(e.traversal.error<=t.errorTarget&&!Se(e)||t.maxDepth>0&&e.internal.depth+1>=t.maxDepth||!Je(e))}function Zr(e,t){let{frameCount:i}=t,{children:r}=e;for(let a=0,s=r.length;a<s;a++){let n=r[a];ne(n,i)&&(n.traversal.active&&(n.traversal.kicked=!0,n.traversal.active=!1),Zr(n,t))}}function Yr(e){return!Se(e)&&(!e.internal.hasContent||Et(e.internal.loadingState))}function Jr(e,t){if(Qe(e,t),!e.traversal.inFrustum)return;let i=e.parent;if(i&&i.refine==="ADD"&&e.geometricError>0&&e.traversal.error*(i.geometricError/e.geometricError)<=t.errorTarget)return;if(!Ns(e,t)){wt(e);return}let r=!1,a=!1,s=e.children;for(let n=0,o=s.length;n<o;n++){let l=s[n];Jr(l,t),r||(r=ne(l,t.frameCount)),a||(a=l.traversal.inFrustum)}if(e.refine==="REPLACE"&&!a&&s.length!==0){e.traversal.inFrustum=!1,t.markTileUsed(e);for(let n=0,o=s.length;n<o;n++)vi(s[n],t,!0);return}if(wt(e),e.refine==="REPLACE"&&r&&(t.loadSiblings||t.loadAncestors))for(let n=0,o=s.length;n<o;n++)vi(s[n],t)}function Kr(e,t){let i=t.frameCount;if(!ne(e,i))return;let r=e.children,a=!1;for(let n=0,o=r.length;n<o;n++){let l=r[n];a||(a=ne(l,i))}if(!a)e.traversal.isLeaf=!0;else{for(let o=0,l=r.length;o<l;o++)Kr(r[o],t);let n=!0;for(let o=0,l=r.length;o<l;o++){let u=r[o];if(ne(u,i)){let c=!Se(u),h=!u.internal.hasContent||Et(u.internal.loadingState);c&&h||u.traversal.allChildrenLoaded||(n=!1)}}e.traversal.allChildrenLoaded=n}let s=!0;for(let n=0,o=r.length;n<o;n++){let l=r[n];ne(l,t.frameCount)&&!l.traversal.allUsedChildrenProcessed&&(s=!1)}e.traversal.allUsedChildrenProcessed=s&&Je(e)}function ea(e,t){if(!ne(e,t.frameCount))return;let i=e.children;if(e.refine==="REPLACE"&&t.loadAncestors&&!e.traversal.allChildrenLoaded&&!Se(e)&&(e.traversal.isLeaf=!0),e.traversal.isLeaf){if(!Se(e)&&(e.traversal.active=!0,Je(e)&&e.internal.hasContent&&!Et(e.internal.loadingState)))for(let a=0,s=i.length;a<s;a++)$r(i[a],t);return}let r=i.length>0;for(let a=0,s=i.length;a<s;a++){let n=i[a];ea(n,t),ne(n,t.frameCount)&&!(n.traversal.active&&Yr(n))&&!n.traversal.allChildrenReady&&(r=!1)}e.traversal.allChildrenReady=r,e.refine==="REPLACE"&&!r&&e.traversal.wasSetActive&&Yr(e)&&(e.traversal.active=!0,Zr(e,t))}function ta(e,t){Qe(e,t);let i=ne(e,t.frameCount);if(i&&(e.internal.hasUnrenderableContent&&(t.markTileUsed(e),t.queueTileForDownload(e)),e.internal.hasRenderableContent&&e.refine==="ADD"&&(e.traversal.active=!0),(e.traversal.active||e.traversal.kicked)&&e.internal.hasContent&&(t.markTileUsed(e),e.traversal.allUsedChildrenProcessed&&t.queueTileForDownload(e),e.internal.loadingState!==4&&(e.traversal.active=!1)),t.loadAncestors&&e.internal.hasContent&&(t.markTileUsed(e),t.queueTileForDownload(e)),e.internal.virtualChildCount>0&&e.internal.hasContent&&t.markTileUsed(e),e.traversal.visible=e.internal.hasRenderableContent&&e.traversal.active&&e.traversal.inFrustum&&e.internal.loadingState===4,t.stats.used++,e.traversal.inFrustum&&t.stats.inFrustum++),i||Pt(e)&&e.traversal.usedLastFrame){let r=!1,a=!1;i?(r=e.traversal.active,a=t.displayActiveTiles&&e.traversal.active||e.traversal.visible):Qe(e,t),e.internal.hasRenderableContent&&e.internal.loadingState===4?(r&&t.stats.active++,a&&t.stats.visible++,e.traversal.wasSetActive!==r&&t.invokeOnePlugin(n=>n.setTileActive&&n.setTileActive(e,r)),e.traversal.wasSetVisible!==a&&t.invokeOnePlugin(n=>n.setTileVisible&&n.setTileVisible(e,a))):e.internal.hasRenderableContent||(a=e.traversal.isLeaf,e.traversal.wasSetVisible!==a&&t.invokeOnePlugin(n=>n.setEmptyTileVisible&&n.setEmptyTileVisible(e,a))),e.traversal.visible=a,e.traversal.active=r;let s=e.children;for(let n=0,o=s.length;n<o;n++){let l=s[n];ta(l,t)}}}function js(e,t){Jr(e,t),Kr(e,t),ea(e,t),ta(e,t)}function Ws(e){let t=null;return()=>{t===null&&(t=Xe.requestAnimationFrame(()=>{t=null,e()}))}}function Gs(e,t=null,i=null){let r=[];for(r.push(e),r.push(null),r.push(0);r.length>0;){let a=r.pop(),s=r.pop(),n=r.pop();if(t&&t(n,s,a)){i&&i(n,s,a);return}let o=n.children;if(o)for(let l=o.length-1;l>=0;l--)r.push(o[l]),r.push(n),r.push(a+1);i&&i(n,s,a)}}var Xr=Symbol("PLUGIN_REGISTERED"),me={inView:!0,error:0,distance:1/0},qs=(e,t)=>{let i=e.priority||0,r=t.priority||0;return i===r?!e.traversal||!t.traversal?0:e.traversal.used===t.traversal.used?e.traversal.error===t.traversal.error?e.traversal.distanceFromCamera===t.traversal.distanceFromCamera?e.internal.depthFromRenderedParent===t.internal.depthFromRenderedParent?0:e.internal.depthFromRenderedParent>t.internal.depthFromRenderedParent?-1:1:e.traversal.distanceFromCamera>t.traversal.distanceFromCamera?-1:1:e.traversal.error>t.traversal.error?1:-1:e.traversal.used?1:-1:i>r?1:-1},Hs=(e,t)=>e.traversal.used===t.traversal.used?e.traversal.inFrustum===t.traversal.inFrustum?e.internal.hasUnrenderableContent===t.internal.hasUnrenderableContent?e.traversal.distanceFromCamera===t.traversal.distanceFromCamera?e.internal.depthFromRenderedParent===t.internal.depthFromRenderedParent?0:e.internal.depthFromRenderedParent>t.internal.depthFromRenderedParent?-1:1:e.traversal.distanceFromCamera>t.traversal.distanceFromCamera?-1:1:e.internal.hasUnrenderableContent?1:-1:e.traversal.inFrustum?1:-1:e.traversal.used?1:-1,Ys=(e,t)=>e.traversal.lastFrameVisited===t.traversal.lastFrameVisited?e.internal.depthFromRenderedParent===t.internal.depthFromRenderedParent?e.internal.loadingState===t.internal.loadingState?e.internal.hasUnrenderableContent===t.internal.hasUnrenderableContent?e.traversal.error===t.traversal.error?0:e.traversal.error>t.traversal.error?-1:1:e.internal.hasUnrenderableContent?-1:1:e.internal.loadingState>t.internal.loadingState?-1:1:e.internal.depthFromRenderedParent>t.internal.depthFromRenderedParent?1:-1:e.traversal.lastFrameVisited>t.traversal.lastFrameVisited?-1:1,Ue=(e,t)=>{let i=e.priority??1/0,r=t.priority??1/0;if(i!==r)return i>r?1:-1;if(!e.internal||!t.internal)return 0;let a=e.internal.renderer,s=t.internal.renderer,n=!a.loadAncestors,o=!s.loadAncestors;return n&&o?Hs(e,t):qs(e,t)},Ti=new Ze;Ti.unloadPriorityCallback=Ys;var $e=new Ct;$e.maxJobsPerOrigin=25,$e.priorityCallback=Ue;var Mt=new ie;Mt.maxJobs=5,Mt.priorityCallback=Ue;var St=new ie;St.maxJobs=25,St.priorityCallback=(e,t)=>{let i=e.parent,r=t.parent;return i===r?0:i?r?Ue(i,r):-1:1};var wi=class{get root(){let e=this.rootTileset;return e?e.root:null}get loadProgress(){let{stats:e,isLoading:t}=this,i=e.queued+e.downloading+e.parsing,r=e.inCacheSinceLoad+ +!!t;return r===0?1:1-i/r}get downloadQueue(){return this._downloadQueue}set downloadQueue(e){if(e instanceof ie){console.warn('TilesRenderer: "downloadQueue" is no longer valid as a PriorityQueue. Use a DownloadPriorityQueue, instead.');return}this._downloadQueue=e}constructor(e=null){this.rootLoadingState=0,this.rootTileset=null,this.rootURL=e,this.fetchOptions={},this.plugins=[],this.queuedTiles=[],this.cachedSinceLoadComplete=new Set,this.isLoading=!1,this.processedTiles=new WeakSet,this.visibleTiles=new Set,this.activeTiles=new Set,this.usedSet=new Set,this.loadingTiles=new Set,this.lruCache=Ti,this.downloadQueue=$e,this.parseQueue=Mt,this.processNodeQueue=St,this.stats={inCacheSinceLoad:0,inCache:0,queued:0,downloading:0,parsing:0,loaded:0,failed:0,inFrustum:0,used:0,active:0,visible:0,tilesProcessed:0},this.frameCount=0,this._dispatchNeedsUpdateEvent=Ws(()=>{this.dispatchEvent({type:"needs-update"})}),this.errorTarget=16,this.errorFalloff=0,this.errorFalloffDensity=2e-4,this.displayActiveTiles=!1,this.maxDepth=1/0,this.loadSiblings=!0,this.loadAncestors=!0,this.maxTilesProcessed=250}registerPlugin(e){if(e[Xr]===!0)throw Error("TilesRendererBase: A plugin can only be registered to a single tileset");let t=this.plugins,i=e.priority||0,r=t.length;for(let a=0;a<t.length;a++)if((t[a].priority||0)>i){r=a;break}t.splice(r,0,e),e[Xr]=!0,e.init&&e.init(this)}unregisterPlugin(e){let t=this.plugins;if(typeof e=="string"&&(e=this.getPluginByName(e)),t.includes(e)){let i=t.indexOf(e);return t.splice(i,1),e.dispose&&e.dispose(),!0}return!1}getPluginByName(e){return this.plugins.find(t=>t.name===e)||null}invokeOnePlugin(e){let t=[...this.plugins,this];for(let i=0;i<t.length;i++){let r=e(t[i]);if(r)return r}return null}invokeAllPlugins(e){let t=[...this.plugins,this],i=[];for(let r=0;r<t.length;r++){let a=e(t[r]);a&&i.push(a)}return i.length===0?null:Promise.all(i)}traverse(e,t,i=!0){this.root&&Gs(this.root,(r,...a)=>(i&&this.ensureChildrenArePreprocessed(r,!0),e?e(r,...a):!1),t)}getAttributions(e=[]){return this.invokeAllPlugins(t=>t!==this&&t.getAttributions&&t.getAttributions(e)),e}update(){let{lruCache:e,usedSet:t,stats:i,root:r,downloadQueue:a,parseQueue:s,processNodeQueue:n}=this;if(this.rootLoadingState===0&&(this.rootLoadingState=2,this.invokeOnePlugin(u=>u.loadRootTileset&&u.loadRootTileset()).then(u=>{let c=this.rootURL;c!==null&&this.invokeAllPlugins(h=>c=h.preprocessURL?h.preprocessURL(c,null):c),this.rootLoadingState=4,this.rootTileset=u,this.dispatchEvent({type:"needs-update"}),this.dispatchEvent({type:"load-tileset",tileset:u,url:c}),this.dispatchEvent({type:"load-root-tileset",tileset:u,url:c})}).catch(u=>{this.rootLoadingState=-1,console.error(u),this.rootTileset=null,this.dispatchEvent({type:"load-error",tile:null,error:u,url:this.rootURL})})),!r)return;let o=null;if(this.invokeAllPlugins(u=>{if(u.doTilesNeedUpdate){let c=u.doTilesNeedUpdate();o=o===null?c:!!(o||c)}}),o===!1){this.dispatchEvent({type:"update-before"}),this.dispatchEvent({type:"update-after"});return}this.dispatchEvent({type:"update-before"}),i.inFrustum=0,i.used=0,i.active=0,i.visible=0,i.tilesProcessed=0,this.frameCount++,t.forEach(u=>e.markUnused(u)),t.clear(),this.prepareForTraversal(),js(r,this),this.removeUnusedPendingTiles();let l=this.queuedTiles;l.sort(e.unloadPriorityCallback);for(let u=0,c=l.length;u<c&&!e.isFull();u++)this.requestTileContents(l[u]);l.length=0,e.scheduleUnload(),(a.running||s.running||n.running)===!1&&this.isLoading===!0&&(this.cachedSinceLoadComplete.clear(),i.inCacheSinceLoad=0,this.dispatchEvent({type:"tiles-load-end"}),this.isLoading=!1),this.dispatchEvent({type:"update-after"})}resetFailedTiles(){this.rootLoadingState===-1&&(this.rootLoadingState=0);let e=this.stats;e.failed!==0&&(this.traverse(t=>{t.internal.loadingState===-1&&(t.internal.loadingState=0)},null,!1),e.failed=0)}calculateTileViewErrorWithPlugin(e,t){this.calculateTileViewError(e,t);let{errorFalloff:i,errorFalloffDensity:r}=this;if(i>0&&Number.isFinite(t.distanceFromCamera)){let o=t.distanceFromCamera*r;t.error-=i*(1-Math.exp(-o*o))}let a=null,s=0,n=1/0;this.invokeAllPlugins(o=>{o!==this&&o.calculateTileViewError&&(me.inView=!0,me.error=0,me.distance=1/0,o.calculateTileViewError(e,me)&&(a===null&&(a=!0),a&&(a=me.inView),me.inView&&(n=Math.min(n,me.distance),s=Math.max(s,me.error))))}),t.inView&&a!==!1?(t.error=Math.max(t.error,s),t.distanceFromCamera=Math.min(t.distanceFromCamera,n)):a?(t.inView=!0,t.error=s,t.distanceFromCamera=n):t.inView=!1}dispose(){[...this.plugins].forEach(i=>{this.unregisterPlugin(i)});let e=this.lruCache,t=[];this.traverse(i=>(t.push(i),!1),null,!1);for(let i=0,r=t.length;i<r;i++)e.remove(t[i]);this.stats={queued:0,parsing:0,downloading:0,failed:0,inFrustum:0,traversed:0,used:0,active:0,visible:0},this.frameCount=0,this.loadingTiles.clear()}calculateBytesUsed(e,t){return 0}dispatchEvent(e){}addEventListener(e,t){}removeEventListener(e,t){}parseTile(e,t,i){return null}prepareForTraversal(){}disposeTile(e){e.traversal.visible&&(e.internal.hasRenderableContent?this.invokeOnePlugin(i=>i.setTileVisible&&i.setTileVisible(e,!1)):this.invokeOnePlugin(i=>i.setEmptyTileVisible&&i.setEmptyTileVisible(e,!1)),e.traversal.visible=!1),e.traversal.active&&e.internal.hasRenderableContent&&this.invokeOnePlugin(i=>i.setTileActive&&i.setTileActive(e,!1)),e.traversal.active=!1;let{scene:t}=e.engineData;t&&this.dispatchEvent({type:"dispose-model",scene:t,tile:e})}preprocessNode(e,t,i=null){if(this.processedTiles.add(e),this.stats.tilesProcessed++,e.content&&(!("uri"in e.content)&&"url"in e.content&&(e.content.uri=e.content.url,delete e.content.url),e.content.boundingVolume&&!("box"in e.content.boundingVolume||"sphere"in e.content.boundingVolume||"region"in e.content.boundingVolume)&&delete e.content.boundingVolume),e.parent=i,e.children=e.children||[],e.internal={hasContent:!1,hasRenderableContent:!1,hasUnrenderableContent:!1,loadingState:0,basePath:t,depth:-1,depthFromRenderedParent:-1,isVirtual:!1,virtualChildCount:0,renderer:this,...e.internal},e.content?.uri){let r=xi(e.content.uri),a=!!(r&&/json$/.test(r));e.internal.hasContent=!0,e.internal.hasUnrenderableContent=a,e.internal.hasRenderableContent=!a}else e.internal.hasContent=!1,e.internal.hasUnrenderableContent=!1,e.internal.hasRenderableContent=!1;i?(e.internal.depth=i.internal.depth+1,e.internal.depthFromRenderedParent=i.internal.depthFromRenderedParent+ +!!e.internal.hasRenderableContent):(e.internal.depth=0,e.internal.depthFromRenderedParent=+!!e.internal.hasRenderableContent),e.traversal={distanceFromCamera:1/0,error:1/0,inFrustum:!1,wasInFrustum:!1,isLeaf:!1,used:!1,usedLastFrame:!1,visible:!1,wasSetVisible:!1,active:!1,wasSetActive:!1,allChildrenReady:!1,allChildrenLoaded:!1,kicked:!1,allUsedChildrenProcessed:!1,lastFrameVisited:-1},i===null?e.refine=e.refine||"REPLACE":e.refine=e.refine||i.refine,e.engineData={scene:null,metadata:null,boundingVolume:null},Object.defineProperty(e,"cached",{get(){return console.warn('TilesRenderer: "tile.cached" field has been renamed to "tile.engineData".'),this.engineData},enumerable:!1,configurable:!0}),this.invokeAllPlugins(r=>{r!==this&&r.preprocessNode&&r.preprocessNode(e,t,i)})}setTileActive(e,t){t?this.activeTiles.add(e):this.activeTiles.delete(e)}setTileVisible(e,t){t?this.visibleTiles.add(e):this.visibleTiles.delete(e),this.dispatchEvent({type:"tile-visibility-change",scene:e.engineData.scene,tile:e,visible:t})}calculateTileViewError(e,t){}removeUnusedPendingTiles(){let{lruCache:e,loadingTiles:t}=this,i=[];for(let r of t)!e.isUsed(r)&&r.internal.loadingState===1&&i.push(r);for(let r=0;r<i.length;r++)e.remove(i[r])}queueTileForDownload(e){e.internal.loadingState!==0||this.lruCache.isFull()||this.queuedTiles.push(e)}markTileUsed(e){this.usedSet.add(e),this.lruCache.markUsed(e)}fetchData(e,t){return fetch(e,t)}ensureChildrenArePreprocessed(e,t=this.stats.tilesProcessed<this.maxTilesProcessed){let i=e.children;if(i.length===0||i[i.length-1].traversal)return;let r=a=>{for(let s=0,n=a.length;s<n;s++){let o=a[s];o&&!o.traversal&&this.preprocessNode(o,e.internal.basePath,e)}};t?(this.processNodeQueue.remove(e),r(i)):this.processNodeQueue.has(e)||this.processNodeQueue.add(e,a=>{r(a.children),this._dispatchNeedsUpdateEvent()})}getBytesUsed(e){let t=0;return this.invokeAllPlugins(i=>{i.calculateBytesUsed&&(t+=i.calculateBytesUsed(e,e.engineData.scene)||0)}),t}recalculateBytesUsed(e=null){let{lruCache:t,processedTiles:i}=this;e===null?t.itemSet.forEach(r=>{i.has(r)&&t.setMemoryUsage(r,this.getBytesUsed(r))}):t.setMemoryUsage(e,this.getBytesUsed(e))}preprocessTileset(e,t,i=null){let[r,a]=e.asset.version.split(".").map(n=>parseInt(n));console.assert(r<=1,"TilesRenderer: asset.version is expected to be a 1.x or a compatible version."),r===1&&a>0&&console.warn("TilesRenderer: tiles versions at 1.1 or higher have limited support. Some new extensions and features may not be supported.");let s=t.replace(/\/[^/]*$/,"");s=new URL(s,window.location.href).toString(),this.preprocessNode(e.root,s,i)}loadRootTileset(){let e=this.rootURL;return this.invokeAllPlugins(t=>e=t.preprocessURL?t.preprocessURL(e,null):e),this.invokeOnePlugin(t=>t.fetchData&&t.fetchData(e,this.fetchOptions)).then(t=>{if(!(t instanceof Response))return t;if(t.ok)return t.json();throw Error(`TilesRenderer: Failed to load tileset "${e}" with status ${t.status} : ${t.statusText}`)}).then(t=>(this.preprocessTileset(t,e),t))}requestTileContents(e){if(e.internal.loadingState!==0)return;let t=!1,i=null,r=new URL(e.content.uri,e.internal.basePath+"/").toString();this.invokeAllPlugins(m=>r=m.preprocessURL?m.preprocessURL(r,e):r);let a=this.stats,s=this.lruCache,n=this.downloadQueue,o=this.parseQueue,l=this.loadingTiles,u=xi(r),c=new AbortController,h=c.signal;if(s.add(e,m=>{c.abort(),t?m.children.length=0:this.invokeAllPlugins(d=>{d.disposeTile&&d.disposeTile(m)}),a.inCache--,this.cachedSinceLoadComplete.has(e)&&(this.cachedSinceLoadComplete.delete(e),a.inCacheSinceLoad--),m.internal.loadingState===1?a.queued--:m.internal.loadingState===2?a.downloading--:m.internal.loadingState===3?a.parsing--:m.internal.loadingState===4&&a.loaded--,m.internal.loadingState=0,o.remove(m),n.remove(m),l.delete(m)}))return this.isLoading||(this.isLoading=!0,this.dispatchEvent({type:"tiles-load-start"})),s.setMemoryUsage(e,this.getBytesUsed(e)),this.cachedSinceLoadComplete.add(e),a.inCacheSinceLoad++,a.inCache++,a.queued++,e.internal.loadingState=1,l.add(e),n.add(r,e,m=>{if(h.aborted)return Promise.resolve();e.internal.loadingState=2,a.downloading++,a.queued--;let d=this.invokeOnePlugin(p=>p.fetchData&&p.fetchData(r,{...this.fetchOptions,signal:h}));return this.dispatchEvent({type:"tile-download-start",tile:e,url:r,get uri(){return console.warn('tile-download-start event: "uri" has been renamed to "url".'),this.url}}),d}).then(m=>{if(!h.aborted){if(!(m instanceof Response))return m;if(m.ok)return u==="json"?m.json():m.arrayBuffer();throw Error(`Failed to load model with error code ${m.status}`)}}).then(m=>{if(!h.aborted)return a.downloading--,a.parsing++,e.internal.loadingState=3,o.add(e,d=>h.aborted?Promise.resolve():u==="json"&&m.root?(this.preprocessTileset(m,r,e),e.children.push(m.root),i=m,t=!0,Promise.resolve()):this.invokeOnePlugin(p=>p.parseTile&&p.parseTile(m,d,u,r,h)))}).then(()=>{if(h.aborted)return;a.parsing--,a.loaded++,e.internal.loadingState=4,l.delete(e),s.setLoaded(e,!0);let m=this.getBytesUsed(e);if(s.getMemoryUsage(e)===0&&m>0&&s.isFull()){s.remove(e);return}s.setMemoryUsage(e,m),this.dispatchEvent({type:"needs-update"}),t&&this.dispatchEvent({type:"load-tileset",tileset:i,url:r}),e.engineData.scene&&this.dispatchEvent({type:"load-model",scene:e.engineData.scene,tile:e,url:r})}).catch(m=>{h.aborted||(m.name==="AbortError"?s.remove(e):(o.remove(e),n.remove(e),e.internal.loadingState===1?a.queued--:e.internal.loadingState===2?a.downloading--:e.internal.loadingState===3?a.parsing--:e.internal.loadingState===4&&a.loaded--,a.failed++,console.error(`TilesRenderer : Failed to load tile at url "${e.content.uri}".`),console.error(m),e.internal.loadingState=-1,l.delete(e),s.setLoaded(e,!0),this.dispatchEvent({type:"load-error",tile:e,error:m,url:r})))})}};function Ce(e){if(e===null||e.byteLength<4)return"";let t;if(t=e instanceof DataView?e:new DataView(e),String.fromCharCode(t.getUint8(0))==="{")return null;let i="";for(let r=0;r<4;r++)i+=String.fromCharCode(t.getUint8(r));return i}var Xs=new TextDecoder;function ia(e){return Xs.decode(e)}function At(e){return e.replace(/[\\/][^\\/]+$/,"")+"/"}var Be=class{constructor(){this.fetchOptions={},this.workingPath=""}loadAsync(e){return fetch(e,this.fetchOptions).then(t=>{if(!t.ok)throw Error(`Failed to load file "${e}" with status ${t.status} : ${t.statusText}`);return t.arrayBuffer()}).then(t=>(this.workingPath===""&&(this.workingPath=At(e)),this.parse(t)))}resolveExternalURL(e){return new URL(e,this.workingPath).href}parse(e){throw Error("LoaderBase: Parse not implemented.")}};function Mi(e,t,i,r,a,s){let n;switch(r){case"SCALAR":n=1;break;case"VEC2":n=2;break;case"VEC3":n=3;break;case"VEC4":n=4;break;default:throw Error(`FeatureTable : Feature type not provided for "${s}".`)}let o,l=i*n;switch(a){case"BYTE":o=new Int8Array(e,t,l);break;case"UNSIGNED_BYTE":o=new Uint8Array(e,t,l);break;case"SHORT":o=new Int16Array(e,t,l);break;case"UNSIGNED_SHORT":o=new Uint16Array(e,t,l);break;case"INT":o=new Int32Array(e,t,l);break;case"UNSIGNED_INT":o=new Uint32Array(e,t,l);break;case"FLOAT":o=new Float32Array(e,t,l);break;case"DOUBLE":o=new Float64Array(e,t,l);break;default:throw Error(`FeatureTable : Feature component type not provided for "${s}".`)}return o}var Ke=class{constructor(e,t,i,r){this.buffer=e,this.binOffset=t+i,this.binLength=r;let a=null;if(i!==0){let s=new Uint8Array(e,t,i);a=JSON.parse(ia(s))}else a={};this.header=a}getKeys(){return Object.keys(this.header).filter(e=>e!=="extensions")}getData(e,t,i=null,r=null){let a=this.header;if(!(e in a))return null;let s=a[e];if(!(s instanceof Object)||Array.isArray(s))return s;{let{buffer:n,binOffset:o,binLength:l}=this,u=s.byteOffset||0,c=s.type||r,h=s.componentType||i;if("type"in s&&r&&s.type!==r)throw Error("FeatureTable: Specified type does not match expected type.");let m=o+u,d=Mi(n,m,t,c,h,e);if(m+d.byteLength>o+l)throw Error("FeatureTable: Feature data read outside binary body length.");return d}}getBuffer(e,t){let{buffer:i,binOffset:r}=this;return i.slice(r+e,r+e+t)}},Qs=class{constructor(e){this.batchTable=e;let t=e.header.extensions["3DTILES_batch_table_hierarchy"];this.classes=t.classes;for(let r of this.classes){let a=r.instances;for(let s in a)r.instances[s]=this._parseProperty(a[s],r.length,s)}if(this.instancesLength=t.instancesLength,this.classIds=this._parseProperty(t.classIds,this.instancesLength,"classIds"),t.parentCounts?this.parentCounts=this._parseProperty(t.parentCounts,this.instancesLength,"parentCounts"):this.parentCounts=Array(this.instancesLength).fill(1),t.parentIds){let r=this.parentCounts.reduce((a,s)=>a+s,0);this.parentIds=this._parseProperty(t.parentIds,r,"parentIds")}else this.parentIds=null;this.instancesIds=[];let i={};for(let r of this.classIds)i[r]=i[r]??0,this.instancesIds.push(i[r]),i[r]++}_parseProperty(e,t,i){if(Array.isArray(e))return e;{let{buffer:r,binOffset:a}=this.batchTable,s=e.byteOffset,n=e.componentType||"UNSIGNED_SHORT";return Mi(r,a+s,t,"SCALAR",n,i)}}getDataFromId(e,t={}){let i=this.parentCounts[e];if(this.parentIds&&i>0){let o=0;for(let l=0;l<e;l++)o+=this.parentCounts[l];for(let l=0;l<i;l++){let u=this.parentIds[o+l];u!==e&&this.getDataFromId(u,t)}}let r=this.classIds[e],a=this.classes[r].instances,s=this.classes[r].name,n=this.instancesIds[e];for(let o in a)t[s]=t[s]||{},t[s][o]=a[o][n];return t}},Lt=class extends Ke{constructor(e,t,i,r,a){super(e,i,r,a),this.count=t,this.extensions={};let s=this.header.extensions;s&&s["3DTILES_batch_table_hierarchy"]&&(this.extensions["3DTILES_batch_table_hierarchy"]=new Qs(this))}getDataFromId(e,t={}){if(e<0||e>=this.count)throw Error(`BatchTable: id value "${e}" out of bounds for "${this.count}" features number.`);for(let i of this.getKeys())t[i]=super.getData(i,this.count)[e];for(let i in this.extensions){let r=this.extensions[i];r.getDataFromId instanceof Function&&(t[i]=t[i]||{},r.getDataFromId(e,t[i]))}return t}getPropertyArray(e){return super.getData(e,this.count)}},Si=class extends Be{parse(e){let t=new DataView(e),i=Ce(t);console.assert(i==="b3dm");let r=t.getUint32(4,!0);console.assert(r===1);let a=t.getUint32(8,!0);console.assert(a===e.byteLength);let s=t.getUint32(12,!0),n=t.getUint32(16,!0),o=t.getUint32(20,!0),l=t.getUint32(24,!0),u=new Ke(e.slice(28,28+s+n),0,s,n),c=28+s+n,h=new Lt(e.slice(c,c+o+l),u.getData("BATCH_LENGTH"),0,o,l),m=c+o+l;return{version:r,featureTable:u,batchTable:h,glbBytes:new Uint8Array(e,m,a-m)}}},Ci=class extends Be{parse(e){let t=new DataView(e),i=Ce(t);console.assert(i==="i3dm");let r=t.getUint32(4,!0);console.assert(r===1);let a=t.getUint32(8,!0);console.assert(a===e.byteLength);let s=t.getUint32(12,!0),n=t.getUint32(16,!0),o=t.getUint32(20,!0),l=t.getUint32(24,!0),u=t.getUint32(28,!0),c=new Ke(e.slice(32,32+s+n),0,s,n),h=32+s+n,m=new Lt(e.slice(h,h+o+l),c.getData("INSTANCES_LENGTH"),0,o,l),d=h+o+l,p=new Uint8Array(e,d,a-d),y=null,M=null,_=null;if(u)y=p,M=Promise.resolve();else{let C=this.resolveExternalURL(ia(p));_=At(C),M=fetch(C,this.fetchOptions).then(g=>{if(!g.ok)throw Error(`I3DMLoaderBase : Failed to load file "${C}" with status ${g.status} : ${g.statusText}`);return g.arrayBuffer()}).then(g=>{y=new Uint8Array(g)})}return M.then(()=>({version:r,featureTable:c,batchTable:m,glbBytes:y,gltfWorkingPath:_}))}},Ei=class extends Be{parse(e){let t=new DataView(e),i=Ce(t);console.assert(i==="pnts");let r=t.getUint32(4,!0);console.assert(r===1);let a=t.getUint32(8,!0);console.assert(a===e.byteLength);let s=t.getUint32(12,!0),n=t.getUint32(16,!0),o=t.getUint32(20,!0),l=t.getUint32(24,!0),u=new Ke(e.slice(28,28+s+n),0,s,n),c=28+s+n,h=new Lt(e.slice(c,c+o+l),u.getData("BATCH_LENGTH")||u.getData("POINTS_LENGTH"),0,o,l);return Promise.resolve({version:r,featureTable:u,batchTable:h})}},Pi=class extends Be{parse(e){let t=new DataView(e),i=Ce(t);console.assert(i==="cmpt",'CMPTLoader: The magic bytes equal "cmpt".');let r=t.getUint32(4,!0);console.assert(r===1,'CMPTLoader: The version listed in the header is "1".');let a=t.getUint32(8,!0);console.assert(a===e.byteLength,"CMPTLoader: The contents buffer length listed in the header matches the file.");let s=t.getUint32(12,!0),n=[],o=16;for(let l=0;l<s;l++){let u=new DataView(e,o,12),c=Ce(u),h=u.getUint32(4,!0),m=u.getUint32(8,!0),d=new Uint8Array(e,o,m);n.push({type:c,buffer:d,version:h}),o+=m}return{version:r,tiles:n}}};import{Box3 as ba,BufferAttribute as Pe,BufferGeometry as $s,Clock as wl,Color as Zs,DefaultLoadingManager as zt,Euler as Js,EventDispatcher as It,Frustum as Ks,Group as Fi,InstancedMesh as en,LoadingManager as tn,MathUtils as xa,Matrix3 as rn,Matrix4 as k,Mesh as Ml,OrthographicCamera as Sl,PerspectiveCamera as Cl,Plane as an,PlaneGeometry as El,Points as sn,PointsMaterial as nn,Quaternion as va,Ray as Vi,Raycaster as Pl,ShaderMaterial as Al,Sphere as _a,Spherical as on,TextureUtils as ln,Vector2 as zi,Vector3 as E}from"three";import{GLTFLoader as Ni}from"three/addons/loaders/GLTFLoader.js";import{estimateBytesUsed as hn}from"three/addons/utils/BufferGeometryUtils.js";var ji=class extends Si{constructor(e=zt){super(),this.manager=e,this.adjustmentTransform=new k}parse(e){let t=super.parse(e),i=t.glbBytes.slice().buffer;return new Promise((r,a)=>{let s=this.manager,n=this.fetchOptions,o=s.getHandler("path.gltf")||new Ni(s);n.credentials==="include"&&n.mode==="cors"&&o.setCrossOrigin("use-credentials"),"credentials"in n&&o.setWithCredentials(n.credentials==="include"),n.headers&&o.setRequestHeader(n.headers);let l=this.workingPath;!/[\\/]$/.test(l)&&l.length&&(l+="/");let u=this.adjustmentTransform;o.parse(i,l,c=>{let{batchTable:h,featureTable:m}=t,{scene:d}=c,p=m.getData("RTC_CENTER",1,"FLOAT","VEC3");p&&(d.position.x+=p[0],d.position.y+=p[1],d.position.z+=p[2]),c.scene.updateMatrix(),c.scene.matrix.multiply(u),c.scene.matrix.decompose(c.scene.position,c.scene.quaternion,c.scene.scale),c.batchTable=h,c.featureTable=m,d.batchTable=h,d.featureTable=m,r(c)},a)})}};function un(e){let t=e>>11,i=e>>5&63,r=e&31;return[Math.round(t/31*255),Math.round(i/63*255),Math.round(r/31*255)]}var et=new zi;function cn(e,t,i=new E){et.set(e,t).divideScalar(256).multiplyScalar(2).subScalar(1),i.set(et.x,et.y,1-Math.abs(et.x)-Math.abs(et.y));let r=xa.clamp(-i.z,0,1);return i.x>=0?i.setX(i.x-r):i.setX(i.x+r),i.y>=0?i.setY(i.y-r):i.setY(i.y+r),i.normalize(),i}var ra={RGB:"color",POSITION:"position"},Wi=class extends Ei{constructor(e=zt){super(),this.manager=e}parse(e){return super.parse(e).then(async t=>{let{featureTable:i,batchTable:r}=t,a=new nn,s=i.header.extensions,n=new E,o;if(s&&s["3DTILES_draco_point_compression"]){let{byteOffset:c,byteLength:h,properties:m}=s["3DTILES_draco_point_compression"],d=this.manager.getHandler("draco.drc");if(d==null)throw Error("PNTSLoader: dracoLoader not available.");let p={};for(let _ in m)if(_ in ra&&_ in m){let C=ra[_];p[C]=m[_]}let y={attributeIDs:p,attributeTypes:{position:"Float32Array",color:"Uint8Array"},useUniqueIDs:!0},M=i.getBuffer(c,h);o=await d.decodeGeometry(M,y),o.attributes.color&&(a.vertexColors=!0)}else{let c=i.getData("POINTS_LENGTH"),h=i.getData("POSITION",c,"FLOAT","VEC3"),m=i.getData("NORMAL",c,"FLOAT","VEC3"),d=i.getData("NORMAL",c,"UNSIGNED_BYTE","VEC2"),p=i.getData("RGB",c,"UNSIGNED_BYTE","VEC3"),y=i.getData("RGBA",c,"UNSIGNED_BYTE","VEC4"),M=i.getData("RGB565",c,"UNSIGNED_SHORT","SCALAR"),_=i.getData("CONSTANT_RGBA",c,"UNSIGNED_BYTE","VEC4"),C=i.getData("POSITION_QUANTIZED",c,"UNSIGNED_SHORT","VEC3"),g=i.getData("QUANTIZED_VOLUME_SCALE",c,"FLOAT","VEC3"),P=i.getData("QUANTIZED_VOLUME_OFFSET",c,"FLOAT","VEC3");if(o=new $s,C){let S=new Float32Array(c*3);for(let v=0;v<c;v++)for(let L=0;L<3;L++){let w=3*v+L;S[w]=C[w]/65535*g[L]}n.x=P[0],n.y=P[1],n.z=P[2],o.setAttribute("position",new Pe(S,3,!1))}else o.setAttribute("position",new Pe(h,3,!1));if(m!==null)o.setAttribute("normal",new Pe(m,3,!1));else if(d!==null){let S=new Float32Array(c*3),v=new E;for(let L=0;L<c;L++){let w=d[L*2],U=d[L*2+1],O=cn(w,U,v);S[L*3]=O.x,S[L*3+1]=O.y,S[L*3+2]=O.z}o.setAttribute("normal",new Pe(S,3,!1))}if(y!==null)o.setAttribute("color",new Pe(y,4,!0)),a.vertexColors=!0,a.transparent=!0,a.depthWrite=!1;else if(p!==null)o.setAttribute("color",new Pe(p,3,!0)),a.vertexColors=!0;else if(M!==null){let S=new Uint8Array(c*3);for(let v=0;v<c;v++){let L=un(M[v]);for(let w=0;w<3;w++){let U=3*v+w;S[U]=L[w]}}o.setAttribute("color",new Pe(S,3,!0)),a.vertexColors=!0}else if(_!==null){a.color=new Zs(_[0],_[1],_[2]);let S=_[3]/255;S<1&&(a.opacity=S,a.transparent=!0,a.depthWrite=!1)}}let l=new sn(o,a);l.position.copy(n),t.scene=l,t.scene.featureTable=i,t.scene.batchTable=r;let u=i.getData("RTC_CENTER",1,"FLOAT","VEC3");return u&&(t.scene.position.x+=u[0],t.scene.position.y+=u[1],t.scene.position.z+=u[2]),t})}};function dn(e){let{x:t,y:i,z:r}=e;e.x=r,e.y=t,e.z=i}function pn(e){return-e+Math.PI/2}var aa=new on,ge=new E,j=new E,Ai=new E,Z=new k,re=new k,Li=new _a,G=new Js,sa=new E,na=new E,oa=new E,tt=new E,Dt=new Vi,mn=1e-12,gn=.1;var Gi=class{constructor(e=1,t=1,i=1){this.name="",this.radius=new E(e,t,i)}intersectRay(e,t){return Z.makeScale(...this.radius).invert(),Li.center.set(0,0,0),Li.radius=1,Dt.copy(e).applyMatrix4(Z),Dt.intersectSphere(Li,t)?(Z.makeScale(...this.radius),t.applyMatrix4(Z),t):null}getEastNorthUpFrame(e,t,i,r){return i.isMatrix4&&(r=i,i=0,console.warn('Ellipsoid: The signature for "getEastNorthUpFrame" has changed.')),this.getEastNorthUpAxes(e,t,sa,na,oa),this.getCartographicToPosition(e,t,i,tt),r.makeBasis(sa,na,oa).setPosition(tt)}getOrientedEastNorthUpFrame(e,t,i,r,a,s,n){return this.getObjectFrame(e,t,i,r,a,s,n,0)}getObjectFrame(e,t,i,r,a,s,n,o=2){return this.getEastNorthUpFrame(e,t,i,Z),G.set(a,s,-r,"ZXY"),n.makeRotationFromEuler(G).premultiply(Z),o===1?(G.set(Math.PI/2,0,0,"XYZ"),re.makeRotationFromEuler(G),n.multiply(re)):o===2&&(G.set(-Math.PI/2,0,Math.PI,"XYZ"),re.makeRotationFromEuler(G),n.multiply(re)),n}getCartographicFromObjectFrame(e,t,i=2){return i===1?(G.set(-Math.PI/2,0,0,"XYZ"),re.makeRotationFromEuler(G).premultiply(e)):i===2?(G.set(-Math.PI/2,0,Math.PI,"XYZ"),re.makeRotationFromEuler(G).premultiply(e)):re.copy(e),tt.setFromMatrixPosition(re),this.getPositionToCartographic(tt,t),this.getEastNorthUpFrame(t.lat,t.lon,0,Z).invert(),re.premultiply(Z),G.setFromRotationMatrix(re,"ZXY"),t.azimuth=-G.z,t.elevation=G.x,t.roll=G.y,t}getEastNorthUpAxes(e,t,i,r,a,s=tt){this.getCartographicToPosition(e,t,0,s),this.getCartographicToNormal(e,t,a),i.set(-s.y,s.x,0).normalize(),r.crossVectors(a,i).normalize()}getCartographicToPosition(e,t,i,r){this.getCartographicToNormal(e,t,ge);let a=this.radius;j.copy(ge),j.x*=a.x**2,j.y*=a.y**2,j.z*=a.z**2;let s=Math.sqrt(ge.dot(j));return j.divideScalar(s),r.copy(j).addScaledVector(ge,i)}getPositionToCartographic(e,t){this.getPositionToSurfacePoint(e,j),this.getPositionToNormal(j,ge);let i=Ai.subVectors(e,j);return t.lon=Math.atan2(ge.y,ge.x),t.lat=Math.asin(ge.z),t.height=Math.sign(i.dot(e))*i.length(),t}getCartographicToNormal(e,t,i){return aa.set(1,pn(e),t),i.setFromSpherical(aa).normalize(),dn(i),i}getPositionToNormal(e,t){let i=this.radius;return t.copy(e),t.x/=i.x**2,t.y/=i.y**2,t.z/=i.z**2,t.normalize(),t}getPositionToSurfacePoint(e,t){let i=this.radius,r=1/i.x**2,a=1/i.y**2,s=1/i.z**2,n=e.x*e.x*r,o=e.y*e.y*a,l=e.z*e.z*s,u=n+o+l,c=Math.sqrt(1/u),h=j.copy(e).multiplyScalar(c);if(u<gn)return isFinite(c)?t.copy(h):null;let m=Ai.set(h.x*r*2,h.y*a*2,h.z*s*2),d=(1-c)*e.length()/(.5*m.length()),p=0,y,M,_,C,g,P,S,v,L,w,U;do{d-=p,_=1/(1+d*r),C=1/(1+d*a),g=1/(1+d*s),P=_*_,S=C*C,v=g*g,L=P*_,w=S*C,U=v*g,y=n*P+o*S+l*v-1,M=n*L*r+o*w*a+l*U*s;let O=-2*M;p=y/O}while(Math.abs(y)>mn);return t.set(e.x*_,e.y*C,e.z*g)}calculateHorizonDistance(e,t){let i=this.calculateEffectiveRadius(e);return Math.sqrt(2*i*t+t**2)}calculateEffectiveRadius(e){let t=this.radius.x,i=1-this.radius.z**2/t**2,r=e*xa.DEG2RAD,a=Math.sin(r)**2;return t/Math.sqrt(1-i*a)}getPositionElevation(e){this.getPositionToSurfacePoint(e,j);let t=Ai.subVectors(e,j);return Math.sign(t.dot(e))*t.length()}closestPointToRayEstimate(e,t){return this.intersectRay(e,t)?t:(Z.makeScale(...this.radius).invert(),Dt.copy(e).applyMatrix4(Z),j.set(0,0,0),Dt.closestPointToPoint(j,t).normalize(),Z.makeScale(...this.radius),t.applyMatrix4(Z))}copy(e){return this.radius.copy(e.radius),this}clone(){return new this.constructor().copy(this)}},nt=new Gi(Ee,Ee,_i);nt.name="WGS84 Earth";var Rt=new E,ke=new E,Fe=new E,Ii=new E,Ot=new va,Ut=new E,Ve=new k,la=new k,ha=new E,ua=new k,Di=new va,Ri={};function ca(e,t,i,r){if(e=e/i*2-1,t=t/i*2-1,r.x=e,r.y=t,r.z=1-Math.abs(e)-Math.abs(t),r.z<0){let a=r.x;r.x=(1-Math.abs(r.y))*(a>=0?1:-1),r.y=(1-Math.abs(a))*(r.y>=0?1:-1)}return r.normalize(),r}var qi=class extends Ci{constructor(e=zt){super(),this.manager=e,this.adjustmentTransform=new k,this.ellipsoid=nt.clone()}resolveExternalURL(e){return this.manager.resolveURL(super.resolveExternalURL(e))}parse(e){return super.parse(e).then(t=>{let{featureTable:i,batchTable:r}=t,a=t.glbBytes.slice().buffer;return new Promise((s,n)=>{let o=this.fetchOptions,l=this.manager,u=l.getHandler("path.gltf")||new Ni(l);o.credentials==="include"&&o.mode==="cors"&&u.setCrossOrigin("use-credentials"),"credentials"in o&&u.setWithCredentials(o.credentials==="include"),o.headers&&u.setRequestHeader(o.headers);let c=t.gltfWorkingPath??this.workingPath;/[\\/]$/.test(c)||(c+="/");let h=this.adjustmentTransform;u.parse(a,c,m=>{let d=i.getData("INSTANCES_LENGTH"),p=i.getData("POSITION",d,"FLOAT","VEC3"),y=i.getData("POSITION_QUANTIZED",d,"UNSIGNED_SHORT","VEC3"),M=i.getData("QUANTIZED_VOLUME_OFFSET",1,"FLOAT","VEC3"),_=i.getData("QUANTIZED_VOLUME_SCALE",1,"FLOAT","VEC3"),C=i.getData("NORMAL_UP",d,"FLOAT","VEC3"),g=i.getData("NORMAL_RIGHT",d,"FLOAT","VEC3"),P=i.getData("NORMAL_UP_OCT32P",d,"UNSIGNED_SHORT","VEC2"),S=i.getData("NORMAL_RIGHT_OCT32P",d,"UNSIGNED_SHORT","VEC2"),v=i.getData("SCALE_NON_UNIFORM",d,"FLOAT","VEC3"),L=i.getData("SCALE",d,"FLOAT","SCALAR"),w=i.getData("RTC_CENTER",1,"FLOAT","VEC3"),U=i.getData("EAST_NORTH_UP");if(!p&&y){p=new Float32Array(d*3);for(let f=0;f<d;f++)p[f*3+0]=M[0]+y[f*3+0]/65535*_[0],p[f*3+1]=M[1]+y[f*3+1]/65535*_[1],p[f*3+2]=M[2]+y[f*3+2]/65535*_[2]}let O=new E;for(let f=0;f<d;f++)O.x+=p[f*3+0]/d,O.y+=p[f*3+1]/d,O.z+=p[f*3+2]/d;let V=[],ue=[];m.scene.updateMatrixWorld(),m.scene.traverse(f=>{if(f.isMesh){ue.push(f);let{geometry:J,material:Le}=f,Q=new en(J,Le,d);Q.position.copy(O),w&&(Q.position.x+=w[0],Q.position.y+=w[1],Q.position.z+=w[2]),V.push(Q)}});for(let f=0;f<d;f++){Ii.set(p[f*3+0]-O.x,p[f*3+1]-O.y,p[f*3+2]-O.z),Ot.identity(),C&&g?(ke.set(C[f*3+0],C[f*3+1],C[f*3+2]),Fe.set(g[f*3+0],g[f*3+1],g[f*3+2]),Rt.crossVectors(Fe,ke).normalize(),Ve.makeBasis(Fe,ke,Rt),Ot.setFromRotationMatrix(Ve)):P&&S&&(ca(P[f*2+0],P[f*2+1],65535,ke),ca(S[f*2+0],S[f*2+1],65535,Fe),Rt.crossVectors(Fe,ke).normalize(),Ve.makeBasis(Fe,ke,Rt),Ot.setFromRotationMatrix(Ve)),Ut.set(1,1,1),v&&Ut.set(v[f*3+0],v[f*3+1],v[f*3+2]),L&&Ut.multiplyScalar(L[f]);for(let J=0,Le=V.length;J<Le;J++){let Q=V[J];Di.copy(Ot),U&&(Q.updateMatrixWorld(),ha.copy(Ii).applyMatrix4(Q.matrixWorld),this.ellipsoid.getPositionToCartographic(ha,Ri),this.ellipsoid.getEastNorthUpFrame(Ri.lat,Ri.lon,ua),Di.setFromRotationMatrix(ua)),Ve.compose(Ii,Di,Ut).multiply(h);let $=ue[J];la.multiplyMatrices(Ve,$.matrixWorld),Q.setMatrixAt(f,la)}}m.scene.clear(),m.scene.add(...V),m.batchTable=r,m.featureTable=i,m.scene.batchTable=r,m.scene.featureTable=i,s(m)},n)})})}},Ta=class extends Pi{constructor(e=zt){super(),this.manager=e,this.adjustmentTransform=new k,this.ellipsoid=nt.clone()}parse(e){let t=super.parse(e),{manager:i,ellipsoid:r,adjustmentTransform:a}=this,s=[];for(let n in t.tiles){let{type:o,buffer:l}=t.tiles[n];switch(o){case"b3dm":{let u=l.slice(),c=new ji(i);c.workingPath=this.workingPath,c.fetchOptions=this.fetchOptions,c.adjustmentTransform.copy(a);let h=c.parse(u.buffer);s.push(h);break}case"pnts":{let u=l.slice(),c=new Wi(i);c.workingPath=this.workingPath,c.fetchOptions=this.fetchOptions;let h=c.parse(u.buffer);s.push(h);break}case"i3dm":{let u=l.slice(),c=new qi(i);c.workingPath=this.workingPath,c.fetchOptions=this.fetchOptions,c.ellipsoid.copy(r),c.adjustmentTransform.copy(a);let h=c.parse(u.buffer);s.push(h);break}}}return Promise.all(s).then(n=>{let o=new Fi;return n.forEach(l=>{o.add(l.scene)}),{tiles:n,scene:o}})}},it=new k,fn=class extends Fi{constructor(e){super(),this.isTilesGroup=!0,this.name="TilesRenderer.TilesGroup",this.tilesRenderer=e,this.matrixWorldInverse=new k}raycast(e,t){return this.tilesRenderer.raycast(e,t),!1}updateMatrixWorld(e){if(this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldNeedsUpdate||e){this.parent===null?it.copy(this.matrix):it.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1;let t=it.elements,i=this.matrixWorld.elements,r=!1;for(let a=0;a<16;a++){let s=t[a],n=i[a];if(Math.abs(s-n)>2**-52){r=!0;break}}if(r){this.matrixWorld.copy(it),this.matrixWorldInverse.copy(it).invert();let a=this.children;for(let l=0,u=a.length;l<u;l++)a[l].updateMatrixWorld();let{tilesRenderer:s}=this,{activeTiles:n,visibleTiles:o}=s;n.forEach(l=>{o.has(l)||l.engineData.scene.updateMatrixWorld(!0)})}}}updateWorldMatrix(e,t){this.parent&&e&&this.parent.updateWorldMatrix(e,!1),this.updateMatrixWorld(!0)}},yn=new Vi;function bn(e,t,i,r){let{scene:a}=e.engineData;i.invokeOnePlugin(s=>s.raycastTile&&s.raycastTile(e,a,t,r))||t.intersectObject(a,!0,r)}function xn(e){return"traversal"in e}function wa(e,t,i,r,a=null){if(!xn(t))return;let{group:s,activeTiles:n}=e,{boundingVolume:o}=t.engineData;if(a===null&&(a=yn,a.copy(i.ray).applyMatrix4(s.matrixWorldInverse)),!t.traversal.used||!o.intersectsRay(a))return;n.has(t)&&bn(t,i,e,r);let l=t.children;for(let u=0,c=l.length;u<c;u++)wa(e,l[u],i,r,a)}var Bt=new E,kt=new E,q=new E,Ft=new Vi,Bi=class{constructor(e=new ba,t=new k){this.box=e.clone(),this.transform=t.clone(),this.inverseTransform=new k,this.points=Array(8).fill().map(()=>new E),this.planes=[,,,,,,].fill().map(()=>new an)}copy(e){return this.box.copy(e.box),this.transform.copy(e.transform),this.update(),this}clone(){return new this.constructor().copy(this)}clampPoint(e,t){return t.copy(e).applyMatrix4(this.inverseTransform).clamp(this.box.min,this.box.max).applyMatrix4(this.transform)}distanceToPoint(e){return this.clampPoint(e,q).distanceTo(e)}containsPoint(e){return q.copy(e).applyMatrix4(this.inverseTransform),this.box.containsPoint(q)}intersectsRay(e){return Ft.copy(e).applyMatrix4(this.inverseTransform),Ft.intersectsBox(this.box)}intersectRay(e,t){return Ft.copy(e).applyMatrix4(this.inverseTransform),Ft.intersectBox(this.box,t)?(t.applyMatrix4(this.transform),t):null}update(){let{points:e,inverseTransform:t,transform:i,box:r}=this;t.copy(i).invert();let{min:a,max:s}=r,n=0;for(let o=-1;o<=1;o+=2)for(let l=-1;l<=1;l+=2)for(let u=-1;u<=1;u+=2)e[n].set(o<0?a.x:s.x,l<0?a.y:s.y,u<0?a.z:s.z).applyMatrix4(i),n++;this.updatePlanes()}updatePlanes(){Bt.copy(this.box.min).applyMatrix4(this.transform),kt.copy(this.box.max).applyMatrix4(this.transform),q.set(0,0,1).transformDirection(this.transform),this.planes[0].setFromNormalAndCoplanarPoint(q,Bt),this.planes[1].setFromNormalAndCoplanarPoint(q,kt).negate(),q.set(0,1,0).transformDirection(this.transform),this.planes[2].setFromNormalAndCoplanarPoint(q,Bt),this.planes[3].setFromNormalAndCoplanarPoint(q,kt).negate(),q.set(1,0,0).transformDirection(this.transform),this.planes[4].setFromNormalAndCoplanarPoint(q,Bt),this.planes[5].setFromNormalAndCoplanarPoint(q,kt).negate()}intersectsSphere(e){return this.clampPoint(e.center,q),q.distanceToSquared(e.center)<=e.radius*e.radius}intersectsFrustum(e){return this._intersectsPlaneShape(e.planes,e.points)}intersectsOBB(e){return this._intersectsPlaneShape(e.planes,e.points)}_intersectsPlaneShape(e,t){let i=this.points,r=this.planes;for(let a=0;a<6;a++){let s=e[a],n=-1/0;for(let o=0;o<8;o++){let l=i[o],u=s.distanceToPoint(l);n=n<u?u:n}if(n<0)return!1}for(let a=0;a<6;a++){let s=r[a],n=-1/0;for(let o=0;o<8;o++){let l=t[o],u=s.distanceToPoint(l);n=n<u?u:n}if(n<0)return!1}return!0}},st=Math.PI,Oi=st/2,rt=new E,Ae=new E,K=new E,T=new E,W=new k,vn=new ba,da=new k;function fe(e,t){t.radius=Math.max(t.radius,e.distanceToSquared(t.center))}function pa(e){return e.x!==e.y}var Ma=class extends Gi{constructor(e=1,t=1,i=1,r=-Oi,a=Oi,s=0,n=2*st,o=0,l=0){super(e,t,i),this.latStart=r,this.latEnd=a,this.lonStart=s,this.lonEnd=n,this.heightStart=o,this.heightEnd=l}getBoundingBox(e,t){pa(this.radius)&&console.warn("EllipsoidRegion: Triaxial ellipsoids are not supported.");let{latStart:i,latEnd:r,lonStart:a,lonEnd:s,heightStart:n,heightEnd:o}=this,l=(i+r)*.5,u=(a+s)*.5,c=i>0,h=r<0,m;m=c?i:h?r:0;let{min:d,max:p}=e;d.setScalar(1/0),p.setScalar(-1/0),s-a<=st?(this.getCartographicToNormal(l,u,K),Ae.set(0,0,1),rt.crossVectors(Ae,K).normalize(),Ae.crossVectors(K,rt).normalize(),t.makeBasis(rt,Ae,K),W.copy(t).invert(),this.getCartographicToPosition(m,a,o,T).applyMatrix4(W),p.x=Math.abs(T.x),d.x=-p.x,this.getCartographicToPosition(r,a,o,T).applyMatrix4(W),p.y=T.y,this.getCartographicToPosition(r,u,o,T).applyMatrix4(W),p.y=Math.max(T.y,p.y),this.getCartographicToPosition(i,a,o,T).applyMatrix4(W),d.y=T.y,this.getCartographicToPosition(i,u,o,T).applyMatrix4(W),d.y=Math.min(T.y,d.y),this.getCartographicToPosition(l,u,o,T).applyMatrix4(W),p.z=T.z,this.getCartographicToPosition(i,a,n,T).applyMatrix4(W),d.z=T.z,this.getCartographicToPosition(r,a,n,T).applyMatrix4(W),d.z=Math.min(T.z,d.z)):(this.getCartographicToPosition(m,u,o,K),K.z=0,K.length()<1e-10?K.set(1,0,0):K.normalize(),Ae.set(0,0,1),rt.crossVectors(K,Ae).normalize(),t.makeBasis(rt,Ae,K),W.copy(t).invert(),this.getCartographicToPosition(m,u+Oi,o,T).applyMatrix4(W),p.x=Math.abs(T.x),d.x=-p.x,this.getCartographicToPosition(r,0,h?n:o,T).applyMatrix4(W),p.y=T.y,this.getCartographicToPosition(i,0,c?n:o,T).applyMatrix4(W),d.y=T.y,this.getCartographicToPosition(m,u,o,T).applyMatrix4(W),p.z=T.z,this.getCartographicToPosition(m,s,o,T).applyMatrix4(W),d.z=T.z),e.getCenter(T),e.min.sub(T).multiplyScalar(1.0000000000001),e.max.sub(T).multiplyScalar(1.0000000000001),T.applyMatrix4(t),t.setPosition(T)}getBoundingSphere(e){pa(this.radius)&&console.warn("EllipsoidRegion: Triaxial ellipsoids are not supported."),this.getBoundingBox(vn,da),e.center.setFromMatrixPosition(da),e.radius=0;let{latStart:t,latEnd:i,lonStart:r,lonEnd:a,heightStart:s,heightEnd:n}=this,o=(t+i)*.5,l=(r+a)*.5,u=t>0,c=i<0,h;h=u?t:c?i:0,this.getCartographicToPosition(h,r,n,T),fe(T,e),this.getCartographicToPosition(i,r,n,T),fe(T,e),this.getCartographicToPosition(i,l,n,T),fe(T,e),this.getCartographicToPosition(t,r,n,T),fe(T,e),this.getCartographicToPosition(t,l,n,T),fe(T,e),this.getCartographicToPosition(o,l,n,T),fe(T,e),this.getCartographicToPosition(t,r,s,T),fe(T,e),a-r>st&&(this.getCartographicToPosition(h,l+st,n,T),fe(T,e)),e.radius=Math.sqrt(e.radius)*1.0000000000001}},oe=new E,le=new E,he=new E,ma=new E,ga=new E,_n=class{constructor(){this.sphere=null,this.obb=null,this.region=null,this.regionObb=null}intersectsRay(e){let t=this.sphere,i=this.obb||this.regionObb;return!(t&&!e.intersectsSphere(t)||i&&!i.intersectsRay(e))}intersectRay(e,t=null){let i=this.sphere,r=this.obb||this.regionObb,a=-1/0,s=-1/0;i&&e.intersectSphere(i,ma)&&(a=i.containsPoint(e.origin)?0:e.origin.distanceToSquared(ma)),r&&r.intersectRay(e,ga)&&(s=r.containsPoint(e.origin)?0:e.origin.distanceToSquared(ga));let n=Math.max(a,s);return n===-1/0?null:(e.at(Math.sqrt(n),t),t)}distanceToPoint(e){let t=this.sphere,i=this.obb||this.regionObb,r=-1/0,a=-1/0;return t&&(r=Math.max(t.distanceToPoint(e),0)),i&&(a=i.distanceToPoint(e)),r>a?r:a}intersectsFrustum(e){let t=this.obb||this.regionObb,i=this.sphere;return i&&!e.intersectsSphere(i)||t&&!t.intersectsFrustum(e)?!1:!!(i||t)}intersectsSphere(e){let t=this.obb||this.regionObb,i=this.sphere;return i&&!i.intersectsSphere(e)||t&&!t.intersectsSphere(e)?!1:!!(i||t)}intersectsOBB(e){let t=this.obb||this.regionObb,i=this.sphere;return i&&!e.intersectsSphere(i)||t&&!t.intersectsOBB(e)?!1:!!(i||t)}getOBB(e,t){let i=this.obb||this.regionObb;i?(e.copy(i.box),t.copy(i.transform)):(this.getAABB(e),t.identity())}getAABB(e){if(this.sphere)this.sphere.getBoundingBox(e);else{let t=this.obb||this.regionObb;e.copy(t.box).applyMatrix4(t.transform)}}getSphere(e){if(this.sphere)e.copy(this.sphere);else if(this.region)this.region.getBoundingSphere(e);else{let t=this.obb||this.regionObb;t.box.getBoundingSphere(e),e.applyMatrix4(t.transform)}}setObbData(e,t){let i=new Bi;oe.set(e[3],e[4],e[5]),le.set(e[6],e[7],e[8]),he.set(e[9],e[10],e[11]);let r=oe.length(),a=le.length(),s=he.length();oe.normalize(),le.normalize(),he.normalize(),r===0&&oe.crossVectors(le,he),a===0&&le.crossVectors(oe,he),s===0&&he.crossVectors(oe,le),i.transform.set(oe.x,le.x,he.x,e[0],oe.y,le.y,he.y,e[1],oe.z,le.z,he.z,e[2],0,0,0,1).premultiply(t),i.box.min.set(-r,-a,-s),i.box.max.set(r,a,s),i.update(),this.obb=i}setSphereData(e,t,i,r,a){let s=new _a;s.center.set(e,t,i),s.radius=r,s.applyMatrix4(a),this.sphere=s}setRegionData(e,t,i,r,a,s,n){let o=new Ma(...e.radius,i,a,t,r,s,n),l=new Bi;o.getBoundingBox(l.box,l.transform),l.update(),this.region=o,this.regionObb=l}},Tn=new rn;function wn(e,t,i,r){let a=Tn.set(e.normal.x,e.normal.y,e.normal.z,t.normal.x,t.normal.y,t.normal.z,i.normal.x,i.normal.y,i.normal.z);return r.set(-e.constant,-t.constant,-i.constant),r.applyMatrix3(a.invert()),r}var Mn=class extends Ks{constructor(){super(),this.points=Array(8).fill().map(()=>new E)}setFromProjectionMatrix(...e){return super.setFromProjectionMatrix(...e),this.calculateFrustumPoints(),this}calculateFrustumPoints(){let{planes:e,points:t}=this;[[e[0],e[3],e[4]],[e[1],e[3],e[4]],[e[0],e[2],e[4]],[e[1],e[2],e[4]],[e[0],e[3],e[5]],[e[1],e[3],e[5]],[e[0],e[2],e[5]],[e[1],e[2],e[5]]].forEach((i,r)=>{wn(i[0],i[1],i[2],t[r])})}};var ki=0;function fa(e,t,i,r){try{return ln.getByteLength(e,t,i,r)}catch{return ki}}function Sn(e){if(!e)return 0;if(e.isExternalTexture)return e.userData?.byteLength??ki;let{format:t,type:i,image:r,mipmaps:a}=e;if(e.isCompressedTexture&&Array.isArray(a)&&a.length>0){let n=0;for(let o of a)o?.data?.byteLength?n+=o.data.byteLength:n+=fa(o.width,o.height,t,i);return n}if(!r)return ki;let s=fa(r.width,r.height,t,i);return s*=e.generateMipmaps?4/3:1,s}function Cn(e){let t=new Set,i=0;return e.traverse(r=>{if(r.geometry&&!t.has(r.geometry)&&(i+=hn(r.geometry),t.add(r.geometry)),r.material){let a=r.material;for(let s in a){let n=a[s];n&&n.isTexture&&!t.has(n)&&(i+=Sn(n),t.add(n))}}}),i}var Sa=Symbol("INITIAL_FRUSTUM_CULLED"),Vt=new k,at=new E,Ui=new zi,En=new E(1,0,0),Pn=new E(0,1,0),An=()=>null;function ya(e,t){e.traverse(i=>{i.frustumCulled=i[Sa]&&t})}var Hi=class extends wi{get autoDisableRendererCulling(){return this._autoDisableRendererCulling}set autoDisableRendererCulling(e){this._autoDisableRendererCulling!==e&&(super._autoDisableRendererCulling=e,this.forEachLoadedModel(t=>{ya(t,!e)}))}constructor(...e){super(...e),this.accelerateRaycast=!0,this.group=new fn(this),this.ellipsoid=nt.clone(),this.cameras=[],this.cameraMap=new Map,this.cameraInfo=[],this._upRotationMatrix=new k,this._bytesUsed=new WeakMap,this._autoDisableRendererCulling=!0,this.manager=new tn,this._listeners={}}addEventListener(e,t){It.prototype.addEventListener.call(this,e,t)}hasEventListener(e,t){return It.prototype.hasEventListener.call(this,e,t)}removeEventListener(e,t){It.prototype.removeEventListener.call(this,e,t)}dispatchEvent(e){It.prototype.dispatchEvent.call(this,e)}getBoundingBox(e){if(!this.root)return!1;let t=this.root.engineData.boundingVolume;return t?(t.getAABB(e),!0):!1}getOrientedBoundingBox(e,t){if(!this.root)return!1;let i=this.root.engineData.boundingVolume;return i?(i.getOBB(e,t),!0):!1}getBoundingSphere(e){if(!this.root)return!1;let t=this.root.engineData.boundingVolume;return t?(t.getSphere(e),!0):!1}forEachLoadedModel(e){this.traverse(t=>{let i=t.engineData&&t.engineData.scene;i&&e(i,t)},null,!1)}raycast(e,t){if(this.root)if(this.accelerateRaycast)wa(this,this.root,e,t);else{let i=e.firstHitOnly?[]:t;for(let r of this.activeTiles){let{scene:a}=r.engineData;this.invokeOnePlugin(s=>s.raycastTile&&s.raycastTile(r,a,e,i))||e.intersectObject(a,!0,i)}e.firstHitOnly&&i.length>0&&(i.sort((r,a)=>r.distance-a.distance),t.push(i[0]))}}hasCamera(e){return this.cameraMap.has(e)}setCamera(e){let t=this.cameras,i=this.cameraMap;return i.has(e)?!1:(i.set(e,new zi),t.push(e),this.dispatchEvent({type:"add-camera",camera:e}),!0)}setResolution(e,t,i){let r=this.cameraMap;if(!r.has(e))return!1;let a=t.isVector2?t.x:t,s=t.isVector2?t.y:i,n=r.get(e);return(n.width!==a||n.height!==s)&&(n.set(a,s),this.dispatchEvent({type:"camera-resolution-change"})),!0}getResolution(e,t){let i=this.cameraMap.get(e);return i?t.copy(i):null}setResolutionFromRenderer(e,t){return t.getSize(Ui),this.setResolution(e,Ui.x,Ui.y)}deleteCamera(e){let t=this.cameras,i=this.cameraMap;if(i.has(e)){let r=t.indexOf(e);return t.splice(r,1),i.delete(e),this.dispatchEvent({type:"delete-camera",camera:e}),!0}return!1}loadRootTileset(...e){return super.loadRootTileset(...e).then(t=>{let{asset:i,extensions:r={}}=t;switch((i&&i.gltfUpAxis||"y").toLowerCase()){case"x":this._upRotationMatrix.makeRotationAxis(Pn,-Math.PI/2);break;case"y":this._upRotationMatrix.makeRotationAxis(En,Math.PI/2);break}if("3DTILES_ellipsoid"in r){let a=r["3DTILES_ellipsoid"],{ellipsoid:s}=this;s.name=a.body,a.radii?s.radius.set(...a.radii):s.radius.set(1,1,1)}return t})}prepareForTraversal(){let e=this.group,t=this.cameras,i=this.cameraMap,r=this.cameraInfo;for(;r.length>t.length;)r.pop();for(;r.length<t.length;)r.push({frustum:new Mn,isOrthographic:!1,sseDenominator:-1,position:new E,invScale:-1,pixelSize:0});at.setFromMatrixScale(e.matrixWorldInverse),Math.abs(Math.max(at.x-at.y,at.x-at.z))>1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when calculating screen space error.");for(let a=0,s=r.length;a<s;a++){let n=t[a],o=r[a],l=o.frustum,u=o.position,c=i.get(n);(c.width===0||c.height===0)&&console.warn("TilesRenderer: resolution for camera error calculation is not set.");let h=n.projectionMatrix.elements;if(o.isOrthographic=h[15]===1,o.isOrthographic){let m=2/h[0],d=2/h[5];o.pixelSize=Math.max(d/c.height,m/c.width)}else o.sseDenominator=2/h[5]/c.height;Vt.copy(e.matrixWorld),Vt.premultiply(n.matrixWorldInverse),Vt.premultiply(n.projectionMatrix),l.setFromProjectionMatrix(Vt,n.coordinateSystem,n.reversedDepth),u.set(0,0,0),u.applyMatrix4(n.matrixWorld),u.applyMatrix4(e.matrixWorldInverse)}}update(){if(super.update(),this.cameras.length===0&&this.root){let e=!1;this.invokeAllPlugins(t=>e||(e=!!(t!==this&&t.calculateTileViewError))),e===!1&&console.warn("TilesRenderer: no cameras defined. Cannot update 3d tiles.")}}preprocessNode(e,t,i=null){super.preprocessNode(e,t,i);let r=new k;if(e.transform){let n=e.transform;for(let o=0;o<16;o++)r.elements[o]=n[o]}i&&r.premultiply(i.engineData.transform);let a=new k().copy(r).invert(),s=new _n;"sphere"in e.boundingVolume&&s.setSphereData(...e.boundingVolume.sphere,r),"box"in e.boundingVolume&&s.setObbData(e.boundingVolume.box,r),"region"in e.boundingVolume&&s.setRegionData(this.ellipsoid,...e.boundingVolume.region),e.engineData.transform=r,e.engineData.transformInverse=a,e.engineData.boundingVolume=s,e.engineData.geometry=null,e.engineData.materials=null,e.engineData.textures=null,e.toJSON=An}async parseTile(e,t,i,r,a){let s=t.engineData,n=At(r),o=this.fetchOptions,l=this.manager,u=null,c=s.transform,h=this._upRotationMatrix,m=(Ce(e)||i).toLowerCase();switch(m){case"b3dm":{let g=new ji(l);g.workingPath=n,g.fetchOptions=o,g.adjustmentTransform.copy(h),u=g.parse(e);break}case"pnts":{let g=new Wi(l);g.workingPath=n,g.fetchOptions=o,u=g.parse(e);break}case"i3dm":{let g=new qi(l);g.workingPath=n,g.fetchOptions=o,g.adjustmentTransform.copy(h),g.ellipsoid.copy(this.ellipsoid),u=g.parse(e);break}case"cmpt":{let g=new Ta(l);g.workingPath=n,g.fetchOptions=o,g.adjustmentTransform.copy(h),g.ellipsoid.copy(this.ellipsoid),u=g.parse(e).then(P=>P.scene);break}case"gltf":case"glb":{let g=l.getHandler("path.gltf")||l.getHandler("path.glb")||new Ni(l);g.setWithCredentials(o.credentials==="include"),g.setRequestHeader(o.headers||{}),o.credentials==="include"&&o.mode==="cors"&&g.setCrossOrigin("use-credentials");let P=g.resourcePath||g.path||n;!/[\\/]$/.test(P)&&P.length&&(P+="/"),u=g.parseAsync(e,P).then(S=>{S.scene=S.scene||new Fi;let{scene:v}=S;return v.updateMatrix(),v.matrix.multiply(h).decompose(v.position,v.quaternion,v.scale),S});break}default:u=this.invokeOnePlugin(g=>g.parseToMesh&&g.parseToMesh(e,t,i,r,a));break}let d=await u;if(d===null)throw Error(`TilesRenderer: Content type "${m}" not supported.`);let p,y;d.isObject3D?(p=d,y=null):(p=d.scene,y=d),p.updateMatrix(),p.matrix.premultiply(c),p.matrix.decompose(p.position,p.quaternion,p.scale),await this.invokeAllPlugins(g=>g.processTileModel&&g.processTileModel(p,t)),p.traverse(g=>{g[Sa]=g.frustumCulled,g.userData.tile=t}),ya(p,!this.autoDisableRendererCulling);let M=[],_=[],C=[];if(p.traverse(g=>{if(g.geometry&&_.push(g.geometry),g.material){let P=g.material;M.push(g.material);for(let S in P){let v=P[S];v&&v.isTexture&&C.push(v)}}}),a.aborted){for(let g=0,P=C.length;g<P;g++){let S=C[g];S.image instanceof ImageBitmap&&S.image.close(),S.dispose()}return}s.materials=M,s.geometry=_,s.textures=C,s.scene=p,s.metadata=y}disposeTile(e){super.disposeTile(e);let t=e.engineData;if(t.scene){let i=t.materials,r=t.geometry,a=t.textures,s=t.scene.parent;t.scene.traverse(n=>{n.userData.meshFeatures&&n.userData.meshFeatures.dispose(),n.userData.structuralMetadata&&n.userData.structuralMetadata.dispose()});for(let n=0,o=r.length;n<o;n++)r[n].dispose();for(let n=0,o=i.length;n<o;n++)i[n].dispose();for(let n=0,o=a.length;n<o;n++){let l=a[n];l.image instanceof ImageBitmap&&l.image.close(),l.dispose()}s&&s.remove(t.scene),t.scene=null,t.materials=null,t.textures=null,t.geometry=null,t.metadata=null}}setTileActive(e,t){super.setTileActive(e,t);let i=e.engineData.scene;i&&(t?(i.parent=this.group,i.updateMatrixWorld(!0)):i.parent=null)}setTileVisible(e,t){let i=e.engineData.scene,{activeTiles:r,group:a}=this;i&&(t?a.add(i):(a.remove(i),r.has(e)&&(i.parent=a))),super.setTileVisible(e,t)}calculateBytesUsed(e,t){let i=this._bytesUsed;return!i.has(e)&&t&&i.set(e,Cn(t)),i.get(e)??null}calculateTileViewError(e,t){let i=e.engineData,r=this.cameras,a=this.cameraInfo,s=i.boundingVolume,n=!1,o=0,l=1/0,u=0,c=1/0;for(let h=0,m=r.length;h<m;h++){let d=a[h],p,y;if(d.isOrthographic){let _=d.pixelSize;p=e.geometricError/_,y=1/0}else{let _=d.sseDenominator;y=s.distanceToPoint(d.position),p=y===0?1/0:e.geometricError/(y*_)}let M=a[h].frustum;s.intersectsFrustum(M)&&(n=!0,o=Math.max(o,p),l=Math.min(l,y)),u=Math.max(u,p),c=Math.min(c,y)}n?(t.inView=!0,t.error=o,t.distanceFromCamera=l):(t.inView=!1,t.error=u,t.distanceFromCamera=c)}dispose(){super.dispose(),this.group.removeFromParent()}};import{BatchedMesh as ph,Box2 as Ln,Box3 as mh,Box3Helper as gh,BoxGeometry as fh,BufferAttribute as Qi,BufferGeometry as yh,CanvasTexture as bh,Color as xh,CustomBlending as In,DataTexture as Dn,DefaultLoadingManager as vh,DoubleSide as _h,EventDispatcher as Th,FileLoader as Rn,FloatType as wh,Frustum as Mh,GreaterDepth as Sh,Group as Ch,LineBasicMaterial as Eh,LineSegments as Ph,LinearFilter as On,LinearMipMapLinearFilter as Ah,MathUtils as $i,Matrix2 as Un,Matrix3 as Bn,Matrix4 as kn,Mesh as Lh,MeshBasicMaterial as Fn,MeshLambertMaterial as Ih,MeshStandardMaterial as Dh,OneFactor as Vn,PlaneGeometry as Rh,Points as Oh,PointsMaterial as Uh,Quaternion as Bh,REVISION as kh,RGFormat as Fh,Ray as Vh,Raycaster as zh,RedFormat as Nh,SRGBColorSpace as jh,ShaderMaterial as zn,Source as Wh,Sphere as Gh,SphereGeometry as qh,Texture as Hh,TextureUtils as Yh,Triangle as Xh,UnsignedByteType as Qh,Vector2 as ee,Vector3 as Na,Vector4 as Nn,WebGLArrayRenderTarget as $h,WebGLRenderTarget as Ca,WebGLRenderer as jn,ZeroFactor as Wn}from"three";import{GLTFLoader as Gn}from"three/addons/loaders/GLTFLoader.js";import{FullScreenQuad as ja}from"three/addons/postprocessing/Pass.js";var Kh=Object.freeze({fill:"#cccccc",stroke:"transparent",strokeWidth:1,radius:2,order:0,visible:!0});var Ea=new ie;Ea.maxJobs=10,Ea.priorityCallback=(e,t)=>{let i=e.tile,r=t.tile,a=i.internal.renderer,s=r.internal.renderer,n=a.visibleTiles.has(i);return n===s.visibleTiles.has(r)?Ue(i,r):n?1:-1};var Pa=new Na;function ot(e,t){if(e.isInterleavedBufferAttribute||e.array instanceof t)return e;let i=t===Int8Array||t===Int16Array||t===Int32Array?-1:0,r=new Qi(new t(e.count*e.itemSize),e.itemSize,!0),a=e.itemSize,s=e.count;for(let n=0;n<s;n++)for(let o=0;o<a;o++){let l=$i.clamp(e.getComponent(n,o),i,1);r.setComponent(n,o,l)}return r}function qn(e,t=Int16Array){let i=e.geometry,r=i.attributes,a=r.position;if(a.isInterleavedBufferAttribute||a.array instanceof t)return a;let s=new Qi(new t(a.count*a.itemSize),a.itemSize,!1),n=a.itemSize,o=a.count;i.computeBoundingBox();let l=i.boundingBox,{min:u,max:c}=l,h=2**(8*t.BYTES_PER_ELEMENT-1)-1,m=-h;for(let d=0;d<o;d++)for(let p=0;p<n;p++){let y=p===0?"x":p===1?"y":"z",M=u[y],_=c[y],C=$i.mapLinear(a.getComponent(d,p),M,_,m,h);s.setComponent(d,p,C)}l.getCenter(Pa).multiply(e.scale).applyQuaternion(e.quaternion),e.position.add(Pa),e.scale.x*=.5*(c.x-u.x)/h,e.scale.y*=.5*(c.y-u.y)/h,e.scale.z*=.5*(c.z-u.z)/h,r.position=s,e.geometry.boundingBox=null,e.geometry.boundingSphere=null,e.updateMatrixWorld()}var Zi=class{constructor(e){this._options={generateNormals:!1,disableMipmaps:!0,compressIndex:!0,compressNormals:!1,compressUvs:!1,compressPosition:!1,uvType:Int8Array,normalType:Int8Array,positionType:Int16Array,...e},this.name="TILES_COMPRESSION_PLUGIN",this.priority=-100}processTileModel(e,t){let{generateNormals:i,disableMipmaps:r,compressIndex:a,compressUvs:s,compressNormals:n,compressPosition:o,uvType:l,normalType:u,positionType:c}=this._options;e.traverse(h=>{if(h.material&&r){let m=h.material;for(let d in m){let p=m[d];p&&p.isTexture&&p.generateMipmaps&&(p.generateMipmaps=!1,p.minFilter=On)}}if(h.geometry){let m=h.geometry,d=m.attributes;if(s){let{uv:p,uv1:y,uv2:M,uv3:_}=d;p&&(d.uv=ot(p,l)),y&&(d.uv1=ot(y,l)),M&&(d.uv2=ot(M,l)),_&&(d.uv3=ot(_,l))}if(i&&!d.normals&&m.computeVertexNormals(),n&&d.normals&&(d.normals=ot(d.normals,u)),o&&qn(h,c),a&&m.index){let p=d.position.count,y=m.index,M=p>65535?Uint32Array:p>255?Uint16Array:Uint8Array;if(!(y.array instanceof M)){let _=new M(m.index.count);_.set(y.array);let C=new Qi(_,1);m.setIndex(C)}}}})}};function F(e,t,i){return e&&t in e?e[t]:i}function Wa(e){return e!=="BOOLEAN"&&e!=="STRING"&&e!=="ENUM"}function Hn(e){return/^FLOAT/.test(e)}function ct(e){return/^VEC/.test(e)}function dt(e){return/^MAT/.test(e)}function Ga(e,t,i,r=null){return dt(i)||ct(i)?r.fromArray(e,t):e[t]}function Yi(e){let{type:t,componentType:i}=e;switch(t){case"SCALAR":return i==="INT64"?0n:0;case"VEC2":return new ee;case"VEC3":return new Na;case"VEC4":return new Nn;case"MAT2":return new Un;case"MAT3":return new Bn;case"MAT4":return new kn;case"BOOLEAN":return!1;case"STRING":return"";case"ENUM":return 0}}function Aa(e,t){if(t==null)return!1;switch(e){case"SCALAR":return typeof t=="number"||typeof t=="bigint";case"VEC2":return t.isVector2;case"VEC3":return t.isVector3;case"VEC4":return t.isVector4;case"MAT2":return t.isMatrix2;case"MAT3":return t.isMatrix3;case"MAT4":return t.isMatrix4;case"BOOLEAN":return typeof t=="boolean";case"STRING":return typeof t=="string";case"ENUM":return typeof t=="number"||typeof t=="bigint"}throw Error("ClassProperty: invalid type.")}function ut(e,t=null){switch(e){case"INT8":return Int8Array;case"INT16":return Int16Array;case"INT32":return Int32Array;case"INT64":return BigInt64Array;case"UINT8":return Uint8Array;case"UINT16":return Uint16Array;case"UINT32":return Uint32Array;case"UINT64":return BigUint64Array;case"FLOAT32":return Float32Array;case"FLOAT64":return Float64Array}switch(t){case"BOOLEAN":return Uint8Array;case"STRING":return Uint8Array}throw Error("ClassProperty: invalid type.")}function Yn(e,t=null){if(e.array){t=t&&Array.isArray(t)?t:[],t.length=e.count;for(let i=0,r=t.length;i<r;i++)t[i]=Nt(e,t[i])}else t=Nt(e,t);return t}function Nt(e,t=null){let i=e.default,r=e.type;if(t||(t=Yi(e)),i===null){switch(r){case"SCALAR":return 0;case"VEC2":return t.set(0,0);case"VEC3":return t.set(0,0,0);case"VEC4":return t.set(0,0,0,0);case"MAT2":return t.identity();case"MAT3":return t.identity();case"MAT4":return t.identity();case"BOOLEAN":return!1;case"STRING":return"";case"ENUM":return""}throw Error("ClassProperty: invalid type.")}else if(dt(r))t.fromArray(i);else if(ct(r))t.fromArray(i);else return i}function Xn(e,t){if(e.noData===null)return t;let i=e.noData,r=e.type;if(Array.isArray(t))for(let n=0,o=t.length;n<o;n++)t[n]=a(t[n]);else t=a(t);return t;function a(n){return s(n)&&(n=Nt(e,n)),n}function s(n){if(dt(r)){let o=n.elements;for(let l=0,u=i.length;l<u;l++)if(i[l]!==o[l])return!1;return!0}else if(ct(r)){for(let o=0,l=i.length;o<l;o++)if(i[o]!==n.getComponent(o))return!1;return!0}else return i===n}}function Qn(e,t){switch(e){case"INT8":return Math.max(t/127,-1);case"INT16":return Math.max(t,32767,-1);case"INT32":return Math.max(t/2147483647,-1);case"INT64":return Math.max(Number(t)/9223372036854776e3,-1);case"UINT8":return t/255;case"UINT16":return t/65535;case"UINT32":return t/4294967295;case"UINT64":return Number(t)/18446744073709552e3}}function $n(e,t){let{type:i,componentType:r,scale:a,offset:s,normalized:n}=e;if(Array.isArray(t))for(let h=0,m=t.length;h<m;h++)t[h]=o(t[h]);else t=o(t);return t;function o(h){return h=dt(i)?u(h):ct(i)?l(h):c(h),h}function l(h){return h.x=c(h.x),h.y=c(h.y),"z"in h&&(h.z=c(h.z)),"w"in h&&(h.w=c(h.w)),h}function u(h){let m=h.elements;for(let d=0,p=m.length;d<p;d++)m[d]=c(m[d]);return h}function c(h){return n&&(h=Qn(r,h)),(n||Hn(r))&&(h=h*a+s),h}}function Ji(e,t,i=null){if(e.array){Array.isArray(t)||(t=Array(e.count||0)),t.length=i===null?e.count:i;for(let r=0,a=t.length;r<a;r++)Aa(e.type,t[r])||(t[r]=Yi(e))}else Aa(e.type,t)||(t=Yi(e));return t}function jt(e,t){for(let i in t)i in e||delete t[i];for(let i in e){let r=e[i];t[i]=Ji(r,t[i])}}function Zn(e){switch(e){case"ENUM":return 1;case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":return 4;case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;case"BOOLEAN":return-1;case"STRING":return-1;default:return-1}}var Gt=class{constructor(e,t,i=null){this.name=t.name||null,this.description=t.description||null,this.type=t.type,this.componentType=t.componentType||null,this.enumType=t.enumType||null,this.array=t.array||!1,this.count=t.count||0,this.normalized=t.normalized||!1,this.offset=t.offset||0,this.scale=F(t,"scale",1),this.max=F(t,"max",1/0),this.min=F(t,"min",-1/0),this.required=t.required||!1,this.noData=F(t,"noData",null),this.default=F(t,"default",null),this.semantic=F(t,"semantic",null),this.enumSet=null,this.accessorProperty=i,i&&(this.offset=F(i,"offset",this.offset),this.scale=F(i,"scale",this.scale),this.max=F(i,"max",this.max),this.min=F(i,"min",this.min)),t.type==="ENUM"&&(this.enumSet=e[this.enumType],this.componentType===null&&(this.componentType=F(this.enumSet,"valueType","UINT16")))}shapeToProperty(e,t=null){return Ji(this,e,t)}resolveDefaultElement(e){return Nt(this,e)}resolveDefault(e){return Yn(this,e)}resolveNoData(e){return Xn(this,e)}resolveEnumsToStrings(e){let t=this.enumSet;if(this.type==="ENUM")if(Array.isArray(e))for(let r=0,a=e.length;r<a;r++)e[r]=i(e[r]);else e=i(e);return e;function i(r){let a=t.values.find(s=>s.value===r);return a===null?"":a.name}}adjustValueScaleOffset(e){return Wa(this.type)?$n(this,e):e}},Ki=class{constructor(e,t={},i={},r=null){this.definition=e,this.class=t[e.class],this.className=e.class,this.enums=i,this.data=r,this.name="name"in e?e.name:null,this.properties=null}getPropertyNames(){return Object.keys(this.class.properties)}includesData(e){return!!this.definition.properties[e]}dispose(){}_initProperties(e=Gt){let t={};for(let i in this.class.properties)t[i]=new e(this.enums,this.class.properties[i],this.definition.properties[i]);this.properties=t}},Jn=class extends Gt{constructor(e,t,i=null){super(e,t,i),this.attribute=i?.attribute??null}},Kn=class extends Ki{constructor(...e){super(...e),this.isPropertyAttributeAccessor=!0,this._initProperties(Jn)}getData(e,t,i={}){let r=this.properties;jt(r,i);for(let a in r)i[a]=this.getPropertyValue(a,e,t,i[a]);return i}getPropertyValue(e,t,i,r=null){if(t>=this.count)throw Error("PropertyAttributeAccessor: Requested index is outside the range of the buffer.");let a=this.properties[e],s=a.type;if(!a)throw Error("PropertyAttributeAccessor: Requested class property does not exist.");if(!this.definition.properties[e])return a.resolveDefault(r);r=a.shapeToProperty(r);let n=i.getAttribute(a.attribute.toLowerCase());if(dt(s)){let o=r.elements;for(let l=o.length;0<l;)o[0]=n.getComponent(t,0)}else if(ct(s))r.fromBufferAttribute(n,t);else if(s==="SCALAR"||s==="ENUM")r=n.getX(t);else throw Error("StructuredMetadata.PropertyAttributeAccessor: BOOLEAN and STRING types are not supported by property attributes.");return r=a.adjustValueScaleOffset(r),r=a.resolveEnumsToStrings(r),r=a.resolveNoData(r),r}},eo=class extends Gt{constructor(e,t,i=null){super(e,t,i),this.values=i?.values??null,this.valueLength=Zn(this.type),this.arrayOffsets=F(i,"arrayOffsets",null),this.stringOffsets=F(i,"stringOffsets",null),this.arrayOffsetType=F(i,"arrayOffsetType","UINT32"),this.stringOffsetType=F(i,"stringOffsetType","UINT32")}getArrayLengthFromId(e,t){let i=this.count;if(this.arrayOffsets!==null){let{arrayOffsets:r,arrayOffsetType:a}=this,s=new(ut(a))(e[r]);i=s[t+1]-s[t]}return i}getIndexOffsetFromId(e,t){let i=t;if(this.arrayOffsets){let{arrayOffsets:r,arrayOffsetType:a}=this;i=new(ut(a))(e[r])[i]}else this.array&&(i*=this.count);return i}},to=class extends Ki{constructor(...e){super(...e),this.isPropertyTableAccessor=!0,this.count=this.definition.count,this._initProperties(eo)}getData(e,t={}){let i=this.properties;jt(i,t);for(let r in i)t[r]=this.getPropertyValue(r,e,t[r]);return t}_readValueAtIndex(e,t,i,r=null){let a=this.properties[e],{componentType:s,type:n}=a,o=this.data,l=o[a.values],u=new(ut(s,n))(l),c=a.getIndexOffsetFromId(o,t);if(Wa(n)||n==="ENUM")return Ga(u,(c+i)*a.valueLength,n,r);if(n==="STRING"){let h=c+i,m=0;if(a.stringOffsets!==null){let{stringOffsets:p,stringOffsetType:y}=a,M=new(ut(y))(o[p]);m=M[h+1]-M[h],h=M[h]}let d=new Uint8Array(u.buffer,h,m);r=new TextDecoder().decode(d)}else if(n==="BOOLEAN"){let h=c+i,m=Math.floor(h/8),d=h%8;r=(u[m]>>d&1)==1}return r}getPropertyValue(e,t,i=null){if(t>=this.count)throw Error("PropertyTableAccessor: Requested index is outside the range of the table.");let r=this.properties[e];if(!r)throw Error("PropertyTableAccessor: Requested property does not exist.");if(!this.definition.properties[e])return r.resolveDefault(i);let a=r.array,s=this.data,n=r.getArrayLengthFromId(s,t);if(i=r.shapeToProperty(i,n),a)for(let o=0,l=i.length;o<l;o++)i[o]=this._readValueAtIndex(e,t,o,i[o]);else i=this._readValueAtIndex(e,t,0,i);return i=r.adjustValueScaleOffset(i),i=r.resolveEnumsToStrings(i),i=r.resolveNoData(i),i}},lt=new Ln,La=class{constructor(){this._renderer=new jn,this._target=new Ca(1,1),this._texTarget=new Ca,this._quad=new ja(new zn({blending:In,blendDst:Wn,blendSrc:Vn,uniforms:{map:{value:null},pixel:{value:new ee}},vertexShader:`
2
+ void main() {
3
+
4
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
5
+
6
+ }
7
+ `,fragmentShader:`
8
+ uniform sampler2D map;
9
+ uniform ivec2 pixel;
10
+
11
+ void main() {
12
+
13
+ gl_FragColor = texelFetch( map, pixel, 0 );
14
+
15
+ }
16
+ `}))}increaseSizeTo(e){this._target.setSize(Math.max(this._target.width,e),1)}readDataAsync(e){let{_renderer:t,_target:i}=this;return t.readRenderTargetPixelsAsync(i,0,0,e.length/4,1,e)}readData(e){let{_renderer:t,_target:i}=this;t.readRenderTargetPixels(i,0,0,e.length/4,1,e)}renderPixelToTarget(e,t,i){let{_renderer:r,_target:a}=this;lt.min.copy(t),lt.max.copy(t),lt.max.x+=1,lt.max.y+=1,r.initRenderTarget(a),r.copyTextureToTexture(e,a.texture,lt,i,0)}},be=new class{constructor(){let e=null;Object.getOwnPropertyNames(La.prototype).forEach(t=>{t!=="constructor"&&(this[t]=(...i)=>(e||(e=new La),e[t](...i)))})}},Ia=new ee,Da=new ee,Ra=new ee;function io(e,t){return t===0?e.getAttribute("uv"):e.getAttribute(`uv${t}`)}function qa(e,t,i=[,,,]){let r=3*t,a=3*t+1,s=3*t+2;return e.index&&(r=e.index.getX(r),a=e.index.getX(a),s=e.index.getX(s)),i[0]=r,i[1]=a,i[2]=s,i}function Ha(e,t,i,r,a){let[s,n,o]=r,l=io(e,t);Ia.fromBufferAttribute(l,s),Da.fromBufferAttribute(l,n),Ra.fromBufferAttribute(l,o),a.set(0,0,0).addScaledVector(Ia,i.x).addScaledVector(Da,i.y).addScaledVector(Ra,i.z)}function Ya(e,t,i,r){let a=e.x-Math.floor(e.x),s=e.y-Math.floor(e.y),n=Math.floor(a*t%t),o=Math.floor(s*i%i);return r.set(n,o),r}var Oa=new ee,Ua=new ee,Ba=new ee,ro=class extends Gt{constructor(e,t,i=null){super(e,t,i),this.channels=F(i,"channels",[0]),this.index=F(i,"index",null),this.texCoord=F(i,"texCoord",null),this.valueLength=parseInt(this.type.replace(/[^0-9]/g,""))||1}readDataFromBuffer(e,t,i=null){let r=this.type;if(r==="BOOLEAN"||r==="STRING")throw Error("PropertyTextureAccessor: BOOLEAN and STRING types not supported.");return Ga(e,t*this.valueLength,r,i)}},ao=class extends Ki{constructor(...e){super(...e),this.isPropertyTextureAccessor=!0,this._asyncRead=!1,this._initProperties(ro)}getData(e,t,i,r={}){let a=this.properties;jt(a,r);let s=Object.keys(a),n=s.map(o=>r[o]);return this.getPropertyValuesAtTexel(s,e,t,i,n),s.forEach((o,l)=>r[o]=n[l]),r}async getDataAsync(e,t,i,r={}){let a=this.properties;jt(a,r);let s=Object.keys(a),n=s.map(o=>r[o]);return await this.getPropertyValuesAtTexelAsync(s,e,t,i,n),s.forEach((o,l)=>r[o]=n[l]),r}getPropertyValuesAtTexelAsync(...e){this._asyncRead=!0;let t=this.getPropertyValuesAtTexel(...e);return this._asyncRead=!1,t}getPropertyValuesAtTexel(e,t,i,r,a=[]){for(;a.length<e.length;)a.push(null);a.length=e.length,be.increaseSizeTo(a.length);let s=this.data,n=this.definition.properties,o=this.properties,l=qa(r,t);for(let h=0,m=e.length;h<m;h++){let d=e[h];if(!n[d])continue;let p=o[d],y=s[p.index];Ha(r,p.texCoord,i,l,Oa),Ya(Oa,y.image.width,y.image.height,Ua),Ba.set(h,0),be.renderPixelToTarget(y,Ua,Ba)}let u=new Uint8Array(e.length*4);if(this._asyncRead)return be.readDataAsync(u).then(()=>(c.call(this),a));return be.readData(u),c.call(this),a;function c(){for(let h=0,m=e.length;h<m;h++){let d=e[h],p=o[d],y=p.type;if(a[h]=Ji(p,a[h]),!p)throw Error("PropertyTextureAccessor: Requested property does not exist.");if(!n[d]){a[h]=p.resolveDefault(a);continue}let M=p.valueLength*(p.count||1),_=p.channels.map(P=>u[4*h+P]),C=p.componentType,g=new(ut(C,y))(M);if(new Uint8Array(g.buffer).set(_),p.array){let P=a[h];for(let S=0,v=P.length;S<v;S++)P[S]=p.readDataFromBuffer(g,S,P[S])}else a[h]=p.readDataFromBuffer(g,0,a[h]);a[h]=p.adjustValueScaleOffset(a[h]),a[h]=p.resolveEnumsToStrings(a[h]),a[h]=p.resolveNoData(a[h])}}}dispose(){this.data.forEach(e=>{e&&(e.dispose(),e.image instanceof ImageBitmap&&e.image.close())})}},Xi=class{constructor(e,t,i,r=null,a=null){let{schema:s,propertyTables:n=[],propertyTextures:o=[],propertyAttributes:l=[]}=e,{enums:u,classes:c}=s,h=n.map(p=>new to(p,c,u,i)),m=[],d=[];r&&(r.propertyTextures&&(m=r.propertyTextures.map(p=>new ao(o[p],c,u,t))),r.propertyAttributes&&(d=r.propertyAttributes.map(p=>new Kn(l[p],c,u)))),this.schema=s,this.tableAccessors=h,this.textureAccessors=m,this.attributeAccessors=d,this.object=a,this.textures=t,this.nodeMetadata=r}getPropertyTableData(e,t,i=null){if(!Array.isArray(e))i||(i={}),i=this.tableAccessors[e].getData(t,i);else{i||(i=[]);let r=Math.min(e.length,t.length);i.length=r;for(let a=0;a<r;a++){let s=this.tableAccessors[e[a]];i[a]=s.getData(t[a],i[a])}}if(Array.isArray(e)!==Array.isArray(i)||Array.isArray(e)!==Array.isArray(t))throw Error("StructuralMetadata: Scalar and array inputs cannot be mixed.");return i}getPropertyTableInfo(e=null){if(e===null&&(e=this.tableAccessors.map((t,i)=>i)),Array.isArray(e))return e.map(t=>{let i=this.tableAccessors[t];return{name:i.name,className:i.definition.class}});{let t=this.tableAccessors[e];return{name:t.name,className:t.definition.class}}}getPropertyTextureData(e,t,i=[]){let r=this.textureAccessors;i.length=r.length;for(let a=0;a<r.length;a++)i[a]=r[a].getData(e,t,this.object.geometry,i[a]);return i}async getPropertyTextureDataAsync(e,t,i=[]){let r=this.textureAccessors;i.length=r.length;let a=[];for(let s=0;s<r.length;s++){let n=r[s].getDataAsync(e,t,this.object.geometry,i[s]).then(o=>{i[s]=o});a.push(n)}return await Promise.all(a),i}getPropertyTextureInfo(){return this.textureAccessors}getPropertyAttributeData(e,t=[]){let i=this.attributeAccessors;t.length=i.length;for(let r=0;r<i.length;r++)t[r]=i[r].getData(e,this.object.geometry,t[r]);return t}getPropertyAttributeInfo(){return this.attributeAccessors.map(e=>({name:e.name,className:e.definition.class}))}dispose(){this.textureAccessors.forEach(e=>e.dispose()),this.tableAccessors.forEach(e=>e.dispose()),this.attributeAccessors.forEach(e=>e.dispose())}},ht="EXT_structural_metadata";function so(e,t=[]){let i=e.json.textures?.length||0,r=Array(i).fill(null);return t.forEach(({properties:a})=>{for(let s in a){let{index:n}=a[s];r[n]===null&&(r[n]=e.loadTexture(n))}}),Promise.all(r)}function no(e,t=[]){let i=e.json.bufferViews?.length||0,r=Array(i).fill(null);return t.forEach(({properties:a})=>{for(let s in a){let{values:n,arrayOffsets:o,stringOffsets:l}=a[s];r[n]===null&&(r[n]=e.getDependency("bufferView",n)),r[o]===null&&(r[o]=e.getDependency("bufferView",o)),r[l]===null&&(r[l]=e.getDependency("bufferView",l))}}),Promise.all(r)}var Xa=class{constructor(e){this.parser=e,this.name=ht}async afterRoot({scene:e,parser:t}){let i=t.json.extensionsUsed;if(!i||!i.includes(ht))return;let r=null,a=t.json.extensions[ht];if(a.schemaUri){let{manager:l,path:u,requestHeader:c,crossOrigin:h}=t.options,m=new URL(a.schemaUri,u).toString(),d=new Rn(l);d.setCrossOrigin(h),d.setResponseType("json"),d.setRequestHeader(c),r=d.loadAsync(m).then(p=>{a={...a,schema:p}})}let[s,n]=await Promise.all([so(t,a.propertyTextures),no(t,a.propertyTables),r]),o=new Xi(a,s,n);e.userData.structuralMetadata=o,e.traverse(l=>{if(t.associations.has(l)){let{meshes:u,primitives:c}=t.associations.get(l),h=t.json.meshes[u]?.primitives[c];if(h&&h.extensions&&h.extensions[ht]){let m=h.extensions[ht];l.userData.structuralMetadata=new Xi(a,s,n,m,l)}else l.userData.structuralMetadata=o}})}},ka=new ee,Fa=new ee,Va=new ee;function oo(e){return e.x>e.y&&e.x>e.z?0:e.y>e.z?1:2}var Qa=class{constructor(e,t,i){this.geometry=e,this.textures=t,this.data=i,this._asyncRead=!1,this.featureIds=i.featureIds.map(r=>{let{texture:a,...s}=r,n={label:null,propertyTable:null,nullFeatureId:null,...s};return a&&(n.texture={texCoord:0,channels:[0],...a}),n})}getTextures(){return this.textures}getFeatureInfo(){return this.featureIds}getFeaturesAsync(...e){this._asyncRead=!0;let t=this.getFeatures(...e);return this._asyncRead=!1,t}getFeatures(e,t){let{geometry:i,textures:r,featureIds:a}=this,s=Array(a.length).fill(null),n=a.length;be.increaseSizeTo(n);let o=qa(i,e),l=o[oo(t)];for(let h=0,m=a.length;h<m;h++){let d=a[h],p="nullFeatureId"in d?d.nullFeatureId:null;if("texture"in d){let y=r[d.texture.index];Ha(i,d.texture.texCoord,t,o,ka),Ya(ka,y.image.width,y.image.height,Fa),Va.set(h,0),be.renderPixelToTarget(r[d.texture.index],Fa,Va)}else if("attribute"in d){let y=i.getAttribute(`_feature_id_${d.attribute}`).getX(l);y!==p&&(s[h]=y)}else{let y=l;y!==p&&(s[h]=y)}}let u=new Uint8Array(n*4);if(this._asyncRead)return be.readDataAsync(u).then(()=>(c(),s));return be.readData(u),c(),s;function c(){let h=new Uint32Array(1);for(let m=0,d=a.length;m<d;m++){let p=a[m],y="nullFeatureId"in p?p.nullFeatureId:null;if("texture"in p){let{channels:M}=p.texture,_=M.map(g=>u[4*m+g]);new Uint8Array(h.buffer).set(_);let C=h[0];C!==y&&(s[m]=C)}}}}dispose(){this.textures.forEach(e=>{e&&(e.dispose(),e.image instanceof ImageBitmap&&e.image.close())})}},Wt="EXT_mesh_features";function za(e,t,i){e.traverse(r=>{if(t.associations.has(r)){let{meshes:a,primitives:s}=t.associations.get(r),n=t.json.meshes[a]?.primitives[s];n&&n.extensions&&n.extensions[Wt]&&i(r,n.extensions[Wt])}})}var $a=class{constructor(e){this.parser=e,this.name=Wt}async afterRoot({scene:e,parser:t}){let i=t.json.extensionsUsed;if(!i||!i.includes(Wt))return;let r=t.json.textures?.length||0,a=Array(r).fill(null);za(e,t,(n,{featureIds:o})=>{o.forEach(l=>{if(l.texture&&a[l.texture.index]===null){let u=l.texture.index;a[u]=t.loadTexture(u)}})});let s=await Promise.all(a);za(e,t,(n,o)=>{n.userData.meshFeatures=new Qa(n.geometry,s,o)})}},Za=class{constructor(){this.name="CESIUM_RTC"}afterRoot(e){if(e.parser.json.extensions&&e.parser.json.extensions.CESIUM_RTC){let{center:t}=e.parser.json.extensions.CESIUM_RTC;t&&(e.scene.position.x+=t[0],e.scene.position.y+=t[1],e.scene.position.z+=t[2])}}},er=class{constructor(e){e={metadata:!0,rtc:!0,plugins:[],dracoLoader:null,ktxLoader:null,meshoptDecoder:null,autoDispose:!0,...e},this.tiles=null,this.metadata=e.metadata,this.rtc=e.rtc,this.plugins=e.plugins,this.dracoLoader=e.dracoLoader,this.ktxLoader=e.ktxLoader,this.meshoptDecoder=e.meshoptDecoder,this._gltfRegex=/\.(gltf|glb)$/g,this._dracoRegex=/\.drc$/g,this._loader=null}init(e){let t=new Gn(e.manager);this.dracoLoader&&(t.setDRACOLoader(this.dracoLoader),e.manager.addHandler(this._dracoRegex,this.dracoLoader)),this.ktxLoader&&t.setKTX2Loader(this.ktxLoader),this.meshoptDecoder&&t.setMeshoptDecoder(this.meshoptDecoder),this.rtc&&t.register(()=>new Za),this.metadata&&(t.register(()=>new Xa),t.register(()=>new $a)),this.plugins.forEach(i=>t.register(i)),e.manager.addHandler(this._gltfRegex,t),this.tiles=e,this._loader=t}dispose(){this.tiles.manager.removeHandler(this._gltfRegex),this.tiles.manager.removeHandler(this._dracoRegex),this.autoDispose&&(this.ktxLoader.dispose(),this.dracoLoader.dispose())}};var{clamp:eu}=$i;var tu=new ja(new Fn),lo=new Dn(new Uint8Array([255,255,255,255]),1,1);lo.needsUpdate=!0;var ho=0,uo=1,co=2,po=3,mo=4,go=5,fo=6,yo=7,bo=8,xo=9,vo=10,_o=11,iu=Object.freeze({NONE:ho,SCREEN_ERROR:uo,GEOMETRIC_ERROR:co,DISTANCE:po,DEPTH:mo,RELATIVE_DEPTH:go,IS_LEAF:fo,RANDOM_COLOR:yo,RANDOM_NODE_COLOR:bo,CUSTOM_COLOR:xo,LOAD_ORDER:vo,INDEXED_COLOR:_o});var ru=Math.PI/4,au=3/5;var ye={NONE:0,NOT_READY:1,NO_FIT:2,DEPTH:3,OCCUPANCY:4,SPACING:5,ANGLE:6,FACING:7};var su=new class{constructor(){this._cache={}}getColor(...e){let t=e.pop(),i=e.join("_"),{_cache:r}=this;return i in r||(t.setHSL(Math.random(),1,.5),r[i]=t.getHex()),t.set(r[i])}};var nu={[ye.NONE]:16777215,[ye.NOT_READY]:7829367,[ye.NO_FIT]:2250239,[ye.DEPTH]:4473924,[ye.OCCUPANCY]:65535,[ye.SPACING]:16776960,[ye.ANGLE]:16711680,[ye.FACING]:16711935};var ou=Math.PI/180;var lu=Ee*Math.PI*2;var hu=Ee*Math.PI*2;import{DRACOLoader as Eo}from"three/examples/jsm/loaders/DRACOLoader.js";import{KTX2Loader as Po}from"three/examples/jsm/loaders/KTX2Loader.js";import{MeshoptDecoder as Ao}from"three/examples/jsm/libs/meshopt_decoder.module.js";import{Box3 as Lo,DoubleSide as Io,MathUtils as Do,Matrix4 as ts,Sphere as Ro,Vector3 as Oo}from"three";import{BufferAttribute as Ja,MathUtils as To}from"three";function Ka(e){return!!e&&!e.isInterleavedBufferAttribute}function es(e,t,i,r){for(let a=0;a<e.count;a+=1)for(let s=0;s<e.itemSize;s+=1)t.setComponent(a,s,To.clamp(e.getComponent(a,s),i,r));return t}function wo(e){for(let t=0;t<e.count;t+=1)for(let i=0;i<e.itemSize;i+=1){let r=e.getComponent(t,i);if(!Number.isFinite(r)||r<0||r>1)return!1}return!0}var qt=class{constructor(){this.name="RI_VERTEX_COMPRESSION_PLUGIN";this.priority=-99}processTileModel(t){t.traverse(i=>{let r=i.geometry;if(!r)return;let a=r.attributes.normal;Ka(a)&&!(a.array instanceof Int16Array)&&(r.attributes.normal=es(a,new Ja(new Int16Array(a.count*a.itemSize),a.itemSize,!0),-1,1));for(let s of["uv","uv1","uv2","uv3"]){let n=r.attributes[s];!Ka(n)||n.array instanceof Uint16Array||!wo(n)||(r.attributes[s]=es(n,new Ja(new Uint16Array(n.count*n.itemSize),n.itemSize,!0),0,1))}})}};import{jsx as rs,jsxs as No}from"react/jsx-runtime";var Uo=0,is=4,Bo=6,ko=12,Fo=4;function Vo(e){try{let t=typeof window>"u"?new URL(e):new URL(e,window.location.href);return new URL("objects.json",t).toString()}catch{return null}}function zo({diagnosticsRef:e,loadingRef:t,url:i,rotation:r=[0,0,0],errorTarget:a=64,cacheSize:s=800,memoryBudgetMB:n=800,decoderConfig:o,objectBindings:l,itemMaterials:u,sceneConfig:c,selectedItem:h,panelHoveredItem:m,highlightOnHover:d=!0,onItemClick:p,onItemHover:y,onItemDoubleClick:M,onItemContextMenu:_,onObjectCatalog:C,onTilesetBounds:g,onModelLoaded:P,onLoadError:S,nodeRefsOut:v,onNodeRefsChange:L,materialRefsOut:w,explodeFactor:U=0,suspendBindingTransforms:O=!1}){let{camera:V,gl:ue,invalidate:f}=Co(),J=z(null),[Le,Q]=tr(null),$=z({onItemClick:p,onItemHover:y,onItemDoubleClick:M,onObjectCatalog:C,onTilesetBounds:g,onModelLoaded:P,onLoadError:S,onNodeRefsChange:L});$.current={onItemClick:p,onItemHover:y,onItemDoubleClick:M,onObjectCatalog:C,onTilesetBounds:g,onModelLoaded:P,onLoadError:S,onNodeRefsChange:L};let _e=z(!0),[Te,as]=tr(null),Ht=z(null);Ht.current=Te;let ss=z([]),pt=z(!1);ve(()=>{let b=new vt;return as(b),()=>b.dispose()},[i]);let ir=z(null),mt=z(0),Yt=z(!1),Xt=n*1024*1024,Qt=z(!1),$t=z(yi),ce=z(null),Zt=z(null),ze=z(null);ve(()=>()=>{ze.current!==null&&clearTimeout(ze.current)},[]);let Jt=o?.dracoDecoderPath??xr,Kt=o?.ktx2TranscoderPath??vr,rr=o?.meshopt??!0,[x,ar]=tr(null);ve(()=>{Yt.current=!1,Qt.current=!1;let b=new Hi(i);b.loadAncestors=!0;let I=new Ct;I.priorityCallback=b.downloadQueue.priorityCallback,I.maxJobsPerOrigin=ko;let D=new ie;D.priorityCallback=b.parseQueue.priorityCallback,D.maxJobs=Bo;let H=new ie;H.priorityCallback=b.processNodeQueue.priorityCallback,H.maxJobs=b.processNodeQueue.maxJobs;let N=new Ze;N.unloadPriorityCallback=b.lruCache.unloadPriorityCallback,b.downloadQueue=I,b.parseQueue=D,b.processNodeQueue=H,b.lruCache=N;let R=Jt?new Eo().setDecoderPath(Jt).setWorkerLimit(Fo):null,B=Kt?new Po().setTranscoderPath(Kt).detectSupport(ue):null;return b.registerPlugin(new er({dracoLoader:R,ktxLoader:B,meshoptDecoder:rr?Ao:null,autoDispose:!1})),b.registerPlugin(new Zi({disableMipmaps:!1,compressIndex:!0,compressNormals:!1,compressUvs:!1,compressPosition:!0})),b.registerPlugin(new qt),ar(b),window.__riTiles=b,()=>{b.forEachLoadedModel(A=>li(A)),b.dispose(),R?.dispose(),B?.dispose(),ar(A=>A===b?null:A)}},[Jt,ue,Kt,rr,i]),ve(()=>{x&&($t.current=yi,ce.current=null,x.errorTarget=a,x.lruCache.maxSize=s,x.lruCache.minSize=Math.max(1,Math.floor(s*.75)),x.lruCache.maxBytesSize=Xt,x.lruCache.minBytesSize=Xt*.75,f())},[s,a,f,Xt,x]);let de=Mo(()=>{let b=l??{};return{objectBindings:b,keyByModelObject:Pr(b),itemMaterials:u,shadingMode:c?.model.shading??"lit",rendererMode:c?.model.renderer??"pbr",selectedKey:h??null,hoveredKey:Ar(Le,m),highlightOnHover:d,suspendTransforms:O,placementFrame:x?.group.matrixWorld,invalidate:f}},[Le,d,f,u,l,m,c,h,O,x]),ns=xe(()=>{if(!x)return;let b=gt.current,I=pt.current?Ht.current?.nodesByBinding(b)??{}:{},D={};x.group.traverse(B=>{if(!B.isMesh)return;let A=pi(B);if(!A)return;let Y=b.keyByModelObject[A]??A;if(!b.objectBindings[Y])return;I[Y]||(I[Y]=B);let te=B.material;te&&(D[Y]=te)});let H=v?.current??{},N=Object.keys(H),R=N.length!==Object.keys(I).length||N.some(B=>H[B]!==I[B]);v&&(v.current=I),w&&(w.current=D),(R||!v)&&$.current.onNodeRefsChange?.()},[w,v,x]),Ne=xe(b=>gi(b,de,"select"),[de]),je=xe(b=>Dr(b,de),[de]),sr=z(je);sr.current=je;let gt=z(de);gt.current=de;let we=xe(()=>{let b=ir.current,I=mt.current;return!b||I<=0?gt.current:{...gt.current,explode:{factor:I,centre:b.centre,radius:b.radius}}},[]);ve(()=>{x&&(je(x.group),_e.current=!0,x.forEachLoadedModel(b=>{je(b),Oe(b,we())}),f())},[je,f,we,x]),ve(()=>{let b=Vo(i);if(!b)return;let I=!1;return fetch(b).then(D=>D.ok?D.json():null).then(D=>{I||!D?.objects||(ss.current=D.objects,pt.current=D.bindingFrame==="gltf-identity-v2",pt.current&&Ht.current?.setCatalog(D.objects),_e.current=!0,$.current.onObjectCatalog?.(D.objects),f())}).catch(()=>{}),()=>{I=!0}},[i,f,Te]),ve(()=>{if(!x)return;let b=!1,I=()=>f(),D=A=>{A.scene&&(A.scene.traverse(Y=>{let te=Y.material;for(let Ie of Array.isArray(te)?te:te?[te]:[])Ie.transparent&&Ie.side===Io&&(Ie.forceSinglePass=!0)}),sr.current(A.scene),Oe(A.scene,we()),gr(A.scene)),_e.current=!0,b||(b=!0,$.current.onModelLoaded?.(x.group)),f()},H=A=>{$.current.onLoadError?.(A.error)},N=A=>{A.scene&&(fi(A.scene),li(A.scene)),_e.current=!0};x.setCamera(V),x.setResolutionFromRenderer(V,ue),x.addEventListener("needs-update",I),x.addEventListener("load-model",D),x.addEventListener("load-error",H),x.addEventListener("dispose-model",N);let R=()=>{_e.current=!0,f()};x.addEventListener("tile-visibility-change",R);let B=()=>{let A=x.root;A&&!A.content?.uri&&A.refine==="REPLACE"&&(A.refine="ADD",f())};return x.addEventListener("load-root-tileset",B),f(),()=>{x.removeEventListener("needs-update",I),x.removeEventListener("load-model",D),x.removeEventListener("load-error",H),x.removeEventListener("dispose-model",N),x.removeEventListener("tile-visibility-change",R),x.removeEventListener("load-root-tileset",B),fi(x.group),x.deleteCamera(V),v&&(v.current={}),w&&(w.current={})}},[V,ue,f,w,v,we,x]);let ei=fr(b=>Ne(b)?.binding??null,_),os=xe(b=>{if(ei.consumeClick())return;let I=Ne(b.object);I&&(b.stopPropagation(),$.current.onItemClick?.(I.binding))},[Ne,ei,p]),ls=xe(b=>{let I=Ne(b.object);if(!I)return;$.current.onItemDoubleClick?.(I.binding,yr(b))&&b.stopPropagation()},[Ne]),hs=xe(b=>{let I=Lr(b.intersections,b.eventObject,de,"hover"),D=I?.key??null;D!==J.current&&(J.current=D,Q(D),$.current.onItemHover?.(I?.binding??null))},[de]),us=xe(()=>{J.current!==null&&(J.current=null,Q(null),$.current.onItemHover?.(null))},[]);return ve(()=>{f()},[f,x]),So((b,I)=>{if(!x)return;if(x.setResolutionFromRenderer(V,ue),pt.current&&Te){let X=Te.sync(we(),h,O);Te.updateBounds(x.root),O&&x.forEachLoadedModel(De=>Oe(De,X))}if(x.update(),!Yt.current){let X=new Lo;if(x.getBoundingBox(X)){Yt.current=!0,x.group.updateMatrixWorld(),X.applyMatrix4(x.group.matrixWorld);let De=X.getBoundingSphere(new Ro);ir.current={centre:De.center.clone(),radius:X.getSize(new Oo).length()*.5},$.current.onTilesetBounds?.(X),f()}}_e.current&&(_e.current=!1,ns());let D=Math.min(Math.max(U,0),1),H=mt.current;Math.abs(H-D)>1e-4?(mt.current=Do.lerp(H,D,1-Math.exp(-6*I)),Oe(x.group,we()),f()):H!==D&&(mt.current=D,Oe(x.group,we()),f());let N=x,R=x.lruCache,B=R.isFull(),A=$t.current,Y=A.loosened&&ce.current?ce.current:{bytes:R.maxBytesSize,items:R.maxSize},te=0;for(let X of R.usedSet??[])te+=R.bytesMap?.get(X)??0;let Ie=!1,cs=x;for(let X of cs.usedSet??[]){let De=X.internal?.loadingState??is;if(X.traversal?.used&&X.internal?.hasContent&&De>=Uo&&De<is){Ie=!0;break}}let ft=Zt.current??(Zt.current={world:new ts,projection:new ts}),nr=!ft.world.equals(V.matrixWorld)||!ft.projection.equals(V.projectionMatrix);nr&&(ft.world.copy(V.matrixWorld),ft.projection.copy(V.projectionMatrix));let ti={full:B,wanting:Ie,moved:nr,usage:Math.max(te/Math.max(1,Y.bytes),(R.usedSet?.size??0)/Math.max(1,Y.items)),now:performance.now()},ae=Gr(A,ti);ae!==A&&(ae.loosened&&(!A.loosened||ae.raisedAt!==A.raisedAt)?(A.loosened||(ce.current=Y),R.maxBytesSize=Math.max(Y.bytes,R.cachedBytes??0)*bi,R.maxSize=Math.ceil(Math.max(Y.items,R.itemSet?.size??0)*bi)):!ae.loosened&&A.loosened&&ce.current&&(R.maxBytesSize=ce.current.bytes,R.maxSize=ce.current.items,ce.current=null),$t.current=ae,x.errorTarget=a*ae.factor,f()),!Qt.current&&B&&ti.wanting&&ae.factor>=Ye&&(Qt.current=!0,console.warn("[react-immersive] The tile memory budget is full even at the coarsest level of detail, so the model may render incompletely. This usually means the model's textures are too large for streaming \u2014 re-process it with a smaller MAX_TEXTURE_SIZE, or raise memoryBudgetMB.")),e&&(e.current={cachedBytes:R.cachedBytes??null,budgetBytes:Y.bytes,cachedTiles:R.itemSet?.size??null,downloading:N.stats?.downloading??0,parsing:N.stats?.parsing??0,cacheFull:B,detailFactor:ae.factor,errorTarget:x.errorTarget});let ii=qr(ae,ti);ii===0?f():ii!==null&&ze.current===null&&(ze.current=setTimeout(()=>{ze.current=null,f()},ii));let or=(N.stats?.downloading??0)>0||(N.stats?.parsing??0)>0||N.loadProgress!==void 0&&N.loadProgress<1&&!B;t&&(t.current=or),or&&f()}),x?No("group",{rotation:r,children:[Te?rs("primitive",{object:Te.group}):null,rs("primitive",{object:x.group,onClick:os,onDoubleClick:ls,onPointerDown:_?ei.onPointerDown:void 0,onPointerMove:hs,onPointerOut:us})]}):null}export{zo as default};