Ahiru Posted September 5, 2015 Share Posted September 5, 2015 I've seen we have var p = new BABYLON.Plane.FromPoints(v1, v2, v3);So we can create a PLANE from Points, why not using this for creating Meshes like CreatePlane, CreateBox ... etc.? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 6, 2015 Share Posted September 6, 2015 Hi again, A! Umm... let's go on a little adventure. First, let's visit the BJS source code. https://github.com/BabylonJS/Babylon.js/ Let's use that search box at the top... to search for BABYLON.Plane.FromPoints. Paste that into the search field and whack ENTER... let's see what blows up. The search returns a few hits... mostly typescript files... but we are most interested in src/Math/babylon.math.js. Math.js! What the heck is it doing in there? The full path... https://github.com/BabylonJS/Babylon.js/blob/master/src/Math/babylon.math.js#L2250 (click to go there, or path-nav yourself there via the 'src/Math' folder.) See that? The plane you speak-of... is a MATH structure, and not a standard mesh with abstractMesh as its super-class. There's no .position, no .scaling, no .rotation, no .material, and no vertexData object. It just doesn't look like it's ready for rendering, does it? I "hijacked" the Math.Plane code into a playground scene and created one - in variable p. http://playground.babylonjs.com/#13ZSAB . Nothing happens, of course. It's not a mesh, it's a thing. Feel free to hack-away on that playground and see if there's some discoveries to be made. I have seen this type of plane used in the code for mirrorTextures. Other than that, I am not sure when and where this Math.Plane is used. It looks like it might be used in our Constructive Solid Geometry (csg) system. (demo @ http://playground.babylonjs.com/#UUXLX#4 ). You COULD create your own function named CreatePlaneFromPoints, but it must internally create a MESH plane and not a MATH plane, or else it won't render into the scene. Often, creating a mesh from a set of points... starts with a blank Babylon.Mesh, and uses applied vertexData types/kinds to shape the blank mesh. Here's an example: http://playground.babylonjs.com/#1UHFAP#21 In that PG, you will see the blank mesh created in line 5, and a bunch of data applied to it... in line 129. *shrug* The experts might visit to tell us more about the reasons for a Math Plane. Also, other math libraries on the planet... sometimes have this 'plane' within them, too, so some web searches as to WHY... might find information. Sorry I couldn't be of more help, but I thought I would tell you the little bit that I know about this subject. I'm sure others will have more information. Party on. Quote Link to comment Share on other sites More sharing options...
Ahiru Posted September 6, 2015 Author Share Posted September 6, 2015 But I guess your normals do not really work, since they are not perpendicular to your faces? Just a suggestion to have them recalculated to make the light-reflections working: http://playground.babylonjs.com/#1UHFAP#22 By the way - do others have the same problem, that if using this link: http://babylonjs-playground.com/#1UHFAP#22 Not the proper code will be loaded, but the first example? Quote Link to comment Share on other sites More sharing options...
Ahiru Posted September 6, 2015 Author Share Posted September 6, 2015 One more thing: The spotlights seem not to be reflected on the vertices 1-4 and 1-3. Maybe one of the more experienced ones could explain why? http://playground.babylonjs.com/#1UHFAP#23 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 6, 2015 Share Posted September 6, 2015 Quote But I guess your normals do not really work, since they are not perpendicular to your faces? They're working exactly how I set them. I hope I'm not under arrest for exercising my freedom to set normals any way I like. But yeah, the normals were just slapped in there, no real thought to them. It's just a demo... nothing to bet your life-on. It has been my thought... that a "standard" direction of a normal... would be the averaging of all the normals of the faces it connects together. IF you do mesh.convertToFlatShadedMesh()... then extra vertices are added, and then... yes, normals tend to go perpendicular to the faces that meet there. If a vertex connects 3 faces, the convertToFlatShadedMesh() probably adds two more vertices to that vertex (now there's 3 normals)... and likely sets one normal to be perpendicular to each face meeting there. Always, only 1 normal per vertex. You can confirm this by displaying the length of vertexKind data before and after a convertTFSM(). Flat-shaded mesh are substantially larger. As always, I could be wrong. Sorry. Quote Link to comment Share on other sites More sharing options...
Ahiru Posted September 7, 2015 Author Share Posted September 7, 2015 The shading works totally different then (but the artefacts at the 1-3 and 1-4 lines are gone) - but what exactly is that used for ? And will it reduce render-time? http://playground.babylonjs.com/#1UHFAP#24 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.