@babylonjs/core 6.21.1 → 6.21.3

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 (165) hide show
  1. package/Animations/animatable.d.ts +4 -0
  2. package/Animations/animatable.js +6 -0
  3. package/Animations/animatable.js.map +1 -1
  4. package/Animations/animationGroup.d.ts +9 -0
  5. package/Animations/animationGroup.js +14 -0
  6. package/Animations/animationGroup.js.map +1 -1
  7. package/Buffers/buffer.d.ts +31 -2
  8. package/Buffers/buffer.js +100 -64
  9. package/Buffers/buffer.js.map +1 -1
  10. package/Engines/Native/nativeInterfaces.d.ts +2 -0
  11. package/Engines/Native/nativeInterfaces.js.map +1 -1
  12. package/Engines/engine.d.ts +8 -1
  13. package/Engines/engine.js +7 -1
  14. package/Engines/engine.js.map +1 -1
  15. package/Engines/nativeEngine.d.ts +2 -2
  16. package/Engines/nativeEngine.js +30 -19
  17. package/Engines/nativeEngine.js.map +1 -1
  18. package/Engines/thinEngine.js +4 -4
  19. package/Engines/thinEngine.js.map +1 -1
  20. package/Engines/webgpuEngine.js +2 -2
  21. package/Engines/webgpuEngine.js.map +1 -1
  22. package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.d.ts +59 -0
  23. package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.js +86 -0
  24. package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.js.map +1 -0
  25. package/FlowGraph/Blocks/Data/Logic/index.d.ts +2 -0
  26. package/FlowGraph/Blocks/Data/Logic/index.js +3 -0
  27. package/FlowGraph/Blocks/Data/Logic/index.js.map +1 -0
  28. package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.d.ts +2 -1
  29. package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.js +6 -2
  30. package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.js.map +1 -1
  31. package/FlowGraph/Blocks/Data/Math/index.d.ts +4 -0
  32. package/FlowGraph/Blocks/Data/Math/index.js +5 -0
  33. package/FlowGraph/Blocks/Data/Math/index.js.map +1 -0
  34. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js +1 -1
  35. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js.map +1 -1
  36. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js +1 -1
  37. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -1
  38. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.d.ts +2 -1
  39. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js +2 -2
  40. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js.map +1 -1
  41. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.d.ts +1 -8
  42. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js +2 -5
  43. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -1
  44. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js +1 -1
  45. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js.map +1 -1
  46. package/FlowGraph/Blocks/Data/index.d.ts +2 -4
  47. package/FlowGraph/Blocks/Data/index.js +4 -4
  48. package/FlowGraph/Blocks/Data/index.js.map +1 -1
  49. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +1 -1
  50. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
  51. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.d.ts +16 -0
  52. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js +18 -0
  53. package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js.map +1 -0
  54. package/FlowGraph/Blocks/Execution/{flowGraphPlayAnimationBlock.d.ts → Animation/flowGraphPlayAnimationBlock.d.ts} +5 -5
  55. package/FlowGraph/Blocks/Execution/{flowGraphPlayAnimationBlock.js → Animation/flowGraphPlayAnimationBlock.js} +15 -10
  56. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -0
  57. package/FlowGraph/Blocks/Execution/{flowGraphStopAnimationBlock.d.ts → Animation/flowGraphStopAnimationBlock.d.ts} +4 -4
  58. package/FlowGraph/Blocks/Execution/{flowGraphStopAnimationBlock.js → Animation/flowGraphStopAnimationBlock.js} +2 -2
  59. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -0
  60. package/FlowGraph/Blocks/Execution/Animation/index.d.ts +3 -0
  61. package/FlowGraph/Blocks/Execution/Animation/index.js +4 -0
  62. package/FlowGraph/Blocks/Execution/Animation/index.js.map +1 -0
  63. package/FlowGraph/Blocks/Execution/{flowGraphConditionalBlock.d.ts → ControlFlow/flowGraphConditionalBlock.d.ts} +5 -5
  64. package/FlowGraph/Blocks/Execution/{flowGraphConditionalBlock.js → ControlFlow/flowGraphConditionalBlock.js} +3 -3
  65. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphConditionalBlock.js.map +1 -0
  66. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.d.ts +20 -0
  67. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +26 -0
  68. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -0
  69. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.d.ts +24 -0
  70. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js +30 -0
  71. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js.map +1 -0
  72. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.d.ts +24 -0
  73. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +27 -0
  74. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -0
  75. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.d.ts +24 -0
  76. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js +27 -0
  77. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js.map +1 -0
  78. package/FlowGraph/Blocks/Execution/{flowGraphForLoopBlock.d.ts → ControlFlow/flowGraphForLoopBlock.d.ts} +4 -4
  79. package/FlowGraph/Blocks/Execution/{flowGraphForLoopBlock.js → ControlFlow/flowGraphForLoopBlock.js} +4 -5
  80. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js.map +1 -0
  81. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.d.ts +51 -0
  82. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js +77 -0
  83. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js.map +1 -0
  84. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.d.ts +31 -0
  85. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js +32 -0
  86. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js.map +1 -0
  87. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.d.ts +24 -0
  88. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +31 -0
  89. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -0
  90. package/FlowGraph/Blocks/Execution/{flowGraphTimerBlock.d.ts → ControlFlow/flowGraphTimerBlock.d.ts} +5 -9
  91. package/FlowGraph/Blocks/Execution/{flowGraphTimerBlock.js → ControlFlow/flowGraphTimerBlock.js} +5 -9
  92. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js.map +1 -0
  93. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.d.ts +32 -0
  94. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js +62 -0
  95. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js.map +1 -0
  96. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.d.ts +31 -0
  97. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +27 -0
  98. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -0
  99. package/FlowGraph/Blocks/Execution/ControlFlow/index.d.ts +12 -0
  100. package/FlowGraph/Blocks/Execution/ControlFlow/index.js +13 -0
  101. package/FlowGraph/Blocks/Execution/ControlFlow/index.js.map +1 -0
  102. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js +0 -1
  103. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js.map +1 -1
  104. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +1 -5
  105. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +3 -8
  106. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
  107. package/FlowGraph/Blocks/Execution/index.d.ts +2 -5
  108. package/FlowGraph/Blocks/Execution/index.js +4 -5
  109. package/FlowGraph/Blocks/Execution/index.js.map +1 -1
  110. package/FlowGraph/flowGraphConnection.d.ts +4 -0
  111. package/FlowGraph/flowGraphConnection.js +5 -0
  112. package/FlowGraph/flowGraphConnection.js.map +1 -1
  113. package/FlowGraph/flowGraphContext.d.ts +42 -2
  114. package/FlowGraph/flowGraphContext.js +58 -6
  115. package/FlowGraph/flowGraphContext.js.map +1 -1
  116. package/FlowGraph/flowGraphDataConnection.d.ts +19 -2
  117. package/FlowGraph/flowGraphDataConnection.js +29 -5
  118. package/FlowGraph/flowGraphDataConnection.js.map +1 -1
  119. package/FlowGraph/flowGraphExecutionBlock.d.ts +1 -1
  120. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  121. package/FlowGraph/flowGraphSignalConnection.js +1 -1
  122. package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
  123. package/Gizmos/axisDragGizmo.js +0 -1
  124. package/Gizmos/axisDragGizmo.js.map +1 -1
  125. package/Gizmos/axisScaleGizmo.js +0 -1
  126. package/Gizmos/axisScaleGizmo.js.map +1 -1
  127. package/Gizmos/boundingBoxGizmo.d.ts +12 -0
  128. package/Gizmos/boundingBoxGizmo.js +37 -1
  129. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  130. package/Gizmos/gizmo.d.ts +0 -4
  131. package/Gizmos/gizmo.js +19 -16
  132. package/Gizmos/gizmo.js.map +1 -1
  133. package/Gizmos/planeDragGizmo.js +0 -1
  134. package/Gizmos/planeDragGizmo.js.map +1 -1
  135. package/Gizmos/planeRotationGizmo.js +0 -1
  136. package/Gizmos/planeRotationGizmo.js.map +1 -1
  137. package/Gizmos/scaleGizmo.d.ts +2 -2
  138. package/Gizmos/scaleGizmo.js +5 -2
  139. package/Gizmos/scaleGizmo.js.map +1 -1
  140. package/Lights/Shadows/cascadedShadowGenerator.js +1 -1
  141. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  142. package/Materials/PBR/pbrBaseMaterial.js +5 -1
  143. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  144. package/Materials/Textures/equiRectangularCubeTexture.js +25 -4
  145. package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
  146. package/Maths/math.vector.d.ts +1 -1
  147. package/Maths/math.vector.js +1 -1
  148. package/Maths/math.vector.js.map +1 -1
  149. package/Meshes/Compression/dracoCompression.d.ts +6 -0
  150. package/Meshes/Compression/dracoCompression.js +51 -11
  151. package/Meshes/Compression/dracoCompression.js.map +1 -1
  152. package/Misc/fileTools.js +2 -2
  153. package/Misc/fileTools.js.map +1 -1
  154. package/Misc/webRequest.d.ts +5 -0
  155. package/Misc/webRequest.js +7 -0
  156. package/Misc/webRequest.js.map +1 -1
  157. package/XR/features/WebXRPlaneDetector.d.ts +8 -0
  158. package/XR/features/WebXRPlaneDetector.js +13 -0
  159. package/XR/features/WebXRPlaneDetector.js.map +1 -1
  160. package/package.json +1 -1
  161. package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.js.map +0 -1
  162. package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.js.map +0 -1
  163. package/FlowGraph/Blocks/Execution/flowGraphPlayAnimationBlock.js.map +0 -1
  164. package/FlowGraph/Blocks/Execution/flowGraphStopAnimationBlock.js.map +0 -1
  165. package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.js.map +0 -1
@@ -62,6 +62,19 @@ export class EquiRectangularCubeTexture extends BaseTexture {
62
62
  * @param onError
63
63
  */
64
64
  _loadImage(loadTextureCallback, onError) {
65
+ const scene = this.getScene();
66
+ if (!scene) {
67
+ return;
68
+ }
69
+ // Create texture before loading
70
+ const texture = scene
71
+ .getEngine()
72
+ .createRawCubeTexture(null, this._size, 4, scene.getEngine().getCaps().textureFloat ? 1 : 7, this._noMipmap, false, 3);
73
+ scene.addPendingData(texture);
74
+ texture.url = this.url;
75
+ texture.isReady = false;
76
+ scene.getEngine()._internalTexturesCache.push(texture);
77
+ this._texture = texture;
65
78
  const canvas = document.createElement("canvas");
66
79
  LoadImage(this.url, (image) => {
67
80
  this._width = image.width;
@@ -75,10 +88,11 @@ export class EquiRectangularCubeTexture extends BaseTexture {
75
88
  canvas.remove();
76
89
  loadTextureCallback();
77
90
  }, (_, e) => {
91
+ scene.removePendingData(texture);
78
92
  if (onError) {
79
93
  onError(`${this.getClassName()} could not be loaded`, e);
80
94
  }
81
- }, null);
95
+ }, scene ? scene.offlineProvider : null);
82
96
  }
83
97
  /**
84
98
  * Convert the image buffer into a cubemap and create a CubeTexture.
@@ -100,9 +114,16 @@ export class EquiRectangularCubeTexture extends BaseTexture {
100
114
  if (!scene) {
101
115
  return;
102
116
  }
103
- this._texture = scene
104
- .getEngine()
105
- .createRawCubeTextureFromUrl(this.url, scene, this._size, 4, scene.getEngine().getCaps().textureFloat ? 1 : 7, this._noMipmap, callback, null, this._onLoad, this._onError);
117
+ const faceDataArrays = callback();
118
+ const texture = this._texture;
119
+ scene.getEngine().updateRawCubeTexture(texture, faceDataArrays, texture.format, texture.type, texture.invertY);
120
+ texture.isReady = true;
121
+ scene.removePendingData(texture);
122
+ texture.onLoadedObservable.notifyObservers(texture);
123
+ texture.onLoadedObservable.clear();
124
+ if (this._onLoad) {
125
+ this._onLoad();
126
+ }
106
127
  }
107
128
  /**
108
129
  * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
@@ -1 +1 @@
1
- {"version":3,"file":"equiRectangularCubeTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/equiRectangularCubeTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,4CAA4C,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,WAAW;IA0BvD;;;;;;;;;;OAUG;IACH,YACI,GAAW,EACX,KAAY,EACZ,IAAY,EACZ,WAAoB,KAAK,EACzB,aAAsB,IAAI,EAC1B,SAA+B,IAAI,EACnC,UAAiE,IAAI,EACrE,WAAW,GAAG,KAAK;QAEnB,KAAK,CAAC,KAAK,CAAC,CAAC;QA1CT,YAAO,GAAyB,IAAI,CAAC;QACrC,aAAQ,GAAyB,IAAI,CAAC;QA2C1C,IAAI,CAAC,GAAG,EAAE;YACN,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SAC3C;QAED,IAAI,CAAC,gBAAgB,GAAG,OAAO,CA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C,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;gBACnB,cAAc,CAAC,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;aACpD;SACJ;QAED,OAAO,cAAc,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,YAAY;QACf,OAAO,4BAA4B,CAAC;IACxC,CAAC;IAED;;;OAGG;IACI,KAAK;QACR,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,KAAK,EAAE;YACR,OAAO,IAAI,CAAC;SACf;QAED,MAAM,UAAU,GAAG,IAAI,0BAA0B,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAEhH,eAAe;QACf,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B,UAAU,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QACpD,UAAU,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAElD,OAAO,UAAU,CAAC;IACtB,CAAC;;AA5MD,iCAAiC;AAClB,wCAAa,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,AAAnD,CAAoD","sourcesContent":["import { PanoramaToCubeMapTools } from \"../../Misc/HighDynamicRange/panoramaToCubemap\";\r\nimport { BaseTexture } from \"./baseTexture\";\r\nimport { Texture } from \"./texture\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport \"../../Engines/Extensions/engine.rawTexture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport { LoadImage } from \"../../Misc/fileTools\";\r\n\r\n/**\r\n * This represents a texture coming from an equirectangular image supported by the web browser canvas.\r\n */\r\nexport class EquiRectangularCubeTexture extends BaseTexture {\r\n /** The six faces of the cube. */\r\n private static _FacesMapping = [\"right\", \"left\", \"up\", \"down\", \"front\", \"back\"];\r\n\r\n private _noMipmap: boolean;\r\n private _onLoad: Nullable<() => void> = null;\r\n private _onError: Nullable<() => void> = null;\r\n\r\n /** The size of the cubemap. */\r\n private _size: number;\r\n\r\n /** Whether to supersample the input image */\r\n private _supersample: boolean;\r\n\r\n /** The buffer of the image. */\r\n private _buffer: ArrayBuffer;\r\n\r\n /** The width of the input image. */\r\n private _width: number;\r\n\r\n /** The height of the input image. */\r\n private _height: number;\r\n\r\n /** The URL to the image. */\r\n public url: string;\r\n\r\n /**\r\n * Instantiates an EquiRectangularCubeTexture from the following parameters.\r\n * @param url The location of the image\r\n * @param scene The scene the texture will be used in\r\n * @param size The cubemap desired size (the more it increases the longer the generation will be)\r\n * @param noMipmap Forces to not generate the mipmap if true\r\n * @param gammaSpace Specifies if the texture will be used in gamma or linear space\r\n * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)\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 */\r\n constructor(\r\n url: string,\r\n scene: Scene,\r\n size: number,\r\n noMipmap: boolean = false,\r\n gammaSpace: boolean = true,\r\n onLoad: Nullable<() => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null,\r\n supersample = false\r\n ) {\r\n super(scene);\r\n\r\n if (!url) {\r\n throw new Error(\"Image url is not set\");\r\n }\r\n\r\n this._coordinatesMode = Texture.CUBIC_MODE;\r\n this.name = url;\r\n this.url = url;\r\n this._size = size;\r\n this._supersample = supersample;\r\n this._noMipmap = noMipmap;\r\n this.gammaSpace = gammaSpace;\r\n this._onLoad = onLoad;\r\n this._onError = onError;\r\n\r\n this.hasAlpha = false;\r\n this.isCube = true;\r\n\r\n this._texture = this._getFromCache(url, this._noMipmap, undefined, undefined, undefined, this.isCube);\r\n\r\n if (!this._texture) {\r\n if (!scene.useDelayedTextureLoading) {\r\n this._loadImage(this._loadTexture.bind(this), this._onError);\r\n } else {\r\n this.delayLoadState = Constants.DELAYLOADSTATE_NOTLOADED;\r\n }\r\n } else if (onLoad) {\r\n if (this._texture.isReady) {\r\n Tools.SetImmediate(() => onLoad());\r\n } else {\r\n this._texture.onLoadedObservable.add(onLoad);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Load the image data, by putting the image on a canvas and extracting its buffer.\r\n * @param loadTextureCallback\r\n * @param onError\r\n */\r\n private _loadImage(loadTextureCallback: () => void, onError: Nullable<(message?: string, exception?: any) => void>): void {\r\n const canvas = document.createElement(\"canvas\");\r\n LoadImage(\r\n this.url,\r\n (image) => {\r\n this._width = image.width;\r\n this._height = image.height;\r\n canvas.width = this._width;\r\n canvas.height = this._height;\r\n\r\n const ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D;\r\n ctx.drawImage(image, 0, 0);\r\n\r\n const imageData = ctx.getImageData(0, 0, image.width, image.height);\r\n this._buffer = imageData.data.buffer as ArrayBuffer;\r\n\r\n canvas.remove();\r\n loadTextureCallback();\r\n },\r\n (_, e) => {\r\n if (onError) {\r\n onError(`${this.getClassName()} could not be loaded`, e);\r\n }\r\n },\r\n null\r\n );\r\n }\r\n\r\n /**\r\n * Convert the image buffer into a cubemap and create a CubeTexture.\r\n */\r\n private _loadTexture(): void {\r\n const scene = this.getScene();\r\n const callback = (): Nullable<ArrayBufferView[]> => {\r\n const imageData = this._getFloat32ArrayFromArrayBuffer(this._buffer);\r\n\r\n // Extract the raw linear data.\r\n const data = PanoramaToCubeMapTools.ConvertPanoramaToCubemap(imageData, this._width, this._height, this._size, this._supersample);\r\n\r\n const results = [];\r\n\r\n // Push each faces.\r\n for (let i = 0; i < 6; i++) {\r\n const dataFace = (data as any)[EquiRectangularCubeTexture._FacesMapping[i]];\r\n results.push(dataFace);\r\n }\r\n\r\n return results;\r\n };\r\n\r\n if (!scene) {\r\n return;\r\n }\r\n this._texture = scene\r\n .getEngine()\r\n .createRawCubeTextureFromUrl(\r\n this.url,\r\n scene,\r\n this._size,\r\n Constants.TEXTUREFORMAT_RGB,\r\n scene.getEngine().getCaps().textureFloat ? Constants.TEXTURETYPE_FLOAT : Constants.TEXTURETYPE_UNSIGNED_INTEGER,\r\n this._noMipmap,\r\n callback,\r\n null,\r\n this._onLoad,\r\n this._onError\r\n );\r\n }\r\n\r\n /**\r\n * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.\r\n * @param buffer The ArrayBuffer that should be converted.\r\n * @returns The buffer as Float32Array.\r\n */\r\n private _getFloat32ArrayFromArrayBuffer(buffer: ArrayBuffer): Float32Array {\r\n const dataView = new DataView(buffer);\r\n const floatImageData = new Float32Array((buffer.byteLength * 3) / 4);\r\n\r\n let k = 0;\r\n for (let i = 0; i < buffer.byteLength; i++) {\r\n // We drop the transparency channel, because we do not need/want it\r\n if ((i + 1) % 4 !== 0) {\r\n floatImageData[k++] = dataView.getUint8(i) / 255;\r\n }\r\n }\r\n\r\n return floatImageData;\r\n }\r\n\r\n /**\r\n * Get the current class name of the texture useful for serialization or dynamic coding.\r\n * @returns \"EquiRectangularCubeTexture\"\r\n */\r\n public getClassName(): string {\r\n return \"EquiRectangularCubeTexture\";\r\n }\r\n\r\n /**\r\n * Create a clone of the current EquiRectangularCubeTexture and return it.\r\n * @returns A clone of the current EquiRectangularCubeTexture.\r\n */\r\n public clone(): EquiRectangularCubeTexture {\r\n const scene = this.getScene();\r\n if (!scene) {\r\n return this;\r\n }\r\n\r\n const newTexture = new EquiRectangularCubeTexture(this.url, scene, this._size, this._noMipmap, this.gammaSpace);\r\n\r\n // Base texture\r\n newTexture.level = this.level;\r\n newTexture.wrapU = this.wrapU;\r\n newTexture.wrapV = this.wrapV;\r\n newTexture.coordinatesIndex = this.coordinatesIndex;\r\n newTexture.coordinatesMode = this.coordinatesMode;\r\n\r\n return newTexture;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"equiRectangularCubeTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/equiRectangularCubeTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,4CAA4C,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,WAAW;IA0BvD;;;;;;;;;;OAUG;IACH,YACI,GAAW,EACX,KAAY,EACZ,IAAY,EACZ,WAAoB,KAAK,EACzB,aAAsB,IAAI,EAC1B,SAA+B,IAAI,EACnC,UAAiE,IAAI,EACrE,WAAW,GAAG,KAAK;QAEnB,KAAK,CAAC,KAAK,CAAC,CAAC;QA1CT,YAAO,GAAyB,IAAI,CAAC;QACrC,aAAQ,GAAyB,IAAI,CAAC;QA2C1C,IAAI,CAAC,GAAG,EAAE;YACN,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SAC3C;QAED,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG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AE,IAAI,CAAC,UAAU,CAAC,CAAC;QAEhH,eAAe;QACf,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B,UAAU,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B,UAAU,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;QACpD,UAAU,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAElD,OAAO,UAAU,CAAC;IACtB,CAAC;;AAnOD,iCAAiC;AAClB,wCAAa,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,AAAnD,CAAoD","sourcesContent":["import { PanoramaToCubeMapTools } from \"../../Misc/HighDynamicRange/panoramaToCubemap\";\r\nimport { BaseTexture } from \"./baseTexture\";\r\nimport { Texture } from \"./texture\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport \"../../Engines/Extensions/engine.rawTexture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport { LoadImage } from \"../../Misc/fileTools\";\r\n\r\n/**\r\n * This represents a texture coming from an equirectangular image supported by the web browser canvas.\r\n */\r\nexport class EquiRectangularCubeTexture extends BaseTexture {\r\n /** The six faces of the cube. */\r\n private static _FacesMapping = [\"right\", \"left\", \"up\", \"down\", \"front\", \"back\"];\r\n\r\n private _noMipmap: boolean;\r\n private _onLoad: Nullable<() => void> = null;\r\n private _onError: Nullable<() => void> = null;\r\n\r\n /** The size of the cubemap. */\r\n private _size: number;\r\n\r\n /** Whether to supersample the input image */\r\n private _supersample: boolean;\r\n\r\n /** The buffer of the image. */\r\n private _buffer: ArrayBuffer;\r\n\r\n /** The width of the input image. */\r\n private _width: number;\r\n\r\n /** The height of the input image. */\r\n private _height: number;\r\n\r\n /** The URL to the image. */\r\n public url: string;\r\n\r\n /**\r\n * Instantiates an EquiRectangularCubeTexture from the following parameters.\r\n * @param url The location of the image\r\n * @param scene The scene the texture will be used in\r\n * @param size The cubemap desired size (the more it increases the longer the generation will be)\r\n * @param noMipmap Forces to not generate the mipmap if true\r\n * @param gammaSpace Specifies if the texture will be used in gamma or linear space\r\n * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)\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 */\r\n constructor(\r\n url: string,\r\n scene: Scene,\r\n size: number,\r\n noMipmap: boolean = false,\r\n gammaSpace: boolean = true,\r\n onLoad: Nullable<() => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null,\r\n supersample = false\r\n ) {\r\n super(scene);\r\n\r\n if (!url) {\r\n throw new Error(\"Image url is not set\");\r\n }\r\n\r\n this._coordinatesMode = Texture.CUBIC_MODE;\r\n this.name = url;\r\n this.url = url;\r\n this._size = size;\r\n this._supersample = supersample;\r\n this._noMipmap = noMipmap;\r\n this.gammaSpace = gammaSpace;\r\n this._onLoad = onLoad;\r\n this._onError = onError;\r\n\r\n this.hasAlpha = false;\r\n this.isCube = true;\r\n\r\n this._texture = this._getFromCache(url, this._noMipmap, undefined, undefined, undefined, this.isCube);\r\n\r\n if (!this._texture) {\r\n if (!scene.useDelayedTextureLoading) {\r\n this._loadImage(this._loadTexture.bind(this), this._onError);\r\n } else {\r\n this.delayLoadState = Constants.DELAYLOADSTATE_NOTLOADED;\r\n }\r\n } else if (onLoad) {\r\n if (this._texture.isReady) {\r\n Tools.SetImmediate(() => onLoad());\r\n } else {\r\n this._texture.onLoadedObservable.add(onLoad);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Load the image data, by putting the image on a canvas and extracting its buffer.\r\n * @param loadTextureCallback\r\n * @param onError\r\n */\r\n private _loadImage(loadTextureCallback: () => void, onError: Nullable<(message?: string, exception?: any) => void>): void {\r\n const scene = this.getScene();\r\n if (!scene) {\r\n return;\r\n }\r\n\r\n // Create texture before loading\r\n const texture = scene\r\n .getEngine()\r\n .createRawCubeTexture(\r\n null,\r\n this._size,\r\n Constants.TEXTUREFORMAT_RGB,\r\n scene.getEngine().getCaps().textureFloat ? Constants.TEXTURETYPE_FLOAT : Constants.TEXTURETYPE_UNSIGNED_INTEGER,\r\n this._noMipmap,\r\n false,\r\n Constants.TEXTURE_TRILINEAR_SAMPLINGMODE\r\n );\r\n scene.addPendingData(texture);\r\n texture.url = this.url;\r\n texture.isReady = false;\r\n scene.getEngine()._internalTexturesCache.push(texture);\r\n this._texture = texture;\r\n\r\n const canvas = document.createElement(\"canvas\");\r\n LoadImage(\r\n this.url,\r\n (image) => {\r\n this._width = image.width;\r\n this._height = image.height;\r\n canvas.width = this._width;\r\n canvas.height = this._height;\r\n\r\n const ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D;\r\n ctx.drawImage(image, 0, 0);\r\n\r\n const imageData = ctx.getImageData(0, 0, image.width, image.height);\r\n this._buffer = imageData.data.buffer as ArrayBuffer;\r\n\r\n canvas.remove();\r\n loadTextureCallback();\r\n },\r\n (_, e) => {\r\n scene.removePendingData(texture);\r\n if (onError) {\r\n onError(`${this.getClassName()} could not be loaded`, e);\r\n }\r\n },\r\n scene ? scene.offlineProvider : null\r\n );\r\n }\r\n\r\n /**\r\n * Convert the image buffer into a cubemap and create a CubeTexture.\r\n */\r\n private _loadTexture(): void {\r\n const scene = this.getScene();\r\n const callback = (): ArrayBufferView[] => {\r\n const imageData = this._getFloat32ArrayFromArrayBuffer(this._buffer);\r\n\r\n // Extract the raw linear data.\r\n const data = PanoramaToCubeMapTools.ConvertPanoramaToCubemap(imageData, this._width, this._height, this._size, this._supersample);\r\n\r\n const results = [];\r\n\r\n // Push each faces.\r\n for (let i = 0; i < 6; i++) {\r\n const dataFace = (data as any)[EquiRectangularCubeTexture._FacesMapping[i]];\r\n results.push(dataFace);\r\n }\r\n\r\n return results;\r\n };\r\n\r\n if (!scene) {\r\n return;\r\n }\r\n const faceDataArrays = callback();\r\n\r\n const texture = this._texture!;\r\n scene.getEngine().updateRawCubeTexture(texture, faceDataArrays, texture.format, texture.type, texture.invertY);\r\n texture.isReady = true;\r\n scene.removePendingData(texture);\r\n\r\n texture.onLoadedObservable.notifyObservers(texture);\r\n texture.onLoadedObservable.clear();\r\n\r\n if (this._onLoad) {\r\n this._onLoad();\r\n }\r\n }\r\n\r\n /**\r\n * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.\r\n * @param buffer The ArrayBuffer that should be converted.\r\n * @returns The buffer as Float32Array.\r\n */\r\n private _getFloat32ArrayFromArrayBuffer(buffer: ArrayBuffer): Float32Array {\r\n const dataView = new DataView(buffer);\r\n const floatImageData = new Float32Array((buffer.byteLength * 3) / 4);\r\n\r\n let k = 0;\r\n for (let i = 0; i < buffer.byteLength; i++) {\r\n // We drop the transparency channel, because we do not need/want it\r\n if ((i + 1) % 4 !== 0) {\r\n floatImageData[k++] = dataView.getUint8(i) / 255;\r\n }\r\n }\r\n\r\n return floatImageData;\r\n }\r\n\r\n /**\r\n * Get the current class name of the texture useful for serialization or dynamic coding.\r\n * @returns \"EquiRectangularCubeTexture\"\r\n */\r\n public getClassName(): string {\r\n return \"EquiRectangularCubeTexture\";\r\n }\r\n\r\n /**\r\n * Create a clone of the current EquiRectangularCubeTexture and return it.\r\n * @returns A clone of the current EquiRectangularCubeTexture.\r\n */\r\n public clone(): EquiRectangularCubeTexture {\r\n const scene = this.getScene();\r\n if (!scene) {\r\n return this;\r\n }\r\n\r\n const newTexture = new EquiRectangularCubeTexture(this.url, scene, this._size, this._noMipmap, this.gammaSpace);\r\n\r\n // Base texture\r\n newTexture.level = this.level;\r\n newTexture.wrapU = this.wrapU;\r\n newTexture.wrapV = this.wrapV;\r\n newTexture.coordinatesIndex = this.coordinatesIndex;\r\n newTexture.coordinatesMode = this.coordinatesMode;\r\n\r\n return newTexture;\r\n }\r\n}\r\n"]}
@@ -2356,7 +2356,7 @@ export declare class Quaternion {
2356
2356
  * Updates the given rotation matrix with the current quaternion values
2357
2357
  * Example Playground https://playground.babylonjs.com/#L49EJ7#67
2358
2358
  * @param result defines the target matrix
2359
- * @returns the current unchanged quaternion
2359
+ * @returns the updated matrix with the rotation
2360
2360
  */
2361
2361
  toRotationMatrix<T extends Matrix>(result: T): T;
2362
2362
  /**
@@ -3853,7 +3853,7 @@ export class Quaternion {
3853
3853
  * Updates the given rotation matrix with the current quaternion values
3854
3854
  * Example Playground https://playground.babylonjs.com/#L49EJ7#67
3855
3855
  * @param result defines the target matrix
3856
- * @returns the current unchanged quaternion
3856
+ * @returns the updated matrix with the rotation
3857
3857
  */
3858
3858
  toRotationMatrix(result) {
3859
3859
  Matrix.FromQuaternionToRef(this, result);