BABYLON.SceneLoader.Append(
"",
//"https://cdn.glitch.com/6887aae9-a0f6-4d7c-95b5-6736d1ee7c6a%2Fmap_d9ec16cc-067f-4d8a-b9fe-0fc9f3f0d2b1_densified_mesh_textured.obj?v=1594250333408",
//simplified tree
//"https://cdn.glitch.com/6887aae9-a0f6-4d7c-95b5-6736d1ee7c6a%2Fsimplified%20tree.obj?v=1595209538348",
//room
"https://cdn.glitch.com/6887aae9-a0f6-4d7c-95b5-6736d1ee7c6a%2F20200818_161923.obj?v=1598059231604",
scene,
function(scene) {
//texture attempt
var mat = new BABYLON.StandardMaterial("dog", scene);
mat.emissiveTexture = mat.diffuseTexture = new BABYLON.Texture("https://cdn.glitch.com/6887aae9-a0f6-4d7c-95b5-6736d1ee7c6a%2F1597792716689_0.png?v=1598404907698", scene);
var test = new BABYLON.StandardMaterial("texture", scene);
test.diffuseColor = new BABYLON.Color3(1, 0, 0); //Red
//test.alpha = 0.1; //0.3;
//six for the complex model
scene.meshes[7].material = mat; //test;
//from tree to forest
//(!)to use the new one you have to group them all together
for (var i = 0; i < 1; i++) {
const flips = [-1, 1];
function randomFlip(flips) {
return flips[Math.floor(Math.random() * flips.length)];
}
var randomX = Math.random() * 500 * randomFlip(flips);
var randomZ = Math.random() * 500 * randomFlip(flips);
var newTree = scene.meshes[7].clone();
newTree.material = mat; //test;
newTree.translate(BABYLON.Axis.X, randomX, BABYLON.Space.WORLD);
newTree.translate(BABYLON.Axis.Z, randomZ, BABYLON.Space.WORLD);
newTree.translate(BABYLON.Axis.Y, -10, BABYLON.Space.WORLD);
}
When I uncomment my other .obj mesh and apply the texture to it, it works fine, but this mesh doesn’t seem to accept the texture. I look it up in the inspector and material = null. Why won’t it accept a material, and then a texture? Advice/thoughts/troubleshooting help?