Take a screenshot of a SceneView
This sample shows how to use the SceneView.takeScreenshot() method to create an image of the current view. The method returns a promise that resolves with a Screenshot object that contains the raw ImageData and the image as a data url. In this sample we add the image data to a canvas so that we can add a custom text on top of it.
Several options can be passed into the method.
The image format can be jpg
or png
. If the format is jpg
you can also set the quality parameter.
The image can be scaled up or down, by setting the width or the height of the image:
Sometimes it is useful to create an image of an area of the view. In this case we can use the area
parameter to only take a screenshot of a section of the screen: