问题
I have created a Forge Viewer using version 7 of the viewer3d.js and can view a model within it.
My issue is that the measurement and slice tools aren't working as expected. FYI I'm using typescript - angular 8.
I'm expecting the graphics to look like this for a slice:
Instead the plane and gyroscope symbol never appear:
Similarly with the measurement tool, the mouse cursor changes to the measurement cursor, but when i click on a surface, nothing happens.
Here is my code for loading the viewer:
loadViewer(forgeTokenData, modelUrn) {
options = {
env: 'AutodeskProduction',
api: 'derivativeV2',
getAccessToken: (onSuccess) => {
onSuccess((forgeTokenData as any).access_token, (forgeTokenData as any).expires_in);
}};
Autodesk.Viewing.Initializer(options, () => {
// Find the element where the 3d viewer will live.
const htmlElement = document.getElementById('viewerContainer');
if (htmlElement) {
// Create and start the viewer in that element
const viewer = new Autodesk.Viewing.GuiViewer3D(htmlElement);
viewer.start();
const documentId = 'urn:' + this.removeBase64Padding(modelUrn);
console.log(documentId);
this.loadDocument(documentId, viewer);
}});
}
I've also loaded the styles and scripts in my index.html head:
<head>
<meta charset="utf-8">
<title>testing</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/style.min.css" type="text/css">
<script src="https://developer.api.autodesk.com/modelderivative/v2/viewers/7.*/viewer3D.min.js" ></script>
</head>
Not sure why this is happening. Are there any other styles or scripts i'm missing?
I've noticed these errors in the console when i click on the slice / measurement tool:
来源:https://stackoverflow.com/questions/59271906/autodesk-forge-measurement-and-slice-not-working-not-an-instance-of-three-obj