I am facing an issue with my code. Although there are no errors during compilation, I encounter a console error stating: 'this.trackArray[0].points.getVector() is not a function.'
Below is the snippet where I invoke this function:
const vecteurPoints: THREE.Vector3[] = this.trackArray[0].points.getVector();
The function implementation is as follows:
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, I can navigate to the function definition by ctrl+clicking on it.
The trackArray is obtained through an API call.
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"))
);
}
To call this class, I use the following method:
this.admin.getTracks().subscribe((track: Track[]) => {this.trackArray = track; });