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

First Round of 3D Tiles 1.0 updates #301

Merged
merged 45 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0e22b00
0.0 to 1.0
lilleyse Jun 20, 2017
7cc26a8
Add link to OneSky blog post
pjcozzi Apr 17, 2018
5a62d6f
Merge pull request #300 from AnalyticalGraphicsInc/pjcozzi-patch-1
pjcozzi Apr 17, 2018
59247c4
3D Tiles 1.0 updates
ggetz Apr 17, 2018
101e8a5
copyedit 1
slchow Apr 21, 2018
12d2583
copyedit 2
slchow Apr 21, 2018
7c9d494
figures
slchow Apr 21, 2018
90b53dd
copyedit
slchow Apr 21, 2018
86d05ae
RegExp
slchow Apr 23, 2018
d68fb03
Response to Gabby's comments
slchow Apr 23, 2018
77c87f8
regExp()
ggetz Apr 23, 2018
192a632
Tweaks
lilleyse Apr 23, 2018
9e7dfc7
Merge branch 'master' into copyedit
slchow Apr 24, 2018
5586e25
Sean corrections
slchow Apr 24, 2018
5117393
capitalization
slchow Apr 24, 2018
7169305
Other edits
lilleyse Apr 24, 2018
ba91831
Merge pull request #302 from slchow/copyedit
lilleyse Apr 25, 2018
899b3a3
Merge branch 'master' into tileset.json-edits
ggetz Apr 25, 2018
d3fce88
Spec clarification edits
ggetz Apr 26, 2018
026d7dd
Address CRS, padding, boundingVolumes, geometric error
ggetz May 3, 2018
0f190b1
Move Batch Table hierarchy to an extension
ggetz May 3, 2018
d5c5491
Update schemas
ggetz May 3, 2018
f0e031b
Tweak wording in local coordinate systems
lilleyse May 7, 2018
469a860
Small tweaks
lilleyse May 7, 2018
af25031
Update to 3DTILES_ prefix, updated contributors, fixed figures
ggetz May 7, 2018
4615dcb
Merge branch 'tileset.json-edits' into hierarchy-extension
ggetz May 7, 2018
83f0144
Random edits
lilleyse May 7, 2018
13d6f78
Twwak image, fix link
ggetz May 7, 2018
c3f7c96
Merge pull request #305 from AnalyticalGraphicsInc/hierarchy-extension
lilleyse May 7, 2018
1143bfa
Edits
ggetz May 7, 2018
7b9ae34
Update bounding volume images
ggetz May 7, 2018
e204c9b
Add Refinement section, url->uri, edits, cleanup
ggetz May 8, 2018
082ec85
Misc updates
lilleyse May 8, 2018
fd74204
Stray url to uri
lilleyse May 8, 2018
c02ba37
Other fixes
lilleyse May 8, 2018
ef40a6e
Tweaks to coordinate system and i3dm glb section
lilleyse May 9, 2018
4f6fc68
Fix sentence
lilleyse May 9, 2018
c954b2b
Updated figures
ggetz May 9, 2018
36dde46
Combine crs paragraphs, use some of the original wording, not complet…
lilleyse May 9, 2018
5ba688c
Formatting fix
ggetz May 9, 2018
384e749
Tweaked CRS
ggetz May 9, 2018
98854ad
Merge branch 'tileset.json-edits' into version-upgrade
ggetz May 9, 2018
f5bffdd
Merge pull request #234 from AnalyticalGraphicsInc/version-upgrade
ggetz May 9, 2018
4bc6f90
Add acknowledgements
ggetz May 9, 2018
6dce1a4
Edits
lilleyse May 9, 2018
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ As we add more tile formats, 3D Tiles needs to stay consistent.
## Terminology

* Tiles are composed of `sections` such as `header` and `body`. Sections are composed of `fields` such as `magic` and `version`.
* "Feature" - indicates one model in a batch of models (b3dm), one instance in a collection of instances (i3dm), one point in a point cloud (pnts), one polygon in a vector tile (vctr), etc.
* "Feature" - indicates one model in a batch of models (`b3dm`), one instance in a collection of instances (`i3dm`), one point in a point cloud (`pnts`), etc.

## Fields

Expand Down
601 changes: 413 additions & 188 deletions README.md

Large diffs are not rendered by default.

236 changes: 76 additions & 160 deletions Styling/README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Styling/schema/style.condition.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id" : "style.condition.schema.json",
"title" : "condition",
"type" : "object",
"description" : "A series of conditions evaluated in order like a series of if...else statements that result in an expression being evaluated.",
"description" : "A series of conditions evaluated in order, like a series of if...else statements that result in an expression being evaluated.",
"properties" : {
"conditions" : {
"type" : "array",
Expand All @@ -17,7 +17,7 @@
"minItems" : 2,
"maxItems" : 2
},
"description" : "A series of boolean conditions evaluated in order. For the first one that evaluates to true, its value, the 'result', (which is also an expression) is evaluated and returned. Result expressions must all be the same type. If no condition evaluates to true, the result is `undefined`. When conditions is `undefined`, `null`, or an empty object, the result is `undefined`."
"description" : "A series of boolean conditions evaluated in order. For the first one that evaluates to true, its value, the 'result' (which is also an expression), is evaluated and returned. Result expressions must all be the same type. If no condition evaluates to true, the result is `undefined`. When conditions is `undefined`, `null`, or an empty object, the result is `undefined`."
}
},
"additionalProperties" : false
Expand Down
435 changes: 45 additions & 390 deletions TileFormats/BatchTable/README.md

Large diffs are not rendered by default.

Binary file not shown.
570 changes: 0 additions & 570 deletions TileFormats/BatchTable/figures/batch-table-hierarchy-block.svg

This file was deleted.

Binary file not shown.
120 changes: 71 additions & 49 deletions TileFormats/Batched3DModel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,129 +6,151 @@
* 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 system](#coordinate-system)
* [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`.
A Batched 3D Model tile is a binary blob in little endian.

## 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 contained [Feature Table](../FeatureTable/README.md#padding) and [Batch Table](../BatchTable/README.md#padding) must conform to their respective padding requirement.

The [binary glTF](#binary-gltf) 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 or Batch Table if they are present.

## Header

The 28-byte header contains the following fields:

|Field name|Data type|Description|
|----------|---------|-----------|
| `magic` | 4-byte ANSI string | `"b3dm"`. This can be used to identify the arraybuffer as a Batched 3D Model tile. |
| `magic` | 4-byte ANSI string | `"b3dm"`. This can be used to identify the content 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. |
| `featureTableBinaryByteLength` | `uint32` | The length of the Feature Table binary section in bytes. |
| `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`.

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.
The body section immediately follows the header section, and is composed of three fields: `Feature Table`, `Batch Table`, and `Binary glTF`.

## Feature Table

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 when positions are defined relative-to-center, (see [Coordinate system](#coordinate-system)). | :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.
Batched 3D Model uses [glTF 2.0](https://github.com/KhronosGroup/glTF/tree/master/specification/2.0) to embed model data.

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.

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"
Copy link
Contributor

Choose a reason for hiding this comment

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

Below this example mention that accessor.type must be "SCALAR", but there are no restrictions on the other properties (as long as they are in accordance with glTF).

}
]
}
```

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.
The `accessor.type` must be a value of `"SCALAR"`. All other properties must conform to the glTF schema, but have no additional requirements.

When a Batch Table is present or the `BATCH_LENGTH` property is greater than `0`, the `_BATCHID` attribute is required; otherwise, it is not.

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.
### Coordinate system

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 embedded glTFs use a right handed coordinate system where the _y_-axis is up. For consistency with the _z_-up coordinate system of 3D Tiles, glTFs must be transformed at runtime or optionally use the [`CESIUM_z_up` glTF extension](https://github.com/ggetz/glTF/tree/cesium-z-up-ext/extensions/2.0/Vendor/CESIUM_z_up). See [coordinate reference system](../../README.md#coordinate-reference-system-crs) for more details.

## File Extension
Vertex positions may be defined relative-to-center for high-precision rendering, see [Precisions, Precisions](http://help.agi.com/AGIComponents/html/BlogPrecisionsPrecisions.htm). If defined, `RTC_CENTER` specifies the center position that all vertex positions are relative to after any coordinate system transformations have been applied.

`.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)_
## Implementation example

`application/octet-stream`
Code for reading the header can be found in
[`Batched3DModelTileContent.js`](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Batched3DModel3DTileContent.js)
in the Cesium implementation of 3D Tiles.
Binary file modified TileFormats/Batched3DModel/figures/layout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading