mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-21 01:01:05 +08:00
Ensure camera settings only update when necessary in Model3D (#6871)
* change reset_camera_position reactivity logic * check for changes when resetting scene * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
parent
377725cbb7
commit
d361a0f179
6
.changeset/clear-adults-fall.md
Normal file
6
.changeset/clear-adults-fall.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gradio/model3d": patch
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
fix:Ensure camera settings only update when necessary in Model3D
|
@ -15,7 +15,8 @@
|
||||
"@gradio/utils": "workspace:^",
|
||||
"@types/babylon": "^6.16.6",
|
||||
"babylonjs": "^4.2.1",
|
||||
"babylonjs-loaders": "^4.2.1"
|
||||
"babylonjs-loaders": "^4.2.1",
|
||||
"dequal": "^2.0.2"
|
||||
},
|
||||
"main_changeset": true,
|
||||
"main": "./Index.svelte",
|
||||
|
@ -7,6 +7,7 @@
|
||||
import * as BABYLON from "babylonjs";
|
||||
import * as BABYLON_LOADERS from "babylonjs-loaders";
|
||||
import type { I18nFormatter } from "@gradio/utils";
|
||||
import { dequal } from "dequal";
|
||||
|
||||
export let value: FileData | null;
|
||||
export let clear_color: [number, number, number, number] = [0, 0, 0, 0];
|
||||
@ -15,7 +16,6 @@
|
||||
export let i18n: I18nFormatter;
|
||||
export let zoom_speed = 1;
|
||||
export let pan_speed = 1;
|
||||
|
||||
// alpha, beta, radius
|
||||
export let camera_position: [number | null, number | null, number | null] = [
|
||||
null,
|
||||
@ -23,6 +23,8 @@
|
||||
null
|
||||
];
|
||||
|
||||
let current_settings = { camera_position, zoom_speed, pan_speed };
|
||||
|
||||
$: {
|
||||
if (
|
||||
BABYLON_LOADERS.OBJFileLoader != undefined &&
|
||||
@ -80,8 +82,17 @@
|
||||
reset_camera_position(scene, camera_position, zoom_speed, pan_speed);
|
||||
}
|
||||
|
||||
$: if (scene)
|
||||
reset_camera_position(scene, camera_position, zoom_speed, pan_speed);
|
||||
$: {
|
||||
if (
|
||||
scene &&
|
||||
(!dequal(current_settings.camera_position, camera_position) ||
|
||||
current_settings.zoom_speed !== zoom_speed ||
|
||||
current_settings.pan_speed !== pan_speed)
|
||||
) {
|
||||
reset_camera_position(scene, camera_position, zoom_speed, pan_speed);
|
||||
current_settings = { camera_position, zoom_speed, pan_speed };
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<BlockLabel
|
||||
|
@ -1164,6 +1164,9 @@ importers:
|
||||
babylonjs-loaders:
|
||||
specifier: ^4.2.1
|
||||
version: 4.2.1
|
||||
dequal:
|
||||
specifier: ^2.0.2
|
||||
version: 2.0.3
|
||||
|
||||
js/number:
|
||||
dependencies:
|
||||
|
Loading…
Reference in New Issue
Block a user