目录

Loading a 3DGS Model

Use Cases

A 3DGS module can be in MP4, PLY, or GLB format

The following figure shows an example.

API Description

The following lists only some of the main APIs called in the sample code in this guide.

API Description
static loadGSNode(scene: Scene, params: GSImportSettings, parent?: Node): Promise<GSNode> Loads a 3DGS model.

Development Procedure

  1. In the entry directory, open /src/main/ets/entryability/EntryAbility.ets and import the spatial modeling module.

    import { spatialRender } from '@kit.SpatialReconKit';
    import { Scene, RenderContext } from '@kit.ArkGraphics3D'
  2. Load the context of the current scene.

    let renderContext: RenderContext | null = Scene.getDefaultRenderContext();
  3. Call the API for loading a 3DGS model.

    if (renderContext != null) {
      renderContext.loadPlugin(spatialRender.GSPlugin.PLUGIN_ID);
      let scene = Scene.load().then(async (scene: Scene) => {
        let uri = "OhosRawFile://assets/gltf/model.glb"; // URI of the 3DGS model. Change it as needed.
        let offset = 0;
        let gsNodeext: spatialRender.GSNode = await spatialRender.GSPlugin.loadGSNode(scene, {uri, offset}, scene.root);
      });
    }