feat(optimization): migrate to Supabase Edge Functions & Storage#554
Open
Schlomoh wants to merge 10 commits into
Open
feat(optimization): migrate to Supabase Edge Functions & Storage#554Schlomoh wants to merge 10 commits into
Schlomoh wants to merge 10 commits into
Conversation
Adds an optional encoder field to TextureCompressOptions, allowing callers to supply a custom image processor instead of relying on the sharp native binary. When encoder is provided it is passed directly to @gltf-transform/functions; otherwise sharp is dynamically imported as before, preserving full backward compatibility. This unlocks use of @vctrl/core in Deno/edge environments (e.g. Supabase Edge Functions) where native binaries are unavailable. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the GCP Cloud Functions v2 optimize-textures worker with a Supabase Edge Function that runs locally via `supabase functions serve` with zero GCP credentials required. - index.ts: HTTP handler preserving the exact Cloud Function contract - encoder.ts: imagescript-based encoder (pure TS/WASM, no native binaries) with a sharp-compatible shim for use with @vctrl/core - types.ts: single source of truth for request contracts and parsing Contributors can test locally with: supabase functions serve optimize-textures curl -X POST http://localhost:54321/functions/v1/optimize-textures ... Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tion Replaces the GCP Cloud Function proxy and local Sharp fallback with a call to the optimize-textures Supabase Edge Function. The function URL is derived from the existing SUPABASE_URL env var so no new variables are required. The OPTIMIZE_TEXTURES_WORKER_URL and OPTIMIZE_TEXTURES_WORKER_TOKEN env vars are no longer read. Quota enforcement and request validation are unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…GlbBuffer Non-texture optimizations (simplify/dedup/quantize/normals) now run in an off-main-thread Web Worker so the UI stays responsive during CPU-intensive operations. Results are transferred back via zero-copy ArrayBuffer handoff and reloaded into the optimizer via a new loadFromGlbBuffer hook method. Texture compression continues through the Supabase Edge Function as before. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace @google-cloud/storage with Supabase Storage (service role client) for all asset upload, download, and delete operations. Enable the storage service in supabase/config.toml and add a migration that creates the private assets bucket with RLS policies mirroring the assets table access rules. Remove the @google-cloud/storage dependency from package.json. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Delete the legacy apps/vectreal-platform/functions/optimize-textures/ Cloud Function source that is superseded by the Supabase Edge Function. Remove the Terraform resources (optimization-functions.tf), variables, output, and artifact zip for the Cloud Function. Update .env.development.example to drop GCP storage vars and add SUPABASE_SERVICE_ROLE_KEY entries. Fix two type errors in optimization.worker.ts (postMessage transfer + OperationProgress field name). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Remove the validateLocalGoogleCloudStorageConfiguration() call from entry.server.tsx and delete gcloud-storage.server.ts — the last GCP dependency blocking local dev without GCP credentials. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Updated `useCalcOptimizationInfo` to use state instead of ref for initial report, ensuring re-renders on capture. - Enhanced `useOptimizeModel` to support loading GLTF models directly from raw bytes with asset maps. - Introduced `createBrowserTextureEncoder` for client-side texture compression using OffscreenCanvas, removing server dependency. - Simplified texture optimization logic by removing server-side optimization functions and delegating to the new browser encoder. - Removed unused validation utilities and adjusted server communication to streamline request handling.
Member
Author
Code reviewFound 3 issues:
vectreal-platform/packages/hooks/src/use-load-model/file-loaders.ts Lines 31 to 36 in 9abe1ab
Lines 30 to 34 in 9abe1ab
vectreal-platform/packages/hooks/src/use-load-model/use-load-model.ts Lines 276 to 285 in 9abe1ab 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several significant improvements to the optimization workflow in the Vectreal platform, focusing on transitioning asset storage from Google Cloud Storage (GCP) to Supabase Storage, enhancing the optimization drawer UI with detailed metrics and file size comparisons, and modularizing optimization utilities for better maintainability and clarity.
Key changes include:
Migration from GCP to Supabase Storage
.env.development.exampleto remove GCP storage credentials and variables, replacing them with Supabase equivalents and clarifying that Supabase Storage is now used for asset storage in all environments. [1] [2] [3]CLAUDE.mdto reflect the storage migration and new Supabase workflow, including commands for serving Supabase edge functions and clarifying the role of theterraformdirectory. [1] [2]Optimization Drawer UI & Metrics Enhancements
optimization-drawer.tsx) to display detailed before-and-after metrics, including triangles, texture size, and file size, with animated transitions and clear percentage/file size reduction labels. Added a dedicatedFileSizeComparisoncomponent for visualizing file size changes. [1] [2] [3] [4] [5] [6] [7]Modularization and Utility Improvements
geometry-worker.ts: Runs geometry optimizations in a Web Worker to keep the UI responsive.optimization-quota.ts: Handles quota checks and consumption for optimization runs, including guest limits and error handling.scene-size.ts: Provides hooks for calculating scene and texture sizes post-optimization.utils/index.tsfor easier imports.Project Structure and Configuration
.claude/skills/to reference skills managed in.agents/skills/, ensuring proper skill resolution. [1] [2] [3]These changes collectively modernize the asset storage approach, improve the user experience around model optimization, and enhance the maintainability of the optimization codebase.- feat(core): expose optional encoder injection in TextureCompressOptions