@babylonjs/core 6.1.0 → 6.3.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 (76) hide show
  1. package/Collisions/pickingInfo.js +24 -9
  2. package/Collisions/pickingInfo.js.map +1 -1
  3. package/Engines/Extensions/engine.rawTexture.js +1 -0
  4. package/Engines/Extensions/engine.rawTexture.js.map +1 -1
  5. package/Engines/WebGPU/webgpuHardwareTexture.js +1 -1
  6. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  7. package/Engines/engine.d.ts +90 -0
  8. package/Engines/thinEngine.js +21 -4
  9. package/Engines/thinEngine.js.map +1 -1
  10. package/Engines/webgpuEngine.js +1 -6
  11. package/Engines/webgpuEngine.js.map +1 -1
  12. package/Gamepads/gamepadManager.js +2 -4
  13. package/Gamepads/gamepadManager.js.map +1 -1
  14. package/Gizmos/gizmo.js +1 -0
  15. package/Gizmos/gizmo.js.map +1 -1
  16. package/Materials/Node/Blocks/PBR/refractionBlock.js +2 -2
  17. package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
  18. package/Materials/Node/Blocks/triPlanarBlock.d.ts +4 -0
  19. package/Materials/Node/Blocks/triPlanarBlock.js +44 -6
  20. package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
  21. package/Materials/Node/nodeMaterialConnectionPointCustomObject.d.ts +1 -1
  22. package/Materials/Node/nodeMaterialConnectionPointCustomObject.js +3 -1
  23. package/Materials/Node/nodeMaterialConnectionPointCustomObject.js.map +1 -1
  24. package/Materials/PBR/pbrMaterial.d.ts +2 -1
  25. package/Materials/PBR/pbrMaterial.js +3 -2
  26. package/Materials/PBR/pbrMaterial.js.map +1 -1
  27. package/Materials/PBR/pbrSubSurfaceConfiguration.js +2 -2
  28. package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
  29. package/Materials/Textures/baseTexture.d.ts +6 -0
  30. package/Materials/Textures/baseTexture.js +8 -0
  31. package/Materials/Textures/baseTexture.js.map +1 -1
  32. package/Materials/Textures/cubeTexture.d.ts +7 -0
  33. package/Materials/Textures/cubeTexture.js +25 -2
  34. package/Materials/Textures/cubeTexture.js.map +1 -1
  35. package/Materials/Textures/renderTargetTexture.js +1 -1
  36. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  37. package/Materials/material.js +1 -1
  38. package/Materials/material.js.map +1 -1
  39. package/Materials/standardMaterial.d.ts +2 -1
  40. package/Materials/standardMaterial.js +3 -2
  41. package/Materials/standardMaterial.js.map +1 -1
  42. package/Meshes/abstractMesh.js +4 -1
  43. package/Meshes/abstractMesh.js.map +1 -1
  44. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.d.ts +4 -0
  45. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js +19 -4
  46. package/Misc/HighDynamicRange/cubemapToSphericalPolynomial.js.map +1 -1
  47. package/Misc/decorators.d.ts +5 -1
  48. package/Misc/decorators.js +12 -4
  49. package/Misc/decorators.js.map +1 -1
  50. package/Misc/dumpTools.js +1 -1
  51. package/Misc/dumpTools.js.map +1 -1
  52. package/Misc/error.d.ts +1 -1
  53. package/Misc/error.js.map +1 -1
  54. package/Misc/tools.d.ts +10 -9
  55. package/Misc/tools.js +48 -16
  56. package/Misc/tools.js.map +1 -1
  57. package/Physics/physicsRaycastResult.js +6 -6
  58. package/Physics/physicsRaycastResult.js.map +1 -1
  59. package/Physics/v2/IPhysicsEnginePlugin.d.ts +2 -0
  60. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  61. package/Physics/v2/Plugins/havokPlugin.d.ts +20 -5
  62. package/Physics/v2/Plugins/havokPlugin.js +66 -8
  63. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  64. package/Physics/v2/physicsAggregate.d.ts +5 -51
  65. package/Physics/v2/physicsAggregate.js +7 -6
  66. package/Physics/v2/physicsAggregate.js.map +1 -1
  67. package/Physics/v2/physicsBody.d.ts +17 -1
  68. package/Physics/v2/physicsBody.js +22 -2
  69. package/Physics/v2/physicsBody.js.map +1 -1
  70. package/assetContainer.d.ts +2 -3
  71. package/assetContainer.js +13 -4
  72. package/assetContainer.js.map +1 -1
  73. package/node.d.ts +8 -0
  74. package/node.js +23 -1
  75. package/node.js.map +1 -1
  76. package/package.json +1 -1
@@ -65,16 +65,25 @@ export class PickingInfo {
65
65
  if (!this.pickedMesh || (useVerticesNormals && !this.pickedMesh.isVerticesDataPresent(VertexBuffer.NormalKind))) {
66
66
  return null;
67
67
  }
68
- const indices = this.pickedMesh.getIndices();
69
- if (!indices) {
70
- return null;
68
+ let indices = this.pickedMesh.getIndices();
69
+ if ((indices === null || indices === void 0 ? void 0 : indices.length) === 0) {
70
+ indices = null;
71
71
  }
72
72
  let result;
73
+ const tmp0 = TmpVectors.Vector3[0];
74
+ const tmp1 = TmpVectors.Vector3[1];
75
+ const tmp2 = TmpVectors.Vector3[2];
73
76
  if (useVerticesNormals) {
74
77
  const normals = this.pickedMesh.getVerticesData(VertexBuffer.NormalKind);
75
- let normal0 = Vector3.FromArray(normals, indices[this.faceId * 3] * 3);
76
- let normal1 = Vector3.FromArray(normals, indices[this.faceId * 3 + 1] * 3);
77
- let normal2 = Vector3.FromArray(normals, indices[this.faceId * 3 + 2] * 3);
78
+ let normal0 = indices
79
+ ? Vector3.FromArrayToRef(normals, indices[this.faceId * 3] * 3, tmp0)
80
+ : tmp0.copyFromFloats(normals[this.faceId * 3 * 3], normals[this.faceId * 3 * 3 + 1], normals[this.faceId * 3 * 3 + 2]);
81
+ let normal1 = indices
82
+ ? Vector3.FromArrayToRef(normals, indices[this.faceId * 3 + 1] * 3, tmp1)
83
+ : tmp1.copyFromFloats(normals[(this.faceId * 3 + 1) * 3], normals[(this.faceId * 3 + 1) * 3 + 1], normals[(this.faceId * 3 + 1) * 3 + 2]);
84
+ let normal2 = indices
85
+ ? Vector3.FromArrayToRef(normals, indices[this.faceId * 3 + 2] * 3, tmp2)
86
+ : tmp2.copyFromFloats(normals[(this.faceId * 3 + 2) * 3], normals[(this.faceId * 3 + 2) * 3 + 1], normals[(this.faceId * 3 + 2) * 3 + 2]);
78
87
  normal0 = normal0.scale(this.bu);
79
88
  normal1 = normal1.scale(this.bv);
80
89
  normal2 = normal2.scale(1.0 - this.bu - this.bv);
@@ -82,9 +91,15 @@ export class PickingInfo {
82
91
  }
83
92
  else {
84
93
  const positions = this.pickedMesh.getVerticesData(VertexBuffer.PositionKind);
85
- const vertex1 = Vector3.FromArray(positions, indices[this.faceId * 3] * 3);
86
- const vertex2 = Vector3.FromArray(positions, indices[this.faceId * 3 + 1] * 3);
87
- const vertex3 = Vector3.FromArray(positions, indices[this.faceId * 3 + 2] * 3);
94
+ const vertex1 = indices
95
+ ? Vector3.FromArrayToRef(positions, indices[this.faceId * 3] * 3, tmp0)
96
+ : tmp0.copyFromFloats(positions[this.faceId * 3 * 3], positions[this.faceId * 3 * 3 + 1], positions[this.faceId * 3 * 3 + 2]);
97
+ const vertex2 = indices
98
+ ? Vector3.FromArrayToRef(positions, indices[this.faceId * 3 + 1] * 3, tmp1)
99
+ : tmp1.copyFromFloats(positions[(this.faceId * 3 + 1) * 3], positions[(this.faceId * 3 + 1) * 3 + 1], positions[(this.faceId * 3 + 1) * 3 + 2]);
100
+ const vertex3 = indices
101
+ ? Vector3.FromArrayToRef(positions, indices[this.faceId * 3 + 2] * 3, tmp2)
102
+ : tmp2.copyFromFloats(positions[(this.faceId * 3 + 2) * 3], positions[(this.faceId * 3 + 2) * 3 + 1], positions[(this.faceId * 3 + 2) * 3 + 2]);
88
103
  const p1p2 = vertex1.subtract(vertex2);
89
104
  const p3p2 = vertex3.subtract(vertex2);
90
105
  result = Vector3.Cross(p1p2, p3p2);
@@ -1 +1 @@
1
- {"version":3,"file":"pickingInfo.js","sourceRoot":"","sources":["../../../../lts/core/generated/Collisions/pickingInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAG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CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACnE,IAAI,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAEnE,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;QAEzC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;CACJ","sourcesContent":["import type { Nullable, FloatArray } from \"../types\";\r\nimport { Vector3, Vector2, TmpVectors } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport type { Sprite } from \"../Sprites/sprite\";\r\n\r\ndeclare type Ray = import(\"../Culling/ray\").Ray;\r\n\r\n/**\r\n * Information about the result of picking within a scene\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/picking_collisions\r\n */\r\nexport class PickingInfo {\r\n /**\r\n * If the pick collided with an object\r\n */\r\n public hit = false;\r\n /**\r\n * Distance away where the pick collided\r\n */\r\n public distance = 0;\r\n /**\r\n * The location of pick collision\r\n */\r\n public pickedPoint: Nullable<Vector3> = null;\r\n /**\r\n * The mesh corresponding the pick collision\r\n */\r\n public pickedMesh: Nullable<AbstractMesh> = null;\r\n /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/\r\n public bu = 0;\r\n /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/\r\n public bv = 0;\r\n /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */\r\n public faceId = -1;\r\n /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */\r\n public subMeshFaceId = -1;\r\n /** Id of the submesh that was picked */\r\n public subMeshId = 0;\r\n /** If a sprite was picked, this will be the sprite the pick collided with */\r\n public pickedSprite: Nullable<Sprite> = null;\r\n /** If we are picking a mesh with thin instance, this will give you the picked thin instance */\r\n public thinInstanceIndex = -1;\r\n /**\r\n * The ray that was used to perform the picking.\r\n */\r\n public ray: Nullable<Ray> = null;\r\n /**\r\n * If a mesh was used to do the picking (eg. 6dof controller) as a \"near interaction\", this will be populated.\r\n */\r\n public originMesh: Nullable<AbstractMesh> = null;\r\n /**\r\n * The aim-space transform of the input used for picking, if it is an XR input source.\r\n */\r\n public aimTransform: Nullable<TransformNode> = null;\r\n /**\r\n * The grip-space transform of the input used for picking, if it is an XR input source.\r\n * Some XR sources, such as input coming from head mounted displays, do not have this.\r\n */\r\n public gripTransform: Nullable<TransformNode> = null;\r\n\r\n /**\r\n * Gets the normal corresponding to the face the pick collided with\r\n * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)\r\n * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map (default: true)\r\n * @returns The normal corresponding to the face the pick collided with\r\n * @remarks Note that the returned normal will always point towards the picking ray.\r\n */\r\n public getNormal(useWorldCoordinates = false, useVerticesNormals = true): Nullable<Vector3> {\r\n if (!this.pickedMesh || (useVerticesNormals && !this.pickedMesh.isVerticesDataPresent(VertexBuffer.NormalKind))) {\r\n return null;\r\n }\r\n\r\n const indices = this.pickedMesh.getIndices();\r\n\r\n if (!indices) {\r\n return null;\r\n }\r\n\r\n let result: Vector3;\r\n\r\n if (useVerticesNormals) {\r\n const normals = <FloatArray>this.pickedMesh.getVerticesData(VertexBuffer.NormalKind);\r\n\r\n let normal0 = Vector3.FromArray(normals, indices[this.faceId * 3] * 3);\r\n let normal1 = Vector3.FromArray(normals, indices[this.faceId * 3 + 1] * 3);\r\n let normal2 = Vector3.FromArray(normals, indices[this.faceId * 3 + 2] * 3);\r\n\r\n normal0 = normal0.scale(this.bu);\r\n normal1 = normal1.scale(this.bv);\r\n normal2 = normal2.scale(1.0 - this.bu - this.bv);\r\n\r\n result = new Vector3(normal0.x + normal1.x + normal2.x, normal0.y + normal1.y + normal2.y, normal0.z + normal1.z + normal2.z);\r\n } else {\r\n const positions = <FloatArray>this.pickedMesh.getVerticesData(VertexBuffer.PositionKind);\r\n\r\n const vertex1 = Vector3.FromArray(positions, indices[this.faceId * 3] * 3);\r\n const vertex2 = Vector3.FromArray(positions, indices[this.faceId * 3 + 1] * 3);\r\n const vertex3 = Vector3.FromArray(positions, indices[this.faceId * 3 + 2] * 3);\r\n\r\n const p1p2 = vertex1.subtract(vertex2);\r\n const p3p2 = vertex3.subtract(vertex2);\r\n\r\n result = Vector3.Cross(p1p2, p3p2);\r\n }\r\n\r\n const transformNormalToWorld = (pickedMesh: AbstractMesh, n: Vector3) => {\r\n let wm = pickedMesh.getWorldMatrix();\r\n\r\n if (pickedMesh.nonUniformScaling) {\r\n TmpVectors.Matrix[0].copyFrom(wm);\r\n wm = TmpVectors.Matrix[0];\r\n wm.setTranslationFromFloats(0, 0, 0);\r\n wm.invert();\r\n wm.transposeToRef(TmpVectors.Matrix[1]);\r\n\r\n wm = TmpVectors.Matrix[1];\r\n }\r\n\r\n Vector3.TransformNormalToRef(n, wm, n);\r\n };\r\n\r\n if (useWorldCoordinates) {\r\n transformNormalToWorld(this.pickedMesh, result);\r\n }\r\n\r\n if (this.ray) {\r\n const normalForDirectionChecking = TmpVectors.Vector3[0].copyFrom(result);\r\n\r\n if (!useWorldCoordinates) {\r\n // the normal has not been transformed to world space as part as the normal processing, so we must do it now\r\n transformNormalToWorld(this.pickedMesh, normalForDirectionChecking);\r\n }\r\n\r\n // Flip the normal if the picking ray is in the same direction.\r\n if (Vector3.Dot(normalForDirectionChecking, this.ray.direction) > 0) {\r\n result.negateInPlace();\r\n }\r\n }\r\n\r\n result.normalize();\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Gets the texture coordinates of where the pick occurred\r\n * @param uvSet The UV set to use to calculate the texture coordinates (default: VertexBuffer.UVKind)\r\n * @returns The vector containing the coordinates of the texture\r\n */\r\n public getTextureCoordinates(uvSet = VertexBuffer.UVKind): Nullable<Vector2> {\r\n if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(uvSet)) {\r\n return null;\r\n }\r\n\r\n const indices = this.pickedMesh.getIndices();\r\n if (!indices) {\r\n return null;\r\n }\r\n\r\n const uvs = this.pickedMesh.getVerticesData(uvSet);\r\n if (!uvs) {\r\n return null;\r\n }\r\n\r\n let uv0 = Vector2.FromArray(uvs, indices[this.faceId * 3] * 2);\r\n let uv1 = Vector2.FromArray(uvs, indices[this.faceId * 3 + 1] * 2);\r\n let uv2 = Vector2.FromArray(uvs, indices[this.faceId * 3 + 2] * 2);\r\n\r\n uv0 = uv0.scale(this.bu);\r\n uv1 = uv1.scale(this.bv);\r\n uv2 = uv2.scale(1.0 - this.bu - this.bv);\r\n\r\n return new Vector2(uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"pickingInfo.js","sourceRoot":"","sources":["../../../../lts/core/generated/Collisions/pickingInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAKjD;;;GAGG;AACH,MAAM,OAAO,WAAW;IAAxB;QACI;;WAEG;QACI,QAAG,GAAG,KAAK,CAAC;QACn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C,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzB,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;QAEzC,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACrE,CAAC;CACJ","sourcesContent":["import type { Nullable, FloatArray } from \"../types\";\r\nimport { Vector3, Vector2, TmpVectors } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport type { Sprite } from \"../Sprites/sprite\";\r\n\r\ndeclare type Ray = import(\"../Culling/ray\").Ray;\r\n\r\n/**\r\n * Information about the result of picking within a scene\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/interactions/picking_collisions\r\n */\r\nexport class PickingInfo {\r\n /**\r\n * If the pick collided with an object\r\n */\r\n public hit = false;\r\n /**\r\n * Distance away where the pick collided\r\n */\r\n public distance = 0;\r\n /**\r\n * The location of pick collision\r\n */\r\n public pickedPoint: Nullable<Vector3> = null;\r\n /**\r\n * The mesh corresponding the pick collision\r\n */\r\n public pickedMesh: Nullable<AbstractMesh> = null;\r\n /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/\r\n public bu = 0;\r\n /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/\r\n public bv = 0;\r\n /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */\r\n public faceId = -1;\r\n /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */\r\n public subMeshFaceId = -1;\r\n /** Id of the submesh that was picked */\r\n public subMeshId = 0;\r\n /** If a sprite was picked, this will be the sprite the pick collided with */\r\n public pickedSprite: Nullable<Sprite> = null;\r\n /** If we are picking a mesh with thin instance, this will give you the picked thin instance */\r\n public thinInstanceIndex = -1;\r\n /**\r\n * The ray that was used to perform the picking.\r\n */\r\n public ray: Nullable<Ray> = null;\r\n /**\r\n * If a mesh was used to do the picking (eg. 6dof controller) as a \"near interaction\", this will be populated.\r\n */\r\n public originMesh: Nullable<AbstractMesh> = null;\r\n /**\r\n * The aim-space transform of the input used for picking, if it is an XR input source.\r\n */\r\n public aimTransform: Nullable<TransformNode> = null;\r\n /**\r\n * The grip-space transform of the input used for picking, if it is an XR input source.\r\n * Some XR sources, such as input coming from head mounted displays, do not have this.\r\n */\r\n public gripTransform: Nullable<TransformNode> = null;\r\n\r\n /**\r\n * Gets the normal corresponding to the face the pick collided with\r\n * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)\r\n * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map (default: true)\r\n * @returns The normal corresponding to the face the pick collided with\r\n * @remarks Note that the returned normal will always point towards the picking ray.\r\n */\r\n public getNormal(useWorldCoordinates = false, useVerticesNormals = true): Nullable<Vector3> {\r\n if (!this.pickedMesh || (useVerticesNormals && !this.pickedMesh.isVerticesDataPresent(VertexBuffer.NormalKind))) {\r\n return null;\r\n }\r\n\r\n let indices = this.pickedMesh.getIndices();\r\n\r\n if (indices?.length === 0) {\r\n indices = null;\r\n }\r\n\r\n let result: Vector3;\r\n\r\n const tmp0 = TmpVectors.Vector3[0];\r\n const tmp1 = TmpVectors.Vector3[1];\r\n const tmp2 = TmpVectors.Vector3[2];\r\n\r\n if (useVerticesNormals) {\r\n const normals = <FloatArray>this.pickedMesh.getVerticesData(VertexBuffer.NormalKind);\r\n\r\n let normal0 = indices\r\n ? Vector3.FromArrayToRef(normals, indices[this.faceId * 3] * 3, tmp0)\r\n : tmp0.copyFromFloats(normals[this.faceId * 3 * 3], normals[this.faceId * 3 * 3 + 1], normals[this.faceId * 3 * 3 + 2]);\r\n let normal1 = indices\r\n ? Vector3.FromArrayToRef(normals, indices[this.faceId * 3 + 1] * 3, tmp1)\r\n : tmp1.copyFromFloats(normals[(this.faceId * 3 + 1) * 3], normals[(this.faceId * 3 + 1) * 3 + 1], normals[(this.faceId * 3 + 1) * 3 + 2]);\r\n let normal2 = indices\r\n ? Vector3.FromArrayToRef(normals, indices[this.faceId * 3 + 2] * 3, tmp2)\r\n : tmp2.copyFromFloats(normals[(this.faceId * 3 + 2) * 3], normals[(this.faceId * 3 + 2) * 3 + 1], normals[(this.faceId * 3 + 2) * 3 + 2]);\r\n\r\n normal0 = normal0.scale(this.bu);\r\n normal1 = normal1.scale(this.bv);\r\n normal2 = normal2.scale(1.0 - this.bu - this.bv);\r\n\r\n result = new Vector3(normal0.x + normal1.x + normal2.x, normal0.y + normal1.y + normal2.y, normal0.z + normal1.z + normal2.z);\r\n } else {\r\n const positions = <FloatArray>this.pickedMesh.getVerticesData(VertexBuffer.PositionKind);\r\n\r\n const vertex1 = indices\r\n ? Vector3.FromArrayToRef(positions, indices[this.faceId * 3] * 3, tmp0)\r\n : tmp0.copyFromFloats(positions[this.faceId * 3 * 3], positions[this.faceId * 3 * 3 + 1], positions[this.faceId * 3 * 3 + 2]);\r\n const vertex2 = indices\r\n ? Vector3.FromArrayToRef(positions, indices[this.faceId * 3 + 1] * 3, tmp1)\r\n : tmp1.copyFromFloats(positions[(this.faceId * 3 + 1) * 3], positions[(this.faceId * 3 + 1) * 3 + 1], positions[(this.faceId * 3 + 1) * 3 + 2]);\r\n const vertex3 = indices\r\n ? Vector3.FromArrayToRef(positions, indices[this.faceId * 3 + 2] * 3, tmp2)\r\n : tmp2.copyFromFloats(positions[(this.faceId * 3 + 2) * 3], positions[(this.faceId * 3 + 2) * 3 + 1], positions[(this.faceId * 3 + 2) * 3 + 2]);\r\n\r\n const p1p2 = vertex1.subtract(vertex2);\r\n const p3p2 = vertex3.subtract(vertex2);\r\n\r\n result = Vector3.Cross(p1p2, p3p2);\r\n }\r\n\r\n const transformNormalToWorld = (pickedMesh: AbstractMesh, n: Vector3) => {\r\n let wm = pickedMesh.getWorldMatrix();\r\n\r\n if (pickedMesh.nonUniformScaling) {\r\n TmpVectors.Matrix[0].copyFrom(wm);\r\n wm = TmpVectors.Matrix[0];\r\n wm.setTranslationFromFloats(0, 0, 0);\r\n wm.invert();\r\n wm.transposeToRef(TmpVectors.Matrix[1]);\r\n\r\n wm = TmpVectors.Matrix[1];\r\n }\r\n\r\n Vector3.TransformNormalToRef(n, wm, n);\r\n };\r\n\r\n if (useWorldCoordinates) {\r\n transformNormalToWorld(this.pickedMesh, result);\r\n }\r\n\r\n if (this.ray) {\r\n const normalForDirectionChecking = TmpVectors.Vector3[0].copyFrom(result);\r\n\r\n if (!useWorldCoordinates) {\r\n // the normal has not been transformed to world space as part as the normal processing, so we must do it now\r\n transformNormalToWorld(this.pickedMesh, normalForDirectionChecking);\r\n }\r\n\r\n // Flip the normal if the picking ray is in the same direction.\r\n if (Vector3.Dot(normalForDirectionChecking, this.ray.direction) > 0) {\r\n result.negateInPlace();\r\n }\r\n }\r\n\r\n result.normalize();\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Gets the texture coordinates of where the pick occurred\r\n * @param uvSet The UV set to use to calculate the texture coordinates (default: VertexBuffer.UVKind)\r\n * @returns The vector containing the coordinates of the texture\r\n */\r\n public getTextureCoordinates(uvSet = VertexBuffer.UVKind): Nullable<Vector2> {\r\n if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(uvSet)) {\r\n return null;\r\n }\r\n\r\n const indices = this.pickedMesh.getIndices();\r\n if (!indices) {\r\n return null;\r\n }\r\n\r\n const uvs = this.pickedMesh.getVerticesData(uvSet);\r\n if (!uvs) {\r\n return null;\r\n }\r\n\r\n let uv0 = Vector2.FromArray(uvs, indices[this.faceId * 3] * 2);\r\n let uv1 = Vector2.FromArray(uvs, indices[this.faceId * 3 + 1] * 2);\r\n let uv2 = Vector2.FromArray(uvs, indices[this.faceId * 3 + 2] * 2);\r\n\r\n uv0 = uv0.scale(this.bu);\r\n uv1 = uv1.scale(this.bv);\r\n uv2 = uv2.scale(1.0 - this.bu - this.bv);\r\n\r\n return new Vector2(uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);\r\n }\r\n}\r\n"]}
@@ -192,6 +192,7 @@ ThinEngine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, f
192
192
  const texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode, null);
193
193
  scene === null || scene === void 0 ? void 0 : scene.addPendingData(texture);
194
194
  texture.url = url;
195
+ texture.isReady = false;
195
196
  this._internalTexturesCache.push(texture);
196
197
  const onerror = (request, exception) => {
197
198
  scene === null || scene === void 0 ? void 0 : scene.removePendingData(texture);
@@ -1 +1 @@
1
- {"version":3,"file":"engine.rawTexture.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Engines/Extensions/engine.rawTexture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AA4R3C,UAAU,CAAC,SAAS,CAAC,gBAAgB,GAAG,UACpC,OAAkC,EAClC,IAA+B,EAC/B,MAAc,EACd,OAAgB,EAChB,cAAgC,IAAI,EACpC,OAAe,SAAS,CAAC,wBAAwB,EACjD,gBAAyB,KAAK;IAE9B,IAAI,CAAC,OAAO,EAAE;QACV,OAAO;KACV;IACD,kEAAkE;IAClE,MAAM,kBAAkB,GAAG,IA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AAC,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,EAAE,cAAc,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;SAC3I;QAED,IAAI,OAAO,CAAC,eAAe,EAAE;YACzB,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;SACnC;QACD,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACxC,4BAA4B;QAC5B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAC3B,CAAC,CAAC;AACN,CAAC;AAED,UAAU,CAAC,SAAS,CAAC,uBAAuB,GAAG,6BAA6B,CAAC,KAAK,CAAC,CAAC;AACpF,UAAU,CAAC,SAAS,CAAC,kBAAkB,GAAG,6BAA6B,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { InternalTexture, InternalTextureSource } from \"../../Materials/Textures/internalTexture\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Constants } from \"../constants\";\r\nimport { ThinEngine } from \"../thinEngine\";\r\nimport type { IWebRequest } from \"../../Misc/interfaces/iWebRequest\";\r\n\r\ndeclare module \"../../Engines/thinEngine\" {\r\n export interface ThinEngine {\r\n /**\r\n * Creates a raw texture\r\n * @param data defines the data to store in the texture\r\n * @param width defines the width of the texture\r\n * @param height defines the height of the texture\r\n * @param format defines the format of the data\r\n * @param generateMipMaps defines if the engine should generate the mip levels\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)\r\n * @param compression defines the compression used (null by default)\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @returns the raw texture inside an InternalTexture\r\n */\r\n createRawTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string>,\r\n type: number,\r\n creationFlags?: number,\r\n useSRGBBuffer?: boolean\r\n ): InternalTexture;\r\n\r\n /**\r\n * Update a raw texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store in the texture\r\n * @param format defines the format of the data\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store in the texture\r\n * @param format defines the format of the data\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the compression used (null by default)\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n */\r\n updateRawTexture(\r\n texture: Nullable<InternalTexture>,\r\n data: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string>,\r\n type: number,\r\n useSRGBBuffer: boolean\r\n ): void;\r\n\r\n /**\r\n * Creates a new raw cube texture\r\n * @param data defines the array of data to use to create each face\r\n * @param size defines the size of the textures\r\n * @param format defines the format of the data\r\n * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)\r\n * @param generateMipMaps defines if the engine should generate the mip levels\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)\r\n * @param compression defines the compression used (null by default)\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createRawCubeTexture(\r\n data: Nullable<ArrayBufferView[]>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string>\r\n ): InternalTexture;\r\n\r\n /**\r\n * Update a raw cube texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw cube texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the compression used (null by default)\r\n */\r\n updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;\r\n\r\n /**\r\n * Update a raw cube texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the compression used (null by default)\r\n * @param level defines which level of the texture to update\r\n */\r\n updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;\r\n\r\n /**\r\n * Creates a new raw cube texture from a specified url\r\n * @param url defines the url where the data is located\r\n * @param scene defines the current scene\r\n * @param size defines the size of the textures\r\n * @param format defines the format of the data\r\n * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)\r\n * @param noMipmap defines if the engine should avoid generating the mip levels\r\n * @param callback defines a callback used to extract texture data from loaded data\r\n * @param mipmapGenerator defines to provide an optional tool to generate mip levels\r\n * @param onLoad defines a callback called when texture is loaded\r\n * @param onError defines a callback called if there is an error\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createRawCubeTextureFromUrl(\r\n url: string,\r\n scene: Nullable<Scene>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n noMipmap: boolean,\r\n callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>,\r\n mipmapGenerator: Nullable<(faces: ArrayBufferView[]) => ArrayBufferView[][]>,\r\n onLoad: Nullable<() => void>,\r\n onError: Nullable<(message?: string, exception?: any) => void>\r\n ): InternalTexture;\r\n\r\n /**\r\n * Creates a new raw cube texture from a specified url\r\n * @param url defines the url where the data is located\r\n * @param scene defines the current scene\r\n * @param size defines the size of the textures\r\n * @param format defines the format of the data\r\n * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)\r\n * @param noMipmap defines if the engine should avoid generating the mip levels\r\n * @param callback defines a callback used to extract texture data from loaded data\r\n * @param mipmapGenerator defines to provide an optional tool to generate mip levels\r\n * @param onLoad defines a callback called when texture is loaded\r\n * @param onError defines a callback called if there is an error\r\n * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createRawCubeTextureFromUrl(\r\n url: string,\r\n scene: Nullable<Scene>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n noMipmap: boolean,\r\n callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>,\r\n mipmapGenerator: Nullable<(faces: ArrayBufferView[]) => ArrayBufferView[][]>,\r\n onLoad: Nullable<() => void>,\r\n onError: Nullable<(message?: string, exception?: any) => void>,\r\n samplingMode: number,\r\n invertY: boolean\r\n ): InternalTexture;\r\n\r\n /**\r\n * Creates a new raw 3D texture\r\n * @param data defines the data used to create the texture\r\n * @param width defines the width of the texture\r\n * @param height defines the height of the texture\r\n * @param depth defines the depth of the texture\r\n * @param format defines the format of the texture\r\n * @param generateMipMaps defines if the engine must generate mip levels\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)\r\n * @param compression defines the compressed used (can be null)\r\n * @param textureType defines the compressed used (can be null)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @returns a new raw 3D texture (stored in an InternalTexture)\r\n */\r\n createRawTexture3D(\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 samplingMode: number,\r\n compression: Nullable<string>,\r\n textureType: number,\r\n creationFlags?: number\r\n ): InternalTexture;\r\n\r\n /**\r\n * Update a raw 3D texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw 3D texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the used compression (can be null)\r\n * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)\r\n */\r\n updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;\r\n\r\n /**\r\n * Creates a new raw 2D array texture\r\n * @param data defines the data used to create the texture\r\n * @param width defines the width of the texture\r\n * @param height defines the height of the texture\r\n * @param depth defines the number of layers of the texture\r\n * @param format defines the format of the texture\r\n * @param generateMipMaps defines if the engine must generate mip levels\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)\r\n * @param compression defines the compressed used (can be null)\r\n * @param textureType defines the compressed used (can be null)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @returns a new raw 2D array texture (stored in an InternalTexture)\r\n */\r\n createRawTexture2DArray(\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 samplingMode: number,\r\n compression: Nullable<string>,\r\n textureType: number,\r\n creationFlags?: number\r\n ): InternalTexture;\r\n\r\n /**\r\n * Update a raw 2D array texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw 2D array texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the used compression (can be null)\r\n * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)\r\n */\r\n updateRawTexture2DArray(\r\n texture: InternalTexture,\r\n data: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string>,\r\n textureType: number\r\n ): void;\r\n }\r\n}\r\n\r\nThinEngine.prototype.updateRawTexture = function (\r\n texture: Nullable<InternalTexture>,\r\n data: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string> = null,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n useSRGBBuffer: boolean = false\r\n): void {\r\n if (!texture) {\r\n return;\r\n }\r\n // Babylon's internalSizedFomat but gl's texImage2D internalFormat\r\n const internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format, useSRGBBuffer);\r\n\r\n // Babylon's internalFormat but gl's texImage2D format\r\n const internalFormat = this._getInternalFormat(format);\r\n const textureType = this._getWebGLTextureType(type);\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);\r\n this._unpackFlipY(invertY === undefined ? true : invertY ? true : false);\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = data;\r\n texture.format = format;\r\n texture.type = type;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n }\r\n\r\n if (texture.width % 4 !== 0) {\r\n this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);\r\n }\r\n\r\n if (compression && data) {\r\n this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, (<any>this.getCaps().s3tc)[compression], texture.width, texture.height, 0, <DataView>data);\r\n } else {\r\n this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);\r\n }\r\n\r\n if (texture.generateMipMaps) {\r\n this._gl.generateMipmap(this._gl.TEXTURE_2D);\r\n }\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D, null);\r\n // this.resetTextureCache();\r\n texture.isReady = true;\r\n};\r\n\r\nThinEngine.prototype.createRawTexture = function (\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string> = null,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n creationFlags = 0,\r\n useSRGBBuffer = false\r\n): InternalTexture {\r\n const texture = new InternalTexture(this, InternalTextureSource.Raw);\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.format = format;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n texture.type = type;\r\n texture._useSRGBBuffer = this._getUseSRGBBuffer(useSRGBBuffer, !generateMipMaps);\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = data;\r\n }\r\n\r\n this.updateRawTexture(texture, data, format, invertY, compression, type, texture._useSRGBBuffer);\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);\r\n\r\n // Filters\r\n const filters = this._getSamplingParameters(samplingMode, generateMipMaps);\r\n\r\n this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);\r\n this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);\r\n\r\n if (generateMipMaps) {\r\n this._gl.generateMipmap(this._gl.TEXTURE_2D);\r\n }\r\n\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D, null);\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n return texture;\r\n};\r\n\r\nThinEngine.prototype.createRawCubeTexture = function (\r\n data: Nullable<ArrayBufferView[]>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string> = null\r\n): InternalTexture {\r\n const gl = this._gl;\r\n const texture = new InternalTexture(this, InternalTextureSource.CubeRaw);\r\n texture.isCube = true;\r\n texture.format = format;\r\n texture.type = type;\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferViewArray = data;\r\n }\r\n\r\n const textureType = this._getWebGLTextureType(type);\r\n let internalFormat = this._getInternalFormat(format);\r\n\r\n if (internalFormat === gl.RGB) {\r\n internalFormat = gl.RGBA;\r\n }\r\n\r\n // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable\r\n if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {\r\n generateMipMaps = false;\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n Logger.Warn(\"Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.\");\r\n } else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {\r\n generateMipMaps = false;\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n Logger.Warn(\"Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.\");\r\n } else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {\r\n generateMipMaps = false;\r\n Logger.Warn(\"Render to float textures is not supported. Mipmap generation forced to false.\");\r\n } else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {\r\n generateMipMaps = false;\r\n Logger.Warn(\"Render to half float textures is not supported. Mipmap generation forced to false.\");\r\n }\r\n\r\n const width = size;\r\n const height = width;\r\n\r\n texture.width = width;\r\n texture.height = height;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n\r\n // Double check on POT to generate Mips.\r\n const isPot = !this.needPOTTextures || (Tools.IsExponentOfTwo(texture.width) && Tools.IsExponentOfTwo(texture.height));\r\n if (!isPot) {\r\n generateMipMaps = false;\r\n }\r\n\r\n // Upload data if needed. The texture won't be ready until then.\r\n if (data) {\r\n this.updateRawCubeTexture(texture, data, format, type, invertY, compression);\r\n } else {\r\n const internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);\r\n const level = 0;\r\n\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);\r\n\r\n for (let faceIndex = 0; faceIndex < 6; faceIndex++) {\r\n if (compression) {\r\n gl.compressedTexImage2D(\r\n gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex,\r\n level,\r\n (<any>this.getCaps().s3tc)[compression],\r\n texture.width,\r\n texture.height,\r\n 0,\r\n undefined as any\r\n );\r\n } else {\r\n gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, null);\r\n }\r\n }\r\n\r\n this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);\r\n }\r\n\r\n this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);\r\n\r\n // Filters\r\n if (data && generateMipMaps) {\r\n this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);\r\n }\r\n\r\n const filters = this._getSamplingParameters(samplingMode, generateMipMaps);\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);\r\n\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);\r\n\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.isReady = true;\r\n\r\n return texture;\r\n};\r\n\r\nThinEngine.prototype.updateRawCubeTexture = function (\r\n texture: InternalTexture,\r\n data: ArrayBufferView[],\r\n format: number,\r\n type: number,\r\n invertY: boolean,\r\n compression: Nullable<string> = null,\r\n level: number = 0\r\n): void {\r\n texture._bufferViewArray = data;\r\n texture.format = format;\r\n texture.type = type;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n\r\n const gl = this._gl;\r\n const textureType = this._getWebGLTextureType(type);\r\n let internalFormat = this._getInternalFormat(format);\r\n const internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);\r\n\r\n let needConversion = false;\r\n if (internalFormat === gl.RGB) {\r\n internalFormat = gl.RGBA;\r\n needConversion = true;\r\n }\r\n\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);\r\n this._unpackFlipY(invertY === undefined ? true : invertY ? true : false);\r\n\r\n if (texture.width % 4 !== 0) {\r\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\r\n }\r\n\r\n // Data are known to be in +X +Y +Z -X -Y -Z\r\n for (let faceIndex = 0; faceIndex < 6; faceIndex++) {\r\n let faceData = data[faceIndex];\r\n\r\n if (compression) {\r\n gl.compressedTexImage2D(\r\n gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex,\r\n level,\r\n (<any>this.getCaps().s3tc)[compression],\r\n texture.width,\r\n texture.height,\r\n 0,\r\n <DataView>faceData\r\n );\r\n } else {\r\n if (needConversion) {\r\n faceData = _convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);\r\n }\r\n gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);\r\n }\r\n }\r\n\r\n const isPot = !this.needPOTTextures || (Tools.IsExponentOfTwo(texture.width) && Tools.IsExponentOfTwo(texture.height));\r\n if (isPot && texture.generateMipMaps && level === 0) {\r\n this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);\r\n }\r\n this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);\r\n\r\n // this.resetTextureCache();\r\n texture.isReady = true;\r\n};\r\n\r\nThinEngine.prototype.createRawCubeTextureFromUrl = function (\r\n url: string,\r\n scene: Nullable<Scene>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n noMipmap: boolean,\r\n callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>,\r\n mipmapGenerator: Nullable<(faces: ArrayBufferView[]) => ArrayBufferView[][]>,\r\n onLoad: Nullable<() => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n invertY: boolean = false\r\n): InternalTexture {\r\n const gl = this._gl;\r\n const texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode, null);\r\n scene?.addPendingData(texture);\r\n texture.url = url;\r\n this._internalTexturesCache.push(texture);\r\n\r\n const onerror = (request?: IWebRequest, exception?: any) => {\r\n scene?.removePendingData(texture);\r\n if (onError && request) {\r\n onError(request.status + \" \" + request.statusText, exception);\r\n }\r\n };\r\n\r\n const internalCallback = (data: any) => {\r\n const width = texture.width;\r\n const faceDataArrays = callback(data);\r\n\r\n if (!faceDataArrays) {\r\n return;\r\n }\r\n\r\n if (mipmapGenerator) {\r\n const textureType = this._getWebGLTextureType(type);\r\n let internalFormat = this._getInternalFormat(format);\r\n const internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);\r\n\r\n let needConversion = false;\r\n if (internalFormat === gl.RGB) {\r\n internalFormat = gl.RGBA;\r\n needConversion = true;\r\n }\r\n\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);\r\n this._unpackFlipY(false);\r\n\r\n const mipData = mipmapGenerator(faceDataArrays);\r\n for (let level = 0; level < mipData.length; level++) {\r\n const mipSize = width >> level;\r\n\r\n for (let faceIndex = 0; faceIndex < 6; faceIndex++) {\r\n let mipFaceData = mipData[level][faceIndex];\r\n if (needConversion) {\r\n mipFaceData = _convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);\r\n }\r\n gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);\r\n }\r\n }\r\n\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);\r\n } else {\r\n this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);\r\n }\r\n\r\n texture.isReady = true;\r\n // this.resetTextureCache();\r\n scene?.removePendingData(texture);\r\n\r\n texture.onLoadedObservable.notifyObservers(texture);\r\n texture.onLoadedObservable.clear();\r\n\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n };\r\n\r\n this._loadFile(\r\n url,\r\n (data) => {\r\n internalCallback(data);\r\n },\r\n undefined,\r\n scene?.offlineProvider,\r\n true,\r\n onerror\r\n );\r\n\r\n return texture;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nfunction _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView {\r\n // Create new RGBA data container.\r\n let rgbaData: any;\r\n let val1 = 1;\r\n if (textureType === Constants.TEXTURETYPE_FLOAT) {\r\n rgbaData = new Float32Array(width * height * 4);\r\n } else if (textureType === Constants.TEXTURETYPE_HALF_FLOAT) {\r\n rgbaData = new Uint16Array(width * height * 4);\r\n val1 = 15360; // 15360 is the encoding of 1 in half float\r\n } else if (textureType === Constants.TEXTURETYPE_UNSIGNED_INTEGER) {\r\n rgbaData = new Uint32Array(width * height * 4);\r\n } else {\r\n rgbaData = new Uint8Array(width * height * 4);\r\n }\r\n\r\n // Convert each pixel.\r\n for (let x = 0; x < width; x++) {\r\n for (let y = 0; y < height; y++) {\r\n const index = (y * width + x) * 3;\r\n const newIndex = (y * width + x) * 4;\r\n\r\n // Map Old Value to new value.\r\n rgbaData[newIndex + 0] = rgbData[index + 0];\r\n rgbaData[newIndex + 1] = rgbData[index + 1];\r\n rgbaData[newIndex + 2] = rgbData[index + 2];\r\n\r\n // Add fully opaque alpha channel.\r\n rgbaData[newIndex + 3] = val1;\r\n }\r\n }\r\n\r\n return rgbaData;\r\n}\r\n\r\n/**\r\n * Create a function for createRawTexture3D/createRawTexture2DArray\r\n * @param is3D true for TEXTURE_3D and false for TEXTURE_2D_ARRAY\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nfunction _makeCreateRawTextureFunction(is3D: boolean) {\r\n return function (\r\n this: ThinEngine,\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 samplingMode: number,\r\n compression: Nullable<string> = null,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT\r\n ): InternalTexture {\r\n const target = is3D ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY;\r\n const source = is3D ? InternalTextureSource.Raw3D : InternalTextureSource.Raw2DArray;\r\n const texture = new InternalTexture(this, source);\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.baseDepth = depth;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.depth = depth;\r\n texture.format = format;\r\n texture.type = textureType;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n if (is3D) {\r\n texture.is3D = true;\r\n } else {\r\n texture.is2DArray = true;\r\n }\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = data;\r\n }\r\n\r\n if (is3D) {\r\n this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);\r\n } else {\r\n this.updateRawTexture2DArray(texture, data, format, invertY, compression, textureType);\r\n }\r\n this._bindTextureDirectly(target, texture, true);\r\n\r\n // Filters\r\n const filters = this._getSamplingParameters(samplingMode, generateMipMaps);\r\n\r\n this._gl.texParameteri(target, this._gl.TEXTURE_MAG_FILTER, filters.mag);\r\n this._gl.texParameteri(target, this._gl.TEXTURE_MIN_FILTER, filters.min);\r\n\r\n if (generateMipMaps) {\r\n this._gl.generateMipmap(target);\r\n }\r\n\r\n this._bindTextureDirectly(target, null);\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n return texture;\r\n };\r\n}\r\n\r\nThinEngine.prototype.createRawTexture2DArray = _makeCreateRawTextureFunction(false);\r\nThinEngine.prototype.createRawTexture3D = _makeCreateRawTextureFunction(true);\r\n\r\n/**\r\n * Create a function for updateRawTexture3D/updateRawTexture2DArray\r\n * @param is3D true for TEXTURE_3D and false for TEXTURE_2D_ARRAY\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nfunction _makeUpdateRawTextureFunction(is3D: boolean) {\r\n return function (\r\n this: ThinEngine,\r\n texture: InternalTexture,\r\n data: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string> = null,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT\r\n ): void {\r\n const target = is3D ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY;\r\n const internalType = this._getWebGLTextureType(textureType);\r\n const internalFormat = this._getInternalFormat(format);\r\n const internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);\r\n\r\n this._bindTextureDirectly(target, texture, true);\r\n this._unpackFlipY(invertY === undefined ? true : invertY ? true : false);\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = data;\r\n texture.format = format;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n }\r\n\r\n if (texture.width % 4 !== 0) {\r\n this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);\r\n }\r\n\r\n if (compression && data) {\r\n this._gl.compressedTexImage3D(target, 0, (<any>this.getCaps().s3tc)[compression], texture.width, texture.height, texture.depth, 0, data);\r\n } else {\r\n this._gl.texImage3D(target, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);\r\n }\r\n\r\n if (texture.generateMipMaps) {\r\n this._gl.generateMipmap(target);\r\n }\r\n this._bindTextureDirectly(target, null);\r\n // this.resetTextureCache();\r\n texture.isReady = true;\r\n };\r\n}\r\n\r\nThinEngine.prototype.updateRawTexture2DArray = _makeUpdateRawTextureFunction(false);\r\nThinEngine.prototype.updateRawTexture3D = _makeUpdateRawTextureFunction(true);\r\n"]}
1
+ {"version":3,"file":"engine.rawTexture.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Engines/Extensions/engine.rawTexture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AA4R3C,UAAU,CAAC,SAAS,CAAC,gBAAgB,GAAG,UACpC,OAAkC,EAClC,IAA+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AAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;SAC5I;aAAM;YACH,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,kBAAkB,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,EAAE,cAAc,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;SAC3I;QAED,IAAI,OAAO,CAAC,eAAe,EAAE;YACzB,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;SACnC;QACD,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACxC,4BAA4B;QAC5B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAC3B,CAAC,CAAC;AACN,CAAC;AAED,UAAU,CAAC,SAAS,CAAC,uBAAuB,GAAG,6BAA6B,CAAC,KAAK,CAAC,CAAC;AACpF,UAAU,CAAC,SAAS,CAAC,kBAAkB,GAAG,6BAA6B,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { InternalTexture, InternalTextureSource } from \"../../Materials/Textures/internalTexture\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Constants } from \"../constants\";\r\nimport { ThinEngine } from \"../thinEngine\";\r\nimport type { IWebRequest } from \"../../Misc/interfaces/iWebRequest\";\r\n\r\ndeclare module \"../../Engines/thinEngine\" {\r\n export interface ThinEngine {\r\n /**\r\n * Creates a raw texture\r\n * @param data defines the data to store in the texture\r\n * @param width defines the width of the texture\r\n * @param height defines the height of the texture\r\n * @param format defines the format of the data\r\n * @param generateMipMaps defines if the engine should generate the mip levels\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)\r\n * @param compression defines the compression used (null by default)\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @returns the raw texture inside an InternalTexture\r\n */\r\n createRawTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string>,\r\n type: number,\r\n creationFlags?: number,\r\n useSRGBBuffer?: boolean\r\n ): InternalTexture;\r\n\r\n /**\r\n * Update a raw texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store in the texture\r\n * @param format defines the format of the data\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store in the texture\r\n * @param format defines the format of the data\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the compression used (null by default)\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n */\r\n updateRawTexture(\r\n texture: Nullable<InternalTexture>,\r\n data: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string>,\r\n type: number,\r\n useSRGBBuffer: boolean\r\n ): void;\r\n\r\n /**\r\n * Creates a new raw cube texture\r\n * @param data defines the array of data to use to create each face\r\n * @param size defines the size of the textures\r\n * @param format defines the format of the data\r\n * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)\r\n * @param generateMipMaps defines if the engine should generate the mip levels\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)\r\n * @param compression defines the compression used (null by default)\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createRawCubeTexture(\r\n data: Nullable<ArrayBufferView[]>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string>\r\n ): InternalTexture;\r\n\r\n /**\r\n * Update a raw cube texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw cube texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the compression used (null by default)\r\n */\r\n updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;\r\n\r\n /**\r\n * Update a raw cube texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the compression used (null by default)\r\n * @param level defines which level of the texture to update\r\n */\r\n updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;\r\n\r\n /**\r\n * Creates a new raw cube texture from a specified url\r\n * @param url defines the url where the data is located\r\n * @param scene defines the current scene\r\n * @param size defines the size of the textures\r\n * @param format defines the format of the data\r\n * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)\r\n * @param noMipmap defines if the engine should avoid generating the mip levels\r\n * @param callback defines a callback used to extract texture data from loaded data\r\n * @param mipmapGenerator defines to provide an optional tool to generate mip levels\r\n * @param onLoad defines a callback called when texture is loaded\r\n * @param onError defines a callback called if there is an error\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createRawCubeTextureFromUrl(\r\n url: string,\r\n scene: Nullable<Scene>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n noMipmap: boolean,\r\n callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>,\r\n mipmapGenerator: Nullable<(faces: ArrayBufferView[]) => ArrayBufferView[][]>,\r\n onLoad: Nullable<() => void>,\r\n onError: Nullable<(message?: string, exception?: any) => void>\r\n ): InternalTexture;\r\n\r\n /**\r\n * Creates a new raw cube texture from a specified url\r\n * @param url defines the url where the data is located\r\n * @param scene defines the current scene\r\n * @param size defines the size of the textures\r\n * @param format defines the format of the data\r\n * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)\r\n * @param noMipmap defines if the engine should avoid generating the mip levels\r\n * @param callback defines a callback used to extract texture data from loaded data\r\n * @param mipmapGenerator defines to provide an optional tool to generate mip levels\r\n * @param onLoad defines a callback called when texture is loaded\r\n * @param onError defines a callback called if there is an error\r\n * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createRawCubeTextureFromUrl(\r\n url: string,\r\n scene: Nullable<Scene>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n noMipmap: boolean,\r\n callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>,\r\n mipmapGenerator: Nullable<(faces: ArrayBufferView[]) => ArrayBufferView[][]>,\r\n onLoad: Nullable<() => void>,\r\n onError: Nullable<(message?: string, exception?: any) => void>,\r\n samplingMode: number,\r\n invertY: boolean\r\n ): InternalTexture;\r\n\r\n /**\r\n * Creates a new raw 3D texture\r\n * @param data defines the data used to create the texture\r\n * @param width defines the width of the texture\r\n * @param height defines the height of the texture\r\n * @param depth defines the depth of the texture\r\n * @param format defines the format of the texture\r\n * @param generateMipMaps defines if the engine must generate mip levels\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)\r\n * @param compression defines the compressed used (can be null)\r\n * @param textureType defines the compressed used (can be null)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @returns a new raw 3D texture (stored in an InternalTexture)\r\n */\r\n createRawTexture3D(\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 samplingMode: number,\r\n compression: Nullable<string>,\r\n textureType: number,\r\n creationFlags?: number\r\n ): InternalTexture;\r\n\r\n /**\r\n * Update a raw 3D texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw 3D texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the used compression (can be null)\r\n * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)\r\n */\r\n updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;\r\n\r\n /**\r\n * Creates a new raw 2D array texture\r\n * @param data defines the data used to create the texture\r\n * @param width defines the width of the texture\r\n * @param height defines the height of the texture\r\n * @param depth defines the number of layers of the texture\r\n * @param format defines the format of the texture\r\n * @param generateMipMaps defines if the engine must generate mip levels\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)\r\n * @param compression defines the compressed used (can be null)\r\n * @param textureType defines the compressed used (can be null)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @returns a new raw 2D array texture (stored in an InternalTexture)\r\n */\r\n createRawTexture2DArray(\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 samplingMode: number,\r\n compression: Nullable<string>,\r\n textureType: number,\r\n creationFlags?: number\r\n ): InternalTexture;\r\n\r\n /**\r\n * Update a raw 2D array texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw 2D array texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the used compression (can be null)\r\n * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)\r\n */\r\n updateRawTexture2DArray(\r\n texture: InternalTexture,\r\n data: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string>,\r\n textureType: number\r\n ): void;\r\n }\r\n}\r\n\r\nThinEngine.prototype.updateRawTexture = function (\r\n texture: Nullable<InternalTexture>,\r\n data: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string> = null,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n useSRGBBuffer: boolean = false\r\n): void {\r\n if (!texture) {\r\n return;\r\n }\r\n // Babylon's internalSizedFomat but gl's texImage2D internalFormat\r\n const internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format, useSRGBBuffer);\r\n\r\n // Babylon's internalFormat but gl's texImage2D format\r\n const internalFormat = this._getInternalFormat(format);\r\n const textureType = this._getWebGLTextureType(type);\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);\r\n this._unpackFlipY(invertY === undefined ? true : invertY ? true : false);\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = data;\r\n texture.format = format;\r\n texture.type = type;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n }\r\n\r\n if (texture.width % 4 !== 0) {\r\n this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);\r\n }\r\n\r\n if (compression && data) {\r\n this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, (<any>this.getCaps().s3tc)[compression], texture.width, texture.height, 0, <DataView>data);\r\n } else {\r\n this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);\r\n }\r\n\r\n if (texture.generateMipMaps) {\r\n this._gl.generateMipmap(this._gl.TEXTURE_2D);\r\n }\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D, null);\r\n // this.resetTextureCache();\r\n texture.isReady = true;\r\n};\r\n\r\nThinEngine.prototype.createRawTexture = function (\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string> = null,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_INT,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n creationFlags = 0,\r\n useSRGBBuffer = false\r\n): InternalTexture {\r\n const texture = new InternalTexture(this, InternalTextureSource.Raw);\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.format = format;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n texture.type = type;\r\n texture._useSRGBBuffer = this._getUseSRGBBuffer(useSRGBBuffer, !generateMipMaps);\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = data;\r\n }\r\n\r\n this.updateRawTexture(texture, data, format, invertY, compression, type, texture._useSRGBBuffer);\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);\r\n\r\n // Filters\r\n const filters = this._getSamplingParameters(samplingMode, generateMipMaps);\r\n\r\n this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);\r\n this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);\r\n\r\n if (generateMipMaps) {\r\n this._gl.generateMipmap(this._gl.TEXTURE_2D);\r\n }\r\n\r\n this._bindTextureDirectly(this._gl.TEXTURE_2D, null);\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n return texture;\r\n};\r\n\r\nThinEngine.prototype.createRawCubeTexture = function (\r\n data: Nullable<ArrayBufferView[]>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string> = null\r\n): InternalTexture {\r\n const gl = this._gl;\r\n const texture = new InternalTexture(this, InternalTextureSource.CubeRaw);\r\n texture.isCube = true;\r\n texture.format = format;\r\n texture.type = type;\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferViewArray = data;\r\n }\r\n\r\n const textureType = this._getWebGLTextureType(type);\r\n let internalFormat = this._getInternalFormat(format);\r\n\r\n if (internalFormat === gl.RGB) {\r\n internalFormat = gl.RGBA;\r\n }\r\n\r\n // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable\r\n if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {\r\n generateMipMaps = false;\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n Logger.Warn(\"Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.\");\r\n } else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {\r\n generateMipMaps = false;\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n Logger.Warn(\"Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.\");\r\n } else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {\r\n generateMipMaps = false;\r\n Logger.Warn(\"Render to float textures is not supported. Mipmap generation forced to false.\");\r\n } else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {\r\n generateMipMaps = false;\r\n Logger.Warn(\"Render to half float textures is not supported. Mipmap generation forced to false.\");\r\n }\r\n\r\n const width = size;\r\n const height = width;\r\n\r\n texture.width = width;\r\n texture.height = height;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n\r\n // Double check on POT to generate Mips.\r\n const isPot = !this.needPOTTextures || (Tools.IsExponentOfTwo(texture.width) && Tools.IsExponentOfTwo(texture.height));\r\n if (!isPot) {\r\n generateMipMaps = false;\r\n }\r\n\r\n // Upload data if needed. The texture won't be ready until then.\r\n if (data) {\r\n this.updateRawCubeTexture(texture, data, format, type, invertY, compression);\r\n } else {\r\n const internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);\r\n const level = 0;\r\n\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);\r\n\r\n for (let faceIndex = 0; faceIndex < 6; faceIndex++) {\r\n if (compression) {\r\n gl.compressedTexImage2D(\r\n gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex,\r\n level,\r\n (<any>this.getCaps().s3tc)[compression],\r\n texture.width,\r\n texture.height,\r\n 0,\r\n undefined as any\r\n );\r\n } else {\r\n gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, null);\r\n }\r\n }\r\n\r\n this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);\r\n }\r\n\r\n this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);\r\n\r\n // Filters\r\n if (data && generateMipMaps) {\r\n this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);\r\n }\r\n\r\n const filters = this._getSamplingParameters(samplingMode, generateMipMaps);\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);\r\n\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);\r\n gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);\r\n\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.isReady = true;\r\n\r\n return texture;\r\n};\r\n\r\nThinEngine.prototype.updateRawCubeTexture = function (\r\n texture: InternalTexture,\r\n data: ArrayBufferView[],\r\n format: number,\r\n type: number,\r\n invertY: boolean,\r\n compression: Nullable<string> = null,\r\n level: number = 0\r\n): void {\r\n texture._bufferViewArray = data;\r\n texture.format = format;\r\n texture.type = type;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n\r\n const gl = this._gl;\r\n const textureType = this._getWebGLTextureType(type);\r\n let internalFormat = this._getInternalFormat(format);\r\n const internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);\r\n\r\n let needConversion = false;\r\n if (internalFormat === gl.RGB) {\r\n internalFormat = gl.RGBA;\r\n needConversion = true;\r\n }\r\n\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);\r\n this._unpackFlipY(invertY === undefined ? true : invertY ? true : false);\r\n\r\n if (texture.width % 4 !== 0) {\r\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\r\n }\r\n\r\n // Data are known to be in +X +Y +Z -X -Y -Z\r\n for (let faceIndex = 0; faceIndex < 6; faceIndex++) {\r\n let faceData = data[faceIndex];\r\n\r\n if (compression) {\r\n gl.compressedTexImage2D(\r\n gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex,\r\n level,\r\n (<any>this.getCaps().s3tc)[compression],\r\n texture.width,\r\n texture.height,\r\n 0,\r\n <DataView>faceData\r\n );\r\n } else {\r\n if (needConversion) {\r\n faceData = _convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);\r\n }\r\n gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);\r\n }\r\n }\r\n\r\n const isPot = !this.needPOTTextures || (Tools.IsExponentOfTwo(texture.width) && Tools.IsExponentOfTwo(texture.height));\r\n if (isPot && texture.generateMipMaps && level === 0) {\r\n this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);\r\n }\r\n this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);\r\n\r\n // this.resetTextureCache();\r\n texture.isReady = true;\r\n};\r\n\r\nThinEngine.prototype.createRawCubeTextureFromUrl = function (\r\n url: string,\r\n scene: Nullable<Scene>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n noMipmap: boolean,\r\n callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>,\r\n mipmapGenerator: Nullable<(faces: ArrayBufferView[]) => ArrayBufferView[][]>,\r\n onLoad: Nullable<() => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n invertY: boolean = false\r\n): InternalTexture {\r\n const gl = this._gl;\r\n const texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode, null);\r\n scene?.addPendingData(texture);\r\n texture.url = url;\r\n texture.isReady = false;\r\n this._internalTexturesCache.push(texture);\r\n\r\n const onerror = (request?: IWebRequest, exception?: any) => {\r\n scene?.removePendingData(texture);\r\n if (onError && request) {\r\n onError(request.status + \" \" + request.statusText, exception);\r\n }\r\n };\r\n\r\n const internalCallback = (data: any) => {\r\n const width = texture.width;\r\n const faceDataArrays = callback(data);\r\n\r\n if (!faceDataArrays) {\r\n return;\r\n }\r\n\r\n if (mipmapGenerator) {\r\n const textureType = this._getWebGLTextureType(type);\r\n let internalFormat = this._getInternalFormat(format);\r\n const internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);\r\n\r\n let needConversion = false;\r\n if (internalFormat === gl.RGB) {\r\n internalFormat = gl.RGBA;\r\n needConversion = true;\r\n }\r\n\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);\r\n this._unpackFlipY(false);\r\n\r\n const mipData = mipmapGenerator(faceDataArrays);\r\n for (let level = 0; level < mipData.length; level++) {\r\n const mipSize = width >> level;\r\n\r\n for (let faceIndex = 0; faceIndex < 6; faceIndex++) {\r\n let mipFaceData = mipData[level][faceIndex];\r\n if (needConversion) {\r\n mipFaceData = _convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);\r\n }\r\n gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);\r\n }\r\n }\r\n\r\n this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);\r\n } else {\r\n this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);\r\n }\r\n\r\n texture.isReady = true;\r\n // this.resetTextureCache();\r\n scene?.removePendingData(texture);\r\n\r\n texture.onLoadedObservable.notifyObservers(texture);\r\n texture.onLoadedObservable.clear();\r\n\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n };\r\n\r\n this._loadFile(\r\n url,\r\n (data) => {\r\n internalCallback(data);\r\n },\r\n undefined,\r\n scene?.offlineProvider,\r\n true,\r\n onerror\r\n );\r\n\r\n return texture;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nfunction _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView {\r\n // Create new RGBA data container.\r\n let rgbaData: any;\r\n let val1 = 1;\r\n if (textureType === Constants.TEXTURETYPE_FLOAT) {\r\n rgbaData = new Float32Array(width * height * 4);\r\n } else if (textureType === Constants.TEXTURETYPE_HALF_FLOAT) {\r\n rgbaData = new Uint16Array(width * height * 4);\r\n val1 = 15360; // 15360 is the encoding of 1 in half float\r\n } else if (textureType === Constants.TEXTURETYPE_UNSIGNED_INTEGER) {\r\n rgbaData = new Uint32Array(width * height * 4);\r\n } else {\r\n rgbaData = new Uint8Array(width * height * 4);\r\n }\r\n\r\n // Convert each pixel.\r\n for (let x = 0; x < width; x++) {\r\n for (let y = 0; y < height; y++) {\r\n const index = (y * width + x) * 3;\r\n const newIndex = (y * width + x) * 4;\r\n\r\n // Map Old Value to new value.\r\n rgbaData[newIndex + 0] = rgbData[index + 0];\r\n rgbaData[newIndex + 1] = rgbData[index + 1];\r\n rgbaData[newIndex + 2] = rgbData[index + 2];\r\n\r\n // Add fully opaque alpha channel.\r\n rgbaData[newIndex + 3] = val1;\r\n }\r\n }\r\n\r\n return rgbaData;\r\n}\r\n\r\n/**\r\n * Create a function for createRawTexture3D/createRawTexture2DArray\r\n * @param is3D true for TEXTURE_3D and false for TEXTURE_2D_ARRAY\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nfunction _makeCreateRawTextureFunction(is3D: boolean) {\r\n return function (\r\n this: ThinEngine,\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 samplingMode: number,\r\n compression: Nullable<string> = null,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT\r\n ): InternalTexture {\r\n const target = is3D ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY;\r\n const source = is3D ? InternalTextureSource.Raw3D : InternalTextureSource.Raw2DArray;\r\n const texture = new InternalTexture(this, source);\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.baseDepth = depth;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.depth = depth;\r\n texture.format = format;\r\n texture.type = textureType;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n if (is3D) {\r\n texture.is3D = true;\r\n } else {\r\n texture.is2DArray = true;\r\n }\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = data;\r\n }\r\n\r\n if (is3D) {\r\n this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);\r\n } else {\r\n this.updateRawTexture2DArray(texture, data, format, invertY, compression, textureType);\r\n }\r\n this._bindTextureDirectly(target, texture, true);\r\n\r\n // Filters\r\n const filters = this._getSamplingParameters(samplingMode, generateMipMaps);\r\n\r\n this._gl.texParameteri(target, this._gl.TEXTURE_MAG_FILTER, filters.mag);\r\n this._gl.texParameteri(target, this._gl.TEXTURE_MIN_FILTER, filters.min);\r\n\r\n if (generateMipMaps) {\r\n this._gl.generateMipmap(target);\r\n }\r\n\r\n this._bindTextureDirectly(target, null);\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n return texture;\r\n };\r\n}\r\n\r\nThinEngine.prototype.createRawTexture2DArray = _makeCreateRawTextureFunction(false);\r\nThinEngine.prototype.createRawTexture3D = _makeCreateRawTextureFunction(true);\r\n\r\n/**\r\n * Create a function for updateRawTexture3D/updateRawTexture2DArray\r\n * @param is3D true for TEXTURE_3D and false for TEXTURE_2D_ARRAY\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nfunction _makeUpdateRawTextureFunction(is3D: boolean) {\r\n return function (\r\n this: ThinEngine,\r\n texture: InternalTexture,\r\n data: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string> = null,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_INT\r\n ): void {\r\n const target = is3D ? this._gl.TEXTURE_3D : this._gl.TEXTURE_2D_ARRAY;\r\n const internalType = this._getWebGLTextureType(textureType);\r\n const internalFormat = this._getInternalFormat(format);\r\n const internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);\r\n\r\n this._bindTextureDirectly(target, texture, true);\r\n this._unpackFlipY(invertY === undefined ? true : invertY ? true : false);\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = data;\r\n texture.format = format;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n }\r\n\r\n if (texture.width % 4 !== 0) {\r\n this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);\r\n }\r\n\r\n if (compression && data) {\r\n this._gl.compressedTexImage3D(target, 0, (<any>this.getCaps().s3tc)[compression], texture.width, texture.height, texture.depth, 0, data);\r\n } else {\r\n this._gl.texImage3D(target, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);\r\n }\r\n\r\n if (texture.generateMipMaps) {\r\n this._gl.generateMipmap(target);\r\n }\r\n this._bindTextureDirectly(target, null);\r\n // this.resetTextureCache();\r\n texture.isReady = true;\r\n };\r\n}\r\n\r\nThinEngine.prototype.updateRawTexture2DArray = _makeUpdateRawTextureFunction(false);\r\nThinEngine.prototype.updateRawTexture3D = _makeUpdateRawTextureFunction(true);\r\n"]}
@@ -21,7 +21,7 @@ export class WebGPUHardwareTexture {
21
21
  releaseMSAATexture() {
22
22
  if (this._webgpuMSAATexture) {
23
23
  for (const texture of this._webgpuMSAATexture) {
24
- texture.destroy();
24
+ texture === null || texture === void 0 ? void 0 : texture.destroy();
25
25
  }
26
26
  this._webgpuMSAATexture = null;
27
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"webgpuHardwareTexture.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Engines/WebGPU/webgpuHardwareTexture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAIrD,gBAAgB;AAChB,MAAM,OAAO,qBAAqB;IAsC9B,IAAW,kBAAkB;QACzB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAEM,cAAc,CAAC,KAAK,GAAG,CAAC;;QAC3B,OAAO,MAAA,MAAA,IAAI,CAAC,kBAAkB,0CAAG,KAAK,CAAC,mCAAI,IAAI,CAAC;IACpD,CAAC;IAEM,cAAc,CAAC,OAAmB,EAAE,KAAK,GAAG,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC1B,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAC;SAChC;QAED,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YACd,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC;SAC1C;QAED,IAAI,CAAC,kBAAmB,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;IAC9C,CAAC;IAEM,kBAAkB;QACrB,IAAI,IAAI,CAAC,kBAAkB,EAAE;YACzB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,kBAAkB,EAAE;gBAC3C,OAAO,CAAC,OAAO,EAAE,CAAC;aACrB;YACD,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;SAClC;IACL,CAAC;IAQD,YAAY,kBAAwC,IAAI;QAJjD,WAAM,GAAqB,eAAe,CAAC,aAAa,CAAC,UAAU,CAAC;QACpE,kBAAa,GAAG,CAAC,CAAC;QAClB,4BAAuB,GAAG,CAAC,CAAC;QAG/B,IAAI,CAAC,cAAc,GAAG,eAAe,CAAC;QACtC,IAAI,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7C;IACL,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC/B,CAAC;IAEM,OAAO;;QACV,MAAA,IAAI,CAAC,cAAc,0CAAE,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,MAAA,IAAI,CAAC,uBAAuB,0CAAE,OAAO,EAAE,CAAC;QACxC,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import type { HardwareTextureWrapper } from \"../../Materials/Textures/hardwareTextureWrapper\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport type { Nullable } from \"../../types\";\r\nimport * as WebGPUConstants from \"./webgpuConstants\";\r\n\r\ndeclare type WebGPUBundleList = import(\"./webgpuBundleList\").WebGPUBundleList;\r\n\r\n/** @internal */\r\nexport class WebGPUHardwareTexture implements HardwareTextureWrapper {\r\n /**\r\n * List of bundles collected in the snapshot rendering mode when the texture is a render target texture\r\n * The index in this array is the current layer we are rendering into\r\n * @internal\r\n */\r\n public _bundleLists: WebGPUBundleList[];\r\n /**\r\n * Current layer we are rendering into when in snapshot rendering mode (if the texture is a render target texture)\r\n * @internal\r\n */\r\n public _currentLayer: number;\r\n\r\n /**\r\n * Cache of RenderPassDescriptor and BindGroup used when generating mipmaps (see WebGPUTextureHelper.generateMipmaps)\r\n * @internal\r\n */\r\n public _mipmapGenRenderPassDescr: GPURenderPassDescriptor[][];\r\n /** @internal */\r\n public _mipmapGenBindGroup: GPUBindGroup[][];\r\n\r\n /**\r\n * Cache for the invertYPreMultiplyAlpha function (see WebGPUTextureHelper)\r\n * @internal\r\n */\r\n public _copyInvertYTempTexture?: GPUTexture;\r\n /** @internal */\r\n public _copyInvertYRenderPassDescr: GPURenderPassDescriptor;\r\n /** @internal */\r\n public _copyInvertYBindGroup: GPUBindGroup;\r\n /** @internal */\r\n public _copyInvertYBindGroupWithOfst: GPUBindGroup;\r\n\r\n private _webgpuTexture: Nullable<GPUTexture>;\r\n // There can be multiple MSAA textures for a single WebGPU texture because different layers of a 2DArrayTexture / 3DTexture\r\n // or different faces of a cube texture can be bound to different render targets at the same time (in a multi RenderTargetWrapper)\r\n private _webgpuMSAATexture: Nullable<GPUTexture[]>;\r\n\r\n public get underlyingResource(): Nullable<GPUTexture> {\r\n return this._webgpuTexture;\r\n }\r\n\r\n public getMSAATexture(index = 0): Nullable<GPUTexture> {\r\n return this._webgpuMSAATexture?.[index] ?? null;\r\n }\r\n\r\n public setMSAATexture(texture: GPUTexture, index = -1) {\r\n if (!this._webgpuMSAATexture) {\r\n this._webgpuMSAATexture = [];\r\n }\r\n\r\n if (index === -1) {\r\n index = this._webgpuMSAATexture.length;\r\n }\r\n\r\n this._webgpuMSAATexture![index] = texture;\r\n }\r\n\r\n public releaseMSAATexture() {\r\n if (this._webgpuMSAATexture) {\r\n for (const texture of this._webgpuMSAATexture) {\r\n texture.destroy();\r\n }\r\n this._webgpuMSAATexture = null;\r\n }\r\n }\r\n\r\n public view: Nullable<GPUTextureView>;\r\n public viewForWriting: Nullable<GPUTextureView>;\r\n public format: GPUTextureFormat = WebGPUConstants.TextureFormat.RGBA8Unorm;\r\n public textureUsages = 0;\r\n public textureAdditionalUsages = 0;\r\n\r\n constructor(existingTexture: Nullable<GPUTexture> = null) {\r\n this._webgpuTexture = existingTexture;\r\n this._webgpuMSAATexture = null;\r\n this.view = null;\r\n this.viewForWriting = null;\r\n }\r\n\r\n public set(hardwareTexture: GPUTexture): void {\r\n this._webgpuTexture = hardwareTexture;\r\n }\r\n\r\n public setUsage(_textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void {\r\n this.createView({\r\n format: this.format,\r\n dimension: isCube ? WebGPUConstants.TextureViewDimension.Cube : WebGPUConstants.TextureViewDimension.E2d,\r\n mipLevelCount: generateMipMaps ? Scalar.ILog2(Math.max(width, height)) + 1 : 1,\r\n baseArrayLayer: 0,\r\n baseMipLevel: 0,\r\n arrayLayerCount: isCube ? 6 : 1,\r\n aspect: WebGPUConstants.TextureAspect.All,\r\n });\r\n }\r\n\r\n public createView(descriptor?: GPUTextureViewDescriptor, createViewForWriting = false): void {\r\n this.view = this._webgpuTexture!.createView(descriptor);\r\n if (createViewForWriting && descriptor) {\r\n const saveNumMipMaps = descriptor.mipLevelCount;\r\n descriptor.mipLevelCount = 1;\r\n this.viewForWriting = this._webgpuTexture!.createView(descriptor);\r\n descriptor.mipLevelCount = saveNumMipMaps;\r\n }\r\n }\r\n\r\n public reset(): void {\r\n this._webgpuTexture = null;\r\n this._webgpuMSAATexture = null;\r\n this.view = null;\r\n this.viewForWriting = null;\r\n }\r\n\r\n public release(): void {\r\n this._webgpuTexture?.destroy();\r\n this.releaseMSAATexture();\r\n this._copyInvertYTempTexture?.destroy();\r\n this.reset();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"webgpuHardwareTexture.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Engines/WebGPU/webgpuHardwareTexture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,OAAO,KAAK,eAAe,MAAM,mBAAmB,CAAC;AAIrD,gBAAgB;AAChB,MAAM,OAAO,qBAAqB;IAsC9B,IAAW,kBAAkB;QACzB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAEM,cAAc,CAAC,KAAK,GAAG,CAAC;;QAC3B,OAAO,MAAA,MAAA,IAAI,CAAC,kBAAkB,0CAAG,KAAK,CAAC,mCAAI,IAAI,CAAC;IACpD,CAAC;IAEM,cAAc,CAAC,OAAmB,EAAE,KAAK,GAAG,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;YAC1B,IAAI,CAAC,kBAAkB,G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AAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9E,cAAc,EAAE,CAAC;YACjB,YAAY,EAAE,CAAC;YACf,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,EAAE,eAAe,CAAC,aAAa,CAAC,GAAG;SAC5C,CAAC,CAAC;IACP,CAAC;IAEM,UAAU,CAAC,UAAqC,EAAE,oBAAoB,GAAG,KAAK;QACjF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,cAAe,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QACxD,IAAI,oBAAoB,IAAI,UAAU,EAAE;YACpC,MAAM,cAAc,GAAG,UAAU,CAAC,aAAa,CAAC;YAChD,UAAU,CAAC,aAAa,GAAG,CAAC,CAAC;YAC7B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAe,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAClE,UAAU,CAAC,aAAa,GAAG,cAAc,CAAC;SAC7C;IACL,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC/B,CAAC;IAEM,OAAO;;QACV,MAAA,IAAI,CAAC,cAAc,0CAAE,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC1B,MAAA,IAAI,CAAC,uBAAuB,0CAAE,OAAO,EAAE,CAAC;QACxC,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import type { HardwareTextureWrapper } from \"../../Materials/Textures/hardwareTextureWrapper\";\r\nimport { Scalar } from \"../../Maths/math.scalar\";\r\nimport type { Nullable } from \"../../types\";\r\nimport * as WebGPUConstants from \"./webgpuConstants\";\r\n\r\ndeclare type WebGPUBundleList = import(\"./webgpuBundleList\").WebGPUBundleList;\r\n\r\n/** @internal */\r\nexport class WebGPUHardwareTexture implements HardwareTextureWrapper {\r\n /**\r\n * List of bundles collected in the snapshot rendering mode when the texture is a render target texture\r\n * The index in this array is the current layer we are rendering into\r\n * @internal\r\n */\r\n public _bundleLists: WebGPUBundleList[];\r\n /**\r\n * Current layer we are rendering into when in snapshot rendering mode (if the texture is a render target texture)\r\n * @internal\r\n */\r\n public _currentLayer: number;\r\n\r\n /**\r\n * Cache of RenderPassDescriptor and BindGroup used when generating mipmaps (see WebGPUTextureHelper.generateMipmaps)\r\n * @internal\r\n */\r\n public _mipmapGenRenderPassDescr: GPURenderPassDescriptor[][];\r\n /** @internal */\r\n public _mipmapGenBindGroup: GPUBindGroup[][];\r\n\r\n /**\r\n * Cache for the invertYPreMultiplyAlpha function (see WebGPUTextureHelper)\r\n * @internal\r\n */\r\n public _copyInvertYTempTexture?: GPUTexture;\r\n /** @internal */\r\n public _copyInvertYRenderPassDescr: GPURenderPassDescriptor;\r\n /** @internal */\r\n public _copyInvertYBindGroup: GPUBindGroup;\r\n /** @internal */\r\n public _copyInvertYBindGroupWithOfst: GPUBindGroup;\r\n\r\n private _webgpuTexture: Nullable<GPUTexture>;\r\n // There can be multiple MSAA textures for a single WebGPU texture because different layers of a 2DArrayTexture / 3DTexture\r\n // or different faces of a cube texture can be bound to different render targets at the same time (in a multi RenderTargetWrapper)\r\n private _webgpuMSAATexture: Nullable<GPUTexture[]>;\r\n\r\n public get underlyingResource(): Nullable<GPUTexture> {\r\n return this._webgpuTexture;\r\n }\r\n\r\n public getMSAATexture(index = 0): Nullable<GPUTexture> {\r\n return this._webgpuMSAATexture?.[index] ?? null;\r\n }\r\n\r\n public setMSAATexture(texture: GPUTexture, index = -1) {\r\n if (!this._webgpuMSAATexture) {\r\n this._webgpuMSAATexture = [];\r\n }\r\n\r\n if (index === -1) {\r\n index = this._webgpuMSAATexture.length;\r\n }\r\n\r\n this._webgpuMSAATexture![index] = texture;\r\n }\r\n\r\n public releaseMSAATexture() {\r\n if (this._webgpuMSAATexture) {\r\n for (const texture of this._webgpuMSAATexture) {\r\n texture?.destroy();\r\n }\r\n this._webgpuMSAATexture = null;\r\n }\r\n }\r\n\r\n public view: Nullable<GPUTextureView>;\r\n public viewForWriting: Nullable<GPUTextureView>;\r\n public format: GPUTextureFormat = WebGPUConstants.TextureFormat.RGBA8Unorm;\r\n public textureUsages = 0;\r\n public textureAdditionalUsages = 0;\r\n\r\n constructor(existingTexture: Nullable<GPUTexture> = null) {\r\n this._webgpuTexture = existingTexture;\r\n this._webgpuMSAATexture = null;\r\n this.view = null;\r\n this.viewForWriting = null;\r\n }\r\n\r\n public set(hardwareTexture: GPUTexture): void {\r\n this._webgpuTexture = hardwareTexture;\r\n }\r\n\r\n public setUsage(_textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void {\r\n this.createView({\r\n format: this.format,\r\n dimension: isCube ? WebGPUConstants.TextureViewDimension.Cube : WebGPUConstants.TextureViewDimension.E2d,\r\n mipLevelCount: generateMipMaps ? Scalar.ILog2(Math.max(width, height)) + 1 : 1,\r\n baseArrayLayer: 0,\r\n baseMipLevel: 0,\r\n arrayLayerCount: isCube ? 6 : 1,\r\n aspect: WebGPUConstants.TextureAspect.All,\r\n });\r\n }\r\n\r\n public createView(descriptor?: GPUTextureViewDescriptor, createViewForWriting = false): void {\r\n this.view = this._webgpuTexture!.createView(descriptor);\r\n if (createViewForWriting && descriptor) {\r\n const saveNumMipMaps = descriptor.mipLevelCount;\r\n descriptor.mipLevelCount = 1;\r\n this.viewForWriting = this._webgpuTexture!.createView(descriptor);\r\n descriptor.mipLevelCount = saveNumMipMaps;\r\n }\r\n }\r\n\r\n public reset(): void {\r\n this._webgpuTexture = null;\r\n this._webgpuMSAATexture = null;\r\n this.view = null;\r\n this.viewForWriting = null;\r\n }\r\n\r\n public release(): void {\r\n this._webgpuTexture?.destroy();\r\n this.releaseMSAATexture();\r\n this._copyInvertYTempTexture?.destroy();\r\n this.reset();\r\n }\r\n}\r\n"]}
@@ -1059,6 +1059,96 @@ const PressureObserver: {
1059
1059
  supportedSources: ReadonlyArray<PressureSource>;
1060
1060
  };
1061
1061
 
1062
+ /**
1063
+ * TODO: remove this file when we upgrade to TypeScript 5.0
1064
+ */
1065
+
1066
+ /* eslint-disable no-var */
1067
+ /* eslint-disable @typescript-eslint/naming-convention */
1068
+ interface OffscreenCanvasEventMap {
1069
+ contextlost: Event;
1070
+ contextrestored: Event;
1071
+ }
1072
+
1073
+ interface OffscreenCanvas extends EventTarget {
1074
+ /**
1075
+ * These attributes return the dimensions of the OffscreenCanvas object's bitmap.
1076
+ *
1077
+ * They can be set, to replace the bitmap with a new, transparent black bitmap of the specified dimensions (effectively resizing it).
1078
+ */
1079
+ height: number;
1080
+ oncontextlost: ((this: OffscreenCanvas, ev: Event) => any) | null;
1081
+ oncontextrestored: ((this: OffscreenCanvas, ev: Event) => any) | null;
1082
+ /**
1083
+ * These attributes return the dimensions of the OffscreenCanvas object's bitmap.
1084
+ *
1085
+ * They can be set, to replace the bitmap with a new, transparent black bitmap of the specified dimensions (effectively resizing it).
1086
+ */
1087
+ width: number;
1088
+ /**
1089
+ * Returns a promise that will fulfill with a new Blob object representing a file containing the image in the OffscreenCanvas object.
1090
+ *
1091
+ * The argument, if provided, is a dictionary that controls the encoding options of the image file to be created. The type field specifies the file format and has a default value of "image/png"; that type is also used if the requested type isn't supported. If the image format supports variable quality (such as "image/jpeg"), then the quality field is a number in the range 0.0 to 1.0 inclusive indicating the desired quality level for the resulting image.
1092
+ */
1093
+ convertToBlob(options?: ImageEncodeOptions): Promise<Blob>;
1094
+ /**
1095
+ * Returns an object that exposes an API for drawing on the OffscreenCanvas object. contextId specifies the desired API: "2d", "bitmaprenderer", "webgl", or "webgl2". options is handled by that API.
1096
+ *
1097
+ * This specification defines the "2d" context below, which is similar but distinct from the "2d" context that is created from a canvas element. The WebGL specifications define the "webgl" and "webgl2" contexts. [WEBGL]
1098
+ *
1099
+ * Returns null if the canvas has already been initialized with another context type (e.g., trying to get a "2d" context after getting a "webgl" context).
1100
+ */
1101
+ getContext(contextId: "2d", options?: any): OffscreenCanvasRenderingContext2D | null;
1102
+ getContext(contextId: "bitmaprenderer", options?: any): ImageBitmapRenderingContext | null;
1103
+ getContext(contextId: "webgl", options?: any): WebGLRenderingContext | null;
1104
+ getContext(contextId: "webgl2", options?: any): WebGL2RenderingContext | null;
1105
+ getContext(contextId: OffscreenRenderingContextId, options?: any): OffscreenRenderingContext | null;
1106
+ /** Returns a newly created ImageBitmap object with the image in the OffscreenCanvas object. The image in the OffscreenCanvas object is replaced with a new blank image. */
1107
+ transferToImageBitmap(): ImageBitmap;
1108
+ addEventListener<K extends keyof OffscreenCanvasEventMap>(
1109
+ type: K,
1110
+ listener: (this: OffscreenCanvas, ev: OffscreenCanvasEventMap[K]) => any,
1111
+ options?: boolean | AddEventListenerOptions
1112
+ ): void;
1113
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
1114
+ removeEventListener<K extends keyof OffscreenCanvasEventMap>(
1115
+ type: K,
1116
+ listener: (this: OffscreenCanvas, ev: OffscreenCanvasEventMap[K]) => any,
1117
+ options?: boolean | EventListenerOptions
1118
+ ): void;
1119
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
1120
+ }
1121
+
1122
+ var OffscreenCanvas: {
1123
+ prototype: OffscreenCanvas;
1124
+ new (width: number, height: number): OffscreenCanvas;
1125
+ };
1126
+
1127
+ interface OffscreenCanvasRenderingContext2D
1128
+ extends CanvasCompositing,
1129
+ CanvasDrawImage,
1130
+ CanvasDrawPath,
1131
+ CanvasFillStrokeStyles,
1132
+ CanvasFilters,
1133
+ CanvasImageData,
1134
+ CanvasImageSmoothing,
1135
+ CanvasPath,
1136
+ CanvasPathDrawingStyles,
1137
+ CanvasRect,
1138
+ CanvasShadowStyles,
1139
+ CanvasState,
1140
+ CanvasText,
1141
+ CanvasTextDrawingStyles,
1142
+ CanvasTransform {
1143
+ readonly canvas: OffscreenCanvas;
1144
+ commit(): void;
1145
+ }
1146
+
1147
+ var OffscreenCanvasRenderingContext2D: {
1148
+ prototype: OffscreenCanvasRenderingContext2D;
1149
+ new (): OffscreenCanvasRenderingContext2D;
1150
+ };
1151
+
1062
1152
  /* eslint-disable no-var */
1063
1153
  /* eslint-disable @typescript-eslint/naming-convention */
1064
1154
  // Type definitions for WebGL 2 extended with Babylon specific types
@@ -34,13 +34,13 @@ export class ThinEngine {
34
34
  */
35
35
  // Not mixed with Version for tooling purpose.
36
36
  static get NpmPackage() {
37
- return "babylonjs@6.1.0";
37
+ return "babylonjs@6.3.0";
38
38
  }
39
39
  /**
40
40
  * Returns the current version of the framework
41
41
  */
42
42
  static get Version() {
43
- return "6.1.0";
43
+ return "6.3.0";
44
44
  }
45
45
  /**
46
46
  * Returns a string describing the current engine
@@ -1288,8 +1288,21 @@ export class ThinEngine {
1288
1288
  this._hardwareScalingLevel *= changeRatio;
1289
1289
  }
1290
1290
  if (IsWindowObjectExist()) {
1291
- width = this._renderingCanvas ? this._renderingCanvas.clientWidth || this._renderingCanvas.width : window.innerWidth;
1292
- height = this._renderingCanvas ? this._renderingCanvas.clientHeight || this._renderingCanvas.height : window.innerHeight;
1291
+ if (this._renderingCanvas) {
1292
+ const boundingRect = this._renderingCanvas.getBoundingClientRect
1293
+ ? this._renderingCanvas.getBoundingClientRect()
1294
+ : {
1295
+ // fallback to last solution in case the function doesn't exist
1296
+ width: this._renderingCanvas.width * this._hardwareScalingLevel,
1297
+ height: this._renderingCanvas.height * this._hardwareScalingLevel,
1298
+ };
1299
+ width = this._renderingCanvas.clientWidth || boundingRect.width;
1300
+ height = this._renderingCanvas.clientHeight || boundingRect.height;
1301
+ }
1302
+ else {
1303
+ width = window.innerWidth;
1304
+ height = window.innerHeight;
1305
+ }
1293
1306
  }
1294
1307
  else {
1295
1308
  width = this._renderingCanvas ? this._renderingCanvas.width : 100;
@@ -3943,6 +3956,10 @@ export class ThinEngine {
3943
3956
  // Video
3944
3957
  if (texture.video) {
3945
3958
  this._activeChannel = channel;
3959
+ const videoInternalTexture = texture.getInternalTexture();
3960
+ if (videoInternalTexture) {
3961
+ videoInternalTexture._associatedChannel = channel;
3962
+ }
3946
3963
  texture.update();
3947
3964
  }
3948
3965
  else if (texture.delayLoadState === 4) {