@huukhanhnguyen/model / schema/textures
schema/textures
CellInfo
CellInfo = {
cellHeight:number;cellWidth:number;k:number;localU:number;localV:number; }
cellHeight
cellHeight:
number
cellWidth
cellWidth:
number
Cell footprint in tile units — the joint test needs physical-ish distances, not cell fractions.
k
k:
number
Stable per-cell id (feeds the formula's k).
localU
localU:
number
Local coordinates 0..1 across this cell/plank (joint included).
localV
localV:
number
Formula
Formula = (
u,v,t,k) =>number
Parameters
u
number
v
number
t
number
k
number
Returns
number
ImageBuffer
ImageBuffer = {
channels:1|4;data:Float32Array;filter?:"linear"|"nearest";height:number;tileHeight?:number;tileWidth?:number;uvSet?:0|1;width:number;wrap?:"repeat"|"clamp"|"mirror"; }
channels
channels:
1|4
1 = scalar field, 4 = RGBA (0..1 floats).
data
data:
Float32Array
filter?
optionalfilter?:"linear"|"nearest"
height
height:
number
tileHeight?
optionaltileHeight?:number
tileWidth?
optionaltileWidth?:number
Physical mm of ONE tile — the chain's DECLARED lengthX/lengthY builtin parameters. Attached by evaluateTexture only when declared/ overridden; absent = the consumer's fallback applies (material tile, then 1000).
uvSet?
optionaluvSet?:0|1
width
width:
number
Pixel dimensions — rectangular tiles are first-class (a 215×65 brick face keeps square physical pixels; height derives from the declared lengthX/lengthY aspect by default). u spans 0..1 over width, v over height.
wrap?
optionalwrap?:"repeat"|"clamp"|"mirror"
Sampling — only when the chain declared wrap/filter/uvSet.
TextureScope
TextureScope = {
cache?:Map<string,ImageBuffer>;imageOf?: (url) =>TextureData|undefined;params:Record<string,number|string>;paramsOf?: (chain) =>Record<string,number|string>;textures:Chain[]; }
cache?
optionalcache?:Map<string,ImageBuffer>
Intra-resolve memo: a chain referenced from several places (a shared height feeding both color and normal) evaluates once per resolve.
imageOf?
optionalimageOf?: (url) =>TextureData|undefined
Bitmap registry for the image source — decoded pixels by url, pre-loaded OUTSIDE the sync resolve (Store scan / editor upload). Absent or unknown url → image fails with a clear error.
Parameters
url
string
Returns
TextureData | undefined
params
params:
Record<string,number|string>
The CURRENT chain's own parameter values (its parameters lane, possibly rebound by a caller's argsOverride) — a texture is a function and sees ONLY its own inputs, never the host model's parameters. Numbers feed formulas; string values (wrap/filter) are sampling-only.
paramsOf?
optionalparamsOf?: (chain) =>Record<string,number|string>
Own-parameter values for a cross-referenced sibling chain — each referenced chain evaluates with ITS OWN signature's defaults, not the referencing chain's params. Absent → referenced chains see {}.
Parameters
chain
Returns
Record<string, number | string>
textures
textures:
Chain[]
Sibling texture chains, for blend/warp/channels cross-references.