0

我正在关注此(https://stackblitz.com/edit/angular-forge-viewer-pjyarf?file=app%2Fapp.component.ts)链接以获取 Angular 中查看器 onclick 事件的 xyz 坐标。我无法获得查看器正确。请帮助获得解决方案。

4

1 回答 1

0

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);

}

于 2021-10-12T08:58:37.367 回答