@gamelearn/arcade-components 1.23.1 → 1.24.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.
@@ -71,7 +71,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
71
71
  var isMobile = (0, _deviceDetection.DeviceDetection)();
72
72
  var crossFadeDuration = 0.5;
73
73
  var characterMs = 75;
74
- var minMs = 1400; // Mobile always zoom in?
74
+ var minMs = 1400;
75
+ var headSize = 2; // Mobile always zoom in?
75
76
 
76
77
  var raycast = new _three.Raycaster();
77
78
  var maxCharacterToSwitch = 70;
@@ -236,26 +237,14 @@ var DialogComponent = function DialogComponent(_ref) {
236
237
  } else {
237
238
  onLoadAnim();
238
239
  }
239
- }, [loader]);
240
+ }, [loader]); // Force default animation without transition
240
241
 
241
242
  var executeDefaultAnimation = function executeDefaultAnimation(element) {
242
- if (element.userData.mixer && element.userData.currentEmotion) {
243
+ if (element.userData.mixer && element.userData.defaultAnim) {
243
244
  var mixer = element.userData.mixer;
244
- var startAction = mixer.clipAction(element.userData.currentEmotion.getClip(), element);
245
245
  var defaultAction = mixer.clipAction(element.userData.defaultAnim, element);
246
-
247
- if (element.userData.currentEmotion !== defaultAction) {
248
- setTimeout(function () {
249
- mixer.stopAllAction();
250
- (0, _helpers.executeCrossFade)(startAction, defaultAction, crossFadeDuration / Math.floor(Math.random() * 3));
251
-
252
- if (element.userData.currentEmotion) {
253
- element.userData.lastEmotion = element.userData.currentEmotion;
254
- }
255
-
256
- element.userData.currentEmotion = defaultAction;
257
- }, Math.floor(Math.random() * 3) * 500);
258
- }
246
+ mixer.stopAllAction();
247
+ defaultAction.play();
259
248
  }
260
249
  }; // Reset currentEmotion to defaultAnim
261
250
 
@@ -271,18 +260,16 @@ var DialogComponent = function DialogComponent(_ref) {
271
260
  if (zoomInActor) setAnimationRunning(true);
272
261
  }, [zoomInActor]);
273
262
  var finishConversation = (0, _react.useCallback)(function () {
274
- resetAnims();
275
263
  lastSet.current = true;
264
+ changeLine(0);
276
265
  setCurrentMessage({
277
266
  show: false
278
267
  });
279
268
  resetCameraView();
280
- setTimeout(function () {
281
- changeLine(0);
282
- emitEvent({
283
- type: 'success'
284
- });
285
- camera.copy(defaultCamera);
269
+ camera.copy(defaultCamera);
270
+ resetAnims();
271
+ emitEvent({
272
+ type: 'success'
286
273
  });
287
274
  }, [camera, emitEvent, resetAnims, resetCameraView]);
288
275
  var handleBranchDirection = (0, _react.useCallback)(function () {
@@ -438,15 +425,9 @@ var DialogComponent = function DialogComponent(_ref) {
438
425
  var element = getCurrentVisible(slot.uid);
439
426
 
440
427
  if (element) {
441
- loadEmotion(slot, element, function (mixer, action, defaultAction) {
442
- setTimeout(function () {
443
- var startAction = element.userData.lastEmotion ? element.userData.lastEmotion : defaultAction;
444
-
445
- if (startAction && action && startAction !== action) {
446
- mixer.stopAllAction();
447
- (0, _helpers.executeCrossFade)(startAction, action, crossFadeDuration / Math.floor(Math.random() * 3));
448
- }
449
- }, Math.floor(Math.random() * 3) * 500);
428
+ loadEmotion(slot, element, function (_, action, defaultAction) {
429
+ var startAction = element.userData.lastEmotion ? element.userData.lastEmotion : defaultAction;
430
+ (0, _helpers.executeCrossFade)(startAction, action, crossFadeDuration);
450
431
  });
451
432
  }
452
433
  }); // Talking element logic
@@ -469,6 +450,8 @@ var DialogComponent = function DialogComponent(_ref) {
469
450
  setTimeout(function () {
470
451
  if (talkingCharacter.uid === element.uid) {
471
452
  var showArrowTop = talkingCharacter.text.length > maxCharacterToSwitch;
453
+ element.updateMatrix();
454
+ element.updateMatrixWorld();
472
455
  var head = element.getObjectByName('Head_M');
473
456
  var target = new _three.Object3D();
474
457
  head.updateMatrix();
@@ -482,6 +465,7 @@ var DialogComponent = function DialogComponent(_ref) {
482
465
  var vector = new _three.Vector3();
483
466
  vector.setFromMatrixPosition(head.matrixWorld);
484
467
  var p = vector.project(defaultCamera);
468
+ target.translateX(headSize);
485
469
  var isLeft = p.x < 0;
486
470
  messagePosition.current = {
487
471
  pos: target.position.toArray(),
@@ -577,7 +561,7 @@ var DialogComponent = function DialogComponent(_ref) {
577
561
  };
578
562
  }, [currentMessage, nextLine, start, stop, currentLine === null || currentLine === void 0 ? void 0 : currentLine.audioType, autoPlayCond, audio, voice, audioFailed]); // Positioning Bubble Message logic
579
563
 
580
- var checkBubblePosition = (0, _react.useCallback)(function () {
564
+ var checkBubbleBounds = (0, _react.useCallback)(function () {
581
565
  if (bubbleRef.current && currentLine !== null && currentLine !== void 0 && currentLine.slots) {
582
566
  var talkingCharacter = currentLine === null || currentLine === void 0 ? void 0 : currentLine.slots.find(function (slot) {
583
567
  return slot.talking;
@@ -623,8 +607,8 @@ var DialogComponent = function DialogComponent(_ref) {
623
607
  }
624
608
  }, [camera.quaternion, currentLine === null || currentLine === void 0 ? void 0 : currentLine.slots, currentMessage.inScene, getAvatarURL]);
625
609
  (0, _react.useEffect)(function () {
626
- checkBubblePosition();
627
- }, [checkBubblePosition]);
610
+ checkBubbleBounds();
611
+ }, [checkBubbleBounds]);
628
612
  (0, _react.useEffect)(function () {
629
613
  if (animationRunning) {
630
614
  var cam = camera;
@@ -637,10 +621,10 @@ var DialogComponent = function DialogComponent(_ref) {
637
621
  }
638
622
 
639
623
  var mult = messagePosition.current.isLeft ? -1 : 1;
640
- var headSpace = 2 * mult; // move bubble
624
+ var headSpace = headSize * mult; // move bubble
641
625
 
642
626
  messagePosition.current.pos[0] -= headSpace;
643
- animationTarget.current.translateX(-10 * mult - headSpace);
627
+ animationTarget.current.translateX(-10 + headSpace);
644
628
  animationTarget.current.translateY(-5);
645
629
  animationTarget.current.translateZ(30);
646
630
  }
@@ -684,7 +668,7 @@ var DialogComponent = function DialogComponent(_ref) {
684
668
  });
685
669
  }
686
670
 
687
- checkBubblePosition();
671
+ checkBubbleBounds();
688
672
  }
689
673
  });
690
674
  var cleanStyle = {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@gamelearn/arcade-components",
3
3
  "author": "Gamelearn",
4
4
  "license": "unlicense",
5
- "version": "1.23.1",
5
+ "version": "1.24.1",
6
6
  "main": "dist/index.js",
7
7
  "files": [
8
8
  "dist",
@@ -14,9 +14,9 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@gamelearn/arcade-styles": "0.11.10",
17
- "@gamelearn/arcade-three-core": "1.1.15",
18
- "@react-three/drei": "8.8.1",
19
- "@react-three/fiber": "7.0.25",
17
+ "@gamelearn/arcade-three-core": "1.10.4",
18
+ "@react-three/drei": "9.4.3",
19
+ "@react-three/fiber": "8.0.10",
20
20
  "@testing-library/jest-dom": "5.11.4",
21
21
  "@testing-library/react": "11.1.0",
22
22
  "@testing-library/user-event": "13.5.0",
@@ -32,7 +32,7 @@
32
32
  "react-pdf": "5.2.0",
33
33
  "react-promise-suspense": "0.3.3",
34
34
  "react-typist": "^2.0.5",
35
- "three": "0.136.0",
35
+ "three": "0.139.2",
36
36
  "web-vitals": "0.2.4"
37
37
  },
38
38
  "scripts": {
@@ -89,8 +89,8 @@
89
89
  "nodemon": "^2.0.13",
90
90
  "plop": "^2.7.4",
91
91
  "prettier": "^2.5.0",
92
- "react": "0.0.0-experimental-27659559e",
93
- "react-dom": "0.0.0-experimental-27659559e",
92
+ "react": "18.0.0",
93
+ "react-dom": "18.0.0",
94
94
  "react-scripts": "4.0.1",
95
95
  "rimraf": "3.0.2"
96
96
  },