Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

GLTFAccessor

继承: Resource < RefCounted < Object

代表 glTF 访问器。

描述

GLTFAccessor 是一种表示 glTF 访问器 "accessors" 的数据结构,可以在 "accessors" 数组中找到。缓冲区是二进制数据块。缓冲区视图是缓冲区的切片。访问器是对缓冲区视图中数据的类型化解释。

大多数存储在 glTF 中的自定义数据不需要访问器,只需要缓冲区视图(见 GLTFBufferView)。访问器适用于更高级的用例,例如为 GPU 编码的交错网格数据。

教程

属性

GLTFAccessorType

accessor_type

0

int

buffer_view

-1

int

byte_offset

0

int

component_type

0

int

count

0

PackedFloat64Array

max

PackedFloat64Array()

PackedFloat64Array

min

PackedFloat64Array()

bool

normalized

false

int

sparse_count

0

int

sparse_indices_buffer_view

0

int

sparse_indices_byte_offset

0

int

sparse_indices_component_type

0

int

sparse_values_buffer_view

0

int

sparse_values_byte_offset

0

int

type


枚举

enum GLTFAccessorType: 🔗

GLTFAccessorType TYPE_SCALAR = 0

“SCALAR”访问器类型。在 glTF 对象模型中可映射为单个 float、int、bool 值或单个 float 数组。

GLTFAccessorType TYPE_VEC2 = 1

“VEC2”访问器类型。在 glTF 对象模型中可映射为“float2”,在 glTF JSON 中表示为包含两个 float 的数组。

GLTFAccessorType TYPE_VEC3 = 2

“VEC3”访问器类型。在 glTF 对象模型中可映射为“float3”,在 glTF JSON 中表示为包含三个 float 的数组。

GLTFAccessorType TYPE_VEC4 = 3

“VEC4”访问器类型。在 glTF 对象模型中可映射为“float4”,在 glTF JSON 中表示为包含四个 float 的数组。

GLTFAccessorType TYPE_MAT2 = 4

“MAT2”访问器类型。在 glTF 对象模型中可映射为“float2x2”,在 glTF JSON 中表示为包含四个 float 的数组。

GLTFAccessorType TYPE_MAT3 = 5

“MAT3”访问器类型。在 glTF 对象模型中可映射为“float3x3”,在 glTF JSON 中表示为包含九个 float 的数组。

GLTFAccessorType TYPE_MAT4 = 6

“MAT4”访问器类型。在 glTF 对象模型中可映射为“float4x4”,在 glTF JSON 中表示为包含十六个 float 的数组。


enum GLTFComponentType: 🔗

GLTFComponentType COMPONENT_TYPE_NONE = 0

组件类型“NONE”。这不是有效的组件类型,用于表示组件类型未设置。

GLTFComponentType COMPONENT_TYPE_SIGNED_BYTE = 5120

组件类型“BYTE”。取值 0x1400 来源于 OpenGL。表示数据的存储形式为 1 字节即 8 位有符号整数。这是 glTF 规范的核心部分。

GLTFComponentType COMPONENT_TYPE_UNSIGNED_BYTE = 5121

组件类型“UNSIGNED_BYTE”。取值 0x1401 来源于 OpenGL。表示数据的存储形式为 1 字节即 8 位无符号整数。这是 glTF 规范的核心部分。

GLTFComponentType COMPONENT_TYPE_SIGNED_SHORT = 5122

组件类型“SHORT”。取值 0x1402 来源于 OpenGL。表示数据的存储形式为 2 字节即 16 位有符号整数。这是 glTF 规范的核心部分。

GLTFComponentType COMPONENT_TYPE_UNSIGNED_SHORT = 5123

组件类型“UNSIGNED_SHORT”。取值 0x1403 来源于 OpenGL。表示数据的存储形式为 2 字节即 16 位无符号整数。这是 glTF 规范的核心部分。

GLTFComponentType COMPONENT_TYPE_SIGNED_INT = 5124

组件类型“INT”。取值 0x1404 来源于 OpenGL。表示数据的存储形式为 4 字节即 32 位有符号整数。这不是 glTF 规范的核心部分,可能并不是所有 glTF 导入器都支持。KHR_interactivity 等扩展可能支持。

GLTFComponentType COMPONENT_TYPE_UNSIGNED_INT = 5125

组件类型“UNSIGNED_INT”。取值 0x1405 来源于 OpenGL。表示数据的存储形式为 4 字节即 32 位无符号整数。这是 glTF 规范的核心部分。

GLTFComponentType COMPONENT_TYPE_SINGLE_FLOAT = 5126

组件类型“FLOAT”。取值 0x1406 来源于 OpenGL。表示数据的存储形式为 4 字节即 32 位浮点数。这是 glTF 规范的核心部分。

GLTFComponentType COMPONENT_TYPE_DOUBLE_FLOAT = 5130

组件类型“DOUBLE”。取值 0x140A 来源于 OpenGL。表示数据的存储形式为 8 字节即 64 位浮点数。这不是 glTF 规范的核心部分,可能并不是所有 glTF 导入器都支持。KHR_interactivity 等扩展可能支持。

GLTFComponentType COMPONENT_TYPE_HALF_FLOAT = 5131

组件类型“HALF_FLOAT”。取值 0x140B 来源于 OpenGL。表示数据的存储形式为 2 字节即 16 位浮点数。这不是 glTF 规范的核心部分,可能并不是所有 glTF 导入器都支持。KHR_interactivity 等扩展可能支持。

GLTFComponentType COMPONENT_TYPE_SIGNED_LONG = 5134

组件类型“LONG”。取值 0x140E 来源于 OpenGL。表示数据的存储形式为 8 字节即 64 位有符号整数。这不是 glTF 规范的核心部分,可能并不是所有 glTF 导入器都支持。KHR_interactivity 等扩展可能支持。

GLTFComponentType COMPONENT_TYPE_UNSIGNED_LONG = 5135

组件类型“UNSIGNED_LONG”。取值 0x140F 来源于 OpenGL。表示数据的存储形式为 8 字节即 64 位无符号整数。这不是 glTF 规范的核心部分,可能并不是所有 glTF 导入器都支持。KHR_interactivity 等扩展可能支持。


属性说明

GLTFAccessorType accessor_type = 0 🔗

glTF 访问器类型枚举。取值为 0 表示“SCALAR”、1 表示“VEC2”、2 表示“VEC3”、3 表示“VEC4”、4 表示“MAT2”、5 表示“MAT3”、6 表示“MAT4”。


int buffer_view = -1 🔗

  • void set_buffer_view(value: int)

  • int get_buffer_view()

该访问器正在引用的缓冲区视图的索引。如果为 -1,则该访问器未引用任何缓冲区视图。


int byte_offset = 0 🔗

  • void set_byte_offset(value: int)

  • int get_byte_offset()

相对于缓冲视图起点的偏移量,单位为字节。


int component_type = 0 🔗

  • void set_component_type(value: int)

  • int get_component_type()

glTF 组件类型枚举。可能的取值见 GLTFComponentType。核心 glTF 规格中,未通过 mesh.primitive.indices 引用的访问器不能使用 5125 或“UNSIGNED_INT”。


int count = 0 🔗

  • void set_count(value: int)

  • int get_count()

该访问器引用的元素数量。


PackedFloat64Array max = PackedFloat64Array() 🔗

该访问器中每个组件的最大值。

Note: The returned array is copied and any changes to it will not update the original property value. See PackedFloat64Array for more details.


PackedFloat64Array min = PackedFloat64Array() 🔗

该访问器中每个组件的最小值。

Note: The returned array is copied and any changes to it will not update the original property value. See PackedFloat64Array for more details.


bool normalized = false 🔗

  • void set_normalized(value: bool)

  • bool get_normalized()

指定整数数据值在使用前是否进行了归一化。


int sparse_count = 0 🔗

  • void set_sparse_count(value: int)

  • int get_sparse_count()

存储在稀疏数组中的偏差访问器值的数量。


int sparse_indices_buffer_view = 0 🔗

  • void set_sparse_indices_buffer_view(value: int)

  • int get_sparse_indices_buffer_view()

具有稀疏索引的缓冲视图的索引。引用的缓冲视图不得定义其 target 或 byteStride 属性。缓冲视图和可选的 byteOffset 必须与 componentType 字节长度对齐。


int sparse_indices_byte_offset = 0 🔗

  • void set_sparse_indices_byte_offset(value: int)

  • int get_sparse_indices_byte_offset()

相对于缓冲视图起点的偏移量,单位为字节。


int sparse_indices_component_type = 0 🔗

  • void set_sparse_indices_component_type(value: int)

  • int get_sparse_indices_component_type()

索引组件数据类型枚举。取值 5121 为“UNSIGNED_BYTE”、5123 为“UNSIGNED_SHORT”、5125 为“UNSIGNED_INT”。


int sparse_values_buffer_view = 0 🔗

  • void set_sparse_values_buffer_view(value: int)

  • int get_sparse_values_buffer_view()

具有稀疏值的 bufferView 的索引。引用的缓冲视图不得定义其 target 或 byteStride 属性。


int sparse_values_byte_offset = 0 🔗

  • void set_sparse_values_byte_offset(value: int)

  • int get_sparse_values_byte_offset()

相对于 bufferView 起始位置的偏移量,单位为字节。


int type 🔗

  • void set_type(value: int)

  • int get_type()

已弃用: Use accessor_type instead.

glTF 访问器类型枚举。请改用 accessor_type