joeBImagine

Members
  • Content count

    14
  • Joined

  • Last visited

  1. Hello BabylonJs peeps!! I am currently able to select and deselect a mesh using actions and triggers as seen in this included playground: http://www.babylonjs-playground.com/#WG9OY#9. I am curious however if there is a way to deselect the mesh if you click anywhere in the scene or even on another mesh Also when I create the same code using an array of meshes, I get errors. I thought wrapping the solution into a for loop would work, but alas I think I am missing something. for (i = 0; i < newMeshes.length; i++) { //select the meshes in the scene newMeshes[i].actionManager = new BABYLON.ActionManager(scene); var hl1 = new BABYLON.HighlightLayer("hl1", scene); const action1 = new BABYLON.ExecuteCodeAction( BABYLON.ActionManager.OnPickTrigger, () => { hl1.addMesh(newMeshes[i], BABYLON.Color3.White()); } ); const action2 = new BABYLON.ExecuteCodeAction( BABYLON.ActionManager.OnPickTrigger, () => { hl1.removeMesh(newMeshes[i]); } ); newMeshes[i].actionManager.registerAction(action1).then(action2); }
  2. Issue with BABYLON.SceneLoader.Load

    const newMeshes = newScene.meshes; newMeshes[0].scaling = new BABYLON.Vector3(0.1, 0.1, 0.1); newMeshes[0].position.y = 0; Mr_Pinc you were right. newScene.meshes worked, than you for the help!!!
  3. Issue with BABYLON.SceneLoader.Load

    I actually got the debugger to work (should have been newScene and not just scene). But I am still slightly confused on the scene.meshes part.
  4. Issue with BABYLON.SceneLoader.Load

    Just for clarity I can take scene.meshes (or in this case newScene.meshes) and get the meshes that are in the scene and wrap them in an array for later use? Also do you know why the debugger doesn't work with this method?
  5. Hello! I am having an issue with BABYLON.SceneLoader.Load. I am able to initialize a file from a local directory no problem. However, unlike BABYLON.SceneLoader.ImportMesh, which puts the imported meshes into an array, I have no clue what the mesh names would be or how to access them. I am also for some reason, unable to initialize the debug layer (It works fine when I create the scene using ImportMesh). The reason I am using SceneLoader.Load instead of SceneLoader.ImportMesh, is because I want each time someone clicks on "New Scene" in the html Navigation, it creates a new scene. if (BABYLON.Engine.isSupported()) { const canvas = document.getElementById('renderCanvas'); const engine = new BABYLON.Engine(canvas, true); const inputElement = document.getElementById('fileUpload'); inputElement.addEventListener( 'change', function handleFiles(event) { const fileList = this.files[0]; const reader = new FileReader(); reader.addEventListener('loadend', () => { let data = reader.result; BABYLON.SceneLoader.Load( '', 'data:' + data, engine, function(newScene) { // Wait for textures and shaders to be ready newScene.executeWhenReady(function() { var camera = new BABYLON.ArcRotateCamera( 'ArcRotateCamera', 0, 0, 0, BABYLON.Vector3.Zero(), newScene ); camera.setPosition(new BABYLON.Vector3(0, 0, -3)); newScene.activeCamera = camera; newScene.activeCamera.attachControl(canvas); newScene.clearColor = new BABYLON.Color3(1, 1, 1); let light0 = new BABYLON.HemisphericLight('Hemi0', new BABYLON.Vector3(0, 1, 0), newScene); light0.intensity = 0.7; light0.diffuse = new BABYLON.Color3(1, 1, 1); light0.specular = new BABYLON.Color3(0, 0, 0); light0.groundColor = new BABYLON.Color3(0, 0, 0); let light1 = new BABYLON.HemisphericLight('Hemi1', new BABYLON.Vector3(0, -1, 0), newScene); light1.intensity = 0.7; light1.diffuse = new BABYLON.Color3(1, 1, 1); light1.specular = new BABYLON.Color3(0, 0, 0); light1.groundColor = new BABYLON.Color3(0, 0, 0); // Once the scene is loaded, just register a render loop to render it engine.runRenderLoop(function() { newScene.render(); }); window.addEventListener('resize', () => { engine.resize(); }); }); }, function(progress) {} ); }); reader.readAsText(fileList); }, false ); }
  6. Understanding FilesInput Class

    Awesome thank you Delta!! You are boon of knowledge!!
  7. I am trying to wrap my head around the differences. Currently I do understand ImportMesh for the most part (allows you to import a mesh into an existing scene)and how to create a scene, but FilesInput not so much. Are there any examples (for noobs!) that go into more detail than the documentation? I have looked at the sandbox version with filesInput, but that does not show a babylon file unless said babylon files has lights and cameras. And as always, please forgive me if this question has already been asked and answered!
  8. Custom textures on blender file from 3ds max

    Good to know thank you!! I am still green to this!! But I am loving babylon!
  9. Custom textures on blender file from 3ds max

    I finally got it!! it should have been: newMeshes[2].material = customMaterial1; as the function newMeshes was the array where my meshes were being held!! var meshVar = BABYLON.SceneLoader.ImportMesh("","scenes/31375_ElliotFabricMicrofiber2PieceSectionalSofa_Graphite/test/", "ElliotMicrofiber2PieceSectionalSofa.babylon", scene, function(newMeshes) { camera.target = newMeshes[0]; var customMaterial1 = new BABYLON.StandardMaterial("fabric", scene); customMaterial1.diffuseTexture = new BABYLON.Texture("scenes/31375_ElliotFabricMicrofiber2PieceSectionalSofa_Graphite/test/fabric.dif.jpg", scene); newMeshes[2].material= customMaterial1; } ); Thank you again for the help!! In the future if a live repo is needed, would I need to add the code to a github repo? Or an actual live server?
  10. Custom textures on blender file from 3ds max

    No error message:
  11. Custom textures on blender file from 3ds max

    Hello Deltakosh!! Thank you for the reply. I have installed the debugger and I am getting this as the names under mesh (the first name is the group/parent): 31375_ElliotFabricMicrofiber2PieceSectionalSofa ElliotFabricMicrofiber2PieceSectionalSofa_Graphite_Legs001 ElliotFabricMicrofiber2PieceSectionalSofa_Graphite_Base001 I've updated the code to reflect the name in the debugger: var meshVar = BABYLON.SceneLoader.ImportMesh("","scenes/31375_ElliotFabricMicrofiber2PieceSectionalSofa_Graphite/test/", "ElliotMicrofiber2PieceSectionalSofa.babylon", scene, function(newMeshes) { camera.target = newMeshes[0]; var customMaterial1 = new BABYLON.StandardMaterial("fabric", scene); customMaterial1.diffuseTexture = new BABYLON.Texture("scenes/31375_ElliotFabricMicrofiber2PieceSectionalSofa_Graphite/test/fabric.dif.jpg", scene); ElliotFabricMicrofiber2PieceSectionalSofa_Graphite_Base001.material = customMaterial1; } ); I've even tried: meshVar.material = customMaterial1; But still nothing. The texture is definitely there however: I am not sure what I am doing wrong and/or missing.
  12. Hello Babylon aficionados!! I was hoping you all would be able to help. I am not sure what I am doing wrong, but I am trying to attach a custom texture to a babylon file I exported from 3ds max. This is the error in the console: babylon.js:3 BJS - [06:55:16]: Babylon.js engine (v3.0) launched babylon.js:3 BJS - [06:55:17]: Material not found for mesh fc4bd914-849c-4954-9f0c-8c25b763cecb t._WarnEnabled @ babylon.js:3 importMesh @ babylon.js:28 m @ babylon.js:28 (anonymous) @ babylon.js:28 a.oncomplete @ babylon.js:29 babylon.js:3 BJS - [06:55:17]: Material not found for mesh 6569d8e7-4fbc-478c-af4f-dbe31c4db185 t._WarnEnabled @ babylon.js:3 importMesh @ babylon.js:28 m @ babylon.js:28 (anonymous) @ babylon.js:28 a.oncomplete @ babylon.js:29 Which I understand, but I do not understand why using Babylon.Standardmaterial is not working. Here is the javascript code. Let me know if anything else is needed to diagnose!! var canvas, engine, createScene, scene, light, camera, sphere, box; canvas = document.querySelector("#renderCanvas"); engine = new BABYLON.Engine(canvas, true); createScene = function() { scene = new BABYLON.Scene(engine); scene.clearColor = new BABYLON.Color3(0.85, 0.85, 0.85); scene.ambientColor = new BABYLON.Color3(0.75, 0.75, 0.75); //var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene); camera = new BABYLON.ArcRotateCamera("camera1", 0, 0, 10, new BABYLON.Vector3.Zero(0, 0, 0), scene); //camera.radius = 5000; camera.setPosition(new BABYLON.Vector3(0, 5000, -10)); camera.setTarget(BABYLON.Vector3.Zero(0, 5000, 0)); camera.attachControl(canvas, true); camera.wheelPrecision = .1; light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene); light.intensity = 1.0; sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 500, scene); //var box = BABYLON.Mesh.CreateBox("box", 6.0, scene, false, BABYLON.Mesh.DEFAULTSIDE); sphere.position.y = 1; //var ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene); var meshVar = BABYLON.SceneLoader.ImportMesh("","scenes/31375_ElliotFabricMicrofiber2PieceSectionalSofa_Graphite/test/", "ElliotMicrofiber2PieceSectionalSofa.babylon", scene, function(newMeshes) { camera.target = newMeshes[0]; var customMaterial = new BABYLON.StandardMaterial("customMaterial", scene); customMaterial.diffuseTexture = new BABYLON.Texture("scenes/31375_ElliotFabricMicrofiber2PieceSectionalSofa_Graphite/test/fabric.dif.jpg", scene); var customTexture = scene.meshes[0]; customTexture.material = customMaterial; } ); sphere.dispose(); return scene; }; scene = createScene(); engine.runRenderLoop(function() { scene.render(); }); window.addEventListener("resize", function() { engine.resize(); });
  13. Multi sub like materials

    Awesome!! Thank you! Please forgive the late reply. I will definitely check this out!1
  14. Multi sub like materials

    Hello all!! I was curious whether or not there is a multi-sub material in babylon similar to to the one in 3ds max that allows you to place texture based off of material id. I ask because I am creating a viewer that allows for changing the materials of furniture. So say I have fabric on the sofa, and wood on the legs, and I want to change both separately with a procedural texture. Is that possible in a .babylon mesh exported from max? Or should they be exported separately or as an .obj/.fbx? Cheers and thank you in advance. Also please forgive me if this question has already been addressed.