Up to date

This page is up to date for Godot 4.3. If you still find outdated information, please open an issue.

GLTFAccessor

继承: Resource < RefCounted < Object

代表 GLTF 访问器。

描述

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

大多数存储在 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 的数组。


属性说明

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 组件类型枚举。取值为 5120 表示“BYTE”、5121 表示“UNSIGNED_BYTE”、5122 表示“SHORT”、5123 表示“UNSIGNED_SHORT”、5125 表示“UNSIGNED_INT”、5126 表示“FLOAT”。不是通过mesh.primitive.indices 引用的访问器不能使用 5125 或“UNSIGNED_INT”。


int count = 0 🔗

  • void set_count(value: int)

  • int get_count()

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


PackedFloat64Array max = PackedFloat64Array() 🔗

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


PackedFloat64Array min = PackedFloat64Array() 🔗

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


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