All my models render fine but every time I try to use texture I get black screen.
Not able to replicate that on playground but I will use example part of this simple playground code to explain the issue.
I believe texture should be loaded in an async manner and update material when ready, right?
However if I run code as per playground example I get the black screen and NO errors.
// code produces black screen - no errors
const url = 'https://upload.wikimedia.org/wikipedia/commons/8/87/Alaskan_Malamute%2BBlank.png'
const mat = new StandardMaterial('dog', scene)
const texture = new Texture(url, scene)
mat.diffuseTexture = texture
const box = MeshBuilder.CreateBox('box', { size: 40 }, scene)
box.material = mat
I tried to defer assigning textures wrapping them in setTimeout
(as below) and then everything loads fine but that seems super hacky.
// works fine but feels very hacky
const url = 'https://upload.wikimedia.org/wikipedia/commons/8/87/Alaskan_Malamute%2BBlank.png'
const mat = new StandardMaterial('dog', scene)
setTimeout(() => {
const texture = new Texture(url, scene)
mat.diffuseTexture = texture
})
const box = MeshBuilder.CreateBox('box', { size: 40 }, scene)
box.material = mat
Clearly I am missing something. I would appreciate any help / suggestions.