jerome Posted September 22, 2015 Share Posted September 22, 2015 Hi guys, Mr Stemkosky, a ThreeJS guy, did a really nice work here : http://stemkoski.github.io/Three.js/Polyhedra.htmlHe converted to JSON all the data compiled by George Hart here : http://www.georgehart.com/virtual-polyhedra/vp.html That's for the credits... So I just re-used the JSON file and implemented in BJS an algo to build polyhedrons the same way Stemkosky did in ThreeJS. Here is the result : http://www.babylonjs-playground.com/#21QRSK If you hide the editor (button "-Editor"), you can display the pointed polyhedron name on the screen. There are 126 different shapes here.I guess I won't hard-code all of them as BJS basic shapes, but maybe only the most useful (how to determine the usefulness of a shape ?) or the smallest ones in term of faces : tetrahedron, pyramid, octohedron, dodecahedron, prismHaving some hard-coded polyhedrons allow to pre-compute their UVs (there are none here), what is a quite complex thing to do. Unless you prefer I just code this full bunch as a BJS extension (so no hard coded UVs at all, what is too bad imho)something like :Extension.CreatePolyhedron(name, polyhedronTypeId, size, scene) ;I need to have some polyhedrons in BJS before I start to port the SPS in the BJS core because I want to simplify it :no more dedicated methods addCubes(), addTetrahedrons(), etcbut only something homogeneous like :var model = BABYLON.Mesh.CreateXXX(); // it may be a cube, a sphere, a polyhedron, a ribbon, whatever the geometrySPS.addShape(model, modelNb);model.dispose(); Dad72, iiceman, Ahiru and 4 others 7 Quote Link to comment Share on other sites More sharing options...
jerome Posted September 22, 2015 Author Share Posted September 22, 2015 raw data here : http://jerome.bousquie.fr/BJS/polyhedrons/polyhedra.js for curious people Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted September 22, 2015 Share Posted September 22, 2015 Titleist might have some use for a gaming platform. Looking at one now. Never noticed that all the faces are not the same size. Kind of think the number CreateXXX()'s inside of Mesh.ts would get out of hand. If you went with an extension, I would drop this static create pattern thing, and create mesh subclasses. Just have a constructor for each like: var thing = new Polyhedron.Pyramid(name, size, scene); This would allow someone to subclass them. jerome 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted September 22, 2015 Share Posted September 22, 2015 I like the way you dynamically brought in an external script file, btw. Think I could use that. Other good shapes are all kinds of balls, sports objects. Soccer ball, football, hockey puck, basketball, baseball, bowling ball, home plate, etc. I know it is not what is on offer, but you did ask. These things are for geometry teachers / academics. Quote Link to comment Share on other sites More sharing options...
jerome Posted September 22, 2015 Author Share Posted September 22, 2015 the same with slower rotations so everyone can admire their beauty http://www.babylonjs-playground.com/#21QRSK#1 Quote Link to comment Share on other sites More sharing options...
monkeyface Posted September 22, 2015 Share Posted September 22, 2015 http://www.babylonjs-playground.com/#IZPUO#1Diamonds! jerome 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 22, 2015 Share Posted September 22, 2015 Excellent..This is a good candidate for bjs 2.3 If you feel that you need to add too much code to mesh.ts, I'm ok to add a mesh.polyhedron.ts file Quote Link to comment Share on other sites More sharing options...
jerome Posted September 23, 2015 Author Share Posted September 23, 2015 when I said that BJS odd number version were better ... I'm just thinking about how to do.I'm trying to handle two different issues in the same time :- to provide to the library the more polygon shapes possible : can you imagine a framework providing almost 150 built-in shapes ? never seen anywhere !- to pre-compute the UVs on some of them (I guess that I need to add this in the JSON structure) what can be really complex according to the shape itself (especially when its faces are different polygon types) and the choices about how the texture should be applied on each polyhedron. I think a dedicated file would be a good option to keep clear code anyway. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 23, 2015 Share Posted September 23, 2015 If this adds too much code to the framework we will think about generating a version of bjs with and one without to keep the file size reasonable Quote Link to comment Share on other sites More sharing options...
jerome Posted September 23, 2015 Author Share Posted September 23, 2015 Maybe it is better to select only some useful polyhedrons only (pyramids, and some up to 12 faces max, say 4 or 5 shapes only... so not really much code) to add in BJS core and to keep the full pack of 126 shapes as a extension apart ? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted September 23, 2015 Share Posted September 23, 2015 You totally totally rock, Jerome! YAY!! The George W. Hart/Stemkoski json-o-polyhedra... has finally made the trip to BJS! WOW! Excellent! (Wingy dances!) Ok, I'll get started converting all that static data... to math formulas. I'll have it done in a few hours. (yeeeeah, right, Wingleberry) Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 23, 2015 Share Posted September 23, 2015 @Jerome: completely agree. You can create an extension for others here:https://github.com/BabylonJS/Extensions Quote Link to comment Share on other sites More sharing options...
jerome Posted October 13, 2015 Author Share Posted October 13, 2015 CreatePolyhedron() at last PRedvar pol = BABYLON.Mesh.CreatePolyhedron("name", {type?: number, size?: number, custom?: polyhedronObject}, scene); type : embedded polyhedron type number. There are 15 common usual polyhedron types provided (to keep the code light). This will be documented size, or also sizeX, sizeY, sizeZ : polyhedron size custom : a polyhedron object reference, copied/pasted from a provided external file (126 samples). This will be documented. If passed, the custom polyhedron is created instead of a BJS core one. faceColors and faceUV : arrays, nb of faces long, used to set color or image per polyhedron sideand of course sideOrientation and updatable parametersEverything is optional :BABYLON.Mesh.CreatePolyhedron("name", {}, scene);will build a simple tetrahedron (type = 0) JohnK 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted October 13, 2015 Author Share Posted October 13, 2015 Who could please create a directory called Polyhedron in this repo : https://github.com/BabylonJS/Extensions so I can (or someone else) just upload the external polyhedron sample file ? Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted October 13, 2015 Share Posted October 13, 2015 You cannot actually add directories in GIT. If you fork repository, you can add file(s) in a directory, push to your fork, & PR. Or get push access directly. Then you can just skip the fork. Quote Link to comment Share on other sites More sharing options...
jerome Posted October 13, 2015 Author Share Posted October 13, 2015 that's why I asked to this repo administrator Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 13, 2015 Share Posted October 13, 2015 Done:https://github.com/BabylonJS/Extensions/tree/master/Polyhedron jerome 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted October 13, 2015 Share Posted October 13, 2015 Hi guys. Good work going on here, thanks! I just wanted to mention... that WAY BACK when I came-across that Hart/Stemkoski json file, I never verified re-use rights for it. If we are re-publishing all or part of that, maybe we should introduce ourselves and make sure of stuff. *shrug* Just thinking. Quote Link to comment Share on other sites More sharing options...
jerome Posted October 13, 2015 Author Share Posted October 13, 2015 You might be right.Stemkoski added a reference to the site of Hart when clicking on the "I" here : http://stemkoski.github.io/Three.js/Polyhedra.html. Maybe asked he the permission to Hart to use his data ?However, the Hart site says, in the copyright part, says this : "All the text and 2D images of Virtual Polyhedra are copyright 1996, 1997, 1998, 1999 by George W. Hart, with all rights reserved. They may not be reproduced in any form without my expressed written permission, except for the incidental reproduction which is inherent in your real-time viewing (and local caching) of the information with a web browser.However, upon request, I will likely grant reproduction permission for noncommercial purposes. You can send me email at [email protected]An exception is the collection of individual *.wrl files which contain the mathematical description of each polyhedron. Because these contain mathematical information, they may be of use to others with an interest in polyhedra. They may be reproduced and used for noncommercial purposes. Note that a written comment to this effect is already present in each of the data files."As we use Stemkosky data, what are actually Hart data parsed from WRL into JSON (and if my legal English understanding is good enough), I guess we match the exceptional case of his copyright disclaimer. The original sources of data (Stemkoski + Hart) will of course be written in the provided extension file. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted October 13, 2015 Share Posted October 13, 2015 Yeah, we probably fall-under the same .WRL (data only) non-commercial thing... maybe. But don't we need commercial rights? Some of our users are going to "market" their stuff... and.. hmm. *shrug* Let's get Davrous to fire a cool two-way email at the boys. He's a smooth talker... and that baby face... gets 'em EVERY TIME! I'll email 'em... if folks think I should. You can, too, Jerome. I exchanged short interaction with Prof. Stemkoski... on his blog. He's a sweetheart. Hart seems ok, too... by the words on his site. But I think DK would be the one who would need to get the official perms. Um... how close are we... to being able to dynamically gen those shapes? I can break-into, or continually-talk until they ALLOW me-into... the code vaults at MathLab, Inc. heh Thoughts? Quote Link to comment Share on other sites More sharing options...
jerome Posted October 14, 2015 Author Share Posted October 14, 2015 OkIf one of the native english speaker here could gently ask, this would be great indeed. I don't feel comfortable enough in English to do such a request correctly. I'm not expert in US laws but I'm not sure some computed coordinates can be copyrighted. We would have get the same results if we had done the computations by ourselves : box vertex coordinates are the same whomever does the computation. We can't really dynamically compute all this data with a universal algo because it really depends on the polyhedron category, so at least an algo per category. If we had done it, we would have done the same : to precompute everything because it's simpler and lighter than implementing dozens fo different algos. Before you gave the link to Stemkosky site, I implemented the tetrahedron in the SPS and started then to study many other regular polygons on the basis of the attached document (french maths, you won't like ) : I was just about to begin to compute the first platonic solid vertex coordinates ... just as Hart did.geometrie_espace.pdf Quote Link to comment Share on other sites More sharing options...
jerome Posted October 14, 2015 Author Share Posted October 14, 2015 added the extension file online : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron Quote Link to comment Share on other sites More sharing options...
Wingnut Posted October 14, 2015 Share Posted October 14, 2015 Oooh, you did that with class and good taste. Nice. Deltakosh, did you want to handle this? I would be glad to translate something French-written... into English, and smooth the wording. I can deliver, or someone else can. I'm a little scared to take this on by myself, though. If I screwed it up, folks would hate me forever. I would like to have "authorization" by Deltakosh or one of the co-founders... before I move forward on this. You should have a strong say, too, Jerome. And, forum users should be able to have a say on this too, but those preferences might be overridden by "the big dogs". heh (I'm NOT a big dog, I'm just a noisy dog.) I suggest that we offer Mr. Stemkoski and Mr. Hart... a usage rights statement from them... inside that same directory, or included in that .md documentation. And, I have $20 to donate to their causes. By including usage rights statements by these authors on our site, we will cover our butts from users who use this data for commercial purposes. We have then included the authors... into our site and project... and they will have editing powers on those usage rights statements. And... maybe... we can get these guys to join the forum and have good geometry fun with us. Essentially, we bring 'em on-board and hug them until they submit to our evil wonderful plans. Thoughts? I can also email Mr. Hart as a NON-representative of BJS, and just "test the waters", too. (offering-up a few hypothetical usage situations for him/them to comment-on). Anything goes, guys. Let me know if/when/where I can be of service, I am more than glad to do it. Quote Link to comment Share on other sites More sharing options...
jerome Posted October 14, 2015 Author Share Posted October 14, 2015 You are right Wingy.We need to ask them gently. And I don't think this kind of smart people want some money (maybe I'm wrong). I can also add a link to the copyright terms of Hart and explicitly write that, according to these rules, the BJS user can only use the extension file in a non-commercial project unless they (Hart/Stemkoski) accept. Don't know ... Waiting for their reply, I don't change anything for now.If they don't accept, I will detail the copyright terms on the extension site (it's then the user responsibility to respect them) and I will probably just recompute the internal provided polyhedron coordinates by my own (or lower their number) or get them already computed from somewhere else on the web (there are plenty of websites about this).And maybe I will just get the same results from another source. [EDIT] I just added something about the rights in the doc : https://github.com/BabylonJS/Extensions/blob/master/Polyhedron/readme.md Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 14, 2015 Share Posted October 14, 2015 Hello, as I'm working for Microsoft I do not want this to interfere. So I'd rather prefer having Jerome (helped by wingy:)) to ask for validation of what Jerome already mentioned in the readme 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.