@babylonjs/viewer 7.41.0-alpha → 7.41.1
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.
- package/configuration/configuration.d.ts +107 -0
- package/configuration/configuration.js +16 -0
- package/configuration/configuration.js.map +1 -0
- package/configuration/configurationCompatibility.d.ts +8 -0
- package/configuration/configurationCompatibility.js +66 -0
- package/configuration/configurationCompatibility.js.map +1 -0
- package/configuration/configurationContainer.d.ts +10 -0
- package/configuration/configurationContainer.js +10 -0
- package/configuration/configurationContainer.js.map +1 -0
- package/configuration/globals.d.ts +6 -0
- package/configuration/globals.js +18 -0
- package/configuration/globals.js.map +1 -0
- package/configuration/index.d.ts +2 -0
- package/configuration/index.js +4 -0
- package/configuration/index.js.map +1 -0
- package/configuration/interfaces/cameraConfiguration.d.ts +31 -0
- package/configuration/interfaces/cameraConfiguration.js +2 -0
- package/configuration/interfaces/cameraConfiguration.js.map +1 -0
- package/configuration/interfaces/colorGradingConfiguration.d.ts +81 -0
- package/configuration/interfaces/colorGradingConfiguration.js +2 -0
- package/configuration/interfaces/colorGradingConfiguration.js.map +1 -0
- package/configuration/interfaces/defaultRenderingPipelineConfiguration.d.ts +20 -0
- package/configuration/interfaces/defaultRenderingPipelineConfiguration.js +2 -0
- package/configuration/interfaces/defaultRenderingPipelineConfiguration.js.map +1 -0
- package/configuration/interfaces/environmentMapConfiguration.d.ts +22 -0
- package/configuration/interfaces/environmentMapConfiguration.js +2 -0
- package/configuration/interfaces/environmentMapConfiguration.js.map +1 -0
- package/configuration/interfaces/groundConfiguration.d.ts +24 -0
- package/configuration/interfaces/groundConfiguration.js +2 -0
- package/configuration/interfaces/groundConfiguration.js.map +1 -0
- package/configuration/interfaces/imageProcessingConfiguration.d.ts +45 -0
- package/configuration/interfaces/imageProcessingConfiguration.js +2 -0
- package/configuration/interfaces/imageProcessingConfiguration.js.map +1 -0
- package/configuration/interfaces/index.d.ts +15 -0
- package/configuration/interfaces/index.js +16 -0
- package/configuration/interfaces/index.js.map +1 -0
- package/configuration/interfaces/lightConfiguration.d.ts +60 -0
- package/configuration/interfaces/lightConfiguration.js +2 -0
- package/configuration/interfaces/lightConfiguration.js.map +1 -0
- package/configuration/interfaces/modelAnimationConfiguration.d.ts +26 -0
- package/configuration/interfaces/modelAnimationConfiguration.js +2 -0
- package/configuration/interfaces/modelAnimationConfiguration.js.map +1 -0
- package/configuration/interfaces/modelConfiguration.d.ts +65 -0
- package/configuration/interfaces/modelConfiguration.js +2 -0
- package/configuration/interfaces/modelConfiguration.js.map +1 -0
- package/configuration/interfaces/observersConfiguration.d.ts +5 -0
- package/configuration/interfaces/observersConfiguration.js +2 -0
- package/configuration/interfaces/observersConfiguration.js.map +1 -0
- package/configuration/interfaces/sceneConfiguration.d.ts +48 -0
- package/configuration/interfaces/sceneConfiguration.js +2 -0
- package/configuration/interfaces/sceneConfiguration.js.map +1 -0
- package/configuration/interfaces/sceneOptimizerConfiguration.d.ts +23 -0
- package/configuration/interfaces/sceneOptimizerConfiguration.js +2 -0
- package/configuration/interfaces/sceneOptimizerConfiguration.js.map +1 -0
- package/configuration/interfaces/skyboxConfiguration.d.ts +21 -0
- package/configuration/interfaces/skyboxConfiguration.js +2 -0
- package/configuration/interfaces/skyboxConfiguration.js.map +1 -0
- package/configuration/interfaces/templateConfiguration.d.ts +67 -0
- package/configuration/interfaces/templateConfiguration.js +2 -0
- package/configuration/interfaces/templateConfiguration.js.map +1 -0
- package/configuration/interfaces/vrConfiguration.d.ts +16 -0
- package/configuration/interfaces/vrConfiguration.js +2 -0
- package/configuration/interfaces/vrConfiguration.js.map +1 -0
- package/configuration/loader.d.ts +4 -0
- package/configuration/loader.js +17 -0
- package/configuration/loader.js.map +1 -0
- package/configuration/mappers.d.ts +43 -0
- package/configuration/mappers.js +193 -0
- package/configuration/mappers.js.map +1 -0
- package/configuration/renderOnlyLoader.d.ts +33 -0
- package/configuration/renderOnlyLoader.js +162 -0
- package/configuration/renderOnlyLoader.js.map +1 -0
- package/configuration/types/default.d.ts +6 -0
- package/configuration/types/default.js +121 -0
- package/configuration/types/default.js.map +1 -0
- package/configuration/types/environmentMap.d.ts +5 -0
- package/configuration/types/environmentMap.js +14 -0
- package/configuration/types/environmentMap.js.map +1 -0
- package/configuration/types/extended.d.ts +6 -0
- package/configuration/types/extended.js +317 -0
- package/configuration/types/extended.js.map +1 -0
- package/configuration/types/index.d.ts +14 -0
- package/configuration/types/index.js +51 -0
- package/configuration/types/index.js.map +1 -0
- package/configuration/types/minimal.d.ts +6 -0
- package/configuration/types/minimal.js +43 -0
- package/configuration/types/minimal.js.map +1 -0
- package/configuration/types/renderOnlyDefault.d.ts +30 -0
- package/configuration/types/renderOnlyDefault.js +31 -0
- package/configuration/types/renderOnlyDefault.js.map +1 -0
- package/configuration/types/shadowLight.d.ts +9 -0
- package/configuration/types/shadowLight.js +64 -0
- package/configuration/types/shadowLight.js.map +1 -0
- package/helper/index.d.ts +29 -0
- package/helper/index.js +66 -0
- package/helper/index.js.map +1 -0
- package/index.d.ts +30 -0
- package/index.js +46 -0
- package/index.js.map +1 -0
- package/initializer.d.ts +11 -0
- package/initializer.js +35 -0
- package/initializer.js.map +1 -0
- package/interfaces.d.ts +5 -0
- package/interfaces.js +7 -0
- package/interfaces.js.map +1 -0
- package/labs/environmentSerializer.d.ts +126 -0
- package/labs/environmentSerializer.js +191 -0
- package/labs/environmentSerializer.js.map +1 -0
- package/labs/texture.d.ts +183 -0
- package/labs/texture.js +351 -0
- package/labs/texture.js.map +1 -0
- package/labs/viewerLabs.d.ts +51 -0
- package/labs/viewerLabs.js +134 -0
- package/labs/viewerLabs.js.map +1 -0
- package/loader/modelLoader.d.ts +56 -0
- package/loader/modelLoader.js +202 -0
- package/loader/modelLoader.js.map +1 -0
- package/loader/plugins/applyMaterialConfig.d.ts +12 -0
- package/loader/plugins/applyMaterialConfig.js +16 -0
- package/loader/plugins/applyMaterialConfig.js.map +1 -0
- package/loader/plugins/extendedMaterialLoaderPlugin.d.ts +9 -0
- package/loader/plugins/extendedMaterialLoaderPlugin.js +16 -0
- package/loader/plugins/extendedMaterialLoaderPlugin.js.map +1 -0
- package/loader/plugins/index.d.ts +19 -0
- package/loader/plugins/index.js +44 -0
- package/loader/plugins/index.js.map +1 -0
- package/loader/plugins/loaderPlugin.d.ts +24 -0
- package/loader/plugins/loaderPlugin.js +2 -0
- package/loader/plugins/loaderPlugin.js.map +1 -0
- package/loader/plugins/msftLodLoaderPlugin.d.ts +12 -0
- package/loader/plugins/msftLodLoaderPlugin.js +21 -0
- package/loader/plugins/msftLodLoaderPlugin.js.map +1 -0
- package/loader/plugins/telemetryLoaderPlugin.d.ts +12 -0
- package/loader/plugins/telemetryLoaderPlugin.js +36 -0
- package/loader/plugins/telemetryLoaderPlugin.js.map +1 -0
- package/managers/observablesManager.d.ts +66 -0
- package/managers/observablesManager.js +35 -0
- package/managers/observablesManager.js.map +1 -0
- package/managers/sceneManager.d.ts +245 -0
- package/managers/sceneManager.js +1375 -0
- package/managers/sceneManager.js.map +1 -0
- package/managers/telemetryManager.d.ts +78 -0
- package/managers/telemetryManager.js +117 -0
- package/managers/telemetryManager.js.map +1 -0
- package/model/modelAnimation.d.ts +215 -0
- package/model/modelAnimation.js +237 -0
- package/model/modelAnimation.js.map +1 -0
- package/model/viewerModel.d.ts +233 -0
- package/model/viewerModel.js +673 -0
- package/model/viewerModel.js.map +1 -0
- package/optimizer/custom/extended.d.ts +13 -0
- package/optimizer/custom/extended.js +101 -0
- package/optimizer/custom/extended.js.map +1 -0
- package/optimizer/custom/index.d.ts +9 -0
- package/optimizer/custom/index.js +26 -0
- package/optimizer/custom/index.js.map +1 -0
- package/package.json +28 -19
- package/readme.md +28 -28
- package/renderOnlyIndex.d.ts +11 -0
- package/renderOnlyIndex.js +18 -0
- package/renderOnlyIndex.js.map +1 -0
- package/templating/eventManager.d.ts +35 -0
- package/templating/eventManager.js +66 -0
- package/templating/eventManager.js.map +1 -0
- package/templating/plugins/hdButtonPlugin.d.ts +9 -0
- package/templating/plugins/hdButtonPlugin.js +22 -0
- package/templating/plugins/hdButtonPlugin.js.map +1 -0
- package/templating/plugins/printButton.d.ts +9 -0
- package/templating/plugins/printButton.js +41 -0
- package/templating/plugins/printButton.js.map +1 -0
- package/templating/templateManager.d.ts +197 -0
- package/templating/templateManager.js +561 -0
- package/templating/templateManager.js.map +1 -0
- package/templating/viewerTemplatePlugin.d.ts +21 -0
- package/templating/viewerTemplatePlugin.js +69 -0
- package/templating/viewerTemplatePlugin.js.map +1 -0
- package/viewer/defaultViewer.d.ts +130 -0
- package/viewer/defaultViewer.js +672 -0
- package/viewer/defaultViewer.js.map +1 -0
- package/viewer/renderOnlyViewer.d.ts +9 -0
- package/viewer/renderOnlyViewer.js +46 -0
- package/viewer/renderOnlyViewer.js.map +1 -0
- package/viewer/viewer.d.ts +258 -0
- package/viewer/viewer.js +783 -0
- package/viewer/viewer.js.map +1 -0
- package/viewer/viewerManager.d.ts +58 -0
- package/viewer/viewerManager.js +91 -0
- package/viewer/viewerManager.js.map +1 -0
- package/viewer/viewerWithTemplate.d.ts +9 -0
- package/viewer/viewerWithTemplate.js +20 -0
- package/viewer/viewerWithTemplate.js.map +1 -0
- package/assets/photoStudio.env +0 -0
- package/dist/babylon-viewer.esm.js +0 -2
- package/dist/babylon-viewer.esm.js.map +0 -1
- package/dist/babylon-viewer.esm.min.js +0 -2
- package/dist/babylon-viewer.esm.min.js.map +0 -1
- package/dist/chunks/EXT_lights_ies-CFzvmxxg.esm.min.js +0 -2
- package/dist/chunks/EXT_lights_ies-CFzvmxxg.esm.min.js.map +0 -1
- package/dist/chunks/EXT_lights_ies-cyFdY7yl.esm.js +0 -84
- package/dist/chunks/EXT_lights_ies-cyFdY7yl.esm.js.map +0 -1
- package/dist/chunks/EXT_lights_image_based-BNmSqx40.esm.min.js +0 -2
- package/dist/chunks/EXT_lights_image_based-BNmSqx40.esm.min.js.map +0 -1
- package/dist/chunks/EXT_lights_image_based-CC48JVU0.esm.js +0 -171
- package/dist/chunks/EXT_lights_image_based-CC48JVU0.esm.js.map +0 -1
- package/dist/chunks/EXT_mesh_gpu_instancing-B2qj3kQu.esm.js +0 -86
- package/dist/chunks/EXT_mesh_gpu_instancing-B2qj3kQu.esm.js.map +0 -1
- package/dist/chunks/EXT_mesh_gpu_instancing-lanrAAoi.esm.min.js +0 -2
- package/dist/chunks/EXT_mesh_gpu_instancing-lanrAAoi.esm.min.js.map +0 -1
- package/dist/chunks/EXT_meshopt_compression-DjvHx7gJ.esm.js +0 -134
- package/dist/chunks/EXT_meshopt_compression-DjvHx7gJ.esm.js.map +0 -1
- package/dist/chunks/EXT_meshopt_compression-oH6HzGir.esm.min.js +0 -2
- package/dist/chunks/EXT_meshopt_compression-oH6HzGir.esm.min.js.map +0 -1
- package/dist/chunks/EXT_texture_avif-BYWETW7-.esm.min.js +0 -2
- package/dist/chunks/EXT_texture_avif-BYWETW7-.esm.min.js.map +0 -1
- package/dist/chunks/EXT_texture_avif-CKXEq29h.esm.js +0 -44
- package/dist/chunks/EXT_texture_avif-CKXEq29h.esm.js.map +0 -1
- package/dist/chunks/EXT_texture_webp-Dl4GPoEU.esm.min.js +0 -2
- package/dist/chunks/EXT_texture_webp-Dl4GPoEU.esm.min.js.map +0 -1
- package/dist/chunks/EXT_texture_webp-fAiSgaNl.esm.js +0 -43
- package/dist/chunks/EXT_texture_webp-fAiSgaNl.esm.js.map +0 -1
- package/dist/chunks/ExtrasAsMetadata-BUQ3X3M6.esm.js +0 -64
- package/dist/chunks/ExtrasAsMetadata-BUQ3X3M6.esm.js.map +0 -1
- package/dist/chunks/ExtrasAsMetadata-C_M9nxb4.esm.min.js +0 -2
- package/dist/chunks/ExtrasAsMetadata-C_M9nxb4.esm.min.js.map +0 -1
- package/dist/chunks/KHR_animation_pointer-BdFZyLUq.esm.js +0 -352
- package/dist/chunks/KHR_animation_pointer-BdFZyLUq.esm.js.map +0 -1
- package/dist/chunks/KHR_animation_pointer-CBqZcURZ.esm.min.js +0 -2
- package/dist/chunks/KHR_animation_pointer-CBqZcURZ.esm.min.js.map +0 -1
- package/dist/chunks/KHR_draco_mesh_compression-DU2Rk2nj.esm.min.js +0 -2
- package/dist/chunks/KHR_draco_mesh_compression-DU2Rk2nj.esm.min.js.map +0 -1
- package/dist/chunks/KHR_draco_mesh_compression-hVF9XuFz.esm.js +0 -610
- package/dist/chunks/KHR_draco_mesh_compression-hVF9XuFz.esm.js.map +0 -1
- package/dist/chunks/KHR_interactivity-COE1p684.esm.min.js +0 -2
- package/dist/chunks/KHR_interactivity-COE1p684.esm.min.js.map +0 -1
- package/dist/chunks/KHR_interactivity-Cv1s_pea.esm.js +0 -4033
- package/dist/chunks/KHR_interactivity-Cv1s_pea.esm.js.map +0 -1
- package/dist/chunks/KHR_lights_punctual-CHf5kbKi.esm.js +0 -581
- package/dist/chunks/KHR_lights_punctual-CHf5kbKi.esm.js.map +0 -1
- package/dist/chunks/KHR_lights_punctual-DIEAP5SG.esm.min.js +0 -2
- package/dist/chunks/KHR_lights_punctual-DIEAP5SG.esm.min.js.map +0 -1
- package/dist/chunks/KHR_materials_anisotropy-CU-xxV6y.esm.js +0 -65
- package/dist/chunks/KHR_materials_anisotropy-CU-xxV6y.esm.js.map +0 -1
- package/dist/chunks/KHR_materials_anisotropy-Cq6CU4qW.esm.min.js +0 -2
- package/dist/chunks/KHR_materials_anisotropy-Cq6CU4qW.esm.min.js.map +0 -1
- package/dist/chunks/KHR_materials_clearcoat-BSjcmIju.esm.js +0 -96
- package/dist/chunks/KHR_materials_clearcoat-BSjcmIju.esm.js.map +0 -1
- package/dist/chunks/KHR_materials_clearcoat-CVNNhJRE.esm.min.js +0 -2
- package/dist/chunks/KHR_materials_clearcoat-CVNNhJRE.esm.min.js.map +0 -1
- package/dist/chunks/KHR_materials_diffuse_transmission-BDuGIkOh.esm.min.js +0 -2
- package/dist/chunks/KHR_materials_diffuse_transmission-BDuGIkOh.esm.min.js.map +0 -1
- package/dist/chunks/KHR_materials_diffuse_transmission-BZ-9rJUf.esm.js +0 -97
- package/dist/chunks/KHR_materials_diffuse_transmission-BZ-9rJUf.esm.js.map +0 -1
- package/dist/chunks/KHR_materials_dispersion-BxiGElVU.esm.min.js +0 -2
- package/dist/chunks/KHR_materials_dispersion-BxiGElVU.esm.min.js.map +0 -1
- package/dist/chunks/KHR_materials_dispersion-UI4zH1V_.esm.js +0 -62
- package/dist/chunks/KHR_materials_dispersion-UI4zH1V_.esm.js.map +0 -1
- package/dist/chunks/KHR_materials_emissive_strength-BT-Nu60T.esm.js +0 -55
- package/dist/chunks/KHR_materials_emissive_strength-BT-Nu60T.esm.js.map +0 -1
- package/dist/chunks/KHR_materials_emissive_strength-CwkVNmN7.esm.min.js +0 -2
- package/dist/chunks/KHR_materials_emissive_strength-CwkVNmN7.esm.min.js.map +0 -1
- package/dist/chunks/KHR_materials_ior-BGUUe5AW.esm.min.js +0 -2
- package/dist/chunks/KHR_materials_ior-BGUUe5AW.esm.min.js.map +0 -1
- package/dist/chunks/KHR_materials_ior-BbBQF-yw.esm.js +0 -64
- package/dist/chunks/KHR_materials_ior-BbBQF-yw.esm.js.map +0 -1
- package/dist/chunks/KHR_materials_iridescence-IFN2ewvr.esm.min.js +0 -2
- package/dist/chunks/KHR_materials_iridescence-IFN2ewvr.esm.min.js.map +0 -1
- package/dist/chunks/KHR_materials_iridescence-nLZDN7sc.esm.js +0 -72
- package/dist/chunks/KHR_materials_iridescence-nLZDN7sc.esm.js.map +0 -1
- package/dist/chunks/KHR_materials_pbrSpecularGlossiness-CyNVQC-W.esm.js +0 -81
- package/dist/chunks/KHR_materials_pbrSpecularGlossiness-CyNVQC-W.esm.js.map +0 -1
- package/dist/chunks/KHR_materials_pbrSpecularGlossiness-zxcydJdp.esm.min.js +0 -2
- package/dist/chunks/KHR_materials_pbrSpecularGlossiness-zxcydJdp.esm.min.js.map +0 -1
- package/dist/chunks/KHR_materials_sheen-BWL9yo8Z.esm.min.js +0 -2
- package/dist/chunks/KHR_materials_sheen-BWL9yo8Z.esm.min.js.map +0 -1
- package/dist/chunks/KHR_materials_sheen-DSThWwq2.esm.js +0 -85
- package/dist/chunks/KHR_materials_sheen-DSThWwq2.esm.js.map +0 -1
- package/dist/chunks/KHR_materials_specular-B96NRFEV.esm.js +0 -75
- package/dist/chunks/KHR_materials_specular-B96NRFEV.esm.js.map +0 -1
- package/dist/chunks/KHR_materials_specular-D2JwOdxw.esm.min.js +0 -2
- package/dist/chunks/KHR_materials_specular-D2JwOdxw.esm.min.js.map +0 -1
- package/dist/chunks/KHR_materials_transmission-BvqtJXfD.esm.js +0 -307
- package/dist/chunks/KHR_materials_transmission-BvqtJXfD.esm.js.map +0 -1
- package/dist/chunks/KHR_materials_transmission-ljXN4y_0.esm.min.js +0 -2
- package/dist/chunks/KHR_materials_transmission-ljXN4y_0.esm.min.js.map +0 -1
- package/dist/chunks/KHR_materials_unlit-CjGTXU3z.esm.min.js +0 -2
- package/dist/chunks/KHR_materials_unlit-CjGTXU3z.esm.min.js.map +0 -1
- package/dist/chunks/KHR_materials_unlit-ww00IloC.esm.js +0 -74
- package/dist/chunks/KHR_materials_unlit-ww00IloC.esm.js.map +0 -1
- package/dist/chunks/KHR_materials_variants-D0pVU1lm.esm.min.js +0 -2
- package/dist/chunks/KHR_materials_variants-D0pVU1lm.esm.min.js.map +0 -1
- package/dist/chunks/KHR_materials_variants-D3IDOJfB.esm.js +0 -262
- package/dist/chunks/KHR_materials_variants-D3IDOJfB.esm.js.map +0 -1
- package/dist/chunks/KHR_materials_volume-BfZR8rbr.esm.min.js +0 -2
- package/dist/chunks/KHR_materials_volume-BfZR8rbr.esm.min.js.map +0 -1
- package/dist/chunks/KHR_materials_volume-CLkC_Bvi.esm.js +0 -87
- package/dist/chunks/KHR_materials_volume-CLkC_Bvi.esm.js.map +0 -1
- package/dist/chunks/KHR_mesh_quantization-BJv1P2Wt.esm.js +0 -26
- package/dist/chunks/KHR_mesh_quantization-BJv1P2Wt.esm.js.map +0 -1
- package/dist/chunks/KHR_mesh_quantization-D69X_5bR.esm.min.js +0 -2
- package/dist/chunks/KHR_mesh_quantization-D69X_5bR.esm.min.js.map +0 -1
- package/dist/chunks/KHR_node_hoverability-CG6s7hhs.esm.min.js +0 -2
- package/dist/chunks/KHR_node_hoverability-CG6s7hhs.esm.min.js.map +0 -1
- package/dist/chunks/KHR_node_hoverability-xgvyZ_r-.esm.js +0 -39
- package/dist/chunks/KHR_node_hoverability-xgvyZ_r-.esm.js.map +0 -1
- package/dist/chunks/KHR_node_visibility-DUozjXRR.esm.min.js +0 -2
- package/dist/chunks/KHR_node_visibility-DUozjXRR.esm.min.js.map +0 -1
- package/dist/chunks/KHR_node_visibility-aAs5Kkey.esm.js +0 -46
- package/dist/chunks/KHR_node_visibility-aAs5Kkey.esm.js.map +0 -1
- package/dist/chunks/KHR_texture_basisu-Bjw0jG1d.esm.js +0 -43
- package/dist/chunks/KHR_texture_basisu-Bjw0jG1d.esm.js.map +0 -1
- package/dist/chunks/KHR_texture_basisu-FWm46QOj.esm.min.js +0 -2
- package/dist/chunks/KHR_texture_basisu-FWm46QOj.esm.min.js.map +0 -1
- package/dist/chunks/KHR_texture_transform-BZYr2brj.esm.min.js +0 -2
- package/dist/chunks/KHR_texture_transform-BZYr2brj.esm.min.js.map +0 -1
- package/dist/chunks/KHR_texture_transform-DdsN6SA_.esm.js +0 -63
- package/dist/chunks/KHR_texture_transform-DdsN6SA_.esm.js.map +0 -1
- package/dist/chunks/KHR_xmp_json_ld-DhFD64vh.esm.min.js +0 -2
- package/dist/chunks/KHR_xmp_json_ld-DhFD64vh.esm.min.js.map +0 -1
- package/dist/chunks/KHR_xmp_json_ld-sTn6N13E.esm.js +0 -51
- package/dist/chunks/KHR_xmp_json_ld-sTn6N13E.esm.js.map +0 -1
- package/dist/chunks/MSFT_audio_emitter-5lrNj8-c.esm.min.js +0 -2
- package/dist/chunks/MSFT_audio_emitter-5lrNj8-c.esm.min.js.map +0 -1
- package/dist/chunks/MSFT_audio_emitter-B7RJSCaF.esm.js +0 -2201
- package/dist/chunks/MSFT_audio_emitter-B7RJSCaF.esm.js.map +0 -1
- package/dist/chunks/MSFT_lod-BJBjM7Gp.esm.js +0 -337
- package/dist/chunks/MSFT_lod-BJBjM7Gp.esm.js.map +0 -1
- package/dist/chunks/MSFT_lod-DpEZMnoU.esm.min.js +0 -2
- package/dist/chunks/MSFT_lod-DpEZMnoU.esm.min.js.map +0 -1
- package/dist/chunks/MSFT_minecraftMesh-CXHPdyar.esm.min.js +0 -2
- package/dist/chunks/MSFT_minecraftMesh-CXHPdyar.esm.min.js.map +0 -1
- package/dist/chunks/MSFT_minecraftMesh-DRC2tMvY.esm.js +0 -46
- package/dist/chunks/MSFT_minecraftMesh-DRC2tMvY.esm.js.map +0 -1
- package/dist/chunks/MSFT_sRGBFactors-Db1asZRk.esm.js +0 -47
- package/dist/chunks/MSFT_sRGBFactors-Db1asZRk.esm.js.map +0 -1
- package/dist/chunks/MSFT_sRGBFactors-RhAtY3q7.esm.min.js +0 -2
- package/dist/chunks/MSFT_sRGBFactors-RhAtY3q7.esm.min.js.map +0 -1
- package/dist/chunks/animationGroup-CjaFhT87.esm.min.js +0 -2
- package/dist/chunks/animationGroup-CjaFhT87.esm.min.js.map +0 -1
- package/dist/chunks/animationGroup-Ctc6BUYh.esm.js +0 -2482
- package/dist/chunks/animationGroup-Ctc6BUYh.esm.js.map +0 -1
- package/dist/chunks/assetContainer-DDEska5G.esm.min.js +0 -2
- package/dist/chunks/assetContainer-DDEska5G.esm.min.js.map +0 -1
- package/dist/chunks/assetContainer-QD3gUzyx.esm.js +0 -1720
- package/dist/chunks/assetContainer-QD3gUzyx.esm.js.map +0 -1
- package/dist/chunks/audioEngine-C6R2Ow6e.esm.js +0 -305
- package/dist/chunks/audioEngine-C6R2Ow6e.esm.js.map +0 -1
- package/dist/chunks/audioEngine-FKYFzzDb.esm.min.js +0 -2
- package/dist/chunks/audioEngine-FKYFzzDb.esm.min.js.map +0 -1
- package/dist/chunks/bakedVertexAnimation-DKR6lpIg.esm.min.js +0 -2
- package/dist/chunks/bakedVertexAnimation-DKR6lpIg.esm.min.js.map +0 -1
- package/dist/chunks/bakedVertexAnimation-Hxn22qoJ.esm.js +0 -114
- package/dist/chunks/bakedVertexAnimation-Hxn22qoJ.esm.js.map +0 -1
- package/dist/chunks/basisTextureLoader-BcNAHqjw.esm.min.js +0 -2
- package/dist/chunks/basisTextureLoader-BcNAHqjw.esm.min.js.map +0 -1
- package/dist/chunks/basisTextureLoader-Dr2d0ez5.esm.js +0 -600
- package/dist/chunks/basisTextureLoader-Dr2d0ez5.esm.js.map +0 -1
- package/dist/chunks/dds-CFrq_XFM.esm.js +0 -540
- package/dist/chunks/dds-CFrq_XFM.esm.js.map +0 -1
- package/dist/chunks/dds-D1NTXLIL.esm.min.js +0 -2
- package/dist/chunks/dds-D1NTXLIL.esm.min.js.map +0 -1
- package/dist/chunks/ddsTextureLoader-DbvffCUa.esm.min.js +0 -2
- package/dist/chunks/ddsTextureLoader-DbvffCUa.esm.min.js.map +0 -1
- package/dist/chunks/ddsTextureLoader-wyjUdBoO.esm.js +0 -88
- package/dist/chunks/ddsTextureLoader-wyjUdBoO.esm.js.map +0 -1
- package/dist/chunks/decalFragment-CGto5zyq.esm.js +0 -18
- package/dist/chunks/decalFragment-CGto5zyq.esm.js.map +0 -1
- package/dist/chunks/decalFragment-CU64C8uG.esm.min.js +0 -2
- package/dist/chunks/decalFragment-CU64C8uG.esm.min.js.map +0 -1
- package/dist/chunks/default.fragment-B2bhCC4E.esm.js +0 -446
- package/dist/chunks/default.fragment-B2bhCC4E.esm.js.map +0 -1
- package/dist/chunks/default.fragment-Boq79lom.esm.min.js +0 -2
- package/dist/chunks/default.fragment-Boq79lom.esm.min.js.map +0 -1
- package/dist/chunks/default.fragment-CluFtXFp.esm.min.js +0 -2
- package/dist/chunks/default.fragment-CluFtXFp.esm.min.js.map +0 -1
- package/dist/chunks/default.fragment-Dshl5Uqc.esm.js +0 -515
- package/dist/chunks/default.fragment-Dshl5Uqc.esm.js.map +0 -1
- package/dist/chunks/default.vertex-BAAgCiYo.esm.min.js +0 -2
- package/dist/chunks/default.vertex-BAAgCiYo.esm.min.js.map +0 -1
- package/dist/chunks/default.vertex-BhOIicZW.esm.min.js +0 -2
- package/dist/chunks/default.vertex-BhOIicZW.esm.min.js.map +0 -1
- package/dist/chunks/default.vertex-DL7IogGB.esm.js +0 -211
- package/dist/chunks/default.vertex-DL7IogGB.esm.js.map +0 -1
- package/dist/chunks/default.vertex-DOXcZEQ0.esm.js +0 -190
- package/dist/chunks/default.vertex-DOXcZEQ0.esm.js.map +0 -1
- package/dist/chunks/defaultUboDeclaration-1qBz6EuF.esm.js +0 -15
- package/dist/chunks/defaultUboDeclaration-1qBz6EuF.esm.js.map +0 -1
- package/dist/chunks/defaultUboDeclaration-B9LzMzlw.esm.min.js +0 -2
- package/dist/chunks/defaultUboDeclaration-B9LzMzlw.esm.min.js.map +0 -1
- package/dist/chunks/defaultUboDeclaration-CXdodf7i.esm.js +0 -13
- package/dist/chunks/defaultUboDeclaration-CXdodf7i.esm.js.map +0 -1
- package/dist/chunks/defaultUboDeclaration-CZlCaxgu.esm.min.js +0 -2
- package/dist/chunks/defaultUboDeclaration-CZlCaxgu.esm.min.js.map +0 -1
- package/dist/chunks/drawWrapper.functions-CKg3_9x4.esm.js +0 -11
- package/dist/chunks/drawWrapper.functions-CKg3_9x4.esm.js.map +0 -1
- package/dist/chunks/drawWrapper.functions-ng7lvueZ.esm.min.js +0 -2
- package/dist/chunks/drawWrapper.functions-ng7lvueZ.esm.min.js.map +0 -1
- package/dist/chunks/dumpTools-C3vcqEdz.esm.js +0 -200
- package/dist/chunks/dumpTools-C3vcqEdz.esm.js.map +0 -1
- package/dist/chunks/dumpTools-C8ZzlWEh.esm.min.js +0 -2
- package/dist/chunks/dumpTools-C8ZzlWEh.esm.min.js.map +0 -1
- package/dist/chunks/engine-_wVL12I1.esm.js +0 -2213
- package/dist/chunks/engine-_wVL12I1.esm.js.map +0 -1
- package/dist/chunks/engine-nCWszV_w.esm.min.js +0 -2
- package/dist/chunks/engine-nCWszV_w.esm.min.js.map +0 -1
- package/dist/chunks/engine.common-BuPfo1Wj.esm.min.js +0 -2
- package/dist/chunks/engine.common-BuPfo1Wj.esm.min.js.map +0 -1
- package/dist/chunks/engine.common-CT5iq3ZT.esm.js +0 -1162
- package/dist/chunks/engine.common-CT5iq3ZT.esm.js.map +0 -1
- package/dist/chunks/envTextureLoader-D7L0fVXR.esm.min.js +0 -2
- package/dist/chunks/envTextureLoader-D7L0fVXR.esm.min.js.map +0 -1
- package/dist/chunks/envTextureLoader-PtuRNDrr.esm.js +0 -64
- package/dist/chunks/envTextureLoader-PtuRNDrr.esm.js.map +0 -1
- package/dist/chunks/environmentTextureTools-BjmCbfSf.esm.min.js +0 -2
- package/dist/chunks/environmentTextureTools-BjmCbfSf.esm.min.js.map +0 -1
- package/dist/chunks/environmentTextureTools-DYbFmR95.esm.js +0 -382
- package/dist/chunks/environmentTextureTools-DYbFmR95.esm.js.map +0 -1
- package/dist/chunks/exrTextureLoader-BIPK0bPG.esm.min.js +0 -2
- package/dist/chunks/exrTextureLoader-BIPK0bPG.esm.min.js.map +0 -1
- package/dist/chunks/exrTextureLoader-CEhv_7O9.esm.js +0 -1683
- package/dist/chunks/exrTextureLoader-CEhv_7O9.esm.js.map +0 -1
- package/dist/chunks/fogFragment-B7_evZbY.esm.js +0 -102
- package/dist/chunks/fogFragment-B7_evZbY.esm.js.map +0 -1
- package/dist/chunks/fogFragment-CoZPb7oI.esm.min.js +0 -2
- package/dist/chunks/fogFragment-CoZPb7oI.esm.min.js.map +0 -1
- package/dist/chunks/fogFragment-DSO97-dc.esm.min.js +0 -2
- package/dist/chunks/fogFragment-DSO97-dc.esm.min.js.map +0 -1
- package/dist/chunks/fogFragment-wY2jQ7fb.esm.js +0 -101
- package/dist/chunks/fogFragment-wY2jQ7fb.esm.js.map +0 -1
- package/dist/chunks/fresnelFunction-BSEp5SCT.esm.js +0 -12
- package/dist/chunks/fresnelFunction-BSEp5SCT.esm.js.map +0 -1
- package/dist/chunks/fresnelFunction-Cg-NNSrz.esm.min.js +0 -2
- package/dist/chunks/fresnelFunction-Cg-NNSrz.esm.min.js.map +0 -1
- package/dist/chunks/glTFLoader-3ZUBWawQ.esm.min.js +0 -2
- package/dist/chunks/glTFLoader-3ZUBWawQ.esm.min.js.map +0 -1
- package/dist/chunks/glTFLoader-DVoAJl_A.esm.js +0 -7658
- package/dist/chunks/glTFLoader-DVoAJl_A.esm.js.map +0 -1
- package/dist/chunks/glTFLoaderAnimation-By7yP8sQ.esm.js +0 -77
- package/dist/chunks/glTFLoaderAnimation-By7yP8sQ.esm.js.map +0 -1
- package/dist/chunks/glTFLoaderAnimation-C9g-SHaJ.esm.min.js +0 -2
- package/dist/chunks/glTFLoaderAnimation-C9g-SHaJ.esm.min.js.map +0 -1
- package/dist/chunks/gltfPathToObjectConverter-Dyt_Y9jE.esm.min.js +0 -2
- package/dist/chunks/gltfPathToObjectConverter-Dyt_Y9jE.esm.min.js.map +0 -1
- package/dist/chunks/gltfPathToObjectConverter-GcUmfOyo.esm.js +0 -67
- package/dist/chunks/gltfPathToObjectConverter-GcUmfOyo.esm.js.map +0 -1
- package/dist/chunks/harmonicsFunctions-B8pgRSdd.esm.min.js +0 -2
- package/dist/chunks/harmonicsFunctions-B8pgRSdd.esm.min.js.map +0 -1
- package/dist/chunks/harmonicsFunctions-BcfkM4gb.esm.js +0 -35
- package/dist/chunks/harmonicsFunctions-BcfkM4gb.esm.js.map +0 -1
- package/dist/chunks/harmonicsFunctions-DF1x585z.esm.min.js +0 -2
- package/dist/chunks/harmonicsFunctions-DF1x585z.esm.min.js.map +0 -1
- package/dist/chunks/harmonicsFunctions-a48Ki58F.esm.js +0 -34
- package/dist/chunks/harmonicsFunctions-a48Ki58F.esm.js.map +0 -1
- package/dist/chunks/hdrTextureLoader-BWnO8u1r.esm.js +0 -253
- package/dist/chunks/hdrTextureLoader-BWnO8u1r.esm.js.map +0 -1
- package/dist/chunks/hdrTextureLoader-Bii9QpYI.esm.min.js +0 -2
- package/dist/chunks/hdrTextureLoader-Bii9QpYI.esm.min.js.map +0 -1
- package/dist/chunks/helperFunctions-BinFB44e.esm.js +0 -110
- package/dist/chunks/helperFunctions-BinFB44e.esm.js.map +0 -1
- package/dist/chunks/helperFunctions-CZAyJNTJ.esm.min.js +0 -2
- package/dist/chunks/helperFunctions-CZAyJNTJ.esm.min.js.map +0 -1
- package/dist/chunks/helperFunctions-DjoUVhI2.esm.min.js +0 -2
- package/dist/chunks/helperFunctions-DjoUVhI2.esm.min.js.map +0 -1
- package/dist/chunks/helperFunctions-Ds3-3-tu.esm.js +0 -83
- package/dist/chunks/helperFunctions-Ds3-3-tu.esm.js.map +0 -1
- package/dist/chunks/iesTextureLoader-CsnjIN7M.esm.js +0 -189
- package/dist/chunks/iesTextureLoader-CsnjIN7M.esm.js.map +0 -1
- package/dist/chunks/iesTextureLoader-DkmTomCD.esm.min.js +0 -2
- package/dist/chunks/iesTextureLoader-DkmTomCD.esm.min.js.map +0 -1
- package/dist/chunks/index-Cw2FZpYY.esm.js +0 -74870
- package/dist/chunks/index-Cw2FZpYY.esm.js.map +0 -1
- package/dist/chunks/index-DRbhrB0j.esm.min.js +0 -57
- package/dist/chunks/index-DRbhrB0j.esm.min.js.map +0 -1
- package/dist/chunks/ktxTextureLoader-B4pmAFQl.esm.js +0 -814
- package/dist/chunks/ktxTextureLoader-B4pmAFQl.esm.js.map +0 -1
- package/dist/chunks/ktxTextureLoader-B8Rlj2T0.esm.min.js +0 -2
- package/dist/chunks/ktxTextureLoader-B8Rlj2T0.esm.min.js.map +0 -1
- package/dist/chunks/logDepthDeclaration-CGz2sG_K.esm.js +0 -11
- package/dist/chunks/logDepthDeclaration-CGz2sG_K.esm.js.map +0 -1
- package/dist/chunks/logDepthDeclaration-CfVFs2QC.esm.min.js +0 -2
- package/dist/chunks/logDepthDeclaration-CfVFs2QC.esm.min.js.map +0 -1
- package/dist/chunks/logDepthDeclaration-CzVshpad.esm.min.js +0 -2
- package/dist/chunks/logDepthDeclaration-CzVshpad.esm.min.js.map +0 -1
- package/dist/chunks/logDepthDeclaration-xOwnAKtd.esm.js +0 -35
- package/dist/chunks/logDepthDeclaration-xOwnAKtd.esm.js.map +0 -1
- package/dist/chunks/logDepthVertex-BRgUZAsw.esm.js +0 -81
- package/dist/chunks/logDepthVertex-BRgUZAsw.esm.js.map +0 -1
- package/dist/chunks/logDepthVertex-CWfPfN9-.esm.min.js +0 -2
- package/dist/chunks/logDepthVertex-CWfPfN9-.esm.min.js.map +0 -1
- package/dist/chunks/logDepthVertex-HDlt7vTP.esm.min.js +0 -2
- package/dist/chunks/logDepthVertex-HDlt7vTP.esm.min.js.map +0 -1
- package/dist/chunks/logDepthVertex-l0uEG89p.esm.js +0 -77
- package/dist/chunks/logDepthVertex-l0uEG89p.esm.js.map +0 -1
- package/dist/chunks/mainUVVaryingDeclaration-B72zV2P9.esm.min.js +0 -2
- package/dist/chunks/mainUVVaryingDeclaration-B72zV2P9.esm.min.js.map +0 -1
- package/dist/chunks/mainUVVaryingDeclaration-BDogjZrz.esm.js +0 -11
- package/dist/chunks/mainUVVaryingDeclaration-BDogjZrz.esm.js.map +0 -1
- package/dist/chunks/mainUVVaryingDeclaration-DO5HJKyl.esm.min.js +0 -2
- package/dist/chunks/mainUVVaryingDeclaration-DO5HJKyl.esm.min.js.map +0 -1
- package/dist/chunks/mainUVVaryingDeclaration-DqzNajlu.esm.js +0 -11
- package/dist/chunks/mainUVVaryingDeclaration-DqzNajlu.esm.js.map +0 -1
- package/dist/chunks/mesh.vertexData.functions-B_pMCAzZ.esm.js +0 -119
- package/dist/chunks/mesh.vertexData.functions-B_pMCAzZ.esm.js.map +0 -1
- package/dist/chunks/mesh.vertexData.functions-Bo7e6Of9.esm.min.js +0 -2
- package/dist/chunks/mesh.vertexData.functions-Bo7e6Of9.esm.min.js.map +0 -1
- package/dist/chunks/meshUboDeclaration-BCO87lfZ.esm.js +0 -26
- package/dist/chunks/meshUboDeclaration-BCO87lfZ.esm.js.map +0 -1
- package/dist/chunks/meshUboDeclaration-o4Xf2fwW.esm.min.js +0 -2
- package/dist/chunks/meshUboDeclaration-o4Xf2fwW.esm.min.js.map +0 -1
- package/dist/chunks/objFileLoader-BfPYM2Sh.esm.min.js +0 -2
- package/dist/chunks/objFileLoader-BfPYM2Sh.esm.min.js.map +0 -1
- package/dist/chunks/objFileLoader-D1emf4Qh.esm.js +0 -1338
- package/dist/chunks/objFileLoader-D1emf4Qh.esm.js.map +0 -1
- package/dist/chunks/oitFragment-B92YpEfj.esm.min.js +0 -2
- package/dist/chunks/oitFragment-B92YpEfj.esm.min.js.map +0 -1
- package/dist/chunks/oitFragment-BoFKkDNv.esm.js +0 -1078
- package/dist/chunks/oitFragment-BoFKkDNv.esm.js.map +0 -1
- package/dist/chunks/oitFragment-Cfx3g0iX.esm.js +0 -1240
- package/dist/chunks/oitFragment-Cfx3g0iX.esm.js.map +0 -1
- package/dist/chunks/oitFragment-CiA7gld-.esm.min.js +0 -2
- package/dist/chunks/oitFragment-CiA7gld-.esm.min.js.map +0 -1
- package/dist/chunks/pass.fragment-BLbIViJ7.esm.js +0 -15
- package/dist/chunks/pass.fragment-BLbIViJ7.esm.js.map +0 -1
- package/dist/chunks/pass.fragment-BqMk9ouF.esm.min.js +0 -2
- package/dist/chunks/pass.fragment-BqMk9ouF.esm.min.js.map +0 -1
- package/dist/chunks/pass.fragment-BuVDFNSR.esm.js +0 -15
- package/dist/chunks/pass.fragment-BuVDFNSR.esm.js.map +0 -1
- package/dist/chunks/pass.fragment-cM5FBHLm.esm.min.js +0 -2
- package/dist/chunks/pass.fragment-cM5FBHLm.esm.min.js.map +0 -1
- package/dist/chunks/pbr.fragment-5L_F7nGn.esm.js +0 -3222
- package/dist/chunks/pbr.fragment-5L_F7nGn.esm.js.map +0 -1
- package/dist/chunks/pbr.fragment-BJNPHSa-.esm.min.js +0 -2
- package/dist/chunks/pbr.fragment-BJNPHSa-.esm.min.js.map +0 -1
- package/dist/chunks/pbr.fragment-CTLrOzV2.esm.js +0 -3269
- package/dist/chunks/pbr.fragment-CTLrOzV2.esm.js.map +0 -1
- package/dist/chunks/pbr.fragment-D9MJFOr2.esm.min.js +0 -2
- package/dist/chunks/pbr.fragment-D9MJFOr2.esm.min.js.map +0 -1
- package/dist/chunks/pbr.vertex-BJyjq_fb.esm.js +0 -223
- package/dist/chunks/pbr.vertex-BJyjq_fb.esm.js.map +0 -1
- package/dist/chunks/pbr.vertex-Bm8Ng4Sx.esm.min.js +0 -2
- package/dist/chunks/pbr.vertex-Bm8Ng4Sx.esm.min.js.map +0 -1
- package/dist/chunks/pbr.vertex-CAKPUhfb.esm.min.js +0 -2
- package/dist/chunks/pbr.vertex-CAKPUhfb.esm.min.js.map +0 -1
- package/dist/chunks/pbr.vertex-DJd_-MvE.esm.js +0 -348
- package/dist/chunks/pbr.vertex-DJd_-MvE.esm.js.map +0 -1
- package/dist/chunks/postprocess.vertex-BjRX5eGi.esm.min.js +0 -2
- package/dist/chunks/postprocess.vertex-BjRX5eGi.esm.min.js.map +0 -1
- package/dist/chunks/postprocess.vertex-CFaKNIU-.esm.js +0 -20
- package/dist/chunks/postprocess.vertex-CFaKNIU-.esm.js.map +0 -1
- package/dist/chunks/rawTexture-ByD8l28R.esm.min.js +0 -2
- package/dist/chunks/rawTexture-ByD8l28R.esm.min.js.map +0 -1
- package/dist/chunks/rawTexture-DGz22uaX.esm.js +0 -191
- package/dist/chunks/rawTexture-DGz22uaX.esm.js.map +0 -1
- package/dist/chunks/ray-ByafiITx.esm.js +0 -946
- package/dist/chunks/ray-ByafiITx.esm.js.map +0 -1
- package/dist/chunks/ray-ChSTYrPm.esm.min.js +0 -2
- package/dist/chunks/ray-ChSTYrPm.esm.min.js.map +0 -1
- package/dist/chunks/rgbdDecode.fragment-CJ7PpH1N.esm.js +0 -13
- package/dist/chunks/rgbdDecode.fragment-CJ7PpH1N.esm.js.map +0 -1
- package/dist/chunks/rgbdDecode.fragment-DJ9crbPP.esm.js +0 -13
- package/dist/chunks/rgbdDecode.fragment-DJ9crbPP.esm.js.map +0 -1
- package/dist/chunks/rgbdDecode.fragment-DLpb3z18.esm.min.js +0 -2
- package/dist/chunks/rgbdDecode.fragment-DLpb3z18.esm.min.js.map +0 -1
- package/dist/chunks/rgbdDecode.fragment-ygeOUzIi.esm.min.js +0 -2
- package/dist/chunks/rgbdDecode.fragment-ygeOUzIi.esm.min.js.map +0 -1
- package/dist/chunks/rgbdEncode.fragment-BTG_wbck.esm.min.js +0 -2
- package/dist/chunks/rgbdEncode.fragment-BTG_wbck.esm.min.js.map +0 -1
- package/dist/chunks/rgbdEncode.fragment-C2s4AQaM.esm.js +0 -13
- package/dist/chunks/rgbdEncode.fragment-C2s4AQaM.esm.js.map +0 -1
- package/dist/chunks/rgbdEncode.fragment-C6LKySQH.esm.js +0 -13
- package/dist/chunks/rgbdEncode.fragment-C6LKySQH.esm.js.map +0 -1
- package/dist/chunks/rgbdEncode.fragment-CKB2lpgL.esm.min.js +0 -2
- package/dist/chunks/rgbdEncode.fragment-CKB2lpgL.esm.min.js.map +0 -1
- package/dist/chunks/splatFileLoader-BtSUlfZs.esm.min.js +0 -2
- package/dist/chunks/splatFileLoader-BtSUlfZs.esm.min.js.map +0 -1
- package/dist/chunks/splatFileLoader-Wn5sDtLq.esm.js +0 -3379
- package/dist/chunks/splatFileLoader-Wn5sDtLq.esm.js.map +0 -1
- package/dist/chunks/spotLight-CmDQEB8V.esm.js +0 -701
- package/dist/chunks/spotLight-CmDQEB8V.esm.js.map +0 -1
- package/dist/chunks/spotLight-hg94aMJD.esm.min.js +0 -2
- package/dist/chunks/spotLight-hg94aMJD.esm.min.js.map +0 -1
- package/dist/chunks/standardMaterial-BhIiLn1_.esm.js +0 -1806
- package/dist/chunks/standardMaterial-BhIiLn1_.esm.js.map +0 -1
- package/dist/chunks/standardMaterial-DQii8fRL.esm.min.js +0 -2
- package/dist/chunks/standardMaterial-DQii8fRL.esm.min.js.map +0 -1
- package/dist/chunks/stlFileLoader-D83u9BOr.esm.js +0 -238
- package/dist/chunks/stlFileLoader-D83u9BOr.esm.js.map +0 -1
- package/dist/chunks/stlFileLoader-DkXWqjZo.esm.min.js +0 -2
- package/dist/chunks/stlFileLoader-DkXWqjZo.esm.min.js.map +0 -1
- package/dist/chunks/tgaTextureLoader-C9xl6cvE.esm.js +0 -349
- package/dist/chunks/tgaTextureLoader-C9xl6cvE.esm.js.map +0 -1
- package/dist/chunks/tgaTextureLoader-DfzjGulW.esm.min.js +0 -2
- package/dist/chunks/tgaTextureLoader-DfzjGulW.esm.min.js.map +0 -1
- package/dist/chunks/thinEngine-Cu21aOSC.esm.min.js +0 -2
- package/dist/chunks/thinEngine-Cu21aOSC.esm.min.js.map +0 -1
- package/dist/chunks/thinEngine-IzS60pqU.esm.js +0 -3853
- package/dist/chunks/thinEngine-IzS60pqU.esm.js.map +0 -1
- package/dist/chunks/thinInstanceMesh-BN8Ev-h8.esm.js +0 -314
- package/dist/chunks/thinInstanceMesh-BN8Ev-h8.esm.js.map +0 -1
- package/dist/chunks/thinInstanceMesh-Bm9vmKU4.esm.min.js +0 -2
- package/dist/chunks/thinInstanceMesh-Bm9vmKU4.esm.min.js.map +0 -1
- package/dist/chunks/vertexColorMixing-Cazf4vEl.esm.min.js +0 -2
- package/dist/chunks/vertexColorMixing-Cazf4vEl.esm.min.js.map +0 -1
- package/dist/chunks/vertexColorMixing-DGvq3Fju.esm.js +0 -421
- package/dist/chunks/vertexColorMixing-DGvq3Fju.esm.js.map +0 -1
- package/dist/chunks/vertexColorMixing-D_6ZvivZ.esm.min.js +0 -2
- package/dist/chunks/vertexColorMixing-D_6ZvivZ.esm.min.js.map +0 -1
- package/dist/chunks/vertexColorMixing-DuYHnuUm.esm.js +0 -531
- package/dist/chunks/vertexColorMixing-DuYHnuUm.esm.js.map +0 -1
- package/dist/chunks/webgpuEngine-DHaXinU4.esm.min.js +0 -2
- package/dist/chunks/webgpuEngine-DHaXinU4.esm.min.js.map +0 -1
- package/dist/chunks/webgpuEngine-Dxev7pbz.esm.js +0 -11538
- package/dist/chunks/webgpuEngine-Dxev7pbz.esm.js.map +0 -1
- package/dist/chunks/workerPool-BUOov2K1.esm.js +0 -122
- package/dist/chunks/workerPool-BUOov2K1.esm.js.map +0 -1
- package/dist/chunks/workerPool-BWHiDmEZ.esm.min.js +0 -2
- package/dist/chunks/workerPool-BWHiDmEZ.esm.min.js.map +0 -1
- package/lib/index.d.ts +0 -591
- package/lib/index.js +0 -2165
- package/lib/index.js.map +0 -1
|
@@ -1,3853 +0,0 @@
|
|
|
1
|
-
import { D as DataBuffer, b0 as _ConcatenateShader, A as AbstractEngine, n as Effect, b1 as deleteStateObject, L as Logger, b2 as getStateObject, C as Constants, r as resetCachedPipeline, b3 as _getGlobalDefines, b4 as createRawShaderProgram, b5 as createShaderProgram, b6 as createPipelineContext, b7 as _finalizePipelineContext, b8 as _preparePipelineContext, b9 as _createShaderProgram, ba as _isRenderingStateCompiled, bb as _executeWhenRenderingStateIsCompiled, I as InternalTexture, bc as IsDepthTexture, H as HasStencilAspect, G as GetExponentOfTwo, bd as _setProgram, p as IsWindowObjectExist } from './index-Cw2FZpYY.esm.js';
|
|
2
|
-
import { I as IsWrapper } from './drawWrapper.functions-CKg3_9x4.esm.js';
|
|
3
|
-
|
|
4
|
-
/** @internal */
|
|
5
|
-
class WebGLShaderProcessor {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.shaderLanguage = 0 /* ShaderLanguage.GLSL */;
|
|
8
|
-
}
|
|
9
|
-
postProcessor(code, defines, isFragment, processingContext, parameters) {
|
|
10
|
-
// Remove extensions
|
|
11
|
-
if (parameters.drawBuffersExtensionDisabled) {
|
|
12
|
-
// even if enclosed in #if/#endif, IE11 does parse the #extension declaration, so we need to remove it altogether
|
|
13
|
-
const regex = /#extension.+GL_EXT_draw_buffers.+(enable|require)/g;
|
|
14
|
-
code = code.replace(regex, "");
|
|
15
|
-
}
|
|
16
|
-
return code;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const varyingRegex = /(flat\s)?\s*varying\s*.*/;
|
|
21
|
-
/** @internal */
|
|
22
|
-
class WebGL2ShaderProcessor {
|
|
23
|
-
constructor() {
|
|
24
|
-
this.shaderLanguage = 0 /* ShaderLanguage.GLSL */;
|
|
25
|
-
}
|
|
26
|
-
attributeProcessor(attribute) {
|
|
27
|
-
return attribute.replace("attribute", "in");
|
|
28
|
-
}
|
|
29
|
-
varyingCheck(varying, _isFragment) {
|
|
30
|
-
return varyingRegex.test(varying);
|
|
31
|
-
}
|
|
32
|
-
varyingProcessor(varying, isFragment) {
|
|
33
|
-
return varying.replace("varying", isFragment ? "in" : "out");
|
|
34
|
-
}
|
|
35
|
-
postProcessor(code, defines, isFragment) {
|
|
36
|
-
const hasDrawBuffersExtension = code.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
|
|
37
|
-
// Remove extensions
|
|
38
|
-
const regex = /#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
|
|
39
|
-
code = code.replace(regex, "");
|
|
40
|
-
// Replace instructions
|
|
41
|
-
code = code.replace(/texture2D\s*\(/g, "texture(");
|
|
42
|
-
if (isFragment) {
|
|
43
|
-
const hasOutput = code.search(/layout *\(location *= *0\) *out/g) !== -1;
|
|
44
|
-
code = code.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
|
|
45
|
-
code = code.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
|
|
46
|
-
code = code.replace(/textureCube\s*\(/g, "texture(");
|
|
47
|
-
code = code.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
|
|
48
|
-
code = code.replace(/gl_FragColor/g, "glFragColor");
|
|
49
|
-
code = code.replace(/gl_FragData/g, "glFragData");
|
|
50
|
-
code = code.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension || hasOutput ? "" : "layout(location = 0) out vec4 glFragColor;\n") + "void main(");
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
const hasMultiviewExtension = defines.indexOf("#define MULTIVIEW") !== -1;
|
|
54
|
-
if (hasMultiviewExtension) {
|
|
55
|
-
return "#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n" + code;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return code;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** @internal */
|
|
63
|
-
class WebGLDataBuffer extends DataBuffer {
|
|
64
|
-
constructor(resource) {
|
|
65
|
-
super();
|
|
66
|
-
this._buffer = resource;
|
|
67
|
-
}
|
|
68
|
-
get underlyingResource() {
|
|
69
|
-
return this._buffer;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/** @internal */
|
|
74
|
-
class WebGLHardwareTexture {
|
|
75
|
-
get underlyingResource() {
|
|
76
|
-
return this._webGLTexture;
|
|
77
|
-
}
|
|
78
|
-
constructor(existingTexture = null, context) {
|
|
79
|
-
// There can be multiple buffers for a single WebGL texture because different layers of a 2DArrayTexture / 3DTexture
|
|
80
|
-
// or different faces of a cube texture can be bound to different render targets at the same time.
|
|
81
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
82
|
-
this._MSAARenderBuffers = null;
|
|
83
|
-
this._context = context;
|
|
84
|
-
if (!existingTexture) {
|
|
85
|
-
existingTexture = context.createTexture();
|
|
86
|
-
if (!existingTexture) {
|
|
87
|
-
throw new Error("Unable to create webGL texture");
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
this.set(existingTexture);
|
|
91
|
-
}
|
|
92
|
-
setUsage() { }
|
|
93
|
-
set(hardwareTexture) {
|
|
94
|
-
this._webGLTexture = hardwareTexture;
|
|
95
|
-
}
|
|
96
|
-
reset() {
|
|
97
|
-
this._webGLTexture = null;
|
|
98
|
-
this._MSAARenderBuffers = null;
|
|
99
|
-
}
|
|
100
|
-
addMSAARenderBuffer(buffer) {
|
|
101
|
-
if (!this._MSAARenderBuffers) {
|
|
102
|
-
this._MSAARenderBuffers = [];
|
|
103
|
-
}
|
|
104
|
-
this._MSAARenderBuffers.push(buffer);
|
|
105
|
-
}
|
|
106
|
-
releaseMSAARenderBuffers() {
|
|
107
|
-
if (this._MSAARenderBuffers) {
|
|
108
|
-
for (const buffer of this._MSAARenderBuffers) {
|
|
109
|
-
this._context.deleteRenderbuffer(buffer);
|
|
110
|
-
}
|
|
111
|
-
this._MSAARenderBuffers = null;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
getMSAARenderBuffer(index = 0) {
|
|
115
|
-
return this._MSAARenderBuffers?.[index] ?? null;
|
|
116
|
-
}
|
|
117
|
-
release() {
|
|
118
|
-
this.releaseMSAARenderBuffers();
|
|
119
|
-
if (this._webGLTexture) {
|
|
120
|
-
this._context.deleteTexture(this._webGLTexture);
|
|
121
|
-
}
|
|
122
|
-
this.reset();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Keeps track of all the buffer info used in engine.
|
|
128
|
-
*/
|
|
129
|
-
class BufferPointer {
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* The base engine class (root of all engines)
|
|
133
|
-
*/
|
|
134
|
-
class ThinEngine extends AbstractEngine {
|
|
135
|
-
/**
|
|
136
|
-
* Gets or sets the name of the engine
|
|
137
|
-
*/
|
|
138
|
-
get name() {
|
|
139
|
-
return this._name;
|
|
140
|
-
}
|
|
141
|
-
set name(value) {
|
|
142
|
-
this._name = value;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Returns the version of the engine
|
|
146
|
-
*/
|
|
147
|
-
get version() {
|
|
148
|
-
return this._webGLVersion;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Gets or sets the relative url used to load shaders if using the engine in non-minified mode
|
|
152
|
-
*/
|
|
153
|
-
static get ShadersRepository() {
|
|
154
|
-
return Effect.ShadersRepository;
|
|
155
|
-
}
|
|
156
|
-
static set ShadersRepository(value) {
|
|
157
|
-
Effect.ShadersRepository = value;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Gets a boolean indicating that the engine supports uniform buffers
|
|
161
|
-
* @see https://doc.babylonjs.com/setup/support/webGL2#uniform-buffer-objets
|
|
162
|
-
*/
|
|
163
|
-
get supportsUniformBuffers() {
|
|
164
|
-
return this.webGLVersion > 1 && !this.disableUniformBuffers;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Gets a boolean indicating that only power of 2 textures are supported
|
|
168
|
-
* Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
|
|
169
|
-
*/
|
|
170
|
-
get needPOTTextures() {
|
|
171
|
-
return this._webGLVersion < 2 || this.forcePOTTextures;
|
|
172
|
-
}
|
|
173
|
-
get _supportsHardwareTextureRescaling() {
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* sets the object from which width and height will be taken from when getting render width and height
|
|
178
|
-
* Will fallback to the gl object
|
|
179
|
-
* @param dimensions the framebuffer width and height that will be used.
|
|
180
|
-
*/
|
|
181
|
-
set framebufferDimensionsObject(dimensions) {
|
|
182
|
-
this._framebufferDimensionsObject = dimensions;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Creates a new snapshot at the next frame using the current snapshotRenderingMode
|
|
186
|
-
*/
|
|
187
|
-
snapshotRenderingReset() {
|
|
188
|
-
this.snapshotRendering = false;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Creates a new engine
|
|
192
|
-
* @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which already used the WebGL context
|
|
193
|
-
* @param antialias defines whether anti-aliasing should be enabled (default value is "undefined", meaning that the browser may or may not enable it)
|
|
194
|
-
* @param options defines further options to be sent to the getContext() function
|
|
195
|
-
* @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
|
|
196
|
-
*/
|
|
197
|
-
constructor(canvasOrContext, antialias, options, adaptToDeviceRatio) {
|
|
198
|
-
options = options || {};
|
|
199
|
-
super(antialias ?? options.antialias, options, adaptToDeviceRatio);
|
|
200
|
-
/** @internal */
|
|
201
|
-
this._name = "WebGL";
|
|
202
|
-
/**
|
|
203
|
-
* Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
|
|
204
|
-
*/
|
|
205
|
-
this.forcePOTTextures = false;
|
|
206
|
-
/** Gets or sets a boolean indicating if the engine should validate programs after compilation */
|
|
207
|
-
this.validateShaderPrograms = false;
|
|
208
|
-
/**
|
|
209
|
-
* Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
|
|
210
|
-
*/
|
|
211
|
-
this.disableUniformBuffers = false;
|
|
212
|
-
/** @internal */
|
|
213
|
-
this._webGLVersion = 1.0;
|
|
214
|
-
this._vertexAttribArraysEnabled = [];
|
|
215
|
-
this._uintIndicesCurrentlySet = false;
|
|
216
|
-
this._currentBoundBuffer = new Array();
|
|
217
|
-
/** @internal */
|
|
218
|
-
this._currentFramebuffer = null;
|
|
219
|
-
/** @internal */
|
|
220
|
-
this._dummyFramebuffer = null;
|
|
221
|
-
this._currentBufferPointers = new Array();
|
|
222
|
-
this._currentInstanceLocations = new Array();
|
|
223
|
-
this._currentInstanceBuffers = new Array();
|
|
224
|
-
this._vaoRecordInProgress = false;
|
|
225
|
-
this._mustWipeVertexAttributes = false;
|
|
226
|
-
this._nextFreeTextureSlots = new Array();
|
|
227
|
-
this._maxSimultaneousTextures = 0;
|
|
228
|
-
this._maxMSAASamplesOverride = null;
|
|
229
|
-
this._unpackFlipYCached = null;
|
|
230
|
-
/**
|
|
231
|
-
* In case you are sharing the context with other applications, it might
|
|
232
|
-
* be interested to not cache the unpack flip y state to ensure a consistent
|
|
233
|
-
* value would be set.
|
|
234
|
-
*/
|
|
235
|
-
this.enableUnpackFlipYCached = true;
|
|
236
|
-
/**
|
|
237
|
-
* @internal
|
|
238
|
-
*/
|
|
239
|
-
this._boundUniforms = {};
|
|
240
|
-
if (!canvasOrContext) {
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
let canvas = null;
|
|
244
|
-
if (canvasOrContext.getContext) {
|
|
245
|
-
canvas = canvasOrContext;
|
|
246
|
-
if (options.preserveDrawingBuffer === undefined) {
|
|
247
|
-
options.preserveDrawingBuffer = false;
|
|
248
|
-
}
|
|
249
|
-
if (options.xrCompatible === undefined) {
|
|
250
|
-
options.xrCompatible = false;
|
|
251
|
-
}
|
|
252
|
-
// Exceptions
|
|
253
|
-
if (navigator && navigator.userAgent) {
|
|
254
|
-
this._setupMobileChecks();
|
|
255
|
-
const ua = navigator.userAgent;
|
|
256
|
-
for (const exception of ThinEngine.ExceptionList) {
|
|
257
|
-
const key = exception.key;
|
|
258
|
-
const targets = exception.targets;
|
|
259
|
-
const check = new RegExp(key);
|
|
260
|
-
if (check.test(ua)) {
|
|
261
|
-
if (exception.capture && exception.captureConstraint) {
|
|
262
|
-
const capture = exception.capture;
|
|
263
|
-
const constraint = exception.captureConstraint;
|
|
264
|
-
const regex = new RegExp(capture);
|
|
265
|
-
const matches = regex.exec(ua);
|
|
266
|
-
if (matches && matches.length > 0) {
|
|
267
|
-
const capturedValue = parseInt(matches[matches.length - 1]);
|
|
268
|
-
if (capturedValue >= constraint) {
|
|
269
|
-
continue;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
for (const target of targets) {
|
|
274
|
-
switch (target) {
|
|
275
|
-
case "uniformBuffer":
|
|
276
|
-
this.disableUniformBuffers = true;
|
|
277
|
-
break;
|
|
278
|
-
case "vao":
|
|
279
|
-
this.disableVertexArrayObjects = true;
|
|
280
|
-
break;
|
|
281
|
-
case "antialias":
|
|
282
|
-
options.antialias = false;
|
|
283
|
-
break;
|
|
284
|
-
case "maxMSAASamples":
|
|
285
|
-
this._maxMSAASamplesOverride = 1;
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
// Context lost
|
|
293
|
-
if (!this._doNotHandleContextLost) {
|
|
294
|
-
this._onContextLost = (evt) => {
|
|
295
|
-
evt.preventDefault();
|
|
296
|
-
this._contextWasLost = true;
|
|
297
|
-
deleteStateObject(this._gl);
|
|
298
|
-
Logger.Warn("WebGL context lost.");
|
|
299
|
-
this.onContextLostObservable.notifyObservers(this);
|
|
300
|
-
};
|
|
301
|
-
this._onContextRestored = () => {
|
|
302
|
-
this._restoreEngineAfterContextLost(() => this._initGLContext());
|
|
303
|
-
};
|
|
304
|
-
canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
|
|
305
|
-
options.powerPreference = options.powerPreference || "high-performance";
|
|
306
|
-
}
|
|
307
|
-
else {
|
|
308
|
-
this._onContextLost = () => {
|
|
309
|
-
deleteStateObject(this._gl);
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
canvas.addEventListener("webglcontextlost", this._onContextLost, false);
|
|
313
|
-
if (this._badDesktopOS) {
|
|
314
|
-
options.xrCompatible = false;
|
|
315
|
-
}
|
|
316
|
-
// GL
|
|
317
|
-
if (!options.disableWebGL2Support) {
|
|
318
|
-
try {
|
|
319
|
-
this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
|
|
320
|
-
if (this._gl) {
|
|
321
|
-
this._webGLVersion = 2.0;
|
|
322
|
-
this._shaderPlatformName = "WEBGL2";
|
|
323
|
-
// Prevent weird browsers to lie (yeah that happens!)
|
|
324
|
-
if (!this._gl.deleteQuery) {
|
|
325
|
-
this._webGLVersion = 1.0;
|
|
326
|
-
this._shaderPlatformName = "WEBGL1";
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
catch (e) {
|
|
331
|
-
// Do nothing
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
if (!this._gl) {
|
|
335
|
-
if (!canvas) {
|
|
336
|
-
throw new Error("The provided canvas is null or undefined.");
|
|
337
|
-
}
|
|
338
|
-
try {
|
|
339
|
-
this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
|
|
340
|
-
}
|
|
341
|
-
catch (e) {
|
|
342
|
-
throw new Error("WebGL not supported");
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
if (!this._gl) {
|
|
346
|
-
throw new Error("WebGL not supported");
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
else {
|
|
350
|
-
this._gl = canvasOrContext;
|
|
351
|
-
canvas = this._gl.canvas;
|
|
352
|
-
if (this._gl.renderbufferStorageMultisample) {
|
|
353
|
-
this._webGLVersion = 2.0;
|
|
354
|
-
this._shaderPlatformName = "WEBGL2";
|
|
355
|
-
}
|
|
356
|
-
else {
|
|
357
|
-
this._shaderPlatformName = "WEBGL1";
|
|
358
|
-
}
|
|
359
|
-
const attributes = this._gl.getContextAttributes();
|
|
360
|
-
if (attributes) {
|
|
361
|
-
options.stencil = attributes.stencil;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
this._sharedInit(canvas);
|
|
365
|
-
// Ensures a consistent color space unpacking of textures cross browser.
|
|
366
|
-
this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);
|
|
367
|
-
if (options.useHighPrecisionFloats !== undefined) {
|
|
368
|
-
this._highPrecisionShadersAllowed = options.useHighPrecisionFloats;
|
|
369
|
-
}
|
|
370
|
-
this.resize();
|
|
371
|
-
this._initGLContext();
|
|
372
|
-
this._initFeatures();
|
|
373
|
-
// Prepare buffer pointers
|
|
374
|
-
for (let i = 0; i < this._caps.maxVertexAttribs; i++) {
|
|
375
|
-
this._currentBufferPointers[i] = new BufferPointer();
|
|
376
|
-
}
|
|
377
|
-
// Shader processor
|
|
378
|
-
this._shaderProcessor = this.webGLVersion > 1 ? new WebGL2ShaderProcessor() : new WebGLShaderProcessor();
|
|
379
|
-
// Starting with iOS 14, we can trust the browser
|
|
380
|
-
// let matches = navigator.userAgent.match(/Version\/(\d+)/);
|
|
381
|
-
// if (matches && matches.length === 2) {
|
|
382
|
-
// if (parseInt(matches[1]) >= 14) {
|
|
383
|
-
// this._badOS = false;
|
|
384
|
-
// }
|
|
385
|
-
// }
|
|
386
|
-
const versionToLog = `Babylon.js v${ThinEngine.Version}`;
|
|
387
|
-
Logger.Log(versionToLog + ` - ${this.description}`);
|
|
388
|
-
// Check setAttribute in case of workers
|
|
389
|
-
if (this._renderingCanvas && this._renderingCanvas.setAttribute) {
|
|
390
|
-
this._renderingCanvas.setAttribute("data-engine", versionToLog);
|
|
391
|
-
}
|
|
392
|
-
const stateObject = getStateObject(this._gl);
|
|
393
|
-
// update state object with the current engine state
|
|
394
|
-
stateObject.validateShaderPrograms = this.validateShaderPrograms;
|
|
395
|
-
stateObject.parallelShaderCompile = this._caps.parallelShaderCompile;
|
|
396
|
-
}
|
|
397
|
-
_clearEmptyResources() {
|
|
398
|
-
this._dummyFramebuffer = null;
|
|
399
|
-
super._clearEmptyResources();
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* @internal
|
|
403
|
-
*/
|
|
404
|
-
_getShaderProcessingContext(shaderLanguage) {
|
|
405
|
-
return null;
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Gets a boolean indicating if all created effects are ready
|
|
409
|
-
* @returns true if all effects are ready
|
|
410
|
-
*/
|
|
411
|
-
areAllEffectsReady() {
|
|
412
|
-
for (const key in this._compiledEffects) {
|
|
413
|
-
const effect = this._compiledEffects[key];
|
|
414
|
-
if (!effect.isReady()) {
|
|
415
|
-
return false;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
return true;
|
|
419
|
-
}
|
|
420
|
-
_initGLContext() {
|
|
421
|
-
// Caps
|
|
422
|
-
this._caps = {
|
|
423
|
-
maxTexturesImageUnits: this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),
|
|
424
|
-
maxCombinedTexturesImageUnits: this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
|
|
425
|
-
maxVertexTextureImageUnits: this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
|
|
426
|
-
maxTextureSize: this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),
|
|
427
|
-
maxSamples: this._webGLVersion > 1 ? this._gl.getParameter(this._gl.MAX_SAMPLES) : 1,
|
|
428
|
-
maxCubemapTextureSize: this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),
|
|
429
|
-
maxRenderTextureSize: this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),
|
|
430
|
-
maxVertexAttribs: this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),
|
|
431
|
-
maxVaryingVectors: this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),
|
|
432
|
-
maxFragmentUniformVectors: this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),
|
|
433
|
-
maxVertexUniformVectors: this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),
|
|
434
|
-
parallelShaderCompile: this._gl.getExtension("KHR_parallel_shader_compile") || undefined,
|
|
435
|
-
standardDerivatives: this._webGLVersion > 1 || this._gl.getExtension("OES_standard_derivatives") !== null,
|
|
436
|
-
maxAnisotropy: 1,
|
|
437
|
-
astc: this._gl.getExtension("WEBGL_compressed_texture_astc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),
|
|
438
|
-
bptc: this._gl.getExtension("EXT_texture_compression_bptc") || this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),
|
|
439
|
-
s3tc: this._gl.getExtension("WEBGL_compressed_texture_s3tc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),
|
|
440
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
441
|
-
s3tc_srgb: this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),
|
|
442
|
-
pvrtc: this._gl.getExtension("WEBGL_compressed_texture_pvrtc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),
|
|
443
|
-
etc1: this._gl.getExtension("WEBGL_compressed_texture_etc1") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),
|
|
444
|
-
etc2: this._gl.getExtension("WEBGL_compressed_texture_etc") ||
|
|
445
|
-
this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc") ||
|
|
446
|
-
this._gl.getExtension("WEBGL_compressed_texture_es3_0"), // also a requirement of OpenGL ES 3
|
|
447
|
-
textureAnisotropicFilterExtension: this._gl.getExtension("EXT_texture_filter_anisotropic") ||
|
|
448
|
-
this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic") ||
|
|
449
|
-
this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),
|
|
450
|
-
uintIndices: this._webGLVersion > 1 || this._gl.getExtension("OES_element_index_uint") !== null,
|
|
451
|
-
fragmentDepthSupported: this._webGLVersion > 1 || this._gl.getExtension("EXT_frag_depth") !== null,
|
|
452
|
-
highPrecisionShaderSupported: false,
|
|
453
|
-
timerQuery: this._gl.getExtension("EXT_disjoint_timer_query_webgl2") || this._gl.getExtension("EXT_disjoint_timer_query"),
|
|
454
|
-
supportOcclusionQuery: this._webGLVersion > 1,
|
|
455
|
-
canUseTimestampForTimerQuery: false,
|
|
456
|
-
drawBuffersExtension: false,
|
|
457
|
-
maxMSAASamples: 1,
|
|
458
|
-
colorBufferFloat: !!(this._webGLVersion > 1 && this._gl.getExtension("EXT_color_buffer_float")),
|
|
459
|
-
supportFloatTexturesResolve: false,
|
|
460
|
-
rg11b10ufColorRenderable: false,
|
|
461
|
-
colorBufferHalfFloat: !!(this._webGLVersion > 1 && this._gl.getExtension("EXT_color_buffer_half_float")),
|
|
462
|
-
textureFloat: this._webGLVersion > 1 || this._gl.getExtension("OES_texture_float") ? true : false,
|
|
463
|
-
textureHalfFloat: this._webGLVersion > 1 || this._gl.getExtension("OES_texture_half_float") ? true : false,
|
|
464
|
-
textureHalfFloatRender: false,
|
|
465
|
-
textureFloatLinearFiltering: false,
|
|
466
|
-
textureFloatRender: false,
|
|
467
|
-
textureHalfFloatLinearFiltering: false,
|
|
468
|
-
vertexArrayObject: false,
|
|
469
|
-
instancedArrays: false,
|
|
470
|
-
textureLOD: this._webGLVersion > 1 || this._gl.getExtension("EXT_shader_texture_lod") ? true : false,
|
|
471
|
-
texelFetch: this._webGLVersion !== 1,
|
|
472
|
-
blendMinMax: false,
|
|
473
|
-
multiview: this._gl.getExtension("OVR_multiview2"),
|
|
474
|
-
oculusMultiview: this._gl.getExtension("OCULUS_multiview"),
|
|
475
|
-
depthTextureExtension: false,
|
|
476
|
-
canUseGLInstanceID: this._webGLVersion > 1,
|
|
477
|
-
canUseGLVertexID: this._webGLVersion > 1,
|
|
478
|
-
supportComputeShaders: false,
|
|
479
|
-
supportSRGBBuffers: false,
|
|
480
|
-
supportTransformFeedbacks: this._webGLVersion > 1,
|
|
481
|
-
textureMaxLevel: this._webGLVersion > 1,
|
|
482
|
-
texture2DArrayMaxLayerCount: this._webGLVersion > 1 ? this._gl.getParameter(this._gl.MAX_ARRAY_TEXTURE_LAYERS) : 128,
|
|
483
|
-
disableMorphTargetTexture: false,
|
|
484
|
-
textureNorm16: this._gl.getExtension("EXT_texture_norm16") ? true : false,
|
|
485
|
-
};
|
|
486
|
-
this._caps.supportFloatTexturesResolve = this._caps.colorBufferFloat;
|
|
487
|
-
this._caps.rg11b10ufColorRenderable = this._caps.colorBufferFloat;
|
|
488
|
-
// Infos
|
|
489
|
-
this._glVersion = this._gl.getParameter(this._gl.VERSION);
|
|
490
|
-
const rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
|
|
491
|
-
if (rendererInfo != null) {
|
|
492
|
-
this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
|
|
493
|
-
this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
|
|
494
|
-
}
|
|
495
|
-
if (!this._glVendor) {
|
|
496
|
-
this._glVendor = this._gl.getParameter(this._gl.VENDOR) || "Unknown vendor";
|
|
497
|
-
}
|
|
498
|
-
if (!this._glRenderer) {
|
|
499
|
-
this._glRenderer = this._gl.getParameter(this._gl.RENDERER) || "Unknown renderer";
|
|
500
|
-
}
|
|
501
|
-
// Constants
|
|
502
|
-
if (this._gl.HALF_FLOAT_OES !== 0x8d61) {
|
|
503
|
-
this._gl.HALF_FLOAT_OES = 0x8d61; // Half floating-point type (16-bit).
|
|
504
|
-
}
|
|
505
|
-
if (this._gl.RGBA16F !== 0x881a) {
|
|
506
|
-
this._gl.RGBA16F = 0x881a; // RGBA 16-bit floating-point color-renderable internal sized format.
|
|
507
|
-
}
|
|
508
|
-
if (this._gl.RGBA32F !== 0x8814) {
|
|
509
|
-
this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
|
|
510
|
-
}
|
|
511
|
-
if (this._gl.DEPTH24_STENCIL8 !== 35056) {
|
|
512
|
-
this._gl.DEPTH24_STENCIL8 = 35056;
|
|
513
|
-
}
|
|
514
|
-
// Extensions
|
|
515
|
-
if (this._caps.timerQuery) {
|
|
516
|
-
if (this._webGLVersion === 1) {
|
|
517
|
-
this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
|
|
518
|
-
}
|
|
519
|
-
// WebGLQuery casted to number to avoid TS error
|
|
520
|
-
this._caps.canUseTimestampForTimerQuery = (this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) ?? 0) > 0;
|
|
521
|
-
}
|
|
522
|
-
this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension
|
|
523
|
-
? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT)
|
|
524
|
-
: 0;
|
|
525
|
-
this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension("OES_texture_float_linear") ? true : false;
|
|
526
|
-
this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
|
|
527
|
-
this._caps.textureHalfFloatLinearFiltering =
|
|
528
|
-
this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension("OES_texture_half_float_linear")) ? true : false;
|
|
529
|
-
if (this._caps.textureNorm16) {
|
|
530
|
-
this._gl.R16_EXT = 0x822a;
|
|
531
|
-
this._gl.RG16_EXT = 0x822c;
|
|
532
|
-
this._gl.RGB16_EXT = 0x8054;
|
|
533
|
-
this._gl.RGBA16_EXT = 0x805b;
|
|
534
|
-
this._gl.R16_SNORM_EXT = 0x8f98;
|
|
535
|
-
this._gl.RG16_SNORM_EXT = 0x8f99;
|
|
536
|
-
this._gl.RGB16_SNORM_EXT = 0x8f9a;
|
|
537
|
-
this._gl.RGBA16_SNORM_EXT = 0x8f9b;
|
|
538
|
-
}
|
|
539
|
-
// Compressed formats
|
|
540
|
-
if (this._caps.astc) {
|
|
541
|
-
this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
|
|
542
|
-
}
|
|
543
|
-
if (this._caps.bptc) {
|
|
544
|
-
this._gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = this._caps.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;
|
|
545
|
-
}
|
|
546
|
-
if (this._caps.s3tc_srgb) {
|
|
547
|
-
this._gl.COMPRESSED_SRGB_S3TC_DXT1_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_S3TC_DXT1_EXT;
|
|
548
|
-
this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
|
|
549
|
-
this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
|
|
550
|
-
}
|
|
551
|
-
if (this._caps.etc2) {
|
|
552
|
-
this._gl.COMPRESSED_SRGB8_ETC2 = this._caps.etc2.COMPRESSED_SRGB8_ETC2;
|
|
553
|
-
this._gl.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = this._caps.etc2.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
|
|
554
|
-
}
|
|
555
|
-
// Checks if some of the format renders first to allow the use of webgl inspector.
|
|
556
|
-
if (this._webGLVersion > 1) {
|
|
557
|
-
if (this._gl.HALF_FLOAT_OES !== 0x140b) {
|
|
558
|
-
this._gl.HALF_FLOAT_OES = 0x140b;
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
|
|
562
|
-
// Draw buffers
|
|
563
|
-
if (this._webGLVersion > 1) {
|
|
564
|
-
this._caps.drawBuffersExtension = true;
|
|
565
|
-
this._caps.maxMSAASamples = this._maxMSAASamplesOverride !== null ? this._maxMSAASamplesOverride : this._gl.getParameter(this._gl.MAX_SAMPLES);
|
|
566
|
-
this._caps.maxDrawBuffers = this._gl.getParameter(this._gl.MAX_DRAW_BUFFERS);
|
|
567
|
-
}
|
|
568
|
-
else {
|
|
569
|
-
const drawBuffersExtension = this._gl.getExtension("WEBGL_draw_buffers");
|
|
570
|
-
if (drawBuffersExtension !== null) {
|
|
571
|
-
this._caps.drawBuffersExtension = true;
|
|
572
|
-
this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
|
|
573
|
-
this._caps.maxDrawBuffers = this._gl.getParameter(drawBuffersExtension.MAX_DRAW_BUFFERS_WEBGL);
|
|
574
|
-
this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
|
|
575
|
-
for (let i = 0; i < 16; i++) {
|
|
576
|
-
this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
// Depth Texture
|
|
581
|
-
if (this._webGLVersion > 1) {
|
|
582
|
-
this._caps.depthTextureExtension = true;
|
|
583
|
-
}
|
|
584
|
-
else {
|
|
585
|
-
const depthTextureExtension = this._gl.getExtension("WEBGL_depth_texture");
|
|
586
|
-
if (depthTextureExtension != null) {
|
|
587
|
-
this._caps.depthTextureExtension = true;
|
|
588
|
-
this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
// Vertex array object
|
|
592
|
-
if (this.disableVertexArrayObjects) {
|
|
593
|
-
this._caps.vertexArrayObject = false;
|
|
594
|
-
}
|
|
595
|
-
else if (this._webGLVersion > 1) {
|
|
596
|
-
this._caps.vertexArrayObject = true;
|
|
597
|
-
}
|
|
598
|
-
else {
|
|
599
|
-
const vertexArrayObjectExtension = this._gl.getExtension("OES_vertex_array_object");
|
|
600
|
-
if (vertexArrayObjectExtension != null) {
|
|
601
|
-
this._caps.vertexArrayObject = true;
|
|
602
|
-
this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
|
|
603
|
-
this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
|
|
604
|
-
this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
// Instances count
|
|
608
|
-
if (this._webGLVersion > 1) {
|
|
609
|
-
this._caps.instancedArrays = true;
|
|
610
|
-
}
|
|
611
|
-
else {
|
|
612
|
-
const instanceExtension = this._gl.getExtension("ANGLE_instanced_arrays");
|
|
613
|
-
if (instanceExtension != null) {
|
|
614
|
-
this._caps.instancedArrays = true;
|
|
615
|
-
this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
|
|
616
|
-
this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
|
|
617
|
-
this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
|
|
618
|
-
}
|
|
619
|
-
else {
|
|
620
|
-
this._caps.instancedArrays = false;
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
if (this._gl.getShaderPrecisionFormat) {
|
|
624
|
-
const vertexhighp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
|
|
625
|
-
const fragmenthighp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
|
|
626
|
-
if (vertexhighp && fragmenthighp) {
|
|
627
|
-
this._caps.highPrecisionShaderSupported = vertexhighp.precision !== 0 && fragmenthighp.precision !== 0;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
if (this._webGLVersion > 1) {
|
|
631
|
-
this._caps.blendMinMax = true;
|
|
632
|
-
}
|
|
633
|
-
else {
|
|
634
|
-
const blendMinMaxExtension = this._gl.getExtension("EXT_blend_minmax");
|
|
635
|
-
if (blendMinMaxExtension != null) {
|
|
636
|
-
this._caps.blendMinMax = true;
|
|
637
|
-
this._gl.MAX = blendMinMaxExtension.MAX_EXT;
|
|
638
|
-
this._gl.MIN = blendMinMaxExtension.MIN_EXT;
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
// sRGB buffers
|
|
642
|
-
// only run this if not already set to true (in the constructor, for example)
|
|
643
|
-
if (!this._caps.supportSRGBBuffers) {
|
|
644
|
-
if (this._webGLVersion > 1) {
|
|
645
|
-
this._caps.supportSRGBBuffers = true;
|
|
646
|
-
this._glSRGBExtensionValues = {
|
|
647
|
-
SRGB: WebGL2RenderingContext.SRGB,
|
|
648
|
-
SRGB8: WebGL2RenderingContext.SRGB8,
|
|
649
|
-
SRGB8_ALPHA8: WebGL2RenderingContext.SRGB8_ALPHA8,
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
|
-
else {
|
|
653
|
-
const sRGBExtension = this._gl.getExtension("EXT_sRGB");
|
|
654
|
-
if (sRGBExtension != null) {
|
|
655
|
-
this._caps.supportSRGBBuffers = true;
|
|
656
|
-
this._glSRGBExtensionValues = {
|
|
657
|
-
SRGB: sRGBExtension.SRGB_EXT,
|
|
658
|
-
SRGB8: sRGBExtension.SRGB_ALPHA_EXT,
|
|
659
|
-
SRGB8_ALPHA8: sRGBExtension.SRGB_ALPHA_EXT,
|
|
660
|
-
};
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
// take into account the forced state that was provided in options
|
|
664
|
-
if (this._creationOptions) {
|
|
665
|
-
const forceSRGBBufferSupportState = this._creationOptions.forceSRGBBufferSupportState;
|
|
666
|
-
if (forceSRGBBufferSupportState !== undefined) {
|
|
667
|
-
this._caps.supportSRGBBuffers = this._caps.supportSRGBBuffers && forceSRGBBufferSupportState;
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
// Depth buffer
|
|
672
|
-
this._depthCullingState.depthTest = true;
|
|
673
|
-
this._depthCullingState.depthFunc = this._gl.LEQUAL;
|
|
674
|
-
this._depthCullingState.depthMask = true;
|
|
675
|
-
// Texture maps
|
|
676
|
-
this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
|
|
677
|
-
for (let slot = 0; slot < this._maxSimultaneousTextures; slot++) {
|
|
678
|
-
this._nextFreeTextureSlots.push(slot);
|
|
679
|
-
}
|
|
680
|
-
if (this._glRenderer === "Mali-G72") {
|
|
681
|
-
// Overcome a bug when using a texture to store morph targets on Mali-G72
|
|
682
|
-
this._caps.disableMorphTargetTexture = true;
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
_initFeatures() {
|
|
686
|
-
this._features = {
|
|
687
|
-
forceBitmapOverHTMLImageElement: typeof HTMLImageElement === "undefined",
|
|
688
|
-
supportRenderAndCopyToLodForFloatTextures: this._webGLVersion !== 1,
|
|
689
|
-
supportDepthStencilTexture: this._webGLVersion !== 1,
|
|
690
|
-
supportShadowSamplers: this._webGLVersion !== 1,
|
|
691
|
-
uniformBufferHardCheckMatrix: false,
|
|
692
|
-
allowTexturePrefiltering: this._webGLVersion !== 1,
|
|
693
|
-
trackUbosInFrame: false,
|
|
694
|
-
checkUbosContentBeforeUpload: false,
|
|
695
|
-
supportCSM: this._webGLVersion !== 1,
|
|
696
|
-
basisNeedsPOT: this._webGLVersion === 1,
|
|
697
|
-
support3DTextures: this._webGLVersion !== 1,
|
|
698
|
-
needTypeSuffixInShaderConstants: this._webGLVersion !== 1,
|
|
699
|
-
supportMSAA: this._webGLVersion !== 1,
|
|
700
|
-
supportSSAO2: this._webGLVersion !== 1,
|
|
701
|
-
supportIBLShadows: this._webGLVersion !== 1,
|
|
702
|
-
supportExtendedTextureFormats: this._webGLVersion !== 1,
|
|
703
|
-
supportSwitchCaseInShader: this._webGLVersion !== 1,
|
|
704
|
-
supportSyncTextureRead: true,
|
|
705
|
-
needsInvertingBitmap: true,
|
|
706
|
-
useUBOBindingCache: true,
|
|
707
|
-
needShaderCodeInlining: false,
|
|
708
|
-
needToAlwaysBindUniformBuffers: false,
|
|
709
|
-
supportRenderPasses: false,
|
|
710
|
-
supportSpriteInstancing: true,
|
|
711
|
-
forceVertexBufferStrideAndOffsetMultiple4Bytes: false,
|
|
712
|
-
_checkNonFloatVertexBuffersDontRecreatePipelineContext: false,
|
|
713
|
-
_collectUbosUpdatedInFrame: false,
|
|
714
|
-
};
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* Gets version of the current webGL context
|
|
718
|
-
* Keep it for back compat - use version instead
|
|
719
|
-
*/
|
|
720
|
-
get webGLVersion() {
|
|
721
|
-
return this._webGLVersion;
|
|
722
|
-
}
|
|
723
|
-
/**
|
|
724
|
-
* Gets a string identifying the name of the class
|
|
725
|
-
* @returns "Engine" string
|
|
726
|
-
*/
|
|
727
|
-
getClassName() {
|
|
728
|
-
return "ThinEngine";
|
|
729
|
-
}
|
|
730
|
-
/** @internal */
|
|
731
|
-
_prepareWorkingCanvas() {
|
|
732
|
-
if (this._workingCanvas) {
|
|
733
|
-
return;
|
|
734
|
-
}
|
|
735
|
-
this._workingCanvas = this.createCanvas(1, 1);
|
|
736
|
-
const context = this._workingCanvas.getContext("2d");
|
|
737
|
-
if (context) {
|
|
738
|
-
this._workingContext = context;
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
/**
|
|
742
|
-
* Gets an object containing information about the current engine context
|
|
743
|
-
* @returns an object containing the vendor, the renderer and the version of the current engine context
|
|
744
|
-
*/
|
|
745
|
-
getInfo() {
|
|
746
|
-
return this.getGlInfo();
|
|
747
|
-
}
|
|
748
|
-
/**
|
|
749
|
-
* Gets an object containing information about the current webGL context
|
|
750
|
-
* @returns an object containing the vendor, the renderer and the version of the current webGL context
|
|
751
|
-
*/
|
|
752
|
-
getGlInfo() {
|
|
753
|
-
return {
|
|
754
|
-
vendor: this._glVendor,
|
|
755
|
-
renderer: this._glRenderer,
|
|
756
|
-
version: this._glVersion,
|
|
757
|
-
};
|
|
758
|
-
}
|
|
759
|
-
/**Gets driver info if available */
|
|
760
|
-
extractDriverInfo() {
|
|
761
|
-
const glInfo = this.getGlInfo();
|
|
762
|
-
if (glInfo && glInfo.renderer) {
|
|
763
|
-
return glInfo.renderer;
|
|
764
|
-
}
|
|
765
|
-
return "";
|
|
766
|
-
}
|
|
767
|
-
/**
|
|
768
|
-
* Gets the current render width
|
|
769
|
-
* @param useScreen defines if screen size must be used (or the current render target if any)
|
|
770
|
-
* @returns a number defining the current render width
|
|
771
|
-
*/
|
|
772
|
-
getRenderWidth(useScreen = false) {
|
|
773
|
-
if (!useScreen && this._currentRenderTarget) {
|
|
774
|
-
return this._currentRenderTarget.width;
|
|
775
|
-
}
|
|
776
|
-
return this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferWidth : this._gl.drawingBufferWidth;
|
|
777
|
-
}
|
|
778
|
-
/**
|
|
779
|
-
* Gets the current render height
|
|
780
|
-
* @param useScreen defines if screen size must be used (or the current render target if any)
|
|
781
|
-
* @returns a number defining the current render height
|
|
782
|
-
*/
|
|
783
|
-
getRenderHeight(useScreen = false) {
|
|
784
|
-
if (!useScreen && this._currentRenderTarget) {
|
|
785
|
-
return this._currentRenderTarget.height;
|
|
786
|
-
}
|
|
787
|
-
return this._framebufferDimensionsObject ? this._framebufferDimensionsObject.framebufferHeight : this._gl.drawingBufferHeight;
|
|
788
|
-
}
|
|
789
|
-
/**
|
|
790
|
-
* Clear the current render buffer or the current render target (if any is set up)
|
|
791
|
-
* @param color defines the color to use
|
|
792
|
-
* @param backBuffer defines if the back buffer must be cleared
|
|
793
|
-
* @param depth defines if the depth buffer must be cleared
|
|
794
|
-
* @param stencil defines if the stencil buffer must be cleared
|
|
795
|
-
*/
|
|
796
|
-
clear(color, backBuffer, depth, stencil = false) {
|
|
797
|
-
const useStencilGlobalOnly = this.stencilStateComposer.useStencilGlobalOnly;
|
|
798
|
-
this.stencilStateComposer.useStencilGlobalOnly = true; // make sure the stencil mask is coming from the global stencil and not from a material (effect) which would currently be in effect
|
|
799
|
-
this.applyStates();
|
|
800
|
-
this.stencilStateComposer.useStencilGlobalOnly = useStencilGlobalOnly;
|
|
801
|
-
let mode = 0;
|
|
802
|
-
if (backBuffer && color) {
|
|
803
|
-
let setBackBufferColor = true;
|
|
804
|
-
if (this._currentRenderTarget) {
|
|
805
|
-
const textureFormat = this._currentRenderTarget.texture?.format;
|
|
806
|
-
if (textureFormat === Constants.TEXTUREFORMAT_RED_INTEGER ||
|
|
807
|
-
textureFormat === Constants.TEXTUREFORMAT_RG_INTEGER ||
|
|
808
|
-
textureFormat === Constants.TEXTUREFORMAT_RGB_INTEGER ||
|
|
809
|
-
textureFormat === Constants.TEXTUREFORMAT_RGBA_INTEGER) {
|
|
810
|
-
const textureType = this._currentRenderTarget.texture?.type;
|
|
811
|
-
if (textureType === Constants.TEXTURETYPE_UNSIGNED_INTEGER || textureType === Constants.TEXTURETYPE_UNSIGNED_SHORT) {
|
|
812
|
-
ThinEngine._TempClearColorUint32[0] = color.r * 255;
|
|
813
|
-
ThinEngine._TempClearColorUint32[1] = color.g * 255;
|
|
814
|
-
ThinEngine._TempClearColorUint32[2] = color.b * 255;
|
|
815
|
-
ThinEngine._TempClearColorUint32[3] = color.a * 255;
|
|
816
|
-
this._gl.clearBufferuiv(this._gl.COLOR, 0, ThinEngine._TempClearColorUint32);
|
|
817
|
-
setBackBufferColor = false;
|
|
818
|
-
}
|
|
819
|
-
else {
|
|
820
|
-
ThinEngine._TempClearColorInt32[0] = color.r * 255;
|
|
821
|
-
ThinEngine._TempClearColorInt32[1] = color.g * 255;
|
|
822
|
-
ThinEngine._TempClearColorInt32[2] = color.b * 255;
|
|
823
|
-
ThinEngine._TempClearColorInt32[3] = color.a * 255;
|
|
824
|
-
this._gl.clearBufferiv(this._gl.COLOR, 0, ThinEngine._TempClearColorInt32);
|
|
825
|
-
setBackBufferColor = false;
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
if (setBackBufferColor) {
|
|
830
|
-
this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
|
|
831
|
-
mode |= this._gl.COLOR_BUFFER_BIT;
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
if (depth) {
|
|
835
|
-
if (this.useReverseDepthBuffer) {
|
|
836
|
-
this._depthCullingState.depthFunc = this._gl.GEQUAL;
|
|
837
|
-
this._gl.clearDepth(0.0);
|
|
838
|
-
}
|
|
839
|
-
else {
|
|
840
|
-
this._gl.clearDepth(1.0);
|
|
841
|
-
}
|
|
842
|
-
mode |= this._gl.DEPTH_BUFFER_BIT;
|
|
843
|
-
}
|
|
844
|
-
if (stencil) {
|
|
845
|
-
this._gl.clearStencil(0);
|
|
846
|
-
mode |= this._gl.STENCIL_BUFFER_BIT;
|
|
847
|
-
}
|
|
848
|
-
this._gl.clear(mode);
|
|
849
|
-
}
|
|
850
|
-
/**
|
|
851
|
-
* @internal
|
|
852
|
-
*/
|
|
853
|
-
_viewport(x, y, width, height) {
|
|
854
|
-
if (x !== this._viewportCached.x || y !== this._viewportCached.y || width !== this._viewportCached.z || height !== this._viewportCached.w) {
|
|
855
|
-
this._viewportCached.x = x;
|
|
856
|
-
this._viewportCached.y = y;
|
|
857
|
-
this._viewportCached.z = width;
|
|
858
|
-
this._viewportCached.w = height;
|
|
859
|
-
this._gl.viewport(x, y, width, height);
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
/**
|
|
863
|
-
* End the current frame
|
|
864
|
-
*/
|
|
865
|
-
endFrame() {
|
|
866
|
-
super.endFrame();
|
|
867
|
-
// Force a flush in case we are using a bad OS.
|
|
868
|
-
if (this._badOS) {
|
|
869
|
-
this.flushFramebuffer();
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
/**
|
|
873
|
-
* Gets the performance monitor attached to this engine
|
|
874
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#engineinstrumentation
|
|
875
|
-
*/
|
|
876
|
-
get performanceMonitor() {
|
|
877
|
-
throw new Error("Not Supported by ThinEngine");
|
|
878
|
-
}
|
|
879
|
-
/**
|
|
880
|
-
* Binds the frame buffer to the specified texture.
|
|
881
|
-
* @param rtWrapper The render target wrapper to render to
|
|
882
|
-
* @param faceIndex The face of the texture to render to in case of cube texture and if the render target wrapper is not a multi render target
|
|
883
|
-
* @param requiredWidth The width of the target to render to
|
|
884
|
-
* @param requiredHeight The height of the target to render to
|
|
885
|
-
* @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
|
|
886
|
-
* @param lodLevel Defines the lod level to bind to the frame buffer
|
|
887
|
-
* @param layer Defines the 2d array index to bind to the frame buffer if the render target wrapper is not a multi render target
|
|
888
|
-
*/
|
|
889
|
-
bindFramebuffer(rtWrapper, faceIndex = 0, requiredWidth, requiredHeight, forceFullscreenViewport, lodLevel = 0, layer = 0) {
|
|
890
|
-
const webglRTWrapper = rtWrapper;
|
|
891
|
-
if (this._currentRenderTarget) {
|
|
892
|
-
this.unBindFramebuffer(this._currentRenderTarget);
|
|
893
|
-
}
|
|
894
|
-
this._currentRenderTarget = rtWrapper;
|
|
895
|
-
this._bindUnboundFramebuffer(webglRTWrapper._framebuffer);
|
|
896
|
-
const gl = this._gl;
|
|
897
|
-
if (!rtWrapper.isMulti) {
|
|
898
|
-
if (rtWrapper.is2DArray || rtWrapper.is3D) {
|
|
899
|
-
gl.framebufferTextureLayer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, rtWrapper.texture._hardwareTexture?.underlyingResource, lodLevel, layer);
|
|
900
|
-
webglRTWrapper._currentLOD = lodLevel;
|
|
901
|
-
}
|
|
902
|
-
else if (rtWrapper.isCube) {
|
|
903
|
-
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, rtWrapper.texture._hardwareTexture?.underlyingResource, lodLevel);
|
|
904
|
-
}
|
|
905
|
-
else if (webglRTWrapper._currentLOD !== lodLevel) {
|
|
906
|
-
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, rtWrapper.texture._hardwareTexture?.underlyingResource, lodLevel);
|
|
907
|
-
webglRTWrapper._currentLOD = lodLevel;
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
const depthStencilTexture = rtWrapper._depthStencilTexture;
|
|
911
|
-
if (depthStencilTexture) {
|
|
912
|
-
if (rtWrapper.is3D) {
|
|
913
|
-
if (rtWrapper.texture.width !== depthStencilTexture.width ||
|
|
914
|
-
rtWrapper.texture.height !== depthStencilTexture.height ||
|
|
915
|
-
rtWrapper.texture.depth !== depthStencilTexture.depth) {
|
|
916
|
-
Logger.Warn("Depth/Stencil attachment for 3D target must have same dimensions as color attachment");
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
const attachment = rtWrapper._depthStencilTextureWithStencil ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;
|
|
920
|
-
if (rtWrapper.is2DArray || rtWrapper.is3D) {
|
|
921
|
-
gl.framebufferTextureLayer(gl.FRAMEBUFFER, attachment, depthStencilTexture._hardwareTexture?.underlyingResource, lodLevel, layer);
|
|
922
|
-
}
|
|
923
|
-
else if (rtWrapper.isCube) {
|
|
924
|
-
gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._hardwareTexture?.underlyingResource, lodLevel);
|
|
925
|
-
}
|
|
926
|
-
else {
|
|
927
|
-
gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, depthStencilTexture._hardwareTexture?.underlyingResource, lodLevel);
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
if (webglRTWrapper._MSAAFramebuffer) {
|
|
931
|
-
this._bindUnboundFramebuffer(webglRTWrapper._MSAAFramebuffer);
|
|
932
|
-
}
|
|
933
|
-
if (this._cachedViewport && !forceFullscreenViewport) {
|
|
934
|
-
this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
|
|
935
|
-
}
|
|
936
|
-
else {
|
|
937
|
-
if (!requiredWidth) {
|
|
938
|
-
requiredWidth = rtWrapper.width;
|
|
939
|
-
if (lodLevel) {
|
|
940
|
-
requiredWidth = requiredWidth / Math.pow(2, lodLevel);
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
if (!requiredHeight) {
|
|
944
|
-
requiredHeight = rtWrapper.height;
|
|
945
|
-
if (lodLevel) {
|
|
946
|
-
requiredHeight = requiredHeight / Math.pow(2, lodLevel);
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
this._viewport(0, 0, requiredWidth, requiredHeight);
|
|
950
|
-
}
|
|
951
|
-
this.wipeCaches();
|
|
952
|
-
}
|
|
953
|
-
/**
|
|
954
|
-
* Set various states to the webGL context
|
|
955
|
-
* @param culling defines culling state: true to enable culling, false to disable it
|
|
956
|
-
* @param zOffset defines the value to apply to zOffset (0 by default)
|
|
957
|
-
* @param force defines if states must be applied even if cache is up to date
|
|
958
|
-
* @param reverseSide defines if culling must be reversed (CCW if false, CW if true)
|
|
959
|
-
* @param cullBackFaces true to cull back faces, false to cull front faces (if culling is enabled)
|
|
960
|
-
* @param stencil stencil states to set
|
|
961
|
-
* @param zOffsetUnits defines the value to apply to zOffsetUnits (0 by default)
|
|
962
|
-
*/
|
|
963
|
-
setState(culling, zOffset = 0, force, reverseSide = false, cullBackFaces, stencil, zOffsetUnits = 0) {
|
|
964
|
-
// Culling
|
|
965
|
-
if (this._depthCullingState.cull !== culling || force) {
|
|
966
|
-
this._depthCullingState.cull = culling;
|
|
967
|
-
}
|
|
968
|
-
// Cull face
|
|
969
|
-
const cullFace = (this.cullBackFaces ?? cullBackFaces ?? true) ? this._gl.BACK : this._gl.FRONT;
|
|
970
|
-
if (this._depthCullingState.cullFace !== cullFace || force) {
|
|
971
|
-
this._depthCullingState.cullFace = cullFace;
|
|
972
|
-
}
|
|
973
|
-
// Z offset
|
|
974
|
-
this.setZOffset(zOffset);
|
|
975
|
-
this.setZOffsetUnits(zOffsetUnits);
|
|
976
|
-
// Front face
|
|
977
|
-
const frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
|
|
978
|
-
if (this._depthCullingState.frontFace !== frontFace || force) {
|
|
979
|
-
this._depthCullingState.frontFace = frontFace;
|
|
980
|
-
}
|
|
981
|
-
this._stencilStateComposer.stencilMaterial = stencil;
|
|
982
|
-
}
|
|
983
|
-
/**
|
|
984
|
-
* @internal
|
|
985
|
-
*/
|
|
986
|
-
_bindUnboundFramebuffer(framebuffer) {
|
|
987
|
-
if (this._currentFramebuffer !== framebuffer) {
|
|
988
|
-
this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
|
|
989
|
-
this._currentFramebuffer = framebuffer;
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
/** @internal */
|
|
993
|
-
_currentFrameBufferIsDefaultFrameBuffer() {
|
|
994
|
-
return this._currentFramebuffer === null;
|
|
995
|
-
}
|
|
996
|
-
/**
|
|
997
|
-
* Generates the mipmaps for a texture
|
|
998
|
-
* @param texture texture to generate the mipmaps for
|
|
999
|
-
*/
|
|
1000
|
-
generateMipmaps(texture) {
|
|
1001
|
-
const target = this._getTextureTarget(texture);
|
|
1002
|
-
this._bindTextureDirectly(target, texture, true);
|
|
1003
|
-
this._gl.generateMipmap(target);
|
|
1004
|
-
this._bindTextureDirectly(target, null);
|
|
1005
|
-
}
|
|
1006
|
-
/**
|
|
1007
|
-
* Unbind the current render target texture from the webGL context
|
|
1008
|
-
* @param texture defines the render target wrapper to unbind
|
|
1009
|
-
* @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
|
|
1010
|
-
* @param onBeforeUnbind defines a function which will be called before the effective unbind
|
|
1011
|
-
*/
|
|
1012
|
-
unBindFramebuffer(texture, disableGenerateMipMaps = false, onBeforeUnbind) {
|
|
1013
|
-
const webglRTWrapper = texture;
|
|
1014
|
-
this._currentRenderTarget = null;
|
|
1015
|
-
if (!webglRTWrapper.disableAutomaticMSAAResolve) {
|
|
1016
|
-
if (texture.isMulti) {
|
|
1017
|
-
this.resolveMultiFramebuffer(texture);
|
|
1018
|
-
}
|
|
1019
|
-
else {
|
|
1020
|
-
this.resolveFramebuffer(texture);
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
if (!disableGenerateMipMaps) {
|
|
1024
|
-
if (texture.isMulti) {
|
|
1025
|
-
this.generateMipMapsMultiFramebuffer(texture);
|
|
1026
|
-
}
|
|
1027
|
-
else {
|
|
1028
|
-
this.generateMipMapsFramebuffer(texture);
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
if (onBeforeUnbind) {
|
|
1032
|
-
if (webglRTWrapper._MSAAFramebuffer) {
|
|
1033
|
-
// Bind the correct framebuffer
|
|
1034
|
-
this._bindUnboundFramebuffer(webglRTWrapper._framebuffer);
|
|
1035
|
-
}
|
|
1036
|
-
onBeforeUnbind();
|
|
1037
|
-
}
|
|
1038
|
-
this._bindUnboundFramebuffer(null);
|
|
1039
|
-
}
|
|
1040
|
-
/**
|
|
1041
|
-
* Generates mipmaps for the texture of the (single) render target
|
|
1042
|
-
* @param texture The render target containing the texture to generate the mipmaps for
|
|
1043
|
-
*/
|
|
1044
|
-
generateMipMapsFramebuffer(texture) {
|
|
1045
|
-
if (!texture.isMulti && texture.texture?.generateMipMaps && !texture.isCube) {
|
|
1046
|
-
this.generateMipmaps(texture.texture);
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
/**
|
|
1050
|
-
* Resolves the MSAA texture of the (single) render target into its non-MSAA version.
|
|
1051
|
-
* Note that if "texture" is not a MSAA render target, no resolve is performed.
|
|
1052
|
-
* @param texture The render target texture containing the MSAA textures to resolve
|
|
1053
|
-
*/
|
|
1054
|
-
resolveFramebuffer(texture) {
|
|
1055
|
-
const rtWrapper = texture;
|
|
1056
|
-
const gl = this._gl;
|
|
1057
|
-
if (!rtWrapper._MSAAFramebuffer || rtWrapper.isMulti) {
|
|
1058
|
-
return;
|
|
1059
|
-
}
|
|
1060
|
-
let bufferBits = rtWrapper.resolveMSAAColors ? gl.COLOR_BUFFER_BIT : 0;
|
|
1061
|
-
bufferBits |= rtWrapper._generateDepthBuffer && rtWrapper.resolveMSAADepth ? gl.DEPTH_BUFFER_BIT : 0;
|
|
1062
|
-
bufferBits |= rtWrapper._generateStencilBuffer && rtWrapper.resolveMSAAStencil ? gl.STENCIL_BUFFER_BIT : 0;
|
|
1063
|
-
gl.bindFramebuffer(gl.READ_FRAMEBUFFER, rtWrapper._MSAAFramebuffer);
|
|
1064
|
-
gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, rtWrapper._framebuffer);
|
|
1065
|
-
gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, bufferBits, gl.NEAREST);
|
|
1066
|
-
}
|
|
1067
|
-
/**
|
|
1068
|
-
* Force a webGL flush (ie. a flush of all waiting webGL commands)
|
|
1069
|
-
*/
|
|
1070
|
-
flushFramebuffer() {
|
|
1071
|
-
this._gl.flush();
|
|
1072
|
-
}
|
|
1073
|
-
/**
|
|
1074
|
-
* Unbind the current render target and bind the default framebuffer
|
|
1075
|
-
*/
|
|
1076
|
-
restoreDefaultFramebuffer() {
|
|
1077
|
-
if (this._currentRenderTarget) {
|
|
1078
|
-
this.unBindFramebuffer(this._currentRenderTarget);
|
|
1079
|
-
}
|
|
1080
|
-
else {
|
|
1081
|
-
this._bindUnboundFramebuffer(null);
|
|
1082
|
-
}
|
|
1083
|
-
if (this._cachedViewport) {
|
|
1084
|
-
this.setViewport(this._cachedViewport);
|
|
1085
|
-
}
|
|
1086
|
-
this.wipeCaches();
|
|
1087
|
-
}
|
|
1088
|
-
// VBOs
|
|
1089
|
-
/** @internal */
|
|
1090
|
-
_resetVertexBufferBinding() {
|
|
1091
|
-
this.bindArrayBuffer(null);
|
|
1092
|
-
this._cachedVertexBuffers = null;
|
|
1093
|
-
}
|
|
1094
|
-
/**
|
|
1095
|
-
* Creates a vertex buffer
|
|
1096
|
-
* @param data the data or size for the vertex buffer
|
|
1097
|
-
* @param _updatable whether the buffer should be created as updatable
|
|
1098
|
-
* @param _label defines the label of the buffer (for debug purpose)
|
|
1099
|
-
* @returns the new WebGL static buffer
|
|
1100
|
-
*/
|
|
1101
|
-
createVertexBuffer(data, _updatable, _label) {
|
|
1102
|
-
return this._createVertexBuffer(data, this._gl.STATIC_DRAW);
|
|
1103
|
-
}
|
|
1104
|
-
_createVertexBuffer(data, usage) {
|
|
1105
|
-
const vbo = this._gl.createBuffer();
|
|
1106
|
-
if (!vbo) {
|
|
1107
|
-
throw new Error("Unable to create vertex buffer");
|
|
1108
|
-
}
|
|
1109
|
-
const dataBuffer = new WebGLDataBuffer(vbo);
|
|
1110
|
-
this.bindArrayBuffer(dataBuffer);
|
|
1111
|
-
if (typeof data !== "number") {
|
|
1112
|
-
if (data instanceof Array) {
|
|
1113
|
-
this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), usage);
|
|
1114
|
-
dataBuffer.capacity = data.length * 4;
|
|
1115
|
-
}
|
|
1116
|
-
else {
|
|
1117
|
-
this._gl.bufferData(this._gl.ARRAY_BUFFER, data, usage);
|
|
1118
|
-
dataBuffer.capacity = data.byteLength;
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
else {
|
|
1122
|
-
this._gl.bufferData(this._gl.ARRAY_BUFFER, new Uint8Array(data), usage);
|
|
1123
|
-
dataBuffer.capacity = data;
|
|
1124
|
-
}
|
|
1125
|
-
this._resetVertexBufferBinding();
|
|
1126
|
-
dataBuffer.references = 1;
|
|
1127
|
-
return dataBuffer;
|
|
1128
|
-
}
|
|
1129
|
-
/**
|
|
1130
|
-
* Creates a dynamic vertex buffer
|
|
1131
|
-
* @param data the data for the dynamic vertex buffer
|
|
1132
|
-
* @param _label defines the label of the buffer (for debug purpose)
|
|
1133
|
-
* @returns the new WebGL dynamic buffer
|
|
1134
|
-
*/
|
|
1135
|
-
createDynamicVertexBuffer(data, _label) {
|
|
1136
|
-
return this._createVertexBuffer(data, this._gl.DYNAMIC_DRAW);
|
|
1137
|
-
}
|
|
1138
|
-
_resetIndexBufferBinding() {
|
|
1139
|
-
this.bindIndexBuffer(null);
|
|
1140
|
-
this._cachedIndexBuffer = null;
|
|
1141
|
-
}
|
|
1142
|
-
/**
|
|
1143
|
-
* Creates a new index buffer
|
|
1144
|
-
* @param indices defines the content of the index buffer
|
|
1145
|
-
* @param updatable defines if the index buffer must be updatable
|
|
1146
|
-
* @param _label defines the label of the buffer (for debug purpose)
|
|
1147
|
-
* @returns a new webGL buffer
|
|
1148
|
-
*/
|
|
1149
|
-
createIndexBuffer(indices, updatable, _label) {
|
|
1150
|
-
const vbo = this._gl.createBuffer();
|
|
1151
|
-
const dataBuffer = new WebGLDataBuffer(vbo);
|
|
1152
|
-
if (!vbo) {
|
|
1153
|
-
throw new Error("Unable to create index buffer");
|
|
1154
|
-
}
|
|
1155
|
-
this.bindIndexBuffer(dataBuffer);
|
|
1156
|
-
const data = this._normalizeIndexData(indices);
|
|
1157
|
-
this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, data, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
|
|
1158
|
-
this._resetIndexBufferBinding();
|
|
1159
|
-
dataBuffer.references = 1;
|
|
1160
|
-
dataBuffer.is32Bits = data.BYTES_PER_ELEMENT === 4;
|
|
1161
|
-
return dataBuffer;
|
|
1162
|
-
}
|
|
1163
|
-
_normalizeIndexData(indices) {
|
|
1164
|
-
const bytesPerElement = indices.BYTES_PER_ELEMENT;
|
|
1165
|
-
if (bytesPerElement === 2) {
|
|
1166
|
-
return indices;
|
|
1167
|
-
}
|
|
1168
|
-
// Check 32 bit support
|
|
1169
|
-
if (this._caps.uintIndices) {
|
|
1170
|
-
if (indices instanceof Uint32Array) {
|
|
1171
|
-
return indices;
|
|
1172
|
-
}
|
|
1173
|
-
else {
|
|
1174
|
-
// number[] or Int32Array, check if 32 bit is necessary
|
|
1175
|
-
for (let index = 0; index < indices.length; index++) {
|
|
1176
|
-
if (indices[index] >= 65535) {
|
|
1177
|
-
return new Uint32Array(indices);
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
return new Uint16Array(indices);
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
// No 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
|
|
1184
|
-
return new Uint16Array(indices);
|
|
1185
|
-
}
|
|
1186
|
-
/**
|
|
1187
|
-
* Bind a webGL buffer to the webGL context
|
|
1188
|
-
* @param buffer defines the buffer to bind
|
|
1189
|
-
*/
|
|
1190
|
-
bindArrayBuffer(buffer) {
|
|
1191
|
-
if (!this._vaoRecordInProgress) {
|
|
1192
|
-
this._unbindVertexArrayObject();
|
|
1193
|
-
}
|
|
1194
|
-
this._bindBuffer(buffer, this._gl.ARRAY_BUFFER);
|
|
1195
|
-
}
|
|
1196
|
-
/**
|
|
1197
|
-
* Bind a specific block at a given index in a specific shader program
|
|
1198
|
-
* @param pipelineContext defines the pipeline context to use
|
|
1199
|
-
* @param blockName defines the block name
|
|
1200
|
-
* @param index defines the index where to bind the block
|
|
1201
|
-
*/
|
|
1202
|
-
bindUniformBlock(pipelineContext, blockName, index) {
|
|
1203
|
-
const program = pipelineContext.program;
|
|
1204
|
-
const uniformLocation = this._gl.getUniformBlockIndex(program, blockName);
|
|
1205
|
-
this._gl.uniformBlockBinding(program, uniformLocation, index);
|
|
1206
|
-
}
|
|
1207
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1208
|
-
bindIndexBuffer(buffer) {
|
|
1209
|
-
if (!this._vaoRecordInProgress) {
|
|
1210
|
-
this._unbindVertexArrayObject();
|
|
1211
|
-
}
|
|
1212
|
-
this._bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
|
|
1213
|
-
}
|
|
1214
|
-
_bindBuffer(buffer, target) {
|
|
1215
|
-
if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
|
|
1216
|
-
this._gl.bindBuffer(target, buffer ? buffer.underlyingResource : null);
|
|
1217
|
-
this._currentBoundBuffer[target] = buffer;
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
/**
|
|
1221
|
-
* update the bound buffer with the given data
|
|
1222
|
-
* @param data defines the data to update
|
|
1223
|
-
*/
|
|
1224
|
-
updateArrayBuffer(data) {
|
|
1225
|
-
this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
|
|
1226
|
-
}
|
|
1227
|
-
_vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset) {
|
|
1228
|
-
const pointer = this._currentBufferPointers[indx];
|
|
1229
|
-
if (!pointer) {
|
|
1230
|
-
return;
|
|
1231
|
-
}
|
|
1232
|
-
let changed = false;
|
|
1233
|
-
if (!pointer.active) {
|
|
1234
|
-
changed = true;
|
|
1235
|
-
pointer.active = true;
|
|
1236
|
-
pointer.index = indx;
|
|
1237
|
-
pointer.size = size;
|
|
1238
|
-
pointer.type = type;
|
|
1239
|
-
pointer.normalized = normalized;
|
|
1240
|
-
pointer.stride = stride;
|
|
1241
|
-
pointer.offset = offset;
|
|
1242
|
-
pointer.buffer = buffer;
|
|
1243
|
-
}
|
|
1244
|
-
else {
|
|
1245
|
-
if (pointer.buffer !== buffer) {
|
|
1246
|
-
pointer.buffer = buffer;
|
|
1247
|
-
changed = true;
|
|
1248
|
-
}
|
|
1249
|
-
if (pointer.size !== size) {
|
|
1250
|
-
pointer.size = size;
|
|
1251
|
-
changed = true;
|
|
1252
|
-
}
|
|
1253
|
-
if (pointer.type !== type) {
|
|
1254
|
-
pointer.type = type;
|
|
1255
|
-
changed = true;
|
|
1256
|
-
}
|
|
1257
|
-
if (pointer.normalized !== normalized) {
|
|
1258
|
-
pointer.normalized = normalized;
|
|
1259
|
-
changed = true;
|
|
1260
|
-
}
|
|
1261
|
-
if (pointer.stride !== stride) {
|
|
1262
|
-
pointer.stride = stride;
|
|
1263
|
-
changed = true;
|
|
1264
|
-
}
|
|
1265
|
-
if (pointer.offset !== offset) {
|
|
1266
|
-
pointer.offset = offset;
|
|
1267
|
-
changed = true;
|
|
1268
|
-
}
|
|
1269
|
-
}
|
|
1270
|
-
if (changed || this._vaoRecordInProgress) {
|
|
1271
|
-
this.bindArrayBuffer(buffer);
|
|
1272
|
-
if (type === this._gl.UNSIGNED_INT || type === this._gl.INT) {
|
|
1273
|
-
this._gl.vertexAttribIPointer(indx, size, type, stride, offset);
|
|
1274
|
-
}
|
|
1275
|
-
else {
|
|
1276
|
-
this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
/**
|
|
1281
|
-
* @internal
|
|
1282
|
-
*/
|
|
1283
|
-
_bindIndexBufferWithCache(indexBuffer) {
|
|
1284
|
-
if (indexBuffer == null) {
|
|
1285
|
-
return;
|
|
1286
|
-
}
|
|
1287
|
-
if (this._cachedIndexBuffer !== indexBuffer) {
|
|
1288
|
-
this._cachedIndexBuffer = indexBuffer;
|
|
1289
|
-
this.bindIndexBuffer(indexBuffer);
|
|
1290
|
-
this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
_bindVertexBuffersAttributes(vertexBuffers, effect, overrideVertexBuffers) {
|
|
1294
|
-
const attributes = effect.getAttributesNames();
|
|
1295
|
-
if (!this._vaoRecordInProgress) {
|
|
1296
|
-
this._unbindVertexArrayObject();
|
|
1297
|
-
}
|
|
1298
|
-
this.unbindAllAttributes();
|
|
1299
|
-
for (let index = 0; index < attributes.length; index++) {
|
|
1300
|
-
const order = effect.getAttributeLocation(index);
|
|
1301
|
-
if (order >= 0) {
|
|
1302
|
-
const ai = attributes[index];
|
|
1303
|
-
let vertexBuffer = null;
|
|
1304
|
-
if (overrideVertexBuffers) {
|
|
1305
|
-
vertexBuffer = overrideVertexBuffers[ai];
|
|
1306
|
-
}
|
|
1307
|
-
if (!vertexBuffer) {
|
|
1308
|
-
vertexBuffer = vertexBuffers[ai];
|
|
1309
|
-
}
|
|
1310
|
-
if (!vertexBuffer) {
|
|
1311
|
-
continue;
|
|
1312
|
-
}
|
|
1313
|
-
this._gl.enableVertexAttribArray(order);
|
|
1314
|
-
if (!this._vaoRecordInProgress) {
|
|
1315
|
-
this._vertexAttribArraysEnabled[order] = true;
|
|
1316
|
-
}
|
|
1317
|
-
const buffer = vertexBuffer.getBuffer();
|
|
1318
|
-
if (buffer) {
|
|
1319
|
-
this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
|
|
1320
|
-
if (vertexBuffer.getIsInstanced()) {
|
|
1321
|
-
this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
|
|
1322
|
-
if (!this._vaoRecordInProgress) {
|
|
1323
|
-
this._currentInstanceLocations.push(order);
|
|
1324
|
-
this._currentInstanceBuffers.push(buffer);
|
|
1325
|
-
}
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
}
|
|
1330
|
-
}
|
|
1331
|
-
/**
|
|
1332
|
-
* Records a vertex array object
|
|
1333
|
-
* @see https://doc.babylonjs.com/setup/support/webGL2#vertex-array-objects
|
|
1334
|
-
* @param vertexBuffers defines the list of vertex buffers to store
|
|
1335
|
-
* @param indexBuffer defines the index buffer to store
|
|
1336
|
-
* @param effect defines the effect to store
|
|
1337
|
-
* @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
|
|
1338
|
-
* @returns the new vertex array object
|
|
1339
|
-
*/
|
|
1340
|
-
recordVertexArrayObject(vertexBuffers, indexBuffer, effect, overrideVertexBuffers) {
|
|
1341
|
-
const vao = this._gl.createVertexArray();
|
|
1342
|
-
if (!vao) {
|
|
1343
|
-
throw new Error("Unable to create VAO");
|
|
1344
|
-
}
|
|
1345
|
-
this._vaoRecordInProgress = true;
|
|
1346
|
-
this._gl.bindVertexArray(vao);
|
|
1347
|
-
this._mustWipeVertexAttributes = true;
|
|
1348
|
-
this._bindVertexBuffersAttributes(vertexBuffers, effect, overrideVertexBuffers);
|
|
1349
|
-
this.bindIndexBuffer(indexBuffer);
|
|
1350
|
-
this._vaoRecordInProgress = false;
|
|
1351
|
-
this._gl.bindVertexArray(null);
|
|
1352
|
-
return vao;
|
|
1353
|
-
}
|
|
1354
|
-
/**
|
|
1355
|
-
* Bind a specific vertex array object
|
|
1356
|
-
* @see https://doc.babylonjs.com/setup/support/webGL2#vertex-array-objects
|
|
1357
|
-
* @param vertexArrayObject defines the vertex array object to bind
|
|
1358
|
-
* @param indexBuffer defines the index buffer to bind
|
|
1359
|
-
*/
|
|
1360
|
-
bindVertexArrayObject(vertexArrayObject, indexBuffer) {
|
|
1361
|
-
if (this._cachedVertexArrayObject !== vertexArrayObject) {
|
|
1362
|
-
this._cachedVertexArrayObject = vertexArrayObject;
|
|
1363
|
-
this._gl.bindVertexArray(vertexArrayObject);
|
|
1364
|
-
this._cachedVertexBuffers = null;
|
|
1365
|
-
this._cachedIndexBuffer = null;
|
|
1366
|
-
this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
|
|
1367
|
-
this._mustWipeVertexAttributes = true;
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
/**
|
|
1371
|
-
* Bind webGl buffers directly to the webGL context
|
|
1372
|
-
* @param vertexBuffer defines the vertex buffer to bind
|
|
1373
|
-
* @param indexBuffer defines the index buffer to bind
|
|
1374
|
-
* @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
|
|
1375
|
-
* @param vertexStrideSize defines the vertex stride of the vertex buffer
|
|
1376
|
-
* @param effect defines the effect associated with the vertex buffer
|
|
1377
|
-
*/
|
|
1378
|
-
bindBuffersDirectly(vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
|
|
1379
|
-
if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
|
|
1380
|
-
this._cachedVertexBuffers = vertexBuffer;
|
|
1381
|
-
this._cachedEffectForVertexBuffers = effect;
|
|
1382
|
-
const attributesCount = effect.getAttributesCount();
|
|
1383
|
-
this._unbindVertexArrayObject();
|
|
1384
|
-
this.unbindAllAttributes();
|
|
1385
|
-
let offset = 0;
|
|
1386
|
-
for (let index = 0; index < attributesCount; index++) {
|
|
1387
|
-
if (index < vertexDeclaration.length) {
|
|
1388
|
-
const order = effect.getAttributeLocation(index);
|
|
1389
|
-
if (order >= 0) {
|
|
1390
|
-
this._gl.enableVertexAttribArray(order);
|
|
1391
|
-
this._vertexAttribArraysEnabled[order] = true;
|
|
1392
|
-
this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
|
|
1393
|
-
}
|
|
1394
|
-
offset += vertexDeclaration[index] * 4;
|
|
1395
|
-
}
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
this._bindIndexBufferWithCache(indexBuffer);
|
|
1399
|
-
}
|
|
1400
|
-
_unbindVertexArrayObject() {
|
|
1401
|
-
if (!this._cachedVertexArrayObject) {
|
|
1402
|
-
return;
|
|
1403
|
-
}
|
|
1404
|
-
this._cachedVertexArrayObject = null;
|
|
1405
|
-
this._gl.bindVertexArray(null);
|
|
1406
|
-
}
|
|
1407
|
-
/**
|
|
1408
|
-
* Bind a list of vertex buffers to the webGL context
|
|
1409
|
-
* @param vertexBuffers defines the list of vertex buffers to bind
|
|
1410
|
-
* @param indexBuffer defines the index buffer to bind
|
|
1411
|
-
* @param effect defines the effect associated with the vertex buffers
|
|
1412
|
-
* @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
|
|
1413
|
-
*/
|
|
1414
|
-
bindBuffers(vertexBuffers, indexBuffer, effect, overrideVertexBuffers) {
|
|
1415
|
-
if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
|
|
1416
|
-
this._cachedVertexBuffers = vertexBuffers;
|
|
1417
|
-
this._cachedEffectForVertexBuffers = effect;
|
|
1418
|
-
this._bindVertexBuffersAttributes(vertexBuffers, effect, overrideVertexBuffers);
|
|
1419
|
-
}
|
|
1420
|
-
this._bindIndexBufferWithCache(indexBuffer);
|
|
1421
|
-
}
|
|
1422
|
-
/**
|
|
1423
|
-
* Unbind all instance attributes
|
|
1424
|
-
*/
|
|
1425
|
-
unbindInstanceAttributes() {
|
|
1426
|
-
let boundBuffer;
|
|
1427
|
-
for (let i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
|
|
1428
|
-
const instancesBuffer = this._currentInstanceBuffers[i];
|
|
1429
|
-
if (boundBuffer != instancesBuffer && instancesBuffer.references) {
|
|
1430
|
-
boundBuffer = instancesBuffer;
|
|
1431
|
-
this.bindArrayBuffer(instancesBuffer);
|
|
1432
|
-
}
|
|
1433
|
-
const offsetLocation = this._currentInstanceLocations[i];
|
|
1434
|
-
this._gl.vertexAttribDivisor(offsetLocation, 0);
|
|
1435
|
-
}
|
|
1436
|
-
this._currentInstanceBuffers.length = 0;
|
|
1437
|
-
this._currentInstanceLocations.length = 0;
|
|
1438
|
-
}
|
|
1439
|
-
/**
|
|
1440
|
-
* Release and free the memory of a vertex array object
|
|
1441
|
-
* @param vao defines the vertex array object to delete
|
|
1442
|
-
*/
|
|
1443
|
-
releaseVertexArrayObject(vao) {
|
|
1444
|
-
this._gl.deleteVertexArray(vao);
|
|
1445
|
-
}
|
|
1446
|
-
/**
|
|
1447
|
-
* @internal
|
|
1448
|
-
*/
|
|
1449
|
-
_releaseBuffer(buffer) {
|
|
1450
|
-
buffer.references--;
|
|
1451
|
-
if (buffer.references === 0) {
|
|
1452
|
-
this._deleteBuffer(buffer);
|
|
1453
|
-
return true;
|
|
1454
|
-
}
|
|
1455
|
-
return false;
|
|
1456
|
-
}
|
|
1457
|
-
_deleteBuffer(buffer) {
|
|
1458
|
-
this._gl.deleteBuffer(buffer.underlyingResource);
|
|
1459
|
-
}
|
|
1460
|
-
/**
|
|
1461
|
-
* Update the content of a webGL buffer used with instantiation and bind it to the webGL context
|
|
1462
|
-
* @param instancesBuffer defines the webGL buffer to update and bind
|
|
1463
|
-
* @param data defines the data to store in the buffer
|
|
1464
|
-
* @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
|
|
1465
|
-
*/
|
|
1466
|
-
updateAndBindInstancesBuffer(instancesBuffer, data, offsetLocations) {
|
|
1467
|
-
this.bindArrayBuffer(instancesBuffer);
|
|
1468
|
-
if (data) {
|
|
1469
|
-
this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
|
|
1470
|
-
}
|
|
1471
|
-
if (offsetLocations[0].index !== undefined) {
|
|
1472
|
-
this.bindInstancesBuffer(instancesBuffer, offsetLocations, true);
|
|
1473
|
-
}
|
|
1474
|
-
else {
|
|
1475
|
-
for (let index = 0; index < 4; index++) {
|
|
1476
|
-
const offsetLocation = offsetLocations[index];
|
|
1477
|
-
if (!this._vertexAttribArraysEnabled[offsetLocation]) {
|
|
1478
|
-
this._gl.enableVertexAttribArray(offsetLocation);
|
|
1479
|
-
this._vertexAttribArraysEnabled[offsetLocation] = true;
|
|
1480
|
-
}
|
|
1481
|
-
this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
|
|
1482
|
-
this._gl.vertexAttribDivisor(offsetLocation, 1);
|
|
1483
|
-
this._currentInstanceLocations.push(offsetLocation);
|
|
1484
|
-
this._currentInstanceBuffers.push(instancesBuffer);
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
/**
|
|
1489
|
-
* Bind the content of a webGL buffer used with instantiation
|
|
1490
|
-
* @param instancesBuffer defines the webGL buffer to bind
|
|
1491
|
-
* @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
|
|
1492
|
-
* @param computeStride defines Whether to compute the strides from the info or use the default 0
|
|
1493
|
-
*/
|
|
1494
|
-
bindInstancesBuffer(instancesBuffer, attributesInfo, computeStride = true) {
|
|
1495
|
-
this.bindArrayBuffer(instancesBuffer);
|
|
1496
|
-
let stride = 0;
|
|
1497
|
-
if (computeStride) {
|
|
1498
|
-
for (let i = 0; i < attributesInfo.length; i++) {
|
|
1499
|
-
const ai = attributesInfo[i];
|
|
1500
|
-
stride += ai.attributeSize * 4;
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
for (let i = 0; i < attributesInfo.length; i++) {
|
|
1504
|
-
const ai = attributesInfo[i];
|
|
1505
|
-
if (ai.index === undefined) {
|
|
1506
|
-
ai.index = this._currentEffect.getAttributeLocationByName(ai.attributeName);
|
|
1507
|
-
}
|
|
1508
|
-
if (ai.index < 0) {
|
|
1509
|
-
continue;
|
|
1510
|
-
}
|
|
1511
|
-
if (!this._vertexAttribArraysEnabled[ai.index]) {
|
|
1512
|
-
this._gl.enableVertexAttribArray(ai.index);
|
|
1513
|
-
this._vertexAttribArraysEnabled[ai.index] = true;
|
|
1514
|
-
}
|
|
1515
|
-
this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attributeType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
|
|
1516
|
-
this._gl.vertexAttribDivisor(ai.index, ai.divisor === undefined ? 1 : ai.divisor);
|
|
1517
|
-
this._currentInstanceLocations.push(ai.index);
|
|
1518
|
-
this._currentInstanceBuffers.push(instancesBuffer);
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1521
|
-
/**
|
|
1522
|
-
* Disable the instance attribute corresponding to the name in parameter
|
|
1523
|
-
* @param name defines the name of the attribute to disable
|
|
1524
|
-
*/
|
|
1525
|
-
disableInstanceAttributeByName(name) {
|
|
1526
|
-
if (!this._currentEffect) {
|
|
1527
|
-
return;
|
|
1528
|
-
}
|
|
1529
|
-
const attributeLocation = this._currentEffect.getAttributeLocationByName(name);
|
|
1530
|
-
this.disableInstanceAttribute(attributeLocation);
|
|
1531
|
-
}
|
|
1532
|
-
/**
|
|
1533
|
-
* Disable the instance attribute corresponding to the location in parameter
|
|
1534
|
-
* @param attributeLocation defines the attribute location of the attribute to disable
|
|
1535
|
-
*/
|
|
1536
|
-
disableInstanceAttribute(attributeLocation) {
|
|
1537
|
-
let shouldClean = false;
|
|
1538
|
-
let index;
|
|
1539
|
-
while ((index = this._currentInstanceLocations.indexOf(attributeLocation)) !== -1) {
|
|
1540
|
-
this._currentInstanceLocations.splice(index, 1);
|
|
1541
|
-
this._currentInstanceBuffers.splice(index, 1);
|
|
1542
|
-
shouldClean = true;
|
|
1543
|
-
index = this._currentInstanceLocations.indexOf(attributeLocation);
|
|
1544
|
-
}
|
|
1545
|
-
if (shouldClean) {
|
|
1546
|
-
this._gl.vertexAttribDivisor(attributeLocation, 0);
|
|
1547
|
-
this.disableAttributeByIndex(attributeLocation);
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
/**
|
|
1551
|
-
* Disable the attribute corresponding to the location in parameter
|
|
1552
|
-
* @param attributeLocation defines the attribute location of the attribute to disable
|
|
1553
|
-
*/
|
|
1554
|
-
disableAttributeByIndex(attributeLocation) {
|
|
1555
|
-
this._gl.disableVertexAttribArray(attributeLocation);
|
|
1556
|
-
this._vertexAttribArraysEnabled[attributeLocation] = false;
|
|
1557
|
-
this._currentBufferPointers[attributeLocation].active = false;
|
|
1558
|
-
}
|
|
1559
|
-
/**
|
|
1560
|
-
* Send a draw order
|
|
1561
|
-
* @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
|
|
1562
|
-
* @param indexStart defines the starting index
|
|
1563
|
-
* @param indexCount defines the number of index to draw
|
|
1564
|
-
* @param instancesCount defines the number of instances to draw (if instantiation is enabled)
|
|
1565
|
-
*/
|
|
1566
|
-
draw(useTriangles, indexStart, indexCount, instancesCount) {
|
|
1567
|
-
this.drawElementsType(useTriangles ? Constants.MATERIAL_TriangleFillMode : Constants.MATERIAL_WireFrameFillMode, indexStart, indexCount, instancesCount);
|
|
1568
|
-
}
|
|
1569
|
-
/**
|
|
1570
|
-
* Draw a list of points
|
|
1571
|
-
* @param verticesStart defines the index of first vertex to draw
|
|
1572
|
-
* @param verticesCount defines the count of vertices to draw
|
|
1573
|
-
* @param instancesCount defines the number of instances to draw (if instantiation is enabled)
|
|
1574
|
-
*/
|
|
1575
|
-
drawPointClouds(verticesStart, verticesCount, instancesCount) {
|
|
1576
|
-
this.drawArraysType(Constants.MATERIAL_PointFillMode, verticesStart, verticesCount, instancesCount);
|
|
1577
|
-
}
|
|
1578
|
-
/**
|
|
1579
|
-
* Draw a list of unindexed primitives
|
|
1580
|
-
* @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
|
|
1581
|
-
* @param verticesStart defines the index of first vertex to draw
|
|
1582
|
-
* @param verticesCount defines the count of vertices to draw
|
|
1583
|
-
* @param instancesCount defines the number of instances to draw (if instantiation is enabled)
|
|
1584
|
-
*/
|
|
1585
|
-
drawUnIndexed(useTriangles, verticesStart, verticesCount, instancesCount) {
|
|
1586
|
-
this.drawArraysType(useTriangles ? Constants.MATERIAL_TriangleFillMode : Constants.MATERIAL_WireFrameFillMode, verticesStart, verticesCount, instancesCount);
|
|
1587
|
-
}
|
|
1588
|
-
/**
|
|
1589
|
-
* Draw a list of indexed primitives
|
|
1590
|
-
* @param fillMode defines the primitive to use
|
|
1591
|
-
* @param indexStart defines the starting index
|
|
1592
|
-
* @param indexCount defines the number of index to draw
|
|
1593
|
-
* @param instancesCount defines the number of instances to draw (if instantiation is enabled)
|
|
1594
|
-
*/
|
|
1595
|
-
drawElementsType(fillMode, indexStart, indexCount, instancesCount) {
|
|
1596
|
-
// Apply states
|
|
1597
|
-
this.applyStates();
|
|
1598
|
-
this._reportDrawCall();
|
|
1599
|
-
// Render
|
|
1600
|
-
const drawMode = this._drawMode(fillMode);
|
|
1601
|
-
const indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
|
|
1602
|
-
const mult = this._uintIndicesCurrentlySet ? 4 : 2;
|
|
1603
|
-
if (instancesCount) {
|
|
1604
|
-
this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
|
|
1605
|
-
}
|
|
1606
|
-
else {
|
|
1607
|
-
this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
|
|
1608
|
-
}
|
|
1609
|
-
}
|
|
1610
|
-
/**
|
|
1611
|
-
* Draw a list of unindexed primitives
|
|
1612
|
-
* @param fillMode defines the primitive to use
|
|
1613
|
-
* @param verticesStart defines the index of first vertex to draw
|
|
1614
|
-
* @param verticesCount defines the count of vertices to draw
|
|
1615
|
-
* @param instancesCount defines the number of instances to draw (if instantiation is enabled)
|
|
1616
|
-
*/
|
|
1617
|
-
drawArraysType(fillMode, verticesStart, verticesCount, instancesCount) {
|
|
1618
|
-
// Apply states
|
|
1619
|
-
this.applyStates();
|
|
1620
|
-
this._reportDrawCall();
|
|
1621
|
-
const drawMode = this._drawMode(fillMode);
|
|
1622
|
-
if (instancesCount) {
|
|
1623
|
-
this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
|
|
1624
|
-
}
|
|
1625
|
-
else {
|
|
1626
|
-
this._gl.drawArrays(drawMode, verticesStart, verticesCount);
|
|
1627
|
-
}
|
|
1628
|
-
}
|
|
1629
|
-
_drawMode(fillMode) {
|
|
1630
|
-
switch (fillMode) {
|
|
1631
|
-
// Triangle views
|
|
1632
|
-
case Constants.MATERIAL_TriangleFillMode:
|
|
1633
|
-
return this._gl.TRIANGLES;
|
|
1634
|
-
case Constants.MATERIAL_PointFillMode:
|
|
1635
|
-
return this._gl.POINTS;
|
|
1636
|
-
case Constants.MATERIAL_WireFrameFillMode:
|
|
1637
|
-
return this._gl.LINES;
|
|
1638
|
-
// Draw modes
|
|
1639
|
-
case Constants.MATERIAL_PointListDrawMode:
|
|
1640
|
-
return this._gl.POINTS;
|
|
1641
|
-
case Constants.MATERIAL_LineListDrawMode:
|
|
1642
|
-
return this._gl.LINES;
|
|
1643
|
-
case Constants.MATERIAL_LineLoopDrawMode:
|
|
1644
|
-
return this._gl.LINE_LOOP;
|
|
1645
|
-
case Constants.MATERIAL_LineStripDrawMode:
|
|
1646
|
-
return this._gl.LINE_STRIP;
|
|
1647
|
-
case Constants.MATERIAL_TriangleStripDrawMode:
|
|
1648
|
-
return this._gl.TRIANGLE_STRIP;
|
|
1649
|
-
case Constants.MATERIAL_TriangleFanDrawMode:
|
|
1650
|
-
return this._gl.TRIANGLE_FAN;
|
|
1651
|
-
default:
|
|
1652
|
-
return this._gl.TRIANGLES;
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
// Shaders
|
|
1656
|
-
/**
|
|
1657
|
-
* @internal
|
|
1658
|
-
*/
|
|
1659
|
-
_releaseEffect(effect) {
|
|
1660
|
-
if (this._compiledEffects[effect._key]) {
|
|
1661
|
-
delete this._compiledEffects[effect._key];
|
|
1662
|
-
}
|
|
1663
|
-
const pipelineContext = effect.getPipelineContext();
|
|
1664
|
-
if (pipelineContext) {
|
|
1665
|
-
this._deletePipelineContext(pipelineContext);
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
/**
|
|
1669
|
-
* @internal
|
|
1670
|
-
*/
|
|
1671
|
-
_deletePipelineContext(pipelineContext) {
|
|
1672
|
-
const webGLPipelineContext = pipelineContext;
|
|
1673
|
-
if (webGLPipelineContext && webGLPipelineContext.program) {
|
|
1674
|
-
webGLPipelineContext.program.__SPECTOR_rebuildProgram = null;
|
|
1675
|
-
resetCachedPipeline(webGLPipelineContext);
|
|
1676
|
-
if (this._gl) {
|
|
1677
|
-
this._gl.deleteProgram(webGLPipelineContext.program);
|
|
1678
|
-
}
|
|
1679
|
-
}
|
|
1680
|
-
}
|
|
1681
|
-
/**
|
|
1682
|
-
* @internal
|
|
1683
|
-
*/
|
|
1684
|
-
_getGlobalDefines(defines) {
|
|
1685
|
-
return _getGlobalDefines(defines, this.isNDCHalfZRange, this.useReverseDepthBuffer, this.useExactSrgbConversions);
|
|
1686
|
-
}
|
|
1687
|
-
/**
|
|
1688
|
-
* Create a new effect (used to store vertex/fragment shaders)
|
|
1689
|
-
* @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
|
|
1690
|
-
* @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
|
|
1691
|
-
* @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
|
|
1692
|
-
* @param samplers defines an array of string used to represent textures
|
|
1693
|
-
* @param defines defines the string containing the defines to use to compile the shaders
|
|
1694
|
-
* @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
|
|
1695
|
-
* @param onCompiled defines a function to call when the effect creation is successful
|
|
1696
|
-
* @param onError defines a function to call when the effect creation has failed
|
|
1697
|
-
* @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
|
|
1698
|
-
* @param shaderLanguage the language the shader is written in (default: GLSL)
|
|
1699
|
-
* @param extraInitializationsAsync additional async code to run before preparing the effect
|
|
1700
|
-
* @returns the new Effect
|
|
1701
|
-
*/
|
|
1702
|
-
createEffect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters, shaderLanguage = 0 /* ShaderLanguage.GLSL */, extraInitializationsAsync) {
|
|
1703
|
-
const vertex = typeof baseName === "string" ? baseName : baseName.vertexToken || baseName.vertexSource || baseName.vertexElement || baseName.vertex;
|
|
1704
|
-
const fragment = typeof baseName === "string" ? baseName : baseName.fragmentToken || baseName.fragmentSource || baseName.fragmentElement || baseName.fragment;
|
|
1705
|
-
const globalDefines = this._getGlobalDefines();
|
|
1706
|
-
let fullDefines = defines ?? attributesNamesOrOptions.defines ?? "";
|
|
1707
|
-
if (globalDefines) {
|
|
1708
|
-
fullDefines += globalDefines;
|
|
1709
|
-
}
|
|
1710
|
-
const name = vertex + "+" + fragment + "@" + fullDefines;
|
|
1711
|
-
if (this._compiledEffects[name]) {
|
|
1712
|
-
const compiledEffect = this._compiledEffects[name];
|
|
1713
|
-
if (onCompiled && compiledEffect.isReady()) {
|
|
1714
|
-
onCompiled(compiledEffect);
|
|
1715
|
-
}
|
|
1716
|
-
compiledEffect._refCount++;
|
|
1717
|
-
return compiledEffect;
|
|
1718
|
-
}
|
|
1719
|
-
if (this._gl) {
|
|
1720
|
-
getStateObject(this._gl);
|
|
1721
|
-
}
|
|
1722
|
-
const effect = new Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, (effect, errors) => {
|
|
1723
|
-
if (onError) {
|
|
1724
|
-
onError(effect, errors);
|
|
1725
|
-
}
|
|
1726
|
-
this.onEffectErrorObservable.notifyObservers({ effect, errors });
|
|
1727
|
-
}, indexParameters, name, attributesNamesOrOptions.shaderLanguage ?? shaderLanguage, attributesNamesOrOptions.extraInitializationsAsync ?? extraInitializationsAsync);
|
|
1728
|
-
this._compiledEffects[name] = effect;
|
|
1729
|
-
return effect;
|
|
1730
|
-
}
|
|
1731
|
-
/**
|
|
1732
|
-
* @internal
|
|
1733
|
-
*/
|
|
1734
|
-
_getShaderSource(shader) {
|
|
1735
|
-
return this._gl.getShaderSource(shader);
|
|
1736
|
-
}
|
|
1737
|
-
/**
|
|
1738
|
-
* Directly creates a webGL program
|
|
1739
|
-
* @param pipelineContext defines the pipeline context to attach to
|
|
1740
|
-
* @param vertexCode defines the vertex shader code to use
|
|
1741
|
-
* @param fragmentCode defines the fragment shader code to use
|
|
1742
|
-
* @param context defines the webGL context to use (if not set, the current one will be used)
|
|
1743
|
-
* @param transformFeedbackVaryings defines the list of transform feedback varyings to use
|
|
1744
|
-
* @returns the new webGL program
|
|
1745
|
-
*/
|
|
1746
|
-
createRawShaderProgram(pipelineContext, vertexCode, fragmentCode, context, transformFeedbackVaryings = null) {
|
|
1747
|
-
const stateObject = getStateObject(this._gl);
|
|
1748
|
-
stateObject._contextWasLost = this._contextWasLost;
|
|
1749
|
-
stateObject.validateShaderPrograms = this.validateShaderPrograms;
|
|
1750
|
-
return createRawShaderProgram(pipelineContext, vertexCode, fragmentCode, context || this._gl, transformFeedbackVaryings);
|
|
1751
|
-
}
|
|
1752
|
-
/**
|
|
1753
|
-
* Creates a webGL program
|
|
1754
|
-
* @param pipelineContext defines the pipeline context to attach to
|
|
1755
|
-
* @param vertexCode defines the vertex shader code to use
|
|
1756
|
-
* @param fragmentCode defines the fragment shader code to use
|
|
1757
|
-
* @param defines defines the string containing the defines to use to compile the shaders
|
|
1758
|
-
* @param context defines the webGL context to use (if not set, the current one will be used)
|
|
1759
|
-
* @param transformFeedbackVaryings defines the list of transform feedback varyings to use
|
|
1760
|
-
* @returns the new webGL program
|
|
1761
|
-
*/
|
|
1762
|
-
createShaderProgram(pipelineContext, vertexCode, fragmentCode, defines, context, transformFeedbackVaryings = null) {
|
|
1763
|
-
const stateObject = getStateObject(this._gl);
|
|
1764
|
-
// assure the state object is correct
|
|
1765
|
-
stateObject._contextWasLost = this._contextWasLost;
|
|
1766
|
-
stateObject.validateShaderPrograms = this.validateShaderPrograms;
|
|
1767
|
-
return createShaderProgram(pipelineContext, vertexCode, fragmentCode, defines, context || this._gl, transformFeedbackVaryings);
|
|
1768
|
-
}
|
|
1769
|
-
/**
|
|
1770
|
-
* Inline functions in shader code that are marked to be inlined
|
|
1771
|
-
* @param code code to inline
|
|
1772
|
-
* @returns inlined code
|
|
1773
|
-
*/
|
|
1774
|
-
inlineShaderCode(code) {
|
|
1775
|
-
// no inlining needed in the WebGL engine
|
|
1776
|
-
return code;
|
|
1777
|
-
}
|
|
1778
|
-
/**
|
|
1779
|
-
* Creates a new pipeline context
|
|
1780
|
-
* @param shaderProcessingContext defines the shader processing context used during the processing if available
|
|
1781
|
-
* @returns the new pipeline
|
|
1782
|
-
*/
|
|
1783
|
-
createPipelineContext(shaderProcessingContext) {
|
|
1784
|
-
if (this._gl) {
|
|
1785
|
-
const stateObject = getStateObject(this._gl);
|
|
1786
|
-
stateObject.parallelShaderCompile = this._caps.parallelShaderCompile;
|
|
1787
|
-
}
|
|
1788
|
-
const context = createPipelineContext(this._gl);
|
|
1789
|
-
context.engine = this;
|
|
1790
|
-
return context;
|
|
1791
|
-
}
|
|
1792
|
-
/**
|
|
1793
|
-
* Creates a new material context
|
|
1794
|
-
* @returns the new context
|
|
1795
|
-
*/
|
|
1796
|
-
createMaterialContext() {
|
|
1797
|
-
return undefined;
|
|
1798
|
-
}
|
|
1799
|
-
/**
|
|
1800
|
-
* Creates a new draw context
|
|
1801
|
-
* @returns the new context
|
|
1802
|
-
*/
|
|
1803
|
-
createDrawContext() {
|
|
1804
|
-
return undefined;
|
|
1805
|
-
}
|
|
1806
|
-
_finalizePipelineContext(pipelineContext) {
|
|
1807
|
-
return _finalizePipelineContext(pipelineContext, this._gl, this.validateShaderPrograms);
|
|
1808
|
-
}
|
|
1809
|
-
/**
|
|
1810
|
-
* @internal
|
|
1811
|
-
*/
|
|
1812
|
-
_preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rawVertexSourceCode, rawFragmentSourceCode, rebuildRebind, defines, transformFeedbackVaryings, key, onReady) {
|
|
1813
|
-
const stateObject = getStateObject(this._gl);
|
|
1814
|
-
stateObject._contextWasLost = this._contextWasLost;
|
|
1815
|
-
stateObject.validateShaderPrograms = this.validateShaderPrograms;
|
|
1816
|
-
stateObject._createShaderProgramInjection = this._createShaderProgram.bind(this);
|
|
1817
|
-
stateObject.createRawShaderProgramInjection = this.createRawShaderProgram.bind(this);
|
|
1818
|
-
stateObject.createShaderProgramInjection = this.createShaderProgram.bind(this);
|
|
1819
|
-
stateObject.loadFileInjection = this._loadFile.bind(this);
|
|
1820
|
-
return _preparePipelineContext(pipelineContext, vertexSourceCode, fragmentSourceCode, createAsRaw, rawVertexSourceCode, rawFragmentSourceCode, rebuildRebind, defines, transformFeedbackVaryings, key, onReady);
|
|
1821
|
-
}
|
|
1822
|
-
_createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings = null) {
|
|
1823
|
-
return _createShaderProgram(pipelineContext, vertexShader, fragmentShader, context, transformFeedbackVaryings);
|
|
1824
|
-
}
|
|
1825
|
-
/**
|
|
1826
|
-
* @internal
|
|
1827
|
-
*/
|
|
1828
|
-
_isRenderingStateCompiled(pipelineContext) {
|
|
1829
|
-
if (this._isDisposed) {
|
|
1830
|
-
return false;
|
|
1831
|
-
}
|
|
1832
|
-
return _isRenderingStateCompiled(pipelineContext, this._gl, this.validateShaderPrograms);
|
|
1833
|
-
}
|
|
1834
|
-
/**
|
|
1835
|
-
* @internal
|
|
1836
|
-
*/
|
|
1837
|
-
_executeWhenRenderingStateIsCompiled(pipelineContext, action) {
|
|
1838
|
-
_executeWhenRenderingStateIsCompiled(pipelineContext, action);
|
|
1839
|
-
}
|
|
1840
|
-
/**
|
|
1841
|
-
* Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
|
|
1842
|
-
* @param pipelineContext defines the pipeline context to use
|
|
1843
|
-
* @param uniformsNames defines the list of uniform names
|
|
1844
|
-
* @returns an array of webGL uniform locations
|
|
1845
|
-
*/
|
|
1846
|
-
getUniforms(pipelineContext, uniformsNames) {
|
|
1847
|
-
const results = new Array();
|
|
1848
|
-
const webGLPipelineContext = pipelineContext;
|
|
1849
|
-
for (let index = 0; index < uniformsNames.length; index++) {
|
|
1850
|
-
results.push(this._gl.getUniformLocation(webGLPipelineContext.program, uniformsNames[index]));
|
|
1851
|
-
}
|
|
1852
|
-
return results;
|
|
1853
|
-
}
|
|
1854
|
-
/**
|
|
1855
|
-
* Gets the list of active attributes for a given webGL program
|
|
1856
|
-
* @param pipelineContext defines the pipeline context to use
|
|
1857
|
-
* @param attributesNames defines the list of attribute names to get
|
|
1858
|
-
* @returns an array of indices indicating the offset of each attribute
|
|
1859
|
-
*/
|
|
1860
|
-
getAttributes(pipelineContext, attributesNames) {
|
|
1861
|
-
const results = [];
|
|
1862
|
-
const webGLPipelineContext = pipelineContext;
|
|
1863
|
-
for (let index = 0; index < attributesNames.length; index++) {
|
|
1864
|
-
try {
|
|
1865
|
-
results.push(this._gl.getAttribLocation(webGLPipelineContext.program, attributesNames[index]));
|
|
1866
|
-
}
|
|
1867
|
-
catch (e) {
|
|
1868
|
-
results.push(-1);
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
return results;
|
|
1872
|
-
}
|
|
1873
|
-
/**
|
|
1874
|
-
* Activates an effect, making it the current one (ie. the one used for rendering)
|
|
1875
|
-
* @param effect defines the effect to activate
|
|
1876
|
-
*/
|
|
1877
|
-
enableEffect(effect) {
|
|
1878
|
-
effect = effect !== null && IsWrapper(effect) ? effect.effect : effect; // get only the effect, we don't need a Wrapper in the WebGL engine
|
|
1879
|
-
if (!effect || effect === this._currentEffect) {
|
|
1880
|
-
return;
|
|
1881
|
-
}
|
|
1882
|
-
this._stencilStateComposer.stencilMaterial = undefined;
|
|
1883
|
-
effect = effect;
|
|
1884
|
-
// Use program
|
|
1885
|
-
this.bindSamplers(effect);
|
|
1886
|
-
this._currentEffect = effect;
|
|
1887
|
-
if (effect.onBind) {
|
|
1888
|
-
effect.onBind(effect);
|
|
1889
|
-
}
|
|
1890
|
-
if (effect._onBindObservable) {
|
|
1891
|
-
effect._onBindObservable.notifyObservers(effect);
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
/**
|
|
1895
|
-
* Set the value of an uniform to a number (int)
|
|
1896
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
1897
|
-
* @param value defines the int number to store
|
|
1898
|
-
* @returns true if the value was set
|
|
1899
|
-
*/
|
|
1900
|
-
setInt(uniform, value) {
|
|
1901
|
-
if (!uniform) {
|
|
1902
|
-
return false;
|
|
1903
|
-
}
|
|
1904
|
-
this._gl.uniform1i(uniform, value);
|
|
1905
|
-
return true;
|
|
1906
|
-
}
|
|
1907
|
-
/**
|
|
1908
|
-
* Set the value of an uniform to a int2
|
|
1909
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
1910
|
-
* @param x defines the 1st component of the value
|
|
1911
|
-
* @param y defines the 2nd component of the value
|
|
1912
|
-
* @returns true if the value was set
|
|
1913
|
-
*/
|
|
1914
|
-
setInt2(uniform, x, y) {
|
|
1915
|
-
if (!uniform) {
|
|
1916
|
-
return false;
|
|
1917
|
-
}
|
|
1918
|
-
this._gl.uniform2i(uniform, x, y);
|
|
1919
|
-
return true;
|
|
1920
|
-
}
|
|
1921
|
-
/**
|
|
1922
|
-
* Set the value of an uniform to a int3
|
|
1923
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
1924
|
-
* @param x defines the 1st component of the value
|
|
1925
|
-
* @param y defines the 2nd component of the value
|
|
1926
|
-
* @param z defines the 3rd component of the value
|
|
1927
|
-
* @returns true if the value was set
|
|
1928
|
-
*/
|
|
1929
|
-
setInt3(uniform, x, y, z) {
|
|
1930
|
-
if (!uniform) {
|
|
1931
|
-
return false;
|
|
1932
|
-
}
|
|
1933
|
-
this._gl.uniform3i(uniform, x, y, z);
|
|
1934
|
-
return true;
|
|
1935
|
-
}
|
|
1936
|
-
/**
|
|
1937
|
-
* Set the value of an uniform to a int4
|
|
1938
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
1939
|
-
* @param x defines the 1st component of the value
|
|
1940
|
-
* @param y defines the 2nd component of the value
|
|
1941
|
-
* @param z defines the 3rd component of the value
|
|
1942
|
-
* @param w defines the 4th component of the value
|
|
1943
|
-
* @returns true if the value was set
|
|
1944
|
-
*/
|
|
1945
|
-
setInt4(uniform, x, y, z, w) {
|
|
1946
|
-
if (!uniform) {
|
|
1947
|
-
return false;
|
|
1948
|
-
}
|
|
1949
|
-
this._gl.uniform4i(uniform, x, y, z, w);
|
|
1950
|
-
return true;
|
|
1951
|
-
}
|
|
1952
|
-
/**
|
|
1953
|
-
* Set the value of an uniform to an array of int32
|
|
1954
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
1955
|
-
* @param array defines the array of int32 to store
|
|
1956
|
-
* @returns true if the value was set
|
|
1957
|
-
*/
|
|
1958
|
-
setIntArray(uniform, array) {
|
|
1959
|
-
if (!uniform) {
|
|
1960
|
-
return false;
|
|
1961
|
-
}
|
|
1962
|
-
this._gl.uniform1iv(uniform, array);
|
|
1963
|
-
return true;
|
|
1964
|
-
}
|
|
1965
|
-
/**
|
|
1966
|
-
* Set the value of an uniform to an array of int32 (stored as vec2)
|
|
1967
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
1968
|
-
* @param array defines the array of int32 to store
|
|
1969
|
-
* @returns true if the value was set
|
|
1970
|
-
*/
|
|
1971
|
-
setIntArray2(uniform, array) {
|
|
1972
|
-
if (!uniform || array.length % 2 !== 0) {
|
|
1973
|
-
return false;
|
|
1974
|
-
}
|
|
1975
|
-
this._gl.uniform2iv(uniform, array);
|
|
1976
|
-
return true;
|
|
1977
|
-
}
|
|
1978
|
-
/**
|
|
1979
|
-
* Set the value of an uniform to an array of int32 (stored as vec3)
|
|
1980
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
1981
|
-
* @param array defines the array of int32 to store
|
|
1982
|
-
* @returns true if the value was set
|
|
1983
|
-
*/
|
|
1984
|
-
setIntArray3(uniform, array) {
|
|
1985
|
-
if (!uniform || array.length % 3 !== 0) {
|
|
1986
|
-
return false;
|
|
1987
|
-
}
|
|
1988
|
-
this._gl.uniform3iv(uniform, array);
|
|
1989
|
-
return true;
|
|
1990
|
-
}
|
|
1991
|
-
/**
|
|
1992
|
-
* Set the value of an uniform to an array of int32 (stored as vec4)
|
|
1993
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
1994
|
-
* @param array defines the array of int32 to store
|
|
1995
|
-
* @returns true if the value was set
|
|
1996
|
-
*/
|
|
1997
|
-
setIntArray4(uniform, array) {
|
|
1998
|
-
if (!uniform || array.length % 4 !== 0) {
|
|
1999
|
-
return false;
|
|
2000
|
-
}
|
|
2001
|
-
this._gl.uniform4iv(uniform, array);
|
|
2002
|
-
return true;
|
|
2003
|
-
}
|
|
2004
|
-
/**
|
|
2005
|
-
* Set the value of an uniform to a number (unsigned int)
|
|
2006
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2007
|
-
* @param value defines the unsigned int number to store
|
|
2008
|
-
* @returns true if the value was set
|
|
2009
|
-
*/
|
|
2010
|
-
setUInt(uniform, value) {
|
|
2011
|
-
if (!uniform) {
|
|
2012
|
-
return false;
|
|
2013
|
-
}
|
|
2014
|
-
this._gl.uniform1ui(uniform, value);
|
|
2015
|
-
return true;
|
|
2016
|
-
}
|
|
2017
|
-
/**
|
|
2018
|
-
* Set the value of an uniform to a unsigned int2
|
|
2019
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2020
|
-
* @param x defines the 1st component of the value
|
|
2021
|
-
* @param y defines the 2nd component of the value
|
|
2022
|
-
* @returns true if the value was set
|
|
2023
|
-
*/
|
|
2024
|
-
setUInt2(uniform, x, y) {
|
|
2025
|
-
if (!uniform) {
|
|
2026
|
-
return false;
|
|
2027
|
-
}
|
|
2028
|
-
this._gl.uniform2ui(uniform, x, y);
|
|
2029
|
-
return true;
|
|
2030
|
-
}
|
|
2031
|
-
/**
|
|
2032
|
-
* Set the value of an uniform to a unsigned int3
|
|
2033
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2034
|
-
* @param x defines the 1st component of the value
|
|
2035
|
-
* @param y defines the 2nd component of the value
|
|
2036
|
-
* @param z defines the 3rd component of the value
|
|
2037
|
-
* @returns true if the value was set
|
|
2038
|
-
*/
|
|
2039
|
-
setUInt3(uniform, x, y, z) {
|
|
2040
|
-
if (!uniform) {
|
|
2041
|
-
return false;
|
|
2042
|
-
}
|
|
2043
|
-
this._gl.uniform3ui(uniform, x, y, z);
|
|
2044
|
-
return true;
|
|
2045
|
-
}
|
|
2046
|
-
/**
|
|
2047
|
-
* Set the value of an uniform to a unsigned int4
|
|
2048
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2049
|
-
* @param x defines the 1st component of the value
|
|
2050
|
-
* @param y defines the 2nd component of the value
|
|
2051
|
-
* @param z defines the 3rd component of the value
|
|
2052
|
-
* @param w defines the 4th component of the value
|
|
2053
|
-
* @returns true if the value was set
|
|
2054
|
-
*/
|
|
2055
|
-
setUInt4(uniform, x, y, z, w) {
|
|
2056
|
-
if (!uniform) {
|
|
2057
|
-
return false;
|
|
2058
|
-
}
|
|
2059
|
-
this._gl.uniform4ui(uniform, x, y, z, w);
|
|
2060
|
-
return true;
|
|
2061
|
-
}
|
|
2062
|
-
/**
|
|
2063
|
-
* Set the value of an uniform to an array of unsigned int32
|
|
2064
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2065
|
-
* @param array defines the array of unsigned int32 to store
|
|
2066
|
-
* @returns true if the value was set
|
|
2067
|
-
*/
|
|
2068
|
-
setUIntArray(uniform, array) {
|
|
2069
|
-
if (!uniform) {
|
|
2070
|
-
return false;
|
|
2071
|
-
}
|
|
2072
|
-
this._gl.uniform1uiv(uniform, array);
|
|
2073
|
-
return true;
|
|
2074
|
-
}
|
|
2075
|
-
/**
|
|
2076
|
-
* Set the value of an uniform to an array of unsigned int32 (stored as vec2)
|
|
2077
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2078
|
-
* @param array defines the array of unsigned int32 to store
|
|
2079
|
-
* @returns true if the value was set
|
|
2080
|
-
*/
|
|
2081
|
-
setUIntArray2(uniform, array) {
|
|
2082
|
-
if (!uniform || array.length % 2 !== 0) {
|
|
2083
|
-
return false;
|
|
2084
|
-
}
|
|
2085
|
-
this._gl.uniform2uiv(uniform, array);
|
|
2086
|
-
return true;
|
|
2087
|
-
}
|
|
2088
|
-
/**
|
|
2089
|
-
* Set the value of an uniform to an array of unsigned int32 (stored as vec3)
|
|
2090
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2091
|
-
* @param array defines the array of unsigned int32 to store
|
|
2092
|
-
* @returns true if the value was set
|
|
2093
|
-
*/
|
|
2094
|
-
setUIntArray3(uniform, array) {
|
|
2095
|
-
if (!uniform || array.length % 3 !== 0) {
|
|
2096
|
-
return false;
|
|
2097
|
-
}
|
|
2098
|
-
this._gl.uniform3uiv(uniform, array);
|
|
2099
|
-
return true;
|
|
2100
|
-
}
|
|
2101
|
-
/**
|
|
2102
|
-
* Set the value of an uniform to an array of unsigned int32 (stored as vec4)
|
|
2103
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2104
|
-
* @param array defines the array of unsigned int32 to store
|
|
2105
|
-
* @returns true if the value was set
|
|
2106
|
-
*/
|
|
2107
|
-
setUIntArray4(uniform, array) {
|
|
2108
|
-
if (!uniform || array.length % 4 !== 0) {
|
|
2109
|
-
return false;
|
|
2110
|
-
}
|
|
2111
|
-
this._gl.uniform4uiv(uniform, array);
|
|
2112
|
-
return true;
|
|
2113
|
-
}
|
|
2114
|
-
/**
|
|
2115
|
-
* Set the value of an uniform to an array of number
|
|
2116
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2117
|
-
* @param array defines the array of number to store
|
|
2118
|
-
* @returns true if the value was set
|
|
2119
|
-
*/
|
|
2120
|
-
setArray(uniform, array) {
|
|
2121
|
-
if (!uniform) {
|
|
2122
|
-
return false;
|
|
2123
|
-
}
|
|
2124
|
-
if (array.length < 1) {
|
|
2125
|
-
return false;
|
|
2126
|
-
}
|
|
2127
|
-
this._gl.uniform1fv(uniform, array);
|
|
2128
|
-
return true;
|
|
2129
|
-
}
|
|
2130
|
-
/**
|
|
2131
|
-
* Set the value of an uniform to an array of number (stored as vec2)
|
|
2132
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2133
|
-
* @param array defines the array of number to store
|
|
2134
|
-
* @returns true if the value was set
|
|
2135
|
-
*/
|
|
2136
|
-
setArray2(uniform, array) {
|
|
2137
|
-
if (!uniform || array.length % 2 !== 0) {
|
|
2138
|
-
return false;
|
|
2139
|
-
}
|
|
2140
|
-
this._gl.uniform2fv(uniform, array);
|
|
2141
|
-
return true;
|
|
2142
|
-
}
|
|
2143
|
-
/**
|
|
2144
|
-
* Set the value of an uniform to an array of number (stored as vec3)
|
|
2145
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2146
|
-
* @param array defines the array of number to store
|
|
2147
|
-
* @returns true if the value was set
|
|
2148
|
-
*/
|
|
2149
|
-
setArray3(uniform, array) {
|
|
2150
|
-
if (!uniform || array.length % 3 !== 0) {
|
|
2151
|
-
return false;
|
|
2152
|
-
}
|
|
2153
|
-
this._gl.uniform3fv(uniform, array);
|
|
2154
|
-
return true;
|
|
2155
|
-
}
|
|
2156
|
-
/**
|
|
2157
|
-
* Set the value of an uniform to an array of number (stored as vec4)
|
|
2158
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2159
|
-
* @param array defines the array of number to store
|
|
2160
|
-
* @returns true if the value was set
|
|
2161
|
-
*/
|
|
2162
|
-
setArray4(uniform, array) {
|
|
2163
|
-
if (!uniform || array.length % 4 !== 0) {
|
|
2164
|
-
return false;
|
|
2165
|
-
}
|
|
2166
|
-
this._gl.uniform4fv(uniform, array);
|
|
2167
|
-
return true;
|
|
2168
|
-
}
|
|
2169
|
-
/**
|
|
2170
|
-
* Set the value of an uniform to an array of float32 (stored as matrices)
|
|
2171
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2172
|
-
* @param matrices defines the array of float32 to store
|
|
2173
|
-
* @returns true if the value was set
|
|
2174
|
-
*/
|
|
2175
|
-
setMatrices(uniform, matrices) {
|
|
2176
|
-
if (!uniform) {
|
|
2177
|
-
return false;
|
|
2178
|
-
}
|
|
2179
|
-
this._gl.uniformMatrix4fv(uniform, false, matrices);
|
|
2180
|
-
return true;
|
|
2181
|
-
}
|
|
2182
|
-
/**
|
|
2183
|
-
* Set the value of an uniform to a matrix (3x3)
|
|
2184
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2185
|
-
* @param matrix defines the Float32Array representing the 3x3 matrix to store
|
|
2186
|
-
* @returns true if the value was set
|
|
2187
|
-
*/
|
|
2188
|
-
setMatrix3x3(uniform, matrix) {
|
|
2189
|
-
if (!uniform) {
|
|
2190
|
-
return false;
|
|
2191
|
-
}
|
|
2192
|
-
this._gl.uniformMatrix3fv(uniform, false, matrix);
|
|
2193
|
-
return true;
|
|
2194
|
-
}
|
|
2195
|
-
/**
|
|
2196
|
-
* Set the value of an uniform to a matrix (2x2)
|
|
2197
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2198
|
-
* @param matrix defines the Float32Array representing the 2x2 matrix to store
|
|
2199
|
-
* @returns true if the value was set
|
|
2200
|
-
*/
|
|
2201
|
-
setMatrix2x2(uniform, matrix) {
|
|
2202
|
-
if (!uniform) {
|
|
2203
|
-
return false;
|
|
2204
|
-
}
|
|
2205
|
-
this._gl.uniformMatrix2fv(uniform, false, matrix);
|
|
2206
|
-
return true;
|
|
2207
|
-
}
|
|
2208
|
-
/**
|
|
2209
|
-
* Set the value of an uniform to a number (float)
|
|
2210
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2211
|
-
* @param value defines the float number to store
|
|
2212
|
-
* @returns true if the value was transferred
|
|
2213
|
-
*/
|
|
2214
|
-
setFloat(uniform, value) {
|
|
2215
|
-
if (!uniform) {
|
|
2216
|
-
return false;
|
|
2217
|
-
}
|
|
2218
|
-
this._gl.uniform1f(uniform, value);
|
|
2219
|
-
return true;
|
|
2220
|
-
}
|
|
2221
|
-
/**
|
|
2222
|
-
* Set the value of an uniform to a vec2
|
|
2223
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2224
|
-
* @param x defines the 1st component of the value
|
|
2225
|
-
* @param y defines the 2nd component of the value
|
|
2226
|
-
* @returns true if the value was set
|
|
2227
|
-
*/
|
|
2228
|
-
setFloat2(uniform, x, y) {
|
|
2229
|
-
if (!uniform) {
|
|
2230
|
-
return false;
|
|
2231
|
-
}
|
|
2232
|
-
this._gl.uniform2f(uniform, x, y);
|
|
2233
|
-
return true;
|
|
2234
|
-
}
|
|
2235
|
-
/**
|
|
2236
|
-
* Set the value of an uniform to a vec3
|
|
2237
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2238
|
-
* @param x defines the 1st component of the value
|
|
2239
|
-
* @param y defines the 2nd component of the value
|
|
2240
|
-
* @param z defines the 3rd component of the value
|
|
2241
|
-
* @returns true if the value was set
|
|
2242
|
-
*/
|
|
2243
|
-
setFloat3(uniform, x, y, z) {
|
|
2244
|
-
if (!uniform) {
|
|
2245
|
-
return false;
|
|
2246
|
-
}
|
|
2247
|
-
this._gl.uniform3f(uniform, x, y, z);
|
|
2248
|
-
return true;
|
|
2249
|
-
}
|
|
2250
|
-
/**
|
|
2251
|
-
* Set the value of an uniform to a vec4
|
|
2252
|
-
* @param uniform defines the webGL uniform location where to store the value
|
|
2253
|
-
* @param x defines the 1st component of the value
|
|
2254
|
-
* @param y defines the 2nd component of the value
|
|
2255
|
-
* @param z defines the 3rd component of the value
|
|
2256
|
-
* @param w defines the 4th component of the value
|
|
2257
|
-
* @returns true if the value was set
|
|
2258
|
-
*/
|
|
2259
|
-
setFloat4(uniform, x, y, z, w) {
|
|
2260
|
-
if (!uniform) {
|
|
2261
|
-
return false;
|
|
2262
|
-
}
|
|
2263
|
-
this._gl.uniform4f(uniform, x, y, z, w);
|
|
2264
|
-
return true;
|
|
2265
|
-
}
|
|
2266
|
-
// States
|
|
2267
|
-
/**
|
|
2268
|
-
* Apply all cached states (depth, culling, stencil and alpha)
|
|
2269
|
-
*/
|
|
2270
|
-
applyStates() {
|
|
2271
|
-
this._depthCullingState.apply(this._gl);
|
|
2272
|
-
this._stencilStateComposer.apply(this._gl);
|
|
2273
|
-
this._alphaState.apply(this._gl);
|
|
2274
|
-
if (this._colorWriteChanged) {
|
|
2275
|
-
this._colorWriteChanged = false;
|
|
2276
|
-
const enable = this._colorWrite;
|
|
2277
|
-
this._gl.colorMask(enable, enable, enable, enable);
|
|
2278
|
-
}
|
|
2279
|
-
}
|
|
2280
|
-
// Textures
|
|
2281
|
-
/**
|
|
2282
|
-
* Force the entire cache to be cleared
|
|
2283
|
-
* You should not have to use this function unless your engine needs to share the webGL context with another engine
|
|
2284
|
-
* @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
|
|
2285
|
-
*/
|
|
2286
|
-
wipeCaches(bruteForce) {
|
|
2287
|
-
if (this.preventCacheWipeBetweenFrames && !bruteForce) {
|
|
2288
|
-
return;
|
|
2289
|
-
}
|
|
2290
|
-
this._currentEffect = null;
|
|
2291
|
-
this._viewportCached.x = 0;
|
|
2292
|
-
this._viewportCached.y = 0;
|
|
2293
|
-
this._viewportCached.z = 0;
|
|
2294
|
-
this._viewportCached.w = 0;
|
|
2295
|
-
// Done before in case we clean the attributes
|
|
2296
|
-
this._unbindVertexArrayObject();
|
|
2297
|
-
if (bruteForce) {
|
|
2298
|
-
this._currentProgram = null;
|
|
2299
|
-
this.resetTextureCache();
|
|
2300
|
-
this._stencilStateComposer.reset();
|
|
2301
|
-
this._depthCullingState.reset();
|
|
2302
|
-
this._depthCullingState.depthFunc = this._gl.LEQUAL;
|
|
2303
|
-
this._alphaState.reset();
|
|
2304
|
-
this._alphaMode = Constants.ALPHA_ADD;
|
|
2305
|
-
this._alphaEquation = Constants.ALPHA_DISABLE;
|
|
2306
|
-
this._colorWrite = true;
|
|
2307
|
-
this._colorWriteChanged = true;
|
|
2308
|
-
this._unpackFlipYCached = null;
|
|
2309
|
-
this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);
|
|
2310
|
-
this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
|
|
2311
|
-
this._mustWipeVertexAttributes = true;
|
|
2312
|
-
this.unbindAllAttributes();
|
|
2313
|
-
}
|
|
2314
|
-
this._resetVertexBufferBinding();
|
|
2315
|
-
this._cachedIndexBuffer = null;
|
|
2316
|
-
this._cachedEffectForVertexBuffers = null;
|
|
2317
|
-
this.bindIndexBuffer(null);
|
|
2318
|
-
}
|
|
2319
|
-
/**
|
|
2320
|
-
* @internal
|
|
2321
|
-
*/
|
|
2322
|
-
_getSamplingParameters(samplingMode, generateMipMaps) {
|
|
2323
|
-
const gl = this._gl;
|
|
2324
|
-
let magFilter = gl.NEAREST;
|
|
2325
|
-
let minFilter = gl.NEAREST;
|
|
2326
|
-
switch (samplingMode) {
|
|
2327
|
-
case Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST:
|
|
2328
|
-
magFilter = gl.LINEAR;
|
|
2329
|
-
if (generateMipMaps) {
|
|
2330
|
-
minFilter = gl.LINEAR_MIPMAP_NEAREST;
|
|
2331
|
-
}
|
|
2332
|
-
else {
|
|
2333
|
-
minFilter = gl.LINEAR;
|
|
2334
|
-
}
|
|
2335
|
-
break;
|
|
2336
|
-
case Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR:
|
|
2337
|
-
magFilter = gl.LINEAR;
|
|
2338
|
-
if (generateMipMaps) {
|
|
2339
|
-
minFilter = gl.LINEAR_MIPMAP_LINEAR;
|
|
2340
|
-
}
|
|
2341
|
-
else {
|
|
2342
|
-
minFilter = gl.LINEAR;
|
|
2343
|
-
}
|
|
2344
|
-
break;
|
|
2345
|
-
case Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR:
|
|
2346
|
-
magFilter = gl.NEAREST;
|
|
2347
|
-
if (generateMipMaps) {
|
|
2348
|
-
minFilter = gl.NEAREST_MIPMAP_LINEAR;
|
|
2349
|
-
}
|
|
2350
|
-
else {
|
|
2351
|
-
minFilter = gl.NEAREST;
|
|
2352
|
-
}
|
|
2353
|
-
break;
|
|
2354
|
-
case Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
|
|
2355
|
-
magFilter = gl.NEAREST;
|
|
2356
|
-
if (generateMipMaps) {
|
|
2357
|
-
minFilter = gl.NEAREST_MIPMAP_NEAREST;
|
|
2358
|
-
}
|
|
2359
|
-
else {
|
|
2360
|
-
minFilter = gl.NEAREST;
|
|
2361
|
-
}
|
|
2362
|
-
break;
|
|
2363
|
-
case Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
|
|
2364
|
-
magFilter = gl.NEAREST;
|
|
2365
|
-
if (generateMipMaps) {
|
|
2366
|
-
minFilter = gl.LINEAR_MIPMAP_NEAREST;
|
|
2367
|
-
}
|
|
2368
|
-
else {
|
|
2369
|
-
minFilter = gl.LINEAR;
|
|
2370
|
-
}
|
|
2371
|
-
break;
|
|
2372
|
-
case Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
|
|
2373
|
-
magFilter = gl.NEAREST;
|
|
2374
|
-
if (generateMipMaps) {
|
|
2375
|
-
minFilter = gl.LINEAR_MIPMAP_LINEAR;
|
|
2376
|
-
}
|
|
2377
|
-
else {
|
|
2378
|
-
minFilter = gl.LINEAR;
|
|
2379
|
-
}
|
|
2380
|
-
break;
|
|
2381
|
-
case Constants.TEXTURE_NEAREST_LINEAR:
|
|
2382
|
-
magFilter = gl.NEAREST;
|
|
2383
|
-
minFilter = gl.LINEAR;
|
|
2384
|
-
break;
|
|
2385
|
-
case Constants.TEXTURE_NEAREST_NEAREST:
|
|
2386
|
-
magFilter = gl.NEAREST;
|
|
2387
|
-
minFilter = gl.NEAREST;
|
|
2388
|
-
break;
|
|
2389
|
-
case Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
|
|
2390
|
-
magFilter = gl.LINEAR;
|
|
2391
|
-
if (generateMipMaps) {
|
|
2392
|
-
minFilter = gl.NEAREST_MIPMAP_NEAREST;
|
|
2393
|
-
}
|
|
2394
|
-
else {
|
|
2395
|
-
minFilter = gl.NEAREST;
|
|
2396
|
-
}
|
|
2397
|
-
break;
|
|
2398
|
-
case Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
|
|
2399
|
-
magFilter = gl.LINEAR;
|
|
2400
|
-
if (generateMipMaps) {
|
|
2401
|
-
minFilter = gl.NEAREST_MIPMAP_LINEAR;
|
|
2402
|
-
}
|
|
2403
|
-
else {
|
|
2404
|
-
minFilter = gl.NEAREST;
|
|
2405
|
-
}
|
|
2406
|
-
break;
|
|
2407
|
-
case Constants.TEXTURE_LINEAR_LINEAR:
|
|
2408
|
-
magFilter = gl.LINEAR;
|
|
2409
|
-
minFilter = gl.LINEAR;
|
|
2410
|
-
break;
|
|
2411
|
-
case Constants.TEXTURE_LINEAR_NEAREST:
|
|
2412
|
-
magFilter = gl.LINEAR;
|
|
2413
|
-
minFilter = gl.NEAREST;
|
|
2414
|
-
break;
|
|
2415
|
-
}
|
|
2416
|
-
return {
|
|
2417
|
-
min: minFilter,
|
|
2418
|
-
mag: magFilter,
|
|
2419
|
-
};
|
|
2420
|
-
}
|
|
2421
|
-
/** @internal */
|
|
2422
|
-
_createTexture() {
|
|
2423
|
-
const texture = this._gl.createTexture();
|
|
2424
|
-
if (!texture) {
|
|
2425
|
-
throw new Error("Unable to create texture");
|
|
2426
|
-
}
|
|
2427
|
-
return texture;
|
|
2428
|
-
}
|
|
2429
|
-
/** @internal */
|
|
2430
|
-
_createHardwareTexture() {
|
|
2431
|
-
return new WebGLHardwareTexture(this._createTexture(), this._gl);
|
|
2432
|
-
}
|
|
2433
|
-
/**
|
|
2434
|
-
* Creates an internal texture without binding it to a framebuffer
|
|
2435
|
-
* @internal
|
|
2436
|
-
* @param size defines the size of the texture
|
|
2437
|
-
* @param options defines the options used to create the texture
|
|
2438
|
-
* @param delayGPUTextureCreation true to delay the texture creation the first time it is really needed. false to create it right away
|
|
2439
|
-
* @param source source type of the texture
|
|
2440
|
-
* @returns a new internal texture
|
|
2441
|
-
*/
|
|
2442
|
-
_createInternalTexture(size, options, delayGPUTextureCreation = true, source = 0 /* InternalTextureSource.Unknown */) {
|
|
2443
|
-
let generateMipMaps = false;
|
|
2444
|
-
let createMipMaps = false;
|
|
2445
|
-
let type = Constants.TEXTURETYPE_UNSIGNED_BYTE;
|
|
2446
|
-
let samplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE;
|
|
2447
|
-
let format = Constants.TEXTUREFORMAT_RGBA;
|
|
2448
|
-
let useSRGBBuffer = false;
|
|
2449
|
-
let samples = 1;
|
|
2450
|
-
let label;
|
|
2451
|
-
let createMSAATexture = false;
|
|
2452
|
-
let comparisonFunction = 0;
|
|
2453
|
-
if (options !== undefined && typeof options === "object") {
|
|
2454
|
-
generateMipMaps = !!options.generateMipMaps;
|
|
2455
|
-
createMipMaps = !!options.createMipMaps;
|
|
2456
|
-
type = options.type === undefined ? Constants.TEXTURETYPE_UNSIGNED_BYTE : options.type;
|
|
2457
|
-
samplingMode = options.samplingMode === undefined ? Constants.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
|
|
2458
|
-
format = options.format === undefined ? Constants.TEXTUREFORMAT_RGBA : options.format;
|
|
2459
|
-
useSRGBBuffer = options.useSRGBBuffer === undefined ? false : options.useSRGBBuffer;
|
|
2460
|
-
samples = options.samples ?? 1;
|
|
2461
|
-
label = options.label;
|
|
2462
|
-
createMSAATexture = !!options.createMSAATexture;
|
|
2463
|
-
comparisonFunction = options.comparisonFunction || 0;
|
|
2464
|
-
}
|
|
2465
|
-
else {
|
|
2466
|
-
generateMipMaps = !!options;
|
|
2467
|
-
}
|
|
2468
|
-
useSRGBBuffer &&= this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || this.isWebGPU);
|
|
2469
|
-
if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
|
|
2470
|
-
// if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
|
|
2471
|
-
samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;
|
|
2472
|
-
}
|
|
2473
|
-
else if (type === Constants.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
|
|
2474
|
-
// if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
|
|
2475
|
-
samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;
|
|
2476
|
-
}
|
|
2477
|
-
if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
|
|
2478
|
-
type = Constants.TEXTURETYPE_UNSIGNED_BYTE;
|
|
2479
|
-
Logger.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE");
|
|
2480
|
-
}
|
|
2481
|
-
const isDepthTexture = IsDepthTexture(format);
|
|
2482
|
-
const hasStencil = HasStencilAspect(format);
|
|
2483
|
-
const gl = this._gl;
|
|
2484
|
-
const texture = new InternalTexture(this, source);
|
|
2485
|
-
const width = size.width || size;
|
|
2486
|
-
const height = size.height || size;
|
|
2487
|
-
const depth = size.depth || 0;
|
|
2488
|
-
const layers = size.layers || 0;
|
|
2489
|
-
const filters = this._getSamplingParameters(samplingMode, (generateMipMaps || createMipMaps) && !isDepthTexture);
|
|
2490
|
-
const target = layers !== 0 ? gl.TEXTURE_2D_ARRAY : depth !== 0 ? gl.TEXTURE_3D : gl.TEXTURE_2D;
|
|
2491
|
-
const sizedFormat = isDepthTexture
|
|
2492
|
-
? this._getInternalFormatFromDepthTextureFormat(format, true, hasStencil)
|
|
2493
|
-
: this._getRGBABufferInternalSizedFormat(type, format, useSRGBBuffer);
|
|
2494
|
-
const internalFormat = isDepthTexture ? (hasStencil ? gl.DEPTH_STENCIL : gl.DEPTH_COMPONENT) : this._getInternalFormat(format);
|
|
2495
|
-
const textureType = isDepthTexture ? this._getWebGLTextureTypeFromDepthTextureFormat(format) : this._getWebGLTextureType(type);
|
|
2496
|
-
// Bind
|
|
2497
|
-
this._bindTextureDirectly(target, texture);
|
|
2498
|
-
if (layers !== 0) {
|
|
2499
|
-
texture.is2DArray = true;
|
|
2500
|
-
gl.texImage3D(target, 0, sizedFormat, width, height, layers, 0, internalFormat, textureType, null);
|
|
2501
|
-
}
|
|
2502
|
-
else if (depth !== 0) {
|
|
2503
|
-
texture.is3D = true;
|
|
2504
|
-
gl.texImage3D(target, 0, sizedFormat, width, height, depth, 0, internalFormat, textureType, null);
|
|
2505
|
-
}
|
|
2506
|
-
else {
|
|
2507
|
-
gl.texImage2D(target, 0, sizedFormat, width, height, 0, internalFormat, textureType, null);
|
|
2508
|
-
}
|
|
2509
|
-
gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, filters.mag);
|
|
2510
|
-
gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, filters.min);
|
|
2511
|
-
gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
2512
|
-
gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
2513
|
-
if (isDepthTexture && this.webGLVersion > 1) {
|
|
2514
|
-
if (comparisonFunction === 0) {
|
|
2515
|
-
gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Constants.LEQUAL);
|
|
2516
|
-
gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
|
|
2517
|
-
}
|
|
2518
|
-
else {
|
|
2519
|
-
gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
|
|
2520
|
-
gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
|
|
2521
|
-
}
|
|
2522
|
-
}
|
|
2523
|
-
// MipMaps
|
|
2524
|
-
if (generateMipMaps || createMipMaps) {
|
|
2525
|
-
this._gl.generateMipmap(target);
|
|
2526
|
-
}
|
|
2527
|
-
this._bindTextureDirectly(target, null);
|
|
2528
|
-
texture._useSRGBBuffer = useSRGBBuffer;
|
|
2529
|
-
texture.baseWidth = width;
|
|
2530
|
-
texture.baseHeight = height;
|
|
2531
|
-
texture.width = width;
|
|
2532
|
-
texture.height = height;
|
|
2533
|
-
texture.depth = layers || depth;
|
|
2534
|
-
texture.isReady = true;
|
|
2535
|
-
texture.samples = samples;
|
|
2536
|
-
texture.generateMipMaps = generateMipMaps;
|
|
2537
|
-
texture.samplingMode = samplingMode;
|
|
2538
|
-
texture.type = type;
|
|
2539
|
-
texture.format = format;
|
|
2540
|
-
texture.label = label;
|
|
2541
|
-
texture.comparisonFunction = comparisonFunction;
|
|
2542
|
-
this._internalTexturesCache.push(texture);
|
|
2543
|
-
if (createMSAATexture) {
|
|
2544
|
-
let renderBuffer = null;
|
|
2545
|
-
if (IsDepthTexture(texture.format)) {
|
|
2546
|
-
renderBuffer = this._setupFramebufferDepthAttachments(HasStencilAspect(texture.format), texture.format !== Constants.TEXTUREFORMAT_STENCIL8, texture.width, texture.height, samples, texture.format, true);
|
|
2547
|
-
}
|
|
2548
|
-
else {
|
|
2549
|
-
renderBuffer = this._createRenderBuffer(texture.width, texture.height, samples, -1 /* not used */, this._getRGBABufferInternalSizedFormat(texture.type, texture.format, texture._useSRGBBuffer), -1 /* attachment */);
|
|
2550
|
-
}
|
|
2551
|
-
if (!renderBuffer) {
|
|
2552
|
-
throw new Error("Unable to create render buffer");
|
|
2553
|
-
}
|
|
2554
|
-
texture._autoMSAAManagement = true;
|
|
2555
|
-
let hardwareTexture = texture._hardwareTexture;
|
|
2556
|
-
if (!hardwareTexture) {
|
|
2557
|
-
hardwareTexture = texture._hardwareTexture = this._createHardwareTexture();
|
|
2558
|
-
}
|
|
2559
|
-
hardwareTexture.addMSAARenderBuffer(renderBuffer);
|
|
2560
|
-
}
|
|
2561
|
-
return texture;
|
|
2562
|
-
}
|
|
2563
|
-
/**
|
|
2564
|
-
* @internal
|
|
2565
|
-
*/
|
|
2566
|
-
_getUseSRGBBuffer(useSRGBBuffer, noMipmap) {
|
|
2567
|
-
// Generating mipmaps for sRGB textures is not supported in WebGL1 so we must disable the support if mipmaps is enabled
|
|
2568
|
-
return useSRGBBuffer && this._caps.supportSRGBBuffers && (this.webGLVersion > 1 || noMipmap);
|
|
2569
|
-
}
|
|
2570
|
-
/**
|
|
2571
|
-
* Usually called from Texture.ts.
|
|
2572
|
-
* Passed information to create a WebGLTexture
|
|
2573
|
-
* @param url defines a value which contains one of the following:
|
|
2574
|
-
* * A conventional http URL, e.g. 'http://...' or 'file://...'
|
|
2575
|
-
* * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
|
|
2576
|
-
* * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
|
|
2577
|
-
* @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
|
|
2578
|
-
* @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
|
|
2579
|
-
* @param scene needed for loading to the correct scene
|
|
2580
|
-
* @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
|
|
2581
|
-
* @param onLoad optional callback to be called upon successful completion
|
|
2582
|
-
* @param onError optional callback to be called upon failure
|
|
2583
|
-
* @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
|
|
2584
|
-
* @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
|
|
2585
|
-
* @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
|
|
2586
|
-
* @param forcedExtension defines the extension to use to pick the right loader
|
|
2587
|
-
* @param mimeType defines an optional mime type
|
|
2588
|
-
* @param loaderOptions options to be passed to the loader
|
|
2589
|
-
* @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)
|
|
2590
|
-
* @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
|
|
2591
|
-
* @returns a InternalTexture for assignment back into BABYLON.Texture
|
|
2592
|
-
*/
|
|
2593
|
-
createTexture(url, noMipmap, invertY, scene, samplingMode = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE, onLoad = null, onError = null, buffer = null, fallback = null, format = null, forcedExtension = null, mimeType, loaderOptions, creationFlags, useSRGBBuffer) {
|
|
2594
|
-
return this._createTextureBase(url, noMipmap, invertY, scene, samplingMode, onLoad, onError, (...args) => this._prepareWebGLTexture(...args, format), (potWidth, potHeight, img, extension, texture, continuationCallback) => {
|
|
2595
|
-
const gl = this._gl;
|
|
2596
|
-
const isPot = img.width === potWidth && img.height === potHeight;
|
|
2597
|
-
texture._creationFlags = creationFlags ?? 0;
|
|
2598
|
-
const tip = this._getTexImageParametersForCreateTexture(texture.format, texture._useSRGBBuffer);
|
|
2599
|
-
if (isPot) {
|
|
2600
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, tip.internalFormat, tip.format, tip.type, img);
|
|
2601
|
-
return false;
|
|
2602
|
-
}
|
|
2603
|
-
const maxTextureSize = this._caps.maxTextureSize;
|
|
2604
|
-
if (img.width > maxTextureSize || img.height > maxTextureSize || !this._supportsHardwareTextureRescaling) {
|
|
2605
|
-
this._prepareWorkingCanvas();
|
|
2606
|
-
if (!this._workingCanvas || !this._workingContext) {
|
|
2607
|
-
return false;
|
|
2608
|
-
}
|
|
2609
|
-
this._workingCanvas.width = potWidth;
|
|
2610
|
-
this._workingCanvas.height = potHeight;
|
|
2611
|
-
this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
|
|
2612
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, tip.internalFormat, tip.format, tip.type, this._workingCanvas);
|
|
2613
|
-
texture.width = potWidth;
|
|
2614
|
-
texture.height = potHeight;
|
|
2615
|
-
return false;
|
|
2616
|
-
}
|
|
2617
|
-
else {
|
|
2618
|
-
// Using shaders when possible to rescale because canvas.drawImage is lossy
|
|
2619
|
-
const source = new InternalTexture(this, 2 /* InternalTextureSource.Temp */);
|
|
2620
|
-
this._bindTextureDirectly(gl.TEXTURE_2D, source, true);
|
|
2621
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, tip.internalFormat, tip.format, tip.type, img);
|
|
2622
|
-
this._rescaleTexture(source, texture, scene, tip.format, () => {
|
|
2623
|
-
this._releaseTexture(source);
|
|
2624
|
-
this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
|
|
2625
|
-
continuationCallback();
|
|
2626
|
-
});
|
|
2627
|
-
}
|
|
2628
|
-
return true;
|
|
2629
|
-
}, buffer, fallback, format, forcedExtension, mimeType, loaderOptions, useSRGBBuffer);
|
|
2630
|
-
}
|
|
2631
|
-
/**
|
|
2632
|
-
* Calls to the GL texImage2D and texImage3D functions require three arguments describing the pixel format of the texture.
|
|
2633
|
-
* createTexture derives these from the babylonFormat and useSRGBBuffer arguments and also the file extension of the URL it's working with.
|
|
2634
|
-
* This function encapsulates that derivation for easy unit testing.
|
|
2635
|
-
* @param babylonFormat Babylon's format enum, as specified in ITextureCreationOptions.
|
|
2636
|
-
* @param fileExtension The file extension including the dot, e.g. .jpg.
|
|
2637
|
-
* @param useSRGBBuffer Use SRGB not linear.
|
|
2638
|
-
* @returns The options to pass to texImage2D or texImage3D calls.
|
|
2639
|
-
* @internal
|
|
2640
|
-
*/
|
|
2641
|
-
_getTexImageParametersForCreateTexture(babylonFormat, useSRGBBuffer) {
|
|
2642
|
-
let format, internalFormat;
|
|
2643
|
-
if (this.webGLVersion === 1) {
|
|
2644
|
-
// In WebGL 1, format and internalFormat must be the same and taken from a limited set of values, see https://docs.gl/es2/glTexImage2D.
|
|
2645
|
-
// The SRGB extension (https://developer.mozilla.org/en-US/docs/Web/API/EXT_sRGB) adds some extra values, hence passing useSRGBBuffer
|
|
2646
|
-
// to getInternalFormat.
|
|
2647
|
-
format = this._getInternalFormat(babylonFormat, useSRGBBuffer);
|
|
2648
|
-
internalFormat = format;
|
|
2649
|
-
}
|
|
2650
|
-
else {
|
|
2651
|
-
// In WebGL 2, format has a wider range of values and internal format can be one of the sized formats, see
|
|
2652
|
-
// https://registry.khronos.org/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml.
|
|
2653
|
-
// SRGB is included in the sized format and should not be passed in "format", hence always passing useSRGBBuffer as false.
|
|
2654
|
-
format = this._getInternalFormat(babylonFormat, false);
|
|
2655
|
-
internalFormat = this._getRGBABufferInternalSizedFormat(Constants.TEXTURETYPE_UNSIGNED_BYTE, babylonFormat, useSRGBBuffer);
|
|
2656
|
-
}
|
|
2657
|
-
return {
|
|
2658
|
-
internalFormat,
|
|
2659
|
-
format,
|
|
2660
|
-
type: this._gl.UNSIGNED_BYTE,
|
|
2661
|
-
};
|
|
2662
|
-
}
|
|
2663
|
-
/**
|
|
2664
|
-
* @internal
|
|
2665
|
-
*/
|
|
2666
|
-
_rescaleTexture(source, destination, scene, internalFormat, onComplete) { }
|
|
2667
|
-
/**
|
|
2668
|
-
* @internal
|
|
2669
|
-
*/
|
|
2670
|
-
_unpackFlipY(value) {
|
|
2671
|
-
if (this._unpackFlipYCached !== value) {
|
|
2672
|
-
this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
|
|
2673
|
-
if (this.enableUnpackFlipYCached) {
|
|
2674
|
-
this._unpackFlipYCached = value;
|
|
2675
|
-
}
|
|
2676
|
-
}
|
|
2677
|
-
}
|
|
2678
|
-
/** @internal */
|
|
2679
|
-
_getUnpackAlignement() {
|
|
2680
|
-
return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
|
|
2681
|
-
}
|
|
2682
|
-
/** @internal */
|
|
2683
|
-
_getTextureTarget(texture) {
|
|
2684
|
-
if (texture.isCube) {
|
|
2685
|
-
return this._gl.TEXTURE_CUBE_MAP;
|
|
2686
|
-
}
|
|
2687
|
-
else if (texture.is3D) {
|
|
2688
|
-
return this._gl.TEXTURE_3D;
|
|
2689
|
-
}
|
|
2690
|
-
else if (texture.is2DArray || texture.isMultiview) {
|
|
2691
|
-
return this._gl.TEXTURE_2D_ARRAY;
|
|
2692
|
-
}
|
|
2693
|
-
return this._gl.TEXTURE_2D;
|
|
2694
|
-
}
|
|
2695
|
-
/**
|
|
2696
|
-
* Update the sampling mode of a given texture
|
|
2697
|
-
* @param samplingMode defines the required sampling mode
|
|
2698
|
-
* @param texture defines the texture to update
|
|
2699
|
-
* @param generateMipMaps defines whether to generate mipmaps for the texture
|
|
2700
|
-
*/
|
|
2701
|
-
updateTextureSamplingMode(samplingMode, texture, generateMipMaps = false) {
|
|
2702
|
-
const target = this._getTextureTarget(texture);
|
|
2703
|
-
const filters = this._getSamplingParameters(samplingMode, texture.useMipMaps || generateMipMaps);
|
|
2704
|
-
this._setTextureParameterInteger(target, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
|
|
2705
|
-
this._setTextureParameterInteger(target, this._gl.TEXTURE_MIN_FILTER, filters.min);
|
|
2706
|
-
if (generateMipMaps) {
|
|
2707
|
-
texture.generateMipMaps = true;
|
|
2708
|
-
this._gl.generateMipmap(target);
|
|
2709
|
-
}
|
|
2710
|
-
this._bindTextureDirectly(target, null);
|
|
2711
|
-
texture.samplingMode = samplingMode;
|
|
2712
|
-
}
|
|
2713
|
-
/**
|
|
2714
|
-
* Update the dimensions of a texture
|
|
2715
|
-
* @param texture texture to update
|
|
2716
|
-
* @param width new width of the texture
|
|
2717
|
-
* @param height new height of the texture
|
|
2718
|
-
* @param depth new depth of the texture
|
|
2719
|
-
*/
|
|
2720
|
-
updateTextureDimensions(texture, width, height, depth = 1) { }
|
|
2721
|
-
/**
|
|
2722
|
-
* Update the sampling mode of a given texture
|
|
2723
|
-
* @param texture defines the texture to update
|
|
2724
|
-
* @param wrapU defines the texture wrap mode of the u coordinates
|
|
2725
|
-
* @param wrapV defines the texture wrap mode of the v coordinates
|
|
2726
|
-
* @param wrapR defines the texture wrap mode of the r coordinates
|
|
2727
|
-
*/
|
|
2728
|
-
updateTextureWrappingMode(texture, wrapU, wrapV = null, wrapR = null) {
|
|
2729
|
-
const target = this._getTextureTarget(texture);
|
|
2730
|
-
if (wrapU !== null) {
|
|
2731
|
-
this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(wrapU), texture);
|
|
2732
|
-
texture._cachedWrapU = wrapU;
|
|
2733
|
-
}
|
|
2734
|
-
if (wrapV !== null) {
|
|
2735
|
-
this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(wrapV), texture);
|
|
2736
|
-
texture._cachedWrapV = wrapV;
|
|
2737
|
-
}
|
|
2738
|
-
if ((texture.is2DArray || texture.is3D) && wrapR !== null) {
|
|
2739
|
-
this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(wrapR), texture);
|
|
2740
|
-
texture._cachedWrapR = wrapR;
|
|
2741
|
-
}
|
|
2742
|
-
this._bindTextureDirectly(target, null);
|
|
2743
|
-
}
|
|
2744
|
-
/**
|
|
2745
|
-
* @internal
|
|
2746
|
-
*/
|
|
2747
|
-
_uploadCompressedDataToTextureDirectly(texture, internalFormat, width, height, data, faceIndex = 0, lod = 0) {
|
|
2748
|
-
const gl = this._gl;
|
|
2749
|
-
let target = gl.TEXTURE_2D;
|
|
2750
|
-
if (texture.isCube) {
|
|
2751
|
-
target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
|
|
2752
|
-
}
|
|
2753
|
-
if (texture._useSRGBBuffer) {
|
|
2754
|
-
switch (internalFormat) {
|
|
2755
|
-
case Constants.TEXTUREFORMAT_COMPRESSED_RGB8_ETC2:
|
|
2756
|
-
case Constants.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL:
|
|
2757
|
-
// Note, if using ETC1 and sRGB is requested, this will use ETC2 if available.
|
|
2758
|
-
if (this._caps.etc2) {
|
|
2759
|
-
internalFormat = gl.COMPRESSED_SRGB8_ETC2;
|
|
2760
|
-
}
|
|
2761
|
-
else {
|
|
2762
|
-
texture._useSRGBBuffer = false;
|
|
2763
|
-
}
|
|
2764
|
-
break;
|
|
2765
|
-
case Constants.TEXTUREFORMAT_COMPRESSED_RGBA8_ETC2_EAC:
|
|
2766
|
-
if (this._caps.etc2) {
|
|
2767
|
-
internalFormat = gl.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
|
|
2768
|
-
}
|
|
2769
|
-
else {
|
|
2770
|
-
texture._useSRGBBuffer = false;
|
|
2771
|
-
}
|
|
2772
|
-
break;
|
|
2773
|
-
case Constants.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:
|
|
2774
|
-
internalFormat = gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;
|
|
2775
|
-
break;
|
|
2776
|
-
case Constants.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:
|
|
2777
|
-
internalFormat = gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
|
|
2778
|
-
break;
|
|
2779
|
-
case Constants.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:
|
|
2780
|
-
if (this._caps.s3tc_srgb) {
|
|
2781
|
-
internalFormat = gl.COMPRESSED_SRGB_S3TC_DXT1_EXT;
|
|
2782
|
-
}
|
|
2783
|
-
else {
|
|
2784
|
-
// S3TC sRGB extension not supported
|
|
2785
|
-
texture._useSRGBBuffer = false;
|
|
2786
|
-
}
|
|
2787
|
-
break;
|
|
2788
|
-
case Constants.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1:
|
|
2789
|
-
if (this._caps.s3tc_srgb) {
|
|
2790
|
-
internalFormat = gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
|
|
2791
|
-
}
|
|
2792
|
-
else {
|
|
2793
|
-
// S3TC sRGB extension not supported
|
|
2794
|
-
texture._useSRGBBuffer = false;
|
|
2795
|
-
}
|
|
2796
|
-
break;
|
|
2797
|
-
case Constants.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:
|
|
2798
|
-
if (this._caps.s3tc_srgb) {
|
|
2799
|
-
internalFormat = gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
|
|
2800
|
-
}
|
|
2801
|
-
else {
|
|
2802
|
-
// S3TC sRGB extension not supported
|
|
2803
|
-
texture._useSRGBBuffer = false;
|
|
2804
|
-
}
|
|
2805
|
-
break;
|
|
2806
|
-
default:
|
|
2807
|
-
// We don't support a sRGB format corresponding to internalFormat, so revert to non sRGB format
|
|
2808
|
-
texture._useSRGBBuffer = false;
|
|
2809
|
-
break;
|
|
2810
|
-
}
|
|
2811
|
-
}
|
|
2812
|
-
this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
|
|
2813
|
-
}
|
|
2814
|
-
/**
|
|
2815
|
-
* @internal
|
|
2816
|
-
*/
|
|
2817
|
-
_uploadDataToTextureDirectly(texture, imageData, faceIndex = 0, lod = 0, babylonInternalFormat, useTextureWidthAndHeight = false) {
|
|
2818
|
-
const gl = this._gl;
|
|
2819
|
-
const textureType = this._getWebGLTextureType(texture.type);
|
|
2820
|
-
const format = this._getInternalFormat(texture.format);
|
|
2821
|
-
const internalFormat = babylonInternalFormat === undefined
|
|
2822
|
-
? this._getRGBABufferInternalSizedFormat(texture.type, texture.format, texture._useSRGBBuffer)
|
|
2823
|
-
: this._getInternalFormat(babylonInternalFormat, texture._useSRGBBuffer);
|
|
2824
|
-
this._unpackFlipY(texture.invertY);
|
|
2825
|
-
let target = gl.TEXTURE_2D;
|
|
2826
|
-
if (texture.isCube) {
|
|
2827
|
-
target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
|
|
2828
|
-
}
|
|
2829
|
-
const lodMaxWidth = Math.round(Math.log(texture.width) * Math.LOG2E);
|
|
2830
|
-
const lodMaxHeight = Math.round(Math.log(texture.height) * Math.LOG2E);
|
|
2831
|
-
const width = useTextureWidthAndHeight ? texture.width : Math.pow(2, Math.max(lodMaxWidth - lod, 0));
|
|
2832
|
-
const height = useTextureWidthAndHeight ? texture.height : Math.pow(2, Math.max(lodMaxHeight - lod, 0));
|
|
2833
|
-
gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
|
|
2834
|
-
}
|
|
2835
|
-
/**
|
|
2836
|
-
* Update a portion of an internal texture
|
|
2837
|
-
* @param texture defines the texture to update
|
|
2838
|
-
* @param imageData defines the data to store into the texture
|
|
2839
|
-
* @param xOffset defines the x coordinates of the update rectangle
|
|
2840
|
-
* @param yOffset defines the y coordinates of the update rectangle
|
|
2841
|
-
* @param width defines the width of the update rectangle
|
|
2842
|
-
* @param height defines the height of the update rectangle
|
|
2843
|
-
* @param faceIndex defines the face index if texture is a cube (0 by default)
|
|
2844
|
-
* @param lod defines the lod level to update (0 by default)
|
|
2845
|
-
* @param generateMipMaps defines whether to generate mipmaps or not
|
|
2846
|
-
*/
|
|
2847
|
-
updateTextureData(texture, imageData, xOffset, yOffset, width, height, faceIndex = 0, lod = 0, generateMipMaps = false) {
|
|
2848
|
-
const gl = this._gl;
|
|
2849
|
-
const textureType = this._getWebGLTextureType(texture.type);
|
|
2850
|
-
const format = this._getInternalFormat(texture.format);
|
|
2851
|
-
this._unpackFlipY(texture.invertY);
|
|
2852
|
-
let targetForBinding = gl.TEXTURE_2D;
|
|
2853
|
-
let target = gl.TEXTURE_2D;
|
|
2854
|
-
if (texture.isCube) {
|
|
2855
|
-
target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
|
|
2856
|
-
targetForBinding = gl.TEXTURE_CUBE_MAP;
|
|
2857
|
-
}
|
|
2858
|
-
this._bindTextureDirectly(targetForBinding, texture, true);
|
|
2859
|
-
gl.texSubImage2D(target, lod, xOffset, yOffset, width, height, format, textureType, imageData);
|
|
2860
|
-
if (generateMipMaps) {
|
|
2861
|
-
this._gl.generateMipmap(target);
|
|
2862
|
-
}
|
|
2863
|
-
this._bindTextureDirectly(targetForBinding, null);
|
|
2864
|
-
}
|
|
2865
|
-
/**
|
|
2866
|
-
* @internal
|
|
2867
|
-
*/
|
|
2868
|
-
_uploadArrayBufferViewToTexture(texture, imageData, faceIndex = 0, lod = 0) {
|
|
2869
|
-
const gl = this._gl;
|
|
2870
|
-
const bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
|
|
2871
|
-
this._bindTextureDirectly(bindTarget, texture, true);
|
|
2872
|
-
this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
|
|
2873
|
-
this._bindTextureDirectly(bindTarget, null, true);
|
|
2874
|
-
}
|
|
2875
|
-
_prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode) {
|
|
2876
|
-
const gl = this._gl;
|
|
2877
|
-
if (!gl) {
|
|
2878
|
-
return;
|
|
2879
|
-
}
|
|
2880
|
-
const filters = this._getSamplingParameters(samplingMode, !noMipmap);
|
|
2881
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
|
|
2882
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
|
|
2883
|
-
if (!noMipmap && !isCompressed) {
|
|
2884
|
-
gl.generateMipmap(gl.TEXTURE_2D);
|
|
2885
|
-
}
|
|
2886
|
-
this._bindTextureDirectly(gl.TEXTURE_2D, null);
|
|
2887
|
-
// this.resetTextureCache();
|
|
2888
|
-
if (scene) {
|
|
2889
|
-
scene.removePendingData(texture);
|
|
2890
|
-
}
|
|
2891
|
-
texture.onLoadedObservable.notifyObservers(texture);
|
|
2892
|
-
texture.onLoadedObservable.clear();
|
|
2893
|
-
}
|
|
2894
|
-
_prepareWebGLTexture(texture, extension, scene, img, invertY, noMipmap, isCompressed, processFunction, samplingMode, format) {
|
|
2895
|
-
const maxTextureSize = this.getCaps().maxTextureSize;
|
|
2896
|
-
const potWidth = Math.min(maxTextureSize, this.needPOTTextures ? GetExponentOfTwo(img.width, maxTextureSize) : img.width);
|
|
2897
|
-
const potHeight = Math.min(maxTextureSize, this.needPOTTextures ? GetExponentOfTwo(img.height, maxTextureSize) : img.height);
|
|
2898
|
-
const gl = this._gl;
|
|
2899
|
-
if (!gl) {
|
|
2900
|
-
return;
|
|
2901
|
-
}
|
|
2902
|
-
if (!texture._hardwareTexture) {
|
|
2903
|
-
// this.resetTextureCache();
|
|
2904
|
-
if (scene) {
|
|
2905
|
-
scene.removePendingData(texture);
|
|
2906
|
-
}
|
|
2907
|
-
return;
|
|
2908
|
-
}
|
|
2909
|
-
this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
|
|
2910
|
-
this._unpackFlipY(invertY === undefined ? true : invertY ? true : false);
|
|
2911
|
-
texture.baseWidth = img.width;
|
|
2912
|
-
texture.baseHeight = img.height;
|
|
2913
|
-
texture.width = potWidth;
|
|
2914
|
-
texture.height = potHeight;
|
|
2915
|
-
texture.isReady = true;
|
|
2916
|
-
texture.type = texture.type !== -1 ? texture.type : Constants.TEXTURETYPE_UNSIGNED_BYTE;
|
|
2917
|
-
texture.format =
|
|
2918
|
-
texture.format !== -1 ? texture.format : (format ?? (extension === ".jpg" && !texture._useSRGBBuffer ? Constants.TEXTUREFORMAT_RGB : Constants.TEXTUREFORMAT_RGBA));
|
|
2919
|
-
if (processFunction(potWidth, potHeight, img, extension, texture, () => {
|
|
2920
|
-
this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
|
|
2921
|
-
})) {
|
|
2922
|
-
// Returning as texture needs extra async steps
|
|
2923
|
-
return;
|
|
2924
|
-
}
|
|
2925
|
-
this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
|
|
2926
|
-
}
|
|
2927
|
-
_getInternalFormatFromDepthTextureFormat(textureFormat, hasDepth, hasStencil) {
|
|
2928
|
-
const gl = this._gl;
|
|
2929
|
-
if (!hasDepth) {
|
|
2930
|
-
return gl.STENCIL_INDEX8;
|
|
2931
|
-
}
|
|
2932
|
-
const format = hasStencil ? gl.DEPTH_STENCIL : gl.DEPTH_COMPONENT;
|
|
2933
|
-
let internalFormat = format;
|
|
2934
|
-
if (this.webGLVersion > 1) {
|
|
2935
|
-
if (textureFormat === Constants.TEXTUREFORMAT_DEPTH16) {
|
|
2936
|
-
internalFormat = gl.DEPTH_COMPONENT16;
|
|
2937
|
-
}
|
|
2938
|
-
else if (textureFormat === Constants.TEXTUREFORMAT_DEPTH24) {
|
|
2939
|
-
internalFormat = gl.DEPTH_COMPONENT24;
|
|
2940
|
-
}
|
|
2941
|
-
else if (textureFormat === Constants.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8 || textureFormat === Constants.TEXTUREFORMAT_DEPTH24_STENCIL8) {
|
|
2942
|
-
internalFormat = hasStencil ? gl.DEPTH24_STENCIL8 : gl.DEPTH_COMPONENT24;
|
|
2943
|
-
}
|
|
2944
|
-
else if (textureFormat === Constants.TEXTUREFORMAT_DEPTH32_FLOAT) {
|
|
2945
|
-
internalFormat = gl.DEPTH_COMPONENT32F;
|
|
2946
|
-
}
|
|
2947
|
-
else if (textureFormat === Constants.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8) {
|
|
2948
|
-
internalFormat = hasStencil ? gl.DEPTH32F_STENCIL8 : gl.DEPTH_COMPONENT32F;
|
|
2949
|
-
}
|
|
2950
|
-
}
|
|
2951
|
-
else {
|
|
2952
|
-
internalFormat = gl.DEPTH_COMPONENT16;
|
|
2953
|
-
}
|
|
2954
|
-
return internalFormat;
|
|
2955
|
-
}
|
|
2956
|
-
_getWebGLTextureTypeFromDepthTextureFormat(textureFormat) {
|
|
2957
|
-
const gl = this._gl;
|
|
2958
|
-
let type = gl.UNSIGNED_INT;
|
|
2959
|
-
if (textureFormat === Constants.TEXTUREFORMAT_DEPTH16) {
|
|
2960
|
-
type = gl.UNSIGNED_SHORT;
|
|
2961
|
-
}
|
|
2962
|
-
else if (textureFormat === Constants.TEXTUREFORMAT_DEPTH24UNORM_STENCIL8 || textureFormat === Constants.TEXTUREFORMAT_DEPTH24_STENCIL8) {
|
|
2963
|
-
type = gl.UNSIGNED_INT_24_8;
|
|
2964
|
-
}
|
|
2965
|
-
else if (textureFormat === Constants.TEXTUREFORMAT_DEPTH32_FLOAT) {
|
|
2966
|
-
type = gl.FLOAT;
|
|
2967
|
-
}
|
|
2968
|
-
else if (textureFormat === Constants.TEXTUREFORMAT_DEPTH32FLOAT_STENCIL8) {
|
|
2969
|
-
type = gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
|
|
2970
|
-
}
|
|
2971
|
-
else if (textureFormat === Constants.TEXTUREFORMAT_STENCIL8) {
|
|
2972
|
-
type = gl.UNSIGNED_BYTE;
|
|
2973
|
-
}
|
|
2974
|
-
return type;
|
|
2975
|
-
}
|
|
2976
|
-
/**
|
|
2977
|
-
* @internal
|
|
2978
|
-
*/
|
|
2979
|
-
_setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples = 1, depthTextureFormat, dontBindRenderBufferToFrameBuffer = false) {
|
|
2980
|
-
const gl = this._gl;
|
|
2981
|
-
depthTextureFormat = depthTextureFormat ?? (generateStencilBuffer ? Constants.TEXTUREFORMAT_DEPTH24_STENCIL8 : Constants.TEXTUREFORMAT_DEPTH32_FLOAT);
|
|
2982
|
-
const internalFormat = this._getInternalFormatFromDepthTextureFormat(depthTextureFormat, generateDepthBuffer, generateStencilBuffer);
|
|
2983
|
-
// Create the depth/stencil buffer
|
|
2984
|
-
if (generateStencilBuffer && generateDepthBuffer) {
|
|
2985
|
-
return this._createRenderBuffer(width, height, samples, gl.DEPTH_STENCIL, internalFormat, dontBindRenderBufferToFrameBuffer ? -1 : gl.DEPTH_STENCIL_ATTACHMENT);
|
|
2986
|
-
}
|
|
2987
|
-
if (generateDepthBuffer) {
|
|
2988
|
-
return this._createRenderBuffer(width, height, samples, internalFormat, internalFormat, dontBindRenderBufferToFrameBuffer ? -1 : gl.DEPTH_ATTACHMENT);
|
|
2989
|
-
}
|
|
2990
|
-
if (generateStencilBuffer) {
|
|
2991
|
-
return this._createRenderBuffer(width, height, samples, internalFormat, internalFormat, dontBindRenderBufferToFrameBuffer ? -1 : gl.STENCIL_ATTACHMENT);
|
|
2992
|
-
}
|
|
2993
|
-
return null;
|
|
2994
|
-
}
|
|
2995
|
-
/**
|
|
2996
|
-
* @internal
|
|
2997
|
-
*/
|
|
2998
|
-
_createRenderBuffer(width, height, samples, internalFormat, msInternalFormat, attachment, unbindBuffer = true) {
|
|
2999
|
-
const gl = this._gl;
|
|
3000
|
-
const renderBuffer = gl.createRenderbuffer();
|
|
3001
|
-
return this._updateRenderBuffer(renderBuffer, width, height, samples, internalFormat, msInternalFormat, attachment, unbindBuffer);
|
|
3002
|
-
}
|
|
3003
|
-
_updateRenderBuffer(renderBuffer, width, height, samples, internalFormat, msInternalFormat, attachment, unbindBuffer = true) {
|
|
3004
|
-
const gl = this._gl;
|
|
3005
|
-
gl.bindRenderbuffer(gl.RENDERBUFFER, renderBuffer);
|
|
3006
|
-
if (samples > 1 && gl.renderbufferStorageMultisample) {
|
|
3007
|
-
gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, msInternalFormat, width, height);
|
|
3008
|
-
}
|
|
3009
|
-
else {
|
|
3010
|
-
gl.renderbufferStorage(gl.RENDERBUFFER, internalFormat, width, height);
|
|
3011
|
-
}
|
|
3012
|
-
if (attachment !== -1) {
|
|
3013
|
-
gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, renderBuffer);
|
|
3014
|
-
}
|
|
3015
|
-
if (unbindBuffer) {
|
|
3016
|
-
gl.bindRenderbuffer(gl.RENDERBUFFER, null);
|
|
3017
|
-
}
|
|
3018
|
-
return renderBuffer;
|
|
3019
|
-
}
|
|
3020
|
-
/**
|
|
3021
|
-
* @internal
|
|
3022
|
-
*/
|
|
3023
|
-
_releaseTexture(texture) {
|
|
3024
|
-
this._deleteTexture(texture._hardwareTexture);
|
|
3025
|
-
// Unbind channels
|
|
3026
|
-
this.unbindAllTextures();
|
|
3027
|
-
const index = this._internalTexturesCache.indexOf(texture);
|
|
3028
|
-
if (index !== -1) {
|
|
3029
|
-
this._internalTexturesCache.splice(index, 1);
|
|
3030
|
-
}
|
|
3031
|
-
// Integrated fixed lod samplers.
|
|
3032
|
-
if (texture._lodTextureHigh) {
|
|
3033
|
-
texture._lodTextureHigh.dispose();
|
|
3034
|
-
}
|
|
3035
|
-
if (texture._lodTextureMid) {
|
|
3036
|
-
texture._lodTextureMid.dispose();
|
|
3037
|
-
}
|
|
3038
|
-
if (texture._lodTextureLow) {
|
|
3039
|
-
texture._lodTextureLow.dispose();
|
|
3040
|
-
}
|
|
3041
|
-
// Integrated irradiance map.
|
|
3042
|
-
if (texture._irradianceTexture) {
|
|
3043
|
-
texture._irradianceTexture.dispose();
|
|
3044
|
-
}
|
|
3045
|
-
}
|
|
3046
|
-
_deleteTexture(texture) {
|
|
3047
|
-
texture?.release();
|
|
3048
|
-
}
|
|
3049
|
-
_setProgram(program) {
|
|
3050
|
-
if (this._currentProgram !== program) {
|
|
3051
|
-
_setProgram(program, this._gl);
|
|
3052
|
-
this._currentProgram = program;
|
|
3053
|
-
}
|
|
3054
|
-
}
|
|
3055
|
-
/**
|
|
3056
|
-
* Binds an effect to the webGL context
|
|
3057
|
-
* @param effect defines the effect to bind
|
|
3058
|
-
*/
|
|
3059
|
-
bindSamplers(effect) {
|
|
3060
|
-
const webGLPipelineContext = effect.getPipelineContext();
|
|
3061
|
-
this._setProgram(webGLPipelineContext.program);
|
|
3062
|
-
const samplers = effect.getSamplers();
|
|
3063
|
-
for (let index = 0; index < samplers.length; index++) {
|
|
3064
|
-
const uniform = effect.getUniform(samplers[index]);
|
|
3065
|
-
if (uniform) {
|
|
3066
|
-
this._boundUniforms[index] = uniform;
|
|
3067
|
-
}
|
|
3068
|
-
}
|
|
3069
|
-
this._currentEffect = null;
|
|
3070
|
-
}
|
|
3071
|
-
_activateCurrentTexture() {
|
|
3072
|
-
if (this._currentTextureChannel !== this._activeChannel) {
|
|
3073
|
-
this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
|
|
3074
|
-
this._currentTextureChannel = this._activeChannel;
|
|
3075
|
-
}
|
|
3076
|
-
}
|
|
3077
|
-
/**
|
|
3078
|
-
* @internal
|
|
3079
|
-
*/
|
|
3080
|
-
_bindTextureDirectly(target, texture, forTextureDataUpdate = false, force = false) {
|
|
3081
|
-
let wasPreviouslyBound = false;
|
|
3082
|
-
const isTextureForRendering = texture && texture._associatedChannel > -1;
|
|
3083
|
-
if (forTextureDataUpdate && isTextureForRendering) {
|
|
3084
|
-
this._activeChannel = texture._associatedChannel;
|
|
3085
|
-
}
|
|
3086
|
-
const currentTextureBound = this._boundTexturesCache[this._activeChannel];
|
|
3087
|
-
if (currentTextureBound !== texture || force) {
|
|
3088
|
-
this._activateCurrentTexture();
|
|
3089
|
-
if (texture && texture.isMultiview) {
|
|
3090
|
-
//this._gl.bindTexture(target, texture ? texture._colorTextureArray : null);
|
|
3091
|
-
Logger.Error(["_bindTextureDirectly called with a multiview texture!", target, texture]);
|
|
3092
|
-
// eslint-disable-next-line no-throw-literal
|
|
3093
|
-
throw "_bindTextureDirectly called with a multiview texture!";
|
|
3094
|
-
}
|
|
3095
|
-
else {
|
|
3096
|
-
this._gl.bindTexture(target, texture?._hardwareTexture?.underlyingResource ?? null);
|
|
3097
|
-
}
|
|
3098
|
-
this._boundTexturesCache[this._activeChannel] = texture;
|
|
3099
|
-
if (texture) {
|
|
3100
|
-
texture._associatedChannel = this._activeChannel;
|
|
3101
|
-
}
|
|
3102
|
-
}
|
|
3103
|
-
else if (forTextureDataUpdate) {
|
|
3104
|
-
wasPreviouslyBound = true;
|
|
3105
|
-
this._activateCurrentTexture();
|
|
3106
|
-
}
|
|
3107
|
-
if (isTextureForRendering && !forTextureDataUpdate) {
|
|
3108
|
-
this._bindSamplerUniformToChannel(texture._associatedChannel, this._activeChannel);
|
|
3109
|
-
}
|
|
3110
|
-
return wasPreviouslyBound;
|
|
3111
|
-
}
|
|
3112
|
-
/**
|
|
3113
|
-
* @internal
|
|
3114
|
-
*/
|
|
3115
|
-
_bindTexture(channel, texture, name) {
|
|
3116
|
-
if (channel === undefined) {
|
|
3117
|
-
return;
|
|
3118
|
-
}
|
|
3119
|
-
if (texture) {
|
|
3120
|
-
texture._associatedChannel = channel;
|
|
3121
|
-
}
|
|
3122
|
-
this._activeChannel = channel;
|
|
3123
|
-
const target = texture ? this._getTextureTarget(texture) : this._gl.TEXTURE_2D;
|
|
3124
|
-
this._bindTextureDirectly(target, texture);
|
|
3125
|
-
}
|
|
3126
|
-
/**
|
|
3127
|
-
* Unbind all textures from the webGL context
|
|
3128
|
-
*/
|
|
3129
|
-
unbindAllTextures() {
|
|
3130
|
-
for (let channel = 0; channel < this._maxSimultaneousTextures; channel++) {
|
|
3131
|
-
this._activeChannel = channel;
|
|
3132
|
-
this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
|
|
3133
|
-
this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
|
|
3134
|
-
if (this.webGLVersion > 1) {
|
|
3135
|
-
this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
|
|
3136
|
-
this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null);
|
|
3137
|
-
}
|
|
3138
|
-
}
|
|
3139
|
-
}
|
|
3140
|
-
/**
|
|
3141
|
-
* Sets a texture to the according uniform.
|
|
3142
|
-
* @param channel The texture channel
|
|
3143
|
-
* @param uniform The uniform to set
|
|
3144
|
-
* @param texture The texture to apply
|
|
3145
|
-
* @param name The name of the uniform in the effect
|
|
3146
|
-
*/
|
|
3147
|
-
setTexture(channel, uniform, texture, name) {
|
|
3148
|
-
if (channel === undefined) {
|
|
3149
|
-
return;
|
|
3150
|
-
}
|
|
3151
|
-
if (uniform) {
|
|
3152
|
-
this._boundUniforms[channel] = uniform;
|
|
3153
|
-
}
|
|
3154
|
-
this._setTexture(channel, texture);
|
|
3155
|
-
}
|
|
3156
|
-
_bindSamplerUniformToChannel(sourceSlot, destination) {
|
|
3157
|
-
const uniform = this._boundUniforms[sourceSlot];
|
|
3158
|
-
if (!uniform || uniform._currentState === destination) {
|
|
3159
|
-
return;
|
|
3160
|
-
}
|
|
3161
|
-
this._gl.uniform1i(uniform, destination);
|
|
3162
|
-
uniform._currentState = destination;
|
|
3163
|
-
}
|
|
3164
|
-
_getTextureWrapMode(mode) {
|
|
3165
|
-
switch (mode) {
|
|
3166
|
-
case Constants.TEXTURE_WRAP_ADDRESSMODE:
|
|
3167
|
-
return this._gl.REPEAT;
|
|
3168
|
-
case Constants.TEXTURE_CLAMP_ADDRESSMODE:
|
|
3169
|
-
return this._gl.CLAMP_TO_EDGE;
|
|
3170
|
-
case Constants.TEXTURE_MIRROR_ADDRESSMODE:
|
|
3171
|
-
return this._gl.MIRRORED_REPEAT;
|
|
3172
|
-
}
|
|
3173
|
-
return this._gl.REPEAT;
|
|
3174
|
-
}
|
|
3175
|
-
_setTexture(channel, texture, isPartOfTextureArray = false, depthStencilTexture = false, name = "") {
|
|
3176
|
-
// Not ready?
|
|
3177
|
-
if (!texture) {
|
|
3178
|
-
if (this._boundTexturesCache[channel] != null) {
|
|
3179
|
-
this._activeChannel = channel;
|
|
3180
|
-
this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
|
|
3181
|
-
this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
|
|
3182
|
-
if (this.webGLVersion > 1) {
|
|
3183
|
-
this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
|
|
3184
|
-
this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, null);
|
|
3185
|
-
}
|
|
3186
|
-
}
|
|
3187
|
-
return false;
|
|
3188
|
-
}
|
|
3189
|
-
// Video
|
|
3190
|
-
if (texture.video) {
|
|
3191
|
-
this._activeChannel = channel;
|
|
3192
|
-
const videoInternalTexture = texture.getInternalTexture();
|
|
3193
|
-
if (videoInternalTexture) {
|
|
3194
|
-
videoInternalTexture._associatedChannel = channel;
|
|
3195
|
-
}
|
|
3196
|
-
texture.update();
|
|
3197
|
-
}
|
|
3198
|
-
else if (texture.delayLoadState === Constants.DELAYLOADSTATE_NOTLOADED) {
|
|
3199
|
-
// Delay loading
|
|
3200
|
-
texture.delayLoad();
|
|
3201
|
-
return false;
|
|
3202
|
-
}
|
|
3203
|
-
let internalTexture;
|
|
3204
|
-
if (depthStencilTexture) {
|
|
3205
|
-
internalTexture = texture.depthStencilTexture;
|
|
3206
|
-
}
|
|
3207
|
-
else if (texture.isReady()) {
|
|
3208
|
-
internalTexture = texture.getInternalTexture();
|
|
3209
|
-
}
|
|
3210
|
-
else if (texture.isCube) {
|
|
3211
|
-
internalTexture = this.emptyCubeTexture;
|
|
3212
|
-
}
|
|
3213
|
-
else if (texture.is3D) {
|
|
3214
|
-
internalTexture = this.emptyTexture3D;
|
|
3215
|
-
}
|
|
3216
|
-
else if (texture.is2DArray) {
|
|
3217
|
-
internalTexture = this.emptyTexture2DArray;
|
|
3218
|
-
}
|
|
3219
|
-
else {
|
|
3220
|
-
internalTexture = this.emptyTexture;
|
|
3221
|
-
}
|
|
3222
|
-
if (!isPartOfTextureArray && internalTexture) {
|
|
3223
|
-
internalTexture._associatedChannel = channel;
|
|
3224
|
-
}
|
|
3225
|
-
let needToBind = true;
|
|
3226
|
-
if (this._boundTexturesCache[channel] === internalTexture) {
|
|
3227
|
-
if (!isPartOfTextureArray) {
|
|
3228
|
-
this._bindSamplerUniformToChannel(internalTexture._associatedChannel, channel);
|
|
3229
|
-
}
|
|
3230
|
-
needToBind = false;
|
|
3231
|
-
}
|
|
3232
|
-
this._activeChannel = channel;
|
|
3233
|
-
const target = this._getTextureTarget(internalTexture);
|
|
3234
|
-
if (needToBind) {
|
|
3235
|
-
this._bindTextureDirectly(target, internalTexture, isPartOfTextureArray);
|
|
3236
|
-
}
|
|
3237
|
-
if (internalTexture && !internalTexture.isMultiview) {
|
|
3238
|
-
// CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
|
|
3239
|
-
if (internalTexture.isCube && internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
|
|
3240
|
-
internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
|
|
3241
|
-
const textureWrapMode = texture.coordinatesMode !== Constants.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Constants.TEXTURE_SKYBOX_MODE
|
|
3242
|
-
? Constants.TEXTURE_WRAP_ADDRESSMODE
|
|
3243
|
-
: Constants.TEXTURE_CLAMP_ADDRESSMODE;
|
|
3244
|
-
texture.wrapU = textureWrapMode;
|
|
3245
|
-
texture.wrapV = textureWrapMode;
|
|
3246
|
-
}
|
|
3247
|
-
if (internalTexture._cachedWrapU !== texture.wrapU) {
|
|
3248
|
-
internalTexture._cachedWrapU = texture.wrapU;
|
|
3249
|
-
this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
|
|
3250
|
-
}
|
|
3251
|
-
if (internalTexture._cachedWrapV !== texture.wrapV) {
|
|
3252
|
-
internalTexture._cachedWrapV = texture.wrapV;
|
|
3253
|
-
this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
|
|
3254
|
-
}
|
|
3255
|
-
if (internalTexture.is3D && internalTexture._cachedWrapR !== texture.wrapR) {
|
|
3256
|
-
internalTexture._cachedWrapR = texture.wrapR;
|
|
3257
|
-
this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
|
|
3258
|
-
}
|
|
3259
|
-
this._setAnisotropicLevel(target, internalTexture, texture.anisotropicFilteringLevel);
|
|
3260
|
-
}
|
|
3261
|
-
return true;
|
|
3262
|
-
}
|
|
3263
|
-
/**
|
|
3264
|
-
* Sets an array of texture to the webGL context
|
|
3265
|
-
* @param channel defines the channel where the texture array must be set
|
|
3266
|
-
* @param uniform defines the associated uniform location
|
|
3267
|
-
* @param textures defines the array of textures to bind
|
|
3268
|
-
* @param name name of the channel
|
|
3269
|
-
*/
|
|
3270
|
-
setTextureArray(channel, uniform, textures, name) {
|
|
3271
|
-
if (channel === undefined || !uniform) {
|
|
3272
|
-
return;
|
|
3273
|
-
}
|
|
3274
|
-
if (!this._textureUnits || this._textureUnits.length !== textures.length) {
|
|
3275
|
-
this._textureUnits = new Int32Array(textures.length);
|
|
3276
|
-
}
|
|
3277
|
-
for (let i = 0; i < textures.length; i++) {
|
|
3278
|
-
const texture = textures[i].getInternalTexture();
|
|
3279
|
-
if (texture) {
|
|
3280
|
-
this._textureUnits[i] = channel + i;
|
|
3281
|
-
texture._associatedChannel = channel + i;
|
|
3282
|
-
}
|
|
3283
|
-
else {
|
|
3284
|
-
this._textureUnits[i] = -1;
|
|
3285
|
-
}
|
|
3286
|
-
}
|
|
3287
|
-
this._gl.uniform1iv(uniform, this._textureUnits);
|
|
3288
|
-
for (let index = 0; index < textures.length; index++) {
|
|
3289
|
-
this._setTexture(this._textureUnits[index], textures[index], true);
|
|
3290
|
-
}
|
|
3291
|
-
}
|
|
3292
|
-
/**
|
|
3293
|
-
* @internal
|
|
3294
|
-
*/
|
|
3295
|
-
_setAnisotropicLevel(target, internalTexture, anisotropicFilteringLevel) {
|
|
3296
|
-
const anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
|
|
3297
|
-
if (internalTexture.samplingMode !== Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST &&
|
|
3298
|
-
internalTexture.samplingMode !== Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR &&
|
|
3299
|
-
internalTexture.samplingMode !== Constants.TEXTURE_LINEAR_LINEAR) {
|
|
3300
|
-
anisotropicFilteringLevel = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
|
|
3301
|
-
}
|
|
3302
|
-
if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== anisotropicFilteringLevel) {
|
|
3303
|
-
this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(anisotropicFilteringLevel, this._caps.maxAnisotropy), internalTexture);
|
|
3304
|
-
internalTexture._cachedAnisotropicFilteringLevel = anisotropicFilteringLevel;
|
|
3305
|
-
}
|
|
3306
|
-
}
|
|
3307
|
-
_setTextureParameterFloat(target, parameter, value, texture) {
|
|
3308
|
-
this._bindTextureDirectly(target, texture, true, true);
|
|
3309
|
-
this._gl.texParameterf(target, parameter, value);
|
|
3310
|
-
}
|
|
3311
|
-
_setTextureParameterInteger(target, parameter, value, texture) {
|
|
3312
|
-
if (texture) {
|
|
3313
|
-
this._bindTextureDirectly(target, texture, true, true);
|
|
3314
|
-
}
|
|
3315
|
-
this._gl.texParameteri(target, parameter, value);
|
|
3316
|
-
}
|
|
3317
|
-
/**
|
|
3318
|
-
* Unbind all vertex attributes from the webGL context
|
|
3319
|
-
*/
|
|
3320
|
-
unbindAllAttributes() {
|
|
3321
|
-
if (this._mustWipeVertexAttributes) {
|
|
3322
|
-
this._mustWipeVertexAttributes = false;
|
|
3323
|
-
for (let i = 0; i < this._caps.maxVertexAttribs; i++) {
|
|
3324
|
-
this.disableAttributeByIndex(i);
|
|
3325
|
-
}
|
|
3326
|
-
return;
|
|
3327
|
-
}
|
|
3328
|
-
for (let i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
|
|
3329
|
-
if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
|
|
3330
|
-
continue;
|
|
3331
|
-
}
|
|
3332
|
-
this.disableAttributeByIndex(i);
|
|
3333
|
-
}
|
|
3334
|
-
}
|
|
3335
|
-
/**
|
|
3336
|
-
* Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
|
|
3337
|
-
*/
|
|
3338
|
-
releaseEffects() {
|
|
3339
|
-
const keys = Object.keys(this._compiledEffects);
|
|
3340
|
-
for (const name of keys) {
|
|
3341
|
-
const effect = this._compiledEffects[name];
|
|
3342
|
-
effect.dispose(true);
|
|
3343
|
-
}
|
|
3344
|
-
this._compiledEffects = {};
|
|
3345
|
-
}
|
|
3346
|
-
/**
|
|
3347
|
-
* Dispose and release all associated resources
|
|
3348
|
-
*/
|
|
3349
|
-
dispose() {
|
|
3350
|
-
// Events
|
|
3351
|
-
if (IsWindowObjectExist()) {
|
|
3352
|
-
if (this._renderingCanvas) {
|
|
3353
|
-
this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
|
|
3354
|
-
if (this._onContextRestored) {
|
|
3355
|
-
this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
|
|
3356
|
-
}
|
|
3357
|
-
}
|
|
3358
|
-
}
|
|
3359
|
-
// Should not be moved up of renderingCanvas will be null.
|
|
3360
|
-
super.dispose();
|
|
3361
|
-
if (this._dummyFramebuffer) {
|
|
3362
|
-
this._gl.deleteFramebuffer(this._dummyFramebuffer);
|
|
3363
|
-
}
|
|
3364
|
-
// Unbind
|
|
3365
|
-
this.unbindAllAttributes();
|
|
3366
|
-
this._boundUniforms = {};
|
|
3367
|
-
this._workingCanvas = null;
|
|
3368
|
-
this._workingContext = null;
|
|
3369
|
-
this._currentBufferPointers.length = 0;
|
|
3370
|
-
this._currentProgram = null;
|
|
3371
|
-
if (this._creationOptions.loseContextOnDispose) {
|
|
3372
|
-
this._gl.getExtension("WEBGL_lose_context")?.loseContext();
|
|
3373
|
-
}
|
|
3374
|
-
// clear the state object
|
|
3375
|
-
deleteStateObject(this._gl);
|
|
3376
|
-
}
|
|
3377
|
-
/**
|
|
3378
|
-
* Attach a new callback raised when context lost event is fired
|
|
3379
|
-
* @param callback defines the callback to call
|
|
3380
|
-
*/
|
|
3381
|
-
attachContextLostEvent(callback) {
|
|
3382
|
-
if (this._renderingCanvas) {
|
|
3383
|
-
this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
|
|
3384
|
-
}
|
|
3385
|
-
}
|
|
3386
|
-
/**
|
|
3387
|
-
* Attach a new callback raised when context restored event is fired
|
|
3388
|
-
* @param callback defines the callback to call
|
|
3389
|
-
*/
|
|
3390
|
-
attachContextRestoredEvent(callback) {
|
|
3391
|
-
if (this._renderingCanvas) {
|
|
3392
|
-
this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
|
|
3393
|
-
}
|
|
3394
|
-
}
|
|
3395
|
-
/**
|
|
3396
|
-
* Get the current error code of the webGL context
|
|
3397
|
-
* @returns the error code
|
|
3398
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
|
|
3399
|
-
*/
|
|
3400
|
-
getError() {
|
|
3401
|
-
return this._gl.getError();
|
|
3402
|
-
}
|
|
3403
|
-
_canRenderToFloatFramebuffer() {
|
|
3404
|
-
if (this._webGLVersion > 1) {
|
|
3405
|
-
return this._caps.colorBufferFloat;
|
|
3406
|
-
}
|
|
3407
|
-
return this._canRenderToFramebuffer(Constants.TEXTURETYPE_FLOAT);
|
|
3408
|
-
}
|
|
3409
|
-
_canRenderToHalfFloatFramebuffer() {
|
|
3410
|
-
if (this._webGLVersion > 1) {
|
|
3411
|
-
return this._caps.colorBufferFloat;
|
|
3412
|
-
}
|
|
3413
|
-
return this._canRenderToFramebuffer(Constants.TEXTURETYPE_HALF_FLOAT);
|
|
3414
|
-
}
|
|
3415
|
-
// Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
|
|
3416
|
-
_canRenderToFramebuffer(type) {
|
|
3417
|
-
const gl = this._gl;
|
|
3418
|
-
//clear existing errors
|
|
3419
|
-
// eslint-disable-next-line no-empty
|
|
3420
|
-
while (gl.getError() !== gl.NO_ERROR) { }
|
|
3421
|
-
let successful = true;
|
|
3422
|
-
const texture = gl.createTexture();
|
|
3423
|
-
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
3424
|
-
gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
|
|
3425
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
3426
|
-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
3427
|
-
const fb = gl.createFramebuffer();
|
|
3428
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
|
|
3429
|
-
gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
|
|
3430
|
-
const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
|
|
3431
|
-
successful = successful && status === gl.FRAMEBUFFER_COMPLETE;
|
|
3432
|
-
successful = successful && gl.getError() === gl.NO_ERROR;
|
|
3433
|
-
//try render by clearing frame buffer's color buffer
|
|
3434
|
-
if (successful) {
|
|
3435
|
-
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
3436
|
-
successful = successful && gl.getError() === gl.NO_ERROR;
|
|
3437
|
-
}
|
|
3438
|
-
//try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
|
|
3439
|
-
if (successful) {
|
|
3440
|
-
//in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
|
|
3441
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
3442
|
-
const readFormat = gl.RGBA;
|
|
3443
|
-
const readType = gl.UNSIGNED_BYTE;
|
|
3444
|
-
const buffer = new Uint8Array(4);
|
|
3445
|
-
gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
|
|
3446
|
-
successful = successful && gl.getError() === gl.NO_ERROR;
|
|
3447
|
-
}
|
|
3448
|
-
//clean up
|
|
3449
|
-
gl.deleteTexture(texture);
|
|
3450
|
-
gl.deleteFramebuffer(fb);
|
|
3451
|
-
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
|
3452
|
-
//clear accumulated errors
|
|
3453
|
-
// eslint-disable-next-line no-empty
|
|
3454
|
-
while (!successful && gl.getError() !== gl.NO_ERROR) { }
|
|
3455
|
-
return successful;
|
|
3456
|
-
}
|
|
3457
|
-
/**
|
|
3458
|
-
* @internal
|
|
3459
|
-
*/
|
|
3460
|
-
_getWebGLTextureType(type) {
|
|
3461
|
-
if (this._webGLVersion === 1) {
|
|
3462
|
-
switch (type) {
|
|
3463
|
-
case Constants.TEXTURETYPE_FLOAT:
|
|
3464
|
-
return this._gl.FLOAT;
|
|
3465
|
-
case Constants.TEXTURETYPE_HALF_FLOAT:
|
|
3466
|
-
return this._gl.HALF_FLOAT_OES;
|
|
3467
|
-
case Constants.TEXTURETYPE_UNSIGNED_BYTE:
|
|
3468
|
-
return this._gl.UNSIGNED_BYTE;
|
|
3469
|
-
case Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
|
|
3470
|
-
return this._gl.UNSIGNED_SHORT_4_4_4_4;
|
|
3471
|
-
case Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
|
|
3472
|
-
return this._gl.UNSIGNED_SHORT_5_5_5_1;
|
|
3473
|
-
case Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
|
|
3474
|
-
return this._gl.UNSIGNED_SHORT_5_6_5;
|
|
3475
|
-
}
|
|
3476
|
-
return this._gl.UNSIGNED_BYTE;
|
|
3477
|
-
}
|
|
3478
|
-
switch (type) {
|
|
3479
|
-
case Constants.TEXTURETYPE_BYTE:
|
|
3480
|
-
return this._gl.BYTE;
|
|
3481
|
-
case Constants.TEXTURETYPE_UNSIGNED_BYTE:
|
|
3482
|
-
return this._gl.UNSIGNED_BYTE;
|
|
3483
|
-
case Constants.TEXTURETYPE_SHORT:
|
|
3484
|
-
return this._gl.SHORT;
|
|
3485
|
-
case Constants.TEXTURETYPE_UNSIGNED_SHORT:
|
|
3486
|
-
return this._gl.UNSIGNED_SHORT;
|
|
3487
|
-
case Constants.TEXTURETYPE_INT:
|
|
3488
|
-
return this._gl.INT;
|
|
3489
|
-
case Constants.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
|
|
3490
|
-
return this._gl.UNSIGNED_INT;
|
|
3491
|
-
case Constants.TEXTURETYPE_FLOAT:
|
|
3492
|
-
return this._gl.FLOAT;
|
|
3493
|
-
case Constants.TEXTURETYPE_HALF_FLOAT:
|
|
3494
|
-
return this._gl.HALF_FLOAT;
|
|
3495
|
-
case Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
|
|
3496
|
-
return this._gl.UNSIGNED_SHORT_4_4_4_4;
|
|
3497
|
-
case Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
|
|
3498
|
-
return this._gl.UNSIGNED_SHORT_5_5_5_1;
|
|
3499
|
-
case Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
|
|
3500
|
-
return this._gl.UNSIGNED_SHORT_5_6_5;
|
|
3501
|
-
case Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
|
|
3502
|
-
return this._gl.UNSIGNED_INT_2_10_10_10_REV;
|
|
3503
|
-
case Constants.TEXTURETYPE_UNSIGNED_INT_24_8:
|
|
3504
|
-
return this._gl.UNSIGNED_INT_24_8;
|
|
3505
|
-
case Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
|
|
3506
|
-
return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
|
|
3507
|
-
case Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
|
|
3508
|
-
return this._gl.UNSIGNED_INT_5_9_9_9_REV;
|
|
3509
|
-
case Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
|
|
3510
|
-
return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
|
|
3511
|
-
}
|
|
3512
|
-
return this._gl.UNSIGNED_BYTE;
|
|
3513
|
-
}
|
|
3514
|
-
/**
|
|
3515
|
-
* @internal
|
|
3516
|
-
*/
|
|
3517
|
-
_getInternalFormat(format, useSRGBBuffer = false) {
|
|
3518
|
-
let internalFormat = useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA;
|
|
3519
|
-
switch (format) {
|
|
3520
|
-
case Constants.TEXTUREFORMAT_ALPHA:
|
|
3521
|
-
internalFormat = this._gl.ALPHA;
|
|
3522
|
-
break;
|
|
3523
|
-
case Constants.TEXTUREFORMAT_LUMINANCE:
|
|
3524
|
-
internalFormat = this._gl.LUMINANCE;
|
|
3525
|
-
break;
|
|
3526
|
-
case Constants.TEXTUREFORMAT_LUMINANCE_ALPHA:
|
|
3527
|
-
internalFormat = this._gl.LUMINANCE_ALPHA;
|
|
3528
|
-
break;
|
|
3529
|
-
case Constants.TEXTUREFORMAT_RED:
|
|
3530
|
-
case Constants.TEXTUREFORMAT_R16_UNORM:
|
|
3531
|
-
case Constants.TEXTUREFORMAT_R16_SNORM:
|
|
3532
|
-
internalFormat = this._gl.RED;
|
|
3533
|
-
break;
|
|
3534
|
-
case Constants.TEXTUREFORMAT_RG:
|
|
3535
|
-
case Constants.TEXTUREFORMAT_RG16_UNORM:
|
|
3536
|
-
case Constants.TEXTUREFORMAT_RG16_SNORM:
|
|
3537
|
-
internalFormat = this._gl.RG;
|
|
3538
|
-
break;
|
|
3539
|
-
case Constants.TEXTUREFORMAT_RGB:
|
|
3540
|
-
case Constants.TEXTUREFORMAT_RGB16_UNORM:
|
|
3541
|
-
case Constants.TEXTUREFORMAT_RGB16_SNORM:
|
|
3542
|
-
internalFormat = useSRGBBuffer ? this._glSRGBExtensionValues.SRGB : this._gl.RGB;
|
|
3543
|
-
break;
|
|
3544
|
-
case Constants.TEXTUREFORMAT_RGBA:
|
|
3545
|
-
case Constants.TEXTUREFORMAT_RGBA16_UNORM:
|
|
3546
|
-
case Constants.TEXTUREFORMAT_RGBA16_SNORM:
|
|
3547
|
-
internalFormat = useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA;
|
|
3548
|
-
break;
|
|
3549
|
-
}
|
|
3550
|
-
if (this._webGLVersion > 1) {
|
|
3551
|
-
switch (format) {
|
|
3552
|
-
case Constants.TEXTUREFORMAT_RED_INTEGER:
|
|
3553
|
-
internalFormat = this._gl.RED_INTEGER;
|
|
3554
|
-
break;
|
|
3555
|
-
case Constants.TEXTUREFORMAT_RG_INTEGER:
|
|
3556
|
-
internalFormat = this._gl.RG_INTEGER;
|
|
3557
|
-
break;
|
|
3558
|
-
case Constants.TEXTUREFORMAT_RGB_INTEGER:
|
|
3559
|
-
internalFormat = this._gl.RGB_INTEGER;
|
|
3560
|
-
break;
|
|
3561
|
-
case Constants.TEXTUREFORMAT_RGBA_INTEGER:
|
|
3562
|
-
internalFormat = this._gl.RGBA_INTEGER;
|
|
3563
|
-
break;
|
|
3564
|
-
}
|
|
3565
|
-
}
|
|
3566
|
-
return internalFormat;
|
|
3567
|
-
}
|
|
3568
|
-
/**
|
|
3569
|
-
* @internal
|
|
3570
|
-
*/
|
|
3571
|
-
_getRGBABufferInternalSizedFormat(type, format, useSRGBBuffer = false) {
|
|
3572
|
-
if (this._webGLVersion === 1) {
|
|
3573
|
-
if (format !== undefined) {
|
|
3574
|
-
switch (format) {
|
|
3575
|
-
case Constants.TEXTUREFORMAT_ALPHA:
|
|
3576
|
-
return this._gl.ALPHA;
|
|
3577
|
-
case Constants.TEXTUREFORMAT_LUMINANCE:
|
|
3578
|
-
return this._gl.LUMINANCE;
|
|
3579
|
-
case Constants.TEXTUREFORMAT_LUMINANCE_ALPHA:
|
|
3580
|
-
return this._gl.LUMINANCE_ALPHA;
|
|
3581
|
-
case Constants.TEXTUREFORMAT_RGB:
|
|
3582
|
-
return useSRGBBuffer ? this._glSRGBExtensionValues.SRGB : this._gl.RGB;
|
|
3583
|
-
}
|
|
3584
|
-
}
|
|
3585
|
-
return this._gl.RGBA;
|
|
3586
|
-
}
|
|
3587
|
-
switch (type) {
|
|
3588
|
-
case Constants.TEXTURETYPE_BYTE:
|
|
3589
|
-
switch (format) {
|
|
3590
|
-
case Constants.TEXTUREFORMAT_RED:
|
|
3591
|
-
return this._gl.R8_SNORM;
|
|
3592
|
-
case Constants.TEXTUREFORMAT_RG:
|
|
3593
|
-
return this._gl.RG8_SNORM;
|
|
3594
|
-
case Constants.TEXTUREFORMAT_RGB:
|
|
3595
|
-
return this._gl.RGB8_SNORM;
|
|
3596
|
-
case Constants.TEXTUREFORMAT_RED_INTEGER:
|
|
3597
|
-
return this._gl.R8I;
|
|
3598
|
-
case Constants.TEXTUREFORMAT_RG_INTEGER:
|
|
3599
|
-
return this._gl.RG8I;
|
|
3600
|
-
case Constants.TEXTUREFORMAT_RGB_INTEGER:
|
|
3601
|
-
return this._gl.RGB8I;
|
|
3602
|
-
case Constants.TEXTUREFORMAT_RGBA_INTEGER:
|
|
3603
|
-
return this._gl.RGBA8I;
|
|
3604
|
-
default:
|
|
3605
|
-
return this._gl.RGBA8_SNORM;
|
|
3606
|
-
}
|
|
3607
|
-
case Constants.TEXTURETYPE_UNSIGNED_BYTE:
|
|
3608
|
-
switch (format) {
|
|
3609
|
-
case Constants.TEXTUREFORMAT_RED:
|
|
3610
|
-
return this._gl.R8;
|
|
3611
|
-
case Constants.TEXTUREFORMAT_RG:
|
|
3612
|
-
return this._gl.RG8;
|
|
3613
|
-
case Constants.TEXTUREFORMAT_RGB:
|
|
3614
|
-
return useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8 : this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
|
|
3615
|
-
case Constants.TEXTUREFORMAT_RGBA:
|
|
3616
|
-
return useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
|
|
3617
|
-
case Constants.TEXTUREFORMAT_RED_INTEGER:
|
|
3618
|
-
return this._gl.R8UI;
|
|
3619
|
-
case Constants.TEXTUREFORMAT_RG_INTEGER:
|
|
3620
|
-
return this._gl.RG8UI;
|
|
3621
|
-
case Constants.TEXTUREFORMAT_RGB_INTEGER:
|
|
3622
|
-
return this._gl.RGB8UI;
|
|
3623
|
-
case Constants.TEXTUREFORMAT_RGBA_INTEGER:
|
|
3624
|
-
return this._gl.RGBA8UI;
|
|
3625
|
-
case Constants.TEXTUREFORMAT_ALPHA:
|
|
3626
|
-
return this._gl.ALPHA;
|
|
3627
|
-
case Constants.TEXTUREFORMAT_LUMINANCE:
|
|
3628
|
-
return this._gl.LUMINANCE;
|
|
3629
|
-
case Constants.TEXTUREFORMAT_LUMINANCE_ALPHA:
|
|
3630
|
-
return this._gl.LUMINANCE_ALPHA;
|
|
3631
|
-
default:
|
|
3632
|
-
return this._gl.RGBA8;
|
|
3633
|
-
}
|
|
3634
|
-
case Constants.TEXTURETYPE_SHORT:
|
|
3635
|
-
switch (format) {
|
|
3636
|
-
case Constants.TEXTUREFORMAT_RED_INTEGER:
|
|
3637
|
-
return this._gl.R16I;
|
|
3638
|
-
case Constants.TEXTUREFORMAT_R16_SNORM:
|
|
3639
|
-
return this._gl.R16_SNORM_EXT;
|
|
3640
|
-
case Constants.TEXTUREFORMAT_RG16_SNORM:
|
|
3641
|
-
return this._gl.RG16_SNORM_EXT;
|
|
3642
|
-
case Constants.TEXTUREFORMAT_RGB16_SNORM:
|
|
3643
|
-
return this._gl.RGB16_SNORM_EXT;
|
|
3644
|
-
case Constants.TEXTUREFORMAT_RGBA16_SNORM:
|
|
3645
|
-
return this._gl.RGBA16_SNORM_EXT;
|
|
3646
|
-
case Constants.TEXTUREFORMAT_RG_INTEGER:
|
|
3647
|
-
return this._gl.RG16I;
|
|
3648
|
-
case Constants.TEXTUREFORMAT_RGB_INTEGER:
|
|
3649
|
-
return this._gl.RGB16I;
|
|
3650
|
-
case Constants.TEXTUREFORMAT_RGBA_INTEGER:
|
|
3651
|
-
return this._gl.RGBA16I;
|
|
3652
|
-
default:
|
|
3653
|
-
return this._gl.RGBA16I;
|
|
3654
|
-
}
|
|
3655
|
-
case Constants.TEXTURETYPE_UNSIGNED_SHORT:
|
|
3656
|
-
switch (format) {
|
|
3657
|
-
case Constants.TEXTUREFORMAT_RED_INTEGER:
|
|
3658
|
-
return this._gl.R16UI;
|
|
3659
|
-
case Constants.TEXTUREFORMAT_R16_UNORM:
|
|
3660
|
-
return this._gl.R16_EXT;
|
|
3661
|
-
case Constants.TEXTUREFORMAT_RG16_UNORM:
|
|
3662
|
-
return this._gl.RG16_EXT;
|
|
3663
|
-
case Constants.TEXTUREFORMAT_RGB16_UNORM:
|
|
3664
|
-
return this._gl.RGB16_EXT;
|
|
3665
|
-
case Constants.TEXTUREFORMAT_RGBA16_UNORM:
|
|
3666
|
-
return this._gl.RGBA16_EXT;
|
|
3667
|
-
case Constants.TEXTUREFORMAT_RG_INTEGER:
|
|
3668
|
-
return this._gl.RG16UI;
|
|
3669
|
-
case Constants.TEXTUREFORMAT_RGB_INTEGER:
|
|
3670
|
-
return this._gl.RGB16UI;
|
|
3671
|
-
case Constants.TEXTUREFORMAT_RGBA_INTEGER:
|
|
3672
|
-
return this._gl.RGBA16UI;
|
|
3673
|
-
default:
|
|
3674
|
-
return this._gl.RGBA16UI;
|
|
3675
|
-
}
|
|
3676
|
-
case Constants.TEXTURETYPE_INT:
|
|
3677
|
-
switch (format) {
|
|
3678
|
-
case Constants.TEXTUREFORMAT_RED_INTEGER:
|
|
3679
|
-
return this._gl.R32I;
|
|
3680
|
-
case Constants.TEXTUREFORMAT_RG_INTEGER:
|
|
3681
|
-
return this._gl.RG32I;
|
|
3682
|
-
case Constants.TEXTUREFORMAT_RGB_INTEGER:
|
|
3683
|
-
return this._gl.RGB32I;
|
|
3684
|
-
case Constants.TEXTUREFORMAT_RGBA_INTEGER:
|
|
3685
|
-
return this._gl.RGBA32I;
|
|
3686
|
-
default:
|
|
3687
|
-
return this._gl.RGBA32I;
|
|
3688
|
-
}
|
|
3689
|
-
case Constants.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
|
|
3690
|
-
switch (format) {
|
|
3691
|
-
case Constants.TEXTUREFORMAT_RED_INTEGER:
|
|
3692
|
-
return this._gl.R32UI;
|
|
3693
|
-
case Constants.TEXTUREFORMAT_RG_INTEGER:
|
|
3694
|
-
return this._gl.RG32UI;
|
|
3695
|
-
case Constants.TEXTUREFORMAT_RGB_INTEGER:
|
|
3696
|
-
return this._gl.RGB32UI;
|
|
3697
|
-
case Constants.TEXTUREFORMAT_RGBA_INTEGER:
|
|
3698
|
-
return this._gl.RGBA32UI;
|
|
3699
|
-
default:
|
|
3700
|
-
return this._gl.RGBA32UI;
|
|
3701
|
-
}
|
|
3702
|
-
case Constants.TEXTURETYPE_FLOAT:
|
|
3703
|
-
switch (format) {
|
|
3704
|
-
case Constants.TEXTUREFORMAT_RED:
|
|
3705
|
-
return this._gl.R32F; // By default. Other possibility is R16F.
|
|
3706
|
-
case Constants.TEXTUREFORMAT_RG:
|
|
3707
|
-
return this._gl.RG32F; // By default. Other possibility is RG16F.
|
|
3708
|
-
case Constants.TEXTUREFORMAT_RGB:
|
|
3709
|
-
return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
|
|
3710
|
-
case Constants.TEXTUREFORMAT_RGBA:
|
|
3711
|
-
return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
|
|
3712
|
-
default:
|
|
3713
|
-
return this._gl.RGBA32F;
|
|
3714
|
-
}
|
|
3715
|
-
case Constants.TEXTURETYPE_HALF_FLOAT:
|
|
3716
|
-
switch (format) {
|
|
3717
|
-
case Constants.TEXTUREFORMAT_RED:
|
|
3718
|
-
return this._gl.R16F;
|
|
3719
|
-
case Constants.TEXTUREFORMAT_RG:
|
|
3720
|
-
return this._gl.RG16F;
|
|
3721
|
-
case Constants.TEXTUREFORMAT_RGB:
|
|
3722
|
-
return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
|
|
3723
|
-
case Constants.TEXTUREFORMAT_RGBA:
|
|
3724
|
-
return this._gl.RGBA16F;
|
|
3725
|
-
default:
|
|
3726
|
-
return this._gl.RGBA16F;
|
|
3727
|
-
}
|
|
3728
|
-
case Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
|
|
3729
|
-
return this._gl.RGB565;
|
|
3730
|
-
case Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
|
|
3731
|
-
return this._gl.R11F_G11F_B10F;
|
|
3732
|
-
case Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
|
|
3733
|
-
return this._gl.RGB9_E5;
|
|
3734
|
-
case Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
|
|
3735
|
-
return this._gl.RGBA4;
|
|
3736
|
-
case Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
|
|
3737
|
-
return this._gl.RGB5_A1;
|
|
3738
|
-
case Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
|
|
3739
|
-
switch (format) {
|
|
3740
|
-
case Constants.TEXTUREFORMAT_RGBA:
|
|
3741
|
-
return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
|
|
3742
|
-
case Constants.TEXTUREFORMAT_RGBA_INTEGER:
|
|
3743
|
-
return this._gl.RGB10_A2UI;
|
|
3744
|
-
default:
|
|
3745
|
-
return this._gl.RGB10_A2;
|
|
3746
|
-
}
|
|
3747
|
-
}
|
|
3748
|
-
return useSRGBBuffer ? this._glSRGBExtensionValues.SRGB8_ALPHA8 : this._gl.RGBA8;
|
|
3749
|
-
}
|
|
3750
|
-
/**
|
|
3751
|
-
* Reads pixels from the current frame buffer. Please note that this function can be slow
|
|
3752
|
-
* @param x defines the x coordinate of the rectangle where pixels must be read
|
|
3753
|
-
* @param y defines the y coordinate of the rectangle where pixels must be read
|
|
3754
|
-
* @param width defines the width of the rectangle where pixels must be read
|
|
3755
|
-
* @param height defines the height of the rectangle where pixels must be read
|
|
3756
|
-
* @param hasAlpha defines whether the output should have alpha or not (defaults to true)
|
|
3757
|
-
* @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
|
|
3758
|
-
* @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
|
|
3759
|
-
*/
|
|
3760
|
-
readPixels(x, y, width, height, hasAlpha = true, flushRenderer = true) {
|
|
3761
|
-
const numChannels = hasAlpha ? 4 : 3;
|
|
3762
|
-
const format = hasAlpha ? this._gl.RGBA : this._gl.RGB;
|
|
3763
|
-
const data = new Uint8Array(height * width * numChannels);
|
|
3764
|
-
if (flushRenderer) {
|
|
3765
|
-
this.flushFramebuffer();
|
|
3766
|
-
}
|
|
3767
|
-
this._gl.readPixels(x, y, width, height, format, this._gl.UNSIGNED_BYTE, data);
|
|
3768
|
-
return Promise.resolve(data);
|
|
3769
|
-
}
|
|
3770
|
-
/**
|
|
3771
|
-
* Gets a Promise<boolean> indicating if the engine can be instantiated (ie. if a webGL context can be found)
|
|
3772
|
-
*/
|
|
3773
|
-
static get IsSupportedAsync() {
|
|
3774
|
-
return Promise.resolve(this.isSupported());
|
|
3775
|
-
}
|
|
3776
|
-
/**
|
|
3777
|
-
* Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
|
|
3778
|
-
*/
|
|
3779
|
-
static get IsSupported() {
|
|
3780
|
-
return this.isSupported(); // Backward compat
|
|
3781
|
-
}
|
|
3782
|
-
/**
|
|
3783
|
-
* Gets a boolean indicating if the engine can be instantiated (ie. if a webGL context can be found)
|
|
3784
|
-
* @returns true if the engine can be created
|
|
3785
|
-
* @ignorenaming
|
|
3786
|
-
*/
|
|
3787
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3788
|
-
static isSupported() {
|
|
3789
|
-
if (this._HasMajorPerformanceCaveat !== null) {
|
|
3790
|
-
return !this._HasMajorPerformanceCaveat; // We know it is performant so WebGL is supported
|
|
3791
|
-
}
|
|
3792
|
-
if (this._IsSupported === null) {
|
|
3793
|
-
try {
|
|
3794
|
-
const tempcanvas = AbstractEngine._CreateCanvas(1, 1);
|
|
3795
|
-
const gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
|
|
3796
|
-
this._IsSupported = gl != null && !!window.WebGLRenderingContext;
|
|
3797
|
-
}
|
|
3798
|
-
catch (e) {
|
|
3799
|
-
this._IsSupported = false;
|
|
3800
|
-
}
|
|
3801
|
-
}
|
|
3802
|
-
return this._IsSupported;
|
|
3803
|
-
}
|
|
3804
|
-
/**
|
|
3805
|
-
* Gets a boolean indicating if the engine can be instantiated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
|
|
3806
|
-
*/
|
|
3807
|
-
static get HasMajorPerformanceCaveat() {
|
|
3808
|
-
if (this._HasMajorPerformanceCaveat === null) {
|
|
3809
|
-
try {
|
|
3810
|
-
const tempcanvas = AbstractEngine._CreateCanvas(1, 1);
|
|
3811
|
-
const gl = tempcanvas.getContext("webgl", { failIfMajorPerformanceCaveat: true }) ||
|
|
3812
|
-
tempcanvas.getContext("experimental-webgl", { failIfMajorPerformanceCaveat: true });
|
|
3813
|
-
this._HasMajorPerformanceCaveat = !gl;
|
|
3814
|
-
}
|
|
3815
|
-
catch (e) {
|
|
3816
|
-
this._HasMajorPerformanceCaveat = false;
|
|
3817
|
-
}
|
|
3818
|
-
}
|
|
3819
|
-
return this._HasMajorPerformanceCaveat;
|
|
3820
|
-
}
|
|
3821
|
-
}
|
|
3822
|
-
ThinEngine._TempClearColorUint32 = new Uint32Array(4);
|
|
3823
|
-
ThinEngine._TempClearColorInt32 = new Int32Array(4);
|
|
3824
|
-
/** Use this array to turn off some WebGL2 features on known buggy browsers version */
|
|
3825
|
-
ThinEngine.ExceptionList = [
|
|
3826
|
-
{ key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
|
|
3827
|
-
{ key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
|
|
3828
|
-
{ key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
|
|
3829
|
-
{ key: "Chrome/72.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
|
|
3830
|
-
{ key: "Chrome/73.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
|
|
3831
|
-
{ key: "Chrome/74.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
|
|
3832
|
-
{ key: "Mac OS.+Chrome/71", capture: null, captureConstraint: null, targets: ["vao"] },
|
|
3833
|
-
{ key: "Mac OS.+Chrome/72", capture: null, captureConstraint: null, targets: ["vao"] },
|
|
3834
|
-
{ key: "Mac OS.+Chrome", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
|
|
3835
|
-
{ key: "Chrome/12\\d\\..+?Mobile", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
|
|
3836
|
-
// desktop osx safari 15.4
|
|
3837
|
-
{ key: ".*AppleWebKit.*(15.4).*Safari", capture: null, captureConstraint: null, targets: ["antialias", "maxMSAASamples"] },
|
|
3838
|
-
// mobile browsers using safari 15.4 on ios
|
|
3839
|
-
{ key: ".*(15.4).*AppleWebKit.*Safari", capture: null, captureConstraint: null, targets: ["antialias", "maxMSAASamples"] },
|
|
3840
|
-
];
|
|
3841
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3842
|
-
ThinEngine._ConcatenateShader = _ConcatenateShader;
|
|
3843
|
-
// Statics
|
|
3844
|
-
ThinEngine._IsSupported = null;
|
|
3845
|
-
ThinEngine._HasMajorPerformanceCaveat = null;
|
|
3846
|
-
|
|
3847
|
-
var thinEngine = /*#__PURE__*/Object.freeze({
|
|
3848
|
-
__proto__: null,
|
|
3849
|
-
ThinEngine: ThinEngine
|
|
3850
|
-
});
|
|
3851
|
-
|
|
3852
|
-
export { ThinEngine as T, WebGLDataBuffer as W, WebGLHardwareTexture as a, thinEngine as t };
|
|
3853
|
-
//# sourceMappingURL=thinEngine-IzS60pqU.esm.js.map
|