I have been exploring the use of GLTFExporter
in a three.js project written in TypeScript. I started with a basic template from https://github.com/pinqy520/three-typescript-starter and made modifications to the render
function as follows:
console.log(`type of exporter = ${typeof(THREE.GLTFExporter)}`)
let exporter = new THREE.GLTFExporter()
exporter.parse(scene, (gltf) => {console.log("Parsed scene!"); }, {});
However, upon running npm start
to view it in the browser, I encountered an issue where THREE.GLTFExporter
was undefined, resulting in a "not a constructor" error. It seems like the TypeScript type definition for GLTFExporter
is present in three-gltfexporter.d.ts
, but the actual class itself is not exported from its source file located at
node_modules/three/examples/js/exports/GLTFExporter.js
(lacking the export
keyword). As I am relatively new to TypeScript, I may be missing something important here. Importing other components of three.js works smoothly, leading me to suspect that the issue lies with GLTFExporter
being solely defined within the examples/
directory.