Skip to content
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

Per-tile transforms #123

Merged
merged 11 commits into from
Aug 26, 2016
Merged

Per-tile transforms #123

merged 11 commits into from
Aug 26, 2016

Conversation

pjcozzi
Copy link
Contributor

@pjcozzi pjcozzi commented Aug 25, 2016

Fixes #98.

See

The new figures will be updated later for consistency with the rest of the spec.

});
}
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a recursive example may be easier to grasp here for most readers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, it is much shorter. If you have a Cesium unit test handy, could you quickly run this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is here: f557f56

@lilleyse
Copy link
Contributor

Wow this covers a lot of small but important cases. Looks good to me!

computeTransform(child, childToRoot);
}
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to make two edits. Here's the working code.

        function computeTransforms(tileset) {
            var t = tileset.root;
            var transformToRoot = defined(t.transform) ? Matrix4.fromArray(t.transform) : Matrix4.IDENTITY;

            computeTransform(t, transformToRoot);
        }

        function computeTransform(tile, transformToRoot) {
            // Apply 4x4 transformToRoot to this tile's positions and bounding volumes

            var inverseTransform = Matrix4.inverse(transformToRoot, new Matrix4());
            var normalTransform = Matrix4.getRotation(inverseTransform, new Matrix3());
            normalTransform = Matrix3.transpose(normalTransform, normalTransform);
            // Apply 3x3 normalTransform to this tile's normals

            var children = tile.children;
            var length = children.length;
            for (var k = 0; k < length; ++k) {
                var child = children[k];
                var childToRoot = defined(child.transform) ? Matrix4.fromArray(child.transform) : Matrix4.clone(Matrix4.IDENTITY);
                childToRoot = Matrix4.multiplyTransformation(transformToRoot, childToRoot, childToRoot);
                computeTransform(child, childToRoot);
            }
        }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just commit the change.

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Aug 26, 2016

Thanks @lilleyse! Is this ready?

Does the spec need to cover anything else based on your implementation experience?

@lilleyse
Copy link
Contributor

It covers everything I can think of.

@lilleyse lilleyse merged commit dff1d88 into master Aug 26, 2016
@lilleyse lilleyse deleted the transform branch August 26, 2016 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants