minerender 2.1.0-alpha.50 → 2.1.0-alpha.52

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.
package/dist/bundle.js CHANGED
@@ -78088,27 +78088,66 @@ ${key}` : key;
78088
78088
  init_dirname();
78089
78089
  init_buffer2();
78090
78090
  init_process2();
78091
+ init_CubeFace();
78091
78092
  ModelGenerator = class {
78093
+ /**
78094
+ * Front and back faces plus one zero-thickness side face per run of texels that border a transparent texel,
78095
+ * like vanilla's ItemModelGenerator. Pass the pixels of a single (first) animation frame.
78096
+ */
78092
78097
  static generateItemModel(imageData, layer) {
78093
78098
  const tintindex = this.ITEM_LAYERS.indexOf(layer);
78099
+ const texture = `#${layer}`;
78094
78100
  const mainElement = {
78095
78101
  from: [0, 0, 7.5],
78096
78102
  to: [16, 16, 8.5],
78097
78103
  faces: {
78098
78104
  "south": {
78099
78105
  uv: [0, 0, 16, 16],
78100
- texture: `#${layer}`,
78106
+ texture,
78101
78107
  tintindex
78102
78108
  },
78103
78109
  "north": {
78104
78110
  uv: [16, 0, 0, 16],
78105
- texture: `#${layer}`,
78111
+ texture,
78106
78112
  tintindex
78107
78113
  }
78108
78114
  },
78109
78115
  shade: true
78110
78116
  };
78111
- return [mainElement];
78117
+ const elements = [mainElement];
78118
+ const { width, height, data } = imageData;
78119
+ const opaque = (x4, y5) => x4 >= 0 && y5 >= 0 && x4 < width && y5 < height && data[(y5 * width + x4) * 4 + 3] !== 0;
78120
+ const sx = 16 / width;
78121
+ const sy = 16 / height;
78122
+ const sides = [["up" /* UP */, 0, -1], ["down" /* DOWN */, 0, 1], ["west" /* WEST */, -1, 0], ["east" /* EAST */, 1, 0]];
78123
+ for (const [face, dx, dy] of sides) {
78124
+ const horizontal = dx === 0;
78125
+ const lines = horizontal ? height : width;
78126
+ const length = horizontal ? width : height;
78127
+ for (let line = 0; line < lines; line++) {
78128
+ for (let start = 0; start < length; start++) {
78129
+ const exposed = (i4) => horizontal ? opaque(i4, line) && !opaque(i4, line + dy) : opaque(line, i4) && !opaque(line + dx, i4);
78130
+ if (!exposed(start)) continue;
78131
+ let end = start + 1;
78132
+ while (end < length && exposed(end)) end++;
78133
+ let uv, from, to;
78134
+ if (horizontal) {
78135
+ const y5 = 16 - (line + (dy > 0 ? 1 : 0)) * sy;
78136
+ uv = [start * sx, line * sy, end * sx, (line + 1) * sy];
78137
+ from = [start * sx, y5, 7.5];
78138
+ to = [end * sx, y5, 8.5];
78139
+ } else {
78140
+ const x4 = (line + (dx > 0 ? 1 : 0)) * sx;
78141
+ uv = [line * sx, start * sy, (line + 1) * sx, end * sy];
78142
+ from = [x4, 16 - end * sy, 7.5];
78143
+ to = [x4, 16 - start * sy, 8.5];
78144
+ }
78145
+ elements.push({ from, to, faces: { [face]: { uv, texture, tintindex } }, shade: true });
78146
+ start = end;
78147
+ }
78148
+ }
78149
+ }
78150
+ return elements;
78112
78151
  }
78113
78152
  };
78114
78153
  ModelGenerator.ITEM_LAYERS = ["layer0", "layer1", "layer2", "layer3", "layer4"];
@@ -78479,7 +78518,15 @@ ${key}` : key;
78479
78518
  for (let layerName of ModelGenerator.ITEM_LAYERS) {
78480
78519
  const textureImage = textureMap[layerName];
78481
78520
  if (textureImage) {
78482
- model.elements.push(...ModelGenerator.generateItemModel(textureImage.data, layerName));
78521
+ const [width, height] = sizes[layerName];
78522
+ const frame = frames[layerName]?.[0].index ?? 0;
78523
+ const columns = textureImage.width / width;
78524
+ model.elements.push(...ModelGenerator.generateItemModel(textureImage.getSectionData(
78525
+ frame % columns * width,
78526
+ Math.floor(frame / columns) * height,
78527
+ width,
78528
+ height
78529
+ ), layerName));
78483
78530
  }
78484
78531
  }
78485
78532
  console.debug(p8, "Item model elements", model.elements);
@@ -79703,7 +79750,6 @@ ${key}` : key;
79703
79750
  if (this.options.tints) this.options.tints = { ...this.options.tints };
79704
79751
  this.addEventListener("added", () => this.updateAnimationSubscription());
79705
79752
  this.addEventListener("removed", () => this.updateAnimationSubscription());
79706
- console.log("ModelObject options", this.options);
79707
79753
  }
79708
79754
  async init() {
79709
79755
  await this.loadTextures();
@@ -83704,6 +83750,10 @@ ${key}` : key;
83704
83750
  uv
83705
83751
  ).clone();
83706
83752
  geometry.translate(cube.origin[0] + width / 2, cube.origin[1] + height / 2, cube.origin[2] + depth / 2);
83753
+ if (Math.min(width + growX * 2, height + growY * 2, depth + growZ * 2) > 0) {
83754
+ const index = Array.from(geometry.getIndex().array);
83755
+ geometry.setIndex(index.concat(index.slice().reverse()));
83756
+ }
83707
83757
  const mesh = this.createMesh(name2, geometry, material);
83708
83758
  mesh.renderOrder = renderOrder;
83709
83759
  anchor.add(mesh);
@@ -86731,7 +86781,7 @@ property list uchar int vertex_index
86731
86781
  }
86732
86782
  init() {
86733
86783
  this.statsContainer.classList.add("minerender-stats");
86734
- setInterval(() => {
86784
+ this.interval = setInterval(() => {
86735
86785
  for (let line of this.lines) {
86736
86786
  line.update();
86737
86787
  }
@@ -86740,6 +86790,13 @@ property list uchar int vertex_index
86740
86790
  appendTo(el) {
86741
86791
  el.append(this.statsContainer);
86742
86792
  }
86793
+ dispose() {
86794
+ clearInterval(this.interval);
86795
+ this.interval = void 0;
86796
+ this.lines.length = 0;
86797
+ this.statsContainer.replaceChildren();
86798
+ this.statsContainer.remove();
86799
+ }
86743
86800
  add(line) {
86744
86801
  if (typeof line !== "undefined") {
86745
86802
  this.lines.push(line);
@@ -89282,7 +89339,7 @@ property list uchar int vertex_index
89282
89339
  init_process2();
89283
89340
  var baseSkinCoordinates = {
89284
89341
  head: {
89285
- east: {
89342
+ west: {
89286
89343
  // left
89287
89344
  uv: [
89288
89345
  0,
@@ -89291,7 +89348,7 @@ property list uchar int vertex_index
89291
89348
  16
89292
89349
  ]
89293
89350
  },
89294
- west: {
89351
+ east: {
89295
89352
  // right
89296
89353
  uv: [
89297
89354
  16,
@@ -89300,7 +89357,7 @@ property list uchar int vertex_index
89300
89357
  16
89301
89358
  ]
89302
89359
  },
89303
- north: {
89360
+ south: {
89304
89361
  // front
89305
89362
  uv: [
89306
89363
  8,
@@ -89309,7 +89366,7 @@ property list uchar int vertex_index
89309
89366
  16
89310
89367
  ]
89311
89368
  },
89312
- south: {
89369
+ north: {
89313
89370
  // back
89314
89371
  uv: [
89315
89372
  24,
@@ -89321,24 +89378,24 @@ property list uchar int vertex_index
89321
89378
  up: {
89322
89379
  // top
89323
89380
  uv: [
89324
- 16,
89325
89381
  8,
89326
- 8,
89327
- 0
89382
+ 0,
89383
+ 16,
89384
+ 8
89328
89385
  ]
89329
89386
  },
89330
89387
  down: {
89331
89388
  // bottom
89332
89389
  uv: [
89333
- 24,
89334
- 0,
89335
89390
  16,
89336
- 8
89391
+ 8,
89392
+ 24,
89393
+ 0
89337
89394
  ]
89338
89395
  }
89339
89396
  },
89340
89397
  body: {
89341
- east: {
89398
+ west: {
89342
89399
  uv: [
89343
89400
  16,
89344
89401
  20,
@@ -89346,7 +89403,7 @@ property list uchar int vertex_index
89346
89403
  32
89347
89404
  ]
89348
89405
  },
89349
- west: {
89406
+ east: {
89350
89407
  uv: [
89351
89408
  28,
89352
89409
  20,
@@ -89354,7 +89411,7 @@ property list uchar int vertex_index
89354
89411
  32
89355
89412
  ]
89356
89413
  },
89357
- north: {
89414
+ south: {
89358
89415
  uv: [
89359
89416
  20,
89360
89417
  20,
@@ -89362,7 +89419,7 @@ property list uchar int vertex_index
89362
89419
  32
89363
89420
  ]
89364
89421
  },
89365
- south: {
89422
+ north: {
89366
89423
  uv: [
89367
89424
  32,
89368
89425
  20,
@@ -89372,23 +89429,23 @@ property list uchar int vertex_index
89372
89429
  },
89373
89430
  up: {
89374
89431
  uv: [
89375
- 28,
89376
- 20,
89377
89432
  20,
89378
- 16
89433
+ 16,
89434
+ 28,
89435
+ 20
89379
89436
  ]
89380
89437
  },
89381
89438
  down: {
89382
89439
  uv: [
89383
- 36,
89384
- 16,
89385
89440
  28,
89386
- 20
89441
+ 20,
89442
+ 36,
89443
+ 16
89387
89444
  ]
89388
89445
  }
89389
89446
  },
89390
89447
  leftArm: {
89391
- east: {
89448
+ west: {
89392
89449
  uv: [
89393
89450
  32,
89394
89451
  52,
@@ -89396,7 +89453,7 @@ property list uchar int vertex_index
89396
89453
  64
89397
89454
  ]
89398
89455
  },
89399
- west: {
89456
+ east: {
89400
89457
  uv: [
89401
89458
  40,
89402
89459
  52,
@@ -89404,7 +89461,7 @@ property list uchar int vertex_index
89404
89461
  64
89405
89462
  ]
89406
89463
  },
89407
- north: {
89464
+ south: {
89408
89465
  uv: [
89409
89466
  36,
89410
89467
  52,
@@ -89412,7 +89469,7 @@ property list uchar int vertex_index
89412
89469
  64
89413
89470
  ]
89414
89471
  },
89415
- south: {
89472
+ north: {
89416
89473
  uv: [
89417
89474
  44,
89418
89475
  52,
@@ -89422,23 +89479,23 @@ property list uchar int vertex_index
89422
89479
  },
89423
89480
  up: {
89424
89481
  uv: [
89425
- 40,
89426
- 52,
89427
89482
  36,
89428
- 48
89483
+ 48,
89484
+ 40,
89485
+ 52
89429
89486
  ]
89430
89487
  },
89431
89488
  down: {
89432
89489
  uv: [
89433
- 44,
89434
- 48,
89435
89490
  40,
89436
- 52
89491
+ 52,
89492
+ 44,
89493
+ 48
89437
89494
  ]
89438
89495
  }
89439
89496
  },
89440
89497
  rightArm: {
89441
- east: {
89498
+ west: {
89442
89499
  uv: [
89443
89500
  40,
89444
89501
  20,
@@ -89446,7 +89503,7 @@ property list uchar int vertex_index
89446
89503
  32
89447
89504
  ]
89448
89505
  },
89449
- west: {
89506
+ east: {
89450
89507
  uv: [
89451
89508
  48,
89452
89509
  20,
@@ -89454,7 +89511,7 @@ property list uchar int vertex_index
89454
89511
  32
89455
89512
  ]
89456
89513
  },
89457
- north: {
89514
+ south: {
89458
89515
  uv: [
89459
89516
  44,
89460
89517
  20,
@@ -89462,7 +89519,7 @@ property list uchar int vertex_index
89462
89519
  32
89463
89520
  ]
89464
89521
  },
89465
- south: {
89522
+ north: {
89466
89523
  uv: [
89467
89524
  52,
89468
89525
  20,
@@ -89472,23 +89529,23 @@ property list uchar int vertex_index
89472
89529
  },
89473
89530
  up: {
89474
89531
  uv: [
89475
- 48,
89476
- 20,
89477
89532
  44,
89478
- 16
89533
+ 16,
89534
+ 48,
89535
+ 20
89479
89536
  ]
89480
89537
  },
89481
89538
  down: {
89482
89539
  uv: [
89483
- 52,
89484
- 16,
89485
89540
  48,
89486
- 20
89541
+ 20,
89542
+ 52,
89543
+ 16
89487
89544
  ]
89488
89545
  }
89489
89546
  },
89490
89547
  leftLeg: {
89491
- east: {
89548
+ west: {
89492
89549
  uv: [
89493
89550
  16,
89494
89551
  52,
@@ -89496,7 +89553,7 @@ property list uchar int vertex_index
89496
89553
  64
89497
89554
  ]
89498
89555
  },
89499
- west: {
89556
+ east: {
89500
89557
  uv: [
89501
89558
  24,
89502
89559
  52,
@@ -89504,7 +89561,7 @@ property list uchar int vertex_index
89504
89561
  64
89505
89562
  ]
89506
89563
  },
89507
- north: {
89564
+ south: {
89508
89565
  uv: [
89509
89566
  20,
89510
89567
  52,
@@ -89512,7 +89569,7 @@ property list uchar int vertex_index
89512
89569
  64
89513
89570
  ]
89514
89571
  },
89515
- south: {
89572
+ north: {
89516
89573
  uv: [
89517
89574
  28,
89518
89575
  52,
@@ -89522,24 +89579,24 @@ property list uchar int vertex_index
89522
89579
  },
89523
89580
  up: {
89524
89581
  uv: [
89525
- 24,
89526
- 52,
89527
89582
  20,
89528
- 48
89583
+ 48,
89584
+ 24,
89585
+ 52
89529
89586
  ]
89530
89587
  },
89531
89588
  down: {
89532
89589
  uv: [
89533
- 28,
89534
- 48,
89535
89590
  24,
89536
- 52
89591
+ 52,
89592
+ 28,
89593
+ 48
89537
89594
  ],
89538
89595
  rotation: 180
89539
89596
  }
89540
89597
  },
89541
89598
  rightLeg: {
89542
- east: {
89599
+ west: {
89543
89600
  uv: [
89544
89601
  0,
89545
89602
  20,
@@ -89547,7 +89604,7 @@ property list uchar int vertex_index
89547
89604
  32
89548
89605
  ]
89549
89606
  },
89550
- west: {
89607
+ east: {
89551
89608
  uv: [
89552
89609
  8,
89553
89610
  20,
@@ -89555,7 +89612,7 @@ property list uchar int vertex_index
89555
89612
  32
89556
89613
  ]
89557
89614
  },
89558
- north: {
89615
+ south: {
89559
89616
  uv: [
89560
89617
  4,
89561
89618
  20,
@@ -89563,7 +89620,7 @@ property list uchar int vertex_index
89563
89620
  32
89564
89621
  ]
89565
89622
  },
89566
- south: {
89623
+ north: {
89567
89624
  uv: [
89568
89625
  12,
89569
89626
  20,
@@ -89573,23 +89630,23 @@ property list uchar int vertex_index
89573
89630
  },
89574
89631
  up: {
89575
89632
  uv: [
89576
- 8,
89577
- 20,
89578
89633
  4,
89579
- 16
89634
+ 16,
89635
+ 8,
89636
+ 20
89580
89637
  ]
89581
89638
  },
89582
89639
  down: {
89583
89640
  uv: [
89584
- 12,
89585
- 16,
89586
89641
  8,
89587
- 20
89642
+ 20,
89643
+ 12,
89644
+ 16
89588
89645
  ]
89589
89646
  }
89590
89647
  },
89591
89648
  hat: {
89592
- east: {
89649
+ west: {
89593
89650
  uv: [
89594
89651
  32,
89595
89652
  8,
@@ -89597,7 +89654,7 @@ property list uchar int vertex_index
89597
89654
  16
89598
89655
  ]
89599
89656
  },
89600
- west: {
89657
+ east: {
89601
89658
  uv: [
89602
89659
  48,
89603
89660
  8,
@@ -89605,7 +89662,7 @@ property list uchar int vertex_index
89605
89662
  16
89606
89663
  ]
89607
89664
  },
89608
- north: {
89665
+ south: {
89609
89666
  uv: [
89610
89667
  40,
89611
89668
  8,
@@ -89613,7 +89670,7 @@ property list uchar int vertex_index
89613
89670
  16
89614
89671
  ]
89615
89672
  },
89616
- south: {
89673
+ north: {
89617
89674
  uv: [
89618
89675
  56,
89619
89676
  8,
@@ -89623,24 +89680,24 @@ property list uchar int vertex_index
89623
89680
  },
89624
89681
  up: {
89625
89682
  uv: [
89626
- 48,
89627
- 8,
89628
89683
  40,
89629
- 0
89684
+ 0,
89685
+ 48,
89686
+ 8
89630
89687
  ]
89631
89688
  },
89632
89689
  down: {
89633
89690
  uv: [
89634
- 56,
89635
- 0,
89636
89691
  48,
89637
- 8
89692
+ 8,
89693
+ 56,
89694
+ 0
89638
89695
  ],
89639
89696
  rotation: 180
89640
89697
  }
89641
89698
  },
89642
89699
  jacket: {
89643
- east: {
89700
+ west: {
89644
89701
  uv: [
89645
89702
  16,
89646
89703
  36,
@@ -89648,7 +89705,7 @@ property list uchar int vertex_index
89648
89705
  48
89649
89706
  ]
89650
89707
  },
89651
- west: {
89708
+ east: {
89652
89709
  uv: [
89653
89710
  28,
89654
89711
  36,
@@ -89656,7 +89713,7 @@ property list uchar int vertex_index
89656
89713
  48
89657
89714
  ]
89658
89715
  },
89659
- north: {
89716
+ south: {
89660
89717
  uv: [
89661
89718
  20,
89662
89719
  36,
@@ -89664,7 +89721,7 @@ property list uchar int vertex_index
89664
89721
  48
89665
89722
  ]
89666
89723
  },
89667
- south: {
89724
+ north: {
89668
89725
  uv: [
89669
89726
  32,
89670
89727
  36,
@@ -89674,24 +89731,24 @@ property list uchar int vertex_index
89674
89731
  },
89675
89732
  up: {
89676
89733
  uv: [
89677
- 28,
89678
- 36,
89679
89734
  20,
89680
- 32
89735
+ 32,
89736
+ 28,
89737
+ 36
89681
89738
  ]
89682
89739
  },
89683
89740
  down: {
89684
89741
  uv: [
89685
- 36,
89686
- 32,
89687
89742
  28,
89688
- 36
89743
+ 36,
89744
+ 36,
89745
+ 32
89689
89746
  ],
89690
89747
  rotation: 180
89691
89748
  }
89692
89749
  },
89693
89750
  leftSleeve: {
89694
- east: {
89751
+ west: {
89695
89752
  uv: [
89696
89753
  48,
89697
89754
  52,
@@ -89699,7 +89756,7 @@ property list uchar int vertex_index
89699
89756
  64
89700
89757
  ]
89701
89758
  },
89702
- west: {
89759
+ east: {
89703
89760
  uv: [
89704
89761
  56,
89705
89762
  52,
@@ -89707,7 +89764,7 @@ property list uchar int vertex_index
89707
89764
  64
89708
89765
  ]
89709
89766
  },
89710
- north: {
89767
+ south: {
89711
89768
  uv: [
89712
89769
  52,
89713
89770
  52,
@@ -89715,7 +89772,7 @@ property list uchar int vertex_index
89715
89772
  64
89716
89773
  ]
89717
89774
  },
89718
- south: {
89775
+ north: {
89719
89776
  uv: [
89720
89777
  60,
89721
89778
  52,
@@ -89725,24 +89782,24 @@ property list uchar int vertex_index
89725
89782
  },
89726
89783
  up: {
89727
89784
  uv: [
89728
- 56,
89729
- 52,
89730
89785
  52,
89731
- 48
89786
+ 48,
89787
+ 56,
89788
+ 52
89732
89789
  ]
89733
89790
  },
89734
89791
  down: {
89735
89792
  uv: [
89736
- 60,
89737
- 48,
89738
89793
  56,
89739
- 52
89794
+ 52,
89795
+ 60,
89796
+ 48
89740
89797
  ],
89741
89798
  rotation: 180
89742
89799
  }
89743
89800
  },
89744
89801
  rightSleeve: {
89745
- east: {
89802
+ west: {
89746
89803
  uv: [
89747
89804
  40,
89748
89805
  36,
@@ -89750,7 +89807,7 @@ property list uchar int vertex_index
89750
89807
  48
89751
89808
  ]
89752
89809
  },
89753
- west: {
89810
+ east: {
89754
89811
  uv: [
89755
89812
  48,
89756
89813
  36,
@@ -89758,7 +89815,7 @@ property list uchar int vertex_index
89758
89815
  48
89759
89816
  ]
89760
89817
  },
89761
- north: {
89818
+ south: {
89762
89819
  uv: [
89763
89820
  44,
89764
89821
  36,
@@ -89766,7 +89823,7 @@ property list uchar int vertex_index
89766
89823
  48
89767
89824
  ]
89768
89825
  },
89769
- south: {
89826
+ north: {
89770
89827
  uv: [
89771
89828
  52,
89772
89829
  36,
@@ -89776,24 +89833,24 @@ property list uchar int vertex_index
89776
89833
  },
89777
89834
  up: {
89778
89835
  uv: [
89779
- 48,
89780
- 36,
89781
89836
  44,
89782
- 32
89837
+ 32,
89838
+ 48,
89839
+ 36
89783
89840
  ]
89784
89841
  },
89785
89842
  down: {
89786
89843
  uv: [
89787
- 52,
89788
- 32,
89789
89844
  48,
89790
- 36
89845
+ 36,
89846
+ 52,
89847
+ 32
89791
89848
  ],
89792
89849
  rotation: 180
89793
89850
  }
89794
89851
  },
89795
89852
  leftTrousers: {
89796
- east: {
89853
+ west: {
89797
89854
  uv: [
89798
89855
  0,
89799
89856
  52,
@@ -89801,7 +89858,7 @@ property list uchar int vertex_index
89801
89858
  64
89802
89859
  ]
89803
89860
  },
89804
- west: {
89861
+ east: {
89805
89862
  uv: [
89806
89863
  8,
89807
89864
  52,
@@ -89809,7 +89866,7 @@ property list uchar int vertex_index
89809
89866
  64
89810
89867
  ]
89811
89868
  },
89812
- north: {
89869
+ south: {
89813
89870
  uv: [
89814
89871
  4,
89815
89872
  52,
@@ -89817,7 +89874,7 @@ property list uchar int vertex_index
89817
89874
  64
89818
89875
  ]
89819
89876
  },
89820
- south: {
89877
+ north: {
89821
89878
  uv: [
89822
89879
  12,
89823
89880
  52,
@@ -89827,23 +89884,23 @@ property list uchar int vertex_index
89827
89884
  },
89828
89885
  up: {
89829
89886
  uv: [
89830
- 8,
89831
- 52,
89832
89887
  4,
89833
- 48
89888
+ 48,
89889
+ 8,
89890
+ 52
89834
89891
  ]
89835
89892
  },
89836
89893
  down: {
89837
89894
  uv: [
89838
- 12,
89839
- 48,
89840
89895
  8,
89841
- 52
89896
+ 52,
89897
+ 12,
89898
+ 48
89842
89899
  ]
89843
89900
  }
89844
89901
  },
89845
89902
  rightTrousers: {
89846
- east: {
89903
+ west: {
89847
89904
  uv: [
89848
89905
  0,
89849
89906
  36,
@@ -89851,7 +89908,7 @@ property list uchar int vertex_index
89851
89908
  48
89852
89909
  ]
89853
89910
  },
89854
- west: {
89911
+ east: {
89855
89912
  uv: [
89856
89913
  8,
89857
89914
  36,
@@ -89859,7 +89916,7 @@ property list uchar int vertex_index
89859
89916
  48
89860
89917
  ]
89861
89918
  },
89862
- north: {
89919
+ south: {
89863
89920
  uv: [
89864
89921
  4,
89865
89922
  36,
@@ -89867,7 +89924,7 @@ property list uchar int vertex_index
89867
89924
  48
89868
89925
  ]
89869
89926
  },
89870
- south: {
89927
+ north: {
89871
89928
  uv: [
89872
89929
  12,
89873
89930
  36,
@@ -89877,18 +89934,18 @@ property list uchar int vertex_index
89877
89934
  },
89878
89935
  up: {
89879
89936
  uv: [
89880
- 8,
89881
- 36,
89882
89937
  4,
89883
- 32
89938
+ 32,
89939
+ 8,
89940
+ 36
89884
89941
  ]
89885
89942
  },
89886
89943
  down: {
89887
89944
  uv: [
89888
- 12,
89889
- 32,
89890
89945
  8,
89891
- 36
89946
+ 36,
89947
+ 12,
89948
+ 32
89892
89949
  ],
89893
89950
  rotation: 180
89894
89951
  }
@@ -89909,35 +89966,35 @@ property list uchar int vertex_index
89909
89966
  ...baseSkinCoordinates,
89910
89967
  leftArm: {
89911
89968
  ...baseSkinCoordinates.leftArm,
89912
- west: { uv: [39, 52, 43, 64] },
89913
- north: { uv: [36, 52, 39, 64] },
89914
- south: { uv: [43, 52, 46, 64] },
89915
- up: { uv: [39, 52, 36, 48] },
89916
- down: { uv: [42, 48, 39, 52] }
89969
+ east: { uv: [39, 52, 43, 64] },
89970
+ south: { uv: [36, 52, 39, 64] },
89971
+ north: { uv: [43, 52, 46, 64] },
89972
+ up: { uv: [36, 48, 39, 52] },
89973
+ down: { uv: [39, 52, 42, 48] }
89917
89974
  },
89918
89975
  rightArm: {
89919
89976
  ...baseSkinCoordinates.rightArm,
89920
- west: { uv: [47, 20, 51, 32] },
89921
- north: { uv: [44, 20, 47, 32] },
89922
- south: { uv: [51, 20, 54, 32] },
89923
- up: { uv: [47, 20, 44, 16] },
89924
- down: { uv: [50, 16, 47, 20] }
89977
+ east: { uv: [47, 20, 51, 32] },
89978
+ south: { uv: [44, 20, 47, 32] },
89979
+ north: { uv: [51, 20, 54, 32] },
89980
+ up: { uv: [44, 16, 47, 20] },
89981
+ down: { uv: [47, 20, 50, 16] }
89925
89982
  },
89926
89983
  leftSleeve: {
89927
89984
  ...baseSkinCoordinates.leftSleeve,
89928
- west: { uv: [55, 52, 59, 64] },
89929
- north: { uv: [52, 52, 55, 64] },
89930
- south: { uv: [59, 52, 62, 64] },
89931
- up: { uv: [55, 52, 52, 48] },
89932
- down: { uv: [58, 48, 55, 52], rotation: 180 }
89985
+ east: { uv: [55, 52, 59, 64] },
89986
+ south: { uv: [52, 52, 55, 64] },
89987
+ north: { uv: [59, 52, 62, 64] },
89988
+ up: { uv: [52, 48, 55, 52] },
89989
+ down: { uv: [55, 52, 58, 48], rotation: 180 }
89933
89990
  },
89934
89991
  rightSleeve: {
89935
89992
  ...baseSkinCoordinates.rightSleeve,
89936
- west: { uv: [47, 36, 51, 48] },
89937
- north: { uv: [44, 36, 47, 48] },
89938
- south: { uv: [51, 36, 54, 48] },
89939
- up: { uv: [47, 36, 44, 32] },
89940
- down: { uv: [50, 32, 47, 36], rotation: 180 }
89993
+ east: { uv: [47, 36, 51, 48] },
89994
+ south: { uv: [44, 36, 47, 48] },
89995
+ north: { uv: [51, 36, 54, 48] },
89996
+ up: { uv: [44, 32, 47, 36] },
89997
+ down: { uv: [47, 36, 50, 32], rotation: 180 }
89941
89998
  }
89942
89999
  };
89943
90000
 
@@ -90189,34 +90246,34 @@ property list uchar int vertex_index
90189
90246
  }
90190
90247
  {
90191
90248
  {
90192
- const leftArmGroup = this.createAndAddGroup("leftArm", -5, 22, 0);
90249
+ const leftArmGroup = this.createAndAddGroup("leftArm", 5, 22, 0);
90193
90250
  const leftArmGeo = this.getBoxGeometry("leftArm" /* LEFT_ARM */);
90194
90251
  const leftArm = this.createAndAddMesh("leftArm", leftArmGroup, leftArmGeo, mat, "y" /* Y */, -4);
90195
- leftArm.position.x = this.slim ? -0.5 : -1;
90252
+ leftArm.position.x = this.slim ? 0.5 : 1;
90196
90253
  const leftSleeveGeo = this.getBoxGeometry("leftSleeve" /* LEFT_SLEEVE */);
90197
90254
  const leftSleeve = this.createAndAddMesh("leftSleeve", leftArmGroup, leftSleeveGeo, mat, "y" /* Y */, -4);
90198
- leftSleeve.position.x = this.slim ? -0.5 : -1;
90255
+ leftSleeve.position.x = this.slim ? 0.5 : 1;
90199
90256
  }
90200
90257
  {
90201
- const rightArmGroup = this.createAndAddGroup("rightArm", 5, 22, 0);
90258
+ const rightArmGroup = this.createAndAddGroup("rightArm", -5, 22, 0);
90202
90259
  const rightArmGeo = this.getBoxGeometry("rightArm" /* RIGHT_ARM */);
90203
90260
  const rightArm = this.createAndAddMesh("rightArm", rightArmGroup, rightArmGeo, mat, "y" /* Y */, -4);
90204
- rightArm.position.x = this.slim ? 0.5 : 1;
90261
+ rightArm.position.x = this.slim ? -0.5 : -1;
90205
90262
  const rightSleeveGeo = this.getBoxGeometry("rightSleeve" /* RIGHT_SLEEVE */);
90206
90263
  const rightSleeve = this.createAndAddMesh("rightSleeve", rightArmGroup, rightSleeveGeo, mat, "y" /* Y */, -4);
90207
- rightSleeve.position.x = this.slim ? 0.5 : 1;
90264
+ rightSleeve.position.x = this.slim ? -0.5 : -1;
90208
90265
  }
90209
90266
  }
90210
90267
  {
90211
90268
  {
90212
- const leftLegGroup = this.createAndAddGroup("leftLeg", -1.9, 12, 0);
90269
+ const leftLegGroup = this.createAndAddGroup("leftLeg", 1.9, 12, 0);
90213
90270
  const leftLegGeo = this.getBoxGeometry("leftLeg" /* LEFT_LEG */);
90214
90271
  const leftLeg = this.createAndAddMesh("leftLeg", leftLegGroup, leftLegGeo, mat, "y" /* Y */, -6);
90215
90272
  const leftTrousersGeo = this.getBoxGeometry("leftTrousers" /* LEFT_TROUSERS */);
90216
90273
  const leftTrousers = this.createAndAddMesh("leftTrousers", leftLegGroup, leftTrousersGeo, mat, "y" /* Y */, -6);
90217
90274
  }
90218
90275
  {
90219
- const rightLegGroup = this.createAndAddGroup("rightLeg", 1.9, 12, 0);
90276
+ const rightLegGroup = this.createAndAddGroup("rightLeg", -1.9, 12, 0);
90220
90277
  const rightLegGeo = this.getBoxGeometry("rightLeg" /* RIGHT_LEG */);
90221
90278
  const rightLeg = this.createAndAddMesh("rightLeg", rightLegGroup, rightLegGeo, mat, "y" /* Y */, -6);
90222
90279
  const rightTrousersGeo = this.getBoxGeometry("rightTrousers" /* RIGHT_TROUSERS */);
@@ -90266,9 +90323,10 @@ property list uchar int vertex_index
90266
90323
  mesh.geometry = geometry;
90267
90324
  } else {
90268
90325
  const body = this.getGroupByName("body" /* BODY */);
90269
- const group = this.createGroup("cape" /* CAPE */, 0, body ? 0 : 24, 2);
90326
+ const group = this.createGroup("cape" /* CAPE */);
90327
+ group.position.set(0, body ? 0 : 24, -2);
90270
90328
  (body ?? this).add(group);
90271
- group.rotation.set(toRadians(-6), Math.PI, 0);
90329
+ group.rotation.x = toRadians(6);
90272
90330
  const cape = this.createAndAddMesh("cape" /* CAPE */, group, geometry, material);
90273
90331
  cape.position.set(0, -8, -0.5);
90274
90332
  }
@@ -90282,7 +90340,7 @@ property list uchar int vertex_index
90282
90340
  updateSlim(slim) {
90283
90341
  if (slim === this.slim) return;
90284
90342
  this.slim = slim;
90285
- const offset = slim ? 0.5 : -0.5;
90343
+ const offset = slim ? -0.5 : 0.5;
90286
90344
  for (const part of ["leftArm" /* LEFT_ARM */, "leftSleeve" /* LEFT_SLEEVE */, "rightArm" /* RIGHT_ARM */, "rightSleeve" /* RIGHT_SLEEVE */]) {
90287
90345
  const mesh = this.getMeshByName(part);
90288
90346
  if (mesh) {
@@ -90376,13 +90434,9 @@ property list uchar int vertex_index
90376
90434
  return this.add(...object);
90377
90435
  }
90378
90436
  async addSceneObject(asset, objectSupplier, _options, parent = this) {
90379
- console.log("addSceneObject", asset);
90380
- console.log("parent", parent);
90381
- console.log(_options);
90382
90437
  this.dirty = true;
90383
90438
  const obj = await objectSupplier();
90384
90439
  if (obj?.options?.instanceMeshes && asset.key && asset.key?.assetType === "models") {
90385
- console.log("instanceMeshes + key");
90386
90440
  let key = asset.key.serialize();
90387
90441
  if (isModelObject(obj)) {
90388
90442
  const { displayPosition, uvLockRotation, tints, cullMask } = obj.options;
@@ -90399,7 +90453,6 @@ property list uchar int vertex_index
90399
90453
  return obj;
90400
90454
  });
90401
90455
  } else {
90402
- console.log("!instanceMeshes | !key");
90403
90456
  obj.scene = this;
90404
90457
  await obj.init();
90405
90458
  if (!isBlockObject(obj)) {
@@ -92875,7 +92928,10 @@ uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuf
92875
92928
  constructor(options) {
92876
92929
  this._dirty = true;
92877
92930
  this._resizeListener = void 0;
92931
+ this._running = false;
92932
+ this._inAnimationLoop = false;
92878
92933
  this._disposed = false;
92934
+ this._frameCallbacks = /* @__PURE__ */ new Map();
92879
92935
  this._debugHelpers = [];
92880
92936
  this._eventDispatchers = /* @__PURE__ */ new Map();
92881
92937
  this._changeListener = () => {
@@ -92886,7 +92942,14 @@ uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuf
92886
92942
  if (!Number.isFinite(pixelRatio) || pixelRatio <= 0) {
92887
92943
  throw new RangeError("render.pixelRatio must be a finite positive number");
92888
92944
  }
92889
- this._animationLoop = this.animate.bind(this);
92945
+ this._animationLoop = (time) => {
92946
+ this._inAnimationLoop = true;
92947
+ try {
92948
+ this.animate(time);
92949
+ } finally {
92950
+ this._inAnimationLoop = false;
92951
+ }
92952
+ };
92890
92953
  this._frameInterval = this.options.render.fpsLimit > 0 ? 1e3 / this.options.render.fpsLimit : void 0;
92891
92954
  this._scene = this.createScene();
92892
92955
  this._camera = this.createCamera();
@@ -93061,15 +93124,39 @@ uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuf
93061
93124
  this._dirty = dirty;
93062
93125
  this.scene.dirty = dirty;
93063
93126
  }
93127
+ /**
93128
+ * Calls a synchronous animation update before each FPS-limited draw while started.
93129
+ * Subscriptions keep the scene drawing without manual dirty flags. Returns an unsubscribe function.
93130
+ * Registering the same callback twice has no effect. Image exports do not invoke callbacks.
93131
+ */
93132
+ onFrame(callback) {
93133
+ if (this._disposed) return () => {
93134
+ };
93135
+ const subscription = this._frameCallbacks.get(callback) ?? {};
93136
+ this._frameCallbacks.set(callback, subscription);
93137
+ return () => {
93138
+ if (this._frameCallbacks.get(callback) === subscription) this._frameCallbacks.delete(callback);
93139
+ };
93140
+ }
93064
93141
  start() {
93065
93142
  if (this._disposed) return;
93066
93143
  this.stop();
93067
- this.renderer.setAnimationLoop(this._animationLoop);
93144
+ this._running = true;
93145
+ if (!this._inAnimationLoop) this.renderer.setAnimationLoop(this._animationLoop);
93068
93146
  }
93069
93147
  stop() {
93070
93148
  if (this._disposed) return;
93071
- this.renderer.setAnimationLoop(null);
93149
+ this._running = false;
93150
+ if (this._inAnimationLoop) {
93151
+ queueMicrotask(() => {
93152
+ this.renderer.setAnimationLoop(null);
93153
+ if (this._running) this.renderer.setAnimationLoop(this._animationLoop);
93154
+ });
93155
+ } else {
93156
+ this.renderer.setAnimationLoop(null);
93157
+ }
93072
93158
  this._nextFrameTime = void 0;
93159
+ for (const subscription of this._frameCallbacks.values()) subscription.previous = void 0;
93073
93160
  }
93074
93161
  /**
93075
93162
  * Stops rendering and releases owned resources. Repeated calls have no effect, and a disposed
@@ -93080,6 +93167,7 @@ uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuf
93080
93167
  if (this._disposed) return;
93081
93168
  this.stop();
93082
93169
  this._disposed = true;
93170
+ this._frameCallbacks.clear();
93083
93171
  if (this._resizeListener) {
93084
93172
  window.removeEventListener("resize", this._resizeListener);
93085
93173
  this._resizeListener = void 0;
@@ -93114,18 +93202,25 @@ uniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuf
93114
93202
  this.renderer.forceContextLoss();
93115
93203
  }
93116
93204
  animate(t5 = performance.now()) {
93117
- if (this._disposed) return;
93205
+ if (!this._running) return;
93118
93206
  if (this._controls?.enabled) {
93119
93207
  this._controls.update();
93120
93208
  }
93121
- if (this._disposed) return;
93122
- if (!this.dirty && !this.options.render.renderAlways) return;
93209
+ if (!this._running) return;
93210
+ if (!this.dirty && !this.options.render.renderAlways && !this._frameCallbacks.size) return;
93123
93211
  const interval = this._frameInterval;
93124
93212
  if (interval) {
93125
93213
  const next = this._nextFrameTime;
93126
93214
  if (next !== void 0 && t5 + 0.1 < next) return;
93127
93215
  this._nextFrameTime = next !== void 0 && t5 - next < interval ? next + interval : t5 + interval;
93128
93216
  }
93217
+ for (const [callback, subscription] of [...this._frameCallbacks]) {
93218
+ if (this._frameCallbacks.get(callback) !== subscription) continue;
93219
+ const previous = subscription.previous;
93220
+ subscription.previous = t5;
93221
+ callback({ time: t5 / 1e3, delta: previous === void 0 ? 0 : (t5 - previous) / 1e3 });
93222
+ if (!this._running) return;
93223
+ }
93129
93224
  this.drawFrame();
93130
93225
  }
93131
93226
  drawFrame() {