@gamelearn/arcade-components 2.12.4 → 2.12.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.
@@ -296,7 +296,7 @@ var DialogComponent = function DialogComponent(_ref) {
296
296
  if (zoomInActor) setAnimationRunning(true);
297
297
  }, [zoomInActor]);
298
298
 
299
- var restTalkingAnimation = function restTalkingAnimation() {
299
+ var resetTalkingAnimation = function resetTalkingAnimation() {
300
300
  var element = getCurrentVisible(talkingCharacter === null || talkingCharacter === void 0 ? void 0 : talkingCharacter.uid);
301
301
 
302
302
  if (!element) {
@@ -323,16 +323,16 @@ var DialogComponent = function DialogComponent(_ref) {
323
323
  (0, _react.useEffect)(function () {
324
324
  var element = getCurrentVisible(talkingCharacter === null || talkingCharacter === void 0 ? void 0 : talkingCharacter.uid);
325
325
 
326
- if (element) {
326
+ if (element && currentMessage.show) {
327
327
  if (talking) {
328
328
  var _talkingCharacter$cha, _talkingCharacter$cha2, _talkingCharacter$cha3, _talkingCharacter$cha4;
329
329
 
330
330
  (0, _helpers.executeTalkingAnimation)(element, talkingCharacter === null || talkingCharacter === void 0 ? void 0 : (_talkingCharacter$cha = talkingCharacter.character) === null || _talkingCharacter$cha === void 0 ? void 0 : (_talkingCharacter$cha2 = _talkingCharacter$cha.resource) === null || _talkingCharacter$cha2 === void 0 ? void 0 : (_talkingCharacter$cha3 = _talkingCharacter$cha2.animations) === null || _talkingCharacter$cha3 === void 0 ? void 0 : (_talkingCharacter$cha4 = _talkingCharacter$cha3.talking) === null || _talkingCharacter$cha4 === void 0 ? void 0 : _talkingCharacter$cha4.url);
331
331
  } else {
332
- restTalkingAnimation();
332
+ resetTalkingAnimation();
333
333
  }
334
334
  }
335
- }, [talkingCharacter, talking]);
335
+ }, [talkingCharacter, talking, currentMessage.show]);
336
336
  var finishConversation = (0, _react.useCallback)(function () {
337
337
  lastSet.current = true;
338
338
  changeLine(0);
@@ -404,7 +404,7 @@ var DialogComponent = function DialogComponent(_ref) {
404
404
  }
405
405
  }, [currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.id, edges, finishConversation, lines]);
406
406
  var backLine = (0, _react.useCallback)(function () {
407
- restTalkingAnimation();
407
+ resetTalkingAnimation();
408
408
  setAudioFailed(false);
409
409
 
410
410
  if (isBranched) {
@@ -417,7 +417,7 @@ var DialogComponent = function DialogComponent(_ref) {
417
417
  }
418
418
  }, [handleBranchDirection, isBranched, lastLine, line]);
419
419
  var nextLine = (0, _react.useCallback)(function (choice, reset) {
420
- restTalkingAnimation();
420
+ resetTalkingAnimation();
421
421
  setEdgesHistory([].concat(_toConsumableArray(edgesHistory), [currentLineData.id]));
422
422
  setAudioFailed(false);
423
423
 
@@ -202,30 +202,38 @@ var executeTalkingAnimation = function executeTalkingAnimation(target, talkingUR
202
202
  var cloned = defaultAnim.clone();
203
203
 
204
204
  var onLoad = function onLoad(anim) {
205
- var _cloned$tracks;
205
+ var talkingClip = anim === null || anim === void 0 ? void 0 : anim.animations[0];
206
206
 
207
- if (anim) {
208
- tracks.push.apply(tracks, _toConsumableArray(anim.animations[0].tracks.filter(function (track) {
207
+ if (talkingClip) {
208
+ var _cloned$tracks;
209
+
210
+ tracks = talkingClip.tracks.filter(function (track) {
209
211
  return bones.find(function (bone) {
210
212
  return track.name.includes(bone);
211
213
  });
212
- })));
213
- }
214
-
215
- cloned.tracks = cloned.tracks.filter(function (track) {
216
- return !bones.find(function (bone) {
217
- return track.name.includes(bone);
218
214
  });
219
- });
215
+ cloned.tracks = cloned.tracks.filter(function (track) {
216
+ return !bones.find(function (bone) {
217
+ return track.name.includes(bone);
218
+ });
219
+ });
220
+
221
+ (_cloned$tracks = cloned.tracks).push.apply(_cloned$tracks, _toConsumableArray(tracks));
220
222
 
221
- (_cloned$tracks = cloned.tracks).push.apply(_cloned$tracks, tracks);
223
+ target.userData.emotionClip = cloned;
224
+ cloned.resetDuration();
225
+ var talkingSubClip = cloned;
222
226
 
223
- target.userData.emotionClip = cloned;
224
- var defaultAction = mixer.clipAction(defaultAnim, target);
225
- var emotionAction = mixer.clipAction(cloned, target);
226
- emotionAction.loop = _three.LoopPingPong;
227
- mixer.stopAllAction();
228
- executeCrossFade(defaultAction, emotionAction, crossFadeDuration);
227
+ if (cloned.duration > 4) {
228
+ talkingSubClip = _three.AnimationUtils.subclip(cloned, 'shortTalking', 0, 120, 30);
229
+ }
230
+
231
+ var defaultAction = mixer.clipAction(defaultAnim, target);
232
+ var emotionAction = mixer.clipAction(talkingSubClip, target);
233
+ emotionAction.loop = _three.LoopPingPong;
234
+ mixer.stopAllAction();
235
+ executeCrossFade(defaultAction, emotionAction, crossFadeDuration);
236
+ }
229
237
  };
230
238
 
231
239
  loader.load(talkingURL, function (anim) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@gamelearn/arcade-components",
3
3
  "author": "Gamelearn",
4
4
  "license": "unlicense",
5
- "version": "2.12.4",
5
+ "version": "2.12.7",
6
6
  "main": "dist/index.js",
7
7
  "files": [
8
8
  "dist",