@liveroom-tech/react-immersive 6.2.2 → 6.2.3
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.
- package/README.md +23 -0
- package/dist/{SequencesTab-LTMJTB76.mjs → SequencesTab-JZEE5WAM.mjs} +1 -1
- package/dist/binding-builder.d.mts +3 -3
- package/dist/binding-builder.d.ts +3 -3
- package/dist/binding-builder.js +41 -41
- package/dist/binding-builder.mjs +1 -1
- package/dist/{chunk-NMRTI3NQ.mjs → chunk-3GA7JFNH.mjs} +1 -1
- package/dist/chunk-3I7PPFUV.mjs +1 -0
- package/dist/{chunk-IT2PUTJS.mjs → chunk-CHMFH4D4.mjs} +1 -1
- package/dist/{chunk-RSUXTWM6.mjs → chunk-CUDL77ZY.mjs} +1 -1
- package/dist/{chunk-XKJQC3N5.mjs → chunk-IEKGBS46.mjs} +1 -1
- package/dist/chunk-LU3BQ7WG.mjs +69 -0
- package/dist/chunk-QZNUWZG7.mjs +50 -0
- package/dist/{chunk-WU3SQZGD.mjs → chunk-TI2YXAHW.mjs} +2 -2
- package/dist/hosted.d.mts +3 -3
- package/dist/hosted.d.ts +3 -3
- package/dist/hosted.js +40 -40
- package/dist/hosted.mjs +1 -1
- package/dist/index.d.mts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +36 -36
- package/dist/index.mjs +1 -1
- package/dist/{modelFileResolver-Bq4pW9vc.d.mts → modelFileResolver-An1aQ0D3.d.mts} +3 -0
- package/dist/{modelFileResolver-Bq4pW9vc.d.ts → modelFileResolver-An1aQ0D3.d.ts} +3 -0
- package/dist/{modelViewerProps-BnrJO5DK.d.ts → modelViewerProps-BnVflYRA.d.mts} +21 -3
- package/dist/{modelViewerProps-wjBT4fks.d.mts → modelViewerProps-H_K454u_.d.ts} +21 -3
- package/dist/{publicProps-BZPMIRwj.d.ts → publicProps-AdNUI06n.d.ts} +1 -1
- package/dist/{publicProps-CW5X_HFh.d.mts → publicProps-BOQBJBA_.d.mts} +1 -1
- package/dist/simple-model-viewer.d.mts +6 -2
- package/dist/simple-model-viewer.d.ts +6 -2
- package/dist/simple-model-viewer.js +5 -5
- package/dist/simple-model-viewer.mjs +1 -1
- package/dist/utils.d.mts +4 -4
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +15 -15
- package/dist/utils.mjs +1 -1
- package/package.json +7 -5
- package/dist/chunk-2LGQKX6Z.mjs +0 -50
- package/dist/chunk-LEOHZ5HM.mjs +0 -69
- package/dist/chunk-UAZ6I25Y.mjs +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{c as ke}from"./chunk-IT2PUTJS.mjs";import"./chunk-MMO7KCYU.mjs";import{a as _e,b as Ne,c as xn}from"./chunk-F5QSXMME.mjs";import{b as yn,f as On,g as jn,q as dt,r as ut,s as He,t as pt,u as qe,v as kn}from"./chunk-LEOHZ5HM.mjs";import"./chunk-RSUXTWM6.mjs";import"./chunk-FGAJ2UT7.mjs";import"./chunk-SOAUR4DL.mjs";import{v as at,w as ct}from"./chunk-XKJQC3N5.mjs";import{a as ot,b as st}from"./chunk-NMRTI3NQ.mjs";import"./chunk-37YITTIK.mjs";import"./chunk-2AJK643D.mjs";import"./chunk-5C4H7SRF.mjs";import"./chunk-3PLML3PO.mjs";import{$ as Wt,Aa as lt,D as re,Da as Ue,E as Ee,Ea as De,Fa as An,G as Dt,Ga as En,H as Ht,Ha as Tn,Ia as In,Ja as Ln,R as _t,T as Nt,V as qt,W as Ft,X as Kt,Y as Gt,Z as zt,_ as $t,aa as fn,ba as ge,ca as ye,da as Le,e as it,ia as gn,ja as mn,n as Ae,oa as bn,pa as hn,ra as Vn,va as Bn,w as Ce,wa as vn,x as Se,xa as Mn,y as kt,ya as Pn,z as Ut,za as Rn}from"./chunk-2LGQKX6Z.mjs";import{a as xt,b as At,e as Et,f as Tt,g as It}from"./chunk-LX3GXQNU.mjs";import{b as fe,c as Ie,d as Xt,e as Jt,f as Qt,g as Zt,h as en,i as tn,j as nn,k as rn,l as on,m as sn,n as an,o as cn,p as ln,q as dn,r as un,s as pn}from"./chunk-7JCFNZJM.mjs";import"./chunk-37QOMZW6.mjs";import{b as Cn,c as Sn}from"./chunk-CCBFMNAU.mjs";import{a as Z,b as ce,c as Te}from"./chunk-GV4ZRXL6.mjs";import"./chunk-7OWHW66D.mjs";import{e as wn}from"./chunk-KFLS7GI6.mjs";import{a as Lt}from"./chunk-UAZ6I25Y.mjs";import{c as Yt}from"./chunk-BNKTI3CY.mjs";import"./chunk-UCD76KQ6.mjs";import"./chunk-TUYVYSN5.mjs";import"./chunk-RXZ4Q7CY.mjs";import"./chunk-JR557W27.mjs";import{useCallback as Un,useEffect as Oe,useMemo as je,useRef as Fe,useState as me}from"react";import{jsx as ue,jsxs as ft}from"react/jsx-runtime";var Dn=Object.freeze({});function gt(e){return ue(ot,{labels:e.labels,children:ue(Hn,{...e})})}function Hn({before:e,after:t,layout:i="slider",split:s,onSplitChange:p,reveal:y="auto",semanticComparison:l=!1,showComparisonOutlines:x,onComparisonOutlinesChange:B,onComparisonChange:O,linkSections:v,...m}){let k=st(),[E,C]=me(y==="auto");Oe(()=>{y==="auto"&&C(!0)},[y]);let[h,b]=me(.5),[f,S]=me(!0),R=x??f,j=P=>{x===void 0&&S(P),B?.(P)},q=He(s??h),X=Un(P=>{let A=He(P);s===void 0&&b(A),p?.(A)},[s,p]),_=Fe([null,null]),[V,J]=me([null,null]),[N,a]=me(null),[r,c]=me(null),u=[{...m,...e},{...m,...t}];Oe(()=>a(null),[u[0].sceneConfig?.section,u[1].sceneConfig?.section]);let w=P=>{let A=u[P].objectBindings;return A&&typeof A=="object"?A:V[P]?.url===u[P].modelUrl?V[P].bindings:Dn},L=w(0),$=w(1),n=je(()=>l?Ue({objectBindings:L,sceneConfig:u[0].sceneConfig},{objectBindings:$,sceneConfig:u[1].sceneConfig},typeof l=="object"?l:{}):null,[l,L,$,u[0].sceneConfig,u[1].sceneConfig]),o=n?JSON.stringify(n):"",g=Fe(null);Oe(()=>{n&&g.current!==o&&(g.current=o,O?.(n))},[n,o,O]);let d=n?.objects.find(P=>P.id===r),M=je(()=>n?[De(n,"before",r),De(n,"after",r)]:null,[n,r]),I=je(()=>ut(),[]);Oe(()=>()=>I.detach(),[I]);let T=[e,t],D=je(()=>[0,1].map(P=>(A,W)=>{_.current[P]=A,J(G=>G[P]?.bindings===A.objectBindings&&G[P]?.url===W?G:G.map((z,we)=>we===P?{url:W,bindings:A.objectBindings}:z)),I.attach(P,A.raw.controls,A.invalidate)}),[I]),Y=T.map((P,A)=>{let{label:W,...G}=P,z={preset:"minimal",...m,...G,refitOnResize:G.refitOnResize??m.refitOnResize??!1},we=G.onViewerReady??m.onViewerReady;return{...z,...v??!!l?{sceneConfig:{...z.sceneConfig,section:N??u[1].sceneConfig?.section??Ce},onSceneConfigChange:ie=>{a(ie.section??Ce),(G.onSceneConfigChange??m.onSceneConfigChange)?.(ie)}}:{},...M?{comparisonHighlights:R?M[A]:void 0,selectedObject:A===0?d?.beforeKey?L[d.beforeKey]:null:d?.afterKey?$[d.afterKey]:null}:{},onObjectSelect:ie=>{if((G.onObjectSelect??m.onObjectSelect)?.(ie),n){let Ve=n.objects.find(Q=>(A===0?Q.beforeObjectId:Q.afterObjectId)===ie?.modelObjectId);c(Ve?.id??null)}},onViewerReady:ie=>{D[A](ie,z.modelUrl),we?.(ie)}}}),K=[e.label??k("compareBefore"),t.label??k("compareAfter")];(!Y[0].modelUrl||!Y[1].modelUrl)&&console.error("[react-immersive] CompareViewer needs a modelUrl, shared or on each side.");let ae=Fe(null),ne=n?ue(dt,{showOutlines:R,onShowOutlinesChange:j,report:n,selected:r,onSelect:P=>{c(P.id);let A=P.afterObjectId?1:0,W=_.current[A],G=A===1?P.afterObjectId:P.beforeObjectId,z=G?W?.raw.nodes[G]:null;W&&z&&(I.setLeader(A),W.raw.controls.fitToBox(z,!0),W.invalidate())},onClear:()=>c(null)}):null;if(!E)return ue(at,{className:"ri-compare",background:ct(m.backgroundColor,m.sceneConfig),poster:m.poster??t.poster??e.poster,onReveal:()=>C(!0)});let F=i==="side-by-side";return ft("div",{ref:ae,className:`ri-compare ${F?"ri-compare--sideBySide":"ri-compare--slider"}`,style:F?void 0:{"--ri-compare-split":`${q*100}%`},children:[Y.map((P,A)=>ft("div",{className:F?"ri-compare__pane":A===1?"ri-compare__layer ri-compare__layer--after":"ri-compare__layer",children:[ue(ke,{...P}),F?ue("span",{className:"ri-compare__label",children:K[A]}):null]},A)),ne,F?null:ue(pt,{split:q,onSplitChange:X,labels:[K[0],K[1]],containerRef:ae})]})}import{useCallback as Re,useRef as jt}from"react";import{useCallback as H,useMemo as mt,useState as _n}from"react";var bt={baseColor:"texture",metalness:"metalnessMap",roughness:"roughnessMap",emissive:"emissiveMap",alpha:"alphaMap",normal:"normalMap",bump:"bumpMap",ao:"aoMap",displacement:"displacementMap",clearcoat:"clearcoatMap",clearcoatRoughness:"clearcoatRoughnessMap",clearcoatNormal:"clearcoatNormalMap",anisotropy:"anisotropyMap",transmission:"transmissionMap",thickness:"thicknessMap",sheenColor:"sheenColorMap",sheenRoughness:"sheenRoughnessMap",specularIntensity:"specularIntensityMap",specularColor:"specularColorMap"};function wt(e){if(e)return Object.fromEntries(Object.entries(e).map(([t,i])=>[t,i&&typeof i=="object"?{...i}:i]))}function Nn(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t.visible===!1).map(([t])=>[t,!0]))}function Ke(e){let[t,i]=_n(e),s=H((a,r)=>{i(c=>r===void 0?fe(c,a):fe(c,a,r))},[]),p=H((a,r)=>s(a,Ie(r)),[s]),y=H((a,r)=>p(a,{baseColor:r}),[p]),l=H((a,r,c="baseColor")=>{let u=bt[c],w=typeof r=="string"?{path:r}:r;s(a,{style:{material:{[u]:w}}})},[s]),x=H((a,r="baseColor")=>{let c=bt[r];s(a,{style:{material:{[c]:void 0}}})},[s]),B=H((a,r)=>{i(c=>{let u=Z(c,a);if(!u)return c;let w=wt(c[u]?.style?.material),L=ce(c,r);if(L.length===0)return c;let $=c;for(let n of L){let o=c[n];o&&($===c&&($={...c}),$[n]={...o,style:{...o.style,material:wt(w)}})}return $})},[]),O=H(a=>s(a,{style:{material:void 0}}),[s]),v=H((a,r)=>s(a,{transform:r}),[s]),m=H(a=>s(a,{transform:void 0}),[s]),k=H((a,r)=>s(a,{metadata:r}),[s]),E=H((a,r)=>{i(c=>{let u=c;for(let w of ce(c,a)){let L=c[w],$=r(L.decals??[]);u===c&&(u={...c}),u[w]={...L,decals:$.length>0?$:void 0}}return u})},[]),C=H((a,r)=>{let c=r.id??`decal-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;return E(a,u=>[...u.filter(w=>w.id!==c),{...r,id:c}]),c},[E]),h=H((a,r,c)=>E(a,u=>u.map(w=>w.id===r?{...w,...c}:w)),[E]),b=H((a,r)=>E(a,c=>c.filter(u=>u.id!==r)),[E]),f=H(a=>Te(t,a),[t]),S=H(a=>ce(t,a).map(r=>t[r]?.id??r),[t]),R=H(a=>{let r=Z(t,a);return r?t[r]?.style?.material??null:null},[t]),j=H(a=>s(a,{visible:!1}),[s]),q=H(a=>s(a,{visible:!0}),[s]),X=H(a=>{i(r=>{let c=ce(r,a).reduce((u,w)=>{let L=r[w];return L&&u.push({ids:w,patch:{visible:L.visible===!1}}),u},[]);return fe(r,c)})},[i]),_=H(()=>{i(a=>fe(a,Object.keys(a),{visible:!0}))},[i]),V=mt(()=>Nn(t),[t]),J=mt(()=>Object.keys(V).map(a=>t[a]?.id??a),[V,t]),N=H(a=>{let r=Z(t,a);return r?t[r]?.visible===!1:!1},[t]);return{objectBindings:t,setObjectBindings:i,updateObjectBindings:s,setMaterial:p,setBaseColor:y,setTexture:l,clearTexture:x,copyMaterial:B,resetMaterial:O,getMaterial:R,setTransform:v,resetTransform:m,updateMetadata:k,addDecal:C,updateDecal:h,removeDecal:b,selectObjectBindings:f,selectObjectBindingIds:S,hiddenObjects:V,hiddenObjectIds:J,hideObject:j,showObject:q,toggleObjectVisibility:X,isObjectHidden:N,clearHiddenObjects:_}}import{useCallback as ee,useMemo as qn,useRef as Fn,useState as Kn}from"react";function Ge(e){let t=Fn(null),[i,s]=Kn(()=>{let f=typeof e=="function"?e():e;return t.current=f,f}),p=ee(f=>{s(S=>{let R=typeof f=="function"?f(S):f;return _e(S,R)})},[]),y=ee(()=>{let f=t.current;f&&s(f)},[]),l=ee((f,S)=>{p(R=>({lighting:{lights:R.lighting.lights.map(j=>j.id===f?{...j,...S}:j)}}))},[p]),x=ee(f=>{p(S=>S.lighting.lights.some(R=>R.id===f.id)?{}:{lighting:{lights:[...S.lighting.lights,Ne(f)]}})},[p]),B=ee(f=>{p(S=>({lighting:{lights:S.lighting.lights.filter(R=>R.id!==f)}}))},[p]),O=ee((f,S)=>l(f,{intensity:S}),[l]),v=ee((f,S)=>l(f,{color:S}),[l]),m=ee(f=>l(f,{visible:!0}),[l]),k=ee(f=>l(f,{visible:!1}),[l]),E=ee(f=>{p(S=>({lighting:{lights:S.lighting.lights.map(R=>R.id===f?{...R,visible:!R.visible}:R)}}))},[p]),C=ee((f,S)=>l(f,{attachment:S,attachedToCamera:!1}),[l]),h=ee(f=>l(f,{attachment:void 0}),[l]),b=qn(()=>({items:i.lighting.lights,get:f=>i.lighting.lights.find(S=>S.id===f),add:x,update:l,remove:B,setIntensity:O,setColor:v,show:m,hide:k,toggle:E,attach:C,detach:h}),[i.lighting.lights,x,l,B,O,v,m,k,E,C,h]);return{sceneConfig:i,setSceneConfig:s,updateSceneConfig:p,resetSceneConfig:y,lights:b}}import{useCallback as ze}from"react";function $e({bindings:e,scene:t,camera:i,animations:s,isolation:p,onAction:y}){let{objectBindings:l,updateObjectBindings:x,showObject:B,hideObject:O,toggleObjectVisibility:v}=e,m=t?.updateSceneConfig,k=i?.focusObject,E=i?.fitScene,C=i?.resetView,h=i?.setCameraTarget,b=i?.setCameraState,f=s?.play,S=s?.pause,R=s?.stop,j=s?.setSpeed,q=s?.seek,X=p?.handleIsolationChange,_=ze(N=>{let a=Z(l,N);return a?l[a]?.actions??[]:[]},[l]),V=ze(async N=>{for(let a of N.action.effects??[]){if("objectBindings"in a){x(a.target,a.objectBindings);continue}if("sceneConfig"in a){m?.(a.sceneConfig);continue}if("isolation"in a){X?.(a.isolation);continue}if("visibility"in a){a.visibility==="show"?B(a.target):a.visibility==="hide"?O(a.target):v(a.target);continue}if("camera"in a){let c=a.camera;c.type==="focus-object"?await k?.(c.objectId??N.objectId):c.type==="fit-scene"?await E?.():c.type==="reset"?await C?.():c.type==="set-target"?await h?.(c.target,c.transition??!0):await b?.(c.state,c.transition??!0);continue}let r=a.animation;if(r.type==="play"){let{type:c,clip:u,...w}=r;f?.(u,w)}else r.type==="pause"?S?.(r.clip):r.type==="stop"?R?.(r.clip):r.type==="set-speed"?j?.(r.speed,r.clip):q?.(r.time,r.clip)}await y?.(N)},[E,k,O,y,S,f,C,q,j,b,h,X,B,R,v,x,m]),J=ze(async(N,a)=>{let r=Z(l,N);if(!r)return null;let c=l[r],u=c?.actions?.find(L=>L.id===a);if(!c||!u)return null;let w={objectId:r,action:u,binding:c};return await V(w),w},[V,l]);return{getActionsForObject:_,handleAction:V,runAction:J}}import{useCallback as he,useRef as yt}from"react";function Gn(e){return typeof e=="function"?e:e?.handleViewerReady??null}function We(...e){let t=yt(null),i=yt(e);i.current=e;let s=he(B=>{t.current=B;let O=new Set;for(let v of i.current){let m=Gn(v);m&&!O.has(m)&&(O.add(m),m(B))}},[]),p=he(()=>t.current,[]),y=he(B=>{let O=t.current;return O?O.captureImage(B):Promise.reject(new Error("ModelViewer is not ready yet."))},[]),l=he(()=>{let B=t.current;return B?(B.invalidate(),!0):!1},[]),x=he(B=>{let O=t.current;return O?O.captureVideo(B):Promise.reject(new Error("ModelViewer is not ready yet."))},[]);return{handleViewerReady:s,getViewer:p,captureImage:y,captureVideo:x,invalidate:l}}import{useCallback as U,useEffect as zn,useRef as oe}from"react";import{Material as $n,PointLight as Wn,Vector3 as Yn}from"three";var Je=["emissiveIntensity","opacity","metalness","roughness","transmission","clearcoat","clearcoatRoughness","ior","thickness"],Be=1;function ve(e){return typeof e=="string"?[e]:e}function Me(e,t=0,i=1){return Math.min(i,Math.max(t,e))}function Ye(e,t){return e+Math.random()*(t-e)}function ht([e,t],i){return e+(t-e)*i}function Xe([e,t],i){return[e[0]+(t[0]-e[0])*i,e[1]+(t[1]-e[1])*i,e[2]+(t[2]-e[2])*i]}function Vt(e,t){let i=Me(e);switch(t){case"ease-in":return i*i;case"ease-out":return 1-(1-i)*(1-i);case"ease-in-out":return i<.5?2*i*i:1-Math.pow(-2*i+2,2)/2;default:return i}}function Xn(e){let t=e.material;return t?(Array.isArray(t)?t:[t]).filter(i=>i instanceof $n):[]}function Jn(e){let t={opacity:e.opacity,transparent:e.transparent};e.color&&(t.baseColor=`#${e.color.getHexString()}`),e.emissive&&(t.emissive=`#${e.emissive.getHexString()}`);for(let i of Je){let s=e[i];typeof s=="number"&&(t[i]=s)}return t}function Ct(e,t){t.baseColor!==void 0&&e.color&&e.color.set(t.baseColor),t.emissive!==void 0&&e.emissive&&e.emissive.set(t.emissive);for(let i of Je){let s=t[i];s!==void 0&&typeof e[i]=="number"&&(e[i]=s)}t.transparent!==void 0&&(e.transparent=t.transparent),e.needsUpdate=!0}function Qn(e){return{position:[e.position.x,e.position.y,e.position.z],rotation:[e.rotation.x,e.rotation.y,e.rotation.z],scale:[e.scale.x,e.scale.y,e.scale.z],visible:e.visible}}function Zn(e,t){if(t.position&&e.position.set(...t.position),t.rotation&&e.rotation.set(...t.rotation),t.scale!==void 0){let i=typeof t.scale=="number"?[t.scale,t.scale,t.scale]:t.scale;e.scale.set(...i)}t.visible!==void 0&&(e.visible=t.visible),e.updateMatrix(),e.updateMatrixWorld(!0)}function Qe(e={}){let t=oe(e);t.current=e;let i=oe(null),s=oe(null),p=oe(null),y=oe(new Map),l=oe(new Map),x=oe(new Map),B=oe(new Map),O=U(n=>{let o=i.current;if(!o)return null;let g=Z(o.objectBindings,n);return o.raw.nodes[n]??(g?o.raw.nodes[g]:null)??(o.raw.scene?it(o.raw.scene,n):null)??null},[]),v=U(n=>{let o=i.current;return o?typeof n=="object"&&!Array.isArray(n)?ce(o.objectBindings,n):ve(n).map(g=>Z(o.objectBindings,g)??g):typeof n=="string"?[n]:Array.isArray(n)?n:[]},[]),m=U(()=>{i.current?.invalidate()},[]),k=U((n,o)=>{let g=!1;for(let d of v(n)){let M=O(d);if(M)for(let I of Xn(M))x.current.has(I)||x.current.set(I,Jn(I)),Ct(I,o),g=!0}return g},[O,v]),E=U((n,o)=>{let g=k(n,o);return g&&m(),g},[m,k]),C=U((n,o)=>{let g=!1;for(let d of v(n)){let M=O(d);M&&(B.current.has(M)||B.current.set(M,Qn(M)),Zn(M,o),g=!0)}return g},[O,v]),h=U((n,o)=>{let g=C(n,o);return g&&m(),g},[m,C]),b=U(n=>{let o=O(n);if(!o)return null;o.updateWorldMatrix(!0,!1);let g=o.getWorldPosition(new Yn);return[g.x,g.y,g.z]},[O]),f=U(n=>{let o=l.current.get(n);return o?(o.light.removeFromParent(),o.light.dispose(),l.current.delete(n),m(),!0):!1},[m]),S=U(n=>{let o=O(n.target);if(!o)return!1;let g=l.current.get(n.id),d=g?.light??new Wn;return g&&g.target!==n.target&&d.removeFromParent(),d.name=`react-immersive-runtime-light:${n.id}`,d.color.set(n.color??"#ffffff"),d.intensity=n.intensity??1,d.distance=n.distance??0,d.decay=n.decay??2,d.castShadow=n.castShadow??!1,d.position.set(...n.offset??[0,0,0]),d.parent!==o&&o.add(d),l.current.set(n.id,{light:d,target:n.target}),m(),!0},[m,O]),R=U((n,o)=>{let g=l.current.get(n);if(!g)return!1;if(o.target&&o.target!==g.target){let d=O(o.target);if(!d)return!1;g.light.removeFromParent(),d.add(g.light),g.target=o.target}return o.color!==void 0&&g.light.color.set(o.color),o.intensity!==void 0&&(g.light.intensity=o.intensity),o.distance!==void 0&&(g.light.distance=o.distance),o.decay!==void 0&&(g.light.decay=o.decay),o.offset!==void 0&&g.light.position.set(...o.offset),o.castShadow!==void 0&&(g.light.castShadow=o.castShadow),m(),!0},[m,O]),j=U((n,o)=>{let g=d=>o[d%o.length]??0;for(let d of n.materials??[])v(d.targets).forEach((M,I)=>{let T=g(I),D={};for(let Y of Je){let K=d.values[Y];K&&(D[Y]=ht(K,T))}k(M,D)});for(let d of n.transforms??[])v(d.targets).forEach((M,I)=>{let T=g(I),D={};d.values.position&&(D.position=Xe(d.values.position,T)),d.values.rotation&&(D.rotation=Xe(d.values.rotation,T)),d.values.scale&&(D.scale=Xe(d.values.scale,T)),C(M,D)});for(let d of n.lights??[])ve(d.lights).forEach((M,I)=>{let T=l.current.get(M);T&&(T.light.intensity=ht(d.intensity,g(I)))})},[v,k,C]),q=oe(()=>{}),X=oe(()=>{});X.current=n=>{p.current=null;let o=!1;for(let[g,d]of y.current){d.startedAt===null&&(d.startedAt=n);let M=d.lastFrameAt??n;d.lastFrameAt=n;let I=d.override&&d.override.until>n?d.override.level:null;d.override&&I===null&&(d.override=null);let T=d.update(n,n-d.startedAt,Math.min(100,n-M),I);o=!0,T||(y.current.delete(g),d.onComplete?.())}o&&m(),y.current.size>0&&q.current()},q.current=()=>{p.current!==null||typeof requestAnimationFrame>"u"||(p.current=requestAnimationFrame(n=>X.current(n)))};let _=U(n=>(y.current.set(n.id,n),q.current(),n.id),[]),V=U((n,o={})=>{let g=o.id??`transition-${Be++}`,d=Math.max(1,o.duration??400),M=o.easing??"ease-in-out";return _({id:g,startedAt:null,lastFrameAt:null,override:null,onComplete:o.onComplete,update:(I,T,D,Y)=>{let K=Y??Vt(T/d,M);return j(n,[K]),T<d}})},[j,_]),J=U((n,o={})=>{let g=o.id??`pulse-${Be++}`,d=Math.max(1,o.duration??1e3),M=o.minLevel??0,I=o.maxLevel??1,T=o.repeat??1/0,D=o.synchronized??!0,Y=Math.max(1,...[...n.materials??[],...n.transforms??[]].map(K=>v(K.targets).length),...(n.lights??[]).map(K=>ve(K.lights).length));return _({id:g,startedAt:null,lastFrameAt:null,override:null,onComplete:o.onComplete,update:(K,ae,de,ne)=>{let F=ae/d,P=Array.from({length:D?1:Y},(A,W)=>{if(ne!==null)return ne;let G=F+(D?0:W/Y),z=.5-Math.cos(G%1*Math.PI*2)/2;return M+(I-M)*z});return j(n,P),T===1/0||F<T}})},[j,_,v]),N=U((n,o={})=>{let g=o.id??`timeline-${Be++}`,d=o.repeat??1,M=n.map(T=>({...T,duration:Math.max(1,T.duration),hold:Math.max(0,T.hold??0)})),I=Math.max(1,M.reduce((T,D)=>T+D.duration+D.hold,0));return _({id:g,startedAt:null,lastFrameAt:null,override:null,onComplete:o.onComplete,update:(T,D,Y,K)=>{if(M.length===0||d<=0)return!1;let ae=D/I;if(d!==1/0&&ae>=d){for(let F of M)j(F.channels,[1]);return!1}let de=D%I,ne=0;for(let F of M){let P=ne+F.duration,A=P+F.hold;if(de>=P){j(F.channels,[K??1]),ne=A;continue}if(de>=ne){let W=K??Vt((de-ne)/F.duration,F.easing??"ease-in-out");j(F.channels,[W]);break}}return!0}})},[j,_]),a=U((n,o={})=>{let g=o.id??`flicker-${Be++}`,d=o.synchronized??!0,M=o.minLevel??.15,I=o.maxLevel??1,T=o.interval??[45,160],D=typeof T=="number"?[T,T]:T,Y=[Math.max(1,Math.min(...D)),Math.max(1,Math.max(...D))],K=Me(o.response??.7,.01,1),ae=Me(o.blackoutChance??.08),de=Me(o.flashChance??.12),ne=o.flashLevel??1.15,F=Math.max(1,...[...n.materials??[],...n.transforms??[]].map(z=>v(z.targets).length),...(n.lights??[]).map(z=>ve(z.lights).length)),P=d?1:F,A=Array.from({length:P},()=>M),W=Array.from({length:P},()=>M),G=Array.from({length:P},()=>0);return _({id:g,startedAt:null,lastFrameAt:null,override:null,onComplete:o.onComplete,update:(z,we,ie,Ve)=>{for(let Q=0;Q<P;Q+=1){if(Ve!==null)W[Q]=Ve;else if(z>=G[Q]){let rt=Math.random();W[Q]=rt<ae?Ye(0,Math.min(.04,M)):rt<ae+de?ne:Ye(M,I),G[Q]=z+Ye(...Y)}let Rt=1-Math.pow(1-K,Math.max(1,ie)/16.67);A[Q]+=(W[Q]-A[Q])*Rt}return j(n,A),o.duration===void 0||we<o.duration}})},[j,_,v]),r=U((n,o,g)=>{let d=y.current.get(n);if(!d)return!1;let M=typeof performance>"u"?Date.now():performance.now();return d.override={level:o,until:M+Math.max(0,g)},q.current(),!0},[]),c=U(n=>y.current.delete(n),[]),u=U(()=>{y.current.clear(),p.current!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(p.current),p.current=null)},[]),w=U(()=>{for(let[n,o]of x.current)Ct(n,o);x.current.clear();for(let[n,o]of B.current)n.position.set(...o.position),n.rotation.set(...o.rotation),n.scale.set(...o.scale),n.visible=o.visible,n.updateMatrix(),n.updateMatrixWorld(!0);B.current.clear();for(let n of l.current.values())n.light.removeFromParent(),n.light.dispose();l.current.clear(),m()},[m]),L=U(()=>{u(),w()},[w,u]),$=U(n=>{s.current&&s.current!==n.raw.scene&&w(),i.current=n,s.current=n.raw.scene,t.current.onViewerReady?.(n)},[w]);return zn(()=>()=>{L(),i.current=null,s.current=null},[L]),{handleViewerReady:$,setMaterial:E,setTransform:h,getWorldPosition:b,addPointLight:S,updatePointLight:R,removePointLight:f,transition:V,timeline:N,pulse:J,flicker:a,overrideEffect:r,stopEffect:c,stopAllEffects:u,resetRuntime:L}}import{useCallback as er,useState as tr}from"react";function Ze(){let[e,t]=tr(null),i=er(s=>{t(s)},[t]);return{hoveredObjectBinding:e,handleHoveredObject:i}}import{useCallback as St,useState as nr}from"react";function et(e=null){let[t,i]=nr(e),s=St((y,l)=>i({...l,target:y}),[]),p=St(()=>i(null),[]);return{isolation:t,isolate:s,clearIsolation:p,handleIsolationChange:i}}import{useCallback as Pe,useState as le}from"react";function tt(){let[e,t]=le(!0),[i,s]=le(!1),[p,y]=le(null),[l,x]=le(null),[B,O]=le(0),[v,m]=le([]),[k,E]=le([]),[C,h]=le([]),b=Pe(j=>{x(j.bounds),O(j.objectCount),m(j.materialVariants),E(j.materialVariantGroups),y(null),t(!1),s(!0)},[]),f=Pe(j=>h(j),[]),S=Pe(j=>{y(j),x(null),O(0),m([]),E([]),h([]),t(!1),s(!1)},[]),R=Pe(()=>{t(!0),s(!1),y(null),x(null),O(0),m([]),E([]),h([])},[]);return{isLoading:e,isReady:i,error:p,bounds:l,objectCount:B,materialVariants:v,materialVariantGroups:k,objects:C,handleModelLoaded:b,handleObjectCatalog:f,handleLoadError:S,resetModelState:R}}import{useCallback as Ot,useState as rr}from"react";function nt(e=null){let[t,i]=rr(e),s=Ot(y=>{i(y)},[i]),p=Ot(()=>{i(null)},[]);return{selectedObjectBinding:t,setSelectedObjectBinding:i,handleObjectSelect:s,clearSelection:p}}var ir={};function or(e={}){let t=jt(e);t.current=e;let i=jt(e.bindings===void 0||e.bindings==="auto"),s=Ke(()=>{let V=t.current.bindings;return V===void 0||V==="auto"?ir:typeof V=="function"?V():V}),p=Ge(()=>{let V=t.current.sceneConfig;return V===void 0?Se:typeof V=="function"?V():V}),y=nt(),l=Ze(),x=Ae(e.camera),B=tt(),O=qe(),v=et(),m=Qe(),k=We(x,m),E=$e({bindings:s,scene:p,camera:x,animations:O,isolation:v,onAction:e.onAction}),{setObjectBindings:C}=s,{handleObjectCatalog:h}=B,b=Re(V=>{h(V),i.current&&C(J=>{let N=lt(V.map(a=>a.name));for(let a of Object.keys(N))J[a]&&(N[a]=J[a]);return N})},[h,C]),{handleObjectSelect:f}=y,S=Re(V=>{f(V),t.current.onObjectSelect?.(V)},[f]),{handleHoveredObject:R}=l,j=Re(V=>{R(V),t.current.onObjectHover?.(V)},[R]),{handleLoadError:q}=B,X=Re(V=>{q(V),t.current.onLoadError?.(V)},[q]),_=e.sceneConfig!==void 0||p.sceneConfig!==Se;return{props:{objectBindings:s.objectBindings,onObjectBindingsChange:C,selectedObject:y.selectedObjectBinding,onObjectSelect:S,onObjectHover:j,onCameraChange:x.handleCameraChange,onViewerReady:k.handleViewerReady,onModelLoaded:B.handleModelLoaded,onLoadError:X,onObjectCatalog:b,onAnimationsReady:O.handleAnimationsReady,onAction:E.handleAction,onSceneConfigChange:p.setSceneConfig,isolation:v.isolation,onIsolationChange:v.handleIsolationChange,..._?{sceneConfig:p.sceneConfig}:{}},bindings:s,selection:y,hover:l,camera:x,model:B,animations:O,actions:E,scene:p,isolation:v,effects:m,connection:k}}import{useMemo as sr}from"react";function ar(e,t){return sr(()=>{if(!t)return null;let i=e[t];return i||(Object.values(e).find(s=>s.id===t||s.modelObjectId===t)??null)},[e,t])}import{useMemo as cr}from"react";function lr(e){return cr(()=>Object.values(e).map(t=>t.modelObjectId),[e])}import{useCallback as te,useEffect as xe,useRef as se,useState as dr}from"react";function ur(e,t){if(!e.objectBindings&&(!!e.hidden?.length||!!e.selected)&&Object.keys(t).length===0)return null;let s={};if(e.objectBindings)s.bindings=e.objectBindings;else if(e.hidden){let p=new Set(e.hidden);s.bindings=Object.fromEntries(Object.entries(t).map(([y,l])=>[y,{...l,visible:!p.has(l.id)}]))}if(e.selected!==void 0){let p=e.objectBindings??t,y=e.selected?Z(p,e.selected):null;s.selected=y?p[y]:null}return s}function Bt(e){return JSON.stringify(e&&{modelUrl:e.modelUrl,activeModelId:e.activeModelId,tilesetUrl:e.tilesetUrl,mergeModels:e.mergeModels,models:e.models?.map(({id:t,url:i,mergeModels:s})=>({id:t,url:i,mergeModels:s}))})}function pr(e){let t=se(e);t.current=e;let i=e.paramKey??"view",s=`${i}Id`,[p,y]=dr(!1),l=se(null),x=se(null),B=se(null),O=se(null),v=se(null),m=se(null),k=se(null),E=se(null),C=se(!0),h=te(r=>{let c=r instanceof Error?r:new Error(String(r));t.current.onError?t.current.onError(c):k.current!==c.message&&console.warn("[react-immersive]",c.message),k.current=c.message},[]),b=te(()=>{v.current!==null&&clearTimeout(v.current),v.current=null},[]);xe(()=>(C.current=!0,()=>{C.current=!1,b()}),[b]);let f=te(()=>{let r=t.current,c=(r.mode??(r.configuration?"configuration":"view"))==="configuration";return{version:1,camera:r.cameraState??void 0,hidden:Object.values(r.objectBindings).filter(u=>u.visible===!1).map(u=>u.id),selected:r.selectedObjectBinding?.id??null,...c?{objectBindings:r.objectBindings,configuration:r.configuration}:{}}},[]),S=te(()=>ye(f(),typeof window>"u"?void 0:window.location.href),[f]),R=te(()=>Le(f(),typeof window>"u"?void 0:window.location.href),[f]),j=te((r,c,u=window.location.href)=>{let w=new URL(u),L=new URLSearchParams(w.hash.slice(1));if(L.delete(i),L.delete(s),L.set(c?s:i,r),w.hash=L.toString(),!c&&w.href.length>(t.current.maxUrlLength??65536))throw new Error("Viewer configuration is too large for an inline link. Save JSON instead, or configure storage for createShareUrl(). Uploaded images can make links large.");return w.href},[i,s]),q=te(()=>j(ge(S()),!1),[S,j]),X=te(async()=>{let r=window.location.href,c=t.current.storage,u=await R();if(!c)return j(ge(u),!1,r);let w=await c.save(u);if(typeof w!="string"||!w.trim()||w.length>2048)throw new Error("Viewer state storage returned an invalid id.");return j(w,!0,r)},[R,j]),_=te(()=>{if(b(),l.current||m.current)return;let r=q();window.history.replaceState(null,"",r),O.current=`inline:${new URL(r).hash}`},[b,q]),V=te(async()=>{let r=l.current;if(!r||x.current||!C.current)return!1;x.current=r,b();try{let c=t.current,u=r.state;if(u.configuration&&!r.configurationApplied){if(!c.onConfigurationChange)throw new Error("Restoring a full viewer configuration requires onConfigurationChange.");return r.configurationApplied=!0,c.onConfigurationChange(u.configuration),!1}if(u.configuration&&Bt(c.configuration)!==Bt(u.configuration)||c.isReady===!1)return!1;if(u.camera&&!r.cameraApplied){if(!await c.setCameraState(u.camera,!1)||l.current!==r||!C.current)return!1;r.cameraApplied=!0}c=t.current;let w=ur(u,c.objectBindings);return!w||l.current!==r?!1:(w.bindings&&c.onObjectBindingsChange(w.bindings),w.selected!==void 0&&c.setSelectedObjectBinding(w.selected),l.current=null,B.current=r.key,y(!0),!0)}catch(c){throw l.current===r&&(l.current=null),y(!1),c}finally{x.current=null,l.current&&l.current!==r&&C.current&&V().catch(h)}},[b,h]),J=te(async r=>{let c=ye(r,window.location.href);b(),E.current=null,m.current=null;let u=new URLSearchParams(window.location.hash.slice(1));return O.current=u.has(i)?`inline:${window.location.hash}`:u.has(s)?`stored:${s}:${u.get(s)}`:null,B.current=null,l.current={key:`manual:${ge(c)}`,origin:"manual",state:c,configurationApplied:!1,cameraApplied:!1},y(!1),V()},[V,b,i,s]),N=te(async()=>{let r=new URLSearchParams(window.location.hash.slice(1)),c=r.get(i),u=r.get(s),w=c!==null?`inline:${window.location.hash}`:u!==null?`stored:${s}:${u}`:null;if(!w)return E.current=null,m.current=null,l.current?.origin==="manual"?V():(l.current=null,B.current=null,y(!0),!1);if(w===O.current||w===B.current)return l.current?.origin==="manual"?V():!1;if(l.current?.key===w)return V();b(),y(!1),E.current=w,l.current=null;let L=c;if(c===null){let n=t.current.storage;if(!n)throw new Error("This shared link requires a viewer state storage adapter.");(!m.current||m.current.key!==w)&&(m.current={key:w,promise:n.load(u)});let o=m.current;try{L=await o.promise}finally{m.current===o&&(m.current=null)}if(E.current!==w||!C.current)return!1;let g=l.current;if(g?.key===w||B.current===w)return g?V():!1}let $;try{$=ye(L,window.location.href)}catch(n){throw n}return l.current={key:w,origin:"url",state:$,configurationApplied:!1,cameraApplied:!1},V()},[V,b,s,i]);xe(()=>{l.current&&V().catch(h)}),xe(()=>{let r=()=>{N().catch(h)};return window.addEventListener("hashchange",r),()=>window.removeEventListener("hashchange",r)},[N,h]);let a=null;if(e.autoSync!==!1&&p&&!l.current&&!m.current)try{a=ge(S())}catch{}return xe(()=>{if(e.autoSync===!1||!p||l.current||m.current){b();return}if(a===null){try{S()}catch(r){h(r)}return}return v.current=setTimeout(()=>{v.current=null;try{_()}catch(r){h(r)}},Math.max(0,e.debounceMs??400)),b},[a,e.autoSync,e.debounceMs,p,b,S,_,h]),{getState:S,getStateAsync:R,restoreState:J,getShareUrl:q,createShareUrl:X,syncUrl:_,restoreFromUrl:N}}import{useCallback as pe,useState as vt}from"react";var fr={};function Mt(){return`asset-${globalThis.crypto.randomUUID()}`}function gr(e){let[t,i]=vt(e),[s,p]=vt(()=>e[0]?re(e[0]):""),y=t.find(C=>re(C)===s)??t[0],l=y?re(y):"",x=pe(C=>{i(h=>h.map(b=>re(b)===l?{...b,objectBindings:C}:b))},[l]),B=pe(C=>{i(h=>h.map(b=>re(b)===l?{...b,sceneConfig:C}:b))},[l]),O=pe(C=>p(h=>{let b=t.find(f=>f.url===C);return b?re(b):h}),[t]),v=pe(C=>{let h={...C,id:C.id??Mt()};return i(b=>{if(b.some(f=>re(f)===h.id))throw new Error("Asset instance ID already exists.");return[...b,h]}),h.id},[]),m=pe(C=>{let h=t.find(j=>re(j)===C);if(!h)return null;let b=structuredClone(h);b.id=Mt(),b.sceneConfig?.measurements&&(b.sceneConfig.measurements.items=b.sceneConfig.measurements.items.map(j=>({...j,modelId:b.id}))),b.label=`${h.label??"Asset"} copy`;let[f,S,R]=h.transform?.position??[0,0,0];return b.transform={...b.transform,position:[f+1,S,R]},i(j=>[...j,b]),b.id},[t]),k=pe(C=>{i(h=>h.filter(b=>re(b)!==C))},[]),E=pe((C,h)=>{let b=Ee(h);i(f=>f.map(S=>re(S)===C?{...S,transform:b}:S))},[]);return{modelUrl:y?.url??"",models:t,activeModelId:l,onModelChange:O,onActiveModelChange:p,objectBindings:fr,onObjectBindingsChange:x,sceneConfig:y?.sceneConfig,onSceneConfigChange:B,addModel:v,duplicateModel:m,removeModel:k,updateModelTransform:E}}import{useCallback as be,useEffect as mr,useState as br,useSyncExternalStore as wr}from"react";var yr={sequenceId:null,time:0,duration:0,status:"stopped",previewing:!1,ready:!1,issues:[]},hr=()=>()=>{},Pt=()=>yr;function Vr(){let[e,t]=br(null),i=wr(e?.subscribe??hr,e?.getState??Pt,Pt);mr(()=>()=>e?.stop(),[e]);let s=be(p=>t(p),[]);return{controls:e,playback:i,handleSequencesReady:s,play:be(p=>e?.play(p)??!1,[e]),pause:be(()=>e?.pause(),[e]),stop:be(()=>e?.stop(),[e]),seek:be(p=>e?.seek(p)??!1,[e]),select:be(p=>e?.select(p)??!1,[e])}}export{hn as ACTION_CATALOG,kn as AssetDiagnosticsPanel,gt as CompareViewer,Lt as DEFAULT_MODEL_VIEWER_LABELS,Se as DEFAULT_SCENE_CONFIG,Ce as DEFAULT_SECTION_CONFIG,En as MATERIAL_BLENDING_MODES,An as MATERIAL_SIDES,fn as MAX_VIEWER_STATE_BYTES,_t as MEASUREMENT_UNITS,yn as MODEL_VIEWER_PRESETS,ke as ModelViewer,jn as ProductOptions,At as SEQUENCE_EASINGS,xt as SEQUENCE_OBJECT_PROPERTIES,vn as applyIsolation,pn as applyProductOptions,Sn as applyStyleRules,Rn as buildBindingsFromNodes,qt as calibrateMeasurements,Yt as chooseMaterialVariant,Tn as collectObjectHierarchy,Cn as colorScaleValue,Ue as compareViewerConfigurations,In as copyBindingStyle,gn as createARHandoffUrl,Pn as createDefaultBinding,on as decodeProductSelections,Jt as defaultProductSelections,xn as defineObjectBindings,rn as encodeProductSelections,Qt as evaluateProductConfiguration,bn as exportConfiguredUSDZ,Vn as findCatalogAction,tn as formatProductPrice,sn as generateProductSkus,Ht as groundAsset,Mn as inferType,wn as inspectAsset,Bn as isolatedBindingKeys,Ie as material,Kt as measurementResult,Nt as measurementScale,Ft as measurementValue,$t as measurementsToCsv,Ee as parseAssetTransform,Gt as parseMeasurements,un as parseProductConfiguration,Xt as parseProductDefinition,ln as parseSceneProduct,kt as parseSectionConfig,Wt as parseSelectionSets,Et as parseSequences,ye as parseViewerState,Ln as pasteBindingStyle,fe as patchBindings,_e as patchSceneConfig,Le as prepareViewerState,nn as productCheckoutUrl,an as productDefinitionWarnings,cn as productOptionStates,en as productPriceFromDefinition,mn as readARHandoffUrl,Zt as resolveProductSelections,Tt as sampleSequenceTrack,Ne as sceneLight,Ut as sectionSnapshot,ce as selectBindingKeys,Te as selectBindings,zt as serializeMeasurements,dn as serializeProductConfiguration,ge as serializeViewerState,Dt as snapAssetToGrid,It as upsertSequenceKeyframe,ar as useObjectBinding,lr as useObjectBindingIds,Ke as useObjectBindings,On as useProductConfigurator,Ge as useSceneConfig,pr as useShareableViewerState,or as useViewer,$e as useViewerActions,qe as useViewerAnimations,Ae as useViewerCamera,We as useViewerConnection,Qe as useViewerEffects,Ze as useViewerHover,et as useViewerIsolation,tt as useViewerModel,gr as useViewerModels,nt as useViewerSelection,Vr as useViewerSequences};
|
|
1
|
+
"use client";import{c as ke}from"./chunk-CHMFH4D4.mjs";import"./chunk-MMO7KCYU.mjs";import{a as _e,b as Ne,c as xn}from"./chunk-F5QSXMME.mjs";import{b as yn,f as On,g as jn,q as dt,r as ut,s as He,t as pt,u as qe,v as kn}from"./chunk-LU3BQ7WG.mjs";import"./chunk-CUDL77ZY.mjs";import"./chunk-FGAJ2UT7.mjs";import"./chunk-SOAUR4DL.mjs";import{v as at,w as ct}from"./chunk-IEKGBS46.mjs";import{a as it,b as st}from"./chunk-3GA7JFNH.mjs";import"./chunk-37YITTIK.mjs";import"./chunk-2AJK643D.mjs";import"./chunk-5C4H7SRF.mjs";import"./chunk-3PLML3PO.mjs";import{$ as zt,A as kt,Aa as Pn,B as Ut,Ba as Rn,Ca as lt,F as re,Fa as Ue,G as Ee,Ga as De,Ha as An,I as Dt,Ia as En,J as Ht,Ja as Tn,Ka as In,La as Ln,T as _t,V as Nt,X as qt,Y as Ft,Z as Kt,_ as Gt,aa as $t,ba as Wt,ca as fn,da as me,e as ot,ea as he,fa as Le,ka as gn,la as mn,p as Ae,qa as bn,ra as hn,ta as Vn,xa as Bn,y as Ce,ya as vn,z as Se,za as Mn}from"./chunk-QZNUWZG7.mjs";import{a as xt,b as At,e as Et,f as Tt,g as It}from"./chunk-LX3GXQNU.mjs";import{b as ge,c as Ie,d as Xt,e as Jt,f as Qt,g as Zt,h as en,i as tn,j as nn,k as rn,l as on,m as sn,n as an,o as cn,p as ln,q as dn,r as un,s as pn}from"./chunk-7JCFNZJM.mjs";import"./chunk-37QOMZW6.mjs";import{b as Cn,c as Sn}from"./chunk-CCBFMNAU.mjs";import{a as Z,b as ce,c as Te}from"./chunk-GV4ZRXL6.mjs";import"./chunk-7OWHW66D.mjs";import{e as wn}from"./chunk-KFLS7GI6.mjs";import{a as Lt}from"./chunk-3I7PPFUV.mjs";import{c as Yt}from"./chunk-BNKTI3CY.mjs";import"./chunk-UCD76KQ6.mjs";import"./chunk-TUYVYSN5.mjs";import"./chunk-RXZ4Q7CY.mjs";import"./chunk-JR557W27.mjs";import{useCallback as Un,useEffect as Oe,useMemo as je,useRef as Fe,useState as be}from"react";import{jsx as ue,jsxs as ft}from"react/jsx-runtime";var Dn=Object.freeze({});function gt(e){return ue(it,{labels:e.labels,children:ue(Hn,{...e})})}function Hn({before:e,after:t,layout:o="slider",split:s,onSplitChange:f,reveal:y="auto",semanticComparison:l=!1,showComparisonOutlines:x,onComparisonOutlinesChange:E,onComparisonChange:B,linkSections:h,...p}){let I=st(),[P,S]=be(y==="auto");Oe(()=>{y==="auto"&&S(!0)},[y]);let[V,b]=be(.5),[g,O]=be(!0),R=x??g,j=M=>{x===void 0&&O(M),E?.(M)},q=He(s??V),X=Un(M=>{let A=He(M);s===void 0&&b(A),f?.(A)},[s,f]),_=Fe([null,null]),[C,J]=be([null,null]),[N,a]=be(null),[r,c]=be(null),u=[{...p,...e},{...p,...t}];Oe(()=>a(null),[u[0].sceneConfig?.section,u[1].sceneConfig?.section]);let w=M=>{let A=u[M].objectBindings;return A&&typeof A=="object"?A:C[M]?.url===u[M].modelUrl?C[M].bindings:Dn},k=w(0),$=w(1),n=je(()=>l?Ue({objectBindings:k,sceneConfig:u[0].sceneConfig},{objectBindings:$,sceneConfig:u[1].sceneConfig},typeof l=="object"?l:{}):null,[l,k,$,u[0].sceneConfig,u[1].sceneConfig]),i=n?JSON.stringify(n):"",m=Fe(null);Oe(()=>{n&&m.current!==i&&(m.current=i,B?.(n))},[n,i,B]);let d=n?.objects.find(M=>M.id===r),v=je(()=>n?[De(n,"before",r),De(n,"after",r)]:null,[n,r]),L=je(()=>ut(),[]);Oe(()=>()=>L.detach(),[L]);let T=[e,t],D=je(()=>[0,1].map(M=>(A,W)=>{_.current[M]=A,J(G=>G[M]?.bindings===A.objectBindings&&G[M]?.url===W?G:G.map((z,ye)=>ye===M?{url:W,bindings:A.objectBindings}:z)),L.attach(M,A.raw.controls,A.invalidate)}),[L]),Y=T.map((M,A)=>{let{label:W,...G}=M,z={preset:"minimal",...p,...G,refitOnResize:G.refitOnResize??p.refitOnResize??!1},ye=G.onViewerReady??p.onViewerReady;return{...z,...h??!!l?{sceneConfig:{...z.sceneConfig,section:N??u[1].sceneConfig?.section??Ce},onSceneConfigChange:oe=>{a(oe.section??Ce),(G.onSceneConfigChange??p.onSceneConfigChange)?.(oe)}}:{},...v?{comparisonHighlights:R?v[A]:void 0,selectedObject:A===0?d?.beforeKey?k[d.beforeKey]:null:d?.afterKey?$[d.afterKey]:null}:{},onObjectSelect:oe=>{if((G.onObjectSelect??p.onObjectSelect)?.(oe),n){let Ve=n.objects.find(Q=>(A===0?Q.beforeObjectId:Q.afterObjectId)===oe?.modelObjectId);c(Ve?.id??null)}},onViewerReady:oe=>{D[A](oe,z.modelUrl),ye?.(oe)}}}),K=[e.label??I("compareBefore"),t.label??I("compareAfter")];(!Y[0].modelUrl||!Y[1].modelUrl)&&console.error("[react-immersive] CompareViewer needs a modelUrl, shared or on each side.");let ae=Fe(null),ne=n?ue(dt,{showOutlines:R,onShowOutlinesChange:j,report:n,selected:r,onSelect:M=>{c(M.id);let A=M.afterObjectId?1:0,W=_.current[A],G=A===1?M.afterObjectId:M.beforeObjectId,z=G?W?.raw.nodes[G]:null;W&&z&&(L.setLeader(A),W.raw.controls.fitToBox(z,!0),W.invalidate())},onClear:()=>c(null)}):null;if(!P)return ue(at,{className:"ri-compare",background:ct(p.backgroundColor,p.sceneConfig),poster:p.poster??t.poster??e.poster,onReveal:()=>S(!0)});let F=o==="side-by-side";return ft("div",{ref:ae,className:`ri-compare ${F?"ri-compare--sideBySide":"ri-compare--slider"}`,style:F?void 0:{"--ri-compare-split":`${q*100}%`},children:[Y.map((M,A)=>ft("div",{className:F?"ri-compare__pane":A===1?"ri-compare__layer ri-compare__layer--after":"ri-compare__layer",children:[ue(ke,{...M}),F?ue("span",{className:"ri-compare__label",children:K[A]}):null]},A)),ne,F?null:ue(pt,{split:q,onSplitChange:X,labels:[K[0],K[1]],containerRef:ae})]})}import{useCallback as Re,useRef as jt}from"react";import{useCallback as H,useMemo as mt,useState as _n}from"react";var bt={baseColor:"texture",metalness:"metalnessMap",roughness:"roughnessMap",emissive:"emissiveMap",alpha:"alphaMap",normal:"normalMap",bump:"bumpMap",ao:"aoMap",displacement:"displacementMap",clearcoat:"clearcoatMap",clearcoatRoughness:"clearcoatRoughnessMap",clearcoatNormal:"clearcoatNormalMap",anisotropy:"anisotropyMap",transmission:"transmissionMap",thickness:"thicknessMap",sheenColor:"sheenColorMap",sheenRoughness:"sheenRoughnessMap",specularIntensity:"specularIntensityMap",specularColor:"specularColorMap"};function wt(e){if(e)return Object.fromEntries(Object.entries(e).map(([t,o])=>[t,o&&typeof o=="object"?{...o}:o]))}function Nn(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t.visible===!1).map(([t])=>[t,!0]))}function Ke(e){let[t,o]=_n(e),s=H((a,r)=>{o(c=>r===void 0?ge(c,a):ge(c,a,r))},[]),f=H((a,r)=>s(a,Ie(r)),[s]),y=H((a,r)=>f(a,{baseColor:r}),[f]),l=H((a,r,c="baseColor")=>{let u=bt[c],w=typeof r=="string"?{path:r}:r;s(a,{style:{material:{[u]:w}}})},[s]),x=H((a,r="baseColor")=>{let c=bt[r];s(a,{style:{material:{[c]:void 0}}})},[s]),E=H((a,r)=>{o(c=>{let u=Z(c,a);if(!u)return c;let w=wt(c[u]?.style?.material),k=ce(c,r);if(k.length===0)return c;let $=c;for(let n of k){let i=c[n];i&&($===c&&($={...c}),$[n]={...i,style:{...i.style,material:wt(w)}})}return $})},[]),B=H(a=>s(a,{style:{material:void 0}}),[s]),h=H((a,r)=>s(a,{transform:r}),[s]),p=H(a=>s(a,{transform:void 0}),[s]),I=H((a,r)=>s(a,{metadata:r}),[s]),P=H((a,r)=>{o(c=>{let u=c;for(let w of ce(c,a)){let k=c[w],$=r(k.decals??[]);u===c&&(u={...c}),u[w]={...k,decals:$.length>0?$:void 0}}return u})},[]),S=H((a,r)=>{let c=r.id??`decal-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;return P(a,u=>[...u.filter(w=>w.id!==c),{...r,id:c}]),c},[P]),V=H((a,r,c)=>P(a,u=>u.map(w=>w.id===r?{...w,...c}:w)),[P]),b=H((a,r)=>P(a,c=>c.filter(u=>u.id!==r)),[P]),g=H(a=>Te(t,a),[t]),O=H(a=>ce(t,a).map(r=>t[r]?.id??r),[t]),R=H(a=>{let r=Z(t,a);return r?t[r]?.style?.material??null:null},[t]),j=H(a=>s(a,{visible:!1}),[s]),q=H(a=>s(a,{visible:!0}),[s]),X=H(a=>{o(r=>{let c=ce(r,a).reduce((u,w)=>{let k=r[w];return k&&u.push({ids:w,patch:{visible:k.visible===!1}}),u},[]);return ge(r,c)})},[o]),_=H(()=>{o(a=>ge(a,Object.keys(a),{visible:!0}))},[o]),C=mt(()=>Nn(t),[t]),J=mt(()=>Object.keys(C).map(a=>t[a]?.id??a),[C,t]),N=H(a=>{let r=Z(t,a);return r?t[r]?.visible===!1:!1},[t]);return{objectBindings:t,setObjectBindings:o,updateObjectBindings:s,setMaterial:f,setBaseColor:y,setTexture:l,clearTexture:x,copyMaterial:E,resetMaterial:B,getMaterial:R,setTransform:h,resetTransform:p,updateMetadata:I,addDecal:S,updateDecal:V,removeDecal:b,selectObjectBindings:g,selectObjectBindingIds:O,hiddenObjects:C,hiddenObjectIds:J,hideObject:j,showObject:q,toggleObjectVisibility:X,isObjectHidden:N,clearHiddenObjects:_}}import{useCallback as ee,useMemo as qn,useRef as Fn,useState as Kn}from"react";function Ge(e){let t=Fn(null),[o,s]=Kn(()=>{let g=typeof e=="function"?e():e;return t.current=g,g}),f=ee(g=>{s(O=>{let R=typeof g=="function"?g(O):g;return _e(O,R)})},[]),y=ee(()=>{let g=t.current;g&&s(g)},[]),l=ee((g,O)=>{f(R=>({lighting:{lights:R.lighting.lights.map(j=>j.id===g?{...j,...O}:j)}}))},[f]),x=ee(g=>{f(O=>O.lighting.lights.some(R=>R.id===g.id)?{}:{lighting:{lights:[...O.lighting.lights,Ne(g)]}})},[f]),E=ee(g=>{f(O=>({lighting:{lights:O.lighting.lights.filter(R=>R.id!==g)}}))},[f]),B=ee((g,O)=>l(g,{intensity:O}),[l]),h=ee((g,O)=>l(g,{color:O}),[l]),p=ee(g=>l(g,{visible:!0}),[l]),I=ee(g=>l(g,{visible:!1}),[l]),P=ee(g=>{f(O=>({lighting:{lights:O.lighting.lights.map(R=>R.id===g?{...R,visible:!R.visible}:R)}}))},[f]),S=ee((g,O)=>l(g,{attachment:O,attachedToCamera:!1}),[l]),V=ee(g=>l(g,{attachment:void 0}),[l]),b=qn(()=>({items:o.lighting.lights,get:g=>o.lighting.lights.find(O=>O.id===g),add:x,update:l,remove:E,setIntensity:B,setColor:h,show:p,hide:I,toggle:P,attach:S,detach:V}),[o.lighting.lights,x,l,E,B,h,p,I,P,S,V]);return{sceneConfig:o,setSceneConfig:s,updateSceneConfig:f,resetSceneConfig:y,lights:b}}import{useCallback as ze}from"react";function $e({bindings:e,scene:t,camera:o,animations:s,isolation:f,onAction:y}){let{objectBindings:l,updateObjectBindings:x,showObject:E,hideObject:B,toggleObjectVisibility:h}=e,p=t?.updateSceneConfig,I=o?.focusObject,P=o?.fitScene,S=o?.resetView,V=o?.setCameraTarget,b=o?.setCameraState,g=s?.play,O=s?.pause,R=s?.stop,j=s?.setSpeed,q=s?.seek,X=f?.handleIsolationChange,_=ze(N=>{let a=Z(l,N);return a?l[a]?.actions??[]:[]},[l]),C=ze(async N=>{for(let a of N.action.effects??[]){if("objectBindings"in a){x(a.target,a.objectBindings);continue}if("sceneConfig"in a){p?.(a.sceneConfig);continue}if("isolation"in a){X?.(a.isolation);continue}if("visibility"in a){a.visibility==="show"?E(a.target):a.visibility==="hide"?B(a.target):h(a.target);continue}if("camera"in a){let c=a.camera;c.type==="focus-object"?await I?.(c.objectId??N.objectId):c.type==="fit-scene"?await P?.():c.type==="reset"?await S?.():c.type==="set-target"?await V?.(c.target,c.transition??!0):await b?.(c.state,c.transition??!0);continue}let r=a.animation;if(r.type==="play"){let{type:c,clip:u,...w}=r;g?.(u,w)}else r.type==="pause"?O?.(r.clip):r.type==="stop"?R?.(r.clip):r.type==="set-speed"?j?.(r.speed,r.clip):q?.(r.time,r.clip)}await y?.(N)},[P,I,B,y,O,g,S,q,j,b,V,X,E,R,h,x,p]),J=ze(async(N,a)=>{let r=Z(l,N);if(!r)return null;let c=l[r],u=c?.actions?.find(k=>k.id===a);if(!c||!u)return null;let w={objectId:r,action:u,binding:c};return await C(w),w},[C,l]);return{getActionsForObject:_,handleAction:C,runAction:J}}import{useCallback as pe,useRef as yt}from"react";function Gn(e){return typeof e=="function"?e:e?.handleViewerReady??null}function We(...e){let t=yt(null),o=yt(e);o.current=e;let s=pe(h=>{t.current=h;let p=new Set;for(let I of o.current){let P=Gn(I);P&&!p.has(P)&&(p.add(P),P(h))}},[]),f=pe(()=>t.current,[]),y=pe(h=>t.current?.goToAnnotation(h)??Promise.resolve(!1),[]),l=pe(()=>t.current?.startAR()??Promise.resolve(!1),[]),x=pe(h=>{let p=t.current;return p?p.captureImage(h):Promise.reject(new Error("ModelViewer is not ready yet."))},[]),E=pe(()=>{let h=t.current;return h?(h.invalidate(),!0):!1},[]),B=pe(h=>{let p=t.current;return p?p.captureVideo(h):Promise.reject(new Error("ModelViewer is not ready yet."))},[]);return{handleViewerReady:s,getViewer:f,goToAnnotation:y,startAR:l,captureImage:x,captureVideo:B,invalidate:E}}import{useCallback as U,useEffect as zn,useRef as ie}from"react";import{Material as $n,PointLight as Wn,Vector3 as Yn}from"three";var Je=["emissiveIntensity","opacity","metalness","roughness","transmission","clearcoat","clearcoatRoughness","ior","thickness"],Be=1;function ve(e){return typeof e=="string"?[e]:e}function Me(e,t=0,o=1){return Math.min(o,Math.max(t,e))}function Ye(e,t){return e+Math.random()*(t-e)}function ht([e,t],o){return e+(t-e)*o}function Xe([e,t],o){return[e[0]+(t[0]-e[0])*o,e[1]+(t[1]-e[1])*o,e[2]+(t[2]-e[2])*o]}function Vt(e,t){let o=Me(e);switch(t){case"ease-in":return o*o;case"ease-out":return 1-(1-o)*(1-o);case"ease-in-out":return o<.5?2*o*o:1-Math.pow(-2*o+2,2)/2;default:return o}}function Xn(e){let t=e.material;return t?(Array.isArray(t)?t:[t]).filter(o=>o instanceof $n):[]}function Jn(e){let t={opacity:e.opacity,transparent:e.transparent};e.color&&(t.baseColor=`#${e.color.getHexString()}`),e.emissive&&(t.emissive=`#${e.emissive.getHexString()}`);for(let o of Je){let s=e[o];typeof s=="number"&&(t[o]=s)}return t}function Ct(e,t){t.baseColor!==void 0&&e.color&&e.color.set(t.baseColor),t.emissive!==void 0&&e.emissive&&e.emissive.set(t.emissive);for(let o of Je){let s=t[o];s!==void 0&&typeof e[o]=="number"&&(e[o]=s)}t.transparent!==void 0&&(e.transparent=t.transparent),e.needsUpdate=!0}function Qn(e){return{position:[e.position.x,e.position.y,e.position.z],rotation:[e.rotation.x,e.rotation.y,e.rotation.z],scale:[e.scale.x,e.scale.y,e.scale.z],visible:e.visible}}function Zn(e,t){if(t.position&&e.position.set(...t.position),t.rotation&&e.rotation.set(...t.rotation),t.scale!==void 0){let o=typeof t.scale=="number"?[t.scale,t.scale,t.scale]:t.scale;e.scale.set(...o)}t.visible!==void 0&&(e.visible=t.visible),e.updateMatrix(),e.updateMatrixWorld(!0)}function Qe(e={}){let t=ie(e);t.current=e;let o=ie(null),s=ie(null),f=ie(null),y=ie(new Map),l=ie(new Map),x=ie(new Map),E=ie(new Map),B=U(n=>{let i=o.current;if(!i)return null;let m=Z(i.objectBindings,n);return i.raw.nodes[n]??(m?i.raw.nodes[m]:null)??(i.raw.scene?ot(i.raw.scene,n):null)??null},[]),h=U(n=>{let i=o.current;return i?typeof n=="object"&&!Array.isArray(n)?ce(i.objectBindings,n):ve(n).map(m=>Z(i.objectBindings,m)??m):typeof n=="string"?[n]:Array.isArray(n)?n:[]},[]),p=U(()=>{o.current?.invalidate()},[]),I=U((n,i)=>{let m=!1;for(let d of h(n)){let v=B(d);if(v)for(let L of Xn(v))x.current.has(L)||x.current.set(L,Jn(L)),Ct(L,i),m=!0}return m},[B,h]),P=U((n,i)=>{let m=I(n,i);return m&&p(),m},[p,I]),S=U((n,i)=>{let m=!1;for(let d of h(n)){let v=B(d);v&&(E.current.has(v)||E.current.set(v,Qn(v)),Zn(v,i),m=!0)}return m},[B,h]),V=U((n,i)=>{let m=S(n,i);return m&&p(),m},[p,S]),b=U(n=>{let i=B(n);if(!i)return null;i.updateWorldMatrix(!0,!1);let m=i.getWorldPosition(new Yn);return[m.x,m.y,m.z]},[B]),g=U(n=>{let i=l.current.get(n);return i?(i.light.removeFromParent(),i.light.dispose(),l.current.delete(n),p(),!0):!1},[p]),O=U(n=>{let i=B(n.target);if(!i)return!1;let m=l.current.get(n.id),d=m?.light??new Wn;return m&&m.target!==n.target&&d.removeFromParent(),d.name=`react-immersive-runtime-light:${n.id}`,d.color.set(n.color??"#ffffff"),d.intensity=n.intensity??1,d.distance=n.distance??0,d.decay=n.decay??2,d.castShadow=n.castShadow??!1,d.position.set(...n.offset??[0,0,0]),d.parent!==i&&i.add(d),l.current.set(n.id,{light:d,target:n.target}),p(),!0},[p,B]),R=U((n,i)=>{let m=l.current.get(n);if(!m)return!1;if(i.target&&i.target!==m.target){let d=B(i.target);if(!d)return!1;m.light.removeFromParent(),d.add(m.light),m.target=i.target}return i.color!==void 0&&m.light.color.set(i.color),i.intensity!==void 0&&(m.light.intensity=i.intensity),i.distance!==void 0&&(m.light.distance=i.distance),i.decay!==void 0&&(m.light.decay=i.decay),i.offset!==void 0&&m.light.position.set(...i.offset),i.castShadow!==void 0&&(m.light.castShadow=i.castShadow),p(),!0},[p,B]),j=U((n,i)=>{let m=d=>i[d%i.length]??0;for(let d of n.materials??[])h(d.targets).forEach((v,L)=>{let T=m(L),D={};for(let Y of Je){let K=d.values[Y];K&&(D[Y]=ht(K,T))}I(v,D)});for(let d of n.transforms??[])h(d.targets).forEach((v,L)=>{let T=m(L),D={};d.values.position&&(D.position=Xe(d.values.position,T)),d.values.rotation&&(D.rotation=Xe(d.values.rotation,T)),d.values.scale&&(D.scale=Xe(d.values.scale,T)),S(v,D)});for(let d of n.lights??[])ve(d.lights).forEach((v,L)=>{let T=l.current.get(v);T&&(T.light.intensity=ht(d.intensity,m(L)))})},[h,I,S]),q=ie(()=>{}),X=ie(()=>{});X.current=n=>{f.current=null;let i=!1;for(let[m,d]of y.current){d.startedAt===null&&(d.startedAt=n);let v=d.lastFrameAt??n;d.lastFrameAt=n;let L=d.override&&d.override.until>n?d.override.level:null;d.override&&L===null&&(d.override=null);let T=d.update(n,n-d.startedAt,Math.min(100,n-v),L);i=!0,T||(y.current.delete(m),d.onComplete?.())}i&&p(),y.current.size>0&&q.current()},q.current=()=>{f.current!==null||typeof requestAnimationFrame>"u"||(f.current=requestAnimationFrame(n=>X.current(n)))};let _=U(n=>(y.current.set(n.id,n),q.current(),n.id),[]),C=U((n,i={})=>{let m=i.id??`transition-${Be++}`,d=Math.max(1,i.duration??400),v=i.easing??"ease-in-out";return _({id:m,startedAt:null,lastFrameAt:null,override:null,onComplete:i.onComplete,update:(L,T,D,Y)=>{let K=Y??Vt(T/d,v);return j(n,[K]),T<d}})},[j,_]),J=U((n,i={})=>{let m=i.id??`pulse-${Be++}`,d=Math.max(1,i.duration??1e3),v=i.minLevel??0,L=i.maxLevel??1,T=i.repeat??1/0,D=i.synchronized??!0,Y=Math.max(1,...[...n.materials??[],...n.transforms??[]].map(K=>h(K.targets).length),...(n.lights??[]).map(K=>ve(K.lights).length));return _({id:m,startedAt:null,lastFrameAt:null,override:null,onComplete:i.onComplete,update:(K,ae,de,ne)=>{let F=ae/d,M=Array.from({length:D?1:Y},(A,W)=>{if(ne!==null)return ne;let G=F+(D?0:W/Y),z=.5-Math.cos(G%1*Math.PI*2)/2;return v+(L-v)*z});return j(n,M),T===1/0||F<T}})},[j,_,h]),N=U((n,i={})=>{let m=i.id??`timeline-${Be++}`,d=i.repeat??1,v=n.map(T=>({...T,duration:Math.max(1,T.duration),hold:Math.max(0,T.hold??0)})),L=Math.max(1,v.reduce((T,D)=>T+D.duration+D.hold,0));return _({id:m,startedAt:null,lastFrameAt:null,override:null,onComplete:i.onComplete,update:(T,D,Y,K)=>{if(v.length===0||d<=0)return!1;let ae=D/L;if(d!==1/0&&ae>=d){for(let F of v)j(F.channels,[1]);return!1}let de=D%L,ne=0;for(let F of v){let M=ne+F.duration,A=M+F.hold;if(de>=M){j(F.channels,[K??1]),ne=A;continue}if(de>=ne){let W=K??Vt((de-ne)/F.duration,F.easing??"ease-in-out");j(F.channels,[W]);break}}return!0}})},[j,_]),a=U((n,i={})=>{let m=i.id??`flicker-${Be++}`,d=i.synchronized??!0,v=i.minLevel??.15,L=i.maxLevel??1,T=i.interval??[45,160],D=typeof T=="number"?[T,T]:T,Y=[Math.max(1,Math.min(...D)),Math.max(1,Math.max(...D))],K=Me(i.response??.7,.01,1),ae=Me(i.blackoutChance??.08),de=Me(i.flashChance??.12),ne=i.flashLevel??1.15,F=Math.max(1,...[...n.materials??[],...n.transforms??[]].map(z=>h(z.targets).length),...(n.lights??[]).map(z=>ve(z.lights).length)),M=d?1:F,A=Array.from({length:M},()=>v),W=Array.from({length:M},()=>v),G=Array.from({length:M},()=>0);return _({id:m,startedAt:null,lastFrameAt:null,override:null,onComplete:i.onComplete,update:(z,ye,oe,Ve)=>{for(let Q=0;Q<M;Q+=1){if(Ve!==null)W[Q]=Ve;else if(z>=G[Q]){let rt=Math.random();W[Q]=rt<ae?Ye(0,Math.min(.04,v)):rt<ae+de?ne:Ye(v,L),G[Q]=z+Ye(...Y)}let Rt=1-Math.pow(1-K,Math.max(1,oe)/16.67);A[Q]+=(W[Q]-A[Q])*Rt}return j(n,A),i.duration===void 0||ye<i.duration}})},[j,_,h]),r=U((n,i,m)=>{let d=y.current.get(n);if(!d)return!1;let v=typeof performance>"u"?Date.now():performance.now();return d.override={level:i,until:v+Math.max(0,m)},q.current(),!0},[]),c=U(n=>y.current.delete(n),[]),u=U(()=>{y.current.clear(),f.current!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(f.current),f.current=null)},[]),w=U(()=>{for(let[n,i]of x.current)Ct(n,i);x.current.clear();for(let[n,i]of E.current)n.position.set(...i.position),n.rotation.set(...i.rotation),n.scale.set(...i.scale),n.visible=i.visible,n.updateMatrix(),n.updateMatrixWorld(!0);E.current.clear();for(let n of l.current.values())n.light.removeFromParent(),n.light.dispose();l.current.clear(),p()},[p]),k=U(()=>{u(),w()},[w,u]),$=U(n=>{s.current&&s.current!==n.raw.scene&&w(),o.current=n,s.current=n.raw.scene,t.current.onViewerReady?.(n)},[w]);return zn(()=>()=>{k(),o.current=null,s.current=null},[k]),{handleViewerReady:$,setMaterial:P,setTransform:V,getWorldPosition:b,addPointLight:O,updatePointLight:R,removePointLight:g,transition:C,timeline:N,pulse:J,flicker:a,overrideEffect:r,stopEffect:c,stopAllEffects:u,resetRuntime:k}}import{useCallback as er,useState as tr}from"react";function Ze(){let[e,t]=tr(null),o=er(s=>{t(s)},[t]);return{hoveredObjectBinding:e,handleHoveredObject:o}}import{useCallback as St,useState as nr}from"react";function et(e=null){let[t,o]=nr(e),s=St((y,l)=>o({...l,target:y}),[]),f=St(()=>o(null),[]);return{isolation:t,isolate:s,clearIsolation:f,handleIsolationChange:o}}import{useCallback as Pe,useState as le}from"react";function tt(){let[e,t]=le(!0),[o,s]=le(!1),[f,y]=le(null),[l,x]=le(null),[E,B]=le(0),[h,p]=le([]),[I,P]=le([]),[S,V]=le([]),b=Pe(j=>{x(j.bounds),B(j.objectCount),p(j.materialVariants),P(j.materialVariantGroups),y(null),t(!1),s(!0)},[]),g=Pe(j=>V(j),[]),O=Pe(j=>{y(j),x(null),B(0),p([]),P([]),V([]),t(!1),s(!1)},[]),R=Pe(()=>{t(!0),s(!1),y(null),x(null),B(0),p([]),P([]),V([])},[]);return{isLoading:e,isReady:o,error:f,bounds:l,objectCount:E,materialVariants:h,materialVariantGroups:I,objects:S,handleModelLoaded:b,handleObjectCatalog:g,handleLoadError:O,resetModelState:R}}import{useCallback as Ot,useState as rr}from"react";function nt(e=null){let[t,o]=rr(e),s=Ot(y=>{o(y)},[o]),f=Ot(()=>{o(null)},[]);return{selectedObjectBinding:t,setSelectedObjectBinding:o,handleObjectSelect:s,clearSelection:f}}var or={};function ir(e={}){let t=jt(e);t.current=e;let o=jt(e.bindings===void 0||e.bindings==="auto"),s=Ke(()=>{let C=t.current.bindings;return C===void 0||C==="auto"?or:typeof C=="function"?C():C}),f=Ge(()=>{let C=t.current.sceneConfig;return C===void 0?Se:typeof C=="function"?C():C}),y=nt(),l=Ze(),x=Ae(e.camera),E=tt(),B=qe(),h=et(),p=Qe(),I=We(x,p),P=$e({bindings:s,scene:f,camera:x,animations:B,isolation:h,onAction:e.onAction}),{setObjectBindings:S}=s,{handleObjectCatalog:V}=E,b=Re(C=>{V(C),o.current&&S(J=>{let N=lt(C.map(a=>a.name));for(let a of Object.keys(N))J[a]&&(N[a]=J[a]);return N})},[V,S]),{handleObjectSelect:g}=y,O=Re(C=>{g(C),t.current.onObjectSelect?.(C)},[g]),{handleHoveredObject:R}=l,j=Re(C=>{R(C),t.current.onObjectHover?.(C)},[R]),{handleLoadError:q}=E,X=Re(C=>{q(C),t.current.onLoadError?.(C)},[q]),_=e.sceneConfig!==void 0||f.sceneConfig!==Se;return{props:{objectBindings:s.objectBindings,onObjectBindingsChange:S,selectedObject:y.selectedObjectBinding,onObjectSelect:O,onObjectHover:j,onCameraChange:x.handleCameraChange,onViewerReady:I.handleViewerReady,onModelLoaded:E.handleModelLoaded,onLoadError:X,onObjectCatalog:b,onAnimationsReady:B.handleAnimationsReady,onAction:P.handleAction,onSceneConfigChange:f.setSceneConfig,isolation:h.isolation,onIsolationChange:h.handleIsolationChange,..._?{sceneConfig:f.sceneConfig}:{}},bindings:s,selection:y,hover:l,camera:x,model:E,animations:B,actions:P,scene:f,isolation:h,effects:p,connection:I}}import{useMemo as sr}from"react";function ar(e,t){return sr(()=>{if(!t)return null;let o=e[t];return o||(Object.values(e).find(s=>s.id===t||s.modelObjectId===t)??null)},[e,t])}import{useMemo as cr}from"react";function lr(e){return cr(()=>Object.values(e).map(t=>t.modelObjectId),[e])}import{useCallback as te,useEffect as xe,useRef as se,useState as dr}from"react";function ur(e,t){if(!e.objectBindings&&(!!e.hidden?.length||!!e.selected)&&Object.keys(t).length===0)return null;let s={};if(e.objectBindings)s.bindings=e.objectBindings;else if(e.hidden){let f=new Set(e.hidden);s.bindings=Object.fromEntries(Object.entries(t).map(([y,l])=>[y,{...l,visible:!f.has(l.id)}]))}if(e.selected!==void 0){let f=e.objectBindings??t,y=e.selected?Z(f,e.selected):null;s.selected=y?f[y]:null}return s}function Bt(e){return JSON.stringify(e&&{modelUrl:e.modelUrl,activeModelId:e.activeModelId,tilesetUrl:e.tilesetUrl,mergeModels:e.mergeModels,models:e.models?.map(({id:t,url:o,mergeModels:s})=>({id:t,url:o,mergeModels:s}))})}function pr(e){let t=se(e);t.current=e;let o=e.paramKey??"view",s=`${o}Id`,[f,y]=dr(!1),l=se(null),x=se(null),E=se(null),B=se(null),h=se(null),p=se(null),I=se(null),P=se(null),S=se(!0),V=te(r=>{let c=r instanceof Error?r:new Error(String(r));t.current.onError?t.current.onError(c):I.current!==c.message&&console.warn("[react-immersive]",c.message),I.current=c.message},[]),b=te(()=>{h.current!==null&&clearTimeout(h.current),h.current=null},[]);xe(()=>(S.current=!0,()=>{S.current=!1,b()}),[b]);let g=te(()=>{let r=t.current,c=(r.mode??(r.configuration?"configuration":"view"))==="configuration";return{version:1,camera:r.cameraState??void 0,hidden:Object.values(r.objectBindings).filter(u=>u.visible===!1).map(u=>u.id),selected:r.selectedObjectBinding?.id??null,...c?{objectBindings:r.objectBindings,configuration:r.configuration}:{}}},[]),O=te(()=>he(g(),typeof window>"u"?void 0:window.location.href),[g]),R=te(()=>Le(g(),typeof window>"u"?void 0:window.location.href),[g]),j=te((r,c,u=window.location.href)=>{let w=new URL(u),k=new URLSearchParams(w.hash.slice(1));if(k.delete(o),k.delete(s),k.set(c?s:o,r),w.hash=k.toString(),!c&&w.href.length>(t.current.maxUrlLength??65536))throw new Error("Viewer configuration is too large for an inline link. Save JSON instead, or configure storage for createShareUrl(). Uploaded images can make links large.");return w.href},[o,s]),q=te(()=>j(me(O()),!1),[O,j]),X=te(async()=>{let r=window.location.href,c=t.current.storage,u=await R();if(!c)return j(me(u),!1,r);let w=await c.save(u);if(typeof w!="string"||!w.trim()||w.length>2048)throw new Error("Viewer state storage returned an invalid id.");return j(w,!0,r)},[R,j]),_=te(()=>{if(b(),l.current||p.current)return;let r=q();window.history.replaceState(null,"",r),B.current=`inline:${new URL(r).hash}`},[b,q]),C=te(async()=>{let r=l.current;if(!r||x.current||!S.current)return!1;x.current=r,b();try{let c=t.current,u=r.state;if(u.configuration&&!r.configurationApplied){if(!c.onConfigurationChange)throw new Error("Restoring a full viewer configuration requires onConfigurationChange.");return r.configurationApplied=!0,c.onConfigurationChange(u.configuration),!1}if(u.configuration&&Bt(c.configuration)!==Bt(u.configuration)||c.isReady===!1)return!1;if(u.camera&&!r.cameraApplied){if(!await c.setCameraState(u.camera,!1)||l.current!==r||!S.current)return!1;r.cameraApplied=!0}c=t.current;let w=ur(u,c.objectBindings);return!w||l.current!==r?!1:(w.bindings&&c.onObjectBindingsChange(w.bindings),w.selected!==void 0&&c.setSelectedObjectBinding(w.selected),l.current=null,E.current=r.key,y(!0),!0)}catch(c){throw l.current===r&&(l.current=null),y(!1),c}finally{x.current=null,l.current&&l.current!==r&&S.current&&C().catch(V)}},[b,V]),J=te(async r=>{let c=he(r,window.location.href);b(),P.current=null,p.current=null;let u=new URLSearchParams(window.location.hash.slice(1));return B.current=u.has(o)?`inline:${window.location.hash}`:u.has(s)?`stored:${s}:${u.get(s)}`:null,E.current=null,l.current={key:`manual:${me(c)}`,origin:"manual",state:c,configurationApplied:!1,cameraApplied:!1},y(!1),C()},[C,b,o,s]),N=te(async()=>{let r=new URLSearchParams(window.location.hash.slice(1)),c=r.get(o),u=r.get(s),w=c!==null?`inline:${window.location.hash}`:u!==null?`stored:${s}:${u}`:null;if(!w)return P.current=null,p.current=null,l.current?.origin==="manual"?C():(l.current=null,E.current=null,y(!0),!1);if(w===B.current||w===E.current)return l.current?.origin==="manual"?C():!1;if(l.current?.key===w)return C();b(),y(!1),P.current=w,l.current=null;let k=c;if(c===null){let n=t.current.storage;if(!n)throw new Error("This shared link requires a viewer state storage adapter.");(!p.current||p.current.key!==w)&&(p.current={key:w,promise:n.load(u)});let i=p.current;try{k=await i.promise}finally{p.current===i&&(p.current=null)}if(P.current!==w||!S.current)return!1;let m=l.current;if(m?.key===w||E.current===w)return m?C():!1}let $;try{$=he(k,window.location.href)}catch(n){throw n}return l.current={key:w,origin:"url",state:$,configurationApplied:!1,cameraApplied:!1},C()},[C,b,s,o]);xe(()=>{l.current&&C().catch(V)}),xe(()=>{let r=()=>{N().catch(V)};return window.addEventListener("hashchange",r),()=>window.removeEventListener("hashchange",r)},[N,V]);let a=null;if(e.autoSync!==!1&&f&&!l.current&&!p.current)try{a=me(O())}catch{}return xe(()=>{if(e.autoSync===!1||!f||l.current||p.current){b();return}if(a===null){try{O()}catch(r){V(r)}return}return h.current=setTimeout(()=>{h.current=null;try{_()}catch(r){V(r)}},Math.max(0,e.debounceMs??400)),b},[a,e.autoSync,e.debounceMs,f,b,O,_,V]),{getState:O,getStateAsync:R,restoreState:J,getShareUrl:q,createShareUrl:X,syncUrl:_,restoreFromUrl:N}}import{useCallback as fe,useState as vt}from"react";var fr={};function Mt(){return`asset-${globalThis.crypto.randomUUID()}`}function gr(e){let[t,o]=vt(e),[s,f]=vt(()=>e[0]?re(e[0]):""),y=t.find(S=>re(S)===s)??t[0],l=y?re(y):"",x=fe(S=>{o(V=>V.map(b=>re(b)===l?{...b,objectBindings:S}:b))},[l]),E=fe(S=>{o(V=>V.map(b=>re(b)===l?{...b,sceneConfig:S}:b))},[l]),B=fe(S=>f(V=>{let b=t.find(g=>g.url===S);return b?re(b):V}),[t]),h=fe(S=>{let V={...S,id:S.id??Mt()};return o(b=>{if(b.some(g=>re(g)===V.id))throw new Error("Asset instance ID already exists.");return[...b,V]}),V.id},[]),p=fe(S=>{let V=t.find(j=>re(j)===S);if(!V)return null;let b=structuredClone(V);b.id=Mt(),b.sceneConfig?.measurements&&(b.sceneConfig.measurements.items=b.sceneConfig.measurements.items.map(j=>({...j,modelId:b.id}))),b.label=`${V.label??"Asset"} copy`;let[g,O,R]=V.transform?.position??[0,0,0];return b.transform={...b.transform,position:[g+1,O,R]},o(j=>[...j,b]),b.id},[t]),I=fe(S=>{o(V=>V.filter(b=>re(b)!==S))},[]),P=fe((S,V)=>{let b=Ee(V);o(g=>g.map(O=>re(O)===S?{...O,transform:b}:O))},[]);return{modelUrl:y?.url??"",models:t,activeModelId:l,onModelChange:B,onActiveModelChange:f,objectBindings:fr,onObjectBindingsChange:x,sceneConfig:y?.sceneConfig,onSceneConfigChange:E,addModel:h,duplicateModel:p,removeModel:I,updateModelTransform:P}}import{useCallback as we,useEffect as mr,useState as br,useSyncExternalStore as wr}from"react";var yr={sequenceId:null,time:0,duration:0,status:"stopped",previewing:!1,ready:!1,issues:[]},hr=()=>()=>{},Pt=()=>yr;function Vr(){let[e,t]=br(null),o=wr(e?.subscribe??hr,e?.getState??Pt,Pt);mr(()=>()=>e?.stop(),[e]);let s=we(f=>t(f),[]);return{controls:e,playback:o,handleSequencesReady:s,play:we(f=>e?.play(f)??!1,[e]),pause:we(()=>e?.pause(),[e]),stop:we(()=>e?.stop(),[e]),seek:we(f=>e?.seek(f)??!1,[e]),select:we(f=>e?.select(f)??!1,[e])}}export{hn as ACTION_CATALOG,kn as AssetDiagnosticsPanel,gt as CompareViewer,Lt as DEFAULT_MODEL_VIEWER_LABELS,Se as DEFAULT_SCENE_CONFIG,Ce as DEFAULT_SECTION_CONFIG,En as MATERIAL_BLENDING_MODES,An as MATERIAL_SIDES,fn as MAX_VIEWER_STATE_BYTES,_t as MEASUREMENT_UNITS,yn as MODEL_VIEWER_PRESETS,ke as ModelViewer,jn as ProductOptions,At as SEQUENCE_EASINGS,xt as SEQUENCE_OBJECT_PROPERTIES,vn as applyIsolation,pn as applyProductOptions,Sn as applyStyleRules,Rn as buildBindingsFromNodes,qt as calibrateMeasurements,Yt as chooseMaterialVariant,Tn as collectObjectHierarchy,Cn as colorScaleValue,Ue as compareViewerConfigurations,In as copyBindingStyle,gn as createARHandoffUrl,Pn as createDefaultBinding,on as decodeProductSelections,Jt as defaultProductSelections,xn as defineObjectBindings,rn as encodeProductSelections,Qt as evaluateProductConfiguration,bn as exportConfiguredUSDZ,Vn as findCatalogAction,tn as formatProductPrice,sn as generateProductSkus,Ht as groundAsset,Mn as inferType,wn as inspectAsset,Bn as isolatedBindingKeys,Ie as material,Kt as measurementResult,Nt as measurementScale,Ft as measurementValue,$t as measurementsToCsv,Ee as parseAssetTransform,Gt as parseMeasurements,un as parseProductConfiguration,Xt as parseProductDefinition,ln as parseSceneProduct,kt as parseSectionConfig,Wt as parseSelectionSets,Et as parseSequences,he as parseViewerState,Ln as pasteBindingStyle,ge as patchBindings,_e as patchSceneConfig,Le as prepareViewerState,nn as productCheckoutUrl,an as productDefinitionWarnings,cn as productOptionStates,en as productPriceFromDefinition,mn as readARHandoffUrl,Zt as resolveProductSelections,Tt as sampleSequenceTrack,Ne as sceneLight,Ut as sectionSnapshot,ce as selectBindingKeys,Te as selectBindings,zt as serializeMeasurements,dn as serializeProductConfiguration,me as serializeViewerState,Dt as snapAssetToGrid,It as upsertSequenceKeyframe,ar as useObjectBinding,lr as useObjectBindingIds,Ke as useObjectBindings,On as useProductConfigurator,Ge as useSceneConfig,pr as useShareableViewerState,ir as useViewer,$e as useViewerActions,qe as useViewerAnimations,Ae as useViewerCamera,We as useViewerConnection,Qe as useViewerEffects,Ze as useViewerHover,et as useViewerIsolation,tt as useViewerModel,gr as useViewerModels,nt as useViewerSelection,Vr as useViewerSequences};
|
|
@@ -1318,6 +1318,9 @@ type ViewerModelInfo = {
|
|
|
1318
1318
|
|
|
1319
1319
|
/** Built-in viewer text. Override only the keys your application needs. */
|
|
1320
1320
|
declare const DEFAULT_MODEL_VIEWER_LABELS: {
|
|
1321
|
+
readonly modelViewer: "3D model viewer";
|
|
1322
|
+
readonly openSceneSettingsPanel: "Open scene settings panel";
|
|
1323
|
+
readonly closeSceneSettingsPanel: "Close scene settings panel";
|
|
1321
1324
|
readonly verifyingLicense: "Verifying License";
|
|
1322
1325
|
readonly checkingYourLicenseKey: "Checking your license key...";
|
|
1323
1326
|
readonly createDevelopmentKey: "Create a free development key";
|
|
@@ -1318,6 +1318,9 @@ type ViewerModelInfo = {
|
|
|
1318
1318
|
|
|
1319
1319
|
/** Built-in viewer text. Override only the keys your application needs. */
|
|
1320
1320
|
declare const DEFAULT_MODEL_VIEWER_LABELS: {
|
|
1321
|
+
readonly modelViewer: "3D model viewer";
|
|
1322
|
+
readonly openSceneSettingsPanel: "Open scene settings panel";
|
|
1323
|
+
readonly closeSceneSettingsPanel: "Close scene settings panel";
|
|
1321
1324
|
readonly verifyingLicense: "Verifying License";
|
|
1322
1325
|
readonly checkingYourLicenseKey: "Checking your license key...";
|
|
1323
1326
|
readonly createDevelopmentKey: "Create a free development key";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aa as ProductCommerceAdapter, ad as ProductConfiguration, P as ObjectBinding, aE as SceneConfig, bg as ViewerCameraState, bj as ViewerModelBounds, as as ReducedMotionSetting, j as CameraLimits, S as ObjectBindingDecal, a5 as ObjectSurfacePoint, L as ModelViewerLabels, bi as ViewerLoading, bl as ViewerReveal, H as ModelFormat, a4 as ObjectPointerEvent, bk as ViewerModelInfo, N as ObjectActionEvent, e as AnimationControls, az as SceneAnnotationMarker, bf as ViewerCameraConfig, bh as ViewerIsolation, at as SavedMeasurement, w as MeasurementSettings, b3 as SequenceControls } from './modelFileResolver-
|
|
1
|
+
import { aa as ProductCommerceAdapter, ad as ProductConfiguration, P as ObjectBinding, aE as SceneConfig, bg as ViewerCameraState, bj as ViewerModelBounds, as as ReducedMotionSetting, j as CameraLimits, S as ObjectBindingDecal, a5 as ObjectSurfacePoint, L as ModelViewerLabels, bi as ViewerLoading, bl as ViewerReveal, H as ModelFormat, a4 as ObjectPointerEvent, bk as ViewerModelInfo, N as ObjectActionEvent, e as AnimationControls, az as SceneAnnotationMarker, bf as ViewerCameraConfig, bh as ViewerIsolation, at as SavedMeasurement, w as MeasurementSettings, b3 as SequenceControls } from './modelFileResolver-An1aQ0D3.mjs';
|
|
2
2
|
import { Object3D, Material } from 'three';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
import { CameraControls } from '@react-three/drei';
|
|
@@ -586,6 +586,19 @@ type UseViewerCameraOptions = {
|
|
|
586
586
|
/** Initial named views, read once. Use setCameraPresets to load later edits. */
|
|
587
587
|
presets?: Record<string, ViewerCameraPreset>;
|
|
588
588
|
};
|
|
589
|
+
/** Finite, nonnegative padding for focusObject's automatic fit, in scene units. */
|
|
590
|
+
type FocusObjectOptions = {
|
|
591
|
+
/** Padding in scene units on every side of the fitted object. Default 0.5. */
|
|
592
|
+
padding?: number;
|
|
593
|
+
/** Per-side scene-unit padding; overrides `padding` for this side. */
|
|
594
|
+
paddingTop?: number;
|
|
595
|
+
/** Bottom padding; overrides `padding`. */
|
|
596
|
+
paddingBottom?: number;
|
|
597
|
+
/** Left padding; overrides `padding`. */
|
|
598
|
+
paddingLeft?: number;
|
|
599
|
+
/** Right padding; overrides `padding`. */
|
|
600
|
+
paddingRight?: number;
|
|
601
|
+
};
|
|
589
602
|
type HomeCameraState = {
|
|
590
603
|
position: [number, number, number];
|
|
591
604
|
target: [number, number, number];
|
|
@@ -593,6 +606,10 @@ type HomeCameraState = {
|
|
|
593
606
|
type ViewerReadyState = {
|
|
594
607
|
objectBindings: Record<string, ObjectBinding>;
|
|
595
608
|
homeCameraState: HomeCameraState | null;
|
|
609
|
+
/** Fly to a visible annotation and open its card. False for an unknown/filtered ID or disconnected camera. */
|
|
610
|
+
goToAnnotation: (annotationId: number) => Promise<boolean>;
|
|
611
|
+
/** Start WebXR AR or open its platform handoff. Call from a user gesture; launch errors reject. */
|
|
612
|
+
startAR: () => Promise<boolean>;
|
|
596
613
|
captureImage: (options?: CaptureImageOptions) => Promise<string>;
|
|
597
614
|
/** Whether a streamed model is still fetching tiles for the current view. */
|
|
598
615
|
isLoadingTiles: () => boolean;
|
|
@@ -630,8 +647,9 @@ type ViewerCameraProps = {
|
|
|
630
647
|
/**
|
|
631
648
|
* Moves to the binding's `cameraState` when it has a position and target,
|
|
632
649
|
* as selecting the object in the viewer does; otherwise frames the object.
|
|
650
|
+
* Padding applies only when framing, and must be finite and nonnegative.
|
|
633
651
|
*/
|
|
634
|
-
focusObject: (objectId: string) => Promise<boolean>;
|
|
652
|
+
focusObject: (objectId: string, options?: FocusObjectOptions) => Promise<boolean>;
|
|
635
653
|
fitScene: () => Promise<boolean>;
|
|
636
654
|
setCameraTarget: (target: [number, number, number], enableTransition?: boolean) => Promise<boolean>;
|
|
637
655
|
setCameraState: (state: ViewerCameraState, enableTransition?: boolean) => Promise<boolean>;
|
|
@@ -947,4 +965,4 @@ type ModelViewerModelEntry = {
|
|
|
947
965
|
sceneConfig?: SceneConfig;
|
|
948
966
|
};
|
|
949
967
|
|
|
950
|
-
export { type
|
|
968
|
+
export { type StreamingDiagnostics as $, type ARExportOptions as A, type ModelMergeSource as B, type CameraControllerType as C, type DecalMoveTarget as D, type ModelViewerControlsOptions as E, type FocusObjectOptions as F, type GroupedModelViewerProps as G, type HomeCameraState as H, type InspectAssetOptions as I, type ModelViewerDecoderOptions as J, type ModelViewerModelEntry as K, type LicenseResult as L, MAX_VIEWER_STATE_BYTES as M, type ModelViewerPerfOptions as N, type ModelViewerPreset as O, type ModelViewerProps as P, type ModelViewerTilesOptions as Q, type ModelViewerToolsOptions as R, type ModelViewerUiOptions as S, type ModelViewerXrOptions as T, type MouseControllerPosition as U, type ObjectTransformSpace as V, type PerformanceProfile as W, type RendererBackend as X, type SceneComposition as Y, type SemanticComparisonOptions as Z, type ShareableViewerState as _, type ARHandoffOptions as a, type TexturePositioningControls as a0, type UseViewerCameraOptions as a1, type ViewerCameraPreset as a2, type ViewerCameraProps as a3, type ViewerConfiguration as a4, type ViewerEngagementEvent as a5, type ViewerObjectInfo as a6, type ViewerProductOptions as a7, type ViewerReadyState as a8, type ViewerRuntimeStats as a9, type ViewerStateStorage as aa, type XRScaleMode as ab, compareViewerConfigurations as ac, groundAsset as ad, parseAssetTransform as ae, parseViewerState as af, prepareViewerState as ag, serializeViewerState as ah, snapAssetToGrid as ai, useViewerCamera as aj, type ARHandoffRequest as b, type ARHandoffStatus as c, type ARSnapshot as d, type ARSnapshotSource as e, type AnnotationMarker as f, type AssetDiagnosticIssue as g, type AssetDiagnosticsReport as h, type AssetDiagnosticsSource as i, type AssetTextureDiagnostic as j, type AssetTransform as k, type CaptureImageOptions as l, type CaptureVideoOptions as m, type CinematicConfig as n, type CinematicWaypoint as o, type ComparisonCategory as p, type ComparisonChange as q, type ComparisonHighlight as r, type ComparisonObject as s, type ComparisonStatus as t, type ConfigurationComparisonInput as u, type ConfigurationComparisonReport as v, type CustomObjectBindingDataPanelProps as w, type CustomSceneObjectsPanelProps as x, type LicenseStatus as y, MODEL_VIEWER_PRESETS as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { aa as ProductCommerceAdapter, ad as ProductConfiguration, P as ObjectBinding, aE as SceneConfig, bg as ViewerCameraState, bj as ViewerModelBounds, as as ReducedMotionSetting, j as CameraLimits, S as ObjectBindingDecal, a5 as ObjectSurfacePoint, L as ModelViewerLabels, bi as ViewerLoading, bl as ViewerReveal, H as ModelFormat, a4 as ObjectPointerEvent, bk as ViewerModelInfo, N as ObjectActionEvent, e as AnimationControls, az as SceneAnnotationMarker, bf as ViewerCameraConfig, bh as ViewerIsolation, at as SavedMeasurement, w as MeasurementSettings, b3 as SequenceControls } from './modelFileResolver-
|
|
1
|
+
import { aa as ProductCommerceAdapter, ad as ProductConfiguration, P as ObjectBinding, aE as SceneConfig, bg as ViewerCameraState, bj as ViewerModelBounds, as as ReducedMotionSetting, j as CameraLimits, S as ObjectBindingDecal, a5 as ObjectSurfacePoint, L as ModelViewerLabels, bi as ViewerLoading, bl as ViewerReveal, H as ModelFormat, a4 as ObjectPointerEvent, bk as ViewerModelInfo, N as ObjectActionEvent, e as AnimationControls, az as SceneAnnotationMarker, bf as ViewerCameraConfig, bh as ViewerIsolation, at as SavedMeasurement, w as MeasurementSettings, b3 as SequenceControls } from './modelFileResolver-An1aQ0D3.js';
|
|
2
2
|
import { Object3D, Material } from 'three';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
import { CameraControls } from '@react-three/drei';
|
|
@@ -586,6 +586,19 @@ type UseViewerCameraOptions = {
|
|
|
586
586
|
/** Initial named views, read once. Use setCameraPresets to load later edits. */
|
|
587
587
|
presets?: Record<string, ViewerCameraPreset>;
|
|
588
588
|
};
|
|
589
|
+
/** Finite, nonnegative padding for focusObject's automatic fit, in scene units. */
|
|
590
|
+
type FocusObjectOptions = {
|
|
591
|
+
/** Padding in scene units on every side of the fitted object. Default 0.5. */
|
|
592
|
+
padding?: number;
|
|
593
|
+
/** Per-side scene-unit padding; overrides `padding` for this side. */
|
|
594
|
+
paddingTop?: number;
|
|
595
|
+
/** Bottom padding; overrides `padding`. */
|
|
596
|
+
paddingBottom?: number;
|
|
597
|
+
/** Left padding; overrides `padding`. */
|
|
598
|
+
paddingLeft?: number;
|
|
599
|
+
/** Right padding; overrides `padding`. */
|
|
600
|
+
paddingRight?: number;
|
|
601
|
+
};
|
|
589
602
|
type HomeCameraState = {
|
|
590
603
|
position: [number, number, number];
|
|
591
604
|
target: [number, number, number];
|
|
@@ -593,6 +606,10 @@ type HomeCameraState = {
|
|
|
593
606
|
type ViewerReadyState = {
|
|
594
607
|
objectBindings: Record<string, ObjectBinding>;
|
|
595
608
|
homeCameraState: HomeCameraState | null;
|
|
609
|
+
/** Fly to a visible annotation and open its card. False for an unknown/filtered ID or disconnected camera. */
|
|
610
|
+
goToAnnotation: (annotationId: number) => Promise<boolean>;
|
|
611
|
+
/** Start WebXR AR or open its platform handoff. Call from a user gesture; launch errors reject. */
|
|
612
|
+
startAR: () => Promise<boolean>;
|
|
596
613
|
captureImage: (options?: CaptureImageOptions) => Promise<string>;
|
|
597
614
|
/** Whether a streamed model is still fetching tiles for the current view. */
|
|
598
615
|
isLoadingTiles: () => boolean;
|
|
@@ -630,8 +647,9 @@ type ViewerCameraProps = {
|
|
|
630
647
|
/**
|
|
631
648
|
* Moves to the binding's `cameraState` when it has a position and target,
|
|
632
649
|
* as selecting the object in the viewer does; otherwise frames the object.
|
|
650
|
+
* Padding applies only when framing, and must be finite and nonnegative.
|
|
633
651
|
*/
|
|
634
|
-
focusObject: (objectId: string) => Promise<boolean>;
|
|
652
|
+
focusObject: (objectId: string, options?: FocusObjectOptions) => Promise<boolean>;
|
|
635
653
|
fitScene: () => Promise<boolean>;
|
|
636
654
|
setCameraTarget: (target: [number, number, number], enableTransition?: boolean) => Promise<boolean>;
|
|
637
655
|
setCameraState: (state: ViewerCameraState, enableTransition?: boolean) => Promise<boolean>;
|
|
@@ -947,4 +965,4 @@ type ModelViewerModelEntry = {
|
|
|
947
965
|
sceneConfig?: SceneConfig;
|
|
948
966
|
};
|
|
949
967
|
|
|
950
|
-
export { type
|
|
968
|
+
export { type StreamingDiagnostics as $, type ARExportOptions as A, type ModelMergeSource as B, type CameraControllerType as C, type DecalMoveTarget as D, type ModelViewerControlsOptions as E, type FocusObjectOptions as F, type GroupedModelViewerProps as G, type HomeCameraState as H, type InspectAssetOptions as I, type ModelViewerDecoderOptions as J, type ModelViewerModelEntry as K, type LicenseResult as L, MAX_VIEWER_STATE_BYTES as M, type ModelViewerPerfOptions as N, type ModelViewerPreset as O, type ModelViewerProps as P, type ModelViewerTilesOptions as Q, type ModelViewerToolsOptions as R, type ModelViewerUiOptions as S, type ModelViewerXrOptions as T, type MouseControllerPosition as U, type ObjectTransformSpace as V, type PerformanceProfile as W, type RendererBackend as X, type SceneComposition as Y, type SemanticComparisonOptions as Z, type ShareableViewerState as _, type ARHandoffOptions as a, type TexturePositioningControls as a0, type UseViewerCameraOptions as a1, type ViewerCameraPreset as a2, type ViewerCameraProps as a3, type ViewerConfiguration as a4, type ViewerEngagementEvent as a5, type ViewerObjectInfo as a6, type ViewerProductOptions as a7, type ViewerReadyState as a8, type ViewerRuntimeStats as a9, type ViewerStateStorage as aa, type XRScaleMode as ab, compareViewerConfigurations as ac, groundAsset as ad, parseAssetTransform as ae, parseViewerState as af, prepareViewerState as ag, serializeViewerState as ah, snapAssetToGrid as ai, useViewerCamera as aj, type ARHandoffRequest as b, type ARHandoffStatus as c, type ARSnapshot as d, type ARSnapshotSource as e, type AnnotationMarker as f, type AssetDiagnosticIssue as g, type AssetDiagnosticsReport as h, type AssetDiagnosticsSource as i, type AssetTextureDiagnostic as j, type AssetTransform as k, type CaptureImageOptions as l, type CaptureVideoOptions as m, type CinematicConfig as n, type CinematicWaypoint as o, type ComparisonCategory as p, type ComparisonChange as q, type ComparisonHighlight as r, type ComparisonObject as s, type ComparisonStatus as t, type ConfigurationComparisonInput as u, type ConfigurationComparisonReport as v, type CustomObjectBindingDataPanelProps as w, type CustomSceneObjectsPanelProps as x, type LicenseStatus as y, MODEL_VIEWER_PRESETS as z };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { L as ModelViewerLabels, bi as ViewerLoading, bl as ViewerReveal, H as ModelFormat, j as CameraLimits, as as ReducedMotionSetting, E as EnvironmentPreset, bk as ViewerModelInfo } from './modelFileResolver-
|
|
3
|
-
export { D as DEFAULT_MODEL_VIEWER_LABELS, p as MaterialVariantGroup, q as MaterialVariantOption, J as ModelViewerLabelKey, bj as ViewerModelBounds } from './modelFileResolver-
|
|
2
|
+
import { L as ModelViewerLabels, bi as ViewerLoading, bl as ViewerReveal, H as ModelFormat, j as CameraLimits, as as ReducedMotionSetting, E as EnvironmentPreset, bk as ViewerModelInfo } from './modelFileResolver-An1aQ0D3.mjs';
|
|
3
|
+
export { D as DEFAULT_MODEL_VIEWER_LABELS, p as MaterialVariantGroup, q as MaterialVariantOption, J as ModelViewerLabelKey, bj as ViewerModelBounds } from './modelFileResolver-An1aQ0D3.mjs';
|
|
4
4
|
|
|
5
5
|
/** How the render's colors are mapped to the screen. */
|
|
6
6
|
type ViewerToneMapping = "aces" | "agx" | "neutral" | "none";
|
|
7
7
|
type SimpleModelViewerProps = {
|
|
8
|
+
/** Accessible viewer name. Defaults to the localized "3D model viewer" label. */
|
|
9
|
+
"aria-label"?: string;
|
|
10
|
+
/** ID(s) of visible text naming this viewer; takes precedence over aria-label. */
|
|
11
|
+
"aria-labelledby"?: string;
|
|
8
12
|
/** Plain-text overrides for built-in viewer text. */
|
|
9
13
|
labels?: ModelViewerLabels;
|
|
10
14
|
modelUrl: string;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { L as ModelViewerLabels, bi as ViewerLoading, bl as ViewerReveal, H as ModelFormat, j as CameraLimits, as as ReducedMotionSetting, E as EnvironmentPreset, bk as ViewerModelInfo } from './modelFileResolver-
|
|
3
|
-
export { D as DEFAULT_MODEL_VIEWER_LABELS, p as MaterialVariantGroup, q as MaterialVariantOption, J as ModelViewerLabelKey, bj as ViewerModelBounds } from './modelFileResolver-
|
|
2
|
+
import { L as ModelViewerLabels, bi as ViewerLoading, bl as ViewerReveal, H as ModelFormat, j as CameraLimits, as as ReducedMotionSetting, E as EnvironmentPreset, bk as ViewerModelInfo } from './modelFileResolver-An1aQ0D3.js';
|
|
3
|
+
export { D as DEFAULT_MODEL_VIEWER_LABELS, p as MaterialVariantGroup, q as MaterialVariantOption, J as ModelViewerLabelKey, bj as ViewerModelBounds } from './modelFileResolver-An1aQ0D3.js';
|
|
4
4
|
|
|
5
5
|
/** How the render's colors are mapped to the screen. */
|
|
6
6
|
type ViewerToneMapping = "aces" | "agx" | "neutral" | "none";
|
|
7
7
|
type SimpleModelViewerProps = {
|
|
8
|
+
/** Accessible viewer name. Defaults to the localized "3D model viewer" label. */
|
|
9
|
+
"aria-label"?: string;
|
|
10
|
+
/** ID(s) of visible text naming this viewer; takes precedence over aria-label. */
|
|
11
|
+
"aria-labelledby"?: string;
|
|
8
12
|
/** Plain-text overrides for built-in viewer text. */
|
|
9
13
|
labels?: ModelViewerLabels;
|
|
10
14
|
modelUrl: string;
|