I want to dynamically set the material of the model, and a solution is to modify the UVs of the vertices at runtime. What can I do to modify vertex UV values
Why are you trying to modify vertex UV values to change a material? The
SetMaterial Blueprint exists; you can iterate over all of the
CesiumGltfPrimitiveComponents of a
Cesium3DTileset and change their material. There is also a
SetMaterial Blueprint on the
If you really don’t want to call this function, then at least change a parameter of the material itself instead of modifying UVs. For example, you can create a scalar parameter, then use
SetScalarParameterValue to set it. Changing the UVs can break some features of the
Cesium3DTileset, including textures, feature IDs, and raster overlays.
OK, What I ultimately achieved was highlighting multiple objects by clicking with the mouse. Actually, I pass a new texture as a parameter to the material to do this. I didn’t find a suitable opportunity to pass this parameter to the material of CesiumGltfPrimitiveComponent. Is there a synchronized event notification external when Cesium generates CesiumGltfPrimitiveComponent, so that newly created CesiumGltfPrimitiveComponents can also apply this texture parameter? Alternatively, provide interface to set parameter before SetMaterial. I cannot call SetMaterial of Cesium3DFileset to modify the material, as this will cause the entire scene to refresh.
There’s no event when a new
CesiumGltfPrimitiveComponent is created. But you can use GetComponents on the
Cesium3DTileset to get all the primitive instances and get or set the material on each.