feat(twin-renderer): Three.js USD product twin renderer + Varitea demo#16
Open
ninan-versioning wants to merge 1 commit into
Open
feat(twin-renderer): Three.js USD product twin renderer + Varitea demo#16ninan-versioning wants to merge 1 commit into
ninan-versioning wants to merge 1 commit into
Conversation
Browser-side renderer consuming product_twin.usda from @shoploop/connector-shopify. Minimal USDA->scene-graph parser, r3f scene builder with procedural placeholder + external GLB/USDZ refs, ProductTwin/VariantSelector/Stage components, and a Varitea demo. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
New package
@shoploop/twin-renderer(packages/twin-renderer/) — the browser-side counterpart to the open-imagine GPU render path. Same source-of-truthproduct_twin.usdaemitted by@shoploop/connector-shopify(#15), two consumers: interactive browser preview here, offline EXR render there.src/parser/usda.ts— minimal, dependency-free USDA → typedProductTwinStageAST. Covers exactly the connector's subset: layer metadata +customLayerData,def/over/classprims,Xform/Mesh/Material/Scope, prim metadata (kind,variantSets,variants,references,apiSchemas), typed attrs (string/int/float/bool/token/asset +[]arrays + numeric tuples), relationships,variantSetblocks,commerce:*/brand:*. No heavy USD libs, no WASM.src/scene/build.ts— AST →THREE.Group. Honors authored mesh geometry, renders a tasteful procedural tea-tin (rounded cylinder) for placeholder meshes, and resolves external GLB/USDZ refs via an injectable loader (kept synchronous + network-free for tests).src/scene/loaders.ts—GLTFLoader/USDZLoaderwrapper (browser only; no SSR of GLBs).<ProductTwin>(props:productTwinUrl,initialVariants,onVariantChange,environment,cameraPresethero|pdp|lifestyle),<VariantSelector>(reads variant sets from the parsed stage, standalone or via context),<Stage>(HDRI + soft warm light + DOF on hero + subtle bloom + vignette + ground shadow — no sterile gray-studio look, no debug helpers).demo/— Varitea-styled card loading the canonical fixture with a working size switcher.pnpm devserves it on:5173.shoploop-shopify ingestoutput, perf notes) + DESIGN.md (Kinfolk gate).Public API is intentionally tiny and stable — it ships into the Varitea landing page (separate PR).
Components
ProductTwin·VariantSelector·Stage·parseUsda/getVariantSets/resolveVariantData/getLayerCommerce·buildScene·createAssetLoader·TwinContext/useTwinContext.Perf budget
heropreset (placeholder twin).pdp/lifestyleorbloom={0}on low-end.dprcapped[1,2], 2048² shadow map. Geometry built once per stage; variant switches are allocation-free.Decision gate
Testing
pnpm --filter @shoploop/twin-renderer test— 14 passing (parser AST shape: xform/variant-set names/commerce attrs/asset refs/over; scene builder: placeholder graph, per-variant userData, tea-tin vs box, injected GLB loader).pnpm --filter @shoploop/twin-renderer typecheck— clean.pnpm --filter @shoploop/twin-renderer build— ESM lib (+ rolled-up.d.ts) and demo site both build.:5173serving the Varitea demo + fixture (verified 200s).Varitea acceptance:
pnpm --filter @shoploop/twin-renderer devloads the Varitea twin with a working variant switcher at 60fps on a 2021 MBP.Screenshot/gif: placeholder — capture from
pnpm devon:5173.🤖 Generated with Claude Code