我正在尝试将STL文件导入Three.js,但three-stl-loader
npm-module没有找到THREE
对象。
此代码:
import * as THREE from 'three'
import * as THREESTLLoader from 'three-stl-loader'
var STLLoader = new THREESTLLoader()
var loader = new STLLoader(THREE)
loader.load('path/to/file.stl', function (geometry: any) {})
在index.js的第45行(在stl-loader中),three-stl-loader
模块使用THREE
对象,但似乎模块不知道{{1对象根本:
该项目是使用Webpack中的TypeScript编译的。我认为它的编译方式可能存在问题。
答案 0 :(得分:2)
THREE
对象,我只需要将THREE
添加到模块中:
import * as THREE from 'three'
import * as THREESTLLoader from 'three-stl-loader'
var STLLoader = new THREESTLLoader(THREE) // Added THREE
var loader = new STLLoader() // Removed THREE
loader.load('path/to/file.stl', function (geometry: any) {})