I wrote an extension for the forge viewer (using angular) but its giving a runtime error saying Autodesk is not defined
export class MyExtension extends Autodesk.Viewing.Extension {
public static extensionName: string = 'MyExtension';
public load() {
console.log('MyExtension loaded!');
return true;
}
public unload() {
console.log('MyExtension unloaded.');
return true;
}
}
I did an npm install @types/forge-viewer and am able to use Autodesk inside a class without any error, just not able to extend it. Does anyone know how to solve this?
Edit: This question seems to be similar to my problem, but I don't understand how the op created the Extension class or how its actually extending the Autodesk.Viewing.Extension since they didn't provide code for that. Using Forge Javascript-based Extension in Angular app
The @types/forge-viewer
module only includes type definitions, not the actual Forge Viewer code. The viewer code is obtained from https://developer.api.autodesk.com, for example:
This library must be loaded before you start defining your viewer extension classes.