From 5763db93f7df63992bdb5ee7627ba81358281b4f Mon Sep 17 00:00:00 2001 From: Mohammad Baghaei Date: Fri, 31 Jan 2025 01:00:52 +0330 Subject: [PATCH] add ar-usdz-max-texture-size (related #4984 issue) --- packages/model-viewer/src/features/ar.ts | 13 +++++++++++-- packages/modelviewer.dev/data/docs.json | 9 +++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/model-viewer/src/features/ar.ts b/packages/model-viewer/src/features/ar.ts index 6c3e9aaf85..b7e7fd6eb2 100644 --- a/packages/model-viewer/src/features/ar.ts +++ b/packages/model-viewer/src/features/ar.ts @@ -72,6 +72,7 @@ export declare interface ARInterface { arPlacement: string; iosSrc: string|null; xrEnvironment: boolean; + arUsdzMaxTextureSize: string; readonly canActivateAR: boolean; activateAR(): Promise; } @@ -83,6 +84,9 @@ export const ARMixin = >( @property({type: String, attribute: 'ar-scale'}) arScale: string = 'auto'; + @property({type: String, attribute: 'ar-usdz-max-texture-size'}) + arUsdzMaxTextureSize: string = 'auto'; + @property({type: String, attribute: 'ar-placement'}) arPlacement: string = 'floor'; @@ -182,7 +186,8 @@ export const ARMixin = >( } if (changedProperties.has('ar') || changedProperties.has('arModes') || - changedProperties.has('src') || changedProperties.has('iosSrc')) { + changedProperties.has('src') || changedProperties.has('iosSrc') || + changedProperties.has('arUsdzMaxTextureSize')) { this[$selectARMode](); } } @@ -446,7 +451,11 @@ configuration or device capabilities'); model.position.copy(target.position); model.updateWorldMatrix(false, true); - const arraybuffer = await exporter.parseAsync(model); + const arraybuffer = await exporter.parseAsync(model, { + maxTextureSize: isNaN(this.arUsdzMaxTextureSize as any) ? + Infinity : + Math.max(parseInt(this.arUsdzMaxTextureSize), 16), + }); model.position.set(0, 0, 0); target.add(model); diff --git a/packages/modelviewer.dev/data/docs.json b/packages/modelviewer.dev/data/docs.json index df297c9931..ff3eaffa17 100644 --- a/packages/modelviewer.dev/data/docs.json +++ b/packages/modelviewer.dev/data/docs.json @@ -355,6 +355,15 @@ "ios-src example" ] }, + { + "name": "ar-usdz-max-texture-size", + "htmlName": "arUsdzMaxTextureSize", + "description": "Set texture max resolution for Quick Look auto generated USDZ model.", + "default": { + "default": "Infinity (no limits for maximum texture resolution)", + "options": "Number greater than or equal to 16" + } + }, { "name": "xr-environment", "htmlName": "xrEnvironment",