Hi,
I’m getting this issue when using SVGLoader.js AND other sub libraries.
i get the message :
"“class constructors must be invoked with ‘new’”.
All I’m getting in research for this message is C++ posts.
Is ANYONE else getting this with the newest (possibly next to last newest revision of three?)
I HAVE to solve this issue. there’s just NO answers for it out there that help!
Thanks!
This would suggest that the other libraries you’re using were written for an older version of three.js. Most of the classes provided by three.js (Mesh, Object3D, etc.) are now ES6 Classes instead of prototype objects (see Eloquent JavaScript Ch. 6), and this means that any third-party code that extends these classes must now be converted from prototype objects to ES6 Classes as well. These ES6 Class conversions began around r120, I’m not sure at which version they completed.
I did a conversion to update the A-Frame Inspector for ES6 Classes recently – see Updates to support recent three.js/a-frame use of ES6 classes. by donmccurdy · Pull Request #627 · aframevr/aframe-inspector · GitHub. The third-party libraries you’re using may need similar updates.
Thank you for that information.
I’ve updated ( though I thought I had) and things seem to be working.
I initially thought that was the issue, and had done so… a second try fixed it. but thanks for the detailed info on the message.
Cheers!
Hi,
I’m back at this issue again.
Could you (or anyone here) possibly give me some example code of how something might be written correctly to fix this issue?
ie: extending a class.
Much appreciated!
There’s nothing special to do — extend the class normally using ES6 Class syntax. If you’re getting this error and you’re not intentionally extending any classes, then the problem is likely to be in some other dependency you are using.
It may help to find the exact code throwing this error in your browser’s debugger.