@liveroom-tech/react-immersive 6.1.3 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{SequencesTab-66VBWTO5.mjs → SequencesTab-ODR5IGDX.mjs} +1 -1
- package/dist/binding-builder.css +1 -1
- package/dist/binding-builder.d.mts +3 -3
- package/dist/binding-builder.d.ts +3 -3
- package/dist/binding-builder.js +40 -40
- package/dist/binding-builder.mjs +1 -1
- package/dist/chunk-2CUPPOBW.mjs +3 -0
- package/dist/chunk-3MIILDHB.mjs +83 -0
- package/dist/chunk-3XZKDTB2.mjs +1 -0
- package/dist/chunk-7MN2TMY6.mjs +47 -0
- package/dist/{chunk-B75URXOE.mjs → chunk-EWNN4BBR.mjs} +1 -1
- package/dist/{chunk-LKKH4PO7.mjs → chunk-GXY3VML4.mjs} +1 -1
- package/dist/chunk-IOLT2VXU.mjs +1 -0
- package/dist/chunk-X4WRTDO6.mjs +50 -0
- package/dist/hosted.css +1 -1
- package/dist/hosted.d.mts +4 -4
- package/dist/hosted.d.ts +4 -4
- package/dist/hosted.js +39 -39
- package/dist/hosted.mjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +37 -37
- package/dist/index.mjs +1 -1
- package/dist/{modelFileResolver-B2B3F3d1.d.mts → modelFileResolver-ChKYsF21.d.mts} +33 -2
- package/dist/{modelFileResolver-B2B3F3d1.d.ts → modelFileResolver-ChKYsF21.d.ts} +33 -2
- package/dist/{modelViewerProps-Bo48RDq6.d.ts → modelViewerProps-Ch6pIZIE.d.ts} +30 -31
- package/dist/{modelViewerProps-DkvYb1GH.d.mts → modelViewerProps-HazR2IE_.d.mts} +30 -31
- package/dist/{publicProps-DJSccx3b.d.ts → publicProps-Cmh9JtzJ.d.ts} +2 -1
- package/dist/{publicProps-DN0-8tBm.d.mts → publicProps-TMARX628.d.mts} +2 -1
- package/dist/simple-model-viewer.css +1 -1
- package/dist/simple-model-viewer.d.mts +15 -2
- package/dist/simple-model-viewer.d.ts +15 -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 +3 -3
- package/dist/utils.mjs +1 -1
- package/package.json +7 -4
- package/dist/chunk-4RYMXBK6.mjs +0 -47
- package/dist/chunk-5P7ETEAN.mjs +0 -50
- package/dist/chunk-EC542N4J.mjs +0 -1
- package/dist/chunk-JK7GRGRG.mjs +0 -1
- package/dist/chunk-U3BQMOC3.mjs +0 -83
- package/dist/chunk-VMYNX63T.mjs +0 -3
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{c as he}from"./chunk-JK7GRGRG.mjs";import"./chunk-MMO7KCYU.mjs";import{a as _e,b as Ne,c as xn}from"./chunk-F5QSXMME.mjs";import{A as qe,B as kn,b as lt,d as yn,l as On,m as jn,w as ut,x as pt,y as He,z as ft}from"./chunk-U3BQMOC3.mjs";import"./chunk-B75URXOE.mjs";import"./chunk-FGAJ2UT7.mjs";import{A as ct}from"./chunk-4RYMXBK6.mjs";import{a as st,b as at}from"./chunk-LKKH4PO7.mjs";import"./chunk-37YITTIK.mjs";import{Aa as mn,Fa as bn,Ga as hn,Ia as Vn,Ma as Bn,N as Se,Na as vn,O as Oe,Oa as Mn,P as kt,Pa as Pn,Q as Ut,Qa as Rn,Ra as dt,U as re,Ua as Ue,V as Te,Va as De,Wa as An,X as Dt,Xa as En,Y as Ht,Ya as Tn,Za as In,_a as Ln,e as ot,ga as _t,ia as Nt,ka as qt,l as Ee,la as Ft,ma as Kt,na as Gt,oa as $t,pa as zt,qa as Wt,ra as fn,sa as ge,ta as ye,ua as ke,za as gn}from"./chunk-5P7ETEAN.mjs";import{b as Cn,c as Sn}from"./chunk-CCBFMNAU.mjs";import"./chunk-7OWHW66D.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 Le,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{a as ee,b as le,c as Ie}from"./chunk-GV4ZRXL6.mjs";import{E as wn}from"./chunk-6Q6YZ7O5.mjs";import{a as Lt}from"./chunk-EC542N4J.mjs";import{c as Yt}from"./chunk-BNKTI3CY.mjs";import"./chunk-JR557W27.mjs";import{useCallback as Un,useEffect as je,useMemo as Be,useRef as Fe,useState as me}from"react";import{jsx as ie,jsxs as Ke}from"react/jsx-runtime";var Dn=Object.freeze({});function gt(e){return ie(st,{labels:e.labels,children:ie(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=at(),[E,C]=me(y==="auto");je(()=>{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}];je(()=>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=Be(()=>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);je(()=>{n&&g.current!==o&&(g.current=o,O?.(n))},[n,o,O]);let d=n?.objects.find(P=>P.id===r),M=Be(()=>n?[De(n,"before",r),De(n,"after",r)]:null,[n,r]),I=Be(()=>pt(),[]);je(()=>()=>I.detach(),[I]);let T=[e,t],D=Be(()=>[0,1].map(P=>(A,W)=>{_.current[P]=A,J(K=>K[P]?.bindings===A.objectBindings&&K[P]?.url===W?K:K.map((G,we)=>we===P?{url:W,bindings:A.objectBindings}:G)),I.attach(P,A.raw.controls,A.invalidate)}),[I]),z=T.map((P,A)=>{let{label:W,...K}=P,G={preset:"minimal",...m,...K},we=K.onViewerReady??m.onViewerReady;return{...G,...v??!!l?{sceneConfig:{...G.sceneConfig,section:N??u[1].sceneConfig?.section??Se},onSceneConfigChange:oe=>{a(oe.section??Se),(K.onSceneConfigChange??m.onSceneConfigChange)?.(oe)}}:{},...M?{comparisonHighlights:R?M[A]:void 0,selectedObject:A===0?d?.beforeKey?L[d.beforeKey]:null:d?.afterKey?$[d.afterKey]:null}:{},onObjectSelect:oe=>{if((K.onObjectSelect??m.onObjectSelect)?.(oe),n){let Ce=n.objects.find(Z=>(A===0?Z.beforeObjectId:Z.afterObjectId)===oe?.modelObjectId);c(Ce?.id??null)}},onViewerReady:oe=>{D[A](oe,G.modelUrl),we?.(oe)}}}),F=[e.label??k("compareBefore"),t.label??k("compareAfter")];(!z[0].modelUrl||!z[1].modelUrl)&&console.error("[react-immersive] CompareViewer needs a modelUrl, shared or on each side.");let ce=Fe(null),Q=n?ie(ut,{showOutlines:R,onShowOutlinesChange:j,report:n,selected:r,onSelect:P=>{c(P.id);let A=P.afterObjectId?1:0,W=_.current[A],K=A===1?P.afterObjectId:P.beforeObjectId,G=K?W?.raw.nodes[K]:null;W&&G&&(I.setLeader(A),W.raw.controls.fitToBox(G,!0),W.invalidate())},onClear:()=>c(null)}):null;if(!E)return ie(ct,{className:"ri-compare",background:lt(m.backgroundColor,m.sceneConfig),poster:m.poster??t.poster??e.poster,onReveal:()=>C(!0)});if(i==="side-by-side")return Ke("div",{className:"ri-compare ri-compare--sideBySide",children:[z.map((P,A)=>Ke("div",{className:"ri-compare__pane",children:[ie(he,{...P}),ie("span",{className:"ri-compare__label",children:F[A]})]},A)),Q]});let Y=`${q*100}%`;return Ke("div",{ref:ce,className:"ri-compare ri-compare--slider",style:{"--ri-compare-split":Y},children:[ie("div",{className:"ri-compare__layer",children:ie(he,{...z[0]})}),ie("div",{className:"ri-compare__layer ri-compare__layer--after",children:ie(he,{...z[1]})}),Q,ie(ft,{split:q,onSplitChange:X,labels:[F[0],F[1]],containerRef:ce})]})}import{useCallback as xe,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 Ge(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,Le(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=ee(c,a);if(!u)return c;let w=wt(c[u]?.style?.material),L=le(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 le(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=>Ie(t,a),[t]),S=H(a=>le(t,a).map(r=>t[r]?.id??r),[t]),R=H(a=>{let r=ee(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=le(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=ee(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 te,useMemo as qn,useRef as Fn,useState as Kn}from"react";function $e(e){let t=Fn(null),[i,s]=Kn(()=>{let f=typeof e=="function"?e():e;return t.current=f,f}),p=te(f=>{s(S=>{let R=typeof f=="function"?f(S):f;return _e(S,R)})},[]),y=te(()=>{let f=t.current;f&&s(f)},[]),l=te((f,S)=>{p(R=>({lighting:{lights:R.lighting.lights.map(j=>j.id===f?{...j,...S}:j)}}))},[p]),x=te(f=>{p(S=>S.lighting.lights.some(R=>R.id===f.id)?{}:{lighting:{lights:[...S.lighting.lights,Ne(f)]}})},[p]),B=te(f=>{p(S=>({lighting:{lights:S.lighting.lights.filter(R=>R.id!==f)}}))},[p]),O=te((f,S)=>l(f,{intensity:S}),[l]),v=te((f,S)=>l(f,{color:S}),[l]),m=te(f=>l(f,{visible:!0}),[l]),k=te(f=>l(f,{visible:!1}),[l]),E=te(f=>{p(S=>({lighting:{lights:S.lighting.lights.map(R=>R.id===f?{...R,visible:!R.visible}:R)}}))},[p]),C=te((f,S)=>l(f,{attachment:S,attachedToCamera:!1}),[l]),h=te(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 We({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=ee(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=ee(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 Ve,useRef as yt}from"react";function Gn(e){return typeof e=="function"?e:e?.handleViewerReady??null}function Ye(...e){let t=yt(null),i=yt(e);i.current=e;let s=Ve(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=Ve(()=>t.current,[]),y=Ve(B=>{let O=t.current;return O?O.captureImage(B):Promise.reject(new Error("ModelViewer is not ready yet."))},[]),l=Ve(()=>{let B=t.current;return B?(B.invalidate(),!0):!1},[]),x=Ve(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 $n,useRef as se}from"react";import{Material as zn,PointLight as Wn,Vector3 as Yn}from"three";var Qe=["emissiveIntensity","opacity","metalness","roughness","transmission","clearcoat","clearcoatRoughness","ior","thickness"],ve=1;function Me(e){return typeof e=="string"?[e]:e}function Pe(e,t=0,i=1){return Math.min(i,Math.max(t,e))}function Xe(e,t){return e+Math.random()*(t-e)}function ht([e,t],i){return e+(t-e)*i}function Je([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=Pe(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 zn):[]}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 Qe){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 Qe){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 Ze(e={}){let t=se(e);t.current=e;let i=se(null),s=se(null),p=se(null),y=se(new Map),l=se(new Map),x=se(new Map),B=se(new Map),O=U(n=>{let o=i.current;if(!o)return null;let g=ee(o.objectBindings,n);return o.raw.nodes[n]??(g?o.raw.nodes[g]:null)??(o.raw.scene?ot(o.raw.scene,n):null)??null},[]),v=U(n=>{let o=i.current;return o?typeof n=="object"&&!Array.isArray(n)?le(o.objectBindings,n):Me(n).map(g=>ee(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 z of Qe){let F=d.values[z];F&&(D[z]=ht(F,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=Je(d.values.position,T)),d.values.rotation&&(D.rotation=Je(d.values.rotation,T)),d.values.scale&&(D.scale=Je(d.values.scale,T)),C(M,D)});for(let d of n.lights??[])Me(d.lights).forEach((M,I)=>{let T=l.current.get(M);T&&(T.light.intensity=ht(d.intensity,g(I)))})},[v,k,C]),q=se(()=>{}),X=se(()=>{});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-${ve++}`,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,z)=>{let F=z??Vt(T/d,M);return j(n,[F]),T<d}})},[j,_]),J=U((n,o={})=>{let g=o.id??`pulse-${ve++}`,d=Math.max(1,o.duration??1e3),M=o.minLevel??0,I=o.maxLevel??1,T=o.repeat??1/0,D=o.synchronized??!0,z=Math.max(1,...[...n.materials??[],...n.transforms??[]].map(F=>v(F.targets).length),...(n.lights??[]).map(F=>Me(F.lights).length));return _({id:g,startedAt:null,lastFrameAt:null,override:null,onComplete:o.onComplete,update:(F,ce,ue,Q)=>{let Y=ce/d,P=Array.from({length:D?1:z},(A,W)=>{if(Q!==null)return Q;let K=Y+(D?0:W/z),G=.5-Math.cos(K%1*Math.PI*2)/2;return M+(I-M)*G});return j(n,P),T===1/0||Y<T}})},[j,_,v]),N=U((n,o={})=>{let g=o.id??`timeline-${ve++}`,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,z,F)=>{if(M.length===0||d<=0)return!1;let ce=D/I;if(d!==1/0&&ce>=d){for(let Y of M)j(Y.channels,[1]);return!1}let ue=D%I,Q=0;for(let Y of M){let P=Q+Y.duration,A=P+Y.hold;if(ue>=P){j(Y.channels,[F??1]),Q=A;continue}if(ue>=Q){let W=F??Vt((ue-Q)/Y.duration,Y.easing??"ease-in-out");j(Y.channels,[W]);break}}return!0}})},[j,_]),a=U((n,o={})=>{let g=o.id??`flicker-${ve++}`,d=o.synchronized??!0,M=o.minLevel??.15,I=o.maxLevel??1,T=o.interval??[45,160],D=typeof T=="number"?[T,T]:T,z=[Math.max(1,Math.min(...D)),Math.max(1,Math.max(...D))],F=Pe(o.response??.7,.01,1),ce=Pe(o.blackoutChance??.08),ue=Pe(o.flashChance??.12),Q=o.flashLevel??1.15,Y=Math.max(1,...[...n.materials??[],...n.transforms??[]].map(G=>v(G.targets).length),...(n.lights??[]).map(G=>Me(G.lights).length)),P=d?1:Y,A=Array.from({length:P},()=>M),W=Array.from({length:P},()=>M),K=Array.from({length:P},()=>0);return _({id:g,startedAt:null,lastFrameAt:null,override:null,onComplete:o.onComplete,update:(G,we,oe,Ce)=>{for(let Z=0;Z<P;Z+=1){if(Ce!==null)W[Z]=Ce;else if(G>=K[Z]){let it=Math.random();W[Z]=it<ce?Xe(0,Math.min(.04,M)):it<ce+ue?Q:Xe(M,I),K[Z]=G+Xe(...z)}let Rt=1-Math.pow(1-F,Math.max(1,oe)/16.67);A[Z]+=(W[Z]-A[Z])*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 $n(()=>()=>{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 et(){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 tt(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 Re,useState as de}from"react";function nt(){let[e,t]=de(!0),[i,s]=de(!1),[p,y]=de(null),[l,x]=de(null),[B,O]=de(0),[v,m]=de([]),[k,E]=de([]),[C,h]=de([]),b=Re(j=>{x(j.bounds),O(j.objectCount),m(j.materialVariants),E(j.materialVariantGroups),y(null),t(!1),s(!0)},[]),f=Re(j=>h(j),[]),S=Re(j=>{y(j),x(null),O(0),m([]),E([]),h([]),t(!1),s(!1)},[]),R=Re(()=>{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 rt(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=Ge(()=>{let V=t.current.bindings;return V===void 0||V==="auto"?ir:typeof V=="function"?V():V}),p=$e(()=>{let V=t.current.sceneConfig;return V===void 0?Oe:typeof V=="function"?V():V}),y=rt(),l=et(),x=Ee(e.camera),B=nt(),O=qe(),v=tt(),m=Ze(),k=Ye(x,m),E=We({bindings:s,scene:p,camera:x,animations:O,isolation:v,onAction:e.onAction}),{setObjectBindings:C}=s,{handleObjectCatalog:h}=B,b=xe(V=>{h(V),i.current&&C(J=>{let N=dt(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=xe(V=>{f(V),t.current.onObjectSelect?.(V)},[f]),{handleHoveredObject:R}=l,j=xe(V=>{R(V),t.current.onObjectHover?.(V)},[R]),{handleLoadError:q}=B,X=xe(V=>{q(V),t.current.onLoadError?.(V)},[q]),_=e.sceneConfig!==void 0||p.sceneConfig!==Oe;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 ne,useEffect as Ae,useRef as ae,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?ee(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=ae(e);t.current=e;let i=e.paramKey??"view",s=`${i}Id`,[p,y]=dr(!1),l=ae(null),x=ae(null),B=ae(null),O=ae(null),v=ae(null),m=ae(null),k=ae(null),E=ae(null),C=ae(!0),h=ne(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=ne(()=>{v.current!==null&&clearTimeout(v.current),v.current=null},[]);Ae(()=>(C.current=!0,()=>{C.current=!1,b()}),[b]);let f=ne(()=>{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=ne(()=>ye(f(),typeof window>"u"?void 0:window.location.href),[f]),R=ne(()=>ke(f(),typeof window>"u"?void 0:window.location.href),[f]),j=ne((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=ne(()=>j(ge(S()),!1),[S,j]),X=ne(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]),_=ne(()=>{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=ne(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=ne(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=ne(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]);Ae(()=>{l.current&&V().catch(h)}),Ae(()=>{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 Ae(()=>{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=Te(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,Oe as DEFAULT_SCENE_CONFIG,Se 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,he 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,Le as material,Kt as measurementResult,Nt as measurementScale,Ft as measurementValue,zt as measurementsToCsv,Te 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,ke 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,le as selectBindingKeys,Ie as selectBindings,$t as serializeMeasurements,dn as serializeProductConfiguration,ge as serializeViewerState,Dt as snapAssetToGrid,It as upsertSequenceKeyframe,ar as useObjectBinding,lr as useObjectBindingIds,Ge as useObjectBindings,On as useProductConfigurator,$e as useSceneConfig,pr as useShareableViewerState,or as useViewer,We as useViewerActions,qe as useViewerAnimations,Ee as useViewerCamera,Ye as useViewerConnection,Ze as useViewerEffects,et as useViewerHover,tt as useViewerIsolation,nt as useViewerModel,gr as useViewerModels,rt as useViewerSelection,Vr as useViewerSequences};
|
|
1
|
+
"use client";import{c as he}from"./chunk-3XZKDTB2.mjs";import"./chunk-MMO7KCYU.mjs";import{a as _e,b as Ne,c as xn}from"./chunk-F5QSXMME.mjs";import{A as kn,b as lt,c as yn,k as On,l as jn,v as ut,w as pt,x as He,y as ft,z as qe}from"./chunk-3MIILDHB.mjs";import"./chunk-EWNN4BBR.mjs";import"./chunk-FGAJ2UT7.mjs";import{A as ct}from"./chunk-7MN2TMY6.mjs";import{a as st,b as at}from"./chunk-GXY3VML4.mjs";import"./chunk-37YITTIK.mjs";import{$a as In,Ba as gn,Ca as mn,Ha as bn,Ia as hn,Ka as Vn,Oa as Bn,P as Se,Pa as vn,Q as Oe,Qa as Mn,R as kt,Ra as Pn,S as Ut,Sa as Rn,Ta as dt,W as re,Wa as Ue,X as Te,Xa as De,Ya as An,Z as Dt,Za as En,_ as Ht,_a as Tn,ab as Ln,e as ot,ia as _t,ka as Nt,ma as qt,n as Ee,na as Ft,oa as Kt,pa as Gt,qa as $t,ra as zt,sa as Wt,ta as fn,ua as ge,va as ye,wa as ke}from"./chunk-X4WRTDO6.mjs";import{b as Cn,c as Sn}from"./chunk-CCBFMNAU.mjs";import"./chunk-7OWHW66D.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 Le,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{a as ee,b as le,c as Ie}from"./chunk-GV4ZRXL6.mjs";import{E as wn}from"./chunk-6Q6YZ7O5.mjs";import{a as Lt}from"./chunk-IOLT2VXU.mjs";import{c as Yt}from"./chunk-BNKTI3CY.mjs";import"./chunk-JR557W27.mjs";import{useCallback as Un,useEffect as je,useMemo as Be,useRef as Fe,useState as me}from"react";import{jsx as ie,jsxs as Ke}from"react/jsx-runtime";var Dn=Object.freeze({});function gt(e){return ie(st,{labels:e.labels,children:ie(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=at(),[E,C]=me(y==="auto");je(()=>{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}];je(()=>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=Be(()=>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);je(()=>{n&&g.current!==o&&(g.current=o,O?.(n))},[n,o,O]);let d=n?.objects.find(P=>P.id===r),M=Be(()=>n?[De(n,"before",r),De(n,"after",r)]:null,[n,r]),I=Be(()=>pt(),[]);je(()=>()=>I.detach(),[I]);let T=[e,t],D=Be(()=>[0,1].map(P=>(A,W)=>{_.current[P]=A,J(K=>K[P]?.bindings===A.objectBindings&&K[P]?.url===W?K:K.map((G,we)=>we===P?{url:W,bindings:A.objectBindings}:G)),I.attach(P,A.raw.controls,A.invalidate)}),[I]),z=T.map((P,A)=>{let{label:W,...K}=P,G={preset:"minimal",...m,...K},we=K.onViewerReady??m.onViewerReady;return{...G,...v??!!l?{sceneConfig:{...G.sceneConfig,section:N??u[1].sceneConfig?.section??Se},onSceneConfigChange:oe=>{a(oe.section??Se),(K.onSceneConfigChange??m.onSceneConfigChange)?.(oe)}}:{},...M?{comparisonHighlights:R?M[A]:void 0,selectedObject:A===0?d?.beforeKey?L[d.beforeKey]:null:d?.afterKey?$[d.afterKey]:null}:{},onObjectSelect:oe=>{if((K.onObjectSelect??m.onObjectSelect)?.(oe),n){let Ce=n.objects.find(Z=>(A===0?Z.beforeObjectId:Z.afterObjectId)===oe?.modelObjectId);c(Ce?.id??null)}},onViewerReady:oe=>{D[A](oe,G.modelUrl),we?.(oe)}}}),F=[e.label??k("compareBefore"),t.label??k("compareAfter")];(!z[0].modelUrl||!z[1].modelUrl)&&console.error("[react-immersive] CompareViewer needs a modelUrl, shared or on each side.");let ce=Fe(null),Q=n?ie(ut,{showOutlines:R,onShowOutlinesChange:j,report:n,selected:r,onSelect:P=>{c(P.id);let A=P.afterObjectId?1:0,W=_.current[A],K=A===1?P.afterObjectId:P.beforeObjectId,G=K?W?.raw.nodes[K]:null;W&&G&&(I.setLeader(A),W.raw.controls.fitToBox(G,!0),W.invalidate())},onClear:()=>c(null)}):null;if(!E)return ie(ct,{className:"ri-compare",background:lt(m.backgroundColor,m.sceneConfig),poster:m.poster??t.poster??e.poster,onReveal:()=>C(!0)});if(i==="side-by-side")return Ke("div",{className:"ri-compare ri-compare--sideBySide",children:[z.map((P,A)=>Ke("div",{className:"ri-compare__pane",children:[ie(he,{...P}),ie("span",{className:"ri-compare__label",children:F[A]})]},A)),Q]});let Y=`${q*100}%`;return Ke("div",{ref:ce,className:"ri-compare ri-compare--slider",style:{"--ri-compare-split":Y},children:[ie("div",{className:"ri-compare__layer",children:ie(he,{...z[0]})}),ie("div",{className:"ri-compare__layer ri-compare__layer--after",children:ie(he,{...z[1]})}),Q,ie(ft,{split:q,onSplitChange:X,labels:[F[0],F[1]],containerRef:ce})]})}import{useCallback as xe,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 Ge(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,Le(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=ee(c,a);if(!u)return c;let w=wt(c[u]?.style?.material),L=le(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 le(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=>Ie(t,a),[t]),S=H(a=>le(t,a).map(r=>t[r]?.id??r),[t]),R=H(a=>{let r=ee(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=le(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=ee(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 te,useMemo as qn,useRef as Fn,useState as Kn}from"react";function $e(e){let t=Fn(null),[i,s]=Kn(()=>{let f=typeof e=="function"?e():e;return t.current=f,f}),p=te(f=>{s(S=>{let R=typeof f=="function"?f(S):f;return _e(S,R)})},[]),y=te(()=>{let f=t.current;f&&s(f)},[]),l=te((f,S)=>{p(R=>({lighting:{lights:R.lighting.lights.map(j=>j.id===f?{...j,...S}:j)}}))},[p]),x=te(f=>{p(S=>S.lighting.lights.some(R=>R.id===f.id)?{}:{lighting:{lights:[...S.lighting.lights,Ne(f)]}})},[p]),B=te(f=>{p(S=>({lighting:{lights:S.lighting.lights.filter(R=>R.id!==f)}}))},[p]),O=te((f,S)=>l(f,{intensity:S}),[l]),v=te((f,S)=>l(f,{color:S}),[l]),m=te(f=>l(f,{visible:!0}),[l]),k=te(f=>l(f,{visible:!1}),[l]),E=te(f=>{p(S=>({lighting:{lights:S.lighting.lights.map(R=>R.id===f?{...R,visible:!R.visible}:R)}}))},[p]),C=te((f,S)=>l(f,{attachment:S,attachedToCamera:!1}),[l]),h=te(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 We({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=ee(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=ee(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 Ve,useRef as yt}from"react";function Gn(e){return typeof e=="function"?e:e?.handleViewerReady??null}function Ye(...e){let t=yt(null),i=yt(e);i.current=e;let s=Ve(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=Ve(()=>t.current,[]),y=Ve(B=>{let O=t.current;return O?O.captureImage(B):Promise.reject(new Error("ModelViewer is not ready yet."))},[]),l=Ve(()=>{let B=t.current;return B?(B.invalidate(),!0):!1},[]),x=Ve(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 $n,useRef as se}from"react";import{Material as zn,PointLight as Wn,Vector3 as Yn}from"three";var Qe=["emissiveIntensity","opacity","metalness","roughness","transmission","clearcoat","clearcoatRoughness","ior","thickness"],ve=1;function Me(e){return typeof e=="string"?[e]:e}function Pe(e,t=0,i=1){return Math.min(i,Math.max(t,e))}function Xe(e,t){return e+Math.random()*(t-e)}function ht([e,t],i){return e+(t-e)*i}function Je([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=Pe(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 zn):[]}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 Qe){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 Qe){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 Ze(e={}){let t=se(e);t.current=e;let i=se(null),s=se(null),p=se(null),y=se(new Map),l=se(new Map),x=se(new Map),B=se(new Map),O=U(n=>{let o=i.current;if(!o)return null;let g=ee(o.objectBindings,n);return o.raw.nodes[n]??(g?o.raw.nodes[g]:null)??(o.raw.scene?ot(o.raw.scene,n):null)??null},[]),v=U(n=>{let o=i.current;return o?typeof n=="object"&&!Array.isArray(n)?le(o.objectBindings,n):Me(n).map(g=>ee(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 z of Qe){let F=d.values[z];F&&(D[z]=ht(F,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=Je(d.values.position,T)),d.values.rotation&&(D.rotation=Je(d.values.rotation,T)),d.values.scale&&(D.scale=Je(d.values.scale,T)),C(M,D)});for(let d of n.lights??[])Me(d.lights).forEach((M,I)=>{let T=l.current.get(M);T&&(T.light.intensity=ht(d.intensity,g(I)))})},[v,k,C]),q=se(()=>{}),X=se(()=>{});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-${ve++}`,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,z)=>{let F=z??Vt(T/d,M);return j(n,[F]),T<d}})},[j,_]),J=U((n,o={})=>{let g=o.id??`pulse-${ve++}`,d=Math.max(1,o.duration??1e3),M=o.minLevel??0,I=o.maxLevel??1,T=o.repeat??1/0,D=o.synchronized??!0,z=Math.max(1,...[...n.materials??[],...n.transforms??[]].map(F=>v(F.targets).length),...(n.lights??[]).map(F=>Me(F.lights).length));return _({id:g,startedAt:null,lastFrameAt:null,override:null,onComplete:o.onComplete,update:(F,ce,ue,Q)=>{let Y=ce/d,P=Array.from({length:D?1:z},(A,W)=>{if(Q!==null)return Q;let K=Y+(D?0:W/z),G=.5-Math.cos(K%1*Math.PI*2)/2;return M+(I-M)*G});return j(n,P),T===1/0||Y<T}})},[j,_,v]),N=U((n,o={})=>{let g=o.id??`timeline-${ve++}`,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,z,F)=>{if(M.length===0||d<=0)return!1;let ce=D/I;if(d!==1/0&&ce>=d){for(let Y of M)j(Y.channels,[1]);return!1}let ue=D%I,Q=0;for(let Y of M){let P=Q+Y.duration,A=P+Y.hold;if(ue>=P){j(Y.channels,[F??1]),Q=A;continue}if(ue>=Q){let W=F??Vt((ue-Q)/Y.duration,Y.easing??"ease-in-out");j(Y.channels,[W]);break}}return!0}})},[j,_]),a=U((n,o={})=>{let g=o.id??`flicker-${ve++}`,d=o.synchronized??!0,M=o.minLevel??.15,I=o.maxLevel??1,T=o.interval??[45,160],D=typeof T=="number"?[T,T]:T,z=[Math.max(1,Math.min(...D)),Math.max(1,Math.max(...D))],F=Pe(o.response??.7,.01,1),ce=Pe(o.blackoutChance??.08),ue=Pe(o.flashChance??.12),Q=o.flashLevel??1.15,Y=Math.max(1,...[...n.materials??[],...n.transforms??[]].map(G=>v(G.targets).length),...(n.lights??[]).map(G=>Me(G.lights).length)),P=d?1:Y,A=Array.from({length:P},()=>M),W=Array.from({length:P},()=>M),K=Array.from({length:P},()=>0);return _({id:g,startedAt:null,lastFrameAt:null,override:null,onComplete:o.onComplete,update:(G,we,oe,Ce)=>{for(let Z=0;Z<P;Z+=1){if(Ce!==null)W[Z]=Ce;else if(G>=K[Z]){let it=Math.random();W[Z]=it<ce?Xe(0,Math.min(.04,M)):it<ce+ue?Q:Xe(M,I),K[Z]=G+Xe(...z)}let Rt=1-Math.pow(1-F,Math.max(1,oe)/16.67);A[Z]+=(W[Z]-A[Z])*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 $n(()=>()=>{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 et(){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 tt(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 Re,useState as de}from"react";function nt(){let[e,t]=de(!0),[i,s]=de(!1),[p,y]=de(null),[l,x]=de(null),[B,O]=de(0),[v,m]=de([]),[k,E]=de([]),[C,h]=de([]),b=Re(j=>{x(j.bounds),O(j.objectCount),m(j.materialVariants),E(j.materialVariantGroups),y(null),t(!1),s(!0)},[]),f=Re(j=>h(j),[]),S=Re(j=>{y(j),x(null),O(0),m([]),E([]),h([]),t(!1),s(!1)},[]),R=Re(()=>{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 rt(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=Ge(()=>{let V=t.current.bindings;return V===void 0||V==="auto"?ir:typeof V=="function"?V():V}),p=$e(()=>{let V=t.current.sceneConfig;return V===void 0?Oe:typeof V=="function"?V():V}),y=rt(),l=et(),x=Ee(e.camera),B=nt(),O=qe(),v=tt(),m=Ze(),k=Ye(x,m),E=We({bindings:s,scene:p,camera:x,animations:O,isolation:v,onAction:e.onAction}),{setObjectBindings:C}=s,{handleObjectCatalog:h}=B,b=xe(V=>{h(V),i.current&&C(J=>{let N=dt(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=xe(V=>{f(V),t.current.onObjectSelect?.(V)},[f]),{handleHoveredObject:R}=l,j=xe(V=>{R(V),t.current.onObjectHover?.(V)},[R]),{handleLoadError:q}=B,X=xe(V=>{q(V),t.current.onLoadError?.(V)},[q]),_=e.sceneConfig!==void 0||p.sceneConfig!==Oe;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 ne,useEffect as Ae,useRef as ae,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?ee(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=ae(e);t.current=e;let i=e.paramKey??"view",s=`${i}Id`,[p,y]=dr(!1),l=ae(null),x=ae(null),B=ae(null),O=ae(null),v=ae(null),m=ae(null),k=ae(null),E=ae(null),C=ae(!0),h=ne(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=ne(()=>{v.current!==null&&clearTimeout(v.current),v.current=null},[]);Ae(()=>(C.current=!0,()=>{C.current=!1,b()}),[b]);let f=ne(()=>{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=ne(()=>ye(f(),typeof window>"u"?void 0:window.location.href),[f]),R=ne(()=>ke(f(),typeof window>"u"?void 0:window.location.href),[f]),j=ne((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=ne(()=>j(ge(S()),!1),[S,j]),X=ne(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]),_=ne(()=>{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=ne(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=ne(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=ne(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]);Ae(()=>{l.current&&V().catch(h)}),Ae(()=>{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 Ae(()=>{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=Te(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,Oe as DEFAULT_SCENE_CONFIG,Se 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,he 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,Le as material,Kt as measurementResult,Nt as measurementScale,Ft as measurementValue,zt as measurementsToCsv,Te 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,ke 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,le as selectBindingKeys,Ie as selectBindings,$t as serializeMeasurements,dn as serializeProductConfiguration,ge as serializeViewerState,Dt as snapAssetToGrid,It as upsertSequenceKeyframe,ar as useObjectBinding,lr as useObjectBindingIds,Ge as useObjectBindings,On as useProductConfigurator,$e as useSceneConfig,pr as useShareableViewerState,or as useViewer,We as useViewerActions,qe as useViewerAnimations,Ee as useViewerCamera,Ye as useViewerConnection,Ze as useViewerEffects,et as useViewerHover,tt as useViewerIsolation,nt as useViewerModel,gr as useViewerModels,rt as useViewerSelection,Vr as useViewerSequences};
|
|
@@ -54,6 +54,7 @@ type ViewerModelInfo = {
|
|
|
54
54
|
declare const DEFAULT_MODEL_VIEWER_LABELS: {
|
|
55
55
|
readonly verifyingLicense: "Verifying License";
|
|
56
56
|
readonly checkingYourLicenseKey: "Checking your license key...";
|
|
57
|
+
readonly createDevelopmentKey: "Create a free development key";
|
|
57
58
|
readonly invalidLicense: "Invalid License";
|
|
58
59
|
readonly licenseHasBeenRevokedOrHasExpired: "License has been revoked or has expired";
|
|
59
60
|
readonly failedToLoadPleaseContactTheSiteAdministrator: "Failed to load. Please contact the site administrator.";
|
|
@@ -87,7 +88,8 @@ declare const DEFAULT_MODEL_VIEWER_LABELS: {
|
|
|
87
88
|
readonly arStartFailed: "Could not start AR. Check camera permissions and try again.";
|
|
88
89
|
readonly arAnimations: "AR animations";
|
|
89
90
|
readonly arAnimationSelect: "Animation";
|
|
90
|
-
readonly arAnimationSaved: "
|
|
91
|
+
readonly arAnimationSaved: "Default";
|
|
92
|
+
readonly arAnimationNone: "No animation";
|
|
91
93
|
readonly arAnimationClips: "Model clips";
|
|
92
94
|
readonly arAnimationSequences: "Sequences";
|
|
93
95
|
readonly arAnimationPlay: "Play animation";
|
|
@@ -362,6 +364,7 @@ declare const DEFAULT_MODEL_VIEWER_LABELS: {
|
|
|
362
364
|
readonly bindingMismatchMany: "{count} object bindings don't match this model";
|
|
363
365
|
readonly simpleLargeModelWarning: "Very large model detected ({millions}M triangles) — it may render and move slowly on this device, and click/hover selection on the model is disabled. Use the scene objects panel to select parts.";
|
|
364
366
|
readonly dropModelHint: "Drag and drop {formats} here";
|
|
367
|
+
readonly retryModelLoad: "Retry loading model";
|
|
365
368
|
readonly loadErrorTitle: "This model couldn't be loaded";
|
|
366
369
|
readonly loadErrorNotFound: "Nothing was found at this address ({status}). Check that modelUrl points to the file.";
|
|
367
370
|
readonly loadErrorDenied: "The server refused access to the file ({status}). Check that the file is public, or that a signed URL hasn't expired.";
|
|
@@ -452,6 +455,34 @@ type ViewerLoading = "lazy" | "eager";
|
|
|
452
455
|
*/
|
|
453
456
|
type ViewerReveal = "auto" | "interaction";
|
|
454
457
|
|
|
458
|
+
type CameraLimits = {
|
|
459
|
+
/** Closest the camera can get to its target, in scene units. Default 0. */
|
|
460
|
+
minDistance?: number;
|
|
461
|
+
/** Farthest the camera can get from its target, in scene units. Default Infinity. */
|
|
462
|
+
maxDistance?: number;
|
|
463
|
+
/**
|
|
464
|
+
* Lowest vertical angle, in degrees: 0 looks straight down from above, 90 is
|
|
465
|
+
* level with the target, 180 looks straight up from below. Default 0.
|
|
466
|
+
*/
|
|
467
|
+
minPolarAngle?: number;
|
|
468
|
+
/** Highest vertical angle, in degrees (see minPolarAngle). Default 180. */
|
|
469
|
+
maxPolarAngle?: number;
|
|
470
|
+
/**
|
|
471
|
+
* Leftmost horizontal angle, in degrees around the vertical axis: 0 views
|
|
472
|
+
* the target from the front (+Z), 90 from its right (+X), -90 from its
|
|
473
|
+
* left. Default -Infinity (no limit).
|
|
474
|
+
*/
|
|
475
|
+
minAzimuthAngle?: number;
|
|
476
|
+
/** Rightmost horizontal angle, in degrees (see minAzimuthAngle). Default Infinity. */
|
|
477
|
+
maxAzimuthAngle?: number;
|
|
478
|
+
/** An axis-aligned world-space box the camera's target can pan within. */
|
|
479
|
+
panBoundary?: [min: [number, number, number], max: [number, number, number]];
|
|
480
|
+
/** Keeps the camera itself, not just its target, inside panBoundary. Default false. */
|
|
481
|
+
boundaryEnclosesCamera?: boolean;
|
|
482
|
+
/** How strongly panning slows near panBoundary, 0–1. Default 0. */
|
|
483
|
+
boundaryFriction?: number;
|
|
484
|
+
};
|
|
485
|
+
|
|
455
486
|
/**
|
|
456
487
|
* Whether the viewer cuts motion that starts on its own: `"user"` follows the
|
|
457
488
|
* visitor's `prefers-reduced-motion` setting, `"always"` and `"never"` override
|
|
@@ -461,4 +492,4 @@ type ReducedMotionSetting = "user" | "always" | "never";
|
|
|
461
492
|
|
|
462
493
|
type ModelFormat = "glb" | "gltf" | "obj" | "fbx" | "usdz" | "stl" | "ply";
|
|
463
494
|
|
|
464
|
-
export { DEFAULT_MODEL_VIEWER_LABELS as D, type MaterialVariantGroup as M, type ReducedMotionSetting as R, type ViewerLoading as V, type MaterialVariantOption as a, type ModelFormat as b, type ModelViewerLabelKey as c, type ModelViewerLabels as d, type ViewerModelBounds as e, type ViewerModelInfo as f, type ViewerReveal as g, chooseMaterialVariant as h };
|
|
495
|
+
export { type CameraLimits as C, DEFAULT_MODEL_VIEWER_LABELS as D, type MaterialVariantGroup as M, type ReducedMotionSetting as R, type ViewerLoading as V, type MaterialVariantOption as a, type ModelFormat as b, type ModelViewerLabelKey as c, type ModelViewerLabels as d, type ViewerModelBounds as e, type ViewerModelInfo as f, type ViewerReveal as g, chooseMaterialVariant as h };
|
|
@@ -54,6 +54,7 @@ type ViewerModelInfo = {
|
|
|
54
54
|
declare const DEFAULT_MODEL_VIEWER_LABELS: {
|
|
55
55
|
readonly verifyingLicense: "Verifying License";
|
|
56
56
|
readonly checkingYourLicenseKey: "Checking your license key...";
|
|
57
|
+
readonly createDevelopmentKey: "Create a free development key";
|
|
57
58
|
readonly invalidLicense: "Invalid License";
|
|
58
59
|
readonly licenseHasBeenRevokedOrHasExpired: "License has been revoked or has expired";
|
|
59
60
|
readonly failedToLoadPleaseContactTheSiteAdministrator: "Failed to load. Please contact the site administrator.";
|
|
@@ -87,7 +88,8 @@ declare const DEFAULT_MODEL_VIEWER_LABELS: {
|
|
|
87
88
|
readonly arStartFailed: "Could not start AR. Check camera permissions and try again.";
|
|
88
89
|
readonly arAnimations: "AR animations";
|
|
89
90
|
readonly arAnimationSelect: "Animation";
|
|
90
|
-
readonly arAnimationSaved: "
|
|
91
|
+
readonly arAnimationSaved: "Default";
|
|
92
|
+
readonly arAnimationNone: "No animation";
|
|
91
93
|
readonly arAnimationClips: "Model clips";
|
|
92
94
|
readonly arAnimationSequences: "Sequences";
|
|
93
95
|
readonly arAnimationPlay: "Play animation";
|
|
@@ -362,6 +364,7 @@ declare const DEFAULT_MODEL_VIEWER_LABELS: {
|
|
|
362
364
|
readonly bindingMismatchMany: "{count} object bindings don't match this model";
|
|
363
365
|
readonly simpleLargeModelWarning: "Very large model detected ({millions}M triangles) — it may render and move slowly on this device, and click/hover selection on the model is disabled. Use the scene objects panel to select parts.";
|
|
364
366
|
readonly dropModelHint: "Drag and drop {formats} here";
|
|
367
|
+
readonly retryModelLoad: "Retry loading model";
|
|
365
368
|
readonly loadErrorTitle: "This model couldn't be loaded";
|
|
366
369
|
readonly loadErrorNotFound: "Nothing was found at this address ({status}). Check that modelUrl points to the file.";
|
|
367
370
|
readonly loadErrorDenied: "The server refused access to the file ({status}). Check that the file is public, or that a signed URL hasn't expired.";
|
|
@@ -452,6 +455,34 @@ type ViewerLoading = "lazy" | "eager";
|
|
|
452
455
|
*/
|
|
453
456
|
type ViewerReveal = "auto" | "interaction";
|
|
454
457
|
|
|
458
|
+
type CameraLimits = {
|
|
459
|
+
/** Closest the camera can get to its target, in scene units. Default 0. */
|
|
460
|
+
minDistance?: number;
|
|
461
|
+
/** Farthest the camera can get from its target, in scene units. Default Infinity. */
|
|
462
|
+
maxDistance?: number;
|
|
463
|
+
/**
|
|
464
|
+
* Lowest vertical angle, in degrees: 0 looks straight down from above, 90 is
|
|
465
|
+
* level with the target, 180 looks straight up from below. Default 0.
|
|
466
|
+
*/
|
|
467
|
+
minPolarAngle?: number;
|
|
468
|
+
/** Highest vertical angle, in degrees (see minPolarAngle). Default 180. */
|
|
469
|
+
maxPolarAngle?: number;
|
|
470
|
+
/**
|
|
471
|
+
* Leftmost horizontal angle, in degrees around the vertical axis: 0 views
|
|
472
|
+
* the target from the front (+Z), 90 from its right (+X), -90 from its
|
|
473
|
+
* left. Default -Infinity (no limit).
|
|
474
|
+
*/
|
|
475
|
+
minAzimuthAngle?: number;
|
|
476
|
+
/** Rightmost horizontal angle, in degrees (see minAzimuthAngle). Default Infinity. */
|
|
477
|
+
maxAzimuthAngle?: number;
|
|
478
|
+
/** An axis-aligned world-space box the camera's target can pan within. */
|
|
479
|
+
panBoundary?: [min: [number, number, number], max: [number, number, number]];
|
|
480
|
+
/** Keeps the camera itself, not just its target, inside panBoundary. Default false. */
|
|
481
|
+
boundaryEnclosesCamera?: boolean;
|
|
482
|
+
/** How strongly panning slows near panBoundary, 0–1. Default 0. */
|
|
483
|
+
boundaryFriction?: number;
|
|
484
|
+
};
|
|
485
|
+
|
|
455
486
|
/**
|
|
456
487
|
* Whether the viewer cuts motion that starts on its own: `"user"` follows the
|
|
457
488
|
* visitor's `prefers-reduced-motion` setting, `"always"` and `"never"` override
|
|
@@ -461,4 +492,4 @@ type ReducedMotionSetting = "user" | "always" | "never";
|
|
|
461
492
|
|
|
462
493
|
type ModelFormat = "glb" | "gltf" | "obj" | "fbx" | "usdz" | "stl" | "ply";
|
|
463
494
|
|
|
464
|
-
export { DEFAULT_MODEL_VIEWER_LABELS as D, type MaterialVariantGroup as M, type ReducedMotionSetting as R, type ViewerLoading as V, type MaterialVariantOption as a, type ModelFormat as b, type ModelViewerLabelKey as c, type ModelViewerLabels as d, type ViewerModelBounds as e, type ViewerModelInfo as f, type ViewerReveal as g, chooseMaterialVariant as h };
|
|
495
|
+
export { type CameraLimits as C, DEFAULT_MODEL_VIEWER_LABELS as D, type MaterialVariantGroup as M, type ReducedMotionSetting as R, type ViewerLoading as V, type MaterialVariantOption as a, type ModelFormat as b, type ModelViewerLabelKey as c, type ModelViewerLabels as d, type ViewerModelBounds as e, type ViewerModelInfo as f, type ViewerReveal as g, chooseMaterialVariant as h };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Object3D, Material } from 'three';
|
|
2
|
-
import { e as ViewerModelBounds, R as ReducedMotionSetting, d as ModelViewerLabels, V as ViewerLoading, g as ViewerReveal, b as ModelFormat, f as ViewerModelInfo } from './modelFileResolver-
|
|
2
|
+
import { e as ViewerModelBounds, R as ReducedMotionSetting, C as CameraLimits, d as ModelViewerLabels, V as ViewerLoading, g as ViewerReveal, b as ModelFormat, f as ViewerModelInfo } from './modelFileResolver-ChKYsF21.js';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
import { CameraControls } from '@react-three/drei';
|
|
5
5
|
|
|
@@ -369,6 +369,8 @@ type SceneLight = {
|
|
|
369
369
|
decay?: number;
|
|
370
370
|
angle?: number;
|
|
371
371
|
penumbra?: number;
|
|
372
|
+
/** Spot/directional aim point; unset aims at the origin (model centre with shadows). */
|
|
373
|
+
target?: [number, number, number];
|
|
372
374
|
attachedToCamera: boolean;
|
|
373
375
|
/** Follow a model object instead of using the world-space position. */
|
|
374
376
|
attachment?: SceneLightAttachment;
|
|
@@ -878,6 +880,8 @@ type AnimationClipState = {
|
|
|
878
880
|
reverse: boolean;
|
|
879
881
|
};
|
|
880
882
|
type AnimationPlaybackState = {
|
|
883
|
+
/** Playback intent is preserved while offscreen rendering is suspended. */
|
|
884
|
+
isRenderPaused?: boolean;
|
|
881
885
|
/** The clip played most recently, while it's active. */
|
|
882
886
|
currentClip: string | null;
|
|
883
887
|
/** Whether any clip is playing. */
|
|
@@ -906,6 +910,7 @@ type AnimationControls = {
|
|
|
906
910
|
subscribe?: (listener: (state: AnimationPlaybackState) => void) => () => void;
|
|
907
911
|
};
|
|
908
912
|
type ViewerAnimationsProps = {
|
|
913
|
+
isRenderPaused: boolean;
|
|
909
914
|
clips: string[];
|
|
910
915
|
clipDetails: AnimationClipInfo[];
|
|
911
916
|
currentClip: string | null;
|
|
@@ -1226,6 +1231,15 @@ type ObjectPointerEvent = {
|
|
|
1226
1231
|
surface?: ObjectSurfacePoint;
|
|
1227
1232
|
};
|
|
1228
1233
|
|
|
1234
|
+
type LicenseStatus = "checking" | "valid" | "invalid";
|
|
1235
|
+
interface LicenseResult {
|
|
1236
|
+
status: LicenseStatus;
|
|
1237
|
+
reason?: string;
|
|
1238
|
+
environment?: "development" | "production";
|
|
1239
|
+
tier?: string;
|
|
1240
|
+
isLocalDomain: boolean;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1229
1243
|
type ViewerProductOptions = {
|
|
1230
1244
|
/** Connects your own pricing, stock, cart and quote services. */
|
|
1231
1245
|
adapter?: ProductCommerceAdapter;
|
|
@@ -1532,34 +1546,6 @@ type ViewerEngagementEvent = {
|
|
|
1532
1546
|
reason: "stopped" | "restarted" | "annotations-changed" | "interrupted";
|
|
1533
1547
|
});
|
|
1534
1548
|
|
|
1535
|
-
type CameraLimits = {
|
|
1536
|
-
/** Closest the camera can get to its target, in scene units. Default 0. */
|
|
1537
|
-
minDistance?: number;
|
|
1538
|
-
/** Farthest the camera can get from its target, in scene units. Default Infinity. */
|
|
1539
|
-
maxDistance?: number;
|
|
1540
|
-
/**
|
|
1541
|
-
* Lowest vertical angle, in degrees: 0 looks straight down from above, 90 is
|
|
1542
|
-
* level with the target, 180 looks straight up from below. Default 0.
|
|
1543
|
-
*/
|
|
1544
|
-
minPolarAngle?: number;
|
|
1545
|
-
/** Highest vertical angle, in degrees (see minPolarAngle). Default 180. */
|
|
1546
|
-
maxPolarAngle?: number;
|
|
1547
|
-
/**
|
|
1548
|
-
* Leftmost horizontal angle, in degrees around the vertical axis: 0 views
|
|
1549
|
-
* the target from the front (+Z), 90 from its right (+X), -90 from its
|
|
1550
|
-
* left. Default -Infinity (no limit).
|
|
1551
|
-
*/
|
|
1552
|
-
minAzimuthAngle?: number;
|
|
1553
|
-
/** Rightmost horizontal angle, in degrees (see minAzimuthAngle). Default Infinity. */
|
|
1554
|
-
maxAzimuthAngle?: number;
|
|
1555
|
-
/** An axis-aligned world-space box the camera's target can pan within. */
|
|
1556
|
-
panBoundary?: [min: [number, number, number], max: [number, number, number]];
|
|
1557
|
-
/** Keeps the camera itself, not just its target, inside panBoundary. Default false. */
|
|
1558
|
-
boundaryEnclosesCamera?: boolean;
|
|
1559
|
-
/** How strongly panning slows near panBoundary, 0–1. Default 0. */
|
|
1560
|
-
boundaryFriction?: number;
|
|
1561
|
-
};
|
|
1562
|
-
|
|
1563
1549
|
type MouseControllerPosition = 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right' | 'center' | 'center-bottom' | 'center-top';
|
|
1564
1550
|
|
|
1565
1551
|
type XRScaleMode = "normalized" | "real-world";
|
|
@@ -1818,7 +1804,7 @@ type UseViewerCameraOptions = {
|
|
|
1818
1804
|
initialTarget?: [number, number, number];
|
|
1819
1805
|
/** Whether the initial position/target should animate. Defaults to false. */
|
|
1820
1806
|
initialTransition?: boolean;
|
|
1821
|
-
/**
|
|
1807
|
+
/** Initial named views, read once. Use setCameraPresets to load later edits. */
|
|
1822
1808
|
presets?: Record<string, ViewerCameraPreset>;
|
|
1823
1809
|
};
|
|
1824
1810
|
type HomeCameraState = {
|
|
@@ -1852,8 +1838,15 @@ type ViewerReadyState = {
|
|
|
1852
1838
|
};
|
|
1853
1839
|
};
|
|
1854
1840
|
type ViewerCameraProps = {
|
|
1841
|
+
/**
|
|
1842
|
+
* Rendering is suspended because the viewer is offscreen. Camera commands
|
|
1843
|
+
* still complete: they jump straight to their end instead of animating.
|
|
1844
|
+
*/
|
|
1845
|
+
isRenderPaused: boolean;
|
|
1855
1846
|
cameraState: ViewerCameraState | null;
|
|
1856
1847
|
cameraPresets: Record<string, ViewerCameraPreset>;
|
|
1848
|
+
/** Replace named views after loading or editing them; does not move the camera. */
|
|
1849
|
+
setCameraPresets: (presets: Record<string, ViewerCameraPreset>) => void;
|
|
1857
1850
|
resetView: () => Promise<boolean>;
|
|
1858
1851
|
focusObject: (objectId: string) => Promise<boolean>;
|
|
1859
1852
|
fitScene: () => Promise<boolean>;
|
|
@@ -1935,6 +1928,8 @@ type ModelViewerProps = GroupedModelViewerProps & {
|
|
|
1935
1928
|
/** Explicit format for extensionless or signed model URLs. */
|
|
1936
1929
|
modelFormat?: ModelFormat;
|
|
1937
1930
|
licenseKey: string;
|
|
1931
|
+
/** License state for application-owned loading and error interfaces. */
|
|
1932
|
+
onLicenseStatusChange?: (result: LicenseResult) => void;
|
|
1938
1933
|
hideLicenseCheckingOverlay?: boolean;
|
|
1939
1934
|
/**
|
|
1940
1935
|
* The model's interactive objects, keyed by node name. Defaults to `"auto"`:
|
|
@@ -1942,6 +1937,10 @@ type ModelViewerProps = GroupedModelViewerProps & {
|
|
|
1942
1937
|
* reported through `onObjectBindingsChange`.
|
|
1943
1938
|
*/
|
|
1944
1939
|
objectBindings?: Record<string, ObjectBinding> | "auto";
|
|
1940
|
+
/**
|
|
1941
|
+
* The selected object's binding (an `ObjectBinding`, not a three.js
|
|
1942
|
+
* `Object3D`). Pass `null` to control selection with nothing selected.
|
|
1943
|
+
*/
|
|
1945
1944
|
selectedObject?: ObjectBinding | null;
|
|
1946
1945
|
/** Transient bounds outlines for semantic comparison; never modify authored materials. */
|
|
1947
1946
|
comparisonHighlights?: readonly ComparisonHighlight[];
|
|
@@ -2157,4 +2156,4 @@ type ModelViewerModelEntry = {
|
|
|
2157
2156
|
sceneConfig?: SceneConfig;
|
|
2158
2157
|
};
|
|
2159
2158
|
|
|
2160
|
-
export {
|
|
2159
|
+
export { MATERIAL_SIDES as $, type ARExportOptions as A, type BindingEdit as B, type CameraAction as C, type ComparisonCategory as D, type ComparisonChange as E, type ComparisonHighlight as F, type ComparisonObject as G, type ComparisonStatus as H, type ConfigurationComparisonInput as I, type ConfigurationComparisonReport as J, type CustomObjectBindingDataPanelProps as K, type CustomSceneObjectsPanelProps as L, DEFAULT_SCENE_CONFIG as M, DEFAULT_SECTION_CONFIG as N, type DecalMoveTarget as O, type DeepPartial as P, type EnvironmentPreset as Q, type GlitchModeName as R, type GroupedModelViewerProps as S, type HomeCameraState as T, type InspectAssetOptions as U, type IsolatedObjectBindings as V, type IsolationActionEffect as W, type KernelSizeName as X, type LicenseResult as Y, type LicenseStatus as Z, MATERIAL_BLENDING_MODES as _, type ARHandoffOptions as a, type ProductPrice as a$, MAX_VIEWER_STATE_BYTES as a0, MODEL_VIEWER_PRESETS as a1, type MeasurementAnchor as a2, type MeasurementCollection as a3, type MeasurementPoint as a4, type MeasurementPosition as a5, type MeasurementResult as a6, type MeasurementSettings as a7, type MeasurementStatus as a8, type MeasurementTool as a9, type ObjectBindingTarget as aA, type ObjectBindingTextureChannel as aB, type ObjectBindingTextureSlot as aC, type ObjectBindingTransform as aD, type ObjectBindingType as aE, type ObjectBindingsActionEffect as aF, type ObjectPointerEvent as aG, type ObjectSurfacePoint as aH, type ObjectTransformSpace as aI, type PerformanceProfile as aJ, type ProductAppearance as aK, type ProductAvailability as aL, type ProductCheckoutContext as aM, type ProductCheckoutLink as aN, type ProductCommerceAdapter as aO, type ProductCommerceContext as aP, type ProductCommerceResult as aQ, type ProductConfiguration as aR, type ProductConfigurationIssue as aS, type ProductDefinition as aT, type ProductDefinitionWarning as aU, type ProductGroupDisplay as aV, type ProductOption as aW, type ProductOptionGroup as aX, type ProductOptionRef as aY, type ProductOptionRule as aZ, type ProductOptionState as a_, type MeasurementUnit as aa, type ModelMergeSource as ab, type ModelViewerControlsOptions as ac, type ModelViewerDecoderOptions as ad, type ModelViewerModelEntry as ae, type ModelViewerPerfOptions as af, type ModelViewerPreset as ag, type ModelViewerProps as ah, type ModelViewerTilesOptions as ai, type ModelViewerToolsOptions as aj, type ModelViewerUiOptions as ak, type ModelViewerXrOptions as al, type MouseControllerPosition as am, type ObjectActionEffect as an, type ObjectActionEvent as ao, type ObjectBinding as ap, type ObjectBindingAction as aq, type ObjectBindingCameraState as ar, type ObjectBindingDecal as as, type ObjectBindingMaterial as at, type ObjectBindingMaterialBlendingMode as au, type ObjectBindingMaterialSide as av, type ObjectBindingPatch as aw, type ObjectBindingSelector as ax, type ObjectBindingStatus as ay, type ObjectBindingStyle as az, type ARHandoffRequest as b, type ViewerCameraProps as b$, type ProductPricing as b0, type ProductSelections as b1, type ProductSku as b2, type RampTypeName as b3, type RendererBackend as b4, type SavedMeasurement as b5, type SceneAnimationClipConfig as b6, type SceneAnimationConfig as b7, type SceneAnnotationCameraView as b8, type SceneAnnotationImage as b9, type SceneSequence as bA, type SceneShadowConfig as bB, type SceneStyleColorScale as bC, type SceneStyleCondition as bD, type SceneStylePulse as bE, type SceneStyleRule as bF, type SceneWireframeConfig as bG, type SemanticComparisonOptions as bH, type SequenceCameraView as bI, type SequenceControls as bJ, type SequenceEasing as bK, type SequenceKeyframe as bL, type SequenceObjectProperty as bM, type SequencePlaybackState as bN, type SequenceTarget as bO, type SequenceTrack as bP, type SequenceValue as bQ, type SequenceVector3 as bR, type ShareableViewerState as bS, type StreamingDiagnostics as bT, type StyledObjectBindings as bU, type StyledObjectPulse as bV, type TexturePositioningControls as bW, type UseViewerCameraOptions as bX, type ViewerAnimationsProps as bY, type ViewerCameraConfig as bZ, type ViewerCameraPreset as b_, type SceneAnnotationLink as ba, type SceneAnnotationMarker as bb, type SceneBackgroundConfig as bc, type SceneCameraConfig as bd, type SceneCinematicConfig as be, type SceneCinematicWaypoint as bf, type SceneComposition as bg, type SceneConfig as bh, type SceneConfigActionEffect as bi, type SceneConfigPatch as bj, type SceneEnvironmentConfig as bk, type SceneGroundShadowConfig as bl, type SceneLight as bm, type SceneLightAttachment as bn, type SceneLightType as bo, type SceneLightingConfig as bp, type SceneModelConfig as bq, type SceneModelRenderer as br, type ScenePostProcessingConfig as bs, type SceneProductConfig as bt, type SceneSectionAxis as bu, type SceneSectionConfig as bv, type SceneSectionPlane as bw, type SceneSectionPreset as bx, type SceneSectionSettings as by, type SceneSelectionSet as bz, type ARHandoffStatus as c, type ViewerCameraState as c0, type ViewerConfiguration as c1, type ViewerEngagementEvent as c2, type ViewerIsolation as c3, type ViewerObjectInfo as c4, type ViewerProductOptions as c5, type ViewerReadyState as c6, type ViewerRuntimeStats as c7, type ViewerStateStorage as c8, type VisibilityActionEffect as c9, type XRScaleMode as ca, applyIsolation as cb, applyStyleRules as cc, colorScaleValue as cd, compareViewerConfigurations as ce, groundAsset as cf, isolatedBindingKeys as cg, material as ch, parseAssetTransform as ci, parseSelectionSets as cj, parseViewerState as ck, patchBindings as cl, patchSceneConfig as cm, prepareViewerState as cn, selectBindingKeys as co, selectBindings as cp, serializeViewerState as cq, snapAssetToGrid as cr, useViewerAnimations as cs, useViewerCamera as ct, type ARSnapshot as d, type ARSnapshotSource as e, type AnimationAction as f, type AnimationActionEffect as g, type AnimationClipInfo as h, type AnimationClipState as i, type AnimationClipStatus as j, type AnimationControls as k, type AnimationLoopMode as l, type AnimationPlayOptions as m, type AnimationPlaybackState as n, type AnnotationMarker as o, type AssetDiagnosticIssue as p, type AssetDiagnosticsReport as q, type AssetDiagnosticsSource as r, type AssetTextureDiagnostic as s, type AssetTransform as t, type CameraActionEffect as u, type CameraControllerType as v, type CaptureImageOptions as w, type CaptureVideoOptions as x, type CinematicConfig as y, type CinematicWaypoint as z };
|