@babylonjs/core 6.21.1 → 6.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/Buffers/buffer.js +4 -3
  2. package/Buffers/buffer.js.map +1 -1
  3. package/Engines/Native/nativeInterfaces.d.ts +2 -0
  4. package/Engines/Native/nativeInterfaces.js.map +1 -1
  5. package/Engines/engine.d.ts +3 -1
  6. package/Engines/engine.js +7 -1
  7. package/Engines/engine.js.map +1 -1
  8. package/Engines/nativeEngine.d.ts +2 -2
  9. package/Engines/nativeEngine.js +30 -19
  10. package/Engines/nativeEngine.js.map +1 -1
  11. package/Engines/thinEngine.js +4 -4
  12. package/Engines/thinEngine.js.map +1 -1
  13. package/Engines/webgpuEngine.js +2 -2
  14. package/Engines/webgpuEngine.js.map +1 -1
  15. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.d.ts +16 -0
  16. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js +18 -0
  17. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js.map +1 -0
  18. package/FlowGraph/Blocks/Execution/{flowGraphPlayAnimationBlock.d.ts → Animation/flowGraphPlayAnimationBlock.d.ts} +5 -5
  19. package/FlowGraph/Blocks/Execution/{flowGraphPlayAnimationBlock.js → Animation/flowGraphPlayAnimationBlock.js} +15 -8
  20. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -0
  21. package/FlowGraph/Blocks/Execution/{flowGraphStopAnimationBlock.d.ts → Animation/flowGraphStopAnimationBlock.d.ts} +4 -4
  22. package/FlowGraph/Blocks/Execution/{flowGraphStopAnimationBlock.js → Animation/flowGraphStopAnimationBlock.js} +2 -2
  23. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -0
  24. package/FlowGraph/Blocks/Execution/Animation/index.d.ts +3 -0
  25. package/FlowGraph/Blocks/Execution/Animation/index.js +4 -0
  26. package/FlowGraph/Blocks/Execution/Animation/index.js.map +1 -0
  27. package/FlowGraph/Blocks/Execution/index.d.ts +1 -2
  28. package/FlowGraph/Blocks/Execution/index.js +2 -2
  29. package/FlowGraph/Blocks/Execution/index.js.map +1 -1
  30. package/Gizmos/axisDragGizmo.js +0 -1
  31. package/Gizmos/axisDragGizmo.js.map +1 -1
  32. package/Gizmos/axisScaleGizmo.js +0 -1
  33. package/Gizmos/axisScaleGizmo.js.map +1 -1
  34. package/Gizmos/boundingBoxGizmo.d.ts +12 -0
  35. package/Gizmos/boundingBoxGizmo.js +37 -1
  36. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  37. package/Gizmos/gizmo.d.ts +0 -4
  38. package/Gizmos/gizmo.js +19 -16
  39. package/Gizmos/gizmo.js.map +1 -1
  40. package/Gizmos/planeDragGizmo.js +0 -1
  41. package/Gizmos/planeDragGizmo.js.map +1 -1
  42. package/Gizmos/planeRotationGizmo.js +0 -1
  43. package/Gizmos/planeRotationGizmo.js.map +1 -1
  44. package/Gizmos/scaleGizmo.d.ts +2 -2
  45. package/Gizmos/scaleGizmo.js +5 -2
  46. package/Gizmos/scaleGizmo.js.map +1 -1
  47. package/Materials/PBR/pbrBaseMaterial.js +5 -1
  48. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  49. package/Materials/Textures/equiRectangularCubeTexture.js +24 -4
  50. package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
  51. package/Maths/math.vector.d.ts +1 -1
  52. package/Maths/math.vector.js +1 -1
  53. package/Maths/math.vector.js.map +1 -1
  54. package/Meshes/Compression/dracoCompression.d.ts +6 -0
  55. package/Meshes/Compression/dracoCompression.js +28 -3
  56. package/Meshes/Compression/dracoCompression.js.map +1 -1
  57. package/package.json +1 -1
  58. package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.js.map +0 -1
  59. package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.js.map +0 -1
package/Buffers/buffer.js CHANGED
@@ -178,10 +178,11 @@ export class Buffer {
178
178
  return;
179
179
  }
180
180
  if (this._engine) {
181
- this._engine._releaseBuffer(this._buffer);
181
+ if (this._engine._releaseBuffer(this._buffer)) {
182
+ this._buffer = null;
183
+ this._data = null;
184
+ }
182
185
  }
183
- this._buffer = null;
184
- this._data = null;
185
186
  }
186
187
  }
187
188
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../../../dev/core/src/Buffers/buffer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C;;GAEG;AACH,MAAM,OAAO,MAAM;IAef;;;;;;;;;;OAUG;IACH,YACI,MAA4B,EAC5B,IAA4B,EAC5B,SAAkB,EAClB,MAAM,GAAG,CAAC,EACV,wBAAwB,GAAG,CAAC,MAAM,EAClC,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,KAAK,EAChB,OAAgB;QA1BZ,oBAAe,GAAG,KAAK,CAAC;QA4B5B,IAAI,MAAM,IAAK,MAA0B,CAAC,QAAQ,EAAE;YAChD,mEAAmE;YACnE,IAAI,CAAC,OAAO,GAAI,MAA0B,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,CAAC;SACrE;aAAM;YACH,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;SACzB;QAED,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAI,CAAC,CAAC;QAE7B,IAAI,IAAI,YAAY,UAAU,EAAE;YAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAClB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACvB;aAAM;YACH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAClB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACvB;QAED,IAAI,CAAC,UAAU,GA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EG;AACoB,gCAAmB,GAAG,iBAAiB,CAAC;AAC/D;;GAEG;AACoB,qCAAwB,GAAG,sBAAsB,CAAC;AACzE;;GAEG;AACoB,qCAAwB,GAAG,sBAAsB,CAAC","sourcesContent":["import type { Nullable, DataArray, FloatArray } from \"../types\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { DataBuffer } from \"./dataBuffer\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\n\r\n/**\r\n * Class used to store data that will be store in GPU memory\r\n */\r\nexport class Buffer {\r\n private _engine: Nullable<ThinEngine>;\r\n private _buffer: Nullable<DataBuffer>;\r\n /** @internal */\r\n public _data: Nullable<DataArray>;\r\n private _updatable: boolean;\r\n private _instanced: boolean;\r\n private _divisor: number;\r\n private _isAlreadyOwned = false;\r\n\r\n /**\r\n * Gets the byte stride.\r\n */\r\n public readonly byteStride: number;\r\n\r\n /**\r\n * Constructor\r\n * @param engine the engine\r\n * @param data the data to use for this buffer\r\n * @param updatable whether the data is updatable\r\n * @param stride the stride (optional)\r\n * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)\r\n * @param instanced whether the buffer is instanced (optional)\r\n * @param useBytes set to true if the stride in in bytes (optional)\r\n * @param divisor sets an optional divisor for instances (1 by default)\r\n */\r\n constructor(\r\n engine: Nullable<ThinEngine>,\r\n data: DataArray | DataBuffer,\r\n updatable: boolean,\r\n stride = 0,\r\n postponeInternalCreation = !engine,\r\n instanced = false,\r\n useBytes = false,\r\n divisor?: number\r\n ) {\r\n if (engine && (engine as unknown as Mesh).getScene) {\r\n // old versions of VertexBuffer accepted 'mesh' instead of 'engine'\r\n this._engine = (engine as unknown as Mesh).getScene().getEngine();\r\n } else {\r\n this._engine = engine;\r\n }\r\n\r\n this._updatable = updatable;\r\n this._instanced = instanced;\r\n this._divisor = divisor || 1;\r\n\r\n if (data instanceof DataBuffer) {\r\n this._data = null;\r\n this._buffer = data;\r\n } else {\r\n this._data = data;\r\n this._buffer = null;\r\n }\r\n\r\n this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;\r\n\r\n if (!postponeInternalCreation) {\r\n // by default\r\n this.create();\r\n }\r\n }\r\n\r\n /**\r\n * Create a new VertexBuffer based on the current buffer\r\n * @param kind defines the vertex buffer kind (position, normal, etc.)\r\n * @param offset defines offset in the buffer (0 by default)\r\n * @param size defines the size in floats of attributes (position is 3 for instance)\r\n * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)\r\n * @param instanced defines if the vertex buffer contains indexed data\r\n * @param useBytes defines if the offset and stride are in bytes *\r\n * @param divisor sets an optional divisor for instances (1 by default)\r\n * @returns the new vertex buffer\r\n */\r\n public createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes = false, divisor?: number): VertexBuffer {\r\n const byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;\r\n const byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;\r\n\r\n // a lot of these parameters are ignored as they are overridden by the buffer\r\n return new VertexBuffer(\r\n this._engine,\r\n this,\r\n kind,\r\n this._updatable,\r\n true,\r\n byteStride,\r\n instanced === undefined ? this._instanced : instanced,\r\n byteOffset,\r\n size,\r\n undefined,\r\n undefined,\r\n true,\r\n this._divisor || divisor\r\n );\r\n }\r\n\r\n // Properties\r\n\r\n /**\r\n * Gets a boolean indicating if the Buffer is updatable?\r\n * @returns true if the buffer is updatable\r\n */\r\n public isUpdatable(): boolean {\r\n return this._updatable;\r\n }\r\n\r\n /**\r\n * Gets current buffer's data\r\n * @returns a DataArray or null\r\n */\r\n public getData(): Nullable<DataArray> {\r\n return this._data;\r\n }\r\n\r\n /**\r\n * Gets underlying native buffer\r\n * @returns underlying native buffer\r\n */\r\n public getBuffer(): Nullable<DataBuffer> {\r\n return this._buffer;\r\n }\r\n\r\n /**\r\n * Gets the stride in float32 units (i.e. byte stride / 4).\r\n * May not be an integer if the byte stride is not divisible by 4.\r\n * @returns the stride in float32 units\r\n * @deprecated Please use byteStride instead.\r\n */\r\n public getStrideSize(): number {\r\n return this.byteStride / Float32Array.BYTES_PER_ELEMENT;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Store data into the buffer. Creates the buffer if not used already.\r\n * If the buffer was already used, it will be updated only if it is updatable, otherwise it will do nothing.\r\n * @param data defines the data to store\r\n */\r\n public create(data: Nullable<DataArray> = null): void {\r\n if (!data && this._buffer) {\r\n return; // nothing to do\r\n }\r\n\r\n data = data || this._data;\r\n\r\n if (!data) {\r\n return;\r\n }\r\n\r\n if (!this._engine) {\r\n throw new Error(\"Engine must be provided in the buffer constructor in order to create\");\r\n }\r\n\r\n if (!this._buffer) {\r\n // create buffer\r\n if (this._updatable) {\r\n this._buffer = this._engine.createDynamicVertexBuffer(data);\r\n this._data = data;\r\n } else {\r\n this._buffer = this._engine.createVertexBuffer(data);\r\n }\r\n } else if (this._updatable) {\r\n // update buffer\r\n this._engine.updateDynamicVertexBuffer(this._buffer, data);\r\n this._data = data;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n this._buffer = null;\r\n this.create(this._data);\r\n }\r\n\r\n /**\r\n * Update current buffer data\r\n * @param data defines the data to store\r\n */\r\n public update(data: DataArray): void {\r\n this.create(data);\r\n }\r\n\r\n /**\r\n * Updates the data directly.\r\n * @param data the new data\r\n * @param offset the new offset\r\n * @param vertexCount the vertex count (optional)\r\n * @param useBytes set to true if the offset is in bytes\r\n */\r\n public updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes: boolean = false): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n if (this._updatable) {\r\n if (!this._engine) {\r\n throw new Error(\"Engine must be provided in the buffer constructor in order to update directly\");\r\n }\r\n\r\n // update buffer\r\n this._engine.updateDynamicVertexBuffer(\r\n this._buffer,\r\n data,\r\n useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT,\r\n vertexCount ? vertexCount * this.byteStride : undefined\r\n );\r\n if (offset === 0 && vertexCount === undefined) {\r\n // Keep the data if we easily can\r\n this._data = data;\r\n } else {\r\n this._data = null;\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _increaseReferences() {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n if (!this._isAlreadyOwned) {\r\n this._isAlreadyOwned = true;\r\n return;\r\n }\r\n\r\n this._buffer.references++;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n if (this._engine) {\r\n this._engine._releaseBuffer(this._buffer);\r\n }\r\n\r\n this._buffer = null;\r\n this._data = null;\r\n }\r\n}\r\n\r\n/**\r\n * Specialized buffer used to store vertex data\r\n */\r\nexport class VertexBuffer {\r\n private static _Counter = 0;\r\n\r\n /** @internal */\r\n public _buffer: Buffer;\r\n /** @internal */\r\n public _validOffsetRange: boolean; // used internally by the engine\r\n private _kind: string;\r\n private _size: number;\r\n private _ownsBuffer: boolean;\r\n private _instanced: boolean;\r\n private _instanceDivisor: number;\r\n\r\n /**\r\n * The byte type.\r\n */\r\n public static readonly BYTE = 5120;\r\n\r\n /**\r\n * The unsigned byte type.\r\n */\r\n public static readonly UNSIGNED_BYTE = 5121;\r\n\r\n /**\r\n * The short type.\r\n */\r\n public static readonly SHORT = 5122;\r\n\r\n /**\r\n * The unsigned short type.\r\n */\r\n public static readonly UNSIGNED_SHORT = 5123;\r\n\r\n /**\r\n * The integer type.\r\n */\r\n public static readonly INT = 5124;\r\n\r\n /**\r\n * The unsigned integer type.\r\n */\r\n public static readonly UNSIGNED_INT = 5125;\r\n\r\n /**\r\n * The float type.\r\n */\r\n public static readonly FLOAT = 5126;\r\n\r\n /**\r\n * Gets or sets the instance divisor when in instanced mode\r\n */\r\n public get instanceDivisor(): number {\r\n return this._instanceDivisor;\r\n }\r\n\r\n public set instanceDivisor(value: number) {\r\n const isInstanced = value != 0;\r\n this._instanceDivisor = value;\r\n\r\n if (isInstanced !== this._instanced) {\r\n this._instanced = isInstanced;\r\n this._computeHashCode();\r\n }\r\n }\r\n\r\n /**\r\n * Gets the byte stride.\r\n */\r\n public readonly byteStride: number;\r\n\r\n /**\r\n * Gets the byte offset.\r\n */\r\n public readonly byteOffset: number;\r\n\r\n /**\r\n * Gets whether integer data values should be normalized into a certain range when being casted to a float.\r\n */\r\n public readonly normalized: boolean;\r\n\r\n /**\r\n * Gets the data type of each component in the array.\r\n */\r\n public readonly type: number;\r\n\r\n /**\r\n * Gets the unique id of this vertex buffer\r\n */\r\n public readonly uniqueId: number;\r\n\r\n /**\r\n * Gets a hash code representing the format (type, normalized, size, instanced, stride) of this buffer\r\n * All buffers with the same format will have the same hash code\r\n */\r\n public readonly hashCode: number;\r\n\r\n /**\r\n * Constructor\r\n * @param engine the engine\r\n * @param data the data to use for this vertex buffer\r\n * @param kind the vertex buffer kind\r\n * @param updatable whether the data is updatable\r\n * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)\r\n * @param stride the stride (optional)\r\n * @param instanced whether the buffer is instanced (optional)\r\n * @param offset the offset of the data (optional)\r\n * @param size the number of components (optional)\r\n * @param type the type of the component (optional)\r\n * @param normalized whether the data contains normalized data (optional)\r\n * @param useBytes set to true if stride and offset are in bytes (optional)\r\n * @param divisor defines the instance divisor to use (1 by default)\r\n * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed\r\n */\r\n constructor(\r\n engine: any,\r\n data: DataArray | Buffer | DataBuffer,\r\n kind: string,\r\n updatable: boolean,\r\n postponeInternalCreation?: boolean,\r\n stride?: number,\r\n instanced?: boolean,\r\n offset?: number,\r\n size?: number,\r\n type?: number,\r\n normalized = false,\r\n useBytes = false,\r\n divisor = 1,\r\n takeBufferOwnership = false\r\n ) {\r\n if (data instanceof Buffer) {\r\n this._buffer = data;\r\n this._ownsBuffer = takeBufferOwnership;\r\n } else {\r\n this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);\r\n this._ownsBuffer = true;\r\n }\r\n\r\n this.uniqueId = VertexBuffer._Counter++;\r\n this._kind = kind;\r\n\r\n if (type == undefined) {\r\n const vertexData = this.getData();\r\n this.type = VertexBuffer.FLOAT;\r\n if (vertexData instanceof Int8Array) {\r\n this.type = VertexBuffer.BYTE;\r\n } else if (vertexData instanceof Uint8Array) {\r\n this.type = VertexBuffer.UNSIGNED_BYTE;\r\n } else if (vertexData instanceof Int16Array) {\r\n this.type = VertexBuffer.SHORT;\r\n } else if (vertexData instanceof Uint16Array) {\r\n this.type = VertexBuffer.UNSIGNED_SHORT;\r\n } else if (vertexData instanceof Int32Array) {\r\n this.type = VertexBuffer.INT;\r\n } else if (vertexData instanceof Uint32Array) {\r\n this.type = VertexBuffer.UNSIGNED_INT;\r\n }\r\n } else {\r\n this.type = type;\r\n }\r\n\r\n const typeByteLength = VertexBuffer.GetTypeByteLength(this.type);\r\n\r\n if (useBytes) {\r\n this._size = size || (stride ? stride / typeByteLength : VertexBuffer.DeduceStride(kind));\r\n this.byteStride = stride || this._buffer.byteStride || this._size * typeByteLength;\r\n this.byteOffset = offset || 0;\r\n } else {\r\n this._size = size || stride || VertexBuffer.DeduceStride(kind);\r\n this.byteStride = stride ? stride * typeByteLength : this._buffer.byteStride || this._size * typeByteLength;\r\n this.byteOffset = (offset || 0) * typeByteLength;\r\n }\r\n\r\n this.normalized = normalized;\r\n\r\n this._instanced = instanced !== undefined ? instanced : false;\r\n this._instanceDivisor = instanced ? divisor : 0;\r\n\r\n this._computeHashCode();\r\n }\r\n\r\n private _computeHashCode(): void {\r\n // note: cast to any because the property is declared readonly\r\n (this.hashCode as any) =\r\n ((this.type - 5120) << 0) +\r\n ((this.normalized ? 1 : 0) << 3) +\r\n (this._size << 4) +\r\n ((this._instanced ? 1 : 0) << 6) +\r\n /* keep 5 bits free */\r\n (this.byteStride << 12);\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n this._buffer._rebuild();\r\n }\r\n\r\n /**\r\n * Returns the kind of the VertexBuffer (string)\r\n * @returns a string\r\n */\r\n public getKind(): string {\r\n return this._kind;\r\n }\r\n\r\n // Properties\r\n\r\n /**\r\n * Gets a boolean indicating if the VertexBuffer is updatable?\r\n * @returns true if the buffer is updatable\r\n */\r\n public isUpdatable(): boolean {\r\n return this._buffer.isUpdatable();\r\n }\r\n\r\n /**\r\n * Gets current buffer's data\r\n * @returns a DataArray or null\r\n */\r\n public getData(): Nullable<DataArray> {\r\n return this._buffer.getData();\r\n }\r\n\r\n /**\r\n * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it\r\n * @returns a float array containing vertex data\r\n */\r\n public getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray> {\r\n const data = this.getData();\r\n if (!data) {\r\n return null;\r\n }\r\n\r\n const tightlyPackedByteStride = this.getSize() * VertexBuffer.GetTypeByteLength(this.type);\r\n const count = totalVertices * this.getSize();\r\n\r\n if (this.type !== VertexBuffer.FLOAT || this.byteStride !== tightlyPackedByteStride) {\r\n const copy = new Float32Array(count);\r\n this.forEach(count, (value, index) => (copy[index] = value));\r\n return copy;\r\n }\r\n\r\n if (!(data instanceof Array || data instanceof Float32Array) || this.byteOffset !== 0 || data.length !== count) {\r\n if (data instanceof Array) {\r\n const offset = this.byteOffset / 4;\r\n return data.slice(offset, offset + count);\r\n } else if (data instanceof ArrayBuffer) {\r\n return new Float32Array(data, this.byteOffset, count);\r\n } else {\r\n let offset = data.byteOffset + this.byteOffset;\r\n if (forceCopy) {\r\n const result = new Float32Array(count);\r\n const source = new Float32Array(data.buffer, offset, count);\r\n\r\n result.set(source);\r\n\r\n return result;\r\n }\r\n\r\n // Protect against bad data\r\n const remainder = offset % 4;\r\n\r\n if (remainder) {\r\n offset = Math.max(0, offset - remainder);\r\n }\r\n\r\n return new Float32Array(data.buffer, offset, count);\r\n }\r\n }\r\n\r\n if (forceCopy) {\r\n return data.slice();\r\n }\r\n\r\n return data;\r\n }\r\n\r\n /**\r\n * Gets underlying native buffer\r\n * @returns underlying native buffer\r\n */\r\n public getBuffer(): Nullable<DataBuffer> {\r\n return this._buffer.getBuffer();\r\n }\r\n\r\n /**\r\n * Gets the stride in float32 units (i.e. byte stride / 4).\r\n * May not be an integer if the byte stride is not divisible by 4.\r\n * @returns the stride in float32 units\r\n * @deprecated Please use byteStride instead.\r\n */\r\n public getStrideSize(): number {\r\n return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);\r\n }\r\n\r\n /**\r\n * Returns the offset as a multiple of the type byte length.\r\n * @returns the offset in bytes\r\n * @deprecated Please use byteOffset instead.\r\n */\r\n public getOffset(): number {\r\n return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);\r\n }\r\n\r\n /**\r\n * Returns the number of components or the byte size per vertex attribute\r\n * @param sizeInBytes If true, returns the size in bytes or else the size in number of components of the vertex attribute (default: false)\r\n * @returns the number of components\r\n */\r\n public getSize(sizeInBytes = false): number {\r\n return sizeInBytes ? this._size * VertexBuffer.GetTypeByteLength(this.type) : this._size;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced\r\n * @returns true if this buffer is instanced\r\n */\r\n public getIsInstanced(): boolean {\r\n return this._instanced;\r\n }\r\n\r\n /**\r\n * Returns the instancing divisor, zero for non-instanced (integer).\r\n * @returns a number\r\n */\r\n public getInstanceDivisor(): number {\r\n return this._instanceDivisor;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property\r\n * @param data defines the data to store\r\n */\r\n public create(data?: DataArray): void {\r\n this._buffer.create(data);\r\n }\r\n\r\n /**\r\n * Updates the underlying buffer according to the passed numeric array or Float32Array.\r\n * This function will create a new buffer if the current one is not updatable\r\n * @param data defines the data to store\r\n */\r\n public update(data: DataArray): void {\r\n this._buffer.update(data);\r\n }\r\n\r\n /**\r\n * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.\r\n * Returns the directly updated WebGLBuffer.\r\n * @param data the new data\r\n * @param offset the new offset\r\n * @param useBytes set to true if the offset is in bytes\r\n */\r\n public updateDirectly(data: DataArray, offset: number, useBytes: boolean = false): void {\r\n this._buffer.updateDirectly(data, offset, undefined, useBytes);\r\n }\r\n\r\n /**\r\n * Disposes the VertexBuffer and the underlying WebGLBuffer.\r\n */\r\n public dispose(): void {\r\n if (this._ownsBuffer) {\r\n this._buffer.dispose();\r\n }\r\n }\r\n\r\n /**\r\n * Enumerates each value of this vertex buffer as numbers.\r\n * @param count the number of values to enumerate\r\n * @param callback the callback function called for each value\r\n */\r\n public forEach(count: number, callback: (value: number, index: number) => void): void {\r\n VertexBuffer.ForEach(this._buffer.getData()!, this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);\r\n }\r\n\r\n // Enums\r\n /**\r\n * Positions\r\n */\r\n public static readonly PositionKind = \"position\";\r\n /**\r\n * Normals\r\n */\r\n public static readonly NormalKind = \"normal\";\r\n /**\r\n * Tangents\r\n */\r\n public static readonly TangentKind = \"tangent\";\r\n /**\r\n * Texture coordinates\r\n */\r\n public static readonly UVKind = \"uv\";\r\n /**\r\n * Texture coordinates 2\r\n */\r\n public static readonly UV2Kind = \"uv2\";\r\n /**\r\n * Texture coordinates 3\r\n */\r\n public static readonly UV3Kind = \"uv3\";\r\n /**\r\n * Texture coordinates 4\r\n */\r\n public static readonly UV4Kind = \"uv4\";\r\n /**\r\n * Texture coordinates 5\r\n */\r\n public static readonly UV5Kind = \"uv5\";\r\n /**\r\n * Texture coordinates 6\r\n */\r\n public static readonly UV6Kind = \"uv6\";\r\n /**\r\n * Colors\r\n */\r\n public static readonly ColorKind = \"color\";\r\n /**\r\n * Instance Colors\r\n */\r\n public static readonly ColorInstanceKind = \"instanceColor\";\r\n /**\r\n * Matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesKind = \"matricesIndices\";\r\n /**\r\n * Matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsKind = \"matricesWeights\";\r\n /**\r\n * Additional matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesExtraKind = \"matricesIndicesExtra\";\r\n /**\r\n * Additional matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsExtraKind = \"matricesWeightsExtra\";\r\n\r\n /**\r\n * Deduces the stride given a kind.\r\n * @param kind The kind string to deduce\r\n * @returns The deduced stride\r\n */\r\n public static DeduceStride(kind: string): number {\r\n switch (kind) {\r\n case VertexBuffer.UVKind:\r\n case VertexBuffer.UV2Kind:\r\n case VertexBuffer.UV3Kind:\r\n case VertexBuffer.UV4Kind:\r\n case VertexBuffer.UV5Kind:\r\n case VertexBuffer.UV6Kind:\r\n return 2;\r\n case VertexBuffer.NormalKind:\r\n case VertexBuffer.PositionKind:\r\n return 3;\r\n case VertexBuffer.ColorKind:\r\n case VertexBuffer.MatricesIndicesKind:\r\n case VertexBuffer.MatricesIndicesExtraKind:\r\n case VertexBuffer.MatricesWeightsKind:\r\n case VertexBuffer.MatricesWeightsExtraKind:\r\n case VertexBuffer.TangentKind:\r\n return 4;\r\n default:\r\n throw new Error(\"Invalid kind '\" + kind + \"'\");\r\n }\r\n }\r\n\r\n /**\r\n * Gets the byte length of the given type.\r\n * @param type the type\r\n * @returns the number of bytes\r\n */\r\n public static GetTypeByteLength(type: number): number {\r\n switch (type) {\r\n case VertexBuffer.BYTE:\r\n case VertexBuffer.UNSIGNED_BYTE:\r\n return 1;\r\n case VertexBuffer.SHORT:\r\n case VertexBuffer.UNSIGNED_SHORT:\r\n return 2;\r\n case VertexBuffer.INT:\r\n case VertexBuffer.UNSIGNED_INT:\r\n case VertexBuffer.FLOAT:\r\n return 4;\r\n default:\r\n throw new Error(`Invalid type '${type}'`);\r\n }\r\n }\r\n\r\n /**\r\n * Enumerates each value of the given parameters as numbers.\r\n * @param data the data to enumerate\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param componentCount the number of components per element\r\n * @param componentType the type of the component\r\n * @param count the number of values to enumerate\r\n * @param normalized whether the data is normalized\r\n * @param callback the callback function called for each value\r\n */\r\n public static ForEach(\r\n data: DataArray,\r\n byteOffset: number,\r\n byteStride: number,\r\n componentCount: number,\r\n componentType: number,\r\n count: number,\r\n normalized: boolean,\r\n callback: (value: number, index: number) => void\r\n ): void {\r\n if (data instanceof Array) {\r\n let offset = byteOffset / 4;\r\n const stride = byteStride / 4;\r\n for (let index = 0; index < count; index += componentCount) {\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n callback(data[offset + componentIndex], index + componentIndex);\r\n }\r\n offset += stride;\r\n }\r\n } else {\r\n const dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n const componentByteLength = VertexBuffer.GetTypeByteLength(componentType);\r\n for (let index = 0; index < count; index += componentCount) {\r\n let componentByteOffset = byteOffset;\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n const value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);\r\n callback(value, index + componentIndex);\r\n componentByteOffset += componentByteLength;\r\n }\r\n byteOffset += byteStride;\r\n }\r\n }\r\n }\r\n\r\n private static _GetFloatValue(dataView: DataView, type: number, byteOffset: number, normalized: boolean): number {\r\n switch (type) {\r\n case VertexBuffer.BYTE: {\r\n let value = dataView.getInt8(byteOffset);\r\n if (normalized) {\r\n value = Math.max(value / 127, -1);\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.UNSIGNED_BYTE: {\r\n let value = dataView.getUint8(byteOffset);\r\n if (normalized) {\r\n value = value / 255;\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.SHORT: {\r\n let value = dataView.getInt16(byteOffset, true);\r\n if (normalized) {\r\n value = Math.max(value / 32767, -1);\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.UNSIGNED_SHORT: {\r\n let value = dataView.getUint16(byteOffset, true);\r\n if (normalized) {\r\n value = value / 65535;\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.INT: {\r\n return dataView.getInt32(byteOffset, true);\r\n }\r\n case VertexBuffer.UNSIGNED_INT: {\r\n return dataView.getUint32(byteOffset, true);\r\n }\r\n case VertexBuffer.FLOAT: {\r\n return dataView.getFloat32(byteOffset, true);\r\n }\r\n default: {\r\n throw new Error(`Invalid component type ${type}`);\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../../../dev/core/src/Buffers/buffer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C;;GAEG;AACH,MAAM,OAAO,MAAM;IAef;;;;;;;;;;OAUG;IACH,YACI,MAA4B,EAC5B,IAA4B,EAC5B,SAAkB,EAClB,MAAM,GAAG,CAAC,EACV,wBAAwB,GAAG,CAAC,MAAM,EAClC,SAAS,GAAG,KAAK,EACjB,QAAQ,GAAG,KAAK,EAChB,OAAgB;QA1BZ,oBAAe,GAAG,KAAK,CAAC;QA4B5B,IAAI,MAAM,IAAK,MAA0B,CAAC,QAAQ,EAAE;YAChD,mEAAmE;YACnE,IAAI,CAAC,OAAO,GAAI,MAA0B,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,CAAC;SACrE;aAAM;YACH,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;SACzB;QAED,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAI,CAAC,CAAC;QAE7B,IAAI,IAAI,YAAY,UAAU,EAAE;YAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAClB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;SACvB;aAAM;YACH,IAAI,CAAC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CAAC;AAC3C;;GAEG;AACoB,8BAAiB,GAAG,eAAe,CAAC;AAC3D;;GAEG;AACoB,gCAAmB,GAAG,iBAAiB,CAAC;AAC/D;;GAEG;AACoB,gCAAmB,GAAG,iBAAiB,CAAC;AAC/D;;GAEG;AACoB,qCAAwB,GAAG,sBAAsB,CAAC;AACzE;;GAEG;AACoB,qCAAwB,GAAG,sBAAsB,CAAC","sourcesContent":["import type { Nullable, DataArray, FloatArray } from \"../types\";\r\nimport type { ThinEngine } from \"../Engines/thinEngine\";\r\nimport { DataBuffer } from \"./dataBuffer\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\n\r\n/**\r\n * Class used to store data that will be store in GPU memory\r\n */\r\nexport class Buffer {\r\n private _engine: Nullable<ThinEngine>;\r\n private _buffer: Nullable<DataBuffer>;\r\n /** @internal */\r\n public _data: Nullable<DataArray>;\r\n private _updatable: boolean;\r\n private _instanced: boolean;\r\n private _divisor: number;\r\n private _isAlreadyOwned = false;\r\n\r\n /**\r\n * Gets the byte stride.\r\n */\r\n public readonly byteStride: number;\r\n\r\n /**\r\n * Constructor\r\n * @param engine the engine\r\n * @param data the data to use for this buffer\r\n * @param updatable whether the data is updatable\r\n * @param stride the stride (optional)\r\n * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)\r\n * @param instanced whether the buffer is instanced (optional)\r\n * @param useBytes set to true if the stride in in bytes (optional)\r\n * @param divisor sets an optional divisor for instances (1 by default)\r\n */\r\n constructor(\r\n engine: Nullable<ThinEngine>,\r\n data: DataArray | DataBuffer,\r\n updatable: boolean,\r\n stride = 0,\r\n postponeInternalCreation = !engine,\r\n instanced = false,\r\n useBytes = false,\r\n divisor?: number\r\n ) {\r\n if (engine && (engine as unknown as Mesh).getScene) {\r\n // old versions of VertexBuffer accepted 'mesh' instead of 'engine'\r\n this._engine = (engine as unknown as Mesh).getScene().getEngine();\r\n } else {\r\n this._engine = engine;\r\n }\r\n\r\n this._updatable = updatable;\r\n this._instanced = instanced;\r\n this._divisor = divisor || 1;\r\n\r\n if (data instanceof DataBuffer) {\r\n this._data = null;\r\n this._buffer = data;\r\n } else {\r\n this._data = data;\r\n this._buffer = null;\r\n }\r\n\r\n this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;\r\n\r\n if (!postponeInternalCreation) {\r\n // by default\r\n this.create();\r\n }\r\n }\r\n\r\n /**\r\n * Create a new VertexBuffer based on the current buffer\r\n * @param kind defines the vertex buffer kind (position, normal, etc.)\r\n * @param offset defines offset in the buffer (0 by default)\r\n * @param size defines the size in floats of attributes (position is 3 for instance)\r\n * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)\r\n * @param instanced defines if the vertex buffer contains indexed data\r\n * @param useBytes defines if the offset and stride are in bytes *\r\n * @param divisor sets an optional divisor for instances (1 by default)\r\n * @returns the new vertex buffer\r\n */\r\n public createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes = false, divisor?: number): VertexBuffer {\r\n const byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;\r\n const byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;\r\n\r\n // a lot of these parameters are ignored as they are overridden by the buffer\r\n return new VertexBuffer(\r\n this._engine,\r\n this,\r\n kind,\r\n this._updatable,\r\n true,\r\n byteStride,\r\n instanced === undefined ? this._instanced : instanced,\r\n byteOffset,\r\n size,\r\n undefined,\r\n undefined,\r\n true,\r\n this._divisor || divisor\r\n );\r\n }\r\n\r\n // Properties\r\n\r\n /**\r\n * Gets a boolean indicating if the Buffer is updatable?\r\n * @returns true if the buffer is updatable\r\n */\r\n public isUpdatable(): boolean {\r\n return this._updatable;\r\n }\r\n\r\n /**\r\n * Gets current buffer's data\r\n * @returns a DataArray or null\r\n */\r\n public getData(): Nullable<DataArray> {\r\n return this._data;\r\n }\r\n\r\n /**\r\n * Gets underlying native buffer\r\n * @returns underlying native buffer\r\n */\r\n public getBuffer(): Nullable<DataBuffer> {\r\n return this._buffer;\r\n }\r\n\r\n /**\r\n * Gets the stride in float32 units (i.e. byte stride / 4).\r\n * May not be an integer if the byte stride is not divisible by 4.\r\n * @returns the stride in float32 units\r\n * @deprecated Please use byteStride instead.\r\n */\r\n public getStrideSize(): number {\r\n return this.byteStride / Float32Array.BYTES_PER_ELEMENT;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Store data into the buffer. Creates the buffer if not used already.\r\n * If the buffer was already used, it will be updated only if it is updatable, otherwise it will do nothing.\r\n * @param data defines the data to store\r\n */\r\n public create(data: Nullable<DataArray> = null): void {\r\n if (!data && this._buffer) {\r\n return; // nothing to do\r\n }\r\n\r\n data = data || this._data;\r\n\r\n if (!data) {\r\n return;\r\n }\r\n\r\n if (!this._engine) {\r\n throw new Error(\"Engine must be provided in the buffer constructor in order to create\");\r\n }\r\n\r\n if (!this._buffer) {\r\n // create buffer\r\n if (this._updatable) {\r\n this._buffer = this._engine.createDynamicVertexBuffer(data);\r\n this._data = data;\r\n } else {\r\n this._buffer = this._engine.createVertexBuffer(data);\r\n }\r\n } else if (this._updatable) {\r\n // update buffer\r\n this._engine.updateDynamicVertexBuffer(this._buffer, data);\r\n this._data = data;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n this._buffer = null;\r\n this.create(this._data);\r\n }\r\n\r\n /**\r\n * Update current buffer data\r\n * @param data defines the data to store\r\n */\r\n public update(data: DataArray): void {\r\n this.create(data);\r\n }\r\n\r\n /**\r\n * Updates the data directly.\r\n * @param data the new data\r\n * @param offset the new offset\r\n * @param vertexCount the vertex count (optional)\r\n * @param useBytes set to true if the offset is in bytes\r\n */\r\n public updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes: boolean = false): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n if (this._updatable) {\r\n if (!this._engine) {\r\n throw new Error(\"Engine must be provided in the buffer constructor in order to update directly\");\r\n }\r\n\r\n // update buffer\r\n this._engine.updateDynamicVertexBuffer(\r\n this._buffer,\r\n data,\r\n useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT,\r\n vertexCount ? vertexCount * this.byteStride : undefined\r\n );\r\n if (offset === 0 && vertexCount === undefined) {\r\n // Keep the data if we easily can\r\n this._data = data;\r\n } else {\r\n this._data = null;\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _increaseReferences() {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n if (!this._isAlreadyOwned) {\r\n this._isAlreadyOwned = true;\r\n return;\r\n }\r\n\r\n this._buffer.references++;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n if (this._engine) {\r\n if (this._engine._releaseBuffer(this._buffer)) {\r\n this._buffer = null;\r\n this._data = null;\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Specialized buffer used to store vertex data\r\n */\r\nexport class VertexBuffer {\r\n private static _Counter = 0;\r\n\r\n /** @internal */\r\n public _buffer: Buffer;\r\n /** @internal */\r\n public _validOffsetRange: boolean; // used internally by the engine\r\n private _kind: string;\r\n private _size: number;\r\n private _ownsBuffer: boolean;\r\n private _instanced: boolean;\r\n private _instanceDivisor: number;\r\n\r\n /**\r\n * The byte type.\r\n */\r\n public static readonly BYTE = 5120;\r\n\r\n /**\r\n * The unsigned byte type.\r\n */\r\n public static readonly UNSIGNED_BYTE = 5121;\r\n\r\n /**\r\n * The short type.\r\n */\r\n public static readonly SHORT = 5122;\r\n\r\n /**\r\n * The unsigned short type.\r\n */\r\n public static readonly UNSIGNED_SHORT = 5123;\r\n\r\n /**\r\n * The integer type.\r\n */\r\n public static readonly INT = 5124;\r\n\r\n /**\r\n * The unsigned integer type.\r\n */\r\n public static readonly UNSIGNED_INT = 5125;\r\n\r\n /**\r\n * The float type.\r\n */\r\n public static readonly FLOAT = 5126;\r\n\r\n /**\r\n * Gets or sets the instance divisor when in instanced mode\r\n */\r\n public get instanceDivisor(): number {\r\n return this._instanceDivisor;\r\n }\r\n\r\n public set instanceDivisor(value: number) {\r\n const isInstanced = value != 0;\r\n this._instanceDivisor = value;\r\n\r\n if (isInstanced !== this._instanced) {\r\n this._instanced = isInstanced;\r\n this._computeHashCode();\r\n }\r\n }\r\n\r\n /**\r\n * Gets the byte stride.\r\n */\r\n public readonly byteStride: number;\r\n\r\n /**\r\n * Gets the byte offset.\r\n */\r\n public readonly byteOffset: number;\r\n\r\n /**\r\n * Gets whether integer data values should be normalized into a certain range when being casted to a float.\r\n */\r\n public readonly normalized: boolean;\r\n\r\n /**\r\n * Gets the data type of each component in the array.\r\n */\r\n public readonly type: number;\r\n\r\n /**\r\n * Gets the unique id of this vertex buffer\r\n */\r\n public readonly uniqueId: number;\r\n\r\n /**\r\n * Gets a hash code representing the format (type, normalized, size, instanced, stride) of this buffer\r\n * All buffers with the same format will have the same hash code\r\n */\r\n public readonly hashCode: number;\r\n\r\n /**\r\n * Constructor\r\n * @param engine the engine\r\n * @param data the data to use for this vertex buffer\r\n * @param kind the vertex buffer kind\r\n * @param updatable whether the data is updatable\r\n * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)\r\n * @param stride the stride (optional)\r\n * @param instanced whether the buffer is instanced (optional)\r\n * @param offset the offset of the data (optional)\r\n * @param size the number of components (optional)\r\n * @param type the type of the component (optional)\r\n * @param normalized whether the data contains normalized data (optional)\r\n * @param useBytes set to true if stride and offset are in bytes (optional)\r\n * @param divisor defines the instance divisor to use (1 by default)\r\n * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed\r\n */\r\n constructor(\r\n engine: any,\r\n data: DataArray | Buffer | DataBuffer,\r\n kind: string,\r\n updatable: boolean,\r\n postponeInternalCreation?: boolean,\r\n stride?: number,\r\n instanced?: boolean,\r\n offset?: number,\r\n size?: number,\r\n type?: number,\r\n normalized = false,\r\n useBytes = false,\r\n divisor = 1,\r\n takeBufferOwnership = false\r\n ) {\r\n if (data instanceof Buffer) {\r\n this._buffer = data;\r\n this._ownsBuffer = takeBufferOwnership;\r\n } else {\r\n this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);\r\n this._ownsBuffer = true;\r\n }\r\n\r\n this.uniqueId = VertexBuffer._Counter++;\r\n this._kind = kind;\r\n\r\n if (type == undefined) {\r\n const vertexData = this.getData();\r\n this.type = VertexBuffer.FLOAT;\r\n if (vertexData instanceof Int8Array) {\r\n this.type = VertexBuffer.BYTE;\r\n } else if (vertexData instanceof Uint8Array) {\r\n this.type = VertexBuffer.UNSIGNED_BYTE;\r\n } else if (vertexData instanceof Int16Array) {\r\n this.type = VertexBuffer.SHORT;\r\n } else if (vertexData instanceof Uint16Array) {\r\n this.type = VertexBuffer.UNSIGNED_SHORT;\r\n } else if (vertexData instanceof Int32Array) {\r\n this.type = VertexBuffer.INT;\r\n } else if (vertexData instanceof Uint32Array) {\r\n this.type = VertexBuffer.UNSIGNED_INT;\r\n }\r\n } else {\r\n this.type = type;\r\n }\r\n\r\n const typeByteLength = VertexBuffer.GetTypeByteLength(this.type);\r\n\r\n if (useBytes) {\r\n this._size = size || (stride ? stride / typeByteLength : VertexBuffer.DeduceStride(kind));\r\n this.byteStride = stride || this._buffer.byteStride || this._size * typeByteLength;\r\n this.byteOffset = offset || 0;\r\n } else {\r\n this._size = size || stride || VertexBuffer.DeduceStride(kind);\r\n this.byteStride = stride ? stride * typeByteLength : this._buffer.byteStride || this._size * typeByteLength;\r\n this.byteOffset = (offset || 0) * typeByteLength;\r\n }\r\n\r\n this.normalized = normalized;\r\n\r\n this._instanced = instanced !== undefined ? instanced : false;\r\n this._instanceDivisor = instanced ? divisor : 0;\r\n\r\n this._computeHashCode();\r\n }\r\n\r\n private _computeHashCode(): void {\r\n // note: cast to any because the property is declared readonly\r\n (this.hashCode as any) =\r\n ((this.type - 5120) << 0) +\r\n ((this.normalized ? 1 : 0) << 3) +\r\n (this._size << 4) +\r\n ((this._instanced ? 1 : 0) << 6) +\r\n /* keep 5 bits free */\r\n (this.byteStride << 12);\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n if (!this._buffer) {\r\n return;\r\n }\r\n\r\n this._buffer._rebuild();\r\n }\r\n\r\n /**\r\n * Returns the kind of the VertexBuffer (string)\r\n * @returns a string\r\n */\r\n public getKind(): string {\r\n return this._kind;\r\n }\r\n\r\n // Properties\r\n\r\n /**\r\n * Gets a boolean indicating if the VertexBuffer is updatable?\r\n * @returns true if the buffer is updatable\r\n */\r\n public isUpdatable(): boolean {\r\n return this._buffer.isUpdatable();\r\n }\r\n\r\n /**\r\n * Gets current buffer's data\r\n * @returns a DataArray or null\r\n */\r\n public getData(): Nullable<DataArray> {\r\n return this._buffer.getData();\r\n }\r\n\r\n /**\r\n * Gets current buffer's data as a float array. Float data is constructed if the vertex buffer data cannot be returned directly.\r\n * @param totalVertices number of vertices in the buffer to take into account\r\n * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it\r\n * @returns a float array containing vertex data\r\n */\r\n public getFloatData(totalVertices: number, forceCopy?: boolean): Nullable<FloatArray> {\r\n const data = this.getData();\r\n if (!data) {\r\n return null;\r\n }\r\n\r\n const tightlyPackedByteStride = this.getSize() * VertexBuffer.GetTypeByteLength(this.type);\r\n const count = totalVertices * this.getSize();\r\n\r\n if (this.type !== VertexBuffer.FLOAT || this.byteStride !== tightlyPackedByteStride) {\r\n const copy = new Float32Array(count);\r\n this.forEach(count, (value, index) => (copy[index] = value));\r\n return copy;\r\n }\r\n\r\n if (!(data instanceof Array || data instanceof Float32Array) || this.byteOffset !== 0 || data.length !== count) {\r\n if (data instanceof Array) {\r\n const offset = this.byteOffset / 4;\r\n return data.slice(offset, offset + count);\r\n } else if (data instanceof ArrayBuffer) {\r\n return new Float32Array(data, this.byteOffset, count);\r\n } else {\r\n let offset = data.byteOffset + this.byteOffset;\r\n if (forceCopy) {\r\n const result = new Float32Array(count);\r\n const source = new Float32Array(data.buffer, offset, count);\r\n\r\n result.set(source);\r\n\r\n return result;\r\n }\r\n\r\n // Protect against bad data\r\n const remainder = offset % 4;\r\n\r\n if (remainder) {\r\n offset = Math.max(0, offset - remainder);\r\n }\r\n\r\n return new Float32Array(data.buffer, offset, count);\r\n }\r\n }\r\n\r\n if (forceCopy) {\r\n return data.slice();\r\n }\r\n\r\n return data;\r\n }\r\n\r\n /**\r\n * Gets underlying native buffer\r\n * @returns underlying native buffer\r\n */\r\n public getBuffer(): Nullable<DataBuffer> {\r\n return this._buffer.getBuffer();\r\n }\r\n\r\n /**\r\n * Gets the stride in float32 units (i.e. byte stride / 4).\r\n * May not be an integer if the byte stride is not divisible by 4.\r\n * @returns the stride in float32 units\r\n * @deprecated Please use byteStride instead.\r\n */\r\n public getStrideSize(): number {\r\n return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);\r\n }\r\n\r\n /**\r\n * Returns the offset as a multiple of the type byte length.\r\n * @returns the offset in bytes\r\n * @deprecated Please use byteOffset instead.\r\n */\r\n public getOffset(): number {\r\n return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);\r\n }\r\n\r\n /**\r\n * Returns the number of components or the byte size per vertex attribute\r\n * @param sizeInBytes If true, returns the size in bytes or else the size in number of components of the vertex attribute (default: false)\r\n * @returns the number of components\r\n */\r\n public getSize(sizeInBytes = false): number {\r\n return sizeInBytes ? this._size * VertexBuffer.GetTypeByteLength(this.type) : this._size;\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced\r\n * @returns true if this buffer is instanced\r\n */\r\n public getIsInstanced(): boolean {\r\n return this._instanced;\r\n }\r\n\r\n /**\r\n * Returns the instancing divisor, zero for non-instanced (integer).\r\n * @returns a number\r\n */\r\n public getInstanceDivisor(): number {\r\n return this._instanceDivisor;\r\n }\r\n\r\n // Methods\r\n\r\n /**\r\n * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property\r\n * @param data defines the data to store\r\n */\r\n public create(data?: DataArray): void {\r\n this._buffer.create(data);\r\n }\r\n\r\n /**\r\n * Updates the underlying buffer according to the passed numeric array or Float32Array.\r\n * This function will create a new buffer if the current one is not updatable\r\n * @param data defines the data to store\r\n */\r\n public update(data: DataArray): void {\r\n this._buffer.update(data);\r\n }\r\n\r\n /**\r\n * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.\r\n * Returns the directly updated WebGLBuffer.\r\n * @param data the new data\r\n * @param offset the new offset\r\n * @param useBytes set to true if the offset is in bytes\r\n */\r\n public updateDirectly(data: DataArray, offset: number, useBytes: boolean = false): void {\r\n this._buffer.updateDirectly(data, offset, undefined, useBytes);\r\n }\r\n\r\n /**\r\n * Disposes the VertexBuffer and the underlying WebGLBuffer.\r\n */\r\n public dispose(): void {\r\n if (this._ownsBuffer) {\r\n this._buffer.dispose();\r\n }\r\n }\r\n\r\n /**\r\n * Enumerates each value of this vertex buffer as numbers.\r\n * @param count the number of values to enumerate\r\n * @param callback the callback function called for each value\r\n */\r\n public forEach(count: number, callback: (value: number, index: number) => void): void {\r\n VertexBuffer.ForEach(this._buffer.getData()!, this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);\r\n }\r\n\r\n // Enums\r\n /**\r\n * Positions\r\n */\r\n public static readonly PositionKind = \"position\";\r\n /**\r\n * Normals\r\n */\r\n public static readonly NormalKind = \"normal\";\r\n /**\r\n * Tangents\r\n */\r\n public static readonly TangentKind = \"tangent\";\r\n /**\r\n * Texture coordinates\r\n */\r\n public static readonly UVKind = \"uv\";\r\n /**\r\n * Texture coordinates 2\r\n */\r\n public static readonly UV2Kind = \"uv2\";\r\n /**\r\n * Texture coordinates 3\r\n */\r\n public static readonly UV3Kind = \"uv3\";\r\n /**\r\n * Texture coordinates 4\r\n */\r\n public static readonly UV4Kind = \"uv4\";\r\n /**\r\n * Texture coordinates 5\r\n */\r\n public static readonly UV5Kind = \"uv5\";\r\n /**\r\n * Texture coordinates 6\r\n */\r\n public static readonly UV6Kind = \"uv6\";\r\n /**\r\n * Colors\r\n */\r\n public static readonly ColorKind = \"color\";\r\n /**\r\n * Instance Colors\r\n */\r\n public static readonly ColorInstanceKind = \"instanceColor\";\r\n /**\r\n * Matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesKind = \"matricesIndices\";\r\n /**\r\n * Matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsKind = \"matricesWeights\";\r\n /**\r\n * Additional matrix indices (for bones)\r\n */\r\n public static readonly MatricesIndicesExtraKind = \"matricesIndicesExtra\";\r\n /**\r\n * Additional matrix weights (for bones)\r\n */\r\n public static readonly MatricesWeightsExtraKind = \"matricesWeightsExtra\";\r\n\r\n /**\r\n * Deduces the stride given a kind.\r\n * @param kind The kind string to deduce\r\n * @returns The deduced stride\r\n */\r\n public static DeduceStride(kind: string): number {\r\n switch (kind) {\r\n case VertexBuffer.UVKind:\r\n case VertexBuffer.UV2Kind:\r\n case VertexBuffer.UV3Kind:\r\n case VertexBuffer.UV4Kind:\r\n case VertexBuffer.UV5Kind:\r\n case VertexBuffer.UV6Kind:\r\n return 2;\r\n case VertexBuffer.NormalKind:\r\n case VertexBuffer.PositionKind:\r\n return 3;\r\n case VertexBuffer.ColorKind:\r\n case VertexBuffer.MatricesIndicesKind:\r\n case VertexBuffer.MatricesIndicesExtraKind:\r\n case VertexBuffer.MatricesWeightsKind:\r\n case VertexBuffer.MatricesWeightsExtraKind:\r\n case VertexBuffer.TangentKind:\r\n return 4;\r\n default:\r\n throw new Error(\"Invalid kind '\" + kind + \"'\");\r\n }\r\n }\r\n\r\n /**\r\n * Gets the byte length of the given type.\r\n * @param type the type\r\n * @returns the number of bytes\r\n */\r\n public static GetTypeByteLength(type: number): number {\r\n switch (type) {\r\n case VertexBuffer.BYTE:\r\n case VertexBuffer.UNSIGNED_BYTE:\r\n return 1;\r\n case VertexBuffer.SHORT:\r\n case VertexBuffer.UNSIGNED_SHORT:\r\n return 2;\r\n case VertexBuffer.INT:\r\n case VertexBuffer.UNSIGNED_INT:\r\n case VertexBuffer.FLOAT:\r\n return 4;\r\n default:\r\n throw new Error(`Invalid type '${type}'`);\r\n }\r\n }\r\n\r\n /**\r\n * Enumerates each value of the given parameters as numbers.\r\n * @param data the data to enumerate\r\n * @param byteOffset the byte offset of the data\r\n * @param byteStride the byte stride of the data\r\n * @param componentCount the number of components per element\r\n * @param componentType the type of the component\r\n * @param count the number of values to enumerate\r\n * @param normalized whether the data is normalized\r\n * @param callback the callback function called for each value\r\n */\r\n public static ForEach(\r\n data: DataArray,\r\n byteOffset: number,\r\n byteStride: number,\r\n componentCount: number,\r\n componentType: number,\r\n count: number,\r\n normalized: boolean,\r\n callback: (value: number, index: number) => void\r\n ): void {\r\n if (data instanceof Array) {\r\n let offset = byteOffset / 4;\r\n const stride = byteStride / 4;\r\n for (let index = 0; index < count; index += componentCount) {\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n callback(data[offset + componentIndex], index + componentIndex);\r\n }\r\n offset += stride;\r\n }\r\n } else {\r\n const dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n const componentByteLength = VertexBuffer.GetTypeByteLength(componentType);\r\n for (let index = 0; index < count; index += componentCount) {\r\n let componentByteOffset = byteOffset;\r\n for (let componentIndex = 0; componentIndex < componentCount; componentIndex++) {\r\n const value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);\r\n callback(value, index + componentIndex);\r\n componentByteOffset += componentByteLength;\r\n }\r\n byteOffset += byteStride;\r\n }\r\n }\r\n }\r\n\r\n private static _GetFloatValue(dataView: DataView, type: number, byteOffset: number, normalized: boolean): number {\r\n switch (type) {\r\n case VertexBuffer.BYTE: {\r\n let value = dataView.getInt8(byteOffset);\r\n if (normalized) {\r\n value = Math.max(value / 127, -1);\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.UNSIGNED_BYTE: {\r\n let value = dataView.getUint8(byteOffset);\r\n if (normalized) {\r\n value = value / 255;\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.SHORT: {\r\n let value = dataView.getInt16(byteOffset, true);\r\n if (normalized) {\r\n value = Math.max(value / 32767, -1);\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.UNSIGNED_SHORT: {\r\n let value = dataView.getUint16(byteOffset, true);\r\n if (normalized) {\r\n value = value / 65535;\r\n }\r\n return value;\r\n }\r\n case VertexBuffer.INT: {\r\n return dataView.getInt32(byteOffset, true);\r\n }\r\n case VertexBuffer.UNSIGNED_INT: {\r\n return dataView.getUint32(byteOffset, true);\r\n }\r\n case VertexBuffer.FLOAT: {\r\n return dataView.getFloat32(byteOffset, true);\r\n }\r\n default: {\r\n throw new Error(`Invalid component type ${type}`);\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -258,7 +258,9 @@ interface INativeEngineConstructor {
258
258
  readonly COMMAND_UNBINDFRAMEBUFFER: NativeData;
259
259
  readonly COMMAND_DELETEFRAMEBUFFER: NativeData;
260
260
  readonly COMMAND_DRAWINDEXED: NativeData;
261
+ readonly COMMAND_DRAWINDEXEDINSTANCED?: NativeData;
261
262
  readonly COMMAND_DRAW: NativeData;
263
+ readonly COMMAND_DRAWINSTANCED?: NativeData;
262
264
  readonly COMMAND_CLEAR: NativeData;
263
265
  readonly COMMAND_SETSTENCIL: NativeData;
264
266
  readonly COMMAND_SETVIEWPORT: NativeData;
@@ -1 +1 @@
1
- {"version":3,"file":"nativeInterfaces.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/Native/nativeInterfaces.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { DeviceType } from \"../../DeviceInput/InputDevices/deviceEnums\";\r\nimport type { IDeviceInputSystem } from \"../../DeviceInput/inputInterfaces\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ICanvas, IImage } from \"../ICanvas\";\r\nimport type { NativeData, NativeDataStream } from \"./nativeDataStream\";\r\n\r\nexport type NativeTexture = NativeData;\r\nexport type NativeFramebuffer = NativeData;\r\nexport type NativeVertexArrayObject = NativeData;\r\nexport type NativeProgram = NativeData;\r\nexport type NativeUniform = NativeData;\r\n\r\n/** @internal */\r\nexport interface INativeEngine {\r\n dispose(): void;\r\n\r\n requestAnimationFrame(callback: () => void): void;\r\n\r\n createVertexArray(): NativeData;\r\n\r\n createIndexBuffer(bytes: ArrayBuffer, byteOffset: number, byteLength: number, is32Bits: boolean, dynamic: boolean): NativeData;\r\n recordIndexBuffer(vertexArray: NativeData, indexBuffer: NativeData): void;\r\n updateDynamicIndexBuffer(buffer: NativeData, bytes: ArrayBuffer, byteOffset: number, byteLength: number, startIndex: number): void;\r\n\r\n createVertexBuffer(bytes: ArrayBuffer, byteOffset: number, byteLength: number, dynamic: boolean): NativeData;\r\n recordVertexBuffer(\r\n vertexArray: NativeData,\r\n vertexBuffer: NativeData,\r\n location: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n numElements: number,\r\n type: number,\r\n normalized: boolean,\r\n instanceDivisor: number\r\n ): void;\r\n updateDynamicVertexBuffer(vertexBuffer: NativeData, bytes: ArrayBuffer, byteOffset: number, byteLength: number): void;\r\n\r\n createProgram(vertexShader: string, fragmentShader: string): NativeProgram;\r\n createProgramAsync(vertexShader: string, fragmentShader: string, onSuccess: () => void, onError: (error: Error) => void): NativeProgram;\r\n getUniforms(shaderProgram: NativeProgram, uniformsNames: string[]): WebGLUniformLocation[];\r\n getAttributes(shaderProgram: NativeProgram, attributeNames: string[]): number[];\r\n\r\n createTexture(): NativeTexture;\r\n initializeTexture(texture: NativeTexture, width: number, height: number, hasMips: boolean, format: number, renderTarget: boolean, srgb: boolean, samples: number): void;\r\n loadTexture(texture: NativeTexture, data: ArrayBufferView, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadRawTexture(texture: NativeTexture, data: ArrayBufferView, width: number, height: number, format: number, generateMips: boolean, invertY: boolean): void;\r\n loadRawTexture2DArray(\r\n texture: NativeTexture,\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean\r\n ): void;\r\n loadCubeTexture(texture: NativeTexture, data: Array<ArrayBufferView>, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadCubeTextureWithMips(texture: NativeTexture, data: Array<Array<ArrayBufferView>>, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n getTextureWidth(texture: NativeTexture): number;\r\n getTextureHeight(texture: NativeTexture): number;\r\n copyTexture(desination: NativeTexture, source: NativeTexture): void;\r\n deleteTexture(texture: NativeTexture): void;\r\n readTexture(\r\n texture: NativeTexture,\r\n mipLevel: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n buffer: Nullable<ArrayBuffer>,\r\n bufferOffset: number,\r\n bufferLength: number\r\n ): Promise<ArrayBuffer>;\r\n\r\n createImageBitmap(data: ArrayBufferView | IImage): ImageBitmap;\r\n resizeImageBitmap(image: ImageBitmap, bufferWidth: number, bufferHeight: number): Uint8Array;\r\n\r\n createFrameBuffer(\r\n texture: Nullable<NativeTexture>,\r\n width: number,\r\n height: number,\r\n generateStencilBuffer: boolean,\r\n generateDepthBuffer: boolean,\r\n samples: number\r\n ): NativeFramebuffer;\r\n\r\n getRenderWidth(): number;\r\n getRenderHeight(): number;\r\n\r\n setHardwareScalingLevel(level: number): void;\r\n\r\n setViewPort(x: number, y: number, width: number, height: number): void;\r\n\r\n setCommandDataStream(dataStream: NativeDataStream): void;\r\n submitCommands(): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeEngineConstructor {\r\n prototype: INativeEngine;\r\n new (): INativeEngine;\r\n\r\n readonly PROTOCOL_VERSION: number;\r\n\r\n readonly CAPS_LIMITS_MAX_TEXTURE_SIZE: number;\r\n readonly CAPS_LIMITS_MAX_TEXTURE_LAYERS: number;\r\n\r\n readonly TEXTURE_NEAREST_NEAREST: number;\r\n readonly TEXTURE_LINEAR_LINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_LINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST: number;\r\n\r\n readonly DEPTH_TEST_LESS: number;\r\n readonly DEPTH_TEST_LEQUAL: number;\r\n readonly DEPTH_TEST_EQUAL: number;\r\n readonly DEPTH_TEST_GEQUAL: number;\r\n readonly DEPTH_TEST_GREATER: number;\r\n readonly DEPTH_TEST_NOTEQUAL: number;\r\n readonly DEPTH_TEST_NEVER: number;\r\n readonly DEPTH_TEST_ALWAYS: number;\r\n\r\n readonly ADDRESS_MODE_WRAP: number;\r\n readonly ADDRESS_MODE_MIRROR: number;\r\n readonly ADDRESS_MODE_CLAMP: number;\r\n readonly ADDRESS_MODE_BORDER: number;\r\n readonly ADDRESS_MODE_MIRROR_ONCE: number;\r\n\r\n readonly TEXTURE_FORMAT_BC1: number;\r\n readonly TEXTURE_FORMAT_BC2: number;\r\n readonly TEXTURE_FORMAT_BC3: number;\r\n readonly TEXTURE_FORMAT_BC4: number;\r\n readonly TEXTURE_FORMAT_BC5: number;\r\n readonly TEXTURE_FORMAT_BC6H: number;\r\n readonly TEXTURE_FORMAT_BC7: number;\r\n readonly TEXTURE_FORMAT_ETC1: number;\r\n readonly TEXTURE_FORMAT_ETC2: number;\r\n readonly TEXTURE_FORMAT_ETC2A: number;\r\n readonly TEXTURE_FORMAT_ETC2A1: number;\r\n readonly TEXTURE_FORMAT_PTC12: number;\r\n readonly TEXTURE_FORMAT_PTC14: number;\r\n readonly TEXTURE_FORMAT_PTC12A: number;\r\n readonly TEXTURE_FORMAT_PTC14A: number;\r\n readonly TEXTURE_FORMAT_PTC22: number;\r\n readonly TEXTURE_FORMAT_PTC24: number;\r\n readonly TEXTURE_FORMAT_ATC: number;\r\n readonly TEXTURE_FORMAT_ATCE: number;\r\n readonly TEXTURE_FORMAT_ATCI: number;\r\n readonly TEXTURE_FORMAT_ASTC4x4: number;\r\n readonly TEXTURE_FORMAT_ASTC5x4: number;\r\n readonly TEXTURE_FORMAT_ASTC5x5: number;\r\n readonly TEXTURE_FORMAT_ASTC6x5: number;\r\n readonly TEXTURE_FORMAT_ASTC6x6: number;\r\n readonly TEXTURE_FORMAT_ASTC8x5: number;\r\n readonly TEXTURE_FORMAT_ASTC8x6: number;\r\n readonly TEXTURE_FORMAT_ASTC8x8: number;\r\n readonly TEXTURE_FORMAT_ASTC10x5: number;\r\n readonly TEXTURE_FORMAT_ASTC10x6: number;\r\n readonly TEXTURE_FORMAT_ASTC10x8: number;\r\n readonly TEXTURE_FORMAT_ASTC10x10: number;\r\n readonly TEXTURE_FORMAT_ASTC12x10: number;\r\n readonly TEXTURE_FORMAT_ASTC12x12: number;\r\n\r\n readonly TEXTURE_FORMAT_R1: number;\r\n readonly TEXTURE_FORMAT_A8: number;\r\n readonly TEXTURE_FORMAT_R8: number;\r\n readonly TEXTURE_FORMAT_R8I: number;\r\n readonly TEXTURE_FORMAT_R8U: number;\r\n readonly TEXTURE_FORMAT_R8S: number;\r\n readonly TEXTURE_FORMAT_R16: number;\r\n readonly TEXTURE_FORMAT_R16I: number;\r\n readonly TEXTURE_FORMAT_R16U: number;\r\n readonly TEXTURE_FORMAT_R16F: number;\r\n readonly TEXTURE_FORMAT_R16S: number;\r\n readonly TEXTURE_FORMAT_R32I: number;\r\n readonly TEXTURE_FORMAT_R32U: number;\r\n readonly TEXTURE_FORMAT_R32F: number;\r\n readonly TEXTURE_FORMAT_RG8: number;\r\n readonly TEXTURE_FORMAT_RG8I: number;\r\n readonly TEXTURE_FORMAT_RG8U: number;\r\n readonly TEXTURE_FORMAT_RG8S: number;\r\n readonly TEXTURE_FORMAT_RG16: number;\r\n readonly TEXTURE_FORMAT_RG16I: number;\r\n readonly TEXTURE_FORMAT_RG16U: number;\r\n readonly TEXTURE_FORMAT_RG16F: number;\r\n readonly TEXTURE_FORMAT_RG16S: number;\r\n readonly TEXTURE_FORMAT_RG32I: number;\r\n readonly TEXTURE_FORMAT_RG32U: number;\r\n readonly TEXTURE_FORMAT_RG32F: number;\r\n readonly TEXTURE_FORMAT_RGB8: number;\r\n readonly TEXTURE_FORMAT_RGB8I: number;\r\n readonly TEXTURE_FORMAT_RGB8U: number;\r\n readonly TEXTURE_FORMAT_RGB8S: number;\r\n readonly TEXTURE_FORMAT_RGB9E5F: number;\r\n readonly TEXTURE_FORMAT_BGRA8: number;\r\n readonly TEXTURE_FORMAT_RGBA8: number;\r\n readonly TEXTURE_FORMAT_RGBA8I: number;\r\n readonly TEXTURE_FORMAT_RGBA8U: number;\r\n readonly TEXTURE_FORMAT_RGBA8S: number;\r\n readonly TEXTURE_FORMAT_RGBA16: number;\r\n readonly TEXTURE_FORMAT_RGBA16I: number;\r\n readonly TEXTURE_FORMAT_RGBA16U: number;\r\n readonly TEXTURE_FORMAT_RGBA16F: number;\r\n readonly TEXTURE_FORMAT_RGBA16S: number;\r\n readonly TEXTURE_FORMAT_RGBA32I: number;\r\n readonly TEXTURE_FORMAT_RGBA32U: number;\r\n readonly TEXTURE_FORMAT_RGBA32F: number;\r\n readonly TEXTURE_FORMAT_B5G6R5: number;\r\n readonly TEXTURE_FORMAT_R5G6B5: number;\r\n readonly TEXTURE_FORMAT_BGRA4: number;\r\n readonly TEXTURE_FORMAT_RGBA4: number;\r\n readonly TEXTURE_FORMAT_BGR5A1: number;\r\n readonly TEXTURE_FORMAT_RGB5A1: number;\r\n readonly TEXTURE_FORMAT_RGB10A2: number;\r\n readonly TEXTURE_FORMAT_RG11B10F: number;\r\n\r\n readonly TEXTURE_FORMAT_D16: number;\r\n readonly TEXTURE_FORMAT_D24: number;\r\n readonly TEXTURE_FORMAT_D24S8: number;\r\n readonly TEXTURE_FORMAT_D32: number;\r\n readonly TEXTURE_FORMAT_D16F: number;\r\n readonly TEXTURE_FORMAT_D24F: number;\r\n readonly TEXTURE_FORMAT_D32F: number;\r\n readonly TEXTURE_FORMAT_D0S8: number;\r\n\r\n readonly ATTRIB_TYPE_INT8: number;\r\n readonly ATTRIB_TYPE_UINT8: number;\r\n readonly ATTRIB_TYPE_INT16: number;\r\n readonly ATTRIB_TYPE_UINT16: number;\r\n readonly ATTRIB_TYPE_FLOAT: number;\r\n\r\n readonly ALPHA_DISABLE: number;\r\n readonly ALPHA_ADD: number;\r\n readonly ALPHA_COMBINE: number;\r\n readonly ALPHA_SUBTRACT: number;\r\n readonly ALPHA_MULTIPLY: number;\r\n readonly ALPHA_MAXIMIZED: number;\r\n readonly ALPHA_ONEONE: number;\r\n readonly ALPHA_PREMULTIPLIED: number;\r\n readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;\r\n readonly ALPHA_INTERPOLATE: number;\r\n readonly ALPHA_SCREENMODE: number;\r\n\r\n readonly STENCIL_TEST_LESS: number;\r\n readonly STENCIL_TEST_LEQUAL: number;\r\n readonly STENCIL_TEST_EQUAL: number;\r\n readonly STENCIL_TEST_GEQUAL: number;\r\n readonly STENCIL_TEST_GREATER: number;\r\n readonly STENCIL_TEST_NOTEQUAL: number;\r\n readonly STENCIL_TEST_NEVER: number;\r\n readonly STENCIL_TEST_ALWAYS: number;\r\n\r\n readonly STENCIL_OP_FAIL_S_ZERO: number;\r\n readonly STENCIL_OP_FAIL_S_KEEP: number;\r\n readonly STENCIL_OP_FAIL_S_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_S_INCR: number;\r\n readonly STENCIL_OP_FAIL_S_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_DECR: number;\r\n readonly STENCIL_OP_FAIL_S_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_INVERT: number;\r\n\r\n readonly STENCIL_OP_FAIL_Z_ZERO: number;\r\n readonly STENCIL_OP_FAIL_Z_KEEP: number;\r\n readonly STENCIL_OP_FAIL_Z_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_Z_INCR: number;\r\n readonly STENCIL_OP_FAIL_Z_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_DECR: number;\r\n readonly STENCIL_OP_FAIL_Z_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_INVERT: number;\r\n\r\n readonly STENCIL_OP_PASS_Z_ZERO: number;\r\n readonly STENCIL_OP_PASS_Z_KEEP: number;\r\n readonly STENCIL_OP_PASS_Z_REPLACE: number;\r\n readonly STENCIL_OP_PASS_Z_INCR: number;\r\n readonly STENCIL_OP_PASS_Z_INCRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_DECR: number;\r\n readonly STENCIL_OP_PASS_Z_DECRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_INVERT: number;\r\n\r\n readonly COMMAND_DELETEVERTEXARRAY: NativeData;\r\n readonly COMMAND_DELETEINDEXBUFFER: NativeData;\r\n readonly COMMAND_DELETEVERTEXBUFFER: NativeData;\r\n readonly COMMAND_SETPROGRAM: NativeData;\r\n readonly COMMAND_SETMATRIX: NativeData;\r\n readonly COMMAND_SETMATRIX3X3: NativeData;\r\n readonly COMMAND_SETMATRIX2X2: NativeData;\r\n readonly COMMAND_SETMATRICES: NativeData;\r\n readonly COMMAND_SETINT: NativeData;\r\n readonly COMMAND_SETINTARRAY: NativeData;\r\n readonly COMMAND_SETINTARRAY2: NativeData;\r\n readonly COMMAND_SETINTARRAY3: NativeData;\r\n readonly COMMAND_SETINTARRAY4: NativeData;\r\n readonly COMMAND_SETFLOATARRAY: NativeData;\r\n readonly COMMAND_SETFLOATARRAY2: NativeData;\r\n readonly COMMAND_SETFLOATARRAY3: NativeData;\r\n readonly COMMAND_SETFLOATARRAY4: NativeData;\r\n readonly COMMAND_SETTEXTURESAMPLING: NativeData;\r\n readonly COMMAND_SETTEXTUREWRAPMODE: NativeData;\r\n readonly COMMAND_SETTEXTUREANISOTROPICLEVEL: NativeData;\r\n readonly COMMAND_SETTEXTURE: NativeData;\r\n readonly COMMAND_BINDVERTEXARRAY: NativeData;\r\n readonly COMMAND_SETSTATE: NativeData;\r\n readonly COMMAND_DELETEPROGRAM: NativeData;\r\n readonly COMMAND_SETZOFFSET: NativeData;\r\n readonly COMMAND_SETZOFFSETUNITS: NativeData;\r\n readonly COMMAND_SETDEPTHTEST: NativeData;\r\n readonly COMMAND_SETDEPTHWRITE: NativeData;\r\n readonly COMMAND_SETCOLORWRITE: NativeData;\r\n readonly COMMAND_SETBLENDMODE: NativeData;\r\n readonly COMMAND_SETFLOAT: NativeData;\r\n readonly COMMAND_SETFLOAT2: NativeData;\r\n readonly COMMAND_SETFLOAT3: NativeData;\r\n readonly COMMAND_SETFLOAT4: NativeData;\r\n readonly COMMAND_BINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_UNBINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DELETEFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DRAWINDEXED: NativeData;\r\n readonly COMMAND_DRAW: NativeData;\r\n readonly COMMAND_CLEAR: NativeData;\r\n readonly COMMAND_SETSTENCIL: NativeData;\r\n readonly COMMAND_SETVIEWPORT: NativeData;\r\n readonly COMMAND_SETSCISSOR: NativeData;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeCamera {\r\n createVideo(constraints: MediaTrackConstraints): any;\r\n updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCameraConstructor {\r\n prototype: INativeCamera;\r\n new (): INativeCamera;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCanvasConstructor {\r\n prototype: ICanvas;\r\n new (): ICanvas;\r\n\r\n loadTTFAsync(fontName: string, buffer: ArrayBuffer): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeImageConstructor {\r\n prototype: IImage;\r\n new (): IImage;\r\n}\r\n\r\n/** @internal */\r\ninterface IDeviceInputSystemConstructor {\r\n prototype: IDeviceInputSystem;\r\n new (\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: number) => void\r\n ): IDeviceInputSystem;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeDataStream {\r\n writeBuffer(buffer: ArrayBuffer, length: number): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeDataStreamConstructor {\r\n prototype: INativeDataStream;\r\n new (requestFlushCallback: () => void): INativeDataStream;\r\n\r\n readonly VALIDATION_ENABLED: boolean;\r\n readonly VALIDATION_UINT_32: number;\r\n readonly VALIDATION_INT_32: number;\r\n readonly VALIDATION_FLOAT_32: number;\r\n readonly VALIDATION_UINT_32_ARRAY: number;\r\n readonly VALIDATION_INT_32_ARRAY: number;\r\n readonly VALIDATION_FLOAT_32_ARRAY: number;\r\n readonly VALIDATION_NATIVE_DATA: number;\r\n readonly VALIDATION_BOOLEAN: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface INative {\r\n Engine: INativeEngineConstructor;\r\n Camera: INativeCameraConstructor;\r\n Canvas: INativeCanvasConstructor;\r\n Image: INativeImageConstructor;\r\n XMLHttpRequest: any; // TODO: how to do this?\r\n DeviceInputSystem: IDeviceInputSystemConstructor;\r\n NativeDataStream: INativeDataStreamConstructor;\r\n}\r\n"]}
1
+ {"version":3,"file":"nativeInterfaces.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/Native/nativeInterfaces.ts"],"names":[],"mappings":"","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { DeviceType } from \"../../DeviceInput/InputDevices/deviceEnums\";\r\nimport type { IDeviceInputSystem } from \"../../DeviceInput/inputInterfaces\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ICanvas, IImage } from \"../ICanvas\";\r\nimport type { NativeData, NativeDataStream } from \"./nativeDataStream\";\r\n\r\nexport type NativeTexture = NativeData;\r\nexport type NativeFramebuffer = NativeData;\r\nexport type NativeVertexArrayObject = NativeData;\r\nexport type NativeProgram = NativeData;\r\nexport type NativeUniform = NativeData;\r\n\r\n/** @internal */\r\nexport interface INativeEngine {\r\n dispose(): void;\r\n\r\n requestAnimationFrame(callback: () => void): void;\r\n\r\n createVertexArray(): NativeData;\r\n\r\n createIndexBuffer(bytes: ArrayBuffer, byteOffset: number, byteLength: number, is32Bits: boolean, dynamic: boolean): NativeData;\r\n recordIndexBuffer(vertexArray: NativeData, indexBuffer: NativeData): void;\r\n updateDynamicIndexBuffer(buffer: NativeData, bytes: ArrayBuffer, byteOffset: number, byteLength: number, startIndex: number): void;\r\n\r\n createVertexBuffer(bytes: ArrayBuffer, byteOffset: number, byteLength: number, dynamic: boolean): NativeData;\r\n recordVertexBuffer(\r\n vertexArray: NativeData,\r\n vertexBuffer: NativeData,\r\n location: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n numElements: number,\r\n type: number,\r\n normalized: boolean,\r\n instanceDivisor: number\r\n ): void;\r\n updateDynamicVertexBuffer(vertexBuffer: NativeData, bytes: ArrayBuffer, byteOffset: number, byteLength: number): void;\r\n\r\n createProgram(vertexShader: string, fragmentShader: string): NativeProgram;\r\n createProgramAsync(vertexShader: string, fragmentShader: string, onSuccess: () => void, onError: (error: Error) => void): NativeProgram;\r\n getUniforms(shaderProgram: NativeProgram, uniformsNames: string[]): WebGLUniformLocation[];\r\n getAttributes(shaderProgram: NativeProgram, attributeNames: string[]): number[];\r\n\r\n createTexture(): NativeTexture;\r\n initializeTexture(texture: NativeTexture, width: number, height: number, hasMips: boolean, format: number, renderTarget: boolean, srgb: boolean, samples: number): void;\r\n loadTexture(texture: NativeTexture, data: ArrayBufferView, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadRawTexture(texture: NativeTexture, data: ArrayBufferView, width: number, height: number, format: number, generateMips: boolean, invertY: boolean): void;\r\n loadRawTexture2DArray(\r\n texture: NativeTexture,\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean\r\n ): void;\r\n loadCubeTexture(texture: NativeTexture, data: Array<ArrayBufferView>, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadCubeTextureWithMips(texture: NativeTexture, data: Array<Array<ArrayBufferView>>, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n getTextureWidth(texture: NativeTexture): number;\r\n getTextureHeight(texture: NativeTexture): number;\r\n copyTexture(desination: NativeTexture, source: NativeTexture): void;\r\n deleteTexture(texture: NativeTexture): void;\r\n readTexture(\r\n texture: NativeTexture,\r\n mipLevel: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n buffer: Nullable<ArrayBuffer>,\r\n bufferOffset: number,\r\n bufferLength: number\r\n ): Promise<ArrayBuffer>;\r\n\r\n createImageBitmap(data: ArrayBufferView | IImage): ImageBitmap;\r\n resizeImageBitmap(image: ImageBitmap, bufferWidth: number, bufferHeight: number): Uint8Array;\r\n\r\n createFrameBuffer(\r\n texture: Nullable<NativeTexture>,\r\n width: number,\r\n height: number,\r\n generateStencilBuffer: boolean,\r\n generateDepthBuffer: boolean,\r\n samples: number\r\n ): NativeFramebuffer;\r\n\r\n getRenderWidth(): number;\r\n getRenderHeight(): number;\r\n\r\n setHardwareScalingLevel(level: number): void;\r\n\r\n setViewPort(x: number, y: number, width: number, height: number): void;\r\n\r\n setCommandDataStream(dataStream: NativeDataStream): void;\r\n submitCommands(): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeEngineConstructor {\r\n prototype: INativeEngine;\r\n new (): INativeEngine;\r\n\r\n readonly PROTOCOL_VERSION: number;\r\n\r\n readonly CAPS_LIMITS_MAX_TEXTURE_SIZE: number;\r\n readonly CAPS_LIMITS_MAX_TEXTURE_LAYERS: number;\r\n\r\n readonly TEXTURE_NEAREST_NEAREST: number;\r\n readonly TEXTURE_LINEAR_LINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_LINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST: number;\r\n\r\n readonly DEPTH_TEST_LESS: number;\r\n readonly DEPTH_TEST_LEQUAL: number;\r\n readonly DEPTH_TEST_EQUAL: number;\r\n readonly DEPTH_TEST_GEQUAL: number;\r\n readonly DEPTH_TEST_GREATER: number;\r\n readonly DEPTH_TEST_NOTEQUAL: number;\r\n readonly DEPTH_TEST_NEVER: number;\r\n readonly DEPTH_TEST_ALWAYS: number;\r\n\r\n readonly ADDRESS_MODE_WRAP: number;\r\n readonly ADDRESS_MODE_MIRROR: number;\r\n readonly ADDRESS_MODE_CLAMP: number;\r\n readonly ADDRESS_MODE_BORDER: number;\r\n readonly ADDRESS_MODE_MIRROR_ONCE: number;\r\n\r\n readonly TEXTURE_FORMAT_BC1: number;\r\n readonly TEXTURE_FORMAT_BC2: number;\r\n readonly TEXTURE_FORMAT_BC3: number;\r\n readonly TEXTURE_FORMAT_BC4: number;\r\n readonly TEXTURE_FORMAT_BC5: number;\r\n readonly TEXTURE_FORMAT_BC6H: number;\r\n readonly TEXTURE_FORMAT_BC7: number;\r\n readonly TEXTURE_FORMAT_ETC1: number;\r\n readonly TEXTURE_FORMAT_ETC2: number;\r\n readonly TEXTURE_FORMAT_ETC2A: number;\r\n readonly TEXTURE_FORMAT_ETC2A1: number;\r\n readonly TEXTURE_FORMAT_PTC12: number;\r\n readonly TEXTURE_FORMAT_PTC14: number;\r\n readonly TEXTURE_FORMAT_PTC12A: number;\r\n readonly TEXTURE_FORMAT_PTC14A: number;\r\n readonly TEXTURE_FORMAT_PTC22: number;\r\n readonly TEXTURE_FORMAT_PTC24: number;\r\n readonly TEXTURE_FORMAT_ATC: number;\r\n readonly TEXTURE_FORMAT_ATCE: number;\r\n readonly TEXTURE_FORMAT_ATCI: number;\r\n readonly TEXTURE_FORMAT_ASTC4x4: number;\r\n readonly TEXTURE_FORMAT_ASTC5x4: number;\r\n readonly TEXTURE_FORMAT_ASTC5x5: number;\r\n readonly TEXTURE_FORMAT_ASTC6x5: number;\r\n readonly TEXTURE_FORMAT_ASTC6x6: number;\r\n readonly TEXTURE_FORMAT_ASTC8x5: number;\r\n readonly TEXTURE_FORMAT_ASTC8x6: number;\r\n readonly TEXTURE_FORMAT_ASTC8x8: number;\r\n readonly TEXTURE_FORMAT_ASTC10x5: number;\r\n readonly TEXTURE_FORMAT_ASTC10x6: number;\r\n readonly TEXTURE_FORMAT_ASTC10x8: number;\r\n readonly TEXTURE_FORMAT_ASTC10x10: number;\r\n readonly TEXTURE_FORMAT_ASTC12x10: number;\r\n readonly TEXTURE_FORMAT_ASTC12x12: number;\r\n\r\n readonly TEXTURE_FORMAT_R1: number;\r\n readonly TEXTURE_FORMAT_A8: number;\r\n readonly TEXTURE_FORMAT_R8: number;\r\n readonly TEXTURE_FORMAT_R8I: number;\r\n readonly TEXTURE_FORMAT_R8U: number;\r\n readonly TEXTURE_FORMAT_R8S: number;\r\n readonly TEXTURE_FORMAT_R16: number;\r\n readonly TEXTURE_FORMAT_R16I: number;\r\n readonly TEXTURE_FORMAT_R16U: number;\r\n readonly TEXTURE_FORMAT_R16F: number;\r\n readonly TEXTURE_FORMAT_R16S: number;\r\n readonly TEXTURE_FORMAT_R32I: number;\r\n readonly TEXTURE_FORMAT_R32U: number;\r\n readonly TEXTURE_FORMAT_R32F: number;\r\n readonly TEXTURE_FORMAT_RG8: number;\r\n readonly TEXTURE_FORMAT_RG8I: number;\r\n readonly TEXTURE_FORMAT_RG8U: number;\r\n readonly TEXTURE_FORMAT_RG8S: number;\r\n readonly TEXTURE_FORMAT_RG16: number;\r\n readonly TEXTURE_FORMAT_RG16I: number;\r\n readonly TEXTURE_FORMAT_RG16U: number;\r\n readonly TEXTURE_FORMAT_RG16F: number;\r\n readonly TEXTURE_FORMAT_RG16S: number;\r\n readonly TEXTURE_FORMAT_RG32I: number;\r\n readonly TEXTURE_FORMAT_RG32U: number;\r\n readonly TEXTURE_FORMAT_RG32F: number;\r\n readonly TEXTURE_FORMAT_RGB8: number;\r\n readonly TEXTURE_FORMAT_RGB8I: number;\r\n readonly TEXTURE_FORMAT_RGB8U: number;\r\n readonly TEXTURE_FORMAT_RGB8S: number;\r\n readonly TEXTURE_FORMAT_RGB9E5F: number;\r\n readonly TEXTURE_FORMAT_BGRA8: number;\r\n readonly TEXTURE_FORMAT_RGBA8: number;\r\n readonly TEXTURE_FORMAT_RGBA8I: number;\r\n readonly TEXTURE_FORMAT_RGBA8U: number;\r\n readonly TEXTURE_FORMAT_RGBA8S: number;\r\n readonly TEXTURE_FORMAT_RGBA16: number;\r\n readonly TEXTURE_FORMAT_RGBA16I: number;\r\n readonly TEXTURE_FORMAT_RGBA16U: number;\r\n readonly TEXTURE_FORMAT_RGBA16F: number;\r\n readonly TEXTURE_FORMAT_RGBA16S: number;\r\n readonly TEXTURE_FORMAT_RGBA32I: number;\r\n readonly TEXTURE_FORMAT_RGBA32U: number;\r\n readonly TEXTURE_FORMAT_RGBA32F: number;\r\n readonly TEXTURE_FORMAT_B5G6R5: number;\r\n readonly TEXTURE_FORMAT_R5G6B5: number;\r\n readonly TEXTURE_FORMAT_BGRA4: number;\r\n readonly TEXTURE_FORMAT_RGBA4: number;\r\n readonly TEXTURE_FORMAT_BGR5A1: number;\r\n readonly TEXTURE_FORMAT_RGB5A1: number;\r\n readonly TEXTURE_FORMAT_RGB10A2: number;\r\n readonly TEXTURE_FORMAT_RG11B10F: number;\r\n\r\n readonly TEXTURE_FORMAT_D16: number;\r\n readonly TEXTURE_FORMAT_D24: number;\r\n readonly TEXTURE_FORMAT_D24S8: number;\r\n readonly TEXTURE_FORMAT_D32: number;\r\n readonly TEXTURE_FORMAT_D16F: number;\r\n readonly TEXTURE_FORMAT_D24F: number;\r\n readonly TEXTURE_FORMAT_D32F: number;\r\n readonly TEXTURE_FORMAT_D0S8: number;\r\n\r\n readonly ATTRIB_TYPE_INT8: number;\r\n readonly ATTRIB_TYPE_UINT8: number;\r\n readonly ATTRIB_TYPE_INT16: number;\r\n readonly ATTRIB_TYPE_UINT16: number;\r\n readonly ATTRIB_TYPE_FLOAT: number;\r\n\r\n readonly ALPHA_DISABLE: number;\r\n readonly ALPHA_ADD: number;\r\n readonly ALPHA_COMBINE: number;\r\n readonly ALPHA_SUBTRACT: number;\r\n readonly ALPHA_MULTIPLY: number;\r\n readonly ALPHA_MAXIMIZED: number;\r\n readonly ALPHA_ONEONE: number;\r\n readonly ALPHA_PREMULTIPLIED: number;\r\n readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;\r\n readonly ALPHA_INTERPOLATE: number;\r\n readonly ALPHA_SCREENMODE: number;\r\n\r\n readonly STENCIL_TEST_LESS: number;\r\n readonly STENCIL_TEST_LEQUAL: number;\r\n readonly STENCIL_TEST_EQUAL: number;\r\n readonly STENCIL_TEST_GEQUAL: number;\r\n readonly STENCIL_TEST_GREATER: number;\r\n readonly STENCIL_TEST_NOTEQUAL: number;\r\n readonly STENCIL_TEST_NEVER: number;\r\n readonly STENCIL_TEST_ALWAYS: number;\r\n\r\n readonly STENCIL_OP_FAIL_S_ZERO: number;\r\n readonly STENCIL_OP_FAIL_S_KEEP: number;\r\n readonly STENCIL_OP_FAIL_S_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_S_INCR: number;\r\n readonly STENCIL_OP_FAIL_S_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_DECR: number;\r\n readonly STENCIL_OP_FAIL_S_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_INVERT: number;\r\n\r\n readonly STENCIL_OP_FAIL_Z_ZERO: number;\r\n readonly STENCIL_OP_FAIL_Z_KEEP: number;\r\n readonly STENCIL_OP_FAIL_Z_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_Z_INCR: number;\r\n readonly STENCIL_OP_FAIL_Z_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_DECR: number;\r\n readonly STENCIL_OP_FAIL_Z_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_INVERT: number;\r\n\r\n readonly STENCIL_OP_PASS_Z_ZERO: number;\r\n readonly STENCIL_OP_PASS_Z_KEEP: number;\r\n readonly STENCIL_OP_PASS_Z_REPLACE: number;\r\n readonly STENCIL_OP_PASS_Z_INCR: number;\r\n readonly STENCIL_OP_PASS_Z_INCRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_DECR: number;\r\n readonly STENCIL_OP_PASS_Z_DECRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_INVERT: number;\r\n\r\n readonly COMMAND_DELETEVERTEXARRAY: NativeData;\r\n readonly COMMAND_DELETEINDEXBUFFER: NativeData;\r\n readonly COMMAND_DELETEVERTEXBUFFER: NativeData;\r\n readonly COMMAND_SETPROGRAM: NativeData;\r\n readonly COMMAND_SETMATRIX: NativeData;\r\n readonly COMMAND_SETMATRIX3X3: NativeData;\r\n readonly COMMAND_SETMATRIX2X2: NativeData;\r\n readonly COMMAND_SETMATRICES: NativeData;\r\n readonly COMMAND_SETINT: NativeData;\r\n readonly COMMAND_SETINTARRAY: NativeData;\r\n readonly COMMAND_SETINTARRAY2: NativeData;\r\n readonly COMMAND_SETINTARRAY3: NativeData;\r\n readonly COMMAND_SETINTARRAY4: NativeData;\r\n readonly COMMAND_SETFLOATARRAY: NativeData;\r\n readonly COMMAND_SETFLOATARRAY2: NativeData;\r\n readonly COMMAND_SETFLOATARRAY3: NativeData;\r\n readonly COMMAND_SETFLOATARRAY4: NativeData;\r\n readonly COMMAND_SETTEXTURESAMPLING: NativeData;\r\n readonly COMMAND_SETTEXTUREWRAPMODE: NativeData;\r\n readonly COMMAND_SETTEXTUREANISOTROPICLEVEL: NativeData;\r\n readonly COMMAND_SETTEXTURE: NativeData;\r\n readonly COMMAND_BINDVERTEXARRAY: NativeData;\r\n readonly COMMAND_SETSTATE: NativeData;\r\n readonly COMMAND_DELETEPROGRAM: NativeData;\r\n readonly COMMAND_SETZOFFSET: NativeData;\r\n readonly COMMAND_SETZOFFSETUNITS: NativeData;\r\n readonly COMMAND_SETDEPTHTEST: NativeData;\r\n readonly COMMAND_SETDEPTHWRITE: NativeData;\r\n readonly COMMAND_SETCOLORWRITE: NativeData;\r\n readonly COMMAND_SETBLENDMODE: NativeData;\r\n readonly COMMAND_SETFLOAT: NativeData;\r\n readonly COMMAND_SETFLOAT2: NativeData;\r\n readonly COMMAND_SETFLOAT3: NativeData;\r\n readonly COMMAND_SETFLOAT4: NativeData;\r\n readonly COMMAND_BINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_UNBINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DELETEFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DRAWINDEXED: NativeData;\r\n readonly COMMAND_DRAWINDEXEDINSTANCED?: NativeData;\r\n readonly COMMAND_DRAW: NativeData;\r\n readonly COMMAND_DRAWINSTANCED?: NativeData;\r\n readonly COMMAND_CLEAR: NativeData;\r\n readonly COMMAND_SETSTENCIL: NativeData;\r\n readonly COMMAND_SETVIEWPORT: NativeData;\r\n readonly COMMAND_SETSCISSOR: NativeData;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeCamera {\r\n createVideo(constraints: MediaTrackConstraints): any;\r\n updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCameraConstructor {\r\n prototype: INativeCamera;\r\n new (): INativeCamera;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCanvasConstructor {\r\n prototype: ICanvas;\r\n new (): ICanvas;\r\n\r\n loadTTFAsync(fontName: string, buffer: ArrayBuffer): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeImageConstructor {\r\n prototype: IImage;\r\n new (): IImage;\r\n}\r\n\r\n/** @internal */\r\ninterface IDeviceInputSystemConstructor {\r\n prototype: IDeviceInputSystem;\r\n new (\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: number) => void\r\n ): IDeviceInputSystem;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeDataStream {\r\n writeBuffer(buffer: ArrayBuffer, length: number): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeDataStreamConstructor {\r\n prototype: INativeDataStream;\r\n new (requestFlushCallback: () => void): INativeDataStream;\r\n\r\n readonly VALIDATION_ENABLED: boolean;\r\n readonly VALIDATION_UINT_32: number;\r\n readonly VALIDATION_INT_32: number;\r\n readonly VALIDATION_FLOAT_32: number;\r\n readonly VALIDATION_UINT_32_ARRAY: number;\r\n readonly VALIDATION_INT_32_ARRAY: number;\r\n readonly VALIDATION_FLOAT_32_ARRAY: number;\r\n readonly VALIDATION_NATIVE_DATA: number;\r\n readonly VALIDATION_BOOLEAN: number;\r\n}\r\n\r\n/** @internal */\r\nexport interface INative {\r\n Engine: INativeEngineConstructor;\r\n Camera: INativeCameraConstructor;\r\n Canvas: INativeCanvasConstructor;\r\n Image: INativeImageConstructor;\r\n XMLHttpRequest: any; // TODO: how to do this?\r\n DeviceInputSystem: IDeviceInputSystemConstructor;\r\n NativeDataStream: INativeDataStreamConstructor;\r\n}\r\n"]}
@@ -832,9 +832,11 @@ export declare class Engine extends ThinEngine {
832
832
  * @param texture defines the external texture
833
833
  * @param hasMipMaps defines whether the external texture has mip maps (default: false)
834
834
  * @param samplingMode defines the sampling mode for the external texture (default: Constants.TEXTURE_TRILINEAR_SAMPLINGMODE)
835
+ * @param width defines the width for the external texture (default: 0)
836
+ * @param height defines the height for the external texture (default: 0)
835
837
  * @returns the babylon internal texture
836
838
  */
837
- wrapWebGLTexture(texture: WebGLTexture, hasMipMaps?: boolean, samplingMode?: number): InternalTexture;
839
+ wrapWebGLTexture(texture: WebGLTexture, hasMipMaps?: boolean, samplingMode?: number, width?: number, height?: number): InternalTexture;
838
840
  /**
839
841
  * @internal
840
842
  */
package/Engines/engine.js CHANGED
@@ -1182,12 +1182,18 @@ export class Engine extends ThinEngine {
1182
1182
  * @param texture defines the external texture
1183
1183
  * @param hasMipMaps defines whether the external texture has mip maps (default: false)
1184
1184
  * @param samplingMode defines the sampling mode for the external texture (default: 3)
1185
+ * @param width defines the width for the external texture (default: 0)
1186
+ * @param height defines the height for the external texture (default: 0)
1185
1187
  * @returns the babylon internal texture
1186
1188
  */
1187
- wrapWebGLTexture(texture, hasMipMaps = false, samplingMode = 3) {
1189
+ wrapWebGLTexture(texture, hasMipMaps = false, samplingMode = 3, width = 0, height = 0) {
1188
1190
  const hardwareTexture = new WebGLHardwareTexture(texture, this._gl);
1189
1191
  const internalTexture = new InternalTexture(this, InternalTextureSource.Unknown, true);
1190
1192
  internalTexture._hardwareTexture = hardwareTexture;
1193
+ internalTexture.baseWidth = width;
1194
+ internalTexture.baseHeight = height;
1195
+ internalTexture.width = width;
1196
+ internalTexture.height = height;
1191
1197
  internalTexture.isReady = true;
1192
1198
  internalTexture.useMipMaps = hasMipMaps;
1193
1199
  this.updateTextureSamplingMode(samplingMode, internalTexture);