# graphics3d/skinnedmodel (vanilla.js 0.4.0)

> https://vanillapunch.com/docs/vanilla.js/0.4.0/api/graphics3d/skinnedmodel/

Skinned model. (model instance, mesh/bone/skin/material/animation data + pose state)

## SkinnedModel extends Object

Skinned model. (model instance, mesh/bone/skin/material/animation data + pose state)
- Interprets GLB (binary glTF) and binary FBX into a common neutral schema and builds GL resources.
- Static meshes without a skin are uploaded with a synthetic skin (1 joint) and morph targets as float textures, and drawn through the same skinning path.
- Supports animation crossfade, joint rotation offsets (procedural pose processing), and morph weights (glTF weights / program).
- Rendering is handled by SkinnedModelRenderer. (The model has no rendering functionality)

Example: Load a GLB model and play the walk animation

```js
import { SkinnedModel, SkinnedModelRenderer, Camera3D, Matrix4, Vector3 } from "./build/vanilla.js";

const width = 640;
const height = 360;
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
document.body.appendChild(canvas);
const webGL2RenderingContext = canvas.getContext("webgl2");
const skinnedModelRenderer = new SkinnedModelRenderer(webGL2RenderingContext);
const skinnedModel = await SkinnedModel.loadFromUrl(webGL2RenderingContext, "examples/ancientmountain/assets/fox.glb", skinnedModelRenderer);
const animationNameList = skinnedModel.getAnimationNameList();
console.log(animationNameList.join(", "));
skinnedModel.playAnimation("Walk", 0);

const cameraX = 0;
const cameraY = 80;
const cameraZ = 220;
const camera = new Camera3D();
camera.setPerspective(Math.PI / 3, 1, 2000);
camera.setAspectRatio(width / height);
const eyePosition = Vector3.create(cameraX, cameraY, cameraZ);
const targetPosition = Vector3.create(0, 45, 0);
camera.lookAt(eyePosition, targetPosition);
const viewProjectionMatrix = camera.getViewProjectionMatrix();
const viewProjectionElements = viewProjectionMatrix.getElements();
const modelMatrix = Matrix4.createIdentity();
const modelMatrixElements = modelMatrix.getElements();
webGL2RenderingContext.enable(webGL2RenderingContext.DEPTH_TEST);

let previousTime = performance.now();
function drawFrame(currentTime) {
	const deltaTime = Math.max(0, currentTime - previousTime) / 1000;
	previousTime = currentTime;
	skinnedModel.update(deltaTime);
	webGL2RenderingContext.viewport(0, 0, width, height);
	webGL2RenderingContext.clearColor(0.16, 0.2, 0.26, 1);
	webGL2RenderingContext.clear(webGL2RenderingContext.COLOR_BUFFER_BIT | webGL2RenderingContext.DEPTH_BUFFER_BIT);
	skinnedModelRenderer.draw(skinnedModel, viewProjectionElements, modelMatrixElements, cameraX, cameraY, cameraZ);
	requestAnimationFrame(drawFrame);
}
requestAnimationFrame(drawFrame);
```

- `constructor(webGL2RenderingContext, shaderProgram)` (constructor, since 0.3.0): Constructor.
  - `webGL2RenderingContext` WebGL2RenderingContext: WebGL2 rendering context. (when null, the model does no GL upload)
  - `shaderProgram` ShaderProgram: Shader program used for attribute locations and materials. (usually the renderer's getShaderProgram, no upload when null)
- `static createWithoutShaderProgram()` (static, since 0.4.0): Creates without a shader. (static, a model that only interprets and computes poses, uploadMeshesAndMaterials throws)
  - Uses only interpretContent / interpretFbxContent and update without GL, such as for animation source models or unit tests.
  - returns SkinnedModel: Model without GL or a shader.

  Example: Interpret a GLB and compute only the pose without GL

  ```js
  import { SkinnedModel } from "./build/vanilla.js";
  
  const response = await fetch("examples/ancientmountain/assets/fox.glb");
  const arrayBuffer = await response.arrayBuffer();
  const glbChunks = SkinnedModel.readGlbChunks(arrayBuffer);
  const skinnedModel = SkinnedModel.createWithoutShaderProgram();
  const interpretation = skinnedModel.interpretContent(glbChunks.json, glbChunks.binaryBuffer);
  skinnedModel.playAnimation("Run", 0);
  skinnedModel.update(0.5);
  const nodeList = skinnedModel.getNodeList();
  console.log(interpretation.meshDescriptionList.length, nodeList.length);
  ```

- `static async loadFromUrl(webGL2RenderingContext, url, skinnedModelRenderer)` (static, since 0.3.0): Loads from URL. (static, GLB binary glTF)
  - `webGL2RenderingContext` WebGL2RenderingContext: WebGL2 rendering context.
  - `url` string: GLB file URL.
  - `skinnedModelRenderer` SkinnedModelRenderer: Renderer to borrow the shader program from.
  - returns Promise<SkinnedModel>: Model with its GL resources uploaded. (throws if the response fails or the file is not GLB)
- Uses the asset cache. If the same path (SkinnedModelAsset.normalizeKey) was already loaded with the same shader program, returns a new instance sharing that asset without fetching or parsing.
  If a load of it is in progress, waits for it and shares the result.
- `static createFromAsset(skinnedModelAsset)` (static, since 0.4.0): Create an instance from an asset. (static, shares the asset's buffers, material prototypes and clips, keeps its own pose and playback state, no GPU upload)
  - `skinnedModelAsset` SkinnedModelAsset: Asset to share. (throws if the asset was destroyed)
  - returns SkinnedModel: New instance that added one to the asset's reference count. (nodes are copied from the prototypes taken when the asset was uploaded)
- `createInstance()` (method, since 0.4.0): Create an instance. (a new model sharing this model's asset; like Unity's Instantiate, GPU resources are not uploaded again)
  - returns SkinnedModel: New instance. (nodes copied from the prototypes taken when the asset was uploaded, playback starts fresh; throws before upload)

  Example: Load one fox and spawn ten

  ```js
  import { SkinnedModel, SkinnedModelRenderer } from "./build/vanilla.js";
  
  const canvas = document.createElement("canvas");
  const webGL2RenderingContext = canvas.getContext("webgl2");
  const skinnedModelRenderer = new SkinnedModelRenderer(webGL2RenderingContext);
  const sourceModel = await SkinnedModel.loadFromUrl(webGL2RenderingContext, "examples/ancientmountain/assets/fox.glb", skinnedModelRenderer);
  const modelList = [sourceModel];
  for (let modelIndex = 1; modelIndex < 10; ++modelIndex) {
  	const instanceModel = sourceModel.createInstance();
  	instanceModel.playAnimation(modelIndex % 2 === 0 ? "Walk" : "Run", 0);
  	modelList.push(instanceModel);
  }
  const skinnedModelAsset = sourceModel.getAsset();
  console.log(skinnedModelAsset.getReferenceCount(), skinnedModelAsset.getGpuByteCount());
  for (const model of modelList) {
  	model.destroy();
  }
  console.log(skinnedModelAsset.isDestroyed());
  ```

- `getAsset()` (method, since 0.4.0): Return the asset.
  - returns SkinnedModelAsset | null: Shared asset. (null before upload or after destroy)
- `static async loadFromBytes(webGL2RenderingContext, arrayBuffer, skinnedModelRenderer)` (static, since 0.4.0): Loads from bytes. (static, GLB binary glTF, the part of loadFromUrl after fetch)
  - Builds from data already received, such as bytes included in a bundle or a BlobAsset.
  - `webGL2RenderingContext` WebGL2RenderingContext: WebGL2 rendering context.
  - `arrayBuffer` ArrayBuffer: GLB file bytes.
  - `skinnedModelRenderer` SkinnedModelRenderer: Renderer to borrow the shader program from.
  - returns Promise<SkinnedModel>: Model with its GL resources uploaded. (throws when the data is not a GLB)

  Example: Build a model from bytes already received

  ```js
  import { SkinnedModel, SkinnedModelRenderer } from "./build/vanilla.js";
  
  const canvas = document.createElement("canvas");
  const webGL2RenderingContext = canvas.getContext("webgl2");
  const skinnedModelRenderer = new SkinnedModelRenderer(webGL2RenderingContext);
  const response = await fetch("examples/ancientmountain/assets/fox.glb");
  const arrayBuffer = await response.arrayBuffer();
  const skinnedModel = await SkinnedModel.loadFromBytes(webGL2RenderingContext, arrayBuffer, skinnedModelRenderer);
  const drawableList = skinnedModel.getDrawableList();
  console.log(drawableList.length);
  skinnedModel.destroy();
  ```

- `static async loadFromFbxUrl(webGL2RenderingContext, url, skinnedModelRenderer)` (static, since 0.3.0): Loads from URL. (static, binary FBX)
  - `webGL2RenderingContext` WebGL2RenderingContext: WebGL2 rendering context.
  - `url` string: Binary FBX file URL.
  - `skinnedModelRenderer` SkinnedModelRenderer: Renderer to borrow the shader program from.
  - returns Promise<SkinnedModel>: Model with its GL resources uploaded. (uses the asset cache like loadFromUrl)
- `static async loadFromFbxBytes(webGL2RenderingContext, arrayBuffer, skinnedModelRenderer)` (static, since 0.4.0): Loads from bytes. (static, binary FBX, the part of loadFromFbxUrl after fetch)
  - `webGL2RenderingContext` WebGL2RenderingContext: WebGL2 rendering context.
  - `arrayBuffer` ArrayBuffer: Binary FBX file bytes.
  - `skinnedModelRenderer` SkinnedModelRenderer: Renderer to borrow the shader program from.
  - returns Promise<SkinnedModel>: Model with its GL resources uploaded.
- `static readGlbChunks(arrayBuffer)` (static, since 0.4.0): Reads GLB chunks. (static, header check + JSON chunk + BIN chunk, GL independent)
  - `arrayBuffer` ArrayBuffer: GLB file bytes.
  - returns { json: object, binaryBuffer: ArrayBuffer }: Object read from the JSON chunk and the BIN chunk bytes. (throws when the header is not GLB, a chunk is broken, or either JSON or BIN is missing)
- `async parseBinary(arrayBuffer)` (method, since 0.3.0): Interprets GLB binary.
  - `arrayBuffer` ArrayBuffer: GLB file bytes.
- `async parseContent(json, binaryBuffer)` (method, since 0.3.0): Parses glTF content. (nodes / skins / meshes / animations / textures → GL upload)
  - `json` object: glTF JSON.
  - `binaryBuffer` ArrayBuffer: BIN chunk of the GLB.
- `interpretContent(json, binaryBuffer)` (method, since 0.4.0): Parses glTF content. (GL independent, fills nodes / skins / animations and returns neutral mesh / material descriptions)
  - External (uri) images get no texture, skins without inverseBindMatrices use identity matrices, channels with no node or an unknown path are dropped.
  - A primitive without normals has flat normals (one per triangle) as the glTF 2.0 specification says. Vertices are split per triangle and given the face normal, and indices is null.
  - `json` object: glTF JSON.
  - `binaryBuffer` ArrayBuffer: BIN chunk of the GLB.
  - returns { meshDescriptionList: object[], materialDescriptionList: object[] }: Neutral mesh description list and neutral material description list. (passed to uploadMeshesAndMaterials)
- `async parseFbxContent(sceneData)` (method, since 0.3.0): Parses the FBX intermediate representation. (nodes/skins/meshes/textures/animations → existing skinning pipeline)
  - `sceneData` object: Intermediate representation read by FbxLoader.
- `interpretFbxContent(sceneData)` (method, since 0.4.0): Parses the FBX intermediate representation. (GL independent, fills nodes / skins / animations and returns neutral mesh / material descriptions)
  - Clusters without a bone get an identity joint, vertex indices outside the array are skipped. Like the original, only meshes with a skin attached are kept.
  - `sceneData` object: Intermediate representation read by FbxLoader.
  - returns { meshDescriptionList: object[], materialDescriptionList: object[] }: Neutral mesh description list and neutral material description list. (passed to uploadMeshesAndMaterials)
- `static splitFbxCornersByMaterial(materialIndexPerTriangle, cornerArrays)` (static, since 0.4.0): Split FBX corners by material. (Static, non-indexed corner arrays, GL independent)
  - When one mesh has several materials, it is drawn as one sub-mesh per material. (Groups in three.js FBXLoader, sub-meshes in Unity and Unreal)
  - Sub-meshes come in ascending material number and keep the original triangle order. With only one material number the arrays are used as they are.
  - `materialIndexPerTriangle` Int32Array: Material number per triangle. (A position in the owner node's materialIds)
  - `cornerArrays` { positions: Float32Array, normals: Float32Array, textureCoordinates: Float32Array, joints: Uint16Array, weights: Float32Array }: Per corner: 3 position, 3 normal, 2 UV, 4 joint and 4 weight values.
  - returns object[]: List of sub-meshes. (localMaterialIndex and the same fields as cornerArrays)

  Example: Of three triangles only the middle one uses material 1 (two sub-meshes, with 2 triangles and 1)

  ```js
  import { SkinnedModel } from "./build/vanilla.js";
  const cornerCount = 9;
  const subMeshList = SkinnedModel.splitFbxCornersByMaterial(new Int32Array([0, 1, 0]), {
  	positions: new Float32Array(cornerCount * 3).map((value, index) => index),
  	normals: new Float32Array(cornerCount * 3),
  	textureCoordinates: new Float32Array(cornerCount * 2),
  	joints: new Uint16Array(cornerCount * 4),
  	weights: new Float32Array(cornerCount * 4),
  });
  console.log(subMeshList.length, subMeshList[0].localMaterialIndex, subMeshList[0].positions.length / 9, subMeshList[1].positions[0]); // 2 0 2 9
  ```

- `async addAnimationsFromFbxUrl(url, clipName, ignoreTranslation = false)` (method, since 0.3.0): Loads additional animation FBX. (retargeting by bone name matching, animation-only Mixamo FBX)
  - Assuming the same skeleton, remaps channels to the current model's node indices and adds the clips.
  - ignoreTranslation: drops translation channels from clips with baked-in root motion. (when game logic controls the position)
  - `url` string: Animation FBX file URL.
  - `clipName` string: Name of the clip to add. (This name when one stack has channels, "this name/stack name" for each stack when there are several)
  - `ignoreTranslation` boolean: Drops translation channels when true. (default false)
- `async addAnimationsFromFbxBytes(arrayBuffer, clipName, ignoreTranslation = false)` (method, since 0.4.0): Adds animation FBX. (bytes, the part of addAnimationsFromFbxUrl after fetch)
  - `arrayBuffer` ArrayBuffer: Animation FBX file bytes.
  - `clipName` string: Name of the clip to add. (This name when one stack has channels, "this name/stack name" for each stack when there are several)
  - `ignoreTranslation` boolean: Drops translation channels when true. (default false)
- `addAnimationsFromFbxSceneData(sceneData, clipName, ignoreTranslation = false)` (method, since 0.4.0): Adds animation FBX. (intermediate representation read by FbxLoader, retargeting by bone name matching)
  - `sceneData` object: Intermediate representation read by FbxLoader.
  - `clipName` string: Name of the clip to add. (This name when one stack has channels, "this name/stack name" for each stack when there are several)
  - `ignoreTranslation` boolean: Drops translation channels when true. (default false)
- `async uploadMeshesAndMaterials(meshDescriptionList, materialDescriptionList)` (method, since 0.3.0): Upload neutral mesh/material descriptions. (shared path, creates Materials and builds VAOs/drawables)
  - Releases the previous asset first. (destroy, so calling it again does not leak)
  - Bundles the uploaded buffers, materials and morph textures with the current nodes, skins and clips into a new asset (SkinnedModelAsset, reference count 1), and this model becomes its first instance.
  - `meshDescriptionList` object[]: Neutral mesh description list.
  - `materialDescriptionList` object[]: Neutral material description list. (referenced by each mesh's materialIndex, the default material when missing)
- `uploadWireframeIndices(drawable)` (method, since 0.3.0): Upload wireframe indices. (Triangle indices → unique edge line indices, three edges per triangle for non-indexed meshes)
  - A separate element buffer independent of the drawable's vertex array. The renderer swaps it in briefly when drawing lines.
  - An already uploaded line buffer is deleted and uploaded again.
  - `drawable` object: Drawable to upload line indices for.
- `static buildWireframeEdgeList(triangleIndices, vertexCount)` (static, since 0.4.0): Builds the wireframe edge list. (static, GL independent, list of index pairs)
  - `triangleIndices` Uint16Array | Uint32Array | null: Triangle indices. (when null, every three vertices form a triangle)
  - `vertexCount` number: Vertex count.
  - returns number[]: Flat list of vertex index pairs for unique edges.
- `uploadMorphTargets(drawable)` (method, since 0.3.0): Uploads morph targets. (drawable's delta list → RGBA32F texture, position block + normal block per target)
  - texel index = vertex index. block start row = target index x 2 x rows per target.
  - `drawable` object: Drawable to upload the morph texture for. (deletes the texture when there are no targets; a texture shared with the asset is left alone and this drawable gets its own)
- `static buildMorphTexelData(morphTargetList, vertexCount)` (static, since 0.4.0): Builds morph texel data. (static, GL independent, texture width, rows per target, RGBA float array)
  - `morphTargetList` object[]: Morph target list. ([{ name, positionDeltas, normalDeltas }])
  - `vertexCount` number: Vertex count.
  - returns { textureWidth: number, rowsPerTarget: number, texelData: Float32Array }: Texture width (the smaller of the vertex count and 2048, at least 1), rows per target, and the RGBA float texel array.
- `addMorphTarget(drawableIndex, targetName, positionDeltas, normalDeltas = null)` (method, since 0.3.0): Adds a morph target. (created in code, per-vertex position deltas [+ normal deltas], uploaded on the next update())
  - `drawableIndex` number: Drawable index. (throws when missing)
  - `targetName` string: Target name. (setMorphWeight looks it up by this name)
  - `positionDeltas` Float32Array: Position delta x, y, z per vertex. (throws when the length is not vertex count x 3)
  - `normalDeltas` Float32Array | null: Normal delta x, y, z per vertex. (normals stay unchanged when null)

  Example: Create a morph target in code and apply it halfway

  ```js
  import { SkinnedModel, SkinnedModelRenderer } from "./build/vanilla.js";
  
  const canvas = document.createElement("canvas");
  const webGL2RenderingContext = canvas.getContext("webgl2");
  const skinnedModelRenderer = new SkinnedModelRenderer(webGL2RenderingContext);
  const skinnedModel = await SkinnedModel.loadFromUrl(webGL2RenderingContext, "examples/ancientmountain/assets/fox.glb", skinnedModelRenderer);
  const drawableList = skinnedModel.getDrawableList();
  const vertexCount = drawableList[0].vertexCount;
  const positionDeltas = new Float32Array(vertexCount * 3);
  for (let vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex) {
  	positionDeltas[vertexIndex * 3 + 1] = 5;
  }
  skinnedModel.addMorphTarget(0, "lift", positionDeltas);
  skinnedModel.setMorphWeight("lift", 0.5);
  skinnedModel.update(0);
  const weight = skinnedModel.getMorphWeight("lift");
  console.log(weight);
  ```

- `setMorphWeight(targetName, weight)` (method, since 0.3.0): Sets the morph weight. (all targets with a matching name, several drawables can share the same name)
  - `targetName` string: Target name.
  - `weight` number: Weight. (0 is off, 1 applies the delta as is)
- `getMorphWeight(targetName)` (method, since 0.3.0): Returns the morph weight. (first matching target, 0 if none)
  - `targetName` string: Target name.
  - returns number: Weight of the first matching target. (0 when none)
- `setMaterial(drawableIndex, material)` (method, since 0.3.0): Replaces the material. (per drawable, applies a material instance made from an external texture)
  - `drawableIndex` number: Drawable index. (throws when missing)
  - `material` Material: Material to swap in. (destroy does not delete it)
- `getMaterial(drawableIndex)` (method, since 0.4.0): Return this instance's material. (Unity Renderer.material: the first call forks a copy of the current material and puts it on this drawable)
  - The copy borrows the textures and keeps its own values. Changing them leaves other instances of the same asset as they are. This model's destroy deletes the copy.
  - If it is already this instance's copy, returns it.
  - `drawableIndex` number: Drawable index. (throws when missing)
  - returns Material: Material used only by this instance.

  Example: Tint only one of several in red

  ```js
  import { SkinnedModel, SkinnedModelRenderer } from "./build/vanilla.js";
  
  const canvas = document.createElement("canvas");
  const webGL2RenderingContext = canvas.getContext("webgl2");
  const skinnedModelRenderer = new SkinnedModelRenderer(webGL2RenderingContext);
  const blueFox = await SkinnedModel.loadFromUrl(webGL2RenderingContext, "examples/ancientmountain/assets/fox.glb", skinnedModelRenderer);
  const redFox = blueFox.createInstance();
  redFox.getMaterial(0).setBaseColorFactor([1, 0.3, 0.3]);
  console.log(blueFox.getSharedMaterial(0).getBaseColorFactor().join(", "), redFox.getSharedMaterial(0).getBaseColorFactor().join(", "));
  redFox.destroy();
  blueFox.destroy();
  ```

- `getSharedMaterial(drawableIndex)` (method, since 0.4.0): Return the material on the drawable. (Unity Renderer.sharedMaterial, does not fork. If it is the asset's prototype, changing it changes every instance of that asset)
  - `drawableIndex` number: Drawable index. (throws when missing)
  - returns Material: Material currently on the drawable. (the copy if getMaterial forked it, or the one given to setMaterial)
- `generateSmoothNormals(positions, indices)` (method, since 0.3.0): Generates smooth normals. (meshes without normals, based on the bind pose, skinning rotation is applied in the shader)
  - `positions` Float32Array: Array of vertex positions x, y, z.
  - `indices` Uint16Array | Uint32Array | null: Triangle indices. (when null, every three vertices form a triangle)
  - returns Float32Array: Normal array made by summing face normals per vertex and normalizing. (same length as positions)
- `bindFloatAttribute(shaderProgram, attributeName, dataArray, componentCount)` (method, since 0.3.0): Binds a float attribute. (creates a new buffer + sets the pointer)
  - `shaderProgram` ShaderProgram: Shader program to look up the attribute location in.
  - `attributeName` string: Attribute name.
  - `dataArray` Float32Array: Vertex data.
  - `componentCount` number: Components per vertex.
  - returns WebGLBuffer | null: The created buffer. (null if the attribute is not in the shader)
- `bindIntegerAttribute(shaderProgram, attributeName, dataArray, componentCount)` (method, since 0.3.0): Binds an integer attribute. (joint indices)
  - `shaderProgram` ShaderProgram: Shader program to look up the attribute location in.
  - `attributeName` string: Attribute name.
  - `dataArray` Uint16Array: Vertex data. (read as UNSIGNED_SHORT)
  - `componentCount` number: Components per vertex.
  - returns WebGLBuffer | null: The created buffer. (null if the attribute is not in the shader)
- `playAnimation(animationName, fadeDuration = 0.25)` (method, since 0.3.0): Plays an animation. (crossfade)
  - `animationName` string: Clip name. (does nothing when it equals the current clip or does not exist, the last one when several share the name)
  - `fadeDuration` number: Time to cross-fade from the previous clip. (seconds, default 0.25)

  Example: Cross-fade from walk to run over 0.4 seconds

  ```js
  import { SkinnedModel } from "./build/vanilla.js";
  
  const response = await fetch("examples/ancientmountain/assets/fox.glb");
  const arrayBuffer = await response.arrayBuffer();
  const glbChunks = SkinnedModel.readGlbChunks(arrayBuffer);
  const skinnedModel = SkinnedModel.createWithoutShaderProgram();
  skinnedModel.interpretContent(glbChunks.json, glbChunks.binaryBuffer);
  skinnedModel.playAnimation("Walk", 0);
  skinnedModel.update(1.0);
  skinnedModel.playAnimation("Run", 0.4);
  for (let frameIndex = 0; frameIndex < 30; ++frameIndex) {
  	skinnedModel.update(1 / 60);
  }
  const skinList = skinnedModel.getSkinList();
  console.log(skinList[0].jointMatrixArray[12]);
  ```

- `sampleAnimation(animation, time, blendWeight)` (method, since 0.3.0): Samples an animation. (weighted blending into the current node pose)
  - `animation` object: Animation clip. ({ name, duration, channels })
  - `time` number: Clip time. (seconds, wrapped by the clip duration)
  - `blendWeight` number: Weight to blend into the current pose. (1 overwrites)
- `update(deltaTime)` (method, since 0.3.0): Update. (advance time → sample pose → compute world/joint matrices)
  - `deltaTime` number: Time elapsed since the last frame. (seconds, advances the clip time multiplied by the playback speed)
- `setJointRotationOffset(jointNamePart, offsetRotation)` (method, since 0.3.0): Sets a joint rotation offset. (accumulates local rotation on nodes whose name partially matches)
  - `jointNamePart` string: Text contained in the node name. (every node that contains it)
  - `offsetRotation` Quaternion: Quaternion multiplied as a local rotation after the animation pose.

  Example: Turn the head on top of the animation

  ```js
  import { SkinnedModel, Quaternion } from "./build/vanilla.js";
  
  const response = await fetch("examples/ancientmountain/assets/fox.glb");
  const arrayBuffer = await response.arrayBuffer();
  const glbChunks = SkinnedModel.readGlbChunks(arrayBuffer);
  const skinnedModel = SkinnedModel.createWithoutShaderProgram();
  skinnedModel.interpretContent(glbChunks.json, glbChunks.binaryBuffer);
  const headTurn = Quaternion.createFromEuler(0, 0.6, 0);
  skinnedModel.setJointRotationOffset("b_Head", headTurn);
  skinnedModel.update(1 / 60);
  skinnedModel.clearJointRotationOffsets();
  ```

- `clearJointRotationOffsets()` (method, since 0.3.0): Clears all joint rotation offsets.
- `getAnimationNameList()` (method, since 0.3.0): Returns the list of animation names.
  - returns string[]: List of clip names. (in clip order)
- `setTimeScale(timeScale)` (method, since 0.3.0): Sets the playback speed.
  - `timeScale` number: Playback speed multiplier. (default 1, not applied to the cross-fade time)
- `getWebGL2RenderingContext()` (method, since 0.3.0): Returns the rendering context.
  - returns WebGL2RenderingContext: Rendering context. (null when built without a shader)
- `getShaderProgram()` (method, since 0.3.0): Returns the shader program.
  - returns ShaderProgram: Shader program. (null when built without a shader)
- `getNodeList()` (method, since 0.3.0): Returns the node list.
  - returns object[]: Node list. (name, child indices, base and current translation, rotation, scale, world matrix)
- `getRootNodeIndices()` (method, since 0.3.0): Returns the list of root node indices.
  - returns number[]: List of scene root node indices.
- `getSkinList()` (method, since 0.3.0): Returns the skin list.
  - returns object[]: Skin list. (joint node indices, inverse bind matrices, joint matrix array)
- `getDrawableList()` (method, since 0.3.0): Returns the drawable list.
  - returns object[]: Drawable list. (vertex array, indices, material, skin index, morph state)
- `getAnimationList()` (method, since 0.4.0): Returns the animation clip list.
  - returns object[]: Animation clip list. ({ name, duration, channels })
- `destroy()` (method, since 0.4.0): Destroy. (deletes this instance's resources and releases the asset; for the last instance the asset deletes its buffers, vertex arrays, morph textures and material prototypes)
  - This instance's resources: wireframe buffers, morph textures forked by addMorphTarget, materials forked by getMaterial.
  - Materials given from outside with setMaterial are not deleted. If the asset's material prototypes were put on another model, they are deleted together when the asset is destroyed.

## Functions and constants

- `MORPH_TARGET_MAXIMUM = 96` (field, since 0.3.0): Maximum number of morph targets per drawable. (matches the shader uniform array size)
  - returns number
