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
17 changes: 9 additions & 8 deletions src/composables/useLoad3dViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,18 @@ export const useLoad3dViewer = (node?: LGraphNode) => {
const width = node.widgets?.find((w) => w.name === 'width')
const height = node.widgets?.find((w) => w.name === 'height')

const hasTargetDimensions = !!(width && height)

load3d = new Load3d(containerRef, {
width: width ? (toRaw(width).value as number) : undefined,
height: height ? (toRaw(height).value as number) : undefined,
getDimensions:
width && height
? () => ({
width: width.value as number,
height: height.value as number
})
: undefined,
isViewerMode: true
getDimensions: hasTargetDimensions
? () => ({
width: width.value as number,
height: height.value as number
Comment on lines +197 to +198
Copy link
Contributor

@DrJKL DrJKL Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Why do we need so many type assertions around these?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

width and height need number type, but width.value could be others

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we constrain the type upstream?

})
: undefined,
isViewerMode: hasTargetDimensions
})

await useLoad3dService().copyLoad3dState(source, load3d)
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/core/load3d/Load3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class Load3d {
STATUS_MOUSE_ON_VIEWER: boolean
INITIAL_RENDER_DONE: boolean = false

targetWidth: number = 512
targetHeight: number = 512
targetWidth: number = 0
targetHeight: number = 0
targetAspectRatio: number = 1
isViewerMode: boolean = false

Expand Down
2 changes: 1 addition & 1 deletion tests-ui/tests/composables/useLoad3dViewer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ describe('useLoad3dViewer', () => {
width: undefined,
height: undefined,
getDimensions: undefined,
isViewerMode: true
isViewerMode: false
})

expect(mockLoad3dService.copyLoad3dState).toHaveBeenCalledWith(
Expand Down
Loading