I have a problem with my code. I have no error when I compile my code, but I have a console error: this.trackArray[0].points.getVector() is not a function.
Here is my code where I call this function
const vecteurPoints: THREE.Vector3[] = this.trackArray[0].points.getVector();
Here is the function
public getVector(): Vector3[] {
const vecArray: Vector3[] = new Array();
for (const i of this.coordX) {
vecArray[i].x = this.coordX[i];
vecArray[i].y = this.coordY[i];
vecArray[i].z = this.coordZ[i];
}
return vecArray;
}
In VS Code, when I ctrl+click on the function it sends me to the function definition.
I get my trackArray with a call to an API.
export class AdminService {
public constructor( private http: HttpClient ) { }
public getTracks(): Observable<Track[]> {
return this.http.get<Track[]>(this.ADMIN_URL).pipe(catchError(this.handleError<Track[]>("getTracks"))
);
}
And I call this class like this
this.admin.getTracks().subscribe((track: Track[]) => {this.trackArray = track; });
this.trackArray[0]exists?getVector()function is problematic, because it tries to set properties onvecArray[i], whenvecArray[i]hasn't been created yet