Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xmas: Let it snow #3731

Merged
merged 9 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions packages/frontend-2/components/viewer/view-modes/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
@click="handleViewModeChange(shortcut.viewMode)"
/>
</div>
<ViewerMenuItem
label="Let it snow"
:active="snowingEnabled"
@click="onSnowModeClick"
/>
</div>
</ViewerMenu>
</template>
Expand All @@ -32,7 +37,7 @@ import { ViewModeShortcuts } from '~/lib/viewer/helpers/shortcuts/shortcuts'

const open = defineModel<boolean>('open', { default: false })

const { setViewMode, currentViewMode } = useViewModeUtilities()
const { setViewMode, currentViewMode, letItSnow } = useViewModeUtilities()
const { getShortcutDisplayText, registerShortcuts } = useViewerShortcuts()
const mp = useMixpanel()

Expand All @@ -55,9 +60,11 @@ registerShortcuts({
SetViewModeColors: () => handleViewModeChange(ViewMode.COLORS, true)
})

const isActiveMode = (mode: ViewMode) => mode === currentViewMode.value
const isActiveMode = (mode: ViewMode) =>
snowingEnabled.value ? false : mode === currentViewMode.value

const viewModeShortcuts = Object.values(ViewModeShortcuts)
const snowingEnabled = ref(false)

const emit = defineEmits<{
(e: 'force-close-others'): void
Expand All @@ -80,6 +87,11 @@ const handleViewModeChange = (mode: ViewMode, isShortcut = false) => {
})
}

const onSnowModeClick = () => {
snowingEnabled.value = !snowingEnabled.value
letItSnow()
}

onUnmounted(() => {
cancelCloseTimer()
})
Expand Down
10 changes: 9 additions & 1 deletion packages/frontend-2/lib/viewer/composables/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import type {
ViewerShortcutAction
} from '~/lib/viewer/helpers/shortcuts/types'
import { useActiveElement } from '@vueuse/core'
import { SnowPipeline } from '@speckle/viewer-sandbox/src/Pipelines/Snow/SnowPipeline'

export function useSectionBoxUtilities() {
const { instance } = useInjectedViewer()
Expand Down Expand Up @@ -501,9 +502,16 @@ export function useViewModeUtilities() {
}
}

const letItSnow = () => {
const snowPipeline = new SnowPipeline(instance.getRenderer())
instance.getRenderer().pipeline = snowPipeline
void snowPipeline.start()
}

return {
currentViewMode,
setViewMode
setViewMode,
letItSnow
}
}

Expand Down