Search the Community
Showing results for tags 'babylonjjs'.
-
Hello, I have a .obj and I'm trying to change the color of it with the material, but this color change works only when I take the .mtl file, what can it be? I noticed that I change the color below .obj // Get the canvas element from our HTML below var canvas = document.querySelector("#renderCanvas"); // Load the BABYLON 3D engine var engine = new BABYLON.Engine(canvas, false); // ------------------------------------------------------------- // Here begins a function that we will 'call' just after it's built var createScene = function () { var scene = new BABYLON.Scene(engine); //Adding a light var light = new BABYLON.HemisphericLight("Hemi0", new BABYLON.Vector3(0, 1, 0), scene); light.diffuse = new BABYLON.Color3(1, 1, 1); light.intensity = 0.8; light.groundColor = new BABYLON.Color3(1, 1, 1); light.direction = new BABYLON.Vector3(0, -1, 0); //Adding an Arc Rotate Camera var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 100, BABYLON.Vector3.Zero(), scene); camera.attachControl(canvas, false); // The first parameter can be used to specify which mesh to import. Here we import all meshes BABYLON.SceneLoader.ImportMesh("", "js/novo/", "edifício sem texturaas.obj", scene, function (newMeshes) { BABYLON.OBJFileLoader.OPTIMIZE_WITH_UV = true; var zeromat = new BABYLON.StandardMaterial("zeromat", scene); zeromat.diffuseColor = new BABYLON.Color3(1,1,1); zeromat.wireframe = false; zeromat.backFaceCulling = true; scene.meshes[0].material = zeromat; // var alltextura = new BABYLON.StandardMaterial("alltextura", scene); // alltextura.backFaceCulling = false; // scene.meshes.material = alltextura; var meiomat = new BABYLON.StandardMaterial("meiomat", scene); meiomat.diffuseColor = new BABYLON.Color3(0.2, 0.2, 0.2); scene.meshes[1].material = meiomat; // Set the target of the camera to the first imported mesh camera.setPosition(new BABYLON.Vector3(8000,8000,8000)); // camera.target = newMeshes[0]; camera.wheelPrecision = 0.1; camera.maxZ= 45000; }); // Move the light with the camera scene.registerBeforeRender(function () { }); return scene; } var scene = createScene(); // Register a render loop to repeatedly render the scene engine.runRenderLoop(function () { scene.render(); }); // Watch for browser/canvas resize events window.addEventListener("resize", function () { engine.resize(); }); edifício sem texturaas.obj edifício_sem_texturaas.mtl