@vincentt-xr/sdk 2.0.0-alpha.15 → 2.0.0-alpha.17

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/GROUNDING.md CHANGED
@@ -10,7 +10,7 @@ or spelunk `node_modules` for the API.
10
10
  The API is split into task-domain entry points. Import each symbol from the door
11
11
  this reference shows for it; the imports here are literal.
12
12
 
13
- - `@vincentt-xr/sdk` — **core**: providers, scene, screen-space layout, runtime renderers (`Transform3D`, `MeshRenderer`, `SceneObjectRenderer`), `TextLabel`, `Panel`, `SpriteAnimation`, `VideoBackground`, `AspectRatioContainer`, capture/share (`useFrameCapture`, `useMediaRecorder`, `dataURLtoFile`), audio, capability detection (`useXRCapabilities`, `detectXRCapabilities`, `resolveTrackerSupport`), camera permission (`CameraPermissionGate`, `useCameraPermission`), adaptive quality (`useXRQuality`, `XRQualityController`), persistent tracking config (`useXRTrackingConfig`), asset lifecycle (`useXRAsset`, `XRAssetCache`, `defineTextureAsset` / `defineGltfAsset` / `defineVideoAsset`).
13
+ - `@vincentt-xr/sdk` — **core**: providers, scene, `Scenes` / `Scene` (screens the editor can jump between), screen-space layout, runtime renderers (`Transform3D`, `MeshRenderer`, `SceneObjectRenderer`), `TextLabel`, `Panel`, `SpriteAnimation`, `VideoBackground`, `AspectRatioContainer`, capture/share (`useFrameCapture`, `useMediaRecorder`, `dataURLtoFile`), audio, capability detection (`useXRCapabilities`, `detectXRCapabilities`, `resolveTrackerSupport`), camera permission (`CameraPermissionGate`, `useCameraPermission`), adaptive quality (`useXRQuality`, `XRQualityController`), persistent tracking config (`useXRTrackingConfig`), asset lifecycle (`useXRAsset`, `XRAssetCache`, `defineTextureAsset` / `defineGltfAsset` / `defineVideoAsset`).
14
14
  - `@vincentt-xr/sdk/scene-object` — **public authoring state**: scene-object/component types, factories, selectors, and immutable store operations.
15
15
  - `@vincentt-xr/sdk/tracking` — **trackers**: face/hand/gesture/body/holistic/segmentation, `TrackingAnchor`, `GestureTrigger`, full-body pose / move triggers (`BodyTrigger`, `useBodyTrigger`), the bare `FaceMesh`, `useFaceResults`, gestures, iris, device calibration (`useXRCalibration`), multi-subject policy (`selectSubject`, `useFaceInfo({ subject })`), the hand rig and hand try-on (`HandRig`, `HandOccluder`, `HandAttachment`, `WristAttachment`, `ForearmOccluder`, `HandTattoo`, `HandNails`), touch objects (`HandTouch`, `Touchable`), the SDK-hosted hand, glove and body models (`sdkModelAsset`), the body avatar (`BodyRig`), body occlusion and attachments (`BodyOccluder`, `BodyAttachment`), the body's depth for shaders (`useBodyDepthTexture`), 3D body poses (`BodyPose`) and up to two people with stable ids (`useBodyIds`, `useBodySubject`, `bodyId` / `subject` on every body feature).
16
16
  - `@vincentt-xr/sdk/instructions` — **instructions**: prompts that ask for a hand gesture, face expression or body pose with a 3D hint and your copy (`HandInstruction`, `FaceInstruction`, `BodyInstruction`), the generic `Instruction` layout, the detector hooks (`useHandGesture`, `useFaceExpression`, `useBodyPose`, `useInstructionHold`), the vocabularies + `define*` helpers + pure classifiers, and the hint kit (`useGhostModel`, `HintStage`, `sampleHintLoop`, blends, ghost materials).
@@ -133,18 +133,20 @@ nothing to an app bundle.
133
133
  - A `text` setting is words shown on screen: `maxLength` is the most code points
134
134
  the editor accepts (at most 500), and `multiline: true` allows line breaks.
135
135
  - An `asset` setting is a file reference; `accept` lists the kinds of file it
136
- takes (only `"image"` today).
136
+ takes: `"image"`, `"model"` (a `.glb`) or `"audio"` (an `.mp3` or `.m4a`).
137
137
  - `overriddenBy` lists other props of the component that, when written, make the
138
138
  setting ignored at run time. The editor hides the setting on an element that
139
139
  has one of them (`ScreenImage.src` is `overriddenBy: ["source"]`).
140
140
  - `element` puts a component on the editor's **supported list** as one list kind
141
- (`screenText`, `screenImage`, `screenShape`), and `supported: true` marks the
141
+ (`screenText`, `screenImage`, `screenShape`, `model`, `sound`), and `supported: true` marks the
142
142
  settings the editor shows for it. The editor shows only supported settings on
143
143
  listed components; a component without `element` is "made by code" there.
144
144
  Declared settings without `supported` stay in the file for other tools.
145
145
 
146
146
  Declared today: `ScreenText`, `TextLabel`, `ScreenSpaceUI` (`depth`),
147
- `ScreenImage`, `ScreenShape`, `PersonCutout`, and the instruction components'
147
+ `ScreenImage`, `ScreenShape`, `PersonCutout`, `MeshRenderer` (`value.assetUrl`,
148
+ a `model` asset: the editor swaps it only when it is a literal in the `value`
149
+ object) and `AudioPlayer` (`src`, a `sound` asset), and the instruction components'
148
150
  text-style props, plus the `ScreenTransform2DSettings` fields under each
149
151
  component's `screenTransform` / `transform`.
150
152
 
@@ -170,7 +172,7 @@ that reaches it.
170
172
 
171
173
  `text` and `asset` are always named, on a string prop. `maxLength=` (a whole
172
174
  number from 1 to 500) and `multiline=true|false` apply to `text`; `accept=`
173
- (comma-separated, `image`) is required on `asset`; `overriddenBy=` takes
175
+ (comma-separated, `image`, `model` or `audio`) is required on `asset`; `overriddenBy=` takes
174
176
  comma-separated top-level prop names of the component and applies to any type.
175
177
 
176
178
  ```ts
@@ -249,6 +251,48 @@ the component's own props object, before destructuring.
249
251
 
250
252
  ---
251
253
 
254
+ ## Scenes and editable shape
255
+
256
+ ### `<Scenes>` / `<Scene>` — screens the editor can jump between (core)
257
+
258
+ ```tsx
259
+ import { Scene, Scenes } from "@vincentt-xr/sdk";
260
+
261
+ const [scene, setScene] = useState("start");
262
+
263
+ <Scenes current={scene}>
264
+ <Scene id="start" label="Start">
265
+ <StartScreen onPlay={() => setScene("game")} />
266
+ </Scene>
267
+ <Scene id="game" label="Game">
268
+ <GameScreen />
269
+ </Scene>
270
+ <Scene id="result" label="Result">
271
+ <ResultScreen />
272
+ </Scene>
273
+ </Scenes>;
274
+ ```
275
+
276
+ - `Scenes` renders the one child `Scene` whose `id` equals `current`, and nothing when none matches. Only `Scene` children count (through fragments); anything else inside `Scenes` is ignored.
277
+ - Flow is the app's own state. `Scenes` holds no state and has no transition API; change `current` to move.
278
+ - Use `Scenes` once in the 3D tree (inside `<Canvas>`) and once in the HTML tree, each with the same ids. A scene present in only one tree is fine.
279
+ - `id` is the name code and comments refer to. Give it lowercase letters, digits, `-` or `_` (1 to 64). It is not editable in the editor and never changes when a creator renames a scene.
280
+ - `label` is the name shown in the editor's scene list; the editor edits only `label`.
281
+ - A published app renders exactly the switch above. The editor's own build swaps in a `Scenes` that can show a chosen scene and catches a scene that throws; app code never imports it (`@vincentt-xr/sdk/editor-scenes` is not for app authors) and must not read `__VCT_EDIT_OVERRIDES__`.
282
+
283
+ ### Editable shape — how to write a project the visual editor can edit
284
+
285
+ The editor reads source, so the shape of the code decides what a creator can change.
286
+
287
+ - **Settings live in the schema file.** Put every number, string, colour and list a creator may tune in `src/settings.ts` (a zod schema plus the `settings` values), and read it from there. Never hard-code a count, duration, label or colour in a component.
288
+ - **Each scene renders on its own.** A `Scene` must render with no earlier scene having run, using the sample values from `settings`. The editor opens any scene directly; a scene that needs state from another one fails to open.
289
+ - **Spawned objects are a component in `.map()`.** Render each kind as `settings.fruits.map((f) => <FallingFruit key={f.name} {...f} />)` and declare the list's varieties in the schema with `.meta({ varietiesOf: "FallingFruit" })`.
290
+ - **Style with Tailwind classes** in a literal `className`. No CSS files and no inline `style` for anything a creator would change.
291
+ - **Plain file paths.** Import with relative or plain paths; no glob imports, no computed dynamic `import()`.
292
+ - **Check your work.** Run `vincentt editor --check` and fix everything it lists that you can, until what remains is code only.
293
+
294
+ ---
295
+
252
296
  ## Screen-space layout (the primary tool)
253
297
 
254
298
  Most Vincentt projects use screen-space UI: decorative frames, prompts, badges, controls — overlaid on the live camera feed. This is more common than world-space landmark attachment.
@@ -0,0 +1,29 @@
1
+ import { jsx as s, Fragment as c } from "react/jsx-runtime";
2
+ import { Children as p, isValidElement as u, Fragment as f } from "react";
3
+ const r = "vctScene";
4
+ function a({ children: t }) {
5
+ return /* @__PURE__ */ s(c, { children: t });
6
+ }
7
+ a[r] = !0;
8
+ function o(t) {
9
+ const e = [];
10
+ for (const n of p.toArray(t)) {
11
+ if (!u(n)) continue;
12
+ if (n.type === f) {
13
+ e.push(...o(n.props.children));
14
+ continue;
15
+ }
16
+ const i = n.type;
17
+ typeof i == "string" || i[r] !== !0 || typeof n.props.id == "string" && e.push({ id: n.props.id, element: n });
18
+ }
19
+ return e;
20
+ }
21
+ function l({ current: t, children: e }) {
22
+ const n = o(e).find((i) => i.id === t);
23
+ return n ? n.element : null;
24
+ }
25
+ export {
26
+ a as S,
27
+ l as a,
28
+ o as s
29
+ };
@@ -0,0 +1 @@
1
+ "use strict";const s=require("react/jsx-runtime"),r=require("react"),o="vctScene";function u({children:n}){return s.jsx(s.Fragment,{children:n})}u[o]=!0;function c(n){const t=[];for(const e of r.Children.toArray(n)){if(!r.isValidElement(e))continue;if(e.type===r.Fragment){t.push(...c(e.props.children));continue}const i=e.type;typeof i=="string"||i[o]!==!0||typeof e.props.id=="string"&&t.push({id:e.props.id,element:e})}return t}function p({current:n,children:t}){const e=c(t).find(i=>i.id===n);return e?e.element:null}exports.Scene=u;exports.Scenes=p;exports.sceneEntries=c;
@@ -1,2 +1,2 @@
1
- "use strict";const H=require("react/jsx-runtime"),x=require("react"),ve=require("@react-three/fiber"),Me=require("./context-hA0Rb2Xa.cjs"),Te=require("./useEditOverrides-C8Kzr6M7.cjs"),xe=require("three");function Oe(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const Ce=Oe(xe),Le=({children:t,depth:e=0})=>{const{camera:n,size:r}=ve.useThree(),a=x.useMemo(()=>{if(!n.isPerspectiveCamera)return{width:10,height:10};const i=n,l=Math.abs(i.position.z-e),f=i.fov*Math.PI/180,s=2*Math.tan(f/2)*l;return{width:s*(r.width/r.height),height:s}},[n,r,e]);return H.jsx(Me.ScreenSpaceContext.Provider,{value:a,children:H.jsx("group",{position:[0,0,e],children:t})})},de=x.forwardRef(({texture:t,name:e,overlay:n,opacity:r,position:a,rotation:i,scale:l,visible:f,renderOrder:s},h)=>H.jsxs("mesh",{ref:h,name:e,position:a,rotation:i,scale:l,visible:f,renderOrder:s,children:[H.jsx("planeGeometry",{args:[1,1]}),H.jsx("meshBasicMaterial",{map:t,transparent:!0,opacity:r,depthTest:!n,depthWrite:!n})]}));de.displayName="TextLabelMesh";const Fe={color:"#ffffff",strokeWidth:0,strokeOpacity:1,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,shadowOpacity:1,fontWeight:"bold",fontStyle:"normal",fontFamily:"Arial, sans-serif",fontSize:48,textAlign:"center",verticalAlign:"center",minFontSize:12,letterSpacing:0,lineSpacing:.3,bgColor:"rgba(20,40,110,0.88)",bgFillMode:"solid",bgOpacity:1,bgFit:"full",bgTextureFit:"cover",bgTextureFlipX:!1,bgTextureFlipY:!1,borderWidth:0,borderRadius:24,padding:32,aspect:2.5,resolution:512,opacity:1,underline:!1,strikethrough:!1,bendPreset:"arc",bendStrength:0},ue=t=>{x.useEffect(()=>()=>{t==null||t.dispose()},[t])};function We(t,e,n){return n==="left"?e:n==="right"?t-e:t/2}function Ye(t,e,n,r,a){return a==="top"?e+n/2:a==="bottom"?t-e-r+n/2:t/2-(r-n)/2}function ke(t,e,n,r){return r==="full"||n==="left"?0:n==="right"?t-e:(t-e)/2}function be(t,e,n,r){return`${t} ${e} ${n}px ${r}`}function R(t,e){const n=Math.max(0,Math.min(e,1));return t*n*.08}function me(t,e){const n=Math.max(0,Math.min(e,1));return t*(1.2+n*.6)}function Se(t,e){"letterSpacing"in t&&(t.letterSpacing=`${e}px`)}function ye(t){"letterSpacing"in t&&(t.letterSpacing="0px")}function p(t,e,n){Se(t,n);const r=t.measureText(e).width;return ye(t),r}function J(t,e,n,r){return Math.max(1,Math.floor((t-e*2)/me(n,r)))}function Pe(t,e,n,r,a){return e.length<=r&&e.every(i=>p(t,i,a)<=n)}function V(t,e,n,r,a,i,l,f){t.font=be(r,a,i,l);const s=e.split(" "),h=[];let o="";for(const d of s){const c=o?`${o} ${d}`:d;p(t,c,f)>n&&o?(h.push(o),o=d):o=c}return o&&h.push(o),h}function fe(t,e,n,r,a,i,l,f){const h=e.split(/\r?\n/).flatMap(o=>o.trim().length===0?[""]:V(t,o,n,r,a,i,l,f));return h.length>0?h:[e]}function we(t,e,n,r,a){const i=r?"...":"";let l=e.trimEnd();for(;l.length>0&&p(t,`${l}${i}`,a)>n;)l=l.slice(0,-1).trimEnd();return`${l}${i}`}function K(t,e,n,r,a){return e.map((i,l)=>{if(p(t,i,a)<=n)return i;const f=l===e.length-1;return we(t,i,n,r==="ellipsis"&&f,a)})}function he(t,e,n,r,a,i){if(e.length<=n)return K(t,e,r,a?"ellipsis":"clip",i);const l=e.slice(0,n),f=l[n-1];return l[n-1]=we(t,f,r,a,i),K(t,l,r,a?"ellipsis":"clip",i)}function He(t){const{ctx:e,text:n,explicitLines:r,maxWidth:a,maxHeight:i,padding:l,fontStyle:f,fontWeight:s,fontSize:h,fontFamily:o,letterSpacing:d,lineSpacing:c,overflow:u,resizeToFit:S,minFontSize:g}=t;let b=h,m=R(b,d),y=r??fe(e,n,a,f,s,b,o,m),v=J(i,l,b,c);const C=S===!0||u==="shrink";for(;C&&!Pe(e,y,a,v,m)&&b>g&&(b=Math.max(g,b-4),m=R(b,d),y=r??fe(e,n,a,f,s,b,o,m),v=J(i,l,b,c),b!==g););return u==="ellipsis"?y=he(e,y,v,a,!0,m):u==="clamp"||u==="shrink"?y=he(e,y,v,a,!1,m):u!=="clip"&&(y=K(e,y,a,void 0,m)),{fontSize:b,lines:y}}function Xe(t){const{ctx:e,text:n,maxWidth:r,maxHeight:a,padding:i,fontStyle:l,fontWeight:f,fontSize:s,fontFamily:h,letterSpacing:o,lineSpacing:d}=t;let c=s,u=V(e,n,r,l,f,c,h,R(c,o));const S=J(a,i,c,d);return u.length>S&&(c=Math.max(12,Math.round(c*.75)),u=V(e,n,r,l,f,c,h,R(c,o))),{fontSize:c,lines:u}}function Q(t,e){return typeof OffscreenCanvas<"u"?new OffscreenCanvas(t,e):(()=>{const n=document.createElement("canvas");return n.width=t,n.height=e,n})()}function pe(t,e){const n=e.width-e.padding*2,a=Array.isArray(e.lines)||e.text.includes(`
1
+ "use strict";const H=require("react/jsx-runtime"),x=require("react"),ve=require("@react-three/fiber"),Me=require("./context-hA0Rb2Xa.cjs"),Te=require("./useEditOverrides-CgapHJzA.cjs"),xe=require("three");function Oe(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const Ce=Oe(xe),Le=({children:t,depth:e=0})=>{const{camera:n,size:r}=ve.useThree(),a=x.useMemo(()=>{if(!n.isPerspectiveCamera)return{width:10,height:10};const i=n,l=Math.abs(i.position.z-e),f=i.fov*Math.PI/180,s=2*Math.tan(f/2)*l;return{width:s*(r.width/r.height),height:s}},[n,r,e]);return H.jsx(Me.ScreenSpaceContext.Provider,{value:a,children:H.jsx("group",{position:[0,0,e],children:t})})},de=x.forwardRef(({texture:t,name:e,overlay:n,opacity:r,position:a,rotation:i,scale:l,visible:f,renderOrder:s},h)=>H.jsxs("mesh",{ref:h,name:e,position:a,rotation:i,scale:l,visible:f,renderOrder:s,children:[H.jsx("planeGeometry",{args:[1,1]}),H.jsx("meshBasicMaterial",{map:t,transparent:!0,opacity:r,depthTest:!n,depthWrite:!n})]}));de.displayName="TextLabelMesh";const Fe={color:"#ffffff",strokeWidth:0,strokeOpacity:1,shadowBlur:0,shadowOffsetX:0,shadowOffsetY:0,shadowOpacity:1,fontWeight:"bold",fontStyle:"normal",fontFamily:"Arial, sans-serif",fontSize:48,textAlign:"center",verticalAlign:"center",minFontSize:12,letterSpacing:0,lineSpacing:.3,bgColor:"rgba(20,40,110,0.88)",bgFillMode:"solid",bgOpacity:1,bgFit:"full",bgTextureFit:"cover",bgTextureFlipX:!1,bgTextureFlipY:!1,borderWidth:0,borderRadius:24,padding:32,aspect:2.5,resolution:512,opacity:1,underline:!1,strikethrough:!1,bendPreset:"arc",bendStrength:0},ue=t=>{x.useEffect(()=>()=>{t==null||t.dispose()},[t])};function We(t,e,n){return n==="left"?e:n==="right"?t-e:t/2}function Ye(t,e,n,r,a){return a==="top"?e+n/2:a==="bottom"?t-e-r+n/2:t/2-(r-n)/2}function ke(t,e,n,r){return r==="full"||n==="left"?0:n==="right"?t-e:(t-e)/2}function be(t,e,n,r){return`${t} ${e} ${n}px ${r}`}function R(t,e){const n=Math.max(0,Math.min(e,1));return t*n*.08}function me(t,e){const n=Math.max(0,Math.min(e,1));return t*(1.2+n*.6)}function Se(t,e){"letterSpacing"in t&&(t.letterSpacing=`${e}px`)}function ye(t){"letterSpacing"in t&&(t.letterSpacing="0px")}function p(t,e,n){Se(t,n);const r=t.measureText(e).width;return ye(t),r}function J(t,e,n,r){return Math.max(1,Math.floor((t-e*2)/me(n,r)))}function Pe(t,e,n,r,a){return e.length<=r&&e.every(i=>p(t,i,a)<=n)}function V(t,e,n,r,a,i,l,f){t.font=be(r,a,i,l);const s=e.split(" "),h=[];let o="";for(const d of s){const c=o?`${o} ${d}`:d;p(t,c,f)>n&&o?(h.push(o),o=d):o=c}return o&&h.push(o),h}function fe(t,e,n,r,a,i,l,f){const h=e.split(/\r?\n/).flatMap(o=>o.trim().length===0?[""]:V(t,o,n,r,a,i,l,f));return h.length>0?h:[e]}function we(t,e,n,r,a){const i=r?"...":"";let l=e.trimEnd();for(;l.length>0&&p(t,`${l}${i}`,a)>n;)l=l.slice(0,-1).trimEnd();return`${l}${i}`}function K(t,e,n,r,a){return e.map((i,l)=>{if(p(t,i,a)<=n)return i;const f=l===e.length-1;return we(t,i,n,r==="ellipsis"&&f,a)})}function he(t,e,n,r,a,i){if(e.length<=n)return K(t,e,r,a?"ellipsis":"clip",i);const l=e.slice(0,n),f=l[n-1];return l[n-1]=we(t,f,r,a,i),K(t,l,r,a?"ellipsis":"clip",i)}function He(t){const{ctx:e,text:n,explicitLines:r,maxWidth:a,maxHeight:i,padding:l,fontStyle:f,fontWeight:s,fontSize:h,fontFamily:o,letterSpacing:d,lineSpacing:c,overflow:u,resizeToFit:S,minFontSize:g}=t;let b=h,m=R(b,d),y=r??fe(e,n,a,f,s,b,o,m),v=J(i,l,b,c);const C=S===!0||u==="shrink";for(;C&&!Pe(e,y,a,v,m)&&b>g&&(b=Math.max(g,b-4),m=R(b,d),y=r??fe(e,n,a,f,s,b,o,m),v=J(i,l,b,c),b!==g););return u==="ellipsis"?y=he(e,y,v,a,!0,m):u==="clamp"||u==="shrink"?y=he(e,y,v,a,!1,m):u!=="clip"&&(y=K(e,y,a,void 0,m)),{fontSize:b,lines:y}}function Xe(t){const{ctx:e,text:n,maxWidth:r,maxHeight:a,padding:i,fontStyle:l,fontWeight:f,fontSize:s,fontFamily:h,letterSpacing:o,lineSpacing:d}=t;let c=s,u=V(e,n,r,l,f,c,h,R(c,o));const S=J(a,i,c,d);return u.length>S&&(c=Math.max(12,Math.round(c*.75)),u=V(e,n,r,l,f,c,h,R(c,o))),{fontSize:c,lines:u}}function Q(t,e){return typeof OffscreenCanvas<"u"?new OffscreenCanvas(t,e):(()=>{const n=document.createElement("canvas");return n.width=t,n.height=e,n})()}function pe(t,e){const n=e.width-e.padding*2,a=Array.isArray(e.lines)||e.text.includes(`
2
2
  `)||e.overflow!==void 0||e.resizeToFit!==void 0?He({ctx:t,text:e.text,explicitLines:e.lines,maxWidth:n,maxHeight:e.height,padding:e.padding,fontStyle:e.fontStyle,fontWeight:e.fontWeight,fontSize:e.fontSize,fontFamily:e.fontFamily,overflow:e.overflow,resizeToFit:e.resizeToFit,minFontSize:e.minFontSize,letterSpacing:e.letterSpacing,lineSpacing:e.lineSpacing}):Xe({ctx:t,text:e.text,maxWidth:n,maxHeight:e.height,padding:e.padding,fontStyle:e.fontStyle,fontWeight:e.fontWeight,fontSize:e.fontSize,fontFamily:e.fontFamily,letterSpacing:e.letterSpacing,lineSpacing:e.lineSpacing}),i=a.fontSize,l=a.lines;t.font=be(e.fontStyle,e.fontWeight,i,e.fontFamily);const f=R(i,e.letterSpacing),s=me(i,e.lineSpacing),h=Math.max(i,i+(l.length-1)*s),o=Ye(e.height,e.padding,i,h,e.verticalAlign),d=l.map(c=>p(t,c,f));return{fontSize:i,resolvedLines:l,letterSpacingPx:f,lineHeight:s,startY:o,textBlockWidth:Math.min(e.width,Math.max(0,Math.max(...d,0))+e.padding*2),textBlockHeight:Math.min(e.height,h+e.padding*2),textX:We(e.width,e.padding,e.textAlign)}}function Ae(t,e,n,r,a,i){t.beginPath(),t.moveTo(e+i,n),t.lineTo(e+r-i,n),t.quadraticCurveTo(e+r,n,e+r,n+i),t.lineTo(e+r,n+a-i),t.quadraticCurveTo(e+r,n+a,e+r-i,n+a),t.lineTo(e+i,n+a),t.quadraticCurveTo(e,n+a,e,n+a-i),t.lineTo(e,n+i),t.quadraticCurveTo(e,n,e+i,n),t.closePath()}function ce(t,e,n){return typeof t!="number"||Number.isNaN(t)||t<=0?e:Math.min(t,n)}function Be(t,e){const n=ke(e.canvasWidth,e.panelWidth,e.textAlign,e.bgFit),r=(e.canvasHeight-e.panelHeight)/2,a=Math.min(e.borderRadius,Math.min(e.panelWidth,e.panelHeight)/2);Ae(t,n,r,e.panelWidth,e.panelHeight,a),ze(t,{panelX:n,panelY:r,panelWidth:e.panelWidth,panelHeight:e.panelHeight,bgColor:e.bgColor,bgFillMode:e.bgFillMode,bgOpacity:e.bgOpacity,bgGradientStops:e.bgGradientStops,bgTextureImage:e.bgTextureImage,bgTextureFit:e.bgTextureFit,bgTextureFlipX:e.bgTextureFlipX,bgTextureFlipY:e.bgTextureFlipY}),e.borderColor&&e.borderWidth>0&&(t.lineWidth=e.borderWidth,t.strokeStyle=e.borderColor,t.stroke())}function ze(t,e){if(t.save(),t.globalAlpha=Math.max(0,Math.min(e.bgOpacity,1)),e.bgFillMode==="gradient"&&e.bgGradientStops&&e.bgGradientStops.length>1){const n=t.createLinearGradient(e.panelX,e.panelY,e.panelX+e.panelWidth,e.panelY+e.panelHeight);[...e.bgGradientStops].sort((r,a)=>r.position-a.position).forEach(r=>n.addColorStop(Math.max(0,Math.min(r.position,1)),r.color)),t.fillStyle=n,t.fill(),t.restore();return}if(e.bgTextureImage){t.clip(),Re(t,{image:e.bgTextureImage,x:e.panelX,y:e.panelY,width:e.panelWidth,height:e.panelHeight,fit:e.bgTextureFit,flipX:e.bgTextureFlipX,flipY:e.bgTextureFlipY}),t.restore();return}t.fillStyle=e.bgColor,t.fill(),t.restore()}function Re(t,e){const{image:n,x:r,y:a,width:i,height:l,fit:f,flipX:s,flipY:h}=e,o="naturalWidth"in n?n.naturalWidth:"videoWidth"in n?n.videoWidth:n.width,d="naturalHeight"in n?n.naturalHeight:"videoHeight"in n?n.videoHeight:n.height;let c=i,u=l,S=r,g=a;if(f!=="stretch"&&o>0&&d>0){const b=f==="cover"?Math.max(i/o,l/d):Math.min(i/o,l/d);c=o*b,u=d*b,S=r+(i-c)/2,g=a+(l-u)/2}t.save(),(s||h)&&(t.translate(s?r+i:0,h?a+l:0),t.scale(s?-1:1,h?-1:1),S=s?-(S-r)-c+r:S,g=h?-(g-a)-u+a:g),t.drawImage(n,S,g,c,u),t.restore()}function Ie(t,e,n,r,a,i){const l=a/72,f=Math.abs(l),s=1-Math.min(1,Math.abs(e)),h=Math.min(1,Math.abs(e)),o=r<=1?.5:n/(r-1),d=Math.sin(o*Math.PI*2-Math.PI/2),c=Math.sin(o*Math.PI*2.7-Math.PI/2)*(.65+o*.35),u=a*e*e,S=2*a*e/i,g={xOffset:0,yOffset:0,rotation:0,scaleX:1,scaleY:1};switch(t){case"arc":return{...g,yOffset:u,rotation:Math.atan(S)};case"arc-lower":return{...g,yOffset:u*.55,scaleY:Math.max(.2,1+l*e*e*.45)};case"arc-upper":return{...g,yOffset:-u*.55,scaleY:Math.max(.2,1-l*e*e*.45)};case"arch":return{...g,yOffset:u};case"bulge":return{...g,scaleY:Math.max(.2,1+l*s*.75)};case"shell-lower":return{...g,yOffset:a*.45*o*s,scaleY:Math.max(.2,1+l*o*s)};case"shell-upper":return{...g,yOffset:-a*.45*(1-o)*s,scaleY:Math.max(.2,1+l*(1-o)*s)};case"flag":return{...g,yOffset:a*.65*c,rotation:Math.atan(a/Math.max(i,1)*Math.cos(o*Math.PI*2.7)*1.6)};case"wave":return{...g,yOffset:a*.6*d,rotation:Math.atan(a/Math.max(i,1)*Math.cos(o*Math.PI*2)*1.4)};case"fish":return{...g,scaleX:Math.max(.25,1-f*h*.55),scaleY:Math.max(.2,1+l*s)};case"rise":return{...g,yOffset:a*e};case"fisheye":return{...g,yOffset:a*.18*e*s,scaleX:Math.max(.25,1+l*s*.7),scaleY:Math.max(.2,1+l*s*.7)};case"inflate":return{...g,scaleX:Math.max(.25,1+l*s*.6),scaleY:Math.max(.2,1+l*s*.6)};case"squeeze":return{...g,scaleY:Math.max(.2,1-l*s*.8)};case"twist":return{...g,yOffset:a*e,rotation:l*e*.45,scaleY:Math.max(.2,1+l*e*.25)};default:return g}}function X(t,e,n,r,a,i,l="arc",f=0){if(f!==0){Ee(t,e,n,r,a,i,l,f);return}Se(t,a),i==="fill"?t.fillText(e,n,r):t.strokeText(e,n,r),ye(t)}function Ee(t,e,n,r,a,i,l,f){const s=Array.from(e);if(s.length===0)return;const h=s.map(m=>t.measureText(m).width),o=h.reduce((m,y)=>m+y,0)+a*Math.max(0,s.length-1),d=t.textAlign,c=d==="right"?n-o:d==="center"?n-o/2:n,S=Math.max(-100,Math.min(f,100))/100*72,g=Math.max(o/2,1);let b=c;for(let m=0;m<s.length;m++){const y=s[m],v=h[m],C=b+v/2,W=(C-c-o/2)/g,O=Ie(l,W,m,s.length,S,g);t.save(),t.translate(C+O.xOffset,r+O.yOffset),t.rotate(O.rotation),t.scale(O.scaleX,O.scaleY),t.textAlign="center",i==="fill"?t.fillText(y,0,0):t.strokeText(y,0,0),t.restore(),b+=v+a}}function ge(t,e,n,r,a,i,l,f,s){const h=p(t,e,f),o=a==="center"?n-h/2:a==="right"?n-h:n,d=s==="underline"?l*.42:-l*.08,c=r+d;t.save(),t.strokeStyle=i,t.lineWidth=Math.max(2,l*.06),t.lineCap="round",t.beginPath(),t.moveTo(o,c),t.lineTo(o+h,c),t.stroke(),t.restore()}function De(t,e){for(let n=0;n<e.lines.length;n++){const r=e.lines[n],a=e.startY+n*e.lineHeight;for(const i of e.shadowLayers)t.save(),t.shadowColor=i.color,t.shadowBlur=i.blur,t.shadowOffsetX=i.offsetX??0,t.shadowOffsetY=i.offsetY??0,t.globalAlpha=i.opacity??1,t.fillStyle=e.color,X(t,r,e.textX,a,e.letterSpacingPx,"fill",e.bendPreset,e.bendStrength),t.restore();for(const i of e.strokeLayers)t.save(),t.lineJoin="round",t.miterLimit=2,t.lineWidth=i.width,t.strokeStyle=i.color,t.globalAlpha=i.opacity??1,X(t,r,e.textX,a,e.letterSpacingPx,"stroke",e.bendPreset,e.bendStrength),t.restore();t.save(),t.fillStyle=e.color,t.globalAlpha=1,X(t,r,e.textX,a,e.letterSpacingPx,"fill",e.bendPreset,e.bendStrength),t.restore(),e.underline&&ge(t,r,e.textX,a,e.textAlign,e.color,e.fontSize,e.letterSpacingPx,"underline"),e.strikethrough&&ge(t,r,e.textX,a,e.textAlign,e.color,e.fontSize,e.letterSpacingPx,"strikethrough")}}function $e(t,e){const n=Math.max(0,Math.min(e.intensity,1));if(n<=0)return;const r=Math.max(0,Math.min(e.range,1)),a=r*72,i=Math.max(-.5,Math.min(e.horizontalAngle,.5))*80,l=Math.max(-.5,Math.min(e.verticalAngle,.5))*80;for(let f=0;f<e.lines.length;f++){const s=e.startY+f*e.lineHeight;t.save(),t.globalAlpha=n,t.shadowColor=e.color,t.shadowBlur=a,t.shadowOffsetX=i,t.shadowOffsetY=l,e.style==="contoured"?(t.lineJoin="round",t.miterLimit=2,t.lineWidth=Math.max(2,r*42),t.strokeStyle=e.color,X(t,e.lines[f],e.textX,s,e.letterSpacingPx,"stroke",e.bendPreset,e.bendStrength)):(t.fillStyle=e.color,X(t,e.lines[f],e.textX,s,e.letterSpacingPx,"fill",e.bendPreset,e.bendStrength)),t.restore()}}function je(t,e){const n=Q(e.width,e.height),r=n.getContext("2d");r.clearRect(0,0,e.width,e.height),r.font=e.font,r.fillStyle="#ffffff",r.textAlign=e.textAlign,r.textBaseline="middle";for(let l=0;l<e.lines.length;l++)X(r,e.lines[l],e.textX,e.startY+l*e.lineHeight,e.letterSpacingPx,"fill",e.bendPreset,e.bendStrength);const a=Q(e.width,e.height),i=a.getContext("2d");i.clearRect(0,0,e.width,e.height),i.save(),i.globalAlpha=e.opacity,i.filter=e.blur>0?`blur(${e.blur}px)`:"none",i.drawImage(n,e.offsetX,e.offsetY),i.restore(),i.globalCompositeOperation="destination-in",i.drawImage(n,0,0),i.globalCompositeOperation="source-in",i.globalAlpha=e.opacity,i.fillStyle=e.color,i.fillRect(0,0,e.width,e.height),t.drawImage(a,0,0)}function qe(t){const{width:e,height:n,color:r,strokeLayers:a,strokeColor:i,strokeWidth:l,strokeOpacity:f,shadowLayers:s,innerShadow:h,glow:o,shadowColor:d,shadowBlur:c,shadowOffsetX:u,shadowOffsetY:S,shadowOpacity:g,textAlign:b,bgFillMode:m,bgOpacity:y,bgFit:v,bgAutoSize:C,bgWidth:W,bgHeight:O,bgGradientStops:L,bgTextureImage:F,bgTextureFit:I,bgTextureFlipX:E,bgTextureFlipY:D,underline:$,strikethrough:j,bendPreset:Y,bendStrength:k}=t;let{fontSize:A,bgColor:B}=t;const q=[...a??[],...i&&l>0?[{color:i,width:l,opacity:f}]:[]].filter(T=>T.width>0),G=[...s??[],...d&&(c>0||u!==0||S!==0)?[{color:d,blur:c,offsetX:u,offsetY:S,opacity:g}]:[]].filter(T=>T.blur>0||(T.offsetX??0)!==0||(T.offsetY??0)!==0);let P;const z=Q(e,n),M=z.getContext("2d");M.clearRect(0,0,e,n),M.fillStyle=r,M.textAlign=b,M.textBaseline="middle";const w=pe(M,t);if(A=w.fontSize,B!=="transparent"){const T=C===!0,_=ce(T?void 0:W,v==="text"||T?w.textBlockWidth:e,e),N=ce(T?void 0:O,v==="text"||T?w.textBlockHeight:n,n);Be(M,{canvasWidth:e,canvasHeight:n,textAlign:b,bgFit:v,panelWidth:_,panelHeight:N,bgColor:B,bgFillMode:m,bgOpacity:y,bgGradientStops:L,bgTextureImage:F,bgTextureFit:I,bgTextureFlipX:E,bgTextureFlipY:D,borderColor:t.borderColor,borderWidth:t.borderWidth,borderRadius:t.borderRadius})}return o&&$e(M,{lines:w.resolvedLines,textX:w.textX,startY:w.startY,lineHeight:w.lineHeight,letterSpacingPx:w.letterSpacingPx,bendPreset:Y,bendStrength:k,color:o.color,style:o.style,intensity:o.intensity??.5,range:o.range??.5,horizontalAngle:o.horizontalAngle??0,verticalAngle:o.verticalAngle??0}),De(M,{lines:w.resolvedLines,textX:w.textX,startY:w.startY,lineHeight:w.lineHeight,textAlign:b,color:r,fontSize:A,letterSpacingPx:w.letterSpacingPx,bendPreset:Y,bendStrength:k,shadowLayers:G,strokeLayers:q,underline:$,strikethrough:j}),h&&je(M,{width:e,height:n,font:M.font,lines:w.resolvedLines,textX:w.textX,startY:w.startY,lineHeight:w.lineHeight,letterSpacingPx:w.letterSpacingPx,bendPreset:Y,bendStrength:k,textAlign:b,color:h.color,opacity:h.opacity??1,blur:h.blur,offsetX:h.offsetX??0,offsetY:h.offsetY??0}),P=new Ce.CanvasTexture(z),P.needsUpdate=!0,P}function Ge(t,e){const{lines:n,color:r,strokeLayers:a,outlineEnabled:i,strokeColor:l,strokeWidth:f,strokeOpacity:s,shadowLayers:h,shadowEnabled:o,innerShadow:d,glow:c,shadowColor:u,shadowBlur:S,shadowOffsetX:g,shadowOffsetY:b,shadowOpacity:m,fontWeight:y,fontStyle:v,fontFamily:C,fontSize:W,textAlign:O,verticalAlign:L,overflow:F,resizeToFit:I,minFontSize:E,letterSpacing:D,lineSpacing:$,bgFillMode:j,bgOpacity:Y,bgFit:k,bgAutoSize:A,bgWidth:B,bgHeight:q,bgGradientStops:G,bgTextureFit:P,bgTextureFlipX:z,bgTextureFlipY:M,borderColor:w,borderWidth:T,borderRadius:_,padding:N,aspect:Z,resolution:U,underline:ee,strikethrough:te,bendPreset:ne,bendStrength:re}=t,ie=x.useMemo(()=>i===!1?[]:a,[i,a]),ae=x.useMemo(()=>o===!1?[]:h,[o,h]),le=void 0,oe=x.useMemo(()=>({text:e.text,lines:n,color:r,strokeLayers:ie,strokeColor:i===!1?void 0:l,strokeWidth:i===!1?0:f,strokeOpacity:s,shadowLayers:ae,innerShadow:d,glow:c,shadowColor:o===!1?void 0:u,shadowBlur:o===!1?0:S,shadowOffsetX:o===!1?0:g,shadowOffsetY:o===!1?0:b,shadowOpacity:m,fontWeight:y,fontStyle:v,fontFamily:C,fontSize:W,textAlign:O,verticalAlign:L,overflow:F,resizeToFit:I,minFontSize:E,letterSpacing:D,lineSpacing:$,bgColor:e.bgColor,bgFillMode:j,bgOpacity:Y,bgFit:k,bgAutoSize:A,bgWidth:B,bgHeight:q,bgGradientStops:G,bgTextureImage:le,bgTextureFit:P,bgTextureFlipX:z,bgTextureFlipY:M,borderColor:w,borderWidth:T,borderRadius:_,padding:N,height:U,width:Math.round(U*Math.max(Z,.1)),underline:ee,strikethrough:te,bendPreset:ne,bendStrength:re}),[e.text,e.bgColor,n,r,ie,i,l,f,s,ae,d,c,o,u,S,g,b,m,y,v,C,W,O,L,F,I,E,D,$,j,Y,k,A,B,q,G,le,P,z,M,w,T,_,N,Z,U,ee,te,ne,re]),se=x.useMemo(()=>qe(oe),[oe]);return ue(se),se}const _e=["color"];function Ne(t){const e=Te.useEditOverrides(t,_e),n={...Fe,...e},{text:r,bgColor:a,opacity:i,name:l,overlay:f=!0,position:s,rotation:h,scale:o,visible:d,renderOrder:c}=n,[u,S]=x.useState(null),[g,b]=x.useState(null),m=x.useRef(r);m.current!==r&&(m.current=r,u!==null&&S(null));const y=x.useRef(a);y.current!==a&&(y.current=a,g!==null&&b(null));const v=x.useRef(null),O=Ge(n,{text:u??r,bgColor:g??a});return x.useEffect(()=>{const L=v.current;if(L)return L.userData.setText=F=>S(F),L.userData.setBgColor=F=>b(F),()=>{delete L.userData.setText,delete L.userData.setBgColor}},[]),H.jsx(de,{ref:v,name:l,texture:O,overlay:f,opacity:i,position:s,rotation:h,scale:o,visible:d,renderOrder:c})}exports.ScreenSpaceUI=Le;exports.TextLabel=Ne;exports.useOwnedTexture=ue;
@@ -2,7 +2,7 @@ import { jsx as z, jsxs as Te } from "react/jsx-runtime";
2
2
  import { useMemo as B, forwardRef as xe, useEffect as be, useState as he, useRef as J } from "react";
3
3
  import { useThree as Ce } from "@react-three/fiber";
4
4
  import { b as Fe } from "./context-DTxSQvp4.js";
5
- import { u as Le } from "./useEditOverrides-DpPTA6BW.js";
5
+ import { u as Le } from "./useEditOverrides-BBkK8cN2.js";
6
6
  import * as We from "three";
7
7
  const et = ({ children: t, depth: e = 0 }) => {
8
8
  const { camera: n, size: i } = Ce(), a = B(() => {
@@ -6,6 +6,7 @@ export interface AudioPlayerHandle {
6
6
  readonly current: HTMLAudioElement | null;
7
7
  }
8
8
  export interface AudioPlayerProps {
9
+ /** @tweak asset accept=audio */
9
10
  src: string;
10
11
  playMode?: AudioPlayMode;
11
12
  /** Total number of plays in `loop` mode. Values below 1 become 1. */
@@ -25,5 +26,6 @@ export interface AudioPlayerProps {
25
26
  * Headless, declarative audio player with timeline-friendly playback
26
27
  * properties. It renders only a hidden HTML audio element; build any visible
27
28
  * controls with the imperative ref or application state.
29
+ * @editorElement sound src
28
30
  */
29
31
  export declare const AudioPlayer: import('react').ForwardRefExoticComponent<AudioPlayerProps & import('react').RefAttributes<AudioPlayerHandle>>;
@@ -27,7 +27,10 @@ export type MeshRendererRenderState = {
27
27
  export type MeshRendererSettings = {
28
28
  enabled: boolean;
29
29
  mesh: MeshRendererMesh;
30
- /** Optional GLTF/GLB asset URL. When set, renders the imported asset instead of a primitive. */
30
+ /**
31
+ * Optional GLTF/GLB asset URL. When set, renders the imported asset instead of a primitive.
32
+ * @tweak asset accept=model
33
+ */
31
34
  assetUrl?: string;
32
35
  assetNodeName?: string;
33
36
  assetAnimation?: ("all" & {}) | (string & {});
@@ -56,4 +59,7 @@ export declare const normalizeMeshRendererRenderState: (renderState?: MeshRender
56
59
  export declare const getThreeDepthFunction: (depthFunc: MeshRendererDepthFunction) => DepthModes;
57
60
  export declare const getThreeSide: (cullMode: MeshRendererCullMode) => Side;
58
61
  export declare const getThreeBlending: (blendMode: MeshRendererBlendMode) => Blending;
62
+ /**
63
+ * @editorElement model value.assetUrl
64
+ */
59
65
  export declare const MeshRenderer: ({ renderOrder, value }: MeshRendererProps) => import("react/jsx-runtime").JSX.Element | null;