From 452f79fd6bd7507cecd9ddcb6070607d33b0c8f0 Mon Sep 17 00:00:00 2001 From: EnderRomantice Date: Tue, 23 Dec 2025 09:30:23 +0800 Subject: [PATCH 1/8] feat: add scale props in InfiniteMenu --- src/content/Components/InfiniteMenu/InfiniteMenu.vue | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/content/Components/InfiniteMenu/InfiniteMenu.vue b/src/content/Components/InfiniteMenu/InfiniteMenu.vue index 11bfd27..4da586c 100644 --- a/src/content/Components/InfiniteMenu/InfiniteMenu.vue +++ b/src/content/Components/InfiniteMenu/InfiniteMenu.vue @@ -11,6 +11,7 @@ type InfiniteMenuItem = { type InfiniteMenuProps = { items?: InfiniteMenuItem[]; + scale?: number; }; const DEFAULT_ITEMS: InfiniteMenuItem[] = [ @@ -22,7 +23,9 @@ const DEFAULT_ITEMS: InfiniteMenuItem[] = [ } ]; -const props = defineProps(); +const props = withDefaults(defineProps(), { + scale: 1.0 +}); // Refs const canvasRef = ref(); @@ -657,7 +660,7 @@ class InfiniteGridMenu { far: 40, fov: Math.PI / 4, aspect: 1, - position: vec3.fromValues(0, 0, 3), + position: vec3.fromValues(0, 0, props.scale), up: vec3.fromValues(0, 1, 0), matrices: { view: mat4.create(), @@ -699,8 +702,11 @@ class InfiniteGridMenu { private items: InfiniteMenuItem[], private onActiveItemChange: (index: number) => void, private onMovementChange: (isMoving: boolean) => void, - private onInit?: (menu: InfiniteGridMenu) => void + private onInit?: (menu: InfiniteGridMenu) => void, + scale: number = 1.0 ) { + this.scaleFactor = scale; + this.camera.position[2] = 3 * scale; this.init(); } From 04efb0a7d1d04fe5f6d059892b349b81753376a7 Mon Sep 17 00:00:00 2001 From: EnderRomantice Date: Tue, 23 Dec 2025 15:47:19 +0800 Subject: [PATCH 2/8] feat: Add scale props in demo --- .../Components/InfiniteMenu/InfiniteMenu.vue | 26 ++++++++++++++++--- src/demo/Components/InfiniteMenuDemo.vue | 17 ++++++++++-- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/content/Components/InfiniteMenu/InfiniteMenu.vue b/src/content/Components/InfiniteMenu/InfiniteMenu.vue index 4da586c..574b392 100644 --- a/src/content/Components/InfiniteMenu/InfiniteMenu.vue +++ b/src/content/Components/InfiniteMenu/InfiniteMenu.vue @@ -660,7 +660,7 @@ class InfiniteGridMenu { far: 40, fov: Math.PI / 4, aspect: 1, - position: vec3.fromValues(0, 0, props.scale), + position: vec3.fromValues(0, 0, 3), up: vec3.fromValues(0, 1, 0), matrices: { view: mat4.create(), @@ -703,10 +703,10 @@ class InfiniteGridMenu { private onActiveItemChange: (index: number) => void, private onMovementChange: (isMoving: boolean) => void, private onInit?: (menu: InfiniteGridMenu) => void, - scale: number = 1.0 + scale: number = 3.0 ) { this.scaleFactor = scale; - this.camera.position[2] = 3 * scale; + this.camera.position[2] = scale; this.init(); } @@ -1133,6 +1133,26 @@ watch( }, { deep: true } ); + +watch( + () => props.scale, + () => { + if (infiniteMenu && canvasRef.value) { + infiniteMenu.destroy(); + infiniteMenu = new InfiniteGridMenu( + canvasRef.value, + resolvedItems.value, + handleActiveItem, + moving => { + isMoving.value = moving; + }, + menu => menu.run(), + + props.scale + ); + } + } +);