@motionscript/core 0.1.1-alpha.3 → 0.1.1-alpha.5

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.
@@ -1,2 +1,2 @@
1
- import{Ee as d,Fe as m,Ge as p,Kd as o,Ld as r,Od as s,Re as f,Sd as n,Td as t,We as _,Yd as a,ee as c,ie as x,te as i,ye as e}from"./chunks/chunk-BPA7KSK2.js";import"./chunks/chunk-5TDMGUXQ.js";var v=o,w=m,S=p,h=t,C=r,D=e;export{x as Aim,s as Corners,n as Flow,f as Material,a as Paint,c as Shapes,i as TextLayout,d as TextStyle,C as Types,_ as View3D,h as commandsFor,v as component2d,S as component3d,w as componentAudio,D as provides};
1
+ import{Ee as d,Fe as m,Ge as p,Kd as o,Ld as r,Od as s,Re as f,Sd as n,Td as t,We as _,Yd as a,ee as c,ie as x,te as i,ye as e}from"./chunks/chunk-XCGYJHZR.js";import"./chunks/chunk-5TDMGUXQ.js";var v=o,w=m,S=p,h=t,C=r,D=e;export{x as Aim,s as Corners,n as Flow,f as Material,a as Paint,c as Shapes,i as TextLayout,d as TextStyle,C as Types,_ as View3D,h as commandsFor,v as component2d,S as component3d,w as componentAudio,D as provides};
2
2
  //# sourceMappingURL=experimental.js.map
@@ -1,2 +1,2 @@
1
- import{$ as $o,$a as Ri,$b as Wa,A as io,Aa as ci,Ab as ma,Ac as pn,B as ao,Ba as gi,Bb as ca,Bc as mn,C as no,Ca as li,Cb as ga,Cc as cn,D as fo,Da as xi,Db as la,Dc as gn,E as ho,Ea as ui,Eb as xa,Ec as ln,F as po,Fa as wi,Fb as ua,Fc as w,G as mo,Ga as yi,Gb as wa,Gc as xn,H as co,Ha as _i,Hb as ya,Hc as y,I as go,Ia as Ai,Ib as _a,Ic as _,J as Fo,Ja as Fi,Jb as Aa,Jc as f,K as Lo,Ka as Li,Kb as Fa,Kc as un,L as Po,La as Pi,Lb as La,Lc as wn,M as Eo,Ma as Ei,Mb as Pa,Mc as yn,N as No,Na as Ni,Nb as Ea,Nc as _n,O as So,Oa as Si,Ob as Na,Oc as Ln,P as To,Pa as Ti,Pb as Sa,Pc as Pn,Q as bo,Qa as bi,Qb as Ta,Qc as En,R as Do,Ra as Di,Rb as x,Rc as Nn,S as Mo,Sa as Mi,Sb as u,T as Uo,Ta as Ui,Tb as ba,U as vo,Ua as vi,Ub as Da,V as Vo,Va as Vi,Vb as Ma,W as Co,Wa as Ci,Wb as Ua,X as Io,Xa as Ii,Xb as va,Y as Wo,Ya as d,Yb as Va,Z as Ko,Za as Wi,Zb as Ca,_ as Ro,_a as Ki,_b as Ia,a as Ze,aa as jo,ab as $i,ac as Ka,b as ke,ba as Yo,bb as ji,bc as Ra,c as Oe,ca as qo,cb as Yi,cc as $a,d as tr,da as zo,db as qi,dc as ja,e as er,ea as Bo,eb as zi,ec as Ya,f as rr,fa as Go,fb as Bi,fc as qa,g as sr,ga as Ho,gb as Gi,gc as za,h as or,ha as Jo,hb as Hi,hc as Ba,i as ir,ia as Qo,ib as Ji,ic as Ga,j as br,ja as Xo,jb as Qi,jc as Ha,k as Dr,ka as Zo,kb as Xi,kc as Ja,l as Mr,la as ko,lb as Zi,lc as Qa,m as Ur,ma as Oo,mb as ki,mc as Xa,n as gs,na as ti,nb as Oi,nc as Za,o as ls,oa as ei,ob as ta,oc as ka,p as xs,pa as ri,pb as ea,pc as Oa,q as us,qa as si,qb as ra,qc as tn,r as Ls,ra as oi,rb as sa,rc as en,s as Zs,sa as ii,sb as oa,sc as rn,t as ks,ta as ai,tb as ia,tc as sn,u as Os,ua as ni,ub as aa,uc as on,v as to,va as di,vb as na,vc as an,w as eo,wa as fi,wb as da,wc as nn,x as ro,xa as hi,xb as fa,xc as dn,y as so,ya as pi,yb as ha,yc as fn,z as oo,za as mi,zb as pa,zc as hn}from"./chunks/chunk-TL432UO5.js";import{$ as St,$a as Te,$c as cs,A as et,Aa as kt,Ab as fr,Ac as Zr,Ad as Bs,B as rt,Ba as Ot,Bb as hr,Bd as Gs,C as st,Ca as te,Cb as pr,Cc as kr,Cd as Hs,D as ot,Da as ee,Db as mr,Dc as o,E as it,Ea as re,Eb as cr,Ec as Or,Ed as Js,Fa as se,Fb as gr,Fc as ts,G as at,Gb as lr,Gc as es,H as nt,Ha as oe,Hb as xr,Hc as rs,Hd as Qs,I as dt,Ia as ie,Ib as ur,Ic as ss,Id as Xs,J as ft,Jb as wr,Jc as os,K as ht,Ka as ae,Kb as yr,Kc as is,L as pt,La as me,Lb as _r,Lc as as,M as mt,Ma as ce,Mc as ns,N as ct,Na as ge,Nc as ds,O as gt,Oa as le,Ob as Ar,Oc as fs,P as lt,Pa as xe,Pb as Fr,Q as xt,Qa as ue,Qb as Lr,R as ut,Ra as we,Rb as Pr,S as wt,Sa as ye,Sb as Er,T as yt,Ta as _e,Tb as Nr,Tc as hs,U as _t,Ua as Ae,Ub as Sr,V as At,Va as Fe,Vb as Tr,W as Ft,Wa as Le,X as Lt,Xa as Pe,Y as Pt,Ya as Ee,Z as Et,Za as Ne,Zb as g,Zc as ps,_ as Nt,_a as Se,_c as ms,a as F,aa as Tt,ab as be,ad as ws,b as L,ba as bt,bb as De,bd as ys,c as P,ca as Dt,cb as Me,cd as _s,d as S,da as Mt,db as Ue,dd as As,e as T,ed as Fs,f as b,fa as Ut,fb as ve,fc as vr,fd as Ps,g as C,ga as vt,gb as Ve,gc as Vr,gd as Es,h as I,ha as Vt,hb as Ce,hc as Cr,hd as Ns,i as W,ia as Ct,ib as Ie,ic as Ir,id as Ss,j as K,ja as It,jb as We,jc as Wr,jd as Ts,je as lo,k as R,ka as Wt,kb as Ke,kc as Kr,kd as bs,ke as xo,l as $,la as Kt,lb as Re,lc as Rr,ld as Ds,le as uo,m as j,ma as Rt,mb as $e,mc as $r,md as Ms,n as Y,na as $t,nb as je,nc as jr,nd as Us,o as q,ob as Ye,oc as Yr,od as vs,p as z,pa as jt,pb as qe,pc as qr,pd as Vs,q as B,qa as Yt,qb as ze,qc as zr,qd as Cs,r as G,ra as qt,rb as Be,rc as Br,rd as Is,s as H,sa as zt,sb as Ge,sc as Gr,sd as Ws,t as J,ta as Bt,tb as He,tc as Hr,td as Ks,u as Q,ua as Gt,ub as Je,uc as Jr,ud as Rs,ue as wo,v as X,va as Ht,vb as Qe,vc as Qr,vd as $s,ve as yo,w as Z,wa as Jt,wb as Xe,wc as l,wd as js,we as _o,x as k,xa as Qt,xb as ar,xd as Ys,xe as Ao,y as O,ya as Xt,yb as nr,yd as qs,z as tt,za as Zt,zb as dr,zc as Xr,zd as zs}from"./chunks/chunk-BPA7KSK2.js";import{g as An,h as Fn}from"./chunks/chunk-GEJEQQER.js";import{b as E,c as N,d as D,e as M,f as U,g as v,h as V,i as ne,j as de,k as fe,l as he,m as pe}from"./chunks/chunk-5TDMGUXQ.js";var p={width:1920,height:1080},m=60,bn={viewport:p,fps:m},A={image:{},video:{},audio:{},font:{}},h=class{platform;viewport;fps;constructor(t,e={}){this.platform=t,this._registry=new d({nodes:e.nodes,shaders:e.shaders,lerps:e.lerps,dynamicNodes:e.dynamicNodes,strict:e.strict}),this.viewport=e.viewport??p,this.fps=e.fps??m,this._manifest=e.manifest??A,this._exporter=t.createExporter()}get manifest(){return this._manifest}get exporter(){return this._exporter}setManifest(t){this._manifest=t;for(let e of this._manifestListeners)e(t)}open(t){return new f(this,t)}knows(t){return this._registry.hasNode(t)}get registry(){return this._registry}async registerNode(t,e){return typeof t=="string"?this._registry.addNodeFromSource(t,e):(this._registry.addNode(t,e),t)}registerShader(t,e,r){return this._registry.addShader(t,e,r)}dispose(){this._manifestListeners.clear(),this.platform.dispose?.()}_registry;_manifest;_exporter;_manifestListeners=new Set;_onManifestChange(t){return this._manifestListeners.add(t),()=>this._manifestListeners.delete(t)}};var i=class{get schedulesAudio(){return!0}setMuted(t){}setVolume(t){}dispose(){this.stop()}};var a=class{catalog;viewport;constructor(t,e){this.catalog=t,this.viewport=e}setCatalog(t){this.catalog=t}inFlightLoads=new Map;cachedAssets=new Set;isLoaded(t){return this.cachedAssets.has(t)}async loadAsset(t,e){let r=this.inFlightLoads.get(t);if(r)return r;if(this.cachedAssets.has(t))return;let s=this.runLoad(t,e);this.inFlightLoads.set(t,s);try{await s}finally{this.inFlightLoads.delete(t)}}async runLoad(t,e){let r=!0;switch(e.type){case"image":await this.loadImage(t);break;case"video":await this.loadVideo(t,e.startFrame,e.endFrame,e.trimStart,e.trimEnd);break;case"font":{let{fontFamily:s,fontWeight:c}=this.parseFontKey(t);if(r=await this.loadFont(t,s,c),!r&&this.getDecodePolicy()==="exact")throw new o("font",s,`The manifest has no font entry for "${s}", so this frame would be shaped against the fallback face and differ from the one drawn once it is described. Add the family to the manifest's font record.`);break}case"audio":break;case"loader":throw new Error("Loader records must not be routed through StorageAdapter.loadAsset");default:{let s=e;throw new Error(`Unsupported asset type: ${s.type}`)}}r&&this.cachedAssets.add(t)}parseFontKey(t){let[e,r]=t.split("@"),s=r?parseInt(r,10):400;return{fontFamily:e||t,fontWeight:isNaN(s)?400:s}}async warmPendingVideo(){return!1}setDecodePolicy(t){}getDecodePolicy(){return"interactive"}hasPendingDecodes(){return!1}async warmPendingDecodes(){return this.warmPendingVideo()}hasPendingUpgrades(){return!1}async warmPendingUpgrades(){return!1}setPlaying(t){}dispose(){this.inFlightLoads.clear(),this.cachedAssets.clear()}};export{z as ASCII_CHARSETS,ji as AUDIO_ROOT_ID,lo as AUTOFIT_PROBE_SIZE,Pt as AdjustmentChain,Nt as Adjustments,ei as AmbientLight3D,ai as AreaLight3D,u as AssetDeclaration,x as AssetManager,o as AssetNotLoadedError,Ja as AssetTimeline,bo as AudioBus,Je as AudioEffectChain,ar as AudioEffectRegistry,Qe as AudioEffects,i as AudioSink,G as BLEND_MODES_LIST,ho as BooleanGroup,Co as Box3D,Xr as COMMAND_META,mo as Camera,ni as Camera3D,Ls as Canvas2D,hi as Canvas3D,Qs as CanvasRenderContext2D,zo as Capsule3D,Yo as Circle3D,hs as Clip,ja as ClipInstance,qa as ClipStore,Bi as ClipTimeline,Ro as Cone3D,Qr as ContextMap,Ko as Cylinder3D,le as DEFAULT_CAP_SCALE,Pe as DEFAULT_EASE,m as DEFAULT_FPS,bn as DEFAULT_OUTPUT,Ya as DEFAULT_PRECOMP_BUDGET_MS,p as DEFAULT_VIEWPORT,Ei as DOCUMENT_FORMAT_VERSION,Si as DOCUMENT_MIGRATIONS,jt as DRAWABLE_KINDS,_o as DataToken,Eo as DefaultTextStyle,si as DirectionalLight3D,Ni as DocumentTooNewError,R as EFFECT_OPTION_KEYS,A as EMPTY_MANIFEST,ne as EMPTY_PATH_DATA,Nr as EMPTY_TEXT_STYLE,dt as EffectChain,ft as Effects,ks as Ellipse,h as Engine,fi as Environment3D,Gs as ExpressionError,Go as Extrude3D,lt as FillChain,xt as Fills,di as Fog3D,ta as Geo,vt as Graphics2D,qt as Graphics3D,vo as Group3D,ri as HemisphereLight3D,ao as Hexagon,is as IDENTITY_QUATERNION,Qo as Instances3D,Ho as Lathe3D,Zo as Line3D,Dr as MAX_SHADER_PROPERTIES,Mr as MAX_SHADER_SOURCE,wt as MINOR_WIDTH_RATIO,Sa as MUTABLE_MATERIAL_KEYS,w as ManifestAssetCatalog,po as MaskGroup,ea as Mat,Vo as Mesh3D,Oo as Model3D,ti as ModelView3D,Ns as NODE_META,xr as NO_PROJECTION_3D,kr as Node,ps as Node2D,Es as Node3D,ws as NodeAudio,H as NodeBlendModes,Xs as NullRenderContext,Lo as NumberNode,no as Octagon,co as OrbitCamera,de as PATH_UNIT_EXTENT,fe as PATH_UNIT_HALF,ro as Path,Ut as PathBuilder,eo as PathShape,io as Pentagon,Wo as Plane3D,xn as Playback,ln as PlaybackController,oi as PointLight3D,Xo as Points3D,Os as Polygon,to as Polygram,Bo as Polyhedron3D,g as PropSlot,No as Provider,li as ROOT_NODE_ID,Ce as RampChain,En as Random,Zs as Rect,d as Registry,ki as RenderBackendError,zt as RenderContext3D,Po as RichText,oo as RightTriangle,qo as Ring3D,go as RotatedBox,Ba as SETTLE_PASSES,bs as SHAPE_ALIGNMENT_KEYS,Ta as STRUCTURAL_MATERIAL_KEYS,Gt as Scene3D,Pn as SeedGenerator,Ao as SeedToken,f as Session,tr as Sound,To as SoundNode,Io as Sphere3D,ii as SpotLight3D,ko as Sprite3D,fo as Star,za as StateEvaluator,_ as SteppedClock,a as StorageAdapter,te as TEXTURE_KEYS,Er as TEXT_SHAPING_KEYS,Pr as TEXT_STYLE_KEYS,ra as Tex,Fo as Text,wo as TextStyleToken,So as ThemeProvider,yo as ThemeToken,y as Ticker,$o as Torus3D,jo as TorusKnot3D,so as Triangle,Jo as Tube3D,he as UNIT_PATH_BOX,Do as Video,Et as VideoAdjustmentChain,St as VideoAdjustments,et as WGSL_CONTRACT,Ma as __resetSchedulerForTests,bt as alignmentOps,us as applyEditorStates,ga as applyMatrix4,mr as applyToPoint,Pi as asProjectDocument,vi as assertValidDocument,Ui as assertValidProjectDocument,nr as audioEffectsOps,Be as audioParamOps,ct as backdropEffects,ys as busPathOf,_s as busPathTo,ir as busStopKey,gr as cameraMatrix,oe as canLerpFill,Ht as canvas3DResourceKey,kt as canvas3DResourceLoader,Qi as caretCount,cn as caretOffsetAt,gn as caretRangeQuads,Fa as centeredBox3,en as childPlanePointAt,Fe as clamp,Le as clamp01,zi as clipDocument,Oe as clipDurationOf,Ua as clipFrameToTime,Ze as clipTimeAtSource,va as clipTimeToFrame,pn as collectBoxes,Xa as collectBoxes3D,Y as colorOps,Br as commandParallel,zr as commandSequence,Ai as commandSpan,la as compose4,Rs as containsClip,$s as containsOps,S as cornerRadiusOps,T as cornerStyleOps,Pa as corners3,Ha as createAssetTimelineProfile,Jr as createContext,Ln as createRef,Ue as curveEase,De as curveSegmentT,be as curveSegments,da as cylinderRadii,st as describeEffect,Bs as distanceToSegment,Fi as documentDuration,Ti as documentFormatVersion,Yr as driveCommand,Ne as easeIn,Te as easeInOut,ve as easeOfSpec,Se as easeOut,ot as effectDescriptors,it as effectSurface,ui as effectiveSpan,yi as effectiveSpanIn,wi as effectiveSpans,er as effectsKey,pt as effectsOps,Fn as enterBudget,ze as equalsParam,os as euler3Ops,ha as evaluateParametric,oa as evaluateRoundedBox,Hs as expressionOps,wr as facesAway,ae as fillOps,Ft as filterSurface,As as findBusById,ms as findNode2D,Or as flowOps,re as forEachTexture3D,gt as foregroundShaderEffects,cs as frameIn,Va as frameSpecAtTime,Ra as frameTime,_n as generateList,Na as geometryBounds3D,J as getBlendModeHash,Zr as getCommandMeta,Ss as getNodeDescriptor,l as getPropSlot,Tr as getPropertyMeta,v as getTypographyPreset,on as handleValueAt,Ot as hasCanvas3DBackend,_t as hasFilter,ur as hasProjection3D,gi as hasTimeline,We as hold,fr as identity,pa as identity4,Dt as insetsOps,Ge as integrateSpeedToClipTime,cr as invert,ca as invert4,ci as isAudioDocument,mt as isBackdropEffect,$r as isCommand,mi as isCompositionDocument,Ct as isDataTexture3D,Me as isEaseCurve,Oi as isFatalRenderIssue,br as isKnownShaderProperty,Mo as isOrbitCamera3D,yt as isPixelFilter,Li as isProjectDocument,dr as isProjective,Ke as isRamp,Nn as isSteppable,pi as isStillDocument,xe as isStrokeMarker,It as isSurfaceTexture3D,ee as isTextureLike,P as isUniformCorners,Qa as isViewport3D,tt as isWgslShader,j as lerpColor,b as lerpCornerScalarStyle,L as lerpCorners,at as lerpEffect,ss as lerpEuler3,ie as lerpFill,At as lerpFilter,Lt as lerpFilterArray,_r as lerpLookAt,E as lerpNumber,qe as lerpParam,N as lerpPerspective,k as lerpUniformRecord,X as lerpUniformValue,D as lerpVector2,es as lerpVector3,Ee as linear,xa as lookAtRotation4,Rt as looksLikeAssetPath,qr as loopCommand,Vr as loopPasses,Wr as loopPhase,Cr as loopRepeats,Ir as loopSpan,Yi as loweredAudioDocument,jr as makeCommand,bi as migrateDocument,Js as migrateNodeProps,Vi as missingNodeOf,pr as multiply,ma as multiply4,zs as nearPolyline,An as niceStep,dn as nodeAt,an as nodeBox,nn as nodeBoxAt,sn as nodeHandlesAt,lr as nodeLocalMatrix,gs as nodePath,yr as nodeProjectedMatrix,xi as nodeSpan,mn as nodeTextLayout,Wi as nodeTypeIsA,ns as normalizeQuaternion,Ur as normalizeShaderPack,Q as normalizeUniforms,ba as now,Aa as orthographic4,Ye as paramKey,Ki as parentIssue,tn as parentPlanePointAt,Ps as parentSpaceOf,wn as parseCSV,Jt as parseCanvas3DResourceKey,V as parseColor,yn as parseData,pe as pathOps,_a as perspective4,hn as pickNode,ka as pickNode3D,Ia as placeTracks,$i as placementIssues,qs as pointInPolygon,js as polygonVertices,Ys as polygramVertices,Hr as prepareNumericCellTween,Gr as prepareNumericTween,xs as primeMotionTree,Za as projectNode3D,fn as projectNode3DAt,ds as quaternionFromEuler,fs as quaternionOps,Ie as ramp,Xt as registerCanvas3DResourceLoader,Qt as registerCanvas3DWarmup,Ci as registryVocabulary,Zi as renderIssueKey,Oa as renderMatrix,Ga as renderSettled,rn as reparentPlacementAt,xo as requireFontFamily,B as resolveAsciiCharset,Xe as resolveAudioEffects,fa as resolveBevel3D,Uo as resolveCameraPlacement,Tt as resolveChainAdjustments,ht as resolveChainEffects,ut as resolveChainFill,F as resolveCorners,C as resolveEffectAxis,W as resolveEffectColor,se as resolveFill,$t as resolveFill3D,Yt as resolveMaterialShorthand3D,q as resolveMotionBlurAlignment,vs as resolvePivotPosition,un as resolveProjectDocument,Re as resolveRamp,nt as resolveShaderProperties,me as resolveShadow,na as resolveShadowOptions3D,Bt as resolveShadows3D,Us as resolveShapeAlignment,Ts as resolveShapePivot,_e as resolveStroke,ge as resolveStrokeAlign,ue as resolveStrokeCap,we as resolveStrokeEnd,ye as resolveStrokeJoin,Vt as resolveSurfaceSource,Wt as resolveTexture3D,ts as resolveVector3,Mt as resolveVideoTimestamp,ya as rotationOf4,I as sameEffectAxis,K as sameEffectColor,$e as sampleRamp,ls as sampleTree,sa as segmentsOf,U as setTheme,Rr as settles,Kr as settling,rt as shaderContractOf,ia as shadowCasts,ce as shadowOps,aa as shadowReceives,Ri as siblingIssue,Fr as size2DOps,Lr as sizeInputOps,as as slerpQuaternion,ke as sourceTimeAtClip,He as sourceTimeAtClipElapsed,Ar as space3dOps,$a as spanFrames,Ka as spansCovering,Ve as specOfEase,je as staticValue,Ms as stripShapeAlignmentKeys,Ae as strokeOps,Fs as structuralPathOf,Sr as textOps,Kt as texture3DSource,vr as toCommand,Hi as toPathString,Xi as toRenderIssue,Wa as totalFramesOf,Ca as trackFrameCount,Ea as transformBox3,ua as transformMatrix4,sr as transitionGainAt,or as transitionKey,rr as transitionSpans,hr as translation,wa as translation4,O as uniformRecordsEqual,Z as uniformValuesEqual,La as unionBox3,_i as untimed,Di as validateDocument,Mi as validateProjectDocument,Ds as validateShapeAlignmentProps,M as vector2Ops,rs as vector3Ops,Ii as vocabularyBreaks,Zt as warmCanvas3D,$ as withEffectOptions,Cs as withEllipseDescriptor,Ks as withLineDescriptor,Ji as withPathDescriptor,qi as withPlayedSounds,Is as withPolygonDescriptor,Ws as withPolygramDescriptor,Vs as withRectDescriptor,Gi as withRichTextDescriptor,uo as withTextDescriptor,Da as yieldToScheduler};
1
+ import{$ as $o,$a as Ri,$b as Wa,A as io,Aa as ci,Ab as ma,Ac as pn,B as ao,Ba as gi,Bb as ca,Bc as mn,C as no,Ca as li,Cb as ga,Cc as cn,D as fo,Da as xi,Db as la,Dc as gn,E as ho,Ea as ui,Eb as xa,Ec as ln,F as po,Fa as wi,Fb as ua,Fc as w,G as mo,Ga as yi,Gb as wa,Gc as xn,H as co,Ha as _i,Hb as ya,Hc as y,I as go,Ia as Ai,Ib as _a,Ic as _,J as Fo,Ja as Fi,Jb as Aa,Jc as f,K as Lo,Ka as Li,Kb as Fa,Kc as un,L as Po,La as Pi,Lb as La,Lc as wn,M as Eo,Ma as Ei,Mb as Pa,Mc as yn,N as No,Na as Ni,Nb as Ea,Nc as _n,O as So,Oa as Si,Ob as Na,Oc as Ln,P as To,Pa as Ti,Pb as Sa,Pc as Pn,Q as bo,Qa as bi,Qb as Ta,Qc as En,R as Do,Ra as Di,Rb as x,Rc as Nn,S as Mo,Sa as Mi,Sb as u,T as Uo,Ta as Ui,Tb as ba,U as vo,Ua as vi,Ub as Da,V as Vo,Va as Vi,Vb as Ma,W as Co,Wa as Ci,Wb as Ua,X as Io,Xa as Ii,Xb as va,Y as Wo,Ya as d,Yb as Va,Z as Ko,Za as Wi,Zb as Ca,_ as Ro,_a as Ki,_b as Ia,a as Ze,aa as jo,ab as $i,ac as Ka,b as ke,ba as Yo,bb as ji,bc as Ra,c as Oe,ca as qo,cb as Yi,cc as $a,d as tr,da as zo,db as qi,dc as ja,e as er,ea as Bo,eb as zi,ec as Ya,f as rr,fa as Go,fb as Bi,fc as qa,g as sr,ga as Ho,gb as Gi,gc as za,h as or,ha as Jo,hb as Hi,hc as Ba,i as ir,ia as Qo,ib as Ji,ic as Ga,j as br,ja as Xo,jb as Qi,jc as Ha,k as Dr,ka as Zo,kb as Xi,kc as Ja,l as Mr,la as ko,lb as Zi,lc as Qa,m as Ur,ma as Oo,mb as ki,mc as Xa,n as gs,na as ti,nb as Oi,nc as Za,o as ls,oa as ei,ob as ta,oc as ka,p as xs,pa as ri,pb as ea,pc as Oa,q as us,qa as si,qb as ra,qc as tn,r as Ls,ra as oi,rb as sa,rc as en,s as Zs,sa as ii,sb as oa,sc as rn,t as ks,ta as ai,tb as ia,tc as sn,u as Os,ua as ni,ub as aa,uc as on,v as to,va as di,vb as na,vc as an,w as eo,wa as fi,wb as da,wc as nn,x as ro,xa as hi,xb as fa,xc as dn,y as so,ya as pi,yb as ha,yc as fn,z as oo,za as mi,zb as pa,zc as hn}from"./chunks/chunk-FPYU47XX.js";import{$ as St,$a as Te,$c as cs,A as et,Aa as kt,Ab as fr,Ac as Zr,Ad as Bs,B as rt,Ba as Ot,Bb as hr,Bd as Gs,C as st,Ca as te,Cb as pr,Cc as kr,Cd as Hs,D as ot,Da as ee,Db as mr,Dc as o,E as it,Ea as re,Eb as cr,Ec as Or,Ed as Js,Fa as se,Fb as gr,Fc as ts,G as at,Gb as lr,Gc as es,H as nt,Ha as oe,Hb as xr,Hc as rs,Hd as Qs,I as dt,Ia as ie,Ib as ur,Ic as ss,Id as Xs,J as ft,Jb as wr,Jc as os,K as ht,Ka as ae,Kb as yr,Kc as is,L as pt,La as me,Lb as _r,Lc as as,M as mt,Ma as ce,Mc as ns,N as ct,Na as ge,Nc as ds,O as gt,Oa as le,Ob as Ar,Oc as fs,P as lt,Pa as xe,Pb as Fr,Q as xt,Qa as ue,Qb as Lr,R as ut,Ra as we,Rb as Pr,S as wt,Sa as ye,Sb as Er,T as yt,Ta as _e,Tb as Nr,Tc as hs,U as _t,Ua as Ae,Ub as Sr,V as At,Va as Fe,Vb as Tr,W as Ft,Wa as Le,X as Lt,Xa as Pe,Y as Pt,Ya as Ee,Z as Et,Za as Ne,Zb as g,Zc as ps,_ as Nt,_a as Se,_c as ms,a as F,aa as Tt,ab as be,ad as ws,b as L,ba as bt,bb as De,bd as ys,c as P,ca as Dt,cb as Me,cd as _s,d as S,da as Mt,db as Ue,dd as As,e as T,ed as Fs,f as b,fa as Ut,fb as ve,fc as vr,fd as Ps,g as C,ga as vt,gb as Ve,gc as Vr,gd as Es,h as I,ha as Vt,hb as Ce,hc as Cr,hd as Ns,i as W,ia as Ct,ib as Ie,ic as Ir,id as Ss,j as K,ja as It,jb as We,jc as Wr,jd as Ts,je as lo,k as R,ka as Wt,kb as Ke,kc as Kr,kd as bs,ke as xo,l as $,la as Kt,lb as Re,lc as Rr,ld as Ds,le as uo,m as j,ma as Rt,mb as $e,mc as $r,md as Ms,n as Y,na as $t,nb as je,nc as jr,nd as Us,o as q,ob as Ye,oc as Yr,od as vs,p as z,pa as jt,pb as qe,pc as qr,pd as Vs,q as B,qa as Yt,qb as ze,qc as zr,qd as Cs,r as G,ra as qt,rb as Be,rc as Br,rd as Is,s as H,sa as zt,sb as Ge,sc as Gr,sd as Ws,t as J,ta as Bt,tb as He,tc as Hr,td as Ks,u as Q,ua as Gt,ub as Je,uc as Jr,ud as Rs,ue as wo,v as X,va as Ht,vb as Qe,vc as Qr,vd as $s,ve as yo,w as Z,wa as Jt,wb as Xe,wc as l,wd as js,we as _o,x as k,xa as Qt,xb as ar,xd as Ys,xe as Ao,y as O,ya as Xt,yb as nr,yd as qs,z as tt,za as Zt,zb as dr,zc as Xr,zd as zs}from"./chunks/chunk-XCGYJHZR.js";import{g as An,h as Fn}from"./chunks/chunk-GEJEQQER.js";import{b as E,c as N,d as D,e as M,f as U,g as v,h as V,i as ne,j as de,k as fe,l as he,m as pe}from"./chunks/chunk-5TDMGUXQ.js";var p={width:1920,height:1080},m=60,bn={viewport:p,fps:m},A={image:{},video:{},audio:{},font:{}},h=class{platform;viewport;fps;constructor(t,e={}){this.platform=t,this._registry=new d({nodes:e.nodes,shaders:e.shaders,lerps:e.lerps,dynamicNodes:e.dynamicNodes,strict:e.strict}),this.viewport=e.viewport??p,this.fps=e.fps??m,this._manifest=e.manifest??A,this._exporter=t.createExporter()}get manifest(){return this._manifest}get exporter(){return this._exporter}setManifest(t){this._manifest=t;for(let e of this._manifestListeners)e(t)}open(t){return new f(this,t)}knows(t){return this._registry.hasNode(t)}get registry(){return this._registry}async registerNode(t,e){return typeof t=="string"?this._registry.addNodeFromSource(t,e):(this._registry.addNode(t,e),t)}registerShader(t,e,r){return this._registry.addShader(t,e,r)}dispose(){this._manifestListeners.clear(),this.platform.dispose?.()}_registry;_manifest;_exporter;_manifestListeners=new Set;_onManifestChange(t){return this._manifestListeners.add(t),()=>this._manifestListeners.delete(t)}};var i=class{get schedulesAudio(){return!0}setMuted(t){}setVolume(t){}dispose(){this.stop()}};var a=class{catalog;viewport;constructor(t,e){this.catalog=t,this.viewport=e}setCatalog(t){this.catalog=t}inFlightLoads=new Map;cachedAssets=new Set;isLoaded(t){return this.cachedAssets.has(t)}async loadAsset(t,e){let r=this.inFlightLoads.get(t);if(r)return r;if(this.cachedAssets.has(t))return;let s=this.runLoad(t,e);this.inFlightLoads.set(t,s);try{await s}finally{this.inFlightLoads.delete(t)}}async runLoad(t,e){let r=!0;switch(e.type){case"image":await this.loadImage(t);break;case"video":await this.loadVideo(t,e.startFrame,e.endFrame,e.trimStart,e.trimEnd);break;case"font":{let{fontFamily:s,fontWeight:c}=this.parseFontKey(t);if(r=await this.loadFont(t,s,c),!r&&this.getDecodePolicy()==="exact")throw new o("font",s,`The manifest has no font entry for "${s}", so this frame would be shaped against the fallback face and differ from the one drawn once it is described. Add the family to the manifest's font record.`);break}case"audio":break;case"loader":throw new Error("Loader records must not be routed through StorageAdapter.loadAsset");default:{let s=e;throw new Error(`Unsupported asset type: ${s.type}`)}}r&&this.cachedAssets.add(t)}parseFontKey(t){let[e,r]=t.split("@"),s=r?parseInt(r,10):400;return{fontFamily:e||t,fontWeight:isNaN(s)?400:s}}async warmPendingVideo(){return!1}setDecodePolicy(t){}getDecodePolicy(){return"interactive"}hasPendingDecodes(){return!1}async warmPendingDecodes(){return this.warmPendingVideo()}hasPendingUpgrades(){return!1}async warmPendingUpgrades(){return!1}setPlaying(t){}dispose(){this.inFlightLoads.clear(),this.cachedAssets.clear()}};export{z as ASCII_CHARSETS,ji as AUDIO_ROOT_ID,lo as AUTOFIT_PROBE_SIZE,Pt as AdjustmentChain,Nt as Adjustments,ei as AmbientLight3D,ai as AreaLight3D,u as AssetDeclaration,x as AssetManager,o as AssetNotLoadedError,Ja as AssetTimeline,bo as AudioBus,Je as AudioEffectChain,ar as AudioEffectRegistry,Qe as AudioEffects,i as AudioSink,G as BLEND_MODES_LIST,ho as BooleanGroup,Co as Box3D,Xr as COMMAND_META,mo as Camera,ni as Camera3D,Ls as Canvas2D,hi as Canvas3D,Qs as CanvasRenderContext2D,zo as Capsule3D,Yo as Circle3D,hs as Clip,ja as ClipInstance,qa as ClipStore,Bi as ClipTimeline,Ro as Cone3D,Qr as ContextMap,Ko as Cylinder3D,le as DEFAULT_CAP_SCALE,Pe as DEFAULT_EASE,m as DEFAULT_FPS,bn as DEFAULT_OUTPUT,Ya as DEFAULT_PRECOMP_BUDGET_MS,p as DEFAULT_VIEWPORT,Ei as DOCUMENT_FORMAT_VERSION,Si as DOCUMENT_MIGRATIONS,jt as DRAWABLE_KINDS,_o as DataToken,Eo as DefaultTextStyle,si as DirectionalLight3D,Ni as DocumentTooNewError,R as EFFECT_OPTION_KEYS,A as EMPTY_MANIFEST,ne as EMPTY_PATH_DATA,Nr as EMPTY_TEXT_STYLE,dt as EffectChain,ft as Effects,ks as Ellipse,h as Engine,fi as Environment3D,Gs as ExpressionError,Go as Extrude3D,lt as FillChain,xt as Fills,di as Fog3D,ta as Geo,vt as Graphics2D,qt as Graphics3D,vo as Group3D,ri as HemisphereLight3D,ao as Hexagon,is as IDENTITY_QUATERNION,Qo as Instances3D,Ho as Lathe3D,Zo as Line3D,Dr as MAX_SHADER_PROPERTIES,Mr as MAX_SHADER_SOURCE,wt as MINOR_WIDTH_RATIO,Sa as MUTABLE_MATERIAL_KEYS,w as ManifestAssetCatalog,po as MaskGroup,ea as Mat,Vo as Mesh3D,Oo as Model3D,ti as ModelView3D,Ns as NODE_META,xr as NO_PROJECTION_3D,kr as Node,ps as Node2D,Es as Node3D,ws as NodeAudio,H as NodeBlendModes,Xs as NullRenderContext,Lo as NumberNode,no as Octagon,co as OrbitCamera,de as PATH_UNIT_EXTENT,fe as PATH_UNIT_HALF,ro as Path,Ut as PathBuilder,eo as PathShape,io as Pentagon,Wo as Plane3D,xn as Playback,ln as PlaybackController,oi as PointLight3D,Xo as Points3D,Os as Polygon,to as Polygram,Bo as Polyhedron3D,g as PropSlot,No as Provider,li as ROOT_NODE_ID,Ce as RampChain,En as Random,Zs as Rect,d as Registry,ki as RenderBackendError,zt as RenderContext3D,Po as RichText,oo as RightTriangle,qo as Ring3D,go as RotatedBox,Ba as SETTLE_PASSES,bs as SHAPE_ALIGNMENT_KEYS,Ta as STRUCTURAL_MATERIAL_KEYS,Gt as Scene3D,Pn as SeedGenerator,Ao as SeedToken,f as Session,tr as Sound,To as SoundNode,Io as Sphere3D,ii as SpotLight3D,ko as Sprite3D,fo as Star,za as StateEvaluator,_ as SteppedClock,a as StorageAdapter,te as TEXTURE_KEYS,Er as TEXT_SHAPING_KEYS,Pr as TEXT_STYLE_KEYS,ra as Tex,Fo as Text,wo as TextStyleToken,So as ThemeProvider,yo as ThemeToken,y as Ticker,$o as Torus3D,jo as TorusKnot3D,so as Triangle,Jo as Tube3D,he as UNIT_PATH_BOX,Do as Video,Et as VideoAdjustmentChain,St as VideoAdjustments,et as WGSL_CONTRACT,Ma as __resetSchedulerForTests,bt as alignmentOps,us as applyEditorStates,ga as applyMatrix4,mr as applyToPoint,Pi as asProjectDocument,vi as assertValidDocument,Ui as assertValidProjectDocument,nr as audioEffectsOps,Be as audioParamOps,ct as backdropEffects,ys as busPathOf,_s as busPathTo,ir as busStopKey,gr as cameraMatrix,oe as canLerpFill,Ht as canvas3DResourceKey,kt as canvas3DResourceLoader,Qi as caretCount,cn as caretOffsetAt,gn as caretRangeQuads,Fa as centeredBox3,en as childPlanePointAt,Fe as clamp,Le as clamp01,zi as clipDocument,Oe as clipDurationOf,Ua as clipFrameToTime,Ze as clipTimeAtSource,va as clipTimeToFrame,pn as collectBoxes,Xa as collectBoxes3D,Y as colorOps,Br as commandParallel,zr as commandSequence,Ai as commandSpan,la as compose4,Rs as containsClip,$s as containsOps,S as cornerRadiusOps,T as cornerStyleOps,Pa as corners3,Ha as createAssetTimelineProfile,Jr as createContext,Ln as createRef,Ue as curveEase,De as curveSegmentT,be as curveSegments,da as cylinderRadii,st as describeEffect,Bs as distanceToSegment,Fi as documentDuration,Ti as documentFormatVersion,Yr as driveCommand,Ne as easeIn,Te as easeInOut,ve as easeOfSpec,Se as easeOut,ot as effectDescriptors,it as effectSurface,ui as effectiveSpan,yi as effectiveSpanIn,wi as effectiveSpans,er as effectsKey,pt as effectsOps,Fn as enterBudget,ze as equalsParam,os as euler3Ops,ha as evaluateParametric,oa as evaluateRoundedBox,Hs as expressionOps,wr as facesAway,ae as fillOps,Ft as filterSurface,As as findBusById,ms as findNode2D,Or as flowOps,re as forEachTexture3D,gt as foregroundShaderEffects,cs as frameIn,Va as frameSpecAtTime,Ra as frameTime,_n as generateList,Na as geometryBounds3D,J as getBlendModeHash,Zr as getCommandMeta,Ss as getNodeDescriptor,l as getPropSlot,Tr as getPropertyMeta,v as getTypographyPreset,on as handleValueAt,Ot as hasCanvas3DBackend,_t as hasFilter,ur as hasProjection3D,gi as hasTimeline,We as hold,fr as identity,pa as identity4,Dt as insetsOps,Ge as integrateSpeedToClipTime,cr as invert,ca as invert4,ci as isAudioDocument,mt as isBackdropEffect,$r as isCommand,mi as isCompositionDocument,Ct as isDataTexture3D,Me as isEaseCurve,Oi as isFatalRenderIssue,br as isKnownShaderProperty,Mo as isOrbitCamera3D,yt as isPixelFilter,Li as isProjectDocument,dr as isProjective,Ke as isRamp,Nn as isSteppable,pi as isStillDocument,xe as isStrokeMarker,It as isSurfaceTexture3D,ee as isTextureLike,P as isUniformCorners,Qa as isViewport3D,tt as isWgslShader,j as lerpColor,b as lerpCornerScalarStyle,L as lerpCorners,at as lerpEffect,ss as lerpEuler3,ie as lerpFill,At as lerpFilter,Lt as lerpFilterArray,_r as lerpLookAt,E as lerpNumber,qe as lerpParam,N as lerpPerspective,k as lerpUniformRecord,X as lerpUniformValue,D as lerpVector2,es as lerpVector3,Ee as linear,xa as lookAtRotation4,Rt as looksLikeAssetPath,qr as loopCommand,Vr as loopPasses,Wr as loopPhase,Cr as loopRepeats,Ir as loopSpan,Yi as loweredAudioDocument,jr as makeCommand,bi as migrateDocument,Js as migrateNodeProps,Vi as missingNodeOf,pr as multiply,ma as multiply4,zs as nearPolyline,An as niceStep,dn as nodeAt,an as nodeBox,nn as nodeBoxAt,sn as nodeHandlesAt,lr as nodeLocalMatrix,gs as nodePath,yr as nodeProjectedMatrix,xi as nodeSpan,mn as nodeTextLayout,Wi as nodeTypeIsA,ns as normalizeQuaternion,Ur as normalizeShaderPack,Q as normalizeUniforms,ba as now,Aa as orthographic4,Ye as paramKey,Ki as parentIssue,tn as parentPlanePointAt,Ps as parentSpaceOf,wn as parseCSV,Jt as parseCanvas3DResourceKey,V as parseColor,yn as parseData,pe as pathOps,_a as perspective4,hn as pickNode,ka as pickNode3D,Ia as placeTracks,$i as placementIssues,qs as pointInPolygon,js as polygonVertices,Ys as polygramVertices,Hr as prepareNumericCellTween,Gr as prepareNumericTween,xs as primeMotionTree,Za as projectNode3D,fn as projectNode3DAt,ds as quaternionFromEuler,fs as quaternionOps,Ie as ramp,Xt as registerCanvas3DResourceLoader,Qt as registerCanvas3DWarmup,Ci as registryVocabulary,Zi as renderIssueKey,Oa as renderMatrix,Ga as renderSettled,rn as reparentPlacementAt,xo as requireFontFamily,B as resolveAsciiCharset,Xe as resolveAudioEffects,fa as resolveBevel3D,Uo as resolveCameraPlacement,Tt as resolveChainAdjustments,ht as resolveChainEffects,ut as resolveChainFill,F as resolveCorners,C as resolveEffectAxis,W as resolveEffectColor,se as resolveFill,$t as resolveFill3D,Yt as resolveMaterialShorthand3D,q as resolveMotionBlurAlignment,vs as resolvePivotPosition,un as resolveProjectDocument,Re as resolveRamp,nt as resolveShaderProperties,me as resolveShadow,na as resolveShadowOptions3D,Bt as resolveShadows3D,Us as resolveShapeAlignment,Ts as resolveShapePivot,_e as resolveStroke,ge as resolveStrokeAlign,ue as resolveStrokeCap,we as resolveStrokeEnd,ye as resolveStrokeJoin,Vt as resolveSurfaceSource,Wt as resolveTexture3D,ts as resolveVector3,Mt as resolveVideoTimestamp,ya as rotationOf4,I as sameEffectAxis,K as sameEffectColor,$e as sampleRamp,ls as sampleTree,sa as segmentsOf,U as setTheme,Rr as settles,Kr as settling,rt as shaderContractOf,ia as shadowCasts,ce as shadowOps,aa as shadowReceives,Ri as siblingIssue,Fr as size2DOps,Lr as sizeInputOps,as as slerpQuaternion,ke as sourceTimeAtClip,He as sourceTimeAtClipElapsed,Ar as space3dOps,$a as spanFrames,Ka as spansCovering,Ve as specOfEase,je as staticValue,Ms as stripShapeAlignmentKeys,Ae as strokeOps,Fs as structuralPathOf,Sr as textOps,Kt as texture3DSource,vr as toCommand,Hi as toPathString,Xi as toRenderIssue,Wa as totalFramesOf,Ca as trackFrameCount,Ea as transformBox3,ua as transformMatrix4,sr as transitionGainAt,or as transitionKey,rr as transitionSpans,hr as translation,wa as translation4,O as uniformRecordsEqual,Z as uniformValuesEqual,La as unionBox3,_i as untimed,Di as validateDocument,Mi as validateProjectDocument,Ds as validateShapeAlignmentProps,M as vector2Ops,rs as vector3Ops,Ii as vocabularyBreaks,Zt as warmCanvas3D,$ as withEffectOptions,Cs as withEllipseDescriptor,Ks as withLineDescriptor,Ji as withPathDescriptor,qi as withPlayedSounds,Is as withPolygonDescriptor,Ws as withPolygramDescriptor,Vs as withRectDescriptor,Gi as withRichTextDescriptor,uo as withTextDescriptor,Da as yieldToScheduler};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@motionscript/core",
3
- "version": "0.1.1-alpha.2",
3
+ "version": "0.1.1-alpha.5",
4
4
  "exports": {
5
5
  ".": "dist/browser/index.js",
6
6
  "./experimental": "dist/browser/experimental.js",
@@ -1,2 +1,2 @@
1
- import{$ as lo,$a as or,A as Ie,Ac as gr,B as we,Ba as Bo,C as Le,Ca as bo,D as Fe,Da as jo,E as Me,Ea as ko,F as Be,G as je,H as ke,Ha as Go,I as Ge,Ia as _o,J as qe,Ja as zo,K as Ke,Ka as Ho,Kc as Cr,L as Qe,La as qo,Lc as Or,M as Ue,Ma as Ko,Mc as vr,N as Je,Na as Qo,Nc as Tr,O as We,Oc as Ar,P as Ye,Pa as Uo,Pc as Rr,Q as Ze,Qa as Jo,Qc as Er,R as $e,Ra as Wo,T as eo,U as to,Ua as Xo,V as ao,Va as Yo,W as no,X as so,Y as po,Ya as Zo,Z as mo,Za as $o,_ as io,_a as er,_b as dr,aa as fo,ab as rr,ba as xo,ca as co,d as H,da as Do,ea as uo,fa as ho,ga as Po,ha as So,hb as tr,ia as go,j as U,ja as Co,ka as Oo,la as vo,m as J,ma as To,oa as Ao,ob as ar,pa as Ro,pb as nr,qa as Eo,qb as sr,qc as xr,r as xe,ra as yo,rb as pr,rc as cr,s as ve,sa as No,sb as mr,sc as Dr,t as Te,ta as Vo,tb as ir,tc as ur,u as Ae,ua as Io,ub as lr,uc as hr,v as Re,va as wo,vc as Pr,w as Ee,wa as Lo,x as ye,xa as Mo,y as Ne,yb as fr,z as Ve,zc as Sr}from"./chunks/chunk-TL432UO5.js";import{$ as u,$a as j,$c as de,Ac as re,Bd as ce,C as p,Cd as De,D as m,Ec as te,Ed as ue,Ee as He,Fa as E,Fc as ae,Fe as Xe,Gc as ne,Ge as oo,H as i,I as l,Ic as se,J as f,Ka as y,Kd as he,La as V,Lc as pe,Ld as Pe,Ma as I,Mc as me,Nc as ie,Ob as q,Q as d,Qb as K,Re as ro,Sd as Se,Ta as w,Tc as le,Td as ge,Ua as L,Ub as Q,Va as F,We as Fo,Y as x,Ya as M,Yd as Ce,Z as c,Za as B,_ as D,_a as b,_c as fe,a as e,ba as h,ca as P,d as r,e as t,ee as Oe,fa as S,ga as g,ha as C,ib as k,ie as be,jb as G,kb as _,mc as W,n as s,na as O,nc as X,pc as Y,qc as Z,ra as v,rc as $,sa as T,ta as A,te as _e,ua as R,uc as ee,vb as z,vc as oe,ye as ze}from"./chunks/chunk-BPA7KSK2.js";import"./chunks/chunk-GEJEQQER.js";import{b as o,d as a,h as n,m as N}from"./chunks/chunk-5TDMGUXQ.js";export{x as AdjustmentChain,D as Adjustments,be as Aim,Ao as AmbientLight3D,Vo as AreaLight3D,Ze as AudioBus,z as AudioEffects,Me as BooleanGroup,no as Box3D,je as Camera,Io as Camera3D,xe as Canvas2D,Mo as Canvas3D,Do as Capsule3D,xo as Circle3D,le as Clip,io as Cone3D,oe as ContextMap,mo as Cylinder3D,Ko as DOCUMENT_FORMAT_VERSION,Ue as DefaultTextStyle,Eo as DirectionalLight3D,Qo as DocumentTooNewError,l as EffectChain,f as Effects,Te as Ellipse,Lo as Environment3D,ce as ExpressionError,ho as Extrude3D,d as Fills,Se as Flow,wo as Fog3D,ar as Geo,g as Graphics2D,v as Graphics3D,to as Group3D,Ro as HemisphereLight3D,we as Hexagon,go as Instances3D,Po as Lathe3D,Oo as Line3D,Be as MaskGroup,nr as Mat,ro as Material,ao as Mesh3D,To as Model3D,Ke as NumberNode,Le as Octagon,ke as OrbitCamera,Ce as Paint,ye as Path,S as PathBuilder,Ee as PathShape,Ie as Pentagon,po as Plane3D,yo as PointLight3D,Co as Points3D,Ae as Polygon,Re as Polygram,uo as Polyhedron3D,Je as Provider,bo as ROOT_NODE_ID,Er as Random,ve as Rect,Zo as Registry,T as RenderContext3D,Qe as RichText,Ve as RightTriangle,co as Ring3D,Ge as RotatedBox,R as Scene3D,Rr as SeedGenerator,Oe as Shapes,H as Sound,Ye as SoundNode,so as Sphere3D,No as SpotLight3D,vo as Sprite3D,Fe as Star,sr as Tex,qe as Text,_e as TextLayout,We as ThemeProvider,lo as Torus3D,fo as TorusKnot3D,Ne as Triangle,So as Tube3D,He as Typeface,Pe as Types,$e as Video,c as VideoAdjustmentChain,u as VideoAdjustments,Fo as View3D,h as alignmentOps,qo as asProjectDocument,Xo as assertValidDocument,cr as childPlanePointAt,F as clamp,gr as collectBoxes,s as colorOps,$ as commandParallel,Z as commandSequence,_o as commandSpan,ge as commandsFor,he as component2d,oo as component3d,Xe as componentAudio,r as cornerRadiusOps,t as cornerStyleOps,ee as createContext,Ar as createRef,p as describeEffect,zo as documentDuration,Uo as documentFormatVersion,B as easeIn,j as easeInOut,b as easeOut,m as effectDescriptors,ko as effectiveSpan,fr as evaluateParametric,mr as evaluateRoundedBox,De as expressionOps,y as fillOps,fe as findNode2D,te as flowOps,de as frameIn,Tr as generateList,re as getCommandMeta,hr as handleValueAt,Bo as hasTimeline,G as hold,P as insetsOps,W as isCommand,U as isKnownShaderProperty,Ho as isProjectDocument,_ as isRamp,se as lerpEuler3,o as lerpNumber,a as lerpVector2,ne as lerpVector3,M as linear,Y as loopCommand,X as makeCommand,Jo as migrateDocument,ue as migrateNodeProps,Yo as missingNodeOf,Pr as nodeBox,ur as nodeHandlesAt,jo as nodeSpan,$o as nodeTypeIsA,me as normalizeQuaternion,J as normalizeShaderPack,er as parentIssue,xr as parentPlanePointAt,Or as parseCSV,n as parseColor,vr as parseData,N as pathOps,Sr as pickNode,dr as placeTracks,rr as placementIssues,ze as provides,ie as quaternionFromEuler,k as ramp,Dr as reparentPlacementAt,eo as resolveCameraPlacement,e as resolveCorners,E as resolveFill,O as resolveFill3D,Cr as resolveProjectDocument,i as resolveShaderProperties,V as resolveShadow,A as resolveShadows3D,w as resolveStroke,C as resolveSurfaceSource,ae as resolveVector3,pr as segmentsOf,ir as shadowCasts,I as shadowOps,lr as shadowReceives,or as siblingIssue,K as sizeInputOps,pe as slerpQuaternion,q as space3dOps,L as strokeOps,Q as textOps,tr as toPathString,Go as untimed,Wo as validateDocument};
1
+ import{$ as Fo,$a as vt,A as oo,Ac as Ht,B as to,Ba as at,C as ro,Ca as it,D as no,Da as pt,E as so,Ea as ct,F as ao,G as po,H as co,Ha as lt,I as lo,Ia as mt,J as xo,Ja as ft,K as ho,Ka as ut,Kc as Kt,L as Do,La as dt,Lc as Qt,M as go,Ma as xt,Mc as Ut,N as Po,Na as ht,Nc as Wt,O as Oo,Oc as Jt,P as To,Pa as Dt,Pc as Xt,Q as yo,Qa as gt,Qc as Yt,R as Co,Ra as Pt,T as vo,U as Ro,Ua as Ot,V as wo,Va as St,W as Eo,X as Mo,Y as No,Ya as Tt,Z as Io,Za as yt,_ as Vo,_a as Ct,_b as kt,aa as ko,ab as bt,ba as Lo,ca as Bo,d as xe,da as jo,ea as zo,fa as Go,ga as _o,ha as qo,hb as At,ia as Ho,j as Pe,ja as Ko,ka as Qo,la as Uo,m as Oe,ma as Wo,oa as Jo,ob as Rt,pa as Xo,pb as wt,qa as Yo,qb as Et,qc as Lt,r as je,ra as Zo,rb as Mt,rc as Bt,s as Ue,sa as $o,sb as Nt,sc as jt,t as We,ta as et,tb as It,tc as zt,u as Je,ua as ot,ub as Vt,uc as Gt,v as Xe,va as tt,vc as _t,w as Ye,wa as rt,x as Ze,xa as st,y as $e,yb as Ft,z as eo,zc as qt}from"./chunks/chunk-FPYU47XX.js";import{$ as q,$a as le,$c as Be,Ac as Re,Bd as ze,C as V,Cd as Ge,D as F,Ec as we,Ed as _e,Ee as uo,Fa as $,Fc as Ee,Fe as So,Gc as Me,Ge as bo,H as k,I as L,Ic as Ne,J as B,Ka as ee,Kd as qe,La as te,Lc as Ie,Ld as u,Ma as re,Mc as Ve,Nc as Fe,Ob as he,Q as j,Qb as De,Re as Ao,Sd as He,Ta as ne,Tc as ke,Td as Ke,Ua as se,Ub as ge,Va as ae,Vd as g,We as nt,Y as z,Ya as ie,Yd as S,Z as G,Za as pe,_,_a as ce,_c as Le,a as A,ba as H,ca as K,d as w,e as E,ee as Qe,fa as Q,ga as U,ha as W,ib as me,ie as io,jb as fe,kb as ue,mc as Se,n as I,na as D,nc as Te,pc as ye,qc as Ce,ra as J,rc as ve,sa as X,ta as Y,te as mo,ua as Z,uc as be,vb as de,vc as Ae,ye as fo}from"./chunks/chunk-XCGYJHZR.js";import"./chunks/chunk-GEJEQQER.js";import{a as b,b as R,d as M,h as N,m as oe}from"./chunks/chunk-5TDMGUXQ.js";var v={};b(v,{BAR:()=>y,STROKE_UNIT:()=>d,bar:()=>P,commands:()=>$t,dashes:()=>C,lines:()=>sr,material:()=>er,state:()=>Zt});var Zt={fill:u.fill,stroke:u.stroke},$t={fillTo:g.fillTo,strokeTo:g.strokeTo},d=.001;function T(e){if(e===void 0||e.type!=="solid"||e.blend!==void 0)return null;let t=e.color;return{color:t,alpha:(t[3]??1)*(e.opacity??1)}}function er(e,t={}){let{type:o="basic",opacity:r,...n}=t,s=r??1;if(e.length===0)return{type:o,...n,visible:!1};let a=e.length===1?T(e[0]):null;if(a!==null){let[c,l,p]=a.color;return{type:o,color:[c,l,p,1],opacity:a.alpha*s,...n}}let i=D(e);return{type:o,...i.color!==void 0?{color:i.color}:{},...i.map!==void 0?{map:i.map}:{},...r!==void 0?{opacity:r}:{},...n}}var y={type:"box",width:1,height:1,depth:1};function or(e,t,o){if(e<=-.9999)return{x:0,y:1,z:0,w:0};let r=-o,n=t,s=1+e,a=Math.hypot(r,n,s);return{x:0,y:r/a,z:n/a,w:s/a}}function P(e,t,o,r=0){let n=t[0]-e[0],s=t[1]-e[1],a=t[2]-e[2],i=Math.hypot(n,s,a)||1e-9;return{position:[(e[0]+t[0])/2,(e[1]+t[1])/2,(e[2]+t[2])/2],quaternion:or(n/i,s/i,a/i),scale:[i+r*2,o,o]}}function tr(e){if(e===void 0||e.length===0)return null;let t=e.map(r=>Math.max(0,r)*d),o=t.length%2===1?[...t,...t]:t;return o.reduce((r,n)=>r+n,0)>1e-9?o:null}function C(e,t,o=0){let r=t.reduce((c,l)=>c+l,0),n=[];if(r<=0||e<=0)return n;let s=-((o%r+r)%r),a=0,i=e-1e-9;for(;s<i;){let c=t[a%t.length];if(a%2===0&&c>0){let l=Math.max(0,s),p=Math.min(e,s+c);p-l>1e-9&&n.push([l,p])}s+=c,a++}return n}function rr(e,t,o){let r=e.weight*d,n=e.cap==="square"?r/2:0,s=tr(e.dash),a=e.dashOffset*d,i=[];for(let[c,l]of t){let p=o?[c[0]+o[0],c[1]+o[1],c[2]+o[2]]:c,m=o?[l[0]+o[0],l[1]+o[1],l[2]+o[2]]:l,x=Math.hypot(m[0]-p[0],m[1]-p[1],m[2]-p[2]);if(x<=1e-9)continue;if(s===null){i.push(P(p,m,r,n));continue}let O=h=>{let f=h/x;return[p[0]+(m[0]-p[0])*f,p[1]+(m[1]-p[1])*f,p[2]+(m[2]-p[2])*f]};for(let[h,f]of C(x,s,a))i.push(P(O(h),O(f),r,n))}return i}function nr(e,t){let o=e.fill.map(T).find(i=>i!==null)??null;if(o===null||o.alpha<=0)return null;let[r,n,s]=o.color,a=o.alpha<1||t;return{type:"basic",color:[r,n,s,1],opacity:o.alpha,...a?{transparent:!0,depthWrite:!1}:{},...t?{depthTest:!1}:{}}}function sr(e,t,o,r={}){let n=r.through??!1;for(let s of t){if(!(s.weight>0))continue;let a=nr(s,n);if(a===null)continue;let i=rr(s,o,r.lift);i.length!==0&&e.instances(y,a,i,r.transform?{transform:r.transform}:void 0)}return e}export{z as AdjustmentChain,_ as Adjustments,io as Aim,Jo as AmbientLight3D,et as AreaLight3D,yo as AudioBus,de as AudioEffects,so as BooleanGroup,Eo as Box3D,po as Camera,ot as Camera3D,je as Canvas2D,st as Canvas3D,jo as Capsule3D,Lo as Circle3D,ke as Clip,Vo as Cone3D,Ae as ContextMap,Io as Cylinder3D,xt as DOCUMENT_FORMAT_VERSION,go as DefaultTextStyle,Yo as DirectionalLight3D,ht as DocumentTooNewError,L as EffectChain,B as Effects,We as Ellipse,rt as Environment3D,ze as ExpressionError,Go as Extrude3D,j as Fills,He as Flow,tt as Fog3D,Rt as Geo,U as Graphics2D,J as Graphics3D,Ro as Group3D,Xo as HemisphereLight3D,to as Hexagon,Ho as Instances3D,_o as Lathe3D,Qo as Line3D,ao as MaskGroup,wt as Mat,Ao as Material,wo as Mesh3D,Wo as Model3D,ho as NumberNode,ro as Octagon,co as OrbitCamera,S as Paint,v as Paint3D,Ze as Path,Q as PathBuilder,Ye as PathShape,oo as Pentagon,No as Plane3D,Zo as PointLight3D,Ko as Points3D,Je as Polygon,Xe as Polygram,zo as Polyhedron3D,Po as Provider,it as ROOT_NODE_ID,Yt as Random,Ue as Rect,Tt as Registry,X as RenderContext3D,Do as RichText,eo as RightTriangle,Bo as Ring3D,lo as RotatedBox,Z as Scene3D,Xt as SeedGenerator,Qe as Shapes,xe as Sound,To as SoundNode,Mo as Sphere3D,$o as SpotLight3D,Uo as Sprite3D,no as Star,Et as Tex,xo as Text,mo as TextLayout,Oo as ThemeProvider,Fo as Torus3D,ko as TorusKnot3D,$e as Triangle,qo as Tube3D,uo as Typeface,u as Types,Co as Video,G as VideoAdjustmentChain,q as VideoAdjustments,nt as View3D,H as alignmentOps,dt as asProjectDocument,Ot as assertValidDocument,Bt as childPlanePointAt,ae as clamp,Ht as collectBoxes,I as colorOps,ve as commandParallel,Ce as commandSequence,mt as commandSpan,Ke as commandsFor,qe as component2d,bo as component3d,So as componentAudio,w as cornerRadiusOps,E as cornerStyleOps,be as createContext,Jt as createRef,V as describeEffect,ft as documentDuration,Dt as documentFormatVersion,pe as easeIn,le as easeInOut,ce as easeOut,F as effectDescriptors,ct as effectiveSpan,Ft as evaluateParametric,Nt as evaluateRoundedBox,Ge as expressionOps,ee as fillOps,Le as findNode2D,we as flowOps,Be as frameIn,Wt as generateList,Re as getCommandMeta,Gt as handleValueAt,at as hasTimeline,fe as hold,K as insetsOps,Se as isCommand,Pe as isKnownShaderProperty,ut as isProjectDocument,ue as isRamp,Ne as lerpEuler3,R as lerpNumber,M as lerpVector2,Me as lerpVector3,ie as linear,ye as loopCommand,Te as makeCommand,gt as migrateDocument,_e as migrateNodeProps,St as missingNodeOf,_t as nodeBox,zt as nodeHandlesAt,pt as nodeSpan,yt as nodeTypeIsA,Ve as normalizeQuaternion,Oe as normalizeShaderPack,Ct as parentIssue,Lt as parentPlanePointAt,Qt as parseCSV,N as parseColor,Ut as parseData,oe as pathOps,qt as pickNode,kt as placeTracks,bt as placementIssues,fo as provides,Fe as quaternionFromEuler,me as ramp,jt as reparentPlacementAt,vo as resolveCameraPlacement,A as resolveCorners,$ as resolveFill,D as resolveFill3D,Kt as resolveProjectDocument,k as resolveShaderProperties,te as resolveShadow,Y as resolveShadows3D,ne as resolveStroke,W as resolveSurfaceSource,Ee as resolveVector3,Mt as segmentsOf,It as shadowCasts,re as shadowOps,Vt as shadowReceives,vt as siblingIssue,De as sizeInputOps,Ie as slerpQuaternion,he as space3dOps,se as strokeOps,ge as textOps,At as toPathString,lt as untimed,Pt as validateDocument};
2
2
  //# sourceMappingURL=sdk.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
3
+ "sources": ["../../src/components/modules/paint3d.ts"],
4
+ "sourcesContent": ["import type { NormalizedColor } from \"@/attributes/shape/fill/color/parser\";\nimport type { FillResolved } from \"@/attributes/shape/fill/union\";\nimport type { StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\nimport { resolveFill3D, type Fill3D } from \"@/render3d/fill3d\";\nimport type { Geometry3D } from \"@/render3d/geometry\";\nimport type { Graphics3D } from \"@/render3d/graphics3d\";\nimport type { BasicMaterial3D, Material3D, StandardMaterial3D } from \"@/render3d/material\";\nimport type { Transform3D } from \"@/render3d/transform\";\nimport type { Quaternion } from \"@/render3d/vector3\";\nimport { Types } from \"@/components/factory/types\";\nimport * as Paint from \"@/components/modules/paint\";\n\n/**\n * A custom 3D node's paint: the same `fill` and `stroke` entries a 2D shape takes, so a 3D component never invents\n * `color`, `lineColor` or `lineWidth`. Spread `...Paint3D.state` and `...Paint3D.commands`, then draw the surface with\n * {@link material} and the lines with {@link lines}. Built-in meshes keep `Material.state`.\n */\nexport const state = {\n fill: Types.fill,\n stroke: Types.stroke,\n};\n\n/** `fillTo` and `strokeTo`, the same commands `Paint` has. */\nexport const commands = {\n fillTo: Paint.commands.fillTo,\n strokeTo: Paint.commands.strokeTo,\n};\n\n/** A point in a node's own 3D space. */\nexport type Vec3 = readonly [number, number, number];\n\n/** A line segment from one point to another. */\nexport type Segment3D = readonly [Vec3, Vec3];\n\n/** A stroke `weight`, `dash` or `dashOffset` of 1 is this many scene units: weights are thousandths of a unit. */\nexport const STROKE_UNIT = 0.001;\n\n/** The surface options {@link material} takes: `type` picks the shading, and every other field is laid over the result. */\nexport type MaterialOptions =\n | ({ readonly type?: \"basic\" } & Partial<Omit<BasicMaterial3D, \"type\">>)\n | ({ readonly type: \"standard\" } & Partial<Omit<StandardMaterial3D, \"type\">>);\n\n/** The colour a fill layer is when it is one flat colour with no blend; `null` for anything else. */\nfunction solidOf(layer: FillResolved | undefined): { color: NormalizedColor; alpha: number } | null {\n if (layer === undefined || layer.type !== \"solid\") return null;\n if (layer.blend !== undefined) return null;\n const color = layer.color;\n return { color, alpha: (color[3] ?? 1) * (layer.opacity ?? 1) };\n}\n\n/**\n * The material a surface painted with `fill` wears. Unlit (`basic`) by default; `{ type: \"standard\" }` lights it.\n *\n * - **One solid layer** becomes `color` with its alpha as `opacity`, so `fillTo` between colours tweens the uniforms\n * and allocates nothing.\n * - **Anything else** (a gradient, an image, a stack of layers) goes through `resolveFill3D` and becomes a `map`.\n * - **An empty fill** gives an invisible material (`visible: false`), as an empty 2D fill paints nothing.\n *\n * Fields in `extra` are laid over the result; its `opacity` multiplies the fill's.\n */\nexport function material(fill: readonly FillResolved[], extra: MaterialOptions = {}): Material3D {\n const { type = \"basic\", opacity: extraOpacity, ...rest } = extra as MaterialOptions & { opacity?: number };\n const scale = extraOpacity ?? 1;\n if (fill.length === 0) return { type, ...rest, visible: false } as Material3D;\n const solid = fill.length === 1 ? solidOf(fill[0]) : null;\n if (solid !== null) {\n const [r, g, b] = solid.color;\n return { type, color: [r, g, b, 1], opacity: solid.alpha * scale, ...rest } as Material3D;\n }\n const resolved = resolveFill3D(fill as unknown as Fill3D);\n return {\n type,\n ...(resolved.color !== undefined ? { color: resolved.color } : {}),\n ...(resolved.map !== undefined ? { map: resolved.map } : {}),\n ...(extraOpacity !== undefined ? { opacity: extraOpacity } : {}),\n ...rest,\n } as Material3D;\n}\n\n/** What {@link lines} takes besides the strokes and segments. */\nexport interface LinesOptions {\n /**\n * Draw through solids: `depthTest: false, depthWrite: false`, and blended so it draws after every opaque mesh. For\n * the hidden lines a CAD view shows dashed through the body.\n */\n readonly through?: boolean;\n /**\n * Added to both ends of every segment: a surface's normal times the gap. A line laid on a face needs a gap of at\n * least the camera distance ÷ 2000 (`docs/3d.md`, Depth rule 2); a bar centred on a solid's edge needs none. Leave\n * it out to place the segments yourself.\n */\n readonly lift?: Vec3;\n /** A transform for the whole draw, as `Graphics3D.instances` takes one. */\n readonly transform?: Transform3D;\n}\n\n/** The unit box each bar scales: 1 long on x, 1 by 1 across. */\nexport const BAR: Geometry3D = { type: \"box\", width: 1, height: 1, depth: 1 };\n\n/** The turn that carries +x onto the unit direction `d`. */\nfunction turnOnto(dx: number, dy: number, dz: number): Quaternion {\n // About +x cross d, by the angle between them; straight back along -x turns half way round y.\n if (dx <= -0.9999) return { x: 0, y: 1, z: 0, w: 0 };\n const qy = -dz;\n const qz = dy;\n const qw = 1 + dx;\n const l = Math.hypot(qy, qz, qw);\n return { x: 0, y: qy / l, z: qz / l, w: qw / l };\n}\n\n/** A square bar from `p` to `q`, `w` across, running `extend` past each end. */\nexport function bar(p: Vec3, q: Vec3, w: number, extend = 0): Transform3D {\n const dx = q[0] - p[0];\n const dy = q[1] - p[1];\n const dz = q[2] - p[2];\n const len = Math.hypot(dx, dy, dz) || 1e-9;\n return {\n position: [(p[0] + q[0]) / 2, (p[1] + q[1]) / 2, (p[2] + q[2]) / 2],\n quaternion: turnOnto(dx / len, dy / len, dz / len),\n scale: [len + extend * 2, w, w],\n };\n}\n\n/** The pattern a `dash` repeats, in scene units: an odd list runs twice, as in SVG; `null` for a solid line. */\nfunction dashPattern(dash: readonly number[] | undefined): number[] | null {\n if (dash === undefined || dash.length === 0) return null;\n const units = dash.map((d) => Math.max(0, d) * STROKE_UNIT);\n const pattern = units.length % 2 === 1 ? [...units, ...units] : units;\n return pattern.reduce((sum, d) => sum + d, 0) > 1e-9 ? pattern : null;\n}\n\n/** The stretches `[from, to]` along a segment `length` long that a dash pattern draws, starting `offset` into it. */\nexport function dashes(length: number, pattern: readonly number[], offset = 0): [number, number][] {\n const period = pattern.reduce((sum, d) => sum + d, 0);\n const out: [number, number][] = [];\n if (period <= 0 || length <= 0) return out;\n // Start at the beginning of the period the offset falls in, before the segment.\n let at = -(((offset % period) + period) % period);\n let i = 0;\n const end = length - 1e-9;\n while (at < end) {\n const d = pattern[i % pattern.length]!;\n if (i % 2 === 0 && d > 0) {\n const from = Math.max(0, at);\n const to = Math.min(length, at + d);\n if (to - from > 1e-9) out.push([from, to]);\n }\n at += d;\n i++;\n }\n return out;\n}\n\n/** The bars one stroke layer draws along `segments`. */\nfunction barsFor(stroke: StrokeResolved, segments: readonly Segment3D[], lift: Vec3 | undefined): Transform3D[] {\n const w = stroke.weight * STROKE_UNIT;\n // `round` has no round end to draw on a box, so it ends flush, as `butt` does.\n const extend = stroke.cap === \"square\" ? w / 2 : 0;\n const pattern = dashPattern(stroke.dash);\n const offset = stroke.dashOffset * STROKE_UNIT;\n const out: Transform3D[] = [];\n for (const [a, b] of segments) {\n const p: Vec3 = lift ? [a[0] + lift[0], a[1] + lift[1], a[2] + lift[2]] : a;\n const q: Vec3 = lift ? [b[0] + lift[0], b[1] + lift[1], b[2] + lift[2]] : b;\n const length = Math.hypot(q[0] - p[0], q[1] - p[1], q[2] - p[2]);\n if (length <= 1e-9) continue;\n if (pattern === null) {\n out.push(bar(p, q, w, extend));\n continue;\n }\n const at = (s: number): Vec3 => {\n const t = s / length;\n return [p[0] + (q[0] - p[0]) * t, p[1] + (q[1] - p[1]) * t, p[2] + (q[2] - p[2]) * t];\n };\n for (const [from, to] of dashes(length, pattern, offset)) out.push(bar(at(from), at(to), w, extend));\n }\n return out;\n}\n\n/** The unlit material one stroke layer draws with, or `null` when it would draw nothing. */\nfunction strokeMaterial(stroke: StrokeResolved, through: boolean): Material3D | null {\n const solid = stroke.fill.map(solidOf).find((s) => s !== null) ?? null;\n if (solid === null || solid.alpha <= 0) return null;\n const [r, g, b] = solid.color;\n const blended = solid.alpha < 1 || through;\n return {\n type: \"basic\",\n color: [r, g, b, 1],\n opacity: solid.alpha,\n ...(blended ? { transparent: true, depthWrite: false } : {}),\n ...(through ? { depthTest: false } : {}),\n } as Material3D;\n}\n\n/**\n * Draws `segments` with each layer of `stroke`, one `g3.instances` call of unit boxes per layer, bottom to top.\n *\n * - **`weight`, `dash` and `dashOffset` are thousandths of a scene unit**: weight 5.5 is a 0.0055-wide bar, a CAD\n * hairline on a model a few units across.\n * - **Caps**: `square` runs each bar (and each dash) half the weight past its ends, so outline corners close; `butt`\n * ends flush. `round` ends flush too, as `butt` does: a box has no round end.\n * - **Colour** is the layer's first solid fill, its alpha the bar's `opacity` (below 1 the bars blend and stop writing\n * depth). A layer with no solid fill, or nothing opaque in it, draws nothing; so does an empty `stroke`.\n * - `align`, `join`, markers and the shape of `startCap`/`endCap` are 2D path ideas and are ignored.\n */\nexport function lines(g3: Graphics3D, stroke: readonly StrokeResolved[], segments: readonly Segment3D[], options: LinesOptions = {}): Graphics3D {\n const through = options.through ?? false;\n for (const layer of stroke) {\n if (!(layer.weight > 0)) continue;\n const ink = strokeMaterial(layer, through);\n if (ink === null) continue;\n const bars = barsFor(layer, segments, options.lift);\n if (bars.length === 0) continue;\n g3.instances(BAR, ink, bars, options.transform ? { transform: options.transform } : undefined);\n }\n return g3;\n}\n"],
5
+ "mappings": "mvDAGA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,SAAAE,EAAA,gBAAAC,EAAA,QAAAC,EAAA,aAAAC,GAAA,WAAAC,EAAA,UAAAC,GAAA,aAAAC,GAAA,UAAAC,KAcO,IAAMC,GAAQ,CACjB,KAAMC,EAAM,KACZ,OAAQA,EAAM,QAILC,GAAW,CACpB,OAAcA,EAAS,OACvB,SAAgBA,EAAS,UAUhBC,EAAc,KAQ3B,SAASC,EAAQC,EAA+B,CAE5C,GADIA,IAAU,QAAaA,EAAM,OAAS,SACtCA,EAAM,QAAU,OAAW,OAAO,KACtC,IAAMC,EAAQD,EAAM,MACpB,MAAO,CAAE,MAAAC,EAAO,OAAQA,EAAM,CAAC,GAAK,IAAMD,EAAM,SAAW,EAAE,CACjE,CAYM,SAAUE,GAASC,EAA+BC,EAAyB,CAAA,EAAE,CAC/E,GAAM,CAAE,KAAAC,EAAO,QAAS,QAASC,EAAc,GAAGC,CAAI,EAAKH,EACrDI,EAAQF,GAAgB,E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AAGH,EAAGI,CAAE,EAAGlB,EAAGC,CAAM,CAAC,CACvG,CACA,OAAOY,CACX,CAGA,SAASa,GAAeN,EAAwBO,EAAgB,CAC5D,IAAM7C,EAAQsC,EAAO,KAAK,IAAIhD,CAAO,EAAE,KAAMoD,GAAMA,IAAM,IAAI,GAAK,KAClE,GAAI1C,IAAU,MAAQA,EAAM,OAAS,EAAG,OAAO,KAC/C,GAAM,CAAC,EAAGE,EAAGC,CAAC,EAAIH,EAAM,MAClB8C,EAAU9C,EAAM,MAAQ,GAAK6C,EACnC,MAAO,CACH,KAAM,QACN,MAAO,CAAC,EAAG3C,EAAGC,EAAG,CAAC,EAClB,QAASH,EAAM,MACf,GAAI8C,EAAU,CAAE,YAAa,GAAM,WAAY,EAAK,EAAK,CAAA,EACzD,GAAID,EAAU,CAAE,UAAW,EAAK,EAAK,CAAA,EAE7C,CAaM,SAAUE,GAAMC,EAAgBV,EAAmCC,EAAgCU,EAAwB,CAAA,EAAE,CAC/H,IAAMJ,EAAUI,EAAQ,SAAW,GACnC,QAAW1D,KAAS+C,EAAQ,CACxB,GAAI,EAAE/C,EAAM,OAAS,GAAI,SACzB,IAAM2D,EAAMN,GAAerD,EAAOsD,CAAO,EACzC,GAAIK,IAAQ,KAAM,SAClB,IAAMC,EAAOd,GAAQ9C,EAAOgD,EAAUU,EAAQ,IAAI,EAC9CE,EAAK,SAAW,GACpBH,EAAG,UAAU1C,EAAK4C,EAAKC,EAAMF,EAAQ,UAAY,CAAE,UAAWA,EAAQ,SAAS,EAAK,MAAS,CACjG,CACA,OAAOD,CACX",
6
+ "names": ["paint3d_exports", "__export", "BAR", "STROKE_UNIT", "bar", "commands", "dashes", "lines", "material", "state", "state", "Types", "commands", "STROKE_UNIT", "solidOf", "layer", "color", "material", "fill", "extra", "type", "extraOpacity", "rest", "scale", "solid", "r", "g", "b", "resolved", "resolveFill3D", "BAR", "turnOnto", "dx", "dy", "dz", "qy", "qz", "qw", "l", "bar", "p", "q", "w", "extend", "len", "dashPattern", "dash", "units", "d", "pattern", "sum", "dashes", "length", "offset", "period", "out", "at", "i", "end", "from", "to", "barsFor", "stroke", "segments", "lift", "a", "s", "t", "strokeMaterial", "through", "blended", "lines", "g3", "options", "ink", "bars"]
7
7
  }
@@ -0,0 +1,84 @@
1
+ import type { FillResolved } from "../../attributes/shape/fill/union.js";
2
+ import type { StrokeResolved } from "../../attributes/shape/stroke/stroke.js";
3
+ import type { Geometry3D } from "../../render3d/geometry.js";
4
+ import type { Graphics3D } from "../../render3d/graphics3d.js";
5
+ import type { BasicMaterial3D, Material3D, StandardMaterial3D } from "../../render3d/material.js";
6
+ import type { Transform3D } from "../../render3d/transform.js";
7
+ /**
8
+ * A custom 3D node's paint: the same `fill` and `stroke` entries a 2D shape takes, so a 3D component never invents
9
+ * `color`, `lineColor` or `lineWidth`. Spread `...Paint3D.state` and `...Paint3D.commands`, then draw the surface with
10
+ * {@link material} and the lines with {@link lines}. Built-in meshes keep `Material.state`.
11
+ */
12
+ export declare const state: {
13
+ fill: import("../../components/factory/types.js").Attribute<import("../../index.js").Fill, FillResolved[]>;
14
+ stroke: import("../../components/factory/types.js").Attribute<import("../../attributes/shape/stroke/stroke.js").Stroke, StrokeResolved[]>;
15
+ };
16
+ /** `fillTo` and `strokeTo`, the same commands `Paint` has. */
17
+ export declare const commands: {
18
+ fillTo: {
19
+ readonly args: readonly ["fill"];
20
+ readonly run?: undefined;
21
+ };
22
+ strokeTo: {
23
+ readonly args: readonly ["stroke"];
24
+ readonly run?: undefined;
25
+ };
26
+ };
27
+ /** A point in a node's own 3D space. */
28
+ export type Vec3 = readonly [number, number, number];
29
+ /** A line segment from one point to another. */
30
+ export type Segment3D = readonly [Vec3, Vec3];
31
+ /** A stroke `weight`, `dash` or `dashOffset` of 1 is this many scene units: weights are thousandths of a unit. */
32
+ export declare const STROKE_UNIT = 0.001;
33
+ /** The surface options {@link material} takes: `type` picks the shading, and every other field is laid over the result. */
34
+ export type MaterialOptions = ({
35
+ readonly type?: "basic";
36
+ } & Partial<Omit<BasicMaterial3D, "type">>) | ({
37
+ readonly type: "standard";
38
+ } & Partial<Omit<StandardMaterial3D, "type">>);
39
+ /**
40
+ * The material a surface painted with `fill` wears. Unlit (`basic`) by default; `{ type: "standard" }` lights it.
41
+ *
42
+ * - **One solid layer** becomes `color` with its alpha as `opacity`, so `fillTo` between colours tweens the uniforms
43
+ * and allocates nothing.
44
+ * - **Anything else** (a gradient, an image, a stack of layers) goes through `resolveFill3D` and becomes a `map`.
45
+ * - **An empty fill** gives an invisible material (`visible: false`), as an empty 2D fill paints nothing.
46
+ *
47
+ * Fields in `extra` are laid over the result; its `opacity` multiplies the fill's.
48
+ */
49
+ export declare function material(fill: readonly FillResolved[], extra?: MaterialOptions): Material3D;
50
+ /** What {@link lines} takes besides the strokes and segments. */
51
+ export interface LinesOptions {
52
+ /**
53
+ * Draw through solids: `depthTest: false, depthWrite: false`, and blended so it draws after every opaque mesh. For
54
+ * the hidden lines a CAD view shows dashed through the body.
55
+ */
56
+ readonly through?: boolean;
57
+ /**
58
+ * Added to both ends of every segment: a surface's normal times the gap. A line laid on a face needs a gap of at
59
+ * least the camera distance ÷ 2000 (`docs/3d.md`, Depth rule 2); a bar centred on a solid's edge needs none. Leave
60
+ * it out to place the segments yourself.
61
+ */
62
+ readonly lift?: Vec3;
63
+ /** A transform for the whole draw, as `Graphics3D.instances` takes one. */
64
+ readonly transform?: Transform3D;
65
+ }
66
+ /** The unit box each bar scales: 1 long on x, 1 by 1 across. */
67
+ export declare const BAR: Geometry3D;
68
+ /** A square bar from `p` to `q`, `w` across, running `extend` past each end. */
69
+ export declare function bar(p: Vec3, q: Vec3, w: number, extend?: number): Transform3D;
70
+ /** The stretches `[from, to]` along a segment `length` long that a dash pattern draws, starting `offset` into it. */
71
+ export declare function dashes(length: number, pattern: readonly number[], offset?: number): [number, number][];
72
+ /**
73
+ * Draws `segments` with each layer of `stroke`, one `g3.instances` call of unit boxes per layer, bottom to top.
74
+ *
75
+ * - **`weight`, `dash` and `dashOffset` are thousandths of a scene unit**: weight 5.5 is a 0.0055-wide bar, a CAD
76
+ * hairline on a model a few units across.
77
+ * - **Caps**: `square` runs each bar (and each dash) half the weight past its ends, so outline corners close; `butt`
78
+ * ends flush. `round` ends flush too, as `butt` does: a box has no round end.
79
+ * - **Colour** is the layer's first solid fill, its alpha the bar's `opacity` (below 1 the bars blend and stop writing
80
+ * depth). A layer with no solid fill, or nothing opaque in it, draws nothing; so does an empty `stroke`.
81
+ * - `align`, `join`, markers and the shape of `startCap`/`endCap` are 2D path ideas and are ignored.
82
+ */
83
+ export declare function lines(g3: Graphics3D, stroke: readonly StrokeResolved[], segments: readonly Segment3D[], options?: LinesOptions): Graphics3D;
84
+ //# sourceMappingURL=paint3d.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paint3d.d.ts","sourceRoot":"","sources":["../../../src/components/modules/paint3d.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKxD;;;;GAIG;AACH,eAAO,MAAM,KAAK;;;CAGjB,CAAC;AAEF,8DAA8D;AAC9D,eAAO,MAAM,QAAQ;;;;;;;;;CAGpB,CAAC;AAEF,wCAAwC;AACxC,MAAM,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAErD,gDAAgD;AAChD,MAAM,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,EAAE,I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S,SAAS,EAAE,EAAE,OAAO,GAAE,YAAiB,GAAG,UAAU,CAW/I"}
@@ -0,0 +1,182 @@
1
+ import { resolveFill3D } from "../../render3d/fill3d.js";
2
+ import { Types } from "../../components/factory/types.js";
3
+ import * as Paint from "../../components/modules/paint.js";
4
+ /**
5
+ * A custom 3D node's paint: the same `fill` and `stroke` entries a 2D shape takes, so a 3D component never invents
6
+ * `color`, `lineColor` or `lineWidth`. Spread `...Paint3D.state` and `...Paint3D.commands`, then draw the surface with
7
+ * {@link material} and the lines with {@link lines}. Built-in meshes keep `Material.state`.
8
+ */
9
+ export const state = {
10
+ fill: Types.fill,
11
+ stroke: Types.stroke,
12
+ };
13
+ /** `fillTo` and `strokeTo`, the same commands `Paint` has. */
14
+ export const commands = {
15
+ fillTo: Paint.commands.fillTo,
16
+ strokeTo: Paint.commands.strokeTo,
17
+ };
18
+ /** A stroke `weight`, `dash` or `dashOffset` of 1 is this many scene units: weights are thousandths of a unit. */
19
+ export const STROKE_UNIT = 0.001;
20
+ /** The colour a fill layer is when it is one flat colour with no blend; `null` for anything else. */
21
+ function solidOf(layer) {
22
+ if (layer === undefined || layer.type !== "solid")
23
+ return null;
24
+ if (layer.blend !== undefined)
25
+ return null;
26
+ const color = layer.color;
27
+ return { color, alpha: (color[3] ?? 1) * (layer.opacity ?? 1) };
28
+ }
29
+ /**
30
+ * The material a surface painted with `fill` wears. Unlit (`basic`) by default; `{ type: "standard" }` lights it.
31
+ *
32
+ * - **One solid layer** becomes `color` with its alpha as `opacity`, so `fillTo` between colours tweens the uniforms
33
+ * and allocates nothing.
34
+ * - **Anything else** (a gradient, an image, a stack of layers) goes through `resolveFill3D` and becomes a `map`.
35
+ * - **An empty fill** gives an invisible material (`visible: false`), as an empty 2D fill paints nothing.
36
+ *
37
+ * Fields in `extra` are laid over the result; its `opacity` multiplies the fill's.
38
+ */
39
+ export function material(fill, extra = {}) {
40
+ const { type = "basic", opacity: extraOpacity, ...rest } = extra;
41
+ const scale = extraOpacity ?? 1;
42
+ if (fill.length === 0)
43
+ return { type, ...rest, visible: false };
44
+ const solid = fill.length === 1 ? solidOf(fill[0]) : null;
45
+ if (solid !== null) {
46
+ const [r, g, b] = solid.color;
47
+ return { type, color: [r, g, b, 1], opacity: solid.alpha * scale, ...rest };
48
+ }
49
+ const resolved = resolveFill3D(fill);
50
+ return {
51
+ type,
52
+ ...(resolved.color !== undefined ? { color: resolved.color } : {}),
53
+ ...(resolved.map !== undefined ? { map: resolved.map } : {}),
54
+ ...(extraOpacity !== undefined ? { opacity: extraOpacity } : {}),
55
+ ...rest,
56
+ };
57
+ }
58
+ /** The unit box each bar scales: 1 long on x, 1 by 1 across. */
59
+ export const BAR = { type: "box", width: 1, height: 1, depth: 1 };
60
+ /** The turn that carries +x onto the unit direction `d`. */
61
+ function turnOnto(dx, dy, dz) {
62
+ // About +x cross d, by the angle between them; straight back along -x turns half way round y.
63
+ if (dx <= -0.9999)
64
+ return { x: 0, y: 1, z: 0, w: 0 };
65
+ const qy = -dz;
66
+ const qz = dy;
67
+ const qw = 1 + dx;
68
+ const l = Math.hypot(qy, qz, qw);
69
+ return { x: 0, y: qy / l, z: qz / l, w: qw / l };
70
+ }
71
+ /** A square bar from `p` to `q`, `w` across, running `extend` past each end. */
72
+ export function bar(p, q, w, extend = 0) {
73
+ const dx = q[0] - p[0];
74
+ const dy = q[1] - p[1];
75
+ const dz = q[2] - p[2];
76
+ const len = Math.hypot(dx, dy, dz) || 1e-9;
77
+ return {
78
+ position: [(p[0] + q[0]) / 2, (p[1] + q[1]) / 2, (p[2] + q[2]) / 2],
79
+ quaternion: turnOnto(dx / len, dy / len, dz / len),
80
+ scale: [len + extend * 2, w, w],
81
+ };
82
+ }
83
+ /** The pattern a `dash` repeats, in scene units: an odd list runs twice, as in SVG; `null` for a solid line. */
84
+ function dashPattern(dash) {
85
+ if (dash === undefined || dash.length === 0)
86
+ return null;
87
+ const units = dash.map((d) => Math.max(0, d) * STROKE_UNIT);
88
+ const pattern = units.length % 2 === 1 ? [...units, ...units] : units;
89
+ return pattern.reduce((sum, d) => sum + d, 0) > 1e-9 ? pattern : null;
90
+ }
91
+ /** The stretches `[from, to]` along a segment `length` long that a dash pattern draws, starting `offset` into it. */
92
+ export function dashes(length, pattern, offset = 0) {
93
+ const period = pattern.reduce((sum, d) => sum + d, 0);
94
+ const out = [];
95
+ if (period <= 0 || length <= 0)
96
+ return out;
97
+ // Start at the beginning of the period the offset falls in, before the segment.
98
+ let at = -(((offset % period) + period) % period);
99
+ let i = 0;
100
+ const end = length - 1e-9;
101
+ while (at < end) {
102
+ const d = pattern[i % pattern.length];
103
+ if (i % 2 === 0 && d > 0) {
104
+ const from = Math.max(0, at);
105
+ const to = Math.min(length, at + d);
106
+ if (to - from > 1e-9)
107
+ out.push([from, to]);
108
+ }
109
+ at += d;
110
+ i++;
111
+ }
112
+ return out;
113
+ }
114
+ /** The bars one stroke layer draws along `segments`. */
115
+ function barsFor(stroke, segments, lift) {
116
+ const w = stroke.weight * STROKE_UNIT;
117
+ // `round` has no round end to draw on a box, so it ends flush, as `butt` does.
118
+ const extend = stroke.cap === "square" ? w / 2 : 0;
119
+ const pattern = dashPattern(stroke.dash);
120
+ const offset = stroke.dashOffset * STROKE_UNIT;
121
+ const out = [];
122
+ for (const [a, b] of segments) {
123
+ const p = lift ? [a[0] + lift[0], a[1] + lift[1], a[2] + lift[2]] : a;
124
+ const q = lift ? [b[0] + lift[0], b[1] + lift[1], b[2] + lift[2]] : b;
125
+ const length = Math.hypot(q[0] - p[0], q[1] - p[1], q[2] - p[2]);
126
+ if (length <= 1e-9)
127
+ continue;
128
+ if (pattern === null) {
129
+ out.push(bar(p, q, w, extend));
130
+ continue;
131
+ }
132
+ const at = (s) => {
133
+ const t = s / length;
134
+ return [p[0] + (q[0] - p[0]) * t, p[1] + (q[1] - p[1]) * t, p[2] + (q[2] - p[2]) * t];
135
+ };
136
+ for (const [from, to] of dashes(length, pattern, offset))
137
+ out.push(bar(at(from), at(to), w, extend));
138
+ }
139
+ return out;
140
+ }
141
+ /** The unlit material one stroke layer draws with, or `null` when it would draw nothing. */
142
+ function strokeMaterial(stroke, through) {
143
+ const solid = stroke.fill.map(solidOf).find((s) => s !== null) ?? null;
144
+ if (solid === null || solid.alpha <= 0)
145
+ return null;
146
+ const [r, g, b] = solid.color;
147
+ const blended = solid.alpha < 1 || through;
148
+ return {
149
+ type: "basic",
150
+ color: [r, g, b, 1],
151
+ opacity: solid.alpha,
152
+ ...(blended ? { transparent: true, depthWrite: false } : {}),
153
+ ...(through ? { depthTest: false } : {}),
154
+ };
155
+ }
156
+ /**
157
+ * Draws `segments` with each layer of `stroke`, one `g3.instances` call of unit boxes per layer, bottom to top.
158
+ *
159
+ * - **`weight`, `dash` and `dashOffset` are thousandths of a scene unit**: weight 5.5 is a 0.0055-wide bar, a CAD
160
+ * hairline on a model a few units across.
161
+ * - **Caps**: `square` runs each bar (and each dash) half the weight past its ends, so outline corners close; `butt`
162
+ * ends flush. `round` ends flush too, as `butt` does: a box has no round end.
163
+ * - **Colour** is the layer's first solid fill, its alpha the bar's `opacity` (below 1 the bars blend and stop writing
164
+ * depth). A layer with no solid fill, or nothing opaque in it, draws nothing; so does an empty `stroke`.
165
+ * - `align`, `join`, markers and the shape of `startCap`/`endCap` are 2D path ideas and are ignored.
166
+ */
167
+ export function lines(g3, stroke, segments, options = {}) {
168
+ const through = options.through ?? false;
169
+ for (const layer of stroke) {
170
+ if (!(layer.weight > 0))
171
+ continue;
172
+ const ink = strokeMaterial(layer, through);
173
+ if (ink === null)
174
+ continue;
175
+ const bars = barsFor(layer, segments, options.lift);
176
+ if (bars.length === 0)
177
+ continue;
178
+ g3.instances(BAR, ink, bars, options.transform ? { transform: options.transform } : undefined);
179
+ }
180
+ return g3;
181
+ }
182
+ //# sourceMappingURL=paint3d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paint3d.js","sourceRoot":"","sources":["../../../src/components/modules/paint3d.ts"],"names":[],"mappings":"AAGA,OAAO,E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,CAAC,KAAK;QACpB,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5D,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7B,CAAC;AACpB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,KAAK,CAAC,EAAc,EAAE,MAAiC,EAAE,QAA8B,EAAE,UAAwB,EAAE;IAC/H,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC;IACzC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YAAE,SAAS;QAClC,MAAM,GAAG,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC3C,IAAI,GAAG,KAAK,IAAI;YAAE,SAAS;QAC3B,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,SAAS;QAChC,EAAE,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACnG,CAAC;IACD,OAAO,EAAE,CAAC;AACd,CAAC","sourcesContent":["import type { NormalizedColor } from \"@/attributes/shape/fill/color/parser\";\nimport type { FillResolved } from \"@/attributes/shape/fill/union\";\nimport type { StrokeResolved } from \"@/attributes/shape/stroke/stroke\";\nimport { resolveFill3D, type Fill3D } from \"@/render3d/fill3d\";\nimport type { Geometry3D } from \"@/render3d/geometry\";\nimport type { Graphics3D } from \"@/render3d/graphics3d\";\nimport type { BasicMaterial3D, Material3D, StandardMaterial3D } from \"@/render3d/material\";\nimport type { Transform3D } from \"@/render3d/transform\";\nimport type { Quaternion } from \"@/render3d/vector3\";\nimport { Types } from \"@/components/factory/types\";\nimport * as Paint from \"@/components/modules/paint\";\n\n/**\n * A custom 3D node's paint: the same `fill` and `stroke` entries a 2D shape takes, so a 3D component never invents\n * `color`, `lineColor` or `lineWidth`. Spread `...Paint3D.state` and `...Paint3D.commands`, then draw the surface with\n * {@link material} and the lines with {@link lines}. Built-in meshes keep `Material.state`.\n */\nexport const state = {\n fill: Types.fill,\n stroke: Types.stroke,\n};\n\n/** `fillTo` and `strokeTo`, the same commands `Paint` has. */\nexport const commands = {\n fillTo: Paint.commands.fillTo,\n strokeTo: Paint.commands.strokeTo,\n};\n\n/** A point in a node's own 3D space. */\nexport type Vec3 = readonly [number, number, number];\n\n/** A line segment from one point to another. */\nexport type Segment3D = readonly [Vec3, Vec3];\n\n/** A stroke `weight`, `dash` or `dashOffset` of 1 is this many scene units: weights are thousandths of a unit. */\nexport const STROKE_UNIT = 0.001;\n\n/** The surface options {@link material} takes: `type` picks the shading, and every other field is laid over the result. */\nexport type MaterialOptions =\n | ({ readonly type?: \"basic\" } & Partial<Omit<BasicMaterial3D, \"type\">>)\n | ({ readonly type: \"standard\" } & Partial<Omit<StandardMaterial3D, \"type\">>);\n\n/** The colour a fill layer is when it is one flat colour with no blend; `null` for anything else. */\nfunction solidOf(layer: FillResolved | undefined): { color: NormalizedColor; alpha: number } | null {\n if (layer === undefined || layer.type !== \"solid\") return null;\n if (layer.blend !== undefined) return null;\n const color = layer.color;\n return { color, alpha: (color[3] ?? 1) * (layer.opacity ?? 1) };\n}\n\n/**\n * The material a surface painted with `fill` wears. Unlit (`basic`) by default; `{ type: \"standard\" }` lights it.\n *\n * - **One solid layer** becomes `color` with its alpha as `opacity`, so `fillTo` between colours tweens the uniforms\n * and allocates nothing.\n * - **Anything else** (a gradient, an image, a stack of layers) goes through `resolveFill3D` and becomes a `map`.\n * - **An empty fill** gives an invisible material (`visible: false`), as an empty 2D fill paints nothing.\n *\n * Fields in `extra` are laid over the result; its `opacity` multiplies the fill's.\n */\nexport function material(fill: readonly FillResolved[], extra: MaterialOptions = {}): Material3D {\n const { type = \"basic\", opacity: extraOpacity, ...rest } = extra as MaterialOptions & { opacity?: number };\n const scale = extraOpacity ?? 1;\n if (fill.length === 0) return { type, ...rest, visible: false } as Material3D;\n const solid = fill.length === 1 ? solidOf(fill[0]) : null;\n if (solid !== null) {\n const [r, g, b] = solid.color;\n return { type, color: [r, g, b, 1], opacity: solid.alpha * scale, ...rest } as Material3D;\n }\n const resolved = resolveFill3D(fill as unknown as Fill3D);\n return {\n type,\n ...(resolved.color !== undefined ? { color: resolved.color } : {}),\n ...(resolved.map !== undefined ? { map: resolved.map } : {}),\n ...(extraOpacity !== undefined ? { opacity: extraOpacity } : {}),\n ...rest,\n } as Material3D;\n}\n\n/** What {@link lines} takes besides the strokes and segments. */\nexport interface LinesOptions {\n /**\n * Draw through solids: `depthTest: false, depthWrite: false`, and blended so it draws after every opaque mesh. For\n * the hidden lines a CAD view shows dashed through the body.\n */\n readonly through?: boolean;\n /**\n * Added to both ends of every segment: a surface's normal times the gap. A line laid on a face needs a gap of at\n * least the camera distance ÷ 2000 (`docs/3d.md`, Depth rule 2); a bar centred on a solid's edge needs none. Leave\n * it out to place the segments yourself.\n */\n readonly lift?: Vec3;\n /** A transform for the whole draw, as `Graphics3D.instances` takes one. */\n readonly transform?: Transform3D;\n}\n\n/** The unit box each bar scales: 1 long on x, 1 by 1 across. */\nexport const BAR: Geometry3D = { type: \"box\", width: 1, height: 1, depth: 1 };\n\n/** The turn that carries +x onto the unit direction `d`. */\nfunction turnOnto(dx: number, dy: number, dz: number): Quaternion {\n // About +x cross d, by the angle between them; straight back along -x turns half way round y.\n if (dx <= -0.9999) return { x: 0, y: 1, z: 0, w: 0 };\n const qy = -dz;\n const qz = dy;\n const qw = 1 + dx;\n const l = Math.hypot(qy, qz, qw);\n return { x: 0, y: qy / l, z: qz / l, w: qw / l };\n}\n\n/** A square bar from `p` to `q`, `w` across, running `extend` past each end. */\nexport function bar(p: Vec3, q: Vec3, w: number, extend = 0): Transform3D {\n const dx = q[0] - p[0];\n const dy = q[1] - p[1];\n const dz = q[2] - p[2];\n const len = Math.hypot(dx, dy, dz) || 1e-9;\n return {\n position: [(p[0] + q[0]) / 2, (p[1] + q[1]) / 2, (p[2] + q[2]) / 2],\n quaternion: turnOnto(dx / len, dy / len, dz / len),\n scale: [len + extend * 2, w, w],\n };\n}\n\n/** The pattern a `dash` repeats, in scene units: an odd list runs twice, as in SVG; `null` for a solid line. */\nfunction dashPattern(dash: readonly number[] | undefined): number[] | null {\n if (dash === undefined || dash.length === 0) return null;\n const units = dash.map((d) => Math.max(0, d) * STROKE_UNIT);\n const pattern = units.length % 2 === 1 ? [...units, ...units] : units;\n return pattern.reduce((sum, d) => sum + d, 0) > 1e-9 ? pattern : null;\n}\n\n/** The stretches `[from, to]` along a segment `length` long that a dash pattern draws, starting `offset` into it. */\nexport function dashes(length: number, pattern: readonly number[], offset = 0): [number, number][] {\n const period = pattern.reduce((sum, d) => sum + d, 0);\n const out: [number, number][] = [];\n if (period <= 0 || length <= 0) return out;\n // Start at the beginning of the period the offset falls in, before the segment.\n let at = -(((offset % period) + period) % period);\n let i = 0;\n const end = length - 1e-9;\n while (at < end) {\n const d = pattern[i % pattern.length]!;\n if (i % 2 === 0 && d > 0) {\n const from = Math.max(0, at);\n const to = Math.min(length, at + d);\n if (to - from > 1e-9) out.push([from, to]);\n }\n at += d;\n i++;\n }\n return out;\n}\n\n/** The bars one stroke layer draws along `segments`. */\nfunction barsFor(stroke: StrokeResolved, segments: readonly Segment3D[], lift: Vec3 | undefined): Transform3D[] {\n const w = stroke.weight * STROKE_UNIT;\n // `round` has no round end to draw on a box, so it ends flush, as `butt` does.\n const extend = stroke.cap === \"square\" ? w / 2 : 0;\n const pattern = dashPattern(stroke.dash);\n const offset = stroke.dashOffset * STROKE_UNIT;\n const out: Transform3D[] = [];\n for (const [a, b] of segments) {\n const p: Vec3 = lift ? [a[0] + lift[0], a[1] + lift[1], a[2] + lift[2]] : a;\n const q: Vec3 = lift ? [b[0] + lift[0], b[1] + lift[1], b[2] + lift[2]] : b;\n const length = Math.hypot(q[0] - p[0], q[1] - p[1], q[2] - p[2]);\n if (length <= 1e-9) continue;\n if (pattern === null) {\n out.push(bar(p, q, w, extend));\n continue;\n }\n const at = (s: number): Vec3 => {\n const t = s / length;\n return [p[0] + (q[0] - p[0]) * t, p[1] + (q[1] - p[1]) * t, p[2] + (q[2] - p[2]) * t];\n };\n for (const [from, to] of dashes(length, pattern, offset)) out.push(bar(at(from), at(to), w, extend));\n }\n return out;\n}\n\n/** The unlit material one stroke layer draws with, or `null` when it would draw nothing. */\nfunction strokeMaterial(stroke: StrokeResolved, through: boolean): Material3D | null {\n const solid = stroke.fill.map(solidOf).find((s) => s !== null) ?? null;\n if (solid === null || solid.alpha <= 0) return null;\n const [r, g, b] = solid.color;\n const blended = solid.alpha < 1 || through;\n return {\n type: \"basic\",\n color: [r, g, b, 1],\n opacity: solid.alpha,\n ...(blended ? { transparent: true, depthWrite: false } : {}),\n ...(through ? { depthTest: false } : {}),\n } as Material3D;\n}\n\n/**\n * Draws `segments` with each layer of `stroke`, one `g3.instances` call of unit boxes per layer, bottom to top.\n *\n * - **`weight`, `dash` and `dashOffset` are thousandths of a scene unit**: weight 5.5 is a 0.0055-wide bar, a CAD\n * hairline on a model a few units across.\n * - **Caps**: `square` runs each bar (and each dash) half the weight past its ends, so outline corners close; `butt`\n * ends flush. `round` ends flush too, as `butt` does: a box has no round end.\n * - **Colour** is the layer's first solid fill, its alpha the bar's `opacity` (below 1 the bars blend and stop writing\n * depth). A layer with no solid fill, or nothing opaque in it, draws nothing; so does an empty `stroke`.\n * - `align`, `join`, markers and the shape of `startCap`/`endCap` are 2D path ideas and are ignored.\n */\nexport function lines(g3: Graphics3D, stroke: readonly StrokeResolved[], segments: readonly Segment3D[], options: LinesOptions = {}): Graphics3D {\n const through = options.through ?? false;\n for (const layer of stroke) {\n if (!(layer.weight > 0)) continue;\n const ink = strokeMaterial(layer, through);\n if (ink === null) continue;\n const bars = barsFor(layer, segments, options.lift);\n if (bars.length === 0) continue;\n g3.instances(BAR, ink, bars, options.transform ? { transform: options.transform } : undefined);\n }\n return g3;\n}\n"]}
@@ -20,7 +20,7 @@ export interface TextureOptions3D {
20
20
  center?: Vector2 | readonly [number, number];
21
21
  magFilter?: TextureFilter3D;
22
22
  minFilter?: TextureFilter3D;
23
- /** Sharpness at grazing angles. Clamped to the GPU's maximum. */
23
+ /** Sharpness at grazing angles: 1 is off, and anything above is rounded up to 4, 8 or 16 (the most WebGPU allows). Needs linear filters. */
24
24
  anisotropy?: number;
25
25
  flipY?: boolean;
26
26
  colorSpace?: TextureColorSpace3D;
@@ -1 +1 @@
1
- {"version":3,"file":"texture.d.ts","sourceRoot":"","sources":["../../src/render3d/texture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAE3D,qDAAqD;AACrD,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE1D,yDAAyD;AACzD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEnD,8SAA8S;AAC9S,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEpD,oDAAoD;AACpD,MAAM,WAAW,gBAAgB;IAC7B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,a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EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAoB,EAAE;QACtD,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAgB,EAAE,CAAC;AACnD,CAAC;AAKD,MAAM,UAAU,eAAe,CAAC,OAAkB;IAC9C,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,MAAM,IAAI,OAAO,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAkB;IACjD,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,QAAQ,IAAI,OAAO,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAkB;IAC/C,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AACpE,CAAC;AAED,6JAA6J;AAC7J,MAAM,UAAU,eAAe,CAAC,OAAkB;IAC9C,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAChD,IAAI,eAAe,CAAC,OAAO,CAAC,IAAI,kBAAkB,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IACzE,OAAO,OAAO,CAAC,GAAG,CAAC;AACvB,CAAC;AAED,sNAAsN;AACtN,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC5C,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;WACrB,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;WACrB,0DAA0D,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClF,CAAC","sourcesContent":["import type { Vector2 } from \"@/attributes/layout/vector2\";\n// Type-only, like `Color`: `render3d` is pure data and never reaches into the render or node layers at runtime (see SurfaceSource3D).\nimport type { Graphics2D } from \"@/render/graphics2d\";\nimport type { Node } from \"@/components/trees/node/node\";\nimport type { Node2D } from \"@/components/trees/2d/node2d\";\n\n/** How sampling behaves outside the 0–1 UV range. */\nexport type TextureWrap3D = \"clamp\" | \"repeat\" | \"mirror\";\n\n/** How texels are blended when the texture is scaled. */\nexport type TextureFilter3D = \"nearest\" | \"linear\";\n\n/** Colour space of the texture's data: `\"srgb\"` for colours an eye would see (albedo/`map`, `emissiveMap`), linearized before lighting; `\"linear\"` for data maps (`normalMap`, `roughnessMap`, `metalnessMap`, `aoMap`, `displacementMap`), which linearizing would corrupt. Each slot defaults correctly. */\nexport type TextureColorSpace3D = \"srgb\" | \"linear\";\n\n/** Sampler state shared by every texture source. */\nexport interface TextureOptions3D {\n wrapS?: TextureWrap3D;\n wrapT?: TextureWrap3D;\n /** UV scale. `[2, 2]` tiles twice on each axis (needs a `repeat` wrap). */\n repeat?: Vector2 | readonly [number, number];\n offset?: Vector2 | readonly [number, number];\n /** UV rotation in **degrees**, about {@link center}. */\n rotation?: number;\n center?: Vector2 | readonly [number, number];\n magFilter?: TextureFilter3D;\n minFilter?: TextureFilter3D;\n /** Sharpness at grazing angles. Clamped to the GPU's maximum. */\n anisotropy?: number;\n flipY?: boolean;\n colorSpace?: TextureColorSpace3D;\n}\n\n/** A texture from the project's asset manifest. `src` is found by the asset-tracking pass and requested through the ordinary image pipeline (as a 2D image fill), so pixels are resident before the frame draws. */\nexport interface ImageTexture3D extends TextureOptions3D {\n src: string;\n}\n\n/** Raw RGBA8888 bytes: the escape hatch for procedurally generated pixels (ramps, noise, LUTs, data as colour). */\nexport interface DataTexture3D extends TextureOptions3D {\n data: ArrayLike<number>;\n width: number;\n height: number;\n /** Bump to force a re-upload after mutating `data` in place (invisible to identity comparison). See {@link BufferGeometry3D.revision}. */\n revision?: number;\n}\n\n/**\n * A texture whose pixels are Motion Script's own 2D output, rasterized offscreen: puts a chart, readout or laid-out UI\n * onto 3D geometry. `source` is a value, a built {@link Graphics2D} or a `Node2D` subtree, supplied directly with no\n * indirection or tree placement.\n *\n * g3.plane({ map: Tex.surface(scopeGraphics, 1024, 640) })\n *\n * A `Node2D` source is adopted for binding by whatever paints the scene (asset catalog, inherited context, clock, so a\n * webfont shapes and an `<Image>` loads); it is never laid out or painted by the scene tree, only measured against\n * `width` x `height` and drawn into the buffer.\n *\n * **Hoist the source.** Building it inside the scene builder allocates a new subtree every frame (re-binding,\n * re-laying-out, defeating the texture cache, leaking). A hoisted source is a stable identity, so the renderer keys\n * the GPU texture off the source object (a `WeakMap`) and a source that goes out of scope becomes collectable.\n */\nexport interface SurfaceTexture3D extends TextureOptions3D {\n /** A built `Graphics2D`, or a `Node2D` subtree (typed structurally, see {@link SurfaceSource3D}). */\n source: SurfaceSource3D;\n /** Buffer width in pixels. This *is* the texture's resolution. */\n width: number;\n height: number;\n /**\n * Declares the source's pixels unchanging, so the buffer is rasterized once and reused. Set by `resolveFill3D` for a\n * fill chain; an author's own source is live by default, so an animated `Graphics2D` or prop-driven subtree works\n * with no bookkeeping. Needs {@link identity} to be cacheable.\n *\n * @internal\n */\n static?: boolean;\n /**\n * Cache identity for a synthesized source. An author's source is identified by the object itself (right for a hoisted\n * one); a source built for a fill is fresh every frame, so the value it was derived from supplies one.\n *\n * @internal\n */\n identity?: string;\n /** Ceiling on the buffer's device-pixel ratio, default 1 (the buffer is exactly `width` x `height`). A surface is sampled at whatever size the geometry occupies, so `width`/`height` is the real control; raise this only for a surface viewed close up that reads soft. */\n maxPixelRatio?: number;\n}\n\n/** What a {@link SurfaceTexture3D} paints from: a built {@link Graphics2D} or a {@link Node2D} subtree. Both imports are type-only: `render3d` is pure data, and a value import of `Node2D` would close a real cycle. Narrow with {@link resolveSurfaceSource}. */\nexport type SurfaceSource3D = Graphics2D | Node;\n\n// Declared against the dimension-agnostic base because that is what a built node is typed as, so\n// `Tex.surface(new Rect({ ... }), ...)` type-checks without a cast. It must be 2D in fact; `resolveSurfaceSource`\n// narrows, and a `Node3D` fails at render time.\n\n/** A {@link SurfaceSource3D} narrowed to the arm its renderer should take. */\nexport type ResolvedSurfaceSource =\n | { kind: \"graphics\"; graphics: Graphics2D }\n | { kind: \"node\"; node: Node2D };\n\n/** Narrows a surface source to the arm that draws it: a `Graphics2D` is replayed into a render context, a `Node2D` is laid out against the buffer and rendered. Structural, not `instanceof` (value imports would close the cycle): `Graphics2D` exposes `ops()` and a `Node2D` doesn't. */\nexport function resolveSurfaceSource(source: SurfaceSource3D): ResolvedSurfaceSource {\n return typeof (source as Graphics2D).ops === \"function\"\n ? { kind: \"graphics\", graphics: source as Graphics2D }\n : { kind: \"node\", node: source as Node2D };\n}\n\n/** A texture reference; a bare string is sugar for `{ src }` (`map: \"/wood.png\"`). */\nexport type Texture3D = string | ImageTexture3D | DataTexture3D | SurfaceTexture3D;\n\nexport function isDataTexture3D(texture: Texture3D): texture is DataTexture3D {\n return typeof texture !== \"string\" && \"data\" in texture;\n}\n\nexport function isSurfaceTexture3D(texture: Texture3D): texture is SurfaceTexture3D {\n return typeof texture !== \"string\" && \"source\" in texture;\n}\n\nexport function resolveTexture3D(texture: Texture3D): ImageTexture3D | DataTexture3D | SurfaceTexture3D {\n return typeof texture === \"string\" ? { src: texture } : texture;\n}\n\n/** The asset `src` a texture reads from, or `null` for a data or surface texture; the asset-tracking pass uses it, and `null` means \"nothing to request\". */\nexport function texture3DSource(texture: Texture3D): string | null {\n if (typeof texture === \"string\") return texture;\n if (isDataTexture3D(texture) || isSurfaceTexture3D(texture)) return null;\n return texture.src;\n}\n\n/** True for a string that names an asset rather than a colour: a leading `/` or `.` is a path, otherwise the extension decides. A bare name like `\"wood\"` is a colour, as the manifest couldn't resolve it either. */\nexport function looksLikeAssetPath(value: string): boolean {\n return value.startsWith(\"/\")\n || value.startsWith(\".\")\n || /\\.(png|jpe?g|webp|avif|svg|ktx2?|hdr|exr|mp4|webm|mov)$/i.test(value);\n}\n"]}
1
+ {"version":3,"file":"texture.js","sourceRoot":"","sources":["../../src/render3d/texture.ts"],"names":[],"mappings":"AAmGA,4RAA4R;AAC5R,MAAM,UAAU,oBAAoB,CAAC,MAAuB;IACxD,OAAO,OAAQ,MAAqB,CAAC,GAAG,KAAK,UAAU;QACnD,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAoB,EAAE;QACtD,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAgB,EAAE,CAAC;AACnD,CAAC;AAKD,MAAM,UAAU,eAAe,CAAC,OAAkB;IAC9C,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,MAAM,IAAI,OAAO,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAkB;IACjD,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,QAAQ,IAAI,OAAO,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,OAAkB;IAC/C,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AACpE,CAAC;AAED,6JAA6J;AAC7J,MAAM,UAAU,eAAe,CAAC,OAAkB;IAC9C,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAChD,IAAI,eAAe,CAAC,OAAO,CAAC,IAAI,kBAAkB,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IACzE,OAAO,OAAO,CAAC,GAAG,CAAC;AACvB,CAAC;AAED,sNAAsN;AACtN,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC5C,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;WACrB,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;WACrB,0DAA0D,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAClF,CAAC","sourcesContent":["import type { Vector2 } from \"@/attributes/layout/vector2\";\n// Type-only, like `Color`: `render3d` is pure data and never reaches into the render or node layers at runtime (see SurfaceSource3D).\nimport type { Graphics2D } from \"@/render/graphics2d\";\nimport type { Node } from \"@/components/trees/node/node\";\nimport type { Node2D } from \"@/components/trees/2d/node2d\";\n\n/** How sampling behaves outside the 0–1 UV range. */\nexport type TextureWrap3D = \"clamp\" | \"repeat\" | \"mirror\";\n\n/** How texels are blended when the texture is scaled. */\nexport type TextureFilter3D = \"nearest\" | \"linear\";\n\n/** Colour space of the texture's data: `\"srgb\"` for colours an eye would see (albedo/`map`, `emissiveMap`), linearized before lighting; `\"linear\"` for data maps (`normalMap`, `roughnessMap`, `metalnessMap`, `aoMap`, `displacementMap`), which linearizing would corrupt. Each slot defaults correctly. */\nexport type TextureColorSpace3D = \"srgb\" | \"linear\";\n\n/** Sampler state shared by every texture source. */\nexport interface TextureOptions3D {\n wrapS?: TextureWrap3D;\n wrapT?: TextureWrap3D;\n /** UV scale. `[2, 2]` tiles twice on each axis (needs a `repeat` wrap). */\n repeat?: Vector2 | readonly [number, number];\n offset?: Vector2 | readonly [number, number];\n /** UV rotation in **degrees**, about {@link center}. */\n rotation?: number;\n center?: Vector2 | readonly [number, number];\n magFilter?: TextureFilter3D;\n minFilter?: TextureFilter3D;\n /** Sharpness at grazing angles: 1 is off, and anything above is rounded up to 4, 8 or 16 (the most WebGPU allows). Needs linear filters. */\n anisotropy?: number;\n flipY?: boolean;\n colorSpace?: TextureColorSpace3D;\n}\n\n/** A texture from the project's asset manifest. `src` is found by the asset-tracking pass and requested through the ordinary image pipeline (as a 2D image fill), so pixels are resident before the frame draws. */\nexport interface ImageTexture3D extends TextureOptions3D {\n src: string;\n}\n\n/** Raw RGBA8888 bytes: the escape hatch for procedurally generated pixels (ramps, noise, LUTs, data as colour). */\nexport interface DataTexture3D extends TextureOptions3D {\n data: ArrayLike<number>;\n width: number;\n height: number;\n /** Bump to force a re-upload after mutating `data` in place (invisible to identity comparison). See {@link BufferGeometry3D.revision}. */\n revision?: number;\n}\n\n/**\n * A texture whose pixels are Motion Script's own 2D output, rasterized offscreen: puts a chart, readout or laid-out UI\n * onto 3D geometry. `source` is a value, a built {@link Graphics2D} or a `Node2D` subtree, supplied directly with no\n * indirection or tree placement.\n *\n * g3.plane({ map: Tex.surface(scopeGraphics, 1024, 640) })\n *\n * A `Node2D` source is adopted for binding by whatever paints the scene (asset catalog, inherited context, clock, so a\n * webfont shapes and an `<Image>` loads); it is never laid out or painted by the scene tree, only measured against\n * `width` x `height` and drawn into the buffer.\n *\n * **Hoist the source.** Building it inside the scene builder allocates a new subtree every frame (re-binding,\n * re-laying-out, defeating the texture cache, leaking). A hoisted source is a stable identity, so the renderer keys\n * the GPU texture off the source object (a `WeakMap`) and a source that goes out of scope becomes collectable.\n */\nexport interface SurfaceTexture3D extends TextureOptions3D {\n /** A built `Graphics2D`, or a `Node2D` subtree (typed structurally, see {@link SurfaceSource3D}). */\n source: SurfaceSource3D;\n /** Buffer width in pixels. This *is* the texture's resolution. */\n width: number;\n height: number;\n /**\n * Declares the source's pixels unchanging, so the buffer is rasterized once and reused. Set by `resolveFill3D` for a\n * fill chain; an author's own source is live by default, so an animated `Graphics2D` or prop-driven subtree works\n * with no bookkeeping. Needs {@link identity} to be cacheable.\n *\n * @internal\n */\n static?: boolean;\n /**\n * Cache identity for a synthesized source. An author's source is identified by the object itself (right for a hoisted\n * one); a source built for a fill is fresh every frame, so the value it was derived from supplies one.\n *\n * @internal\n */\n identity?: string;\n /** Ceiling on the buffer's device-pixel ratio, default 1 (the buffer is exactly `width` x `height`). A surface is sampled at whatever size the geometry occupies, so `width`/`height` is the real control; raise this only for a surface viewed close up that reads soft. */\n maxPixelRatio?: number;\n}\n\n/** What a {@link SurfaceTexture3D} paints from: a built {@link Graphics2D} or a {@link Node2D} subtree. Both imports are type-only: `render3d` is pure data, and a value import of `Node2D` would close a real cycle. Narrow with {@link resolveSurfaceSource}. */\nexport type SurfaceSource3D = Graphics2D | Node;\n\n// Declared against the dimension-agnostic base because that is what a built node is typed as, so\n// `Tex.surface(new Rect({ ... }), ...)` type-checks without a cast. It must be 2D in fact; `resolveSurfaceSource`\n// narrows, and a `Node3D` fails at render time.\n\n/** A {@link SurfaceSource3D} narrowed to the arm its renderer should take. */\nexport type ResolvedSurfaceSource =\n | { kind: \"graphics\"; graphics: Graphics2D }\n | { kind: \"node\"; node: Node2D };\n\n/** Narrows a surface source to the arm that draws it: a `Graphics2D` is replayed into a render context, a `Node2D` is laid out against the buffer and rendered. Structural, not `instanceof` (value imports would close the cycle): `Graphics2D` exposes `ops()` and a `Node2D` doesn't. */\nexport function resolveSurfaceSource(source: SurfaceSource3D): ResolvedSurfaceSource {\n return typeof (source as Graphics2D).ops === \"function\"\n ? { kind: \"graphics\", graphics: source as Graphics2D }\n : { kind: \"node\", node: source as Node2D };\n}\n\n/** A texture reference; a bare string is sugar for `{ src }` (`map: \"/wood.png\"`). */\nexport type Texture3D = string | ImageTexture3D | DataTexture3D | SurfaceTexture3D;\n\nexport function isDataTexture3D(texture: Texture3D): texture is DataTexture3D {\n return typeof texture !== \"string\" && \"data\" in texture;\n}\n\nexport function isSurfaceTexture3D(texture: Texture3D): texture is SurfaceTexture3D {\n return typeof texture !== \"string\" && \"source\" in texture;\n}\n\nexport function resolveTexture3D(texture: Texture3D): ImageTexture3D | DataTexture3D | SurfaceTexture3D {\n return typeof texture === \"string\" ? { src: texture } : texture;\n}\n\n/** The asset `src` a texture reads from, or `null` for a data or surface texture; the asset-tracking pass uses it, and `null` means \"nothing to request\". */\nexport function texture3DSource(texture: Texture3D): string | null {\n if (typeof texture === \"string\") return texture;\n if (isDataTexture3D(texture) || isSurfaceTexture3D(texture)) return null;\n return texture.src;\n}\n\n/** True for a string that names an asset rather than a colour: a leading `/` or `.` is a path, otherwise the extension decides. A bare name like `\"wood\"` is a colour, as the manifest couldn't resolve it either. */\nexport function looksLikeAssetPath(value: string): boolean {\n return value.startsWith(\"/\")\n || value.startsWith(\".\")\n || /\\.(png|jpe?g|webp|avif|svg|ktx2?|hdr|exr|mp4|webm|mov)$/i.test(value);\n}\n"]}
@@ -26,6 +26,7 @@ export * as Aim from '../components/modules/aim.js';
26
26
  export * as Typeface from '../components/modules/text-style.js';
27
27
  export * as TextLayout from '../components/modules/text-layout.js';
28
28
  export * as Material from '../components/modules/material.js';
29
+ export * as Paint3D from '../components/modules/paint3d.js';
29
30
  export * as View3D from '../components/modules/view3d.js';
30
31
  export type { Attribute, EntryOptions, NumberOptions, TextOptions } from '../components/factory/types.js';
31
32
  export type { StyleGroups, StyleInput, StyleOptions, StyleShape, StyleValues } from '../components/factory/style.js';