@cwa/nuxt-edge 1.0.0-29138192.e49c1a0
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/README.md +38 -0
- package/README.template.md +32 -0
- package/dist/layer/error.vue +13 -0
- package/dist/layer/layouts/CwaRootLayout.vue +140 -0
- package/dist/layer/nuxt.config.spec.ts +10 -0
- package/dist/layer/nuxt.config.ts +3 -0
- package/dist/layer/pages/_cwa/composables/useDataList.ts +50 -0
- package/dist/layer/pages/_cwa/composables/useDataType.ts +30 -0
- package/dist/layer/pages/_cwa/composables/useDynamicPageLoader.ts +28 -0
- package/dist/layer/pages/_cwa/composables/useItemPage.ts +172 -0
- package/dist/layer/pages/_cwa/composables/useListPage.ts +43 -0
- package/dist/layer/pages/_cwa/data/[type]/[iri].vue +17 -0
- package/dist/layer/pages/_cwa/data/[type].vue +131 -0
- package/dist/layer/pages/_cwa/data/index.vue +84 -0
- package/dist/layer/pages/_cwa/layouts/[iri].vue +174 -0
- package/dist/layer/pages/_cwa/layouts.vue +77 -0
- package/dist/layer/pages/_cwa/pages/[iri].vue +11 -0
- package/dist/layer/pages/_cwa/pages.vue +129 -0
- package/dist/layer/pages/_cwa/routes.vue +72 -0
- package/dist/layer/pages/_cwa/users/[iri].vue +248 -0
- package/dist/layer/pages/_cwa/users.vue +86 -0
- package/dist/layer/pages/_cwa.vue +43 -0
- package/dist/layer/pages/forgot-password.vue +32 -0
- package/dist/layer/pages/login.vue +33 -0
- package/dist/layer/pages/reset-password/[username]/[token].vue +39 -0
- package/dist/module.d.mts +53 -0
- package/dist/module.json +13 -0
- package/dist/module.mjs +235 -0
- package/dist/runtime/admin/admin.d.ts +36 -0
- package/dist/runtime/admin/admin.js +65 -0
- package/dist/runtime/admin/manageable-resource.d.ts +41 -0
- package/dist/runtime/admin/manageable-resource.js +206 -0
- package/dist/runtime/admin/manager-tabs-resolver.d.ts +17 -0
- package/dist/runtime/admin/manager-tabs-resolver.js +51 -0
- package/dist/runtime/admin/navigation-guard.d.ts +18 -0
- package/dist/runtime/admin/navigation-guard.js +55 -0
- package/dist/runtime/admin/resource-stack-manager.d.ts +92 -0
- package/dist/runtime/admin/resource-stack-manager.js +355 -0
- package/dist/runtime/api/api-documentation.d.ts +28 -0
- package/dist/runtime/api/api-documentation.js +131 -0
- package/dist/runtime/api/auth.d.ts +85 -0
- package/dist/runtime/api/auth.js +183 -0
- package/dist/runtime/api/fetcher/cwa-fetch.d.ts +5 -0
- package/dist/runtime/api/fetcher/cwa-fetch.js +20 -0
- package/dist/runtime/api/fetcher/fetch-status-manager.d.ts +51 -0
- package/dist/runtime/api/fetcher/fetch-status-manager.js +185 -0
- package/dist/runtime/api/fetcher/fetcher.d.ts +57 -0
- package/dist/runtime/api/fetcher/fetcher.js +222 -0
- package/dist/runtime/api/fetcher/preload-headers.d.ts +6 -0
- package/dist/runtime/api/fetcher/preload-headers.js +31 -0
- package/dist/runtime/api/forms.d.ts +40 -0
- package/dist/runtime/api/forms.js +40 -0
- package/dist/runtime/api/mercure.d.ts +33 -0
- package/dist/runtime/api/mercure.js +191 -0
- package/dist/runtime/composables/component/html-content.d.ts +2 -0
- package/dist/runtime/composables/component/html-content.js +82 -0
- package/dist/runtime/composables/cwa-collection-pagination.d.ts +13 -0
- package/dist/runtime/composables/cwa-collection-pagination.js +34 -0
- package/dist/runtime/composables/cwa-collection-resource.d.ts +16 -0
- package/dist/runtime/composables/cwa-collection-resource.js +92 -0
- package/dist/runtime/composables/cwa-image.d.ts +19 -0
- package/dist/runtime/composables/cwa-image.js +43 -0
- package/dist/runtime/composables/cwa-query-bound-model.d.ts +9 -0
- package/dist/runtime/composables/cwa-query-bound-model.js +108 -0
- package/dist/runtime/composables/cwa-resource-endpoint.d.ts +5 -0
- package/dist/runtime/composables/cwa-resource-endpoint.js +36 -0
- package/dist/runtime/composables/cwa-resource-manageable.d.ts +10 -0
- package/dist/runtime/composables/cwa-resource-manageable.js +32 -0
- package/dist/runtime/composables/cwa-resource-manager-tab.d.ts +17 -0
- package/dist/runtime/composables/cwa-resource-manager-tab.js +30 -0
- package/dist/runtime/composables/cwa-resource-model.d.ts +21 -0
- package/dist/runtime/composables/cwa-resource-model.js +149 -0
- package/dist/runtime/composables/cwa-resource-upload.d.ts +8 -0
- package/dist/runtime/composables/cwa-resource-upload.js +70 -0
- package/dist/runtime/composables/cwa-resource.d.ts +24 -0
- package/dist/runtime/composables/cwa-resource.js +22 -0
- package/dist/runtime/composables/cwa-select-input.d.ts +21 -0
- package/dist/runtime/composables/cwa-select-input.js +37 -0
- package/dist/runtime/composables/cwa-select.d.ts +15 -0
- package/dist/runtime/composables/cwa-select.js +24 -0
- package/dist/runtime/composables/cwa.d.ts +2 -0
- package/dist/runtime/composables/cwa.js +2 -0
- package/dist/runtime/composables/forgot-password.d.ts +9 -0
- package/dist/runtime/composables/forgot-password.js +45 -0
- package/dist/runtime/composables/login.d.ts +9 -0
- package/dist/runtime/composables/login.js +30 -0
- package/dist/runtime/composables/popper.d.ts +529 -0
- package/dist/runtime/composables/popper.js +104 -0
- package/dist/runtime/composables/process.d.ts +4 -0
- package/dist/runtime/composables/process.js +6 -0
- package/dist/runtime/composables/reset-password.d.ts +14 -0
- package/dist/runtime/composables/reset-password.js +75 -0
- package/dist/runtime/composables/transitions.d.ts +12 -0
- package/dist/runtime/composables/transitions.js +12 -0
- package/dist/runtime/cwa.d.ts +61 -0
- package/dist/runtime/cwa.js +123 -0
- package/dist/runtime/errors/cwa-resource-error.d.ts +18 -0
- package/dist/runtime/errors/cwa-resource-error.js +54 -0
- package/dist/runtime/plugin.d.ts +7 -0
- package/dist/runtime/plugin.js +18 -0
- package/dist/runtime/resources/resource-utils.d.ts +44 -0
- package/dist/runtime/resources/resource-utils.js +73 -0
- package/dist/runtime/resources/resources-manager.d.ts +70 -0
- package/dist/runtime/resources/resources-manager.js +463 -0
- package/dist/runtime/resources/resources.d.ts +53 -0
- package/dist/runtime/resources/resources.js +300 -0
- package/dist/runtime/route-middleware.d.ts +2 -0
- package/dist/runtime/route-middleware.js +86 -0
- package/dist/runtime/storage/storage.d.ts +20 -0
- package/dist/runtime/storage/storage.js +25 -0
- package/dist/runtime/storage/stores/admin/actions.d.ts +5 -0
- package/dist/runtime/storage/stores/admin/actions.js +10 -0
- package/dist/runtime/storage/stores/admin/admin-store.d.ts +18 -0
- package/dist/runtime/storage/stores/admin/admin-store.js +20 -0
- package/dist/runtime/storage/stores/admin/state.d.ts +7 -0
- package/dist/runtime/storage/stores/admin/state.js +9 -0
- package/dist/runtime/storage/stores/api-documentation/api-documentation-store.d.ts +16 -0
- package/dist/runtime/storage/stores/api-documentation/api-documentation-store.js +18 -0
- package/dist/runtime/storage/stores/api-documentation/state.d.ts +74 -0
- package/dist/runtime/storage/stores/api-documentation/state.js +6 -0
- package/dist/runtime/storage/stores/auth/auth-store.d.ts +16 -0
- package/dist/runtime/storage/stores/auth/auth-store.js +18 -0
- package/dist/runtime/storage/stores/auth/state.d.ts +20 -0
- package/dist/runtime/storage/stores/auth/state.js +15 -0
- package/dist/runtime/storage/stores/cwa-store-types.d.ts +14 -0
- package/dist/runtime/storage/stores/error/actions.d.ts +11 -0
- package/dist/runtime/storage/stores/error/actions.js +69 -0
- package/dist/runtime/storage/stores/error/error-store.d.ts +13 -0
- package/dist/runtime/storage/stores/error/error-store.js +21 -0
- package/dist/runtime/storage/stores/error/getters.d.ts +7 -0
- package/dist/runtime/storage/stores/error/getters.js +11 -0
- package/dist/runtime/storage/stores/error/state.d.ts +35 -0
- package/dist/runtime/storage/stores/error/state.js +15 -0
- package/dist/runtime/storage/stores/fetcher/actions.d.ts +49 -0
- package/dist/runtime/storage/stores/fetcher/actions.js +125 -0
- package/dist/runtime/storage/stores/fetcher/fetcher-store.d.ts +19 -0
- package/dist/runtime/storage/stores/fetcher/fetcher-store.js +23 -0
- package/dist/runtime/storage/stores/fetcher/getter-utils.d.ts +7 -0
- package/dist/runtime/storage/stores/fetcher/getter-utils.js +27 -0
- package/dist/runtime/storage/stores/fetcher/getters.d.ts +13 -0
- package/dist/runtime/storage/stores/fetcher/getters.js +52 -0
- package/dist/runtime/storage/stores/fetcher/state.d.ts +25 -0
- package/dist/runtime/storage/stores/fetcher/state.js +7 -0
- package/dist/runtime/storage/stores/mercure/mercure-store.d.ts +16 -0
- package/dist/runtime/storage/stores/mercure/mercure-store.js +18 -0
- package/dist/runtime/storage/stores/mercure/state.d.ts +5 -0
- package/dist/runtime/storage/stores/mercure/state.js +6 -0
- package/dist/runtime/storage/stores/resources/actions.d.ts +54 -0
- package/dist/runtime/storage/stores/resources/actions.js +390 -0
- package/dist/runtime/storage/stores/resources/getter-utils.d.ts +7 -0
- package/dist/runtime/storage/stores/resources/getter-utils.js +27 -0
- package/dist/runtime/storage/stores/resources/getters.d.ts +38 -0
- package/dist/runtime/storage/stores/resources/getters.js +251 -0
- package/dist/runtime/storage/stores/resources/resources-store.d.ts +19 -0
- package/dist/runtime/storage/stores/resources/resources-store.js +23 -0
- package/dist/runtime/storage/stores/resources/state.d.ts +64 -0
- package/dist/runtime/storage/stores/resources/state.js +24 -0
- package/dist/runtime/templates/assets/base.css +1 -0
- package/dist/runtime/templates/assets/cwa.css +1 -0
- package/dist/runtime/templates/components/core/ComponentPlaceholder.vue +18 -0
- package/dist/runtime/templates/components/core/ComponentPlaceholder.vue.d.ts +3 -0
- package/dist/runtime/templates/components/core/ComponentPosition.spec.ts.snap +16 -0
- package/dist/runtime/templates/components/core/ComponentPosition.vue +63 -0
- package/dist/runtime/templates/components/core/ComponentPosition.vue.d.ts +3 -0
- package/dist/runtime/templates/components/core/ConfirmDialog.vue +41 -0
- package/dist/runtime/templates/components/core/ConfirmDialog.vue.d.ts +9 -0
- package/dist/runtime/templates/components/core/DialogBox.vue +95 -0
- package/dist/runtime/templates/components/core/DialogBox.vue.d.ts +38 -0
- package/dist/runtime/templates/components/core/README.md +1 -0
- package/dist/runtime/templates/components/core/ResourceLoader.spec.ts.snap +39 -0
- package/dist/runtime/templates/components/core/ResourceLoader.vue +151 -0
- package/dist/runtime/templates/components/core/ResourceLoader.vue.d.ts +13 -0
- package/dist/runtime/templates/components/core/admin/ListContainer.vue +7 -0
- package/dist/runtime/templates/components/core/admin/ListContainer.vue.d.ts +12 -0
- package/dist/runtime/templates/components/core/admin/ListContent.vue +136 -0
- package/dist/runtime/templates/components/core/admin/ListContent.vue.d.ts +21 -0
- package/dist/runtime/templates/components/core/admin/ListFilter.vue +49 -0
- package/dist/runtime/templates/components/core/admin/ListFilter.vue.d.ts +9 -0
- package/dist/runtime/templates/components/core/admin/ListFilterButton.vue +53 -0
- package/dist/runtime/templates/components/core/admin/ListFilterButton.vue.d.ts +9 -0
- package/dist/runtime/templates/components/core/admin/ListHeading.vue +32 -0
- package/dist/runtime/templates/components/core/admin/ListHeading.vue.d.ts +20 -0
- package/dist/runtime/templates/components/core/admin/ListPagination.vue +87 -0
- package/dist/runtime/templates/components/core/admin/ListPagination.vue.d.ts +15 -0
- package/dist/runtime/templates/components/core/admin/ListPaginationButton.vue +18 -0
- package/dist/runtime/templates/components/core/admin/ListPaginationButton.vue.d.ts +16 -0
- package/dist/runtime/templates/components/core/admin/PageAdminModal.vue +260 -0
- package/dist/runtime/templates/components/core/admin/PageAdminModal.vue.d.ts +12 -0
- package/dist/runtime/templates/components/core/admin/PageDataAdminModal.vue +187 -0
- package/dist/runtime/templates/components/core/admin/PageDataAdminModal.vue.d.ts +13 -0
- package/dist/runtime/templates/components/core/admin/ResourceModal.vue +99 -0
- package/dist/runtime/templates/components/core/admin/ResourceModal.vue.d.ts +27 -0
- package/dist/runtime/templates/components/core/admin/ResourceModalOverlay.vue +27 -0
- package/dist/runtime/templates/components/core/admin/ResourceModalOverlay.vue.d.ts +6 -0
- package/dist/runtime/templates/components/core/admin/ResourceModalOverlayTemplate.vue +23 -0
- package/dist/runtime/templates/components/core/admin/ResourceModalOverlayTemplate.vue.d.ts +15 -0
- package/dist/runtime/templates/components/core/admin/ResourceModalTabs.vue +77 -0
- package/dist/runtime/templates/components/core/admin/ResourceModalTabs.vue.d.ts +19 -0
- package/dist/runtime/templates/components/core/admin/RouteListRow.vue +102 -0
- package/dist/runtime/templates/components/core/admin/RouteListRow.vue.d.ts +20 -0
- package/dist/runtime/templates/components/core/admin/RouteRedirectsTree.vue +52 -0
- package/dist/runtime/templates/components/core/admin/RouteRedirectsTree.vue.d.ts +10 -0
- package/dist/runtime/templates/components/core/admin/RoutesTab.vue +273 -0
- package/dist/runtime/templates/components/core/admin/RoutesTab.vue.d.ts +12 -0
- package/dist/runtime/templates/components/core/admin/form/FilterFormWrapper.vue +18 -0
- package/dist/runtime/templates/components/core/admin/form/FilterFormWrapper.vue.d.ts +16 -0
- package/dist/runtime/templates/components/core/admin/form/FilterSelect.vue +86 -0
- package/dist/runtime/templates/components/core/admin/form/FilterSelect.vue.d.ts +3 -0
- package/dist/runtime/templates/components/core/admin/form/ModalInfo.vue +23 -0
- package/dist/runtime/templates/components/core/admin/form/ModalInfo.vue.d.ts +16 -0
- package/dist/runtime/templates/components/core/admin/form/ModalInput.vue +30 -0
- package/dist/runtime/templates/components/core/admin/form/ModalInput.vue.d.ts +15 -0
- package/dist/runtime/templates/components/core/admin/form/ModalSelect.vue +99 -0
- package/dist/runtime/templates/components/core/admin/form/ModalSelect.vue.d.ts +6 -0
- package/dist/runtime/templates/components/core/admin/form/PageTypeSelect.vue +112 -0
- package/dist/runtime/templates/components/core/admin/form/PageTypeSelect.vue.d.ts +4 -0
- package/dist/runtime/templates/components/core/assets/CwaLogo.vue +21 -0
- package/dist/runtime/templates/components/core/assets/CwaLogo.vue.d.ts +2 -0
- package/dist/runtime/templates/components/core/assets/IconComponents.vue +15 -0
- package/dist/runtime/templates/components/core/assets/IconComponents.vue.d.ts +2 -0
- package/dist/runtime/templates/components/core/assets/IconData.vue +24 -0
- package/dist/runtime/templates/components/core/assets/IconData.vue.d.ts +2 -0
- package/dist/runtime/templates/components/core/assets/IconLayouts.vue +20 -0
- package/dist/runtime/templates/components/core/assets/IconLayouts.vue.d.ts +2 -0
- package/dist/runtime/templates/components/core/assets/IconPages.vue +21 -0
- package/dist/runtime/templates/components/core/assets/IconPages.vue.d.ts +2 -0
- package/dist/runtime/templates/components/core/assets/IconRoutes.vue +23 -0
- package/dist/runtime/templates/components/core/assets/IconRoutes.vue.d.ts +2 -0
- package/dist/runtime/templates/components/core/assets/IconUsers.vue +13 -0
- package/dist/runtime/templates/components/core/assets/IconUsers.vue.d.ts +2 -0
- package/dist/runtime/templates/components/core/useDataResolver.d.ts +12 -0
- package/dist/runtime/templates/components/core/useDataResolver.js +109 -0
- package/dist/runtime/templates/components/main/ComponentGroup.Util.Positions.d.ts +6 -0
- package/dist/runtime/templates/components/main/ComponentGroup.Util.Positions.js +164 -0
- package/dist/runtime/templates/components/main/ComponentGroup.Util.Synchronizer.d.ts +20 -0
- package/dist/runtime/templates/components/main/ComponentGroup.Util.Synchronizer.js +69 -0
- package/dist/runtime/templates/components/main/ComponentGroup.spec.ts.snap +59 -0
- package/dist/runtime/templates/components/main/ComponentGroup.vue +107 -0
- package/dist/runtime/templates/components/main/ComponentGroup.vue.d.ts +9 -0
- package/dist/runtime/templates/components/main/CwaLink.vue +51 -0
- package/dist/runtime/templates/components/main/CwaLink.vue.d.ts +14 -0
- package/dist/runtime/templates/components/main/DefaultLayout.vue +8 -0
- package/dist/runtime/templates/components/main/DefaultLayout.vue.d.ts +12 -0
- package/dist/runtime/templates/components/main/ErrorPage.vue +98 -0
- package/dist/runtime/templates/components/main/ErrorPage.vue.d.ts +6 -0
- package/dist/runtime/templates/components/main/Logo.vue +18 -0
- package/dist/runtime/templates/components/main/Logo.vue.d.ts +2 -0
- package/dist/runtime/templates/components/main/README.md +7 -0
- package/dist/runtime/templates/components/main/admin/_common/ResourceContextItem.vue +41 -0
- package/dist/runtime/templates/components/main/admin/_common/ResourceContextItem.vue.d.ts +7 -0
- package/dist/runtime/templates/components/main/admin/_common/ResourceLoadingIndicator.vue +48 -0
- package/dist/runtime/templates/components/main/admin/_common/ResourceLoadingIndicator.vue.d.ts +2 -0
- package/dist/runtime/templates/components/main/admin/_common/useDynamicPositionSelectOptions.d.ts +5 -0
- package/dist/runtime/templates/components/main/admin/_common/useDynamicPositionSelectOptions.js +19 -0
- package/dist/runtime/templates/components/main/admin/header/Header.vue +207 -0
- package/dist/runtime/templates/components/main/admin/header/Header.vue.d.ts +2 -0
- package/dist/runtime/templates/components/main/admin/header/_parts/Menu.vue +189 -0
- package/dist/runtime/templates/components/main/admin/header/_parts/Menu.vue.d.ts +2 -0
- package/dist/runtime/templates/components/main/admin/header/_parts/MenuLink.vue +14 -0
- package/dist/runtime/templates/components/main/admin/header/_parts/MenuLink.vue.d.ts +16 -0
- package/dist/runtime/templates/components/main/admin/header/_parts/MenuPrimaryLink.vue +19 -0
- package/dist/runtime/templates/components/main/admin/header/_parts/MenuPrimaryLink.vue.d.ts +15 -0
- package/dist/runtime/templates/components/main/admin/header/_parts/Notification.vue +69 -0
- package/dist/runtime/templates/components/main/admin/header/_parts/Notification.vue.d.ts +12 -0
- package/dist/runtime/templates/components/main/admin/header/_parts/OutdatedContentNotice.vue +19 -0
- package/dist/runtime/templates/components/main/admin/header/_parts/OutdatedContentNotice.vue.d.ts +2 -0
- package/dist/runtime/templates/components/main/admin/header/_parts/PathSelector.vue +79 -0
- package/dist/runtime/templates/components/main/admin/header/_parts/PathSelector.vue.d.ts +2 -0
- package/dist/runtime/templates/components/main/admin/header/_parts/RequestErrors.vue +52 -0
- package/dist/runtime/templates/components/main/admin/header/_parts/RequestErrors.vue.d.ts +2 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/ComponentFocus.vue +151 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/ComponentFocus.vue.d.ts +10 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/LayoutPageOverlay.vue +192 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/LayoutPageOverlay.vue.d.ts +6 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/ResourceManager.vue +186 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/ResourceManager.vue.d.ts +9 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_parts/AddComponentDialog.vue +205 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_parts/AddComponentDialog.vue.d.ts +2 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_parts/CwaResourceManagerContextMenu.vue +38 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_parts/CwaResourceManagerContextMenu.vue.d.ts +6 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_parts/ManagerTab.vue +15 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_parts/ManagerTab.vue.d.ts +7 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_parts/ManagerTabs.vue +44 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_parts/ManagerTabs.vue.d.ts +13 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_tabs/ResourceInfoTab.vue +59 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_tabs/ResourceInfoTab.vue.d.ts +6 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_tabs/component/Order.vue +75 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_tabs/component/Order.vue.d.ts +6 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_tabs/component/Publish.vue +41 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_tabs/component/Publish.vue.d.ts +6 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_tabs/component/Ui.vue +101 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_tabs/component/Ui.vue.d.ts +6 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_tabs/group/Group.vue +34 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_tabs/group/Group.vue.d.ts +6 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_tabs/position/DataPage.vue +121 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_tabs/position/DataPage.vue.d.ts +6 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_tabs/position/DynamicPage.vue +52 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/_tabs/position/DynamicPage.vue.d.ts +6 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/cta/CurrentResourceCta.vue +99 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/cta/CurrentResourceCta.vue.d.ts +7 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/cta/NewResourceCta.vue +59 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/cta/NewResourceCta.vue.d.ts +7 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/cta/ResourceManagerCtaButton.vue +28 -0
- package/dist/runtime/templates/components/main/admin/resource-manager/cta/ResourceManagerCtaButton.vue.d.ts +2 -0
- package/dist/runtime/templates/components/main/auth/ForgotPasswordPage.vue +55 -0
- package/dist/runtime/templates/components/main/auth/ForgotPasswordPage.vue.d.ts +20 -0
- package/dist/runtime/templates/components/main/auth/LoginPage.vue +60 -0
- package/dist/runtime/templates/components/main/auth/LoginPage.vue.d.ts +23 -0
- package/dist/runtime/templates/components/main/auth/ResetPasswordPage.vue +59 -0
- package/dist/runtime/templates/components/main/auth/ResetPasswordPage.vue.d.ts +27 -0
- package/dist/runtime/templates/components/main/auth/_parts/AuthPageLink.spec.ts.snap +14 -0
- package/dist/runtime/templates/components/main/auth/_parts/AuthPageLink.vue +17 -0
- package/dist/runtime/templates/components/main/auth/_parts/AuthPageLink.vue.d.ts +6 -0
- package/dist/runtime/templates/components/main/auth/_parts/AuthTemplate.spec.ts.snap +90 -0
- package/dist/runtime/templates/components/main/auth/_parts/AuthTemplate.vue +45 -0
- package/dist/runtime/templates/components/main/auth/_parts/AuthTemplate.vue.d.ts +17 -0
- package/dist/runtime/templates/components/main/auth/_parts/InputField.spec.ts.snap +111 -0
- package/dist/runtime/templates/components/main/auth/_parts/InputField.vue +50 -0
- package/dist/runtime/templates/components/main/auth/_parts/InputField.vue.d.ts +17 -0
- package/dist/runtime/templates/components/ui/BackgroundParticles.vue +960 -0
- package/dist/runtime/templates/components/ui/BackgroundParticles.vue.d.ts +2 -0
- package/dist/runtime/templates/components/ui/Hamburger.vue +75 -0
- package/dist/runtime/templates/components/ui/Hamburger.vue.d.ts +9 -0
- package/dist/runtime/templates/components/ui/ProgressBar.spec.ts.snap +71 -0
- package/dist/runtime/templates/components/ui/ProgressBar.vue +29 -0
- package/dist/runtime/templates/components/ui/ProgressBar.vue.d.ts +9 -0
- package/dist/runtime/templates/components/ui/README.md +6 -0
- package/dist/runtime/templates/components/ui/alert/Info.spec.ts.snap +23 -0
- package/dist/runtime/templates/components/ui/alert/Info.vue +13 -0
- package/dist/runtime/templates/components/ui/alert/Info.vue.d.ts +12 -0
- package/dist/runtime/templates/components/ui/alert/Warning.spec.ts.snap +14 -0
- package/dist/runtime/templates/components/ui/alert/Warning.vue +8 -0
- package/dist/runtime/templates/components/ui/alert/Warning.vue.d.ts +12 -0
- package/dist/runtime/templates/components/ui/form/Button.vue +139 -0
- package/dist/runtime/templates/components/ui/form/Button.vue.d.ts +52 -0
- package/dist/runtime/templates/components/ui/form/ButtonPopoverGroup.vue +18 -0
- package/dist/runtime/templates/components/ui/form/ButtonPopoverGroup.vue.d.ts +10 -0
- package/dist/runtime/templates/components/ui/form/ButtonPopoverItem.vue +15 -0
- package/dist/runtime/templates/components/ui/form/ButtonPopoverItem.vue.d.ts +10 -0
- package/dist/runtime/templates/components/ui/form/File.vue +72 -0
- package/dist/runtime/templates/components/ui/form/File.vue.d.ts +9 -0
- package/dist/runtime/templates/components/ui/form/Input.vue +22 -0
- package/dist/runtime/templates/components/ui/form/Input.vue.d.ts +5 -0
- package/dist/runtime/templates/components/ui/form/LabelWrapper.vue +16 -0
- package/dist/runtime/templates/components/ui/form/LabelWrapper.vue.d.ts +15 -0
- package/dist/runtime/templates/components/ui/form/SearchResource.vue +212 -0
- package/dist/runtime/templates/components/ui/form/SearchResource.vue.d.ts +14 -0
- package/dist/runtime/templates/components/ui/form/Select.vue +60 -0
- package/dist/runtime/templates/components/ui/form/Select.vue.d.ts +3 -0
- package/dist/runtime/templates/components/ui/form/Toggle.vue +39 -0
- package/dist/runtime/templates/components/ui/form/Toggle.vue.d.ts +6 -0
- package/dist/runtime/templates/components/ui/icon/ArrowIcon.vue +30 -0
- package/dist/runtime/templates/components/ui/icon/ArrowIcon.vue.d.ts +2 -0
- package/dist/runtime/templates/components/ui/icon/BinIcon.vue +24 -0
- package/dist/runtime/templates/components/ui/icon/BinIcon.vue.d.ts +2 -0
- package/dist/runtime/templates/components/ui/icon/CogIcon.vue +9 -0
- package/dist/runtime/templates/components/ui/icon/CogIcon.vue.d.ts +2 -0
- package/dist/runtime/templates/components/ui/icon/EyeIcon.vue +24 -0
- package/dist/runtime/templates/components/ui/icon/EyeIcon.vue.d.ts +2 -0
- package/dist/runtime/templates/components/ui/icon/PenIcon.vue +12 -0
- package/dist/runtime/templates/components/ui/icon/PenIcon.vue.d.ts +2 -0
- package/dist/runtime/templates/components/ui/icon/PlusIcon.vue +9 -0
- package/dist/runtime/templates/components/ui/icon/PlusIcon.vue.d.ts +2 -0
- package/dist/runtime/templates/components/ui/icon/SearchIcon.vue +10 -0
- package/dist/runtime/templates/components/ui/icon/SearchIcon.vue.d.ts +2 -0
- package/dist/runtime/templates/components/ui/icon/TickIcon.vue +23 -0
- package/dist/runtime/templates/components/ui/icon/TickIcon.vue.d.ts +2 -0
- package/dist/runtime/templates/components/ui/icon/WarningIcon.vue +11 -0
- package/dist/runtime/templates/components/ui/icon/WarningIcon.vue.d.ts +2 -0
- package/dist/runtime/templates/components/ui/icon/XMarkIcon.vue +15 -0
- package/dist/runtime/templates/components/ui/icon/XMarkIcon.vue.d.ts +2 -0
- package/dist/runtime/templates/components/utils/ContextMenu.vue +59 -0
- package/dist/runtime/templates/components/utils/ContextMenu.vue.d.ts +21 -0
- package/dist/runtime/templates/components/utils/HotSpot.vue +24 -0
- package/dist/runtime/templates/components/utils/HotSpot.vue.d.ts +9 -0
- package/dist/runtime/templates/components/utils/README.md +1 -0
- package/dist/runtime/templates/components/utils/Spinner.spec.ts.snap +56 -0
- package/dist/runtime/templates/components/utils/Spinner.vue +42 -0
- package/dist/runtime/templates/components/utils/Spinner.vue.d.ts +5 -0
- package/dist/runtime/templates/components/utils/SpinnerTick.vue +43 -0
- package/dist/runtime/templates/components/utils/SpinnerTick.vue.d.ts +6 -0
- package/dist/runtime/templates/cwa-page.spec.ts.snap +20 -0
- package/dist/runtime/templates/cwa-page.vue +32 -0
- package/dist/runtime/templates/cwa-page.vue.d.ts +2 -0
- package/dist/runtime/types/popper.d.ts +14 -0
- package/dist/types.d.mts +9 -0
- package/package.json +108 -0
|
@@ -0,0 +1,960 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
id="particles-container"
|
|
4
|
+
ref="particlesContainer"
|
|
5
|
+
>
|
|
6
|
+
<canvas ref="canvasElement" />
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup>
|
|
11
|
+
import { onBeforeUnmount, onMounted, ref, useTemplateRef } from "vue";
|
|
12
|
+
const particlesContainer = useTemplateRef("particlesContainer");
|
|
13
|
+
const canvasElement = ref();
|
|
14
|
+
class ParticleCanvasMetaFactory {
|
|
15
|
+
canvas;
|
|
16
|
+
context;
|
|
17
|
+
meta;
|
|
18
|
+
constructor(canvas) {
|
|
19
|
+
this.canvas = canvas;
|
|
20
|
+
this.context = this.getRenderingContext();
|
|
21
|
+
this.meta = this.getMetaFromContext(this.context);
|
|
22
|
+
canvas.width = canvas.clientWidth;
|
|
23
|
+
canvas.height = canvas.clientHeight;
|
|
24
|
+
this.canvas = canvas;
|
|
25
|
+
}
|
|
26
|
+
getCanvas() {
|
|
27
|
+
return this.canvas;
|
|
28
|
+
}
|
|
29
|
+
getMeta() {
|
|
30
|
+
return this.meta;
|
|
31
|
+
}
|
|
32
|
+
getRenderingContext() {
|
|
33
|
+
const ops = {
|
|
34
|
+
alpha: true,
|
|
35
|
+
depth: false,
|
|
36
|
+
stencil: false,
|
|
37
|
+
antialias: false
|
|
38
|
+
};
|
|
39
|
+
const gl2 = this.canvas.getContext("webgl2", ops);
|
|
40
|
+
const gl = this.canvas.getContext("webgl", ops);
|
|
41
|
+
if (gl2 && gl2 instanceof WebGL2RenderingContext) {
|
|
42
|
+
return {
|
|
43
|
+
gl: gl2,
|
|
44
|
+
isWebGL2: true
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (gl && gl instanceof WebGLRenderingContext) {
|
|
48
|
+
return {
|
|
49
|
+
gl,
|
|
50
|
+
isWebGL2: false
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
isRenderTextureFormatSupported(gl, internalFormat, format, type) {
|
|
55
|
+
const texture = gl.createTexture();
|
|
56
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
57
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
|
|
58
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
|
|
59
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
60
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
61
|
+
gl.texImage2D(
|
|
62
|
+
gl.TEXTURE_2D,
|
|
63
|
+
0,
|
|
64
|
+
internalFormat,
|
|
65
|
+
4,
|
|
66
|
+
4,
|
|
67
|
+
0,
|
|
68
|
+
format,
|
|
69
|
+
type,
|
|
70
|
+
null
|
|
71
|
+
);
|
|
72
|
+
const fbo = gl.createFramebuffer();
|
|
73
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
|
|
74
|
+
gl.framebufferTexture2D(
|
|
75
|
+
gl.FRAMEBUFFER,
|
|
76
|
+
gl.COLOR_ATTACHMENT0,
|
|
77
|
+
gl.TEXTURE_2D,
|
|
78
|
+
texture,
|
|
79
|
+
0
|
|
80
|
+
);
|
|
81
|
+
const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
|
|
82
|
+
return status === gl.FRAMEBUFFER_COMPLETE;
|
|
83
|
+
}
|
|
84
|
+
getSupportedFormat(gl, internalFormat, format, type) {
|
|
85
|
+
if (!this.isRenderTextureFormatSupported(gl, internalFormat, format, type)) {
|
|
86
|
+
if (!(gl instanceof WebGL2RenderingContext)) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
switch (internalFormat) {
|
|
90
|
+
case gl.R16F:
|
|
91
|
+
return this.getSupportedFormat(gl, gl.RG16F, gl.RG, type);
|
|
92
|
+
case gl.RG16F:
|
|
93
|
+
return this.getSupportedFormat(gl, gl.RGBA16F, gl.RGBA, type);
|
|
94
|
+
default:
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
internalFormat,
|
|
100
|
+
format
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
getWebGLMeta(gl) {
|
|
104
|
+
const halfFloat = gl.getExtension("OES_texture_half_float");
|
|
105
|
+
if (!halfFloat) {
|
|
106
|
+
throw Error("Cannot get half float extension");
|
|
107
|
+
}
|
|
108
|
+
const supportLinearFiltering = !!gl.getExtension("OES_texture_half_float_linear");
|
|
109
|
+
const halfFloatTexType = halfFloat.HALF_FLOAT_OES;
|
|
110
|
+
const formatRGBA = this.getSupportedFormat(gl, gl.RGBA, gl.RGBA, halfFloatTexType);
|
|
111
|
+
const formatRG = this.getSupportedFormat(gl, gl.RGBA, gl.RGBA, halfFloatTexType);
|
|
112
|
+
const formatR = this.getSupportedFormat(gl, gl.RGBA, gl.RGBA, halfFloatTexType);
|
|
113
|
+
return {
|
|
114
|
+
formatRGBA,
|
|
115
|
+
formatRG,
|
|
116
|
+
formatR,
|
|
117
|
+
halfFloatTexType,
|
|
118
|
+
supportLinearFiltering
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
getWebGL2Meta(gl) {
|
|
122
|
+
gl.getExtension("EXT_color_buffer_float");
|
|
123
|
+
const supportLinearFiltering = !!gl.getExtension("OES_texture_float_linear");
|
|
124
|
+
const halfFloatTexType = gl.HALF_FLOAT;
|
|
125
|
+
const formatRGBA = this.getSupportedFormat(
|
|
126
|
+
gl,
|
|
127
|
+
gl.RGBA16F,
|
|
128
|
+
gl.RGBA,
|
|
129
|
+
halfFloatTexType
|
|
130
|
+
);
|
|
131
|
+
const formatRG = this.getSupportedFormat(gl, gl.RG16F, gl.RG, halfFloatTexType);
|
|
132
|
+
const formatR = this.getSupportedFormat(gl, gl.R16F, gl.RED, halfFloatTexType);
|
|
133
|
+
return {
|
|
134
|
+
formatRGBA,
|
|
135
|
+
formatRG,
|
|
136
|
+
formatR,
|
|
137
|
+
halfFloatTexType,
|
|
138
|
+
supportLinearFiltering
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
getMetaFromContext(context) {
|
|
142
|
+
if (!context) {
|
|
143
|
+
throw Error("Cannot get meta from context. Context is undefined.");
|
|
144
|
+
}
|
|
145
|
+
const { gl, isWebGL2 } = context;
|
|
146
|
+
gl.clearColor(0, 0, 0, 0);
|
|
147
|
+
return {
|
|
148
|
+
gl,
|
|
149
|
+
ext: isWebGL2 ? this.getWebGL2Meta(gl) : this.getWebGLMeta(gl)
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
class PointerPrototype {
|
|
154
|
+
id = -1;
|
|
155
|
+
x = 0;
|
|
156
|
+
y = 0;
|
|
157
|
+
dx = 0;
|
|
158
|
+
dy = 0;
|
|
159
|
+
down = false;
|
|
160
|
+
moved = false;
|
|
161
|
+
color = [30, 0, 300];
|
|
162
|
+
}
|
|
163
|
+
class GLProgram {
|
|
164
|
+
uniforms;
|
|
165
|
+
program;
|
|
166
|
+
gl;
|
|
167
|
+
constructor(gl, vertexShader, fragmentShader) {
|
|
168
|
+
this.gl = gl;
|
|
169
|
+
this.uniforms = {};
|
|
170
|
+
this.program = gl.createProgram();
|
|
171
|
+
gl.attachShader(this.program, vertexShader);
|
|
172
|
+
gl.attachShader(this.program, fragmentShader);
|
|
173
|
+
gl.linkProgram(this.program);
|
|
174
|
+
if (!gl.getProgramParameter(this.program, gl.LINK_STATUS))
|
|
175
|
+
throw gl.getProgramInfoLog(this.program);
|
|
176
|
+
const uniformCount = gl.getProgramParameter(
|
|
177
|
+
this.program,
|
|
178
|
+
gl.ACTIVE_UNIFORMS
|
|
179
|
+
);
|
|
180
|
+
for (let i = 0; i < uniformCount; i++) {
|
|
181
|
+
const uniformName = gl.getActiveUniform(this.program, i)?.name;
|
|
182
|
+
if (!uniformName) {
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
this.uniforms[uniformName] = gl.getUniformLocation(
|
|
186
|
+
this.program,
|
|
187
|
+
uniformName
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
bind() {
|
|
192
|
+
this.gl.useProgram(this.program);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
class ParticleProgram {
|
|
196
|
+
config;
|
|
197
|
+
// pointers are for the mouse cursor, or on touch for each touch point
|
|
198
|
+
pointers = [new PointerPrototype()];
|
|
199
|
+
glMeta;
|
|
200
|
+
shaders;
|
|
201
|
+
textureWidth = 0;
|
|
202
|
+
textureHeight = 0;
|
|
203
|
+
density;
|
|
204
|
+
velocity;
|
|
205
|
+
divergence;
|
|
206
|
+
curl;
|
|
207
|
+
pressure;
|
|
208
|
+
programs;
|
|
209
|
+
blit;
|
|
210
|
+
stopped = false;
|
|
211
|
+
lastTime = 0;
|
|
212
|
+
canvas;
|
|
213
|
+
container;
|
|
214
|
+
splatStack = [];
|
|
215
|
+
constructor(config, glMeta, canvas) {
|
|
216
|
+
this.config = config;
|
|
217
|
+
this.glMeta = glMeta;
|
|
218
|
+
this.canvas = canvas;
|
|
219
|
+
this.shaders = this.getShaders();
|
|
220
|
+
this.initFrameBuffers();
|
|
221
|
+
this.programs = this.createPrograms();
|
|
222
|
+
this.blit = this.createBlitFn();
|
|
223
|
+
this.updateAnimation = this.updateAnimation.bind(this);
|
|
224
|
+
this.mousemove = this.mousemove.bind(this);
|
|
225
|
+
this.touchmove = this.touchmove.bind(this);
|
|
226
|
+
this.touchstart = this.touchstart.bind(this);
|
|
227
|
+
this.touchend = this.touchend.bind(this);
|
|
228
|
+
this.mouseleave = this.mouseleave.bind(this);
|
|
229
|
+
}
|
|
230
|
+
getShaders() {
|
|
231
|
+
const { gl } = this.glMeta;
|
|
232
|
+
const baseVertexShader = this.compileShader(
|
|
233
|
+
gl.VERTEX_SHADER,
|
|
234
|
+
`
|
|
235
|
+
precision highp float;
|
|
236
|
+
precision mediump sampler2D;
|
|
237
|
+
|
|
238
|
+
attribute vec2 aPosition;
|
|
239
|
+
varying vec2 vUv;
|
|
240
|
+
varying vec2 vL;
|
|
241
|
+
varying vec2 vR;
|
|
242
|
+
varying vec2 vT;
|
|
243
|
+
varying vec2 vB;
|
|
244
|
+
uniform vec2 texelSize;
|
|
245
|
+
|
|
246
|
+
void main () {
|
|
247
|
+
vUv = aPosition * 0.5 + 0.5;
|
|
248
|
+
vL = vUv - vec2(texelSize.x, 0.0);
|
|
249
|
+
vR = vUv + vec2(texelSize.x, 0.0);
|
|
250
|
+
vT = vUv + vec2(0.0, texelSize.y);
|
|
251
|
+
vB = vUv - vec2(0.0, texelSize.y);
|
|
252
|
+
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
253
|
+
}
|
|
254
|
+
`
|
|
255
|
+
);
|
|
256
|
+
const clearShader = this.compileShader(
|
|
257
|
+
gl.FRAGMENT_SHADER,
|
|
258
|
+
`
|
|
259
|
+
precision highp float;
|
|
260
|
+
precision mediump sampler2D;
|
|
261
|
+
|
|
262
|
+
varying vec2 vUv;
|
|
263
|
+
uniform sampler2D uTexture;
|
|
264
|
+
uniform float value;
|
|
265
|
+
|
|
266
|
+
void main () {
|
|
267
|
+
gl_FragColor = value * texture2D(uTexture, vUv);
|
|
268
|
+
}
|
|
269
|
+
`
|
|
270
|
+
);
|
|
271
|
+
const displayShader = this.compileShader(
|
|
272
|
+
gl.FRAGMENT_SHADER,
|
|
273
|
+
`
|
|
274
|
+
precision highp float;
|
|
275
|
+
precision mediump sampler2D;
|
|
276
|
+
|
|
277
|
+
varying vec2 vUv;
|
|
278
|
+
uniform sampler2D uTexture;
|
|
279
|
+
|
|
280
|
+
void main () {
|
|
281
|
+
gl_FragColor = texture2D(uTexture, vUv);
|
|
282
|
+
}
|
|
283
|
+
`
|
|
284
|
+
);
|
|
285
|
+
const splatShader = this.compileShader(
|
|
286
|
+
gl.FRAGMENT_SHADER,
|
|
287
|
+
`
|
|
288
|
+
precision highp float;
|
|
289
|
+
precision mediump sampler2D;
|
|
290
|
+
|
|
291
|
+
varying vec2 vUv;
|
|
292
|
+
uniform sampler2D uTarget;
|
|
293
|
+
uniform float aspectRatio;
|
|
294
|
+
uniform vec3 color;
|
|
295
|
+
uniform vec2 point;
|
|
296
|
+
uniform float radius;
|
|
297
|
+
|
|
298
|
+
void main () {
|
|
299
|
+
vec2 p = vUv - point.xy;
|
|
300
|
+
p.x *= aspectRatio;
|
|
301
|
+
vec3 splat = exp(-dot(p, p) / radius) * color;
|
|
302
|
+
vec3 base = texture2D(uTarget, vUv).xyz;
|
|
303
|
+
gl_FragColor = vec4(base + splat, 1.0);
|
|
304
|
+
}
|
|
305
|
+
`
|
|
306
|
+
);
|
|
307
|
+
const advectionManualFilteringShader = this.compileShader(
|
|
308
|
+
gl.FRAGMENT_SHADER,
|
|
309
|
+
`
|
|
310
|
+
precision highp float;
|
|
311
|
+
precision mediump sampler2D;
|
|
312
|
+
|
|
313
|
+
varying vec2 vUv;
|
|
314
|
+
uniform sampler2D uVelocity;
|
|
315
|
+
uniform sampler2D uSource;
|
|
316
|
+
uniform vec2 texelSize;
|
|
317
|
+
uniform float dt;
|
|
318
|
+
uniform float dissipation;
|
|
319
|
+
|
|
320
|
+
vec4 bilerp (in sampler2D sam, in vec2 p) {
|
|
321
|
+
vec4 st;
|
|
322
|
+
st.xy = floor(p - 0.5) + 0.5;
|
|
323
|
+
st.zw = st.xy + 1.0;
|
|
324
|
+
vec4 uv = st * texelSize.xyxy;
|
|
325
|
+
vec4 a = texture2D(sam, uv.xy);
|
|
326
|
+
vec4 b = texture2D(sam, uv.zy);
|
|
327
|
+
vec4 c = texture2D(sam, uv.xw);
|
|
328
|
+
vec4 d = texture2D(sam, uv.zw);
|
|
329
|
+
vec2 f = p - st.xy;
|
|
330
|
+
return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
void main () {
|
|
334
|
+
vec2 coord = gl_FragCoord.xy - dt * texture2D(uVelocity, vUv).xy;
|
|
335
|
+
gl_FragColor = dissipation * bilerp(uSource, coord);
|
|
336
|
+
gl_FragColor.a = 1.0;
|
|
337
|
+
}
|
|
338
|
+
`
|
|
339
|
+
);
|
|
340
|
+
const advectionShader = this.compileShader(
|
|
341
|
+
gl.FRAGMENT_SHADER,
|
|
342
|
+
`
|
|
343
|
+
precision highp float;
|
|
344
|
+
precision mediump sampler2D;
|
|
345
|
+
|
|
346
|
+
varying vec2 vUv;
|
|
347
|
+
uniform sampler2D uVelocity;
|
|
348
|
+
uniform sampler2D uSource;
|
|
349
|
+
uniform vec2 texelSize;
|
|
350
|
+
uniform float dt;
|
|
351
|
+
uniform float dissipation;
|
|
352
|
+
|
|
353
|
+
void main () {
|
|
354
|
+
vec2 coord = vUv - dt * texture2D(uVelocity, vUv).xy * texelSize;
|
|
355
|
+
gl_FragColor = dissipation * texture2D(uSource, coord);
|
|
356
|
+
gl_FragColor.a = 1.0;
|
|
357
|
+
}
|
|
358
|
+
`
|
|
359
|
+
);
|
|
360
|
+
const divergenceShader = this.compileShader(
|
|
361
|
+
gl.FRAGMENT_SHADER,
|
|
362
|
+
`
|
|
363
|
+
precision highp float;
|
|
364
|
+
precision mediump sampler2D;
|
|
365
|
+
|
|
366
|
+
varying vec2 vUv;
|
|
367
|
+
varying vec2 vL;
|
|
368
|
+
varying vec2 vR;
|
|
369
|
+
varying vec2 vT;
|
|
370
|
+
varying vec2 vB;
|
|
371
|
+
uniform sampler2D uVelocity;
|
|
372
|
+
|
|
373
|
+
vec2 sampleVelocity (in vec2 uv) {
|
|
374
|
+
vec2 multiplier = vec2(1.0, 1.0);
|
|
375
|
+
if (uv.x < 0.0) { uv.x = 0.0; multiplier.x = -1.0; }
|
|
376
|
+
if (uv.x > 1.0) { uv.x = 1.0; multiplier.x = -1.0; }
|
|
377
|
+
if (uv.y < 0.0) { uv.y = 0.0; multiplier.y = -1.0; }
|
|
378
|
+
if (uv.y > 1.0) { uv.y = 1.0; multiplier.y = -1.0; }
|
|
379
|
+
return multiplier * texture2D(uVelocity, uv).xy;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
void main () {
|
|
383
|
+
float L = sampleVelocity(vL).x;
|
|
384
|
+
float R = sampleVelocity(vR).x;
|
|
385
|
+
float T = sampleVelocity(vT).y;
|
|
386
|
+
float B = sampleVelocity(vB).y;
|
|
387
|
+
float div = 0.5 * (R - L + T - B);
|
|
388
|
+
gl_FragColor = vec4(div, 0.0, 0.0, 1.0);
|
|
389
|
+
}
|
|
390
|
+
`
|
|
391
|
+
);
|
|
392
|
+
const curlShader = this.compileShader(
|
|
393
|
+
gl.FRAGMENT_SHADER,
|
|
394
|
+
`
|
|
395
|
+
precision highp float;
|
|
396
|
+
precision mediump sampler2D;
|
|
397
|
+
|
|
398
|
+
varying vec2 vUv;
|
|
399
|
+
varying vec2 vL;
|
|
400
|
+
varying vec2 vR;
|
|
401
|
+
varying vec2 vT;
|
|
402
|
+
varying vec2 vB;
|
|
403
|
+
uniform sampler2D uVelocity;
|
|
404
|
+
|
|
405
|
+
void main () {
|
|
406
|
+
float L = texture2D(uVelocity, vL).y;
|
|
407
|
+
float R = texture2D(uVelocity, vR).y;
|
|
408
|
+
float T = texture2D(uVelocity, vT).x;
|
|
409
|
+
float B = texture2D(uVelocity, vB).x;
|
|
410
|
+
float vorticity = R - L - T + B;
|
|
411
|
+
gl_FragColor = vec4(vorticity, 0.0, 0.0, 1.0);
|
|
412
|
+
}
|
|
413
|
+
`
|
|
414
|
+
);
|
|
415
|
+
const vorticityShader = this.compileShader(
|
|
416
|
+
gl.FRAGMENT_SHADER,
|
|
417
|
+
`
|
|
418
|
+
precision highp float;
|
|
419
|
+
precision mediump sampler2D;
|
|
420
|
+
|
|
421
|
+
varying vec2 vUv;
|
|
422
|
+
varying vec2 vT;
|
|
423
|
+
varying vec2 vB;
|
|
424
|
+
uniform sampler2D uVelocity;
|
|
425
|
+
uniform sampler2D uCurl;
|
|
426
|
+
uniform float curl;
|
|
427
|
+
uniform float dt;
|
|
428
|
+
|
|
429
|
+
void main () {
|
|
430
|
+
float T = texture2D(uCurl, vT).x;
|
|
431
|
+
float B = texture2D(uCurl, vB).x;
|
|
432
|
+
float C = texture2D(uCurl, vUv).x;
|
|
433
|
+
vec2 force = vec2(abs(T) - abs(B), 0.0);
|
|
434
|
+
force *= 1.0 / length(force + 0.00001) * curl * C;
|
|
435
|
+
vec2 vel = texture2D(uVelocity, vUv).xy;
|
|
436
|
+
gl_FragColor = vec4(vel + force * dt, 0.0, 1.0);
|
|
437
|
+
}
|
|
438
|
+
`
|
|
439
|
+
);
|
|
440
|
+
const pressureShader = this.compileShader(
|
|
441
|
+
gl.FRAGMENT_SHADER,
|
|
442
|
+
`
|
|
443
|
+
precision highp float;
|
|
444
|
+
precision mediump sampler2D;
|
|
445
|
+
|
|
446
|
+
varying vec2 vUv;
|
|
447
|
+
varying vec2 vL;
|
|
448
|
+
varying vec2 vR;
|
|
449
|
+
varying vec2 vT;
|
|
450
|
+
varying vec2 vB;
|
|
451
|
+
uniform sampler2D uPressure;
|
|
452
|
+
uniform sampler2D uDivergence;
|
|
453
|
+
|
|
454
|
+
vec2 boundary (in vec2 uv) {
|
|
455
|
+
uv = min(max(uv, 0.0), 1.0);
|
|
456
|
+
return uv;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
void main () {
|
|
460
|
+
float L = texture2D(uPressure, boundary(vL)).x;
|
|
461
|
+
float R = texture2D(uPressure, boundary(vR)).x;
|
|
462
|
+
float T = texture2D(uPressure, boundary(vT)).x;
|
|
463
|
+
float B = texture2D(uPressure, boundary(vB)).x;
|
|
464
|
+
float C = texture2D(uPressure, vUv).x;
|
|
465
|
+
float divergence = texture2D(uDivergence, vUv).x;
|
|
466
|
+
float pressure = (L + R + B + T - divergence) * 0.25;
|
|
467
|
+
gl_FragColor = vec4(pressure, 0.0, 0.0, 1.0);
|
|
468
|
+
}
|
|
469
|
+
`
|
|
470
|
+
);
|
|
471
|
+
const gradientSubtractShader = this.compileShader(
|
|
472
|
+
gl.FRAGMENT_SHADER,
|
|
473
|
+
`
|
|
474
|
+
precision highp float;
|
|
475
|
+
precision mediump sampler2D;
|
|
476
|
+
|
|
477
|
+
varying vec2 vUv;
|
|
478
|
+
varying vec2 vL;
|
|
479
|
+
varying vec2 vR;
|
|
480
|
+
varying vec2 vT;
|
|
481
|
+
varying vec2 vB;
|
|
482
|
+
uniform sampler2D uPressure;
|
|
483
|
+
uniform sampler2D uVelocity;
|
|
484
|
+
|
|
485
|
+
vec2 boundary (in vec2 uv) {
|
|
486
|
+
uv = min(max(uv, 0.0), 1.0);
|
|
487
|
+
return uv;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
void main () {
|
|
491
|
+
float L = texture2D(uPressure, boundary(vL)).x;
|
|
492
|
+
float R = texture2D(uPressure, boundary(vR)).x;
|
|
493
|
+
float T = texture2D(uPressure, boundary(vT)).x;
|
|
494
|
+
float B = texture2D(uPressure, boundary(vB)).x;
|
|
495
|
+
vec2 velocity = texture2D(uVelocity, vUv).xy;
|
|
496
|
+
velocity.xy -= vec2(R - L, T - B);
|
|
497
|
+
gl_FragColor = vec4(velocity, 0.0, 1.0);
|
|
498
|
+
}
|
|
499
|
+
`
|
|
500
|
+
);
|
|
501
|
+
return {
|
|
502
|
+
baseVertexShader,
|
|
503
|
+
clearShader,
|
|
504
|
+
displayShader,
|
|
505
|
+
splatShader,
|
|
506
|
+
advectionManualFilteringShader,
|
|
507
|
+
advectionShader,
|
|
508
|
+
divergenceShader,
|
|
509
|
+
curlShader,
|
|
510
|
+
vorticityShader,
|
|
511
|
+
pressureShader,
|
|
512
|
+
gradientSubtractShader
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
compileShader(type, source) {
|
|
516
|
+
const { gl } = this.glMeta;
|
|
517
|
+
const shader = gl.createShader(type);
|
|
518
|
+
if (!shader) {
|
|
519
|
+
throw Error(`Cannot create shader type ${type}`);
|
|
520
|
+
}
|
|
521
|
+
gl.shaderSource(shader, source);
|
|
522
|
+
gl.compileShader(shader);
|
|
523
|
+
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
|
524
|
+
throw gl.getShaderInfoLog(shader);
|
|
525
|
+
}
|
|
526
|
+
return shader;
|
|
527
|
+
}
|
|
528
|
+
initFrameBuffers() {
|
|
529
|
+
const { gl, ext } = this.glMeta;
|
|
530
|
+
this.textureWidth = gl.drawingBufferWidth >> this.config.TEXTURE_DOWNSAMPLE;
|
|
531
|
+
this.textureHeight = gl.drawingBufferHeight >> this.config.TEXTURE_DOWNSAMPLE;
|
|
532
|
+
const texType = ext.halfFloatTexType;
|
|
533
|
+
const rgba = ext.formatRGBA;
|
|
534
|
+
const rg = ext.formatRG;
|
|
535
|
+
const r = ext.formatR;
|
|
536
|
+
if (rgba) {
|
|
537
|
+
this.density = this.createDoubleFBO(
|
|
538
|
+
2,
|
|
539
|
+
rgba.internalFormat,
|
|
540
|
+
rgba.format,
|
|
541
|
+
texType,
|
|
542
|
+
ext.supportLinearFiltering ? gl.LINEAR : gl.NEAREST
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
if (rg) {
|
|
546
|
+
this.velocity = this.createDoubleFBO(
|
|
547
|
+
0,
|
|
548
|
+
rg.internalFormat,
|
|
549
|
+
rg.format,
|
|
550
|
+
texType,
|
|
551
|
+
ext.supportLinearFiltering ? gl.LINEAR : gl.NEAREST
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
if (r) {
|
|
555
|
+
this.divergence = this.createFBO(
|
|
556
|
+
4,
|
|
557
|
+
r.internalFormat,
|
|
558
|
+
r.format,
|
|
559
|
+
texType,
|
|
560
|
+
gl.NEAREST
|
|
561
|
+
);
|
|
562
|
+
this.curl = this.createFBO(
|
|
563
|
+
5,
|
|
564
|
+
r.internalFormat,
|
|
565
|
+
r.format,
|
|
566
|
+
texType,
|
|
567
|
+
gl.NEAREST
|
|
568
|
+
);
|
|
569
|
+
this.pressure = this.createDoubleFBO(
|
|
570
|
+
6,
|
|
571
|
+
r.internalFormat,
|
|
572
|
+
r.format,
|
|
573
|
+
texType,
|
|
574
|
+
gl.NEAREST
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
createFBO(texId, internalFormat, format, type, param) {
|
|
579
|
+
const { gl } = this.glMeta;
|
|
580
|
+
const w = this.textureWidth;
|
|
581
|
+
const h = this.textureHeight;
|
|
582
|
+
gl.activeTexture(gl.TEXTURE0 + texId);
|
|
583
|
+
const texture = gl.createTexture();
|
|
584
|
+
gl.bindTexture(gl.TEXTURE_2D, texture);
|
|
585
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, param);
|
|
586
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, param);
|
|
587
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
588
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
589
|
+
gl.texImage2D(
|
|
590
|
+
gl.TEXTURE_2D,
|
|
591
|
+
0,
|
|
592
|
+
internalFormat,
|
|
593
|
+
w,
|
|
594
|
+
h,
|
|
595
|
+
0,
|
|
596
|
+
format,
|
|
597
|
+
type,
|
|
598
|
+
null
|
|
599
|
+
);
|
|
600
|
+
const fbo = gl.createFramebuffer();
|
|
601
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
|
|
602
|
+
gl.framebufferTexture2D(
|
|
603
|
+
gl.FRAMEBUFFER,
|
|
604
|
+
gl.COLOR_ATTACHMENT0,
|
|
605
|
+
gl.TEXTURE_2D,
|
|
606
|
+
texture,
|
|
607
|
+
0
|
|
608
|
+
);
|
|
609
|
+
gl.viewport(0, 0, w, h);
|
|
610
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
611
|
+
return [texture, fbo, texId];
|
|
612
|
+
}
|
|
613
|
+
createDoubleFBO(texId, internalFormat, format, type, param) {
|
|
614
|
+
let fbo1 = this.createFBO(texId, internalFormat, format, type, param);
|
|
615
|
+
let fbo2 = this.createFBO(texId + 1, internalFormat, format, type, param);
|
|
616
|
+
return {
|
|
617
|
+
get read() {
|
|
618
|
+
return fbo1;
|
|
619
|
+
},
|
|
620
|
+
get write() {
|
|
621
|
+
return fbo2;
|
|
622
|
+
},
|
|
623
|
+
swap() {
|
|
624
|
+
const temp = fbo1;
|
|
625
|
+
fbo1 = fbo2;
|
|
626
|
+
fbo2 = temp;
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
createPrograms() {
|
|
631
|
+
const { gl, ext } = this.glMeta;
|
|
632
|
+
const clearProgram = new GLProgram(gl, this.shaders.baseVertexShader, this.shaders.clearShader);
|
|
633
|
+
const displayProgram = new GLProgram(gl, this.shaders.baseVertexShader, this.shaders.displayShader);
|
|
634
|
+
const splatProgram = new GLProgram(gl, this.shaders.baseVertexShader, this.shaders.splatShader);
|
|
635
|
+
const advectionProgram = new GLProgram(
|
|
636
|
+
gl,
|
|
637
|
+
this.shaders.baseVertexShader,
|
|
638
|
+
ext.supportLinearFiltering ? this.shaders.advectionShader : this.shaders.advectionManualFilteringShader
|
|
639
|
+
);
|
|
640
|
+
const divergenceProgram = new GLProgram(gl, this.shaders.baseVertexShader, this.shaders.divergenceShader);
|
|
641
|
+
const curlProgram = new GLProgram(gl, this.shaders.baseVertexShader, this.shaders.curlShader);
|
|
642
|
+
const vorticityProgram = new GLProgram(gl, this.shaders.baseVertexShader, this.shaders.vorticityShader);
|
|
643
|
+
const pressureProgram = new GLProgram(gl, this.shaders.baseVertexShader, this.shaders.pressureShader);
|
|
644
|
+
const gradientSubtractProgram = new GLProgram(
|
|
645
|
+
gl,
|
|
646
|
+
this.shaders.baseVertexShader,
|
|
647
|
+
this.shaders.gradientSubtractShader
|
|
648
|
+
);
|
|
649
|
+
return {
|
|
650
|
+
clearProgram,
|
|
651
|
+
displayProgram,
|
|
652
|
+
splatProgram,
|
|
653
|
+
advectionProgram,
|
|
654
|
+
divergenceProgram,
|
|
655
|
+
curlProgram,
|
|
656
|
+
vorticityProgram,
|
|
657
|
+
pressureProgram,
|
|
658
|
+
gradientSubtractProgram
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
createBlitFn() {
|
|
662
|
+
const { gl } = this.glMeta;
|
|
663
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
|
|
664
|
+
gl.bufferData(
|
|
665
|
+
gl.ARRAY_BUFFER,
|
|
666
|
+
new Float32Array([-1, -1, -1, 1, 1, 1, 1, -1]),
|
|
667
|
+
gl.STATIC_DRAW
|
|
668
|
+
);
|
|
669
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, gl.createBuffer());
|
|
670
|
+
gl.bufferData(
|
|
671
|
+
gl.ELEMENT_ARRAY_BUFFER,
|
|
672
|
+
new Uint16Array([0, 1, 2, 0, 2, 3]),
|
|
673
|
+
gl.STATIC_DRAW
|
|
674
|
+
);
|
|
675
|
+
gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
|
|
676
|
+
gl.enableVertexAttribArray(0);
|
|
677
|
+
return (destination) => {
|
|
678
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, destination);
|
|
679
|
+
gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_SHORT, 0);
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
updateAnimation() {
|
|
683
|
+
if (this.stopped) {
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
const { gl } = this.glMeta;
|
|
687
|
+
this.resizeCanvas();
|
|
688
|
+
const dt = Math.min((Date.now() - this.lastTime) / 1e3, 0.016);
|
|
689
|
+
this.lastTime = Date.now();
|
|
690
|
+
gl.viewport(0, 0, this.textureWidth, this.textureHeight);
|
|
691
|
+
const nextSplatCount = this.splatStack.pop();
|
|
692
|
+
nextSplatCount && this.multipleSplats(nextSplatCount);
|
|
693
|
+
if (this.velocity) {
|
|
694
|
+
this.programs.advectionProgram.bind();
|
|
695
|
+
gl.uniform2f(
|
|
696
|
+
this.programs.advectionProgram.uniforms.texelSize,
|
|
697
|
+
1 / this.textureWidth,
|
|
698
|
+
1 / this.textureHeight
|
|
699
|
+
);
|
|
700
|
+
gl.uniform1i(this.programs.advectionProgram.uniforms.uVelocity, this.velocity.read[2]);
|
|
701
|
+
gl.uniform1i(this.programs.advectionProgram.uniforms.uSource, this.velocity.read[2]);
|
|
702
|
+
gl.uniform1f(this.programs.advectionProgram.uniforms.dt, dt);
|
|
703
|
+
gl.uniform1f(
|
|
704
|
+
this.programs.advectionProgram.uniforms.dissipation,
|
|
705
|
+
this.config.VELOCITY_DISSIPATION
|
|
706
|
+
);
|
|
707
|
+
this.blit(this.velocity.write[1]);
|
|
708
|
+
this.velocity.swap();
|
|
709
|
+
if (this.density) {
|
|
710
|
+
gl.uniform1i(this.programs.advectionProgram.uniforms.uVelocity, this.velocity.read[2]);
|
|
711
|
+
gl.uniform1i(this.programs.advectionProgram.uniforms.uSource, this.density.read[2]);
|
|
712
|
+
gl.uniform1f(
|
|
713
|
+
this.programs.advectionProgram.uniforms.dissipation,
|
|
714
|
+
this.config.DENSITY_DISSIPATION
|
|
715
|
+
);
|
|
716
|
+
this.blit(this.density.write[1]);
|
|
717
|
+
this.density.swap();
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
for (let i = 0; i < this.pointers.length; i++) {
|
|
721
|
+
const pointer = this.pointers[i];
|
|
722
|
+
if (pointer.moved) {
|
|
723
|
+
this.splat(pointer.x, pointer.y, pointer.dx, pointer.dy, pointer.color);
|
|
724
|
+
pointer.moved = false;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
if (this.velocity && this.curl) {
|
|
728
|
+
this.programs.curlProgram.bind();
|
|
729
|
+
gl.uniform2f(
|
|
730
|
+
this.programs.curlProgram.uniforms.texelSize,
|
|
731
|
+
1 / this.textureWidth,
|
|
732
|
+
1 / this.textureHeight
|
|
733
|
+
);
|
|
734
|
+
gl.uniform1i(this.programs.curlProgram.uniforms.uVelocity, this.velocity.read[2]);
|
|
735
|
+
this.blit(this.curl[1]);
|
|
736
|
+
}
|
|
737
|
+
if (this.velocity && this.curl) {
|
|
738
|
+
this.programs.vorticityProgram.bind();
|
|
739
|
+
gl.uniform2f(
|
|
740
|
+
this.programs.vorticityProgram.uniforms.texelSize,
|
|
741
|
+
1 / this.textureWidth,
|
|
742
|
+
1 / this.textureHeight
|
|
743
|
+
);
|
|
744
|
+
gl.uniform1i(this.programs.vorticityProgram.uniforms.uVelocity, this.velocity.read[2]);
|
|
745
|
+
gl.uniform1i(this.programs.vorticityProgram.uniforms.uCurl, this.curl[2]);
|
|
746
|
+
gl.uniform1f(this.programs.vorticityProgram.uniforms.curl, this.config.CURL);
|
|
747
|
+
gl.uniform1f(this.programs.vorticityProgram.uniforms.dt, dt);
|
|
748
|
+
this.blit(this.velocity.write[1]);
|
|
749
|
+
this.velocity.swap();
|
|
750
|
+
}
|
|
751
|
+
if (this.velocity && this.divergence) {
|
|
752
|
+
this.programs.divergenceProgram.bind();
|
|
753
|
+
gl.uniform2f(
|
|
754
|
+
this.programs.divergenceProgram.uniforms.texelSize,
|
|
755
|
+
1 / this.textureWidth,
|
|
756
|
+
1 / this.textureHeight
|
|
757
|
+
);
|
|
758
|
+
gl.uniform1i(this.programs.divergenceProgram.uniforms.uVelocity, this.velocity.read[2]);
|
|
759
|
+
this.blit(this.divergence[1]);
|
|
760
|
+
}
|
|
761
|
+
if (this.pressure) {
|
|
762
|
+
this.programs.clearProgram.bind();
|
|
763
|
+
const pressureTexId = this.pressure.read[2];
|
|
764
|
+
gl.activeTexture(gl.TEXTURE0 + pressureTexId);
|
|
765
|
+
gl.bindTexture(gl.TEXTURE_2D, this.pressure.read[0]);
|
|
766
|
+
gl.uniform1i(this.programs.clearProgram.uniforms.uTexture, pressureTexId);
|
|
767
|
+
gl.uniform1f(this.programs.clearProgram.uniforms.value, this.config.PRESSURE_DISSIPATION);
|
|
768
|
+
this.blit(this.pressure.write[1]);
|
|
769
|
+
this.pressure.swap();
|
|
770
|
+
}
|
|
771
|
+
if (this.divergence && this.pressure) {
|
|
772
|
+
this.programs.pressureProgram.bind();
|
|
773
|
+
gl.uniform2f(
|
|
774
|
+
this.programs.pressureProgram.uniforms.texelSize,
|
|
775
|
+
1 / this.textureWidth,
|
|
776
|
+
1 / this.textureHeight
|
|
777
|
+
);
|
|
778
|
+
gl.uniform1i(this.programs.pressureProgram.uniforms.uDivergence, this.divergence[2]);
|
|
779
|
+
const pressureTexId = this.pressure.read[2];
|
|
780
|
+
gl.uniform1i(this.programs.pressureProgram.uniforms.uPressure, pressureTexId);
|
|
781
|
+
gl.activeTexture(gl.TEXTURE0 + pressureTexId);
|
|
782
|
+
for (let i = 0; i < this.config.PRESSURE_ITERATIONS; i++) {
|
|
783
|
+
gl.bindTexture(gl.TEXTURE_2D, this.pressure.read[0]);
|
|
784
|
+
this.blit(this.pressure.write[1]);
|
|
785
|
+
this.pressure.swap();
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
if (this.pressure && this.velocity) {
|
|
789
|
+
this.programs.gradientSubtractProgram.bind();
|
|
790
|
+
gl.uniform2f(
|
|
791
|
+
this.programs.gradientSubtractProgram.uniforms.texelSize,
|
|
792
|
+
1 / this.textureWidth,
|
|
793
|
+
1 / this.textureHeight
|
|
794
|
+
);
|
|
795
|
+
gl.uniform1i(this.programs.gradientSubtractProgram.uniforms.uPressure, this.pressure.read[2]);
|
|
796
|
+
gl.uniform1i(this.programs.gradientSubtractProgram.uniforms.uVelocity, this.velocity.read[2]);
|
|
797
|
+
this.blit(this.velocity.write[1]);
|
|
798
|
+
this.velocity.swap();
|
|
799
|
+
}
|
|
800
|
+
if (this.density) {
|
|
801
|
+
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
|
|
802
|
+
this.programs.displayProgram.bind();
|
|
803
|
+
gl.uniform1i(this.programs.displayProgram.uniforms.uTexture, this.density.read[2]);
|
|
804
|
+
this.blit(null);
|
|
805
|
+
}
|
|
806
|
+
!this.stopped && requestAnimationFrame(this.updateAnimation);
|
|
807
|
+
}
|
|
808
|
+
resizeCanvas() {
|
|
809
|
+
if (this.canvas.width !== this.canvas.clientWidth || this.canvas.height !== this.canvas.clientHeight) {
|
|
810
|
+
this.canvas.width = this.canvas.clientWidth;
|
|
811
|
+
this.canvas.height = this.canvas.clientHeight;
|
|
812
|
+
this.initFrameBuffers();
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
splat(x, y, dx, dy, color) {
|
|
816
|
+
if (!this.velocity || !this.density) {
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
const { gl } = this.glMeta;
|
|
820
|
+
this.programs.splatProgram.bind();
|
|
821
|
+
gl.uniform1i(this.programs.splatProgram.uniforms.uTarget, this.velocity.read[2]);
|
|
822
|
+
gl.uniform1f(
|
|
823
|
+
this.programs.splatProgram.uniforms.aspectRatio,
|
|
824
|
+
this.canvas.width / this.canvas.height
|
|
825
|
+
);
|
|
826
|
+
gl.uniform2f(
|
|
827
|
+
this.programs.splatProgram.uniforms.point,
|
|
828
|
+
x / this.canvas.width,
|
|
829
|
+
1 - y / this.canvas.height
|
|
830
|
+
);
|
|
831
|
+
gl.uniform3f(this.programs.splatProgram.uniforms.color, dx, -dy, 1);
|
|
832
|
+
gl.uniform1f(this.programs.splatProgram.uniforms.radius, this.config.SPLAT_RADIUS);
|
|
833
|
+
this.blit(this.velocity.write[1]);
|
|
834
|
+
this.velocity.swap();
|
|
835
|
+
gl.uniform1i(this.programs.splatProgram.uniforms.uTarget, this.density.read[2]);
|
|
836
|
+
gl.uniform3f(
|
|
837
|
+
this.programs.splatProgram.uniforms.color,
|
|
838
|
+
color[0] * 0.3,
|
|
839
|
+
color[1] * 0.3,
|
|
840
|
+
color[2] * 0.3
|
|
841
|
+
);
|
|
842
|
+
this.blit(this.density.write[1]);
|
|
843
|
+
this.density.swap();
|
|
844
|
+
}
|
|
845
|
+
mousemove(e) {
|
|
846
|
+
if (!this.container) {
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
849
|
+
const yOffset = this.container.getBoundingClientRect().top;
|
|
850
|
+
const eventClientY = e.clientY - yOffset;
|
|
851
|
+
this.pointers[0].moved = this.pointers[0].down;
|
|
852
|
+
this.pointers[0].dx = (e.clientX - this.pointers[0].x) * 10;
|
|
853
|
+
this.pointers[0].dy = (eventClientY - this.pointers[0].y) * 10;
|
|
854
|
+
this.pointers[0].x = e.clientX;
|
|
855
|
+
this.pointers[0].y = eventClientY;
|
|
856
|
+
this.pointers[0].down = true;
|
|
857
|
+
this.pointers[0].color = [
|
|
858
|
+
Math.random() + 0.2,
|
|
859
|
+
Math.random() + 0.2,
|
|
860
|
+
Math.random() + 0.2
|
|
861
|
+
];
|
|
862
|
+
}
|
|
863
|
+
touchmove(e) {
|
|
864
|
+
const touches = e.targetTouches;
|
|
865
|
+
for (let i = 0; i < touches.length; i++) {
|
|
866
|
+
const pointer = this.pointers[i];
|
|
867
|
+
pointer.moved = pointer.down;
|
|
868
|
+
pointer.dx = (touches[i].clientX - pointer.x) * 10;
|
|
869
|
+
pointer.dy = (touches[i].clientY - pointer.y) * 10;
|
|
870
|
+
pointer.x = touches[i].clientX;
|
|
871
|
+
pointer.y = touches[i].clientY;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
touchstart(e) {
|
|
875
|
+
const touches = e.targetTouches;
|
|
876
|
+
for (let i = 0; i < touches.length; i++) {
|
|
877
|
+
if (i >= this.pointers.length) this.pointers.push(new PointerPrototype());
|
|
878
|
+
this.pointers[i].id = touches[i].identifier;
|
|
879
|
+
this.pointers[i].down = true;
|
|
880
|
+
this.pointers[i].x = touches[i].clientX;
|
|
881
|
+
this.pointers[i].y = touches[i].clientY;
|
|
882
|
+
this.pointers[i].color = [
|
|
883
|
+
Math.random() + 0.2,
|
|
884
|
+
Math.random() + 0.2,
|
|
885
|
+
Math.random() + 0.2
|
|
886
|
+
];
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
touchend(e) {
|
|
890
|
+
const touches = e.changedTouches;
|
|
891
|
+
for (let i = 0; i < touches.length; i++)
|
|
892
|
+
for (let j = 0; j < this.pointers.length; j++)
|
|
893
|
+
if (touches[i].identifier === this.pointers[j].id) this.pointers[j].down = false;
|
|
894
|
+
}
|
|
895
|
+
mouseleave() {
|
|
896
|
+
this.pointers[0].down = false;
|
|
897
|
+
}
|
|
898
|
+
multipleSplats(amount) {
|
|
899
|
+
this.initFrameBuffers();
|
|
900
|
+
for (let i = 0; i < amount; i++) {
|
|
901
|
+
const color = [
|
|
902
|
+
Math.random() * 10,
|
|
903
|
+
Math.random() * 10,
|
|
904
|
+
Math.random() * 10
|
|
905
|
+
];
|
|
906
|
+
const x = this.canvas.width * Math.random();
|
|
907
|
+
const y = this.canvas.height * Math.random();
|
|
908
|
+
const dx = 1e3 * (Math.random() - 0.5);
|
|
909
|
+
const dy = 1e3 * (Math.random() - 0.5);
|
|
910
|
+
this.splat(x, y, dx, dy, color);
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
stop() {
|
|
914
|
+
this.stopped = true;
|
|
915
|
+
const { gl } = this.glMeta;
|
|
916
|
+
const layout = document.body;
|
|
917
|
+
layout.removeEventListener("mousemove", this.mousemove);
|
|
918
|
+
layout.removeEventListener("touchmove", this.touchmove);
|
|
919
|
+
layout.removeEventListener("touchstart", this.touchstart);
|
|
920
|
+
layout.removeEventListener("touchend", this.touchend);
|
|
921
|
+
window.removeEventListener("mouseleave", this.mouseleave);
|
|
922
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
923
|
+
}
|
|
924
|
+
start(container) {
|
|
925
|
+
this.container = container;
|
|
926
|
+
this.stopped = false;
|
|
927
|
+
this.lastTime = Date.now();
|
|
928
|
+
requestAnimationFrame(this.updateAnimation);
|
|
929
|
+
const layout = document.body;
|
|
930
|
+
layout.addEventListener("mousemove", this.mousemove);
|
|
931
|
+
layout.addEventListener("touchmove", this.touchmove, { passive: true });
|
|
932
|
+
layout.addEventListener("touchstart", this.touchstart, { passive: true });
|
|
933
|
+
layout.addEventListener("touchend", this.touchend);
|
|
934
|
+
window.addEventListener("mouseleave", this.mouseleave);
|
|
935
|
+
this.multipleSplats(Math.round(Math.random() * 20) + 5);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
let particles;
|
|
939
|
+
onMounted(() => {
|
|
940
|
+
const metaFactory = new ParticleCanvasMetaFactory(canvasElement.value);
|
|
941
|
+
const config = {
|
|
942
|
+
TEXTURE_DOWNSAMPLE: 2,
|
|
943
|
+
DENSITY_DISSIPATION: 0.98,
|
|
944
|
+
VELOCITY_DISSIPATION: 0.99,
|
|
945
|
+
PRESSURE_DISSIPATION: 0.8,
|
|
946
|
+
PRESSURE_ITERATIONS: 25,
|
|
947
|
+
CURL: 35,
|
|
948
|
+
SPLAT_RADIUS: 2e-3
|
|
949
|
+
};
|
|
950
|
+
particles = new ParticleProgram(config, metaFactory.getMeta(), metaFactory.getCanvas());
|
|
951
|
+
if (particlesContainer.value) particles.start(particlesContainer.value);
|
|
952
|
+
});
|
|
953
|
+
onBeforeUnmount(() => {
|
|
954
|
+
particles?.stop();
|
|
955
|
+
});
|
|
956
|
+
</script>
|
|
957
|
+
|
|
958
|
+
<style>
|
|
959
|
+
#particles-container canvas{height:100%;left:0;position:absolute;top:0;width:100%}
|
|
960
|
+
</style>
|