@gamelearn/arcade-components 2.12.13 → 2.13.1

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.
@@ -69,7 +69,11 @@ function Panel(_ref) {
69
69
  var defaultClip = (0, _react.useRef)();
70
70
  var emotion = (0, _react.useMemo)(function () {
71
71
  if (isCharacter) {
72
- var _character$resource, _character$resource$a, _character$resource$a2, _character$resource3, _character$resource3$;
72
+ var _character$animation, _character$resource, _character$resource$a, _character$resource$a2, _character$resource3, _character$resource3$;
73
+
74
+ if (character.animationId && (_character$animation = character.animation) !== null && _character$animation !== void 0 && _character$animation.url) {
75
+ return character.animation;
76
+ }
73
77
 
74
78
  if (character !== null && character !== void 0 && (_character$resource = character.resource) !== null && _character$resource !== void 0 && (_character$resource$a = _character$resource.animations) !== null && _character$resource$a !== void 0 && (_character$resource$a2 = _character$resource$a[character.emotion]) !== null && _character$resource$a2 !== void 0 && _character$resource$a2.url) {
75
79
  var _character$resource2, _character$resource2$;
@@ -81,7 +85,7 @@ function Panel(_ref) {
81
85
  }
82
86
 
83
87
  return {};
84
- }, [character.emotion, character === null || character === void 0 ? void 0 : (_character$resource4 = character.resource) === null || _character$resource4 === void 0 ? void 0 : _character$resource4.animations, isCharacter]);
88
+ }, [character.emotion, character === null || character === void 0 ? void 0 : character.animationId, character === null || character === void 0 ? void 0 : character.animation, character === null || character === void 0 ? void 0 : (_character$resource4 = character.resource) === null || _character$resource4 === void 0 ? void 0 : _character$resource4.animations, isCharacter]);
85
89
  var resetAnimation = (0, _react.useCallback)(function () {
86
90
  var _model$current$userDa = model.current.userData,
87
91
  mixer = _model$current$userDa.mixer,
@@ -121,9 +125,9 @@ function Panel(_ref) {
121
125
  cameraRef.current.rotation.set(0, 0, 0);
122
126
  cameraRef.current.updateProjectionMatrix();
123
127
  cameraRef.current.layers.enableAll();
128
+ var defaultAnim = object.userData.defaultAnim;
124
129
 
125
- if (character.type === 'character') {
126
- var defaultAnim = object.userData.defaultAnim;
130
+ if (character.type === 'character' && defaultAnim) {
127
131
  model.current = object;
128
132
  defaultClip.current = defaultAnim.clone();
129
133
  cameraRef.current.position.setY(size.y - 1.5 * 1.3); // Retro compatible with resources without eye bone
@@ -135,7 +139,7 @@ function Panel(_ref) {
135
139
  }
136
140
  });
137
141
  cameraRef.current.zoom = 1.85;
138
- } else if (character.type === 'object') {
142
+ } else if (character.type === 'object' || !defaultAnim) {
139
143
  (0, _helpers.cameraFitAnyObject)(object, cameraRef.current);
140
144
  cameraRef.current.zoom = 1;
141
145
  }
@@ -248,10 +248,19 @@ var DialogComponent = function DialogComponent(_ref) {
248
248
  return (slot === null || slot === void 0 ? void 0 : (_slot$character = slot.character) === null || _slot$character === void 0 ? void 0 : (_slot$character$resou = _slot$character.resource) === null || _slot$character$resou === void 0 ? void 0 : _slot$character$resou.url) || (object === null || object === void 0 ? void 0 : object.completeUrl) || '';
249
249
  }, [actors]);
250
250
  var loadEmotion = (0, _react.useCallback)(function (slot, element) {
251
- var _slot$character2;
251
+ var _slot$animation;
252
252
 
253
253
  var onLoadAnim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
254
- var animation = (_slot$character2 = slot.character) === null || _slot$character2 === void 0 ? void 0 : _slot$character2.resource.animations[element.isSeated ? "".concat(slot.emotion, "-seated") : slot.emotion];
254
+ var animation;
255
+
256
+ if (slot !== null && slot !== void 0 && slot.animationId && slot !== null && slot !== void 0 && (_slot$animation = slot.animation) !== null && _slot$animation !== void 0 && _slot$animation.url) {
257
+ animation = slot.animation;
258
+ } else {
259
+ var _slot$character2;
260
+
261
+ animation = (_slot$character2 = slot.character) === null || _slot$character2 === void 0 ? void 0 : _slot$character2.resource.animations[element.isSeated ? "".concat(slot.emotion, "-seated") : slot.emotion];
262
+ }
263
+
255
264
  var mixer = element.userData.mixer;
256
265
 
257
266
  if (animation && animation.url) {
@@ -304,6 +313,10 @@ var DialogComponent = function DialogComponent(_ref) {
304
313
  return;
305
314
  }
306
315
 
316
+ if (!element.isTalking) {
317
+ return;
318
+ }
319
+
307
320
  var _element$userData = element.userData,
308
321
  mixer = _element$userData.mixer,
309
322
  defaultAnim = _element$userData.defaultAnim,
@@ -314,6 +327,7 @@ var DialogComponent = function DialogComponent(_ref) {
314
327
  var defaultAction = mixer.clipAction(defaultAnim, element);
315
328
  mixer.stopAllAction();
316
329
  (0, _helpers.executeCrossFade)(emotionAction, defaultAction, crossFadeDuration);
330
+ element.isTalking = false;
317
331
  }
318
332
 
319
333
  startTalking(false);
@@ -232,6 +232,7 @@ var executeTalkingAnimation = function executeTalkingAnimation(target, talkingUR
232
232
  var emotionAction = mixer.clipAction(talkingSubClip, target);
233
233
  emotionAction.loop = _three.LoopPingPong;
234
234
  mixer.stopAllAction();
235
+ target.isTalking = true;
235
236
  executeCrossFade(defaultAction, emotionAction, crossFadeDuration);
236
237
  }
237
238
  };
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.13",
5
+ "version": "2.13.1",
6
6
  "main": "dist/index.js",
7
7
  "files": [
8
8
  "dist",