How jaxzin/lkg-blocks-viewer works
Project type and purpose
• This is a client-side, single-page VR viewer built with React (JSX/TSX) and Vite. It is not a multi-tier full-stack service but a browser-based application that uses three.js for 3D/WebXR scenes. Its goal is to render “quilt” images in 3D space, handle VR controller interactions, and integrate with the Blocks Auth system so users can “play with Blocks like trading cards.”
File structure
• Top-level directories:
• build/ – output for production (assets, HTML, compiled JS)
• public/ – static assets served as-is (including XRScene.js, script.js)
• src/ – application source code
• Within src/:
• app.jsx, index.jsx – entrypoints
• components/ – React UI components (BlockCard, LoginButton, QuiltMaterial, etc.)
• pages/ – routed pages (home, about, block-test, xr-test)
• hooks/ – custom React hooks (useBlocksAuth, XR wiggle, reduced-motion)
• lib/ – standalone libraries (blocksAuthClient)
• styles/ – CSS files
• Configuration: vite.config.js for bundling; package.json for dependencies; shrinkwrap.yaml/package-lock.json for lockfiles.
README for additional insights
• Goals:
1. Custom shader for quilt images
2. WebXR controller integration
3. Blocks trading-card interactions
• Tech stack: three.js, React, Vite, WebXR API, custom shaders, BlocksAuth (likely calls external Blocks wallet service).
Main components and their interactions
a. Browser & User
• User operates in a WebXR-capable browser.
b. React SPA (app.jsx → router.tsx → pages + components)
• Renders UI and bootstraps three.js scene.
c. three.js Renderer & Scene Graph
• Hosts QuiltMaterial shader; updates per XR frame.
d. WebXR Device API
• Feeds VR headset/controller input to three.js.
e. BlocksAuth Client
• useBlocksAuth hook → lib/blocksAuthClient.ts → external Blocks API (authentication, user data).
f. Static Assets & Quilt Textures
• mesh geometry, quilt images served from public/ or build/assets.
Architectural patterns & design principles
• Component-based UI (React).
• SPA routing (Router TSX).
• Separation of concerns:
• UI layer (components)
• Rendering layer (three.js + custom shader)
• Auth/data layer (BlocksAuth client)
• Build pipeline (Vite): dev vs. prod (build/ folder).