Skip to content

feat: type writer property as GLTFWriter in VariantMaterialExporterPlugin#5175

Open
rajkandula wants to merge 1 commit into
google:masterfrom
charanrajkandula-opensource:feat/exporter-gltfwriter-type
Open

feat: type writer property as GLTFWriter in VariantMaterialExporterPlugin#5175
rajkandula wants to merge 1 commit into
google:masterfrom
charanrajkandula-opensource:feat/exporter-gltfwriter-type

Conversation

@rajkandula

Copy link
Copy Markdown

Description

This PR replaces the any type on the writer property in VariantMaterialExporterPlugin.ts with the concrete GLTFWriter imported from three/examples/jsm/exporters/GLTFExporter.js.

Since @types/three is missing declarations for processMaterialAsync and json on GLTFWriter, this PR utilizes TypeScript module augmentation to safely extend the type. It also adds a type predicate (material is Material) to compatibleMaterial to safely narrow material types within loops and ternary expressions.

This resolves the pending @TODO comment in the exporter plugin file.

Reference Issue

None (resolves a pending inline TODO comment).

Testing

  • Verified successful workspace builds using npm run build.
  • Ran the test suite via npm run test:ci with all tests passing:
    • @google/model-viewer: 393 passed, 0 failed
    • @google/model-viewer-effects: 13 passed, 0 failed
    • @google/model-viewer-space-opera: 99 passed, 0 failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant