eucly2

Members
  • Content Count

    34
  • Joined

  • Last visited

Everything posted by eucly2

  1. You are amazing!!! All work perfectly (I can die in peace now ) Thank you so much for this
  2. Ok it's work, positions, normals and uvs are good, but there is one curious problem. When i change the scale of a new mesh, the scale is good but it move too. You can see the problem on my joins file or on this PG : http://www.babylonjs-playground.com/#1WYYET#4
  3. Hi! Thanks for your answer. That is exactly what i want to do: http://www.babylonjs-playground.com/#1WYYET#2 It's work on the PG so I hope it will work on my project, I try tomorrow on it and I will tell you the result. Thanks DK and JohnK.
  4. Sorry but it doesn't work. With your code, for example, if the size of my indices array is 132 the for loop put 132 values in the positions array instead of 396 (132 x 3)
  5. Hey everyone! I'm trying to extract VerticeData from a SubMesh to create an other mesh but i always failed. I want to extract indices, positions, normals and uvs for the moment: Indices: var result = new VertexData(); var indices = subMesh.getMesh().getIndices(); for (var index = subMesh.indexStart; index < subMesh.indexStart + subMesh.indexCount; index++) { result.indices.push(indices[index]); } Positions and normals: var positions = subMesh.getMesh().getVerticesData(BABYLON.VertexBuffer.PositionKind, copyWhenShared); var vertex; for (var index = subMesh.indexStart; index < subMesh.indexStart + subMesh.indexCount; index+=3) { vertex = new BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(positions[index], positions[index + 1], positions[index + 2]), worldMatrix); result.positions.push(vertex.x); result.positions.push(vertex.y); result.positions.push(vertex.z); } Anyone to help me?
  6. Set the position of the probes, why not... But if meshes are in the box, the reflection render all the meshes : http://www.babylonjs-playground.com/#KA93U#26 Maybe adding scaling properties on probe will be better...
  7. Thanks a lot for this Deltakosh, that is just wooow !! I have questions about that: Why reflections on geometry like a box are so big and not on sphere? http://www.babylonjs-playground.com/#KA93U#24 So is it possible to reduce the reflection? For marble texture it's very awsome...
  8. Done! I make a pull request on arcRotateCamera. Can you take a look?
  9. I up this topic because I'm very interested in it too. hand.js can help for this, no?
  10. I think in BabylonJS the shadows generator use dynamics shadows and that is expensive but in the scene "The train" the shadows are include in the textures (painting when they have create the scene in 3dsMax for example). That why is an optimized scene.
  11. I think we need a new type of camera for translation and with it we can switch to another camera typed of translation when rightmousedown event fired...
  12. Hi! I make a web page with your file. In this page you can change texture and color of all your meshes in your babylon file: <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Using babylon.js - How to load a scene</title> <script src="babylon.js"></script> <style> html, body { width: 100%; height: 100%; padding: 0; margin: 0; overflow: hidden; } #renderCanvas { width: 100%; height: 100%; } </style> </head> <body> <select onchange='changeColor(this.value);'> <option value='0'>Red</option> <option value='1'>Blue</option> <option value='2'>Green</option> </select> <select onchange='changeTexture(this.value);'> <option value='texture/texture1.jpg'>texture1</option> <option value='texture/texture2.jpg'>texture2</option> <option value='texture/texture3.jpg'>texture3</option> </select> <script> function changeTexture(texture) { var allMeshChange = false; var i = 0; while (!allMeshChange) { if (scene.meshes[i].material.diffuseTexture) scene.meshes[i].material.diffuseTexture.dispose(); scene.meshes[i].material.diffuseTexture = new BABYLON.Texture(texture, scene); allMeshChange = i == scene.meshes.length - 1; i++; } } function changeColor(number) { var allMeshChange = false; var i = 0; var color; switch (number) { case '0':// Red color = new BABYLON.Color3(1, 0, 0); break; case '1':// Blue color = new BABYLON.Color3(0, 0, 1); break; case '2':// Green color = new BABYLON.Color3(0, 1, 0); break; case '3':// Purple color = new BABYLON.Color3(1, 0, 1); break; } while (!allMeshChange) { scene.meshes[i].material.diffuseColor = color; allMeshChange = i == scene.meshes.length - 1; i++; } } </script> <canvas id="renderCanvas"></canvas> <script> var scene; if (BABYLON.Engine.isSupported()) { var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); BABYLON.SceneLoader.Load("", "test2.babylon", engine, function(newScene) { newScene.executeWhenReady(function() { newScene.activeCamera.attachControl(canvas); scene = newScene; engine.runRenderLoop(function() { newScene.render(); }); }); }, function(progress) { }); } </script> </body></html>And your textures are in a folder named "texture" I can't do anything else I hope it's will be good for you.
  13. With my last code and personnals textures I can change texture of your mesh dynamicaly: Texture 1: Texture 2: Texture 3: Texture 4: The right select is the second
  14. Can you give me some picture of what you have with my code and what you want please.
  15. You have to create a folder in your web project named "texture" for example, in this folder you put all your texture that you what ("texture1.jpg", "texture2.jpg"...) and after you create your html select like this: <select onchange='changeTexture(this.value);'> <option value='texture/texture1.jpg'>texture1</option> <option value='texture/texture2.jpg'>texture2</option> <option value='texture/texture3.jpg'>texture3</option> <option value='texture/texture4.jpg'>texture4</option></select>And finally you change the changeTexture method like this: function changeTexture(texture) { var allMeshChange = false; var i = 0; while(!allMeshChange){ if(scene.meshes[i].material.diffuseTexture) scene.meshes[i].material.diffuseTexture.dispose(); scene.meshes[i].material.diffuseTexture = new BABYLON.Texture(texture, scene); allMeshChange = i == scene.meshes.length - 1; i++; } }Normaly that will work
  16. That is exactly what I want to say. But Temechon say it better than me
  17. Hi Abhay, The correct code for you is this : <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Using babylon.js - How to load a scene</title> <script src="babylon.js"></script> <style> html, body { width: 100%; height: 100%; padding: 0; margin: 0; overflow: hidden; } #renderCanvas { width: 100%; height: 100%; } </style> </head> <body> <select onchange='changeTexture(this.value);'> <option value='0'>texture1</option> <option value='1'>texture2</option> <option value='2'>texture3</option> <option value='3'>texture4</option> </select> <select onchange='changeColor(this.value);'> <option value='0'>Red</option> <option value='1'>Blue</option> <option value='2'>Green</option> <option value='3'>Purple</option> </select> <script> function changeTexture(number) { var allMeshChange = false; var i = 0; while(!allMeshChange){ scene.meshes[i].material = scene.materials[number]; allMeshChange = i == scene.meshes.length - 1; i++; } } function changeColor(number) { var allMeshChange = false; var i = 0; var color; switch(number){ case '0':// Red color = new BABYLON.Color3(1,0,0); break; case '1':// Blue color = new BABYLON.Color3(0,0,1); break; case '2':// Green color = new BABYLON.Color3(0,1,0); break; case '3':// Purple color = new BABYLON.Color3(1,0,1); break; } while(!allMeshChange){ scene.meshes[i].material.diffuseColor = color; allMeshChange = i == scene.meshes.length - 1; i++; } } </script> <canvas id="renderCanvas"></canvas> <script> var scene; if (BABYLON.Engine.isSupported()) { var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); BABYLON.SceneLoader.Load("", "test2.babylon", engine, function(newScene) { newScene.executeWhenReady(function() { newScene.activeCamera.attachControl(canvas); scene = newScene; engine.runRenderLoop(function() { newScene.render(); }); }); }, function(progress) { }); } </script> </body></html>But I think you have a problem with Blender export because your test1.babylon have 4 material but with no texture in, so the html select change the material on all meshes but no texture appear... In this code I put an html select to change the color of your meshe and that work.
  18. All your texture are in the JS Array BabylonScene.materials so I suggest to you to do something like this: <select onchange='changeTexture(this.value);'> <option value='0'>texture1</option> <option value='1'>texture2</option> <option value='2'>texture3</option> <option value='3'>texture4</option></select><script type="text/javascript"> var canvas; var engine; var scene; $(document).ready(function() { if (BABYLON.Engine.isSupported()) { canvas = document.getElementById("renderCanvas"); engine = new BABYLON.Engine(canvas, true); BABYLON.SceneLoader.Load("", "test1.babylon", engine, function (newScene) { newScene.executeWhenReady(function () { newScene.activeCamera.attachControl(canvas); scene = newScene; engine.runRenderLoop(function() { newScene.render(); }); }); }, function (progress) { }); } }); function changeTexture(number){ myMesh.material= scene.materials[number]; } </script>That should work. If not, can you send me your test1.babylon please.
  19. Hi, I have never use Blender ^^ But if you say "i have a blender exported file & texture is in that file" and if that is possible I think you should have your texture (material) loaded when you load your file. So can you execute this script to load your file : if (BABYLON.Engine.isSupported()) { var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); BABYLON.SceneLoader.Load("", "test1.babylon", engine, function (newScene) { newScene.executeWhenReady(function () { newScene.activeCamera.attachControl(canvas); alert("Nb materials : " + newScene.materials.length); alert("Nb textures : " + newScene.textures.length); engine.runRenderLoop(function() { newScene.render(); }); }); }, function (progress) { });}and say me how many materials and texture you have. If I'm good, you have to do this: <select onchange='changeTexture(this.value);'> <option value='0'>texture1</option> <option value='1'>texture2</option> <option value='2'>texture3</option></select><script> function changetexture(number){ // this if you have more material than 1 myMesh.material= scene.materials[number]; // or this if you have more texture than 1 and material = 1 // myMesh.material.diffuseTexture = scene.textures[number]; } </script>
  20. Yes before changing texture we have to dispose the actual texture if it's existing to free memory space. Thanks Temechon for this add.
  21. Hi Abhay! I think you have to add an onchange event on your dropdownlist. In this event you excute a function with texture name parameter like this: onchange = 'changeTextture(this.value);'and your changeTexture function look like this: function changetexture(textureName){ myMesh.material.diffuseTexture = new BABYLON.Texture(textureName, scene);}finally you should have something like this : <select onchange='changeTexture(this.value);'> <option value='texture/texture1.jpg'>texture1</option> <option value='texture/texture2.jpg'>texture2</option> <option value='texture/texture3.jpg'>texture3</option></select><script> function changetexture(textureName){ myMesh.material.diffuseTexture = new BABYLON.Texture(textureName, scene); } </script>I hope you understand what I mean...