Camera Limits and Annotations are incompatible in the regular viewer and 3D Settings. However, it is possible to combine the two features when using the Viewer API to build an application on top of the Sketchfab viewer in your own website.
There are two options to do this:
- Enable camera limits in 3D Settings like usual, and then use the Viewer API to create annotations at run time. Check out this example. Note how there are camera limits enabled by default, but you can then create annotations.
- Use the Viewer API to manage both camera limits and creating annotations. Check out this example. Notice how both the camera limits and the annotations are being created at run time, using the data from the editor.
In 3D Settings, you can find a "Developer logs" tab to easily copy the JSON data needed to use annotations and camera limits in the Viewer API.
Comments
2 comments
Hi James!
Our team noticed that the annotation position data in the dev logs was not matching up with the annotation position set in the editor. We found it much easier to do the opposite of the first approach. We set camera constraints using the API and then we turned them off in the 3D settings. We then created our annotations in 3D settings. It retained our annotations and constrained the camera no problem!
Ah interesting. Last I tested this, I thought that turning on camera constraints with the Viewer API would fail if there were "regular" annotations (i.e. created and saved in 3D Settings) in the scene. If that's not true, I can update this article to include a third approach that you mention. It actually used to include this until I discovered the above, but maybe I'm wrong here.
To your point about the dev logs not matching annotation positions - you copied those settings but when you create them with the Viewer API they are not in the correct position? Are you using `createAnnotationFromScenePosition` or `createAnnotationFromWorldPosition`? Does it make a difference in correct annotation positions created with the Viewer API?
Please sign in to leave a comment.