public final class ARModel
- Object
- 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 IOException | Reads 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
glbOrGltfbyte[]- the raw model bytes
Returns
the model descriptor
fromGltf
public static ARModel fromGltf(InputStream in)
throws IOExceptionReads all bytes from the stream and creates a glTF model. The stream is
closed.
Parameters
inInputStream- a stream over
.glbor.gltfbytes
Returns
the model descriptor
Throws
fromMesh
public static ARModel fromMesh(Mesh mesh, int argbColor)Creates a model from a mesh rendered in a single solid color.
Parameters
meshMesh- the geometry, in meters
argbColorint- 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
meshMesh- the geometry, in meters, with texture coordinates
textureImage- 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.