@liveroom-tech/react-immersive 6.2.1 → 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/AnimationsTab-IKAAKT3P.mjs +1 -0
- package/dist/AnnotationsTab-NEJIXCOM.mjs +1 -0
- package/dist/CinematicTab-TIQXCPFE.mjs +1 -0
- package/dist/ConfigureTab-NYRMOFW4.mjs +6 -0
- package/dist/RulesTab-2U4MFYOZ.mjs +1 -0
- package/dist/SequencesTab-JZEE5WAM.mjs +1 -0
- package/dist/SequencesTab-O7USMDFP.css +1 -0
- package/dist/{StreamingTilesModel-6Z7SIC2J.mjs → StreamingTilesModel-IM2DDWO5.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 +45 -45
- package/dist/binding-builder.mjs +1 -1
- package/dist/chunk-37QOMZW6.mjs +1 -0
- package/dist/{chunk-NMRTI3NQ.mjs → chunk-3GA7JFNH.mjs} +1 -1
- package/dist/chunk-3I7PPFUV.mjs +1 -0
- package/dist/chunk-3PLML3PO.mjs +1 -0
- package/dist/chunk-5C4H7SRF.mjs +1 -0
- package/dist/chunk-CHMFH4D4.mjs +1 -0
- package/dist/chunk-CUDL77ZY.mjs +1 -0
- package/dist/{chunk-UTVFRMYW.mjs → chunk-IEKGBS46.mjs} +2 -2
- package/dist/chunk-LU3BQ7WG.mjs +69 -0
- package/dist/chunk-QZNUWZG7.mjs +50 -0
- package/dist/{chunk-3OCHN3CA.mjs → chunk-SOAUR4DL.mjs} +1 -1
- package/dist/chunk-SXN3YYD3.mjs +1 -0
- package/dist/chunk-TI2YXAHW.mjs +3 -0
- package/dist/exportSceneMesh-MSQIMBFF.mjs +1 -0
- package/dist/hosted.css +1 -1
- package/dist/hosted.d.mts +5 -3
- package/dist/hosted.d.ts +5 -3
- package/dist/hosted.js +44 -44
- package/dist/hosted.mjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.mts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +42 -42
- package/dist/index.mjs +1 -1
- package/dist/{modelFileResolver-CVmON8hg.d.mts → modelFileResolver-An1aQ0D3.d.mts} +42 -29
- package/dist/{modelFileResolver-CVmON8hg.d.ts → modelFileResolver-An1aQ0D3.d.ts} +42 -29
- package/dist/{modelViewerProps-BBnZTFO-.d.ts → modelViewerProps-BnVflYRA.d.mts} +22 -3
- package/dist/{modelViewerProps-CIY4nsNY.d.mts → modelViewerProps-H_K454u_.d.ts} +22 -3
- package/dist/{publicProps-BARVwXu7.d.ts → publicProps-AdNUI06n.d.ts} +1 -1
- package/dist/{publicProps-n0Yvr_Km.d.mts → publicProps-BOQBJBA_.d.mts} +1 -1
- package/dist/simple-model-viewer.css +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/AnimationsTab-NUJTEMZ5.mjs +0 -1
- package/dist/AnnotationsTab-OHRVWRKI.mjs +0 -1
- package/dist/CinematicTab-IJAY2BS6.mjs +0 -1
- package/dist/ConfigureTab-UQRRATCY.mjs +0 -6
- package/dist/RulesTab-YVBZGJZX.mjs +0 -1
- package/dist/SequencesTab-IC5LWQ6N.css +0 -1
- package/dist/SequencesTab-VZKEKAUG.mjs +0 -1
- package/dist/chunk-25WC5KDO.mjs +0 -50
- package/dist/chunk-7OVEHDDE.mjs +0 -1
- package/dist/chunk-AL6UIGWP.mjs +0 -1
- package/dist/chunk-KYXJG3TX.mjs +0 -1
- package/dist/chunk-LD7QWHB4.mjs +0 -3
- package/dist/chunk-RKDATTUM.mjs +0 -1
- package/dist/chunk-UAZ6I25Y.mjs +0 -1
- package/dist/chunk-UHRJ2RBF.mjs +0 -1
- package/dist/chunk-YKDDNX2D.mjs +0 -69
- package/dist/exportSceneMesh-YJFOLFHS.mjs +0 -1
package/dist/utils.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ce,b as se,c as pe}from"./chunk-F5QSXMME.mjs";import{$ as A,
|
|
1
|
+
import{a as ce,b as se,c as pe}from"./chunk-F5QSXMME.mjs";import{$ as x,A as s,Aa as re,B as p,Ba as ie,Fa as ae,G as u,Ha as ue,I as d,Ia as de,J as m,Ja as me,Ka as Se,La as le,T as S,V as l,X as f,Y as g,Z as C,_ as y,aa as P,ba as A,ca as H,da as F,ea as K,fa as W,ka as z,la as Q,qa as J,ra as Y,ta as Z,xa as te,y as a,ya as oe,z as c,za as ne}from"./chunk-QZNUWZG7.mjs";import{a as e,b as t,e as o,f as n,g as r}from"./chunk-LX3GXQNU.mjs";import{b,c as E,d as h,e as j,f as R,g as T,h as V,i as I,j as L,k as w,l as D,m as _,n as N,o as q,p as k,q as v,r as U,s as G}from"./chunk-7JCFNZJM.mjs";import"./chunk-37QOMZW6.mjs";import{b as $,c as ee}from"./chunk-CCBFMNAU.mjs";import{b as O,c as B}from"./chunk-GV4ZRXL6.mjs";import"./chunk-7OWHW66D.mjs";import{e as X}from"./chunk-KFLS7GI6.mjs";import{a as i}from"./chunk-3I7PPFUV.mjs";import{c as M}from"./chunk-BNKTI3CY.mjs";import"./chunk-UCD76KQ6.mjs";import"./chunk-RXZ4Q7CY.mjs";import"./chunk-JR557W27.mjs";export{Y as ACTION_CATALOG,i as DEFAULT_MODEL_VIEWER_LABELS,c as DEFAULT_SCENE_CONFIG,a as DEFAULT_SECTION_CONFIG,de as MATERIAL_BLENDING_MODES,ue as MATERIAL_SIDES,H as MAX_VIEWER_STATE_BYTES,S as MEASUREMENT_UNITS,t as SEQUENCE_EASINGS,e as SEQUENCE_OBJECT_PROPERTIES,oe as applyIsolation,G as applyProductOptions,ee as applyStyleRules,ie as buildBindingsFromNodes,f as calibrateMeasurements,M as chooseMaterialVariant,me as collectObjectHierarchy,$ as colorScaleValue,ae as compareViewerConfigurations,Se as copyBindingStyle,z as createARHandoffUrl,re as createDefaultBinding,D as decodeProductSelections,j as defaultProductSelections,pe as defineObjectBindings,w as encodeProductSelections,R as evaluateProductConfiguration,J as exportConfiguredUSDZ,Z as findCatalogAction,I as formatProductPrice,_ as generateProductSkus,m as groundAsset,ne as inferType,X as inspectAsset,te as isolatedBindingKeys,E as material,C as measurementResult,l as measurementScale,g as measurementValue,P as measurementsToCsv,u as parseAssetTransform,y as parseMeasurements,U as parseProductConfiguration,h as parseProductDefinition,k as parseSceneProduct,s as parseSectionConfig,A as parseSelectionSets,o as parseSequences,K as parseViewerState,le as pasteBindingStyle,b as patchBindings,ce as patchSceneConfig,W as prepareViewerState,L as productCheckoutUrl,N as productDefinitionWarnings,q as productOptionStates,V as productPriceFromDefinition,Q as readARHandoffUrl,T as resolveProductSelections,n as sampleSequenceTrack,se as sceneLight,p as sectionSnapshot,O as selectBindingKeys,B as selectBindings,x as serializeMeasurements,v as serializeProductConfiguration,F as serializeViewerState,d as snapAssetToGrid,r as upsertSequenceKeyframe};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@liveroom-tech/react-immersive",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,9 +27,11 @@
|
|
|
27
27
|
"require": "./dist/utils.js"
|
|
28
28
|
},
|
|
29
29
|
"./hosted": {
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
"liveroom-internal": {
|
|
31
|
+
"types": "./dist/hosted.d.ts",
|
|
32
|
+
"import": "./dist/hosted.mjs",
|
|
33
|
+
"require": "./dist/hosted.js"
|
|
34
|
+
}
|
|
33
35
|
},
|
|
34
36
|
"./styles.css": "./dist/index.css",
|
|
35
37
|
"./simple-model-viewer.css": "./dist/simple-model-viewer.css",
|
|
@@ -57,7 +59,7 @@
|
|
|
57
59
|
"typecheck": "tsc --noEmit -p .",
|
|
58
60
|
"lint": "eslint src",
|
|
59
61
|
"verify": "npm run typecheck && npm test",
|
|
60
|
-
"check:types": "tsc -p scripts/check-types && node scripts/check-types/exports.mjs",
|
|
62
|
+
"check:types": "tsc -p scripts/check-types && node scripts/check-types/exports.mjs && node scripts/check-types/hosted.mjs",
|
|
61
63
|
"test:browser": "playwright test --config validation/browser/playwright.config.ts",
|
|
62
64
|
"measure:bundle": "npm run build && node scripts/measure-bundle.mjs"
|
|
63
65
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as w,f as C,k as M,l as k}from"./chunk-AL6UIGWP.mjs";import{c as S,h as A,i as P}from"./chunk-FGAJ2UT7.mjs";import"./chunk-JR557W27.mjs";import{useMemo as q,useState as D}from"react";import{ChevronRight as I,EyeOff as V,Pause as L,Play as G,Rewind as J,Square as K}from"lucide-react";import{Fragment as Y,jsx as n,jsxs as i}from"react/jsx-runtime";var Q={playing:"Playing",paused:"Paused",finished:"Finished"};function R(o){let r=Number.isFinite(o)&&o>0?o:0;if(r<60)return`${r.toFixed(1)}s`;let u=Math.floor(r/60),m=(r%60).toFixed(1).padStart(4,"0");return`${u}:${m}`}function W(o){return Number.isFinite(o)?Math.min(3,Math.max(.1,Number(o.toFixed(2)))):1}function X({config:o,onChange:r,clipDetails:u,active:m,play:b,pause:y,stop:h,setSpeed:x,seek:T}){let v=S(A().tier,"animationConfig"),[c,$]=D(!1),F=q(()=>new Map(u.map(e=>[e.sourceName,e.duration])),[u]),f=o.animations.clips.filter(e=>!e.hidden),d=o.animations.clips.filter(e=>e.hidden),N=(e,a=o.animations.autoplayClip)=>{r({...o,animations:{clips:e(o.animations.clips),autoplayClip:a}})},g=(e,a)=>{N(t=>t.map(l=>l.sourceName===e?a(l):l))},B=(e,a)=>{g(e,t=>({...t,loopMode:a}))},z=(e,a)=>{let t=W(a);g(e,l=>({...l,speed:t})),m.some(l=>l.clip===e)&&x(t,e)},O=(e,a)=>{g(e,t=>({...t,displayName:a}))},H=e=>{let a=o.animations.autoplayClip===e?null:e;r({...o,animations:{...o.animations,autoplayClip:a}})},E=e=>{N(a=>a.map(t=>t.sourceName===e?{...t,hidden:!0}:t),o.animations.autoplayClip===e?null:o.animations.autoplayClip),m.some(a=>a.clip===e)&&h(e)},U=e=>{N(a=>a.map(t=>t.sourceName===e?{...t,hidden:!1}:t))};return o.animations.clips.length===0?n(C,{title:"Clips",children:n("div",{className:"se-helperCard",children:"This model has no animation clips. Open one that does to set playback, names, and autoplay here."})}):i(C,{title:"Clips",children:[v?null:n(P,{requiredTier:"starter",feature:"Autoplay, looping, speed and clip names"}),f.length===0?n("p",{className:"se-listEmpty",children:"All clips are hidden. Show one below to use it again."}):n("div",{className:"se-animationList",children:f.map(e=>{let a=m.find(s=>s.clip===e.sourceName),t=a?.status==="playing",l=a?.time??0,p=F.get(e.sourceName)??0,_=a?Q[a.status]:"Ready";return i("article",{className:`se-clip ${a?"se-clip--active":""}`,children:[i("div",{className:"se-clipHeader",children:[n("input",{className:"se-clipName","aria-label":`Name of ${e.sourceName}`,title:e.sourceName,value:e.displayName,onChange:s=>O(e.sourceName,s.target.value),placeholder:e.sourceName}),o.animations.autoplayClip===e.sourceName?n("span",{className:"rui-chip",children:"Autoplay"}):null,n("span",{className:"rui-chip",children:_}),n("button",{type:"button",className:"se-iconButton",onClick:()=>E(e.sourceName),title:"Hide clip","aria-label":`Hide ${e.sourceName}`,children:n(V,{size:13})})]}),i("div",{className:"se-clipTransport",children:[n("button",{type:"button",className:"se-iconButton",onClick:()=>t&&!a?.reverse?y(e.sourceName):b(e.sourceName,{alongside:!0}),"aria-label":t&&!a?.reverse?"Pause":"Play",title:t&&!a?.reverse?"Pause":"Play",children:t&&!a?.reverse?n(L,{size:13}):n(G,{size:13})}),n("button",{type:"button",className:"se-iconButton",onClick:()=>t&&a?.reverse?y(e.sourceName):b(e.sourceName,{alongside:!0,reverse:!0}),"aria-label":t&&a?.reverse?"Pause":"Play backwards",title:t&&a?.reverse?"Pause":"Play backwards",children:t&&a?.reverse?n(L,{size:13}):n(J,{size:13})}),n("button",{type:"button",className:"se-iconButton",onClick:()=>h(e.sourceName),disabled:!a,"aria-label":"Stop",title:"Stop",children:n(K,{size:13})}),n("input",{className:"se-slider se-clipSeek",type:"range",min:0,max:Math.max(p,.001),step:.01,value:Math.min(l,p),disabled:!a||p<=0,onChange:s=>T(Number(s.target.value),e.sourceName),"aria-label":"Seek"}),i("code",{className:"se-clipTime",children:[R(Math.min(l,p))," / ",R(p)]})]}),v?i(Y,{children:[n(w,{label:"Loop",path:"sceneConfig.animations.clips[\u2026].loopMode",children:i("select",{className:"se-select",value:e.loopMode,onChange:s=>B(e.sourceName,s.target.value),children:[n("option",{value:"repeat",children:"Loop"}),n("option",{value:"once",children:"Play once"}),n("option",{value:"ping-pong",children:"Ping-pong"})]})}),n(M,{label:"Speed",path:"sceneConfig.animations.clips[\u2026].speed",value:e.speed,min:.1,max:3,step:.1,formatValue:s=>`${s.toFixed(2)}x`,onChange:s=>z(e.sourceName,s)}),n(k,{label:"Autoplay",path:"sceneConfig.animations.autoplayClip",checked:o.animations.autoplayClip===e.sourceName,onChange:()=>H(e.sourceName)})]}):null]},e.sourceName)})}),d.length>0?i("section",{className:"se-removedAnimations",children:[n("div",{className:"se-panelHeaderRow",children:i("button",{type:"button",className:"se-panelHeader","aria-expanded":c,onClick:()=>$(e=>!e),children:[n(I,{size:13,className:`se-panelChevron ${c?"se-panelChevron--open":""}`}),i("span",{className:"se-panelTitle",children:["Hidden clips (",d.length,")"]})]})}),c?n("div",{className:"rui-list",children:d.map(e=>i("div",{className:"rui-listRow",children:[i("span",{className:"rui-listRowMain",children:[n("span",{className:"rui-listRowTitle",children:e.displayName||e.sourceName}),n("code",{className:"rui-listRowMeta",children:e.sourceName})]}),n("button",{type:"button",className:"bb-button bb-button--small",onClick:()=>U(e.sourceName),children:"Show"})]},e.sourceName))}):null]}):null]})}export{X as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as f}from"./chunk-FXV4CLAK.mjs";import{b as u,c as L,d as M,e as c}from"./chunk-AL6UIGWP.mjs";import{a as k,e as B}from"./chunk-7OWHW66D.mjs";import"./chunk-JR557W27.mjs";import{useState as v}from"react";import{Eye as I,Pencil as E,Plus as V,Trash2 as G,X as P}from"lucide-react";import{Fragment as $,jsx as t,jsxs as o}from"react/jsx-runtime";function H({config:r,onChange:w,cameraState:N,onPreviewView:b}){let[a,n]=v(null),[h,y]=v(""),[C,R]=v(""),z=e=>{n(structuredClone(e)),y(e.minDistance?.toString()??""),R(e.maxDistance?.toString()??"")},p=h.trim()===""?void 0:Number(h),d=C.trim()===""?void 0:Number(C),g=[p,d].some(e=>e!==void 0&&(!Number.isFinite(e)||e<0))?"Distances must be non-negative numbers.":p!==void 0&&d!==void 0&&p>d?"Maximum distance must be at least the minimum.":a?.images?.some(e=>e.src.trim()&&!k(e.src))||a?.links?.some(e=>e.href.trim()&&!k(e.href))?"Use an HTTP(S) URL or a relative path for images and links.":null,T=()=>{if(!a?.title.trim()||g)return;let e={...a,title:a.title.trim(),category:a.category?.trim()||void 0,minDistance:p,maxDistance:d,images:a.images?.filter(i=>i.src.trim()).map(i=>({...i,src:i.src.trim()})),links:a.links?.filter(i=>i.href.trim()).map(i=>({...i,href:i.href.trim(),label:i.label.trim()||"Learn more"}))};w({...r,annotations:r.annotations.map(i=>i.id===a.id?e:i)}),n(null)},[D,m]=v(null),F=e=>{w({...r,annotations:r.annotations.filter(i=>i.id!==e).map((i,l)=>({...i,id:l+1}))}),n(null)},S=(e,i)=>a&&n({...a,images:a.images.map((l,s)=>s===e?{...l,...i}:l)}),A=(e,i)=>a&&n({...a,links:a.links.map((l,s)=>s===e?{...l,...i}:l)});return o("div",{className:"se-annotations",children:[t(M,{title:"Annotations",children:t("span",{className:"se-listHeaderHint",children:"Double-click the model to add"})}),D!==null?t(f,{title:"Delete this annotation?",onCancel:()=>m(null),footer:o($,{children:[t("button",{type:"button",className:"bb-dialogButton",onClick:()=>m(null),children:"Cancel"}),t("button",{type:"button",className:"bb-dialogButton bb-dialogButton--danger",autoFocus:!0,onClick:()=>{F(D),m(null)},children:"Delete"})]}),children:t("p",{children:"You can undo this."})}):null,r.annotations.length===0?t("p",{className:"se-listEmpty",children:"No annotations yet."}):t("div",{className:"rui-list",children:r.annotations.map(e=>o("div",{className:"rui-listRow",children:[t("span",{className:"rui-listRowIndex",children:e.id}),o("span",{className:"rui-listRowMain",children:[t("span",{className:"rui-listRowTitle",title:e.title,children:e.title}),e.description||e.category?.trim()?t("span",{className:"rui-listRowMeta",title:e.description,children:[e.category?.trim(),e.description].filter(Boolean).join(" \xB7 ")}):null]}),o("span",{className:"rui-listRowActions",children:[B(e.cameraView)&&t("button",{type:"button",className:"se-iconButton",disabled:!b,onClick:()=>b?.(e.cameraView),title:"Preview saved view","aria-label":`Preview saved view for ${e.title}`,children:t(I,{size:13,"aria-hidden":"true"})}),t("button",{type:"button",className:"se-iconButton",onClick:()=>z(e),title:"Edit annotation","aria-label":`Edit ${e.title}`,children:t(E,{size:13,"aria-hidden":"true"})}),t("button",{type:"button",className:"se-iconButton",onClick:()=>m(e.id),title:"Delete annotation","aria-label":`Delete ${e.title}`,children:t(G,{size:13,"aria-hidden":"true"})})]})]},e.id))}),a&&t(f,{title:"Edit annotation",onCancel:()=>n(null),footer:o($,{children:[t("button",{type:"button",className:"bb-dialogButton bb-dialogFooterStart",onClick:()=>{m(a.id),n(null)},children:"Delete"}),t("button",{type:"button",className:"bb-dialogButton",onClick:()=>n(null),children:"Cancel"}),t("button",{type:"button",className:"bb-dialogButton bb-dialogButton--primary",disabled:!a.title.trim()||!!g,onClick:T,children:"Save"})]}),children:o("div",{className:"rui-dialogRows",children:[t(u,{label:"Title",children:t("input",{className:"bb-input",autoFocus:!0,value:a.title,onChange:e=>n({...a,title:e.target.value})})}),t(u,{label:"Description",children:t("textarea",{className:"bb-textarea bb-textarea--short",rows:2,value:a.description,onChange:e=>n({...a,description:e.target.value})})}),t(u,{label:"Category",children:t("input",{className:"bb-input",value:a.category??"",placeholder:"Features",onChange:e=>n({...a,category:e.target.value})})}),t(u,{label:"Position",children:t("code",{className:"rui-readout",children:a.worldPosition.map(e=>e.toFixed(2)).join(", ")})}),o(c,{title:"Camera view",children:[t("p",{className:"rui-note",children:a.cameraView?"Tours fly to this view.":"Tours zoom in on the marker unless you capture a view."}),o(L,{children:[t("button",{type:"button",className:"bb-button",disabled:!N,onClick:()=>N&&n({...a,cameraView:structuredClone(N)}),children:"Capture"}),t("button",{type:"button",className:"bb-button",disabled:!a.cameraView||!b,onClick:()=>a.cameraView&&b?.(a.cameraView),children:"Preview"}),t("button",{type:"button",className:"bb-button",disabled:!a.cameraView,onClick:()=>n({...a,cameraView:void 0}),children:"Clear"})]})]}),t(c,{title:"Visible between",children:t(u,{label:"Distance",title:"In scene units. Leave blank to show the marker at any distance.",children:o("span",{className:"rui-pair",children:[t("input",{className:"bb-input",type:"number",min:"0",step:"any","aria-label":"Minimum distance",placeholder:"Min",value:h,onChange:e=>y(e.target.value)}),t("input",{className:"bb-input",type:"number",min:"0",step:"any","aria-label":"Maximum distance",placeholder:"Max",value:C,onChange:e=>R(e.target.value)})]})})}),t(c,{title:"Images",actions:t("button",{type:"button",className:"se-iconButton",title:"Add image","aria-label":"Add image",onClick:()=>n({...a,images:[...a.images??[],{src:"",alt:""}]}),children:t(V,{size:14})}),children:a.images?.map((e,i)=>o("div",{className:"rui-mediaRow",children:[t("input",{className:"bb-input","aria-label":`Image URL ${i+1}`,placeholder:"https://example.com/image.jpg",value:e.src,onChange:l=>S(i,{src:l.target.value})}),t("input",{className:"bb-input","aria-label":`Image description ${i+1}`,placeholder:"Description",value:e.alt??"",onChange:l=>S(i,{alt:l.target.value})}),t("button",{type:"button",className:"se-iconButton",title:"Remove image","aria-label":`Remove image ${i+1}`,onClick:()=>n({...a,images:a.images.filter((l,s)=>s!==i)}),children:t(P,{size:13})})]},i))}),t(c,{title:"Links",actions:t("button",{type:"button",className:"se-iconButton",title:"Add link","aria-label":"Add link",onClick:()=>n({...a,links:[...a.links??[],{href:"",label:""}]}),children:t(V,{size:14})}),children:a.links?.map((e,i)=>o("div",{className:"rui-mediaRow",children:[t("input",{className:"bb-input","aria-label":`Link URL ${i+1}`,placeholder:"https://example.com/details",value:e.href,onChange:l=>A(i,{href:l.target.value})}),t("input",{className:"bb-input","aria-label":`Link label ${i+1}`,placeholder:"Learn more",value:e.label,onChange:l=>A(i,{label:l.target.value})}),t("button",{type:"button",className:"se-iconButton",title:"Remove link","aria-label":`Remove link ${i+1}`,onClick:()=>n({...a,links:a.links.filter((l,s)=>s!==i)}),children:t(P,{size:13})})]},i))}),g?t("p",{className:"bb-note bb-note--error",role:"alert",children:g}):null]})})]})}export{H as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as A,d as h,k as C,l as d}from"./chunk-AL6UIGWP.mjs";import{a as N}from"./chunk-37YITTIK.mjs";import"./chunk-JR557W27.mjs";import{useState as T,useCallback as p}from"react";import{ArrowDown as M,ArrowUp as E,MapPin as F,Plus as L,Trash2 as B}from"lucide-react";import{jsx as n,jsxs as m}from"react/jsx-runtime";var I={enabled:!0,waypoints:[],loop:!0,autoPlay:!1},b=3.5;function U({config:g,onChange:w,cameraState:r,onPreviewWaypoint:f}){let i=g.cinematic??I,W=N(),{waypoints:o}=i,u=p((t,e)=>{if(t.length<2)return 0;let s=0;for(let a=0;a<t.length-1;a++){let c=t[a].segmentDuration??b;s+=c}return e&&t.length>1&&(s+=t[t.length-1].segmentDuration??b),Math.max(s,0)},[]),l=p(t=>{w({...g,cinematic:{...i,...t}})},[g,i,w]),R=p(()=>{if(!r)return;let t={position:[...r.position],target:[...r.target],...r.azimuthAngle!=null?{azimuthAngle:r.azimuthAngle}:{},...r.polarAngle!=null?{polarAngle:r.polarAngle}:{},segmentDuration:b},e=[...o,t],s=u(e,i.loop);l({waypoints:e,duration:s})},[r,o,i.loop,u,l]),k=p(t=>{let e=o.filter((a,c)=>c!==t),s=u(e,i.loop);l({waypoints:e,duration:s})},[o,i.loop,u,l]),v=p((t,e)=>{let s=t+e;if(s<0||s>=o.length)return;let a=[...o];[a[t],a[s]]=[a[s],a[t]];let c=u(a,i.loop);l({waypoints:a,duration:c})},[o,i.loop,u,l]),z=p((t,e)=>{let s=o.map((c,P)=>P===t?{...c,...e}:c),a=u(s,i.loop);l({waypoints:s,duration:a})},[o,i.loop,u,l]),[y,S]=T(!1),_=o.some(t=>t.segmentDuration!==void 0),$=p(t=>t>=o.length-1?b:o[t]?.segmentDuration??b,[o]),D=o.length>=2;return m("div",{className:"se-cinematic",children:[m("div",{className:"se-cinematicSettings",children:[n(h,{title:"Playback"}),n(d,{label:"Enabled",path:"sceneConfig.cinematic.enabled",checked:i.enabled,onChange:t=>l({enabled:t})}),n(d,{label:"Loop",path:"sceneConfig.cinematic.loop",checked:i.loop,onChange:t=>{l({loop:t,duration:u(o,t)})}}),n(d,{label:"Autoplay",path:"sceneConfig.cinematic.autoPlay",checked:i.autoPlay,onChange:t=>l({autoPlay:t})}),i.autoPlay&&W?n("p",{className:"rui-note",children:"Your device reduces motion, so this preview won't play on its own. Visitors without that setting will see it."}):null,n(d,{label:"Segment timing",checked:y,onChange:S}),!y&&D?n(C,{label:"Duration",path:"sceneConfig.cinematic.duration",value:i.duration??u(o,i.loop),min:4,max:120,step:1,formatValue:t=>`${t}s`,onChange:t=>l({duration:t})}):n(A,{label:"Total",children:n("code",{className:"rui-readout",children:D?`${(i.duration??u(o,i.loop)).toFixed(1)}s`:"Add at least 2 waypoints"})})]}),m("div",{className:"se-cinematicWaypoints",children:[n(h,{title:`Waypoints${o.length?` (${o.length})`:""}`,children:m("button",{type:"button",className:"bb-button bb-button--small",onClick:R,disabled:!r,title:"Capture the current camera view as a waypoint",children:[n(L,{size:13,"aria-hidden":"true"}),"Add from view"]})}),o.length===0?n("p",{className:"se-listEmpty",children:"Frame the model, then add it as a waypoint. The camera glides through them in order."}):n("div",{className:"rui-list",children:o.map((t,e)=>{let s=e===o.length-1;return m("div",{children:[m("div",{className:"rui-listRow",children:[n("span",{className:"rui-listRowIndex",children:e+1}),n("span",{className:"rui-listRowMain",children:n("code",{className:"rui-listRowCode",title:"Camera position",children:t.position.map(a=>a.toFixed(2)).join(", ")})}),m("span",{className:"rui-listRowActions rui-listRowActions--visible",children:[n("button",{type:"button",className:"se-iconButton",disabled:!f,onClick:()=>f?.(t),title:"Fly to this waypoint","aria-label":`Fly to waypoint ${e+1}`,children:n(F,{size:13})}),n("button",{type:"button",className:"se-iconButton",disabled:e===0,onClick:()=>v(e,-1),title:"Move up","aria-label":`Move waypoint ${e+1} up`,children:n(E,{size:13})}),n("button",{type:"button",className:"se-iconButton",disabled:s,onClick:()=>v(e,1),title:"Move down","aria-label":`Move waypoint ${e+1} down`,children:n(M,{size:13})}),n("button",{type:"button",className:"se-iconButton",onClick:()=>k(e),title:"Delete waypoint","aria-label":`Delete waypoint ${e+1}`,children:n(B,{size:13})})]})]}),y&&!s?n(C,{label:`${e+1} \u2192 ${e+2}`,path:"sceneConfig.cinematic.waypoints[\u2026].segmentDuration",value:$(e),min:1,max:20,step:.5,formatValue:a=>`${a.toFixed(1)}s`,onChange:a=>z(e,{segmentDuration:a})}):null]},`waypoint-${e}`)})})]})]})}export{U as default};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{b as B,d as X,g as q,l as Q,m as le,o as ce}from"./chunk-AL6UIGWP.mjs";import{c as Ne,e as ke,f as we,h as Oe,i as _}from"./chunk-FGAJ2UT7.mjs";import{d as re,e as fe,f as ve,m as ye,n as Ce}from"./chunk-7JCFNZJM.mjs";import"./chunk-GV4ZRXL6.mjs";import"./chunk-BNKTI3CY.mjs";import"./chunk-JR557W27.mjs";import{useEffect as ne,useState as T}from"react";import{ArrowDown as Me,ArrowUp as Be,Check as qe,ChevronRight as ze,Copy as De,Crosshair as Ee,EyeOff as je,MousePointerClick as Ue,Palette as Ke,Play as Le,Plus as pe,Trash2 as ee,X as Fe}from"lucide-react";import{Fragment as Z,jsx as t,jsxs as c}from"react/jsx-runtime";var Je=["list","chips","swatches"],de=["USD","EUR","GBP","SGD","AUD","CAD","INR","JPY"],We="https://shop.example.com/cart/add?sku={sku}&qty={quantity}";function te(o,n){let r=1;for(;n.includes(`${o}-${r}`);)r++;return`${o}-${r}`}function z(o,n,r){let a=o.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||n;return r.includes(a)?te(a,r):a}function Pe(o,n="New choice"){return{id:z(n,"choice",o),label:n,required:!0,defaultOptionId:"option-1",options:[{id:"option-1",label:"Option 1"},{id:"option-2",label:"Option 2"}]}}function oe(o,n){return o[n]?.label||n}function Ae(o){let n=o?.style?.material?.baseColor;return typeof n=="string"&&/^#[0-9a-f]{3,8}$/i.test(n)?n:"#888888"}function Se(o,n,r){let a=`${oe(o,n)} color`,h=Ae(o[n]);return{id:z(a,"color",r),label:a,required:!0,display:"swatches",defaultOptionId:"original",options:[{id:"original",label:"Original",swatch:h},{id:"color-2",label:"New color",swatch:"#2457c5",appearance:[{target:n,material:{baseColor:"#2457c5"}}]}]}}function Ie(o,n,r){let a=oe(o,n);return{id:z(a,"part",r),label:a,required:!0,display:"chips",defaultOptionId:"included",options:[{id:"included",label:"Included",appearance:[{target:n,visible:!0}]},{id:"not-included",label:"Not included",appearance:[{target:n,visible:!1}]}]}}function Ve(o){try{return new Intl.NumberFormat(void 0,{style:"currency",currency:o}).resolvedOptions().maximumFractionDigits??2}catch{return 2}}function He(o){return typeof o=="string"?`object:${o}`:Array.isArray(o)?`object:${o[0]??""}`:"group"in o?`group:${o.group}`:"tag"in o?`tag:${o.tag}`:"type"in o?`type:${o.type}`:""}function Ye(o){let n=o.indexOf(":"),r=o.slice(0,n),a=o.slice(n+1);return r==="group"?{group:a}:r==="tag"?{tag:a}:r==="type"?{type:a}:a}function _e(o){let n=Object.entries(o).filter(([,a])=>!a.removed),r=a=>[...new Set(a.filter(h=>!!h))].sort();return{groups:r(n.map(([,a])=>a.group)),tags:r(n.flatMap(([,a])=>a.tags??[])),objects:n.map(([a,h])=>({key:a,label:h.label||a}))}}function $({label:o,value:n,placeholder:r,onCommit:a,path:h}){let[w,v]=T(n);ne(()=>v(n),[n]);let N=()=>{w.trim()!==n&&a(w.trim())};return t(B,{label:o,path:h,children:t("input",{className:"se-textInput","aria-label":o,value:w,placeholder:r,onChange:m=>v(m.target.value),onBlur:N,onKeyDown:m=>{m.key==="Enter"&&N()}})})}function Te({label:o,valueMinor:n,currency:r,signed:a,onCommit:h,path:w}){let v=Ve(r),N=n===void 0?"":(n/10**v).toFixed(v),[m,M]=T(N);ne(()=>M(N),[N]);let O=()=>{if(m.trim()===N)return;let y=Number(m);if(!m.trim()||!Number.isFinite(y)||!a&&y<0){M(N),m.trim()||h(void 0);return}h(Math.round(y*10**v))};return t(B,{label:o,path:w,children:c("span",{className:"se-productMoney",children:[t("input",{className:"se-textInput","aria-label":o,inputMode:"decimal",value:m,placeholder:"0",onChange:y=>M(y.target.value),onBlur:O,onKeyDown:y=>{y.key==="Enter"&&O()}}),t("span",{children:r})]})})}function P({label:o,onClick:n,disabled:r,children:a}){return t("button",{type:"button",className:"se-iconButton","aria-label":o,title:o,disabled:r,onClick:n,children:a})}function ue(o,n,r){let a=[...o],[h]=a.splice(n,1);return a.splice(n+r,0,h),a}function Xe(o){return o.visible===!1?"hide":o.visible===!0?"show":"color"}function Qe({edit:o,bindings:n,selectedKey:r,onChange:a,onRemove:h}){let{groups:w,tags:v,objects:N}=_e(n),m=He(o.target),M=m.startsWith("group:")?w.includes(m.slice(6)):m.startsWith("tag:")?v.includes(m.slice(4)):m.startsWith("object:")?N.some(u=>u.key===m.slice(7)):!1,O=Xe(o),y=o.material?.baseColor;return c("div",{className:"se-productChange",children:[t(B,{label:"Part",children:c("span",{className:"se-productInline",children:[c("select",{className:"se-select","aria-label":"Part of the model",value:m,onChange:u=>a({...o,target:Ye(u.target.value)}),children:[M?null:t("option",{value:m,children:m||"Choose a part"}),t("optgroup",{label:"Objects",children:N.map(u=>t("option",{value:`object:${u.key}`,children:u.label},u.key))}),w.length?t("optgroup",{label:"Groups",children:w.map(u=>t("option",{value:`group:${u}`,children:u},u))}):null,v.length?t("optgroup",{label:"Tags",children:v.map(u=>t("option",{value:`tag:${u}`,children:u},u))}):null]}),r&&m!==`object:${r}`?t(P,{label:`Use the selected object: ${oe(n,r)}`,onClick:()=>a({...o,target:r}),children:t(Ee,{size:13})}):null,t(P,{label:"Remove this change",onClick:h,children:t(Fe,{size:13})})]})}),t(B,{label:"Does",children:c("select",{className:"se-select","aria-label":"What this does",value:O,onChange:u=>{let k=u.target.value;a(k==="color"?{target:o.target,material:{...o.material,baseColor:typeof y=="string"?y:"#888888"}}:{target:o.target,visible:k==="show"})},children:[t("option",{value:"color",children:"Changes its color"}),t("option",{value:"hide",children:"Hides it"}),t("option",{value:"show",children:"Shows it"})]})}),O==="color"?t(ce,{label:"Color",value:typeof y=="string"?y:"#888888",onChange:u=>a({...o,material:{...o.material,baseColor:u}})}):null]})}function Ze({group:o,option:n,index:r,definition:a,bindings:h,variantGroups:w,canSell:v,selectedKey:N,isStart:m,isShown:M,open:O,onToggleOpen:y,onSetStart:u,onChange:k,onRemove:E,onMove:j,onDuplicate:F}){let D=n.appearance??[],U=w.flatMap(p=>p.variants.map(R=>R.name)),K=N??Object.keys(h)[0]??"",x=[m?"customers start here":"",!D.length&&!n.variants?.length?"changes nothing":""].filter(Boolean).join(" \xB7 "),L=p=>{let R=n.appearance?.[0]?.material?.baseColor,S=p[0]?.material?.baseColor,I=n.swatch!==void 0&&n.swatch===R&&typeof S=="string";k({appearance:p.length?p:void 0,...I?{swatch:S}:{}})};return c("div",{className:`se-productOption ${O?"se-productOption--open":""} ${M?"se-productOption--shown":""}`,children:[t("div",{className:"se-productOptionHeader",children:c("button",{type:"button",className:"se-productOptionToggle","aria-expanded":O,title:"Edit this option and show it on the model",onClick:y,children:[t(ze,{size:12,"aria-hidden":"true",className:O?"se-productChevron--open":""}),n.swatch?t("span",{className:"se-productSwatch",style:{background:n.swatch},"aria-hidden":"true"}):null,t("span",{className:"se-productOptionName",children:n.label}),x?t("small",{children:x}):null]})}),O?c("div",{className:"se-productOptionBody",children:[t($,{label:"Name",value:n.label,onCommit:p=>{p&&k({label:p})}}),v&&a.pricing?t(Te,{label:"Price change",signed:!0,currency:a.pricing.currency,valueMinor:n.priceDeltaMinor,onCommit:p=>k({priceDeltaMinor:p})}):null,D.map((p,R)=>t(Qe,{edit:p,bindings:h,selectedKey:N,onChange:S=>L(D.map((I,C)=>C===R?S:I)),onRemove:()=>L(D.filter((S,I)=>I!==R))},R)),c("div",{className:"se-productActions",children:[c("button",{type:"button",className:"bb-button",disabled:!K,onClick:()=>L([...D,{target:K,material:{baseColor:Ae(h[K])}}]),children:[t(pe,{size:13,"aria-hidden":"true"})," ",D.length?"Change another part":"Change a part"]}),m?null:t("button",{type:"button",className:"bb-button",onClick:u,children:"Start here"})]}),c("details",{className:"se-productMore",children:[t("summary",{children:"More"}),t($,{label:"Description",value:n.description??"",placeholder:"Shown under the name",onCommit:p=>k({description:p||void 0})}),t(Q,{label:"Swatch",checked:!!n.swatch,onChange:p=>k({swatch:p?"#888888":void 0})}),n.swatch?t(ce,{label:"Swatch color",value:n.swatch,onChange:p=>k({swatch:p})}):null,U.length?t(B,{label:"Material variant",children:c("select",{className:"se-select","aria-label":"Material variant",value:n.variants?.[0]??"",onChange:p=>k({variants:p.target.value?[p.target.value]:void 0}),children:[t("option",{value:"",children:"None"}),U.map(p=>t("option",{value:p,children:p},p))]})}):null,v?t($,{label:"SKU",value:n.sku??"",placeholder:"Your stock code",onCommit:p=>k({sku:p||void 0})}):null,c("div",{className:"se-productActions",children:[t(P,{label:`Move ${n.label} up`,disabled:r===0,onClick:()=>j(-1),children:t(Be,{size:13})}),t(P,{label:`Move ${n.label} down`,disabled:r===o.options.length-1,onClick:()=>j(1),children:t(Me,{size:13})}),t(P,{label:`Duplicate ${n.label}`,onClick:F,children:t(De,{size:13})}),t(P,{label:`Delete ${n.label}`,disabled:o.options.length<=1,onClick:E,children:t(ee,{size:13})})]})]})]}):null]})}function Re(o,n){let r=o.groups.find(a=>a.id===n.groupId);return`${r?.label??n.groupId}: ${r?.options.find(a=>a.id===n.optionId)?.label??n.optionId}`}function $e({bindings:o,selectedKey:n,disabled:r,onColor:a,onVisibility:h}){return!n||!o[n]?c("p",{className:"se-productHint",children:[t(Ue,{size:14,"aria-hidden":"true"}),"Click a part of the model to let customers change it."]}):c("div",{className:"se-productStarter",children:[c("p",{children:["Let customers change ",t("strong",{children:oe(o,n)}),":"]}),c("div",{className:"se-productActions",children:[c("button",{type:"button",className:"bb-button",disabled:r,onClick:()=>a(n),children:[t(Ke,{size:13,"aria-hidden":"true"})," Its color"]}),c("button",{type:"button",className:"bb-button",disabled:r,onClick:()=>h(n),children:[t(je,{size:13,"aria-hidden":"true"})," Show or hide it"]})]})]})}function et({code:o}){let[n,r]=T(!1);return ne(()=>{if(!n)return;let a=setTimeout(()=>r(!1),2e3);return()=>clearTimeout(a)},[n]),c("div",{className:"se-productCode",children:[t("pre",{children:o}),t(P,{label:n?"Copied":"Copy code",onClick:()=>{navigator.clipboard.writeText(o).then(()=>r(!0)).catch(()=>{})},children:n?t(qe,{size:13}):t(De,{size:13})})]})}function tt({config:o,onChange:n,objectBindings:r,materialVariantGroups:a,selectedKey:h,previewSelections:w,onPreviewChange:v,onPreviewAsCustomer:N,publish:m,modelFileName:M}){let{tier:O}=Oe(),y=Ne(O,"productCommerce"),u=o.product,[k,E]=T(null),[j,F]=T(null),[D,U]=T({}),[K,x]=T(null),L=JSON.stringify(u?.definition??null),[p,R]=T("");ne(()=>{R(u?JSON.stringify(u.definition,null,2):"")},[L]);let S=(e,l=!1)=>D[e]??l,I=(e,l=!1)=>U(s=>({...s,[e]:!(s[e]??l)})),C=e=>{try{let l=re(e),s=Object.fromEntries(l.groups.map(d=>{let b=u?.selections[d.id];return[d.id,b===null||d.options.some(g=>g.id===b)?b??null:d.defaultOptionId??null]}));n({...o,product:{definition:l,selections:s}}),E(null)}catch(l){E(l instanceof Error?l.message:String(l))}},be=M.replace(/\.[a-z0-9]+$/i,"").replace(/[-_]+/g," ").trim()||"My product",J=e=>{let l={id:z(be,"product",[]),label:be,revision:"1",groups:e};n({...o,product:{definition:l,selections:fe(l)}})};if(!u)return c("div",{className:"se-productEmpty",children:[t("h3",{children:"Let customers customize this model"}),t("p",{children:"They pick from your options beside the model and watch it change, with a price and a button to buy."}),c("div",{className:"se-productExample","aria-hidden":"true",children:[t("span",{children:"Wood"}),t("i",{style:{background:"#b89063"}}),t("i",{className:"is-on",style:{background:"#453025"}}),t("i",{style:{background:"#d7c4a3"}}),t("span",{children:"Fabric"}),t("b",{children:"Linen"}),t("b",{className:"is-on",children:"Leather"}),t("em",{children:"$304.00"}),t("u",{children:"Buy"})]}),t($e,{bindings:r,selectedKey:h,onColor:e=>{let l=Se(r,e,[]);J([l]),x(`${l.id}/color-2`),v({[l.id]:"color-2"})},onVisibility:e=>J([Ie(r,e,[])])}),a.length?c("button",{type:"button",className:"bb-button",onClick:()=>{let e=[];J(a.map(l=>{let s=z(l.name??"","variants",e);e.push(s);let d=[],b=l.variants.map(f=>{let Y=z(f.label,"option",d);return d.push(Y),{id:Y,label:f.label,variants:[f.name],...f.swatch?.startsWith("#")?{swatch:f.swatch}:{}}}),g=b.every(f=>f.swatch)?"swatches":"list";return{id:s,label:l.name??"Variant",required:!0,defaultOptionId:b[0]?.id,display:g,options:b}}))},children:["Use this model's ",a.flatMap(e=>e.variants).length," material variants"]}):null,t("button",{type:"button",className:"se-productLink",onClick:()=>J([Pe([],"Finish")]),children:"Or start with a blank choice"})]});let i=u.definition,ie=i.groups.map(e=>e.id),xe=ke(O,"productGroups",i.groups.length),W=i.groups.flatMap(e=>e.options.map(l=>({groupId:e.id,optionId:l.id}))),G=e=>JSON.stringify([e.groupId,e.optionId]),me=e=>{let[l,s]=JSON.parse(e);return{groupId:l,optionId:s}},he=ve(i,u.selections),ge=Ce(i,r,a.length?a.flatMap(e=>e.variants.map(l=>l.name)):void 0),V=w??u.selections,se=e=>{let l=b=>e.some(g=>g.id===b.groupId&&g.options.some(f=>f.id===b.optionId)),s=(i.rules??[]).filter(b=>l(b.when)).map(b=>({...b,requires:b.requires?.filter(l),excludes:b.excludes?.filter(l)})).filter(b=>b.requires?.length||b.excludes?.length),d=b=>JSON.stringify(b.map(g=>[g.id,g.required,g.options.map(f=>f.id)]));C({...i,groups:e,rules:s,skus:d(e)===d(i.groups)?i.skus:void 0})},ae=(e,l)=>{se([...i.groups,e]),U(s=>({...s,[`group:${e.id}`]:!0})),l&&(x(`${e.id}/${l}`),v({...V,[e.id]:l}))},A=(e,l)=>se(i.groups.map(s=>s.id===e?{...s,...l}:s)),Ge=(e,l,s)=>A(e.id,{options:e.options.map(d=>d.id===l?{...d,...s}:d)}),H=(e,l)=>C({...i,rules:i.rules.map(s=>s.id===e?{...s,...l}:s)});return c("div",{className:"se-generalContent",children:[c("div",{className:"se-productTop",children:[t($,{label:"Product",path:"sceneConfig.product.definition.label",value:i.label,onCommit:e=>{e&&C({...i,label:e})}}),t("div",{className:"se-productActions",children:c("button",{type:"button",className:"bb-button bb-button--primary",onClick:N,children:[t(Le,{size:13,"aria-hidden":"true"})," Preview as a customer"]})})]}),ge.length?t("ul",{className:"se-productWarnings","aria-label":"Problems to fix",children:ge.map((e,l)=>t("li",{children:e.message},l))}):null,k?t("p",{className:"bb-note bb-note--error se-productError",role:"alert",children:k}):null,t(X,{title:"What customers can choose"}),i.groups.map(e=>{let l=u.selections[e.id]??null;return c(q,{title:e.label,open:S(`group:${e.id}`,i.groups.length===1),onToggle:()=>I(`group:${e.id}`,i.groups.length===1),trailing:c("small",{className:"se-productCount",children:[e.options.length," options"]}),children:[t("div",{className:"se-productOptions",children:e.options.map((s,d)=>{let b=`${e.id}/${s.id}`;return t(Ze,{group:e,option:s,index:d,definition:i,bindings:r,variantGroups:a,canSell:y,selectedKey:h,isStart:l===s.id,isShown:V[e.id]===s.id,open:K===b,onToggleOpen:()=>{x(g=>g===b?null:b),v({...V,[e.id]:s.id})},onSetStart:()=>{let g={...i,groups:i.groups.map(f=>f.id===e.id?{...f,defaultOptionId:s.id}:f)};n({...o,product:{definition:g,selections:{...u.selections,[e.id]:s.id}}})},onChange:g=>Ge(e,s.id,g),onMove:g=>A(e.id,{options:ue(e.options,d,g)}),onDuplicate:()=>{let g=e.options.map(Y=>Y.id),f=[...e.options];f.splice(d+1,0,{...structuredClone(s),id:te("option",g),label:`${s.label} copy`,sku:void 0}),A(e.id,{options:f})},onRemove:()=>{let g=e.options.filter(f=>f.id!==s.id);A(e.id,{options:g,defaultOptionId:e.defaultOptionId===s.id?e.required?g[0]?.id:void 0:e.defaultOptionId})}},s.id)})}),t("div",{className:"se-productActions",children:c("button",{type:"button",className:"bb-button",onClick:()=>{let s=te("option",e.options.map(b=>b.id)),d=e.display==="swatches";A(e.id,{options:[...e.options,{id:s,label:d?"New color":`Option ${e.options.length+1}`,...d?{swatch:"#888888"}:{}}]}),x(`${e.id}/${s}`),v({...V,[e.id]:s})},children:[t(pe,{size:13,"aria-hidden":"true"})," Add option"]})}),c("details",{className:"se-productMore",children:[t("summary",{children:"Choice settings"}),t($,{label:"Name",value:e.label,onCommit:s=>{s&&A(e.id,{label:s})}}),t(le,{label:"Show as",value:e.display??"list",options:Je,onChange:s=>A(e.id,{display:s})}),t(Q,{label:"Customers can skip it",checked:!e.required,onChange:s=>A(e.id,{required:!s,defaultOptionId:e.defaultOptionId??(s?void 0:e.options[0]?.id)})}),c("div",{className:"se-productActions",children:[t(P,{label:`Move ${e.label} up`,disabled:i.groups.indexOf(e)===0,onClick:()=>{let s=i.groups.indexOf(e);C({...i,groups:ue(i.groups,s,-1)})},children:t(Be,{size:13})}),t(P,{label:`Move ${e.label} down`,disabled:i.groups.indexOf(e)===i.groups.length-1,onClick:()=>{let s=i.groups.indexOf(e);C({...i,groups:ue(i.groups,s,1)})},children:t(Me,{size:13})}),t(P,{label:`Delete ${e.label}`,disabled:i.groups.length<=1,onClick:()=>se(i.groups.filter(s=>s.id!==e.id)),children:t(ee,{size:13})})]})]})]},e.id)}),xe?c("div",{className:"se-productAdd",children:[t($e,{bindings:r,selectedKey:h,onColor:e=>ae(Se(r,e,ie),"color-2"),onVisibility:e=>ae(Ie(r,e,ie))}),t("button",{type:"button",className:"se-productLink",onClick:()=>ae(Pe(ie)),children:"Or add a blank choice"})]}):t(_,{requiredTier:we("productGroups",i.groups.length),feature:"More choices"}),t(q,{title:"Prices and buying",open:S("selling"),onToggle:()=>I("selling"),children:y?c(Z,{children:[t(Q,{label:"Show a price",checked:!!i.pricing,onChange:e=>C({...i,pricing:e?{currency:"USD",basePriceMinor:0}:void 0})}),i.pricing?c(Z,{children:[t(le,{label:"Currency",path:"sceneConfig.product.definition.pricing.currency",value:i.pricing.currency,options:de.includes(i.pricing.currency)?de:[...de,i.pricing.currency],onChange:e=>C({...i,pricing:{...i.pricing,currency:e}})}),t(Te,{label:"Base price",path:"sceneConfig.product.definition.pricing.basePriceMinor",currency:i.pricing.currency,valueMinor:i.pricing.basePriceMinor,onCommit:e=>C({...i,pricing:{...i.pricing,basePriceMinor:e??0}})}),t("p",{className:"bb-note",children:"Open an option to add what it costs extra. This price is for show: always charge from your own store."})]}):null,t($,{label:"Buy link",path:"sceneConfig.product.definition.checkout.urlTemplate",placeholder:We,value:i.checkout?.urlTemplate??"",onCommit:e=>C({...i,checkout:e?{...i.checkout,urlTemplate:e}:void 0})}),i.checkout?t($,{label:"Button text",placeholder:"Buy now",value:i.checkout.label??"",onCommit:e=>C({...i,checkout:{...i.checkout,label:e||void 0}})}):null,c("p",{className:"bb-note",children:["Where the button goes. The link can include ","{sku}",", ","{quantity}",", ","{productId}"," and ","{selections}","."]})]}):t(_,{requiredTier:"starter",feature:"Prices and buy links"})}),t(q,{title:`Restrictions${i.rules?.length?` (${i.rules.length})`:""}`,open:S("rules"),onToggle:()=>I("rules"),children:y?c(Z,{children:[t("p",{className:"bb-note",children:"For combinations you don't sell. Customers see your message, and picking a blocked option changes the others to fit."}),i.rules?.map(e=>{let l=e.excludes?.length?"excludes":"requires",s=(e[l]??[])[0];return c("div",{className:"se-productRule",children:[t(B,{label:"When",children:t("select",{className:"se-select","aria-label":`Condition for ${e.id}`,value:G(e.when),onChange:d=>H(e.id,{when:me(d.target.value)}),children:W.map(d=>t("option",{value:G(d),children:Re(i,d)},G(d)))})}),t(B,{label:"Then",children:c("select",{className:"se-select","aria-label":`Kind of rule for ${e.id}`,value:l,onChange:d=>{let b=d.target.value;H(e.id,b==="requires"?{requires:e.excludes,excludes:void 0}:{excludes:e.requires,requires:void 0})},children:[t("option",{value:"requires",children:"Must have"}),t("option",{value:"excludes",children:"Can't have"})]})}),t(B,{label:"Option",children:t("select",{className:"se-select","aria-label":`Choice for ${e.id}`,value:s?G(s):"",onChange:d=>H(e.id,{[l]:[me(d.target.value)]}),children:W.filter(d=>d.groupId!==e.when.groupId).map(d=>t("option",{value:G(d),children:Re(i,d)},G(d)))})}),t($,{label:"Message",placeholder:"Shown when it's blocked",value:e.message??"",onCommit:d=>H(e.id,{message:d||void 0})}),t("div",{className:"se-productActions",children:t(P,{label:`Delete restriction ${e.id}`,onClick:()=>C({...i,rules:i.rules.filter(d=>d.id!==e.id)}),children:t(ee,{size:13})})})]},e.id)}),i.groups.length<2?t("p",{className:"bb-note",children:"Add a second choice to restrict combinations."}):t("div",{className:"se-productActions",children:c("button",{type:"button",className:"bb-button",onClick:()=>{let e=W[0],l=W.find(s=>s.groupId!==e.groupId);C({...i,rules:[...i.rules??[],{id:te("rule",(i.rules??[]).map(s=>s.id)),when:e,requires:[l]}]})},children:[t(pe,{size:13,"aria-hidden":"true"})," Add restriction"]})})]}):t(_,{requiredTier:"starter",feature:"Restrictions"})}),t(q,{title:"Publish",open:S("publish"),onToggle:()=>I("publish"),children:m?c("div",{className:"se-productPublish",children:[t("p",{className:"bb-note",children:"Customers can choose wherever this project is shared or embedded. Set access to Anyone with the link, then copy the embed code."}),m]}):c("div",{className:"se-productPublish",children:[c("p",{className:"bb-note",children:["Use ",t("strong",{children:"Export \u203A Scene settings"})," in the top bar, then show it with the options panel on:"]}),t(et,{code:`<ModelViewer
|
|
2
|
-
modelUrl="/model.glb"
|
|
3
|
-
licenseKey={licenseKey}
|
|
4
|
-
sceneConfig={sceneConfig}
|
|
5
|
-
productOptions
|
|
6
|
-
/>`})]})}),c(q,{title:"Advanced",open:S("advanced"),onToggle:()=>I("advanced"),children:[t($,{label:"Product ID",path:"sceneConfig.product.definition.id",value:i.id,onCommit:e=>{e&&C({...i,id:e})}}),t($,{label:"Revision",path:"sceneConfig.product.definition.revision",value:i.revision,onCommit:e=>{e&&C({...i,revision:e})}}),y?c(Z,{children:[t(X,{title:`SKU combinations (${i.skus?.length??0})`}),t("p",{className:"bb-note",children:"Once this list has entries, combinations not on it can't be bought."}),c("div",{className:"se-productActions",children:[t("button",{type:"button",className:"bb-button",onClick:()=>{try{let e=ye({...i,skus:void 0});F(e.length?`Generated ${e.length} ${e.length===1?"combination":"combinations"}.`:"Give each option an SKU first, under More."),e.length&&C({...i,skus:e})}catch(e){F(e instanceof Error?e.message:String(e))}},children:"Generate from option SKUs"}),i.skus?.length?t(P,{label:"Clear SKU combinations",onClick:()=>C({...i,skus:void 0}),children:t(ee,{size:13})}):null]}),j?t("p",{className:"bb-note",role:"status",children:j}):null,he.sku?c("p",{className:"bb-note",children:["Customers start on: ",he.sku]}):null]}):null,t(X,{title:"Definition JSON"}),t("p",{className:"bb-note",children:"For textures and anything else without a control. It's checked before it's applied."}),t("div",{className:"se-productJson",children:t("textarea",{className:"bb-textarea","aria-label":"Product definition JSON",rows:10,value:p,spellCheck:!1,onChange:e=>R(e.target.value)})}),c("div",{className:"se-productActions",children:[t("button",{type:"button",className:"bb-button",onClick:()=>{try{C(re(p))}catch(e){E(e instanceof Error?e.message:String(e))}},children:"Apply JSON"}),t("button",{type:"button",className:"bb-button",onClick:()=>{v(null),n({...o,product:void 0})},children:"Remove all of this"})]})]})]})}export{tt as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as _}from"./chunk-E24EFHB5.mjs";import{c as F,d as D,k as L,n as z}from"./chunk-AL6UIGWP.mjs";import{a as P}from"./chunk-CCBFMNAU.mjs";import{b as K}from"./chunk-GV4ZRXL6.mjs";import"./chunk-JR557W27.mjs";import{useMemo as ee,useState as te}from"react";import{ArrowDown as ae,ArrowUp as ne,ChevronRight as le,Plus as G,Trash2 as se,X as U}from"lucide-react";import{Fragment as J,jsx as a,jsxs as r}from"react/jsx-runtime";var H={all:"All objects",group:"Group",tag:"Tag",type:"Type",object:"One object"},V={metric:"Metric",status:"Status",metadata:"Metadata"},oe={metric:"",stops:[[0,"#3b82f6"],[100,"#ef4444"]]};function ie(n){return n===void 0?"all":typeof n=="string"||Array.isArray(n)?"object":"group"in n?"group":"tag"in n?"tag":"type"}function w(n){return n===void 0?"":typeof n=="string"?n:Array.isArray(n)?n[0]??"":"group"in n?n.group:"tag"in n?n.tag:n.type}function W(n,s){if(n!=="all")return n==="object"?s:n==="group"?{group:s}:n==="tag"?{tag:s}:{type:s}}function re(n){return"metric"in n?"metric":"status"in n?"status":"metadata"}function X(n){return n==="metric"?{metric:""}:n==="status"?{status:["disabled"]}:{metadata:"",equals:""}}function ce(n){let s=n.trim();return s==="true"?!0:s==="false"?!1:s==="null"?null:s!==""&&Number.isFinite(Number(s))?Number(s):n}function I(n){return n.trim()===""||!Number.isFinite(Number(n))?void 0:Number(n)}function Q(n,s="",c=0){return typeof n!="object"||n===null||Array.isArray(n)?s?[s]:[]:c>2?s?[s]:[]:Object.entries(n).flatMap(([d,h])=>Q(h,s?`${s}.${d}`:d,c+1))}var j=n=>[...new Set(n.filter(s=>!!s))].sort((s,c)=>s.localeCompare(c));function y({label:n,children:s}){return r("label",{className:"se-field se-fieldInline",children:[a("span",{className:"se-fieldLabel",title:n,children:n}),s]})}function O({label:n,checked:s,color:c,onToggle:d,onColorChange:h}){return r("div",{className:"se-field se-fieldInline",children:[r("label",{className:"se-ruleLook",children:[a("input",{type:"checkbox",className:"se-checkbox",checked:s,onChange:T=>d(T.target.checked)}),n]}),s&&c!==void 0&&h?a(z,{label:n,value:c,onChange:h}):null]})}function ue({title:n,open:s,onToggle:c,actions:d,children:h}){return r("section",{className:"se-panel",children:[r("div",{className:"se-panelHeaderRow",children:[r("button",{type:"button",className:"se-panelHeader",onClick:c,"aria-expanded":s,children:[a(le,{size:13,className:`se-panelChevron ${s?"se-panelChevron--open":""}`}),a("span",{className:"se-panelTitle",children:n})]}),a("span",{className:"se-listHeaderActions",children:d})]}),s?a("div",{className:"se-panelBody",children:h}):null]})}function de({config:n,onChange:s,objectBindings:c}){let d=n.styleRules??[],[h,T]=te(d[0]?.id??null),b=ee(()=>{let t=Object.values(c);return{groups:j(t.map(i=>i.group)),tags:j(t.flatMap(i=>i.tags??[])),types:j(t.map(i=>i.type??"other")),objects:t.map(i=>({id:i.id,label:i.label||i.id})).sort((i,u)=>i.label.localeCompare(u.label)),metrics:j(t.flatMap(i=>Object.keys(i.metrics??{}))),metadata:j(t.flatMap(i=>Q(i.metadata)))}},[c]),A=t=>s({...n,styleRules:t}),v=(t,i)=>A(d.map(u=>u.id===t?i(u):u)),Y=()=>{let t=crypto.randomUUID();A([...d,{id:t,label:`Rule ${d.length+1}`,when:[{status:["disabled"]}],material:{baseColor:"#9ca3af"}}]),T(t)},$=(t,i)=>{let u=[...d],[m]=u.splice(t,1);u.splice(t+i,0,m),A(u)},Z=t=>{let i=t.target?K(c,t.target):Object.keys(c),u=t.when?Array.isArray(t.when)?t.when:[t.when]:[];return i.filter(m=>u.every(f=>P(c[m],f))).length};return r("div",{className:"se-rules",children:[a(D,{title:"Rules",children:r("button",{type:"button",className:"bb-button bb-button--small",onClick:Y,children:[a(G,{size:13,"aria-hidden":"true"})," Add rule"]})}),a("p",{className:"rui-note",children:"Restyle objects from their metrics, status, or metadata while the app runs. Later rules win."}),a("datalist",{id:"se-ruleMetrics",children:b.metrics.map(t=>a("option",{value:t},t))}),a("datalist",{id:"se-ruleMetadata",children:b.metadata.map(t=>a("option",{value:t},t))}),d.map((t,i)=>{let u=t.when?Array.isArray(t.when)?t.when:[t.when]:[],m=ie(t.target),f=t.material??{},S=t.pulse===!0?{}:t.pulse||void 0,q=t.target?K(c,t.target).length:Object.keys(c).length,M=e=>v(t.id,l=>({...l,when:e.length>0?e:void 0})),C=(e,l)=>M(u.map((p,o)=>o===e?l:p)),N=e=>v(t.id,l=>{let p={...l.material,...e};for(let o of Object.keys(p))p[o]===void 0&&delete p[o];return{...l,material:Object.keys(p).length>0?p:void 0}}),k=e=>v(t.id,l=>({...l,colorScale:e})),E=m==="group"?b.groups:m==="tag"?b.tags:m==="type"?b.types:[];return r(ue,{title:t.label||`Rule ${i+1}`,open:h===t.id,onToggle:()=>T(e=>e===t.id?null:t.id),actions:r(J,{children:[a("button",{type:"button",className:"se-iconButton",onClick:()=>$(i,-1),disabled:i===0,"aria-label":"Move rule up",title:"Move up",children:a(ne,{size:13})}),a("button",{type:"button",className:"se-iconButton",onClick:()=>$(i,1),disabled:i===d.length-1,"aria-label":"Move rule down",title:"Move down",children:a(ae,{size:13})}),a("button",{type:"button",className:"se-iconButton",onClick:()=>A(d.filter(e=>e.id!==t.id)),"aria-label":"Delete rule",title:"Delete rule",children:a(se,{size:13})})]}),children:[a(y,{label:"Name",children:a("input",{className:"se-textInput",value:t.label??"",placeholder:`Rule ${i+1}`,onChange:e=>v(t.id,l=>({...l,label:e.target.value}))})}),r("div",{className:"se-ruleGrid",children:[a(y,{label:"Applies to",children:a("select",{className:"se-select",value:m,onChange:e=>{let l=e.target.value,p=l==="object"?b.objects[0]?.id:l==="group"?b.groups[0]:l==="tag"?b.tags[0]:l==="type"?b.types[0]:"";v(t.id,o=>({...o,target:W(l,p??"")}))},children:Object.keys(H).map(e=>a("option",{value:e,children:H[e]},e))})}),m!=="all"?a(y,{label:H[m],children:r("select",{className:"se-select",value:w(t.target),onChange:e=>v(t.id,l=>({...l,target:W(m,e.target.value)})),children:[m==="object"?b.objects.map(e=>a("option",{value:e.id,children:e.label},e.id)):E.map(e=>a("option",{value:e,children:e},e)),(m==="object"?b.objects.some(e=>e.id===w(t.target)):E.includes(w(t.target)))?null:a("option",{value:w(t.target),children:w(t.target)||"None in this model"})]})}):null]}),a("div",{className:"rui-groupHeader",children:a("span",{children:"When"})}),u.length===0?a("p",{className:"rui-note",children:"Always applies."}):null,u.map((e,l)=>{let p=re(e);return r("div",{className:"se-ruleCondition",children:[r("div",{className:"se-ruleConditionHeader",children:[a("select",{className:"se-select","aria-label":"Condition type",value:p,onChange:o=>C(l,X(o.target.value)),children:Object.keys(V).map(o=>a("option",{value:o,children:V[o]},o))}),a("button",{type:"button",className:"se-iconButton","aria-label":"Remove condition",title:"Remove condition",onClick:()=>M(u.filter((o,g)=>g!==l)),children:a(U,{size:13})})]}),"metric"in e?r("div",{className:"se-ruleGrid se-ruleGrid--three",children:[a(y,{label:"Metric",children:a("input",{className:"se-textInput",list:"se-ruleMetrics",value:e.metric,placeholder:"temperature",onChange:o=>C(l,{...e,metric:o.target.value})})}),a(y,{label:"Above",children:a("input",{className:"se-numberInput",type:"number",value:e.above??"",placeholder:"any",onChange:o=>C(l,{...e,above:I(o.target.value)})})}),a(y,{label:"Below",children:a("input",{className:"se-numberInput",type:"number",value:e.below??"",placeholder:"any",onChange:o=>C(l,{...e,below:I(o.target.value)})})})]}):"status"in e?a("div",{className:"se-ruleStatuses",children:_.map(o=>{let g=[].concat(e.status).includes(o);return r("label",{className:"se-ruleStatus",children:[a("input",{type:"checkbox",className:"se-checkbox",checked:g,onChange:()=>{let R=[].concat(e.status),B=g?R.filter(x=>x!==o):[...R,o];C(l,{status:B})}}),o]},o)})}):r("div",{className:"se-ruleGrid",children:[a(y,{label:"Key",children:a("input",{className:"se-textInput",list:"se-ruleMetadata",value:e.metadata,placeholder:"alarm.state",onChange:o=>C(l,{...e,metadata:o.target.value})})}),a(y,{label:"Equals",children:a("input",{className:"se-textInput",value:e.equals===null?"null":String(e.equals),placeholder:"fault",onChange:o=>C(l,{...e,equals:ce(o.target.value)})})})]})]},l)}),a(F,{children:r("button",{type:"button",className:"bb-button",onClick:()=>M([...u,X("metric")]),children:[a(G,{size:13,"aria-hidden":"true"})," Add condition"]})}),a("div",{className:"rui-groupHeader",children:a("span",{children:"Look"})}),a(O,{label:"Color",checked:f.baseColor!==void 0,color:f.baseColor,onToggle:e=>N({baseColor:e?"#9ca3af":void 0}),onColorChange:e=>N({baseColor:e})}),a(O,{label:"Opacity",checked:f.opacity!==void 0,onToggle:e=>N({opacity:e?.4:void 0})}),f.opacity!==void 0?a(L,{label:"Opacity",value:f.opacity,min:0,max:1,step:.05,formatValue:e=>`${Math.round(e*100)}%`,onChange:e=>N({opacity:e})}):null,a(O,{label:"Glow",checked:f.emissive!==void 0,color:f.emissive,onToggle:e=>N({emissive:e?"#ff3b30":void 0,emissiveIntensity:e?f.emissiveIntensity??1:void 0}),onColorChange:e=>N({emissive:e})}),a(O,{label:"Color from a metric",checked:t.colorScale!==void 0,onToggle:e=>k(e?{...oe,metric:b.metrics[0]??""}:void 0)}),t.colorScale?r("div",{className:"se-ruleCondition",children:[r("div",{className:"se-ruleGrid",children:[a(y,{label:"Metric",children:a("input",{className:"se-textInput",list:"se-ruleMetrics",value:t.colorScale.metric,placeholder:"temperature",onChange:e=>k({...t.colorScale,metric:e.target.value})})}),a(y,{label:"Sets",children:r("select",{className:"se-select",value:t.colorScale.channel??"baseColor",onChange:e=>k({...t.colorScale,channel:e.target.value}),children:[a("option",{value:"baseColor",children:"Color"}),a("option",{value:"emissive",children:"Glow color"})]})})]}),t.colorScale.stops.map(([e,l],p)=>{let o=g=>k({...t.colorScale,stops:t.colorScale.stops.map((R,B)=>B===p?g:R)});return r("div",{className:"se-ruleStop",children:[a("input",{className:"se-numberInput",type:"number","aria-label":"Stop value",value:e,onChange:g=>o([I(g.target.value)??0,l])}),a(z,{label:`Color at ${e}`,value:l,onChange:g=>o([e,g])}),a("button",{type:"button",className:"se-iconButton","aria-label":"Remove stop",title:"Remove stop",disabled:t.colorScale.stops.length<=1,onClick:()=>k({...t.colorScale,stops:t.colorScale.stops.filter((g,R)=>R!==p)}),children:a(U,{size:13})})]},p)}),a(F,{children:r("button",{type:"button",className:"bb-button",onClick:()=>{let e=t.colorScale.stops,l=e[e.length-1];k({...t.colorScale,stops:[...e,[(l?.[0]??0)+10,l?.[1]??"#ffffff"]]})},children:[a(G,{size:13,"aria-hidden":"true"})," Add stop"]})})]}):null,a(O,{label:"Pulse",checked:S!==void 0,color:S?.color??"#ff3b30",onToggle:e=>v(t.id,l=>({...l,pulse:e?{color:"#ff3b30",speed:1}:void 0})),onColorChange:e=>v(t.id,l=>({...l,pulse:{...S,color:e}}))}),S?a(J,{children:a(L,{label:"Pulses per second",value:S.speed??1,min:.2,max:4,step:.1,formatValue:e=>e.toFixed(1),onChange:e=>v(t.id,l=>({...l,pulse:{...S,speed:e}}))})}):null,r("p",{className:"rui-note",children:["Matches ",Z(t)," of ",q," ",q===1?"object":"objects"," right now."]})]},t.id)})]})}export{de as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.sq-editor{color:var(--ri-ui-text-2);padding:12px;font-size:12px}.sq-header,.sq-picker,.sq-inspectorTitle,.sq-settings{display:flex;align-items:center;gap:10px}.sq-header{justify-content:space-between;margin-bottom:16px}.sq-header h2{margin:0;font-size:13px}.sq-header p,.sq-hint{color:var(--ri-ui-text-2);font-size:11px;line-height:1.5}.sq-header p{margin:6px 0 0}.sq-picker .sq-field{flex:1;min-width:0}.sq-field{display:flex;flex-direction:column;gap:6px;margin-bottom:12px;min-width:0}.sq-field>span{font-size:11px;color:var(--ri-ui-text-2)}.sq-field input,.sq-field select{width:100%;min-width:0;box-sizing:border-box;border:1px solid var(--ri-ui-line);border-radius:var(--ri-ui-radius-m);padding:8px;color:var(--ri-ui-text);background:var(--ri-ui-raised);font:inherit}.sq-field input:focus-visible,.sq-field select:focus-visible,.sq-editor button:focus-visible{outline:2px solid var(--ri-ui-accent);outline-offset:2px}.sq-settings{flex-wrap:wrap;align-items:center;margin:10px 0}.sq-settings .sq-field{width:105px;margin:0}.sq-check{display:flex;align-items:center;gap:6px;color:var(--ri-ui-text-2);font-size:11px}.sq-editor input[type=checkbox]{accent-color:var(--ri-ui-accent)}.sq-twoFields{display:grid;grid-template-columns:1fr 1fr;gap:10px}.sq-vector{border:0;padding:0;margin:10px 0;min-width:0}.sq-vector legend{color:var(--ri-ui-text-2);margin-bottom:8px}.sq-vector>div{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px}.sq-color{flex-direction:row;align-items:center;gap:12px}.sq-color input{width:40px;height:32px;padding:3px}.sq-empty{padding:24px 12px;border:1px dashed var(--ri-ui-line-strong);border-radius:var(--ri-ui-radius-m);text-align:center;line-height:1.6;color:var(--ri-ui-text-2)}.sq-empty button{margin-top:8px}.sq-timeline{margin-top:16px;padding:10px;border:1px solid var(--ri-ui-line);border-radius:var(--ri-ui-radius-m);background:transparent}.sq-ruler{display:flex;justify-content:space-between;color:var(--ri-ui-text-2);font-size:11px;padding-bottom:10px;font-variant-numeric:tabular-nums}.sq-track{margin-bottom:10px;border-radius:var(--ri-ui-radius-s);padding:7px 8px;background:var(--ri-ui-hover);border:1px solid transparent}.sq-track--active{border-color:var(--ri-ui-accent);background:var(--ri-ui-accent-dim)}.sq-trackLabel{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}.sq-trackLabel>button{min-width:0;border:0;padding:0;color:var(--ri-ui-text-2);background:none;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font:inherit;cursor:pointer}.sq-trackLabel label{display:flex;gap:4px;align-items:center;font-size:11px;color:var(--ri-ui-text-2)}.sq-lane{position:relative;height:28px;margin:0 8px;background:repeating-linear-gradient(90deg,transparent,transparent calc(25% - 1px),rgba(148,163,184,.12) calc(25% - 1px),rgba(148,163,184,.12) 25%);border-bottom:1px solid var(--ri-ui-line)}.sq-key{position:absolute;top:8px;width:12px;height:12px;padding:0;border:1px solid var(--ri-ui-line-strong);background:var(--ri-ui-field);border-radius:2px;transform:translate(-50%) rotate(45deg);cursor:ew-resize;touch-action:none}.sq-key--active{background:var(--ri-ui-accent);border-color:var(--ri-ui-accent)}.sq-playhead{position:absolute;top:0;bottom:-1px;width:1px;background:var(--ri-ui-warning);pointer-events:none}.sq-addTrack,.sq-inspector{border-top:1px solid var(--ri-ui-line);padding-top:14px;margin-top:18px}.sq-editor h3{margin:0 0 12px;font-size:12px;font-weight:600}.sq-inspectorTitle{justify-content:space-between;margin-bottom:10px}.sq-inspectorTitle h3{margin:0}.sq-inspector>button{margin-bottom:16px}.sq-error{border:1px solid var(--ri-ui-warning);border-radius:var(--ri-ui-radius-m);padding:10px;color:var(--ri-ui-warning);background:var(--ri-ui-warning-dim);line-height:1.5}.sq-key{top:3px;width:22px;height:22px;border:0;background:transparent;transform:translate(-50%)}.sq-key:before{content:"";position:absolute;left:5px;top:5px;width:10px;height:10px;border:1px solid var(--ri-ui-line-strong);border-radius:2px;background:var(--ri-ui-field);transform:rotate(45deg)}.sq-key--active:before{background:var(--ri-ui-accent);border-color:var(--ri-ui-accent)}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as ce}from"./chunk-AL6UIGWP.mjs";import{a as re,b as ne}from"./chunk-KYXJG3TX.mjs";import{e as U,f as se,h as oe,i as le}from"./chunk-FGAJ2UT7.mjs";import"./chunk-NMRTI3NQ.mjs";import{a as ee,b as te,c as $,d as ae,e as L,g as ie}from"./chunk-LX3GXQNU.mjs";import"./chunk-UAZ6I25Y.mjs";import"./chunk-JR557W27.mjs";import{useEffect as be,useMemo as Te,useRef as we,useState as S}from"react";import{Copy as je,DiamondPlus as Ie,Plus as _,ScanLine as Ee,Trash2 as G}from"lucide-react";import{useEffect as de,useState as pe}from"react";import{Fragment as ue,jsx as g,jsxs as T}from"react/jsx-runtime";function j({label:p,value:o,onChange:r,min:l,max:u,step:f=.1,disabled:q=!1}){let[y,d]=pe(String(Number(o.toFixed(5))));return de(()=>d(String(Number(o.toFixed(5)))),[o]),T("label",{className:"sq-field",children:[g("span",{children:p}),g("input",{type:"number","aria-label":p,value:y,step:f,min:l,max:u,disabled:q,onChange:m=>d(m.target.value),onBlur:()=>{let m=y.trim()?Number(y):NaN;Number.isFinite(m)&&(l===void 0||m>=l)&&(u===void 0||m<=u)&&m!==o&&r(m),d(String(Number(o.toFixed(5))))},onKeyDown:m=>{m.stopPropagation(),m.key==="Enter"&&m.currentTarget.blur(),m.key==="Escape"&&(m.preventDefault(),d(String(o)))}})]})}function X({label:p,value:o,onChange:r}){let[l,u]=pe(o);return de(()=>u(o),[o]),T("label",{className:"sq-field",children:[g("span",{children:p}),g("input",{"aria-label":p,value:l,maxLength:256,onChange:f=>u(f.target.value),onBlur:()=>{l.trim()&&l.trim()!==o?r(l.trim()):u(o)},onKeyDown:f=>{f.stopPropagation(),f.key==="Enter"&&f.currentTarget.blur()}})]})}function H({label:p,value:o,onChange:r,degrees:l=!1}){return T("fieldset",{className:"sq-vector",children:[T("legend",{children:[p,l?" (\xB0)":""]}),g("div",{children:o.map((u,f)=>g(j,{label:["X","Y","Z"][f],value:l?u*180/Math.PI:u,onChange:q=>r(o.map((y,d)=>f===d?l?q*Math.PI/180:q:y))},f))})]})}function me({target:p,value:o,onChange:r}){if(p.kind==="camera"){let l=o;return T(ue,{children:[g(H,{label:"Camera position",value:l.position,onChange:u=>r({...l,position:u})}),g(H,{label:"Camera target",value:l.target,onChange:u=>r({...l,target:u})}),T(ue,{children:[l.fov!==null&&g(j,{label:"FOV (\xB0)",min:1,max:179,value:l.fov,onChange:u=>r({...l,fov:u})}),g(j,{label:"Zoom",min:.001,value:l.zoom,onChange:u=>r({...l,zoom:u})})]})]})}return Array.isArray(o)?g(H,{label:p.kind==="object"?p.property[0].toUpperCase()+p.property.slice(1):"Value",value:o,degrees:p.kind==="object"&&p.property==="rotation",onChange:r}):typeof o=="boolean"?T("label",{className:"sq-check",children:[g("input",{type:"checkbox",checked:o,onChange:l=>r(l.target.checked)}),"Visible"]}):typeof o=="string"?T("label",{className:"sq-field sq-color",children:[g("span",{children:"Color"}),g("input",{type:"color","aria-label":"Keyframe color",value:o,onChange:l=>r(l.target.value)}),g("code",{children:o})]}):g(j,{label:p.kind==="clip"?"Clip time (s)":"Value",min:0,max:p.kind==="object"&&p.property!=="emissiveIntensity"?1:void 0,step:.01,value:o,onChange:r})}import{Fragment as fe,jsx as t,jsxs as s}from"react/jsx-runtime";var I=()=>crypto.randomUUID(),ge={position:"Position",rotation:"Rotation",scale:"Scale",visible:"Visibility",baseColor:"Color",emissive:"Emissive color",opacity:"Opacity",roughness:"Roughness",metalness:"Metalness",emissiveIntensity:"Emissive intensity"},Pe={linear:"Linear","ease-in":"Ease in","ease-out":"Ease out","ease-in-out":"Ease in / out",step:"Hold / step"};function Ae({config:p,onChange:o,controls:r,bindings:l,clipDetails:u}){let{tier:f}=oe(),q=re(r),y=Te(()=>{try{return{sequences:L(p.sequences??[]),error:""}}catch(e){return{sequences:[],error:e instanceof Error?e.message:"Invalid sequence data."}}},[p.sequences]),d=y.sequences,[Q,m]=S(null),[qe,N]=S(null),[ke,x]=S(null),[w,he]=S("object"),[ve,ye]=S(""),[V,xe]=S("position"),[Y,Se]=S(""),[Z,P]=S(""),[D,K]=S(null),A=we(null),i=d.find(e=>e.id===Q)??d[0],c=i?.tracks.find(e=>e.id===qe)??i?.tracks[0],h=c?.keyframes.find(e=>e.id===ke)??c?.keyframes[0],B=Object.values(l).filter((e,a,k)=>!e.removed&&k.findIndex(n=>n.modelObjectId===e.modelObjectId)===a),M=B.find(e=>e.modelObjectId===ve)??B[0],R=u.some(e=>e.sourceName===Y)?Y:u[0]?.sourceName;be(()=>{i&&r&&q.sequenceId!==i.id&&r.select(i.id)},[r,i?.id,q]),be(()=>()=>r?.stop(),[r]);let O=e=>{try{let a=L(e);o({...p,sequences:a}),P("")}catch(a){P(a instanceof Error?a.message:"Invalid sequence.")}},E=e=>O(d.map(a=>a.id===e.id?e:a)),z=e=>{i&&E({...i,tracks:i.tracks.map(a=>a.id===e.id?e:a)})},C=(e,a)=>{if(!i||!ae(a.value,e.target)){P("Use a valid value; scale components must be nonzero.");return}z(ie(e,{...a,time:Math.max(0,Math.min(i.duration,a.time))})),N(e.id),x(a.id),r?.pause(),r?.seek(a.time)},J=()=>{if(d.length>=64)return;let e={id:I(),name:`Sequence ${d.length+1}`,duration:5,loop:!1,autoPlay:!1,tracks:[]};O([...d,e]),m(e.id),N(null),x(null)},v=w==="camera"?{kind:"camera"}:w==="clip"?R?{kind:"clip",clip:R}:null:M?{kind:"object",objectId:M.modelObjectId,property:V}:null,F=!!v&&i?.tracks.some(e=>$(e.target)===$(v)),Ne=()=>{if(!i||!v||F)return;let e=r?.capture(v);if(e==null){P("That target is not ready. Wait for the model, or choose another object/clip.");return}let a=v.kind==="clip"?Math.min(i.duration,u.find(n=>n.sourceName===v.clip)?.duration??i.duration):structuredClone(e),k={id:I(),name:v.kind==="camera"?"Camera":v.kind==="clip"?v.clip:`${M?.label||M?.modelObjectId} \xB7 ${ge[V]}`,target:v,keyframes:[{id:I(),time:0,value:e,easing:V==="visible"&&w==="object"?"step":"ease-in-out"},{id:I(),time:i.duration,value:a}]};E({...i,tracks:[...i.tracks,k]}),N(k.id),x(k.keyframes[1].id),r?.seek(i.duration)},Ce=()=>{if(!c||!i||c.keyframes.length>=2048)return;let e=r?.capture(c.target);if(e==null){P("The selected target is unavailable.");return}let a={id:I(),time:Math.min(q.time,i.duration),value:e,easing:"ease-in-out"};C(c,a)};return s("section",{className:"sq-editor","aria-label":"Visual sequence authoring",children:[y.error&&t("p",{role:"alert",className:"sq-error",children:y.error}),U(f,"sequences",d.length)?null:t(le,{requiredTier:se("sequences",d.length),feature:"More sequences"}),i?s(fe,{children:[s("div",{className:"sq-toolbar",children:[t("select",{className:"se-select sq-toolbarPicker","aria-label":"Authored sequence",value:i.id,onChange:e=>{m(e.target.value),N(null),x(null),r?.select(e.target.value)},children:d.map(e=>t("option",{value:e.id,children:e.name},e.id))}),t("button",{type:"button",className:"se-iconButton",title:"Add sequence","aria-label":"Add sequence",disabled:d.length>=64||!U(f,"sequences",d.length),onClick:J,children:t(_,{size:14})}),t("button",{type:"button",className:"se-iconButton",title:"Duplicate sequence","aria-label":"Duplicate sequence",disabled:d.length>=64,onClick:()=>{let e={...structuredClone(i),id:I(),name:`${i.name} copy`.slice(0,256),autoPlay:!1};O([...d,e]),m(e.id)},children:t(je,{size:13})}),t("button",{type:"button",className:"se-iconButton",title:"Delete sequence","aria-label":"Delete sequence",onClick:()=>{r?.stop(),O(d.filter(e=>e.id!==i.id)),m(null)},children:t(G,{size:13})}),t("span",{className:"sq-toolbarDivider"}),t(X,{label:"Name",value:i.name,onChange:e=>E({...i,name:e})}),t(j,{label:"Duration",min:.1,max:3600,value:i.duration,onChange:e=>E({...i,duration:e,tracks:i.tracks.map(a=>({...a,keyframes:a.keyframes.map(k=>({...k,time:k.time/i.duration*e}))}))})}),s("label",{className:"sq-check",children:[t("input",{type:"checkbox",checked:i.loop,onChange:e=>E({...i,loop:e.target.checked})}),"Loop"]}),s("label",{className:"sq-check",children:[t("input",{type:"checkbox",checked:i.autoPlay,onChange:e=>O(d.map(a=>({...a,autoPlay:a.id===i.id?e.target.checked:!1})))}),"Autoplay"]})]}),s("div",{className:"sq-body",children:[s("div",{className:"sq-main",children:[t(ne,{controls:r,duration:i.duration,hasTracks:i.tracks.some(e=>!e.muted&&e.keyframes.length>0)}),s("div",{className:"sq-timeline","aria-label":"Sequence timeline",title:"Drag keys to retime. Arrow keys move 0.1s; Shift moves 0.01s. A key at the same time is replaced.",children:[s("div",{className:"sq-ruler",children:[t("span",{className:"sq-rulerTitle",children:"Tracks"}),t("div",{className:"sq-rulerScale",children:[0,.25,.5,.75,1].map(e=>s("span",{children:[(i.duration*e).toFixed(1),"s"]},e))})]}),!i.tracks.length&&t("p",{className:"sq-hint",children:"Add a track to create its start and end keyframes."}),i.tracks.map(e=>s("div",{className:`sq-track ${c?.id===e.id?"sq-track--active":""}`,children:[s("div",{className:"sq-trackLabel",children:[t("button",{type:"button",title:e.name,onClick:()=>{N(e.id),x(e.keyframes[0]?.id??null)},children:e.name}),s("label",{title:"Mute track",children:[t("input",{"aria-label":`Mute ${e.name}`,type:"checkbox",checked:!!e.muted,onChange:a=>z({...e,muted:a.target.checked})}),"Mute"]})]}),s("div",{className:"sq-lane",role:"group","aria-label":`${e.name} keyframes`,onDoubleClick:a=>{if(a.target!==a.currentTarget)return;let k=a.currentTarget.getBoundingClientRect(),n=Math.round(Math.max(0,Math.min(1,(a.clientX-k.left)/k.width))*i.duration*100)/100,b=r?.capture(e.target);b!=null&&C(e,{id:I(),time:n,value:b})},children:[t("span",{className:"sq-playhead",style:{left:`${q.time/i.duration*100}%`}}),e.keyframes.map(a=>{let k=D?.frameId===a.id&&D.trackId===e.id?D.time:a.time;return t("button",{type:"button",className:`sq-key ${h?.id===a.id&&c?.id===e.id?"sq-key--active":""}`,style:{left:`${k/i.duration*100}%`},"aria-label":`${e.name} keyframe at ${k.toFixed(2)} seconds`,"aria-pressed":h?.id===a.id&&c?.id===e.id,onClick:n=>{n.detail===0&&(N(e.id),x(a.id),r?.pause(),r?.seek(a.time))},onPointerDown:n=>{if(n.button!==0)return;n.preventDefault(),n.stopPropagation(),n.currentTarget.focus(),n.currentTarget.setPointerCapture(n.pointerId);let b=n.currentTarget.parentElement.getBoundingClientRect();A.current={track:e,frame:a,left:b.left,width:b.width,time:a.time},N(e.id),x(a.id),r?.pause(),r?.seek(a.time)},onPointerMove:n=>{let b=A.current;if(!b||b.frame.id!==a.id||b.track.id!==e.id)return;let W=n.shiftKey?.01:.1;b.time=Math.min(i.duration,Math.max(0,Math.round((n.clientX-b.left)/b.width*i.duration/W)*W)),K({trackId:e.id,frameId:a.id,time:b.time}),r?.seek(b.time)},onPointerUp:()=>{let n=A.current;n&&(n.time!==n.frame.time&&C(n.track,{...n.frame,time:n.time}),A.current=null,K(null))},onPointerCancel:()=>{A.current=null,K(null),r?.seek(a.time)},onKeyDown:n=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(n.key))return;n.preventDefault(),n.stopPropagation();let b=n.key==="Home"?0:n.key==="End"?i.duration:a.time+(n.key==="ArrowLeft"?-1:1)*(n.shiftKey?.01:.1);C(e,{...a,time:b})}},a.id)})]})]},e.id))]})]}),s("aside",{className:"sq-side",children:[s(ce,{title:"Add track",children:[s("label",{className:"sq-field",children:[t("span",{children:"Type"}),s("select",{"aria-label":"Track type",value:w,onChange:e=>he(e.target.value),children:[t("option",{value:"object",children:"Object"}),t("option",{value:"camera",children:"Camera"}),t("option",{value:"clip",children:"Animation clip"})]})]}),w==="object"&&s("label",{className:"sq-field",children:[t("span",{children:"Property"}),t("select",{"aria-label":"Track property",value:V,onChange:e=>xe(e.target.value),children:ee.map(e=>t("option",{value:e,children:ge[e]},e))})]}),w==="object"&&s("label",{className:"sq-field",children:[t("span",{children:"Object"}),t("select",{"aria-label":"Track object",value:M?.modelObjectId??"",onChange:e=>ye(e.target.value),children:B.map(e=>t("option",{value:e.modelObjectId,children:e.label||e.modelObjectId},e.modelObjectId))})]}),w==="clip"&&s("label",{className:"sq-field",children:[t("span",{children:"Clip"}),t("select",{"aria-label":"Track animation clip",value:R??"",onChange:e=>Se(e.target.value),children:u.map(e=>t("option",{value:e.sourceName,children:e.sourceName},e.sourceName))}),!u.length&&t("small",{children:"This model has no animation clips."})]}),t("div",{className:"rui-actions",children:s("button",{type:"button",className:"bb-button",onClick:Ne,disabled:!v||!q.ready||F||i.tracks.length>=128,children:[t(_,{size:13,"aria-hidden":"true"}),"Add track"]})}),F&&t("p",{className:"rui-note",children:"That property already has a track."})]}),c&&s("section",{className:"sq-inspector","aria-label":"Selected track and keyframe",children:[s("div",{className:"rui-groupHeader",children:[t("span",{children:"Selected track"}),t("button",{type:"button",className:"se-iconButton",title:"Delete track","aria-label":"Delete track",onClick:()=>{E({...i,tracks:i.tracks.filter(e=>e.id!==c.id)}),N(null),x(null)},children:t(G,{size:13})})]}),t(X,{label:"Name",value:c.name,onChange:e=>z({...c,name:e})}),t("div",{className:"rui-actions",children:s("button",{type:"button",className:"bb-button",disabled:!q.ready||c.keyframes.length>=2048,onClick:Ce,children:[t(Ie,{size:13,"aria-hidden":"true"}),"Add keyframe at playhead"]})}),h&&s(fe,{children:[s("div",{className:"rui-groupHeader",children:[t("span",{children:"Keyframe"}),t("button",{type:"button",className:"se-iconButton",title:"Delete keyframe","aria-label":"Delete keyframe",onClick:()=>{z({...c,keyframes:c.keyframes.filter(e=>e.id!==h.id)}),x(null)},children:t(G,{size:14})})]}),t(j,{label:"Time",min:0,max:i.duration,value:h.time,step:.01,onChange:e=>C(c,{...h,time:e})}),s("label",{className:"sq-field",children:[t("span",{children:"Easing"}),t("select",{"aria-label":"Keyframe easing",value:c.target.kind==="object"&&c.target.property==="visible"?"step":h.easing??"ease-in-out",disabled:c.target.kind==="object"&&c.target.property==="visible",onChange:e=>C(c,{...h,easing:e.target.value}),children:te.map(e=>t("option",{value:e,children:Pe[e]},e))})]}),t(me,{target:c.target,value:h.value,onChange:e=>C(c,{...h,value:e})}),t("div",{className:"rui-actions",children:s("button",{type:"button",className:"bb-button",disabled:!q.ready,onClick:()=>{let e=r?.capture(c.target);e!=null&&C(c,{...h,value:e})},children:[t(Ee,{size:13,"aria-hidden":"true"}),"Capture current value"]})})]})]})]})]})]}):s("div",{className:"sq-empty",children:[t("p",{children:"Add a sequence, then add tracks and capture keyframes on the timeline."}),s("button",{type:"button",className:"bb-button bb-button--primary",onClick:J,children:[t(_,{size:13,"aria-hidden":"true"}),"Create sequence"]})]}),(Z||q.issues.length>0)&&t("div",{role:"status",className:"sq-error",children:Z||q.issues.join(" ")})]})}export{Ae as default};
|
package/dist/chunk-25WC5KDO.mjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import{e as Ae,f as ut}from"./chunk-LX3GXQNU.mjs";import{p as Mt}from"./chunk-7JCFNZJM.mjs";import{b as Le,c as xt,i as je,t as At}from"./chunk-UHRJ2RBF.mjs";import{a as ft,b as ve}from"./chunk-GV4ZRXL6.mjs";import{f as pt,h as gt}from"./chunk-7OWHW66D.mjs";import{a as Ct,o as ke,q as jt}from"./chunk-UCD76KQ6.mjs";import{a as ge,b as bt,c as ht,d as Me,e as Ce,f as yt,g as St,h as wt}from"./chunk-RXZ4Q7CY.mjs";var Oe=new WeakMap;function nr(e,t){return Oe.set(e,t),()=>{Oe.get(e)===t&&Oe.delete(e)}}function vt(e){Oe.get(e)?.()}var kt=new WeakMap;function $e(e){let t=kt.get(e);return t||(t={state:"active",listeners:new Set},kt.set(e,t)),t}function Ue(e){return e?$e(e).state:"active"}function _e(e){return Ue(e)==="paused"}function Fe(e,t){let o=$e(e);return o.listeners.add(t),()=>{o.listeners.delete(t)}}function ir(e,t){let o=$e(e);o.state!==t&&(o.state=t,o.listeners.forEach(n=>n()))}async function re(e,t,o){if(Ue(e)==="disconnected")throw new Error("The camera is disconnected from the viewer.");vt(e);let n=async()=>{await t(!1),e.update(0)};if(_e(e))return n();if(!o){await t(!1);return}let r=[];try{await new Promise((a,s)=>{let i=!1,c=l=>{i||(i=!0,l())};if(r.push(Fe(e,()=>{let l=Ue(e);l==="paused"?n().then(()=>c(a),f=>c(()=>s(f))):l==="disconnected"&&c(()=>s(new Error("The camera move was cancelled because the viewer disconnected.")))})),e.addEventListener&&e.removeEventListener){let l=!1,f=()=>{l=!0},u=()=>{l&&c(a)};e.addEventListener("update",f),e.addEventListener("sleep",u),r.push(()=>{e.removeEventListener?.("update",f),e.removeEventListener?.("sleep",u)})}Promise.resolve().then(()=>t(!0)).then(()=>c(a),l=>c(()=>s(l)))})}finally{r.forEach(a=>a())}}import{useCallback as Z,useRef as de,useState as He,useSyncExternalStore as Un}from"react";import{Vector3 as Et}from"three";var qe=new WeakSet;function me(e){qe.add(e)}function sr(e){let t=qe.has(e);return t&&qe.delete(e),t}var We=new WeakSet;function lr(e,t){t?We.add(e):We.delete(e)}function Ot(e,t){return We.has(e)?0:t}import{Box3 as It,Matrix4 as Ln,PerspectiveCamera as Rt,Vector3 as Ge}from"three";function fr(e,t){let o=pt(e);if(!(e.camera instanceof Rt)||!t)return o;let n=t instanceof It?t:new It().setFromObject(t);return n.isEmpty()||(o.framing={aspect:e.camera.aspect,min:n.min.toArray(),max:n.max.toArray()}),o}function Tt(e,t){let o=t.camera,n=e.framing;if(!(o instanceof Rt)||!n||!(o.aspect>0)||Math.abs(o.aspect-n.aspect)<1e-6)return[...e.position];let r=new Ge(...e.position),a=new Ge(...e.target),s=r.clone().sub(a).normalize(),i=new Ln().lookAt(r,a,o.up).invert(),c=Math.tan((e.fov??o.fov)*Math.PI/360)/(e.zoom??o.zoom);if(!(c>0)||!Number.isFinite(c))return[...e.position];let l=0;for(let f of[n.min[0],n.max[0]])for(let u of[n.min[1],n.max[1]])for(let m of[n.min[2],n.max[2]]){let d=new Ge(f,u,m).sub(r).applyMatrix4(i);l=Math.max(l,Math.abs(d.x)/(c*o.aspect)+d.z,Math.abs(d.y)/c+d.z)}return r.addScaledVector(s,l*1.02).toArray()}function Bt(e){return[e.x,e.y,e.z]}function ne(e,t){let o=new Et,n=new Et;return t.getPosition(o),t.getTarget(n),{position:Bt(o),target:Bt(n),fov:"fov"in e&&typeof e.fov=="number"?e.fov:null,zoom:"zoom"in e&&typeof e.zoom=="number"?e.zoom:1,azimuthAngle:t.azimuthAngle,polarAngle:t.polarAngle}}function $n(e,t){return e?e.position[0]===t.position[0]&&e.position[1]===t.position[1]&&e.position[2]===t.position[2]&&e.target[0]===t.target[0]&&e.target[1]===t.target[1]&&e.target[2]===t.target[2]&&e.fov===t.fov&&e.zoom===t.zoom&&e.azimuthAngle===t.azimuthAngle&&e.polarAngle===t.polarAngle:!1}async function ue(e,t,o=.6){let n=e.smoothTime;e.smoothTime=Ot(e,o);try{await re(e,t,!0)}finally{e.smoothTime=n}}function jr(e={}){let t=de(e);t.current=e;let o=de(null),[n,r]=He(null),a=Z(y=>n?Fe(n,y):()=>{},[n]),s=Z(()=>_e(n),[n]),i=Un(a,s,()=>!1),[c,l]=He(null),[f,u]=He(()=>({...e.presets})),m=de(f);m.current=f;let d=Z(y=>{l(x=>$n(x,y)?x:y)},[]),p=Z(y=>{d(y)},[d]),M=de(null),b=de(null),S=de(null),A=Z(y=>{o.current=y,r(y.raw.controls);let x=ne(y.raw.controls.camera,y.raw.controls);d(x),y.raw.scene!==b.current&&(b.current=y.raw.scene,M.current=null,S.current=null),y.homeCameraState&&!M.current&&(M.current=y.homeCameraState);let{initialPosition:j,initialTarget:B,initialTransition:q=!1}=t.current;if((j||B)&&y.raw.scene&&(j||y.homeCameraState)&&S.current!==y.raw.controls){S.current=y.raw.controls,y.homeCameraState||me(y.raw.controls);let W=j??x.position,K=B??x.target;re(y.raw.controls,J=>y.raw.controls.setLookAt(W[0],W[1],W[2],K[0],K[1],K[2],J),q).then(()=>{if(o.current?.raw.controls!==y.raw.controls)return;let J=ne(y.raw.controls.camera,y.raw.controls);M.current={position:J.position,target:J.target},d(J)}).catch(()=>{})}},[d]),g=Z(async()=>{let y=o.current,x=y?.raw.controls;if(!x)return!1;try{let j=M.current;if(j){gt(x,j);let B=Tt(j,x);await ue(x,q=>x.setLookAt(B[0],B[1],B[2],j.target[0],j.target[1],j.target[2],q))}else y?.raw.scene?await ue(x,B=>x.fitToBox(y.raw.scene,B,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5})):await ue(x,B=>x.reset(B));return!0}catch{return!1}},[]),w=Z(async()=>{let y=o.current;if(!y?.raw.controls||!y.raw.scene)return!1;try{return await ue(y.raw.controls,x=>y.raw.controls.fitToBox(y.raw.scene,x,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5})),!0}catch{return!1}},[]),v=Z(async y=>{let x=o.current;if(!x?.raw.controls)return!1;let j=ft(x.objectBindings,y);if(!j)return!1;let B=x.objectBindings[j]?.cameraState;if(B?.position&&B?.target){let[W,K,J]=B.position,[_,I,U]=B.target;try{return await ue(x.raw.controls,L=>x.raw.controls.setLookAt(W,K,J,_,I,U,L)),!0}catch{return!1}}let q=x.raw.nodes[j];if(!q)return!1;try{return await ue(x.raw.controls,W=>x.raw.controls.fitToBox(q,W,{paddingTop:.5,paddingBottom:.5,paddingLeft:.5,paddingRight:.5})),!0}catch{return!1}},[]),P=Z(async(y,x=!0)=>{let j=o.current?.raw.controls;if(!j)return!1;try{return o.current?.homeCameraState||me(j),await re(j,B=>j.setTarget(y[0],y[1],y[2],B),x),d(ne(j.camera,j)),!0}catch{return!1}},[d]),T=Z(async(y,x=!0)=>{let j=o.current?.raw.controls;if(!j)return!1;try{o.current?.homeCameraState||me(j),await re(j,async W=>{let K=[j.setLookAt(y.position[0],y.position[1],y.position[2],y.target[0],y.target[1],y.target[2],W)];y.azimuthAngle!=null&&y.polarAngle!=null&&K.push(j.rotateTo(y.azimuthAngle,y.polarAngle,W)),await Promise.all(K)},x);let B=j.camera,q=!1;return y.fov!=null&&"fov"in B&&typeof B.fov=="number"&&(B.fov=y.fov,q=!0),y.zoom!=null&&"zoom"in B&&typeof B.zoom=="number"&&(B.zoom=y.zoom,q=!0),q&&"updateProjectionMatrix"in B&&B.updateProjectionMatrix(),d(ne(B,j)),!0}catch{return!1}},[d]),N=Z((y,x=!0)=>T(y,x),[T]),O=Z((y,x,j=!0)=>T({position:y,target:x},j),[T]),h=Z(async(y,x,j=!0)=>{let B=o.current?.raw.controls;if(!B)return!1;try{return o.current?.homeCameraState||me(B),await re(B,q=>B.rotateTo(y*Math.PI/180,x*Math.PI/180,q),j),d(ne(B.camera,B)),!0}catch{return!1}},[d]),C=Z(async(y,x=!0)=>{let j=o.current?.raw.controls;if(!j)return!1;try{return o.current?.homeCameraState||me(j),await re(j,B=>j.dollyTo(y,B),x),d(ne(j.camera,j)),!0}catch{return!1}},[d]),k=Z(y=>{let x={...y};m.current=x,u(x)},[]),E=Z(y=>{let x=o.current?.raw.controls,j=y.trim();if(!x||!j)return null;let B=ne(x.camera,x);return m.current={...m.current,[j]:B},u(q=>({...q,[j]:B})),d(B),B},[d]),V=Z((y,x=!0)=>{let j=m.current[y];return j?T(j,x):Promise.resolve(!1)},[T]);return{isRenderPaused:i,cameraState:c,cameraPresets:f,setCameraPresets:k,resetView:g,focusObject:v,fitScene:w,setCameraTarget:P,setCameraState:N,lookAt:O,orbitTo:h,dollyTo:C,savePreset:E,goToPreset:V,handleCameraChange:p,handleViewerReady:A}}function kr(e){let t=e.trim();return t?/\.(hdr|exr|jpg|jpeg|png|webp)(?:[?#].*)?$/i.test(t):!1}var Or=["none","directional","point","spot","hemisphere"],Ir=["pbr","matcap","uv-checker"],Rr=["neutral","apartment","city","dawn","forest","lobby","night","park","studio","sunset","warehouse"];var Tr=["sporadic","constantMild","constantWild"],Er=["linear","radial","mirroredLinear"],Br=["verySmall","small","medium","large","veryLarge","huge"];var Xe={enabled:!1,axis:"y",position:.5,flip:!1},_n={clips:[],autoplayClip:null},Fn={autofocus:{enabled:!1,focusDistance:5,focusRange:5,focalLength:.02,bokehScale:6,target:[0,0,0],mouse:!0,debug:0,manual:!1,smoothTime:.25},toneMapping:{enabled:!1,mode:"aces",exposure:1,resolution:256,whitePoint:4,middleGrey:.6,minLuminance:.01,averageLuminance:1,adaptationRate:1},brightnessContrast:{enabled:!1,brightness:0,contrast:0},hueSaturation:{enabled:!1,hue:0,saturation:0},colorAverage:{enabled:!1},dotScreen:{enabled:!1,angle:Math.PI/2,scale:1},glitch:{enabled:!1,mode:"sporadic",delay:[1.5,3.5],duration:[.6,1],strength:[.3,1],chromaticAberrationOffset:[0,0],columns:.05,ratio:.85},ssao:{enabled:!1,samples:30,rings:4,intensity:8,radius:.25,bias:.025,luminanceInfluence:.6,fade:.01,minRadiusScale:.33,worldDistanceThreshold:20,worldDistanceFalloff:5,worldProximityThreshold:6,worldProximityFalloff:3},bloom:{enabled:!1,intensity:.3,luminanceThreshold:.9,luminanceSmoothing:.2,mipmapBlur:!0,radius:0,levels:8},godRays:{enabled:!1,sunPosition:[5,10,5],samples:60,density:.96,decay:.9,weight:.4,exposure:.6,clampMax:1,blur:!0,kernelSize:"small"},grid:{enabled:!1,scale:1,lineWidth:0},noise:{enabled:!1,opacity:1,premultiply:!1},depthOfField:{enabled:!1,focusDistance:5,focusRange:5,focalLength:.02,bokehScale:6},chromaticAberration:{enabled:!1,offsetX:.002,offsetY:.002,radialModulation:!1,modulationOffset:.15},lensflare:{enabled:!1,lensPosition:[-25,6,-60],smoothTime:.07,glareSize:.2,flareSize:.01,flareSpeed:.01,flareShape:.01,animated:!0,anamorphic:!1,colorGain:"#141414",haloScale:.5,secondaryGhosts:!0,aditionalStreaks:!0,ghostScale:0,opacity:1,starBurst:!1},vignette:{enabled:!1,offset:.3,darkness:.3,eskil:!1},smaa:{enabled:!1},sepia:{enabled:!1,intensity:0},scanline:{enabled:!1,density:1.25},pixelation:{enabled:!1,granularity:5},outline:{enabled:!1,selectionLayer:10,edgeStrength:2.5,pulseSpeed:0,visibleEdgeColor:"#ffffff",hiddenEdgeColor:"#22090a",kernelSize:"large",blur:!1,xRay:!0},selectiveBloom:{enabled:!1,selectionLayer:10,intensity:1,luminanceThreshold:.9,luminanceSmoothing:.025,kernelSize:"large",mipmapBlur:!0,inverted:!1,ignoreBackground:!1},ramp:{enabled:!1,rampType:"linear",rampStart:[.5,.5],rampEnd:[1,1],startColor:"#000000",endColor:"#ffffff",opacity:.5,rampBias:.5,rampGain:.5,rampMask:!1,rampInvert:!1}},fe={model:{rotation:[0,0,0],showAdvancedRotation:!1,renderer:"pbr",shading:"lit",autoRotate:!1,autoRotateSpeed:1},camera:{fieldOfView:50,showAdvancedSettings:!1},lighting:{ambient:{intensity:.25,color:"#ffffff"},lights:[{id:"light-hemi",type:"hemisphere",color:"#ffffff",intensity:.3,position:[0,1,0],attachedToCamera:!1,castShadow:!1,shadowBias:-5e-4,visible:!0},{id:"light-key",type:"directional",color:"#ffffff",intensity:2.5,position:[6,12,6],attachedToCamera:!1,castShadow:!0,shadowBias:-5e-4,visible:!0},{id:"light-fill",type:"directional",color:"#ffffff",intensity:0,position:[-6,8,-6],attachedToCamera:!1,castShadow:!1,shadowBias:-5e-4,visible:!0}]},shadows:{enabled:!0,mapSize:2048,bias:-5e-4,normalBias:.02,radius:3},environment:{source:"preset",preset:"neutral",customEnvironmentUrl:"",intensity:.25,rotation:0,shadowLight:{enabled:!1,intensity:2.5,bias:-5e-4}},wireframe:{enabled:!1,color:"#000000",opacity:1},background:{enabled:!1,type:"color",color:"#1c1c1d",imageUrl:""},groundShadows:{enabled:!1,mode:"shadowCatcher",intensity:.7,borderFade:1,height:0,size:10},postProcessing:Fn,animations:_n,annotations:[]};function be(e){let t=f=>{throw new Error(`Invalid section: ${f}`)},o=f=>f&&typeof f=="object"&&!Array.isArray(f)?f:t("expected an object"),n=f=>typeof f=="string"&&f.trim().length>0&&f.length<=200?f:t("expected a nonempty name or id (up to 200 characters)"),r=f=>typeof f=="number"&&Number.isFinite(f)&&f>=0&&f<=1?f:t("position must be between 0 and 1"),a=f=>!Array.isArray(f)||f.length!==3||!f.every(u=>typeof u=="number"&&Number.isFinite(u))||Math.hypot(...f)<1e-8?t("normal must be a finite, nonzero vector"):[...f],s=f=>{let u=o(f);return!["x","y","z"].includes(u.axis)||typeof u.enabled!="boolean"||typeof u.flip!="boolean"?t("invalid plane"):{enabled:u.enabled,axis:u.axis,position:r(u.position),flip:u.flip,...u.normal!==void 0?{normal:a(u.normal)}:{}}},i=f=>{let u=o(f),m=s(u);if(u.mode!==void 0){if(!["plane","planes","box"].includes(u.mode))return t("invalid mode");m.mode=u.mode}if(u.planes!==void 0){if(!Array.isArray(u.planes)||u.planes.length>6)return t("at most six planes are supported");let d=new Set;m.planes=u.planes.map(p=>{let M=o(p),b=n(M.id);return d.has(b)?t("duplicate plane id"):(d.add(b),{...s(M),id:b,name:n(M.name)})})}if(u.activePlaneId!==void 0&&(m.activePlaneId=n(u.activePlaneId)),u.invertBox!==void 0){if(typeof u.invertBox!="boolean")return t("invalid box inversion");m.invertBox=u.invertBox}if(u.box!==void 0){let d=o(u.box),p=S=>!Array.isArray(S)||S.length!==3?t("invalid box bounds"):S.map(r),M=p(d.min),b=p(d.max);if(M.some((S,A)=>S>=b[A]))return t("box minimum must be below its maximum on every axis");m.box={min:M,max:b}}return m},c=o(e),l=i(c);if(c.presets!==void 0){if(!Array.isArray(c.presets)||c.presets.length>32)return t("at most 32 presets are supported");let f=new Set;l.presets=c.presets.map(u=>{let m=o(u),d=n(m.id);return f.has(d)?t("duplicate preset id"):(f.add(d),{id:d,name:n(m.name),settings:i(m.settings)})})}return l}function Vr(e){let{presets:t,...o}=be(e);return o}function zr(e){try{return be(e)}catch{return Xe}}function Dr(e,t){if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Invalid section: expected an object");let o=["enabled","axis","position","flip"].every(n=>Object.prototype.hasOwnProperty.call(t,n));return be(o?t:{...Xe,...e,...t})}import{Box3 as Pt,Matrix4 as Re,Quaternion as qn,Vector3 as Ie,Euler as Wn}from"three";var $r={version:1,placements:{},gridSize:1};function Ke(e){return e.id??e.url}function he(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Expected an asset transform object.");let t={};for(let o of["position","rotation","scale"]){let n=e[o];if(n!==void 0){if(!Array.isArray(n)||n.length!==3||!n.every(r=>typeof r=="number"&&Number.isFinite(r))||o==="scale"&&n.some(r=>r===0))throw new Error(`Invalid asset ${o}: expected three finite ${o==="scale"?"nonzero ":""}numbers.`);t[o]=[...n]}}return t}function _r(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid scene composition.");let t=e;if(t.version!==1||!Number.isFinite(t.gridSize)||t.gridSize<=0||!t.placements||typeof t.placements!="object"||Array.isArray(t.placements)||Object.keys(t.placements).length>256)throw new Error("Invalid scene composition version, grid size or placements (maximum 256).");let o={};for(let[n,r]of Object.entries(t.placements)){if(!n||["__proto__","constructor","prototype"].includes(n))throw new Error("Invalid asset instance ID.");let a=he(r);if(r.label!==void 0&&(typeof r.label!="string"||r.label.length>512))throw new Error("Invalid asset label.");for(let s of["visible","deleted"])if(r[s]!==void 0&&typeof r[s]!="boolean")throw new Error(`Invalid asset ${s}.`);o[n]={...a,...r.label!==void 0?{label:r.label}:{},...r.visible!==void 0?{visible:r.visible}:{},...r.deleted!==void 0?{deleted:r.deleted}:{}}}return{version:1,gridSize:t.gridSize,placements:o}}function Fr(e,t){if(!Number.isFinite(t)||t<=0)throw new Error("Grid size must be positive.");let o=he(e),[n,r,a]=o.position??[0,0,0];return{...o,position:[Math.round(n/t)*t,r,Math.round(a/t)*t]}}function qr(e,t){let o=he(e),n=o.position??[0,0,0],r=new Re().compose(new Ie(...n),new qn().setFromEuler(new Wn(...o.rotation??[0,0,0])),new Ie(...o.scale??[1,1,1])),a=new Pt(new Ie(...t.min),new Ie(...t.max)).applyMatrix4(r);if(!Number.isFinite(a.min.y))throw new Error("Cannot place an asset with empty bounds.");return{...o,position:[n[0],n[1]-a.min.y,n[2]]}}function Wr(e){e.updateWorldMatrix(!0,!0);let t=new Re().copy(e.parent?.parent?.matrixWorld??new Re).invert(),o=new Pt;return e.traverse(n=>{let r=n;r.geometry&&(r.geometry.computeBoundingBox(),r.geometry.boundingBox&&o.union(r.geometry.boundingBox.clone().applyMatrix4(new Re().multiplyMatrices(t,r.matrixWorld))))}),o.isEmpty()||![...o.min.toArray(),...o.max.toArray()].every(Number.isFinite)?null:{min:o.min.toArray(),max:o.max.toArray()}}import{BufferGeometry as Gn,Float32BufferAttribute as Hn,Matrix4 as Vt,Mesh as Ze,ShapeUtils as Xn,Vector2 as zt,Vector3 as H,Vector4 as Kn}from"three";function Dt(e){if(e.length!==3)return null;let t=new H(...e[0]).sub(new H(...e[1])),o=new H(...e[2]).sub(new H(...e[1]));return t.lengthSq()===0||o.lengthSq()===0?null:Math.acos(Math.max(-1,Math.min(1,t.normalize().dot(o.normalize()))))*180/Math.PI}function Lt(e,t){if(!e.normal)return null;let o=new H(...e.normal);if(o.lengthSq()===0)return null;o.normalize();let n=new H(...t),r=n.clone().sub(new H(...e.position)).dot(o);return{distance:Math.abs(r),projection:n.addScaledVector(o,-r).toArray()}}function Ut(e){if(e.length<3)return{error:"Pick at least three points to finish the area."};let t=new H(...e[0]),o=e.map(b=>new H(...b).sub(t)),n=Math.max(...o.map(b=>b.length()));if(n===0)return{error:"Area points must be distinct."};let r=new H;for(let b=1;b<o.length-1;b+=1){let S=o[b].clone().cross(o[b+1]);S.lengthSq()>r.lengthSq()&&r.copy(S)}if(r.length()<=n*n*1e-10)return{error:"Area points must not lie on one straight line."};r.normalize();let a=Math.max(n*1e-5,Number.EPSILON*Math.max(...e.flat().map(Math.abs))*32);if(o.some(b=>Math.abs(b.dot(r))>a))return{error:"Area points must lie on one plane."};let s=o.find(b=>b.length()>n*1e-10).clone().normalize(),i=r.clone().cross(s).normalize(),c=o.map(b=>new zt(b.dot(s),b.dot(i))),l=(b,S,A)=>(S.x-b.x)*(A.y-b.y)-(S.y-b.y)*(A.x-b.x),f=n*n*1e-10,u=(b,S,A)=>Math.abs(l(b,S,A))<=f&&A.x>=Math.min(b.x,S.x)-n*1e-10&&A.x<=Math.max(b.x,S.x)+n*1e-10&&A.y>=Math.min(b.y,S.y)-n*1e-10&&A.y<=Math.max(b.y,S.y)+n*1e-10;for(let b=0;b<c.length;b+=1){let S=c[b],A=c[(b+1)%c.length];if(S.distanceTo(A)<=n*1e-10)return{error:"Area points must be distinct."};for(let g=b+1;g<c.length;g+=1){if(g===b+1||b===0&&g===c.length-1)continue;let w=c[g],v=c[(g+1)%c.length],P=l(S,A,w),T=l(S,A,v),N=l(w,v,S),O=l(w,v,A);if(P*T<0&&N*O<0||u(S,A,w)||u(S,A,v)||u(w,v,S)||u(w,v,A))return{error:"Area edges must not cross or touch each other."}}}let m=0,d=0,p=0;for(let b=0;b<c.length;b+=1){let S=c[b],A=c[(b+1)%c.length],g=S.x*A.y-A.x*S.y;m+=g,d+=(S.x+A.x)*g,p+=(S.y+A.y)*g}if(Math.abs(m)<=f)return{error:"The polygon has no measurable area."};let M=t.clone().addScaledVector(s,d/(3*m)).addScaledVector(i,p/(3*m));return{area:Math.abs(m)/2,center:M.toArray(),triangles:Xn.triangulateShape(c,[])}}function Ye(e,t){if(e.length<2)return 0;let o=0;for(let n=1;n<e.length;n+=1)o+=new H(...e[n]).distanceTo(new H(...e[n-1]));return t&&(o+=new H(...e[e.length-1]).distanceTo(new H(...e[0]))),o}var Zn=1e-5;function Yn(e,t){let o=e.getAttribute("position"),n=e.getIndex(),r=o.count,a=Math.max(t,1e-9),s=(p,M,b)=>`${Math.round(p/a)}_${Math.round(M/a)}_${Math.round(b/a)}`,i=new Int32Array(r),c=[],l=new Map;for(let p=0;p<r;p+=1){let M=o.getX(p),b=o.getY(p),S=o.getZ(p),A=s(M,b,S),g=l.get(A);g===void 0&&(g=c.length,c.push(new H(M,b,S)),l.set(A,g)),i[p]=g}let f=c.map(()=>new Map),u=(p,M)=>{if(p===M)return;let b=c[p].distanceTo(c[M]);f[p].has(M)||f[p].set(M,b),f[M].has(p)||f[M].set(p,b)},m=(n?n.count:r)/3,d=p=>n?n.getX(p):p;for(let p=0;p<m;p+=1)u(i[d(p*3)],i[d(p*3+1)]),u(i[d(p*3+1)],i[d(p*3+2)]),u(i[d(p*3+2)],i[d(p*3)]);return{weldedId:i,weldedPosition:c,neighbors:f}}function Jn(e,t,o){let n=new Map([[t,0]]),r=[t];for(let a=0;a<o&&r.length>0;a+=1){let s=[];for(let i of r){let c=n.get(i)??0;for(let[l,f]of e[i]??[])n.has(l)||(n.set(l,c+f),s.push(l))}r=s}return n}function Qn(e){let o=(Math.abs(e.y)<.9?new H(0,1,0):new H(1,0,0)).clone().cross(e).normalize(),n=e.clone().cross(o).normalize();return[o,n]}function eo(e,t,o){let[n,r]=Qn(t),a=0,s=0,i=0;for(let M of o){let b=M.clone().sub(e),S=b.dot(n),A=b.dot(r);a+=S*S,s+=S*A,i+=A*A}let c=a+i,l=a*i-s*s,f=Math.sqrt(Math.max(0,c*c/4-l)),u=c/2+f,m=1,d=0;Math.abs(s)>1e-12?(m=u-i,d=s):i>a&&(m=0,d=1);let p=Math.hypot(m,d)||1;return n.clone().multiplyScalar(m/p).add(r.clone().multiplyScalar(d/p)).normalize()}function to(e,t,o,n){let r=e.getAttribute("position"),a=e.getIndex(),s=r.count,i=(a?a.count:s)/3,c=m=>a?a.getX(m):m,l=m=>new H(r.getX(m),r.getY(m),r.getZ(m)).applyMatrix4(t),f=m=>m.clone().sub(o).dot(n),u=[];for(let m=0;m<i;m+=1){let d=l(c(m*3)),p=l(c(m*3+1)),M=l(c(m*3+2)),b=f(d),S=f(p),A=f(M),g=[],w=(v,P,T,N)=>{P>0!=N>0&&g.push(v.clone().lerp(T,P/(P-N)))};w(d,b,p,S),w(p,S,M,A),w(M,A,d,b),g.length===2&&u.push([g[0],g[1]])}return u}function no(e,t){let o=Math.max(t,1e-9),n=m=>`${Math.round(m.x/o)}_${Math.round(m.y/o)}_${Math.round(m.z/o)}`,r=new Map,a=[],s=m=>{let d=n(m),p=r.get(d);return p===void 0&&(p=a.length,a.push(m),r.set(d,p)),p},i=[],c=m=>{for(;i.length<=m;)i.push(new Map)};for(let[m,d]of e){let p=s(m),M=s(d);p!==M&&(c(p),c(M),i[p].set(M,(i[p].get(M)??0)+1),i[M].set(p,(i[M].get(p)??0)+1))}let l=(m,d)=>m<d?`${m}_${d}`:`${d}_${m}`,f=new Set,u=[];for(let m=0;m<i.length;m+=1)for(let d of i[m]?.keys()??[]){if(f.has(l(m,d)))continue;let p=[m],M=m,b=d;f.add(l(M,b));let S=0;for(;b!==m&&b>=0&&S<i.length+4;){p.push(b);let A=[...i[b].keys()].filter(w=>w!==M),g;if(A.length<=1)g=A[0];else{let w=a[b].clone().sub(a[M]).normalize(),v=-1/0;for(let P of A){let T=a[P].clone().sub(a[b]).normalize(),N=w.dot(T);N>v&&(v=N,g=P)}}if(g===void 0){b=-1;break}f.add(l(b,g)),M=b,b=g,S+=1}b===m&&p.length>=3&&u.push(p.map(A=>a[A]))}return u}function Nt(e,t){let o=1/0;for(let n of e)o=Math.min(o,n.distanceTo(t));return o}function oo(e,t){let o=0,n=1/0;return e.forEach((r,a)=>{let s=r.distanceTo(t);s<n&&(n=s,o=a)}),[...e.slice(o),...e.slice(0,o)]}function $t(e,t,o,n,r){let a=to(e,t,n,r);if(a.length===0)return{error:"Couldn't trace a loop around this point."};let s=no(a,o*t.getMaxScaleOnAxis());if(s.length===0)return{error:"The surface here doesn't form a closed loop around this point (it may be near an open edge)."};let i=s[0],c=Nt(i,n);for(let f of s.slice(1)){let u=Nt(f,n);u<c&&(c=u,i=f)}let l=oo(i,n).map(f=>f.toArray());return{points:l,length:Ye(l,!0)}}function _t(e){if(!(e.object instanceof Ze)||!e.face)return null;let t=e.object,o=t.geometry;if(t.isSkinnedMesh||t.morphTargetInfluences?.some(a=>a!==0)){let a=o.getAttribute("position"),s=new Hn(new Float32Array(a.count*3),3),i=new H;for(let c=0;c<a.count;c++)t.getVertexPosition(c,i),s.setXYZ(c,i.x,i.y,i.z);o=new Gn().setAttribute("position",s).setIndex(o.getIndex())}let n=t.matrixWorld.clone();if(e.instanceId!==void 0&&"getMatrixAt"in t){let a=new Vt;t.getMatrixAt(e.instanceId,a),n.multiply(a)}o.computeBoundingSphere();let r=o.boundingSphere&&o.boundingSphere.radius>0?o.boundingSphere.radius:1;return{face:e.face,geometry:o,matrix:n,weldTolerance:r*Zn}}function Xr(e,t=6){let o=_t(e);if(!o)return{error:"Pick a point on the mesh surface to trace a loop around it."};let{face:n,geometry:r,matrix:a,weldTolerance:s}=o,i=Ft(e);if(!i)return{error:"Pick a point on the mesh surface to trace a loop around it."};let c=i[1].clone().sub(i[0]).cross(i[2].clone().sub(i[0]));if(c.lengthSq()===0)return{error:"Couldn't determine the surface direction at this point."};c.normalize();let{weldedId:l,weldedPosition:f,neighbors:u}=Yn(r,s),m=r.getAttribute("position"),d=e.point.clone().applyMatrix4(a.clone().invert()),p=[n.a,n.b,n.c],M=p[0],b=1/0;for(let P of p){let N=new H(m.getX(P),m.getY(P),m.getZ(P)).distanceTo(d);N<b&&(b=N,M=P)}let S=l[M],A=f[S].clone().applyMatrix4(a),g=Jn(u,S,t),w=[];for(let P of g.keys())w.push(f[P].clone().applyMatrix4(a));if(w.length<6)return{error:"Not enough surface detail near this point to trace a loop. Try a different spot."};let v=eo(A,c,w);return $t(r,a,s,e.point.clone(),v)}function Kr(e,t=new H(0,1,0)){let o=_t(e);if(!o)return{error:"Pick a point on the mesh surface to trace a loop around it."};let{geometry:n,matrix:r,weldTolerance:a}=o,s=t.clone().normalize();return s.lengthSq()===0?{error:"Couldn't determine a horizontal direction."}:$t(n,r,a,e.point.clone(),s)}function Ft(e){if(!(e.object instanceof Ze)||!e.face)return null;let t=e.object,o=t.matrixWorld.clone();if(e.instanceId!==void 0&&"getMatrixAt"in t){let n=new Vt;t.getMatrixAt(e.instanceId,n),o.multiply(n)}return[e.face.a,e.face.b,e.face.c].map(n=>t.getVertexPosition(n,new H).applyMatrix4(o))}function Zr(e){if(!(e.object instanceof Ze))return!1;for(let o=e.object;o;o=o.parent)if(!o.visible||o.userData.riEditorGizmo||o.userData.riDecal)return!1;return(Array.isArray(e.object.material)?e.object.material:[e.object.material])[e.face?.materialIndex??0]?.visible!==!1}function Yr(e,t,o,n,r,a=12){let s=Ft(e),i=s?s[1].clone().sub(s[0]).cross(s[2].clone().sub(s[0])).normalize():null,c={position:e.point.toArray(),...i&&i.lengthSq()>0?{normal:i.toArray()}:{},...s?{faceVertices:s.map(m=>m.toArray())}:{}};if(!s||r==="none")return c;let l=m=>{let d=new Kn(m.x,m.y,m.z,1).applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix);return d.w<=0||d.z/d.w<-1||d.z/d.w>1?null:{screen:new zt((d.x/d.w+1)*n.width/2,(1-d.y/d.w)*n.height/2),w:d.w}},f=s.map(l),u=a;if((r==="vertex"||r==="auto")&&(f.forEach((m,d)=>{let p=m?.screen.distanceTo(o)??1/0;p<=u&&(u=p,c.position=s[d].toArray(),c.snapped="vertex")}),c.snapped))return c;if(r==="edge"||r==="auto")for(let m=0;m<3;m+=1){let d=(m+1)%3,p=f[m],M=f[d];if(!p||!M)continue;let b=M.screen.clone().sub(p.screen);if(b.lengthSq()===0)continue;let S=Math.max(0,Math.min(1,o.clone().sub(p.screen).dot(b)/b.lengthSq())),A=p.screen.clone().addScaledVector(b,S).distanceTo(o);if(A<=u){u=A;let g=S*p.w/((1-S)*M.w+S*p.w);c.position=s[m].clone().lerp(s[d],g).toArray(),c.snapped="edge"}}return c}var ro=["m","cm","mm","in","ft"],Je={m:1,cm:.01,mm:.001,in:.0254,ft:.3048},io=["distance","angle","area","pointToPlane","wrap","wrapHorizontal"];function Qe(e){return ro.includes(e)}function ao(e={},t="m"){let o=e.displayUnit??t,n=e.metersPerUnit??Je[e.sourceUnit??"m"];if(!Number.isFinite(n)||n<=0)throw new Error("Measurement scale must be a positive finite number.");return{displayUnit:o,metersPerUnit:n,factor:Qe(o)?n/Je[o]:1}}function ei(e){try{return new URL(e,typeof window<"u"?window.location?.href:void 0).href}catch{return e}}function ti(e,t,o,n={}){if(!Qe(o)||!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0)throw new Error("Calibration needs two distinct points and a positive known distance.");let r=t*Je[o]/e;if(!Number.isFinite(r)||r<=0)throw new Error("Calibration scale is outside the supported range.");return{...n,metersPerUnit:r}}function qt(e,t){let o=t.map(n=>n.position);if(e==="angle"){let n=Dt(o);return n===null?null:{value:n,dimension:0}}if(e==="area"){let n=Ut(o);return"error"in n?null:{value:n.area,dimension:2}}if(e==="pointToPlane"){let n=t.length===2?Lt(t[0],t[1].position):null;return n?{value:n.distance,dimension:1}:null}return t.length<(e==="distance"?2:3)?null:{value:Ye(o,e!=="distance"),dimension:1}}function so(e,t={},o="m",n=e.points,r=e.approximate?"approximate":"ready"){let a=qt(e.tool,n),{factor:s,displayUnit:i}=ao(t,o),c=r==="ready"||r==="approximate",l=c&&a?a.value*s**a.dimension:null;return{id:e.id,status:c?a&&l!==null&&Number.isFinite(l)?r:"invalid":r,rawValue:c&&a&&Number.isFinite(a.value)?a.value:null,value:l!==null&&Number.isFinite(l)?l:null,unit:e.tool==="angle"?"\xB0":e.tool==="area"?`${i}\xB2`:i}}function ye(e){function t(){throw new Error("Invalid measurements: expected settings and valid named measurements with finite points.")}let o=i=>!!i&&typeof i=="object"&&!Array.isArray(i),n=i=>Array.isArray(i)&&i.length===3&&i.every(c=>typeof c=="number"&&Number.isFinite(c));typeof e=="string"&&(e.length>5*1024*1024&&t(),e=JSON.parse(e)),(!o(e)||e.version!==void 0&&e.version!==1||!o(e.settings)||!Array.isArray(e.items)||e.items.length>256)&&t();let r={};for(let i of["sourceUnit","displayUnit"])e.settings[i]!==void 0&&(Qe(e.settings[i])||t(),r[i]=e.settings[i]);e.settings.metersPerUnit!==void 0&&((typeof e.settings.metersPerUnit!="number"||!Number.isFinite(e.settings.metersPerUnit)||e.settings.metersPerUnit<=0)&&t(),r.metersPerUnit=e.settings.metersPerUnit);let a=new Set,s=e.items.map(i=>{(!o(i)||typeof i.id!="string"||!i.id||a.has(i.id)||typeof i.name!="string"||!i.name.trim()||typeof i.modelId!="string"||!i.modelId||!io.includes(i.tool)||!Array.isArray(i.points)||i.points.length>8192||typeof i.createdAt!="string"||!Number.isFinite(Date.parse(i.createdAt)))&&t(),a.add(i.id),i.tilesetUrl!==void 0&&i.tilesetUrl!==null&&typeof i.tilesetUrl!="string"&&t(),(i.visible!==void 0&&typeof i.visible!="boolean"||i.approximate!==void 0&&typeof i.approximate!="boolean")&&t();let c=new Set,l=i.points.map(u=>{if((!o(u)||typeof u.id!="number"||!Number.isFinite(u.id)||!n(u.position))&&t(),c.has(u.id)&&t(),c.add(u.id),u.normal!==void 0&&!n(u.normal)&&t(),u.faceVertices!==void 0&&(!Array.isArray(u.faceVertices)||u.faceVertices.length!==3||!u.faceVertices.every(n))&&t(),u.snapped!==void 0&&!["vertex","edge"].includes(u.snapped)&&t(),u.anchor!==void 0){let d=u.anchor;(!o(d)||typeof d.nodeId!="string"||!d.nodeId||!n(d.localPosition)||typeof d.geometrySignature!="string"||typeof d.poseSignature!="string")&&t(),d.localNormal!==void 0&&!n(d.localNormal)&&t(),d.localFaceVertices!==void 0&&(!Array.isArray(d.localFaceVertices)||d.localFaceVertices.length!==3||!d.localFaceVertices.every(n))&&t(),d.instanceId!==void 0&&(!Number.isInteger(d.instanceId)||d.instanceId<0)&&t()}let m=u.anchor;return{id:u.id,position:[...u.position],...u.normal?{normal:[...u.normal]}:{},...u.faceVertices?{faceVertices:u.faceVertices.map(d=>[...d])}:{},...u.snapped?{snapped:u.snapped}:{},...m?{anchor:{nodeId:m.nodeId,localPosition:[...m.localPosition],geometrySignature:m.geometrySignature,poseSignature:m.poseSignature,...m.localNormal?{localNormal:[...m.localNormal]}:{},...m.localFaceVertices?{localFaceVertices:m.localFaceVertices.map(d=>[...d])}:{},...m.instanceId!==void 0?{instanceId:m.instanceId}:{}}}:{}}}),f={id:i.id,name:i.name,modelId:i.modelId,tool:i.tool,points:l,createdAt:i.createdAt,...i.tilesetUrl!==void 0?{tilesetUrl:i.tilesetUrl}:{},...i.visible!==void 0?{visible:i.visible}:{},...i.approximate!==void 0?{approximate:i.approximate}:{}};return qt(f.tool,l)||t(),f});return{settings:r,items:s}}function ni(e){return JSON.stringify({version:1,...ye(e)},null,2)}function oi(e,t,o="m"){let n=ye(e),r=new Map(t?.map(s=>[s.id,s])),a=s=>{let i=String(s??"");return/^[=+@-]/.test(i)&&(i=`'${i}`),`"${i.replace(/"/g,'""')}"`};return[["id","name","modelId","type","status","value","unit","createdAt"],...n.items.map(s=>{let i=r.get(s.id)??so(s,n.settings,o);return[s.id,s.name,s.modelId,s.tool,i.status,i.value,i.unit,s.createdAt]})].map(s=>s.map(a).join(",")).join(`\r
|
|
2
|
-
`)}function Wt(e){if(!Array.isArray(e)||e.length>128)throw new Error("Invalid selections: expected up to 128 named selection sets.");let t=new Set;return e.map(o=>{if(!o||typeof o!="object"||typeof o.id!="string"||!o.id||t.has(o.id)||typeof o.name!="string"||!o.name.trim()||o.name.length>200||!Array.isArray(o.objectIds)||o.objectIds.length>1e5||o.objectIds.some(n=>typeof n!="string"||!n))throw new Error("Invalid selections: each set needs a unique id, a name, and model object ids.");return t.add(o.id),{id:o.id,name:o.name.trim(),objectIds:[...new Set(o.objectIds)]}})}var ie=5*1024*1024,co=["activeModelId","modelUrl","modelFormat","tilesetUrl","models","mergeModels","sceneConfig","isolation","multiSelectedKeys","activeAnnotation","annotationCategories","backgroundColor","shadows","cinematic","cameraControllerType","objectTransformSpace","arScaleMode","usdzUrl","measurements","measurementSettings","measurementUnit","measurementModelId"];function R(e,t){throw new Error(`Invalid viewer state at ${e}: ${t}`)}function X(e,t){(!e||typeof e!="object"||Array.isArray(e))&&R(t,"expected an object.")}function Se(e,t){(!Array.isArray(e)||!e.every(o=>typeof o=="string"))&&R(t,"expected strings.")}function ee(e,t,o){(!Array.isArray(e)||e.length!==t||!e.every(n=>typeof n=="number"&&Number.isFinite(n)))&&R(o,`expected ${t} finite numbers.`)}function lo(e){let t=new Set,o=0;function n(r,a,s){if((++o>2e5||s>64)&&R(a,"configuration is too complex."),r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r))return r;(typeof r!="object"||!r)&&R(a,"expected JSON data (finite numbers, no functions)."),t.has(r)&&R(a,"cyclic data."),!Array.isArray(r)&&Object.getPrototypeOf(r)!==Object.prototype&&Object.getPrototypeOf(r)!==null&&R(a,"expected plain JSON data."),t.add(r);let i=Array.isArray(r)?[]:{};for(let[c,l]of Object.entries(r))["__proto__","constructor","prototype"].includes(c)&&R(`${a}.${c}`,"reserved property."),l!==void 0?i[c]=n(l,`${a}.${c}`,s+1):Array.isArray(r)&&R(a,"undefined array entry.");return t.delete(r),i}return n(e,"state",0)}function te(e,t,o,n,r=!1,a){let s=e[t];if(s==null||s==="")return;typeof s!="string"&&R(o,"expected a URL.");let i=r?je(s)??s:s;if(i.trim().startsWith("blob:")){if(r&&a){a.set(s,{source:i,path:o});return}R(o,r?"this image is temporary. Use getStateAsync() for JSON or createShareUrl() to include it.":"upload this model/environment asset to a durable URL before saving or sharing.")}if(i!==s&&(s=i,e[t]=i),r&&/^data:image\//i.test(s))return;let c;try{c=new URL(s,n??"https://relative.invalid/")}catch{R(o,"invalid asset URL.")}["http:","https:"].includes(c.protocol)||R(o,"use an HTTP(S) asset URL."),n&&(e[t]=c.href)}function mo(e,t){X(e,t),ee(e.position,3,`${t}.position`),ee(e.target,3,`${t}.target`),(typeof e.zoom!="number"||e.zoom<=0)&&R(t,"zoom must be positive."),e.fov!==null&&(typeof e.fov!="number"||e.fov<=0||e.fov>=180)&&R(t,"fov must be null or between 0 and 180.");for(let o of["azimuthAngle","polarAngle"])e[o]!==void 0&&typeof e[o]!="number"&&R(t,`${o} must be a number.`)}function Xt(e,t,o,n){X(e,t),(typeof e.id!="number"||typeof e.title!="string"||typeof e.description!="string")&&R(t,"expected an annotation id, title and description.");for(let r of["worldPosition","localPosition"])ee(e[r],3,`${t}.${r}`);e.images!==void 0&&(Array.isArray(e.images)||R(t,"images must be an array."),e.images.forEach(r=>{X(r,t),te(r,"src",t,o,!0,n)})),e.links!==void 0&&(Array.isArray(e.links)||R(t,"links must be an array."),e.links.forEach(r=>{X(r,t),te(r,"href",t,o,!1,n)}))}function Kt(e,t){X(e,t),e.waypoints!==void 0&&(Array.isArray(e.waypoints)||R(t,"expected waypoints."),e.waypoints.forEach(o=>{X(o,t),ee(o.position,3,t),ee(o.target,3,t)}));for(let o of["enabled","loop","autoPlay"])e[o]!==void 0&&typeof e[o]!="boolean"&&R(t,`${o} must be boolean.`);e.duration!==void 0&&(typeof e.duration!="number"||e.duration<=0)&&R(t,"duration must be positive.")}function et(e,t,o){if(t!==null)if(Array.isArray(t))Array.isArray(e)||R(o,"expected an array."),t.length&&e.forEach(n=>et(n,t[0],o));else if(typeof t=="object"){X(e,o);for(let[n,r]of Object.entries(t))et(e[n],r,`${o}.${n}`)}else typeof e!=typeof t&&R(o,`expected ${typeof t}.`)}function Gt(e,t,o,n){if(et(e,fe,t),e.measurements!==void 0&&(e.measurements=ye(e.measurements)),e.sequences!==void 0&&(e.sequences=Ae(e.sequences)),e.selectionSets!==void 0&&(e.selectionSets=Wt(e.selectionSets)),e.product!==void 0&&(e.product=Mt(e.product),e.product.definition.groups.forEach(r=>r.options.forEach(a=>a.appearance?.forEach(s=>{for(let[i,c]of Object.entries(s.material??{}))c&&typeof c=="object"&&!Array.isArray(c)&&"path"in c&&te(c,"path",`${t}.product.material.${i}.path`,o,!0,n)})))),ee(e.model.rotation,3,`${t}.model.rotation`),e.lighting.lights.forEach(r=>ee(r.position,3,`${t}.lighting.lights`)),e.annotations.forEach(r=>Xt(r,`${t}.annotations`,o,n)),e.animations.autoplayClip!==null&&typeof e.animations.autoplayClip!="string"&&R(t,"invalid autoplay clip."),e.animations.clips.forEach(r=>{X(r,t),(typeof r.sourceName!="string"||typeof r.displayName!="string"||typeof r.hidden!="boolean"||typeof r.speed!="number"||!["repeat","once","ping-pong"].includes(r.loopMode))&&R(t,"invalid animation clip settings.")}),e.cinematic!==void 0&&Kt(e.cinematic,`${t}.cinematic`),e.styleRules!==void 0&&!Array.isArray(e.styleRules)&&R(t,"styleRules must be an array."),te(e.environment,"customEnvironmentUrl",`${t}.environment`,o,!1,n),te(e.background,"imageUrl",`${t}.background`,o,!0,n),e.model.activeVariants!==void 0&&Se(e.model.activeVariants,t),e.section!==void 0)try{e.section=be(e.section)}catch(r){R(`${t}.section`,r.message)}}function Zt(e,t,o,n){X(e,t);for(let[r,a]of Object.entries(e)){let s=`${t}.${r}`;X(a,s),(typeof a.id!="string"||typeof a.modelObjectId!="string")&&R(s,"expected binding id and modelObjectId.");for(let i of["label","group","type","status"])a[i]!==void 0&&typeof a[i]!="string"&&R(s,`${i} must be a string.`);a.tags!==void 0&&Se(a.tags,s),a.metadata!==void 0&&X(a.metadata,`${s}.metadata`),a.metrics!==void 0&&(X(a.metrics,s),Object.values(a.metrics).some(i=>typeof i!="number")&&R(s,"metrics must be numbers.")),a.actions!==void 0&&(Array.isArray(a.actions)||R(s,"actions must be an array."),a.actions.forEach(i=>{X(i,s),(typeof i.id!="string"||typeof i.label!="string"||i.type!=="command"||i.effects!==void 0&&!Array.isArray(i.effects))&&R(s,"invalid action.")}));for(let i of["visible","removed","selectable","hoverable"])a[i]!==void 0&&typeof a[i]!="boolean"&&R(s,`${i} must be boolean.`);if(a.transform!==void 0){X(a.transform,s);for(let i of["position","rotation","scale","shear"])a.transform[i]!==void 0&&ee(a.transform[i],3,`${s}.transform.${i}`);a.transform.pivot!==void 0&&(X(a.transform.pivot,s),ee(a.transform.pivot.point,3,s),ee(a.transform.pivot.offset,3,s))}if(a.style!==void 0&&(X(a.style,s),a.style.material!==void 0)){X(a.style.material,s);for(let[i,c]of Object.entries(a.style.material))c&&typeof c=="object"&&!Array.isArray(c)&&"path"in c&&te(c,"path",`${s}.style.material.${i}.path`,o,!0,n)}a.decals!==void 0&&(Array.isArray(a.decals)||R(s,"decals must be an array."),a.decals.forEach(i=>{X(i,s),(typeof i.id!="string"||typeof i.size!="number"||i.size<=0)&&R(s,"invalid decal."),ee(i.position,3,s),ee(i.normal,3,s),te(i,"image",s,o,!0,n)}))}}function Ht(e,t,o,n){Array.isArray(e)||R(t,"expected merge sources."),e.forEach(r=>{X(r,t),(typeof r.url!="string"||!r.url||typeof r.namePrefix!="string")&&R(t,"expected source URL and prefix."),te(r,"url",t,o,!1,n)})}function uo(e,t,o){X(e,"configuration");let n=Object.fromEntries(co.filter(r=>e[r]!==void 0).map(r=>[r,e[r]]));(typeof n.modelUrl!="string"||!n.modelUrl)&&R("configuration.modelUrl","expected the active model URL.");for(let r of["modelUrl","tilesetUrl","usdzUrl"])te(n,r,`configuration.${r}`,t,!1,o);if(n.sceneConfig!==void 0&&Gt(n.sceneConfig,"configuration.sceneConfig",t,o),n.mergeModels!==void 0&&Ht(n.mergeModels,"configuration.mergeModels",t,o),n.models!==void 0){(!Array.isArray(n.models)||n.models.length===0)&&R("configuration.models","expected model entries.");let r=new Set,a=new Set;n.models.forEach(s=>{X(s,"model"),(typeof s.url!="string"||!s.url)&&R("model.url","expected a URL."),te(s,"url","model.url",t,!1,o),s.id!==void 0&&(typeof s.id!="string"||!s.id.trim())&&R("model.id","expected a nonempty instance ID.");let i=Ke({id:s.id,url:s.url});a.has(i)&&R("configuration.models","instance identities must be unique; assign IDs when reusing a URL."),a.add(i),s.transform!==void 0&&(s.transform=he(s.transform)),s.visible!==void 0&&typeof s.visible!="boolean"&&R("model.visible","expected boolean."),r.add(s.url),Zt(s.objectBindings,"model.objectBindings",t,o),s.sceneConfig!==void 0&&Gt(s.sceneConfig,"model.sceneConfig",t,o),s.mergeModels!==void 0&&Ht(s.mergeModels,"model.mergeModels",t,o)}),n.activeModelId!==void 0&&(typeof n.activeModelId!="string"||!a.has(n.activeModelId))&&R("configuration.activeModelId","active instance is not in models."),n.activeModelId!==void 0&&n.models.find(s=>Ke(s)===n.activeModelId)?.url!==n.modelUrl&&R("configuration.modelUrl","source does not match the active instance."),r.has(n.modelUrl)||R("configuration.modelUrl","active model is not in models.")}if(n.multiSelectedKeys!==void 0&&Se(n.multiSelectedKeys,"configuration.multiSelectedKeys"),n.annotationCategories!==void 0&&n.annotationCategories!==null&&Se(n.annotationCategories,"configuration.annotationCategories"),n.activeAnnotation!==void 0&&n.activeAnnotation!==null&&Xt(n.activeAnnotation,"configuration.activeAnnotation",t,o),n.measurements!==void 0||n.measurementSettings!==void 0){let r=ye({items:n.measurements??[],settings:n.measurementSettings??{}});n.measurements!==void 0&&(n.measurements=r.items),n.measurementSettings!==void 0&&(n.measurementSettings=r.settings)}n.measurementModelId!==void 0&&typeof n.measurementModelId!="string"&&R("configuration.measurementModelId","expected a stable id."),n.measurementUnit!==void 0&&typeof n.measurementUnit!="string"&&R("configuration.measurementUnit","expected a unit label.");for(let r of["backgroundColor"])n[r]!==void 0&&typeof n[r]!="string"&&R(r,"expected a string.");n.shadows!==void 0&&typeof n.shadows!="boolean"&&R("shadows","expected boolean.");for(let[r,a]of Object.entries({modelFormat:["glb","gltf","obj","fbx","usdz","stl","ply"],cameraControllerType:["orbit","pointerLock"],objectTransformSpace:["world","local"],arScaleMode:["normalized","real-world"]}))n[r]!==void 0&&!a.includes(n[r])&&R(r,"unsupported value.");if(n.cinematic!==void 0&&Kt(n.cinematic,"cinematic"),n.isolation!==void 0&&n.isolation!==null){let{target:r,mode:a,ghostOpacity:s}=n.isolation;typeof r=="string"||Array.isArray(r)&&r.every(i=>typeof i=="string")||r&&typeof r=="object"&&["group","tag","type"].some(i=>typeof r[i]=="string")||R("configuration.isolation","invalid target."),a!==void 0&&!["ghost","hide"].includes(a)&&R("configuration.isolation","invalid mode."),s!==void 0&&(typeof s!="number"||s<0||s>1)&&R("configuration.isolation","opacity must be between 0 and 1.")}return n}function Yt(e,t,o,n){if(!(!e||typeof e!="object"))for(let[r,a]of Object.entries(e))r!=="metadata"&&(typeof a=="string"&&["url","modelUrl","tilesetUrl","usdzUrl","path","image","src","href","imageUrl","customEnvironmentUrl"].includes(r)?te(e,r,`${t}.${r}`,o,["path","image","src","imageUrl"].includes(r),n):Yt(a,`${t}.${r}`,o,n))}function Jt(e,t,o){typeof e=="string"&&(new TextEncoder().encode(e).length>ie&&R("state","exceeds the 5 MiB limit."),e=JSON.parse(e));let n=lo(e);X(n,"state"),new TextEncoder().encode(JSON.stringify(n)).length>ie&&R("state","exceeds the 5 MiB limit."),n.version!==void 0&&n.version!==1&&R("version","unsupported version."),n.version===void 0&&(n.objectBindings!==void 0||n.configuration!==void 0)&&R("version","full configurations require version 1.");let r={};return n.version!==void 0&&(r.version=1),n.camera!==void 0&&(mo(n.camera,"camera"),r.camera=n.camera),n.hidden!==void 0&&(Se(n.hidden,"hidden"),r.hidden=n.hidden),n.selected!==void 0&&(n.selected!==null&&typeof n.selected!="string"&&R("selected","expected an object id or null."),r.selected=n.selected),n.objectBindings!==void 0&&(Zt(n.objectBindings,"objectBindings",t,o),r.objectBindings=n.objectBindings),n.configuration!==void 0&&(r.configuration=uo(n.configuration,t,o)),Yt(r,"state",t,o),new TextEncoder().encode(JSON.stringify(r)).length>ie&&R("state","exceeds the 5 MiB limit."),r}function pi(e,t){return JSON.stringify(Te(e,t))}function Te(e,t){return Jt(e,t)}async function Qt(e,t){let o=new Map,n=Jt(e,t,o),r=new Map,a=new Map;for(let[i,{source:c,path:l}]of o){let f=r.get(c);f||(f=(async()=>{let u;try{u=await fetch(c)}catch{R(l,"this temporary image is no longer available. Reload or reselect it before saving.")}u.ok||R(l,"could not read the temporary image. Reload or reselect it before saving.");let m=await u.blob();m.size>ie*3/4&&R(l,"embedded image exceeds the 5 MiB configuration limit. Use a hosted image URL.");let d=new Uint8Array(await m.arrayBuffer()),p=m.type.split(";")[0].toLowerCase(),M=p.startsWith("image/")?p:fo(d);M||R(l,"temporary asset is not a supported image. Use a hosted asset URL.");let b="";for(let S=0;S<d.length;S+=32768)b+=String.fromCharCode(...d.subarray(S,S+32768));return`data:${M};base64,${btoa(b)}`})(),r.set(c,f)),a.set(i,await f)}function s(i){if(!(!i||typeof i!="object"))for(let[c,l]of Object.entries(i))c!=="metadata"&&(["path","image","src","imageUrl"].includes(c)&&typeof l=="string"&&a.has(l)?i[c]=a.get(l):s(l))}return s(n),Te(n,t)}function fo(e){let t=(o,n)=>String.fromCharCode(...e.subarray(o,n));if(e[0]===137&&t(1,4)==="PNG")return"image/png";if(e[0]===255&&e[1]===216&&e[2]===255)return"image/jpeg";if(t(0,3)==="GIF")return"image/gif";if(t(0,4)==="RIFF"&&t(8,12)==="WEBP")return"image/webp";if(t(4,8)==="ftyp"&&["avif","avis"].includes(t(8,12)))return"image/avif";if(/<svg[\s>]/i.test(new TextDecoder().decode(e.subarray(0,1024))))return"image/svg+xml"}import{strFromU8 as po,strToU8 as en,unzlibSync as go,zlibSync as bo}from"fflate";var Ee="ri-ar",Be="ri-ar-id",tn=4096,ho=2200,yo=en(JSON.stringify(fe)).byteLength;function nn(e){return e==="localhost"||e.endsWith(".localhost")||/^127\./.test(e)||e==="[::1]"||e==="0.0.0.0"}function on(e){if(typeof e=="string"&&/^https?:\/\//i.test(e)&&nn(new URL(e).hostname))throw new Error("An asset URL points to this computer. Use model and texture URLs reachable from the phone.");if(e&&typeof e=="object")for(let t of Object.values(e))on(t)}function wi(e){return e&&typeof e=="object"?e:void 0}function xi(e){let t=new URLSearchParams(new URL(e,"https://viewer.invalid/").hash.slice(1));return t.has(Ee)||t.has(Be)}function So(e,t){let o=new URL(e,t);if(!["https:","http:"].includes(o.protocol))throw new Error("AR handoff requires an HTTP(S) URL.");return o.toString()}function Ai(e,t="",o=2048){let n=new Set,r=a=>{if(typeof a=="string")return je(a)??a;if(a===null||typeof a!="object")return a;if(n.has(a))throw new Error("AR configuration cannot contain cycles.");n.add(a);let s=Array.isArray(a)?a.map(r):Object.fromEntries(Object.keys(a).sort().map(i=>[i,r(a[i])]));return n.delete(a),s};return JSON.stringify([t,o,r({...e,camera:void 0})])}function rn(e,t){if(JSON.stringify(e)!==JSON.stringify(t))return e&&t&&typeof e=="object"&&typeof t=="object"&&!Array.isArray(e)&&!Array.isArray(t)?Object.fromEntries(Object.entries(e).map(([o,n])=>[o,rn(n,t[o])]).filter(([,o])=>o!==void 0)):e}function an(e,t,o=0){if(o>64)throw new Error("AR configuration is too deeply nested.");if(e&&t&&typeof e=="object"&&typeof t=="object"&&!Array.isArray(e)&&!Array.isArray(t)){let n=e,r=t;return Object.fromEntries([...new Set([...Object.keys(r),...Object.keys(n)])].map(a=>[a,Object.prototype.hasOwnProperty.call(n,a)?an(n[a],r[a],o+1):r[a]]))}return e}function sn(e,t){let o=structuredClone(e);if(o.configuration){o.configuration.sceneConfig&&(o.configuration.sceneConfig=t(o.configuration.sceneConfig));for(let n of o.configuration.models??[])n.sceneConfig&&(n.sceneConfig=t(n.sceneConfig))}return o}function we(e){e?.throwIfAborted()}async function Mi(e,t,o,n){we(n);let r=new URL(So(t));if(nn(r.hostname))throw new Error("Phone links need a viewer URL reachable from your phone. Download the USDZ for local uploads, or provide a public viewer URL.");let a=await Qt(e,r.toString());we(n),on(a);let s=new URLSearchParams(r.hash.slice(1));if(s.delete(Ee),s.delete(Be),s.delete("view"),s.delete("viewId"),s.delete("view-id"),o){let i=await o.save(a);if(we(n),typeof i!="string"||!i||i.length>512)throw new Error("AR storage returned an invalid configuration ID.");s.set(Be,i)}else{let i=bo(en(JSON.stringify({ar:1,state:sn(a,l=>rn(l,fe)??{})})),{level:9});if(i.byteLength>tn)throw new Error("This configuration needs an AR storage adapter to share on a phone. The USDZ download is still available.");let c="";for(let l of i)c+=String.fromCharCode(l);s.set(Ee,btoa(c).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""))}if(r.hash=s.toString(),r.toString().length>ho)throw new Error("This configuration is too large for a reliable QR code. Use an AR storage adapter or download the USDZ.");return r.toString()}async function Ci(e,t,o){let n=new URL(e),r=new URLSearchParams(n.hash.slice(1)),a=r.get(Be),s=r.get(Ee);if(a!==null&&s!==null)throw new Error("AR link contains conflicting configurations.");if(a===null&&s===null)return null;we(o);let i;if(a!==null){if(!t)throw new Error("This AR link requires the application's configuration storage adapter.");if(!a||a.length>512)throw new Error("Invalid AR configuration ID.");i=await t.load(a)}else{if(!s||s.length>Math.ceil(tn*4/3)||!/^[\w-]+$/.test(s))throw new Error("Invalid or oversized AR link.");let l=atob(s.replace(/-/g,"+").replace(/_/g,"/")),f=Uint8Array.from(l,d=>d.charCodeAt(0)),u=go(f);if(u.byteLength>ie)throw new Error("AR configuration exceeds the 5 MiB limit.");let m=JSON.parse(po(u));if(m?.ar===1&&m.state){let d=m.state.configuration,p=(d?.sceneConfig?1:0)+(Array.isArray(d?.models)?d.models.filter(M=>M?.sceneConfig).length:0);if(u.byteLength+p*yo>ie)throw new Error("Expanded AR configuration exceeds the 5 MiB limit.");i=sn(m.state,M=>an(M,fe))}else i=m}we(o);let c=Te(i,n.toString());if(c.version!==1||!c.configuration)throw new Error("AR handoff requires a complete versioned viewer configuration.");return c}var tt=new WeakMap;function vi(e,t){t?tt.set(e,t):tt.delete(e)}function cn(e){e.traverse(t=>{let o=tt.get(t);if(o)throw new Error(o)})}import{Box3 as $o,BufferAttribute as Pe,BufferGeometry as On,Color as _o,DoubleSide as Fo,FrontSide as dt,Group as In,Matrix4 as qo,Mesh as Wo,Vector3 as Ne}from"three";import{PropertyBinding as nt}from"three";var ot=Symbol("react-immersive.model-node-id");function wo(e,t){Object.defineProperty(e,ot,{value:t,configurable:!0})}function ae(e){let t=new Map;e.traverse(c=>{if(!c.name)return;let l=t.get(c.name);l?l.push(c):t.set(c.name,[c])});let o=Object.create(null),n=new WeakMap,r=new Map,a=new Set(Array.from(t,([c,l])=>l.length===1?c:null).filter(c=>c!==null)),s=new Set,i=(c,l)=>{wo(c,l),o[l]=c,n.set(c,l),s.add(l)};for(let[c,l]of t)l.length===1&&i(l[0],c);for(let[c,l]of t){if(l.length<2)continue;let f=[];l.forEach((u,m)=>{let d=`${c} [${m+1}]`,p=d,M=2;for(;a.has(p)||s.has(p);)p=`${d}.${M++}`;i(u,p),f.push(p)}),r.set(c,f)}return{nodesById:o,idByNode:n,duplicateNames:r}}function xe(e){return e[ot]??e.name??null}function Ii(e,t){let o=t.replace(/\.[^./\\]+$/,"");e.traverse(n=>{n.name&&(n.name=nt.sanitizeNodeName(`${o}_${n.name}`))})}function Ri(e,t){let o=t.replace(/\.[^./\\]+$/,""),n=e.clone();for(let r of n.tracks){let s=nt.parseTrackName(r.name).nodeName??"",i=nt.sanitizeNodeName(`${o}_${s}`);r.name=i+r.name.slice(s.length)}return n}function ln(e,t){let o=null,n=[];return e.traverse(r=>{r[ot]===t&&(o=r),r.name===t&&n.push(r)}),o??(n.length===1?n[0]:null)}import{AnimationClip as Ro,Group as To,Matrix4 as Eo,Vector3 as Bo,PropertyBinding as Cn}from"three";import{clone as Po}from"three/examples/jsm/utils/SkeletonUtils.js";import{strFromU8 as No,strToU8 as mt,unzipSync as Vo,zipSync as zo}from"fflate";import{AnimationMixer as xo,LoopOnce as Ao,LoopPingPong as mn,LoopRepeat as Mo}from"three";function dn(e){let t=e._loopCount;return e.loop===mn&&(t&1)===1}function Co(e){return dn(e)?e.getClip().duration-e.time:e.time}function un({root:e,clips:t,getClipConfig:o,onChange:n}){let r=new xo(e),a=new Map;for(let{clip:h,sourceName:C}of t)a.set(C,r.clipAction(h));let s=new Map,i=new Set,c=new Map,l=1,f=h=>typeof h=="string",u=h=>f(h)?s.has(h)?[h]:[]:[...s.keys()],m=(h,C)=>{let k=jt(o(C));k==="once"?h.setLoop(Ao,1):k==="ping-pong"?h.setLoop(mn,1/0):h.setLoop(Mo,1/0),h.clampWhenFinished=k==="once"},d=h=>{h.action.setEffectiveTimeScale(h.reverse?-h.speed:h.speed)},p=h=>{let C=s.get(h);C&&(C.action.stop(),s.delete(h))},M=(h,C={})=>{let k=a.get(h);if(!k||o(h)?.hidden)return;let E=Number.isFinite(C.fade)&&C.fade>0?C.fade:0,V=C.reverse??!1;if(!C.alongside)for(let[B,q]of[...s])B!==h&&(E>0?(s.delete(B),q.action.fadeOut(E),i.add(q.action)):p(B));i.delete(k)&&k.stop();let y=k.getClip().duration,x=s.get(h),j=()=>{k.reset(),V&&(k.time=y),k.play()};if(!x)j(),E>0&&k.fadeIn(E);else{let B=V?k.time<=0:k.time>=y;x.finished&&B&&j(),k.paused=!1,k.enabled=!0,s.delete(h)}m(k,h),x={action:k,speed:o(h)?.speed??c.get(h)??l,reverse:V,finished:!1},x.speed=ke(x.speed),d(x),s.set(h,x),n()},b=h=>{for(let C of u(h))s.get(C).action.paused=!0;n()},S=h=>{for(let C of u(h))p(C);if(!f(h)){for(let C of i)C.stop();i.clear()}n()},A=(h,C)=>{let k=ke(h);f(C)?c.set(C,k):l=k;for(let E of u(C)){let V=s.get(E);c.set(E,k),V.speed=k,d(V)}n()},g=(h,C)=>{for(let k of u(C)){let E=s.get(k),V=E.action.getClip().duration,y=Math.min(Math.max(h,0),V);E.action.time=dn(E.action)?V-y:y,E.finished&&(E.finished=!1,E.action.paused=!0)}r.update(0),n()},w=()=>{for(let[h,C]of[...s]){let k=o(h);if(k?.hidden){p(h);continue}m(C.action,h),k?.speed!==void 0&&(C.speed=ke(k.speed),d(C))}n()},v=h=>{for(let C of s.values())C.action===h.action&&(C.finished=!0);n()};return r.addEventListener("finished",v),{play:M,pause:b,stop:S,setSpeed:A,seek:g,getState:()=>{let h=[...s].map(([k,E])=>({clip:k,status:E.finished?"finished":E.action.paused?"paused":"playing",time:Co(E.action),duration:E.action.getClip().duration,speed:E.speed,reverse:E.reverse})),C=h[h.length-1];return{currentClip:C?.clip??null,isPlaying:h.some(k=>k.status==="playing"),speed:C?.speed??l,time:C?.time??0,duration:C?.duration??0,active:h}},applyClipConfigs:w,isRunning:()=>{if(i.size>0)return!0;for(let{action:h}of s.values())if(!h.paused&&h.enabled)return!0;return!1},update:h=>{r.update(h);for(let C of i)(!C.enabled||C.getEffectiveWeight()<=0)&&(C.stop(),i.delete(C))},dispose:()=>{r.removeEventListener("finished",v),r.stopAllAction(),r.uncacheRoot(e),s.clear(),i.clear()}}}import{Color as fn}from"three";var rt=e=>e==="baseColor"?"color":e;function pn(e){let t=new Set;return e.traverse(o=>{let n=o;if(n.isMesh)for(let r of Array.isArray(n.material)?n.material:[n.material])r&&t.add(r)}),[...t]}function gn({root:e,controls:t,animations:o,invalidate:n,cameraEnabled:r=()=>!0}){let a=new Map,s=new Map,i=new Map,c=new Set,l=new Map,f=null,u="",m=g=>e()?ln(e(),g):null,d=g=>{if(g.kind==="camera"){let N=t();if(!N)return null;let O=ne(N.camera,N);return{position:O.position,target:O.target,fov:O.fov,zoom:O.zoom}}if(g.kind==="clip"){let N=o();return N?.clips.includes(g.clip)?N.getState?.().active.find(O=>O.clip===g.clip)?.time??0:null}let w=m(g.objectId);if(!w)return null;let v=g.property;if(v==="position"||v==="rotation"||v==="scale")return[w[v].x,w[v].y,w[v].z];if(v==="visible")return w.visible;let P=pn(w).find(N=>N[rt(v)]!==void 0),T=P?P[rt(v)]:void 0;return T?.isColor?`#${T.getHexString()}`:typeof T=="number"?T:null},p=g=>{if(!r())return;let w=t();w&&(w.stop(),w.setLookAt(...g.position,...g.target,!1),g.fov!==null&&"fov"in w.camera&&(w.camera.fov=g.fov,w.camera.updateProjectionMatrix()),w.zoomTo(g.zoom,!1),w.update(0))},M=g=>{if(a.has(g))return;g.updateWorldMatrix(!0,!0);let w=g.matrixAutoUpdate?void 0:xt(g.matrix,g.scale,g.quaternion).shear;a.set(g,{position:g.position.toArray(),rotation:[g.rotation.x,g.rotation.y,g.rotation.z],scale:g.scale.toArray(),matrix:g.matrix.clone(),auto:g.matrixAutoUpdate,shear:w});for(let v of bt(g))ht(v)||(Me(v,v.matrixWorld),c.add(v))},b=(g,w)=>{let v=o();v?.stop(g),w&&v&&(v.play(g,{alongside:!0,reverse:w.reverse}),v.setSpeed(w.speed,g),v.seek?.(w.time,g),w.status!=="playing"&&v.pause(g))};return{capture:d,restore:()=>{for(let[g,w]of l)b(g,w);l.clear();for(let[g,w]of a)g.position.fromArray(w.position),g.rotation.set(...w.rotation),g.scale.fromArray(w.scale),g.matrix.copy(w.matrix),g.matrixAutoUpdate=w.auto,g.matrixWorldNeedsUpdate=!0;a.clear(),s.forEach((g,w)=>w.visible=g),s.clear(),i.forEach((g,w)=>{g.forEach((v,P)=>{v instanceof fn?w[P].copy(v):w[P]=v}),w.needsUpdate=!0}),i.clear(),c.forEach(St),c.clear(),f&&p(f),f=null,u="",e()?.updateWorldMatrix(!0,!0),n()},inspect:g=>g.tracks.filter(w=>!w.muted&&w.keyframes.length&&(w.target.kind!=="camera"||r())&&d(w.target)===null).map(w=>`Unavailable target: ${w.name}.`),invalidate:n,apply:({sequence:g,time:w,playing:v})=>{let P=g.tracks.filter(O=>O.target.kind!=="camera"||r()).map(O=>({track:O,value:ut(O,w)})).filter(O=>O.value!==null);for(let[O,h]of l)P.some(({track:C})=>C.target.kind==="clip"&&C.target.clip===O)||(b(O,h),l.delete(O));for(let{track:O}of P)if(O.target.kind==="object"&&["position","rotation","scale"].includes(O.target.property)){let h=m(O.target.objectId);h&&M(h)}let T=new Map([...i.keys()].map(O=>[O,O.transparent]));s.forEach((O,h)=>h.visible=O),a.forEach((O,h)=>{h.position.fromArray(O.position),h.rotation.set(...O.rotation),h.scale.fromArray(O.scale),Le(h,O.shear)}),i.forEach((O,h)=>O.forEach((C,k)=>{C instanceof fn?h[k].copy(C):h[k]=C}));let N=o();for(let{track:O,value:h}of P){if(O.target.kind!=="clip"||!N?.seek||!N.clips.includes(O.target.clip))continue;let C=O.target.clip;l.has(C)||(l.set(C,N.getState?.().active.find(k=>k.clip===C)),N.play(C,{alongside:!0}),N.pause(C)),N.seek(h,C)}for(let{track:O,value:h}of P){let C=O.target;if(C.kind==="clip")continue;if(C.kind==="camera"){f||(f=d(C));let V=JSON.stringify(h);(v||V!==u)&&(p(h),u=V);continue}let k=m(C.objectId);if(!k)continue;let E=C.property;if(E==="visible")s.has(k)||s.set(k,k.visible),k.visible=h;else if(E==="position"||E==="rotation"||E==="scale")E==="rotation"?k.rotation.set(...h):k[E].fromArray(h),Le(k,a.get(k)?.shear);else for(let V of pn(k)){let y=rt(E),x=V[y];if(x===void 0)continue;let j=i.get(V);if(j||(j=new Map,i.set(V,j)),T.has(V)||T.set(V,V.transparent),j.has(y)||j.set(y,x?.isColor?x.clone():x),x?.isColor?x.set(h):V[y]=h,E==="opacity"){j.has("transparent")||j.set("transparent",V.transparent);let B=h<1||j.get("transparent")===!0;V.transparent=B}}}f&&!P.some(({track:O})=>O.target.kind==="camera")&&(p(f),u=""),T.forEach((O,h)=>{O!==h.transparent&&(h.needsUpdate=!0)}),e()?.updateWorldMatrix(!0,!0)}}}function bn(e){let t=new Map;return e.map((o,n)=>{let a=o.name.trim()||`Animation ${n+1}`,s=t.get(a)??0;return t.set(a,s+1),{clip:o,sourceName:s===0?a:`${a} (${s+1})`,duration:o.duration}})}import{Box3 as it,Group as jo,BufferAttribute as vo,Matrix4 as hn,Mesh as ko,Quaternion as Oo,Vector3 as pe}from"three";function Io(e){let t=e.getAttribute("arSourceVertex"),o=e.getAttribute("arNormalSign");if(!t)return;let n=new Map,r=[],a=[];for(let i=0;i<t.count;i++){let c=`${t.getX(i)}:${o?.getX(i)??1}`,l=n.get(c);l===void 0&&(l=r.length,r.push(i),n.set(c,l)),a.push(l)}let s=e.index?Array.from(e.index.array,i=>a[i]):a;for(let[i,c]of Object.entries(e.attributes)){let l=new Float32Array(r.length*c.itemSize);r.forEach((f,u)=>{for(let m=0;m<c.itemSize;m++)l[u*c.itemSize+m]=c.getComponent(f,m)}),e.setAttribute(i,new vo(l,c.itemSize))}e.setIndex(s)}function yn(e,t,o,n){let r=[],a=[],s=new Map;for(let i of e){let c=i.source;if(!c.isSkinnedMesh)continue;let l=t.get(c),f=c.skeleton,u=JSON.stringify(f.bones.map((O,h)=>[O.uuid,f.boneInverses[h].elements])),m=s.get(u);if(!m){let O=new Map(f.bones.map((x,j)=>[x,j])),h=f.bones.map(x=>{for(let j=x.parent;j;j=j.parent)if(O.has(j))return O.get(j);return-1}),C=[],k=x=>{C.includes(x)||(h[x]>=0&&k(h[x]),C.push(x))};f.bones.forEach((x,j)=>k(j));let E=C.map(x=>C.indexOf(h[x])),V=[];C.forEach((x,j)=>V.push(`${E[j]<0?"":V[E[j]]+"/"}J_${x}`));let y={name:`${n}_${r.length}`,joints:V,parents:E,bones:C.map(x=>t.get(f.bones[x])),bindTransforms:C.map(x=>f.boneInverses[x].clone().invert()),restTransforms:[],worlds:C.map(()=>new hn),referenceInverse:o.clone().invert(),frames:[]};if(y.bones.some(x=>!x))throw new Error("The AR skeleton has joints outside the exported scene.");m={rig:y,order:C},s.set(u,m),r.push(y)}Io(i.exported.geometry);let d=i.exported.geometry.getAttribute("arSourceVertex"),p=c.geometry.getAttribute("skinIndex"),M=c.geometry.getAttribute("skinWeight");if(!d||!p||!M||p.itemSize!==4||M.itemSize!==4)throw new Error("AR skeletal animation needs four joint indices and weights per vertex.");let b={target:i,node:l,rig:m.rig,reference:o,geomBind:c.bindMatrix.clone(),jointIndices:[],jointWeights:[],jointBounds:m.order.map(()=>new it),extent:new it},S=i.exported.geometry.getAttribute("position"),A=i.exported.geometry.getAttribute("normal"),g=c.geometry.getAttribute("normal"),w=i.exported.geometry.getAttribute("arNormalSign"),v=new pe,P=new pe,T=new Map(m.order.map((O,h)=>[O,h])),N=b.rig.bindTransforms.map(O=>O.clone().invert().multiply(c.bindMatrix));for(let O=0;O<d.count;O++){let h=d.getX(O);if(ko.prototype.getVertexPosition.call(c,h,v),S.setXYZ(O,v.x,v.y,v.z),g&&A){P.fromBufferAttribute(g,h);let k=P.clone();c.geometry.morphAttributes.normal?.forEach((E,V)=>{let y=c.morphTargetInfluences?.[V]??0;y&&P.addScaledVector(new pe().fromBufferAttribute(E,h).sub(c.geometry.morphTargetsRelative?new pe:k),y)}),P.normalize().multiplyScalar(w?.getX(O)??1),A.setXYZ(O,P.x,P.y,P.z)}let C=[0,1,2,3].reduce((k,E)=>k+M.getComponent(h,E),0);if(!Number.isFinite(C)||C<=0)throw new Error("The AR skin has a vertex without valid joint weights.");for(let k=0;k<4;k++){let E=M.getComponent(h,k)/C,V=E?T.get(p.getComponent(h,k))??-1:0;if(V<0||!Number.isFinite(E)||E<0)throw new Error("The AR skin has invalid joint indices or weights.");b.jointIndices.push(V),b.jointWeights.push(E),E&&b.jointBounds[V].expandByPoint(v.clone().applyMatrix4(N[V]))}}S.needsUpdate=!0,A?A.needsUpdate=!0:i.exported.geometry.computeVertexNormals(),i.exported.geometry.computeBoundingBox(),i.exported.matrixAutoUpdate=!1,i.exported.matrix.copy(ct(b)),a.push(b)}return{rigs:r,skins:a}}function ct(e){return e.node.matrixWorld.clone().multiply(e.node.bindMatrixInverse).multiply(e.reference)}function Sn(e,t,o){let n=new pe,r=new Oo,a=new pe,s=new hn;for(let i of e){let c={time:o,translations:[],rotations:[],scales:[]};i.bones.forEach((l,f)=>i.worlds[f].multiplyMatrices(i.referenceInverse,l.matrixWorld)),i.worlds.forEach((l,f)=>{let u=i.parents[f],m=u<0?l.clone():i.worlds[u].clone().invert().multiply(l);m.decompose(n,r,a),r.normalize(),s.compose(n,r,a);let d=1e-5*Math.max(1,...m.elements.map(Math.abs));if(!m.elements.every(Number.isFinite)||m.elements.some((p,M)=>Math.abs(p-s.elements[M])>d)||Math.abs(m.determinant())<1e-15)throw new Error("The AR skeleton contains a sheared or zero-scale joint that Quick Look cannot preserve. Use arHandoff.createUSDZ for this rig.");c.translations.push(...n.toArray()),c.rotations.push(r.w,r.x,r.y,r.z),c.scales.push(...a.toArray()),i.frames.length||i.restTransforms.push(m)}),i.frames.push(c)}for(let i of t)i.jointBounds.forEach((c,l)=>{c.isEmpty()||i.extent.union(c.clone().applyMatrix4(i.rig.worlds[l]))})}var lt=e=>String(Number(e.toPrecision(9))),at=e=>{let t=Array.isArray(e)?e:e.elements;return`(${[0,4,8,12].map(o=>`(${t.slice(o,o+4).map(lt).join(", ")})`).join(", ")})`},st=(e,t)=>Array.from({length:e.length/t},(o,n)=>`(${e.slice(n*t,(n+1)*t).map(lt).join(", ")})`).join(", ");function wn(e){let t=(s,i,c=1e-7)=>Math.abs(s-i)>c*Math.max(1,Math.abs(s),Math.abs(i)),o=[["translations",3,"float3"],["rotations",4,"quatf"],["scales",3,"half3"]],n=e.frames[0],r=e.joints.map((s,i)=>i).filter(s=>o.some(([i,c])=>e.frames.some(l=>l[i].slice(s*c,(s+1)*c).some((f,u)=>t(f,n[i][s*c+u])))));r.length||(r=e.joints.map((s,i)=>i));let a=o.map(([s,i,c])=>{let l=e.frames.map(u=>r.flatMap(m=>u[s].slice(m*i,(m+1)*i)));return l.some(u=>u.some((m,d)=>t(m,l[0][d],c==="half3"?1e-4:1e-7)))?`${c}[] ${s}.timeSamples = {${e.frames.map((u,m)=>`${u.time}: [${st(l[m],i)}]`).join(`,
|
|
3
|
-
`)}}`:`${c}[] ${s} = [${st(l[0],i)}]`}).join(`
|
|
4
|
-
`);return`#usda 1.0
|
|
5
|
-
(
|
|
6
|
-
defaultPrim = "Skeleton"
|
|
7
|
-
metersPerUnit = 1
|
|
8
|
-
upAxis = "Y"
|
|
9
|
-
timeCodesPerSecond = 30
|
|
10
|
-
framesPerSecond = 30
|
|
11
|
-
)
|
|
12
|
-
def Skeleton "Skeleton" (prepend apiSchemas = ["SkelBindingAPI"]) {
|
|
13
|
-
uniform token[] joints = ${JSON.stringify(e.joints)}
|
|
14
|
-
uniform matrix4d[] bindTransforms = [${e.bindTransforms.map(at).join(", ")}]
|
|
15
|
-
uniform matrix4d[] restTransforms = [${e.restTransforms.map(at).join(", ")}]
|
|
16
|
-
rel skel:animationSource = <Animation>
|
|
17
|
-
def SkelAnimation "Animation" {
|
|
18
|
-
uniform token[] joints = ${JSON.stringify(r.map(s=>e.joints[s]))}
|
|
19
|
-
${a}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
`}function xn(e,t){let o=new Map;for(let n of e){let r=n.target.exported,a=t.get(r.name),s=l=>Math.round(l*1e7)/1e7,i=JSON.stringify([n.rig.name,a?.map(l=>l.matrix.map(s))??r.matrix.elements.map(s)]),c=o.get(i);if(!c){let l=new jo;l.name=`AR_Rig_${o.size}`,l.matrixAutoUpdate=!1,l.matrix.copy(r.matrix),r.parent.add(l),c={node:l,rig:n.rig,skins:[],extent:new it},o.set(i,c),a&&t.set(l.name,a)}c.node.add(r),r.matrix.identity(),t.delete(r.name),c.skins.push(n),c.extent.union(n.extent)}return[...o.values()]}function An(e){return`
|
|
23
|
-
rel skel:skeleton = <Skeleton>
|
|
24
|
-
rel skel:animationSource = <Skeleton/Animation>
|
|
25
|
-
float3[] extent = [${st([...e.extent.min.toArray(),...e.extent.max.toArray()],3)}]
|
|
26
|
-
def Skeleton "Skeleton" (prepend references = @./rigs/${e.rig.name}.usda@</Skeleton>) {}
|
|
27
|
-
`}function Mn(e){return`
|
|
28
|
-
over "Geometry" (prepend apiSchemas = ["SkelBindingAPI"]) {
|
|
29
|
-
rel skel:skeleton = <../../Skeleton>
|
|
30
|
-
uniform token[] skel:joints = ${JSON.stringify(e.rig.joints)}
|
|
31
|
-
uniform token primvars:skel:skinningMethod = "classicLinear"
|
|
32
|
-
matrix4d primvars:skel:geomBindTransform = ${at(e.geomBind)}
|
|
33
|
-
int[] primvars:skel:jointIndices = [${e.jointIndices.join(", ")}] (
|
|
34
|
-
interpolation = "vertex"
|
|
35
|
-
elementSize = 4
|
|
36
|
-
)
|
|
37
|
-
float[] primvars:skel:jointWeights = [${e.jointWeights.map(lt).join(", ")}] (
|
|
38
|
-
interpolation = "vertex"
|
|
39
|
-
elementSize = 4
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
`}var se=30,Do=12e4,Lo=1e6,jn=new Set(["position","quaternion","rotation","scale"]);function Uo(e){let t=Ae(e.sceneConfig?.sequences??[]).find(l=>l.autoPlay),o=e.sceneConfig?.animations.autoplayClip,n=bn(e.scene.animations),r=n.find(l=>l.sourceName===o),a=e.sceneConfig?.animations.clips.find(l=>l.sourceName===o),s=a?.speed??1,i=Number.isFinite(s)&&s>0?s:1,c=r&&!a?.hidden?r.duration*(a?.loopMode==="ping-pong"?2:1)/i:0;return{sequence:t,autoplay:o,clips:n,duration:Math.max(c,t?.duration??0)}}function vn(e,t,o){let n=new Set,r=new Map,a=0,s=0,i=0,c=[],l=[],f=e.map(Uo),u=Math.max(0,...f.map(m=>m.duration));for(let[m,d]of e.entries()){o?.throwIfAborted();let{sequence:p,autoplay:M}=f[m];if(!p&&!M)continue;let b=Po(d.scene),S=[],A=[];d.scene.traverse(I=>S.push(I)),b.traverse(I=>A.push(I));let g=new Map;S.forEach((I,U)=>{A[U].uuid=I.uuid,g.set(I,A[U]);let L=Ce(I);L&&I.isSkinnedMesh&&(delete A[U].userData.reactImmersiveSkinFreeze,Me(A[U],L.clone().invert(),yt(I)??void 0))});let w=ae(b),v=new To;v.matrixAutoUpdate=!1,v.matrix.copy(d.scene.parent?.matrixWorld??new Eo),v.add(b),v.updateMatrixWorld(!0);let P=t.filter(I=>I.sourceIndex===m),T=P.some(I=>I.source.isSkinnedMesh),N=new Set(p?.tracks.filter(I=>!I.muted&&I.target.kind==="clip").map(I=>I.target.kind==="clip"?I.target.clip:"")??[]);M&&N.add(M);let O=f[m].clips.map(I=>{if(!N.has(I.sourceName))return I;let U=I.clip.tracks.filter(L=>{let F=Cn.parseTrackName(L.name),Q=Cn.findNode(b,F.nodeName),D=!!Q&&jn.has(F.propertyName)&&(Q?.type!=="Bone"||T)&&!F.objectName;return D||n.add(Q?.type==="Bone"?"Skeletal tracks without an exported skinned mesh are omitted.":"Quick Look exports object and skeletal motion. Morph and other unsupported clip tracks keep their captured pose."),D});return{...I,clip:new Ro(I.clip.name,I.duration,U)}}),h=I=>d.sceneConfig?.animations.clips.find(U=>U.sourceName===I),C=un({root:b,clips:O,getClipConfig:h,onChange(){}}),k={...C,clips:O.map(I=>I.sourceName)},E=gn({root:()=>b,controls:()=>null,animations:()=>k,invalidate(){},cameraEnabled:()=>!1}),V=p?.tracks.filter(I=>{if(!T&&I.target.kind==="object"&&w.nodesById[I.target.objectId]?.type==="Bone")return I.muted||n.add("Quick Look keeps skeletal deformation at its captured pose."),!1;let U=I.target.kind==="clip"||I.target.kind==="object"&&jn.has(I.target.property);return!U&&!I.muted&&n.add("Quick Look exports sequence object motion. Camera, visibility and appearance tracks stay in WebXR."),U}),y=p?{...p,tracks:V??[]}:void 0;y&&E.inspect(y).forEach(I=>n.add(I));let x=O.some(I=>N.has(I.sourceName)&&I.clip.tracks.length&&!h(I.sourceName)?.hidden),j=V?.some(I=>!I.muted&&I.keyframes.length&&I.target.kind==="object");if(!x&&!j){C.dispose();continue}let B=yn(P,g,v.matrix,`Skin_${m}`),q=new Map(B.skins.map(I=>[I.target,I])),W=u,K=Math.ceil(W*se);if(s+=(K+1)*P.length,i+=(K+1)*B.rigs.reduce((I,U)=>I+U.joints.length,0),!Number.isFinite(W)||s>Do||i>Lo)throw C.dispose(),new Error("This animation is too large for browser USDZ conversion. Use arHandoff.createUSDZ for this model.");let J=Object.entries(d.objectBindings??{}).flatMap(([I,U])=>{if(!U.transform)return[];let L=w.nodesById[U.modelObjectId??I];return L?[{node:L,matrix:L.matrix.clone(),position:L.position.clone(),quaternion:L.quaternion.clone(),scale:L.scale.clone()}]:[]}),_=P.map(I=>({target:I,node:g.get(I.source),inverse:I.bakedMatrix.clone().invert(),frames:[]}));try{M&&C.play(M);let I=0;for(let U=0;U<=K;U++){o?.throwIfAborted();let L=Math.min(U/se,W);C.update(L-I),I=L;for(let F of J)F.node.position.copy(F.position),F.node.quaternion.copy(F.quaternion),F.node.scale.copy(F.scale),F.node.matrix.copy(F.matrix);if(y){let F=y.loop&&L>y.duration?L%y.duration:Math.min(L,y.duration);E.apply({sequence:y,time:F,playing:!1})}v.updateMatrixWorld(!0),Sn(B.rigs,B.skins,L*se);for(let F of _){let Q=q.get(F.target),D=Q?ct(Q):F.node.matrixWorld.clone().multiply(F.target.instanceMatrix).multiply(F.inverse);if(!D.elements.every(Number.isFinite)||D.determinant()<=0)throw new Error("Quick Look animation cannot preserve a reflected or zero-scale transform. Use arHandoff.createUSDZ.");F.frames.push({time:L*se,matrix:D.toArray()})}}for(let U of _){let L=U.frames[0]?.matrix;L&&U.frames.some(F=>F.matrix.some((Q,D)=>Math.abs(Q-L[D])>1e-8))&&(r.set(U.target.exported.name,U.frames),a=Math.max(a,W))}if(B.skins.length){for(let U of B.skins)U.extent.expandByScalar(Math.max(1e-6,U.extent.getSize(new Bo).length()*.001));c.push(...B.rigs),l.push(...B.skins),a=Math.max(a,W)}}finally{E.restore(),C.dispose()}}return{samples:r,rigs:c,skins:l,duration:a,warnings:[...n]}}function kn(e,t,o){if(!t.samples.size&&!t.skins.length)return e;let n=Vo(e),r=No(n["model.usda"]);r=r.replace(" metersPerUnit = 1",` startTimeCode = 0
|
|
43
|
-
endTimeCode = ${t.duration*se}
|
|
44
|
-
timeCodesPerSecond = ${se}
|
|
45
|
-
framesPerSecond = ${se}
|
|
46
|
-
autoPlay = true
|
|
47
|
-
metersPerUnit = 1`);for(let[i,c]of t.samples){let l=new RegExp(`(def Xform "${i}"[\\s\\S]*?\\n[\\t ]*)matrix4d xformOp:transform = [^\\n]+`);if(!l.test(r))throw new Error("The USDZ exporter produced an unsupported animation layout.");let f=c.map(u=>{let m=[0,4,8,12].map(d=>`(${u.matrix.slice(d,d+4).join(", ")})`);return`${u.time}: (${m.join(", ")})`}).join(`,
|
|
48
|
-
`);r=r.replace(l,(u,m)=>`${m}matrix4d xformOp:transform.timeSamples = {
|
|
49
|
-
${f}
|
|
50
|
-
}`)}for(let i of t.rigs)n[`rigs/${i.name}.usda`]=mt(wn(i));for(let i of o){let c=new RegExp(`def Xform "${i.node.name}"(\\s*\\{)`);if(!c.test(r))throw new Error("The USDZ exporter produced an unsupported skeleton root layout.");r=r.replace(c,`def SkelRoot "${i.node.name}" (prepend apiSchemas = ["SkelBindingAPI"]) $1${An(i)}`)}for(let i of t.skins){let c=new RegExp(`def Xform "${i.target.exported.name}"(\\s*\\([\\s\\S]*?\\)\\s*\\{)`);if(!c.test(r))throw new Error("The USDZ exporter produced an unsupported skeleton layout.");r=r.replace(c,(l,f)=>`def Xform "${i.target.exported.name}"${f}${Mn(i)}`)}n["model.usda"]=mt(r);let a={},s=0;for(let[i,c]of Object.entries(n)){s+=34+mt(i).length;let l=s&63;a[i]=l===4?c:[c,{extra:{12345:new Uint8Array(64-l)}}],s=c.length}return zo(a,{level:0})}function Go(e,t={}){t.signal?.throwIfAborted();let o=new In,n=new In;o.add(n);let r=new Set,a=[],s=[],i=[],c=new Map,l=[],f=0,u=0,m=()=>{a.forEach(d=>d.dispose()),s.forEach(d=>d.dispose()),i.forEach(d=>d.dispose())};try{for(let[S,{scene:A,objectBindings:g={},materialOverrides:w={}}]of e.entries()){cn(A),A.updateWorldMatrix(!0,!0);let v=new Map(Object.entries(g).map(([P,T])=>[T.modelObjectId??P,P]));A.traverse(P=>{let T=P;if(!T.isMesh||!T.geometry)return;for(let E=P;E;E=E.parent){let V=xe(E)??E.name??E.uuid;if(!E.visible||g[v.get(V)??V]?.visible===!1||g[v.get(V)??V]?.removed)return}let N=xe(T)??T.name??T.uuid,O=w[v.get(N)??N]??T.material;if(!O)throw new Error(`Material for ${N} is not ready. Wait for the model to finish loading.`);let h=Array.isArray(O)?O:[O],C=T.isInstancedMesh?T.count:1;if(T.userData.riDecal&&ge(T)&&T.parent){let E=Ce(T.parent);E&&T.bindMatrixInverse.copy(E)}let k=ge(T)?wt(T):T.geometry.clone();try{if(!ge(T)&&T.morphTargetInfluences?.some(y=>y!==0)){let y=k.getAttribute("position"),x=new Ne;for(let j=0;j<y.count;j++)T.getVertexPosition(j,x),y.setXYZ(j,x.x,x.y,x.z);k.morphAttributes={},k.computeVertexNormals()}if(!k.getAttribute("position"))throw new Error(`Mesh ${N} has no positions.`);let E=k.index?.count??k.getAttribute("position").count,V=Array.isArray(O)?k.groups:[{start:0,count:E,materialIndex:0}];if(!V.length)throw new Error(`Mesh ${N} has multiple materials without geometry groups.`);for(let y=0;y<C;y++){let x=T.matrixWorld.clone(),j=new qo;T.isInstancedMesh&&(T.getMatrixAt(y,j),x.multiply(j));for(let B of V){let q=h[B.materialIndex??0];if(!q)throw new Error(`A material group on ${N} is missing its material.`);if(!q.visible)continue;let W=q;if(!W.isMeshStandardMaterial||W.wireframe||W.vertexColors)throw new Error(`AR snapshot cannot preserve ${q.type}${W.wireframe?" wireframe":W.vertexColors?" vertex colors":""} on ${N}. Use a PBR material or provide arHandoff.createUSDZ.`);let K=Math.max(B.start,k.drawRange.start),J=Math.min(E,B.start+B.count,k.drawRange.start+k.drawRange.count);if(J<=K)continue;if(K%3||(J-K)%3)throw new Error(`Mesh ${N} has an incomplete triangle range.`);let _=new On;a.push(_);let I=Array.from({length:J-K},(D,$)=>k.index?k.index.getX(K+$):K+$);if(x.determinant()<0)for(let D=0;D<I.length;D+=3)[I[D+1],I[D+2]]=[I[D+2],I[D+1]];for(let[D,$]of Object.entries(k.attributes)){let G=new Float32Array(I.length*$.itemSize);for(let z=0;z<I.length;z++)for(let Y=0;Y<$.itemSize;Y++)G[z*$.itemSize+Y]=$.getComponent(I[z],Y);_.setAttribute(D,new Pe(G,$.itemSize))}ge(T)&&(_.setAttribute("arSourceVertex",new Pe(new Float32Array(I),1)),_.setAttribute("arNormalSign",new Pe(new Float32Array(I.length).fill(1),1))),_.setIndex(I.map((D,$)=>$)),_.applyMatrix4(x);let U=_.getAttribute("position");for(let D=0;D<U.count;D++)if(![U.getX(D),U.getY(D),U.getZ(D)].every(Number.isFinite))throw new Error(`Mesh ${N} contains invalid coordinates.`);_.getAttribute("normal")||_.computeVertexNormals();let L=W.clone();s.push(L);let F=W.userData.reactImmersiveConfiguredEmissive;if(F?.isColor&&L.emissive.copy(F),L.side===Fo){let D=_.toNonIndexed();a.push(D);let $=D.getAttribute("position").count,G=new On;a.push(G);for(let[z,Y]of Object.entries(D.attributes)){let De=new Float32Array($*Y.itemSize*2);for(let oe=0;oe<$;oe++)for(let le=0;le<Y.itemSize;le++){De[oe*Y.itemSize+le]=Y.getComponent(oe,le);let Dn=Math.floor(oe/3)*3+(2-oe%3);De[($+oe)*Y.itemSize+le]=Y.getComponent(Dn,le)*(z==="normal"||z==="arNormalSign"?-1:1)}G.setAttribute(z,new Pe(De,Y.itemSize))}L.side=dt,_.copy(G)}else if(L.side!==dt){let D=_.getIndex();for(let z=0;z<D.count;z+=3){let Y=D.getX(z+1);D.setX(z+1,D.getX(z+2)),D.setX(z+2,Y)}let $=_.getAttribute("normal");for(let z=0;z<$.count;z++)$.setXYZ(z,-$.getX(z),-$.getY(z),-$.getZ(z));let G=_.getAttribute("arNormalSign");if(G)for(let z=0;z<G.count;z++)G.setX(z,-G.getX(z));L.side=dt}if(T.isInstancedMesh&&T.instanceColor){let D=new _o;T.getColorAt(y,D),L.color.multiply(D)}for(let[D,$]of Object.entries(L)){if(!$?.isTexture)continue;let G=$;if(At(G)||!G.image||G.image.complete===!1)throw new Error(`Texture on ${N} is not ready. Wait for image loading or replace failed textures before preparing AR.`);let z=c.get(G);if(z||(z=G.clone(),c.set(G,z),i.push(z)),L[D]=z,!_.getAttribute(z.channel?`uv${z.channel}`:"uv"))throw new Error(`Texture on ${N} needs UV coordinates missing from this geometry.`)}if(T.userData.riDecal){_.computeBoundingBox();let D=Math.max(1e-6,_.boundingBox.getSize(new Ne).length()*1e-4),$=_.getAttribute("position"),G=_.getAttribute("normal");for(let z=0;z<$.count;z++)$.setXYZ(z,$.getX(z)+G.getX(z)*D,$.getY(z)+G.getY(z)*D,$.getZ(z)+G.getZ(z)*D)}let Q=new Wo(_,L);Q.name=`AR_${f++}`,n.add(Q),l.push({sourceIndex:S,source:T,exported:Q,bakedMatrix:x.clone(),instanceMatrix:j}),u+=(_.index?.count??_.getAttribute("position").count)/3,(L.clearcoat||L.transmission||L.iridescence||L.anisotropy)&&r.add("Advanced PBR effects may look different in Quick Look.")}}}finally{k.dispose()}})}if(!f||!u)throw new Error("There is no visible model geometry to send to AR.");let d=new $o().setFromObject(n),p=d.getSize(new Ne),M=d.getCenter(new Ne),b=t.scaleMode==="real-world"?1:1/Math.max(p.x,p.y,p.z,1e-9);return n.position.set(-M.x*b,-d.min.y*b,-M.z*b),n.scale.setScalar(b),o.updateMatrixWorld(!0),r.add("Viewer lighting, background, post-processing, annotations and measurement overlays stay in the web viewer."),{root:o,meshCount:f,triangleCount:u,scale:b,warnings:[...r],textures:i,motionMeshes:l,dispose:m}}catch(d){throw m(),d}}async function ga(e,t={}){let o=t.maxTextureSize??2048;if(!Number.isInteger(o)||o<256||o>4096)throw new Error("AR maxTextureSize must be an integer from 256 to 4096.");let n=Go(e,t),r=[];try{let a=vn(e,n.motionMeshes,t.signal),s=xn(a.skins,a.samples);n.root.updateMatrixWorld(!0);let{USDZExporter:i}=await import("three/examples/jsm/exporters/USDZExporter.js");t.signal?.throwIfAborted();for(let f of n.textures){if(!f.isCompressedTexture)continue;let{decompress:u}=await import("three/examples/jsm/utils/WebGLTextureUtils.js"),m=u(f,o);r.push(m),n.root.traverse(d=>{let p=d.material;if(p)for(let M of Object.keys(p))p[M]===f&&(p[M]=m)})}let c=await new i().parseAsync(n.root,{onlyVisible:!0,quickLookCompatible:!0,maxTextureSize:o});t.signal?.throwIfAborted();let l=kn(c,a,s);return{blob:new Blob([new Uint8Array(l)],{type:"model/vnd.usdz+zip"}),meshCount:n.meshCount,triangleCount:n.triangleCount,scale:n.scale,warnings:[...n.warnings,...a.warnings]}}catch(a){if(t.signal?.aborted)throw a;let s=a instanceof Error&&a.name==="SecurityError"?" Textures must allow cross-origin canvas access.":"";throw new Error(`Could not prepare the configured USDZ: ${a instanceof Error?a.message:"export failed"}${s}`)}finally{n.dispose(),r.forEach(a=>a.dispose())}}var Ve=Object.freeze([{id:"change-color",label:"Change Color",handling:"viewer",description:"Opens a color picker docked under the action and commits the result to style.material.baseColor."},{id:"change-material",label:"Change Material",handling:"viewer",description:"Opens the material picker so the viewer can swap the object's texture."},{id:"add-text",label:"Add Text",handling:"viewer",description:"Opens a text box docked under the action; the viewer's user types, clicks the object to place it, and can resize, turn, move, or remove it. Saved to the binding's decals."},{id:"add-image",label:"Add Image",handling:"viewer",description:"Lets the viewer's user choose an image, click the object to place it, and resize, turn, move, or remove it. Saved to the binding's decals."},{id:"toggle-visibility",label:"Toggle Visibility",handling:"viewer",description:"Flips the binding's visible flag."},{id:"toggle-light",label:"Toggle Light",handling:"viewer",description:"Turns the scene lights attached to this object on or off, or the object's own glow when none is attached."},{id:"change-light-color",label:"Change Light Color",handling:"viewer",description:"Opens a color picker docked under the action for the scene lights attached to this object, or the object's own glow."},{id:"set-brightness",label:"Set Brightness",handling:"viewer",description:"Opens a brightness slider docked under the action for the scene lights attached to this object, or the object's own glow."}]),ha="__custom__";function Ho(e){return Ve.find(t=>t.id===e)}var Tn=Ve.filter(e=>e.handling==="viewer").map(e=>e.id),Xo=new Set(["","New Action",...Ve.map(e=>e.label)]);function ya(e){return Xo.has(e.trim())}function Rn(e,t){let o=Array.from({length:t.length+1},(n,r)=>r);for(let n=1;n<=e.length;n+=1){let r=[n];for(let a=1;a<=t.length;a+=1){let s=o[a-1]+(e[n-1]===t[a-1]?0:1);r[a]=Math.min(r[a-1]+1,o[a]+1,s)}o=r}return o[t.length]}function Sa(e){if(Ho(e))return null;let t=e.trim().toLowerCase();if(!t)return null;let o=t.replace(/[^a-z0-9]/g,""),n=null;for(let r of Ve){let a=Math.min(Rn(t,r.id),Rn(o,r.id.replace(/[^a-z0-9]/g,"")));(!n||a<n.distance)&&(n={id:r.id,distance:a})}return n&&n.distance<=2?n.id:null}var Ko=.12,En=new Set;function Zo(e,t){return t?new Set(ve(e,t.target)):En}function Aa(e,t){let o=Zo(e.bindings,t);if(!t||o.size===0)return{...e,setAside:En};let n=Math.min(Math.max(t.ghostOpacity??Ko,0),1),r={...e.bindings},a=new WeakMap,s=new Set;for(let[i,c]of Object.entries(e.bindings)){if(o.has(i))continue;s.add(i);let l=t.mode==="hide"?{...c,visible:!1}:{...c,style:{...c.style,material:{...c.style?.material,opacity:Math.min(c.style?.material?.opacity??1,n)}}};r[i]=l,a.set(l,e.sourceOf(c))}return{bindings:r,pulses:e.pulses,sourceOf:i=>a.get(i)??e.sourceOf(i),setAside:s}}function Yo(e){return e.trim().replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[_\s]+/g,"-").replace(/[^a-zA-Z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase()}function Jo(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,t=>t.toUpperCase())}function Qo(e){let t=e.toLowerCase();return t.includes("light")?"light":t.includes("wheel")||t.includes("rim")||t.includes("tire")?"wheel":t.includes("glass")||t.includes("window")||t.includes("windshield")||t.includes("sunroof")?"glass":t.includes("seat")||t.includes("dashboard")||t.includes("console")||t.includes("doorpanel")?"interior":t.includes("floor")?"floor":t.includes("wall")?"wall":t.includes("door")?"door":t.includes("chair")||t.includes("table")||t.includes("sofa")||t.includes("bed")?"furniture":"other"}function Bn(e,t=!0){return e==="light"||e.endsWith("light")?[{id:"toggle-light",label:"Toggle Light",type:"command"},{id:"change-light-color",label:"Change Light Color",type:"command"},{id:"set-brightness",label:"Set Brightness",type:"command"}]:[{id:"change-color",label:"Change Color",type:"command"},...t?[{id:"change-material",label:"Change Material",type:"command"}]:[],{id:"toggle-visibility",label:"Toggle Visibility",type:"command"}]}function Pn(e,t=!0){let o=Qo(e);return{id:Yo(e),modelObjectId:e,type:o,label:Jo(e),status:"normal",selectable:!0,hoverable:!0,visible:!0,style:{},actions:Bn(o,t),metrics:{},metadata:{}}}function ka(e,t){return Object.fromEntries(e.map(o=>[o,Pn(o,!t?.has(o))]))}function Oa(e,t){let o=new Set,n={};for(let r of e){let a=Pn(r,!t?.has(r)),s=a.id||"object",i=s;for(let l=2;o.has(i);l++)i=`${s}-${l}`;o.add(i),a.id=i;let c=(a.actions??[]).filter(l=>Tn.includes(l.id));a.actions=c.length>0?c:Bn("other",!t?.has(r)),n[r]=a}return n}function Ia(e){let t=new Set;for(let[o,n]of Object.entries(ae(e).nodesById))Ct(n)||t.add(o);return t}function Ra(e){let{nodesById:t}=ae(e),o=[];for(let[n,r]of Object.entries(t)){let a=r;a.isMesh&&a.geometry&&r.name&&o.push(n)}return o.sort((n,r)=>n.localeCompare(r))}var zn={id:"identity",modelObjectId:"identity",label:"identity",type:"identity",group:"identity",tags:"identity",style:"appearance",decals:"appearance",transform:"transform",visible:"visibility",removed:"visibility",status:"visibility",selectable:"behavior",hoverable:"behavior",actions:"behavior",cameraState:"behavior",metadata:"data",metrics:"data"},er=Object.keys(zn),tr=new Set(["__proto__","prototype","constructor"]);function ce(e,t=new Set){if(e==null||typeof e=="string"||typeof e=="boolean")return e;if(typeof e=="number"){if(!Number.isFinite(e))throw new Error("Comparison values must be finite JSON data");return e}if(typeof e!="object"||t.has(e))throw new Error("Comparison values must be acyclic JSON data");t.add(e);let o=Array.isArray(e)?e.map(n=>ce(n,t)):Object.fromEntries(Object.entries(e).filter(([n,r])=>!tr.has(n)&&r!==void 0).map(([n,r])=>[n,ce(r,t)]));return t.delete(e),o}var Nn=e=>e&&typeof e=="object"&&!Array.isArray(e)&&!Object.keys(e).length;function Vn(e,t){let o=ce(e);o.visible=e.visible??!0,o.selectable=e.selectable??!0,o.hoverable=e.hoverable??!0,o.status=e.status??"normal",o.type=e.type??"other",o.tags=[...new Set(e.tags??[])].sort(),Nn(o.transform)&&delete o.transform,o.metadata=Object.fromEntries(Object.entries(e.metadata??{}).filter(([n])=>!t.includes(n)));for(let n of["metrics","style","metadata"])Nn(o[n])&&delete o[n];for(let n of["actions","decals"])Array.isArray(o[n])&&!o[n].length&&delete o[n];return o}function ze(e,t,o,n,r,a){let s=c=>c===void 0||Array.isArray(c)&&c.length===0;if(Object.is(e,t)||s(e)&&s(t)||typeof e=="number"&&typeof t=="number"&&Math.abs(e-t)<=r)return;let i=c=>!!c&&typeof c=="object"&&!Array.isArray(c);if(i(e)&&i(t)){for(let c of[...new Set([...Object.keys(e),...Object.keys(t)])].sort())ze(e[c],t[c],`${o}.${c}`,n,r,a);return}if(Array.isArray(e)&&Array.isArray(t)&&e.length===t.length){for(let c=0;c<e.length;c++)ze(e[c],t[c],`${o}[${c}]`,n,r,a);return}a.push({path:o,category:n,...e!==void 0?{before:ce(e)}:{},...t!==void 0?{after:ce(t)}:{}})}function Ea(e,t,o={}){let n=o.tolerance??1e-6;if(!Number.isFinite(n)||n<0)throw new Error("Comparison tolerance must be finite and nonnegative");let r=Object.entries(e.objectBindings).filter(([,S])=>!S.removed),a=Object.entries(t.objectBindings).filter(([,S])=>!S.removed),s=new Map(r),i=new Map(a),c=new Set,l=new Set,f=[],u=S=>{let A=o.matchBy??"modelObjectId",g=typeof A=="object"?S.metadata?.[A.metadataKey]:S[A];return typeof g=="string"&&g.length>0||typeof g=="number"?`${typeof g}:${g}`:null};function m(S,A,g){let w=S===void 0?void 0:s.get(S),v=A===void 0?void 0:i.get(A),P=[];if(w||v){let N=w?Vn(w,o.ignoreMetadataKeys??[]):{},O=v?Vn(v,o.ignoreMetadataKeys??[]):{};for(let h of er)ze(N[h],O[h],h,zn[h],n,P)}let T=w?v?P.length?"modified":"unchanged":"removed":"added";f.push({id:JSON.stringify([S??null,A??null]),identity:g,label:v?.label??w?.label??v?.modelObjectId??w?.modelObjectId??g,status:T,beforeKey:S,afterKey:A,beforeObjectId:w?.modelObjectId,afterObjectId:v?.modelObjectId,changes:P}),S!==void 0&&c.add(S),A!==void 0&&l.add(A)}let d=new Set;for(let[S,A]of Object.entries(o.mapping??{})){if(!s.has(S)||!i.has(A)||d.has(A))throw new Error("Comparison mapping must reference existing, unique binding keys");d.add(A),m(S,A,`mapped:${S}`)}let p=new Map;for(let[S,A,g]of[[r,c,"a"],[a,l,"b"]])for(let[w,v]of S){if(A.has(w))continue;let P=u(v);if(P===null){f.push({id:JSON.stringify([g,w]),identity:"",label:v.label??v.modelObjectId,status:"ambiguous",...g==="a"?{beforeKey:w,beforeObjectId:v.modelObjectId}:{afterKey:w,afterObjectId:v.modelObjectId},changes:[],message:"Missing match identity. Supply an explicit mapping or another match field."});continue}let T=p.get(P)??{a:[],b:[]};T[g].push(w),p.set(P,T)}for(let[S,A]of p){if(A.a.length<=1&&A.b.length<=1){m(A.a[0],A.b[0],S);continue}for(let g of["a","b"])for(let w of A[g]){let v=(g==="a"?s:i).get(w);f.push({id:JSON.stringify([g,w]),identity:S,label:v.label??v.modelObjectId,status:"ambiguous",...g==="a"?{beforeKey:w,beforeObjectId:v.modelObjectId}:{afterKey:w,afterObjectId:v.modelObjectId},changes:[],message:"Duplicate match identity. Supply an explicit one-to-one mapping."})}}f.sort((S,A)=>S.label.localeCompare(A.label)||S.id.localeCompare(A.id));let M=[];ze(ce(e.sceneConfig??{}),ce(t.sceneConfig??{}),"sceneConfig","scene",n,M);let b={added:0,removed:0,modified:0,unchanged:0,ambiguous:0};for(let S of f)b[S.status]++;return{version:1,objects:f,counts:b,sceneChanges:M}}function Ba(e,t,o){let n={added:"#22c55e",removed:"#f87171",modified:"#fbbf24",unchanged:"#94a3b8",ambiguous:"#c084fc"};return e.objects.flatMap(r=>{let a=t==="before"?r.beforeObjectId:r.afterObjectId;return a&&(r.status!=="unchanged"||r.id===o)?[{objectId:a,color:r.id===o?"#22d3ee":n[r.status]}]:[]})}var Na=["front","back","double"],Va=["normal","additive"];function La(e){ae(e);let t=[],o=[{node:e,path:"0",parentId:null}];for(;o.length;){let{node:r,path:a,parentId:s}=o.pop(),i=`node:${a}`,c=r.isMesh&&r.name?xe(r):null;t.push({id:i,parentId:s,name:r.name||r.type||"Group",...c?{objectId:c}:{}});for(let l=r.children.length-1;l>=0;l--)o.push({node:r.children[l],path:`${a}/${l}`,parentId:i})}let n=new Set;for(let r=t.length-1;r>=0;r--){let a=t[r];(a.objectId||n.has(a.id))&&(n.add(a.id),a.parentId&&n.add(a.parentId))}return t.filter(r=>n.has(r.id))}function _a(e){return structuredClone(e.style??{})}function Fa(e,t,o){let n=ve(e,t).filter(a=>!e[a].removed);if(!n.length)return e;let r={...e};for(let a of n)r[a]={...e[a],style:structuredClone(o)};return r}export{ae as a,xe as b,Ii as c,Ri as d,ln as e,nr as f,ir as g,sr as h,lr as i,Ot as j,fr as k,Tt as l,ne as m,jr as n,gn as o,kr as p,Or as q,Ir as r,Rr as s,Tr as t,Er as u,Br as v,Xe as w,fe as x,be as y,Vr as z,zr as A,Dr as B,$r as C,Ke as D,he as E,_r as F,Fr as G,qr as H,Wr as I,Dt as J,Lt as K,Ut as L,Ye as M,Xr as N,Kr as O,Zr as P,Yr as Q,ro as R,Qe as S,ao as T,ei as U,ti as V,qt as W,so as X,ye as Y,ni as Z,oi as _,Wt as $,ie as aa,pi as ba,Te as ca,Qt as da,wi as ea,xi as fa,So as ga,Ai as ha,Mi as ia,Ci as ja,vi as ka,cn as la,un as ma,bn as na,ga as oa,Ve as pa,ha as qa,Ho as ra,Tn as sa,ya as ta,Sa as ua,Zo as va,Aa as wa,Qo as xa,Pn as ya,ka as za,Oa as Aa,Ia as Ba,Ra as Ca,Ea as Da,Ba as Ea,Na as Fa,Va as Ga,La as Ha,_a as Ia,Fa as Ja};
|
package/dist/chunk-7OVEHDDE.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as i}from"./chunk-MMO7KCYU.mjs";import{p as n}from"./chunk-YKDDNX2D.mjs";var c={licenseKey:!0,onLicenseStatusChange:!0,arHandoff:!0,mobileHandoffUrl:!0,dracoDecoderPath:!0,ktx2TranscoderPath:!0,meshopt:!0,hideLicenseCheckingOverlay:!0},s={licenseValidationUrl:!0,arLanding:!0,gizmoTool:!0,showFloorGrid:!0,onObjectEditLeaseChange:!0,onSelectionClear:!0,onSceneLoaded:!0,onTexturePositioningChange:!0,endTexturePositioningRef:!0};function u(e,t){let o={};for(let r of Object.keys(t))r in e&&(o[r]=e[r]);return o}function d(e,t){let o={...e};for(let r of Object.keys(t))delete o[r];return o}import{jsx as a}from"react/jsx-runtime";function l(e){return i("model-viewer","ModelViewer"),a(n,{...d(e,s)})}export{c as a,u as b,l as c};
|
package/dist/chunk-AL6UIGWP.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{useLayoutEffect as y,useRef as x,useState as g}from"react";import{createPortal as T}from"react-dom";import{ChevronRight as P,Info as H}from"lucide-react";import{HexColorInput as I,HexColorPicker as S}from"react-colorful";import{useEffect as L}from"react";function w(e,n,t){L(()=>{if(!t)return;let a=Array.isArray(e)?e:[e],s=i=>{let o=i.target;a.some(u=>u.current?.contains(o))||n()};return document.addEventListener("pointerdown",s,!0),()=>{document.removeEventListener("pointerdown",s,!0)}},[e,n,t])}import{jsx as r,jsxs as c}from"react/jsx-runtime";function M({anchorRef:e,onClose:n,children:t}){let a=x(null),[s,i]=g(null);return w([a,e],n,!0),y(()=>{let o=e.current;if(!o)return;let l=o.getBoundingClientRect(),u=222,p=8,d=Math.min(Math.max(l.right-u,p),window.innerWidth-u-p),b=Math.min(l.bottom+6,window.innerHeight-200);i({top:b,left:d})},[e]),s?T(r("div",{ref:a,className:"se-colorPickerPopover",style:{position:"fixed",top:s.top,left:s.left},children:t}),document.body):null}function F(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,n=>n.toUpperCase())}function G({label:e,title:n,path:t,children:a}){return c("div",{className:"se-field se-fieldInline","data-ri-path":t,children:[r("span",{className:"se-fieldLabel",title:n??e,children:e}),a]})}function U({children:e}){return r("div",{className:"rui-actions",children:e})}function W({title:e,children:n}){return c("div",{className:"se-listHeader",children:[r("span",{children:e}),n?r("span",{className:"se-listHeaderActions",children:n}):null]})}function _({title:e,actions:n,children:t}){return c("div",{className:"rui-group",children:[c("div",{className:"rui-groupHeader",children:[r("span",{children:e}),n]}),t]})}function q({title:e,children:n}){return c("section",{className:"se-section",children:[r("h3",{className:"se-sectionTitle",children:e}),r("div",{className:"se-sectionBody",children:n})]})}function J({title:e,open:n,onToggle:t,trailing:a,children:s,disabled:i,tooltip:o}){return c("section",{className:"se-panel","data-ri-section":e,children:[c("div",{className:"se-panelHeaderRow",children:[c("button",{type:"button",className:"se-panelHeader",onClick:t,"aria-expanded":n,title:o,children:[r(P,{size:13,className:`se-panelChevron ${n?"se-panelChevron--open":""}`}),r("span",{className:"se-panelTitle",children:e}),o?r(H,{size:11,className:"se-panelHelp","aria-hidden":"true"}):null]}),a?r("span",{className:"se-panelTrailing",children:a}):null]}),n?r("div",{className:`se-panelBody ${i?"se-panelBody--disabled":""}`,children:s}):null]})}function Q({checked:e,onChange:n,label:t}){return c("label",{className:"se-switch","aria-label":t,children:[r("input",{type:"checkbox",checked:e,onChange:a=>n(a.target.checked)}),r("span",{className:"se-switchTrack",children:r("span",{className:"se-switchThumb"})})]})}function k(e){return e>=1||!Number.isFinite(e)?0:Math.min(6,Math.ceil(-Math.log10(e)-1e-9))}function N(e,n,t){let a=e;return n!==void 0&&Number.isFinite(n)&&(a=Math.max(n,a)),t!==void 0&&Number.isFinite(t)&&(a=Math.min(t,a)),a}function $({value:e,step:n,min:t,max:a,disabled:s,onChange:i}){return{onPointerDown(o){if(s||o.button!==0)return;o.preventDefault();let l=o.currentTarget;l.setPointerCapture(o.pointerId);let u=o.clientX,p=e,d=k(n),b=v=>{let h=(v.clientX-u)*n*(v.shiftKey?10:1);i(N(Number((p+h).toFixed(d)),t,a))},f=()=>{l.removeEventListener("pointermove",b),l.removeEventListener("pointerup",f),l.removeEventListener("pointercancel",f)};l.addEventListener("pointermove",b),l.addEventListener("pointerup",f),l.addEventListener("pointercancel",f)}}}function D({label:e,value:n,min:t,max:a,step:s,formatValue:i,onChange:o,disabled:l=!1,unset:u=!1}){let[p,d]=g(!1),[b,f]=g(""),v=a>t?N((n-t)/(a-t)*100,0,100):0,h=u?"\u2013":i?i(n):String(Number(n.toFixed(k(s)))),C=()=>{l||(f(String(n)),d(!0))},R=()=>{let m=Number(b);b.trim()!==""&&Number.isFinite(m)&&o(m),d(!1)};return p?r("input",{className:"rui-sliderInput",type:"number","aria-label":e,autoFocus:!0,step:s,value:b,onFocus:m=>m.currentTarget.select(),onChange:m=>f(m.target.value),onBlur:R,onKeyDown:m=>{m.key==="Enter"&&R(),m.key==="Escape"&&(m.stopPropagation(),d(!1))}}):c("div",{className:`rui-slider ${l?"rui-slider--disabled":""}`,children:[r("i",{className:"rui-sliderFill",style:{width:`${v}%`}}),r("span",{className:"rui-sliderValue",children:h}),r("input",{type:"range","aria-label":e,min:t,max:a,step:s,value:N(n,t,a),disabled:l,onChange:m=>o(Number(m.target.value)),onDoubleClick:C,onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),C())}})]})}function ee({label:e,value:n,min:t,max:a,step:s,formatValue:i,onChange:o,disabled:l=!1,path:u}){return c("div",{className:`se-field se-fieldInline ${l?"se-field--disabled":""}`,"data-ri-path":u,children:[r("span",{className:"se-fieldLabel",title:e,children:e}),r(D,{label:e,value:n,min:t,max:a,step:s,formatValue:i,onChange:o,disabled:l})]})}function ne({label:e,checked:n,onChange:t,path:a}){return c("label",{className:"se-field se-fieldInline","data-ri-path":a,children:[r("span",{className:"se-fieldLabel",title:e,children:e}),r("span",{className:"rui-checkCell",children:r("input",{type:"checkbox",className:"se-checkbox",checked:n,onChange:s=>t(s.target.checked)})})]})}function te({label:e,value:n,options:t,onChange:a,path:s}){return c("label",{className:"se-field se-fieldInline","data-ri-path":s,children:[r("span",{className:"se-fieldLabel",title:e,children:e}),r("select",{className:"se-select",value:n,onChange:i=>a(i.target.value),children:t.map(i=>r("option",{value:i,children:F(i)},i))})]})}function V({label:e,value:n,onChange:t}){let[a,s]=g(!1),i=x(null);return c("span",{className:"rui-color",ref:i,children:[r("button",{type:"button",className:"rui-colorSwatch",style:{background:n},"aria-label":`Pick ${e}`,"aria-expanded":a,onClick:()=>s(o=>!o)}),r(I,{prefixed:!0,className:"rui-colorHex","aria-label":e,color:n,onChange:t}),a?r(M,{anchorRef:i,onClose:()=>s(!1),children:r(S,{color:n,onChange:t})}):null]})}function ae({label:e,value:n,onChange:t,path:a}){return c("div",{className:"se-field se-fieldInline","data-ri-path":a,children:[r("span",{className:"se-fieldLabel",title:e,children:e}),r(V,{label:e,value:n,onChange:t})]})}function O({value:e,min:n,max:t,step:a,label:s,onChange:i}){let[o,l]=g(String(e)),u=x(!1);return y(()=>{u.current||l(String(e))},[e]),r("input",{type:"number",className:"se-numberInput","aria-label":s,min:n,max:t,step:a,value:o,onFocus:()=>{u.current=!0},onChange:p=>{let d=p.target.value;l(d),d!==""&&d!=="-"&&!Number.isNaN(Number(d))&&i(Number(d))},onBlur:()=>{u.current=!1,l(String(e))}})}function E({axis:e,label:n,value:t,min:a,max:s,step:i,onChange:o}){let l=$({value:t,step:i,min:a,max:s,onChange:o});return c("span",{className:"se-vectorAxis",children:[r("span",{className:`rui-axis rui-axis--${e.toLowerCase()}`,title:`Drag to change ${e}`,...l,children:e}),r(O,{value:t,min:a,max:s,step:i,label:`${n} ${e}`,onChange:o})]})}function re({label:e,value:n,min:t,max:a,step:s,onChange:i,path:o}){return c("div",{className:"se-field se-fieldInline","data-ri-path":o,children:[r("span",{className:"se-fieldLabel",title:e,children:e}),r("div",{className:"se-vectorRow",children:["X","Y","Z"].map((u,p)=>r(E,{axis:u,label:e,value:n[p],min:t,max:a,step:s,onChange:d=>{let b=[...n];b[p]=d,i(b)}},u))})]})}function se({label:e,value:n,min:t,max:a,step:s,onChange:i,path:o}){return c("div",{className:"se-field se-fieldInline","data-ri-path":o,children:[r("span",{className:"se-fieldLabel",title:e,children:e}),r("div",{className:"se-vectorRow se-vectorRow--2",children:["X","Y"].map((u,p)=>r(E,{axis:u,label:e,value:n[p],min:t,max:a,step:s,onChange:d=>{let b=[...n];b[p]=d,i(b)}},u))})]})}export{w as a,G as b,U as c,W as d,_ as e,q as f,J as g,Q as h,$ as i,D as j,ee as k,ne as l,te as m,V as n,ae as o,re as p,se as q};
|
package/dist/chunk-KYXJG3TX.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as o}from"./chunk-NMRTI3NQ.mjs";import{useSyncExternalStore as m}from"react";import{Pause as q,Play as S,Square as b}from"lucide-react";import{jsx as a,jsxs as l}from"react/jsx-runtime";var y={sequenceId:null,time:0,duration:0,status:"stopped",previewing:!1,ready:!1,issues:[]},c=()=>y,g=()=>()=>{};function p(t){return m(t?.subscribe??g,t?.getState??c,c)}function P({controls:t,duration:n,showScrubber:i=!0,hasTracks:s=!0}){let e=o(),u=p(t),r=u.status==="playing";return l("div",{className:"ri-sequenceTransport",children:[a("button",{type:"button",onClick:()=>r?t?.pause():t?.play(),disabled:!u.ready||!n||!s,"aria-label":e(r?"sequencePause":"sequencePlay"),title:e(r?"sequencePause":"sequencePlay"),children:a("span",{"aria-hidden":"true",children:r?a(q,{size:15}):a(S,{size:15})})}),a("button",{type:"button",onClick:()=>t?.stop(),disabled:!u.previewing,"aria-label":e("sequenceStop"),title:e("sequenceStop"),children:a(b,{size:14,"aria-hidden":"true"})}),i&&a("input",{"aria-label":e("sequencePlayhead"),type:"range",min:0,max:n||1,step:.01,value:Math.min(u.time,n),disabled:!u.ready||!n,onChange:d=>{t?.pause(),t?.seek(Number(d.target.value))}}),l("output",{"aria-label":e("sequenceTime"),children:[u.time.toFixed(2)," / ",n.toFixed(2),"s"]})]})}function v({controls:t,sequences:n}){let i=o(),s=p(t);return n.length?l("section",{className:"ri-sequencePlayer","aria-label":i("sequencePlayer"),onPointerDown:e=>e.stopPropagation(),children:[a("select",{"aria-label":i("sequenceSelect"),value:s.sequenceId??"",onChange:e=>t.select(e.target.value),children:n.map(e=>a("option",{value:e.id,children:e.name},e.id))}),a(P,{controls:t,duration:s.duration,hasTracks:n.find(e=>e.id===s.sequenceId)?.tracks.some(e=>!e.muted&&e.keyframes.length>0)??!1}),!!s.issues.length&&l("details",{children:[a("summary",{children:i("sequenceIssues")}),s.issues.map(e=>a("p",{children:e},e))]})]}):null}export{p as a,P as b,v as c};
|