Model loading · class

BlendData

A parsed file: its blocks, its catalogue, and the maps from an address to a block.

Explained in Importing models.

class BlendData
import { BlendData } from '@driftengine/assets';

Constructor

new

constructor(bytes: Uint8Array)
ParameterTypeDescription
bytesUint8Array

Properties

NameTypeDescription
bytesreadonlyUint8Array
viewreadonlyDataView
blocksreadonlyreadonly BlendBlock[]
structsreadonlyreadonly DnaStruct[]

Methods

struct

struct(type: string): DnaStruct | undefined

The catalogue entry for a struct type, or undefined where this file's Blender had none.

ParameterTypeDescription
typestring

scopeOf

scopeOf(block: number): number

The datablock a block's data belongs to, which is what scopes every pointer inside it.

ParameterTypeDescription
blocknumber

find

find(address: bigint, scope: number): { block: number; offset: number; } | null

The block an address falls in, and how far into it, as seen from inside datablock scope.

ParameterTypeDescription
addressbigint
scopenumber
More

The datablock's own data first, then the datablocks themselves, which is the order Blender's reader resolves in. Null for an address nothing holds.

idsOf

idsOf(code: string): BlendStruct[]

Every datablock of a two-letter code — OB, ME, MA — as views of their own struct.

ParameterTypeDescription
codestring

at

at(address: bigint, scope: number, type?: string): BlendStruct | null

A view of the struct at an address, typed by the block that holds it or by type.

ParameterTypeDescription
addressbigint
scopenumber
type?string

array

array(address: bigint, scope: number, type: string, count?: number): BlendStruct[]

The structs of an array a pointer names, indexed inside its block.

ParameterTypeDescription
addressbigint
scopenumber
typestring
count?number
More

Never by adding to the address. From 5.0 an address is a placeholder rather than a location, so base + 24 is not the second element and can be exactly the address of some unrelated block.

raw

raw(address: bigint, scope: number): Uint8Array | null

The raw bytes a pointer names, through the end of its block.

ParameterTypeDescription
addressbigint
scopenumber

text

text(address: bigint, scope: number): string

A zero-terminated string a char * names.

ParameterTypeDescription
addressbigint
scopenumber

blockOf

blockOf(address: bigint, scope: number): BlendBlock | null

The block a pointer names, for its count and its catalogue type.

ParameterTypeDescription
addressbigint
scopenumber

pointer

pointer(at: number): bigint
ParameterTypeDescription
atnumber