Skip to content

Latest commit

 

History

History
238 lines (173 loc) · 10.9 KB

File metadata and controls

238 lines (173 loc) · 10.9 KB

Batched 3D Model

Warning
Batched 3D Model was deprecated in 3D Tiles 1.1. See b3dm migration guide.

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.

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. The following figure shows the Batched 3D Model layout (dashes indicate optional fields):

layout
Figure 1. Data layout of a Batched 3D Model

Padding

A tile’s byteLength shall be aligned to an 8-byte boundary. The contained Feature Table and Batch Table shall conform to their respective padding requirement.

The binary glTF shall start and end on an 8-byte boundary so that glTF’s byte-alignment guarantees are met. The proper alignment for the start of the binary glTF data can be achieved by padding the Feature Table, or by padding the Batch Table if it is present. The alignment for the end of the binary glTF data can be achieved by padding the tile data with 0-bytes. The actual binary glTF data does not include possible trailing padding bytes. Clients must take into account the length from the binary glTF header, and use this length to determine the part of the tile data that actually represents the binary glTF.

Header

The 28-byte header contains the following fields:

Table 1. Header fields for Batched 3D Models
Field name Data type Description

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.

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.

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.

The full JSON schema can be found in b3dm.featureTable.schema.json.

Semantics

Feature semantics

There are currently no per-feature semantics.

Global semantics

These semantics define global properties for all features.

Table 2. Global semantics for Batched 3D models
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 shall be 0.

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).

No.

Batch Table

The Batch Table contains per-model application-specific properties, 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 a 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 reference for more information.

Binary glTF

Batched 3D Model embeds glTF 2.0 containing model geometry and texture information.

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.

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:

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 batchIds can be assigned.

The batchId parameter is specified in a glTF mesh primitive by providing the _BATCHID attribute semantic, along with the index of the batchId accessor. For example,

"primitives": [
    {
        "attributes": {
            "_BATCHID": 0
        }
    }
]
{
    "accessors": [
        {
            "bufferView": 1,
            "byteOffset": 0,
            "componentType": 5126,
            "count": 4860,
            "max": [2],
            "min": [0],
            "type": "SCALAR"
        }
    ]
}

The accessor.type shall be a value of "SCALAR". All other properties shall 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.

Coordinate system

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 shall be transformed at runtime. See glTF transforms for more details.

Vertex positions may be defined relative-to-center for high-precision rendering, see Precisions, Precisions. If defined, RTC_CENTER specifies the center position that all vertex positions are relative to after the coordinate system transform and glTF node hierarchy transforms have been applied. Specifically, when the RTC_CENTER is defined in the feature table of a Batched 3D Model, the computation of the tile transform is done as follows:

  1. glTF node hierarchy transformations

  2. glTF y-up to z-up transform

  3. The transform for the RTC_CENTER, which is used to translate model vertices

  4. Tile transform

File extension and media type

Batched 3D Model tiles use the .b3dm extension and application/octet-stream media 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.

Implementation example

This section is informative

Code for reading the header can be found in B3dmParser.js in the CesiumJS implementation of 3D Tiles.