deni Posted October 9, 2014 Share Posted October 9, 2014 I'm using the babylonjs 3D WebGL library. It's great library, but I can't find the same, which exists in THREE.JS library. For example, I have 2D polygons in database, I'm fetching the polygon data from it and then create a custom mesh and extruding it. With the THREE.JS, there isn't any problem, I can add to some array: ... points.push( new THREE.Vector2( part.x, -part.y ) ); ... var shape = new THREE.Shape( points ); var extrusion = { amount: building.height, bevelEnabled: false }; var geometry = new THREE.ExtrudeGeometry( shape, extrusion ); var mesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial({ ambient: 0xbbbbb, color: 0xff0000 }); ... scene.add( mesh );It's very simple. How to do the same, I couldn't find. I've found only some information here: - http://www.html5gamedevs.com/topic/4530-create-a-mesh-from-a-list-of-vertices-and-faces/ - http://blogs.msdn.com/b/eternalcoding/archive/2013/06/27/babylon-js-a-complete-javascript-framework-for-building-3d-games-with-html-5-and-webgl.aspx With such an example (from msdn by Ctrl + F -> `You can also create a mesh from a list of vertices and faces`): var plane = new BABYLON.Mesh(name, scene); var indices = []; var positions = []; var normals = []; var uvs = []; // Vertices var halfSize = size / 2.0; positions.push(-halfSize, -halfSize, 0); normals.push(0, 0, -1.0); uvs.push(0.0, 0.0); positions.push(halfSize, -halfSize, 0); normals.push(0, 0, -1.0); uvs.push(1.0, 0.0); positions.push(halfSize, halfSize, 0); normals.push(0, 0, -1.0); uvs.push(1.0, 1.0); positions.push(-halfSize, halfSize, 0); normals.push(0, 0, -1.0); uvs.push(0.0, 1.0); // Indices indices.push(0); indices.push(1); indices.push(2); indices.push(0); indices.push(2); indices.push(3); plane.setVerticesData(positions, BABYLON.VertexBuffer.PositionKind); plane.setVerticesData(normals, BABYLON.VertexBuffer.NormalKind); plane.setVerticesData(uvs, BABYLON.VertexBuffer.UVKind); plane.setIndices(indices); return plane;But's it's rather not the same as with the THREE.JS. For example I need to count index buffer manually where in THREE.JS I don't need it, also it's a sample with plane only and I didn't find any info about extruding exactly. So... Maybe, there are some easy ways in BabylonJS? Ahiru 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 9, 2014 Share Posted October 9, 2014 Hello this is something not yet supported but it was added to the roadmap Quote Link to comment Share on other sites More sharing options...
deni Posted August 30, 2015 Author Share Posted August 30, 2015 Hello this is something not yet supported but it was added to the roadmapWhat's about right now? Has such possibilities appeared in BabylonJs? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 31, 2015 Share Posted August 31, 2015 Yes sir:) http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion Ahiru 1 Quote Link to comment Share on other sites More sharing options...
Ahiru Posted August 31, 2015 Share Posted August 31, 2015 This link: http://www.babylonjs-playground.com/#295H7U#4 throws a compilation error: Compilation errorCannot read property 'subtract' of undefined Quote Link to comment Share on other sites More sharing options...
jerome Posted August 31, 2015 Share Posted August 31, 2015 mmhh.. It seems related to a temporary bug due to the new normal computation along the seam. I will fix it soon Quote Link to comment Share on other sites More sharing options...
Ahiru Posted August 31, 2015 Share Posted August 31, 2015 So, I guess that in this Scene it's the same problem? http://www.babylonjs-playground.com/#RF9W9#4 Quote Link to comment Share on other sites More sharing options...
jerome Posted August 31, 2015 Share Posted August 31, 2015 yepprobably, everywhere where the ribbon is used with closePath set to true (I couldn't remember if it was the case on the extrusion, but maybe)You could use ExtrudeShapeCustom meanwhile to get sure the closePath parameter is set to false. I wished I could fix this today but I was too busy at work to find a little time to do it. Sorry.I wish I can do it tomorrow. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 31, 2015 Share Posted August 31, 2015 Jerome is back from holiday..Hurrah Wingnut 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted August 31, 2015 Share Posted August 31, 2015 mouarf BTW, for french readers, an article about BJS in this pro magazine (nothing you don't already know actually) : http://www.programmez.com/magazine/article/la-3d-sur-le-web-avec-babylonjs Temechon 1 Quote Link to comment Share on other sites More sharing options...
adam Posted August 31, 2015 Share Posted August 31, 2015 Yes! Jerome is back! 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.