@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,4033 +0,0 @@
|
|
|
1
|
-
import { aU as RandomGUID, T as Tools, R as RegisterClass, u as Vector2, v as Vector3, ad as Vector4, a5 as Matrix, s as Color3, ac as Quaternion, m as Color4, an as __decorate, ar as serialize, aV as Observable, l as AbstractMesh, aW as PointerEventTypes, L as Logger, aQ as unregisterGLTFExtension, aR as registerGLTFExtension } from './index-Cw2FZpYY.esm.js';
|
|
2
|
-
import { G as GLTFPathToObjectConverter } from './gltfPathToObjectConverter-GcUmfOyo.esm.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @experimental
|
|
6
|
-
* The type of a connection point - inpput or output.
|
|
7
|
-
*/
|
|
8
|
-
var FlowGraphConnectionType;
|
|
9
|
-
(function (FlowGraphConnectionType) {
|
|
10
|
-
FlowGraphConnectionType[FlowGraphConnectionType["Input"] = 0] = "Input";
|
|
11
|
-
FlowGraphConnectionType[FlowGraphConnectionType["Output"] = 1] = "Output";
|
|
12
|
-
})(FlowGraphConnectionType || (FlowGraphConnectionType = {}));
|
|
13
|
-
/**
|
|
14
|
-
* @experimental
|
|
15
|
-
* The base connection class.
|
|
16
|
-
*/
|
|
17
|
-
class FlowGraphConnection {
|
|
18
|
-
constructor(name, _connectionType,
|
|
19
|
-
/* @internal */ _ownerBlock) {
|
|
20
|
-
this._ownerBlock = _ownerBlock;
|
|
21
|
-
/** @internal */
|
|
22
|
-
this._connectedPoint = [];
|
|
23
|
-
/**
|
|
24
|
-
* A uniquely identifying string for the connection.
|
|
25
|
-
*/
|
|
26
|
-
this.uniqueId = RandomGUID();
|
|
27
|
-
/**
|
|
28
|
-
* Used for parsing connections.
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
// disable warning as this is used for parsing
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
-
this.connectedPointIds = [];
|
|
34
|
-
this.name = name;
|
|
35
|
-
this._connectionType = _connectionType;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* The type of the connection
|
|
39
|
-
*/
|
|
40
|
-
get connectionType() {
|
|
41
|
-
return this._connectionType;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* @internal
|
|
45
|
-
* Override this to indicate if a point can connect to more than one point.
|
|
46
|
-
*/
|
|
47
|
-
_isSingularConnection() {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Returns if a point is connected to any other point.
|
|
52
|
-
* @returns boolean indicating if the point is connected.
|
|
53
|
-
*/
|
|
54
|
-
isConnected() {
|
|
55
|
-
return this._connectedPoint.length > 0;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Connects two connections together.
|
|
59
|
-
* @param point the connection to connect to.
|
|
60
|
-
*/
|
|
61
|
-
connectTo(point) {
|
|
62
|
-
if (this._connectionType === point._connectionType) {
|
|
63
|
-
throw new Error(`Cannot connect two points of type ${this.connectionType}`);
|
|
64
|
-
}
|
|
65
|
-
if ((this._isSingularConnection() && this._connectedPoint.length > 0) || (point._isSingularConnection() && point._connectedPoint.length > 0)) {
|
|
66
|
-
throw new Error("Max number of connections for point reached");
|
|
67
|
-
}
|
|
68
|
-
this._connectedPoint.push(point);
|
|
69
|
-
point._connectedPoint.push(this);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Saves the connection to a JSON object.
|
|
73
|
-
* @param serializationObject the object to serialize to.
|
|
74
|
-
*/
|
|
75
|
-
serialize(serializationObject = {}) {
|
|
76
|
-
serializationObject.uniqueId = this.uniqueId;
|
|
77
|
-
serializationObject.name = this.name;
|
|
78
|
-
serializationObject._connectionType = this._connectionType;
|
|
79
|
-
serializationObject.connectedPointIds = [];
|
|
80
|
-
serializationObject.className = this.getClassName();
|
|
81
|
-
for (const point of this._connectedPoint) {
|
|
82
|
-
serializationObject.connectedPointIds.push(point.uniqueId);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* @returns class name of the connection.
|
|
87
|
-
*/
|
|
88
|
-
getClassName() {
|
|
89
|
-
return "FGConnection";
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Deserialize from a object into this
|
|
93
|
-
* @param serializationObject the object to deserialize from.
|
|
94
|
-
*/
|
|
95
|
-
deserialize(serializationObject) {
|
|
96
|
-
this.uniqueId = serializationObject.uniqueId;
|
|
97
|
-
this.name = serializationObject.name;
|
|
98
|
-
this._connectionType = serializationObject._connectionType;
|
|
99
|
-
this.connectedPointIds = serializationObject.connectedPointIds;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Parses a connection from an object
|
|
103
|
-
* @param serializationObject the object to parse from.
|
|
104
|
-
* @param ownerBlock the block that owns the connection.
|
|
105
|
-
* @returns the parsed connection.
|
|
106
|
-
*/
|
|
107
|
-
static Parse(serializationObject = {}, ownerBlock) {
|
|
108
|
-
const type = Tools.Instantiate(serializationObject.className);
|
|
109
|
-
const connection = new type(serializationObject.name, serializationObject._connectionType, ownerBlock);
|
|
110
|
-
connection.deserialize(serializationObject);
|
|
111
|
-
return connection;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* @experimental
|
|
117
|
-
* Class that represents an integer value.
|
|
118
|
-
*/
|
|
119
|
-
class FlowGraphInteger {
|
|
120
|
-
constructor(value) {
|
|
121
|
-
this.value = this._toInt(value);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Converts a float to an integer.
|
|
125
|
-
* @param n the float to convert
|
|
126
|
-
* @returns the result of n | 0 - converting it to a int
|
|
127
|
-
*/
|
|
128
|
-
_toInt(n) {
|
|
129
|
-
return n | 0;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Adds two integers together.
|
|
133
|
-
* @param other the other integer to add
|
|
134
|
-
* @returns a FlowGraphInteger with the result of the addition
|
|
135
|
-
*/
|
|
136
|
-
add(other) {
|
|
137
|
-
return new FlowGraphInteger(this.value + other.value);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Subtracts two integers.
|
|
141
|
-
* @param other the other integer to subtract
|
|
142
|
-
* @returns a FlowGraphInteger with the result of the subtraction
|
|
143
|
-
*/
|
|
144
|
-
subtract(other) {
|
|
145
|
-
return new FlowGraphInteger(this.value - other.value);
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Multiplies two integers.
|
|
149
|
-
* @param other the other integer to multiply
|
|
150
|
-
* @returns a FlowGraphInteger with the result of the multiplication
|
|
151
|
-
*/
|
|
152
|
-
multiply(other) {
|
|
153
|
-
return new FlowGraphInteger(Math.imul(this.value, other.value));
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Divides two integers.
|
|
157
|
-
* @param other the other integer to divide
|
|
158
|
-
* @returns a FlowGraphInteger with the result of the division
|
|
159
|
-
*/
|
|
160
|
-
divide(other) {
|
|
161
|
-
return new FlowGraphInteger(this.value / other.value);
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* The class name of this type.
|
|
165
|
-
* @returns
|
|
166
|
-
*/
|
|
167
|
-
getClassName() {
|
|
168
|
-
return FlowGraphInteger.ClassName;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Compares two integers for equality.
|
|
172
|
-
* @param other the other integer to compare
|
|
173
|
-
* @returns
|
|
174
|
-
*/
|
|
175
|
-
equals(other) {
|
|
176
|
-
return this.value === other.value;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Parses a FlowGraphInteger from a serialization object.
|
|
180
|
-
* @param serializationObject
|
|
181
|
-
* @returns
|
|
182
|
-
*/
|
|
183
|
-
static Parse(serializationObject) {
|
|
184
|
-
return new FlowGraphInteger(serializationObject.value);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
FlowGraphInteger.ClassName = "FlowGraphInteger";
|
|
188
|
-
RegisterClass("FlowGraphInteger", FlowGraphInteger);
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* A rich type represents extra information about a type,
|
|
192
|
-
* such as its name and a default value constructor.
|
|
193
|
-
* @experimental
|
|
194
|
-
*/
|
|
195
|
-
class RichType {
|
|
196
|
-
constructor(
|
|
197
|
-
/**
|
|
198
|
-
* The name given to the type.
|
|
199
|
-
*/
|
|
200
|
-
typeName,
|
|
201
|
-
/**
|
|
202
|
-
* The default value of the type.
|
|
203
|
-
*/
|
|
204
|
-
defaultValue) {
|
|
205
|
-
this.typeName = typeName;
|
|
206
|
-
this.defaultValue = defaultValue;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Serializes this rich type into a serialization object.
|
|
210
|
-
* @param serializationObject the object to serialize to
|
|
211
|
-
*/
|
|
212
|
-
serialize(serializationObject) {
|
|
213
|
-
serializationObject.typeName = this.typeName;
|
|
214
|
-
serializationObject.defaultValue = this.defaultValue;
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Parses a rich type from a serialization object.
|
|
218
|
-
* @param serializationObject a serialization object
|
|
219
|
-
* @returns the parsed rich type
|
|
220
|
-
*/
|
|
221
|
-
static Parse(serializationObject) {
|
|
222
|
-
return new RichType(serializationObject.typeName, serializationObject.defaultValue);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
const RichTypeAny = new RichType("any", undefined);
|
|
226
|
-
const RichTypeNumber = new RichType("number", 0);
|
|
227
|
-
const RichTypeBoolean = new RichType("boolean", false);
|
|
228
|
-
const RichTypeVector2 = new RichType("Vector2", Vector2.Zero());
|
|
229
|
-
const RichTypeVector3 = new RichType("Vector3", Vector3.Zero());
|
|
230
|
-
new RichType("Vector4", Vector4.Zero());
|
|
231
|
-
const RichTypeMatrix = new RichType("Matrix", Matrix.Identity());
|
|
232
|
-
new RichType("Color3", Color3.Black());
|
|
233
|
-
new RichType("Quaternion", Quaternion.Identity());
|
|
234
|
-
const RichTypeFlowGraphInteger = new RichType("FlowGraphInteger", new FlowGraphInteger(0));
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* @experimental
|
|
238
|
-
* Represents a connection point for data.
|
|
239
|
-
* An unconnected input point can have a default value.
|
|
240
|
-
* An output point will only have a value if it is connected to an input point. Furthermore,
|
|
241
|
-
* if the point belongs to a "function" node, the node will run its function to update the value.
|
|
242
|
-
*/
|
|
243
|
-
class FlowGraphDataConnection extends FlowGraphConnection {
|
|
244
|
-
/**
|
|
245
|
-
* Create a new data connection point.
|
|
246
|
-
* @param name
|
|
247
|
-
* @param connectionType
|
|
248
|
-
* @param ownerBlock
|
|
249
|
-
* @param richType
|
|
250
|
-
*/
|
|
251
|
-
constructor(name, connectionType, ownerBlock,
|
|
252
|
-
/**
|
|
253
|
-
* the type of the data in this block
|
|
254
|
-
*/
|
|
255
|
-
richType) {
|
|
256
|
-
super(name, connectionType, ownerBlock);
|
|
257
|
-
this.richType = richType;
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* An output data block can connect to multiple input data blocks,
|
|
261
|
-
* but an input data block can only connect to one output data block.
|
|
262
|
-
* @returns true if the connection is singular
|
|
263
|
-
*/
|
|
264
|
-
_isSingularConnection() {
|
|
265
|
-
return this.connectionType === 0 /* FlowGraphConnectionType.Input */;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Set the value of the connection in a specific context.
|
|
269
|
-
* @param value the value to set
|
|
270
|
-
* @param context the context to which the value is set
|
|
271
|
-
*/
|
|
272
|
-
setValue(value, context) {
|
|
273
|
-
context._setConnectionValue(this, value);
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Connect this point to another point.
|
|
277
|
-
* @param point the point to connect to.
|
|
278
|
-
*/
|
|
279
|
-
connectTo(point) {
|
|
280
|
-
super.connectTo(point);
|
|
281
|
-
}
|
|
282
|
-
_getValueOrDefault(context) {
|
|
283
|
-
if (context._hasConnectionValue(this)) {
|
|
284
|
-
return context._getConnectionValue(this);
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
return this.richType.defaultValue;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Gets the value of the connection in a specific context.
|
|
292
|
-
* @param context the context from which the value is retrieved
|
|
293
|
-
* @returns the value of the connection
|
|
294
|
-
*/
|
|
295
|
-
getValue(context) {
|
|
296
|
-
if (this.connectionType === 1 /* FlowGraphConnectionType.Output */) {
|
|
297
|
-
context._notifyExecuteNode(this._ownerBlock);
|
|
298
|
-
this._ownerBlock._updateOutputs(context);
|
|
299
|
-
return this._getValueOrDefault(context);
|
|
300
|
-
}
|
|
301
|
-
if (!this.isConnected()) {
|
|
302
|
-
return this._getValueOrDefault(context);
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
return this._connectedPoint[0].getValue(context);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* @returns class name of the object.
|
|
310
|
-
*/
|
|
311
|
-
getClassName() {
|
|
312
|
-
return "FGDataConnection";
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Serializes this object.
|
|
316
|
-
* @param serializationObject the object to serialize to
|
|
317
|
-
*/
|
|
318
|
-
serialize(serializationObject = {}) {
|
|
319
|
-
super.serialize(serializationObject);
|
|
320
|
-
serializationObject.richType = {};
|
|
321
|
-
this.richType.serialize(serializationObject.richType);
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Parses a data connection from a serialized object.
|
|
325
|
-
* @param serializationObject the object to parse from
|
|
326
|
-
* @param ownerBlock the block that owns the connection
|
|
327
|
-
* @returns the parsed connection
|
|
328
|
-
*/
|
|
329
|
-
static Parse(serializationObject, ownerBlock) {
|
|
330
|
-
const obj = FlowGraphConnection.Parse(serializationObject, ownerBlock);
|
|
331
|
-
obj.richType = RichType.Parse(serializationObject.richType);
|
|
332
|
-
return obj;
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
RegisterClass("FGDataConnection", FlowGraphDataConnection);
|
|
336
|
-
|
|
337
|
-
function isMeshClassName(className) {
|
|
338
|
-
return (className === "Mesh" ||
|
|
339
|
-
className === "AbstractMesh" ||
|
|
340
|
-
className === "GroundMesh" ||
|
|
341
|
-
className === "InstanceMesh" ||
|
|
342
|
-
className === "LinesMesh" ||
|
|
343
|
-
className === "GoldbergMesh" ||
|
|
344
|
-
className === "GreasedLineMesh" ||
|
|
345
|
-
className === "TrailMesh");
|
|
346
|
-
}
|
|
347
|
-
function isVectorClassName(className) {
|
|
348
|
-
return className === "Vector2" || className === "Vector3" || className === "Vector4" || className === "Quaternion" || className === "Color3" || className === "Color4";
|
|
349
|
-
}
|
|
350
|
-
function parseVector(className, value) {
|
|
351
|
-
if (className === "Vector2") {
|
|
352
|
-
return Vector2.FromArray(value);
|
|
353
|
-
}
|
|
354
|
-
else if (className === "Vector3") {
|
|
355
|
-
return Vector3.FromArray(value);
|
|
356
|
-
}
|
|
357
|
-
else if (className === "Vector4") {
|
|
358
|
-
return Vector4.FromArray(value);
|
|
359
|
-
}
|
|
360
|
-
else if (className === "Quaternion") {
|
|
361
|
-
return Quaternion.FromArray(value);
|
|
362
|
-
}
|
|
363
|
-
else if (className === "Color3") {
|
|
364
|
-
return new Color3(value[0], value[1], value[2]);
|
|
365
|
-
}
|
|
366
|
-
else if (className === "Color4") {
|
|
367
|
-
return new Color4(value[0], value[1], value[2], value[3]);
|
|
368
|
-
}
|
|
369
|
-
else {
|
|
370
|
-
throw new Error(`Unknown vector class name ${className}`);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* The default function that serializes values in a context object to a serialization object
|
|
375
|
-
* @param key the key where the value should be stored in the serialization object
|
|
376
|
-
* @param value the value to store
|
|
377
|
-
* @param serializationObject the object where the value will be stored
|
|
378
|
-
*/
|
|
379
|
-
function defaultValueSerializationFunction(key, value, serializationObject) {
|
|
380
|
-
const className = value?.getClassName?.() ?? "";
|
|
381
|
-
if (isMeshClassName(className)) {
|
|
382
|
-
serializationObject[key] = {
|
|
383
|
-
name: value.name,
|
|
384
|
-
className,
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
else if (isVectorClassName(className)) {
|
|
388
|
-
serializationObject[key] = {
|
|
389
|
-
value: value.asArray(),
|
|
390
|
-
className,
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
else {
|
|
394
|
-
serializationObject[key] = value;
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* The default function that parses values stored in a serialization object
|
|
399
|
-
* @param key the key to the value that will be parsed
|
|
400
|
-
* @param serializationObject the object that will be parsed
|
|
401
|
-
* @param scene
|
|
402
|
-
* @returns
|
|
403
|
-
*/
|
|
404
|
-
function defaultValueParseFunction(key, serializationObject, scene) {
|
|
405
|
-
const intermediateValue = serializationObject[key];
|
|
406
|
-
let finalValue;
|
|
407
|
-
const className = intermediateValue?.className;
|
|
408
|
-
if (isMeshClassName(className)) {
|
|
409
|
-
finalValue = scene.getMeshByName(intermediateValue.name);
|
|
410
|
-
}
|
|
411
|
-
else if (isVectorClassName(className)) {
|
|
412
|
-
finalValue = parseVector(className, intermediateValue.value);
|
|
413
|
-
}
|
|
414
|
-
else if (className === "Matrix") {
|
|
415
|
-
finalValue = Matrix.FromArray(intermediateValue.value);
|
|
416
|
-
}
|
|
417
|
-
else if (className === FlowGraphInteger.ClassName) {
|
|
418
|
-
finalValue = FlowGraphInteger.Parse(intermediateValue);
|
|
419
|
-
}
|
|
420
|
-
else if (intermediateValue && intermediateValue.value !== undefined) {
|
|
421
|
-
finalValue = intermediateValue.value;
|
|
422
|
-
}
|
|
423
|
-
else {
|
|
424
|
-
finalValue = intermediateValue;
|
|
425
|
-
}
|
|
426
|
-
return finalValue;
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* Given a name of a flow graph block class, return if this
|
|
430
|
-
* class needs to be created with a path converter. Used in
|
|
431
|
-
* parsing.
|
|
432
|
-
* @param className the name of the flow graph block class
|
|
433
|
-
* @returns a boolean indicating if the class needs a path converter
|
|
434
|
-
*/
|
|
435
|
-
function needsPathConverter(className) {
|
|
436
|
-
// I am not using the ClassName property here because it was causing a circular dependency
|
|
437
|
-
// that jest didn't like!
|
|
438
|
-
return className === "FGSetPropertyBlock" || className === "FGGetPropertyBlock" || className === "FGPlayAnimationBlock" || className === "FGMeshPickEventBlock";
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* @experimental
|
|
443
|
-
* A block in a flow graph. The most basic form
|
|
444
|
-
* of a block has inputs and outputs that contain
|
|
445
|
-
* data.
|
|
446
|
-
*/
|
|
447
|
-
class FlowGraphBlock {
|
|
448
|
-
/** Constructor is protected so only subclasses can be instantiated
|
|
449
|
-
* @param config optional configuration for this block
|
|
450
|
-
*/
|
|
451
|
-
constructor(
|
|
452
|
-
/**
|
|
453
|
-
* the configuration of the block
|
|
454
|
-
*/
|
|
455
|
-
config) {
|
|
456
|
-
this.config = config;
|
|
457
|
-
/**
|
|
458
|
-
* A randomly generated GUID for each block.
|
|
459
|
-
*/
|
|
460
|
-
this.uniqueId = RandomGUID();
|
|
461
|
-
this.name = this.config?.name ?? this.getClassName();
|
|
462
|
-
this.dataInputs = [];
|
|
463
|
-
this.dataOutputs = [];
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* @internal
|
|
467
|
-
*/
|
|
468
|
-
_updateOutputs(_context) {
|
|
469
|
-
// empty by default, overriden in data blocks
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* Registers a data input on the block.
|
|
473
|
-
* @param name the name of the input
|
|
474
|
-
* @param richType the type of the input
|
|
475
|
-
* @returns the created connection
|
|
476
|
-
*/
|
|
477
|
-
registerDataInput(name, richType) {
|
|
478
|
-
const input = new FlowGraphDataConnection(name, 0 /* FlowGraphConnectionType.Input */, this, richType);
|
|
479
|
-
this.dataInputs.push(input);
|
|
480
|
-
return input;
|
|
481
|
-
}
|
|
482
|
-
/**
|
|
483
|
-
* Registers a data output on the block.
|
|
484
|
-
* @param name the name of the input
|
|
485
|
-
* @param richType the type of the input
|
|
486
|
-
* @returns the created connection
|
|
487
|
-
*/
|
|
488
|
-
registerDataOutput(name, richType) {
|
|
489
|
-
const output = new FlowGraphDataConnection(name, 1 /* FlowGraphConnectionType.Output */, this, richType);
|
|
490
|
-
this.dataOutputs.push(output);
|
|
491
|
-
return output;
|
|
492
|
-
}
|
|
493
|
-
/**
|
|
494
|
-
* Given the name of a data input, returns the connection if it exists
|
|
495
|
-
* @param name the name of the input
|
|
496
|
-
* @returns the connection if it exists, undefined otherwise
|
|
497
|
-
*/
|
|
498
|
-
getDataInput(name) {
|
|
499
|
-
return this.dataInputs.find((i) => i.name === name);
|
|
500
|
-
}
|
|
501
|
-
/**
|
|
502
|
-
* Given the name of a data output, returns the connection if it exists
|
|
503
|
-
* @param name the name of the output
|
|
504
|
-
* @returns the connection if it exists, undefined otherwise
|
|
505
|
-
*/
|
|
506
|
-
getDataOutput(name) {
|
|
507
|
-
return this.dataOutputs.find((i) => i.name === name);
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* Serializes this block
|
|
511
|
-
* @param serializationObject the object to serialize to
|
|
512
|
-
* @param _valueSerializeFunction a function that serializes a specific value
|
|
513
|
-
*/
|
|
514
|
-
serialize(serializationObject = {}, _valueSerializeFunction = defaultValueSerializationFunction) {
|
|
515
|
-
serializationObject.uniqueId = this.uniqueId;
|
|
516
|
-
serializationObject.config = {};
|
|
517
|
-
if (this.config) {
|
|
518
|
-
serializationObject.config["name"] = this.config.name;
|
|
519
|
-
}
|
|
520
|
-
serializationObject.dataInputs = [];
|
|
521
|
-
serializationObject.dataOutputs = [];
|
|
522
|
-
serializationObject.className = this.getClassName();
|
|
523
|
-
for (const input of this.dataInputs) {
|
|
524
|
-
const serializedInput = {};
|
|
525
|
-
input.serialize(serializedInput);
|
|
526
|
-
serializationObject.dataInputs.push(serializedInput);
|
|
527
|
-
}
|
|
528
|
-
for (const output of this.dataOutputs) {
|
|
529
|
-
const serializedOutput = {};
|
|
530
|
-
output.serialize(serializedOutput);
|
|
531
|
-
serializationObject.dataOutputs.push(serializedOutput);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
/**
|
|
535
|
-
* Gets the class name of this block
|
|
536
|
-
* @returns the class name
|
|
537
|
-
*/
|
|
538
|
-
getClassName() {
|
|
539
|
-
return "FGBlock";
|
|
540
|
-
}
|
|
541
|
-
/**
|
|
542
|
-
* Parses a block from a serialization object
|
|
543
|
-
* @param serializationObject the object to parse from
|
|
544
|
-
* @param parseOptions options for parsing the block
|
|
545
|
-
* @returns the parsed block
|
|
546
|
-
*/
|
|
547
|
-
static Parse(serializationObject, parseOptions) {
|
|
548
|
-
const classType = Tools.Instantiate(serializationObject.className);
|
|
549
|
-
const parsedConfig = {};
|
|
550
|
-
const valueParseFunction = parseOptions.valueParseFunction ?? defaultValueParseFunction;
|
|
551
|
-
if (serializationObject.config) {
|
|
552
|
-
for (const key in serializationObject.config) {
|
|
553
|
-
parsedConfig[key] = valueParseFunction(key, serializationObject.config, parseOptions.scene);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
if (needsPathConverter(serializationObject.className)) {
|
|
557
|
-
parsedConfig.pathConverter = parseOptions.pathConverter;
|
|
558
|
-
}
|
|
559
|
-
const obj = new classType(parsedConfig);
|
|
560
|
-
obj.uniqueId = serializationObject.uniqueId;
|
|
561
|
-
for (let i = 0; i < serializationObject.dataInputs.length; i++) {
|
|
562
|
-
const dataInput = obj.getDataInput(serializationObject.dataInputs[i].name);
|
|
563
|
-
if (dataInput) {
|
|
564
|
-
dataInput.deserialize(serializationObject.dataInputs[i]);
|
|
565
|
-
}
|
|
566
|
-
else {
|
|
567
|
-
throw new Error("Could not find data input with name " + serializationObject.dataInputs[i].name + " in block " + serializationObject.className);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
for (let i = 0; i < serializationObject.dataOutputs.length; i++) {
|
|
571
|
-
const dataOutput = obj.getDataOutput(serializationObject.dataOutputs[i].name);
|
|
572
|
-
if (dataOutput) {
|
|
573
|
-
dataOutput.deserialize(serializationObject.dataOutputs[i]);
|
|
574
|
-
}
|
|
575
|
-
else {
|
|
576
|
-
throw new Error("Could not find data output with name " + serializationObject.dataOutputs[i].name + " in block " + serializationObject.className);
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
obj.metadata = serializationObject.metadata;
|
|
580
|
-
obj.deserialize && obj.deserialize(serializationObject);
|
|
581
|
-
return obj;
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
* @experimental
|
|
587
|
-
* Represents a connection point for a signal.
|
|
588
|
-
* When an output point is activated, it will activate the connected input point.
|
|
589
|
-
* When an input point is activated, it will execute the block it belongs to.
|
|
590
|
-
*/
|
|
591
|
-
class FlowGraphSignalConnection extends FlowGraphConnection {
|
|
592
|
-
/**
|
|
593
|
-
* @internal
|
|
594
|
-
* A signal input can be connected to more than one signal output,
|
|
595
|
-
* but a signal output can only connect to one signal input
|
|
596
|
-
* @returns true if the connection is singular
|
|
597
|
-
*/
|
|
598
|
-
_isSingularConnection() {
|
|
599
|
-
return this.connectionType === 1 /* FlowGraphConnectionType.Output */;
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* @internal
|
|
603
|
-
*/
|
|
604
|
-
_activateSignal(context) {
|
|
605
|
-
if (this.connectionType === 0 /* FlowGraphConnectionType.Input */) {
|
|
606
|
-
context._notifyExecuteNode(this._ownerBlock);
|
|
607
|
-
this._ownerBlock._execute(context, this);
|
|
608
|
-
context._increaseExecutionId();
|
|
609
|
-
}
|
|
610
|
-
else {
|
|
611
|
-
this._connectedPoint[0]?._activateSignal(context);
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
RegisterClass("FlowGraphSignalConnection", FlowGraphSignalConnection);
|
|
616
|
-
|
|
617
|
-
/**
|
|
618
|
-
* @experimental
|
|
619
|
-
* A block that executes some action. Always has an input signal (which is not used by event blocks).
|
|
620
|
-
* Can have one or more output signals.
|
|
621
|
-
*/
|
|
622
|
-
class FlowGraphExecutionBlock extends FlowGraphBlock {
|
|
623
|
-
constructor(config) {
|
|
624
|
-
super(config);
|
|
625
|
-
this.signalInputs = [];
|
|
626
|
-
this.signalOutputs = [];
|
|
627
|
-
this.in = this._registerSignalInput("in");
|
|
628
|
-
}
|
|
629
|
-
_registerSignalInput(name) {
|
|
630
|
-
const input = new FlowGraphSignalConnection(name, 0 /* FlowGraphConnectionType.Input */, this);
|
|
631
|
-
this.signalInputs.push(input);
|
|
632
|
-
return input;
|
|
633
|
-
}
|
|
634
|
-
_registerSignalOutput(name) {
|
|
635
|
-
const output = new FlowGraphSignalConnection(name, 1 /* FlowGraphConnectionType.Output */, this);
|
|
636
|
-
this.signalOutputs.push(output);
|
|
637
|
-
return output;
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* Given a name of a signal input, return that input if it exists
|
|
641
|
-
* @param name the name of the input
|
|
642
|
-
* @returns if the input exists, the input. Otherwise, undefined.
|
|
643
|
-
*/
|
|
644
|
-
getSignalInput(name) {
|
|
645
|
-
return this.signalInputs.find((input) => input.name === name);
|
|
646
|
-
}
|
|
647
|
-
/**
|
|
648
|
-
* Given a name of a signal output, return that input if it exists
|
|
649
|
-
* @param name the name of the input
|
|
650
|
-
* @returns if the input exists, the input. Otherwise, undefined.
|
|
651
|
-
*/
|
|
652
|
-
getSignalOutput(name) {
|
|
653
|
-
return this.signalOutputs.find((output) => output.name === name);
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* Serializes this block
|
|
657
|
-
* @param serializationObject the object to serialize in
|
|
658
|
-
*/
|
|
659
|
-
serialize(serializationObject = {}) {
|
|
660
|
-
super.serialize(serializationObject);
|
|
661
|
-
serializationObject.signalInputs = [];
|
|
662
|
-
serializationObject.signalOutputs = [];
|
|
663
|
-
for (const input of this.signalInputs) {
|
|
664
|
-
const serializedInput = {};
|
|
665
|
-
input.serialize(serializedInput);
|
|
666
|
-
serializationObject.signalInputs.push(serializedInput);
|
|
667
|
-
}
|
|
668
|
-
for (const output of this.signalOutputs) {
|
|
669
|
-
const serializedOutput = {};
|
|
670
|
-
output.serialize(serializedOutput);
|
|
671
|
-
serializationObject.signalOutputs.push(serializedOutput);
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* Deserializes from an object
|
|
676
|
-
* @param serializationObject the object to deserialize from
|
|
677
|
-
*/
|
|
678
|
-
deserialize(serializationObject) {
|
|
679
|
-
for (let i = 0; i < serializationObject.signalInputs.length; i++) {
|
|
680
|
-
const signalInput = this.getSignalInput(serializationObject.signalInputs[i].name);
|
|
681
|
-
if (signalInput) {
|
|
682
|
-
signalInput.deserialize(serializationObject.signalInputs[i]);
|
|
683
|
-
}
|
|
684
|
-
else {
|
|
685
|
-
throw new Error("Could not find signal input with name " + serializationObject.signalInputs[i].name + " in block " + serializationObject.className);
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
for (let i = 0; i < serializationObject.signalOutputs.length; i++) {
|
|
689
|
-
const signalOutput = this.getSignalOutput(serializationObject.signalOutputs[i].name);
|
|
690
|
-
if (signalOutput) {
|
|
691
|
-
signalOutput.deserialize(serializationObject.signalOutputs[i]);
|
|
692
|
-
}
|
|
693
|
-
else {
|
|
694
|
-
throw new Error("Could not find signal output with name " + serializationObject.signalOutputs[i].name + " in block " + serializationObject.className);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
/**
|
|
699
|
-
* @returns the class name
|
|
700
|
-
*/
|
|
701
|
-
getClassName() {
|
|
702
|
-
return "FGExecutionBlock";
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
/**
|
|
707
|
-
* An async execution block can start tasks that will be executed asynchronously.
|
|
708
|
-
* It should also be responsible for clearing it in _cancelPendingTasks.
|
|
709
|
-
* @experimental
|
|
710
|
-
*/
|
|
711
|
-
class FlowGraphAsyncExecutionBlock extends FlowGraphExecutionBlock {
|
|
712
|
-
constructor(config) {
|
|
713
|
-
super(config);
|
|
714
|
-
this.out = this._registerSignalOutput("out");
|
|
715
|
-
this.done = this._registerSignalOutput("done");
|
|
716
|
-
}
|
|
717
|
-
/**
|
|
718
|
-
* @internal
|
|
719
|
-
* @param context
|
|
720
|
-
*/
|
|
721
|
-
_startPendingTasks(context) {
|
|
722
|
-
this._preparePendingTasks(context);
|
|
723
|
-
context._addPendingBlock(this);
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
/**
|
|
728
|
-
* @experimental
|
|
729
|
-
* A type of block that listens to an event observable and activates
|
|
730
|
-
* its output signal when the event is triggered.
|
|
731
|
-
*/
|
|
732
|
-
class FlowGraphEventBlock extends FlowGraphAsyncExecutionBlock {
|
|
733
|
-
/**
|
|
734
|
-
* @internal
|
|
735
|
-
*/
|
|
736
|
-
_execute(context) {
|
|
737
|
-
context._notifyExecuteNode(this);
|
|
738
|
-
this.out._activateSignal(context);
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
/**
|
|
743
|
-
* @experimental
|
|
744
|
-
* The context represents the current state and execution of the flow graph.
|
|
745
|
-
* It contains both user-defined variables, which are derived from
|
|
746
|
-
* a more general variable definition, and execution variables that
|
|
747
|
-
* are set by the blocks.
|
|
748
|
-
*/
|
|
749
|
-
class FlowGraphContext {
|
|
750
|
-
constructor(params) {
|
|
751
|
-
/**
|
|
752
|
-
* A randomly generated GUID for each context.
|
|
753
|
-
*/
|
|
754
|
-
this.uniqueId = RandomGUID();
|
|
755
|
-
/**
|
|
756
|
-
* These are the variables defined by a user.
|
|
757
|
-
*/
|
|
758
|
-
this._userVariables = {};
|
|
759
|
-
/**
|
|
760
|
-
* These are the variables set by the blocks.
|
|
761
|
-
*/
|
|
762
|
-
this._executionVariables = {};
|
|
763
|
-
/**
|
|
764
|
-
* These are the values for the data connection points
|
|
765
|
-
*/
|
|
766
|
-
this._connectionValues = {};
|
|
767
|
-
/**
|
|
768
|
-
* These are blocks that have currently pending tasks/listeners that need to be cleaned up.
|
|
769
|
-
*/
|
|
770
|
-
this._pendingBlocks = [];
|
|
771
|
-
/**
|
|
772
|
-
* A monotonically increasing ID for each execution.
|
|
773
|
-
* Incremented for every block executed.
|
|
774
|
-
*/
|
|
775
|
-
this._executionId = 0;
|
|
776
|
-
/**
|
|
777
|
-
* Observable that is triggered when a node is executed.
|
|
778
|
-
*/
|
|
779
|
-
this.onNodeExecutedObservable = new Observable();
|
|
780
|
-
this._configuration = params;
|
|
781
|
-
}
|
|
782
|
-
/**
|
|
783
|
-
* Check if a user-defined variable is defined.
|
|
784
|
-
* @param name the name of the variable
|
|
785
|
-
* @returns true if the variable is defined
|
|
786
|
-
*/
|
|
787
|
-
hasVariable(name) {
|
|
788
|
-
return name in this._userVariables;
|
|
789
|
-
}
|
|
790
|
-
/**
|
|
791
|
-
* Set a user-defined variable.
|
|
792
|
-
* @param name the name of the variable
|
|
793
|
-
* @param value the value of the variable
|
|
794
|
-
*/
|
|
795
|
-
setVariable(name, value) {
|
|
796
|
-
this._userVariables[name] = value;
|
|
797
|
-
}
|
|
798
|
-
/**
|
|
799
|
-
* Get a user-defined variable.
|
|
800
|
-
* @param name the name of the variable
|
|
801
|
-
* @returns the value of the variable
|
|
802
|
-
*/
|
|
803
|
-
getVariable(name) {
|
|
804
|
-
return this._userVariables[name];
|
|
805
|
-
}
|
|
806
|
-
/**
|
|
807
|
-
* Gets all user variables map
|
|
808
|
-
*/
|
|
809
|
-
get userVariables() {
|
|
810
|
-
return this._userVariables;
|
|
811
|
-
}
|
|
812
|
-
_getUniqueIdPrefixedName(obj, name) {
|
|
813
|
-
return `${obj.uniqueId}_${name}`;
|
|
814
|
-
}
|
|
815
|
-
/**
|
|
816
|
-
* Set an internal execution variable
|
|
817
|
-
* @internal
|
|
818
|
-
* @param name
|
|
819
|
-
* @param value
|
|
820
|
-
*/
|
|
821
|
-
_setExecutionVariable(block, name, value) {
|
|
822
|
-
this._executionVariables[this._getUniqueIdPrefixedName(block, name)] = value;
|
|
823
|
-
}
|
|
824
|
-
/**
|
|
825
|
-
* Get an internal execution variable
|
|
826
|
-
* @internal
|
|
827
|
-
* @param name
|
|
828
|
-
* @returns
|
|
829
|
-
*/
|
|
830
|
-
_getExecutionVariable(block, name, defaultValue) {
|
|
831
|
-
if (this._hasExecutionVariable(block, name)) {
|
|
832
|
-
return this._executionVariables[this._getUniqueIdPrefixedName(block, name)];
|
|
833
|
-
}
|
|
834
|
-
else {
|
|
835
|
-
return defaultValue;
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
/**
|
|
839
|
-
* Delete an internal execution variable
|
|
840
|
-
* @internal
|
|
841
|
-
* @param block
|
|
842
|
-
* @param name
|
|
843
|
-
*/
|
|
844
|
-
_deleteExecutionVariable(block, name) {
|
|
845
|
-
delete this._executionVariables[this._getUniqueIdPrefixedName(block, name)];
|
|
846
|
-
}
|
|
847
|
-
/**
|
|
848
|
-
* Check if an internal execution variable is defined
|
|
849
|
-
* @internal
|
|
850
|
-
* @param block
|
|
851
|
-
* @param name
|
|
852
|
-
* @returns
|
|
853
|
-
*/
|
|
854
|
-
_hasExecutionVariable(block, name) {
|
|
855
|
-
return this._getUniqueIdPrefixedName(block, name) in this._executionVariables;
|
|
856
|
-
}
|
|
857
|
-
/**
|
|
858
|
-
* Check if a connection value is defined
|
|
859
|
-
* @internal
|
|
860
|
-
* @param connectionPoint
|
|
861
|
-
* @returns
|
|
862
|
-
*/
|
|
863
|
-
_hasConnectionValue(connectionPoint) {
|
|
864
|
-
return connectionPoint.uniqueId in this._connectionValues;
|
|
865
|
-
}
|
|
866
|
-
/**
|
|
867
|
-
* Set a connection value
|
|
868
|
-
* @internal
|
|
869
|
-
* @param connectionPoint
|
|
870
|
-
* @param value
|
|
871
|
-
*/
|
|
872
|
-
_setConnectionValue(connectionPoint, value) {
|
|
873
|
-
this._connectionValues[connectionPoint.uniqueId] = value;
|
|
874
|
-
}
|
|
875
|
-
/**
|
|
876
|
-
* Get a connection value
|
|
877
|
-
* @internal
|
|
878
|
-
* @param connectionPoint
|
|
879
|
-
* @returns
|
|
880
|
-
*/
|
|
881
|
-
_getConnectionValue(connectionPoint) {
|
|
882
|
-
return this._connectionValues[connectionPoint.uniqueId];
|
|
883
|
-
}
|
|
884
|
-
/**
|
|
885
|
-
* Get the configuration
|
|
886
|
-
* @internal
|
|
887
|
-
* @param name
|
|
888
|
-
* @param value
|
|
889
|
-
*/
|
|
890
|
-
get configuration() {
|
|
891
|
-
return this._configuration;
|
|
892
|
-
}
|
|
893
|
-
/**
|
|
894
|
-
* Add a block to the list of blocks that have pending tasks.
|
|
895
|
-
* @internal
|
|
896
|
-
* @param block
|
|
897
|
-
*/
|
|
898
|
-
_addPendingBlock(block) {
|
|
899
|
-
this._pendingBlocks.push(block);
|
|
900
|
-
}
|
|
901
|
-
/**
|
|
902
|
-
* Remove a block from the list of blocks that have pending tasks.
|
|
903
|
-
* @internal
|
|
904
|
-
* @param block
|
|
905
|
-
*/
|
|
906
|
-
_removePendingBlock(block) {
|
|
907
|
-
const index = this._pendingBlocks.indexOf(block);
|
|
908
|
-
if (index !== -1) {
|
|
909
|
-
this._pendingBlocks.splice(index, 1);
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
/**
|
|
913
|
-
* Clear all pending blocks.
|
|
914
|
-
* @internal
|
|
915
|
-
*/
|
|
916
|
-
_clearPendingBlocks() {
|
|
917
|
-
for (const block of this._pendingBlocks) {
|
|
918
|
-
block._cancelPendingTasks(this);
|
|
919
|
-
}
|
|
920
|
-
this._pendingBlocks.length = 0;
|
|
921
|
-
}
|
|
922
|
-
/**
|
|
923
|
-
* @internal
|
|
924
|
-
* Function that notifies the node executed observable
|
|
925
|
-
* @param node
|
|
926
|
-
*/
|
|
927
|
-
_notifyExecuteNode(node) {
|
|
928
|
-
this.onNodeExecutedObservable.notifyObservers(node);
|
|
929
|
-
}
|
|
930
|
-
/**
|
|
931
|
-
* @internal
|
|
932
|
-
*/
|
|
933
|
-
_increaseExecutionId() {
|
|
934
|
-
this._executionId++;
|
|
935
|
-
}
|
|
936
|
-
/**
|
|
937
|
-
* A monotonically increasing ID for each execution.
|
|
938
|
-
* Incremented for every block executed.
|
|
939
|
-
*/
|
|
940
|
-
get executionId() {
|
|
941
|
-
return this._executionId;
|
|
942
|
-
}
|
|
943
|
-
/**
|
|
944
|
-
* Serializes a context
|
|
945
|
-
* @param serializationObject the object to write the values in
|
|
946
|
-
* @param valueSerializationFunction a function to serialize complex values
|
|
947
|
-
*/
|
|
948
|
-
serialize(serializationObject = {}, valueSerializationFunction = defaultValueSerializationFunction) {
|
|
949
|
-
serializationObject.uniqueId = this.uniqueId;
|
|
950
|
-
serializationObject._userVariables = {};
|
|
951
|
-
for (const key in this._userVariables) {
|
|
952
|
-
valueSerializationFunction(key, this._userVariables[key], serializationObject._userVariables);
|
|
953
|
-
}
|
|
954
|
-
serializationObject._connectionValues = {};
|
|
955
|
-
for (const key in this._connectionValues) {
|
|
956
|
-
valueSerializationFunction(key, this._connectionValues[key], serializationObject._connectionValues);
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
/**
|
|
960
|
-
* @returns the class name of the object.
|
|
961
|
-
*/
|
|
962
|
-
getClassName() {
|
|
963
|
-
return "FGContext";
|
|
964
|
-
}
|
|
965
|
-
/**
|
|
966
|
-
* Parses a context
|
|
967
|
-
* @param serializationObject the object containing the context serialization values
|
|
968
|
-
* @param options the options for parsing the context
|
|
969
|
-
* @returns
|
|
970
|
-
*/
|
|
971
|
-
static Parse(serializationObject, options) {
|
|
972
|
-
const result = options.graph.createContext();
|
|
973
|
-
const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;
|
|
974
|
-
result.uniqueId = serializationObject.uniqueId;
|
|
975
|
-
for (const key in serializationObject._userVariables) {
|
|
976
|
-
const value = valueParseFunction(key, serializationObject._userVariables, result._configuration.scene);
|
|
977
|
-
result._userVariables[key] = value;
|
|
978
|
-
}
|
|
979
|
-
for (const key in serializationObject._connectionValues) {
|
|
980
|
-
const value = valueParseFunction(key, serializationObject._connectionValues, result._configuration.scene);
|
|
981
|
-
result._connectionValues[key] = value;
|
|
982
|
-
}
|
|
983
|
-
return result;
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
__decorate([
|
|
987
|
-
serialize()
|
|
988
|
-
], FlowGraphContext.prototype, "uniqueId", void 0);
|
|
989
|
-
|
|
990
|
-
/**
|
|
991
|
-
* @internal
|
|
992
|
-
* Returns if mesh1 is a descendant of mesh2
|
|
993
|
-
* @param mesh1
|
|
994
|
-
* @param mesh2
|
|
995
|
-
* @returns
|
|
996
|
-
*/
|
|
997
|
-
function _isADescendantOf(mesh1, mesh2) {
|
|
998
|
-
return !!(mesh1.parent && (mesh1.parent === mesh2 || _isADescendantOf(mesh1.parent, mesh2)));
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
/**
|
|
1002
|
-
* @experimental
|
|
1003
|
-
* A block that activates when a mesh is picked.
|
|
1004
|
-
*/
|
|
1005
|
-
class FlowGraphMeshPickEventBlock extends FlowGraphEventBlock {
|
|
1006
|
-
constructor(
|
|
1007
|
-
/**
|
|
1008
|
-
* the configuration of the block
|
|
1009
|
-
*/
|
|
1010
|
-
config) {
|
|
1011
|
-
super(config);
|
|
1012
|
-
this.config = config;
|
|
1013
|
-
}
|
|
1014
|
-
_getReferencedMesh() {
|
|
1015
|
-
const iAccessor = this.config.pathConverter.convert(this.config.path);
|
|
1016
|
-
const mesh = iAccessor.info.getObject(iAccessor.object);
|
|
1017
|
-
if (!mesh || !(mesh instanceof AbstractMesh)) {
|
|
1018
|
-
throw new Error("Mesh pick event block requires a valid mesh");
|
|
1019
|
-
}
|
|
1020
|
-
return mesh;
|
|
1021
|
-
}
|
|
1022
|
-
/**
|
|
1023
|
-
* @internal
|
|
1024
|
-
*/
|
|
1025
|
-
_preparePendingTasks(context) {
|
|
1026
|
-
let pickObserver = context._getExecutionVariable(this, "meshPickObserver");
|
|
1027
|
-
if (!pickObserver) {
|
|
1028
|
-
const mesh = this._getReferencedMesh();
|
|
1029
|
-
context._setExecutionVariable(this, "mesh", mesh);
|
|
1030
|
-
pickObserver = mesh.getScene().onPointerObservable.add((pointerInfo) => {
|
|
1031
|
-
if (pointerInfo.type === PointerEventTypes.POINTERPICK &&
|
|
1032
|
-
pointerInfo.pickInfo?.pickedMesh &&
|
|
1033
|
-
(pointerInfo.pickInfo?.pickedMesh === mesh || _isADescendantOf(pointerInfo.pickInfo?.pickedMesh, mesh))) {
|
|
1034
|
-
this._execute(context);
|
|
1035
|
-
}
|
|
1036
|
-
});
|
|
1037
|
-
const disposeObserver = mesh.onDisposeObservable.add(() => this._onDispose);
|
|
1038
|
-
context._setExecutionVariable(this, "meshPickObserver", pickObserver);
|
|
1039
|
-
context._setExecutionVariable(this, "meshDisposeObserver", disposeObserver);
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
_onDispose(context) {
|
|
1043
|
-
this._cancelPendingTasks(context);
|
|
1044
|
-
context._removePendingBlock(this);
|
|
1045
|
-
}
|
|
1046
|
-
/**
|
|
1047
|
-
* @internal
|
|
1048
|
-
*/
|
|
1049
|
-
_cancelPendingTasks(context) {
|
|
1050
|
-
const mesh = context._getExecutionVariable(this, "mesh");
|
|
1051
|
-
const pickObserver = context._getExecutionVariable(this, "meshPickObserver");
|
|
1052
|
-
const disposeObserver = context._getExecutionVariable(this, "meshDisposeObserver");
|
|
1053
|
-
mesh.getScene().onPointerObservable.remove(pickObserver);
|
|
1054
|
-
mesh.onDisposeObservable.remove(disposeObserver);
|
|
1055
|
-
context._deleteExecutionVariable(this, "mesh");
|
|
1056
|
-
context._deleteExecutionVariable(this, "meshPickObserver");
|
|
1057
|
-
context._deleteExecutionVariable(this, "meshDisposeObserver");
|
|
1058
|
-
}
|
|
1059
|
-
/**
|
|
1060
|
-
* @returns class name of the block.
|
|
1061
|
-
*/
|
|
1062
|
-
getClassName() {
|
|
1063
|
-
return FlowGraphMeshPickEventBlock.ClassName;
|
|
1064
|
-
}
|
|
1065
|
-
/**
|
|
1066
|
-
* Serializes the block to a JSON object.
|
|
1067
|
-
* @param serializationObject the object to serialize to.
|
|
1068
|
-
*/
|
|
1069
|
-
serialize(serializationObject) {
|
|
1070
|
-
super.serialize(serializationObject);
|
|
1071
|
-
serializationObject.config.path = this.config.path;
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
/**
|
|
1075
|
-
* Class name of the block.
|
|
1076
|
-
*/
|
|
1077
|
-
FlowGraphMeshPickEventBlock.ClassName = "FGMeshPickEventBlock";
|
|
1078
|
-
RegisterClass(FlowGraphMeshPickEventBlock.ClassName, FlowGraphMeshPickEventBlock);
|
|
1079
|
-
|
|
1080
|
-
var FlowGraphState;
|
|
1081
|
-
(function (FlowGraphState) {
|
|
1082
|
-
/**
|
|
1083
|
-
* The graph is stopped
|
|
1084
|
-
*/
|
|
1085
|
-
FlowGraphState[FlowGraphState["Stopped"] = 0] = "Stopped";
|
|
1086
|
-
/**
|
|
1087
|
-
* The graph is running
|
|
1088
|
-
*/
|
|
1089
|
-
FlowGraphState[FlowGraphState["Started"] = 1] = "Started";
|
|
1090
|
-
})(FlowGraphState || (FlowGraphState = {}));
|
|
1091
|
-
/**
|
|
1092
|
-
* @experimental
|
|
1093
|
-
* Class used to represent a flow graph.
|
|
1094
|
-
* A flow graph is a graph of blocks that can be used to create complex logic.
|
|
1095
|
-
* Blocks can be added to the graph and connected to each other.
|
|
1096
|
-
* The graph can then be started, which will init and start all of its event blocks.
|
|
1097
|
-
*/
|
|
1098
|
-
class FlowGraph {
|
|
1099
|
-
/**
|
|
1100
|
-
* Construct a Flow Graph
|
|
1101
|
-
* @param params construction parameters. currently only the scene
|
|
1102
|
-
*/
|
|
1103
|
-
constructor(params) {
|
|
1104
|
-
/** @internal */
|
|
1105
|
-
this._eventBlocks = [];
|
|
1106
|
-
this._executionContexts = [];
|
|
1107
|
-
/**
|
|
1108
|
-
* The state of the graph
|
|
1109
|
-
*/
|
|
1110
|
-
this.state = 0 /* FlowGraphState.Stopped */;
|
|
1111
|
-
this._scene = params.scene;
|
|
1112
|
-
this._coordinator = params.coordinator;
|
|
1113
|
-
this._sceneDisposeObserver = this._scene.onDisposeObservable.add(() => this.dispose());
|
|
1114
|
-
}
|
|
1115
|
-
/**
|
|
1116
|
-
* Create a context. A context represents one self contained execution for the graph, with its own variables.
|
|
1117
|
-
* @returns the context, where you can get and set variables
|
|
1118
|
-
*/
|
|
1119
|
-
createContext() {
|
|
1120
|
-
const context = new FlowGraphContext({ scene: this._scene, coordinator: this._coordinator });
|
|
1121
|
-
this._executionContexts.push(context);
|
|
1122
|
-
return context;
|
|
1123
|
-
}
|
|
1124
|
-
/**
|
|
1125
|
-
* Returns the execution context at a given index
|
|
1126
|
-
* @param index the index of the context
|
|
1127
|
-
* @returns the execution context at that index
|
|
1128
|
-
*/
|
|
1129
|
-
getContext(index) {
|
|
1130
|
-
return this._executionContexts[index];
|
|
1131
|
-
}
|
|
1132
|
-
/**
|
|
1133
|
-
* Add an event block. When the graph is started, it will start listening to events
|
|
1134
|
-
* from the block and execute the graph when they are triggered.
|
|
1135
|
-
* @param block the event block to be added
|
|
1136
|
-
*/
|
|
1137
|
-
addEventBlock(block) {
|
|
1138
|
-
this._eventBlocks.push(block);
|
|
1139
|
-
}
|
|
1140
|
-
/**
|
|
1141
|
-
* Starts the flow graph. Initializes the event blocks and starts listening to events.
|
|
1142
|
-
*/
|
|
1143
|
-
start() {
|
|
1144
|
-
if (this.state === 1 /* FlowGraphState.Started */) {
|
|
1145
|
-
return;
|
|
1146
|
-
}
|
|
1147
|
-
this.state = 1 /* FlowGraphState.Started */;
|
|
1148
|
-
if (this._executionContexts.length === 0) {
|
|
1149
|
-
this.createContext();
|
|
1150
|
-
}
|
|
1151
|
-
for (const context of this._executionContexts) {
|
|
1152
|
-
const contextualOrder = this._getContextualOrder();
|
|
1153
|
-
for (const block of contextualOrder) {
|
|
1154
|
-
block._startPendingTasks(context);
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
_getContextualOrder() {
|
|
1159
|
-
const order = [];
|
|
1160
|
-
for (const block1 of this._eventBlocks) {
|
|
1161
|
-
// If the block is a mesh pick, guarantee that picks of children meshes come before picks of parent meshes
|
|
1162
|
-
if (block1.getClassName() === FlowGraphMeshPickEventBlock.ClassName) {
|
|
1163
|
-
const mesh1 = block1._getReferencedMesh();
|
|
1164
|
-
let i = 0;
|
|
1165
|
-
for (; i < order.length; i++) {
|
|
1166
|
-
const block2 = order[i];
|
|
1167
|
-
const mesh2 = block2._getReferencedMesh();
|
|
1168
|
-
if (mesh1 && mesh2 && _isADescendantOf(mesh1, mesh2)) {
|
|
1169
|
-
break;
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
order.splice(i, 0, block1);
|
|
1173
|
-
}
|
|
1174
|
-
else {
|
|
1175
|
-
order.push(block1);
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
return order;
|
|
1179
|
-
}
|
|
1180
|
-
/**
|
|
1181
|
-
* Disposes of the flow graph. Cancels any pending tasks and removes all event listeners.
|
|
1182
|
-
*/
|
|
1183
|
-
dispose() {
|
|
1184
|
-
if (this.state === 0 /* FlowGraphState.Stopped */) {
|
|
1185
|
-
return;
|
|
1186
|
-
}
|
|
1187
|
-
this.state = 0 /* FlowGraphState.Stopped */;
|
|
1188
|
-
for (const context of this._executionContexts) {
|
|
1189
|
-
context._clearPendingBlocks();
|
|
1190
|
-
}
|
|
1191
|
-
this._executionContexts.length = 0;
|
|
1192
|
-
this._eventBlocks.length = 0;
|
|
1193
|
-
this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
|
|
1194
|
-
this._sceneDisposeObserver = null;
|
|
1195
|
-
}
|
|
1196
|
-
/**
|
|
1197
|
-
* Executes a function in all blocks of a flow graph, starting with the event blocks.
|
|
1198
|
-
* @param visitor the function to execute.
|
|
1199
|
-
*/
|
|
1200
|
-
visitAllBlocks(visitor) {
|
|
1201
|
-
const visitList = [];
|
|
1202
|
-
const idsAddedToVisitList = new Set();
|
|
1203
|
-
for (const block of this._eventBlocks) {
|
|
1204
|
-
visitList.push(block);
|
|
1205
|
-
idsAddedToVisitList.add(block.uniqueId);
|
|
1206
|
-
}
|
|
1207
|
-
while (visitList.length > 0) {
|
|
1208
|
-
const block = visitList.pop();
|
|
1209
|
-
visitor(block);
|
|
1210
|
-
for (const dataIn of block.dataInputs) {
|
|
1211
|
-
for (const connection of dataIn._connectedPoint) {
|
|
1212
|
-
if (!idsAddedToVisitList.has(connection._ownerBlock.uniqueId)) {
|
|
1213
|
-
visitList.push(connection._ownerBlock);
|
|
1214
|
-
idsAddedToVisitList.add(connection._ownerBlock.uniqueId);
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
if (block instanceof FlowGraphExecutionBlock) {
|
|
1219
|
-
for (const signalOut of block.signalOutputs) {
|
|
1220
|
-
for (const connection of signalOut._connectedPoint) {
|
|
1221
|
-
if (!idsAddedToVisitList.has(connection._ownerBlock.uniqueId)) {
|
|
1222
|
-
visitList.push(connection._ownerBlock);
|
|
1223
|
-
idsAddedToVisitList.add(connection._ownerBlock.uniqueId);
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
|
-
}
|
|
1230
|
-
/**
|
|
1231
|
-
* Serializes a graph
|
|
1232
|
-
* @param serializationObject the object to write the values in
|
|
1233
|
-
* @param valueSerializeFunction a function to serialize complex values
|
|
1234
|
-
*/
|
|
1235
|
-
serialize(serializationObject = {}, valueSerializeFunction) {
|
|
1236
|
-
serializationObject.allBlocks = [];
|
|
1237
|
-
this.visitAllBlocks((block) => {
|
|
1238
|
-
const serializedBlock = {};
|
|
1239
|
-
block.serialize(serializedBlock);
|
|
1240
|
-
serializationObject.allBlocks.push(serializedBlock);
|
|
1241
|
-
});
|
|
1242
|
-
serializationObject.executionContexts = [];
|
|
1243
|
-
for (const context of this._executionContexts) {
|
|
1244
|
-
const serializedContext = {};
|
|
1245
|
-
context.serialize(serializedContext, valueSerializeFunction);
|
|
1246
|
-
serializationObject.executionContexts.push(serializedContext);
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
/**
|
|
1250
|
-
* Given a list of blocks, find an output data connection that has a specific unique id
|
|
1251
|
-
* @param blocks a list of flow graph blocks
|
|
1252
|
-
* @param uniqueId the unique id of a connection
|
|
1253
|
-
* @returns the connection that has this unique id. throws an error if none was found
|
|
1254
|
-
*/
|
|
1255
|
-
static GetDataOutConnectionByUniqueId(blocks, uniqueId) {
|
|
1256
|
-
for (const block of blocks) {
|
|
1257
|
-
for (const dataOut of block.dataOutputs) {
|
|
1258
|
-
if (dataOut.uniqueId === uniqueId) {
|
|
1259
|
-
return dataOut;
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
throw new Error("Could not find data out connection with unique id " + uniqueId);
|
|
1264
|
-
}
|
|
1265
|
-
/**
|
|
1266
|
-
* Given a list of blocks, find an input signal connection that has a specific unique id
|
|
1267
|
-
* @param blocks a list of flow graph blocks
|
|
1268
|
-
* @param uniqueId the unique id of a connection
|
|
1269
|
-
* @returns the connection that has this unique id. throws an error if none was found
|
|
1270
|
-
*/
|
|
1271
|
-
static GetSignalInConnectionByUniqueId(blocks, uniqueId) {
|
|
1272
|
-
for (const block of blocks) {
|
|
1273
|
-
if (block instanceof FlowGraphExecutionBlock) {
|
|
1274
|
-
for (const signalIn of block.signalInputs) {
|
|
1275
|
-
if (signalIn.uniqueId === uniqueId) {
|
|
1276
|
-
return signalIn;
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
throw new Error("Could not find signal in connection with unique id " + uniqueId);
|
|
1282
|
-
}
|
|
1283
|
-
/**
|
|
1284
|
-
* Parses a graph from a given serialization object
|
|
1285
|
-
* @param serializationObject the object where the values are written
|
|
1286
|
-
* @param options options for parsing the graph
|
|
1287
|
-
* @returns the parsed graph
|
|
1288
|
-
*/
|
|
1289
|
-
static Parse(serializationObject, options) {
|
|
1290
|
-
const graph = options.coordinator.createGraph();
|
|
1291
|
-
const blocks = [];
|
|
1292
|
-
const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;
|
|
1293
|
-
// Parse all blocks
|
|
1294
|
-
for (const serializedBlock of serializationObject.allBlocks) {
|
|
1295
|
-
const block = FlowGraphBlock.Parse(serializedBlock, { scene: options.coordinator.config.scene, pathConverter: options.pathConverter, valueParseFunction });
|
|
1296
|
-
blocks.push(block);
|
|
1297
|
-
if (block instanceof FlowGraphEventBlock) {
|
|
1298
|
-
graph.addEventBlock(block);
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
// After parsing all blocks, connect them
|
|
1302
|
-
for (const block of blocks) {
|
|
1303
|
-
for (const dataIn of block.dataInputs) {
|
|
1304
|
-
for (const serializedConnection of dataIn.connectedPointIds) {
|
|
1305
|
-
const connection = FlowGraph.GetDataOutConnectionByUniqueId(blocks, serializedConnection);
|
|
1306
|
-
dataIn.connectTo(connection);
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
if (block instanceof FlowGraphExecutionBlock) {
|
|
1310
|
-
for (const signalOut of block.signalOutputs) {
|
|
1311
|
-
for (const serializedConnection of signalOut.connectedPointIds) {
|
|
1312
|
-
const connection = FlowGraph.GetSignalInConnectionByUniqueId(blocks, serializedConnection);
|
|
1313
|
-
signalOut.connectTo(connection);
|
|
1314
|
-
}
|
|
1315
|
-
}
|
|
1316
|
-
}
|
|
1317
|
-
}
|
|
1318
|
-
for (const serializedContext of serializationObject.executionContexts) {
|
|
1319
|
-
FlowGraphContext.Parse(serializedContext, { graph, valueParseFunction });
|
|
1320
|
-
}
|
|
1321
|
-
return graph;
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
/**
|
|
1326
|
-
* This class holds all of the existing flow graphs and is responsible for creating new ones.
|
|
1327
|
-
* It also handles starting/stopping multiple graphs and communication between them through an Event Coordinator
|
|
1328
|
-
*/
|
|
1329
|
-
class FlowGraphCoordinator {
|
|
1330
|
-
constructor(
|
|
1331
|
-
/**
|
|
1332
|
-
* the configuration of the block
|
|
1333
|
-
*/
|
|
1334
|
-
config) {
|
|
1335
|
-
this.config = config;
|
|
1336
|
-
this._flowGraphs = [];
|
|
1337
|
-
this._customEventsMap = new Map();
|
|
1338
|
-
// When the scene is disposed, dispose all graphs currently running on it.
|
|
1339
|
-
this.config.scene.onDisposeObservable.add(() => {
|
|
1340
|
-
this.dispose();
|
|
1341
|
-
});
|
|
1342
|
-
// Add itself to the SceneCoordinators list for the Inspector.
|
|
1343
|
-
const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];
|
|
1344
|
-
coordinators.push(this);
|
|
1345
|
-
}
|
|
1346
|
-
/**
|
|
1347
|
-
* Creates a new flow graph and adds it to the list of existing flow graphs
|
|
1348
|
-
* @returns a new flow graph
|
|
1349
|
-
*/
|
|
1350
|
-
createGraph() {
|
|
1351
|
-
const graph = new FlowGraph({ scene: this.config.scene, coordinator: this });
|
|
1352
|
-
this._flowGraphs.push(graph);
|
|
1353
|
-
return graph;
|
|
1354
|
-
}
|
|
1355
|
-
/**
|
|
1356
|
-
* Removes a flow graph from the list of existing flow graphs and disposes it
|
|
1357
|
-
* @param graph the graph to remove
|
|
1358
|
-
*/
|
|
1359
|
-
removeGraph(graph) {
|
|
1360
|
-
const index = this._flowGraphs.indexOf(graph);
|
|
1361
|
-
if (index !== -1) {
|
|
1362
|
-
graph.dispose();
|
|
1363
|
-
this._flowGraphs.splice(index, 1);
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
/**
|
|
1367
|
-
* Starts all graphs
|
|
1368
|
-
*/
|
|
1369
|
-
start() {
|
|
1370
|
-
this._flowGraphs.forEach((graph) => graph.start());
|
|
1371
|
-
}
|
|
1372
|
-
/**
|
|
1373
|
-
* Disposes all graphs
|
|
1374
|
-
*/
|
|
1375
|
-
dispose() {
|
|
1376
|
-
this._flowGraphs.forEach((graph) => graph.dispose());
|
|
1377
|
-
this._flowGraphs.length = 0;
|
|
1378
|
-
// Remove itself from the SceneCoordinators list for the Inspector.
|
|
1379
|
-
const coordinators = FlowGraphCoordinator.SceneCoordinators.get(this.config.scene) ?? [];
|
|
1380
|
-
const index = coordinators.indexOf(this);
|
|
1381
|
-
if (index !== -1) {
|
|
1382
|
-
coordinators.splice(index, 1);
|
|
1383
|
-
}
|
|
1384
|
-
}
|
|
1385
|
-
/**
|
|
1386
|
-
* Serializes this coordinator to a JSON object.
|
|
1387
|
-
* @param serializationObject the object to serialize to
|
|
1388
|
-
* @param valueSerializeFunction the function to use to serialize the value
|
|
1389
|
-
*/
|
|
1390
|
-
serialize(serializationObject, valueSerializeFunction) {
|
|
1391
|
-
serializationObject._flowGraphs = [];
|
|
1392
|
-
this._flowGraphs.forEach((graph) => {
|
|
1393
|
-
const serializedGraph = {};
|
|
1394
|
-
graph.serialize(serializedGraph, valueSerializeFunction);
|
|
1395
|
-
serializationObject._flowGraphs.push(serializedGraph);
|
|
1396
|
-
});
|
|
1397
|
-
}
|
|
1398
|
-
/**
|
|
1399
|
-
* Parses a serialized coordinator.
|
|
1400
|
-
* @param serializedObject the object to parse
|
|
1401
|
-
* @param options the options to use when parsing
|
|
1402
|
-
* @returns the parsed coordinator
|
|
1403
|
-
*/
|
|
1404
|
-
static Parse(serializedObject, options) {
|
|
1405
|
-
const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;
|
|
1406
|
-
const coordinator = new FlowGraphCoordinator({ scene: options.scene });
|
|
1407
|
-
serializedObject._flowGraphs?.forEach((serializedGraph) => {
|
|
1408
|
-
FlowGraph.Parse(serializedGraph, { coordinator, valueParseFunction, pathConverter: options.pathConverter });
|
|
1409
|
-
});
|
|
1410
|
-
return coordinator;
|
|
1411
|
-
}
|
|
1412
|
-
/**
|
|
1413
|
-
* Gets the list of flow graphs
|
|
1414
|
-
*/
|
|
1415
|
-
get flowGraphs() {
|
|
1416
|
-
return this._flowGraphs;
|
|
1417
|
-
}
|
|
1418
|
-
/**
|
|
1419
|
-
* Get an observable that will be notified when the event with the given id is fired.
|
|
1420
|
-
* @param id the id of the event
|
|
1421
|
-
* @returns the observable for the event
|
|
1422
|
-
*/
|
|
1423
|
-
getCustomEventObservable(id) {
|
|
1424
|
-
let observable = this._customEventsMap.get(id);
|
|
1425
|
-
if (!observable) {
|
|
1426
|
-
observable = new Observable();
|
|
1427
|
-
this._customEventsMap.set(id, observable);
|
|
1428
|
-
}
|
|
1429
|
-
return observable;
|
|
1430
|
-
}
|
|
1431
|
-
/**
|
|
1432
|
-
* Notifies the observable for the given event id with the given data.
|
|
1433
|
-
* @param id the id of the event
|
|
1434
|
-
* @param data the data to send with the event
|
|
1435
|
-
*/
|
|
1436
|
-
notifyCustomEvent(id, data) {
|
|
1437
|
-
const observable = this._customEventsMap.get(id);
|
|
1438
|
-
if (observable) {
|
|
1439
|
-
observable.notifyObservers(data);
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
/**
|
|
1444
|
-
* @internal
|
|
1445
|
-
* A list of all the coordinators per scene. Will be used by the inspector
|
|
1446
|
-
*/
|
|
1447
|
-
FlowGraphCoordinator.SceneCoordinators = new Map();
|
|
1448
|
-
|
|
1449
|
-
/**
|
|
1450
|
-
* @experimental
|
|
1451
|
-
* Block that triggers when a scene is ready.
|
|
1452
|
-
*/
|
|
1453
|
-
class FlowGraphSceneReadyEventBlock extends FlowGraphEventBlock {
|
|
1454
|
-
/**
|
|
1455
|
-
* @internal
|
|
1456
|
-
*/
|
|
1457
|
-
_preparePendingTasks(context) {
|
|
1458
|
-
if (!context._getExecutionVariable(this, "sceneReadyObserver")) {
|
|
1459
|
-
const scene = context.configuration.scene;
|
|
1460
|
-
const contextObserver = scene.onReadyObservable.add(() => {
|
|
1461
|
-
this._execute(context);
|
|
1462
|
-
});
|
|
1463
|
-
context._setExecutionVariable(this, "sceneReadyObserver", contextObserver);
|
|
1464
|
-
}
|
|
1465
|
-
}
|
|
1466
|
-
/**
|
|
1467
|
-
* @internal
|
|
1468
|
-
*/
|
|
1469
|
-
_cancelPendingTasks(context) {
|
|
1470
|
-
const contextObserver = context._getExecutionVariable(this, "sceneReadyObserver");
|
|
1471
|
-
const scene = context.configuration.scene;
|
|
1472
|
-
scene.onReadyObservable.remove(contextObserver);
|
|
1473
|
-
context._deleteExecutionVariable(this, "sceneReadyObserver");
|
|
1474
|
-
}
|
|
1475
|
-
/**
|
|
1476
|
-
* @returns class name of the block.
|
|
1477
|
-
*/
|
|
1478
|
-
getClassName() {
|
|
1479
|
-
return FlowGraphSceneReadyEventBlock.ClassName;
|
|
1480
|
-
}
|
|
1481
|
-
}
|
|
1482
|
-
/**
|
|
1483
|
-
* the class name of the block.
|
|
1484
|
-
*/
|
|
1485
|
-
FlowGraphSceneReadyEventBlock.ClassName = "FGSceneReadyEventBlock";
|
|
1486
|
-
RegisterClass("FGSceneReadyEventBlock", FlowGraphSceneReadyEventBlock);
|
|
1487
|
-
|
|
1488
|
-
/**
|
|
1489
|
-
* @experimental
|
|
1490
|
-
* Block that triggers on scene tick (before each render).
|
|
1491
|
-
*/
|
|
1492
|
-
class FlowGraphSceneTickEventBlock extends FlowGraphEventBlock {
|
|
1493
|
-
/**
|
|
1494
|
-
* @internal
|
|
1495
|
-
*/
|
|
1496
|
-
_preparePendingTasks(context) {
|
|
1497
|
-
if (!context._getExecutionVariable(this, "sceneBeforeRender")) {
|
|
1498
|
-
const scene = context.configuration.scene;
|
|
1499
|
-
const contextObserver = scene.onBeforeRenderObservable.add(() => {
|
|
1500
|
-
this._execute(context);
|
|
1501
|
-
});
|
|
1502
|
-
context._setExecutionVariable(this, "sceneBeforeRender", contextObserver);
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
|
-
/**
|
|
1506
|
-
* @internal
|
|
1507
|
-
*/
|
|
1508
|
-
_cancelPendingTasks(context) {
|
|
1509
|
-
const contextObserver = context._getExecutionVariable(this, "sceneBeforeRender");
|
|
1510
|
-
const scene = context.configuration.scene;
|
|
1511
|
-
scene.onBeforeRenderObservable.remove(contextObserver);
|
|
1512
|
-
context._deleteExecutionVariable(this, "sceneBeforeRender");
|
|
1513
|
-
}
|
|
1514
|
-
/**
|
|
1515
|
-
* @returns class name of the block.
|
|
1516
|
-
*/
|
|
1517
|
-
getClassName() {
|
|
1518
|
-
return FlowGraphSceneTickEventBlock.ClassName;
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1521
|
-
/**
|
|
1522
|
-
* the class name of the block.
|
|
1523
|
-
*/
|
|
1524
|
-
FlowGraphSceneTickEventBlock.ClassName = "FGSceneTickEventBlock";
|
|
1525
|
-
RegisterClass(FlowGraphSceneTickEventBlock.ClassName, FlowGraphSceneTickEventBlock);
|
|
1526
|
-
|
|
1527
|
-
/**
|
|
1528
|
-
* @experimental
|
|
1529
|
-
* An execution block that has an out signal. This signal is triggered when the synchronous execution of this block is done.
|
|
1530
|
-
* Most execution blocks will inherit from this, except for the ones that have multiple signals to be triggered.
|
|
1531
|
-
* (such as if blocks)
|
|
1532
|
-
*/
|
|
1533
|
-
class FlowGraphExecutionBlockWithOutSignal extends FlowGraphExecutionBlock {
|
|
1534
|
-
constructor(config) {
|
|
1535
|
-
super(config);
|
|
1536
|
-
this.out = this._registerSignalOutput("out");
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
|
|
1540
|
-
/**
|
|
1541
|
-
* @experimental
|
|
1542
|
-
* Block that logs a message to the console.
|
|
1543
|
-
*/
|
|
1544
|
-
class FlowGraphConsoleLogBlock extends FlowGraphExecutionBlockWithOutSignal {
|
|
1545
|
-
constructor(config) {
|
|
1546
|
-
super(config);
|
|
1547
|
-
this.message = this.registerDataInput("message", RichTypeAny);
|
|
1548
|
-
}
|
|
1549
|
-
/**
|
|
1550
|
-
* @internal
|
|
1551
|
-
*/
|
|
1552
|
-
_execute(context) {
|
|
1553
|
-
const messageValue = this.message.getValue(context);
|
|
1554
|
-
Logger.Log(messageValue);
|
|
1555
|
-
// activate the output flow block
|
|
1556
|
-
this.out._activateSignal(context);
|
|
1557
|
-
}
|
|
1558
|
-
/**
|
|
1559
|
-
* @returns class name of the block.
|
|
1560
|
-
*/
|
|
1561
|
-
getClassName() {
|
|
1562
|
-
return FlowGraphConsoleLogBlock.ClassName;
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
/**
|
|
1566
|
-
* the class name of the block.
|
|
1567
|
-
*/
|
|
1568
|
-
FlowGraphConsoleLogBlock.ClassName = "FGConsoleLogBlock";
|
|
1569
|
-
RegisterClass(FlowGraphConsoleLogBlock.ClassName, FlowGraphConsoleLogBlock);
|
|
1570
|
-
|
|
1571
|
-
/**
|
|
1572
|
-
* The current state of the timer
|
|
1573
|
-
*/
|
|
1574
|
-
var TimerState;
|
|
1575
|
-
(function (TimerState) {
|
|
1576
|
-
/**
|
|
1577
|
-
* Timer initialized, not yet started
|
|
1578
|
-
*/
|
|
1579
|
-
TimerState[TimerState["INIT"] = 0] = "INIT";
|
|
1580
|
-
/**
|
|
1581
|
-
* Timer started and counting
|
|
1582
|
-
*/
|
|
1583
|
-
TimerState[TimerState["STARTED"] = 1] = "STARTED";
|
|
1584
|
-
/**
|
|
1585
|
-
* Timer ended (whether aborted or time reached)
|
|
1586
|
-
*/
|
|
1587
|
-
TimerState[TimerState["ENDED"] = 2] = "ENDED";
|
|
1588
|
-
})(TimerState || (TimerState = {}));
|
|
1589
|
-
/**
|
|
1590
|
-
* An advanced implementation of a timer class
|
|
1591
|
-
*/
|
|
1592
|
-
class AdvancedTimer {
|
|
1593
|
-
/**
|
|
1594
|
-
* Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
|
|
1595
|
-
* @param options construction options for this advanced timer
|
|
1596
|
-
*/
|
|
1597
|
-
constructor(options) {
|
|
1598
|
-
/**
|
|
1599
|
-
* Will notify each time the timer calculates the remaining time
|
|
1600
|
-
*/
|
|
1601
|
-
this.onEachCountObservable = new Observable();
|
|
1602
|
-
/**
|
|
1603
|
-
* Will trigger when the timer was aborted due to the break condition
|
|
1604
|
-
*/
|
|
1605
|
-
this.onTimerAbortedObservable = new Observable();
|
|
1606
|
-
/**
|
|
1607
|
-
* Will trigger when the timer ended successfully
|
|
1608
|
-
*/
|
|
1609
|
-
this.onTimerEndedObservable = new Observable();
|
|
1610
|
-
/**
|
|
1611
|
-
* Will trigger when the timer state has changed
|
|
1612
|
-
*/
|
|
1613
|
-
this.onStateChangedObservable = new Observable();
|
|
1614
|
-
this._observer = null;
|
|
1615
|
-
this._breakOnNextTick = false;
|
|
1616
|
-
this._tick = (payload) => {
|
|
1617
|
-
const now = Date.now();
|
|
1618
|
-
this._timer = now - this._startTime;
|
|
1619
|
-
const data = {
|
|
1620
|
-
startTime: this._startTime,
|
|
1621
|
-
currentTime: now,
|
|
1622
|
-
deltaTime: this._timer,
|
|
1623
|
-
completeRate: this._timer / this._timeToEnd,
|
|
1624
|
-
payload,
|
|
1625
|
-
};
|
|
1626
|
-
const shouldBreak = this._breakOnNextTick || this._breakCondition(data);
|
|
1627
|
-
if (shouldBreak || this._timer >= this._timeToEnd) {
|
|
1628
|
-
this._stop(data, shouldBreak);
|
|
1629
|
-
}
|
|
1630
|
-
else {
|
|
1631
|
-
this.onEachCountObservable.notifyObservers(data);
|
|
1632
|
-
}
|
|
1633
|
-
};
|
|
1634
|
-
this._setState(0 /* TimerState.INIT */);
|
|
1635
|
-
this._contextObservable = options.contextObservable;
|
|
1636
|
-
this._observableParameters = options.observableParameters ?? {};
|
|
1637
|
-
this._breakCondition = options.breakCondition ?? (() => false);
|
|
1638
|
-
this._timeToEnd = options.timeout;
|
|
1639
|
-
if (options.onEnded) {
|
|
1640
|
-
this.onTimerEndedObservable.add(options.onEnded);
|
|
1641
|
-
}
|
|
1642
|
-
if (options.onTick) {
|
|
1643
|
-
this.onEachCountObservable.add(options.onTick);
|
|
1644
|
-
}
|
|
1645
|
-
if (options.onAborted) {
|
|
1646
|
-
this.onTimerAbortedObservable.add(options.onAborted);
|
|
1647
|
-
}
|
|
1648
|
-
}
|
|
1649
|
-
/**
|
|
1650
|
-
* set a breaking condition for this timer. Default is to never break during count
|
|
1651
|
-
* @param predicate the new break condition. Returns true to break, false otherwise
|
|
1652
|
-
*/
|
|
1653
|
-
set breakCondition(predicate) {
|
|
1654
|
-
this._breakCondition = predicate;
|
|
1655
|
-
}
|
|
1656
|
-
/**
|
|
1657
|
-
* Reset ALL associated observables in this advanced timer
|
|
1658
|
-
*/
|
|
1659
|
-
clearObservables() {
|
|
1660
|
-
this.onEachCountObservable.clear();
|
|
1661
|
-
this.onTimerAbortedObservable.clear();
|
|
1662
|
-
this.onTimerEndedObservable.clear();
|
|
1663
|
-
this.onStateChangedObservable.clear();
|
|
1664
|
-
}
|
|
1665
|
-
/**
|
|
1666
|
-
* Will start a new iteration of this timer. Only one instance of this timer can run at a time.
|
|
1667
|
-
*
|
|
1668
|
-
* @param timeToEnd how much time to measure until timer ended
|
|
1669
|
-
*/
|
|
1670
|
-
start(timeToEnd = this._timeToEnd) {
|
|
1671
|
-
if (this._state === 1 /* TimerState.STARTED */) {
|
|
1672
|
-
throw new Error("Timer already started. Please stop it before starting again");
|
|
1673
|
-
}
|
|
1674
|
-
this._timeToEnd = timeToEnd;
|
|
1675
|
-
this._startTime = Date.now();
|
|
1676
|
-
this._timer = 0;
|
|
1677
|
-
this._observer = this._contextObservable.add(this._tick, this._observableParameters.mask, this._observableParameters.insertFirst, this._observableParameters.scope);
|
|
1678
|
-
this._setState(1 /* TimerState.STARTED */);
|
|
1679
|
-
}
|
|
1680
|
-
/**
|
|
1681
|
-
* Will force a stop on the next tick.
|
|
1682
|
-
*/
|
|
1683
|
-
stop() {
|
|
1684
|
-
if (this._state !== 1 /* TimerState.STARTED */) {
|
|
1685
|
-
return;
|
|
1686
|
-
}
|
|
1687
|
-
this._breakOnNextTick = true;
|
|
1688
|
-
}
|
|
1689
|
-
/**
|
|
1690
|
-
* Dispose this timer, clearing all resources
|
|
1691
|
-
*/
|
|
1692
|
-
dispose() {
|
|
1693
|
-
if (this._observer) {
|
|
1694
|
-
this._contextObservable.remove(this._observer);
|
|
1695
|
-
}
|
|
1696
|
-
this.clearObservables();
|
|
1697
|
-
}
|
|
1698
|
-
_setState(newState) {
|
|
1699
|
-
this._state = newState;
|
|
1700
|
-
this.onStateChangedObservable.notifyObservers(this._state);
|
|
1701
|
-
}
|
|
1702
|
-
_stop(data, aborted = false) {
|
|
1703
|
-
this._contextObservable.remove(this._observer);
|
|
1704
|
-
this._setState(2 /* TimerState.ENDED */);
|
|
1705
|
-
if (aborted) {
|
|
1706
|
-
this.onTimerAbortedObservable.notifyObservers(data);
|
|
1707
|
-
}
|
|
1708
|
-
else {
|
|
1709
|
-
this.onTimerEndedObservable.notifyObservers(data);
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1712
|
-
}
|
|
1713
|
-
|
|
1714
|
-
/**
|
|
1715
|
-
* @experimental
|
|
1716
|
-
* Block that provides two different output flows. One is started immediately once the block is executed,
|
|
1717
|
-
* and the other is executed after a set time. The timer for this block runs based on the scene's render loop.
|
|
1718
|
-
*/
|
|
1719
|
-
class FlowGraphTimerBlock extends FlowGraphAsyncExecutionBlock {
|
|
1720
|
-
constructor(config) {
|
|
1721
|
-
super(config);
|
|
1722
|
-
this.timeout = this.registerDataInput("timeout", RichTypeNumber);
|
|
1723
|
-
}
|
|
1724
|
-
_preparePendingTasks(context) {
|
|
1725
|
-
const currentTimeout = this.timeout.getValue(context);
|
|
1726
|
-
if (currentTimeout !== undefined && currentTimeout >= 0) {
|
|
1727
|
-
const timers = context._getExecutionVariable(this, "runningTimers") || [];
|
|
1728
|
-
const scene = context.configuration.scene;
|
|
1729
|
-
const timer = new AdvancedTimer({
|
|
1730
|
-
timeout: currentTimeout,
|
|
1731
|
-
contextObservable: scene.onBeforeRenderObservable,
|
|
1732
|
-
onEnded: () => this._onEnded(timer, context),
|
|
1733
|
-
});
|
|
1734
|
-
timer.start();
|
|
1735
|
-
timers.push(timer);
|
|
1736
|
-
context._setExecutionVariable(this, "runningTimers", timers);
|
|
1737
|
-
}
|
|
1738
|
-
}
|
|
1739
|
-
/**
|
|
1740
|
-
* @internal
|
|
1741
|
-
*/
|
|
1742
|
-
_execute(context) {
|
|
1743
|
-
this._startPendingTasks(context);
|
|
1744
|
-
this.out._activateSignal(context);
|
|
1745
|
-
}
|
|
1746
|
-
_onEnded(timer, context) {
|
|
1747
|
-
const timers = context._getExecutionVariable(this, "runningTimers") || [];
|
|
1748
|
-
const index = timers.indexOf(timer);
|
|
1749
|
-
if (index !== -1) {
|
|
1750
|
-
timers.splice(index, 1);
|
|
1751
|
-
}
|
|
1752
|
-
else {
|
|
1753
|
-
Tools.Warn("FlowGraphTimerBlock: Timer ended but was not found in the running timers list");
|
|
1754
|
-
}
|
|
1755
|
-
context._removePendingBlock(this);
|
|
1756
|
-
this.done._activateSignal(context);
|
|
1757
|
-
}
|
|
1758
|
-
_cancelPendingTasks(context) {
|
|
1759
|
-
const timers = context._getExecutionVariable(this, "runningTimers") || [];
|
|
1760
|
-
for (const timer of timers) {
|
|
1761
|
-
timer.dispose();
|
|
1762
|
-
}
|
|
1763
|
-
context._deleteExecutionVariable(this, "runningTimers");
|
|
1764
|
-
}
|
|
1765
|
-
/**
|
|
1766
|
-
* @returns class name of the block.
|
|
1767
|
-
*/
|
|
1768
|
-
getClassName() {
|
|
1769
|
-
return FlowGraphTimerBlock.ClassName;
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
/**
|
|
1773
|
-
* the class name of the block.
|
|
1774
|
-
*/
|
|
1775
|
-
FlowGraphTimerBlock.ClassName = "FGTimerBlock";
|
|
1776
|
-
RegisterClass("FGTimerBlock", FlowGraphTimerBlock);
|
|
1777
|
-
|
|
1778
|
-
/**
|
|
1779
|
-
* @experimental
|
|
1780
|
-
*/
|
|
1781
|
-
class FlowGraphSendCustomEventBlock extends FlowGraphExecutionBlockWithOutSignal {
|
|
1782
|
-
constructor(
|
|
1783
|
-
/**
|
|
1784
|
-
* the configuration of the block
|
|
1785
|
-
*/
|
|
1786
|
-
config) {
|
|
1787
|
-
super(config);
|
|
1788
|
-
this.config = config;
|
|
1789
|
-
for (let i = 0; i < this.config.eventData.length; i++) {
|
|
1790
|
-
const dataName = this.config.eventData[i];
|
|
1791
|
-
this.registerDataInput(dataName, RichTypeAny);
|
|
1792
|
-
}
|
|
1793
|
-
}
|
|
1794
|
-
_execute(context) {
|
|
1795
|
-
const eventId = this.config.eventId;
|
|
1796
|
-
const eventDatas = this.dataInputs.map((port) => port.getValue(context));
|
|
1797
|
-
context.configuration.coordinator.notifyCustomEvent(eventId, eventDatas);
|
|
1798
|
-
this.out._activateSignal(context);
|
|
1799
|
-
}
|
|
1800
|
-
/**
|
|
1801
|
-
* @returns class name of the block.
|
|
1802
|
-
*/
|
|
1803
|
-
getClassName() {
|
|
1804
|
-
return FlowGraphSendCustomEventBlock.ClassName;
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
/**
|
|
1808
|
-
* the class name of the block.
|
|
1809
|
-
*/
|
|
1810
|
-
FlowGraphSendCustomEventBlock.ClassName = "FGSendCustomEventBlock";
|
|
1811
|
-
RegisterClass("FGSendCustomEventBlock", FlowGraphSendCustomEventBlock);
|
|
1812
|
-
|
|
1813
|
-
/**
|
|
1814
|
-
* @experimental
|
|
1815
|
-
* A block that receives a custom event. It saves the data sent in the eventData output.
|
|
1816
|
-
*/
|
|
1817
|
-
class FlowGraphReceiveCustomEventBlock extends FlowGraphEventBlock {
|
|
1818
|
-
constructor(
|
|
1819
|
-
/**
|
|
1820
|
-
* the configuration of the block
|
|
1821
|
-
*/
|
|
1822
|
-
config) {
|
|
1823
|
-
super(config);
|
|
1824
|
-
this.config = config;
|
|
1825
|
-
for (let i = 0; i < this.config.eventData.length; i++) {
|
|
1826
|
-
const dataName = this.config.eventData[i];
|
|
1827
|
-
this.registerDataOutput(dataName, RichTypeAny);
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
_preparePendingTasks(context) {
|
|
1831
|
-
const observable = context.configuration.coordinator.getCustomEventObservable(this.config.eventId);
|
|
1832
|
-
this._eventObserver = observable.add((eventDatas) => {
|
|
1833
|
-
for (let i = 0; i < eventDatas.length; i++) {
|
|
1834
|
-
this.dataOutputs[i].setValue(eventDatas[i], context);
|
|
1835
|
-
}
|
|
1836
|
-
this._execute(context);
|
|
1837
|
-
});
|
|
1838
|
-
}
|
|
1839
|
-
_cancelPendingTasks(context) {
|
|
1840
|
-
const observable = context.configuration.coordinator.getCustomEventObservable(this.config.eventId);
|
|
1841
|
-
if (observable) {
|
|
1842
|
-
observable.remove(this._eventObserver);
|
|
1843
|
-
}
|
|
1844
|
-
else {
|
|
1845
|
-
Tools.Warn(`FlowGraphReceiveCustomEventBlock: Missing observable for event ${this.config.eventId}`);
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
/**
|
|
1849
|
-
* @returns class name of the block.
|
|
1850
|
-
*/
|
|
1851
|
-
getClassName() {
|
|
1852
|
-
return FlowGraphReceiveCustomEventBlock.ClassName;
|
|
1853
|
-
}
|
|
1854
|
-
/**
|
|
1855
|
-
* Serializes this block
|
|
1856
|
-
* @param serializationObject the object to serialize to
|
|
1857
|
-
*/
|
|
1858
|
-
serialize(serializationObject) {
|
|
1859
|
-
super.serialize(serializationObject);
|
|
1860
|
-
serializationObject.eventId = this.config.eventId;
|
|
1861
|
-
serializationObject.eventData = this.config.eventData;
|
|
1862
|
-
}
|
|
1863
|
-
}
|
|
1864
|
-
/**
|
|
1865
|
-
* the class name of the block.
|
|
1866
|
-
*/
|
|
1867
|
-
FlowGraphReceiveCustomEventBlock.ClassName = "FGReceiveCustomEventBlock";
|
|
1868
|
-
RegisterClass(FlowGraphReceiveCustomEventBlock.ClassName, FlowGraphReceiveCustomEventBlock);
|
|
1869
|
-
|
|
1870
|
-
/**
|
|
1871
|
-
* @experimental
|
|
1872
|
-
* A block that executes its output flows in sequence.
|
|
1873
|
-
*/
|
|
1874
|
-
class FlowGraphSequenceBlock extends FlowGraphExecutionBlock {
|
|
1875
|
-
constructor(
|
|
1876
|
-
/**
|
|
1877
|
-
* the configuration of the block
|
|
1878
|
-
*/
|
|
1879
|
-
config) {
|
|
1880
|
-
super(config);
|
|
1881
|
-
this.config = config;
|
|
1882
|
-
this.outFlows = [];
|
|
1883
|
-
for (let i = 0; i < this.config.numberOutputFlows; i++) {
|
|
1884
|
-
this.outFlows.push(this._registerSignalOutput(`${i}`));
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
_execute(context) {
|
|
1888
|
-
for (let i = 0; i < this.config.numberOutputFlows; i++) {
|
|
1889
|
-
this.outFlows[i]._activateSignal(context);
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
/**
|
|
1893
|
-
* @returns class name of the block.
|
|
1894
|
-
*/
|
|
1895
|
-
getClassName() {
|
|
1896
|
-
return FlowGraphSequenceBlock.ClassName;
|
|
1897
|
-
}
|
|
1898
|
-
}
|
|
1899
|
-
/**
|
|
1900
|
-
* the class name of the block.
|
|
1901
|
-
*/
|
|
1902
|
-
FlowGraphSequenceBlock.ClassName = "FGSequenceBlock";
|
|
1903
|
-
RegisterClass(FlowGraphSequenceBlock.ClassName, FlowGraphSequenceBlock);
|
|
1904
|
-
|
|
1905
|
-
const pathHasTemplatesRegex = new RegExp(/\{(\w+)\}/g);
|
|
1906
|
-
/**
|
|
1907
|
-
* @experimental
|
|
1908
|
-
* A component that converts a path to an object accessor.
|
|
1909
|
-
*/
|
|
1910
|
-
class FlowGraphPathConverterComponent {
|
|
1911
|
-
constructor(path, ownerBlock) {
|
|
1912
|
-
this.path = path;
|
|
1913
|
-
this.ownerBlock = ownerBlock;
|
|
1914
|
-
/**
|
|
1915
|
-
* The templated inputs for the provided path.
|
|
1916
|
-
*/
|
|
1917
|
-
this.templatedInputs = [];
|
|
1918
|
-
let match = pathHasTemplatesRegex.exec(path);
|
|
1919
|
-
while (match) {
|
|
1920
|
-
const [, matchGroup] = match;
|
|
1921
|
-
this.templatedInputs.push(ownerBlock.registerDataInput(matchGroup, RichTypeFlowGraphInteger));
|
|
1922
|
-
match = pathHasTemplatesRegex.exec(path);
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
getAccessor(pathConverter, context) {
|
|
1926
|
-
let finalPath = this.path;
|
|
1927
|
-
for (const templatedInput of this.templatedInputs) {
|
|
1928
|
-
const valueToReplace = templatedInput.getValue(context).value;
|
|
1929
|
-
finalPath = finalPath.replace(`{${templatedInput.name}}`, valueToReplace.toString());
|
|
1930
|
-
}
|
|
1931
|
-
return pathConverter.convert(finalPath);
|
|
1932
|
-
}
|
|
1933
|
-
}
|
|
1934
|
-
|
|
1935
|
-
/**
|
|
1936
|
-
* @experimental
|
|
1937
|
-
*/
|
|
1938
|
-
class FlowGraphGetPropertyBlock extends FlowGraphBlock {
|
|
1939
|
-
constructor(
|
|
1940
|
-
/**
|
|
1941
|
-
* the configuration of the block
|
|
1942
|
-
*/
|
|
1943
|
-
config) {
|
|
1944
|
-
super(config);
|
|
1945
|
-
this.config = config;
|
|
1946
|
-
this.value = this.registerDataOutput("value", RichTypeAny);
|
|
1947
|
-
this.templateComponent = new FlowGraphPathConverterComponent(config.path, this);
|
|
1948
|
-
}
|
|
1949
|
-
_updateOutputs(context) {
|
|
1950
|
-
const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);
|
|
1951
|
-
const value = accessorContainer.info.get(accessorContainer.object);
|
|
1952
|
-
this.value.setValue(value, context);
|
|
1953
|
-
}
|
|
1954
|
-
/**
|
|
1955
|
-
* Gets the class name of this block
|
|
1956
|
-
* @returns the class name
|
|
1957
|
-
*/
|
|
1958
|
-
getClassName() {
|
|
1959
|
-
return FlowGraphGetPropertyBlock.ClassName;
|
|
1960
|
-
}
|
|
1961
|
-
/**
|
|
1962
|
-
* Serializes this block
|
|
1963
|
-
* @param serializationObject the object to serialize to
|
|
1964
|
-
*/
|
|
1965
|
-
serialize(serializationObject = {}) {
|
|
1966
|
-
super.serialize(serializationObject);
|
|
1967
|
-
serializationObject.config.path = this.config.path;
|
|
1968
|
-
}
|
|
1969
|
-
}
|
|
1970
|
-
/**
|
|
1971
|
-
* Class name of the block.
|
|
1972
|
-
*/
|
|
1973
|
-
FlowGraphGetPropertyBlock.ClassName = "FGGetPropertyBlock";
|
|
1974
|
-
RegisterClass(FlowGraphGetPropertyBlock.ClassName, FlowGraphGetPropertyBlock);
|
|
1975
|
-
|
|
1976
|
-
/**
|
|
1977
|
-
* @experimental
|
|
1978
|
-
* Block that sets a property on a target object.
|
|
1979
|
-
*/
|
|
1980
|
-
class FlowGraphSetPropertyBlock extends FlowGraphExecutionBlockWithOutSignal {
|
|
1981
|
-
constructor(
|
|
1982
|
-
/**
|
|
1983
|
-
* the configuration of the block
|
|
1984
|
-
*/
|
|
1985
|
-
config) {
|
|
1986
|
-
super(config);
|
|
1987
|
-
this.config = config;
|
|
1988
|
-
this.a = this.registerDataInput("a", RichTypeAny);
|
|
1989
|
-
this.templateComponent = new FlowGraphPathConverterComponent(config.path, this);
|
|
1990
|
-
}
|
|
1991
|
-
_execute(context) {
|
|
1992
|
-
const value = this.a.getValue(context);
|
|
1993
|
-
const accessor = this.templateComponent.getAccessor(this.config.pathConverter, context);
|
|
1994
|
-
accessor.info.set(value, accessor.object);
|
|
1995
|
-
this.out._activateSignal(context);
|
|
1996
|
-
}
|
|
1997
|
-
/**
|
|
1998
|
-
* Serializes the block to a JSON object.
|
|
1999
|
-
* @param serializationObject the object to serialize to.
|
|
2000
|
-
*/
|
|
2001
|
-
serialize(serializationObject = {}) {
|
|
2002
|
-
super.serialize(serializationObject);
|
|
2003
|
-
serializationObject.config.path = this.config.path;
|
|
2004
|
-
}
|
|
2005
|
-
/**
|
|
2006
|
-
* @returns class name of the block.
|
|
2007
|
-
*/
|
|
2008
|
-
getClassName() {
|
|
2009
|
-
return FlowGraphSetPropertyBlock.ClassName;
|
|
2010
|
-
}
|
|
2011
|
-
}
|
|
2012
|
-
/**
|
|
2013
|
-
* Class name of the block.
|
|
2014
|
-
*/
|
|
2015
|
-
FlowGraphSetPropertyBlock.ClassName = "FGSetPropertyBlock";
|
|
2016
|
-
RegisterClass("FGSetPropertyBlock", FlowGraphSetPropertyBlock);
|
|
2017
|
-
|
|
2018
|
-
const cacheName = "cachedOperationValue";
|
|
2019
|
-
const cacheExecIdName = "cachedExecutionId";
|
|
2020
|
-
/**
|
|
2021
|
-
* @experimental
|
|
2022
|
-
*/
|
|
2023
|
-
class FlowGraphCachedOperationBlock extends FlowGraphBlock {
|
|
2024
|
-
constructor(outputRichType, config) {
|
|
2025
|
-
super(config);
|
|
2026
|
-
this.value = this.registerDataOutput("value", outputRichType);
|
|
2027
|
-
}
|
|
2028
|
-
_updateOutputs(context) {
|
|
2029
|
-
const cachedExecutionId = context._getExecutionVariable(this, cacheExecIdName);
|
|
2030
|
-
const cachedValue = context._getExecutionVariable(this, cacheName);
|
|
2031
|
-
if (cachedValue !== undefined && cachedExecutionId === context.executionId) {
|
|
2032
|
-
this.value.setValue(cachedValue, context);
|
|
2033
|
-
}
|
|
2034
|
-
else {
|
|
2035
|
-
const calculatedValue = this._doOperation(context);
|
|
2036
|
-
context._setExecutionVariable(this, cacheName, calculatedValue);
|
|
2037
|
-
context._setExecutionVariable(this, cacheExecIdName, context.executionId);
|
|
2038
|
-
this.value.setValue(calculatedValue, context);
|
|
2039
|
-
}
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
|
|
2043
|
-
/**
|
|
2044
|
-
* @experimental
|
|
2045
|
-
* The base block for all binary operation blocks. Receives an input of type
|
|
2046
|
-
* LeftT, one of type RightT, and outputs a value of type ResultT.
|
|
2047
|
-
*/
|
|
2048
|
-
class FlowGraphBinaryOperationBlock extends FlowGraphCachedOperationBlock {
|
|
2049
|
-
constructor(leftRichType, rightRichType, resultRichType, _operation, _className, config) {
|
|
2050
|
-
super(resultRichType, config);
|
|
2051
|
-
this._operation = _operation;
|
|
2052
|
-
this._className = _className;
|
|
2053
|
-
this.a = this.registerDataInput("a", leftRichType);
|
|
2054
|
-
this.b = this.registerDataInput("b", rightRichType);
|
|
2055
|
-
}
|
|
2056
|
-
/**
|
|
2057
|
-
* the operation performed by this block
|
|
2058
|
-
* @param context the graph context
|
|
2059
|
-
* @returns the result of the operation
|
|
2060
|
-
*/
|
|
2061
|
-
_doOperation(context) {
|
|
2062
|
-
return this._operation(this.a.getValue(context), this.b.getValue(context));
|
|
2063
|
-
}
|
|
2064
|
-
/**
|
|
2065
|
-
* Gets the class name of this block
|
|
2066
|
-
* @returns the class name
|
|
2067
|
-
*/
|
|
2068
|
-
getClassName() {
|
|
2069
|
-
return this._className;
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
|
-
|
|
2073
|
-
/**
|
|
2074
|
-
* @experimental
|
|
2075
|
-
* Block that outputs a value of type ResultT, resulting of an operation with no inputs.
|
|
2076
|
-
*/
|
|
2077
|
-
class FlowGraphConstantOperationBlock extends FlowGraphCachedOperationBlock {
|
|
2078
|
-
constructor(richType, _operation, _className, config) {
|
|
2079
|
-
super(richType, config);
|
|
2080
|
-
this._operation = _operation;
|
|
2081
|
-
this._className = _className;
|
|
2082
|
-
}
|
|
2083
|
-
/**
|
|
2084
|
-
* the operation performed by this block
|
|
2085
|
-
* @param _context the graph context
|
|
2086
|
-
* @returns the result of the operation
|
|
2087
|
-
*/
|
|
2088
|
-
_doOperation(_context) {
|
|
2089
|
-
return this._operation();
|
|
2090
|
-
}
|
|
2091
|
-
/**
|
|
2092
|
-
* Gets the class name of this block
|
|
2093
|
-
* @returns the class name
|
|
2094
|
-
*/
|
|
2095
|
-
getClassName() {
|
|
2096
|
-
return this._className;
|
|
2097
|
-
}
|
|
2098
|
-
}
|
|
2099
|
-
|
|
2100
|
-
/**
|
|
2101
|
-
* @experimental
|
|
2102
|
-
* The base block for all unary operation blocks. Receives an input of type InputT, and outputs a value of type ResultT.
|
|
2103
|
-
*/
|
|
2104
|
-
class FlowGraphUnaryOperationBlock extends FlowGraphCachedOperationBlock {
|
|
2105
|
-
constructor(inputRichType, resultRichType, _operation, _className, config) {
|
|
2106
|
-
super(resultRichType, config);
|
|
2107
|
-
this._operation = _operation;
|
|
2108
|
-
this._className = _className;
|
|
2109
|
-
this.a = this.registerDataInput("a", inputRichType);
|
|
2110
|
-
}
|
|
2111
|
-
/**
|
|
2112
|
-
* the operation performed by this block
|
|
2113
|
-
* @param context the graph context
|
|
2114
|
-
* @returns the result of the operation
|
|
2115
|
-
*/
|
|
2116
|
-
_doOperation(context) {
|
|
2117
|
-
return this._operation(this.a.getValue(context));
|
|
2118
|
-
}
|
|
2119
|
-
/**
|
|
2120
|
-
* Gets the class name of this block
|
|
2121
|
-
* @returns the class name
|
|
2122
|
-
*/
|
|
2123
|
-
getClassName() {
|
|
2124
|
-
return this._className;
|
|
2125
|
-
}
|
|
2126
|
-
}
|
|
2127
|
-
|
|
2128
|
-
/**
|
|
2129
|
-
* @experimental
|
|
2130
|
-
* The base block for all ternary operation blocks.
|
|
2131
|
-
*/
|
|
2132
|
-
class FlowGraphTernaryOperationBlock extends FlowGraphCachedOperationBlock {
|
|
2133
|
-
constructor(t1Type, t2Type, t3Type, resultRichType, _operation, _className, config) {
|
|
2134
|
-
super(resultRichType, config);
|
|
2135
|
-
this._operation = _operation;
|
|
2136
|
-
this._className = _className;
|
|
2137
|
-
this.a = this.registerDataInput("a", t1Type);
|
|
2138
|
-
this.b = this.registerDataInput("b", t2Type);
|
|
2139
|
-
this.c = this.registerDataInput("c", t3Type);
|
|
2140
|
-
}
|
|
2141
|
-
/**
|
|
2142
|
-
* the operation performed by this block
|
|
2143
|
-
* @param context the graph context
|
|
2144
|
-
* @returns the result of the operation
|
|
2145
|
-
*/
|
|
2146
|
-
_doOperation(context) {
|
|
2147
|
-
return this._operation(this.a.getValue(context), this.b.getValue(context), this.c.getValue(context));
|
|
2148
|
-
}
|
|
2149
|
-
/**
|
|
2150
|
-
* Gets the class name of this block
|
|
2151
|
-
* @returns the class name
|
|
2152
|
-
*/
|
|
2153
|
-
getClassName() {
|
|
2154
|
-
return this._className;
|
|
2155
|
-
}
|
|
2156
|
-
}
|
|
2157
|
-
|
|
2158
|
-
/**
|
|
2159
|
-
* @internal
|
|
2160
|
-
*/
|
|
2161
|
-
function _getClassNameOf(v) {
|
|
2162
|
-
if (v.getClassName) {
|
|
2163
|
-
return v.getClassName();
|
|
2164
|
-
}
|
|
2165
|
-
return "";
|
|
2166
|
-
}
|
|
2167
|
-
/**
|
|
2168
|
-
* @internal
|
|
2169
|
-
* @returns
|
|
2170
|
-
*/
|
|
2171
|
-
function _areSameVectorClass(className, className2) {
|
|
2172
|
-
return (className === "Vector2" && className2 === "Vector2") || (className === "Vector3" && className2 === "Vector3") || (className === "Vector4" && className2 === "Vector4");
|
|
2173
|
-
}
|
|
2174
|
-
/**
|
|
2175
|
-
* @internal
|
|
2176
|
-
* @returns
|
|
2177
|
-
*/
|
|
2178
|
-
function _areSameMatrixClass(className, className2) {
|
|
2179
|
-
return className === "Matrix" && className2 === "Matrix";
|
|
2180
|
-
}
|
|
2181
|
-
/**
|
|
2182
|
-
* @internal
|
|
2183
|
-
* @returns
|
|
2184
|
-
*/
|
|
2185
|
-
function _areSameIntegerClass(className, className2) {
|
|
2186
|
-
return className === "FlowGraphInteger" && className2 === "FlowGraphInteger";
|
|
2187
|
-
}
|
|
2188
|
-
/**
|
|
2189
|
-
* @experimental
|
|
2190
|
-
* Polymorphic add block.
|
|
2191
|
-
*/
|
|
2192
|
-
class FlowGraphAddBlock extends FlowGraphBinaryOperationBlock {
|
|
2193
|
-
constructor(config) {
|
|
2194
|
-
super(RichTypeAny, RichTypeAny, RichTypeAny, (a, b) => this._polymorphicAdd(a, b), FlowGraphAddBlock.ClassName, config);
|
|
2195
|
-
}
|
|
2196
|
-
_polymorphicAdd(a, b) {
|
|
2197
|
-
const aClassName = _getClassNameOf(a);
|
|
2198
|
-
const bClassName = _getClassNameOf(b);
|
|
2199
|
-
if (_areSameVectorClass(aClassName, bClassName) || _areSameMatrixClass(aClassName, bClassName) || _areSameIntegerClass(aClassName, bClassName)) {
|
|
2200
|
-
return a.add(b);
|
|
2201
|
-
}
|
|
2202
|
-
else {
|
|
2203
|
-
return a + b;
|
|
2204
|
-
}
|
|
2205
|
-
}
|
|
2206
|
-
}
|
|
2207
|
-
/**
|
|
2208
|
-
* the class name of the block.
|
|
2209
|
-
*/
|
|
2210
|
-
FlowGraphAddBlock.ClassName = "FGAddBlock";
|
|
2211
|
-
RegisterClass(FlowGraphAddBlock.ClassName, FlowGraphAddBlock);
|
|
2212
|
-
/**
|
|
2213
|
-
* @experimental
|
|
2214
|
-
* Polymorphic add block.
|
|
2215
|
-
*/
|
|
2216
|
-
class FlowGraphSubtractBlock extends FlowGraphBinaryOperationBlock {
|
|
2217
|
-
constructor(config) {
|
|
2218
|
-
super(RichTypeAny, RichTypeAny, RichTypeAny, (a, b) => this._polymorphicAdd(a, b), FlowGraphSubtractBlock.ClassName, config);
|
|
2219
|
-
}
|
|
2220
|
-
_polymorphicAdd(a, b) {
|
|
2221
|
-
const aClassName = _getClassNameOf(a);
|
|
2222
|
-
const bClassName = _getClassNameOf(b);
|
|
2223
|
-
if (_areSameVectorClass(aClassName, bClassName) || _areSameIntegerClass(aClassName, bClassName)) {
|
|
2224
|
-
return a.subtract(b);
|
|
2225
|
-
}
|
|
2226
|
-
else if (_areSameMatrixClass(aClassName, bClassName)) {
|
|
2227
|
-
return a.add(b.scale(-1));
|
|
2228
|
-
}
|
|
2229
|
-
else {
|
|
2230
|
-
return a - b;
|
|
2231
|
-
}
|
|
2232
|
-
}
|
|
2233
|
-
}
|
|
2234
|
-
/**
|
|
2235
|
-
* the class name of the block.
|
|
2236
|
-
*/
|
|
2237
|
-
FlowGraphSubtractBlock.ClassName = "FGSubBlock";
|
|
2238
|
-
RegisterClass(FlowGraphSubtractBlock.ClassName, FlowGraphSubtractBlock);
|
|
2239
|
-
/**
|
|
2240
|
-
* @experimental
|
|
2241
|
-
* Polymorphic multiply block.
|
|
2242
|
-
* In case of matrix, it is a component wise multiplication.
|
|
2243
|
-
*/
|
|
2244
|
-
class FlowGraphMultiplyBlock extends FlowGraphBinaryOperationBlock {
|
|
2245
|
-
constructor(config) {
|
|
2246
|
-
super(RichTypeAny, RichTypeAny, RichTypeAny, (a, b) => this._polymorphicMultiply(a, b), FlowGraphMultiplyBlock.ClassName, config);
|
|
2247
|
-
}
|
|
2248
|
-
_polymorphicMultiply(a, b) {
|
|
2249
|
-
const aClassName = _getClassNameOf(a);
|
|
2250
|
-
const bClassName = _getClassNameOf(b);
|
|
2251
|
-
if (_areSameVectorClass(aClassName, bClassName) || _areSameIntegerClass(aClassName, bClassName)) {
|
|
2252
|
-
return a.multiply(b);
|
|
2253
|
-
}
|
|
2254
|
-
else if (_areSameMatrixClass(aClassName, bClassName)) {
|
|
2255
|
-
return Matrix.FromValues(a.m[0] * b.m[0], a.m[4] * b.m[4], a.m[8] * b.m[8], a.m[12] * b.m[12], a.m[1] * b.m[1], a.m[5] * b.m[5], a.m[9] * b.m[9], a.m[13] * b.m[13], a.m[2] * b.m[2], a.m[6] * b.m[6], a.m[10] * b.m[10], a.m[14] * b.m[14], a.m[3] * b.m[3], a.m[7] * b.m[7], a.m[11] * b.m[11], a.m[15] * b.m[15]);
|
|
2256
|
-
}
|
|
2257
|
-
else {
|
|
2258
|
-
return a * b;
|
|
2259
|
-
}
|
|
2260
|
-
}
|
|
2261
|
-
}
|
|
2262
|
-
/**
|
|
2263
|
-
* the class name of the block.
|
|
2264
|
-
*/
|
|
2265
|
-
FlowGraphMultiplyBlock.ClassName = "FGMultiplyBlock";
|
|
2266
|
-
RegisterClass(FlowGraphMultiplyBlock.ClassName, FlowGraphMultiplyBlock);
|
|
2267
|
-
/**
|
|
2268
|
-
* @experimental
|
|
2269
|
-
* Polymorphic division block.
|
|
2270
|
-
*/
|
|
2271
|
-
class FlowGraphDivideBlock extends FlowGraphBinaryOperationBlock {
|
|
2272
|
-
constructor(config) {
|
|
2273
|
-
super(RichTypeAny, RichTypeAny, RichTypeAny, (a, b) => this._polymorphicDivide(a, b), FlowGraphDivideBlock.ClassName, config);
|
|
2274
|
-
}
|
|
2275
|
-
_polymorphicDivide(a, b) {
|
|
2276
|
-
const aClassName = _getClassNameOf(a);
|
|
2277
|
-
const bClassName = _getClassNameOf(b);
|
|
2278
|
-
if (_areSameVectorClass(aClassName, bClassName) || _areSameIntegerClass(aClassName, bClassName)) {
|
|
2279
|
-
return a.divide(b);
|
|
2280
|
-
}
|
|
2281
|
-
else if (_areSameMatrixClass(aClassName, bClassName)) {
|
|
2282
|
-
return Matrix.FromValues(a.m[0] / b.m[0], a.m[4] / b.m[4], a.m[8] / b.m[8], a.m[12] / b.m[12], a.m[1] / b.m[1], a.m[5] / b.m[5], a.m[9] / b.m[9], a.m[13] / b.m[13], a.m[2] / b.m[2], a.m[6] / b.m[6], a.m[10] / b.m[10], a.m[14] / b.m[14], a.m[3] / b.m[3], a.m[7] / b.m[7], a.m[11] / b.m[11], a.m[15] / b.m[15]);
|
|
2283
|
-
}
|
|
2284
|
-
else {
|
|
2285
|
-
return a / b;
|
|
2286
|
-
}
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
/**
|
|
2290
|
-
* the class name of the block.
|
|
2291
|
-
*/
|
|
2292
|
-
FlowGraphDivideBlock.ClassName = "FGDivideBlock";
|
|
2293
|
-
RegisterClass(FlowGraphDivideBlock.ClassName, FlowGraphDivideBlock);
|
|
2294
|
-
/**
|
|
2295
|
-
* @experimental
|
|
2296
|
-
* Random number between 0 and 1.
|
|
2297
|
-
*/
|
|
2298
|
-
class FlowGraphRandomBlock extends FlowGraphConstantOperationBlock {
|
|
2299
|
-
constructor(config) {
|
|
2300
|
-
super(RichTypeNumber, () => Math.random(), FlowGraphRandomBlock.ClassName, config);
|
|
2301
|
-
}
|
|
2302
|
-
}
|
|
2303
|
-
/**
|
|
2304
|
-
* the class name of the block.
|
|
2305
|
-
*/
|
|
2306
|
-
FlowGraphRandomBlock.ClassName = "FGRandomBlock";
|
|
2307
|
-
RegisterClass(FlowGraphRandomBlock.ClassName, FlowGraphRandomBlock);
|
|
2308
|
-
/**
|
|
2309
|
-
* @experimental
|
|
2310
|
-
* Dot product block.
|
|
2311
|
-
*/
|
|
2312
|
-
class FlowGraphDotBlock extends FlowGraphBinaryOperationBlock {
|
|
2313
|
-
constructor(config) {
|
|
2314
|
-
super(RichTypeAny, RichTypeAny, RichTypeNumber, (a, b) => this._polymorphicDot(a, b), FlowGraphDotBlock.ClassName, config);
|
|
2315
|
-
}
|
|
2316
|
-
_polymorphicDot(a, b) {
|
|
2317
|
-
const className = _getClassNameOf(a);
|
|
2318
|
-
switch (className) {
|
|
2319
|
-
case "Vector2":
|
|
2320
|
-
return Vector2.Dot(a, b);
|
|
2321
|
-
case "Vector3":
|
|
2322
|
-
return Vector3.Dot(a, b);
|
|
2323
|
-
case "Vector4":
|
|
2324
|
-
return Vector4.Dot(a, b);
|
|
2325
|
-
default:
|
|
2326
|
-
throw new Error(`Cannot get dot product of ${a} and ${b}`);
|
|
2327
|
-
}
|
|
2328
|
-
}
|
|
2329
|
-
}
|
|
2330
|
-
/**
|
|
2331
|
-
* the class name of the block.
|
|
2332
|
-
*/
|
|
2333
|
-
FlowGraphDotBlock.ClassName = "FGDotBlock";
|
|
2334
|
-
RegisterClass(FlowGraphDotBlock.ClassName, FlowGraphDotBlock);
|
|
2335
|
-
/**
|
|
2336
|
-
* @experimental
|
|
2337
|
-
* E constant.
|
|
2338
|
-
*/
|
|
2339
|
-
class FlowGraphEBlock extends FlowGraphConstantOperationBlock {
|
|
2340
|
-
constructor(config) {
|
|
2341
|
-
super(RichTypeNumber, () => Math.E, FlowGraphEBlock.ClassName, config);
|
|
2342
|
-
}
|
|
2343
|
-
}
|
|
2344
|
-
/**
|
|
2345
|
-
* the class name of the block.
|
|
2346
|
-
*/
|
|
2347
|
-
FlowGraphEBlock.ClassName = "FGEBlock";
|
|
2348
|
-
RegisterClass(FlowGraphEBlock.ClassName, FlowGraphEBlock);
|
|
2349
|
-
/**
|
|
2350
|
-
* @experimental
|
|
2351
|
-
* Pi constant.
|
|
2352
|
-
*/
|
|
2353
|
-
class FlowGraphPiBlock extends FlowGraphConstantOperationBlock {
|
|
2354
|
-
constructor(config) {
|
|
2355
|
-
super(RichTypeNumber, () => Math.PI, FlowGraphPiBlock.ClassName, config);
|
|
2356
|
-
}
|
|
2357
|
-
}
|
|
2358
|
-
/**
|
|
2359
|
-
* the class name of the block.
|
|
2360
|
-
*/
|
|
2361
|
-
FlowGraphPiBlock.ClassName = "FGPIBlock";
|
|
2362
|
-
RegisterClass(FlowGraphPiBlock.ClassName, FlowGraphPiBlock);
|
|
2363
|
-
/**
|
|
2364
|
-
* @experimental
|
|
2365
|
-
* Positive inf constant.
|
|
2366
|
-
*/
|
|
2367
|
-
class FlowGraphInfBlock extends FlowGraphConstantOperationBlock {
|
|
2368
|
-
constructor(config) {
|
|
2369
|
-
super(RichTypeNumber, () => Number.POSITIVE_INFINITY, FlowGraphInfBlock.ClassName, config);
|
|
2370
|
-
}
|
|
2371
|
-
}
|
|
2372
|
-
/**
|
|
2373
|
-
* the class name of the block.
|
|
2374
|
-
*/
|
|
2375
|
-
FlowGraphInfBlock.ClassName = "FGInfBlock";
|
|
2376
|
-
RegisterClass(FlowGraphInfBlock.ClassName, FlowGraphInfBlock);
|
|
2377
|
-
/**
|
|
2378
|
-
* @experimental
|
|
2379
|
-
* NaN constant.
|
|
2380
|
-
*/
|
|
2381
|
-
class FlowGraphNaNBlock extends FlowGraphConstantOperationBlock {
|
|
2382
|
-
constructor(config) {
|
|
2383
|
-
super(RichTypeNumber, () => Number.NaN, FlowGraphNaNBlock.ClassName, config);
|
|
2384
|
-
}
|
|
2385
|
-
}
|
|
2386
|
-
/**
|
|
2387
|
-
* the class name of the block.
|
|
2388
|
-
*/
|
|
2389
|
-
FlowGraphNaNBlock.ClassName = "FGNaNBlock";
|
|
2390
|
-
RegisterClass(FlowGraphNaNBlock.ClassName, FlowGraphNaNBlock);
|
|
2391
|
-
function _componentWiseUnaryOperation(a, op) {
|
|
2392
|
-
const aClassName = _getClassNameOf(a);
|
|
2393
|
-
switch (aClassName) {
|
|
2394
|
-
case "FlowGraphInteger":
|
|
2395
|
-
return new FlowGraphInteger(op(a.value));
|
|
2396
|
-
case "Vector2":
|
|
2397
|
-
return new Vector2(op(a.x), op(a.y));
|
|
2398
|
-
case "Vector3":
|
|
2399
|
-
return new Vector3(op(a.x), op(a.y), op(a.z));
|
|
2400
|
-
case "Vector4":
|
|
2401
|
-
return new Vector4(op(a.x), op(a.y), op(a.z), op(a.w));
|
|
2402
|
-
case "Matrix":
|
|
2403
|
-
return Matrix.FromValues(op(a.m[0]), op(a.m[4]), op(a.m[8]), op(a.m[12]), op(a.m[1]), op(a.m[5]), op(a.m[9]), op(a.m[13]), op(a.m[2]), op(a.m[6]), op(a.m[10]), op(a.m[14]), op(a.m[3]), op(a.m[7]), op(a.m[11]), op(a.m[15]));
|
|
2404
|
-
default:
|
|
2405
|
-
return op(a);
|
|
2406
|
-
}
|
|
2407
|
-
}
|
|
2408
|
-
/**
|
|
2409
|
-
* @experimental
|
|
2410
|
-
* Absolute value block.
|
|
2411
|
-
*/
|
|
2412
|
-
class FlowGraphAbsBlock extends FlowGraphUnaryOperationBlock {
|
|
2413
|
-
constructor(config) {
|
|
2414
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicAbs(a), FlowGraphAbsBlock.ClassName, config);
|
|
2415
|
-
}
|
|
2416
|
-
_polymorphicAbs(a) {
|
|
2417
|
-
return _componentWiseUnaryOperation(a, Math.abs);
|
|
2418
|
-
}
|
|
2419
|
-
}
|
|
2420
|
-
/**
|
|
2421
|
-
* the class name of the block.
|
|
2422
|
-
*/
|
|
2423
|
-
FlowGraphAbsBlock.ClassName = "FGAbsBlock";
|
|
2424
|
-
RegisterClass(FlowGraphAbsBlock.ClassName, FlowGraphAbsBlock);
|
|
2425
|
-
/**
|
|
2426
|
-
* @experimental
|
|
2427
|
-
* Sign block.
|
|
2428
|
-
*/
|
|
2429
|
-
class FlowGraphSignBlock extends FlowGraphUnaryOperationBlock {
|
|
2430
|
-
constructor(config) {
|
|
2431
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicSign(a), FlowGraphSignBlock.ClassName, config);
|
|
2432
|
-
}
|
|
2433
|
-
_polymorphicSign(a) {
|
|
2434
|
-
return _componentWiseUnaryOperation(a, Math.sign);
|
|
2435
|
-
}
|
|
2436
|
-
}
|
|
2437
|
-
/**
|
|
2438
|
-
* the class name of the block.
|
|
2439
|
-
*/
|
|
2440
|
-
FlowGraphSignBlock.ClassName = "FGSignBlock";
|
|
2441
|
-
RegisterClass(FlowGraphSignBlock.ClassName, FlowGraphSignBlock);
|
|
2442
|
-
/**
|
|
2443
|
-
* @experimental
|
|
2444
|
-
* Truncation block.
|
|
2445
|
-
*/
|
|
2446
|
-
class FlowGraphTruncBlock extends FlowGraphUnaryOperationBlock {
|
|
2447
|
-
constructor(config) {
|
|
2448
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicTrunc(a), FlowGraphTruncBlock.ClassName, config);
|
|
2449
|
-
}
|
|
2450
|
-
_polymorphicTrunc(a) {
|
|
2451
|
-
return _componentWiseUnaryOperation(a, Math.trunc);
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
/**
|
|
2455
|
-
* the class name of the block.
|
|
2456
|
-
*/
|
|
2457
|
-
FlowGraphTruncBlock.ClassName = "FGTruncBlock";
|
|
2458
|
-
RegisterClass(FlowGraphTruncBlock.ClassName, FlowGraphTruncBlock);
|
|
2459
|
-
/**
|
|
2460
|
-
* @experimental
|
|
2461
|
-
* Floor block.
|
|
2462
|
-
*/
|
|
2463
|
-
class FlowGraphFloorBlock extends FlowGraphUnaryOperationBlock {
|
|
2464
|
-
constructor(config) {
|
|
2465
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicFloor(a), FlowGraphFloorBlock.ClassName, config);
|
|
2466
|
-
}
|
|
2467
|
-
_polymorphicFloor(a) {
|
|
2468
|
-
return _componentWiseUnaryOperation(a, Math.floor);
|
|
2469
|
-
}
|
|
2470
|
-
}
|
|
2471
|
-
/**
|
|
2472
|
-
* the class name of the block.
|
|
2473
|
-
*/
|
|
2474
|
-
FlowGraphFloorBlock.ClassName = "FGFloorBlock";
|
|
2475
|
-
RegisterClass(FlowGraphFloorBlock.ClassName, FlowGraphFloorBlock);
|
|
2476
|
-
/**
|
|
2477
|
-
* @experimental
|
|
2478
|
-
* Ceiling block.
|
|
2479
|
-
*/
|
|
2480
|
-
class FlowGraphCeilBlock extends FlowGraphUnaryOperationBlock {
|
|
2481
|
-
constructor(config) {
|
|
2482
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicCeiling(a), FlowGraphCeilBlock.ClassName, config);
|
|
2483
|
-
}
|
|
2484
|
-
_polymorphicCeiling(a) {
|
|
2485
|
-
return _componentWiseUnaryOperation(a, Math.ceil);
|
|
2486
|
-
}
|
|
2487
|
-
}
|
|
2488
|
-
/**
|
|
2489
|
-
* the class name of the block.
|
|
2490
|
-
*/
|
|
2491
|
-
FlowGraphCeilBlock.ClassName = "FGCeilBlock";
|
|
2492
|
-
RegisterClass(FlowGraphCeilBlock.ClassName, FlowGraphCeilBlock);
|
|
2493
|
-
/**
|
|
2494
|
-
* @experimental
|
|
2495
|
-
* Fract block.
|
|
2496
|
-
*/
|
|
2497
|
-
class FlowGraphFractBlock extends FlowGraphUnaryOperationBlock {
|
|
2498
|
-
constructor(config) {
|
|
2499
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicFract(a), FlowGraphFractBlock.ClassName, config);
|
|
2500
|
-
}
|
|
2501
|
-
_polymorphicFract(a) {
|
|
2502
|
-
return _componentWiseUnaryOperation(a, (a) => a - Math.floor(a));
|
|
2503
|
-
}
|
|
2504
|
-
}
|
|
2505
|
-
/**
|
|
2506
|
-
* the class name of the block.
|
|
2507
|
-
*/
|
|
2508
|
-
FlowGraphFractBlock.ClassName = "FGFractBlock";
|
|
2509
|
-
RegisterClass(FlowGraphFractBlock.ClassName, FlowGraphFractBlock);
|
|
2510
|
-
/**
|
|
2511
|
-
* @experimental
|
|
2512
|
-
* Negation block.
|
|
2513
|
-
*/
|
|
2514
|
-
class FlowGraphNegBlock extends FlowGraphUnaryOperationBlock {
|
|
2515
|
-
/**
|
|
2516
|
-
* construct a new negation block.
|
|
2517
|
-
* @param config optional configuration
|
|
2518
|
-
*/
|
|
2519
|
-
constructor(config) {
|
|
2520
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicNeg(a), FlowGraphNegBlock.ClassName, config);
|
|
2521
|
-
}
|
|
2522
|
-
_polymorphicNeg(a) {
|
|
2523
|
-
return _componentWiseUnaryOperation(a, (a) => -a);
|
|
2524
|
-
}
|
|
2525
|
-
}
|
|
2526
|
-
/**
|
|
2527
|
-
* the class name of the block.
|
|
2528
|
-
*/
|
|
2529
|
-
FlowGraphNegBlock.ClassName = "FGNegBlock";
|
|
2530
|
-
RegisterClass(FlowGraphNegBlock.ClassName, FlowGraphNegBlock);
|
|
2531
|
-
function _componentWiseBinaryOperation(a, b, op) {
|
|
2532
|
-
const aClassName = _getClassNameOf(a);
|
|
2533
|
-
switch (aClassName) {
|
|
2534
|
-
case "FlowGraphInteger":
|
|
2535
|
-
return new FlowGraphInteger(op(a.value, b.value));
|
|
2536
|
-
case "Vector2":
|
|
2537
|
-
return new Vector2(op(a.x, b.x), op(a.y, b.y));
|
|
2538
|
-
case "Vector3":
|
|
2539
|
-
return new Vector3(op(a.x, b.x), op(a.y, b.y), op(a.z, b.z));
|
|
2540
|
-
case "Vector4":
|
|
2541
|
-
return new Vector4(op(a.x, b.x), op(a.y, b.y), op(a.z, b.z), op(a.w, b.w));
|
|
2542
|
-
case "Matrix":
|
|
2543
|
-
return Matrix.FromValues(op(a.m[0], b.m[0]), op(a.m[4], b.m[4]), op(a.m[8], b.m[8]), op(a.m[12], b.m[12]), op(a.m[1], b.m[1]), op(a.m[5], b.m[5]), op(a.m[9], b.m[9]), op(a.m[13], b.m[13]), op(a.m[2], b.m[2]), op(a.m[6], b.m[6]), op(a.m[10], b.m[10]), op(a.m[14], b.m[14]), op(a.m[3], b.m[3]), op(a.m[7], b.m[7]), op(a.m[11], b.m[11]), op(a.m[15], b.m[15]));
|
|
2544
|
-
default:
|
|
2545
|
-
return op(a, b);
|
|
2546
|
-
}
|
|
2547
|
-
}
|
|
2548
|
-
/**
|
|
2549
|
-
* @experimental
|
|
2550
|
-
* Remainder block.
|
|
2551
|
-
*/
|
|
2552
|
-
class FlowGraphRemainderBlock extends FlowGraphBinaryOperationBlock {
|
|
2553
|
-
constructor(config) {
|
|
2554
|
-
super(RichTypeAny, RichTypeAny, RichTypeAny, (a, b) => this._polymorphicRemainder(a, b), FlowGraphRemainderBlock.ClassName, config);
|
|
2555
|
-
}
|
|
2556
|
-
_polymorphicRemainder(a, b) {
|
|
2557
|
-
return _componentWiseBinaryOperation(a, b, (a, b) => a % b);
|
|
2558
|
-
}
|
|
2559
|
-
}
|
|
2560
|
-
/**
|
|
2561
|
-
* the class name of the block.
|
|
2562
|
-
*/
|
|
2563
|
-
FlowGraphRemainderBlock.ClassName = "FGRemainderBlock";
|
|
2564
|
-
RegisterClass(FlowGraphRemainderBlock.ClassName, FlowGraphRemainderBlock);
|
|
2565
|
-
/**
|
|
2566
|
-
* @experimental
|
|
2567
|
-
* Min block.
|
|
2568
|
-
*/
|
|
2569
|
-
class FlowGraphMinBlock extends FlowGraphBinaryOperationBlock {
|
|
2570
|
-
constructor(config) {
|
|
2571
|
-
super(RichTypeAny, RichTypeAny, RichTypeAny, (a, b) => this._polymorphicMin(a, b), FlowGraphMinBlock.ClassName, config);
|
|
2572
|
-
}
|
|
2573
|
-
_polymorphicMin(a, b) {
|
|
2574
|
-
return _componentWiseBinaryOperation(a, b, Math.min);
|
|
2575
|
-
}
|
|
2576
|
-
}
|
|
2577
|
-
/**
|
|
2578
|
-
* the class name of the block.
|
|
2579
|
-
*/
|
|
2580
|
-
FlowGraphMinBlock.ClassName = "FGMinBlock";
|
|
2581
|
-
RegisterClass(FlowGraphMinBlock.ClassName, FlowGraphMinBlock);
|
|
2582
|
-
/**
|
|
2583
|
-
* @experimental
|
|
2584
|
-
* Max block
|
|
2585
|
-
*/
|
|
2586
|
-
class FlowGraphMaxBlock extends FlowGraphBinaryOperationBlock {
|
|
2587
|
-
constructor(config) {
|
|
2588
|
-
super(RichTypeAny, RichTypeAny, RichTypeAny, (a, b) => this._polymorphicMax(a, b), FlowGraphMaxBlock.ClassName, config);
|
|
2589
|
-
}
|
|
2590
|
-
_polymorphicMax(a, b) {
|
|
2591
|
-
return _componentWiseBinaryOperation(a, b, Math.max);
|
|
2592
|
-
}
|
|
2593
|
-
}
|
|
2594
|
-
/**
|
|
2595
|
-
* the class name of the block.
|
|
2596
|
-
*/
|
|
2597
|
-
FlowGraphMaxBlock.ClassName = "FGMaxBlock";
|
|
2598
|
-
RegisterClass(FlowGraphMaxBlock.ClassName, FlowGraphMaxBlock);
|
|
2599
|
-
function _clamp(a, b, c) {
|
|
2600
|
-
return Math.min(Math.max(a, Math.min(b, c)), Math.max(b, c));
|
|
2601
|
-
}
|
|
2602
|
-
function _componentWiseTernaryOperation(a, b, c, op) {
|
|
2603
|
-
const aClassName = _getClassNameOf(a);
|
|
2604
|
-
switch (aClassName) {
|
|
2605
|
-
case "FlowGraphInteger":
|
|
2606
|
-
return new FlowGraphInteger(op(a.value, b.value, c.value));
|
|
2607
|
-
case "Vector2":
|
|
2608
|
-
return new Vector2(op(a.x, b.x, c.x), op(a.y, b.y, c.y));
|
|
2609
|
-
case "Vector3":
|
|
2610
|
-
return new Vector3(op(a.x, b.x, c.x), op(a.y, b.y, c.y), op(a.z, b.z, c.z));
|
|
2611
|
-
case "Vector4":
|
|
2612
|
-
return new Vector4(op(a.x, b.x, c.x), op(a.y, b.y, c.y), op(a.z, b.z, c.z), op(a.w, b.w, c.w));
|
|
2613
|
-
case "Matrix":
|
|
2614
|
-
return Matrix.FromValues(op(a.m[0], b.m[0], c.m[0]), op(a.m[4], b.m[4], c.m[4]), op(a.m[8], b.m[8], c.m[8]), op(a.m[12], b.m[12], c.m[12]), op(a.m[1], b.m[1], c.m[1]), op(a.m[5], b.m[5], c.m[5]), op(a.m[9], b.m[9], c.m[9]), op(a.m[13], b.m[13], c.m[13]), op(a.m[2], b.m[2], c.m[2]), op(a.m[6], b.m[6], c.m[6]), op(a.m[10], b.m[10], c.m[10]), op(a.m[14], b.m[14], c.m[14]), op(a.m[3], b.m[3], c.m[3]), op(a.m[7], b.m[7], c.m[7]), op(a.m[11], b.m[11], c.m[11]), op(a.m[15], b.m[15], c.m[15]));
|
|
2615
|
-
default:
|
|
2616
|
-
return op(a, b, c);
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
/**
|
|
2620
|
-
* @experimental
|
|
2621
|
-
* Clamp block.
|
|
2622
|
-
*/
|
|
2623
|
-
class FlowGraphClampBlock extends FlowGraphTernaryOperationBlock {
|
|
2624
|
-
constructor(config) {
|
|
2625
|
-
super(RichTypeAny, RichTypeAny, RichTypeAny, RichTypeAny, (a, b, c) => this._polymorphicClamp(a, b, c), FlowGraphClampBlock.ClassName, config);
|
|
2626
|
-
}
|
|
2627
|
-
_polymorphicClamp(a, b, c) {
|
|
2628
|
-
return _componentWiseTernaryOperation(a, b, c, _clamp);
|
|
2629
|
-
}
|
|
2630
|
-
}
|
|
2631
|
-
/**
|
|
2632
|
-
* the class name of the block.
|
|
2633
|
-
*/
|
|
2634
|
-
FlowGraphClampBlock.ClassName = "FGClampBlock";
|
|
2635
|
-
RegisterClass(FlowGraphClampBlock.ClassName, FlowGraphClampBlock);
|
|
2636
|
-
function _saturate(a) {
|
|
2637
|
-
return Math.min(Math.max(a, 0), 1);
|
|
2638
|
-
}
|
|
2639
|
-
/**
|
|
2640
|
-
* @experimental
|
|
2641
|
-
* Saturate block.
|
|
2642
|
-
*/
|
|
2643
|
-
class FlowGraphSaturateBlock extends FlowGraphUnaryOperationBlock {
|
|
2644
|
-
constructor(config) {
|
|
2645
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicSaturate(a), FlowGraphSaturateBlock.ClassName, config);
|
|
2646
|
-
}
|
|
2647
|
-
_polymorphicSaturate(a) {
|
|
2648
|
-
return _componentWiseUnaryOperation(a, _saturate);
|
|
2649
|
-
}
|
|
2650
|
-
}
|
|
2651
|
-
/**
|
|
2652
|
-
* the class name of the block.
|
|
2653
|
-
*/
|
|
2654
|
-
FlowGraphSaturateBlock.ClassName = "FGSaturateBlock";
|
|
2655
|
-
RegisterClass(FlowGraphSaturateBlock.ClassName, FlowGraphSaturateBlock);
|
|
2656
|
-
/**
|
|
2657
|
-
* @experimental
|
|
2658
|
-
* Interpolate block.
|
|
2659
|
-
*/
|
|
2660
|
-
class FlowGraphInterpolateBlock extends FlowGraphTernaryOperationBlock {
|
|
2661
|
-
constructor(config) {
|
|
2662
|
-
super(RichTypeAny, RichTypeAny, RichTypeAny, RichTypeAny, (a, b, c) => this._polymorphicInterpolate(a, b, c), FlowGraphInterpolateBlock.ClassName, config);
|
|
2663
|
-
}
|
|
2664
|
-
_interpolate(a, b, c) {
|
|
2665
|
-
return (1 - c) * a + c * b;
|
|
2666
|
-
}
|
|
2667
|
-
_polymorphicInterpolate(a, b, c) {
|
|
2668
|
-
return _componentWiseTernaryOperation(a, b, c, this._interpolate);
|
|
2669
|
-
}
|
|
2670
|
-
}
|
|
2671
|
-
/**
|
|
2672
|
-
* the class name of the block.
|
|
2673
|
-
*/
|
|
2674
|
-
FlowGraphInterpolateBlock.ClassName = "FGInterpolateBlock";
|
|
2675
|
-
RegisterClass(FlowGraphInterpolateBlock.ClassName, FlowGraphInterpolateBlock);
|
|
2676
|
-
/**
|
|
2677
|
-
* @experimental
|
|
2678
|
-
* Equals block.
|
|
2679
|
-
*/
|
|
2680
|
-
class FlowGraphEqBlock extends FlowGraphBinaryOperationBlock {
|
|
2681
|
-
constructor(config) {
|
|
2682
|
-
super(RichTypeAny, RichTypeAny, RichTypeBoolean, (a, b) => this._polymorphicEq(a, b), FlowGraphEqBlock.ClassName, config);
|
|
2683
|
-
}
|
|
2684
|
-
_polymorphicEq(a, b) {
|
|
2685
|
-
const aClassName = _getClassNameOf(a);
|
|
2686
|
-
const bClassName = _getClassNameOf(b);
|
|
2687
|
-
if (_areSameVectorClass(aClassName, bClassName) || _areSameMatrixClass(aClassName, bClassName) || _areSameIntegerClass(aClassName, bClassName)) {
|
|
2688
|
-
return a.equals(b);
|
|
2689
|
-
}
|
|
2690
|
-
else {
|
|
2691
|
-
return a === b;
|
|
2692
|
-
}
|
|
2693
|
-
}
|
|
2694
|
-
}
|
|
2695
|
-
/**
|
|
2696
|
-
* the class name of the block.
|
|
2697
|
-
*/
|
|
2698
|
-
FlowGraphEqBlock.ClassName = "FGEqBlock";
|
|
2699
|
-
RegisterClass(FlowGraphEqBlock.ClassName, FlowGraphEqBlock);
|
|
2700
|
-
function _comparisonOperators(a, b, op) {
|
|
2701
|
-
const aClassName = _getClassNameOf(a);
|
|
2702
|
-
const bClassName = _getClassNameOf(b);
|
|
2703
|
-
if (aClassName === bClassName) {
|
|
2704
|
-
// float
|
|
2705
|
-
if (aClassName === "") {
|
|
2706
|
-
return op(a, b);
|
|
2707
|
-
}
|
|
2708
|
-
else if (aClassName === "FlowGraphInteger") {
|
|
2709
|
-
return op(a.value, b.value);
|
|
2710
|
-
}
|
|
2711
|
-
else {
|
|
2712
|
-
throw new Error(`Cannot compare ${a} and ${b}`);
|
|
2713
|
-
}
|
|
2714
|
-
}
|
|
2715
|
-
throw new Error(`${a} and ${b} are of different types.`);
|
|
2716
|
-
}
|
|
2717
|
-
/**
|
|
2718
|
-
* @experimental
|
|
2719
|
-
* Less than block.
|
|
2720
|
-
*/
|
|
2721
|
-
class FlowGraphLessThanBlock extends FlowGraphBinaryOperationBlock {
|
|
2722
|
-
constructor(config) {
|
|
2723
|
-
super(RichTypeAny, RichTypeAny, RichTypeBoolean, (a, b) => this._polymorphicLessThan(a, b), FlowGraphLessThanBlock.ClassName, config);
|
|
2724
|
-
}
|
|
2725
|
-
_polymorphicLessThan(a, b) {
|
|
2726
|
-
return _comparisonOperators(a, b, (a, b) => a < b);
|
|
2727
|
-
}
|
|
2728
|
-
}
|
|
2729
|
-
/**
|
|
2730
|
-
* the class name of the block.
|
|
2731
|
-
*/
|
|
2732
|
-
FlowGraphLessThanBlock.ClassName = "FGLessThanBlock";
|
|
2733
|
-
RegisterClass(FlowGraphLessThanBlock.ClassName, FlowGraphLessThanBlock);
|
|
2734
|
-
/**
|
|
2735
|
-
* @experimental
|
|
2736
|
-
* Less than or equal block.
|
|
2737
|
-
*/
|
|
2738
|
-
class FlowGraphLessThanOrEqualBlock extends FlowGraphBinaryOperationBlock {
|
|
2739
|
-
constructor(config) {
|
|
2740
|
-
super(RichTypeAny, RichTypeAny, RichTypeBoolean, (a, b) => this._polymorphicLessThanOrEqual(a, b), FlowGraphLessThanOrEqualBlock.ClassName, config);
|
|
2741
|
-
}
|
|
2742
|
-
_polymorphicLessThanOrEqual(a, b) {
|
|
2743
|
-
return _comparisonOperators(a, b, (a, b) => a <= b);
|
|
2744
|
-
}
|
|
2745
|
-
}
|
|
2746
|
-
/**
|
|
2747
|
-
* the class name of the block.
|
|
2748
|
-
*/
|
|
2749
|
-
FlowGraphLessThanOrEqualBlock.ClassName = "FGLessThanOrEqualBlock";
|
|
2750
|
-
/**
|
|
2751
|
-
* @experimental
|
|
2752
|
-
* Greater than block.
|
|
2753
|
-
*/
|
|
2754
|
-
class FlowGraphGreaterThanBlock extends FlowGraphBinaryOperationBlock {
|
|
2755
|
-
constructor(config) {
|
|
2756
|
-
super(RichTypeAny, RichTypeAny, RichTypeBoolean, (a, b) => this._polymorphicGreaterThan(a, b), FlowGraphGreaterThanBlock.ClassName, config);
|
|
2757
|
-
}
|
|
2758
|
-
_polymorphicGreaterThan(a, b) {
|
|
2759
|
-
return _comparisonOperators(a, b, (a, b) => a > b);
|
|
2760
|
-
}
|
|
2761
|
-
}
|
|
2762
|
-
/**
|
|
2763
|
-
* the class name of the block.
|
|
2764
|
-
*/
|
|
2765
|
-
FlowGraphGreaterThanBlock.ClassName = "FGGreaterThanBlock";
|
|
2766
|
-
RegisterClass(FlowGraphGreaterThanBlock.ClassName, FlowGraphGreaterThanBlock);
|
|
2767
|
-
/**
|
|
2768
|
-
* @experimental
|
|
2769
|
-
* Greater than or equal block.
|
|
2770
|
-
*/
|
|
2771
|
-
class FlowGraphGreaterThanOrEqualBlock extends FlowGraphBinaryOperationBlock {
|
|
2772
|
-
constructor(config) {
|
|
2773
|
-
super(RichTypeAny, RichTypeAny, RichTypeBoolean, (a, b) => this._polymorphicGreaterThanOrEqual(a, b), FlowGraphGreaterThanOrEqualBlock.ClassName, config);
|
|
2774
|
-
}
|
|
2775
|
-
_polymorphicGreaterThanOrEqual(a, b) {
|
|
2776
|
-
return _comparisonOperators(a, b, (a, b) => a >= b);
|
|
2777
|
-
}
|
|
2778
|
-
}
|
|
2779
|
-
/**
|
|
2780
|
-
* the class name of the block.
|
|
2781
|
-
*/
|
|
2782
|
-
FlowGraphGreaterThanOrEqualBlock.ClassName = "FGGreaterThanOrEqualBlock";
|
|
2783
|
-
RegisterClass(FlowGraphGreaterThanOrEqualBlock.ClassName, FlowGraphGreaterThanOrEqualBlock);
|
|
2784
|
-
/**
|
|
2785
|
-
* @experimental
|
|
2786
|
-
* Is NaN block.
|
|
2787
|
-
*/
|
|
2788
|
-
class FlowGraphIsNanBlock extends FlowGraphUnaryOperationBlock {
|
|
2789
|
-
constructor(config) {
|
|
2790
|
-
super(RichTypeAny, RichTypeBoolean, (a) => this._polymorphicIsNan(a), FlowGraphIsNanBlock.ClassName, config);
|
|
2791
|
-
}
|
|
2792
|
-
_polymorphicIsNan(a) {
|
|
2793
|
-
const aClassName = _getClassNameOf(a);
|
|
2794
|
-
if (aClassName === "") {
|
|
2795
|
-
return isNaN(a);
|
|
2796
|
-
}
|
|
2797
|
-
else if (aClassName === "FlowGraphInteger") {
|
|
2798
|
-
return isNaN(a.value);
|
|
2799
|
-
}
|
|
2800
|
-
else {
|
|
2801
|
-
throw new Error(`Cannot get NaN of ${a}`);
|
|
2802
|
-
}
|
|
2803
|
-
}
|
|
2804
|
-
}
|
|
2805
|
-
/**
|
|
2806
|
-
* the class name of the block.
|
|
2807
|
-
*/
|
|
2808
|
-
FlowGraphIsNanBlock.ClassName = "FGIsNanBlock";
|
|
2809
|
-
RegisterClass(FlowGraphIsNanBlock.ClassName, FlowGraphIsNanBlock);
|
|
2810
|
-
/**
|
|
2811
|
-
* @experimental
|
|
2812
|
-
* Is Inf block.
|
|
2813
|
-
*/
|
|
2814
|
-
class FlowGraphIsInfBlock extends FlowGraphUnaryOperationBlock {
|
|
2815
|
-
constructor(config) {
|
|
2816
|
-
super(RichTypeAny, RichTypeBoolean, (a) => this._polymorphicIsInf(a), FlowGraphIsInfBlock.ClassName, config);
|
|
2817
|
-
}
|
|
2818
|
-
_polymorphicIsInf(a) {
|
|
2819
|
-
const aClassName = _getClassNameOf(a);
|
|
2820
|
-
if (aClassName === "") {
|
|
2821
|
-
return !isFinite(a);
|
|
2822
|
-
}
|
|
2823
|
-
else if (aClassName === "FlowGraphInteger") {
|
|
2824
|
-
return !isFinite(a.value);
|
|
2825
|
-
}
|
|
2826
|
-
else {
|
|
2827
|
-
throw new Error(`Cannot get isInf of ${a}`);
|
|
2828
|
-
}
|
|
2829
|
-
}
|
|
2830
|
-
}
|
|
2831
|
-
/**
|
|
2832
|
-
* the class name of the block.
|
|
2833
|
-
*/
|
|
2834
|
-
FlowGraphIsInfBlock.ClassName = "FGIsInfBlock";
|
|
2835
|
-
/**
|
|
2836
|
-
* @experimental
|
|
2837
|
-
* Convert degrees to radians block.
|
|
2838
|
-
*/
|
|
2839
|
-
class FlowGraphDegToRadBlock extends FlowGraphUnaryOperationBlock {
|
|
2840
|
-
constructor(config) {
|
|
2841
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicDegToRad(a), FlowGraphDegToRadBlock.ClassName, config);
|
|
2842
|
-
}
|
|
2843
|
-
_degToRad(a) {
|
|
2844
|
-
return (a * Math.PI) / 180;
|
|
2845
|
-
}
|
|
2846
|
-
_polymorphicDegToRad(a) {
|
|
2847
|
-
return _componentWiseUnaryOperation(a, this._degToRad);
|
|
2848
|
-
}
|
|
2849
|
-
}
|
|
2850
|
-
/**
|
|
2851
|
-
* the class name of the block.
|
|
2852
|
-
*/
|
|
2853
|
-
FlowGraphDegToRadBlock.ClassName = "FGDegToRadBlock";
|
|
2854
|
-
RegisterClass(FlowGraphDegToRadBlock.ClassName, FlowGraphDegToRadBlock);
|
|
2855
|
-
/**
|
|
2856
|
-
* @experimental
|
|
2857
|
-
* Convert radians to degrees block.
|
|
2858
|
-
*/
|
|
2859
|
-
class FlowGraphRadToDegBlock extends FlowGraphUnaryOperationBlock {
|
|
2860
|
-
constructor(config) {
|
|
2861
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicRadToDeg(a), FlowGraphRadToDegBlock.ClassName, config);
|
|
2862
|
-
}
|
|
2863
|
-
_radToDeg(a) {
|
|
2864
|
-
return (a * 180) / Math.PI;
|
|
2865
|
-
}
|
|
2866
|
-
_polymorphicRadToDeg(a) {
|
|
2867
|
-
return _componentWiseUnaryOperation(a, this._radToDeg);
|
|
2868
|
-
}
|
|
2869
|
-
}
|
|
2870
|
-
/**
|
|
2871
|
-
* the class name of the block.
|
|
2872
|
-
*/
|
|
2873
|
-
FlowGraphRadToDegBlock.ClassName = "FGRadToDegBlock";
|
|
2874
|
-
RegisterClass(FlowGraphRadToDegBlock.ClassName, FlowGraphRadToDegBlock);
|
|
2875
|
-
/**
|
|
2876
|
-
* @experimental
|
|
2877
|
-
* Sin block.
|
|
2878
|
-
*/
|
|
2879
|
-
class FlowGraphSinBlock extends FlowGraphUnaryOperationBlock {
|
|
2880
|
-
constructor(config) {
|
|
2881
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicSin(a), FlowGraphSinBlock.ClassName, config);
|
|
2882
|
-
}
|
|
2883
|
-
_polymorphicSin(a) {
|
|
2884
|
-
return _componentWiseUnaryOperation(a, Math.sin);
|
|
2885
|
-
}
|
|
2886
|
-
}
|
|
2887
|
-
/**
|
|
2888
|
-
* the class name of the block.
|
|
2889
|
-
*/
|
|
2890
|
-
FlowGraphSinBlock.ClassName = "FGSinBlock";
|
|
2891
|
-
RegisterClass(FlowGraphSinBlock.ClassName, FlowGraphSinBlock);
|
|
2892
|
-
/**
|
|
2893
|
-
* @experimental
|
|
2894
|
-
* Cos block.
|
|
2895
|
-
*/
|
|
2896
|
-
class FlowGraphCosBlock extends FlowGraphUnaryOperationBlock {
|
|
2897
|
-
constructor(config) {
|
|
2898
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicCos(a), FlowGraphCosBlock.ClassName, config);
|
|
2899
|
-
}
|
|
2900
|
-
_polymorphicCos(a) {
|
|
2901
|
-
return _componentWiseUnaryOperation(a, Math.cos);
|
|
2902
|
-
}
|
|
2903
|
-
}
|
|
2904
|
-
/**
|
|
2905
|
-
* the class name of the block.
|
|
2906
|
-
*/
|
|
2907
|
-
FlowGraphCosBlock.ClassName = "FGCosBlock";
|
|
2908
|
-
RegisterClass(FlowGraphCosBlock.ClassName, FlowGraphCosBlock);
|
|
2909
|
-
/**
|
|
2910
|
-
* @experimental
|
|
2911
|
-
* Tan block.
|
|
2912
|
-
*/
|
|
2913
|
-
class FlowGraphTanBlock extends FlowGraphUnaryOperationBlock {
|
|
2914
|
-
constructor(config) {
|
|
2915
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicTan(a), FlowGraphTanBlock.ClassName, config);
|
|
2916
|
-
}
|
|
2917
|
-
_polymorphicTan(a) {
|
|
2918
|
-
return _componentWiseUnaryOperation(a, Math.tan);
|
|
2919
|
-
}
|
|
2920
|
-
}
|
|
2921
|
-
/**
|
|
2922
|
-
* the class name of the block.
|
|
2923
|
-
*/
|
|
2924
|
-
FlowGraphTanBlock.ClassName = "FGTanBlock";
|
|
2925
|
-
RegisterClass(FlowGraphTanBlock.ClassName, FlowGraphTanBlock);
|
|
2926
|
-
/**
|
|
2927
|
-
* @experimental
|
|
2928
|
-
* Arcsin block.
|
|
2929
|
-
*/
|
|
2930
|
-
class FlowGraphAsinBlock extends FlowGraphUnaryOperationBlock {
|
|
2931
|
-
constructor(config) {
|
|
2932
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicAsin(a), FlowGraphAsinBlock.ClassName, config);
|
|
2933
|
-
}
|
|
2934
|
-
_polymorphicAsin(a) {
|
|
2935
|
-
return _componentWiseUnaryOperation(a, Math.asin);
|
|
2936
|
-
}
|
|
2937
|
-
}
|
|
2938
|
-
/**
|
|
2939
|
-
* the class name of the block.
|
|
2940
|
-
*/
|
|
2941
|
-
FlowGraphAsinBlock.ClassName = "FGAsinBlock";
|
|
2942
|
-
RegisterClass(FlowGraphAsinBlock.ClassName, FlowGraphAsinBlock);
|
|
2943
|
-
/**
|
|
2944
|
-
* @experimental
|
|
2945
|
-
* Arccos block.
|
|
2946
|
-
*/
|
|
2947
|
-
class FlowGraphAcosBlock extends FlowGraphUnaryOperationBlock {
|
|
2948
|
-
constructor(config) {
|
|
2949
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicAcos(a), FlowGraphAcosBlock.ClassName, config);
|
|
2950
|
-
}
|
|
2951
|
-
_polymorphicAcos(a) {
|
|
2952
|
-
return _componentWiseUnaryOperation(a, Math.acos);
|
|
2953
|
-
}
|
|
2954
|
-
}
|
|
2955
|
-
/**
|
|
2956
|
-
* the class name of the block.
|
|
2957
|
-
*/
|
|
2958
|
-
FlowGraphAcosBlock.ClassName = "FGAcosBlock";
|
|
2959
|
-
RegisterClass(FlowGraphAcosBlock.ClassName, FlowGraphAcosBlock);
|
|
2960
|
-
/**
|
|
2961
|
-
* @experimental
|
|
2962
|
-
* Arctan block.
|
|
2963
|
-
*/
|
|
2964
|
-
class FlowGraphAtanBlock extends FlowGraphUnaryOperationBlock {
|
|
2965
|
-
constructor(config) {
|
|
2966
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicAtan(a), FlowGraphAtanBlock.ClassName, config);
|
|
2967
|
-
}
|
|
2968
|
-
_polymorphicAtan(a) {
|
|
2969
|
-
return _componentWiseUnaryOperation(a, Math.atan);
|
|
2970
|
-
}
|
|
2971
|
-
}
|
|
2972
|
-
/**
|
|
2973
|
-
* the class name of the block.
|
|
2974
|
-
*/
|
|
2975
|
-
FlowGraphAtanBlock.ClassName = "FGAtanBlock";
|
|
2976
|
-
RegisterClass(FlowGraphAtanBlock.ClassName, FlowGraphAtanBlock);
|
|
2977
|
-
/**
|
|
2978
|
-
* @experimental
|
|
2979
|
-
* Arctan2 block.
|
|
2980
|
-
*/
|
|
2981
|
-
class FlowGraphAtan2Block extends FlowGraphBinaryOperationBlock {
|
|
2982
|
-
constructor(config) {
|
|
2983
|
-
super(RichTypeAny, RichTypeAny, RichTypeAny, (a, b) => this._polymorphicAtan2(a, b), FlowGraphAtan2Block.ClassName, config);
|
|
2984
|
-
}
|
|
2985
|
-
_polymorphicAtan2(a, b) {
|
|
2986
|
-
return _componentWiseBinaryOperation(a, b, Math.atan2);
|
|
2987
|
-
}
|
|
2988
|
-
}
|
|
2989
|
-
/**
|
|
2990
|
-
* the class name of the block.
|
|
2991
|
-
*/
|
|
2992
|
-
FlowGraphAtan2Block.ClassName = "FGAtan2Block";
|
|
2993
|
-
RegisterClass(FlowGraphAtan2Block.ClassName, FlowGraphAtan2Block);
|
|
2994
|
-
/**
|
|
2995
|
-
* @experimental
|
|
2996
|
-
* Hyperbolic sin block.
|
|
2997
|
-
*/
|
|
2998
|
-
class FlowGraphSinhBlock extends FlowGraphUnaryOperationBlock {
|
|
2999
|
-
constructor(config) {
|
|
3000
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicSinh(a), FlowGraphSinhBlock.ClassName, config);
|
|
3001
|
-
}
|
|
3002
|
-
_polymorphicSinh(a) {
|
|
3003
|
-
return _componentWiseUnaryOperation(a, Math.sinh);
|
|
3004
|
-
}
|
|
3005
|
-
}
|
|
3006
|
-
/**
|
|
3007
|
-
* the class name of the block.
|
|
3008
|
-
*/
|
|
3009
|
-
FlowGraphSinhBlock.ClassName = "FGSinhBlock";
|
|
3010
|
-
RegisterClass(FlowGraphSinhBlock.ClassName, FlowGraphSinhBlock);
|
|
3011
|
-
/**
|
|
3012
|
-
* @experimental
|
|
3013
|
-
* Hyperbolic cos block.
|
|
3014
|
-
*/
|
|
3015
|
-
class FlowGraphCoshBlock extends FlowGraphUnaryOperationBlock {
|
|
3016
|
-
constructor(config) {
|
|
3017
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicCosh(a), FlowGraphCoshBlock.ClassName, config);
|
|
3018
|
-
}
|
|
3019
|
-
_polymorphicCosh(a) {
|
|
3020
|
-
return _componentWiseUnaryOperation(a, Math.cosh);
|
|
3021
|
-
}
|
|
3022
|
-
}
|
|
3023
|
-
/**
|
|
3024
|
-
* the class name of the block.
|
|
3025
|
-
*/
|
|
3026
|
-
FlowGraphCoshBlock.ClassName = "FGCoshBlock";
|
|
3027
|
-
RegisterClass(FlowGraphCoshBlock.ClassName, FlowGraphCoshBlock);
|
|
3028
|
-
/**
|
|
3029
|
-
* @experimental
|
|
3030
|
-
* Hyperbolic tan block.
|
|
3031
|
-
*/
|
|
3032
|
-
class FlowGraphTanhBlock extends FlowGraphUnaryOperationBlock {
|
|
3033
|
-
constructor(config) {
|
|
3034
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicTanh(a), FlowGraphTanhBlock.ClassName, config);
|
|
3035
|
-
}
|
|
3036
|
-
_polymorphicTanh(a) {
|
|
3037
|
-
return _componentWiseUnaryOperation(a, Math.tanh);
|
|
3038
|
-
}
|
|
3039
|
-
}
|
|
3040
|
-
/**
|
|
3041
|
-
* the class name of the block.
|
|
3042
|
-
*/
|
|
3043
|
-
FlowGraphTanhBlock.ClassName = "FGTanhBlock";
|
|
3044
|
-
RegisterClass(FlowGraphTanhBlock.ClassName, FlowGraphTanhBlock);
|
|
3045
|
-
/**
|
|
3046
|
-
* @experimental
|
|
3047
|
-
* Hyperbolic arcsin block.
|
|
3048
|
-
*/
|
|
3049
|
-
class FlowGraphAsinhBlock extends FlowGraphUnaryOperationBlock {
|
|
3050
|
-
constructor(config) {
|
|
3051
|
-
super(RichTypeAny, RichTypeNumber, (a) => this._polymorphicAsinh(a), FlowGraphAsinhBlock.ClassName, config);
|
|
3052
|
-
}
|
|
3053
|
-
_polymorphicAsinh(a) {
|
|
3054
|
-
return _componentWiseUnaryOperation(a, Math.asinh);
|
|
3055
|
-
}
|
|
3056
|
-
}
|
|
3057
|
-
/**
|
|
3058
|
-
* the class name of the block.
|
|
3059
|
-
*/
|
|
3060
|
-
FlowGraphAsinhBlock.ClassName = "FGAsinhBlock";
|
|
3061
|
-
RegisterClass(FlowGraphAsinhBlock.ClassName, FlowGraphAsinhBlock);
|
|
3062
|
-
/**
|
|
3063
|
-
* @experimental
|
|
3064
|
-
* Hyperbolic arccos block.
|
|
3065
|
-
*/
|
|
3066
|
-
class FlowGraphAcoshBlock extends FlowGraphUnaryOperationBlock {
|
|
3067
|
-
constructor(config) {
|
|
3068
|
-
super(RichTypeAny, RichTypeNumber, (a) => this._polymorphicAcosh(a), FlowGraphAcoshBlock.ClassName, config);
|
|
3069
|
-
}
|
|
3070
|
-
_polymorphicAcosh(a) {
|
|
3071
|
-
return _componentWiseUnaryOperation(a, Math.acosh);
|
|
3072
|
-
}
|
|
3073
|
-
}
|
|
3074
|
-
/**
|
|
3075
|
-
* the class name of the block.
|
|
3076
|
-
*/
|
|
3077
|
-
FlowGraphAcoshBlock.ClassName = "FGAcoshBlock";
|
|
3078
|
-
RegisterClass(FlowGraphAcoshBlock.ClassName, FlowGraphAcoshBlock);
|
|
3079
|
-
/**
|
|
3080
|
-
* @experimental
|
|
3081
|
-
* Hyperbolic arctan block.
|
|
3082
|
-
*/
|
|
3083
|
-
class FlowGraphAtanhBlock extends FlowGraphUnaryOperationBlock {
|
|
3084
|
-
constructor(config) {
|
|
3085
|
-
super(RichTypeAny, RichTypeNumber, (a) => this._polymorphicAtanh(a), FlowGraphAtanhBlock.ClassName, config);
|
|
3086
|
-
}
|
|
3087
|
-
_polymorphicAtanh(a) {
|
|
3088
|
-
return _componentWiseUnaryOperation(a, Math.atanh);
|
|
3089
|
-
}
|
|
3090
|
-
}
|
|
3091
|
-
/**
|
|
3092
|
-
* the class name of the block.
|
|
3093
|
-
*/
|
|
3094
|
-
FlowGraphAtanhBlock.ClassName = "FGAtanhBlock";
|
|
3095
|
-
RegisterClass(FlowGraphAtanhBlock.ClassName, FlowGraphAtanhBlock);
|
|
3096
|
-
/**
|
|
3097
|
-
* @experimental
|
|
3098
|
-
* Exponential block.
|
|
3099
|
-
*/
|
|
3100
|
-
class FlowGraphExpBlock extends FlowGraphUnaryOperationBlock {
|
|
3101
|
-
constructor(config) {
|
|
3102
|
-
super(RichTypeAny, RichTypeNumber, (a) => this._polymorphicExp(a), FlowGraphExpBlock.ClassName, config);
|
|
3103
|
-
}
|
|
3104
|
-
_polymorphicExp(a) {
|
|
3105
|
-
return _componentWiseUnaryOperation(a, Math.exp);
|
|
3106
|
-
}
|
|
3107
|
-
}
|
|
3108
|
-
/**
|
|
3109
|
-
* the class name of the block.
|
|
3110
|
-
*/
|
|
3111
|
-
FlowGraphExpBlock.ClassName = "FGExpBlock";
|
|
3112
|
-
RegisterClass(FlowGraphExpBlock.ClassName, FlowGraphExpBlock);
|
|
3113
|
-
/**
|
|
3114
|
-
* @experimental
|
|
3115
|
-
* Logarithm block.
|
|
3116
|
-
*/
|
|
3117
|
-
class FlowGraphLogBlock extends FlowGraphUnaryOperationBlock {
|
|
3118
|
-
constructor(config) {
|
|
3119
|
-
super(RichTypeAny, RichTypeNumber, (a) => this._polymorphicLog(a), FlowGraphLogBlock.ClassName, config);
|
|
3120
|
-
}
|
|
3121
|
-
_polymorphicLog(a) {
|
|
3122
|
-
return _componentWiseUnaryOperation(a, Math.log);
|
|
3123
|
-
}
|
|
3124
|
-
}
|
|
3125
|
-
/**
|
|
3126
|
-
* the class name of the block.
|
|
3127
|
-
*/
|
|
3128
|
-
FlowGraphLogBlock.ClassName = "FGLogBlock";
|
|
3129
|
-
RegisterClass(FlowGraphLogBlock.ClassName, FlowGraphLogBlock);
|
|
3130
|
-
/**
|
|
3131
|
-
* @experimental
|
|
3132
|
-
* Base 2 logarithm block.
|
|
3133
|
-
*/
|
|
3134
|
-
class FlowGraphLog2Block extends FlowGraphUnaryOperationBlock {
|
|
3135
|
-
constructor(config) {
|
|
3136
|
-
super(RichTypeAny, RichTypeNumber, (a) => this._polymorphicLog2(a), FlowGraphLog2Block.ClassName, config);
|
|
3137
|
-
}
|
|
3138
|
-
_polymorphicLog2(a) {
|
|
3139
|
-
return _componentWiseUnaryOperation(a, Math.log2);
|
|
3140
|
-
}
|
|
3141
|
-
}
|
|
3142
|
-
/**
|
|
3143
|
-
* the class name of the block.
|
|
3144
|
-
*/
|
|
3145
|
-
FlowGraphLog2Block.ClassName = "FGLog2Block";
|
|
3146
|
-
RegisterClass(FlowGraphLog2Block.ClassName, FlowGraphLog2Block);
|
|
3147
|
-
/**
|
|
3148
|
-
* @experimental
|
|
3149
|
-
* Base 10 logarithm block.
|
|
3150
|
-
*/
|
|
3151
|
-
class FlowGraphLog10Block extends FlowGraphUnaryOperationBlock {
|
|
3152
|
-
constructor(config) {
|
|
3153
|
-
super(RichTypeAny, RichTypeNumber, (a) => this._polymorphicLog10(a), FlowGraphLog10Block.ClassName, config);
|
|
3154
|
-
}
|
|
3155
|
-
_polymorphicLog10(a) {
|
|
3156
|
-
return _componentWiseUnaryOperation(a, Math.log10);
|
|
3157
|
-
}
|
|
3158
|
-
}
|
|
3159
|
-
/**
|
|
3160
|
-
* the class name of the block.
|
|
3161
|
-
*/
|
|
3162
|
-
FlowGraphLog10Block.ClassName = "FGLog10Block";
|
|
3163
|
-
RegisterClass(FlowGraphLog10Block.ClassName, FlowGraphLog10Block);
|
|
3164
|
-
/**
|
|
3165
|
-
* @experimental
|
|
3166
|
-
* Square root block.
|
|
3167
|
-
*/
|
|
3168
|
-
class FlowGraphSqrtBlock extends FlowGraphUnaryOperationBlock {
|
|
3169
|
-
constructor(config) {
|
|
3170
|
-
super(RichTypeAny, RichTypeNumber, (a) => this._polymorphicSqrt(a), FlowGraphSqrtBlock.ClassName, config);
|
|
3171
|
-
}
|
|
3172
|
-
_polymorphicSqrt(a) {
|
|
3173
|
-
return _componentWiseUnaryOperation(a, Math.sqrt);
|
|
3174
|
-
}
|
|
3175
|
-
}
|
|
3176
|
-
/**
|
|
3177
|
-
* the class name of the block.
|
|
3178
|
-
*/
|
|
3179
|
-
FlowGraphSqrtBlock.ClassName = "FGSqrtBlock";
|
|
3180
|
-
RegisterClass(FlowGraphSqrtBlock.ClassName, FlowGraphSqrtBlock);
|
|
3181
|
-
/**
|
|
3182
|
-
* @experimental
|
|
3183
|
-
* Cube root block.
|
|
3184
|
-
*/
|
|
3185
|
-
class FlowGraphCubeRootBlock extends FlowGraphUnaryOperationBlock {
|
|
3186
|
-
constructor(config) {
|
|
3187
|
-
super(RichTypeAny, RichTypeNumber, (a) => this._polymorphicCubeRoot(a), FlowGraphCubeRootBlock.ClassName, config);
|
|
3188
|
-
}
|
|
3189
|
-
_polymorphicCubeRoot(a) {
|
|
3190
|
-
return _componentWiseUnaryOperation(a, Math.cbrt);
|
|
3191
|
-
}
|
|
3192
|
-
}
|
|
3193
|
-
/**
|
|
3194
|
-
* the class name of the block.
|
|
3195
|
-
*/
|
|
3196
|
-
FlowGraphCubeRootBlock.ClassName = "FGCubeRootBlock";
|
|
3197
|
-
RegisterClass(FlowGraphCubeRootBlock.ClassName, FlowGraphCubeRootBlock);
|
|
3198
|
-
/**
|
|
3199
|
-
* @experimental
|
|
3200
|
-
* Power block.
|
|
3201
|
-
*/
|
|
3202
|
-
class FlowGraphPowBlock extends FlowGraphBinaryOperationBlock {
|
|
3203
|
-
constructor(config) {
|
|
3204
|
-
super(RichTypeAny, RichTypeNumber, RichTypeNumber, (a, b) => this._polymorphicPow(a, b), FlowGraphPowBlock.ClassName, config);
|
|
3205
|
-
}
|
|
3206
|
-
_polymorphicPow(a, b) {
|
|
3207
|
-
return _componentWiseBinaryOperation(a, b, Math.pow);
|
|
3208
|
-
}
|
|
3209
|
-
}
|
|
3210
|
-
/**
|
|
3211
|
-
* the class name of the block.
|
|
3212
|
-
*/
|
|
3213
|
-
FlowGraphPowBlock.ClassName = "FGPowBlock";
|
|
3214
|
-
RegisterClass(FlowGraphPowBlock.ClassName, FlowGraphPowBlock);
|
|
3215
|
-
/**
|
|
3216
|
-
* @experimental
|
|
3217
|
-
* Vector length block.
|
|
3218
|
-
*/
|
|
3219
|
-
class FlowGraphLengthBlock extends FlowGraphUnaryOperationBlock {
|
|
3220
|
-
constructor(config) {
|
|
3221
|
-
super(RichTypeAny, RichTypeNumber, (a) => this._polymorphicLength(a), FlowGraphLengthBlock.ClassName, config);
|
|
3222
|
-
}
|
|
3223
|
-
_polymorphicLength(a) {
|
|
3224
|
-
const aClassName = _getClassNameOf(a);
|
|
3225
|
-
switch (aClassName) {
|
|
3226
|
-
case "Vector2":
|
|
3227
|
-
case "Vector3":
|
|
3228
|
-
case "Vector4":
|
|
3229
|
-
return a.length();
|
|
3230
|
-
default:
|
|
3231
|
-
throw new Error(`Cannot compute length of value ${a}`);
|
|
3232
|
-
}
|
|
3233
|
-
}
|
|
3234
|
-
}
|
|
3235
|
-
/**
|
|
3236
|
-
* the class name of the block.
|
|
3237
|
-
*/
|
|
3238
|
-
FlowGraphLengthBlock.ClassName = "FGLengthBlock";
|
|
3239
|
-
RegisterClass(FlowGraphLengthBlock.ClassName, FlowGraphLengthBlock);
|
|
3240
|
-
/**
|
|
3241
|
-
* @experimental
|
|
3242
|
-
* Vector normalize block.
|
|
3243
|
-
*/
|
|
3244
|
-
class FlowGraphNormalizeBlock extends FlowGraphUnaryOperationBlock {
|
|
3245
|
-
constructor(config) {
|
|
3246
|
-
super(RichTypeAny, RichTypeAny, (a) => this._polymorphicNormalize(a), FlowGraphNormalizeBlock.ClassName, config);
|
|
3247
|
-
}
|
|
3248
|
-
_polymorphicNormalize(a) {
|
|
3249
|
-
const aClassName = _getClassNameOf(a);
|
|
3250
|
-
switch (aClassName) {
|
|
3251
|
-
case "Vector2":
|
|
3252
|
-
case "Vector3":
|
|
3253
|
-
case "Vector4":
|
|
3254
|
-
return a.normalize();
|
|
3255
|
-
default:
|
|
3256
|
-
throw new Error(`Cannot normalize value ${a}`);
|
|
3257
|
-
}
|
|
3258
|
-
}
|
|
3259
|
-
}
|
|
3260
|
-
/**
|
|
3261
|
-
* the class name of the block.
|
|
3262
|
-
*/
|
|
3263
|
-
FlowGraphNormalizeBlock.ClassName = "FGNormalizeBlock";
|
|
3264
|
-
RegisterClass(FlowGraphNormalizeBlock.ClassName, FlowGraphNormalizeBlock);
|
|
3265
|
-
/**
|
|
3266
|
-
* @experimental
|
|
3267
|
-
* Cross product block.
|
|
3268
|
-
*/
|
|
3269
|
-
class FlowGraphCrossBlock extends FlowGraphBinaryOperationBlock {
|
|
3270
|
-
constructor(config) {
|
|
3271
|
-
super(RichTypeVector3, RichTypeVector3, RichTypeVector3, (a, b) => Vector3.Cross(a, b), FlowGraphCrossBlock.ClassName, config);
|
|
3272
|
-
}
|
|
3273
|
-
}
|
|
3274
|
-
/**
|
|
3275
|
-
* the class name of the block.
|
|
3276
|
-
*/
|
|
3277
|
-
FlowGraphCrossBlock.ClassName = "FGCrossBlock";
|
|
3278
|
-
RegisterClass(FlowGraphCrossBlock.ClassName, FlowGraphCrossBlock);
|
|
3279
|
-
/**
|
|
3280
|
-
* @experimental
|
|
3281
|
-
* 2D rotation block.
|
|
3282
|
-
*/
|
|
3283
|
-
class FlowGraphRotate2DBlock extends FlowGraphBinaryOperationBlock {
|
|
3284
|
-
constructor(config) {
|
|
3285
|
-
super(RichTypeVector2, RichTypeNumber, RichTypeVector2, (a, b) => Vector2.Transform(a, Matrix.RotationZ(b)), FlowGraphRotate2DBlock.ClassName, config);
|
|
3286
|
-
}
|
|
3287
|
-
}
|
|
3288
|
-
/**
|
|
3289
|
-
* the class name of the block.
|
|
3290
|
-
*/
|
|
3291
|
-
FlowGraphRotate2DBlock.ClassName = "FGRotate2DBlock";
|
|
3292
|
-
RegisterClass(FlowGraphRotate2DBlock.ClassName, FlowGraphRotate2DBlock);
|
|
3293
|
-
/**
|
|
3294
|
-
* @experimental
|
|
3295
|
-
* 3D rotation block.
|
|
3296
|
-
*/
|
|
3297
|
-
class FlowGraphRotate3DBlock extends FlowGraphTernaryOperationBlock {
|
|
3298
|
-
constructor(config) {
|
|
3299
|
-
super(RichTypeVector3, RichTypeVector3, RichTypeNumber, RichTypeVector3, (a, b, c) => Vector3.TransformCoordinates(a, Matrix.RotationAxis(b, c)), FlowGraphRotate3DBlock.ClassName, config);
|
|
3300
|
-
}
|
|
3301
|
-
}
|
|
3302
|
-
/**
|
|
3303
|
-
* the class name of the block.
|
|
3304
|
-
*/
|
|
3305
|
-
FlowGraphRotate3DBlock.ClassName = "FGRotate3DBlock";
|
|
3306
|
-
RegisterClass(FlowGraphRotate3DBlock.ClassName, FlowGraphRotate3DBlock);
|
|
3307
|
-
/**
|
|
3308
|
-
* @experimental
|
|
3309
|
-
* Transposes a matrix.
|
|
3310
|
-
*/
|
|
3311
|
-
class FlowGraphTransposeBlock extends FlowGraphUnaryOperationBlock {
|
|
3312
|
-
constructor(config) {
|
|
3313
|
-
super(RichTypeMatrix, RichTypeMatrix, (a) => Matrix.Transpose(a), FlowGraphTransposeBlock.ClassName, config);
|
|
3314
|
-
}
|
|
3315
|
-
}
|
|
3316
|
-
/**
|
|
3317
|
-
* the class name of the block.
|
|
3318
|
-
*/
|
|
3319
|
-
FlowGraphTransposeBlock.ClassName = "FGTransposeBlock";
|
|
3320
|
-
RegisterClass(FlowGraphTransposeBlock.ClassName, FlowGraphTransposeBlock);
|
|
3321
|
-
/**
|
|
3322
|
-
* @experimental
|
|
3323
|
-
* Gets the determinant of a matrix.
|
|
3324
|
-
*/
|
|
3325
|
-
class FlowGraphDeterminantBlock extends FlowGraphUnaryOperationBlock {
|
|
3326
|
-
constructor(config) {
|
|
3327
|
-
super(RichTypeMatrix, RichTypeNumber, (a) => a.determinant(), FlowGraphDeterminantBlock.ClassName, config);
|
|
3328
|
-
}
|
|
3329
|
-
}
|
|
3330
|
-
/**
|
|
3331
|
-
* the class name of the block.
|
|
3332
|
-
*/
|
|
3333
|
-
FlowGraphDeterminantBlock.ClassName = "FGDeterminantBlock";
|
|
3334
|
-
RegisterClass(FlowGraphDeterminantBlock.ClassName, FlowGraphDeterminantBlock);
|
|
3335
|
-
/**
|
|
3336
|
-
* @experimental
|
|
3337
|
-
* Inverts a matrix.
|
|
3338
|
-
*/
|
|
3339
|
-
class FlowGraphInvertMatrixBlock extends FlowGraphUnaryOperationBlock {
|
|
3340
|
-
constructor(config) {
|
|
3341
|
-
super(RichTypeMatrix, RichTypeMatrix, (a) => Matrix.Invert(a), FlowGraphInvertMatrixBlock.ClassName, config);
|
|
3342
|
-
}
|
|
3343
|
-
}
|
|
3344
|
-
/**
|
|
3345
|
-
* the class name of the block.
|
|
3346
|
-
*/
|
|
3347
|
-
FlowGraphInvertMatrixBlock.ClassName = "FGInvertMatrixBlock";
|
|
3348
|
-
RegisterClass(FlowGraphInvertMatrixBlock.ClassName, FlowGraphInvertMatrixBlock);
|
|
3349
|
-
/**
|
|
3350
|
-
* @experimental
|
|
3351
|
-
* Multiplies two matrices.
|
|
3352
|
-
*/
|
|
3353
|
-
class FlowGraphMatMulBlock extends FlowGraphBinaryOperationBlock {
|
|
3354
|
-
constructor(config) {
|
|
3355
|
-
super(RichTypeMatrix, RichTypeMatrix, RichTypeMatrix, (a, b) => b.multiply(a), FlowGraphMatMulBlock.ClassName, config);
|
|
3356
|
-
}
|
|
3357
|
-
}
|
|
3358
|
-
/**
|
|
3359
|
-
* the class name of the block.
|
|
3360
|
-
*/
|
|
3361
|
-
FlowGraphMatMulBlock.ClassName = "FGMatMulBlock";
|
|
3362
|
-
RegisterClass(FlowGraphMatMulBlock.ClassName, FlowGraphMatMulBlock);
|
|
3363
|
-
/**
|
|
3364
|
-
* @experimental
|
|
3365
|
-
* Bitwise NOT operation
|
|
3366
|
-
*/
|
|
3367
|
-
class FlowGraphBitwiseNotBlock extends FlowGraphUnaryOperationBlock {
|
|
3368
|
-
constructor(config) {
|
|
3369
|
-
super(RichTypeFlowGraphInteger, RichTypeFlowGraphInteger, (a) => new FlowGraphInteger(~a.value), FlowGraphBitwiseNotBlock.ClassName, config);
|
|
3370
|
-
}
|
|
3371
|
-
}
|
|
3372
|
-
/**
|
|
3373
|
-
* the class name of the block.
|
|
3374
|
-
*/
|
|
3375
|
-
FlowGraphBitwiseNotBlock.ClassName = "FGBitwiseNotBlock";
|
|
3376
|
-
RegisterClass(FlowGraphBitwiseNotBlock.ClassName, FlowGraphBitwiseNotBlock);
|
|
3377
|
-
/**
|
|
3378
|
-
* @experimental
|
|
3379
|
-
* Bitwise AND operation
|
|
3380
|
-
*/
|
|
3381
|
-
class FlowGraphBitwiseAndBlock extends FlowGraphBinaryOperationBlock {
|
|
3382
|
-
constructor(config) {
|
|
3383
|
-
super(RichTypeFlowGraphInteger, RichTypeFlowGraphInteger, RichTypeFlowGraphInteger, (a, b) => new FlowGraphInteger(a.value & b.value), FlowGraphBitwiseAndBlock.ClassName, config);
|
|
3384
|
-
}
|
|
3385
|
-
}
|
|
3386
|
-
/**
|
|
3387
|
-
* the class name of the block.
|
|
3388
|
-
*/
|
|
3389
|
-
FlowGraphBitwiseAndBlock.ClassName = "FGBitwiseAndBlock";
|
|
3390
|
-
RegisterClass(FlowGraphBitwiseAndBlock.ClassName, FlowGraphBitwiseAndBlock);
|
|
3391
|
-
/**
|
|
3392
|
-
* @experimental
|
|
3393
|
-
* Bitwise OR operation
|
|
3394
|
-
*/
|
|
3395
|
-
class FlowGraphBitwiseOrBlock extends FlowGraphBinaryOperationBlock {
|
|
3396
|
-
constructor(config) {
|
|
3397
|
-
super(RichTypeFlowGraphInteger, RichTypeFlowGraphInteger, RichTypeFlowGraphInteger, (a, b) => new FlowGraphInteger(a.value | b.value), FlowGraphBitwiseOrBlock.ClassName, config);
|
|
3398
|
-
}
|
|
3399
|
-
}
|
|
3400
|
-
/**
|
|
3401
|
-
* the class name of the block.
|
|
3402
|
-
*/
|
|
3403
|
-
FlowGraphBitwiseOrBlock.ClassName = "FGBitwiseOrBlock";
|
|
3404
|
-
RegisterClass(FlowGraphBitwiseOrBlock.ClassName, FlowGraphBitwiseOrBlock);
|
|
3405
|
-
/**
|
|
3406
|
-
* @experimental
|
|
3407
|
-
* Bitwise XOR operation
|
|
3408
|
-
*/
|
|
3409
|
-
class FlowGraphBitwiseXorBlock extends FlowGraphBinaryOperationBlock {
|
|
3410
|
-
constructor(config) {
|
|
3411
|
-
super(RichTypeFlowGraphInteger, RichTypeFlowGraphInteger, RichTypeFlowGraphInteger, (a, b) => new FlowGraphInteger(a.value ^ b.value), FlowGraphBitwiseXorBlock.ClassName, config);
|
|
3412
|
-
}
|
|
3413
|
-
}
|
|
3414
|
-
/**
|
|
3415
|
-
* the class name of the block.
|
|
3416
|
-
*/
|
|
3417
|
-
FlowGraphBitwiseXorBlock.ClassName = "FGBitwiseXorBlock";
|
|
3418
|
-
RegisterClass(FlowGraphBitwiseXorBlock.ClassName, FlowGraphBitwiseXorBlock);
|
|
3419
|
-
/**
|
|
3420
|
-
* @experimental
|
|
3421
|
-
* Bitwise left shift operation
|
|
3422
|
-
*/
|
|
3423
|
-
class FlowGraphBitwiseLeftShiftBlock extends FlowGraphBinaryOperationBlock {
|
|
3424
|
-
constructor(config) {
|
|
3425
|
-
super(RichTypeFlowGraphInteger, RichTypeFlowGraphInteger, RichTypeFlowGraphInteger, (a, b) => new FlowGraphInteger(a.value << b.value), FlowGraphBitwiseLeftShiftBlock.ClassName, config);
|
|
3426
|
-
}
|
|
3427
|
-
}
|
|
3428
|
-
/**
|
|
3429
|
-
* the class name of the block.
|
|
3430
|
-
*/
|
|
3431
|
-
FlowGraphBitwiseLeftShiftBlock.ClassName = "FGBitwiseLeftShiftBlock";
|
|
3432
|
-
RegisterClass(FlowGraphBitwiseLeftShiftBlock.ClassName, FlowGraphBitwiseLeftShiftBlock);
|
|
3433
|
-
/**
|
|
3434
|
-
* @experimental
|
|
3435
|
-
* Bitwise right shift operation
|
|
3436
|
-
*/
|
|
3437
|
-
class FlowGraphBitwiseRightShiftBlock extends FlowGraphBinaryOperationBlock {
|
|
3438
|
-
constructor(config) {
|
|
3439
|
-
super(RichTypeFlowGraphInteger, RichTypeFlowGraphInteger, RichTypeFlowGraphInteger, (a, b) => new FlowGraphInteger(a.value >> b.value), FlowGraphBitwiseRightShiftBlock.ClassName, config);
|
|
3440
|
-
}
|
|
3441
|
-
}
|
|
3442
|
-
/**
|
|
3443
|
-
* the class name of the block.
|
|
3444
|
-
*/
|
|
3445
|
-
FlowGraphBitwiseRightShiftBlock.ClassName = "FGBitwiseRightShiftBlock";
|
|
3446
|
-
RegisterClass(FlowGraphBitwiseRightShiftBlock.ClassName, FlowGraphBitwiseRightShiftBlock);
|
|
3447
|
-
/**
|
|
3448
|
-
* @experimental
|
|
3449
|
-
* Count leading zeros operation
|
|
3450
|
-
*/
|
|
3451
|
-
class FlowGraphCountLeadingZerosBlock extends FlowGraphUnaryOperationBlock {
|
|
3452
|
-
constructor(config) {
|
|
3453
|
-
super(RichTypeFlowGraphInteger, RichTypeFlowGraphInteger, (a) => new FlowGraphInteger(Math.clz32(a.value)), FlowGraphCountLeadingZerosBlock.ClassName, config);
|
|
3454
|
-
}
|
|
3455
|
-
}
|
|
3456
|
-
/**
|
|
3457
|
-
* the class name of the block.
|
|
3458
|
-
*/
|
|
3459
|
-
FlowGraphCountLeadingZerosBlock.ClassName = "FGCountLeadingZerosBlock";
|
|
3460
|
-
RegisterClass(FlowGraphCountLeadingZerosBlock.ClassName, FlowGraphCountLeadingZerosBlock);
|
|
3461
|
-
/**
|
|
3462
|
-
* @experimental
|
|
3463
|
-
* Count trailing zeros operation
|
|
3464
|
-
*/
|
|
3465
|
-
class FlowGraphCountTrailingZerosBlock extends FlowGraphUnaryOperationBlock {
|
|
3466
|
-
constructor(config) {
|
|
3467
|
-
super(RichTypeFlowGraphInteger, RichTypeFlowGraphInteger, (a) => new FlowGraphInteger(a.value ? 31 - Math.clz32(a.value & -a.value) : 32), FlowGraphCountTrailingZerosBlock.ClassName, config);
|
|
3468
|
-
}
|
|
3469
|
-
}
|
|
3470
|
-
/**
|
|
3471
|
-
* the class name of the block.
|
|
3472
|
-
*/
|
|
3473
|
-
FlowGraphCountTrailingZerosBlock.ClassName = "FGCountTrailingZerosBlock";
|
|
3474
|
-
RegisterClass(FlowGraphCountTrailingZerosBlock.ClassName, FlowGraphCountTrailingZerosBlock);
|
|
3475
|
-
/**
|
|
3476
|
-
* Given a number (which is converted to a 32-bit integer), return the
|
|
3477
|
-
* number of bits set to one on that number.
|
|
3478
|
-
* @internal
|
|
3479
|
-
* @param n
|
|
3480
|
-
*/
|
|
3481
|
-
function _countOnes(n) {
|
|
3482
|
-
let result = 0;
|
|
3483
|
-
while (n) {
|
|
3484
|
-
// This zeroes out all bits except for the least significant one.
|
|
3485
|
-
// So if the bit is set, it will be 1, otherwise it will be 0.
|
|
3486
|
-
result += n & 1;
|
|
3487
|
-
// This shifts n's bits to the right by one
|
|
3488
|
-
n >>= 1;
|
|
3489
|
-
}
|
|
3490
|
-
return result;
|
|
3491
|
-
}
|
|
3492
|
-
/**
|
|
3493
|
-
* @experimental
|
|
3494
|
-
* Count one bits operation
|
|
3495
|
-
*/
|
|
3496
|
-
class FlowGraphCountOneBitsBlock extends FlowGraphUnaryOperationBlock {
|
|
3497
|
-
constructor(config) {
|
|
3498
|
-
super(RichTypeFlowGraphInteger, RichTypeFlowGraphInteger, (a) => new FlowGraphInteger(_countOnes(a.value)), FlowGraphCountOneBitsBlock.ClassName, config);
|
|
3499
|
-
}
|
|
3500
|
-
}
|
|
3501
|
-
/**
|
|
3502
|
-
* the class name of the block.
|
|
3503
|
-
*/
|
|
3504
|
-
FlowGraphCountOneBitsBlock.ClassName = "FGCountOneBitsBlock";
|
|
3505
|
-
RegisterClass(FlowGraphCountOneBitsBlock.ClassName, FlowGraphCountOneBitsBlock);
|
|
3506
|
-
|
|
3507
|
-
/**
|
|
3508
|
-
* A block that executes a branch a set number of times.
|
|
3509
|
-
* @experimental
|
|
3510
|
-
*/
|
|
3511
|
-
class FlowGraphDoNBlock extends FlowGraphExecutionBlockWithOutSignal {
|
|
3512
|
-
constructor(
|
|
3513
|
-
/**
|
|
3514
|
-
* [Object] the configuration of the block
|
|
3515
|
-
*/
|
|
3516
|
-
config = { startIndex: new FlowGraphInteger(0) }) {
|
|
3517
|
-
super(config);
|
|
3518
|
-
this.config = config;
|
|
3519
|
-
this.reset = this._registerSignalInput("reset");
|
|
3520
|
-
this.n = this.registerDataInput("n", RichTypeFlowGraphInteger);
|
|
3521
|
-
this.value = this.registerDataOutput("value", RichTypeFlowGraphInteger);
|
|
3522
|
-
}
|
|
3523
|
-
_execute(context, callingSignal) {
|
|
3524
|
-
if (callingSignal === this.reset) {
|
|
3525
|
-
this.value.setValue(this.config.startIndex, context);
|
|
3526
|
-
}
|
|
3527
|
-
else {
|
|
3528
|
-
const currentCountValue = this.value.getValue(context);
|
|
3529
|
-
if (currentCountValue.value < this.n.getValue(context).value) {
|
|
3530
|
-
this.value.setValue(new FlowGraphInteger(currentCountValue.value + 1), context);
|
|
3531
|
-
this.out._activateSignal(context);
|
|
3532
|
-
}
|
|
3533
|
-
}
|
|
3534
|
-
}
|
|
3535
|
-
/**
|
|
3536
|
-
* @returns class name of the block.
|
|
3537
|
-
*/
|
|
3538
|
-
getClassName() {
|
|
3539
|
-
return FlowGraphDoNBlock.ClassName;
|
|
3540
|
-
}
|
|
3541
|
-
}
|
|
3542
|
-
/**
|
|
3543
|
-
* the class name of the block.
|
|
3544
|
-
*/
|
|
3545
|
-
FlowGraphDoNBlock.ClassName = "FGDoNBlock";
|
|
3546
|
-
RegisterClass(FlowGraphDoNBlock.ClassName, FlowGraphDoNBlock);
|
|
3547
|
-
|
|
3548
|
-
/**
|
|
3549
|
-
* A block that gets the value of a variable.
|
|
3550
|
-
* @experimental
|
|
3551
|
-
*/
|
|
3552
|
-
class FlowGraphGetVariableBlock extends FlowGraphBlock {
|
|
3553
|
-
/**
|
|
3554
|
-
* Construct a FlowGraphGetVariableBlock.
|
|
3555
|
-
* @param config construction parameters
|
|
3556
|
-
*/
|
|
3557
|
-
constructor(config) {
|
|
3558
|
-
super(config);
|
|
3559
|
-
this.config = config;
|
|
3560
|
-
// The output connection has to have the name of the variable.
|
|
3561
|
-
this.output = this.registerDataOutput(config.variableName, RichTypeAny);
|
|
3562
|
-
}
|
|
3563
|
-
/**
|
|
3564
|
-
* @internal
|
|
3565
|
-
*/
|
|
3566
|
-
_updateOutputs(context) {
|
|
3567
|
-
const variableNameValue = this.config.variableName;
|
|
3568
|
-
if (context.hasVariable(variableNameValue)) {
|
|
3569
|
-
this.output.setValue(context.getVariable(variableNameValue), context);
|
|
3570
|
-
}
|
|
3571
|
-
}
|
|
3572
|
-
/**
|
|
3573
|
-
* Gets the class name of this block
|
|
3574
|
-
* @returns the class name
|
|
3575
|
-
*/
|
|
3576
|
-
getClassName() {
|
|
3577
|
-
return FlowGraphGetVariableBlock.ClassName;
|
|
3578
|
-
}
|
|
3579
|
-
/**
|
|
3580
|
-
* Serializes this block
|
|
3581
|
-
* @param serializationObject the object to serialize to
|
|
3582
|
-
*/
|
|
3583
|
-
serialize(serializationObject) {
|
|
3584
|
-
super.serialize(serializationObject);
|
|
3585
|
-
serializationObject.config.variableName = this.config.variableName;
|
|
3586
|
-
}
|
|
3587
|
-
}
|
|
3588
|
-
/**
|
|
3589
|
-
* Class name of the block.
|
|
3590
|
-
*/
|
|
3591
|
-
FlowGraphGetVariableBlock.ClassName = "FGGetVariableBlock";
|
|
3592
|
-
RegisterClass(FlowGraphGetVariableBlock.ClassName, FlowGraphGetVariableBlock);
|
|
3593
|
-
|
|
3594
|
-
/**
|
|
3595
|
-
* Block to set a variable.
|
|
3596
|
-
* @experimental
|
|
3597
|
-
*/
|
|
3598
|
-
class FlowGraphSetVariableBlock extends FlowGraphExecutionBlockWithOutSignal {
|
|
3599
|
-
constructor(
|
|
3600
|
-
/**
|
|
3601
|
-
* the configuration of the block
|
|
3602
|
-
*/
|
|
3603
|
-
config) {
|
|
3604
|
-
super(config);
|
|
3605
|
-
this.config = config;
|
|
3606
|
-
this.input = this.registerDataInput(config.variableName, RichTypeAny);
|
|
3607
|
-
}
|
|
3608
|
-
_execute(context) {
|
|
3609
|
-
const variableNameValue = this.config.variableName;
|
|
3610
|
-
const inputValue = this.input.getValue(context);
|
|
3611
|
-
context.setVariable(variableNameValue, inputValue);
|
|
3612
|
-
this.out._activateSignal(context);
|
|
3613
|
-
}
|
|
3614
|
-
/**
|
|
3615
|
-
* @returns class name of the block.
|
|
3616
|
-
*/
|
|
3617
|
-
getClassName() {
|
|
3618
|
-
return FlowGraphSetVariableBlock.ClassName;
|
|
3619
|
-
}
|
|
3620
|
-
}
|
|
3621
|
-
/**
|
|
3622
|
-
* the class name of the block.
|
|
3623
|
-
*/
|
|
3624
|
-
FlowGraphSetVariableBlock.ClassName = "FGSetVariableBlock";
|
|
3625
|
-
RegisterClass(FlowGraphSetVariableBlock.ClassName, FlowGraphSetVariableBlock);
|
|
3626
|
-
|
|
3627
|
-
/**
|
|
3628
|
-
* @experimental
|
|
3629
|
-
* A block that executes a branch while a condition is true.
|
|
3630
|
-
*/
|
|
3631
|
-
class FlowGraphWhileLoopBlock extends FlowGraphExecutionBlockWithOutSignal {
|
|
3632
|
-
constructor(
|
|
3633
|
-
/**
|
|
3634
|
-
* the configuration of the block
|
|
3635
|
-
*/
|
|
3636
|
-
config) {
|
|
3637
|
-
super(config);
|
|
3638
|
-
this.config = config;
|
|
3639
|
-
this.condition = this.registerDataInput("condition", RichTypeBoolean);
|
|
3640
|
-
this.loopBody = this._registerSignalOutput("loopBody");
|
|
3641
|
-
}
|
|
3642
|
-
_execute(context, _callingSignal) {
|
|
3643
|
-
let conditionValue = this.condition.getValue(context);
|
|
3644
|
-
if (this.config?.isDo && !conditionValue) {
|
|
3645
|
-
this.loopBody._activateSignal(context);
|
|
3646
|
-
}
|
|
3647
|
-
while (conditionValue) {
|
|
3648
|
-
this.loopBody._activateSignal(context);
|
|
3649
|
-
conditionValue = this.condition.getValue(context);
|
|
3650
|
-
}
|
|
3651
|
-
this.out._activateSignal(context);
|
|
3652
|
-
}
|
|
3653
|
-
/**
|
|
3654
|
-
* @returns class name of the block.
|
|
3655
|
-
*/
|
|
3656
|
-
getClassName() {
|
|
3657
|
-
return FlowGraphWhileLoopBlock.ClassName;
|
|
3658
|
-
}
|
|
3659
|
-
/**
|
|
3660
|
-
* Serializes the block to a JSON object.
|
|
3661
|
-
* @param serializationObject the object to serialize to.
|
|
3662
|
-
*/
|
|
3663
|
-
serialize(serializationObject) {
|
|
3664
|
-
super.serialize(serializationObject);
|
|
3665
|
-
serializationObject.isDo = this.config?.isDo;
|
|
3666
|
-
}
|
|
3667
|
-
}
|
|
3668
|
-
/**
|
|
3669
|
-
* the class name of the block.
|
|
3670
|
-
*/
|
|
3671
|
-
FlowGraphWhileLoopBlock.ClassName = "FGWhileLoopBlock";
|
|
3672
|
-
RegisterClass(FlowGraphWhileLoopBlock.ClassName, FlowGraphWhileLoopBlock);
|
|
3673
|
-
|
|
3674
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
3675
|
-
const gltfToFlowGraphTypeMap = {
|
|
3676
|
-
"lifecycle/onStart": FlowGraphSceneReadyEventBlock.ClassName,
|
|
3677
|
-
"lifecycle/onTick": FlowGraphSceneTickEventBlock.ClassName,
|
|
3678
|
-
log: FlowGraphConsoleLogBlock.ClassName,
|
|
3679
|
-
"flow/delay": FlowGraphTimerBlock.ClassName,
|
|
3680
|
-
"customEvent/send": FlowGraphSendCustomEventBlock.ClassName,
|
|
3681
|
-
"customEvent/receive": FlowGraphReceiveCustomEventBlock.ClassName,
|
|
3682
|
-
"flow/sequence": FlowGraphSequenceBlock.ClassName,
|
|
3683
|
-
"world/get": FlowGraphGetPropertyBlock.ClassName,
|
|
3684
|
-
"world/set": FlowGraphSetPropertyBlock.ClassName,
|
|
3685
|
-
"flow/doN": FlowGraphDoNBlock.ClassName,
|
|
3686
|
-
"variable/get": FlowGraphGetVariableBlock.ClassName,
|
|
3687
|
-
"variable/set": FlowGraphSetVariableBlock.ClassName,
|
|
3688
|
-
"flow/whileLoop": FlowGraphWhileLoopBlock.ClassName,
|
|
3689
|
-
"math/random": FlowGraphRandomBlock.ClassName,
|
|
3690
|
-
"math/e": FlowGraphEBlock.ClassName,
|
|
3691
|
-
"math/pi": FlowGraphPiBlock.ClassName,
|
|
3692
|
-
"math/inf": FlowGraphInfBlock.ClassName,
|
|
3693
|
-
"math/nan": FlowGraphNaNBlock.ClassName,
|
|
3694
|
-
"math/abs": FlowGraphAbsBlock.ClassName,
|
|
3695
|
-
"math/sign": FlowGraphSignBlock.ClassName,
|
|
3696
|
-
"math/trunc": FlowGraphTruncBlock.ClassName,
|
|
3697
|
-
"math/floor": FlowGraphFloorBlock.ClassName,
|
|
3698
|
-
"math/ceil": FlowGraphCeilBlock.ClassName,
|
|
3699
|
-
"math/fract": FlowGraphFractBlock.ClassName,
|
|
3700
|
-
"math/neg": FlowGraphNegBlock.ClassName,
|
|
3701
|
-
"math/add": FlowGraphAddBlock.ClassName,
|
|
3702
|
-
"math/sub": FlowGraphSubtractBlock.ClassName,
|
|
3703
|
-
"math/mul": FlowGraphMultiplyBlock.ClassName,
|
|
3704
|
-
"math/div": FlowGraphDivideBlock.ClassName,
|
|
3705
|
-
"math/rem": FlowGraphRemainderBlock.ClassName,
|
|
3706
|
-
"math/min": FlowGraphMinBlock.ClassName,
|
|
3707
|
-
"math/max": FlowGraphMaxBlock.ClassName,
|
|
3708
|
-
"math/clamp": FlowGraphClampBlock.ClassName,
|
|
3709
|
-
"math/saturate": FlowGraphSaturateBlock.ClassName,
|
|
3710
|
-
"math/mix": FlowGraphInterpolateBlock.ClassName,
|
|
3711
|
-
"math/eq": FlowGraphEqBlock.ClassName,
|
|
3712
|
-
"math/lt": FlowGraphLessThanBlock.ClassName,
|
|
3713
|
-
"math/le": FlowGraphLessThanOrEqualBlock.ClassName,
|
|
3714
|
-
"math/gt": FlowGraphGreaterThanBlock.ClassName,
|
|
3715
|
-
"math/ge": FlowGraphGreaterThanOrEqualBlock.ClassName,
|
|
3716
|
-
"math/isnan": FlowGraphIsNanBlock.ClassName,
|
|
3717
|
-
"math/isinf": FlowGraphIsInfBlock.ClassName,
|
|
3718
|
-
"math/rad": FlowGraphDegToRadBlock.ClassName,
|
|
3719
|
-
"math/deg": FlowGraphRadToDegBlock.ClassName,
|
|
3720
|
-
"math/sin": FlowGraphSinBlock.ClassName,
|
|
3721
|
-
"math/cos": FlowGraphCosBlock.ClassName,
|
|
3722
|
-
"math/tan": FlowGraphTanBlock.ClassName,
|
|
3723
|
-
"math/asin": FlowGraphAsinBlock.ClassName,
|
|
3724
|
-
"math/acos": FlowGraphAcosBlock.ClassName,
|
|
3725
|
-
"math/atan": FlowGraphAtanBlock.ClassName,
|
|
3726
|
-
"math/atan2": FlowGraphAtan2Block.ClassName,
|
|
3727
|
-
"math/sinh": FlowGraphSinhBlock.ClassName,
|
|
3728
|
-
"math/cosh": FlowGraphCoshBlock.ClassName,
|
|
3729
|
-
"math/tanh": FlowGraphTanhBlock.ClassName,
|
|
3730
|
-
"math/asinh": FlowGraphAsinhBlock.ClassName,
|
|
3731
|
-
"math/acosh": FlowGraphAcoshBlock.ClassName,
|
|
3732
|
-
"math/atanh": FlowGraphAtanhBlock.ClassName,
|
|
3733
|
-
"math/exp": FlowGraphExpBlock.ClassName,
|
|
3734
|
-
"math/log": FlowGraphLogBlock.ClassName,
|
|
3735
|
-
"math/log2": FlowGraphLog2Block.ClassName,
|
|
3736
|
-
"math/log10": FlowGraphLog10Block.ClassName,
|
|
3737
|
-
"math/sqrt": FlowGraphSqrtBlock.ClassName,
|
|
3738
|
-
"math/cbrt": FlowGraphCubeRootBlock.ClassName,
|
|
3739
|
-
"math/pow": FlowGraphPowBlock.ClassName,
|
|
3740
|
-
"math/length": FlowGraphLengthBlock.ClassName,
|
|
3741
|
-
"math/normalize": FlowGraphNormalizeBlock.ClassName,
|
|
3742
|
-
"math/dot": FlowGraphDotBlock.ClassName,
|
|
3743
|
-
"math/cross": FlowGraphCrossBlock.ClassName,
|
|
3744
|
-
"math/rotate2d": FlowGraphRotate2DBlock.ClassName,
|
|
3745
|
-
"math/rotate3d": FlowGraphRotate3DBlock.ClassName,
|
|
3746
|
-
"math/transpose": FlowGraphTransposeBlock.ClassName,
|
|
3747
|
-
"math/determinant": FlowGraphDeterminantBlock.ClassName,
|
|
3748
|
-
"math/inverse": FlowGraphInvertMatrixBlock.ClassName,
|
|
3749
|
-
"math/matmul": FlowGraphMatMulBlock.ClassName,
|
|
3750
|
-
"math/not": FlowGraphBitwiseNotBlock.ClassName,
|
|
3751
|
-
"math/and": FlowGraphBitwiseAndBlock.ClassName,
|
|
3752
|
-
"math/or": FlowGraphBitwiseOrBlock.ClassName,
|
|
3753
|
-
"math/xor": FlowGraphBitwiseXorBlock.ClassName,
|
|
3754
|
-
"math/asr": FlowGraphBitwiseRightShiftBlock.ClassName,
|
|
3755
|
-
"math/lsl": FlowGraphBitwiseLeftShiftBlock.ClassName,
|
|
3756
|
-
"math/clz": FlowGraphCountLeadingZerosBlock.ClassName,
|
|
3757
|
-
"math/ctz": FlowGraphCountTrailingZerosBlock.ClassName,
|
|
3758
|
-
"math/popcnt": FlowGraphCountOneBitsBlock.ClassName,
|
|
3759
|
-
};
|
|
3760
|
-
const gltfTypeToBabylonType = {
|
|
3761
|
-
float2: "Vector2",
|
|
3762
|
-
float3: "Vector3",
|
|
3763
|
-
float4: "Vector4",
|
|
3764
|
-
float4x4: "Matrix",
|
|
3765
|
-
int: "FlowGraphInteger",
|
|
3766
|
-
};
|
|
3767
|
-
|
|
3768
|
-
function convertValueWithType(configObject, definition, context) {
|
|
3769
|
-
if (configObject.type !== undefined) {
|
|
3770
|
-
// get the type on the gltf definition
|
|
3771
|
-
const type = definition.types && definition.types[configObject.type];
|
|
3772
|
-
if (!type) {
|
|
3773
|
-
throw new Error(`${context}: Unknown type: ${configObject.type}`);
|
|
3774
|
-
}
|
|
3775
|
-
const signature = type.signature;
|
|
3776
|
-
if (!signature) {
|
|
3777
|
-
throw new Error(`${context}: Type ${configObject.type} has no signature`);
|
|
3778
|
-
}
|
|
3779
|
-
const convertedType = gltfTypeToBabylonType[signature];
|
|
3780
|
-
return {
|
|
3781
|
-
value: configObject.value,
|
|
3782
|
-
className: convertedType,
|
|
3783
|
-
};
|
|
3784
|
-
}
|
|
3785
|
-
else {
|
|
3786
|
-
return configObject.value;
|
|
3787
|
-
}
|
|
3788
|
-
}
|
|
3789
|
-
function convertConfiguration(gltfBlock, definition, id) {
|
|
3790
|
-
const converted = {};
|
|
3791
|
-
const configurationList = gltfBlock.configuration ?? [];
|
|
3792
|
-
for (const configObject of configurationList) {
|
|
3793
|
-
if (configObject.id === "customEvent") {
|
|
3794
|
-
const customEvent = definition.customEvents && definition.customEvents[configObject.value];
|
|
3795
|
-
if (!customEvent) {
|
|
3796
|
-
throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown custom event: ${configObject.value}`);
|
|
3797
|
-
}
|
|
3798
|
-
converted.eventId = customEvent.id;
|
|
3799
|
-
converted.eventData = customEvent.values.map((v) => v.id);
|
|
3800
|
-
}
|
|
3801
|
-
else if (configObject.id === "variable") {
|
|
3802
|
-
const variable = definition.variables && definition.variables[configObject.value];
|
|
3803
|
-
if (!variable) {
|
|
3804
|
-
throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown variable: ${configObject.value}`);
|
|
3805
|
-
}
|
|
3806
|
-
converted.variableName = variable.id;
|
|
3807
|
-
}
|
|
3808
|
-
else if (configObject.id === "path") {
|
|
3809
|
-
// Convert from a GLTF path to a reference to the Babylon.js object
|
|
3810
|
-
const pathValue = configObject.value;
|
|
3811
|
-
converted.path = pathValue;
|
|
3812
|
-
}
|
|
3813
|
-
else {
|
|
3814
|
-
converted[configObject.id] = convertValueWithType(configObject, definition, `/extensions/KHR_interactivity/nodes/${id}`);
|
|
3815
|
-
}
|
|
3816
|
-
}
|
|
3817
|
-
return converted;
|
|
3818
|
-
}
|
|
3819
|
-
function convertBlock(id, gltfBlock, definition) {
|
|
3820
|
-
const className = gltfToFlowGraphTypeMap[gltfBlock.type];
|
|
3821
|
-
if (!className) {
|
|
3822
|
-
throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown block type: ${gltfBlock.type}`);
|
|
3823
|
-
}
|
|
3824
|
-
const uniqueId = id.toString();
|
|
3825
|
-
const config = convertConfiguration(gltfBlock, definition, uniqueId);
|
|
3826
|
-
const metadata = gltfBlock.metadata;
|
|
3827
|
-
const dataInputs = [];
|
|
3828
|
-
const dataOutputs = [];
|
|
3829
|
-
const signalInputs = [];
|
|
3830
|
-
const signalOutputs = [];
|
|
3831
|
-
return {
|
|
3832
|
-
className,
|
|
3833
|
-
config,
|
|
3834
|
-
uniqueId,
|
|
3835
|
-
metadata,
|
|
3836
|
-
dataInputs,
|
|
3837
|
-
dataOutputs,
|
|
3838
|
-
signalInputs,
|
|
3839
|
-
signalOutputs,
|
|
3840
|
-
};
|
|
3841
|
-
}
|
|
3842
|
-
/**
|
|
3843
|
-
* @internal
|
|
3844
|
-
* Converts a glTF Interactivity Extension to a serialized flow graph.
|
|
3845
|
-
* @param gltf the interactivity data
|
|
3846
|
-
* @returns a serialized flow graph
|
|
3847
|
-
*/
|
|
3848
|
-
function convertGLTFToSerializedFlowGraph(gltf) {
|
|
3849
|
-
// create an empty serialized context to store the values of the connections
|
|
3850
|
-
const context = {
|
|
3851
|
-
uniqueId: RandomGUID(),
|
|
3852
|
-
_userVariables: {},
|
|
3853
|
-
_connectionValues: {},
|
|
3854
|
-
};
|
|
3855
|
-
const executionContexts = [context];
|
|
3856
|
-
// Blocks converted to the flow graph json format
|
|
3857
|
-
const flowGraphJsonBlocks = [];
|
|
3858
|
-
for (let i = 0; i < gltf.nodes.length; i++) {
|
|
3859
|
-
const gltfBlock = gltf.nodes[i];
|
|
3860
|
-
const flowGraphJsonBlock = convertBlock(i, gltfBlock, gltf);
|
|
3861
|
-
flowGraphJsonBlocks.push(flowGraphJsonBlock);
|
|
3862
|
-
}
|
|
3863
|
-
// Parse the connections
|
|
3864
|
-
for (let i = 0; i < gltf.nodes.length; i++) {
|
|
3865
|
-
const gltfBlock = gltf.nodes[i];
|
|
3866
|
-
// get the block that was created in the previous step
|
|
3867
|
-
const fgBlock = flowGraphJsonBlocks[i];
|
|
3868
|
-
const gltfFlows = gltfBlock.flows ?? [];
|
|
3869
|
-
// for each output flow of the gltf block
|
|
3870
|
-
for (const flow of gltfFlows) {
|
|
3871
|
-
const socketOutName = flow.id;
|
|
3872
|
-
// create an output connection for the flow graph block
|
|
3873
|
-
const socketOut = {
|
|
3874
|
-
uniqueId: RandomGUID(),
|
|
3875
|
-
name: socketOutName,
|
|
3876
|
-
_connectionType: 1 /* FlowGraphConnectionType.Output */, // Output
|
|
3877
|
-
connectedPointIds: [],
|
|
3878
|
-
};
|
|
3879
|
-
fgBlock.signalOutputs.push(socketOut);
|
|
3880
|
-
// get the input node of this flow
|
|
3881
|
-
const nodeInId = flow.node;
|
|
3882
|
-
const nodeInSocketName = flow.socket;
|
|
3883
|
-
// find the corresponding flow graph node
|
|
3884
|
-
const nodeIn = flowGraphJsonBlocks[nodeInId];
|
|
3885
|
-
if (!nodeIn) {
|
|
3886
|
-
throw new Error(`/extensions/KHR_interactivity/nodes/${i}: Could not find node with id ${nodeInId} that connects its input with with node ${i}'s output ${socketOutName}`);
|
|
3887
|
-
}
|
|
3888
|
-
// in all of the flow graph input connections, find the one with the same name as the socket
|
|
3889
|
-
let socketIn = nodeIn.signalInputs.find((s) => s.name === nodeInSocketName);
|
|
3890
|
-
// if the socket doesn't exist, create the input socket for the connection
|
|
3891
|
-
if (!socketIn) {
|
|
3892
|
-
socketIn = {
|
|
3893
|
-
uniqueId: RandomGUID(),
|
|
3894
|
-
name: nodeInSocketName,
|
|
3895
|
-
_connectionType: 0 /* FlowGraphConnectionType.Input */, // Input
|
|
3896
|
-
connectedPointIds: [],
|
|
3897
|
-
};
|
|
3898
|
-
nodeIn.signalInputs.push(socketIn);
|
|
3899
|
-
}
|
|
3900
|
-
// connect the sockets
|
|
3901
|
-
socketIn.connectedPointIds.push(socketOut.uniqueId);
|
|
3902
|
-
socketOut.connectedPointIds.push(socketIn.uniqueId);
|
|
3903
|
-
}
|
|
3904
|
-
// for each input value of the gltf block
|
|
3905
|
-
const gltfValues = gltfBlock.values ?? [];
|
|
3906
|
-
for (const value of gltfValues) {
|
|
3907
|
-
const socketInName = value.id;
|
|
3908
|
-
// create an input data connection for the flow graph block
|
|
3909
|
-
const socketIn = {
|
|
3910
|
-
uniqueId: RandomGUID(),
|
|
3911
|
-
name: socketInName,
|
|
3912
|
-
_connectionType: 0 /* FlowGraphConnectionType.Input */,
|
|
3913
|
-
connectedPointIds: [],
|
|
3914
|
-
};
|
|
3915
|
-
fgBlock.dataInputs.push(socketIn);
|
|
3916
|
-
if (value.value !== undefined) {
|
|
3917
|
-
// if the value is set on the socket itself, store it in the context
|
|
3918
|
-
const convertedValue = convertValueWithType(value, gltf, `/extensions/KHR_interactivity/nodes/${i}`);
|
|
3919
|
-
// convertBlockInputType(gltfBlock, value, convertedValue, `/extensions/KHR_interactivity/nodes/${i}`);
|
|
3920
|
-
context._connectionValues[socketIn.uniqueId] = convertedValue;
|
|
3921
|
-
}
|
|
3922
|
-
else if (value.node !== undefined && value.socket !== undefined) {
|
|
3923
|
-
// if the value is connected with the output data of another socket, connect the two
|
|
3924
|
-
const nodeOutId = value.node;
|
|
3925
|
-
const nodeOutSocketName = value.socket;
|
|
3926
|
-
// find the flow graph node that owns that output socket
|
|
3927
|
-
const nodeOut = flowGraphJsonBlocks[nodeOutId];
|
|
3928
|
-
if (!nodeOut) {
|
|
3929
|
-
throw new Error(`/extensions/KHR_interactivity/nodes/${i}: Could not find node with id ${nodeOutId} that connects its output with node${i}'s input ${socketInName}`);
|
|
3930
|
-
}
|
|
3931
|
-
let socketOut = nodeOut.dataOutputs.find((s) => s.name === nodeOutSocketName);
|
|
3932
|
-
// if the socket doesn't exist, create it
|
|
3933
|
-
if (!socketOut) {
|
|
3934
|
-
socketOut = {
|
|
3935
|
-
uniqueId: RandomGUID(),
|
|
3936
|
-
name: nodeOutSocketName,
|
|
3937
|
-
_connectionType: 1 /* FlowGraphConnectionType.Output */,
|
|
3938
|
-
connectedPointIds: [],
|
|
3939
|
-
};
|
|
3940
|
-
nodeOut.dataOutputs.push(socketOut);
|
|
3941
|
-
}
|
|
3942
|
-
// connect the sockets
|
|
3943
|
-
socketIn.connectedPointIds.push(socketOut.uniqueId);
|
|
3944
|
-
socketOut.connectedPointIds.push(socketIn.uniqueId);
|
|
3945
|
-
}
|
|
3946
|
-
else {
|
|
3947
|
-
throw new Error(`/extensions/KHR_interactivity/nodes/${i}: Invalid socket ${socketInName} in node ${i}`);
|
|
3948
|
-
}
|
|
3949
|
-
}
|
|
3950
|
-
}
|
|
3951
|
-
const variables = gltf.variables ?? [];
|
|
3952
|
-
// Parse variables
|
|
3953
|
-
for (let i = 0; i < variables.length; i++) {
|
|
3954
|
-
const variable = variables[i];
|
|
3955
|
-
const variableName = variable.id;
|
|
3956
|
-
context._userVariables[variableName] = convertValueWithType(variable, gltf, `/extensions/KHR_interactivity/variables/${i}`);
|
|
3957
|
-
}
|
|
3958
|
-
return {
|
|
3959
|
-
allBlocks: flowGraphJsonBlocks,
|
|
3960
|
-
executionContexts,
|
|
3961
|
-
};
|
|
3962
|
-
}
|
|
3963
|
-
|
|
3964
|
-
/**
|
|
3965
|
-
* Class to convert an interactivity pointer path to a smart object
|
|
3966
|
-
*/
|
|
3967
|
-
class InteractivityPathToObjectConverter extends GLTFPathToObjectConverter {
|
|
3968
|
-
constructor(gltf) {
|
|
3969
|
-
super(gltf, gltfTree);
|
|
3970
|
-
}
|
|
3971
|
-
}
|
|
3972
|
-
const nodesTree = {
|
|
3973
|
-
__array__: {
|
|
3974
|
-
__target__: true,
|
|
3975
|
-
translation: {
|
|
3976
|
-
type: "Vector3",
|
|
3977
|
-
get: (node) => {
|
|
3978
|
-
const babylonObject = node._babylonTransformNode;
|
|
3979
|
-
return babylonObject.position;
|
|
3980
|
-
},
|
|
3981
|
-
set: (value, node) => {
|
|
3982
|
-
const babylonObject = node._babylonTransformNode;
|
|
3983
|
-
babylonObject.position = value;
|
|
3984
|
-
},
|
|
3985
|
-
getObject(node) {
|
|
3986
|
-
return node._babylonTransformNode;
|
|
3987
|
-
},
|
|
3988
|
-
},
|
|
3989
|
-
},
|
|
3990
|
-
};
|
|
3991
|
-
const gltfTree = {
|
|
3992
|
-
nodes: nodesTree,
|
|
3993
|
-
};
|
|
3994
|
-
|
|
3995
|
-
const NAME = "KHR_interactivity";
|
|
3996
|
-
/**
|
|
3997
|
-
* Loader extension for KHR_interactivity
|
|
3998
|
-
*/
|
|
3999
|
-
class KHR_interactivity {
|
|
4000
|
-
/**
|
|
4001
|
-
* @internal
|
|
4002
|
-
* @param _loader
|
|
4003
|
-
*/
|
|
4004
|
-
constructor(_loader) {
|
|
4005
|
-
this._loader = _loader;
|
|
4006
|
-
/**
|
|
4007
|
-
* The name of this extension.
|
|
4008
|
-
*/
|
|
4009
|
-
this.name = NAME;
|
|
4010
|
-
this.enabled = this._loader.isExtensionUsed(NAME);
|
|
4011
|
-
this._pathConverter = new InteractivityPathToObjectConverter(this._loader.gltf);
|
|
4012
|
-
}
|
|
4013
|
-
dispose() {
|
|
4014
|
-
this._loader = null;
|
|
4015
|
-
delete this._pathConverter;
|
|
4016
|
-
}
|
|
4017
|
-
onReady() {
|
|
4018
|
-
if (!this._loader.babylonScene || !this._pathConverter) {
|
|
4019
|
-
return;
|
|
4020
|
-
}
|
|
4021
|
-
const scene = this._loader.babylonScene;
|
|
4022
|
-
const interactivityDefinition = this._loader.gltf.extensions?.KHR_interactivity;
|
|
4023
|
-
const json = convertGLTFToSerializedFlowGraph(interactivityDefinition);
|
|
4024
|
-
const coordinator = new FlowGraphCoordinator({ scene });
|
|
4025
|
-
FlowGraph.Parse(json, { coordinator, pathConverter: this._pathConverter });
|
|
4026
|
-
coordinator.start();
|
|
4027
|
-
}
|
|
4028
|
-
}
|
|
4029
|
-
unregisterGLTFExtension(NAME);
|
|
4030
|
-
registerGLTFExtension(NAME, true, (loader) => new KHR_interactivity(loader));
|
|
4031
|
-
|
|
4032
|
-
export { KHR_interactivity };
|
|
4033
|
-
//# sourceMappingURL=KHR_interactivity-Cv1s_pea.esm.js.map
|