gradio/js/model3D/interactive/InteractiveModel3d.svelte
Abubakar Abid 79d8f9d891
Adds height and zoom_speed parameters to Model3D component, as well as a button to reset the camera position (#5373)
* add params in backend

* tweaks

* add changeset

* updates

* tweaks

* lint

* cleanup

* fix tests

* add reset button

* add changeset

* lint

* add changeset

* add changeset

* lint

* add changeset

* faster

* add changeset

* undo website

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
2023-08-31 12:24:22 -07:00

74 lines
1.9 KiB
Svelte

<script lang="ts">
import type { Gradio } from "@gradio/utils";
import type { FileData } from "@gradio/upload";
import { normalise_file } from "@gradio/upload";
import Model3DUpload from "./Model3DUpload.svelte";
import { Block, UploadText } from "@gradio/atoms";
import { StatusTracker } from "@gradio/statustracker";
import type { LoadingStatus } from "@gradio/statustracker";
import { _ } from "svelte-i18n";
export let elem_id = "";
export let elem_classes: string[] = [];
export let visible = true;
export let value: null | FileData = null;
export let root: string;
export let root_url: null | string;
export let clear_color: [number, number, number, number];
export let loading_status: LoadingStatus;
export let label: string;
export let show_label: boolean;
export let container = true;
export let scale: number | null = null;
export let min_width: number | undefined = undefined;
export let gradio: Gradio<{
change: typeof value;
clear: never;
}>;
export let zoom_speed = 1;
export let height: number | undefined = undefined;
// alpha, beta, radius
export let camera_position: [number | null, number | null, number | null] = [
null,
null,
null
];
let _value: null | FileData;
$: _value = normalise_file(value, root, root_url);
let dragging = false;
</script>
<Block
{visible}
variant={value === null ? "dashed" : "solid"}
border_mode={dragging ? "focus" : "base"}
padding={false}
{elem_id}
{elem_classes}
{container}
{scale}
{min_width}
{height}
>
<StatusTracker {...loading_status} />
<Model3DUpload
{label}
{show_label}
{clear_color}
value={_value}
{camera_position}
{zoom_speed}
on:change={({ detail }) => (value = detail)}
on:drag={({ detail }) => (dragging = detail)}
on:change={({ detail }) => gradio.dispatch("change", detail)}
on:clear={() => gradio.dispatch("clear")}
>
<UploadText type="file" />
</Model3DUpload>
</Block>