What errors are you getting? Besides, be aware that you set the scaling to the same value over and over again. It’s probably better to do this just once and not during the whole animation.
As I’ve read, it has something to do with objects being not loaded when this function is being executed and it creates error.
I know it is not the best idea to set scaling like this, but later on I will implement a slider (dat.GUI), so it would be possible to change the rim size in real time (this is how my project looks like, car just rolls down the street):
I have edited my previous post and added a link to whole JS code.
I have tried your suggestion and program didn’t crash, but now wheel doesn’t have animations at all, just stuck to the ground (while other wheels spin and go):
And if I do it with !== 'undefined' it gives me the same error.
I think the problem is that you declare wheel_frame_f_right as a global variable but you redeclare it in createWheel_frame_f_right(). So instead of doing this:
var wheel_frame_f_right = new THREE.Mesh(wheel_frame_f_right_geometry, wheel_frame_f_right_material );
do this:
wheel_frame_f_right = new THREE.Mesh(wheel_frame_f_right_geometry, wheel_frame_f_right_material );