Jump to content

Projecting onto a sphere


Recommended Posts

Hi Raanan, 


Perhaps I didn't explain it very well, I wasn't sure exactly how to phrase it. I want a sphere that's made up of subdivided diamonds, starting with an octahedron. As in this article: http://www.isprs.org/proceedings/XXXVI/4-W6/papers/267-270JianjunBai-A042.pdf


I've seen something similar done with three.js but not quite sure of the methods used (the example using three started with an icosahedron and subdivided to triangles).


But basically, an octahedron (that will be further subdivided) bent into the shape of a sphere.

Link to comment
Share on other sites

Hi jermone,


That's good to know. Assuming BJS gets regular polyhedrons soon, is there anything bakes into BJS at the moment that would allow me to distort them into a sphere or to subdivide it's faces?


Or perhaps another approach would be to start with a mesh of 4 diamonds (i.e. a flattened out octahedron, subdivided or otherwise) and bend it round a sphere like you would a texture? Ultimately I need to be able to perform actions on the diamonds separately after/before they are made into s sphere. They will essentially be tiles on a world.

Link to comment
Share on other sites

Hi Sparky!  http://urbanproductions.com/wingy/babylon/hedra/hedra01.htm  [zipped] (sorry for the slow camera and beginner code)  That's likely totally useless to you, as you probably prefer genned vertices, not hard-coded.


Professor Stemkoski is a trailblazer of great 3js demos... one of which is a massive polyhedra demo.  In that demo... he uses a json storage object...  http://stemkoski.github.io/Three.js/js/polyhedra.js ... and I stole that data for my demo (the first url in this post).


As you can see, I have incorrectly applied the indices and normals data.  In fact, the only good-for-BJS data inside that json structure... is the vertex data.  The rest of it is for quad-patch meshes and per-face stuff used by 3JS (I think). 


What good is any of this for you, from within BabylonJS?  Probably none whatsoever.  :)


Actually, I never expected to see Prof Stemkoski use static hedra defs.  I figged he would have used fancy math formulas... dynamically plotting the shapes.  Nope.  Static.  Oh well.   Sparky, I think you should stay right here with us, and play with some BJS geometry plotting.  Even in the BabylonJS playground!  (Ignore the blue boxes.  They were there to help me learn, and can be turned off.)


C'mon Sparky!  Can I get you a beverage?  Some wheat thins?  (quick, someone book him a nice hotel room... I'm sure he'll stay and party with us for at least one more night)  :D

Link to comment
Share on other sites

Thanks Wingnut, that looks interesting. Same for the link you posted jerome.

I'm staying here for the party, I'm just considering pre-drinks at three to help me get my head around it :). I'm really not that hot on 3D stuff, but would be happy to contribute if I manage to do something useful!

I've found a couple of articles with fancy maths, here's the one that started me on this road:


What Andy has done is great, but I'm put off by the hexagons as it's difficult to have varying levels of detail with hex's as one set of hexes don't sit nicely within another, hence looking at the diamond option.

So far I'm basking in a maths headache trying to understand the methods Andy has used, particularly slerp() and subdividing a icosahedron on a spherical plane. Although I'm starting to find my way out of that.

I'd be interested to understand how the subdivision of a sphere works in BJS at the moment as that might help. (I'll dig out the code later)

Also, I don't quite understand the notation used defining the vertices for a shape as per the preparatory json link jerome posted. Am I right in thinking its defining each vertex as an offset from 0,0,0? (Told you I'm a 3d noob!)

Thanks again for all your help.

P.s wheat thins? (I'm a Brit - never heard of them)

Link to comment
Share on other sites

For comparison, Andy uses these for a isocahedron:


    var phi = (1.0 + Math.sqrt(5.0)) / 2.0;
    var du = 1.0 / Math.sqrt(phi * phi + 1.0);
    var dv = phi * du;
    nodes =
        { p: new Vector3(0, +dv, +du), e: [], f: [] },
        { p: new Vector3(0, +dv, -du), e: [], f: [] },
        { p: new Vector3(0, -dv, +du), e: [], f: [] },
        { p: new Vector3(0, -dv, -du), e: [], f: [] },
        { p: new Vector3(+du, 0, +dv), e: [], f: [] },
        { p: new Vector3(-du, 0, +dv), e: [], f: [] },
        { p: new Vector3(+du, 0, -dv), e: [], f: [] },
        { p: new Vector3(-du, 0, -dv), e: [], f: [] },
        { p: new Vector3(+dv, +du, 0), e: [], f: [] },
        { p: new Vector3(+dv, -du, 0), e: [], f: [] },
        { p: new Vector3(-dv, +du, 0), e: [], f: [] },
        { p: new Vector3(-dv, -du, 0), e: [], f: [] },

Link to comment
Share on other sites

Ok, I finally read the PDF and saw what Andy is doing, so I understand where you want to go.  Yeah, BJS has ya covered... for the high-performance rendering/visualization of that stuff.  Fastest gun in the west!  The BJS engine will be dozing-off, waiting for your JS to give it more data to render at 120 fps.  ;)


Okay, that was a bit of bloviating on my part.  But, yeah, I would love to see BJS-based tools that we could use to experiment with these things.


Terrain quantizing and indexing.  I think earthquake researchers use things like these, sometimes fed with remote sensor data.  Way cool.  Great topic/project!

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...