sa2kit 1.4.1 → 1.4.3

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/mmd/index.js CHANGED
@@ -501,6 +501,56 @@ var MMDPlayerBase = React6.forwardRef((props, ref) => {
501
501
  });
502
502
  scene.add(mesh);
503
503
  console.log("[MMDPlayerBase] \u2705 Model added to scene (fully loaded)");
504
+ const isMobileDevice = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || window.innerWidth <= 768;
505
+ if (isMobileDevice) {
506
+ console.log("[MMDPlayerBase] \u{1F4F1} Mobile device detected, applying optimizations...");
507
+ if (renderer.capabilities.vertexTextures) {
508
+ console.log("[MMDPlayerBase] \u2705 Vertex textures supported");
509
+ } else {
510
+ console.log("[MMDPlayerBase] \u26A0\uFE0F Vertex textures NOT supported");
511
+ }
512
+ let simplifiedMaterialCount = 0;
513
+ mesh.traverse((child) => {
514
+ if (child instanceof THREE__namespace.Mesh || child instanceof THREE__namespace.SkinnedMesh) {
515
+ const materials = Array.isArray(child.material) ? child.material : [child.material];
516
+ materials.forEach((material, idx) => {
517
+ if (material instanceof THREE__namespace.MeshPhongMaterial || material instanceof THREE__namespace.MeshStandardMaterial) {
518
+ const originalColor = material.color?.clone();
519
+ const originalMap = material.map;
520
+ const basicMaterial = new THREE__namespace.MeshBasicMaterial({
521
+ color: originalColor || 16777215,
522
+ map: originalMap,
523
+ transparent: material.transparent,
524
+ opacity: material.opacity,
525
+ side: material.side,
526
+ alphaTest: material.alphaTest
527
+ });
528
+ if (Array.isArray(child.material)) {
529
+ child.material[idx] = basicMaterial;
530
+ } else {
531
+ child.material = basicMaterial;
532
+ }
533
+ material.dispose();
534
+ simplifiedMaterialCount++;
535
+ }
536
+ });
537
+ }
538
+ });
539
+ if (simplifiedMaterialCount > 0) {
540
+ console.log(`[MMDPlayerBase] \u2705 Simplified ${simplifiedMaterialCount} materials to MeshBasicMaterial`);
541
+ }
542
+ const MAX_BONES = 64;
543
+ if (mesh.skeleton) {
544
+ const boneCount = mesh.skeleton.bones.length;
545
+ if (boneCount > MAX_BONES) {
546
+ console.warn(`[MMDPlayerBase] \u26A0\uFE0F Model has ${boneCount} bones (max recommended: ${MAX_BONES})`);
547
+ console.warn(`[MMDPlayerBase] This may cause performance issues on mobile devices`);
548
+ } else {
549
+ console.log(`[MMDPlayerBase] \u2705 Bone count: ${boneCount} (within limit)`);
550
+ }
551
+ }
552
+ console.log("[MMDPlayerBase] \u{1F4F1} Mobile optimizations applied");
553
+ }
504
554
  if (resources.cameraPath) {
505
555
  loader.loadAnimation(
506
556
  resources.cameraPath,