@gradio/model3d 0.3.0-beta.6 → 0.3.0-beta.8
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 +16 -0
- package/Index.svelte +9 -4
- package/README.md +49 -0
- package/package.json +8 -6
- package/shared/Model3D.svelte +14 -8
- package/shared/Model3DUpload.svelte +12 -7
- package/shared/utils.ts +5 -10
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
# @gradio/model3d
|
2
2
|
|
3
|
+
## 0.3.0-beta.8
|
4
|
+
|
5
|
+
### Features
|
6
|
+
|
7
|
+
- [#6143](https://github.com/gradio-app/gradio/pull/6143) [`e4f7b4b40`](https://github.com/gradio-app/gradio/commit/e4f7b4b409323b01aa01b39e15ce6139e29aa073) - fix circular dependency with client + upload. Thanks [@pngwn](https://github.com/pngwn)!
|
8
|
+
- [#6136](https://github.com/gradio-app/gradio/pull/6136) [`667802a6c`](https://github.com/gradio-app/gradio/commit/667802a6cdbfb2ce454a3be5a78e0990b194548a) - JS Component Documentation. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
|
9
|
+
- [#6094](https://github.com/gradio-app/gradio/pull/6094) [`c476bd5a5`](https://github.com/gradio-app/gradio/commit/c476bd5a5b70836163b9c69bf4bfe068b17fbe13) - Image v4. Thanks [@pngwn](https://github.com/pngwn)!
|
10
|
+
- [#6149](https://github.com/gradio-app/gradio/pull/6149) [`90318b1dd`](https://github.com/gradio-app/gradio/commit/90318b1dd118ae08a695a50e7c556226234ab6dc) - swap `mode` on the frontned to `interactive` to match the backend. Thanks [@pngwn](https://github.com/pngwn)!
|
11
|
+
|
12
|
+
## 0.3.0-beta.7
|
13
|
+
|
14
|
+
### Features
|
15
|
+
|
16
|
+
- [#6016](https://github.com/gradio-app/gradio/pull/6016) [`83e947676`](https://github.com/gradio-app/gradio/commit/83e947676d327ca2ab6ae2a2d710c78961c771a0) - Format js in v4 branch. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
|
17
|
+
- [#5955](https://github.com/gradio-app/gradio/pull/5955) [`825c9cddc`](https://github.com/gradio-app/gradio/commit/825c9cddc83a09457d8c85ebeecb4bc705572d82) - Fix dev mode model3D. Thanks [@freddyaboulton](https://github.com/freddyaboulton)!
|
18
|
+
|
3
19
|
## 0.3.0-beta.6
|
4
20
|
|
5
21
|
### Features
|
package/Index.svelte
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
<script context="module" lang="ts">
|
2
|
+
export { default as BaseModel3D } from "./shared/Model3D.svelte";
|
3
|
+
export { default as BaseModel3DUpload } from "./shared/Model3DUpload.svelte";
|
4
|
+
export { default as BaseExample } from "./Example.svelte";
|
5
|
+
</script>
|
6
|
+
|
1
7
|
<script lang="ts">
|
2
|
-
import type
|
3
|
-
import { normalise_file } from "@gradio/upload";
|
8
|
+
import { normalise_file, type FileData } from "@gradio/client";
|
4
9
|
import Model3D from "./shared/Model3D.svelte";
|
5
10
|
import Model3DUpload from "./shared/Model3DUpload.svelte";
|
6
11
|
import { BlockLabel, Block, Empty, UploadText } from "@gradio/atoms";
|
@@ -33,7 +38,7 @@
|
|
33
38
|
null,
|
34
39
|
null
|
35
40
|
];
|
36
|
-
export let
|
41
|
+
export let interactive: boolean;
|
37
42
|
|
38
43
|
let _value: null | FileData;
|
39
44
|
$: _value = normalise_file(value, root, root_url);
|
@@ -41,7 +46,7 @@
|
|
41
46
|
let dragging = false;
|
42
47
|
</script>
|
43
48
|
|
44
|
-
{#if
|
49
|
+
{#if !interactive}
|
45
50
|
<Block
|
46
51
|
{visible}
|
47
52
|
variant={value === null ? "dashed" : "solid"}
|
package/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# `gradio/model3d`
|
2
|
+
|
3
|
+
```html
|
4
|
+
<script>
|
5
|
+
import {BaseModel3D, BaseModel3DUpload, BaseExample } from `@gradio/model3d`;
|
6
|
+
</script>
|
7
|
+
```
|
8
|
+
|
9
|
+
BaseModel3D
|
10
|
+
```javascript
|
11
|
+
export let value: FileData | null;
|
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
|
+
|
18
|
+
// alpha, beta, radius
|
19
|
+
export let camera_position: [number | null, number | null, number | null] = [
|
20
|
+
null,
|
21
|
+
null,
|
22
|
+
null
|
23
|
+
];
|
24
|
+
```
|
25
|
+
|
26
|
+
BaseModel3DUpload
|
27
|
+
```javascript
|
28
|
+
export let value: null | FileData;
|
29
|
+
export let clear_color: [number, number, number, number] = [0, 0, 0, 0];
|
30
|
+
export let label = "";
|
31
|
+
export let show_label: boolean;
|
32
|
+
export let root: string;
|
33
|
+
export let i18n: I18nFormatter;
|
34
|
+
export let zoom_speed = 1;
|
35
|
+
|
36
|
+
// alpha, beta, radius
|
37
|
+
export let camera_position: [number | null, number | null, number | null] = [
|
38
|
+
null,
|
39
|
+
null,
|
40
|
+
null
|
41
|
+
];
|
42
|
+
```
|
43
|
+
|
44
|
+
BaseExample
|
45
|
+
```javascript
|
46
|
+
export let value: string;
|
47
|
+
export let type: "gallery" | "table";
|
48
|
+
export let selected = false;
|
49
|
+
```
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@gradio/model3d",
|
3
|
-
"version": "0.3.0-beta.
|
3
|
+
"version": "0.3.0-beta.8",
|
4
4
|
"description": "Gradio UI packages",
|
5
5
|
"type": "module",
|
6
6
|
"author": "",
|
@@ -10,13 +10,15 @@
|
|
10
10
|
"@types/babylon": "^6.16.6",
|
11
11
|
"babylonjs": "^4.2.1",
|
12
12
|
"babylonjs-loaders": "^4.2.1",
|
13
|
-
"@gradio/atoms": "^0.2.0-beta.
|
14
|
-
"@gradio/
|
15
|
-
"@gradio/
|
16
|
-
"@gradio/
|
17
|
-
"@gradio/
|
13
|
+
"@gradio/atoms": "^0.2.0-beta.6",
|
14
|
+
"@gradio/client": "^0.7.0-beta.1",
|
15
|
+
"@gradio/icons": "^0.2.0-beta.3",
|
16
|
+
"@gradio/statustracker": "^0.3.0-beta.8",
|
17
|
+
"@gradio/upload": "^0.3.0-beta.6",
|
18
|
+
"@gradio/utils": "^0.2.0-beta.6"
|
18
19
|
},
|
19
20
|
"main_changeset": true,
|
21
|
+
"main": "./Index.svelte",
|
20
22
|
"exports": {
|
21
23
|
".": "./Index.svelte",
|
22
24
|
"./example": "./Example.svelte",
|
package/shared/Model3D.svelte
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
<script lang="ts">
|
2
|
-
import type { FileData } from "@gradio/
|
2
|
+
import type { FileData } from "@gradio/client";
|
3
3
|
import { BlockLabel, IconButton } from "@gradio/atoms";
|
4
4
|
import { File, Download, Undo } from "@gradio/icons";
|
5
5
|
import { add_new_model, reset_camera_position } from "./utils";
|
@@ -22,7 +22,14 @@
|
|
22
22
|
null
|
23
23
|
];
|
24
24
|
|
25
|
-
|
25
|
+
$: {
|
26
|
+
if (
|
27
|
+
BABYLON_LOADERS.OBJFileLoader != undefined &&
|
28
|
+
!BABYLON_LOADERS.OBJFileLoader.IMPORT_VERTEX_COLORS
|
29
|
+
) {
|
30
|
+
BABYLON_LOADERS.OBJFileLoader.IMPORT_VERTEX_COLORS = true;
|
31
|
+
}
|
32
|
+
}
|
26
33
|
|
27
34
|
let canvas: HTMLCanvasElement;
|
28
35
|
let scene: BABYLON.Scene;
|
@@ -37,12 +44,11 @@
|
|
37
44
|
mounted = true;
|
38
45
|
});
|
39
46
|
|
40
|
-
$: ({
|
41
|
-
|
42
|
-
name: undefined
|
47
|
+
$: ({ path } = value || {
|
48
|
+
path: undefined
|
43
49
|
});
|
44
50
|
|
45
|
-
$: canvas && mounted &&
|
51
|
+
$: canvas && mounted && path && dispose();
|
46
52
|
|
47
53
|
function dispose(): void {
|
48
54
|
if (scene && !scene.isDisposed) {
|
@@ -83,9 +89,9 @@
|
|
83
89
|
<div class="buttons">
|
84
90
|
<IconButton Icon={Undo} label="Undo" on:click={() => handle_undo()} />
|
85
91
|
<a
|
86
|
-
href={value.
|
92
|
+
href={value.path}
|
87
93
|
target={window.__is_colab__ ? "_blank" : null}
|
88
|
-
download={window.__is_colab__ ? null : value.orig_name || value.
|
94
|
+
download={window.__is_colab__ ? null : value.orig_name || value.path}
|
89
95
|
>
|
90
96
|
<IconButton Icon={Download} label={i18n("common.download")} />
|
91
97
|
</a>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<script lang="ts">
|
2
2
|
import { createEventDispatcher, tick, onMount } from "svelte";
|
3
3
|
import { Upload, ModifyUpload } from "@gradio/upload";
|
4
|
-
import type { FileData } from "@gradio/
|
4
|
+
import type { FileData } from "@gradio/client";
|
5
5
|
import { BlockLabel } from "@gradio/atoms";
|
6
6
|
import { File } from "@gradio/icons";
|
7
7
|
import { add_new_model, reset_camera_position } from "./utils";
|
@@ -45,13 +45,11 @@
|
|
45
45
|
mounted = true;
|
46
46
|
});
|
47
47
|
|
48
|
-
$: ({
|
49
|
-
|
50
|
-
is_file: undefined,
|
51
|
-
name: undefined
|
48
|
+
$: ({ path } = value || {
|
49
|
+
path: undefined
|
52
50
|
});
|
53
51
|
|
54
|
-
$: canvas && mounted &&
|
52
|
+
$: canvas && mounted && path != null && reset_scene();
|
55
53
|
|
56
54
|
async function handle_upload({
|
57
55
|
detail
|
@@ -88,7 +86,14 @@
|
|
88
86
|
import * as BABYLON_LOADERS from "babylonjs-loaders";
|
89
87
|
import type { I18nFormatter } from "js/utils/src";
|
90
88
|
|
91
|
-
|
89
|
+
$: {
|
90
|
+
if (
|
91
|
+
BABYLON_LOADERS.OBJFileLoader != undefined &&
|
92
|
+
!BABYLON_LOADERS.OBJFileLoader.IMPORT_VERTEX_COLORS
|
93
|
+
) {
|
94
|
+
BABYLON_LOADERS.OBJFileLoader.IMPORT_VERTEX_COLORS = true;
|
95
|
+
}
|
96
|
+
}
|
92
97
|
|
93
98
|
$: dispatch("drag", dragging);
|
94
99
|
</script>
|
package/shared/utils.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { FileData } from "@gradio/
|
1
|
+
import type { FileData } from "@gradio/client";
|
2
2
|
import * as BABYLON from "babylonjs";
|
3
3
|
|
4
4
|
const create_camera = (
|
@@ -53,14 +53,9 @@ export const add_new_model = (
|
|
53
53
|
|
54
54
|
if (!value) return scene;
|
55
55
|
let url: string;
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
let base64_model_content = value.data;
|
60
|
-
let raw_content = BABYLON.Tools.DecodeBase64(base64_model_content);
|
61
|
-
let blob = new Blob([raw_content]);
|
62
|
-
url = URL.createObjectURL(blob);
|
63
|
-
}
|
56
|
+
|
57
|
+
url = value.url!;
|
58
|
+
|
64
59
|
BABYLON.SceneLoader.ShowLoadingScreen = false;
|
65
60
|
BABYLON.SceneLoader.Append(
|
66
61
|
url,
|
@@ -69,7 +64,7 @@ export const add_new_model = (
|
|
69
64
|
() => create_camera(scene, camera_position, zoom_speed),
|
70
65
|
undefined,
|
71
66
|
undefined,
|
72
|
-
"." + value.
|
67
|
+
"." + value.path.split(".")[1]
|
73
68
|
);
|
74
69
|
return scene;
|
75
70
|
};
|