Variable of 3D object becoming `undefined`, after rendering

Hello, I am making a 3D configuration model app in Angular 10.
I loaded 3D model from the Blender file and stored the model inside the model variable(that contains the loaded 3D model).
after rendering the scene, when I try to access the model variable in another method, I am getting an undefined value.
In belove code, when I invoke changeColorOfTheWholeModel method. I am getting this error:

ERROR TypeError: Cannot read properties of undefined (reading 'traverse')
    at EngineService.changeColorOfTheWholeModel (engine.service.ts:204:19)
    at EngineComponent.ngOnInit (engine.component.ts:22:18)

please help me, I tried everything as possible as I can.
engine.service.ts (5.9 KB)

thanks for reading my post.

i havent touched classes for years but most likely it’s loosing “this”, something like

this.frameId = requestAnimationFrame(this.render.bind(this))
1 Like