Skip to content

Textures

­Sollace edited this page Apr 18, 2020 · 2 revisions

Textures are a special compound object Mson defines to allow for setting up the texture mappings within a model more easily. It's used to control which part of the master texture is aligned to which part of the model, and defines both the uv (segment position) and wh (texture file dimensions) to use. Rather then having to worry about 4 (possibly more in the future) properties on the component, you have only one: Texture.

Every attribute inside the texture is optional, or course. Where not defined, these will either inherit their value from the parent component, the parent model context, or take on a default value if already working at the root.

Attributes

Attribute Name Attribute Type Default Value Description
u number {inherited, otherwise 0} The horizontal pixel coordinate of the texture, taken as a value between 0 and w. This is left edge of your texture.
v number {inherited, otherwise 0} The vertical pixel coordinate of the texture, taken as a value between 0 and h. This is top edge of your texture.
w number {inherited, otherwise 0} The expected total width of the texture file, in pixels.
h number {inherited, otherwise 0} The expected total height of the texture file, in pixels.

Notation

Textures can be specified in two ways. Both versions are the same, and can be used interchangeably throughout Mson.

Named form

Written as a json object, each attribute is named and can be defined in any order. Attributes can be excluded and will be inherited/defaulted where not defined.

{ w: 0, h: 0, u: 0, v: 0}

Array Form

Written as a json array, this form is more concise but the order cannot be changed. As is the case for any array attribute in Mson, you can define fewer elements and the remaining will be inherited/defaulted where necessary.

[ u, v, w, h ]

[ u, v, w ]

[ u, v ]

[ u ]

[ ]

Clone this wiki locally