-
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
First Round of 3D Tiles 1.0 updates #301
Changes from 21 commits
0e22b00
7cc26a8
5a62d6f
59247c4
101e8a5
12d2583
7c9d494
90b53dd
86d05ae
d68fb03
77c87f8
192a632
9e7dfc7
5586e25
5117393
7169305
ba91831
899b3a3
d3fce88
026d7dd
0f190b1
d5c5491
f0e031b
469a860
af25031
4615dcb
83f0144
13d6f78
c3f7c96
1143bfa
7b9ae34
e204c9b
082ec85
fd74204
c02ba37
ef40a6e
4f6fc68
c954b2b
36dde46
5ba688c
384e749
98854ad
f5bffdd
4bc6f90
6dce1a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,22 +6,41 @@ | |
* Tom Fili, [@CesiumFili](https://twitter.com/CesiumFili) | ||
* Sean Lilley, [@lilleyse](https://github.com/lilleyse) | ||
|
||
## Contents | ||
|
||
* [Overview](#overview) | ||
* [Layout](#layout) | ||
* [Padding](#padding) | ||
* [Header](#header) | ||
* [Feature Table](#feature-table) | ||
* [Semantics](#semantics) | ||
* [Feature semantics](#feature-semantics) | ||
* [Global semantics](#global-semantics) | ||
* [Batch Table](#batch-table) | ||
* [Binary glTF](#binary-gltf) | ||
* [Coordinate reference system (CRS)](#coordinate-reference-system-crs) | ||
* [File extension and MIME type](#file-extension-and-mime-type) | ||
|
||
## Overview | ||
|
||
_Batched 3D Model_ allows offline batching of heterogeneous 3D models, such as different buildings in a city, for efficient streaming to a web client for rendering and interaction. Efficiency comes from transferring multiple models in a single request and rendering them in the least number of WebGL draw calls necessary. Using the core 3D Tiles spec language, each model is a _feature_. | ||
|
||
Per-model properties, such as IDs, enable individual models to be identified and updated at runtime, e.g., show/hide, highlight color, etc. Properties may be used, for example, to query a web service to access metadata, such as passing a building's ID to get its address. Or a property might be referenced on-the-fly for changing a model's appearance, e.g., changing highlight color based on a property value. | ||
Per-model properties, such as IDs, enable individual models to be identified and updated at runtime, e.g., show/hide, highlight color, etc. Properties may be used, for example, to query a web service to access metadata, such as passing a building's ID to get its address. Or a property might be referenced on the fly for changing a model's appearance, e.g., changing highlight color based on a property value. | ||
|
||
Batched 3D Model, or just the _batch_, is a binary blob in little endian accessed in JavaScript as an `ArrayBuffer`. | ||
|
||
## Layout | ||
|
||
A tile is composed of two sections: a header immediately followed by a body. | ||
|
||
**Figure 1**: Batched 3D Model layout (dashes indicate optional fields). | ||
A tile is composed of two sections: a header immediately followed by a body. The following figure shows the Batched 3D Model layout (dashes indicate optional fields): | ||
|
||
![](figures/layout.png) | ||
|
||
### Padding | ||
|
||
A tile's `byteLength` must be aligned to an 8-byte boundary. | ||
|
||
The [binary glTF](#binary-gltf) (if present) must start and end on an 8-byte alignment so that glTF's byte-alignment guarantees are met. This can be done by padding the [Feature Table](../FeatureTable/README.md#padding) or [Batch Table](../BatchTable/README.md#padding) if they are present. | ||
|
||
## Header | ||
|
||
The 28-byte header contains the following fields: | ||
|
@@ -31,16 +50,16 @@ The 28-byte header contains the following fields: | |
| `magic` | 4-byte ANSI string | `"b3dm"`. This can be used to identify the arraybuffer as a Batched 3D Model tile. | | ||
| `version` | `uint32` | The version of the Batched 3D Model format. It is currently `1`. | | ||
| `byteLength` | `uint32` | The length of the entire tile, including the header, in bytes. | | ||
| `featureTableJSONByteLength` | `uint32` | The length of the feature table JSON section in bytes. Zero indicates there is no feature table. | | ||
| `featureTableBinaryByteLength` | `uint32` | The length of the feature table binary section in bytes. If `featureTableJSONByteLength` is zero, this will also be zero. | | ||
| `batchTableJSONByteLength` | `uint32` | The length of the batch table JSON section in bytes. Zero indicates there is no batch table. | | ||
| `batchTableBinaryByteLength` | `uint32` | The length of the batch table binary section in bytes. If `batchTableJSONByteLength` is zero, this will also be zero. | | ||
| `featureTableJSONByteLength` | `uint32` | The length of the Feature Table JSON section in bytes. Zero indicates there is no Feature Table. | | ||
| `featureTableBinaryByteLength` | `uint32` | The length of the Feature Table binary section in bytes. If `featureTableJSONByteLength` is zero, this will also be zero. | | ||
| `batchTableJSONByteLength` | `uint32` | The length of the Batch Table JSON section in bytes. Zero indicates there is no Batch Table. | | ||
| `batchTableBinaryByteLength` | `uint32` | The length of the Batch Table binary section in bytes. If `batchTableJSONByteLength` is zero, this will also be zero. | | ||
|
||
If `featureTableJSONByteLength` equals zero, the tile does not need to be rendered. | ||
|
||
The body section immediately follows the header section, and is composed of three fields: `Feature Table`, `Batch Table` and `Binary glTF`. | ||
The body section immediately follows the header section, and is composed of three fields: `Feature Table`, `Batch Table`, and `Binary glTF`. | ||
|
||
Code for reading the header can be found in | ||
> Implementation Note: Code for reading the header can be found in | ||
[Batched3DModelTileContent](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Batched3DModel3DTileContent.js) | ||
in the Cesium implementation of 3D Tiles. | ||
|
||
|
@@ -49,86 +68,93 @@ in the Cesium implementation of 3D Tiles. | |
Contains values for `b3dm` semantics. | ||
More information is available in the [Feature Table specification](../FeatureTable/README.md). | ||
|
||
The `b3dm` Feature Table JSON Schema is defined in [b3dm.featureTable.schema.json](../../schema/b3dm.featureTable.schema.json). | ||
The `b3dm` Feature Table JSON schema is defined in [b3dm.featureTable.schema.json](../../schema/b3dm.featureTable.schema.json). | ||
|
||
### Semantics | ||
|
||
#### Feature Semantics | ||
#### Feature semantics | ||
|
||
There are currently no per-feature semantics. | ||
|
||
#### Global Semantics | ||
#### Global semantics | ||
|
||
These semantics define global properties for all features. | ||
|
||
| Semantic | Data Type | Description | Required | | ||
| --- | --- | --- | --- | | ||
| `BATCH_LENGTH` | `uint32` | The number of distinguishable models, also called features, in the batch. If the Binary glTF does not have a `batchId` attribute, this field _must_ be `0`. | :white_check_mark: Yes. | | ||
| `RTC_CENTER` | `float32[3]` | A 3-component array of numbers defining the center position in _z_-up coordinates when positions are defined relative-to-center. | :red_circle: No. | | ||
|
||
## Batch Table | ||
|
||
The _Batch Table_ contains per-model application-specific metadata, indexable by `batchId`, that can be used for declarative styling and application-specific use cases such as populating a UI or issuing a REST API request. In the Binary glTF section, each vertex has an numeric `batchId` attribute in the integer range `[0, number of models in the batch - 1]`. The `batchId` indicates the model to which the vertex belongs. This allows models to be batched together and still be identifiable. | ||
The _Batch Table_ contains per-model application-specific metadata, indexable by `batchId`, that can be used for [declarative styling](../../Styling/README.md) and application-specific use cases such as populating a UI or issuing a REST API request. In the binary glTF section, each vertex has an numeric `batchId` attribute in the integer range `[0, number of models in the batch - 1]`. The `batchId` indicates the model to which the vertex belongs. This allows models to be batched together and still be identifiable. | ||
|
||
See the [Batch Table](../BatchTable/README.md) reference for more information. | ||
|
||
## Binary glTF | ||
|
||
[glTF](https://www.khronos.org/gltf) is the runtime asset format for WebGL. [Binary glTF](https://github.com/KhronosGroup/glTF/tree/master/extensions/Khronos/KHR_binary_glTF) is an extension defining a binary container for glTF. Batched 3D Model uses glTF 1.0 with the [KHR_binary_glTF](https://github.com/KhronosGroup/glTF/tree/master/extensions/Khronos/KHR_binary_glTF) extension. | ||
|
||
The binary glTF immediately follows the feature table and batch table. It may embed all of its geometry, texture, and animations, or it may refer to external sources for some or all of these data. | ||
Batched 3D Model uses [glTF 2.0](https://github.com/KhronosGroup/glTF/tree/master/specification/2.0) to embed model data. | ||
|
||
The glTF asset must be 8-byte aligned so that glTF's byte-alignment guarantees are met. This can be done by padding the Feature Table or Batch Table if they are present. | ||
The [binary glTF](https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#binary-gltf-layout) immediately follows the Feature Table and Batch Table. It may embed all of its geometry, texture, and animations, or it may refer to external sources for some or all of these data. | ||
|
||
As described above, each vertex has a `batchId` attribute indicating the model to which it belongs. For example, vertices for a batch with three models may look like this: | ||
``` | ||
batchId: [0, 0, 0, ..., 1, 1, 1, ..., 2, 2, 2, ...] | ||
position: [xyz, xyz, xyz, ..., xyz, xyz, xyz, ..., xyz, xyz, xyz, ...] | ||
normal: [xyz, xyz, xyz, ..., xyz, xyz, xyz, ..., xyz, xyz, xyz, ...] | ||
``` | ||
Vertices do not need to be ordered by `batchId` so the following is also OK: | ||
Vertices do not need to be ordered by `batchId`, so the following is also OK: | ||
``` | ||
batchId: [0, 1, 2, ..., 2, 1, 0, ..., 1, 2, 0, ...] | ||
position: [xyz, xyz, xyz, ..., xyz, xyz, xyz, ..., xyz, xyz, xyz, ...] | ||
normal: [xyz, xyz, xyz, ..., xyz, xyz, xyz, ..., xyz, xyz, xyz, ...] | ||
``` | ||
Note that a vertex can't belong to more than one model; in that case, the vertex needs to be duplicated so the `batchId`s can be assigned. | ||
|
||
The `batchId` is identified by the glTF technique parameter semantic `_BATCHID`. For example: | ||
The `batchId` parameter is specified in a glTF mesh [primitive](https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-primitive) by providing the `_BATCHID` attribute semantic, along with the index of the `batchId` [accessor](https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#accessors). For example, | ||
|
||
```JSON | ||
"technique": { | ||
"attributes": { | ||
"a_batchId": "batchId" | ||
}, | ||
"parameters": { | ||
"batchId": { | ||
"semantic": "_BATCHID", | ||
"type": 5126 | ||
"primitives": [ | ||
{ | ||
"attributes": { | ||
"_BATCHID": 0 | ||
} | ||
} | ||
} | ||
] | ||
``` | ||
|
||
For this example the attribute is named `a_batchId`, and is declared in the vertex shader as: | ||
|
||
```glsl | ||
attribute float a_batchId; | ||
```JSON | ||
{ | ||
"accessors": [ | ||
{ | ||
"bufferView": 1, | ||
"byteOffset": 0, | ||
"componentType": 5125, | ||
"count": 4860, | ||
"max": [2], | ||
"min": [0], | ||
"type": "SCALAR" | ||
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. Below this example mention that |
||
} | ||
] | ||
} | ||
``` | ||
|
||
The vertex shader can be modified at runtime to use `a_batchId` to access individual models in the batch, e.g., to change their color. | ||
When a Batch Table is present or the `BATCH_LENGTH` property is greater than `0`, the `_BATCHID` attribute is required; otherwise, it is not. | ||
|
||
### Coordinate reference system (CRS) | ||
|
||
When a Batch Table is present or the `BATCH_LENGTH` property is greater than `0`, the `batchId` attribute (with the parameter semantic `_BATCHID`) is required; otherwise, it is not. | ||
3D Tiles local coordinate systems use a right-handed 3-axis (x, y, z) Cartesian coordinate system; that is, the cross product of _x_ and _y_ yields _z_. 3D Tiles defines the _z_ axis as up for local Cartesian coordinate systems. | ||
|
||
Although not strictly required, clients may find the glTF [CESIUM_RTC](https://github.com/KhronosGroup/glTF/tree/master/extensions/1.0/Vendor/CESIUM_RTC) extension useful for high-precision rendering. | ||
By default, vertex positions of the embedded glTF are defined according to a right-handed coordinate system where the _y_-axis is up, but vertex positions may be defined in a coordinate system where the _z_axis is up by specifying the [`CESIUM_z_up` glTF extension](TODO) in the embedded glTF (see [local coordinate systems](../../README.md#local-coordinate-systems)). | ||
|
||
## File Extension | ||
Vertex positions may be defined relative-to-center for high-precision rendering [1]. If defined, `RTC_CENTER` specifies the center position and all vertex positions are treated as relative to this value. The center position provided for `RTC_CENTER` is defined according to a coordinate system where the _z_-axis is up. | ||
|
||
`.b3dm` | ||
## File extension and MIME type | ||
|
||
The file extension is optional. Valid implementations ignore it and identify a content's format by the `magic` field in its header. | ||
Batched 3D Model tiles use the `.b3dm` extension and `application/octet-stream` MIME type. | ||
|
||
## MIME Type | ||
An explicit file extension is optional. Valid implementations may ignore it and identify a content's format by the `magic` field in its header. | ||
|
||
_TODO, [#60](https://github.com/AnalyticalGraphicsInc/3d-tiles/issues/60)_ | ||
## Resources | ||
|
||
`application/octet-stream` | ||
1. [Precisions, Precisions](http://blogs.agi.com/insight3d/index.php/2008/09/03/precisions-precisions/) |
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.
Drop
in z-up coordinates
and add a link to the CRS section below.