A Icon Handler holds and handle interaction of icons and it´s gpu representation.
The API is required for accessing current scene.
Optionaloptions: IconAtlasOptionsHere you can provide a everything you need to set the icon texture atlas.
// Create an IconHandler instance.
const iconHandler = new IconHandler(api);
// Add a icon atlas to use for all icons. Provide the babylonTextre, the total icon count, the amount of icons in a group and if the texture use the alpha channel.
iconHandler.setIconAtlas({
texture: (await getTexture('./icon.png')),
totalNumberOfIconsAndStyles: 100,
numberOfIconsInAStyle: 1,
hasAlpha: true
});
// Add a icon to be renderd.
iconHandler.attach(new Icon(
"someId",
Math.floor(Math.random() * 100), // Use a random icon form the 10X10 icon atlas.
0, // Use a style index, in this case there is no groups of icons in the texture atlas, so we use the first icon.
1, // Size
new Vector3(0, 0, 0), // Add a position for the icon. (at origin in this case).
new Color4(Math.random(), Math.random(), Math.random(), 1) // Add a random color to the icon, and the max size to the icon. (1).
));
Defines how often the Icons in the IconHandler are alpha sorted (back to front) relative the camera if icons are transparent.
ReadonlyapiThe API is required for accessing current scene.
ReadonlyidUnique id of IconHandler.
Defines how often the Icons in the IconHandler are occlusion culled in milliseconds.
Number if icons.
Render group icons are rendered in.
Sets the render group id 0-4 for all icons. Use this with a larger value to render it on top of other geometry in the engine.
Clears icon handler of all currently attached icons. Attached icons will be detached.
Disposes icon handler. Call when it is no longer in use. After call the icon handler cannot be used again.
Icons currently attached to IconHandler.
This function adds a texture and metadata about it to the icon handler. Changes are automatically reflected in rendering.
Option in the form of IconAtlasOptions.
Icon Handler is a class for handling a set of Icon:s. Make a instance and setIconAtlas with a texture. Then addIcons to provide a array of Icon[]. Each Icon in the handler can be updated using forEach(). Followed by update().