UNPKG

@babylonjs/core

Version:

Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.

49 lines 2.08 kB
import { ThinEngine } from "../../Engines/thinEngine.js"; // eslint-disable-next-line @typescript-eslint/no-unused-vars ThinEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset = 0) { // Force cache update this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null; this.bindIndexBuffer(indexBuffer); let view; if (indexBuffer.is32Bits) { // anything else than Uint32Array needs to be converted to Uint32Array view = indices instanceof Uint32Array ? indices : new Uint32Array(indices); } else { // anything else than Uint16Array needs to be converted to Uint16Array view = indices instanceof Uint16Array ? indices : new Uint16Array(indices); } this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, view, this._gl.DYNAMIC_DRAW); this._resetIndexBufferBinding(); }; ThinEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) { this.bindArrayBuffer(vertexBuffer); if (byteOffset === undefined) { byteOffset = 0; } const dataLength = data.byteLength || data.length; if (byteLength === undefined || (byteLength >= dataLength && byteOffset === 0)) { if (data instanceof Array) { this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data)); } else { this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data); } } else { if (data instanceof Array) { this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data).subarray(0, byteLength / 4)); } else { if (data instanceof ArrayBuffer) { data = new Uint8Array(data, 0, byteLength); } else { data = new Uint8Array(data.buffer, data.byteOffset, byteLength); } this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data); } } this._resetVertexBufferBinding(); }; //# sourceMappingURL=engine.dynamicBuffer.js.map