Updated THREE, and it looks like I can't use derived classes any more?

I just updated THREE from the last version recorded as three.js in NPM to the latest one, so 0.77.0 to 0.122.0. Suddenly, something that had been working perfectly until now stopped doing so. I was using some custom classes inheriting from THREE classes like Mesh, Group etc. Nothing to do with the graphics themselves, really, they mostly provided convenience methods to access or edit properties. Now however the same objects give me a series of errors like:

three.js:5292 THREE.Object3D.add: object not an instance of THREE.Object3D

Is this an expected change in behaviour? Should I just change my code to account for this or what?

Do you mind sharing your repository that demonstrates the issue? Right now, it’s not clear what produces the mentioned error message.

It’s this one: https://github.com/stur86/crystvis-js

The derived classes giving me trouble in particular are found in https://github.com/stur86/crystvis-js/blob/b381bfaf283451d4fc5ecb9d8fbd8c0b181bdb62/lib/graphics.js and used in https://github.com/stur86/crystvis-js/blob/b381bfaf283451d4fc5ecb9d8fbd8c0b181bdb62/lib/render.js. Those should be the critical spots.

TBH, I’ve expected you would share an app that I can debug offline. It seems there are only unit tests in your repo.

BTW: I can’t see something problematic if I just look at the code.

You can try it with npm run test-html and then open the test app in localhost:8080. The console is full of error messages.

Okay. But doing this gives me:

sh: http-server: command not found

You should always configure a project with all dev dependencies and not assume certain stuff is globally installed on a system. Anyway, I’ve added latest http-server myself to package.json. After running the command, everything seems to work fine:

I have no error messages in my browser console.

2 Likes

Ok, thanks, so there’s just something wrong in my installation for some reason. Good to know. And yeah, for http-server I’ve used it globally for so long I forgot about it in this repo.