So, there are should be a TypeScript error in this case right in the IDE, not in runtime. As I understand, the InstancedMesh should be readonly. And what is reason? As we can see in my playground example it works well.
Check the pg I made with typescript and uncoment line 23 to get the same error like you say, but in your pg made with js there is no error because
we don’t have readonly keyword in js. You can set and get anything in js
I talking about TS error, seems it should be an error here:
no errors here
And it has if I define possible type in forEach:
So, it looks like the scene.meshes has irrelevant type — in fact it can be also is InstacedMesh with readonly visibility, but current types does not pass this case.
AbstractMesh is a superclass of InstancedMesh so the typing isn’t “irrelevant”, it’s just considering the more general case. In any case, I wonder if we should define a setter with a warning on InstancedMesh to avoid an error? @RaananW