UNPKG

2.87 kBTypeScriptView Raw
1import { Object3D } from "../core/Object3D.js";
2import { Matrix4 } from "../math/Matrix4.js";
3import { Bone } from "../objects/Bone.js";
4import { LineSegments } from "../objects/LineSegments.js";
5import { SkinnedMesh } from "../objects/SkinnedMesh.js";
6
7/**
8 * A helper object to assist with visualizing a {@link Skeleton | Skeleton}
9 * @remarks
10 * The helper is rendered using a {@link LineBasicMaterial | LineBasicMaterial}.
11 * @example
12 * ```typescript
13 * const helper = new THREE.SkeletonHelper(skinnedMesh);
14 * scene.add(helper);
15 * ```
16 * @see Example: {@link https://threejs.org/examples/#webgl_animation_skinning_blending | WebGL / animation / skinning / blending}
17 * @see Example: {@link https://threejs.org/examples/#webgl_animation_skinning_morph | WebGL / animation / skinning / morph}
18 * @see Example: {@link https://threejs.org/examples/#webgl_loader_bvh | WebGL / loader / bvh }
19 * @see {@link https://threejs.org/docs/index.html#api/en/helpers/SkeletonHelper | Official Documentation}
20 * @see {@link https://github.com/mrdoob/three.js/blob/master/src/helpers/SkeletonHelper.js | Source}
21 */
22export class SkeletonHelper extends LineSegments {
23 /**
24 * Create a new instance of {@link SkeletonHelper}
25 * @param object Usually an instance of {@link THREE.SkinnedMesh | SkinnedMesh}.
26 * However, any instance of {@link THREE.Object3D | Object3D} can be used if it represents a hierarchy of {@link Bone | Bone}s (via {@link THREE.Object3D.children | Object3D.children}).
27 */
28 constructor(object: SkinnedMesh | Object3D);
29
30 /**
31 * Read-only flag to check if a given object is of type {@link SkeletonHelper}.
32 * @remarks This is a _constant_ value
33 * @defaultValue `true`
34 */
35 readonly isSkeletonHelper = true;
36
37 /**
38 * A Read-only _string_ to check if `this` object type.
39 * @remarks Sub-classes will update this value.
40 * @override
41 * @defaultValue `SkeletonHelper`
42 */
43 override readonly type: string | "SkeletonHelper";
44
45 /**
46 * The list of bones that the helper renders as {@link Line | Lines}.
47 */
48 bones: Bone[];
49
50 /**
51 * The object passed in the constructor.
52 */
53 root: SkinnedMesh | Object3D;
54
55 /**
56 * Reference to the {@link THREE.Object3D.matrixWorld | root.matrixWorld}.
57 */
58 matrix: Matrix4;
59
60 /**
61 * Is set to `false`, as the helper is using the {@link THREE.Object3D.matrixWorld | root.matrixWorld}.
62 * @see {@link THREE.Object3D.matrixAutoUpdate | Object3D.matrixAutoUpdate}.
63 * @defaultValue `false`.
64 */
65 override matrixAutoUpdate: boolean;
66
67 /**
68 * Updates the helper.
69 */
70 update(): void;
71
72 /**
73 * Frees the GPU-related resources allocated by this instance
74 * @remarks
75 * Call this method whenever this instance is no longer used in your app.
76 */
77 dispose(): void;
78}