mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-01 05:49:54 +00:00
Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Chenlei Hu <huchenlei@proton.me>
233 lines
6.4 KiB
Vue
233 lines
6.4 KiB
Vue
<template>
|
|
<div class="relative w-full h-full">
|
|
<Load3DAnimationScene
|
|
:node="node"
|
|
:type="type"
|
|
:backgroundColor="backgroundColor"
|
|
:showGrid="showGrid"
|
|
:lightIntensity="lightIntensity"
|
|
:fov="fov"
|
|
:cameraType="cameraType"
|
|
:showPreview="showPreview"
|
|
:showFOVButton="showFOVButton"
|
|
:showLightIntensityButton="showLightIntensityButton"
|
|
:playing="playing"
|
|
:selectedSpeed="selectedSpeed"
|
|
:selectedAnimation="selectedAnimation"
|
|
:backgroundImage="backgroundImage"
|
|
:upDirection="upDirection"
|
|
:materialMode="materialMode"
|
|
@materialModeChange="listenMaterialModeChange"
|
|
@backgroundColorChange="listenBackgroundColorChange"
|
|
@lightIntensityChange="listenLightIntensityChange"
|
|
@fovChange="listenFOVChange"
|
|
@cameraTypeChange="listenCameraTypeChange"
|
|
@showGridChange="listenShowGridChange"
|
|
@showPreviewChange="listenShowPreviewChange"
|
|
@backgroundImageChange="listenBackgroundImageChange"
|
|
@animationListChange="animationListChange"
|
|
@upDirectionChange="listenUpDirectionChange"
|
|
/>
|
|
<div class="absolute top-0 left-0 w-full h-full pointer-events-none">
|
|
<Load3DControls
|
|
:backgroundColor="backgroundColor"
|
|
:showGrid="showGrid"
|
|
:showPreview="showPreview"
|
|
:lightIntensity="lightIntensity"
|
|
:showLightIntensityButton="showLightIntensityButton"
|
|
:fov="fov"
|
|
:showFOVButton="showFOVButton"
|
|
:showPreviewButton="showPreviewButton"
|
|
:cameraType="cameraType"
|
|
:hasBackgroundImage="hasBackgroundImage"
|
|
:upDirection="upDirection"
|
|
:materialMode="materialMode"
|
|
@updateBackgroundImage="handleBackgroundImageUpdate"
|
|
@switchCamera="switchCamera"
|
|
@toggleGrid="toggleGrid"
|
|
@updateBackgroundColor="handleBackgroundColorChange"
|
|
@updateLightIntensity="handleUpdateLightIntensity"
|
|
@togglePreview="togglePreview"
|
|
@updateFOV="handleUpdateFOV"
|
|
@updateUpDirection="handleUpdateUpDirection"
|
|
@updateMaterialMode="handleUpdateMaterialMode"
|
|
/>
|
|
<Load3DAnimationControls
|
|
:animations="animations"
|
|
:playing="playing"
|
|
@togglePlay="togglePlay"
|
|
@speedChange="speedChange"
|
|
@animationChange="animationChange"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { computed, ref } from 'vue'
|
|
|
|
import Load3DAnimationControls from '@/components/load3d/Load3DAnimationControls.vue'
|
|
import Load3DAnimationScene from '@/components/load3d/Load3DAnimationScene.vue'
|
|
import Load3DControls from '@/components/load3d/Load3DControls.vue'
|
|
import Load3dUtils from '@/extensions/core/load3d/Load3dUtils'
|
|
import {
|
|
AnimationItem,
|
|
CameraType,
|
|
MaterialMode,
|
|
UpDirection
|
|
} from '@/extensions/core/load3d/interfaces'
|
|
|
|
const props = defineProps<{
|
|
node: any
|
|
type: 'Load3DAnimation' | 'Preview3DAnimation'
|
|
}>()
|
|
|
|
const node = ref(props.node)
|
|
const backgroundColor = ref('#000000')
|
|
const showGrid = ref(true)
|
|
const showPreview = ref(false)
|
|
const lightIntensity = ref(5)
|
|
const showLightIntensityButton = ref(true)
|
|
const fov = ref(75)
|
|
const showFOVButton = ref(true)
|
|
const cameraType = ref<'perspective' | 'orthographic'>('perspective')
|
|
const hasBackgroundImage = ref(false)
|
|
|
|
const animations = ref<AnimationItem[]>([])
|
|
const playing = ref(false)
|
|
const selectedSpeed = ref(1)
|
|
const selectedAnimation = ref(0)
|
|
const backgroundImage = ref('')
|
|
|
|
const showPreviewButton = computed(() => {
|
|
return !props.type.includes('Preview')
|
|
})
|
|
|
|
const switchCamera = () => {
|
|
cameraType.value =
|
|
cameraType.value === 'perspective' ? 'orthographic' : 'perspective'
|
|
|
|
showFOVButton.value = cameraType.value === 'perspective'
|
|
|
|
node.value.properties['Camera Type'] = cameraType.value
|
|
}
|
|
|
|
const togglePreview = (value: boolean) => {
|
|
showPreview.value = value
|
|
|
|
node.value.properties['Show Preview'] = showPreview.value
|
|
}
|
|
|
|
const toggleGrid = (value: boolean) => {
|
|
showGrid.value = value
|
|
|
|
node.value.properties['Show Grid'] = showGrid.value
|
|
}
|
|
|
|
const handleUpdateLightIntensity = (value: number) => {
|
|
lightIntensity.value = value
|
|
|
|
node.value.properties['Light Intensity'] = lightIntensity.value
|
|
}
|
|
|
|
const handleBackgroundImageUpdate = async (file: File | null) => {
|
|
if (!file) {
|
|
hasBackgroundImage.value = false
|
|
backgroundImage.value = ''
|
|
node.value.properties['Background Image'] = ''
|
|
return
|
|
}
|
|
|
|
backgroundImage.value = await Load3dUtils.uploadFile(file)
|
|
|
|
node.value.properties['Background Image'] = backgroundImage.value
|
|
}
|
|
|
|
const handleUpdateFOV = (value: number) => {
|
|
fov.value = value
|
|
|
|
node.value.properties['FOV'] = fov.value
|
|
}
|
|
|
|
const materialMode = ref<MaterialMode>('original')
|
|
const upDirection = ref<UpDirection>('original')
|
|
|
|
const handleUpdateUpDirection = (value: UpDirection) => {
|
|
upDirection.value = value
|
|
|
|
node.value.properties['Up Direction'] = value
|
|
}
|
|
|
|
const handleUpdateMaterialMode = (value: MaterialMode) => {
|
|
materialMode.value = value
|
|
|
|
node.value.properties['Material Mode'] = value
|
|
}
|
|
|
|
const handleBackgroundColorChange = (value: string) => {
|
|
backgroundColor.value = value
|
|
|
|
node.value.properties['Background Color'] = value
|
|
}
|
|
|
|
const togglePlay = (value: boolean) => {
|
|
playing.value = value
|
|
}
|
|
|
|
const speedChange = (value: number) => {
|
|
selectedSpeed.value = value
|
|
}
|
|
|
|
const animationChange = (value: number) => {
|
|
selectedAnimation.value = value
|
|
}
|
|
|
|
const animationListChange = (value: any) => {
|
|
animations.value = value
|
|
}
|
|
|
|
const listenMaterialModeChange = (mode: MaterialMode) => {
|
|
materialMode.value = mode
|
|
|
|
showLightIntensityButton.value = mode === 'original'
|
|
}
|
|
|
|
const listenUpDirectionChange = (value: UpDirection) => {
|
|
upDirection.value = value
|
|
}
|
|
|
|
const listenBackgroundColorChange = (value: string) => {
|
|
backgroundColor.value = value
|
|
}
|
|
|
|
const listenLightIntensityChange = (value: number) => {
|
|
lightIntensity.value = value
|
|
}
|
|
|
|
const listenFOVChange = (value: number) => {
|
|
fov.value = value
|
|
}
|
|
|
|
const listenCameraTypeChange = (value: CameraType) => {
|
|
cameraType.value = value
|
|
|
|
showFOVButton.value = cameraType.value === 'perspective'
|
|
}
|
|
|
|
const listenShowGridChange = (value: boolean) => {
|
|
showGrid.value = value
|
|
}
|
|
|
|
const listenShowPreviewChange = (value: boolean) => {
|
|
showPreview.value = value
|
|
}
|
|
|
|
const listenBackgroundImageChange = (value: string) => {
|
|
backgroundImage.value = value
|
|
|
|
if (backgroundImage.value && backgroundImage.value !== '') {
|
|
hasBackgroundImage.value = true
|
|
}
|
|
}
|
|
</script>
|