3D skin viewer

mosaicary-skin displays a skin as a rotatable 3D figure with standing and walking animations. It can be connected to catalogue selection or used with a local PNG. Choose it when the application needs an interactive preview rather than the fixed card image provided by mosaicary-skin-preview. The 3D entry point includes three.js and requires WebGL.

Choose a file URL or an API object

Set the src attribute for a PNG address or assign a Skin object to the skin property. The object setter supplies both the file address and the arm model. For a raw file, arms accepts classic or slim; when omitted, the image is inspected. Mosaicary preview URLs require ?for=view, or fileOf(item, { view: true }), so a displayed file does not count as a download. Local blob URLs should be revoked after use.

import 'mosaicary/viewer/define';
import { fileOf } from 'mosaicary';
const viewer = document.querySelector('mosaicary-skin');
viewer.skin = skin;
// Equivalent file URL, when handling the arm model separately:
viewer.setAttribute('src', fileOf(skin, { view: true }));

Select animation and inspect the decoded skin

clip="idle" is the initial standing animation and clip="walk" selects walking. The boolean still attribute pauses initial playback; its presence matters, so still="false" still means paused. After decoding, mosaicary-read supplies detail.sheet, also available through viewer.sheet. The sheet reports arms, image dimensions, HD, legacy layout and transparency information. This event describes reading the skin, not a completed download or a user selection.

<mosaicary-skin src="skin.png" arms="slim" clip="walk" still></mosaicary-skin>
viewer.addEventListener('mosaicary-read', ({ detail }) => {
  console.log(detail.sheet.arms, detail.sheet.hd, viewer.sheet);
});

Size the element and its scene

Without an assigned height, the scene derives its dimensions from its width and --mosaicary-stage-ratio, with controls below it. With a height on the element, or one imposed by grid or flex layout, the scene fills the space remaining after controls. This avoids controls overlapping following content. Set a finite height for side panels; use the ratio for naturally flowing article previews. Both arrangements preserve drag, zoom and reset controls.

mosaicary-skin {
  height: 360px;
}
/* Without an explicit height: */
.preview {
  --mosaicary-stage-ratio: 4 / 3;
}

Preserve state during language changes

An element without its own lang follows the nearest parent, including <html lang>, as it changes. Updating that language or assigning words refreshes labels while retaining the loaded skin and camera. An explicit element language takes precedence. If WebGL is unavailable, the viewer displays a localized explanation instead of a working scene; applications should keep file information and other actions available outside the viewer. No mosaicary-error event is promised for viewer failures.