Jump to content

What's wrong with my Rubik's Cube code : is it meshes group management ?


Recommended Posts

Hello everyone  :),


I've built a Rubik's Cube with the latest BabylonJS version, you can find my experiment here : http://jsfiddle.net/loloof64/UK8Mn/1/


If you click on the two buttons rotateWhole and rotateX, whatever the order, you may notice that there are some troubles : the Rubik's Cube recover its initial state after each move (instead of keeping the last state).


My main opinion is that there is a problem with the RubiksCube#clearGroupToRotate() method (line 269) : the way I assign several cubes to the groupToRotate mesh seems weird. But still, I haven't found the best workaround to solve it.


Does someone has an idea ?




(I've tried to split my JS files into several ones, but it seems that JsFiddle doesn't work this way, even when they are hosted on my Github project, though I managed for the libraries files. And I would like to apologize for this source code presentation)

Link to comment
Share on other sites

Wow, sorry you haven't gotten any replies on the forum, loloof64.  I love your project, but your code is a little over my head.  But I figured the experts would have jumped aboard this project with you, because it is a cool project!  You have apparently stumped the experts, loloof64.  :)  My no-solution reply will bring your subject to the top of the forum list again, at least.  Any news from your end?  Any new discoveries or changes?  (thx)

Link to comment
Share on other sites

I think that in order to keep rotation correct you have to change boxes' position after affecting the parent


I mean, let's imagine that the center cube is always the parent then other cubes should have position = originalPosition - parentPosition


And obviously you have to do the opposite when removing the parent: position = parentPosition + position

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...