sa2kit 1.0.6 → 1.0.7

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.
@@ -491,7 +491,6 @@ var MMDPlayerEnhanced = ({
491
491
  };
492
492
  }, [stage]);
493
493
  const clearOldResources = () => {
494
- console.log("\u{1F9F9} [MMDPlayerEnhanced] \u5F00\u59CB\u6E05\u9664\u65E7\u8D44\u6E90\uFF08\u589E\u5F3A\u6E05\u7406\uFF09");
495
494
  if (!sceneRef.current) return;
496
495
  if (isPlayingRef.current) {
497
496
  isPlayingRef.current = false;
@@ -501,58 +500,64 @@ var MMDPlayerEnhanced = ({
501
500
  audioRef.current.pause();
502
501
  audioRef.current.currentTime = 0;
503
502
  audioRef.current.onended = null;
503
+ audioRef.current.src = "";
504
+ audioRef.current.load();
504
505
  audioRef.current = null;
505
506
  }
506
507
  if (helperRef.current) {
507
- console.log("\u{1F9F9} \u5F00\u59CB\u6E05\u7406 MMDAnimationHelper");
508
508
  try {
509
509
  helperRef.current.enable("animation", false);
510
510
  helperRef.current.enable("ik", false);
511
511
  helperRef.current.enable("grant", false);
512
512
  helperRef.current.enable("physics", false);
513
- console.log("\u2705 \u5DF2\u505C\u7528\u6240\u6709 helper \u7CFB\u7EDF");
514
- } catch (error2) {
515
- console.warn("\u26A0\uFE0F \u505C\u7528 helper \u7CFB\u7EDF\u5931\u8D25:", error2);
516
- }
517
- try {
518
513
  const helperObjects = helperRef.current.objects;
519
514
  if (helperObjects && Array.isArray(helperObjects)) {
520
- console.log(`\u{1F9F9} \u6E05\u9664 helper \u4E2D\u7684 ${helperObjects.length} \u4E2A\u5BF9\u8C61\uFF08\u5305\u62EC\u7269\u7406\u7CFB\u7EDF\uFF09`);
521
515
  helperObjects.forEach((obj) => {
522
516
  if (obj.physics) {
523
- console.log("\u{1F527} \u6E05\u7406\u7269\u7406\u7CFB\u7EDF:", obj.mesh?.name || "unnamed");
524
517
  try {
525
- if (obj.physics.reset) {
526
- obj.physics.reset();
518
+ const physics = obj.physics;
519
+ if (physics.bodies && Array.isArray(physics.bodies)) {
520
+ physics.bodies.forEach((body) => {
521
+ if (physics.world && body) {
522
+ physics.world.removeRigidBody(body);
523
+ }
524
+ });
525
+ physics.bodies.length = 0;
527
526
  }
528
- if (obj.physics.world) {
529
- const world = obj.physics.world;
527
+ if (physics.constraints && Array.isArray(physics.constraints)) {
528
+ physics.constraints.forEach((constraint) => {
529
+ if (physics.world && constraint) {
530
+ physics.world.removeConstraint(constraint);
531
+ }
532
+ });
533
+ physics.constraints.length = 0;
534
+ }
535
+ if (physics.world) {
536
+ const world = physics.world;
530
537
  while (world.getNumCollisionObjects() > 0) {
531
538
  const body = world.getCollisionObjectArray().at(0);
532
539
  world.removeCollisionObject(body);
533
540
  }
534
541
  }
542
+ if (physics.reset) physics.reset();
535
543
  obj.physics = null;
536
- } catch (physicsError) {
537
- console.warn("\u26A0\uFE0F \u6E05\u7406\u7269\u7406\u7CFB\u7EDF\u5931\u8D25:", physicsError);
544
+ } catch (e) {
545
+ console.warn("\u6E05\u7406\u7269\u7406\u7CFB\u7EDF\u5931\u8D25:", e);
538
546
  }
539
547
  }
540
548
  });
541
549
  helperObjects.length = 0;
542
550
  }
543
551
  } catch (error2) {
544
- console.warn("\u26A0\uFE0F \u65E0\u6CD5\u8BBF\u95EE helper.objects:", error2);
552
+ console.warn("\u6E05\u7406 helper \u5931\u8D25:", error2);
545
553
  }
546
554
  helperRef.current = null;
547
- console.log("\u2705 MMDAnimationHelper \u6E05\u7406\u5B8C\u6210");
548
555
  }
549
556
  if (sceneRef.current.background && sceneRef.current.background.isTexture) {
550
- console.log("\u{1F9F9} \u6E05\u9664\u573A\u666F\u80CC\u666F\u8D34\u56FE");
551
557
  sceneRef.current.background.dispose();
552
558
  sceneRef.current.background = null;
553
559
  }
554
560
  if (sceneRef.current.environment && sceneRef.current.environment.isTexture) {
555
- console.log("\u{1F9F9} \u6E05\u9664\u573A\u666F\u73AF\u5883\u8D34\u56FE");
556
561
  sceneRef.current.environment.dispose();
557
562
  sceneRef.current.environment = null;
558
563
  }
@@ -566,26 +571,28 @@ var MMDPlayerEnhanced = ({
566
571
  }
567
572
  });
568
573
  objectsToRemove.forEach((obj) => {
569
- if (obj.parent) {
570
- obj.parent.remove(obj);
571
- }
574
+ if (obj.parent) obj.parent.remove(obj);
572
575
  if (obj.geometry) {
573
576
  obj.geometry.dispose();
574
577
  }
575
578
  if (obj.material) {
576
- const material = obj.material;
577
579
  const disposeMaterial = (m) => {
578
- if (m.map) m.map.dispose();
579
- if (m.emissiveMap) m.emissiveMap.dispose();
580
- if (m.normalMap) m.normalMap.dispose();
581
- if (m.bumpMap) m.bumpMap.dispose();
582
- if (m.specularMap) m.specularMap.dispose();
583
- if (m.envMap) m.envMap.dispose();
584
- if (m.lightMap) m.lightMap.dispose();
585
- if (m.aoMap) m.aoMap.dispose();
586
- if (m.alphaMap) m.alphaMap.dispose();
580
+ [
581
+ "map",
582
+ "emissiveMap",
583
+ "normalMap",
584
+ "bumpMap",
585
+ "specularMap",
586
+ "envMap",
587
+ "lightMap",
588
+ "aoMap",
589
+ "alphaMap"
590
+ ].forEach((prop) => {
591
+ if (m[prop]) m[prop].dispose();
592
+ });
587
593
  m.dispose();
588
594
  };
595
+ const material = obj.material;
589
596
  if (Array.isArray(material)) {
590
597
  material.forEach(disposeMaterial);
591
598
  } else {
@@ -593,29 +600,23 @@ var MMDPlayerEnhanced = ({
593
600
  }
594
601
  }
595
602
  if (obj.skeleton) {
596
- console.log("\u{1F9F9} \u6E05\u7406\u9AA8\u9ABC\u6570\u636E");
597
603
  obj.skeleton = null;
598
604
  }
599
605
  });
600
606
  clockRef.current = new THREE2.Clock();
601
607
  vmdDataRef.current = null;
602
608
  setNeedReset(false);
603
- console.log(`\u2705 [MMDPlayerEnhanced] \u5DF2\u6E05\u9664 ${objectsToRemove.length} \u4E2A\u5BF9\u8C61\uFF08\u589E\u5F3A\u6E05\u7406\u5B8C\u6210\uFF09`);
609
+ if (window.gc) {
610
+ try {
611
+ window.gc();
612
+ } catch (e) {
613
+ }
614
+ }
615
+ console.log(`\u2705 \u8D44\u6E90\u6E05\u7406\u5B8C\u6210 (${objectsToRemove.length} \u4E2A\u5BF9\u8C61)`);
604
616
  };
605
617
  useEffect(() => {
606
- console.log("\u{1F4E6} [MMDPlayerEnhanced] \u8D44\u6E90\u52A0\u8F7D useEffect \u89E6\u53D1");
607
- console.log("\u{1F50D} [MMDPlayerEnhanced] sceneRef.current:", sceneRef.current);
608
- console.log("\u{1F50D} [MMDPlayerEnhanced] cameraRef.current:", cameraRef.current);
609
- console.log("\u{1F50D} [MMDPlayerEnhanced] isLoadedRef.current:", isLoadedRef.current);
610
- if (!sceneRef.current || !cameraRef.current) {
611
- console.warn("\u26A0\uFE0F [MMDPlayerEnhanced] \u573A\u666F\u6216\u76F8\u673A\u672A\u521D\u59CB\u5316\uFF0C\u8DF3\u8FC7\u8D44\u6E90\u52A0\u8F7D");
612
- return;
613
- }
614
- if (isLoadedRef.current) {
615
- console.log("\u26A0\uFE0F [MMDPlayerEnhanced] \u8D44\u6E90\u5DF2\u52A0\u8F7D\uFF0C\u8DF3\u8FC7\u91CD\u590D\u52A0\u8F7D");
616
- return;
617
- }
618
- console.log("\u2705 [MMDPlayerEnhanced] \u573A\u666F\u548C\u76F8\u673A\u5DF2\u5C31\u7EEA\uFF0C\u5F00\u59CB\u52A0\u8F7D\u8D44\u6E90");
618
+ if (!sceneRef.current || !cameraRef.current) return;
619
+ if (isLoadedRef.current) return;
619
620
  clearOldResources();
620
621
  isLoadedRef.current = true;
621
622
  const loadMMD = async () => {
@@ -628,63 +629,39 @@ var MMDPlayerEnhanced = ({
628
629
  lastAnimationTimeRef.current = 0;
629
630
  animationStoppedCountRef.current = 0;
630
631
  if (stage?.enablePhysics !== false) {
631
- const ammoScriptPath = stage?.ammoPath || "/mikutalking/libs/ammo.wasm.js";
632
- const ammoWasmPath = stage?.ammoWasmPath || "/mikutalking/libs/";
633
- console.log("\u{1F527} [MMDPlayerEnhanced] \u68C0\u6D4B\u5230\u542F\u7528\u7269\u7406\uFF0C\u5F00\u59CB\u52A0\u8F7D Ammo.js");
634
- console.log("\u{1F4C2} [MMDPlayerEnhanced] Ammo \u811A\u672C\u8DEF\u5F84:", ammoScriptPath);
635
- console.log("\u{1F4C2} [MMDPlayerEnhanced] Ammo WASM \u8DEF\u5F84:", ammoWasmPath);
636
632
  setLoadingProgress(5);
637
633
  await loadAmmo({
638
- scriptPath: ammoScriptPath,
639
- wasmBasePath: ammoWasmPath
634
+ scriptPath: stage?.ammoPath || "/mikutalking/libs/ammo.wasm.js",
635
+ wasmBasePath: stage?.ammoWasmPath || "/mikutalking/libs/"
640
636
  });
641
- console.log("\u2705 [MMDPlayerEnhanced] Ammo.js \u52A0\u8F7D\u5B8C\u6210");
642
637
  }
643
638
  const manager = new THREE2.LoadingManager();
644
- const modelUrl = currentResources.modelPath;
645
- const basePath = modelUrl.substring(0, modelUrl.lastIndexOf("/") + 1);
646
- console.log("\u{1F4C2} [MMDPlayerEnhanced] \u6A21\u578B\u57FA\u7840\u8DEF\u5F84:", basePath);
639
+ const basePath = currentResources.modelPath.substring(0, currentResources.modelPath.lastIndexOf("/") + 1);
647
640
  manager.setURLModifier((url) => {
648
- if (url.startsWith("http://") || url.startsWith("https://")) {
649
- console.log("\u{1F517} [MMDPlayerEnhanced] \u4F7F\u7528\u5B8C\u6574 URL:", url);
650
- return url;
651
- }
652
- if (url.startsWith("/")) {
653
- console.log("\u{1F517} [MMDPlayerEnhanced] \u4F7F\u7528\u7EDD\u5BF9\u8DEF\u5F84:", url);
654
- return url;
655
- }
656
- const fullUrl = basePath + url;
657
- console.log("\u{1F517} [MMDPlayerEnhanced] \u76F8\u5BF9\u8DEF\u5F84\u8F6C\u6362:", url, "->", fullUrl);
658
- return fullUrl;
641
+ if (url.startsWith("http://") || url.startsWith("https://")) return url;
642
+ if (url.startsWith("/")) return url;
643
+ return basePath + url;
659
644
  });
660
645
  const loader = new MMDLoader(manager);
661
646
  const helper = new MMDAnimationHelper();
662
647
  helperRef.current = helper;
663
648
  setLoadingProgress(20);
664
649
  const modelStartTime = performance.now();
665
- console.log("\u{1F3AD} \u5F00\u59CB\u52A0\u8F7D\u6A21\u578B:", currentResources.modelPath);
666
- console.log("\u{1F4CA} [\u6027\u80FD] \u6A21\u578B\u52A0\u8F7D\u5F00\u59CB\u65F6\u95F4:", (/* @__PURE__ */ new Date()).toISOString());
667
650
  const mesh = await new Promise((resolve, reject) => {
668
651
  loader.load(
669
652
  currentResources.modelPath,
670
653
  (object) => {
671
- const modelEndTime = performance.now();
672
- const modelLoadTime = ((modelEndTime - modelStartTime) / 1e3).toFixed(2);
673
- console.log(`\u2705 \u6A21\u578B\u52A0\u8F7D\u6210\u529F (\u8017\u65F6: ${modelLoadTime}\u79D2)`);
674
- console.log(`\u{1F4CA} [\u6027\u80FD] \u6A21\u578B\u5927\u5C0F: ${object.geometry ? (object.geometry.attributes.position.count * 3 * 4 / 1024 / 1024).toFixed(2) : "N/A"} MB`);
654
+ const loadTime = ((performance.now() - modelStartTime) / 1e3).toFixed(2);
655
+ console.log(`\u2705 \u6A21\u578B\u52A0\u8F7D\u5B8C\u6210 (${loadTime}s)`);
675
656
  resolve(object);
676
657
  },
677
658
  (progress) => {
678
659
  if (progress.total > 0) {
679
- const percent = progress.loaded / progress.total * 30 + 20;
680
- setLoadingProgress(Math.min(percent, 50));
681
- console.log(`\u{1F4E5} \u6A21\u578B\u52A0\u8F7D\u8FDB\u5EA6: ${(progress.loaded / progress.total * 100).toFixed(1)}% (${(progress.loaded / 1024 / 1024).toFixed(2)}MB / ${(progress.total / 1024 / 1024).toFixed(2)}MB)`);
660
+ setLoadingProgress(Math.min(progress.loaded / progress.total * 30 + 20, 50));
682
661
  }
683
662
  },
684
663
  (error2) => {
685
- const modelEndTime = performance.now();
686
- const modelLoadTime = ((modelEndTime - modelStartTime) / 1e3).toFixed(2);
687
- console.error(`\u274C \u6A21\u578B\u52A0\u8F7D\u5931\u8D25 (\u8017\u65F6: ${modelLoadTime}\u79D2):`, error2);
664
+ console.error("\u274C \u6A21\u578B\u52A0\u8F7D\u5931\u8D25:", error2);
688
665
  reject(error2);
689
666
  }
690
667
  );
@@ -694,52 +671,21 @@ var MMDPlayerEnhanced = ({
694
671
  }
695
672
  sceneRef.current.add(mesh);
696
673
  if (currentResources.stageModelPath) {
697
- console.log("\u{1F3F0} \u5F00\u59CB\u52A0\u8F7D\u573A\u666F\u6A21\u578B:", currentResources.stageModelPath);
698
674
  const stageMesh = await new Promise((resolve, reject) => {
699
- loader.load(
700
- currentResources.stageModelPath,
701
- (object) => {
702
- console.log("\u2705 \u573A\u666F\u6A21\u578B\u52A0\u8F7D\u6210\u529F");
703
- resolve(object);
704
- },
705
- void 0,
706
- (error2) => {
707
- console.error("\u274C \u573A\u666F\u6A21\u578B\u52A0\u8F7D\u5931\u8D25:", error2);
708
- reject(error2);
709
- }
710
- );
675
+ loader.load(currentResources.stageModelPath, resolve, void 0, reject);
711
676
  });
712
677
  sceneRef.current.add(stageMesh);
713
678
  }
714
679
  if (currentResources.backgroundPath && sceneRef.current) {
715
- const bgStartTime = performance.now();
716
- console.log("\u{1F5BC}\uFE0F \u5F00\u59CB\u52A0\u8F7D\u80CC\u666F\u56FE\u7247:", currentResources.backgroundPath);
717
680
  const textureLoader = new THREE2.TextureLoader();
718
681
  const backgroundTexture = await new Promise((resolve, reject) => {
719
- textureLoader.load(
720
- currentResources.backgroundPath,
721
- (texture) => {
722
- const bgEndTime = performance.now();
723
- const bgLoadTime = ((bgEndTime - bgStartTime) / 1e3).toFixed(2);
724
- console.log(`\u2705 \u80CC\u666F\u56FE\u7247\u52A0\u8F7D\u6210\u529F (\u8017\u65F6: ${bgLoadTime}\u79D2, \u5C3A\u5BF8: ${texture.image.width}x${texture.image.height})`);
725
- resolve(texture);
726
- },
727
- void 0,
728
- (err) => {
729
- const bgEndTime = performance.now();
730
- const bgLoadTime = ((bgEndTime - bgStartTime) / 1e3).toFixed(2);
731
- console.error(`\u274C \u80CC\u666F\u56FE\u7247\u52A0\u8F7D\u5931\u8D25 (\u8017\u65F6: ${bgLoadTime}\u79D2):`, err);
732
- reject(err);
733
- }
734
- );
682
+ textureLoader.load(currentResources.backgroundPath, resolve, void 0, reject);
735
683
  });
736
684
  backgroundTexture.colorSpace = THREE2.SRGBColorSpace;
737
685
  if (stage?.backgroundType === "skybox") {
738
686
  backgroundTexture.mapping = THREE2.EquirectangularReflectionMapping;
739
687
  sceneRef.current.background = backgroundTexture;
740
688
  sceneRef.current.environment = backgroundTexture;
741
- } else if (stage?.backgroundType === "image") {
742
- sceneRef.current.background = backgroundTexture;
743
689
  } else {
744
690
  sceneRef.current.background = backgroundTexture;
745
691
  }
@@ -748,31 +694,17 @@ var MMDPlayerEnhanced = ({
748
694
  let cameraVmd = null;
749
695
  if (currentResources.motionPath) {
750
696
  setLoadingProgress(60);
751
- const motionStartTime = performance.now();
752
- console.log("\u{1F483} \u5F00\u59CB\u52A0\u8F7D\u52A8\u4F5C:", currentResources.motionPath);
753
697
  vmd = await new Promise((resolve, reject) => {
754
698
  loader.loadAnimation(
755
699
  currentResources.motionPath,
756
700
  mesh,
757
- (vmdObject) => {
758
- const motionEndTime = performance.now();
759
- const motionLoadTime = ((motionEndTime - motionStartTime) / 1e3).toFixed(2);
760
- console.log(`\u2705 \u52A8\u4F5C\u52A0\u8F7D\u6210\u529F (\u8017\u65F6: ${motionLoadTime}\u79D2)`);
761
- resolve(vmdObject);
762
- },
701
+ resolve,
763
702
  (progress) => {
764
703
  if (progress.total > 0) {
765
- const percent = progress.loaded / progress.total * 20 + 60;
766
- setLoadingProgress(Math.min(percent, 80));
767
- console.log(`\u{1F4E5} \u52A8\u4F5C\u52A0\u8F7D\u8FDB\u5EA6: ${(progress.loaded / progress.total * 100).toFixed(1)}%`);
704
+ setLoadingProgress(Math.min(progress.loaded / progress.total * 20 + 60, 80));
768
705
  }
769
706
  },
770
- (error2) => {
771
- const motionEndTime = performance.now();
772
- const motionLoadTime = ((motionEndTime - motionStartTime) / 1e3).toFixed(2);
773
- console.error(`\u274C \u52A8\u4F5C\u52A0\u8F7D\u5931\u8D25 (\u8017\u65F6: ${motionLoadTime}\u79D2):`, error2);
774
- reject(error2);
775
- }
707
+ reject
776
708
  );
777
709
  });
778
710
  helper.add(mesh, {
@@ -790,10 +722,6 @@ var MMDPlayerEnhanced = ({
790
722
  }
791
723
  if (maxDuration > 0) {
792
724
  animationDurationRef.current = maxDuration;
793
- console.log("\u23F1\uFE0F \u52A8\u753B\u65F6\u957F:", maxDuration, "\u79D2");
794
- } else {
795
- console.warn("\u26A0\uFE0F \u65E0\u6CD5\u83B7\u53D6\u52A8\u753B\u65F6\u957F\uFF0C\u5C06\u65E0\u6CD5\u81EA\u52A8\u68C0\u6D4B\u52A8\u753B\u7ED3\u675F");
796
- console.log("\u{1F4CB} VMD \u6570\u636E\u7ED3\u6784:", vmd);
797
725
  }
798
726
  }
799
727
  } else {
@@ -801,38 +729,18 @@ var MMDPlayerEnhanced = ({
801
729
  }
802
730
  if (currentResources.cameraPath && cameraRef.current) {
803
731
  setLoadingProgress(80);
804
- console.log("\u{1F4F7} \u5F00\u59CB\u52A0\u8F7D\u955C\u5934:", currentResources.cameraPath);
805
732
  cameraVmd = await new Promise((resolve, reject) => {
806
- loader.loadAnimation(
807
- currentResources.cameraPath,
808
- cameraRef.current,
809
- (vmdObject) => {
810
- console.log("\u2705 \u955C\u5934\u52A0\u8F7D\u6210\u529F");
811
- resolve(vmdObject);
812
- },
813
- void 0,
814
- (error2) => {
815
- console.error("\u274C \u955C\u5934\u52A0\u8F7D\u5931\u8D25:", error2);
816
- reject(error2);
817
- }
818
- );
733
+ loader.loadAnimation(currentResources.cameraPath, cameraRef.current, resolve, void 0, reject);
819
734
  });
820
735
  helper.add(cameraRef.current, { animation: cameraVmd });
821
736
  }
822
737
  if (currentResources.audioPath) {
823
738
  setLoadingProgress(90);
824
- const audioStartTime = performance.now();
825
- console.log("\u{1F3B5} \u5F00\u59CB\u52A0\u8F7D\u97F3\u9891:", currentResources.audioPath);
826
739
  const audio = new Audio(currentResources.audioPath);
827
740
  audio.volume = 0.5;
828
741
  audio.loop = loop;
829
742
  audioRef.current = audio;
830
743
  hasAudioRef.current = true;
831
- audio.onloadedmetadata = () => {
832
- const audioEndTime = performance.now();
833
- const audioLoadTime = ((audioEndTime - audioStartTime) / 1e3).toFixed(2);
834
- console.log(`\u2705 \u97F3\u9891\u52A0\u8F7D\u6210\u529F (\u8017\u65F6: ${audioLoadTime}\u79D2, \u65F6\u957F: ${audio.duration.toFixed(2)}\u79D2)`);
835
- };
836
744
  audio.onended = () => {
837
745
  if (!loop) {
838
746
  setIsPlaying(false);
@@ -850,12 +758,7 @@ var MMDPlayerEnhanced = ({
850
758
  }
851
759
  setLoadingProgress(100);
852
760
  setLoading(false);
853
- vmdDataRef.current = {
854
- mesh,
855
- vmd,
856
- cameraVmd
857
- };
858
- console.log("\u{1F389} \u6240\u6709\u8D44\u6E90\u52A0\u8F7D\u5B8C\u6210\uFF01");
761
+ vmdDataRef.current = { mesh, vmd, cameraVmd };
859
762
  if (shouldAutoPlayAfterReloadRef.current) {
860
763
  shouldAutoPlayAfterReloadRef.current = false;
861
764
  setTimeout(() => play(), 500);
@@ -874,64 +777,49 @@ var MMDPlayerEnhanced = ({
874
777
  loadMMD();
875
778
  }, [currentResources, stage?.enablePhysics, autoPlay, loop, onLoad, onError, reloadTrigger]);
876
779
  const play = () => {
877
- console.log("\u{1F3AC} [play] \u51FD\u6570\u88AB\u8C03\u7528\uFF0CneedReset =", needReset);
878
780
  if (!helperRef.current && !needReset) return;
879
781
  if (needReset && vmdDataRef.current && sceneRef.current && cameraRef.current) {
880
- console.log("\u{1F504} \u68C0\u6D4B\u5230\u9700\u8981\u91CD\u7F6E\uFF0C\u91CD\u65B0\u521D\u59CB\u5316 helper\uFF08\u4FDD\u7559\u6A21\u578B\uFF09");
881
782
  const { mesh, vmd, cameraVmd } = vmdDataRef.current;
882
783
  if (helperRef.current) {
883
784
  try {
884
785
  const helperObjects = helperRef.current.objects;
885
786
  if (helperObjects && Array.isArray(helperObjects)) {
886
787
  helperObjects.length = 0;
887
- console.log("\u{1F9F9} \u6E05\u7A7A\u4E86\u65E7 helper \u7684 objects \u6570\u7EC4");
888
788
  }
889
789
  } catch (error2) {
890
- console.warn("\u26A0\uFE0F \u65E0\u6CD5\u6E05\u7A7A\u65E7 helper.objects:", error2);
891
790
  }
892
791
  }
893
792
  const newHelper = new MMDAnimationHelper();
894
793
  helperRef.current = newHelper;
895
794
  clockRef.current = new THREE2.Clock();
896
795
  if (vmd && typeof vmd === "object") {
897
- console.log("\u{1F4E6} \u91CD\u65B0\u6DFB\u52A0\u6A21\u578B\u52A8\u753B");
898
796
  try {
899
797
  newHelper.add(mesh, {
900
798
  animation: vmd,
901
799
  physics: stage?.enablePhysics !== false
902
800
  });
903
- console.log("\u2705 \u6A21\u578B\u52A8\u753B\u6DFB\u52A0\u6210\u529F");
904
801
  } catch (error2) {
905
- console.error("\u274C \u91CD\u65B0\u6DFB\u52A0\u6A21\u578B\u52A8\u753B\u5931\u8D25:", error2);
906
802
  try {
907
803
  newHelper.add(mesh, { physics: stage?.enablePhysics !== false });
908
- console.log("\u2705 \u4EC5\u6DFB\u52A0\u6A21\u578B\u548C\u7269\u7406\uFF08\u65E0\u52A8\u753B\uFF09");
909
804
  } catch (innerError) {
910
- console.error("\u274C \u6DFB\u52A0\u6A21\u578B\u4E5F\u5931\u8D25\u4E86:", innerError);
911
805
  }
912
806
  }
913
807
  } else {
914
808
  try {
915
809
  newHelper.add(mesh, { physics: stage?.enablePhysics !== false });
916
- console.log("\u2705 \u4EC5\u6DFB\u52A0\u6A21\u578B\u548C\u7269\u7406\uFF08\u65E0\u52A8\u753B\u6570\u636E\uFF09");
917
810
  } catch (error2) {
918
- console.error("\u274C \u6DFB\u52A0\u6A21\u578B\u5931\u8D25:", error2);
919
811
  }
920
812
  }
921
813
  if (cameraVmd && typeof cameraVmd === "object") {
922
- console.log("\u{1F4F7} \u91CD\u65B0\u6DFB\u52A0\u76F8\u673A\u52A8\u753B");
923
814
  try {
924
815
  newHelper.add(cameraRef.current, { animation: cameraVmd });
925
- console.log("\u2705 \u76F8\u673A\u52A8\u753B\u6DFB\u52A0\u6210\u529F");
926
816
  } catch (error2) {
927
- console.error("\u274C \u91CD\u65B0\u6DFB\u52A0\u76F8\u673A\u52A8\u753B\u5931\u8D25:", error2);
928
817
  }
929
818
  }
930
819
  if (audioRef.current) {
931
820
  audioRef.current.currentTime = 0;
932
821
  }
933
822
  setNeedReset(false);
934
- console.log("\u2705 Helper \u91CD\u65B0\u521D\u59CB\u5316\u5B8C\u6210\uFF0C\u51C6\u5907\u4ECE\u7B2C\u4E00\u5E27\u64AD\u653E");
935
823
  }
936
824
  if (!helperRef.current) {
937
825
  console.error("\u274C [play] helper \u4E0D\u5B58\u5728\uFF0C\u65E0\u6CD5\u64AD\u653E");