cancel
Showing results for 
Search instead for 
Did you mean: 

How to change appearance(baseColorTexture) of a preload glb runtime?

BigMac1771
Honored Guest
Im a beginner in 3D development. I import a glb object into environment.env with predefined textures(baseColorTexture, normalTexture, occlusionTexture), and I try to change the appearance(runtime) when clicking buttons.
 
Here are my code,  but It didn't work to change the texture (baseColor or baseColorTexture).
 
Is there anyone could help me? Thank you very much.

private fun changeMaterial(node : SceneObject) {
        val material = node.mesh?.materials?.get(0)
        var mesh = node.mesh
        var meshMaterial = node.mesh?.getMaterial(0) as SceneMaterial
        var test_texture = SceneTexture(activity.getDrawable(R.drawable.test_texture))
       //var texture_name = "baseColor" //--> exception: baseColor not found
        var texture_name = "occlusion" //--> worked and texture is changed
        meshMaterial.setTexture(texture_name, test_texture)
}
0 REPLIES 0