-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support cube non rectangle #216
base: master
Are you sure you want to change the base?
Support cube non rectangle #216
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here (e.g. What to do if you already signed the CLAIndividual signers
Corporate signers
|
I signed it! |
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
…r column position
a07dfc0
to
dd47e52
Compare
CLAs look good, thanks! |
@@ -138,32 +140,46 @@ CubeTile.prototype.rotY = function() { | |||
|
|||
|
|||
CubeTile.prototype.centerX = function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be expressed more succinctly as
var levelWidth = this._level.width();
var tileWidth = this._level.tileWidth();
return (this.x * tileWidth + 0.5 * this.width()) / levelWidth - 0.5;
which is the same logic as in FlatView
.
var foreWidth = this._level.tileWidth() * this.x; | ||
var partOfWidth = this.width() / 2; | ||
// Compute tile centerX of face | ||
return (foreWidth + partOfWidth + 0.5) / this._level.width() - 0.5; | ||
}; | ||
|
||
|
||
CubeTile.prototype.centerY = function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise as above.
src/geometries/Cube.js
Outdated
@@ -488,47 +499,6 @@ CubeLevel.prototype.tileHeight = function() { | |||
}; | |||
|
|||
|
|||
CubeLevel.prototype._validateWithParentLevel = function(parentLevel) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still want to validate that each tile has at most one parent tile in the previous level (i.e., the tile width must be a submultiple of the parent width, and the same for height). Otherwise, CubeTile#parent
and CubeTile#children
no longer work correctly.
If you're up for it, you can lift this restriction afterwards (but please make it a separate PR, to keep each change small).
* - The number of tiles in a level must be a multiple of the number of tiles | ||
* in the parent level. | ||
* - All tiles must be square, except when in the last row or column position, | ||
* and must form a rectangular grid; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
- The tile width (respectively, height) for a level must be a submultiple of the tile width (respectively, height) for the parent level.
per the discussion above.
@@ -124,6 +124,8 @@ function CubeTile(face, x, y, z, geometry) { | |||
this.z = z; | |||
this._geometry = geometry; | |||
this._level = geometry.levelList[z]; | |||
// Pre compute last tile size, when all is square, it's 0 | |||
this._tileResidue = this._level.width() % this._level.tileWidth(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to change the CubeTile#neighbors
method. Currently, the logic assumes that an edge tile never meets more than one tile in the other face; this is no longer true with residual tiles.
Consider, for example, the non-residual tile at the top left of the down face. This tile meets two different tiles in the left face: the residual tile at the bottom right of the left face, and the non-residual tile immediately to the left.
A similar situation happens with some of the other corners of the cube. A strategy that might work is to have a lookup table indicating whether a particular corner is "special" or not ("special" meaning that a residual tile meets a non-residual one at that corner). Then add the additional tile to the neighbor set in the cases where the corner is "special".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great addition, but I have some concerns that need to be addressed. Please see my review comments.
Support cube tile non rectangle when in the last row or column position