@@ -194,6 +194,15 @@ const LEAVES = {
194
194
[ SpeciesHash . Walnut ] : WALNUT_LEAVES
195
195
} ;
196
196
197
+ const LEAF_SCALE = {
198
+ [ SpeciesHash . Ash ] : 4 ,
199
+ [ SpeciesHash . Birch ] : 4 ,
200
+ [ SpeciesHash . Oak ] : 4 ,
201
+ [ SpeciesHash . Redwood ] : 0.5 ,
202
+ [ SpeciesHash . Standard ] : 4 ,
203
+ [ SpeciesHash . Walnut ] : 4
204
+ } ;
205
+
197
206
const compositionMap : CompositionMap = {
198
207
Woodcut_B0_B0 : { Top_8056 : BRANCHES } ,
199
208
Woodcut_B0_B0_S15 : { Top_53706 : BRANCHES , Stick_53710 : STICKS } ,
@@ -297,17 +306,18 @@ const populateSegment = (
297
306
const createChildPrefab = ( speciesHash : SpeciesHash , segment : Segment , parentHash : number = 0 ) : ChildPrefab => {
298
307
const [ segmentName , connectionMap ] = Object . entries ( segment ) [ 0 ] as [ SegmentName , Connections ] ;
299
308
const connections = Object . entries ( connectionMap ) ;
309
+ const rotation = randomRotation ( ) ;
300
310
301
311
return {
302
312
parentHash,
303
313
prefab : {
304
314
prefabObject : {
305
315
hash : Prefab [ segmentName ] . hash ,
306
- rotation : randomRotation ( )
316
+ rotation
307
317
} ,
308
318
childPrefabs :
309
319
connections . length === 0
310
- ? attachLeafNode ( speciesHash )
320
+ ? attachLeafNode ( speciesHash , rotation )
311
321
: connections . map ( ( [ embeddedEntity , childSegment ] ) =>
312
322
// After several hours I can't figure out the proper way to access this object and I cbf anymore.
313
323
createChildPrefab (
@@ -320,7 +330,10 @@ const createChildPrefab = (speciesHash: SpeciesHash, segment: Segment, parentHas
320
330
} ;
321
331
} ;
322
332
323
- const attachLeafNode = ( speciesHash : SpeciesHash ) : ChildPrefab [ ] => {
333
+ const attachLeafNode = (
334
+ speciesHash : SpeciesHash ,
335
+ rotation : { x : number ; y : number ; z : number ; w : number }
336
+ ) : ChildPrefab [ ] => {
324
337
const prefab = pickRandom ( LEAVES [ speciesHash ] ) ;
325
338
326
339
return [
@@ -329,12 +342,13 @@ const attachLeafNode = (speciesHash: SpeciesHash): ChildPrefab[] => {
329
342
prefab : {
330
343
prefabObject : {
331
344
hash : Prefab [ prefab ] . hash ,
332
- position : {
333
- x : 0 ,
334
- y : 0.25 ,
335
- z : 0
345
+ rotation : {
346
+ x : - rotation . x ,
347
+ y : - rotation . y ,
348
+ z : - rotation . z ,
349
+ w : - rotation . w
336
350
} ,
337
- scale : 1 + Math . random ( ) * 0.4
351
+ scale : LEAF_SCALE [ speciesHash ] + Math . random ( ) * 0.4
338
352
}
339
353
}
340
354
}
0 commit comments