Package 

Class ModelViewer

  • All Implemented Interfaces:
    android.view.View.OnTouchListener

    
    public final class ModelViewer
     implements View.OnTouchListener
                        

    Helps render glTF models into a SurfaceView or TextureView with an orbit controller.

    ModelViewer owns a Filament engine, renderer, swapchain, view, and scene. It allows clients to access these objects via read-only properties. The viewer can display only one glTF scene at a time, which can be scaled and translated into the viewing frustum by calling transformToUnitCube. All ECS entities can be accessed and modified via the asset property.

    For GLB files, clients can call loadModelGlb and pass in a Buffer with the contents of the GLB file. For glTF files, clients can call loadModelGltf and pass in a Buffer with the JSON contents, as well as a callback for loading external resources.

    ModelViewer reduces much of the boilerplate required for simple Filament applications, but clients still have the responsibility of adding an IndirectLight and Skybox to the scene. Additionally, clients should:

    NOTE: if its associated SurfaceView or TextureView has become detached from its window, the ModelViewer becomes invalid and must be recreated.

    See sample-gltf-viewer for a usage example.