|
@@ -1,5 +1,5 @@
|
|
|
import { Observable } from "../Misc/observable";
|
|
|
-import { Nullable, IndicesArray, DataArray } from "../types";
|
|
|
+import { Nullable } from "../types";
|
|
|
import { Scene } from "../scene";
|
|
|
import { InternalTexture } from "../Materials/Textures/internalTexture";
|
|
|
import { IAudioEngine } from "../Audio/audioEngine";
|
|
@@ -23,6 +23,7 @@ import { Logger } from '../Misc/logger';
|
|
|
|
|
|
import "./Extensions/engine.alpha";
|
|
|
import "./Extensions/engine.readTexture";
|
|
|
+import "./Extensions/engine.dynamicBuffer";
|
|
|
|
|
|
declare type Material = import("../Materials/material").Material;
|
|
|
declare type PostProcess = import("../PostProcesses/postProcess").PostProcess;
|
|
@@ -1342,45 +1343,6 @@ export class Engine extends ThinEngine {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Updates a dynamic vertex buffer.
|
|
|
- * @param vertexBuffer the vertex buffer to update
|
|
|
- * @param data the data used to update the vertex buffer
|
|
|
- * @param byteOffset the byte offset of the data
|
|
|
- * @param byteLength the byte length of the data
|
|
|
- */
|
|
|
- public updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void {
|
|
|
- this.bindArrayBuffer(vertexBuffer);
|
|
|
-
|
|
|
- if (byteOffset === undefined) {
|
|
|
- byteOffset = 0;
|
|
|
- }
|
|
|
-
|
|
|
- const dataLength = (data as number[]).length || (data as ArrayBuffer).byteLength;
|
|
|
-
|
|
|
- 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, <ArrayBuffer>data);
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (data instanceof Array) {
|
|
|
- this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
|
|
|
- } else {
|
|
|
- if (data instanceof ArrayBuffer) {
|
|
|
- data = new Uint8Array(data, byteOffset, byteLength);
|
|
|
- } else {
|
|
|
- data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
|
|
|
- }
|
|
|
-
|
|
|
- this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, <ArrayBuffer>data);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- this._resetVertexBufferBinding();
|
|
|
- }
|
|
|
-
|
|
|
public _deletePipelineContext(pipelineContext: IPipelineContext): void {
|
|
|
let webGLPipelineContext = pipelineContext as WebGLPipelineContext;
|
|
|
if (webGLPipelineContext && webGLPipelineContext.program) {
|
|
@@ -1563,29 +1525,6 @@ export class Engine extends ThinEngine {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Update a dynamic index buffer
|
|
|
- * @param indexBuffer defines the target index buffer
|
|
|
- * @param indices defines the data to update
|
|
|
- * @param offset defines the offset in the target index buffer where update should start
|
|
|
- */
|
|
|
- public updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset: number = 0): void {
|
|
|
- // Force cache update
|
|
|
- this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
|
|
|
- this.bindIndexBuffer(indexBuffer);
|
|
|
- var arrayBuffer;
|
|
|
-
|
|
|
- if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
|
|
|
- arrayBuffer = indices;
|
|
|
- } else {
|
|
|
- arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
|
|
|
- }
|
|
|
-
|
|
|
- this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
|
|
|
-
|
|
|
- this._resetIndexBufferBinding();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* Updates the sample count of a render target texture
|
|
|
* @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
|
|
|
* @param texture defines the texture to update
|