sa2kit 1.0.2 → 1.0.4

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.
@@ -571,7 +571,24 @@ var MMDPlayerEnhanced = ({
571
571
  });
572
572
  console.log("\u2705 [MMDPlayerEnhanced] Ammo.js \u52A0\u8F7D\u5B8C\u6210");
573
573
  }
574
- const loader = new MMDLoader();
574
+ const manager = new THREE2.LoadingManager();
575
+ const modelUrl = currentResources.modelPath;
576
+ const basePath = modelUrl.substring(0, modelUrl.lastIndexOf("/") + 1);
577
+ console.log("\u{1F4C2} [MMDPlayerEnhanced] \u6A21\u578B\u57FA\u7840\u8DEF\u5F84:", basePath);
578
+ manager.setURLModifier((url) => {
579
+ if (url.startsWith("http://") || url.startsWith("https://")) {
580
+ console.log("\u{1F517} [MMDPlayerEnhanced] \u4F7F\u7528\u5B8C\u6574 URL:", url);
581
+ return url;
582
+ }
583
+ if (url.startsWith("/")) {
584
+ console.log("\u{1F517} [MMDPlayerEnhanced] \u4F7F\u7528\u7EDD\u5BF9\u8DEF\u5F84:", url);
585
+ return url;
586
+ }
587
+ const fullUrl = basePath + url;
588
+ console.log("\u{1F517} [MMDPlayerEnhanced] \u76F8\u5BF9\u8DEF\u5F84\u8F6C\u6362:", url, "->", fullUrl);
589
+ return fullUrl;
590
+ });
591
+ const loader = new MMDLoader(manager);
575
592
  const helper = new MMDAnimationHelper();
576
593
  helperRef.current = helper;
577
594
  setLoadingProgress(20);
@@ -1164,8 +1181,35 @@ var MMDPlaylist = ({
1164
1181
  return /* @__PURE__ */ React2.createElement("div", { className: "flex h-full w-full items-center justify-center bg-black text-white" }, /* @__PURE__ */ React2.createElement("p", null, "\u64AD\u653E\u5217\u8868\u8282\u70B9\u7D22\u5F15\u65E0\u6548"));
1165
1182
  }
1166
1183
  console.log("\u{1F3AF} [MMDPlaylist] \u5F53\u524D\u8282\u70B9:", currentNode.name, "\u7D22\u5F15:", currentNodeIndex);
1184
+ const stopNode = (nodeIndex) => {
1185
+ const playerElement = playerRefsMap.current.get(nodeIndex);
1186
+ if (!playerElement) return;
1187
+ console.log(`\u23F9\uFE0F [MMDPlaylist] \u505C\u6B62\u8282\u70B9 ${nodeIndex}`);
1188
+ const audioElement = playerElement.querySelector("audio");
1189
+ if (audioElement) {
1190
+ audioElement.pause();
1191
+ audioElement.currentTime = 0;
1192
+ console.log(` \u{1F507} \u505C\u6B62\u97F3\u9891`);
1193
+ }
1194
+ const stopButton = playerElement.querySelector('button[title="\u505C\u6B62"]');
1195
+ if (stopButton) {
1196
+ stopButton.click();
1197
+ console.log(` \u23F9\uFE0F \u70B9\u51FB\u505C\u6B62\u6309\u94AE`);
1198
+ } else {
1199
+ const pauseButton = playerElement.querySelector('button[title="\u6682\u505C"]');
1200
+ if (pauseButton) {
1201
+ pauseButton.click();
1202
+ console.log(` \u23F8\uFE0F \u70B9\u51FB\u6682\u505C\u6309\u94AE`);
1203
+ }
1204
+ }
1205
+ };
1167
1206
  useEffect(() => {
1168
1207
  console.log(`\u{1F504} [MMDPlaylist] \u8282\u70B9\u5207\u6362: ${currentNodeIndex} - ${currentNode.name}`);
1208
+ editableNodes.forEach((_, index) => {
1209
+ if (index !== currentNodeIndex) {
1210
+ stopNode(index);
1211
+ }
1212
+ });
1169
1213
  onNodeChange?.(currentNodeIndex, currentNode);
1170
1214
  if (!isPreloading && (isAutoSwitchRef.current || playlist.autoPlay)) {
1171
1215
  console.log(`\u25B6\uFE0F [MMDPlaylist] \u51C6\u5907\u64AD\u653E\u8282\u70B9 ${currentNodeIndex}`);
@@ -1188,7 +1232,7 @@ var MMDPlaylist = ({
1188
1232
  }
1189
1233
  });
1190
1234
  }
1191
- }, [currentNodeIndex, currentNode, onNodeChange, isPreloading, playlist.autoPlay, preloadedNodes]);
1235
+ }, [currentNodeIndex, currentNode, onNodeChange, isPreloading, playlist.autoPlay, preloadedNodes, editableNodes]);
1192
1236
  const handleNodePreloaded = (nodeIndex) => {
1193
1237
  console.log(`\u2705 [MMDPlaylist] \u8282\u70B9 ${nodeIndex} \u9884\u52A0\u8F7D\u5B8C\u6210`);
1194
1238
  setPreloadedNodes((prev) => {