Add a uvs array property to SceneJS.Geometry to accept an array of UV arrays, so that we can have an unlimited number of UV layers.
API Changes
Deprecate uv, uv2 and uv3 properties and their accessors.
Add setUVs and getUVs accessors.
See constructor config changes in example below. Note that SceneJS.Texture nodes can still use the same applyTo values of uv, uv2, uv3 etc, where those will reference uvs sub-arrays.
When uv, uv2 or uv3 are supplied, the Geometry will internally convert those into a uvs property, which will be accessible via getUVs.
The existing getUV, getUV2, getUV3, setUV, setUV2 and setUV3 accessors will internally access subarrays of the uvs property.
UV attributes in shaders will be named SCENEJS_aUVCoord0, SCENEJS_aUVCoord1, SCENEJS_aUVCoord<n> for UV layers 0...n.
var uvs = geometry.getUVs(); // Returns 3D array
//...
geometry.setUVs([ // Sets a 3D array
[.....], // Layer 1
[.....], // Layer 2
[.....], // Layer 3
//....etc
]);
Internal changes
Add uvs property to Geometry render states.
Handle inheritance of UV layers within nested Geometry nodes in the scene node hierarchy (ie. for vertex sharing).
Shader composition in programSourceFactory will need to loop over uvs to create shader UV code blocks.
Shader composition also needs to be generalized here to allow unlimited UV layer indexing by TextureapplyFrom.
Extend triangle picking logic to return an interpolated UV coordinate from each layer. For efficiency, possibly need to pass in a mask when picking to specify whether we want the UVs in the result, but then that would need to be applied for all pick result components, and changes API, so that needs discussion.
Change validation of SceneJS.TextureapplyFrom to allow more UV indices than just uv, uv2, uv3 etc.
Add a
uvs
array property toSceneJS.Geometry
to accept an array of UV arrays, so that we can have an unlimited number of UV layers.API Changes
uv
,uv2
anduv3
properties and their accessors.setUVs
andgetUVs
accessors.See constructor config changes in example below. Note that
SceneJS.Texture
nodes can still use the sameapplyTo
values ofuv
,uv2
,uv3
etc, where those will referenceuvs
sub-arrays.When
uv
,uv2
oruv3
are supplied, theGeometry
will internally convert those into auvs
property, which will be accessible viagetUVs
.The existing
getUV
,getUV2
,getUV3
,setUV
,setUV2
andsetUV3
accessors will internally access subarrays of theuvs
property.UV attributes in shaders will be named
SCENEJS_aUVCoord0
,SCENEJS_aUVCoord1
,SCENEJS_aUVCoord<n>
for UV layers 0...n.Example
Accessor changes:
Internal changes
uvs
property toGeometry
render states.uvs
to create shader UV code blocks.Texture
applyFrom
.SceneJS.Texture
applyFrom
to allow more UV indices than justuv
,uv2
,uv3
etc.