[3d] refactor legacy code by using new vue style (#3161)

This commit is contained in:
Terry Jia
2025-03-20 10:28:35 -04:00
committed by GitHub
parent cc8dc3dbfb
commit afdb94f12f
12 changed files with 64 additions and 35 deletions

View File

@@ -3,6 +3,7 @@ import { toRaw } from 'vue'
import Load3d from '@/extensions/core/load3d/Load3d'
import Load3dAnimation from '@/extensions/core/load3d/Load3dAnimation'
import type { CustomInputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
export class Load3dService {
private static instance: Load3dService
@@ -20,7 +21,7 @@ export class Load3dService {
registerLoad3d(
node: LGraphNode,
container: HTMLElement,
type: 'Load3D' | 'Load3DAnimation' | 'Preview3D' | 'Preview3DAnimation'
inputSpec: CustomInputSpec
) {
const rawNode = toRaw(node)
@@ -28,15 +29,15 @@ export class Load3dService {
this.removeLoad3d(rawNode)
}
const type = inputSpec.type
const isAnimation = type.includes('Animation')
const Load3dClass = isAnimation ? Load3dAnimation : Load3d
const isPreview = type.includes('Preview')
const instance = new Load3dClass(container, {
createPreview: !isPreview,
node: rawNode
node: rawNode,
inputSpec: inputSpec
})
rawNode.onMouseEnter = function () {