Constructor
# new BufferHandler(device, gpuBuffer, maxBufferLength)
Creates a new buffer handler
Parameters:
Name | Type | Description |
---|---|---|
device |
GPUDevice
|
WebGPU device instance |
gpuBuffer |
GPUBuffer
|
GPU buffer for vertex data |
maxBufferLength |
number
|
Maximum buffer length in bytes |
Classes
Members
Methods
# addNewData(data) → {void}
Adds new data to the buffer
Parameters:
Name | Type | Description |
---|---|---|
data |
Float32Array
|
New data to append to buffer |
void
# clearBuffer() → {void}
Clears the buffer content Resets filled length and issues clear command
void
# async exchange_data(data) → {Promise.<void>}
Exchanges current buffer data with new data Clears buffer, adds new data, and waits for GPU operations to complete
Parameters:
Name | Type | Description |
---|---|---|
data |
Float32Array
|
New data to replace current buffer content |
Promise that resolves when buffer update is complete
Promise.<void>
# getBufferLength(buffer_num) → {number}
Gets the total buffer length for a given buffer number
Parameters:
Name | Type | Description |
---|---|---|
buffer_num |
number
|
Buffer index |
Total buffer length in bytes
number
# register_change(func)
Registers a function to be called when buffer content changes
Parameters:
Name | Type | Description |
---|---|---|
func |
function
|
Callback function for change events |
# replaceData(data)
Replaces buffer data without waiting for GPU operations
Parameters:
Name | Type | Description |
---|---|---|
data |
Float32Array
|
New data to replace current buffer content |