@babylonjs/core 6.46.1 → 6.48.0

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 (72) hide show
  1. package/Buffers/buffer.align.d.ts +3 -3
  2. package/Buffers/buffer.align.js +1 -1
  3. package/Buffers/buffer.align.js.map +1 -1
  4. package/Engines/Native/nativeInterfaces.d.ts +1 -0
  5. package/Engines/Native/nativeInterfaces.js.map +1 -1
  6. package/Engines/engine.js +9 -9
  7. package/Engines/engine.js.map +1 -1
  8. package/Engines/engineFeatures.d.ts +2 -2
  9. package/Engines/engineFeatures.js.map +1 -1
  10. package/Engines/nativeEngine.d.ts +1 -0
  11. package/Engines/nativeEngine.js +21 -1
  12. package/Engines/nativeEngine.js.map +1 -1
  13. package/Engines/nullEngine.js +1 -1
  14. package/Engines/nullEngine.js.map +1 -1
  15. package/Engines/thinEngine.d.ts +5 -3
  16. package/Engines/thinEngine.js +53 -43
  17. package/Engines/thinEngine.js.map +1 -1
  18. package/Engines/webgpuEngine.js +1 -1
  19. package/Engines/webgpuEngine.js.map +1 -1
  20. package/Loading/sceneLoader.js +2 -1
  21. package/Loading/sceneLoader.js.map +1 -1
  22. package/Materials/Node/Blocks/posterizeBlock.js +1 -0
  23. package/Materials/Node/Blocks/posterizeBlock.js.map +1 -1
  24. package/Maths/index.d.ts +1 -0
  25. package/Maths/index.js +1 -0
  26. package/Maths/index.js.map +1 -1
  27. package/Maths/math.vector.functions.d.ts +22 -0
  28. package/Maths/math.vector.functions.js +28 -0
  29. package/Maths/math.vector.functions.js.map +1 -0
  30. package/Meshes/Node/Blocks/debugBlock.d.ts +1 -1
  31. package/Meshes/Node/Blocks/debugBlock.js +16 -2
  32. package/Meshes/Node/Blocks/debugBlock.js.map +1 -1
  33. package/Meshes/Node/Blocks/geometryPosterizeBlock.js +26 -1
  34. package/Meshes/Node/Blocks/geometryPosterizeBlock.js.map +1 -1
  35. package/Meshes/mesh.js +12 -0
  36. package/Meshes/mesh.js.map +1 -1
  37. package/Misc/khronosTextureContainer2Worker.js +1 -1
  38. package/Misc/khronosTextureContainer2Worker.js.map +1 -1
  39. package/NOTICE.md +10 -0
  40. package/Particles/IParticleSystem.d.ts +3 -1
  41. package/Particles/IParticleSystem.js.map +1 -1
  42. package/Particles/particleSystem.d.ts +1 -1
  43. package/Particles/particleSystem.js +17 -1
  44. package/Particles/particleSystem.js.map +1 -1
  45. package/Particles/thinParticleSystem.d.ts +5 -3
  46. package/Particles/thinParticleSystem.js +6 -4
  47. package/Particles/thinParticleSystem.js.map +1 -1
  48. package/Physics/physicsPointProximityQuery.d.ts +1 -1
  49. package/Physics/physicsPointProximityQuery.js.map +1 -1
  50. package/Physics/v2/Plugins/havokPlugin.js +3 -1
  51. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  52. package/Physics/v2/physicsBody.d.ts +6 -1
  53. package/Physics/v2/physicsBody.js +7 -0
  54. package/Physics/v2/physicsBody.js.map +1 -1
  55. package/Physics/v2/ragdoll.d.ts +16 -5
  56. package/Physics/v2/ragdoll.js +91 -42
  57. package/Physics/v2/ragdoll.js.map +1 -1
  58. package/XR/features/WebXRAbstractFeature.d.ts +2 -1
  59. package/XR/features/WebXRAbstractFeature.js +3 -2
  60. package/XR/features/WebXRAbstractFeature.js.map +1 -1
  61. package/XR/features/WebXRControllerPointerSelection.d.ts +10 -0
  62. package/XR/features/WebXRControllerPointerSelection.js +41 -20
  63. package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
  64. package/XR/features/WebXRControllerTeleportation.d.ts +1 -0
  65. package/XR/features/WebXRControllerTeleportation.js +7 -2
  66. package/XR/features/WebXRControllerTeleportation.js.map +1 -1
  67. package/assetContainer.js +1 -1
  68. package/assetContainer.js.map +1 -1
  69. package/assets/Basis/basis_transcoder.js +24 -0
  70. package/assets/Draco/draco_decoder_gltf.js +35 -0
  71. package/assets/Draco/draco_wasm_wrapper_gltf.js +116 -0
  72. package/package.json +3 -3
@@ -4,17 +4,17 @@ declare module "./buffer" {
4
4
  interface VertexBuffer {
5
5
  /**
6
6
  * Gets the effective byte stride, that is the byte stride of the buffer that is actually sent to the GPU.
7
- * It could be different from VertexBuffer.byteStride if a new buffer must be created under the hood because of the forceVertexBufferStrideMultiple4Bytes engine flag.
7
+ * It could be different from VertexBuffer.byteStride if a new buffer must be created under the hood because of the forceVertexBufferStrideAndOffsetMultiple4Bytes engine flag.
8
8
  */
9
9
  effectiveByteStride: number;
10
10
  /**
11
11
  * Gets the effective byte offset, that is the byte offset of the buffer that is actually sent to the GPU.
12
- * It could be different from VertexBuffer.byteOffset if a new buffer must be created under the hood because of the forceVertexBufferStrideMultiple4Bytes engine flag.
12
+ * It could be different from VertexBuffer.byteOffset if a new buffer must be created under the hood because of the forceVertexBufferStrideAndOffsetMultiple4Bytes engine flag.
13
13
  */
14
14
  effectiveByteOffset: number;
15
15
  /**
16
16
  * Gets the effective buffer, that is the buffer that is actually sent to the GPU.
17
- * It could be different from VertexBuffer.getBuffer() if a new buffer must be created under the hood because of the forceVertexBufferStrideMultiple4Bytes engine flag.
17
+ * It could be different from VertexBuffer.getBuffer() if a new buffer must be created under the hood because of the forceVertexBufferStrideAndOffsetMultiple4Bytes engine flag.
18
18
  */
19
19
  effectiveBuffer: Nullable<DataBuffer>;
20
20
  /** @internal */
@@ -42,7 +42,7 @@ VertexBuffer.prototype.getWrapperBuffer = function () {
42
42
  };
43
43
  VertexBuffer.prototype._alignBuffer = function () {
44
44
  const data = this._buffer.getData();
45
- if (!this.engine._features.forceVertexBufferStrideMultiple4Bytes || this.byteStride % 4 === 0 || !data) {
45
+ if (!this.engine._features.forceVertexBufferStrideAndOffsetMultiple4Bytes || (this.byteStride % 4 === 0 && this.byteOffset % 4 === 0) || !data) {
46
46
  return;
47
47
  }
48
48
  const typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
@@ -1 +1 @@
1
- {"version":3,"file":"buffer.align.js","sourceRoot":"","sources":["../../../../dev/core/src/Buffers/buffer.align.ts"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,CAAC,EAAE,cAAc,CAAC,CAAC;oBAC7F,MAAM;gBACV,KAAK,YAAY,CAAC,YAAY;oBAC1B,WAAW,CAAC,CAAC,GAAG,WAAW,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,YAAY,GAAG,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC,CAAC;oBAC9F,MAAM;gBACV,KAAK,YAAY,CAAC,KAAK;oBACnB,WAAW,CAAC,CAAC,GAAG,WAAW,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,YAAY,GAAG,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC,CAAC;oBAC/F,MAAM;aACb;SACJ;QACD,YAAY,IAAI,IAAI,CAAC,UAAU,CAAC;KACnC;IAED,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC;IAC/B,IAAI,CAAC,cAAc,GAAG,IAAI,MAAM,CAC5B,IAAI,CAAC,MAAM,EACX,WAAW,EACX,KAAK,EACL,iBAAiB,EACjB,KAAK,EACL,IAAI,CAAC,cAAc,EAAE,EACrB,IAAI,EACJ,IAAI,CAAC,eAAe,EACpB,CAAC,IAAI,CAAC,MAAM,IAAI,cAAc,CAAC,GAAG,UAAU,CAC/C,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { DataBuffer } from \"./dataBuffer\";\r\nimport { Buffer, VertexBuffer } from \"./buffer\";\r\n\r\nconst isLittleEndian = (() => {\r\n const array = new Uint8Array(4);\r\n const view = new Uint32Array(array.buffer);\r\n\r\n return !!((view[0] = 1) & array[0]);\r\n})();\r\n\r\ndeclare module \"./buffer\" {\r\n export interface VertexBuffer {\r\n /**\r\n * Gets the effective byte stride, that is the byte stride of the buffer that is actually sent to the GPU.\r\n * It could be different from VertexBuffer.byteStride if a new buffer must be created under the hood because of the forceVertexBufferStrideMultiple4Bytes engine flag.\r\n */\r\n effectiveByteStride: number;\r\n\r\n /**\r\n * Gets the effective byte offset, that is the byte offset of the buffer that is actually sent to the GPU.\r\n * It could be different from VertexBuffer.byteOffset if a new buffer must be created under the hood because of the forceVertexBufferStrideMultiple4Bytes engine flag.\r\n */\r\n effectiveByteOffset: number;\r\n\r\n /**\r\n * Gets the effective buffer, that is the buffer that is actually sent to the GPU.\r\n * It could be different from VertexBuffer.getBuffer() if a new buffer must be created under the hood because of the forceVertexBufferStrideMultiple4Bytes engine flag.\r\n */\r\n effectiveBuffer: Nullable<DataBuffer>;\r\n\r\n /** @internal */\r\n _alignBuffer(): void;\r\n\r\n /** @internal */\r\n _alignedBuffer?: Buffer;\r\n }\r\n}\r\n\r\nObject.defineProperty(VertexBuffer.prototype, \"effectiveByteStride\", {\r\n get: function (this: VertexBuffer) {\r\n return (this._alignedBuffer && this._alignedBuffer.byteStride) || this.byteStride;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(VertexBuffer.prototype, \"effectiveByteOffset\", {\r\n get: function (this: VertexBuffer) {\r\n return this._alignedBuffer ? 0 : this.byteOffset;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(VertexBuffer.prototype, \"effectiveBuffer\", {\r\n get: function (this: VertexBuffer) {\r\n return (this._alignedBuffer && this._alignedBuffer.getBuffer()) || this._buffer.getBuffer();\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nVertexBuffer.prototype._rebuild = function (): void {\r\n this._buffer?._rebuild();\r\n this._alignedBuffer?._rebuild();\r\n};\r\n\r\nVertexBuffer.prototype.dispose = function (): void {\r\n if (this._ownsBuffer) {\r\n this._buffer.dispose();\r\n }\r\n\r\n this._alignedBuffer?.dispose();\r\n this._alignedBuffer = undefined;\r\n\r\n this._isDisposed = true;\r\n};\r\n\r\nVertexBuffer.prototype.getWrapperBuffer = function (): Buffer {\r\n return this._alignedBuffer || this._buffer;\r\n};\r\n\r\nVertexBuffer.prototype._alignBuffer = function (): void {\r\n const data = this._buffer.getData();\r\n\r\n if (!this.engine._features.forceVertexBufferStrideMultiple4Bytes || this.byteStride % 4 === 0 || !data) {\r\n return;\r\n }\r\n\r\n const typeByteLength = VertexBuffer.GetTypeByteLength(this.type);\r\n const alignedByteStride = (this.byteStride + 3) & ~3;\r\n const alignedSize = alignedByteStride / typeByteLength;\r\n const totalVertices = this._maxVerticesCount;\r\n const totalByteLength = totalVertices * alignedByteStride;\r\n const totalLength = totalByteLength / typeByteLength;\r\n\r\n let sourceData: DataView;\r\n\r\n if (Array.isArray(data)) {\r\n const sourceDataAsFloat = new Float32Array(data);\r\n sourceData = new DataView(sourceDataAsFloat.buffer, sourceDataAsFloat.byteOffset, sourceDataAsFloat.byteLength);\r\n } else if (data instanceof ArrayBuffer) {\r\n sourceData = new DataView(data, 0, data.byteLength);\r\n } else {\r\n sourceData = new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n }\r\n\r\n let alignedData: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array;\r\n\r\n if (this.type === VertexBuffer.BYTE) {\r\n alignedData = new Int8Array(totalLength);\r\n } else if (this.type === VertexBuffer.UNSIGNED_BYTE) {\r\n alignedData = new Uint8Array(totalLength);\r\n } else if (this.type === VertexBuffer.SHORT) {\r\n alignedData = new Int16Array(totalLength);\r\n } else if (this.type === VertexBuffer.UNSIGNED_SHORT) {\r\n alignedData = new Uint16Array(totalLength);\r\n } else if (this.type === VertexBuffer.INT) {\r\n alignedData = new Int32Array(totalLength);\r\n } else if (this.type === VertexBuffer.UNSIGNED_INT) {\r\n alignedData = new Uint32Array(totalLength);\r\n } else {\r\n alignedData = new Float32Array(totalLength);\r\n }\r\n\r\n const numComponents = this.getSize();\r\n\r\n let sourceOffset = this.byteOffset;\r\n\r\n for (let i = 0; i < totalVertices; ++i) {\r\n for (let j = 0; j < numComponents; ++j) {\r\n switch (this.type) {\r\n case VertexBuffer.BYTE:\r\n alignedData[i * alignedSize + j] = sourceData.getInt8(sourceOffset + j);\r\n break;\r\n case VertexBuffer.UNSIGNED_BYTE:\r\n alignedData[i * alignedSize + j] = sourceData.getUint8(sourceOffset + j);\r\n break;\r\n case VertexBuffer.SHORT:\r\n alignedData[i * alignedSize + j] = sourceData.getInt16(sourceOffset + j * 2, isLittleEndian);\r\n break;\r\n case VertexBuffer.UNSIGNED_SHORT:\r\n alignedData[i * alignedSize + j] = sourceData.getUint16(sourceOffset + j * 2, isLittleEndian);\r\n break;\r\n case VertexBuffer.INT:\r\n alignedData[i * alignedSize + j] = sourceData.getInt32(sourceOffset + j * 4, isLittleEndian);\r\n break;\r\n case VertexBuffer.UNSIGNED_INT:\r\n alignedData[i * alignedSize + j] = sourceData.getUint32(sourceOffset + j * 4, isLittleEndian);\r\n break;\r\n case VertexBuffer.FLOAT:\r\n alignedData[i * alignedSize + j] = sourceData.getFloat32(sourceOffset + j * 4, isLittleEndian);\r\n break;\r\n }\r\n }\r\n sourceOffset += this.byteStride;\r\n }\r\n\r\n this._alignedBuffer?.dispose();\r\n this._alignedBuffer = new Buffer(\r\n this.engine,\r\n alignedData,\r\n false,\r\n alignedByteStride,\r\n false,\r\n this.getIsInstanced(),\r\n true,\r\n this.instanceDivisor,\r\n (this._label ?? \"VertexBuffer\") + \"_aligned\"\r\n );\r\n};\r\n"]}
1
+ {"version":3,"file":"buffer.align.js","sourceRoot":"","sources":["../../../../dev/core/src/Buffers/buffer.align.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE;IACzB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE3C,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;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CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,YAAY,GAAG,CAAC,GAAG,CAAC,EAAE,cAAc,CAAC,CAAC;oBAC/F,MAAM;aACb;SACJ;QACD,YAAY,IAAI,IAAI,CAAC,UAAU,CAAC;KACnC;IAED,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC;IAC/B,IAAI,CAAC,cAAc,GAAG,IAAI,MAAM,CAC5B,IAAI,CAAC,MAAM,EACX,WAAW,EACX,KAAK,EACL,iBAAiB,EACjB,KAAK,EACL,IAAI,CAAC,cAAc,EAAE,EACrB,IAAI,EACJ,IAAI,CAAC,eAAe,EACpB,CAAC,IAAI,CAAC,MAAM,IAAI,cAAc,CAAC,GAAG,UAAU,CAC/C,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { DataBuffer } from \"./dataBuffer\";\r\nimport { Buffer, VertexBuffer } from \"./buffer\";\r\n\r\nconst isLittleEndian = (() => {\r\n const array = new Uint8Array(4);\r\n const view = new Uint32Array(array.buffer);\r\n\r\n return !!((view[0] = 1) & array[0]);\r\n})();\r\n\r\ndeclare module \"./buffer\" {\r\n export interface VertexBuffer {\r\n /**\r\n * Gets the effective byte stride, that is the byte stride of the buffer that is actually sent to the GPU.\r\n * It could be different from VertexBuffer.byteStride if a new buffer must be created under the hood because of the forceVertexBufferStrideAndOffsetMultiple4Bytes engine flag.\r\n */\r\n effectiveByteStride: number;\r\n\r\n /**\r\n * Gets the effective byte offset, that is the byte offset of the buffer that is actually sent to the GPU.\r\n * It could be different from VertexBuffer.byteOffset if a new buffer must be created under the hood because of the forceVertexBufferStrideAndOffsetMultiple4Bytes engine flag.\r\n */\r\n effectiveByteOffset: number;\r\n\r\n /**\r\n * Gets the effective buffer, that is the buffer that is actually sent to the GPU.\r\n * It could be different from VertexBuffer.getBuffer() if a new buffer must be created under the hood because of the forceVertexBufferStrideAndOffsetMultiple4Bytes engine flag.\r\n */\r\n effectiveBuffer: Nullable<DataBuffer>;\r\n\r\n /** @internal */\r\n _alignBuffer(): void;\r\n\r\n /** @internal */\r\n _alignedBuffer?: Buffer;\r\n }\r\n}\r\n\r\nObject.defineProperty(VertexBuffer.prototype, \"effectiveByteStride\", {\r\n get: function (this: VertexBuffer) {\r\n return (this._alignedBuffer && this._alignedBuffer.byteStride) || this.byteStride;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(VertexBuffer.prototype, \"effectiveByteOffset\", {\r\n get: function (this: VertexBuffer) {\r\n return this._alignedBuffer ? 0 : this.byteOffset;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nObject.defineProperty(VertexBuffer.prototype, \"effectiveBuffer\", {\r\n get: function (this: VertexBuffer) {\r\n return (this._alignedBuffer && this._alignedBuffer.getBuffer()) || this._buffer.getBuffer();\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\nVertexBuffer.prototype._rebuild = function (): void {\r\n this._buffer?._rebuild();\r\n this._alignedBuffer?._rebuild();\r\n};\r\n\r\nVertexBuffer.prototype.dispose = function (): void {\r\n if (this._ownsBuffer) {\r\n this._buffer.dispose();\r\n }\r\n\r\n this._alignedBuffer?.dispose();\r\n this._alignedBuffer = undefined;\r\n\r\n this._isDisposed = true;\r\n};\r\n\r\nVertexBuffer.prototype.getWrapperBuffer = function (): Buffer {\r\n return this._alignedBuffer || this._buffer;\r\n};\r\n\r\nVertexBuffer.prototype._alignBuffer = function (): void {\r\n const data = this._buffer.getData();\r\n\r\n if (!this.engine._features.forceVertexBufferStrideAndOffsetMultiple4Bytes || (this.byteStride % 4 === 0 && this.byteOffset % 4 === 0) || !data) {\r\n return;\r\n }\r\n\r\n const typeByteLength = VertexBuffer.GetTypeByteLength(this.type);\r\n const alignedByteStride = (this.byteStride + 3) & ~3;\r\n const alignedSize = alignedByteStride / typeByteLength;\r\n const totalVertices = this._maxVerticesCount;\r\n const totalByteLength = totalVertices * alignedByteStride;\r\n const totalLength = totalByteLength / typeByteLength;\r\n\r\n let sourceData: DataView;\r\n\r\n if (Array.isArray(data)) {\r\n const sourceDataAsFloat = new Float32Array(data);\r\n sourceData = new DataView(sourceDataAsFloat.buffer, sourceDataAsFloat.byteOffset, sourceDataAsFloat.byteLength);\r\n } else if (data instanceof ArrayBuffer) {\r\n sourceData = new DataView(data, 0, data.byteLength);\r\n } else {\r\n sourceData = new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n }\r\n\r\n let alignedData: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array;\r\n\r\n if (this.type === VertexBuffer.BYTE) {\r\n alignedData = new Int8Array(totalLength);\r\n } else if (this.type === VertexBuffer.UNSIGNED_BYTE) {\r\n alignedData = new Uint8Array(totalLength);\r\n } else if (this.type === VertexBuffer.SHORT) {\r\n alignedData = new Int16Array(totalLength);\r\n } else if (this.type === VertexBuffer.UNSIGNED_SHORT) {\r\n alignedData = new Uint16Array(totalLength);\r\n } else if (this.type === VertexBuffer.INT) {\r\n alignedData = new Int32Array(totalLength);\r\n } else if (this.type === VertexBuffer.UNSIGNED_INT) {\r\n alignedData = new Uint32Array(totalLength);\r\n } else {\r\n alignedData = new Float32Array(totalLength);\r\n }\r\n\r\n const numComponents = this.getSize();\r\n\r\n let sourceOffset = this.byteOffset;\r\n\r\n for (let i = 0; i < totalVertices; ++i) {\r\n for (let j = 0; j < numComponents; ++j) {\r\n switch (this.type) {\r\n case VertexBuffer.BYTE:\r\n alignedData[i * alignedSize + j] = sourceData.getInt8(sourceOffset + j);\r\n break;\r\n case VertexBuffer.UNSIGNED_BYTE:\r\n alignedData[i * alignedSize + j] = sourceData.getUint8(sourceOffset + j);\r\n break;\r\n case VertexBuffer.SHORT:\r\n alignedData[i * alignedSize + j] = sourceData.getInt16(sourceOffset + j * 2, isLittleEndian);\r\n break;\r\n case VertexBuffer.UNSIGNED_SHORT:\r\n alignedData[i * alignedSize + j] = sourceData.getUint16(sourceOffset + j * 2, isLittleEndian);\r\n break;\r\n case VertexBuffer.INT:\r\n alignedData[i * alignedSize + j] = sourceData.getInt32(sourceOffset + j * 4, isLittleEndian);\r\n break;\r\n case VertexBuffer.UNSIGNED_INT:\r\n alignedData[i * alignedSize + j] = sourceData.getUint32(sourceOffset + j * 4, isLittleEndian);\r\n break;\r\n case VertexBuffer.FLOAT:\r\n alignedData[i * alignedSize + j] = sourceData.getFloat32(sourceOffset + j * 4, isLittleEndian);\r\n break;\r\n }\r\n }\r\n sourceOffset += this.byteStride;\r\n }\r\n\r\n this._alignedBuffer?.dispose();\r\n this._alignedBuffer = new Buffer(\r\n this.engine,\r\n alignedData,\r\n false,\r\n alignedByteStride,\r\n false,\r\n this.getIsInstanced(),\r\n true,\r\n this.instanceDivisor,\r\n (this._label ?? \"VertexBuffer\") + \"_aligned\"\r\n );\r\n};\r\n"]}
@@ -13,6 +13,7 @@ export type NativeUniform = NativeData;
13
13
  export interface INativeEngine {
14
14
  dispose(): void;
15
15
  requestAnimationFrame(callback: () => void): void;
16
+ setDeviceLostCallback(callback: () => void): void;
16
17
  createVertexArray(): NativeData;
17
18
  createIndexBuffer(dataBuffer: ArrayBuffer, dataByteOffset: number, dataByteLength: number, is32Bits: boolean, dynamic: boolean): NativeData;
18
19
  recordIndexBuffer(vertexArray: NativeData, indexBuffer: NativeData): void;
@@ -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(dataBuffer: ArrayBuffer, dataByteOffset: number, dataByteLength: number, is32Bits: boolean, dynamic: boolean): NativeData;\r\n recordIndexBuffer(vertexArray: NativeData, indexBuffer: NativeData): void;\r\n updateDynamicIndexBuffer(indexBuffer: NativeData, data: ArrayBuffer, dataByteOffset: number, dataByteLength: number, startIndex: number): void;\r\n\r\n createVertexBuffer(dataBuffer: ArrayBuffer, dataByteOffset: number, dataByteLength: 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, dataBuffer: ArrayBuffer, dataByteOffset: number, dataByteLength: number, vertexByteOffset?: 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"]}
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 setDeviceLostCallback(callback: () => void): void;\r\n\r\n createVertexArray(): NativeData;\r\n\r\n createIndexBuffer(dataBuffer: ArrayBuffer, dataByteOffset: number, dataByteLength: number, is32Bits: boolean, dynamic: boolean): NativeData;\r\n recordIndexBuffer(vertexArray: NativeData, indexBuffer: NativeData): void;\r\n updateDynamicIndexBuffer(indexBuffer: NativeData, data: ArrayBuffer, dataByteOffset: number, dataByteLength: number, startIndex: number): void;\r\n\r\n createVertexBuffer(dataBuffer: ArrayBuffer, dataByteOffset: number, dataByteLength: 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, dataBuffer: ArrayBuffer, dataByteOffset: number, dataByteLength: number, vertexByteOffset?: 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"]}
package/Engines/engine.js CHANGED
@@ -810,11 +810,13 @@ export class Engine extends ThinEngine {
810
810
  }
811
811
  }
812
812
  _cancelFrame() {
813
- if (this._renderingQueueLaunched && this.customAnimationFrameRequester) {
814
- this._renderingQueueLaunched = false;
815
- const { cancelAnimationFrame } = this.customAnimationFrameRequester;
816
- if (cancelAnimationFrame) {
817
- cancelAnimationFrame(this.customAnimationFrameRequester.requestID);
813
+ if (this.customAnimationFrameRequester) {
814
+ if (this._frameHandler !== 0) {
815
+ this._frameHandler = 0;
816
+ const { cancelAnimationFrame } = this.customAnimationFrameRequester;
817
+ if (cancelAnimationFrame) {
818
+ cancelAnimationFrame(this.customAnimationFrameRequester.requestID);
819
+ }
818
820
  }
819
821
  }
820
822
  else {
@@ -822,6 +824,7 @@ export class Engine extends ThinEngine {
822
824
  }
823
825
  }
824
826
  _renderLoop() {
827
+ this._frameHandler = 0;
825
828
  if (!this._contextWasLost) {
826
829
  let shouldRender = true;
827
830
  if (this.isDisposed || (!this.renderEvenInBackground && this._windowIsBackground)) {
@@ -839,7 +842,7 @@ export class Engine extends ThinEngine {
839
842
  this.endFrame();
840
843
  }
841
844
  }
842
- if (this._activeRenderLoops.length > 0) {
845
+ if (this._frameHandler === 0) {
843
846
  // Register new frame
844
847
  if (this.customAnimationFrameRequester) {
845
848
  this.customAnimationFrameRequester.requestID = this._queueNewFrame(this.customAnimationFrameRequester.renderFunction || this._boundRenderFunction, this.customAnimationFrameRequester);
@@ -849,9 +852,6 @@ export class Engine extends ThinEngine {
849
852
  this._frameHandler = this._queueNewFrame(this._boundRenderFunction, this.getHostWindow());
850
853
  }
851
854
  }
852
- else {
853
- this._renderingQueueLaunched = false;
854
- }
855
855
  }
856
856
  /** @internal */
857
857
  _renderViews() {