privateboard 0.1.38 → 0.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/boot.js +327 -50
  2. package/dist/boot.js.map +1 -1
  3. package/dist/cli.js +327 -50
  4. package/dist/cli.js.map +1 -1
  5. package/dist/server.js +201 -40
  6. package/dist/server.js.map +1 -1
  7. package/dist/version.d.ts +1 -1
  8. package/dist/version.js +1 -1
  9. package/dist/version.js.map +1 -1
  10. package/package.json +1 -1
  11. package/public/__avatar3d_test.html +156 -0
  12. package/public/agent-overlay.css +14 -6
  13. package/public/agent-overlay.js +6 -6
  14. package/public/agent-profile.css +9 -12
  15. package/public/agent-profile.js +91 -38
  16. package/public/app.js +471 -528
  17. package/public/avatar-3d-snap.js +205 -0
  18. package/public/avatar-3d.js +836 -0
  19. package/public/avatar-customizer.html +274 -0
  20. package/public/avatar3d-editor.css +240 -0
  21. package/public/avatar3d-editor.js +484 -0
  22. package/public/avatars/3d/chair.png +0 -0
  23. package/public/avatars/3d/first-principles.png +0 -0
  24. package/public/avatars/3d/historian.png +0 -0
  25. package/public/avatars/3d/long-horizon.png +0 -0
  26. package/public/avatars/3d/phenomenologist.png +0 -0
  27. package/public/avatars/3d/socrates.png +0 -0
  28. package/public/avatars/3d/user-empathy.png +0 -0
  29. package/public/avatars/3d/value-investor.png +0 -0
  30. package/public/core-avatars.js +86 -0
  31. package/public/home-3d-loader.js +15 -4
  32. package/public/home-3d-mock.js +25 -14
  33. package/public/home.html +78 -16
  34. package/public/i18n.js +8 -4
  35. package/public/icons/avatar_1779855104027.glb +0 -0
  36. package/public/icons/logo.png +0 -0
  37. package/public/icons/new-style.glb +0 -0
  38. package/public/icons/new-style2.glb +0 -0
  39. package/public/icons/new-style3.glb +0 -0
  40. package/public/icons/new-style4.glb +0 -0
  41. package/public/icons/new-style5.glb +0 -0
  42. package/public/icons/new-style6.glb +0 -0
  43. package/public/icons/office.glb +0 -0
  44. package/public/icons/stuff.glb +0 -0
  45. package/public/index.html +169 -141
  46. package/public/magazine.html +1 -1
  47. package/public/new-agent.js +46 -20
  48. package/public/newspaper.html +1 -1
  49. package/public/office-viewer.html +340 -0
  50. package/public/ppt.html +1 -1
  51. package/public/stuff-viewer.html +330 -0
  52. package/public/thread.css +16 -15
  53. package/public/user-settings.css +7 -31
  54. package/public/user-settings.js +75 -89
  55. package/public/vendor/BufferGeometryUtils.js +1434 -0
  56. package/public/vendor/DRACOLoader.js +739 -0
  57. package/public/vendor/GLTFLoader.js +4860 -0
  58. package/public/vendor/RoomEnvironment.js +185 -0
  59. package/public/vendor/SkeletonUtils.js +496 -0
  60. package/public/vendor/draco/draco_decoder.js +34 -0
  61. package/public/vendor/draco/draco_decoder.wasm +0 -0
  62. package/public/vendor/draco/draco_encoder.js +33 -0
  63. package/public/vendor/draco/draco_wasm_wrapper.js +117 -0
  64. package/public/vendor/meshopt_decoder.module.js +196 -0
  65. package/public/voice-3d-banner.js +19 -7
  66. package/public/voice-3d.js +1407 -432
  67. package/public/voice-replay.js +21 -0
  68. package/public/avatar-skill.js +0 -629
  69. package/public/avatars/chair-blink.svg +0 -1
  70. package/public/avatars/chair.svg +0 -1
  71. package/public/avatars/first-principles.svg +0 -1
  72. package/public/avatars/historian.svg +0 -1
  73. package/public/avatars/long-horizon.svg +0 -1
  74. package/public/avatars/phenomenologist.svg +0 -1
  75. package/public/avatars/socrates.svg +0 -1
  76. package/public/avatars/user-empathy.svg +0 -1
  77. package/public/avatars/value-investor.svg +0 -1
  78. package/public/icons/folded-sidebar.png +0 -0
@@ -0,0 +1,185 @@
1
+ import {
2
+ BackSide,
3
+ BoxGeometry,
4
+ InstancedMesh,
5
+ Mesh,
6
+ MeshLambertMaterial,
7
+ MeshStandardMaterial,
8
+ PointLight,
9
+ Scene,
10
+ Object3D,
11
+ } from '/vendor/three.module.min.js';
12
+
13
+ /**
14
+ * This class represents a scene with a basic room setup that can be used as
15
+ * input for {@link PMREMGenerator#fromScene}. The resulting PMREM represents the room's
16
+ * lighting and can be used for Image Based Lighting by assigning it to {@link Scene#environment}
17
+ * or directly as an environment map to PBR materials.
18
+ *
19
+ * The implementation is based on the [EnvironmentScene](https://github.com/google/model-viewer/blob/master/packages/model-viewer/src/three-components/EnvironmentScene.ts)
20
+ * component from the `model-viewer` project.
21
+ *
22
+ * ```js
23
+ * const environment = new RoomEnvironment();
24
+ * const pmremGenerator = new THREE.PMREMGenerator( renderer );
25
+ *
26
+ * const envMap = pmremGenerator.fromScene( environment ).texture;
27
+ * scene.environment = envMap;
28
+ * ```
29
+ *
30
+ * @augments Scene
31
+ * @three_import import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
32
+ */
33
+ class RoomEnvironment extends Scene {
34
+
35
+ constructor() {
36
+
37
+ super();
38
+
39
+ this.name = 'RoomEnvironment';
40
+ this.position.y = - 3.5;
41
+
42
+ const geometry = new BoxGeometry();
43
+ geometry.deleteAttribute( 'uv' );
44
+
45
+ const roomMaterial = new MeshStandardMaterial( { side: BackSide } );
46
+ const boxMaterial = new MeshStandardMaterial();
47
+
48
+ const mainLight = new PointLight( 0xffffff, 900, 28, 2 );
49
+ mainLight.position.set( 0.418, 16.199, 0.300 );
50
+ this.add( mainLight );
51
+
52
+ const room = new Mesh( geometry, roomMaterial );
53
+ room.position.set( - 0.757, 13.219, 0.717 );
54
+ room.scale.set( 31.713, 28.305, 28.591 );
55
+ this.add( room );
56
+
57
+ const boxes = new InstancedMesh( geometry, boxMaterial, 6 );
58
+ const transform = new Object3D();
59
+
60
+ // box1
61
+ transform.position.set( - 10.906, 2.009, 1.846 );
62
+ transform.rotation.set( 0, - 0.195, 0 );
63
+ transform.scale.set( 2.328, 7.905, 4.651 );
64
+ transform.updateMatrix();
65
+ boxes.setMatrixAt( 0, transform.matrix );
66
+
67
+ // box2
68
+ transform.position.set( - 5.607, - 0.754, - 0.758 );
69
+ transform.rotation.set( 0, 0.994, 0 );
70
+ transform.scale.set( 1.970, 1.534, 3.955 );
71
+ transform.updateMatrix();
72
+ boxes.setMatrixAt( 1, transform.matrix );
73
+
74
+ // box3
75
+ transform.position.set( 6.167, 0.857, 7.803 );
76
+ transform.rotation.set( 0, 0.561, 0 );
77
+ transform.scale.set( 3.927, 6.285, 3.687 );
78
+ transform.updateMatrix();
79
+ boxes.setMatrixAt( 2, transform.matrix );
80
+
81
+ // box4
82
+ transform.position.set( - 2.017, 0.018, 6.124 );
83
+ transform.rotation.set( 0, 0.333, 0 );
84
+ transform.scale.set( 2.002, 4.566, 2.064 );
85
+ transform.updateMatrix();
86
+ boxes.setMatrixAt( 3, transform.matrix );
87
+
88
+ // box5
89
+ transform.position.set( 2.291, - 0.756, - 2.621 );
90
+ transform.rotation.set( 0, - 0.286, 0 );
91
+ transform.scale.set( 1.546, 1.552, 1.496 );
92
+ transform.updateMatrix();
93
+ boxes.setMatrixAt( 4, transform.matrix );
94
+
95
+ // box6
96
+ transform.position.set( - 2.193, - 0.369, - 5.547 );
97
+ transform.rotation.set( 0, 0.516, 0 );
98
+ transform.scale.set( 3.875, 3.487, 2.986 );
99
+ transform.updateMatrix();
100
+ boxes.setMatrixAt( 5, transform.matrix );
101
+
102
+ this.add( boxes );
103
+
104
+
105
+ // -x right
106
+ const light1 = new Mesh( geometry, createAreaLightMaterial( 50 ) );
107
+ light1.position.set( - 16.116, 14.37, 8.208 );
108
+ light1.scale.set( 0.1, 2.428, 2.739 );
109
+ this.add( light1 );
110
+
111
+ // -x left
112
+ const light2 = new Mesh( geometry, createAreaLightMaterial( 50 ) );
113
+ light2.position.set( - 16.109, 18.021, - 8.207 );
114
+ light2.scale.set( 0.1, 2.425, 2.751 );
115
+ this.add( light2 );
116
+
117
+ // +x
118
+ const light3 = new Mesh( geometry, createAreaLightMaterial( 17 ) );
119
+ light3.position.set( 14.904, 12.198, - 1.832 );
120
+ light3.scale.set( 0.15, 4.265, 6.331 );
121
+ this.add( light3 );
122
+
123
+ // +z
124
+ const light4 = new Mesh( geometry, createAreaLightMaterial( 43 ) );
125
+ light4.position.set( - 0.462, 8.89, 14.520 );
126
+ light4.scale.set( 4.38, 5.441, 0.088 );
127
+ this.add( light4 );
128
+
129
+ // -z
130
+ const light5 = new Mesh( geometry, createAreaLightMaterial( 20 ) );
131
+ light5.position.set( 3.235, 11.486, - 12.541 );
132
+ light5.scale.set( 2.5, 2.0, 0.1 );
133
+ this.add( light5 );
134
+
135
+ // +y
136
+ const light6 = new Mesh( geometry, createAreaLightMaterial( 100 ) );
137
+ light6.position.set( 0.0, 20.0, 0.0 );
138
+ light6.scale.set( 1.0, 0.1, 1.0 );
139
+ this.add( light6 );
140
+
141
+ }
142
+
143
+ /**
144
+ * Frees internal resources. This method should be called
145
+ * when the environment is no longer required.
146
+ */
147
+ dispose() {
148
+
149
+ const resources = new Set();
150
+
151
+ this.traverse( ( object ) => {
152
+
153
+ if ( object.isMesh ) {
154
+
155
+ resources.add( object.geometry );
156
+ resources.add( object.material );
157
+
158
+ }
159
+
160
+ } );
161
+
162
+ for ( const resource of resources ) {
163
+
164
+ resource.dispose();
165
+
166
+ }
167
+
168
+ }
169
+
170
+ }
171
+
172
+ function createAreaLightMaterial( intensity ) {
173
+
174
+ // create an emissive-only material. see #31348
175
+ const material = new MeshLambertMaterial( {
176
+ color: 0x000000,
177
+ emissive: 0xffffff,
178
+ emissiveIntensity: intensity
179
+ } );
180
+
181
+ return material;
182
+
183
+ }
184
+
185
+ export { RoomEnvironment };
@@ -0,0 +1,496 @@
1
+ import {
2
+ AnimationClip,
3
+ AnimationMixer,
4
+ Matrix4,
5
+ Quaternion,
6
+ QuaternionKeyframeTrack,
7
+ SkeletonHelper,
8
+ Vector3,
9
+ VectorKeyframeTrack
10
+ } from '/vendor/three.module.min.js';
11
+
12
+ /**
13
+ * @module SkeletonUtils
14
+ * @three_import import * as SkeletonUtils from 'three/addons/utils/SkeletonUtils.js';
15
+ */
16
+
17
+ function getBoneName( bone, options ) {
18
+
19
+ if ( options.getBoneName !== undefined ) {
20
+
21
+ return options.getBoneName( bone );
22
+
23
+ }
24
+
25
+ return options.names[ bone.name ];
26
+
27
+ }
28
+
29
+ /**
30
+ * Retargets the skeleton from the given source to the target.
31
+ *
32
+ * Both `target` and `source` can be a 3D object with a skeleton property (e.g. a skinned mesh)
33
+ * or a {@link Skeleton} directly.
34
+ *
35
+ * @param {Object3D|Skeleton} target - The target object.
36
+ * @param {Object3D|Skeleton} source - The source object.
37
+ * @param {module:SkeletonUtils~RetargetOptions} options - The options.
38
+ */
39
+ function retarget( target, source, options = {} ) {
40
+
41
+ const quat = new Quaternion(),
42
+ scale = new Vector3(),
43
+ relativeMatrix = new Matrix4(),
44
+ globalMatrix = new Matrix4();
45
+
46
+ options.preserveBoneMatrix = options.preserveBoneMatrix !== undefined ? options.preserveBoneMatrix : true;
47
+ options.preserveBonePositions = options.preserveBonePositions !== undefined ? options.preserveBonePositions : true;
48
+ options.useTargetMatrix = options.useTargetMatrix !== undefined ? options.useTargetMatrix : false;
49
+ options.hip = options.hip !== undefined ? options.hip : 'hip';
50
+ options.hipInfluence = options.hipInfluence !== undefined ? options.hipInfluence : new Vector3( 1, 1, 1 );
51
+ options.scale = options.scale !== undefined ? options.scale : 1;
52
+ options.names = options.names || {};
53
+
54
+ const sourceBones = source.isObject3D ? source.skeleton.bones : getBones( source ),
55
+ bones = target.isObject3D ? target.skeleton.bones : getBones( target );
56
+
57
+ let bone, name, boneTo,
58
+ bonesPosition;
59
+
60
+ // reset bones
61
+
62
+ if ( target.isObject3D ) {
63
+
64
+ target.skeleton.pose();
65
+
66
+ } else {
67
+
68
+ options.useTargetMatrix = true;
69
+ options.preserveBoneMatrix = false;
70
+
71
+ }
72
+
73
+ if ( options.preserveBonePositions ) {
74
+
75
+ bonesPosition = [];
76
+
77
+ for ( let i = 0; i < bones.length; i ++ ) {
78
+
79
+ bonesPosition.push( bones[ i ].position.clone() );
80
+
81
+ }
82
+
83
+ }
84
+
85
+ if ( options.preserveBoneMatrix ) {
86
+
87
+ // reset matrix
88
+
89
+ target.updateMatrixWorld();
90
+
91
+ target.matrixWorld.identity();
92
+
93
+ // reset children matrix
94
+
95
+ for ( let i = 0; i < target.children.length; ++ i ) {
96
+
97
+ target.children[ i ].updateMatrixWorld( true );
98
+
99
+ }
100
+
101
+ }
102
+
103
+ for ( let i = 0; i < bones.length; ++ i ) {
104
+
105
+ bone = bones[ i ];
106
+ name = getBoneName( bone, options );
107
+
108
+ boneTo = getBoneByName( name, sourceBones );
109
+
110
+ globalMatrix.copy( bone.matrixWorld );
111
+
112
+ if ( boneTo ) {
113
+
114
+ boneTo.updateMatrixWorld();
115
+
116
+ if ( options.useTargetMatrix ) {
117
+
118
+ relativeMatrix.copy( boneTo.matrixWorld );
119
+
120
+ } else {
121
+
122
+ relativeMatrix.copy( target.matrixWorld ).invert();
123
+ relativeMatrix.multiply( boneTo.matrixWorld );
124
+
125
+ }
126
+
127
+ // ignore scale to extract rotation
128
+
129
+ scale.setFromMatrixScale( relativeMatrix );
130
+ relativeMatrix.scale( scale.set( 1 / scale.x, 1 / scale.y, 1 / scale.z ) );
131
+
132
+ // apply to global matrix
133
+
134
+ globalMatrix.makeRotationFromQuaternion( quat.setFromRotationMatrix( relativeMatrix ) );
135
+
136
+ if ( target.isObject3D ) {
137
+
138
+ if ( options.localOffsets ) {
139
+
140
+ if ( options.localOffsets[ bone.name ] ) {
141
+
142
+ globalMatrix.multiply( options.localOffsets[ bone.name ] );
143
+
144
+ }
145
+
146
+ }
147
+
148
+ }
149
+
150
+ globalMatrix.copyPosition( relativeMatrix );
151
+
152
+ }
153
+
154
+ if ( name === options.hip ) {
155
+
156
+ globalMatrix.elements[ 12 ] *= options.scale * options.hipInfluence.x;
157
+ globalMatrix.elements[ 13 ] *= options.scale * options.hipInfluence.y;
158
+ globalMatrix.elements[ 14 ] *= options.scale * options.hipInfluence.z;
159
+
160
+ if ( options.hipPosition !== undefined ) {
161
+
162
+ globalMatrix.elements[ 12 ] += options.hipPosition.x * options.scale;
163
+ globalMatrix.elements[ 13 ] += options.hipPosition.y * options.scale;
164
+ globalMatrix.elements[ 14 ] += options.hipPosition.z * options.scale;
165
+
166
+ }
167
+
168
+ }
169
+
170
+ if ( bone.parent ) {
171
+
172
+ bone.matrix.copy( bone.parent.matrixWorld ).invert();
173
+ bone.matrix.multiply( globalMatrix );
174
+
175
+ } else {
176
+
177
+ bone.matrix.copy( globalMatrix );
178
+
179
+ }
180
+
181
+ bone.matrix.decompose( bone.position, bone.quaternion, bone.scale );
182
+
183
+ bone.updateMatrixWorld();
184
+
185
+ }
186
+
187
+ if ( options.preserveBonePositions ) {
188
+
189
+ for ( let i = 0; i < bones.length; ++ i ) {
190
+
191
+ bone = bones[ i ];
192
+ name = getBoneName( bone, options ) || bone.name;
193
+
194
+ if ( name !== options.hip ) {
195
+
196
+ bone.position.copy( bonesPosition[ i ] );
197
+
198
+ }
199
+
200
+ }
201
+
202
+ }
203
+
204
+ if ( options.preserveBoneMatrix ) {
205
+
206
+ // restore matrix
207
+
208
+ target.updateMatrixWorld( true );
209
+
210
+ }
211
+
212
+ }
213
+
214
+ /**
215
+ * Retargets the animation clip of the source to the target 3D object.
216
+ *
217
+ * The `source` can be a 3D object with a skeleton property (e.g. a skinned mesh)
218
+ * or a {@link Skeleton} directly.
219
+ *
220
+ * @param {Object3D} target - The target 3D object. Must have a `skeleton` property.
221
+ * @param {Object3D|Skeleton} source - The source object.
222
+ * @param {AnimationClip} clip - The animation clip.
223
+ * @param {module:SkeletonUtils~RetargetOptions} options - The options.
224
+ * @return {AnimationClip} The retargeted animation clip.
225
+ */
226
+ function retargetClip( target, source, clip, options = {} ) {
227
+
228
+ options.useFirstFramePosition = options.useFirstFramePosition !== undefined ? options.useFirstFramePosition : false;
229
+
230
+ // Calculate the fps from the source clip based on the track with the most frames, unless fps is already provided.
231
+ options.fps = options.fps !== undefined ? options.fps : ( Math.max( ...clip.tracks.map( track => track.times.length ) ) / clip.duration );
232
+ options.names = options.names || [];
233
+
234
+ if ( ! source.isObject3D ) {
235
+
236
+ source = getHelperFromSkeleton( source );
237
+
238
+ }
239
+
240
+ const numFrames = Math.round( clip.duration * ( options.fps / 1000 ) * 1000 ),
241
+ delta = clip.duration / ( numFrames - 1 ),
242
+ convertedTracks = [],
243
+ mixer = new AnimationMixer( source ),
244
+ bones = getBones( target.skeleton ),
245
+ boneDatas = [];
246
+
247
+ let positionOffset,
248
+ bone, boneTo, boneData,
249
+ name;
250
+
251
+ mixer.clipAction( clip ).play();
252
+
253
+ // trim
254
+
255
+ let start = 0, end = numFrames;
256
+
257
+ if ( options.trim !== undefined ) {
258
+
259
+ start = Math.round( options.trim[ 0 ] * options.fps );
260
+ end = Math.min( Math.round( options.trim[ 1 ] * options.fps ), numFrames ) - start;
261
+
262
+ mixer.update( options.trim[ 0 ] );
263
+
264
+ } else {
265
+
266
+ mixer.update( 0 );
267
+
268
+ }
269
+
270
+ source.updateMatrixWorld();
271
+
272
+ //
273
+
274
+ for ( let frame = 0; frame < end; ++ frame ) {
275
+
276
+ const time = frame * delta;
277
+
278
+ retarget( target, source, options );
279
+
280
+ for ( let j = 0; j < bones.length; ++ j ) {
281
+
282
+ bone = bones[ j ];
283
+ name = getBoneName( bone, options ) || bone.name;
284
+ boneTo = getBoneByName( name, source.skeleton );
285
+
286
+ if ( boneTo ) {
287
+
288
+ boneData = boneDatas[ j ] = boneDatas[ j ] || { bone: bone };
289
+
290
+ if ( options.hip === name ) {
291
+
292
+ if ( ! boneData.pos ) {
293
+
294
+ boneData.pos = {
295
+ times: new Float32Array( end ),
296
+ values: new Float32Array( end * 3 )
297
+ };
298
+
299
+ }
300
+
301
+ if ( options.useFirstFramePosition ) {
302
+
303
+ if ( frame === 0 ) {
304
+
305
+ positionOffset = bone.position.clone();
306
+
307
+ }
308
+
309
+ bone.position.sub( positionOffset );
310
+
311
+ }
312
+
313
+ boneData.pos.times[ frame ] = time;
314
+
315
+ bone.position.toArray( boneData.pos.values, frame * 3 );
316
+
317
+ }
318
+
319
+ if ( ! boneData.quat ) {
320
+
321
+ boneData.quat = {
322
+ times: new Float32Array( end ),
323
+ values: new Float32Array( end * 4 )
324
+ };
325
+
326
+ }
327
+
328
+ boneData.quat.times[ frame ] = time;
329
+
330
+ bone.quaternion.toArray( boneData.quat.values, frame * 4 );
331
+
332
+ }
333
+
334
+ }
335
+
336
+ if ( frame === end - 2 ) {
337
+
338
+ // last mixer update before final loop iteration
339
+ // make sure we do not go over or equal to clip duration
340
+ mixer.update( delta - 0.0000001 );
341
+
342
+ } else {
343
+
344
+ mixer.update( delta );
345
+
346
+ }
347
+
348
+ source.updateMatrixWorld();
349
+
350
+ }
351
+
352
+ for ( let i = 0; i < boneDatas.length; ++ i ) {
353
+
354
+ boneData = boneDatas[ i ];
355
+
356
+ if ( boneData ) {
357
+
358
+ if ( boneData.pos ) {
359
+
360
+ convertedTracks.push( new VectorKeyframeTrack(
361
+ '.bones[' + boneData.bone.name + '].position',
362
+ boneData.pos.times,
363
+ boneData.pos.values
364
+ ) );
365
+
366
+ }
367
+
368
+ convertedTracks.push( new QuaternionKeyframeTrack(
369
+ '.bones[' + boneData.bone.name + '].quaternion',
370
+ boneData.quat.times,
371
+ boneData.quat.values
372
+ ) );
373
+
374
+ }
375
+
376
+ }
377
+
378
+ mixer.uncacheAction( clip );
379
+
380
+ return new AnimationClip( clip.name, - 1, convertedTracks );
381
+
382
+ }
383
+
384
+ /**
385
+ * Clones the given 3D object and its descendants, ensuring that any `SkinnedMesh` instances are
386
+ * correctly associated with their bones. Bones are also cloned, and must be descendants of the
387
+ * object passed to this method. Other data, like geometries and materials, are reused by reference.
388
+ *
389
+ * @param {Object3D} source - The 3D object to clone.
390
+ * @return {Object3D} The cloned 3D object.
391
+ */
392
+ function clone( source ) {
393
+
394
+ const sourceLookup = new Map();
395
+ const cloneLookup = new Map();
396
+
397
+ const clone = source.clone();
398
+
399
+ parallelTraverse( source, clone, function ( sourceNode, clonedNode ) {
400
+
401
+ sourceLookup.set( clonedNode, sourceNode );
402
+ cloneLookup.set( sourceNode, clonedNode );
403
+
404
+ } );
405
+
406
+ clone.traverse( function ( node ) {
407
+
408
+ if ( ! node.isSkinnedMesh ) return;
409
+
410
+ const clonedMesh = node;
411
+ const sourceMesh = sourceLookup.get( node );
412
+ const sourceBones = sourceMesh.skeleton.bones;
413
+
414
+ clonedMesh.skeleton = sourceMesh.skeleton.clone();
415
+ clonedMesh.bindMatrix.copy( sourceMesh.bindMatrix );
416
+
417
+ clonedMesh.skeleton.bones = sourceBones.map( function ( bone ) {
418
+
419
+ return cloneLookup.get( bone );
420
+
421
+ } );
422
+
423
+ clonedMesh.bind( clonedMesh.skeleton, clonedMesh.bindMatrix );
424
+
425
+ } );
426
+
427
+ return clone;
428
+
429
+ }
430
+
431
+ // internal helper
432
+
433
+ function getBoneByName( name, skeleton ) {
434
+
435
+ for ( let i = 0, bones = getBones( skeleton ); i < bones.length; i ++ ) {
436
+
437
+ if ( name === bones[ i ].name )
438
+
439
+ return bones[ i ];
440
+
441
+ }
442
+
443
+ }
444
+
445
+ function getBones( skeleton ) {
446
+
447
+ return Array.isArray( skeleton ) ? skeleton : skeleton.bones;
448
+
449
+ }
450
+
451
+
452
+ function getHelperFromSkeleton( skeleton ) {
453
+
454
+ const source = new SkeletonHelper( skeleton.bones[ 0 ] );
455
+ source.skeleton = skeleton;
456
+
457
+ return source;
458
+
459
+ }
460
+
461
+ function parallelTraverse( a, b, callback ) {
462
+
463
+ callback( a, b );
464
+
465
+ for ( let i = 0; i < a.children.length; i ++ ) {
466
+
467
+ parallelTraverse( a.children[ i ], b.children[ i ], callback );
468
+
469
+ }
470
+
471
+ }
472
+
473
+ /**
474
+ * Retarget options of `SkeletonUtils`.
475
+ *
476
+ * @typedef {Object} module:SkeletonUtils~RetargetOptions
477
+ * @property {boolean} [useFirstFramePosition=false] - Whether to use the position of the first frame or not.
478
+ * @property {number} [fps] - The FPS of the clip.
479
+ * @property {Object<string,string>} [names] - A dictionary for mapping target to source bone names.
480
+ * @property {function(string):string} [getBoneName] - A function for mapping bone names. Alternative to `names`.
481
+ * @property {Array<number>} [trim] - Whether to trim the clip or not. If set the array should hold two values for the start and end.
482
+ * @property {boolean} [preserveBoneMatrix=true] - Whether to preserve bone matrices or not.
483
+ * @property {boolean} [preserveBonePositions=true] - Whether to preserve bone positions or not.
484
+ * @property {boolean} [useTargetMatrix=false] - Whether to use the target matrix or not.
485
+ * @property {string} [hip='hip'] - The name of the source's hip bone.
486
+ * @property {Vector3} [hipInfluence=(1,1,1)] - The hip influence.
487
+ * @property {number} [scale=1] - The scale.
488
+ * @property {Object<string,Matrix4>} [localOffsets] - Per-bone local offset matrices, keyed by bone name.
489
+ * @property {Vector3} [hipPosition] - An additional position offset applied to the hip bone.
490
+ **/
491
+
492
+ export {
493
+ retarget,
494
+ retargetClip,
495
+ clone,
496
+ };