How to get xyz cordinates of forge-viewer onClick event?

119 Views Asked by At

I am following this (https://stackblitz.com/edit/angular-forge-viewer-pjyarf?file=app%2Fapp.component.ts) link to get the xyz cordinates of viewer onclick event in Angular.I cant get the viewer properly. Please help to get the solution.

1

There are 1 best solutions below

0
On

ngOnInit() {

this.mainFunction();

}

mainFunction(){ this.viewerOptions = {

initializerOptions: {
    env: 'AutodeskProduction',
    getAccessToken: (
      onGetAccessToken: (token: string, expire: number) => void
    ) => {
      const expireTimeSeconds = 60 * 30;
      onGetAccessToken(ACCESS_TOKEN, expireTimeSeconds);
    },
    api: 'derivativeV2',
    enableMemoryManagement: true,
  },
  onViewerInitialized: (args: ViewerInitializedEvent) => {
    args.viewerComponent.DocumentId = DOCUMENT_URN;
    this.viewer=args.viewer;

  },
  
};

} selectionChanged(e){

const state = this.viewer.viewerState.getState({ viewport: true });
const globalOffset = this.viewer.model.myData.globalOffset

const currentPosition = new THREE.Vector3().fromArray( state.viewport.eye );
const originPosition = currentPosition.clone().add( globalOffset );
  console.log("hiiihhaaaaaa:",originPosition);

}