• Content Count

  • Joined

  • Last visited

  1. Hi guys I been working on a small project where I am rotation the mesh along its y axis. I am using the following to "animate" the mesh. scene.registerBeforeRender(function () { physicalbase.rotation.y += 0.01; }); Now I like to add in GUI functionality that can stop, speed or change the direction. In the code below I am trying to stop the rotation but it doesnt work. I even tried changing the direction but that too doesnt work. I will some advice help in this regards to better understand animation in BabylonJs properly and then learn how to interact with it (chaning values etc ) with the GUI var advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI"); var button1 = BABYLON.GUI.Button.CreateSimpleButton("but1", "Stop"); button1.width = "150px" button1.height = "40px"; button1.color = "white"; button1.cornerRadius = 20; button1.background = "green"; button1.onPointerUpObservable.add(function() { physicalbase.rotation.y = 0.00; }); advancedTexture.addControl(button1);
  2. WIngnut thanks for the help solved alot of my problems
  3. Hi Guys, I am working with a custom model and I am attaching child meshes to it. I am trying to rectify a problem that I am having when I add colour to the model. I lose the 3d shape, the child meshes look flat and you cant differentiate between them When I remove the colour in the material, in greyscale it looks fine. see attached pictures for comparison. Also Multi Material doesnt seem to be working as expected. The next issue I am having is the orientation of the "base modal". When I init the script its rendering the base in an angle vs being upright, as per picture. If I apply a transformation to it, it does something funky to the rest of the world co-ord mapping and everything else breaks afterwards. I am new to this and in 3d programming in general. Any insights to help me solve these 2 issues would be helpful. My code can be found on
  4. Hi JohnK here is the babylon playground link as you can see there are alot of meshes floating outside the base mesh. Im using verticesdata to get each point so theoretically all new meshes should be all within the base mesh. another slight hicup as I continue to work on this project To get the orientation correct, I transformed the base mesh using rotation tet1.rotation.z = -0.4;tet1.rotation.y = 2.5;tet1.rotation.x = 2.6;tet1.bakeCurrentTransformIntoVertices();now when I want to add in some animation using scene.beforeRender its taking the above into its calculation which is not the desired results. Once I orientate the base I just want it to spin along its y axis. If I remove the above code it spins properly but the orientation is off . zak
  5. thanks for clarifying the issue on the number of vertices. can anyone shed any light on why getVerticesData is giving me points off the model in space? Should it not all be on the model? I am very new to this. Zak
  6. JohnK I have 72 positions not 24 from the model import. Even if there was some duplication, where isnt my meshes not aligning with the base mesh vertices points ,when using data from its vertex data function
  7. Hi I am trying to do the following, Take a model in wireframe and add new meshes to its vertices. I created a simple model of 2 tetrahedrons and imported it into babylon using the raw data from the export file, using setVerticesData. It renders correctly however the next part to my project is to add meshes to each vertex point ( suppose to be 8 ), I instead get 24 points into my array when I use the function getVerticesData(BABYLON.VertexBuffer.PositionKind);In I see 8 vertices. So I am not sure why I am getting so many vertex points. The reason why I am importing the raw data is due to the fact I do not want to use a web server for this project. it must run off the browser in offline mode. see code I also attached screenshots from the playground I would like to get the correct 8 vertices to add my custom meshes to it link to model thanks zak var createScene = function () { var scene = new BABYLON.Scene(engine);var camera = new BABYLON.ArcRotateCamera("Camera", 3 * Math.PI / 2, Math.PI / 8, 50, BABYLON.Vector3.Zero(), scene);var light = new BABYLON.HemisphericLight("hemi", new BABYLON.Vector3(0, 1, 0), scene);camera.attachControl(canvas, true); // Default intensity is 1. Let's dim the light a small amount light.intensity = 0.7;var base = createBase(scene);var vertices = base.getVerticesData(BABYLON.VertexBuffer.PositionKind);createMeshAtVertices(vertices, scene)return scene;};function createBase(scene){var tet1 = new BABYLON.Mesh("base", scene); var tet1positions = [-0.009,0.1071,-0.01,-0.2019,0.7687,0.4279,0.473,0.7658,-0.0316,-0.2019,0.7687,0.4279,-0.009,0.1071,-0.01,-0.2622,0.7861,-0.3862,0.473,0.7658,-0.0316,-0.2019,0.7687,0.4279,-0.2622,0.7861,-0.3862,-0.009,0.1071,-0.01,0.473,0.7658,-0.0316,-0.2622,0.7861,-0.3862,0.009,-0.1271,0.0092,0.2622,-0.8054,0.3865,-0.473,-0.7857,0.0319,0.2019,-0.7894,-0.4276,-0.473,-0.7857,0.0319,0.2622,-0.8054,0.3865,0.2019,-0.7894,-0.4276,0.2622,-0.8054,0.3865,0.009,-0.1271,0.0092,0.2019,-0.7894,-0.4276,0.009,-0.1271,0.0092,-0.473,-0.7857,0.0319];var tet1normals = [0.5243,-0.3584,0.7725,0.5243,-0.3584,0.7725,0.5243,-0.3584,0.7725,-0.9461,-0.3177,0.0632,-0.9461,-0.3177,0.0632,-0.9461,-0.3177,0.0632,0.018,0.9996,0.02,0.018,0.9996,0.02,0.018,0.9996,0.02,0.4038,-0.3236,-0.8557,0.4038,-0.3236,-0.8557,0.4038,-0.3236,-0.8557,-0.4038,0.3249,0.8552,-0.4038,0.3249,0.8552,-0.4038,0.3249,0.8552,-0.0179,-0.9997,-0.0184,-0.0179,-0.9997,-0.0184,-0.0179,-0.9997,-0.0184,0.9461,0.3177,-0.0637,0.9461,0.3177,-0.0637,0.9461,0.3177,-0.0637,-0.5243,0.3571,-0.773,-0.5243,0.3571,-0.773,-0.5243,0.3571,-0.7734];var tet1uvs = [0.375,0.6959,0.875,0.6959,0.625,0.3041,0.875,0.6959,0.375,0.6959,0.125,0.3041,0.625,0.3041,0.875,0.6959,0.125,0.3041,0.375,0.6959,0.625,0.3041,0.125,0.3041,0.625,0.3041,0.875,0.6959,0.375,0.6959,0.125,0.3041,0.375,0.6959,0.875,0.6959,0.125,0.3041,0.875,0.6959,0.625,0.3041,0.125,0.3041,0.625,0.3041,0.375,0.6959];var indices = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23];tet1.setVerticesData(BABYLON.VertexBuffer.PositionKind, tet1positions, true);tet1.setVerticesData(BABYLON.VertexBuffer.NormalKind, tet1normals, true);tet1.setVerticesData(BABYLON.VertexBuffer.UVKind, tet1uvs, true);tet1.setIndices(indices);var material = new BABYLON.StandardMaterial("pyshical", scene);material.wireframe = true;material.diffuseColor = BABYLON.Color3.White();material.specularColor = BABYLON.Color3.White();material.emissiveColor = BABYLON.Color3.Blue();tet1.material = material;tet1.scaling = new BABYLON.Vector3(15, 15, 15);tet1.rotation.z = -0.4;tet1.rotation.y = 2.5;tet1.rotation.x = 2.6;tet1.bakeCurrentTransformIntoVertices();return tet1;};function createMeshAtVertices(vertices, scene) {var stype = 0;var shape;for (var i = 0; i < vertices.length / 3; i++ ){if(stype == 5)stype = 0;shape = BABYLON.Mesh.CreatePolyhedron("pyshical", { type: stype, size:0.5 }, scene); shape.position = BABYLON.Vector3.FromArray(vertices, i);shape.scaling = new BABYLON.Vector3(1, 1, 1);stype++;}};
  8. Hi ya ok so i figured why I was getting errors and the default export file not working in the sandbox. On the export I was using download manger to download the file. For some reason it was corrupting it. A regular save as did the trick zak
  9. Hi I am trying to figure out my why my import babylon scene file is always not found. I included it in the same location as my html files I am not running it off a web server, its running of my browser. var canvas = document.getElementById("3dCanvas"); var engine = new BABYLON.Engine(canvas, true); var scene; BABYLON.SceneLoader.Load("", "t.babylon", engine, function (newScene){ scene = newScene; var c = scene.getMeshByName("tetrahedron"); //Do what you want });XMLHttpRequest cannot load file:///C:/Users/zmm/lifeprint/new/t.babylon.manifest?1448032895642. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.t.checkManifestFile @ babylon.js:2babylon.js:3 XMLHttpRequest cannot load file:///C:/Users/zmm/lifeprint/new/t.babylon. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.h @ babylon.js:3babylon.js:3 Uncaught Error: Error status: 0 - Unable to load t.babylon
  10. Hi I am new to Babylon and 3d modelling in general. I manage to get the basics down. I am trying to export a basic model into babylon however it never seems to initialize. I tried the same import file in the babylon sandbox and get the same black scene with the loading circle. My scene in is pretty simple, its an upside down tetrahedron. I also tried exporting it to blend and I get some error. Any ideas on what I could be doing wrong? thanks zak