JKoehoorn Posted May 22, 2015 Share Posted May 22, 2015 I added extrusion to your code. it's a optional parameter and works with holes to.see https://github.com/BabylonJS/Babylon.js/pull/522 NasimiAsl and c75 2 Quote Link to comment Share on other sites More sharing options...
MauJovi Posted May 3, 2016 Share Posted May 3, 2016 So, how is it going? I want to create polygons by points and extrude them. What's the syntax? I only found the example with the big string... Is there a way like: Mesh.addPoint, so I can do simple loop to create it... Thanks Quote Link to comment Share on other sites More sharing options...
JKoehoorn Posted May 3, 2016 Share Posted May 3, 2016 var contour = BABYLON.Polygon.Parse(PointsData); contour.push(point) var b = new BABYLON.PolygonMeshBuilder(name, contour, scene); You could push points into the contour and then create tour polygon. Job MauJovi 1 Quote Link to comment Share on other sites More sharing options...
MauJovi Posted May 3, 2016 Share Posted May 3, 2016 5 hours ago, JKoehoorn said: var contour = BABYLON.Polygon.Parse(PointsData); contour.push(point) var b = new BABYLON.PolygonMeshBuilder(name, contour, scene); You could push points into the contour and then create tour polygon. Job What I couldn't understand before was that backslash in the string, but i realized its function was to concatenate. lol. Didn't find it good, cause it makes to lose the indenting. Anyway, thank you. Quote Link to comment Share on other sites More sharing options...
MauJovi Posted May 3, 2016 Share Posted May 3, 2016 By the way, i was talking about this example http://www.babylonjs.com/Demos/Polygon/polygon.js Quote Link to comment Share on other sites More sharing options...
MauJovi Posted May 12, 2016 Share Posted May 12, 2016 I'm getting the "e.equalsWithEpsilon is not a function" error. My code: var contour = BABYLON.Polygon.Parse(''); for(var i in this.arrEstandes2) { this.arrEstandes2[i]['pontos'] = jQuery.parseJSON(this.arrEstandes2[i]['pontos']); for(var j in this.arrEstandes2[i]['pontos']) { contour.push(this.arrEstandes2[i]['pontos'][j].replace(',', ' ')); } break; } var poly = new BABYLON.PolygonMeshBuilder('polygon', contour, this.scene); poly.build(); poly.material = new BABYLON.StandardMaterial("mat", scene); Am I not including something? Babylon and poly2tri are on... Thanks Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 12, 2016 Share Posted May 12, 2016 poly2tri is an external file and is not in Babylon. You'll find it here: https://github.com/BabylonJS/Babylon.js/tree/master/dist Quote Link to comment Share on other sites More sharing options...
MauJovi Posted May 12, 2016 Share Posted May 12, 2016 12 hours ago, Dad72 said: poly2tri is an external file and is not in Babylon. You'll find it here: https://github.com/BabylonJS/Babylon.js/tree/master/dist But I already included both Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 12, 2016 Share Posted May 12, 2016 Maybe a bug then. I do not know why you got this error. have you try to create a playground that we can see what's wrong. Quote Link to comment Share on other sites More sharing options...
MauJovi Posted May 13, 2016 Share Posted May 13, 2016 Here it is http://www.babylonjs-playground.com/#1LGENM#0 I followed JKoehoorn suggestion, with push. Parsing the whole string i don't get the error but neither the polygon. Maybe i'm doing something very dumb Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 13, 2016 Share Posted May 13, 2016 Your problem seems to be here. it is expected vector2 and not a string var contour = BABYLON.Polygon.Parse(''); contour.push('655.55 120.85'); contour.push('655.55 65.3'); contour.push('708.75 65.3'); contour.push('708.75 120.85'); I think it must be something like this: http://www.babylonjs-playground.com/#1LGENM#1 I have no error, but I do not know the result you expect this playgroud. (This is something that I have no experience yet poly2tri) Quote Link to comment Share on other sites More sharing options...
MauJovi Posted May 13, 2016 Share Posted May 13, 2016 Oh, i see... Now the problem is the scale! Very large numbers. Here it's ok: http://www.babylonjs-playground.com/#1LGENM#3 Thank you very much GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
MauJovi Posted May 20, 2016 Share Posted May 20, 2016 Hey, it's me again! haha I needed to extrude my polygons, so I switched to this: shape.push(...Vector3 here...); var path = [ BABYLON.Vector3.Zero(), new BABYLON.Vector3(0, 0.05, 0) ]; var extruded = BABYLON.Mesh.ExtrudeShape("extruded", shape, path, 1, 0, 0, scene); extruded.material = new BABYLON.StandardMaterial("mat", scene); But i need my shape to be closed. I saw a lot of examples, but none helped me. Could any of you? Thanks Quote Link to comment Share on other sites More sharing options...
jerome Posted May 20, 2016 Share Posted May 20, 2016 Don't be confused by this title post : triangulation makes a plain polygon (so a surface) from a list of Vector3 extrusion makes a solid from a series of Vector3, what is a linear shape, not a surface in other terms, extrusion extrudes a linear shape not a plain polygon. That said, extrusion can extrude any linear shape, closed or not. What is your problem ? Could you show us a PG repro ? MauJovi 1 Quote Link to comment Share on other sites More sharing options...
MauJovi Posted May 20, 2016 Share Posted May 20, 2016 Thank you for your reply. Simple example: I got four points that turn into a square and i wanted it to be a cube. Using the code I posted before, it does the job, but i need my square to be closed at its top. Should I put another shape above it? This should be a little heavy to my application. And sorry about being a noob at 3D, i may be using wrong terms... Quote Link to comment Share on other sites More sharing options...
jerome Posted May 20, 2016 Share Posted May 20, 2016 well, to close an extruded shape, you've got two ways : the most straigt forward is to use the CAP parameter of the extrusion method if the way the cap is built doesn't fit your expectations, you can then use a polygon built by triangulation please read the doc about extrusion to know how to add this cap : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes if you use the MeshBuilder class instead of Mesh class, what is recommended MauJovi 1 Quote Link to comment Share on other sites More sharing options...
MauJovi Posted May 20, 2016 Share Posted May 20, 2016 Yeah, I did it! I was really using the wrong terms. If I looked for cap before... haha Thank you again! 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.