Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"@primevue/icons": "catalog:",
"@primevue/themes": "catalog:",
"@sentry/vue": "catalog:",
"@sparkjsdev/spark": "catalog:",
"@tiptap/core": "^2.10.4",
"@tiptap/extension-link": "^2.10.4",
"@tiptap/extension-table": "^2.10.4",
Expand Down
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ catalog:
'@primevue/themes': ^4.2.5
'@sentry/vite-plugin': ^4.6.0
'@sentry/vue': ^8.48.0
'@sparkjsdev/spark': ^0.1.10
'@storybook/addon-docs': ^10.1.9
'@storybook/vue3': ^10.1.9
'@storybook/vue3-vite': ^10.1.9
Expand Down
4 changes: 4 additions & 0 deletions src/components/load3d/Load3D.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
v-model:model-config="modelConfig"
v-model:camera-config="cameraConfig"
v-model:light-config="lightConfig"
:is-splat-model="isSplatModel"
:is-ply-model="isPlyModel"
@update-background-image="handleBackgroundImageUpdate"
@export-model="handleExportModel"
/>
Expand Down Expand Up @@ -109,6 +111,8 @@ const {
// other state
isRecording,
isPreview,
isSplatModel,
isPlyModel,
hasRecording,
recordingDuration,
animations,
Expand Down
11 changes: 11 additions & 0 deletions src/components/load3d/Load3DControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
v-if="showModelControls"
v-model:material-mode="modelConfig!.materialMode"
v-model:up-direction="modelConfig!.upDirection"
:hide-material-mode="isSplatModel"
:is-ply-model="isPlyModel"
/>

<CameraControls
Expand Down Expand Up @@ -85,6 +87,11 @@ import type {
SceneConfig
} from '@/extensions/core/load3d/interfaces'

const { isSplatModel = false, isPlyModel = false } = defineProps<{
isSplatModel?: boolean
isPlyModel?: boolean
}>()

const sceneConfig = defineModel<SceneConfig>('sceneConfig')
const modelConfig = defineModel<ModelConfig>('modelConfig')
const cameraConfig = defineModel<CameraConfig>('cameraConfig')
Expand All @@ -101,6 +108,10 @@ const categoryLabels: Record<string, string> = {
}

const availableCategories = computed(() => {
if (isSplatModel) {
return ['scene', 'model', 'camera']
}

return ['scene', 'model', 'camera', 'light', 'export']
})

Expand Down
6 changes: 4 additions & 2 deletions src/components/load3d/Load3dViewerContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
<ModelControls
v-model:up-direction="viewer.upDirection.value"
v-model:material-mode="viewer.materialMode.value"
:hide-material-mode="viewer.isSplatModel.value"
:is-ply-model="viewer.isPlyModel.value"
/>
</div>

Expand All @@ -56,13 +58,13 @@
/>
</div>

<div class="space-y-4 p-2">
<div v-if="!viewer.isSplatModel.value" class="space-y-4 p-2">
<LightControls
v-model:light-intensity="viewer.lightIntensity.value"
/>
</div>

<div class="space-y-4 p-2">
<div v-if="!viewer.isSplatModel.value" class="space-y-4 p-2">
<ExportControls @export-model="viewer.exportModel" />
</div>
</div>
Expand Down
12 changes: 11 additions & 1 deletion src/components/load3d/controls/ModelControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>
</div>

<div class="show-material-mode relative">
<div v-if="!hideMaterialMode" class="show-material-mode relative">
<Button
class="p-button-rounded p-button-text"
@click="toggleMaterialMode"
Expand Down Expand Up @@ -71,6 +71,11 @@ import type {
} from '@/extensions/core/load3d/interfaces'
import { t } from '@/i18n'

const { hideMaterialMode = false, isPlyModel = false } = defineProps<{
hideMaterialMode?: boolean
isPlyModel?: boolean
}>()

const materialMode = defineModel<MaterialMode>('materialMode')
const upDirection = defineModel<UpDirection>('upDirection')

Expand All @@ -95,6 +100,11 @@ const materialModes = computed(() => {
//'depth' disable for now
]

// Only show pointCloud mode for PLY files (point cloud rendering)
if (isPlyModel) {
modes.splice(1, 0, 'pointCloud')
}

return modes
})

Expand Down
25 changes: 21 additions & 4 deletions src/components/load3d/controls/viewer/ViewerModelControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/>
</div>

<div>
<div v-if="!hideMaterialMode">
<label>{{ $t('load3d.materialMode') }}</label>
<Select
v-model="materialMode"
Expand All @@ -32,6 +32,11 @@ import type {
} from '@/extensions/core/load3d/interfaces'
import { t } from '@/i18n'

const { hideMaterialMode = false, isPlyModel = false } = defineProps<{
hideMaterialMode?: boolean
isPlyModel?: boolean
}>()

const upDirection = defineModel<UpDirection>('upDirection')
const materialMode = defineModel<MaterialMode>('materialMode')

Expand All @@ -46,10 +51,22 @@ const upDirectionOptions = [
]

const materialModeOptions = computed(() => {
return [
{ label: t('load3d.materialModes.original'), value: 'original' },
const options = [
{ label: t('load3d.materialModes.original'), value: 'original' }
]

if (isPlyModel) {
options.push({
label: t('load3d.materialModes.pointCloud'),
value: 'pointCloud'
})
}

options.push(
{ label: t('load3d.materialModes.normal'), value: 'normal' },
{ label: t('load3d.materialModes.wireframe'), value: 'wireframe' }
]
)

return options
})
</script>
6 changes: 6 additions & 0 deletions src/composables/useLoad3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export const useLoad3d = (nodeOrRef: MaybeRef<LGraphNode | null>) => {
const loading = ref(false)
const loadingMessage = ref('')
const isPreview = ref(false)
const isSplatModel = ref(false)
const isPlyModel = ref(false)

const initializeLoad3d = async (containerRef: HTMLElement) => {
const rawNode = toRaw(nodeRef.value)
Expand Down Expand Up @@ -490,6 +492,8 @@ export const useLoad3d = (nodeOrRef: MaybeRef<LGraphNode | null>) => {
modelLoadingEnd: () => {
loadingMessage.value = ''
loading.value = false
isSplatModel.value = load3d?.isSplatModel() ?? false
isPlyModel.value = load3d?.isPlyModel() ?? false
},
exportLoadingStart: (message: string) => {
loadingMessage.value = message || t('load3d.exportingModel')
Expand Down Expand Up @@ -561,6 +565,8 @@ export const useLoad3d = (nodeOrRef: MaybeRef<LGraphNode | null>) => {
lightConfig,
isRecording,
isPreview,
isSplatModel,
isPlyModel,
hasRecording,
recordingDuration,
animations,
Expand Down
9 changes: 9 additions & 0 deletions src/composables/useLoad3dViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export const useLoad3dViewer = (node?: LGraphNode) => {
const needApplyChanges = ref(true)
const isPreview = ref(false)
const isStandaloneMode = ref(false)
const isSplatModel = ref(false)
const isPlyModel = ref(false)

let load3d: Load3d | null = null
let sourceLoad3d: Load3d | null = null
Expand Down Expand Up @@ -253,6 +255,9 @@ export const useLoad3dViewer = (node?: LGraphNode) => {
modelConfig.materialMode || source.modelManager.materialMode
}

isSplatModel.value = source.isSplatModel()
isPlyModel.value = source.isPlyModel()

initialState.value = {
backgroundColor: backgroundColor.value,
showGrid: showGrid.value,
Expand Down Expand Up @@ -301,6 +306,8 @@ export const useLoad3dViewer = (node?: LGraphNode) => {
backgroundRenderMode.value = 'tiled'
upDirection.value = 'original'
materialMode.value = 'original'
isSplatModel.value = load3d.isSplatModel()
isPlyModel.value = load3d.isPlyModel()

isPreview.value = true
} catch (error) {
Expand Down Expand Up @@ -517,6 +524,8 @@ export const useLoad3dViewer = (node?: LGraphNode) => {
needApplyChanges,
isPreview,
isStandaloneMode,
isSplatModel,
isPlyModel,

// Methods
initializeViewer,
Expand Down
20 changes: 19 additions & 1 deletion src/extensions/core/load3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ useExtensionService().registerExtension({
type: 'boolean',
defaultValue: false,
experimental: true
},
{
id: 'Comfy.Load3D.PLYEngine',
category: ['3D', 'PLY', 'PLY Engine'],
name: 'PLY Engine',
tooltip:
'Select the engine for loading PLY files. "threejs" uses the native Three.js PLYLoader (best for mesh PLY files). "fastply" uses an optimized loader for ASCII point cloud PLY files. "sparkjs" uses Spark.js for 3D Gaussian Splatting PLY files.',
type: 'combo',
options: ['threejs', 'fastply', 'sparkjs'],
defaultValue: 'threejs',
experimental: true
}
],
commands: [
Expand Down Expand Up @@ -238,7 +249,10 @@ useExtensionService().registerExtension({
getCustomWidgets() {
return {
LOAD_3D(node) {
const fileInput = createFileInput('.gltf,.glb,.obj,.fbx,.stl', false)
const fileInput = createFileInput(
'.gltf,.glb,.obj,.fbx,.stl,.ply,.spz,.splat,.ksplat',
false
)

node.properties['Resource Folder'] = ''

Expand Down Expand Up @@ -301,6 +315,8 @@ useExtensionService().registerExtension({
const load3d = useLoad3dService().getLoad3d(node)
if (!load3d) return []

if (load3d.isSplatModel()) return []

return createExportMenuItems(load3d)
},

Expand Down Expand Up @@ -409,6 +425,8 @@ useExtensionService().registerExtension({
const load3d = useLoad3dService().getLoad3d(node)
if (!load3d) return []

if (load3d.isSplatModel()) return []

return createExportMenuItems(load3d)
},

Expand Down
8 changes: 8 additions & 0 deletions src/extensions/core/load3d/Load3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,14 @@ class Load3d {
this.loadingPromise = null
}

isSplatModel(): boolean {
return this.modelManager.containsSplatMesh()
}

isPlyModel(): boolean {
return this.modelManager.originalModel instanceof THREE.BufferGeometry
}

clearModel(): void {
this.animationManager.dispose()
this.modelManager.clearModel()
Expand Down
Loading