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

I3dm updates #100

Merged
merged 50 commits into from
Aug 19, 2016
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d764f6f
Added new figures
lasalvavida Jul 8, 2016
0044d03
Format changes
lasalvavida Jul 8, 2016
798ecd9
Added rendered pngs
lasalvavida Jul 8, 2016
ec2f757
Changed svg paths to pngs
lasalvavida Jul 8, 2016
4ea9d2d
Removed empty table rows
lasalvavida Jul 8, 2016
80c29dc
Take images out of tables
lasalvavida Jul 8, 2016
59a9c4a
Tweaks
lasalvavida Jul 8, 2016
dd2dcec
Smaller and transparent backgrounds
lasalvavida Jul 8, 2016
34d0445
Shrink again
lasalvavida Jul 8, 2016
439ac61
A little bigger
lasalvavida Jul 8, 2016
9eb48c8
A little bigger
lasalvavida Jul 8, 2016
54ba552
Last edit for this image I promise
lasalvavida Jul 8, 2016
cfac79c
Edits
lasalvavida Jul 11, 2016
3e7b8c3
Instances are SOA
lasalvavida Jul 11, 2016
54724c8
Resize new boxes and a few more edits
lasalvavida Jul 11, 2016
f47b88c
Changed up and right names
lasalvavida Jul 12, 2016
294c609
Switch to axis angle for figures
lasalvavida Jul 12, 2016
125200b
Axis angle changes
lasalvavida Jul 12, 2016
1aa7968
Added resources
lasalvavida Jul 12, 2016
87c8708
Small edits
lasalvavida Jul 12, 2016
964a99c
Fixed link
lasalvavida Jul 12, 2016
eb3efe5
Bulk changes for feature table
lasalvavida Jul 15, 2016
9a8a48b
Added box-rotated-basis and remove instance layout
lasalvavida Jul 15, 2016
5ba2c94
Updated with suggested changes
lasalvavida Jul 15, 2016
ead4fef
Center subheader
lasalvavida Jul 15, 2016
935f0dc
Updated png
lasalvavida Jul 15, 2016
a4fd66e
Fix header error
lasalvavida Jul 15, 2016
5328021
Some edits and try putting dependencies in required
lasalvavida Jul 15, 2016
761145f
Used large blue diamond
lasalvavida Jul 15, 2016
606da2f
Add red circles to 'no'
lasalvavida Jul 15, 2016
f057b33
Typo
lasalvavida Jul 15, 2016
b463829
Adds examples and edits for publishing
lasalvavida Aug 18, 2016
5199ebe
Updated examples
lasalvavida Aug 18, 2016
6f18800
JSON formatting fixes
lasalvavida Aug 18, 2016
ec28280
JSON formatting fixes
lasalvavida Aug 18, 2016
1d3531a
Switched header-layout back to ppt
lasalvavida Aug 18, 2016
5a08d5c
Removed svgs and updated README
lasalvavida Aug 18, 2016
5020644
Fixed alignment in one of the header boxes
lasalvavida Aug 18, 2016
2917cc4
Edits
lasalvavida Aug 19, 2016
6d281a3
More edits
lasalvavida Aug 19, 2016
18d1c95
Updated with binary clause
lasalvavida Aug 19, 2016
4475a14
Fix JSON formatting
lasalvavida Aug 19, 2016
af90e4f
Define how the tileset transform affects orientation
lasalvavida Aug 19, 2016
756b0dc
Reword table and add make examples into js
lasalvavida Aug 19, 2016
01501ae
Clarify case where quantized and oct-encoded as well as uncompressed are
lasalvavida Aug 19, 2016
c454a3d
Typo
lasalvavida Aug 19, 2016
352b9ce
Flipped NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P
lasalvavida Aug 19, 2016
f56dc10
Consistent periods
lasalvavida Aug 19, 2016
38b6d51
Add link to examples section
lasalvavida Aug 19, 2016
decc08d
Missed a change
lasalvavida Aug 19, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 63 additions & 14 deletions TileFormats/Instanced3DModel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,39 @@ Instanced 3D Model maps well to the [ANGLE_instanced_arrays](https://www.khronos

A tile is composed of a header section immediately followed by a body section.


**Figure 1**: Instanced 3D Model layout (dashes indicate optional fields).

![](figures/layout.png)
![header layout](figures/header-layout.png)
Copy link
Contributor

Choose a reason for hiding this comment

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

In the Cesium implementation span is called scale. What is the standard terminology for quantization? Let's use it in all cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment with origin and translation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm open to whatever you think is best as far as naming goes.

span is a little different from scale in quantization. In quantization since we store everything in a decode matrix scale is stored as span divided by 2^16-1. However, here we can choose not do that and potentially improve precision which is what I am doing currently.

Copy link
Contributor

Choose a reason for hiding this comment

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

So it sounds like scale is the right term here. Is origin the standard quantization term used in the literature?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By the literature, origin should be offset and span should be scale. I'll make those changes.


![body layout](figures/body-layout.png)

![instance layout](figures/instance-layout.png)
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the canonical name for v1 and v2 in the graphics literature? Perhaps i and j are better. I dunno.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They would be up and right I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

Double check, and let's go with those semantics since I think they provide more intuition.



## Header

The 28-byte header contains the following fields:
The 76-byte header contains the following fields:

|Field name|Data type|Description|
|----------|---------|-----------|
| Field name | Data type | Description |
| --- | --- | --- |
| `magic` | 4-byte ANSI string | `"i3dm"`. This can be used to identify the arraybuffer as an Instanced 3D Model tile. |
| `version` | `uint32` | The version of the Instanced 3D Model format. It is currently `1`. |
| `byteLength` | `uint32` | The length of the entire tile, including the header, in bytes. |
| `batchTableByteLength` | `uint32` | The length of the batch table in bytes. Zero indicates there is not a batch table. |
| `gltfByteLength` | `uint32` | The length of the glTF field in bytes. |
| `gltfFormat` | `uint32` | Indicates the format of the glTF field of the body. `0` indicates it is a url, `1` indicates it is embedded binary glTF. See the glTF section below. |
| `instancesLength` | `uint32` | The number of instances, also called features, in the tile. |
| `origin.x` | `double` | The `x` coordinate of the origin for the instance region. |
Copy link
Contributor

Choose a reason for hiding this comment

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

Here and below, what is the "instance region?" Is it different than a tile? Perhaps just call this tile. The spec needs to be very precise so we need to be careful about not implicitly introducing new terms, especially if they are redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The "instance region" is different from a tile. It is a volume defined by the origin and span defined in the header. This doesn't have to be the same as the tile's bounding volume or the content bounding volume, though it's probably worth adding that the instance region should be contained by the tile volume.

| `origin.y` | `double` | The `y` coordinate of the origin for the instance region. |
| `origin.z` | `double` | The `z` coordinate of the origin for the instance region. |
| `span.x` | `double` | The distance from the origin in the `x` direction covered by the instance region. |
| `span.y` | `double` | The distance from the origin in the `y` direction covered by the instance region. |
| `span.z` | `double` | The distance from the origin in the `z` direction covered by the instance region. |

_TODO: Link to Cesium code for reading header_
Code for reading the header can be found in
[Instanced3DModelTileContent](https://github.com/AnalyticalGraphicsInc/cesium/blob/3d-tiles/Source/Scene/Instanced3DModel3DTileContent.js#L170)
Copy link
Contributor

Choose a reason for hiding this comment

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

"Instanced3DModelTileContent" -> "Instanced3DModelTileContent.js"

Copy link
Contributor

Choose a reason for hiding this comment

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

Change this to:

Source/Scene/Instanced3DModelTileContent.js

If you can give me commit access to your fork, I will make minor changes like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also note that I dropped the link to the exact line number.

in the Cesium implementation of 3D Tiles.

If either `gltfByteLength` or `instancesLength` equal zero, the tile does not need to be rendered.

Expand Down Expand Up @@ -98,19 +112,54 @@ In either case, `header.gltfByteLength` contains the length of the glTF field in

The `instances` field immediately follows the `glTF` field (which may be omitted when `header.gltfByteLength` is `0`).

The `instances` field contains `header.instancesLength` of tightly packed instances. Each instance has three fields:
The `instances` field contains `header.instancesLength` of tightly packed instances. Each instance has the following fields:

| Field name | Data type | Description | Required |
| --- | --- | --- | --- |
| `position.x` | `uint16` | The x-coordinate in quantized cartesian coordinates. | `yes` |
Copy link
Contributor

Choose a reason for hiding this comment

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

Throughout: "cartesian" -> "Cartesian"

| `position.y` | `uint16` | The y-coordinate in quantized cartesian coordinates. | `yes` |
| `position.z` | `uint16` | The z-coordinate in quantized cartesian coordinates. | `yes` |
| `v1.x` | `uint` | The first component of the oct-encoded vector `v1`. | `yes` |
| `v1.y` | `uint` | The second component of the oct-encoded vector `v1`. | `yes` |
| `v2.x` | `uint` | The first component of the oct-encoded vector `v2`. | `yes` |
| `v2.y` | `uint` | The second component of the oct-encoded vector `v2`. | `yes` |
| `batchId` | `uint16` | ID in the range `[0, length of arrays in the Batch Table)`, which indicates the corresponding properties. | `if header.batchTableByteLength > 0`

### X, Y, and Z for Translation

`x`, `y`, and `z` are stored as `uint16` positions in the quantized instance region defined by the `origin` and `span` fields in the header.
Copy link
Contributor

Choose a reason for hiding this comment

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

The definition here for "quantized instance region" should come earlier in the spec, and how it does/doesn't relate to the bounding volume should be explicit to avoid confusion; readers may think they are the same at first glance.

Also, "quantized volume" is a better name since instance is implicit in this context and the reader won't need to wonder if there is a difference between volume and region; it is the prefix, "bounding" or "quantized", that defines that.

Copy link
Contributor Author

@lasalvavida lasalvavida Jul 11, 2016

Choose a reason for hiding this comment

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

I agree, and quantized volume is a better name.


**Figure 2:** The instance region defined by `origin` and `span`

![](figures/instance-region.png)

Transforming `position` in instance region space to `position_w` in world space can be done using the formula:
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not say "world space" here; "model space" would be fine even if model == world for now. If we say world, we will need to update this later for #98.


`position_w` = `origin` + [`position` * `span` / (`2^16-1`)].

### V1, and V2 for Rotation
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop the comma.


`v1` and `v2` are stored as two components in oct-encoded format as described in
[*A Survey of Efficient Representations of Independent Unit Vectors* by Cigolle et al.](http://jcgt.org/published/0003/02/01/)
The [AttributeCompression](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Core/AttributeCompression.js)
module in Cesium contains an implementation for encoding and decoding vectors in this fashion.

In their decoded form, `v1` and `v2` establish a new orthonormal basis, effectively rotating the coordinate system.

Copy link
Contributor

Choose a reason for hiding this comment

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

The line:

The glTF field immediately follows the batch table (or immediately follows the header, if header.batchTableByteLength is zero).

is no longer accurate now that there's a feature table.

The `y` and `x` vectors in the natural basis are transformed to map onto `v1` and `v2` respectively.
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be more natural for readers to map x/y, not y/x.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe. The only reason I did it this way was to map up first for orientation and then right for rotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll change this to read as right/up/forward which seems to be the common notation.


**Figure 3:** A 3D box in the natural basis
Copy link
Contributor

Choose a reason for hiding this comment

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

The perspective is awkward in this figures. Is it possible to generate them using an orthogonal projection?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They're done in inkscape which is not the best for generating 3D figures. I'll see what I can do.


![](figures/box-unit-basis.png)

|Field name|Data type|Description|
|----------|---------|-----------|
| `longitude` | `double` | The longitude, in radians, in the range `[-PI, PI]`. |
| `latitude` | `double` | The latitude, in radians, in the range `[-PI / 2, PI / 2]`. |
| `batchId` | `uint16` | ID in the range `[0, length of arrays in the Batch Table)`, which indicates the corresponding properties. |
**Figure 4:** A 3D box in the rotated basis

_TODO: make this much more memory efficient and more general, [#33](https://github.com/AnalyticalGraphicsInc/3d-tiles/issues/33)._
![](figures/box-rotated-basis.png)

When `header.batchTableByteLength` is zero, which indicates there is not a batch table, `batchId` is omitted, so each instance contains only `longitude` and `latitude` fields.
The mapping for `z` can be omitted since it will be the cross product of `v1` and `v2`.

Each instance is in the east-north-up reference frame (`x` points east, `y` points north, and `z` points along the geodetic surface normal).
A rotation matrix can be created from `v1`, `v2`, and `v3`=`v2`x`v1` by placing `v2` into the first column,
Copy link
Contributor

Choose a reason for hiding this comment

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

`v1` into the second column, and `v3` into the third column.

## File Extension

Expand Down
Binary file removed TileFormats/Instanced3DModel/figures/Figures.pptx
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
192 changes: 192 additions & 0 deletions TileFormats/Instanced3DModel/figures/body-layout.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading