UNPKG

rc-js-util

Version:

A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.

47 lines 1.77 kB
import { _Debug } from "../debug/_debug.js"; /** * @public * Describes a buffer in a fashion similar to an OpenGL attribute. */ export class SegmentedBufferDescriptor { constructor(blockSize, stride = blockSize, start = 0, count = -1) { this.blockSize = blockSize; this.stride = stride; this.start = start; this.count = count; this.end = start + count; } } export function createSegmentedBufferView(buffer, descriptor, wrapper, owner) { return new SegmentedBufferView(buffer, descriptor, wrapper !== null && wrapper !== void 0 ? wrapper : null, owner !== null && owner !== void 0 ? owner : null); } class SegmentedBufferView { getWrapper() { return this.wrapper; } constructor(buffer, descriptor, wrapper, owner) { this.buffer = buffer; this.descriptor = descriptor; this.wrapper = wrapper; if (_BUILD.DEBUG) { _Debug.assert(descriptor.stride > 0, "invalid stride size"); _Debug.assert(descriptor.blockSize > 0, "invalid block size"); } if (descriptor.count === -1) { const writable = descriptor; writable.count = ((buffer.getArray().length - descriptor.start) / descriptor.stride) | 0; writable.end = descriptor.start + descriptor.count * descriptor.stride; } if (buffer.getSharedObjectHandle() == null) { _BUILD.DEBUG && _Debug.assert(wrapper != null, "received shared object, but it was not bound"); this.resourceHandle = wrapper.lifecycleStrategy.createNode(owner); } } getBuffer() { return this.buffer; } getDescriptor() { return this.descriptor; } } //# sourceMappingURL=segmented-buffer-view.js.map