mout99 Posted July 6, 2017 Share Posted July 6, 2017 Hello, I'm making a page to see 3D objects with a .obj loader, this page has a menu that, when tight, changes the scene, So I'm just changing the location of the file and the name Code: BABYLON.SceneLoader.ImportMesh("", caminho, arquivo, scene, function (newMeshes) // caminho = way // arquivo = file These values I get from a function The problem is that when I change the scene he applies the materials of the previous scene in the current scene, what am I doing wrong? $scope.load3d = function(caminho,arquivo){ $state.go('app.interna', null, {reload: true}); var canvas = document.querySelector("#renderCanvas"); var engine = new BABYLON.Engine(canvas, false); var createScene = function () { var scene = new BABYLON.Scene(engine); var light = new BABYLON.HemisphericLight("Hemi0", new BABYLON.Vector3(0, 1, 0), scene); light.diffuse = new BABYLON.Color3(1, 1, 1); light.intensity = 0.7; light.groundColor = new BABYLON.Color3(1, 1, 1); light.direction = new BABYLON.Vector3(0, -1, 0); var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 100, BABYLON.Vector3.Zero(), scene); camera.attachControl(canvas, false); BABYLON.OBJFileLoader.OPTIMIZE_WITH_UV = true; BABYLON.SceneLoader.ImportMesh("", caminho, arquivo, scene, function (newMeshes) { // caminho = way // arquivo = file var zeromat = new BABYLON.StandardMaterial("zeromat", scene); zeromat.emissiveTexture = new BABYLON.Texture("js/back2.jpg", scene); zeromat.wireframe = false; zeromat.backFaceCulling = true; newMeshes[0].material = zeromat; var meiomat = new BABYLON.StandardMaterial("meiomat", scene); meiomat.diffuseColor = new BABYLON.Color3(0.3,0.3,0.3); newMeshes[1].material = meiomat; camera.maxZ= 45000; camera.setPosition(new BABYLON.Vector3(7000,7000,7000)); camera.wheelPrecision = 0.1; }); // 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(); }); } Sorry for my english, I'm using google translate Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted July 6, 2017 Share Posted July 6, 2017 http://doc.babylonjs.com/tutorials/how_to_use_assetsmanager GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.