Cannot read property 'rotation' of undefined

I tried loading with GLTFLoader. I get that it’s asynchronous therefore the declaration occurs after the animate function is called. It’s just that I don’t know how to get it to work. The thing I’ve tried is calling the animate function in the loader but doesn’t feel quite right

Link to the code:

Try putting

if(model) model.rotation.y -= 0.1

What happens is, the program tries to access the property rotation but your model is undefined, so it complains about not being able to access the property of a non-existing object.