How I can import the skeleton utils in typescript, since version 0.132

Since version 0.132, I must import the skeletons utils like this:
import * as SkeletonUtils from ‘three/examples/jsm/utils/SkeletonUtils’;

but when I trying to use SkeletonUtils.clone() method, typescript throw an error:

I can’t find any way to solve this.

1 Like

It looks like the type declaration is incorrect.
My program is built like this:

import { SkeletonUtils } from 'three/examples/jsm/utils/SkeletonUtils'

However, the program does not work:

Judging by the JavaScript code, the type declaration should be something like:

import { AnimationClip, Bone, Matrix4, Object3D, Skeleton, SkeletonHelper } from '../../../src/Three';

function retarget(target: Object3D | Skeleton, source: Object3D | Skeleton, options: {}): void;

function retargetClip(
    target: Skeleton | Object3D,
    source: Skeleton | Object3D,
    clip: AnimationClip,
    options: {},
): AnimationClip;

function getHelperFromSkeleton(skeleton: Skeleton): SkeletonHelper;

function getSkeletonOffsets(target: Object3D | Skeleton, source: Object3D | Skeleton, options: {}): Matrix4[];

function renameBones(skeleton: Skeleton, names: {}): any;

function getBones(skeleton: Skeleton | Bone[]): Bone[];

function getBoneByName(name: string, skeleton: Skeleton): Bone;

function getNearestBone(bone: Bone, names: {}): Bone;

function findBoneTrackData(name: string, tracks: any[]): {};

function getEqualsBonesNames(skeleton: Skeleton, targetSkeleton: Skeleton): string[];

function clone(source: Object3D): Object3D;

export default {

Since the program is built on the build server, and dependencies are pulled from the npm package - I didn’t want to replace the type declaration. I’m also looking for a solution to this problem.

Sorry for my English.

I tried to replace the type declaration - as a result, it works the same as the library declaration. I had to return my copied and reworked JavaScript implementation code that works.

  parallelTraverse (a: Object3D, b: Object3D, callback: (a: Object3D, b: Object3D) => void) {
    callback(a, b)
    for (let i = 0; i < a.children.length; i++) {
      this.parallelTraverse(a.children[i], b.children[i], callback)

  clone (source: Object3D) {
    const sourceLookup = new Map<any, any>()
    const cloneLookup = new Map<any, any>()
    const clone = source.clone()

    this.parallelTraverse(source, clone, (sourceNode, clonedNode) => {
      sourceLookup.set(clonedNode, sourceNode)
      cloneLookup.set(sourceNode, clonedNode)
    clone.traverse((node) => {
      if (!(node instanceof SkinnedMesh)) {
      const clonedMesh = node
      const sourceMesh = sourceLookup.get(node)
      const sourceBones = sourceMesh.skeleton.bones
      clonedMesh.skeleton = sourceMesh.skeleton.clone()
      clonedMesh.skeleton.bones = Bone) => {
        return cloneLookup.get(bone)
      clonedMesh.bind(clonedMesh.skeleton, clonedMesh.bindMatrix)
    return clone