public final class ARModel

  1. Object
  2. ARModel

The renderable content of an ARNode: geometry plus an optional base-color texture or solid color. Models are immutable descriptors - the platform backend uploads them into its native renderer when the node is attached to an anchor.

Create a model either from a glTF 2.0 asset (.glb or .gltf bytes, parsed with com.codename1.gpu.GltfLoader) or directly from a com.codename1.gpu.Mesh such as one built by com.codename1.gpu.Primitives. Geometry units are meters in the anchor’s local frame.

Methods

public static ARModel fromGltf(byte[] glbOrGltf)Creates a model from in-memory glTF 2.0 bytes (binary .glb or JSON .gltf).
public static ARModel fromGltf(InputStream in) throws IOExceptionReads all bytes from the stream and creates a glTF model.
public static ARModel fromMesh(Mesh mesh, int argbColor)Creates a model from a mesh rendered in a single solid color.
public static ARModel fromMesh(Mesh mesh, Image texture)Creates a model from a mesh with a base-color texture.
public byte[] getGltfBytes()The raw glTF bytes as a newly allocated array, or null for mesh-based models.
public synchronized Mesh getMesh()The model geometry.
public synchronized Image getBaseColorImage()The decoded base-color image, or null when the model has none.
public int getColor()The solid base color as 0xAARRGGBB, used when the model carries no texture.

Inherited methods

Method details

fromGltf

public static ARModel fromGltf(byte[] glbOrGltf)
Creates a model from in-memory glTF 2.0 bytes (binary .glb or JSON .gltf). The geometry and base-color texture are parsed lazily on first access.

Parameters

glbOrGltf byte[]
the raw model bytes

Returns

the model descriptor

fromGltf

public static ARModel fromGltf(InputStream in) throws IOException
Reads all bytes from the stream and creates a glTF model. The stream is closed.

Parameters

in InputStream
a stream over .glb or .gltf bytes

Returns

the model descriptor

fromMesh

public static ARModel fromMesh(Mesh mesh, int argbColor)
Creates a model from a mesh rendered in a single solid color.

Parameters

mesh Mesh
the geometry, in meters
argbColor int
the solid base color as 0xAARRGGBB

Returns

the model descriptor

fromMesh

public static ARModel fromMesh(Mesh mesh, Image texture)
Creates a model from a mesh with a base-color texture.

Parameters

mesh Mesh
the geometry, in meters, with texture coordinates
texture Image
the base-color image

Returns

the model descriptor

getGltfBytes

public byte[] getGltfBytes()
The raw glTF bytes as a newly allocated array, or null for mesh-based models.

getMesh

public synchronized Mesh getMesh()
The model geometry. For glTF models the geometry is parsed on first access.

getBaseColorImage

public synchronized Image getBaseColorImage()
The decoded base-color image, or null when the model has none. For glTF models the image is extracted on first access.

getColor

public int getColor()
The solid base color as 0xAARRGGBB, used when the model carries no texture. Defaults to opaque white.