@@ -64,10 +64,14 @@ function createMergedSkeleton(meshes){
64
64
if ( boneArr . indexOf ( bone ) !== - 1 ) {
65
65
const clone = boneClones . get ( bone . name )
66
66
if ( clone == null ) { // no clone was found with the bone
67
+ const newBone = bone . clone ( false ) ;
68
+ if ( bone . name == 'hips' )
69
+ newBone . scale . set ( 0.7 , 0.7 , 0.7 ) ;
70
+ newBone . position . set ( newBone . x * 0.7 , newBone . y * 0.7 , newBone . z * 0.7 )
67
71
const boneData = {
68
72
index,
69
73
boneInverses :mesh . skeleton . boneInverses [ boneInd ] ,
70
- bone :bone . clone ( false ) ,
74
+ bone :newBone ,
71
75
parentName : bone . parent ?. type == "Bone" ? bone . parent . name :null
72
76
}
73
77
index ++
@@ -91,7 +95,11 @@ function createMergedSkeleton(meshes){
91
95
}
92
96
} ) ;
93
97
const newSkeleton = new THREE . Skeleton ( finalBones , finalBoneInverses ) ;
94
- newSkeleton . pose ( )
98
+ newSkeleton . pose ( ) ;
99
+
100
+ newSkeleton . bones . forEach ( bn => {
101
+ bn . position . set ( bn . position . x * 0.7 , bn . position . y * 0.7 , bn . position . z * 0.7 ) ;
102
+ } ) ;
95
103
return newSkeleton
96
104
}
97
105
function getUpdatedSkinIndex ( newSkeleton , mesh ) {
@@ -170,7 +178,6 @@ export async function combine({ transparentColor, avatar, atlasSize = 4096 }, is
170
178
const newSkeleton = createMergedSkeleton ( meshes ) ;
171
179
172
180
meshes . forEach ( ( mesh ) => {
173
-
174
181
const geometry = mesh . geometry ;
175
182
176
183
const baseIndArr = geometry . index . array
@@ -228,6 +235,14 @@ export async function combine({ transparentColor, avatar, atlasSize = 4096 }, is
228
235
geometry . morphAttributes = dest . morphAttributes ;
229
236
geometry . morphTargetsRelative = true ;
230
237
geometry . setIndex ( dest . index ) ;
238
+
239
+ const vertices = geometry . attributes . position . array ;
240
+ for ( let i = 0 ; i < vertices . length ; i += 3 ) {
241
+ vertices [ i ] *= 0.7 ;
242
+ vertices [ i + 1 ] *= 0.7 ;
243
+ vertices [ i + 2 ] *= 0.7 ;
244
+ }
245
+
231
246
const material = new THREE . MeshStandardMaterial ( {
232
247
map : textures [ "diffuse" ] ,
233
248
} ) ;
@@ -257,12 +272,6 @@ export async function combine({ transparentColor, avatar, atlasSize = 4096 }, is
257
272
258
273
259
274
mesh . bind ( newSkeleton ) ;
260
- // clones.forEach((clone) => {
261
- // clone.bind(skeleton);
262
- // });
263
- //console.log(newSkeleton)
264
- //console.log(mesh.geometry.attributes.skinIndex.array)
265
-
266
275
267
276
const group = new THREE . Object3D ( ) ;
268
277
group . name = "AvatarRoot" ;
@@ -363,13 +372,18 @@ function mergeSourceMorphAttributes({ meshes, sourceMorphTargetDictionaries, sou
363
372
merged [ propName ] = [ ] ;
364
373
for ( let i = 0 ; i < Object . entries ( destMorphTargetDictionary ) . length ; i ++ ) {
365
374
merged [ propName ] [ i ] = BufferGeometryUtils . mergeBufferAttributes ( unmerged [ propName ] [ i ] ) ;
375
+ const buffArr = merged [ propName ] [ i ] . array ;
366
376
if ( isVrm0 ) {
367
- const buffArr = merged [ propName ] [ i ] . array ;
368
377
for ( let j = 0 ; j < buffArr . length ; j += 3 ) {
369
378
buffArr [ j ] *= - 1 ;
370
379
buffArr [ j + 2 ] *= - 1 ;
371
380
}
372
381
}
382
+ for ( let j = 0 ; j < buffArr . length ; j += 3 ) {
383
+ buffArr [ j ] *= 0.7 ;
384
+ buffArr [ j + 1 ] *= 0.7 ;
385
+ buffArr [ j + 2 ] *= 0.7 ;
386
+ }
373
387
}
374
388
} ) ;
375
389
return merged ;
0 commit comments