Good day everyone, I have a simple question: I need to create static background of the scene in 3D scene, I have a .png picture.
I loading image using asset manager as texture (textureTask)
I am creating backgroundMaterial
I am trying to apply loaded texture as diffuseTexture of background material, but it’s look’s like this property awaits some another type of argument.
There is another problem, when I am trying to load image as texture, it’s provides the error:
"index.js:2178 BJS - [19:39:47]: Error while trying to load image: /game-assets/"
I am loading assets with AssetsManager, as I said:
for (let textureName in Textures) {
let task = assetsManager.addTextureTask(`${textureName}Task`, "/game-assets/backgrounds");
task.onSuccess = task => ImportedTextures[textureName] = task.texture;
}
On the other hand, I’m loading meshes with this and it’s works perfect:
for (let meshName in tiles) {
let meshOptions = tiles[meshName];
let task = assetsManager.addMeshTask(`${meshName}Task`, "", "/game-assets/tiles/", meshOptions.filename);
task.onSuccess = task => tilesMeshes[meshName] = task.loadedMeshes[0];
}
Should I transfer png image to texture somehow, before apply it to textureTask or here is another problem?
Thx for the reply, as I see layer is really a better way, but the problem is in the importing of png image as texture type.
It’s giving me useless error, I just can’t figure out what it means, it’s look like: "Hey, man, you have an error, lol "
But another question, layer constructor as well as texture constructor awaits as argument url, should I pass here in-project path to the file with file name and should it contain file extension: “image.jpg” or just “image”?