-
Notifications
You must be signed in to change notification settings - Fork 470
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
I3dm updates #100
Changes from 12 commits
d764f6f
0044d03
798ecd9
ec2f757
4ea9d2d
80c29dc
59a9c4a
dd2dcec
34d0445
439ac61
9eb48c8
54ba552
cfac79c
3e7b8c3
54724c8
f47b88c
294c609
125200b
1aa7968
87c8708
964a99c
eb3efe5
9a8a48b
5ba2c94
ead4fef
935f0dc
a4fd66e
5328021
761145f
606da2f
f057b33
b463829
5199ebe
6f18800
ec28280
1d3531a
5a08d5c
5020644
2917cc4
6d281a3
18d1c95
4475a14
af90e4f
756b0dc
01501ae
c454a3d
352b9ce
f56dc10
38b6d51
decc08d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
||
![body layout](figures/body-layout.png) | ||
|
||
![instance layout](figures/instance-layout.png) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the canonical name for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They would be There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Instanced3DModelTileContent" -> "Instanced3DModelTileContent.js" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change this to: If you can give me commit access to your fork, I will make minor changes like this. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
||
|
@@ -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` | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The line:
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe. The only reason I did it this way was to map There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll change this to read as |
||
|
||
**Figure 3:** A 3D box in the natural basis | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this include simple equations like, for example, https://github.com/tsturm/glTF/blob/master/extensions/Vendor/FRAUNHOFER_materials_pbr/Appendix.md#specular-brdf |
||
`v1` into the second column, and `v3` into the third column. | ||
|
||
## File Extension | ||
|
||
|
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.
In the Cesium implementation
span
is calledscale
. What is the standard terminology for quantization? Let's use it in all cases.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.
Same comment with
origin
andtranslation
.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'm open to whatever you think is best as far as naming goes.
span
is a little different fromscale
in quantization. In quantization since we store everything in a decode matrixscale
is stored asspan
divided by2^16-1
. However, here we can choose not do that and potentially improve precision which is what I am doing currently.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.
So it sounds like
scale
is the right term here. Isorigin
the standard quantization term used in the literature?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.
By the literature,
origin
should beoffset
andspan
should bescale
. I'll make those changes.