@gradio/model3d 0.15.1-dev.0 → 0.15.1-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/Index.svelte +113 -99
- package/dist/Example.svelte +4 -3
- package/dist/Example.svelte.d.ts +20 -18
- package/dist/Index.svelte +125 -101
- package/dist/Index.svelte.d.ts +3 -39
- package/dist/shared/Canvas3D.svelte +107 -86
- package/dist/shared/Canvas3D.svelte.d.ts +28 -25
- package/dist/shared/Canvas3DGS.svelte +99 -80
- package/dist/shared/Canvas3DGS.svelte.d.ts +20 -18
- package/dist/shared/Model3D.svelte +66 -51
- package/dist/shared/Model3D.svelte.d.ts +27 -25
- package/dist/shared/Model3DUpload.svelte +89 -67
- package/dist/shared/Model3DUpload.svelte.d.ts +47 -37
- package/dist/types.d.ts +19 -0
- package/dist/types.js +1 -0
- package/package.json +19 -14
- package/shared/Canvas3D.svelte +1 -1
- package/shared/Model3DUpload.svelte +3 -1
- package/types.ts +21 -0
|
@@ -1,89 +1,110 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export let
|
|
9
|
-
|
|
10
|
-
let
|
|
11
|
-
let
|
|
12
|
-
let
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
import type { FileData } from "@gradio/client";
|
|
4
|
+
import type { Viewer, ViewerDetails } from "@babylonjs/viewer";
|
|
5
|
+
|
|
6
|
+
let BABYLON_VIEWER: typeof import("@babylonjs/viewer");
|
|
7
|
+
|
|
8
|
+
export let value: FileData;
|
|
9
|
+
export let display_mode: "solid" | "point_cloud" | "wireframe";
|
|
10
|
+
export let clear_color: [number, number, number, number];
|
|
11
|
+
export let camera_position: [number | null, number | null, number | null];
|
|
12
|
+
export let zoom_speed: number;
|
|
13
|
+
export let pan_speed: number;
|
|
14
|
+
|
|
15
|
+
$: url = value.url;
|
|
16
|
+
|
|
17
|
+
let canvas: HTMLCanvasElement;
|
|
18
|
+
let viewer: Viewer;
|
|
19
|
+
let viewerDetails: Readonly<ViewerDetails>;
|
|
20
|
+
let mounted = false;
|
|
21
|
+
|
|
22
|
+
onMount(() => {
|
|
23
|
+
const initViewer = async (): Promise<void> => {
|
|
24
|
+
BABYLON_VIEWER = await import("@babylonjs/viewer");
|
|
25
|
+
BABYLON_VIEWER.CreateViewerForCanvas(canvas, {
|
|
26
|
+
clearColor: clear_color,
|
|
27
|
+
useRightHandedSystem: true,
|
|
28
|
+
animationAutoPlay: true,
|
|
29
|
+
cameraAutoOrbit: { enabled: false },
|
|
30
|
+
onInitialized: (details: any) => {
|
|
31
|
+
viewerDetails = details;
|
|
32
|
+
}
|
|
33
|
+
}).then((promiseViewer: any) => {
|
|
34
|
+
viewer = promiseViewer;
|
|
35
|
+
mounted = true;
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
initViewer();
|
|
40
|
+
|
|
41
|
+
return () => {
|
|
42
|
+
viewer?.dispose();
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
$: mounted && load_model(url);
|
|
47
|
+
|
|
48
|
+
function setRenderingMode(pointsCloud: boolean, wireframe: boolean): void {
|
|
49
|
+
viewerDetails.scene.forcePointsCloud = pointsCloud;
|
|
50
|
+
viewerDetails.scene.forceWireframe = wireframe;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function load_model(url: string | undefined): void {
|
|
54
|
+
if (viewer) {
|
|
55
|
+
if (url) {
|
|
56
|
+
viewer
|
|
57
|
+
.loadModel(url, {
|
|
58
|
+
pluginOptions: {
|
|
59
|
+
obj: {
|
|
60
|
+
importVertexColors: true
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
.then(() => {
|
|
65
|
+
if (display_mode === "point_cloud") {
|
|
66
|
+
setRenderingMode(true, false);
|
|
67
|
+
} else if (display_mode === "wireframe") {
|
|
68
|
+
setRenderingMode(false, true);
|
|
69
|
+
} else {
|
|
70
|
+
update_camera(camera_position, zoom_speed, pan_speed);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
viewer.resetModel();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function update_camera(
|
|
80
|
+
camera_position: [number | null, number | null, number | null],
|
|
81
|
+
zoom_speed: number,
|
|
82
|
+
pan_speed: number
|
|
83
|
+
): void {
|
|
84
|
+
const camera = viewerDetails.camera;
|
|
85
|
+
if (camera_position[0] !== null) {
|
|
86
|
+
camera.alpha = (camera_position[0] * Math.PI) / 180;
|
|
87
|
+
}
|
|
88
|
+
if (camera_position[1] !== null) {
|
|
89
|
+
camera.beta = (camera_position[1] * Math.PI) / 180;
|
|
90
|
+
}
|
|
91
|
+
if (camera_position[2] !== null) {
|
|
92
|
+
camera.radius = camera_position[2];
|
|
93
|
+
}
|
|
94
|
+
camera.lowerRadiusLimit = 0.1;
|
|
95
|
+
const updateCameraSensibility = (): void => {
|
|
96
|
+
camera.wheelPrecision = 250 / (camera.radius * zoom_speed);
|
|
97
|
+
camera.panningSensibility = (10000 * pan_speed) / camera.radius;
|
|
98
|
+
};
|
|
99
|
+
updateCameraSensibility();
|
|
100
|
+
camera.onAfterCheckInputsObservable.add(updateCameraSensibility);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function reset_camera_position(): void {
|
|
104
|
+
if (viewerDetails) {
|
|
105
|
+
viewer.resetCamera();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
87
108
|
</script>
|
|
88
109
|
|
|
89
110
|
<canvas bind:this={canvas}></canvas>
|
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { FileData } from "@gradio/client";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
[evt: string]: CustomEvent<any>;
|
|
16
|
-
};
|
|
17
|
-
slots: {};
|
|
18
|
-
exports?: {} | undefined;
|
|
19
|
-
bindings?: string | undefined;
|
|
20
|
-
};
|
|
21
|
-
export type Canvas3DProps = typeof __propDef.props;
|
|
22
|
-
export type Canvas3DEvents = typeof __propDef.events;
|
|
23
|
-
export type Canvas3DSlots = typeof __propDef.slots;
|
|
24
|
-
export default class Canvas3D extends SvelteComponent<Canvas3DProps, Canvas3DEvents, Canvas3DSlots> {
|
|
25
|
-
get update_camera(): (camera_position: [number | null, number | null, number | null], zoom_speed: number, pan_speed: number) => void;
|
|
26
|
-
get reset_camera_position(): () => void;
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
27
14
|
}
|
|
28
|
-
|
|
15
|
+
declare const Canvas3D: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
value: FileData;
|
|
17
|
+
display_mode: "solid" | "point_cloud" | "wireframe";
|
|
18
|
+
clear_color: [number, number, number, number];
|
|
19
|
+
camera_position: [number | null, number | null, number | null];
|
|
20
|
+
zoom_speed: number;
|
|
21
|
+
pan_speed: number;
|
|
22
|
+
update_camera?: (camera_position: [number | null, number | null, number | null], zoom_speed: number, pan_speed: number) => void;
|
|
23
|
+
reset_camera_position?: () => void;
|
|
24
|
+
}, {
|
|
25
|
+
[evt: string]: CustomEvent<any>;
|
|
26
|
+
}, {}, {
|
|
27
|
+
update_camera: (camera_position: [number | null, number | null, number | null], zoom_speed: number, pan_speed: number) => void;
|
|
28
|
+
reset_camera_position: () => void;
|
|
29
|
+
}, string>;
|
|
30
|
+
type Canvas3D = InstanceType<typeof Canvas3D>;
|
|
31
|
+
export default Canvas3D;
|
|
@@ -1,83 +1,102 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
let
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
let
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
import * as SPLAT from "gsplat";
|
|
4
|
+
import type { FileData } from "@gradio/client";
|
|
5
|
+
|
|
6
|
+
export let value: FileData;
|
|
7
|
+
export let zoom_speed: number;
|
|
8
|
+
export let pan_speed: number;
|
|
9
|
+
|
|
10
|
+
$: url = value.url;
|
|
11
|
+
|
|
12
|
+
let canvas: HTMLCanvasElement;
|
|
13
|
+
let scene: SPLAT.Scene;
|
|
14
|
+
let camera: SPLAT.Camera;
|
|
15
|
+
let renderer: SPLAT.WebGLRenderer | null = null;
|
|
16
|
+
let controls: SPLAT.OrbitControls;
|
|
17
|
+
let mounted = false;
|
|
18
|
+
let frameId: number | null = null;
|
|
19
|
+
|
|
20
|
+
function reset_scene(): void {
|
|
21
|
+
if (frameId !== null) {
|
|
22
|
+
cancelAnimationFrame(frameId);
|
|
23
|
+
frameId = null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (renderer !== null) {
|
|
27
|
+
renderer.dispose();
|
|
28
|
+
renderer = null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
scene = new SPLAT.Scene();
|
|
32
|
+
camera = new SPLAT.Camera();
|
|
33
|
+
renderer = new SPLAT.WebGLRenderer(canvas);
|
|
34
|
+
controls = new SPLAT.OrbitControls(camera, canvas);
|
|
35
|
+
controls.zoomSpeed = zoom_speed;
|
|
36
|
+
controls.panSpeed = pan_speed;
|
|
37
|
+
|
|
38
|
+
if (!value) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let loading = false;
|
|
43
|
+
const load = async (): Promise<void> => {
|
|
44
|
+
if (loading) {
|
|
45
|
+
console.error("Already loading");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (!url) {
|
|
49
|
+
throw new Error("No resolved URL");
|
|
50
|
+
}
|
|
51
|
+
loading = true;
|
|
52
|
+
if (url.endsWith(".ply")) {
|
|
53
|
+
await SPLAT.PLYLoader.LoadAsync(url, scene, undefined);
|
|
54
|
+
} else if (url.endsWith(".splat")) {
|
|
55
|
+
await SPLAT.Loader.LoadAsync(url, scene, undefined);
|
|
56
|
+
} else {
|
|
57
|
+
throw new Error("Unsupported file type");
|
|
58
|
+
}
|
|
59
|
+
loading = false;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const frame = (): void => {
|
|
63
|
+
if (!renderer) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (loading) {
|
|
68
|
+
frameId = requestAnimationFrame(frame);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
controls.update();
|
|
73
|
+
renderer.render(scene, camera);
|
|
74
|
+
|
|
75
|
+
frameId = requestAnimationFrame(frame);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
load();
|
|
79
|
+
frameId = requestAnimationFrame(frame);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
onMount(() => {
|
|
83
|
+
if (value != null) {
|
|
84
|
+
reset_scene();
|
|
85
|
+
}
|
|
86
|
+
mounted = true;
|
|
87
|
+
|
|
88
|
+
return () => {
|
|
89
|
+
if (renderer) {
|
|
90
|
+
renderer.dispose();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
$: ({ path } = value || {
|
|
96
|
+
path: undefined
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
$: canvas && mounted && path && reset_scene();
|
|
81
100
|
</script>
|
|
82
101
|
|
|
83
102
|
<canvas bind:this={canvas}></canvas>
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { FileData } from "@gradio/client";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
8
12
|
};
|
|
9
|
-
|
|
10
|
-
[evt: string]: CustomEvent<any>;
|
|
11
|
-
};
|
|
12
|
-
slots: {};
|
|
13
|
-
exports?: {} | undefined;
|
|
14
|
-
bindings?: string | undefined;
|
|
15
|
-
};
|
|
16
|
-
export type Canvas3DgsProps = typeof __propDef.props;
|
|
17
|
-
export type Canvas3DgsEvents = typeof __propDef.events;
|
|
18
|
-
export type Canvas3DgsSlots = typeof __propDef.slots;
|
|
19
|
-
export default class Canvas3Dgs extends SvelteComponent<Canvas3DgsProps, Canvas3DgsEvents, Canvas3DgsSlots> {
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
20
14
|
}
|
|
21
|
-
|
|
15
|
+
declare const Canvas3DGS: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
value: FileData;
|
|
17
|
+
zoom_speed: number;
|
|
18
|
+
pan_speed: number;
|
|
19
|
+
}, {
|
|
20
|
+
[evt: string]: CustomEvent<any>;
|
|
21
|
+
}, {}, {}, string>;
|
|
22
|
+
type Canvas3DGS = InstanceType<typeof Canvas3DGS>;
|
|
23
|
+
export default Canvas3DGS;
|
|
@@ -1,54 +1,69 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export let
|
|
11
|
-
export let
|
|
12
|
-
export let
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export let
|
|
18
|
-
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { FileData } from "@gradio/client";
|
|
3
|
+
import { BlockLabel, IconButton, IconButtonWrapper } from "@gradio/atoms";
|
|
4
|
+
import { File, Download, Undo } from "@gradio/icons";
|
|
5
|
+
import type { I18nFormatter } from "@gradio/utils";
|
|
6
|
+
import { dequal } from "dequal";
|
|
7
|
+
import type Canvas3DGS from "./Canvas3DGS.svelte";
|
|
8
|
+
import type Canvas3D from "./Canvas3D.svelte";
|
|
9
|
+
|
|
10
|
+
export let value: FileData | null;
|
|
11
|
+
export let display_mode: "solid" | "point_cloud" | "wireframe" = "solid";
|
|
12
|
+
export let clear_color: [number, number, number, number] = [0, 0, 0, 0];
|
|
13
|
+
export let label = "";
|
|
14
|
+
export let show_label: boolean;
|
|
15
|
+
export let i18n: I18nFormatter;
|
|
16
|
+
export let zoom_speed = 1;
|
|
17
|
+
export let pan_speed = 1;
|
|
18
|
+
// alpha, beta, radius
|
|
19
|
+
export let camera_position: [number | null, number | null, number | null] = [
|
|
20
|
+
null,
|
|
21
|
+
null,
|
|
22
|
+
null
|
|
23
|
+
];
|
|
24
|
+
export let has_change_history = false;
|
|
25
|
+
|
|
26
|
+
let current_settings = { camera_position, zoom_speed, pan_speed };
|
|
27
|
+
|
|
28
|
+
let use_3dgs = false;
|
|
29
|
+
let Canvas3DGSComponent: typeof Canvas3DGS;
|
|
30
|
+
let Canvas3DComponent: typeof Canvas3D;
|
|
31
|
+
async function loadCanvas3D(): Promise<typeof Canvas3D> {
|
|
32
|
+
const module = await import("./Canvas3D.svelte");
|
|
33
|
+
return module.default;
|
|
34
|
+
}
|
|
35
|
+
async function loadCanvas3DGS(): Promise<typeof Canvas3DGS> {
|
|
36
|
+
const module = await import("./Canvas3DGS.svelte");
|
|
37
|
+
return module.default;
|
|
38
|
+
}
|
|
39
|
+
$: if (value) {
|
|
40
|
+
use_3dgs = value.path.endsWith(".splat") || value.path.endsWith(".ply");
|
|
41
|
+
if (use_3dgs) {
|
|
42
|
+
loadCanvas3DGS().then((component) => {
|
|
43
|
+
Canvas3DGSComponent = component;
|
|
44
|
+
});
|
|
45
|
+
} else {
|
|
46
|
+
loadCanvas3D().then((component) => {
|
|
47
|
+
Canvas3DComponent = component;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
let canvas3d: Canvas3D | undefined;
|
|
53
|
+
function handle_undo(): void {
|
|
54
|
+
canvas3d?.reset_camera_position();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
$: {
|
|
58
|
+
if (
|
|
59
|
+
!dequal(current_settings.camera_position, camera_position) ||
|
|
60
|
+
current_settings.zoom_speed !== zoom_speed ||
|
|
61
|
+
current_settings.pan_speed !== pan_speed
|
|
62
|
+
) {
|
|
63
|
+
canvas3d?.update_camera(camera_position, zoom_speed, pan_speed);
|
|
64
|
+
current_settings = { camera_position, zoom_speed, pan_speed };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
52
67
|
</script>
|
|
53
68
|
|
|
54
69
|
<BlockLabel
|
|
@@ -1,29 +1,31 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { FileData } from "@gradio/client";
|
|
3
2
|
import type { I18nFormatter } from "@gradio/utils";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
camera_position?: [number | null, number | null, number | null];
|
|
15
|
-
has_change_history?: boolean;
|
|
3
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
4
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
5
|
+
$$bindings?: Bindings;
|
|
6
|
+
} & Exports;
|
|
7
|
+
(internal: unknown, props: Props & {
|
|
8
|
+
$$events?: Events;
|
|
9
|
+
$$slots?: Slots;
|
|
10
|
+
}): Exports & {
|
|
11
|
+
$set?: any;
|
|
12
|
+
$on?: any;
|
|
16
13
|
};
|
|
17
|
-
|
|
18
|
-
[evt: string]: CustomEvent<any>;
|
|
19
|
-
};
|
|
20
|
-
slots: {};
|
|
21
|
-
exports?: {} | undefined;
|
|
22
|
-
bindings?: string | undefined;
|
|
23
|
-
};
|
|
24
|
-
export type Model3DProps = typeof __propDef.props;
|
|
25
|
-
export type Model3DEvents = typeof __propDef.events;
|
|
26
|
-
export type Model3DSlots = typeof __propDef.slots;
|
|
27
|
-
export default class Model3D extends SvelteComponent<Model3DProps, Model3DEvents, Model3DSlots> {
|
|
14
|
+
z_$$bindings?: Bindings;
|
|
28
15
|
}
|
|
29
|
-
|
|
16
|
+
declare const Model3D: $$__sveltets_2_IsomorphicComponent<{
|
|
17
|
+
value: FileData | null;
|
|
18
|
+
display_mode?: "solid" | "point_cloud" | "wireframe";
|
|
19
|
+
clear_color?: [number, number, number, number];
|
|
20
|
+
label?: string;
|
|
21
|
+
show_label: boolean;
|
|
22
|
+
i18n: I18nFormatter;
|
|
23
|
+
zoom_speed?: number;
|
|
24
|
+
pan_speed?: number;
|
|
25
|
+
camera_position?: [number | null, number | null, number | null];
|
|
26
|
+
has_change_history?: boolean;
|
|
27
|
+
}, {
|
|
28
|
+
[evt: string]: CustomEvent<any>;
|
|
29
|
+
}, {}, {}, string>;
|
|
30
|
+
type Model3D = InstanceType<typeof Model3D>;
|
|
31
|
+
export default Model3D;
|