-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Class constructor EventDispatcher cannot be invoked without 'new' #39
Comments
+1 |
1 similar comment
+1 |
Same issue. Have a suspicion that it is connected to parcel. Do you use it?
|
+1 |
1 similar comment
+1 |
same |
I ran into this issue trying to use three.interaction in Vite.js. My solution was to download the repository and include it directly instead of importing it from node_modules. Change There may be a better way, but this worked for me. |
This problem is caused by an inconsistency of three.js and three.interaction.js : three.js is distributed with classes declared as These two ways of class declaration does not get along well (therefore, an error), so the solution is to match ES versions of distributed code. For that, you may either upgrade distributed version of three.interaction.js (peteradamsdev's solution), or downgrade version of three.js with something like Babell (I failed to do so). Note that I'm not talking about version of the libraries; I'm talking about what javascript versions libraries' distributions conform to. Three.js devs claim that official distribution is in ES5, but it's not. Maybe something changed in the last two years. After all this said, for me the optimal solution was to take the source code of three.interaction.js, use |
@nartallax excellent explanation. |
Sure: |
想要在vue中使用这个自定义版本需要这样做
import * as THREE from 'three'
// 事件点击库
import '@/utils/three.interaction.js'
const webpack = require('webpack')
// vue.config.js
module.exports = {
chainWebpack: config => {
config
.plugin('html')
.tap(args => {
args[0].title = 'vue three'
return args
})
.end()
.plugin('provide')
.use(webpack.ProvidePlugin, [{
// 定义THREE为全局变量
THREE: 'three'
}])
.end()
}
}
const interaction = new THREE.Interaction(renderer, scene, camera) |
Does anyone have a fork of three.interaction on npm that does this? |
Have similar issue when trying to use module in browser. Uncaught (in promise) TypeError: class constructors must be invoked with 'new' |
Having the same issue, 'Uncaught TypeError: Class constructor EventDispatcher cannot be invoked without 'new' '. Using react.js Please help |
I speak on behalf of this guy as well. This other guy literally saved our project:
Thank you so much! |
TypeError: Class constructor EventDispatcher cannot be invoked without 'new'
with three.js version 0.128.0
The text was updated successfully, but these errors were encountered: