@babylonjs/core 5.35.0 → 5.36.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 (250) hide show
  1. package/Audio/sound.d.ts +5 -0
  2. package/Audio/sound.js +7 -0
  3. package/Audio/sound.js.map +1 -1
  4. package/Debug/physicsViewer.d.ts +4 -3
  5. package/Debug/physicsViewer.js +2 -2
  6. package/Debug/physicsViewer.js.map +1 -1
  7. package/Engines/Extensions/engine.renderTarget.js +15 -15
  8. package/Engines/Extensions/engine.renderTarget.js.map +1 -1
  9. package/Engines/Extensions/engine.renderTargetCube.d.ts +1 -1
  10. package/Engines/Extensions/engine.renderTargetCube.js.map +1 -1
  11. package/Engines/Extensions/engine.views.d.ts +4 -0
  12. package/Engines/Extensions/engine.views.js +61 -42
  13. package/Engines/Extensions/engine.views.js.map +1 -1
  14. package/Engines/Native/nativeHardwareTexture.d.ts +14 -0
  15. package/Engines/Native/nativeHardwareTexture.js +24 -0
  16. package/Engines/Native/nativeHardwareTexture.js.map +1 -0
  17. package/Engines/Native/nativeInterfaces.d.ts +22 -15
  18. package/Engines/Native/nativeInterfaces.js.map +1 -1
  19. package/Engines/Native/nativePipelineContext.d.ts +252 -0
  20. package/Engines/Native/nativePipelineContext.js +502 -0
  21. package/Engines/Native/nativePipelineContext.js.map +1 -0
  22. package/Engines/Native/nativeRenderTargetWrapper.d.ts +16 -0
  23. package/Engines/Native/nativeRenderTargetWrapper.js +33 -0
  24. package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -0
  25. package/Engines/WebGPU/Extensions/engine.renderTarget.js +3 -3
  26. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  27. package/Engines/WebGPU/Extensions/engine.renderTargetCube.js.map +1 -1
  28. package/Engines/engine.d.ts +1 -0
  29. package/Engines/engine.js +24 -18
  30. package/Engines/engine.js.map +1 -1
  31. package/Engines/nativeEngine.d.ts +18 -17
  32. package/Engines/nativeEngine.js +100 -598
  33. package/Engines/nativeEngine.js.map +1 -1
  34. package/Engines/nullEngine.d.ts +1 -1
  35. package/Engines/nullEngine.js.map +1 -1
  36. package/Engines/thinEngine.d.ts +1 -1
  37. package/Engines/thinEngine.js +41 -38
  38. package/Engines/thinEngine.js.map +1 -1
  39. package/Engines/webgpuEngine.js.map +1 -1
  40. package/Gizmos/planeRotationGizmo.js +3 -1
  41. package/Gizmos/planeRotationGizmo.js.map +1 -1
  42. package/Inputs/scene.inputManager.js +4 -4
  43. package/Inputs/scene.inputManager.js.map +1 -1
  44. package/Loading/Plugins/babylonFileLoader.js +3 -3
  45. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  46. package/Materials/Node/Blocks/Dual/textureBlock.js +1 -1
  47. package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
  48. package/Materials/Node/nodeMaterial.d.ts +19 -1
  49. package/Materials/Node/nodeMaterial.js +30 -0
  50. package/Materials/Node/nodeMaterial.js.map +1 -1
  51. package/Materials/Node/nodeMaterialBuildStateSharedData.d.ts +2 -8
  52. package/Materials/Node/nodeMaterialBuildStateSharedData.js.map +1 -1
  53. package/Materials/Textures/baseTexture.d.ts +2 -1
  54. package/Materials/Textures/baseTexture.js +3 -2
  55. package/Materials/Textures/baseTexture.js.map +1 -1
  56. package/Materials/Textures/internalTexture.d.ts +2 -0
  57. package/Materials/Textures/internalTexture.js +4 -0
  58. package/Materials/Textures/internalTexture.js.map +1 -1
  59. package/Materials/Textures/mirrorTexture.js +0 -2
  60. package/Materials/Textures/mirrorTexture.js.map +1 -1
  61. package/Materials/Textures/renderTargetTexture.d.ts +53 -3
  62. package/Materials/Textures/renderTargetTexture.js +25 -25
  63. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  64. package/Materials/Textures/texture.d.ts +2 -0
  65. package/Materials/Textures/texture.js +35 -7
  66. package/Materials/Textures/texture.js.map +1 -1
  67. package/Materials/Textures/textureCreationOptions.d.ts +4 -1
  68. package/Materials/Textures/textureCreationOptions.js.map +1 -1
  69. package/Materials/material.js +1 -1
  70. package/Materials/material.js.map +1 -1
  71. package/Meshes/abstractMesh.d.ts +4 -4
  72. package/Meshes/abstractMesh.js +4 -4
  73. package/Meshes/abstractMesh.js.map +1 -1
  74. package/Meshes/mesh.d.ts +2 -2
  75. package/Meshes/mesh.js +1 -1
  76. package/Meshes/mesh.js.map +1 -1
  77. package/Misc/copyTextureToTexture.d.ts +9 -2
  78. package/Misc/copyTextureToTexture.js +23 -1
  79. package/Misc/copyTextureToTexture.js.map +1 -1
  80. package/Particles/IParticleSystem.d.ts +15 -1
  81. package/Particles/IParticleSystem.js.map +1 -1
  82. package/Particles/gpuParticleSystem.d.ts +24 -2
  83. package/Particles/gpuParticleSystem.js +98 -43
  84. package/Particles/gpuParticleSystem.js.map +1 -1
  85. package/Particles/particleSystem.d.ts +6 -1
  86. package/Particles/particleSystem.js +7 -2
  87. package/Particles/particleSystem.js.map +1 -1
  88. package/Physics/IPhysicsEngine.d.ts +8 -108
  89. package/Physics/IPhysicsEngine.js.map +1 -1
  90. package/Physics/Plugins/ammoJSPlugin.d.ts +1 -389
  91. package/Physics/Plugins/ammoJSPlugin.js +2 -1414
  92. package/Physics/Plugins/ammoJSPlugin.js.map +1 -1
  93. package/Physics/Plugins/cannonJSPlugin.d.ts +1 -75
  94. package/Physics/Plugins/cannonJSPlugin.js +2 -664
  95. package/Physics/Plugins/cannonJSPlugin.js.map +1 -1
  96. package/Physics/Plugins/oimoJSPlugin.d.ts +1 -59
  97. package/Physics/Plugins/oimoJSPlugin.js +2 -432
  98. package/Physics/Plugins/oimoJSPlugin.js.map +1 -1
  99. package/Physics/index.d.ts +3 -6
  100. package/Physics/index.js +3 -6
  101. package/Physics/index.js.map +1 -1
  102. package/Physics/physicsEngine.d.ts +1 -135
  103. package/Physics/physicsEngine.js +2 -221
  104. package/Physics/physicsEngine.js.map +1 -1
  105. package/Physics/physicsEngineComponent.d.ts +7 -42
  106. package/Physics/physicsEngineComponent.js +11 -71
  107. package/Physics/physicsEngineComponent.js.map +1 -1
  108. package/Physics/physicsHelper.d.ts +1 -411
  109. package/Physics/physicsHelper.js +2 -708
  110. package/Physics/physicsHelper.js.map +1 -1
  111. package/Physics/physicsImpostor.d.ts +1 -640
  112. package/Physics/physicsImpostor.js +2 -1004
  113. package/Physics/physicsImpostor.js.map +1 -1
  114. package/Physics/physicsJoint.d.ts +1 -275
  115. package/Physics/physicsJoint.js +2 -222
  116. package/Physics/physicsJoint.js.map +1 -1
  117. package/Physics/v1/IPhysicsEnginePlugin.d.ts +73 -0
  118. package/Physics/v1/IPhysicsEnginePlugin.js +2 -0
  119. package/Physics/v1/IPhysicsEnginePlugin.js.map +1 -0
  120. package/Physics/v1/Plugins/ammoJSPlugin.d.ts +401 -0
  121. package/Physics/v1/Plugins/ammoJSPlugin.js +1431 -0
  122. package/Physics/v1/Plugins/ammoJSPlugin.js.map +1 -0
  123. package/Physics/v1/Plugins/cannonJSPlugin.d.ts +87 -0
  124. package/Physics/v1/Plugins/cannonJSPlugin.js +683 -0
  125. package/Physics/v1/Plugins/cannonJSPlugin.js.map +1 -0
  126. package/Physics/{Plugins → v1/Plugins}/index.d.ts +0 -0
  127. package/Physics/{Plugins → v1/Plugins}/index.js +0 -0
  128. package/Physics/v1/Plugins/index.js.map +1 -0
  129. package/Physics/v1/Plugins/oimoJSPlugin.d.ts +71 -0
  130. package/Physics/v1/Plugins/oimoJSPlugin.js +450 -0
  131. package/Physics/v1/Plugins/oimoJSPlugin.js.map +1 -0
  132. package/Physics/v1/index.d.ts +7 -0
  133. package/Physics/v1/index.js +9 -0
  134. package/Physics/v1/index.js.map +1 -0
  135. package/Physics/v1/physicsEngine.d.ts +147 -0
  136. package/Physics/v1/physicsEngine.js +237 -0
  137. package/Physics/v1/physicsEngine.js.map +1 -0
  138. package/Physics/v1/physicsEngineComponent.d.ts +45 -0
  139. package/Physics/v1/physicsEngineComponent.js +70 -0
  140. package/Physics/v1/physicsEngineComponent.js.map +1 -0
  141. package/Physics/v1/physicsHelper.d.ts +411 -0
  142. package/Physics/v1/physicsHelper.js +709 -0
  143. package/Physics/v1/physicsHelper.js.map +1 -0
  144. package/Physics/v1/physicsImpostor.d.ts +636 -0
  145. package/Physics/v1/physicsImpostor.js +1001 -0
  146. package/Physics/v1/physicsImpostor.js.map +1 -0
  147. package/Physics/v1/physicsJoint.d.ts +275 -0
  148. package/Physics/v1/physicsJoint.js +223 -0
  149. package/Physics/v1/physicsJoint.js.map +1 -0
  150. package/Physics/v2/IPhysicsEnginePlugin.d.ts +170 -0
  151. package/Physics/v2/IPhysicsEnginePlugin.js +47 -0
  152. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -0
  153. package/Physics/v2/Plugins/index.d.ts +0 -0
  154. package/Physics/v2/Plugins/index.js +2 -0
  155. package/Physics/v2/Plugins/index.js.map +1 -0
  156. package/Physics/v2/index.d.ts +6 -0
  157. package/Physics/v2/index.js +8 -0
  158. package/Physics/v2/index.js.map +1 -0
  159. package/Physics/v2/physicsAggregate.d.ts +114 -0
  160. package/Physics/v2/physicsAggregate.js +46 -0
  161. package/Physics/v2/physicsAggregate.js.map +1 -0
  162. package/Physics/v2/physicsBody.d.ts +109 -0
  163. package/Physics/v2/physicsBody.js +158 -0
  164. package/Physics/v2/physicsBody.js.map +1 -0
  165. package/Physics/v2/physicsConstraint.d.ts +184 -0
  166. package/Physics/v2/physicsConstraint.js +257 -0
  167. package/Physics/v2/physicsConstraint.js.map +1 -0
  168. package/Physics/v2/physicsEngine.d.ts +103 -0
  169. package/Physics/v2/physicsEngine.js +146 -0
  170. package/Physics/v2/physicsEngine.js.map +1 -0
  171. package/Physics/v2/physicsEngineComponent.d.ts +31 -0
  172. package/Physics/v2/physicsEngineComponent.js +50 -0
  173. package/Physics/v2/physicsEngineComponent.js.map +1 -0
  174. package/Physics/v2/physicsMaterial.d.ts +45 -0
  175. package/Physics/v2/physicsMaterial.js +67 -0
  176. package/Physics/v2/physicsMaterial.js.map +1 -0
  177. package/Physics/v2/physicsShape.d.ts +182 -0
  178. package/Physics/v2/physicsShape.js +229 -0
  179. package/Physics/v2/physicsShape.js.map +1 -0
  180. package/PostProcesses/postProcess.d.ts +3 -1
  181. package/PostProcesses/postProcess.js +4 -1
  182. package/PostProcesses/postProcess.js.map +1 -1
  183. package/Rendering/fluidRenderer/fluidRenderer.d.ts +153 -0
  184. package/Rendering/fluidRenderer/fluidRenderer.js +410 -0
  185. package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -0
  186. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.d.ts +13 -0
  187. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js +31 -0
  188. package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js.map +1 -0
  189. package/Rendering/fluidRenderer/fluidRenderingObject.d.ts +81 -0
  190. package/Rendering/fluidRenderer/fluidRenderingObject.js +180 -0
  191. package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -0
  192. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.d.ts +63 -0
  193. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js +130 -0
  194. package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -0
  195. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.d.ts +64 -0
  196. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js +104 -0
  197. package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js.map +1 -0
  198. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.d.ts +234 -0
  199. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +690 -0
  200. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -0
  201. package/Rendering/fluidRenderer/fluidRenderingTextures.d.ts +56 -0
  202. package/Rendering/fluidRenderer/fluidRenderingTextures.js +261 -0
  203. package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -0
  204. package/Rendering/fluidRenderer/index.d.ts +5 -0
  205. package/Rendering/fluidRenderer/index.js +6 -0
  206. package/Rendering/fluidRenderer/index.js.map +1 -0
  207. package/Rendering/index.d.ts +1 -0
  208. package/Rendering/index.js +2 -0
  209. package/Rendering/index.js.map +1 -1
  210. package/Shaders/copyTextureToTexture.fragment.js +4 -1
  211. package/Shaders/copyTextureToTexture.fragment.js.map +1 -1
  212. package/Shaders/fluidRenderingBilateralBlur.fragment.d.ts +5 -0
  213. package/Shaders/fluidRenderingBilateralBlur.fragment.js +9 -0
  214. package/Shaders/fluidRenderingBilateralBlur.fragment.js.map +1 -0
  215. package/Shaders/fluidRenderingParticleDepth.fragment.d.ts +5 -0
  216. package/Shaders/fluidRenderingParticleDepth.fragment.js +17 -0
  217. package/Shaders/fluidRenderingParticleDepth.fragment.js.map +1 -0
  218. package/Shaders/fluidRenderingParticleDepth.vertex.d.ts +5 -0
  219. package/Shaders/fluidRenderingParticleDepth.vertex.js +13 -0
  220. package/Shaders/fluidRenderingParticleDepth.vertex.js.map +1 -0
  221. package/Shaders/fluidRenderingParticleDiffuse.fragment.d.ts +5 -0
  222. package/Shaders/fluidRenderingParticleDiffuse.fragment.js +9 -0
  223. package/Shaders/fluidRenderingParticleDiffuse.fragment.js.map +1 -0
  224. package/Shaders/fluidRenderingParticleDiffuse.vertex.d.ts +5 -0
  225. package/Shaders/fluidRenderingParticleDiffuse.vertex.js +4 -0
  226. package/Shaders/fluidRenderingParticleDiffuse.vertex.js.map +1 -0
  227. package/Shaders/fluidRenderingParticleThickness.fragment.d.ts +5 -0
  228. package/Shaders/fluidRenderingParticleThickness.fragment.js +9 -0
  229. package/Shaders/fluidRenderingParticleThickness.fragment.js.map +1 -0
  230. package/Shaders/fluidRenderingParticleThickness.vertex.d.ts +5 -0
  231. package/Shaders/fluidRenderingParticleThickness.vertex.js +9 -0
  232. package/Shaders/fluidRenderingParticleThickness.vertex.js.map +1 -0
  233. package/Shaders/fluidRenderingRender.fragment.d.ts +5 -0
  234. package/Shaders/fluidRenderingRender.fragment.js +46 -0
  235. package/Shaders/fluidRenderingRender.fragment.js.map +1 -0
  236. package/Shaders/fluidRenderingStandardBlur.fragment.d.ts +5 -0
  237. package/Shaders/fluidRenderingStandardBlur.fragment.js +9 -0
  238. package/Shaders/fluidRenderingStandardBlur.fragment.js.map +1 -0
  239. package/XR/features/WebXRControllerPhysics.d.ts +1 -1
  240. package/XR/features/WebXRControllerPhysics.js +1 -1
  241. package/XR/features/WebXRControllerPhysics.js.map +1 -1
  242. package/XR/features/WebXRHandTracking.js +1 -1
  243. package/XR/features/WebXRHandTracking.js.map +1 -1
  244. package/package.json +1 -1
  245. package/scene.js +6 -1
  246. package/scene.js.map +1 -1
  247. package/sceneComponent.d.ts +3 -0
  248. package/sceneComponent.js +3 -0
  249. package/sceneComponent.js.map +1 -1
  250. package/Physics/Plugins/index.js.map +0 -1
@@ -12,10 +12,11 @@ import { ThinEngine } from "./thinEngine.js";
12
12
  import { EngineStore } from "./engineStore.js";
13
13
  import { ShaderCodeInliner } from "./Processors/shaderCodeInliner.js";
14
14
  import { WebGL2ShaderProcessor } from "../Engines/WebGL/webGL2ShaderProcessors.js";
15
- import { RenderTargetWrapper } from "./renderTargetWrapper.js";
16
15
  import { NativeDataStream } from "./Native/nativeDataStream.js";
17
16
  import { RuntimeError, ErrorCodes } from "../Misc/error.js";
18
- import { WebGLHardwareTexture } from "./WebGL/webGLHardwareTexture.js";
17
+ import { NativePipelineContext } from "./Native/nativePipelineContext.js";
18
+ import { NativeRenderTargetWrapper } from "./Native/nativeRenderTargetWrapper.js";
19
+ import { NativeHardwareTexture } from "./Native/nativeHardwareTexture.js";
19
20
  const onNativeObjectInitialized = new Observable();
20
21
  if (typeof self !== "undefined" && !Object.prototype.hasOwnProperty.call(self, "_native")) {
21
22
  let __native;
@@ -50,538 +51,6 @@ export function AcquireNativeObjectAsync() {
50
51
  export async function RegisterNativeTypeAsync(typeName, constructor) {
51
52
  (await AcquireNativeObjectAsync())[typeName] = constructor;
52
53
  }
53
- class NativePipelineContext {
54
- constructor(engine) {
55
- // TODO: async should be true?
56
- this.isAsync = false;
57
- this.isReady = false;
58
- this._valueCache = {};
59
- this.engine = engine;
60
- }
61
- _getVertexShaderCode() {
62
- return null;
63
- }
64
- _getFragmentShaderCode() {
65
- return null;
66
- }
67
- // TODO: what should this do?
68
- _handlesSpectorRebuildCallback(onCompiled) {
69
- throw new Error("Not implemented");
70
- }
71
- _fillEffectInformation(effect, uniformBuffersNames, uniformsNames, uniforms, samplerList, samplers, attributesNames, attributes) {
72
- const engine = this.engine;
73
- if (engine.supportsUniformBuffers) {
74
- for (const name in uniformBuffersNames) {
75
- effect.bindUniformBlock(name, uniformBuffersNames[name]);
76
- }
77
- }
78
- const effectAvailableUniforms = this.engine.getUniforms(this, uniformsNames);
79
- effectAvailableUniforms.forEach((uniform, index) => {
80
- uniforms[uniformsNames[index]] = uniform;
81
- });
82
- this._uniforms = uniforms;
83
- let index;
84
- for (index = 0; index < samplerList.length; index++) {
85
- const sampler = effect.getUniform(samplerList[index]);
86
- if (sampler == null) {
87
- samplerList.splice(index, 1);
88
- index--;
89
- }
90
- }
91
- samplerList.forEach((name, index) => {
92
- samplers[name] = index;
93
- });
94
- attributes.push(...engine.getAttributes(this, attributesNames));
95
- }
96
- /**
97
- * Release all associated resources.
98
- **/
99
- dispose() {
100
- this._uniforms = {};
101
- }
102
- /**
103
- * @internal
104
- */
105
- _cacheMatrix(uniformName, matrix) {
106
- const cache = this._valueCache[uniformName];
107
- const flag = matrix.updateFlag;
108
- if (cache !== undefined && cache === flag) {
109
- return false;
110
- }
111
- this._valueCache[uniformName] = flag;
112
- return true;
113
- }
114
- /**
115
- * @internal
116
- */
117
- _cacheFloat2(uniformName, x, y) {
118
- let cache = this._valueCache[uniformName];
119
- if (!cache) {
120
- cache = [x, y];
121
- this._valueCache[uniformName] = cache;
122
- return true;
123
- }
124
- let changed = false;
125
- if (cache[0] !== x) {
126
- cache[0] = x;
127
- changed = true;
128
- }
129
- if (cache[1] !== y) {
130
- cache[1] = y;
131
- changed = true;
132
- }
133
- return changed;
134
- }
135
- /**
136
- * @internal
137
- */
138
- _cacheFloat3(uniformName, x, y, z) {
139
- let cache = this._valueCache[uniformName];
140
- if (!cache) {
141
- cache = [x, y, z];
142
- this._valueCache[uniformName] = cache;
143
- return true;
144
- }
145
- let changed = false;
146
- if (cache[0] !== x) {
147
- cache[0] = x;
148
- changed = true;
149
- }
150
- if (cache[1] !== y) {
151
- cache[1] = y;
152
- changed = true;
153
- }
154
- if (cache[2] !== z) {
155
- cache[2] = z;
156
- changed = true;
157
- }
158
- return changed;
159
- }
160
- /**
161
- * @internal
162
- */
163
- _cacheFloat4(uniformName, x, y, z, w) {
164
- let cache = this._valueCache[uniformName];
165
- if (!cache) {
166
- cache = [x, y, z, w];
167
- this._valueCache[uniformName] = cache;
168
- return true;
169
- }
170
- let changed = false;
171
- if (cache[0] !== x) {
172
- cache[0] = x;
173
- changed = true;
174
- }
175
- if (cache[1] !== y) {
176
- cache[1] = y;
177
- changed = true;
178
- }
179
- if (cache[2] !== z) {
180
- cache[2] = z;
181
- changed = true;
182
- }
183
- if (cache[3] !== w) {
184
- cache[3] = w;
185
- changed = true;
186
- }
187
- return changed;
188
- }
189
- /**
190
- * Sets an integer value on a uniform variable.
191
- * @param uniformName Name of the variable.
192
- * @param value Value to be set.
193
- */
194
- setInt(uniformName, value) {
195
- const cache = this._valueCache[uniformName];
196
- if (cache !== undefined && cache === value) {
197
- return;
198
- }
199
- if (this.engine.setInt(this._uniforms[uniformName], value)) {
200
- this._valueCache[uniformName] = value;
201
- }
202
- }
203
- /**
204
- * Sets a int2 on a uniform variable.
205
- * @param uniformName Name of the variable.
206
- * @param x First int in int2.
207
- * @param y Second int in int2.
208
- */
209
- setInt2(uniformName, x, y) {
210
- if (this._cacheFloat2(uniformName, x, y)) {
211
- if (!this.engine.setInt2(this._uniforms[uniformName], x, y)) {
212
- this._valueCache[uniformName] = null;
213
- }
214
- }
215
- }
216
- /**
217
- * Sets a int3 on a uniform variable.
218
- * @param uniformName Name of the variable.
219
- * @param x First int in int3.
220
- * @param y Second int in int3.
221
- * @param z Third int in int3.
222
- */
223
- setInt3(uniformName, x, y, z) {
224
- if (this._cacheFloat3(uniformName, x, y, z)) {
225
- if (!this.engine.setInt3(this._uniforms[uniformName], x, y, z)) {
226
- this._valueCache[uniformName] = null;
227
- }
228
- }
229
- }
230
- /**
231
- * Sets a int4 on a uniform variable.
232
- * @param uniformName Name of the variable.
233
- * @param x First int in int4.
234
- * @param y Second int in int4.
235
- * @param z Third int in int4.
236
- * @param w Fourth int in int4.
237
- */
238
- setInt4(uniformName, x, y, z, w) {
239
- if (this._cacheFloat4(uniformName, x, y, z, w)) {
240
- if (!this.engine.setInt4(this._uniforms[uniformName], x, y, z, w)) {
241
- this._valueCache[uniformName] = null;
242
- }
243
- }
244
- }
245
- /**
246
- * Sets an int array on a uniform variable.
247
- * @param uniformName Name of the variable.
248
- * @param array array to be set.
249
- */
250
- setIntArray(uniformName, array) {
251
- this._valueCache[uniformName] = null;
252
- this.engine.setIntArray(this._uniforms[uniformName], array);
253
- }
254
- /**
255
- * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
256
- * @param uniformName Name of the variable.
257
- * @param array array to be set.
258
- */
259
- setIntArray2(uniformName, array) {
260
- this._valueCache[uniformName] = null;
261
- this.engine.setIntArray2(this._uniforms[uniformName], array);
262
- }
263
- /**
264
- * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
265
- * @param uniformName Name of the variable.
266
- * @param array array to be set.
267
- */
268
- setIntArray3(uniformName, array) {
269
- this._valueCache[uniformName] = null;
270
- this.engine.setIntArray3(this._uniforms[uniformName], array);
271
- }
272
- /**
273
- * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
274
- * @param uniformName Name of the variable.
275
- * @param array array to be set.
276
- */
277
- setIntArray4(uniformName, array) {
278
- this._valueCache[uniformName] = null;
279
- this.engine.setIntArray4(this._uniforms[uniformName], array);
280
- }
281
- /**
282
- * Sets an float array on a uniform variable.
283
- * @param uniformName Name of the variable.
284
- * @param array array to be set.
285
- */
286
- setFloatArray(uniformName, array) {
287
- this._valueCache[uniformName] = null;
288
- this.engine.setFloatArray(this._uniforms[uniformName], array);
289
- }
290
- /**
291
- * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
292
- * @param uniformName Name of the variable.
293
- * @param array array to be set.
294
- */
295
- setFloatArray2(uniformName, array) {
296
- this._valueCache[uniformName] = null;
297
- this.engine.setFloatArray2(this._uniforms[uniformName], array);
298
- }
299
- /**
300
- * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
301
- * @param uniformName Name of the variable.
302
- * @param array array to be set.
303
- */
304
- setFloatArray3(uniformName, array) {
305
- this._valueCache[uniformName] = null;
306
- this.engine.setFloatArray3(this._uniforms[uniformName], array);
307
- }
308
- /**
309
- * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
310
- * @param uniformName Name of the variable.
311
- * @param array array to be set.
312
- */
313
- setFloatArray4(uniformName, array) {
314
- this._valueCache[uniformName] = null;
315
- this.engine.setFloatArray4(this._uniforms[uniformName], array);
316
- }
317
- /**
318
- * Sets an array on a uniform variable.
319
- * @param uniformName Name of the variable.
320
- * @param array array to be set.
321
- */
322
- setArray(uniformName, array) {
323
- this._valueCache[uniformName] = null;
324
- this.engine.setArray(this._uniforms[uniformName], array);
325
- }
326
- /**
327
- * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
328
- * @param uniformName Name of the variable.
329
- * @param array array to be set.
330
- */
331
- setArray2(uniformName, array) {
332
- this._valueCache[uniformName] = null;
333
- this.engine.setArray2(this._uniforms[uniformName], array);
334
- }
335
- /**
336
- * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
337
- * @param uniformName Name of the variable.
338
- * @param array array to be set.
339
- * @returns this effect.
340
- */
341
- setArray3(uniformName, array) {
342
- this._valueCache[uniformName] = null;
343
- this.engine.setArray3(this._uniforms[uniformName], array);
344
- }
345
- /**
346
- * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
347
- * @param uniformName Name of the variable.
348
- * @param array array to be set.
349
- */
350
- setArray4(uniformName, array) {
351
- this._valueCache[uniformName] = null;
352
- this.engine.setArray4(this._uniforms[uniformName], array);
353
- }
354
- /**
355
- * Sets matrices on a uniform variable.
356
- * @param uniformName Name of the variable.
357
- * @param matrices matrices to be set.
358
- */
359
- setMatrices(uniformName, matrices) {
360
- if (!matrices) {
361
- return;
362
- }
363
- this._valueCache[uniformName] = null;
364
- this.engine.setMatrices(this._uniforms[uniformName], matrices);
365
- }
366
- /**
367
- * Sets matrix on a uniform variable.
368
- * @param uniformName Name of the variable.
369
- * @param matrix matrix to be set.
370
- */
371
- setMatrix(uniformName, matrix) {
372
- if (this._cacheMatrix(uniformName, matrix)) {
373
- if (!this.engine.setMatrices(this._uniforms[uniformName], matrix.toArray())) {
374
- this._valueCache[uniformName] = null;
375
- }
376
- }
377
- }
378
- /**
379
- * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
380
- * @param uniformName Name of the variable.
381
- * @param matrix matrix to be set.
382
- */
383
- setMatrix3x3(uniformName, matrix) {
384
- this._valueCache[uniformName] = null;
385
- this.engine.setMatrix3x3(this._uniforms[uniformName], matrix);
386
- }
387
- /**
388
- * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
389
- * @param uniformName Name of the variable.
390
- * @param matrix matrix to be set.
391
- */
392
- setMatrix2x2(uniformName, matrix) {
393
- this._valueCache[uniformName] = null;
394
- this.engine.setMatrix2x2(this._uniforms[uniformName], matrix);
395
- }
396
- /**
397
- * Sets a float on a uniform variable.
398
- * @param uniformName Name of the variable.
399
- * @param value value to be set.
400
- * @returns this effect.
401
- */
402
- setFloat(uniformName, value) {
403
- const cache = this._valueCache[uniformName];
404
- if (cache !== undefined && cache === value) {
405
- return;
406
- }
407
- if (this.engine.setFloat(this._uniforms[uniformName], value)) {
408
- this._valueCache[uniformName] = value;
409
- }
410
- }
411
- /**
412
- * Sets a boolean on a uniform variable.
413
- * @param uniformName Name of the variable.
414
- * @param bool value to be set.
415
- */
416
- setBool(uniformName, bool) {
417
- const cache = this._valueCache[uniformName];
418
- if (cache !== undefined && cache === bool) {
419
- return;
420
- }
421
- if (this.engine.setInt(this._uniforms[uniformName], bool ? 1 : 0)) {
422
- this._valueCache[uniformName] = bool ? 1 : 0;
423
- }
424
- }
425
- /**
426
- * Sets a Vector2 on a uniform variable.
427
- * @param uniformName Name of the variable.
428
- * @param vector2 vector2 to be set.
429
- */
430
- setVector2(uniformName, vector2) {
431
- if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
432
- if (!this.engine.setFloat2(this._uniforms[uniformName], vector2.x, vector2.y)) {
433
- this._valueCache[uniformName] = null;
434
- }
435
- }
436
- }
437
- /**
438
- * Sets a float2 on a uniform variable.
439
- * @param uniformName Name of the variable.
440
- * @param x First float in float2.
441
- * @param y Second float in float2.
442
- */
443
- setFloat2(uniformName, x, y) {
444
- if (this._cacheFloat2(uniformName, x, y)) {
445
- if (!this.engine.setFloat2(this._uniforms[uniformName], x, y)) {
446
- this._valueCache[uniformName] = null;
447
- }
448
- }
449
- }
450
- /**
451
- * Sets a Vector3 on a uniform variable.
452
- * @param uniformName Name of the variable.
453
- * @param vector3 Value to be set.
454
- */
455
- setVector3(uniformName, vector3) {
456
- if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
457
- if (!this.engine.setFloat3(this._uniforms[uniformName], vector3.x, vector3.y, vector3.z)) {
458
- this._valueCache[uniformName] = null;
459
- }
460
- }
461
- }
462
- /**
463
- * Sets a float3 on a uniform variable.
464
- * @param uniformName Name of the variable.
465
- * @param x First float in float3.
466
- * @param y Second float in float3.
467
- * @param z Third float in float3.
468
- */
469
- setFloat3(uniformName, x, y, z) {
470
- if (this._cacheFloat3(uniformName, x, y, z)) {
471
- if (!this.engine.setFloat3(this._uniforms[uniformName], x, y, z)) {
472
- this._valueCache[uniformName] = null;
473
- }
474
- }
475
- }
476
- /**
477
- * Sets a Vector4 on a uniform variable.
478
- * @param uniformName Name of the variable.
479
- * @param vector4 Value to be set.
480
- */
481
- setVector4(uniformName, vector4) {
482
- if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
483
- if (!this.engine.setFloat4(this._uniforms[uniformName], vector4.x, vector4.y, vector4.z, vector4.w)) {
484
- this._valueCache[uniformName] = null;
485
- }
486
- }
487
- }
488
- /**
489
- * Sets a Quaternion on a uniform variable.
490
- * @param uniformName Name of the variable.
491
- * @param quaternion Value to be set.
492
- */
493
- setQuaternion(uniformName, quaternion) {
494
- if (this._cacheFloat4(uniformName, quaternion.x, quaternion.y, quaternion.z, quaternion.w)) {
495
- if (!this.engine.setFloat4(this._uniforms[uniformName], quaternion.x, quaternion.y, quaternion.z, quaternion.w)) {
496
- this._valueCache[uniformName] = null;
497
- }
498
- }
499
- }
500
- /**
501
- * Sets a float4 on a uniform variable.
502
- * @param uniformName Name of the variable.
503
- * @param x First float in float4.
504
- * @param y Second float in float4.
505
- * @param z Third float in float4.
506
- * @param w Fourth float in float4.
507
- * @returns this effect.
508
- */
509
- setFloat4(uniformName, x, y, z, w) {
510
- if (this._cacheFloat4(uniformName, x, y, z, w)) {
511
- if (!this.engine.setFloat4(this._uniforms[uniformName], x, y, z, w)) {
512
- this._valueCache[uniformName] = null;
513
- }
514
- }
515
- }
516
- /**
517
- * Sets a Color3 on a uniform variable.
518
- * @param uniformName Name of the variable.
519
- * @param color3 Value to be set.
520
- */
521
- setColor3(uniformName, color3) {
522
- if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
523
- if (!this.engine.setFloat3(this._uniforms[uniformName], color3.r, color3.g, color3.b)) {
524
- this._valueCache[uniformName] = null;
525
- }
526
- }
527
- }
528
- /**
529
- * Sets a Color4 on a uniform variable.
530
- * @param uniformName Name of the variable.
531
- * @param color3 Value to be set.
532
- * @param alpha Alpha value to be set.
533
- */
534
- setColor4(uniformName, color3, alpha) {
535
- if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
536
- if (!this.engine.setFloat4(this._uniforms[uniformName], color3.r, color3.g, color3.b, alpha)) {
537
- this._valueCache[uniformName] = null;
538
- }
539
- }
540
- }
541
- /**
542
- * Sets a Color4 on a uniform variable
543
- * @param uniformName defines the name of the variable
544
- * @param color4 defines the value to be set
545
- */
546
- setDirectColor4(uniformName, color4) {
547
- if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
548
- if (!this.engine.setFloat4(this._uniforms[uniformName], color4.r, color4.g, color4.b, color4.a)) {
549
- this._valueCache[uniformName] = null;
550
- }
551
- }
552
- }
553
- }
554
- class NativeRenderTargetWrapper extends RenderTargetWrapper {
555
- constructor(isMulti, isCube, size, engine) {
556
- super(isMulti, isCube, size, engine);
557
- this.__framebuffer = null;
558
- this.__framebufferDepthStencil = null;
559
- this._engine = engine;
560
- }
561
- get _framebuffer() {
562
- return this.__framebuffer;
563
- }
564
- set _framebuffer(framebuffer) {
565
- if (this.__framebuffer) {
566
- this._engine._releaseFramebufferObjects(this.__framebuffer);
567
- }
568
- this.__framebuffer = framebuffer;
569
- }
570
- get _framebufferDepthStencil() {
571
- return this.__framebufferDepthStencil;
572
- }
573
- set _framebufferDepthStencil(framebufferDepthStencil) {
574
- if (this.__framebufferDepthStencil) {
575
- this._engine._releaseFramebufferObjects(this.__framebufferDepthStencil);
576
- }
577
- this.__framebufferDepthStencil = framebufferDepthStencil;
578
- }
579
- dispose(disposeOnlyFramebuffers = false) {
580
- this._framebuffer = null;
581
- this._framebufferDepthStencil = null;
582
- super.dispose(disposeOnlyFramebuffers);
583
- }
584
- }
585
54
  /**
586
55
  * Container for accessors for natively-stored mesh data buffers.
587
56
  */
@@ -1010,13 +479,13 @@ export class NativeEngine extends Engine {
1010
479
  createDrawContext() {
1011
480
  return undefined;
1012
481
  }
1013
- _preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rawVertexSourceCode, rawFragmentSourceCode, rebuildRebind, defines, transformFeedbackVaryings) {
482
+ _preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, _rawVertexSourceCode, _rawFragmentSourceCode, _rebuildRebind, defines) {
1014
483
  const nativePipelineContext = pipelineContext;
1015
484
  if (createAsRaw) {
1016
- nativePipelineContext.nativeProgram = this.createRawShaderProgram(pipelineContext, vertexSourceCode, fragmentSourceCode, undefined, transformFeedbackVaryings);
485
+ nativePipelineContext.nativeProgram = this.createRawShaderProgram();
1017
486
  }
1018
487
  else {
1019
- nativePipelineContext.nativeProgram = this.createShaderProgram(pipelineContext, vertexSourceCode, fragmentSourceCode, defines, undefined, transformFeedbackVaryings);
488
+ nativePipelineContext.nativeProgram = this.createShaderProgram(pipelineContext, vertexSourceCode, fragmentSourceCode, defines);
1020
489
  }
1021
490
  }
1022
491
  /**
@@ -1033,10 +502,10 @@ export class NativeEngine extends Engine {
1033
502
  // TODO: support async shader compilcation
1034
503
  action();
1035
504
  }
1036
- createRawShaderProgram(pipelineContext, vertexCode, fragmentCode, context, transformFeedbackVaryings = null) {
505
+ createRawShaderProgram() {
1037
506
  throw new Error("Not Supported");
1038
507
  }
1039
- createShaderProgram(pipelineContext, vertexCode, fragmentCode, defines, context, transformFeedbackVaryings = null) {
508
+ createShaderProgram(_pipelineContext, vertexCode, fragmentCode, defines) {
1040
509
  this.onBeforeShaderCompilationObservable.notifyObservers(this);
1041
510
  const vertexInliner = new ShaderCodeInliner(vertexCode);
1042
511
  vertexInliner.processCode();
@@ -1098,16 +567,6 @@ export class NativeEngine extends Engine {
1098
567
  }
1099
568
  this._currentEffect = null;
1100
569
  }
1101
- setMatrix(uniform, matrix) {
1102
- if (!uniform) {
1103
- return;
1104
- }
1105
- const matrixArray = matrix.toArray();
1106
- this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETMATRIX);
1107
- this._commandBufferEncoder.encodeCommandArgAsNativeData(uniform);
1108
- this._commandBufferEncoder.encodeCommandArgAsFloat32s(matrixArray);
1109
- this._commandBufferEncoder.finishEncodingCommand();
1110
- }
1111
570
  getRenderWidth(useScreen = false) {
1112
571
  if (!useScreen && this._currentRenderTarget) {
1113
572
  return this._currentRenderTarget.width;
@@ -1766,10 +1225,10 @@ export class NativeEngine extends Engine {
1766
1225
  texture.samplingMode = samplingMode;
1767
1226
  texture.is2DArray = true;
1768
1227
  if (texture._hardwareTexture) {
1769
- const webGLTexture = texture._hardwareTexture.underlyingResource;
1770
- this._engine.loadRawTexture2DArray(webGLTexture, data, width, height, depth, this._getNativeTextureFormat(format, textureType), generateMipMaps, invertY);
1228
+ const nativeTexture = texture._hardwareTexture.underlyingResource;
1229
+ this._engine.loadRawTexture2DArray(nativeTexture, data, width, height, depth, this._getNativeTextureFormat(format, textureType), generateMipMaps, invertY);
1771
1230
  const filter = this._getNativeSamplingMode(samplingMode);
1772
- this._setTextureSampling(webGLTexture, filter);
1231
+ this._setTextureSampling(nativeTexture, filter);
1773
1232
  }
1774
1233
  texture.isReady = true;
1775
1234
  this._internalTexturesCache.push(texture);
@@ -1788,7 +1247,7 @@ export class NativeEngine extends Engine {
1788
1247
  // TODO: Refactor to share more logic with babylon.engine.ts version.
1789
1248
  /**
1790
1249
  * Usually called from Texture.ts.
1791
- * Passed information to create a WebGLTexture
1250
+ * Passed information to create a NativeTexture
1792
1251
  * @param url defines a value which contains one of the following:
1793
1252
  * * A conventional http URL, e.g. 'http://...' or 'file://...'
1794
1253
  * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
@@ -1932,8 +1391,7 @@ export class NativeEngine extends Engine {
1932
1391
  * @returns the babylon internal texture
1933
1392
  */
1934
1393
  wrapNativeTexture(texture) {
1935
- // Currently native is using the WebGL wrapper
1936
- const hardwareTexture = new WebGLHardwareTexture(texture, this._gl);
1394
+ const hardwareTexture = new NativeHardwareTexture(texture, this._engine);
1937
1395
  const internalTexture = new InternalTexture(this, InternalTextureSource.Unknown, true);
1938
1396
  internalTexture._hardwareTexture = hardwareTexture;
1939
1397
  internalTexture.isReady = true;
@@ -1947,11 +1405,12 @@ export class NativeEngine extends Engine {
1947
1405
  throw new Error("wrapWebGLTexture is not supported, use wrapNativeTexture instead.");
1948
1406
  }
1949
1407
  _createDepthStencilTexture(size, options, rtWrapper) {
1408
+ // TODO: options?
1950
1409
  const nativeRTWrapper = rtWrapper;
1951
1410
  const texture = new InternalTexture(this, InternalTextureSource.DepthStencil);
1952
1411
  const width = size.width || size;
1953
1412
  const height = size.height || size;
1954
- const framebuffer = this._engine.createFrameBuffer(texture._hardwareTexture.underlyingResource, width, height, _native.Engine.TEXTURE_FORMAT_RGBA8, false, true, false);
1413
+ const framebuffer = this._engine.createFrameBuffer(texture._hardwareTexture.underlyingResource, width, height, true, true);
1955
1414
  nativeRTWrapper._framebufferDepthStencil = framebuffer;
1956
1415
  return texture;
1957
1416
  }
@@ -1965,9 +1424,8 @@ export class NativeEngine extends Engine {
1965
1424
  this._commandBufferEncoder.finishEncodingCommand();
1966
1425
  }
1967
1426
  }
1968
- /** @internal */
1969
1427
  /**
1970
- * Engine abstraction for loading and creating an image bitmap from a given source string.
1428
+ * @internal Engine abstraction for loading and creating an image bitmap from a given source string.
1971
1429
  * @param imageSource source to load the image from.
1972
1430
  * @param options An object that sets options for the image's extraction.
1973
1431
  * @returns ImageBitmap
@@ -2119,64 +1577,100 @@ export class NativeEngine extends Engine {
2119
1577
  this._internalTexturesCache.push(texture);
2120
1578
  return texture;
2121
1579
  }
2122
- /**
2123
- * @internal
2124
- */
1580
+ /** @internal */
1581
+ _createHardwareTexture() {
1582
+ return new NativeHardwareTexture(this._createTexture(), this._engine);
1583
+ }
1584
+ /** @internal */
2125
1585
  _createHardwareRenderTargetWrapper(isMulti, isCube, size) {
2126
1586
  const rtWrapper = new NativeRenderTargetWrapper(isMulti, isCube, size, this);
2127
1587
  this._renderTargetWrapperCache.push(rtWrapper);
2128
1588
  return rtWrapper;
2129
1589
  }
2130
- createRenderTargetTexture(size, options) {
2131
- const rtWrapper = this._createHardwareRenderTargetWrapper(false, false, size);
2132
- const fullOptions = {};
1590
+ /** @internal */
1591
+ _createInternalTexture(size, options, _delayGPUTextureCreation = true, source = InternalTextureSource.Unknown) {
1592
+ var _a;
1593
+ let generateMipMaps = false;
1594
+ let type = 0;
1595
+ let samplingMode = 3;
1596
+ let format = 5;
1597
+ let useSRGBBuffer = false;
1598
+ let samples = 1;
2133
1599
  if (options !== undefined && typeof options === "object") {
2134
- fullOptions.generateMipMaps = options.generateMipMaps;
2135
- fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
2136
- fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
2137
- fullOptions.type = options.type === undefined ? 0 : options.type;
2138
- fullOptions.samplingMode = options.samplingMode === undefined ? 3 : options.samplingMode;
2139
- fullOptions.format = options.format === undefined ? 5 : options.format;
1600
+ generateMipMaps = !!options.generateMipMaps;
1601
+ type = options.type === undefined ? 0 : options.type;
1602
+ samplingMode = options.samplingMode === undefined ? 3 : options.samplingMode;
1603
+ format = options.format === undefined ? 5 : options.format;
1604
+ useSRGBBuffer = options.useSRGBBuffer === undefined ? false : options.useSRGBBuffer;
1605
+ samples = (_a = options.samples) !== null && _a !== void 0 ? _a : 1;
2140
1606
  }
2141
1607
  else {
2142
- fullOptions.generateMipMaps = options;
2143
- fullOptions.generateDepthBuffer = true;
2144
- fullOptions.generateStencilBuffer = false;
2145
- fullOptions.type = 0;
2146
- fullOptions.samplingMode = 3;
2147
- fullOptions.format = 5;
2148
- }
2149
- if (fullOptions.type === 1 && !this._caps.textureFloatLinearFiltering) {
1608
+ generateMipMaps = !!options;
1609
+ }
1610
+ useSRGBBuffer && (useSRGBBuffer = this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU));
1611
+ if (type === 1 && !this._caps.textureFloatLinearFiltering) {
2150
1612
  // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
2151
- fullOptions.samplingMode = 1;
1613
+ samplingMode = 1;
2152
1614
  }
2153
- else if (fullOptions.type === 2 && !this._caps.textureHalfFloatLinearFiltering) {
1615
+ else if (type === 2 && !this._caps.textureHalfFloatLinearFiltering) {
2154
1616
  // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
2155
- fullOptions.samplingMode = 1;
1617
+ samplingMode = 1;
1618
+ }
1619
+ if (type === 1 && !this._caps.textureFloat) {
1620
+ type = 0;
1621
+ Logger.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE");
2156
1622
  }
2157
- const texture = new InternalTexture(this, InternalTextureSource.RenderTarget);
1623
+ const texture = new InternalTexture(this, source);
2158
1624
  const width = size.width || size;
2159
1625
  const height = size.height || size;
2160
- if (fullOptions.type === 1 && !this._caps.textureFloat) {
2161
- fullOptions.type = 0;
2162
- Logger.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
2163
- }
2164
- const framebuffer = this._engine.createFrameBuffer(texture._hardwareTexture.underlyingResource, width, height, this._getNativeTextureFormat(fullOptions.format, fullOptions.type), fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, fullOptions.generateMipMaps ? true : false);
2165
- rtWrapper._framebuffer = framebuffer;
2166
- rtWrapper._generateDepthBuffer = fullOptions.generateDepthBuffer;
2167
- rtWrapper._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
1626
+ const layers = size.layers || 0;
1627
+ if (layers !== 0) {
1628
+ throw new Error("Texture layers are not supported in Babylon Native");
1629
+ }
1630
+ const nativeTexture = texture._hardwareTexture.underlyingResource;
1631
+ const nativeTextureFormat = this._getNativeTextureFormat(format, type);
1632
+ // REVIEW: We are always setting the renderTarget flag as we don't know whether the texture will be used as a render target.
1633
+ this._engine.initializeTexture(nativeTexture, width, height, generateMipMaps, nativeTextureFormat, true, useSRGBBuffer);
1634
+ this._setTextureSampling(nativeTexture, this._getNativeSamplingMode(samplingMode));
1635
+ texture._useSRGBBuffer = useSRGBBuffer;
2168
1636
  texture.baseWidth = width;
2169
1637
  texture.baseHeight = height;
2170
1638
  texture.width = width;
2171
1639
  texture.height = height;
1640
+ texture.depth = layers;
2172
1641
  texture.isReady = true;
2173
- texture.samples = 1;
2174
- texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
2175
- texture.samplingMode = fullOptions.samplingMode;
2176
- texture.type = fullOptions.type;
2177
- texture.format = fullOptions.format;
1642
+ texture.samples = samples;
1643
+ texture.generateMipMaps = generateMipMaps;
1644
+ texture.samplingMode = samplingMode;
1645
+ texture.type = type;
1646
+ texture.format = format;
2178
1647
  this._internalTexturesCache.push(texture);
1648
+ return texture;
1649
+ }
1650
+ createRenderTargetTexture(size, options) {
1651
+ const rtWrapper = this._createHardwareRenderTargetWrapper(false, false, size);
1652
+ let generateDepthBuffer = true;
1653
+ let generateStencilBuffer = false;
1654
+ let noColorAttachment = false;
1655
+ let colorAttachment = undefined;
1656
+ //let samples = 1;
1657
+ if (options !== undefined && typeof options === "object") {
1658
+ generateDepthBuffer = !!options.generateDepthBuffer;
1659
+ generateStencilBuffer = !!options.generateStencilBuffer;
1660
+ noColorAttachment = !!options.noColorAttachment;
1661
+ colorAttachment = options.colorAttachment;
1662
+ //samples = options.samples ?? 1;
1663
+ }
1664
+ const texture = colorAttachment || (noColorAttachment ? null : this._createInternalTexture(size, options, true, InternalTextureSource.RenderTarget));
1665
+ const width = size.width || size;
1666
+ const height = size.height || size;
1667
+ const framebuffer = this._engine.createFrameBuffer(texture ? texture._hardwareTexture.underlyingResource : null, width, height, generateStencilBuffer, generateDepthBuffer);
1668
+ rtWrapper._framebuffer = framebuffer;
1669
+ rtWrapper._generateDepthBuffer = generateDepthBuffer;
1670
+ rtWrapper._generateStencilBuffer = generateStencilBuffer;
2179
1671
  rtWrapper.setTextures(texture);
1672
+ // TODO: handle this in native
1673
+ //this.updateRenderTargetTextureSampleCount(rtWrapper, samples);
2180
1674
  return rtWrapper;
2181
1675
  }
2182
1676
  updateTextureSamplingMode(samplingMode, texture) {
@@ -2188,6 +1682,10 @@ export class NativeEngine extends Engine {
2188
1682
  }
2189
1683
  bindFramebuffer(texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
2190
1684
  const nativeRTWrapper = texture;
1685
+ if (this._currentRenderTarget) {
1686
+ this.unBindFramebuffer(this._currentRenderTarget);
1687
+ }
1688
+ this._currentRenderTarget = texture;
2191
1689
  if (faceIndex) {
2192
1690
  throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");
2193
1691
  }
@@ -2206,6 +1704,7 @@ export class NativeEngine extends Engine {
2206
1704
  }
2207
1705
  unBindFramebuffer(texture, disableGenerateMipMaps = false, onBeforeUnbind) {
2208
1706
  // NOTE: Disabling mipmap generation is not yet supported in NativeEngine.
1707
+ this._currentRenderTarget = null;
2209
1708
  if (onBeforeUnbind) {
2210
1709
  onBeforeUnbind();
2211
1710
  }
@@ -2235,7 +1734,7 @@ export class NativeEngine extends Engine {
2235
1734
  if (!texture) {
2236
1735
  if (this._boundTexturesCache[channel] != null) {
2237
1736
  this._activeChannel = channel;
2238
- this._setTextureCore(uniform, null);
1737
+ this._boundTexturesCache[channel] = null;
2239
1738
  }
2240
1739
  return false;
2241
1740
  }
@@ -2546,6 +2045,9 @@ export class NativeEngine extends Engine {
2546
2045
  else if (format == 5 && type == 0) {
2547
2046
  return _native.Engine.TEXTURE_FORMAT_RGBA8;
2548
2047
  }
2048
+ else if (format == 5 && type == 2) {
2049
+ return _native.Engine.TEXTURE_FORMAT_RGBA16F;
2050
+ }
2549
2051
  else if (format == 5 && type == 1) {
2550
2052
  return _native.Engine.TEXTURE_FORMAT_RGBA32F;
2551
2053
  }
@@ -2602,7 +2104,7 @@ export class NativeEngine extends Engine {
2602
2104
  const result = { ascent: 0, height: 0, descent: 0 };
2603
2105
  return result;
2604
2106
  }
2605
- _readTexturePixels(texture, width, height, faceIndex, level, buffer, flushRenderer, noDataConversion, x, y) {
2107
+ _readTexturePixels(texture, width, height, faceIndex, level, buffer, _flushRenderer, _noDataConversion, x, y) {
2606
2108
  var _a, _b, _c, _d;
2607
2109
  if (faceIndex !== undefined && faceIndex !== -1) {
2608
2110
  throw new Error(`Reading cubemap faces is not supported, but faceIndex is ${faceIndex}.`);
@@ -2618,5 +2120,5 @@ export class NativeEngine extends Engine {
2618
2120
  }
2619
2121
  }
2620
2122
  // This must match the protocol version in NativeEngine.cpp
2621
- NativeEngine.PROTOCOL_VERSION = 6;
2123
+ NativeEngine.PROTOCOL_VERSION = 7;
2622
2124
  //# sourceMappingURL=nativeEngine.js.map