@gamelearn/arcade-components 2.27.0 → 2.29.2

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.
Files changed (206) hide show
  1. package/dist/components/animation-component/components/AnimationComponent.js +10 -28
  2. package/dist/components/animation-component/index.js +0 -3
  3. package/dist/components/animation-component/mocks/mockForStory.js +0 -3
  4. package/dist/components/auto-evaluation-component/components/AutoEvaluation.js +30 -71
  5. package/dist/components/auto-evaluation-component/components/EndScreen.js +1 -9
  6. package/dist/components/auto-evaluation-component/components/StartScreen.js +2 -6
  7. package/dist/components/auto-evaluation-component/index.js +0 -3
  8. package/dist/components/auto-evaluation-component/mocks/mockForStory.js +0 -2
  9. package/dist/components/cards-selector-puzzle-component/components/Board/index.js +23 -55
  10. package/dist/components/cards-selector-puzzle-component/components/Card/index.js +4 -23
  11. package/dist/components/cards-selector-puzzle-component/components/CardsSelectorPuzzleComponent.js +41 -92
  12. package/dist/components/cards-selector-puzzle-component/index.js +0 -3
  13. package/dist/components/cards-selector-puzzle-component/mocks/mockForStory.js +4 -10
  14. package/dist/components/cartel-component/components/CartelComponent.js +16 -42
  15. package/dist/components/cartel-component/index.js +0 -3
  16. package/dist/components/chained-image-click-puzzle-component/components/ChainedImageClickPuzzleComponent.js +20 -38
  17. package/dist/components/chained-image-click-puzzle-component/components/CurrentImagePuzzle.js +25 -64
  18. package/dist/components/chained-image-click-puzzle-component/index.js +0 -3
  19. package/dist/components/chained-image-click-puzzle-component/mocks/mockForStory.js +1 -2
  20. package/dist/components/comic-component/components/ComicComponent.js +37 -81
  21. package/dist/components/comic-component/components/Slide.js +2 -7
  22. package/dist/components/comic-component/components/Vignette.js +7 -23
  23. package/dist/components/comic-component/index.js +0 -3
  24. package/dist/components/comic-component/mocks/mockForStory.js +1 -2
  25. package/dist/components/conversational-component/components/ConversationalComponent.js +15 -39
  26. package/dist/components/conversational-component/index.js +0 -3
  27. package/dist/components/conversational-pro-component/components/ConversationalProComponent.js +54 -137
  28. package/dist/components/conversational-pro-component/components/Message.js +1 -9
  29. package/dist/components/conversational-pro-component/components/Slot.js +3 -20
  30. package/dist/components/conversational-pro-component/components/SlotList.js +16 -40
  31. package/dist/components/conversational-pro-component/components/scene/Panel.js +12 -54
  32. package/dist/components/conversational-pro-component/components/scene/Panels.js +10 -17
  33. package/dist/components/conversational-pro-component/components/scene/index.js +11 -30
  34. package/dist/components/conversational-pro-component/index.js +0 -3
  35. package/dist/components/conversational-pro-component/mocks/mockForStory.js +1 -2
  36. package/dist/components/cracker-puzzle-component/components/CrackerPuzzleComponent.js +35 -89
  37. package/dist/components/cracker-puzzle-component/components/DrawGrid/index.js +3 -7
  38. package/dist/components/cracker-puzzle-component/components/DrawItem/index.js +4 -9
  39. package/dist/components/cracker-puzzle-component/components/DrawRow/index.js +4 -9
  40. package/dist/components/cracker-puzzle-component/components/helpers.js +15 -55
  41. package/dist/components/cracker-puzzle-component/index.js +0 -3
  42. package/dist/components/cracker-puzzle-component/mocks/mockForStory.js +0 -2
  43. package/dist/components/decision-component/components/DecisionBody.js +26 -48
  44. package/dist/components/decision-component/components/DecisionComponent.js +22 -70
  45. package/dist/components/decision-component/components/Feedback.js +2 -11
  46. package/dist/components/decision-component/components/Options.js +12 -31
  47. package/dist/components/decision-component/index.js +0 -3
  48. package/dist/components/decision-component/mocks/mockForStory.js +0 -2
  49. package/dist/components/dialog-component/components/BubbleWrapper.js +1 -7
  50. package/dist/components/dialog-component/components/DialogComponent.js +118 -338
  51. package/dist/components/dialog-component/components/DialogDecision.js +3 -13
  52. package/dist/components/dialog-component/components/SpeechBubbleComponent.js +6 -24
  53. package/dist/components/dialog-component/index.js +0 -3
  54. package/dist/components/dialog-component/mocks/mockForStory.js +1 -5
  55. package/dist/components/drag-item-puzzle-component/components/DragItemPuzzleComponent.js +34 -90
  56. package/dist/components/drag-item-puzzle-component/components/Messages.js +0 -4
  57. package/dist/components/drag-item-puzzle-component/index.js +0 -3
  58. package/dist/components/drag-item-puzzle-component/mocks/mockForStory.js +1 -2
  59. package/dist/components/feedback-component/components/FeedbackComponent.js +34 -52
  60. package/dist/components/feedback-component/index.js +0 -3
  61. package/dist/components/feedback-component/mocks/mockForStory.js +1 -2
  62. package/dist/components/frame-click-puzzle-component/components/Counter/index.js +3 -8
  63. package/dist/components/frame-click-puzzle-component/components/CurrentFramePuzzle.js +36 -68
  64. package/dist/components/frame-click-puzzle-component/components/FrameClickPuzzleComponent.js +33 -68
  65. package/dist/components/frame-click-puzzle-component/components/Tooltip/index.js +0 -6
  66. package/dist/components/frame-click-puzzle-component/index.js +0 -3
  67. package/dist/components/frame-click-puzzle-component/mocks/mockForStory.js +1 -2
  68. package/dist/components/hacker-puzzle-component/components/HackerPuzzleComponent.js +29 -69
  69. package/dist/components/hacker-puzzle-component/index.js +0 -3
  70. package/dist/components/hacker-puzzle-component/mocks/mockForStory.js +0 -2
  71. package/dist/components/hanged-puzzle-component/components/HangedPuzzleComponent.js +48 -123
  72. package/dist/components/hanged-puzzle-component/index.js +0 -3
  73. package/dist/components/hanged-puzzle-component/mocks/mockForStory.js +0 -3
  74. package/dist/components/hanged-puzzle-component/utils.js +0 -20
  75. package/dist/components/image-click-puzzle-component/components/ImageClickPuzzleComponent.js +1 -8
  76. package/dist/components/image-click-puzzle-component/index.js +0 -3
  77. package/dist/components/image-click-puzzle-component/mocks/mockForStory.js +0 -2
  78. package/dist/components/image-click-wrapper-component/components/CountDown/index.js +0 -4
  79. package/dist/components/image-click-wrapper-component/components/ImageClickWrapperComponent.js +67 -134
  80. package/dist/components/image-click-wrapper-component/components/TimerDialog/index.js +2 -6
  81. package/dist/components/image-click-wrapper-component/index.js +0 -3
  82. package/dist/components/image-click-wrapper-component/mocks/mockForStory.js +0 -2
  83. package/dist/components/image-component/components/ImageComponent.js +14 -33
  84. package/dist/components/image-component/index.js +0 -3
  85. package/dist/components/image-component/mocks/mockForStory.js +0 -2
  86. package/dist/components/index.js +0 -39
  87. package/dist/components/inventory-item/components/InventoryItem.js +9 -35
  88. package/dist/components/inventory-item/index.js +0 -3
  89. package/dist/components/inventory-item/mocks/mockForStory.js +0 -3
  90. package/dist/components/keyboard-puzzle-component/components/KeyboardPuzzleComponent.js +33 -75
  91. package/dist/components/keyboard-puzzle-component/index.js +0 -3
  92. package/dist/components/keyboard-puzzle-component/mocks/mockForStory.js +0 -2
  93. package/dist/components/konva-components/Area/index.js +15 -44
  94. package/dist/components/konva-components/KonvaMapper.js +19 -42
  95. package/dist/components/lectures-component/components/LectureButtons.js +12 -13
  96. package/dist/components/lectures-component/components/LecturesComponent.js +29 -55
  97. package/dist/components/lectures-component/index.js +0 -3
  98. package/dist/components/lectures-component/mocks/mockForStory.js +6 -9
  99. package/dist/components/login-puzzle-component/components/LoginPuzzleComponent.js +38 -80
  100. package/dist/components/login-puzzle-component/index.js +0 -3
  101. package/dist/components/login-puzzle-component/mocks/mockForStory.js +0 -2
  102. package/dist/components/notice-component/components/NoticeComponent.js +8 -21
  103. package/dist/components/notice-component/index.js +0 -3
  104. package/dist/components/notice-component/mocks/mockForStory.js +0 -2
  105. package/dist/components/pattern-component/components/PatternComponent.js +8 -24
  106. package/dist/components/pattern-component/index.js +0 -3
  107. package/dist/components/pattern-component/mocks/mockForStory.js +0 -2
  108. package/dist/components/pdf-component/components/PdfComponent.js +23 -55
  109. package/dist/components/pdf-component/components/PdfVisor.js +22 -58
  110. package/dist/components/pdf-component/index.js +0 -3
  111. package/dist/components/pdf-component/mocks/mockForProps.js +1 -2
  112. package/dist/components/referral-component/components/EmailPill.js +2 -6
  113. package/dist/components/referral-component/components/ReferralComponent.js +30 -59
  114. package/dist/components/referral-component/components/StepOne.js +14 -48
  115. package/dist/components/referral-component/components/StepTwo.js +8 -23
  116. package/dist/components/referral-component/index.js +0 -3
  117. package/dist/components/referral-component/mocks/mockForStory.js +0 -2
  118. package/dist/components/survey-component/components/ApplicableBox.js +8 -15
  119. package/dist/components/survey-component/components/OpinionBox.js +8 -15
  120. package/dist/components/survey-component/components/SurveyComponent.js +13 -40
  121. package/dist/components/survey-component/components/TextBox.js +7 -13
  122. package/dist/components/survey-component/index.js +0 -3
  123. package/dist/components/survey-component/mocks/mockForStory.js +0 -2
  124. package/dist/components/terminal-puzzle-component/components/FilesGroup/Item.js +1 -6
  125. package/dist/components/terminal-puzzle-component/components/FilesGroup/index.js +4 -10
  126. package/dist/components/terminal-puzzle-component/components/Image/index.js +2 -6
  127. package/dist/components/terminal-puzzle-component/components/TerminalPuzzleComponent.js +26 -65
  128. package/dist/components/terminal-puzzle-component/components/Visor/index.js +15 -35
  129. package/dist/components/terminal-puzzle-component/components/utils/index.js +0 -3
  130. package/dist/components/terminal-puzzle-component/index.js +0 -3
  131. package/dist/components/terminal-puzzle-component/mocks/mockForStory.js +1 -2
  132. package/dist/components/test-component/components/Container.js +26 -60
  133. package/dist/components/test-component/components/Feedbacks.js +3 -13
  134. package/dist/components/test-component/components/Questions.js +11 -45
  135. package/dist/components/test-component/components/Results.js +28 -52
  136. package/dist/components/test-component/components/TestComponent.js +59 -110
  137. package/dist/components/test-component/index.js +0 -3
  138. package/dist/components/test-component/mocks/mockForStory.js +4 -8
  139. package/dist/components/text-click-puzzle-component/components/TextClickPuzzleComponent.js +58 -95
  140. package/dist/components/text-click-puzzle-component/index.js +0 -3
  141. package/dist/components/text-click-puzzle-component/mocks/mockForStory.js +1 -2
  142. package/dist/components/text-click-puzzle-component/utils/index.js +6 -31
  143. package/dist/components/url-component/components/UrlComponent.js +16 -34
  144. package/dist/components/url-component/index.js +0 -3
  145. package/dist/components/url-component/mocks/mockForProps.js +0 -2
  146. package/dist/components/video-component/components/VideoComponent.js +11 -25
  147. package/dist/components/video-component/index.js +0 -3
  148. package/dist/components/video-component/mocks/mockForStory.js +0 -2
  149. package/dist/components/video-visor/components/VideoControllers/BufferBar.js +10 -37
  150. package/dist/components/video-visor/components/VideoControllers/ControlButtons.js +2 -6
  151. package/dist/components/video-visor/components/VideoControllers/FinishedVideoButtons.js +1 -5
  152. package/dist/components/video-visor/components/VideoControllers/PlayInitButton.js +2 -8
  153. package/dist/components/video-visor/components/VideoControllers/SkipButton.js +5 -9
  154. package/dist/components/video-visor/components/VideoControllers/Timer.js +0 -5
  155. package/dist/components/video-visor/components/VideoControllers/VolumeBar.js +4 -20
  156. package/dist/components/video-visor/components/VideoControllers/index.js +17 -29
  157. package/dist/components/video-visor/components/VideoVisor.js +38 -92
  158. package/dist/components/video-visor/index.js +0 -3
  159. package/dist/components/video-visor/mocks/mockForStory.js +1 -2
  160. package/dist/components/web-builder-puzzle-component/Popups/PopupColorComponent/index.js +11 -28
  161. package/dist/components/web-builder-puzzle-component/Popups/PopupImageComponent/index.js +10 -27
  162. package/dist/components/web-builder-puzzle-component/Popups/PopupTextComponent/index.js +13 -36
  163. package/dist/components/web-builder-puzzle-component/Popups/index.js +0 -4
  164. package/dist/components/web-builder-puzzle-component/Templates/Facebook.js +0 -2
  165. package/dist/components/web-builder-puzzle-component/components/EditButton/index.js +1 -5
  166. package/dist/components/web-builder-puzzle-component/components/Feedback/index.js +3 -7
  167. package/dist/components/web-builder-puzzle-component/components/PublishButton/index.js +1 -5
  168. package/dist/components/web-builder-puzzle-component/components/WebBuilderBody/BankBody.js +5 -12
  169. package/dist/components/web-builder-puzzle-component/components/WebBuilderBody/FacebookBody.js +5 -11
  170. package/dist/components/web-builder-puzzle-component/components/WebBuilderBody/index.js +0 -7
  171. package/dist/components/web-builder-puzzle-component/components/WebBuilderFront/index.js +5 -14
  172. package/dist/components/web-builder-puzzle-component/components/WebBuilderHeader/BankHeader.js +5 -13
  173. package/dist/components/web-builder-puzzle-component/components/WebBuilderHeader/FacebookHeader.js +3 -8
  174. package/dist/components/web-builder-puzzle-component/components/WebBuilderHeader/index.js +3 -10
  175. package/dist/components/web-builder-puzzle-component/components/WebBuilderPuzzleComponent.js +47 -112
  176. package/dist/components/web-builder-puzzle-component/components/WebBuilderTopBar/index.js +3 -9
  177. package/dist/components/web-builder-puzzle-component/index.js +0 -3
  178. package/dist/components/web-builder-puzzle-component/mocks/mockForStory.js +0 -3
  179. package/dist/components/writer-puzzle-component/components/ElectionComponent.js +13 -30
  180. package/dist/components/writer-puzzle-component/components/FeedbackComponent.js +14 -30
  181. package/dist/components/writer-puzzle-component/components/FeedbackElement.js +2 -6
  182. package/dist/components/writer-puzzle-component/components/FinishedTextComponent.js +1 -6
  183. package/dist/components/writer-puzzle-component/components/FixedComponent.js +17 -52
  184. package/dist/components/writer-puzzle-component/components/SingleElection.js +13 -41
  185. package/dist/components/writer-puzzle-component/components/WriterPuzzleComponent.js +63 -145
  186. package/dist/components/writer-puzzle-component/index.js +0 -3
  187. package/dist/components/writer-puzzle-component/mocks/mockForStory.js +10 -7
  188. package/dist/components/zoom-test/components/ZoomTest.js +7 -25
  189. package/dist/components/zoom-test/index.js +0 -3
  190. package/dist/components/zoom-test/mocks/mockForStory.js +0 -4
  191. package/dist/helpers/LangIsRtl.js +0 -4
  192. package/dist/helpers/LightSet.js +0 -4
  193. package/dist/helpers/LodController.js +1 -10
  194. package/dist/helpers/deviceDetection.js +2 -5
  195. package/dist/helpers/drawLOD.js +11 -53
  196. package/dist/helpers/index.js +73 -102
  197. package/dist/helpers/lodStats.js +2 -10
  198. package/dist/helpers/mocker.js +1 -20
  199. package/dist/helpers/useEkho.js +64 -91
  200. package/dist/helpers/useGLB.js +5 -13
  201. package/dist/helpers/useStateMachine.js +257 -0
  202. package/dist/helpers/useTimeout.js +0 -6
  203. package/dist/helpers/useWindowSize.js +8 -22
  204. package/dist/index.js +0 -2
  205. package/dist/test/testSceneWrapper.js +0 -8
  206. package/package.json +3 -2
@@ -1,69 +1,39 @@
1
1
  "use strict";
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _react = _interopRequireWildcard(require("react"));
11
-
12
9
  var _fiber = require("@react-three/fiber");
13
-
14
10
  var _three = require("three");
15
-
16
- var _GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader");
17
-
18
11
  var _arcadeThreeCore = require("@gamelearn/arcade-three-core");
19
-
20
12
  var _gsap = _interopRequireDefault(require("gsap"));
21
-
22
- var _helpers = require("../../../helpers");
23
-
24
13
  var _useTimeout2 = _interopRequireDefault(require("../../../helpers/useTimeout"));
25
-
26
14
  var _useEkho = _interopRequireDefault(require("../../../helpers/useEkho"));
27
-
28
15
  var _LangIsRtl = _interopRequireDefault(require("../../../helpers/LangIsRtl"));
29
-
30
16
  var _BubbleWrapper = _interopRequireDefault(require("./BubbleWrapper"));
31
-
32
17
  var _DialogDecision = _interopRequireDefault(require("./DialogDecision"));
33
-
18
+ var _useStateMachine2 = _interopRequireDefault(require("../../../helpers/useStateMachine"));
34
19
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
-
36
20
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
37
-
38
21
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
39
-
40
22
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
41
-
42
23
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
43
-
44
24
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
45
-
46
25
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
47
-
48
26
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
49
-
50
27
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
51
-
52
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
53
-
28
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
29
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
30
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
54
31
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
55
-
56
32
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
57
-
58
33
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
59
-
60
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
61
-
62
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
63
-
64
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
65
-
66
- var crossFadeDuration = 0.1;
34
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
35
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
36
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /* eslint-disable react-hooks/exhaustive-deps */
67
37
  var characterMs = 75;
68
38
  var minMs = 1400;
69
39
  var headSize = 2;
@@ -71,62 +41,45 @@ var raycast = new _three.Raycaster();
71
41
  var animationTarget = new _three.Object3D();
72
42
  var maxCharacterToSwitch = 70;
73
43
  raycast.firstHitOnly = true;
74
-
75
44
  var DialogComponent = function DialogComponent(_ref) {
76
45
  var _currentLineData$slot;
77
-
78
46
  var keyboardControl = _ref.keyboardControl,
79
- emitEvent = _ref.emitEvent,
80
- lines = _ref.lines,
81
- actors = _ref.actors,
82
- edges = _ref.edges,
83
- soundActions = _ref.soundActions,
84
- zoomInActor = _ref.zoomInActor,
85
- autoPlay = _ref.autoPlay,
86
- pause = _ref.pause,
87
- progress = _ref.progress;
47
+ emitEvent = _ref.emitEvent,
48
+ lines = _ref.lines,
49
+ actors = _ref.actors,
50
+ edges = _ref.edges,
51
+ soundActions = _ref.soundActions,
52
+ zoomInActor = _ref.zoomInActor,
53
+ autoPlay = _ref.autoPlay,
54
+ pause = _ref.pause,
55
+ progress = _ref.progress;
88
56
  var defaultLine = (progress === null || progress === void 0 ? void 0 : progress.line) || 0;
89
-
90
57
  var _useState = (0, _react.useState)(defaultLine),
91
- _useState2 = _slicedToArray(_useState, 2),
92
- line = _useState2[0],
93
- changeLine = _useState2[1];
94
-
58
+ _useState2 = _slicedToArray(_useState, 2),
59
+ line = _useState2[0],
60
+ changeLine = _useState2[1];
95
61
  var _useState3 = (0, _react.useState)(!!autoPlay),
96
- _useState4 = _slicedToArray(_useState3, 2),
97
- automatic = _useState4[0],
98
- setAutomatic = _useState4[1];
99
-
62
+ _useState4 = _slicedToArray(_useState3, 2),
63
+ automatic = _useState4[0],
64
+ setAutomatic = _useState4[1];
100
65
  var _useState5 = (0, _react.useState)(false),
101
- _useState6 = _slicedToArray(_useState5, 2),
102
- mounted = _useState6[0],
103
- setMounted = _useState6[1];
104
-
66
+ _useState6 = _slicedToArray(_useState5, 2),
67
+ mounted = _useState6[0],
68
+ setMounted = _useState6[1];
105
69
  var _useState7 = (0, _react.useState)(false),
106
- _useState8 = _slicedToArray(_useState7, 2),
107
- talking = _useState8[0],
108
- startTalking = _useState8[1];
109
-
110
- var _useState9 = (0, _react.useState)(false),
111
- _useState10 = _slicedToArray(_useState9, 2),
112
- audioFailed = _useState10[0],
113
- setAudioFailed = _useState10[1];
114
-
70
+ _useState8 = _slicedToArray(_useState7, 2),
71
+ audioFailed = _useState8[0],
72
+ setAudioFailed = _useState8[1];
115
73
  var scene = (0, _fiber.useThree)(function (state) {
116
74
  return state.scene;
117
75
  });
118
76
  var camera = (0, _fiber.useThree)(function (state) {
119
77
  return state.camera;
120
78
  });
121
-
122
79
  var _useTimeout = (0, _useTimeout2.default)(),
123
- start = _useTimeout.start,
124
- stop = _useTimeout.stop;
125
-
80
+ start = _useTimeout.start,
81
+ stop = _useTimeout.stop;
126
82
  var changedMats = (0, _react.useRef)([]);
127
- var loader = (0, _react.useMemo)(function () {
128
- return new _GLTFLoader.GLTFLoader();
129
- }, []);
130
83
  var defaultCamera = (0, _react.useMemo)(function () {
131
84
  return camera.clone();
132
85
  }, []);
@@ -140,40 +93,40 @@ var DialogComponent = function DialogComponent(_ref) {
140
93
  var lastSet = (0, _react.useRef)(false);
141
94
  var isBranched = !!edges;
142
95
  var onZoomEnd = (0, _react.useRef)(function () {});
143
-
144
96
  var _ref2 = currentLineData || {},
145
- voiceOver = _ref2.voiceOver,
146
- decision = _ref2.decision;
147
-
97
+ voiceOver = _ref2.voiceOver,
98
+ decision = _ref2.decision;
148
99
  var lastTalking = (0, _react.useRef)({});
149
100
  var talkingCharacter = currentLineData === null || currentLineData === void 0 ? void 0 : (_currentLineData$slot = currentLineData.slots) === null || _currentLineData$slot === void 0 ? void 0 : _currentLineData$slot.find(function (slot) {
150
101
  return slot.talking;
151
102
  });
152
103
  var zoomStarted = (0, _react.useRef)(false);
104
+ var _useStateMachine = (0, _useStateMachine2.default)(lines),
105
+ startAnimation = _useStateMachine.startAnimation,
106
+ resetActives = _useStateMachine.resetActives;
153
107
  var autoPlayCond = automatic && !(currentLineData !== null && currentLineData !== void 0 && currentLineData.decision);
154
108
  var audio = Object.keys((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audio) || {}).length;
155
109
  var voice = Object.keys((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.voice) || {}).length;
156
110
  var isVoiceOver = voiceOver || (currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.type) === 'conversationalNarration';
157
- var isDecision = decision || (currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.type) === 'conversationalDecision'; // Force camera update (r3f selector not updating)
111
+ var isDecision = decision || (currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.type) === 'conversationalDecision';
158
112
 
113
+ // Force camera update (r3f selector not updating)
159
114
  (0, _fiber.useFrame)(function (_ref3) {
160
115
  var sceneCam = _ref3.camera;
161
116
  actualCamera.current = sceneCam;
162
117
  });
163
-
164
- var _useState11 = (0, _react.useState)({
165
- text: '',
166
- name: '',
167
- inScene: false,
168
- thinkful: false,
169
- voiceOver: false,
170
- avatar: '',
171
- show: false
172
- }),
173
- _useState12 = _slicedToArray(_useState11, 2),
174
- currentMessage = _useState12[0],
175
- setCurrentMessage = _useState12[1];
176
-
118
+ var _useState9 = (0, _react.useState)({
119
+ text: '',
120
+ name: '',
121
+ inScene: false,
122
+ thinkful: false,
123
+ voiceOver: false,
124
+ avatar: '',
125
+ show: false
126
+ }),
127
+ _useState10 = _slicedToArray(_useState9, 2),
128
+ currentMessage = _useState10[0],
129
+ setCurrentMessage = _useState10[1];
177
130
  var charactersInvolved = (0, _react.useMemo)(function () {
178
131
  return lines.reduce(function (acc, current) {
179
132
  if (current.slots) {
@@ -184,7 +137,6 @@ var DialogComponent = function DialogComponent(_ref) {
184
137
  if (!acc.includes(currentParticipant.uid)) acc.push(currentParticipant.uid);
185
138
  });
186
139
  }
187
-
188
140
  return acc;
189
141
  }, []);
190
142
  }, [lines]);
@@ -194,12 +146,10 @@ var DialogComponent = function DialogComponent(_ref) {
194
146
  payload: id
195
147
  });
196
148
  }, [emitEvent]);
197
-
198
- var _useState13 = (0, _react.useState)([]),
199
- _useState14 = _slicedToArray(_useState13, 2),
200
- edgesHistory = _useState14[0],
201
- setEdgesHistory = _useState14[1];
202
-
149
+ var _useState11 = (0, _react.useState)([]),
150
+ _useState12 = _slicedToArray(_useState11, 2),
151
+ edgesHistory = _useState12[0],
152
+ setEdgesHistory = _useState12[1];
203
153
  var lastNodeId = (0, _react.useMemo)(function () {
204
154
  return edgesHistory[edgesHistory.length - 1];
205
155
  }, [edgesHistory]);
@@ -212,24 +162,21 @@ var DialogComponent = function DialogComponent(_ref) {
212
162
  var lastL = lines.find(function (l) {
213
163
  return l.id === (lastEdge === null || lastEdge === void 0 ? void 0 : lastEdge.fromId);
214
164
  });
215
-
216
165
  if (!lastNodeId && (progress === null || progress === void 0 ? void 0 : progress.line) >= 0) {
217
166
  return {
218
167
  decision: true
219
168
  };
220
169
  }
221
-
222
170
  return lastL;
223
171
  }, [edges, lines, lastNodeId]);
224
172
  var previousLineWasDecision = (0, _react.useCallback)(function () {
225
173
  if (isBranched) {
226
174
  // if we have edges, we need to check if the previous line was a decision
227
175
  var _lastL = findLastLineBranched();
228
-
229
176
  return _lastL === null || _lastL === void 0 ? void 0 : _lastL.decision;
230
- } // if there is no branching, the previous line is the previous one
231
-
177
+ }
232
178
 
179
+ // if there is no branching, the previous line is the previous one
233
180
  var lastL = lines[line - 1] ? lines[line - 1] : {};
234
181
  return line > 0 && (lastL === null || lastL === void 0 ? void 0 : lastL.decision);
235
182
  }, [currentLineData, isBranched, lines, lastNodeId, edges]);
@@ -245,90 +192,31 @@ var DialogComponent = function DialogComponent(_ref) {
245
192
  }, [scene]);
246
193
  var getAvatarURL = (0, _react.useCallback)(function (slot) {
247
194
  var _slot$character, _slot$character$resou;
248
-
249
195
  var object = actors.find(function (element) {
250
196
  if ((element === null || element === void 0 ? void 0 : element.uid) === (slot === null || slot === void 0 ? void 0 : slot.uid)) {
251
197
  return element;
252
198
  }
253
-
254
199
  return '';
255
200
  });
256
201
  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) || '';
257
202
  }, [actors]);
258
- var loadEmotion = (0, _react.useCallback)(function (slot, element) {
259
- var _slot$animation;
260
-
261
- var onLoadAnim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
262
- var animation;
263
- var emotion = element.isSeated && !slot.emotion.includes('seated') ? "".concat(slot.emotion, "-seated") : slot.emotion;
264
-
265
- 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) {
266
- // force camera transition seated -> not seated
267
- if (lastTalking.current && lastTalking.current.uid === element.uid) {
268
- var currentIsSeated = slot.emotion.includes('seated');
269
- var lastIsSeated = lastTalking.current.emotion.includes('seated');
270
- if (currentIsSeated && !lastIsSeated) lastTalking.current = {};
271
- if (!currentIsSeated && lastIsSeated) lastTalking.current = {};
272
- }
273
-
274
- animation = slot.animation;
275
- } else {
276
- var _slot$character2;
277
-
278
- animation = (_slot$character2 = slot.character) === null || _slot$character2 === void 0 ? void 0 : _slot$character2.resource.animations[emotion];
279
- }
280
-
281
- var mixer = element.userData.mixer;
282
-
283
- if (animation && animation.url) {
284
- loader.load(animation.url, function (anim) {
285
- var emotionClip = anim.animations[0];
286
- var defaultClip = element.userData.defaultAnim;
287
- var emotionAction = mixer.clipAction(emotionClip, element);
288
- var defaultAction = mixer.clipAction(defaultClip, element);
289
-
290
- if (element.userData.currentEmotion) {
291
- element.userData.lastEmotion = element.userData.currentEmotion;
292
- }
293
-
294
- element.userData.currentEmotion = emotionAction;
295
- onLoadAnim(mixer, emotionAction, defaultAction);
296
- });
297
- } else {
298
- onLoadAnim(mixer);
299
- }
300
- }, [loader]); // Force default animation without transition
301
-
302
- var executeDefaultAnimation = function executeDefaultAnimation(element) {
303
- if (!talkingCharacter || element.uid === talkingCharacter.uid) return;
304
-
305
- if (element.userData.mixer && element.userData.defaultAnim) {
306
- var mixer = element.userData.mixer;
307
- var defaultAction = mixer.clipAction(element.userData.defaultAnim, element);
308
- mixer.stopAllAction();
309
- defaultAction.play();
310
- }
311
- }; // Starts camera transition
312
-
313
203
 
204
+ // Starts camera transition
314
205
  var animateCameraTransition = function animateCameraTransition() {
315
206
  if (!zoomStarted.current) {
316
207
  var cam = actualCamera.current;
317
208
  var targetPosition = messagePosition.current.child ? messagePosition.current.pos : defaultCamera.position.toArray();
318
209
  animationTarget.position.fromArray(targetPosition);
319
-
320
210
  if (messagePosition.current.parent) {
321
211
  if (!animationTarget.quaternion.equals(cam.quaternion)) {
322
212
  animationTarget.applyQuaternion(cam.quaternion);
323
213
  }
324
-
325
214
  var mult = messagePosition.current.isLeft ? -1 : 1;
326
215
  var headSpace = headSize * mult;
327
216
  animationTarget.translateX(-10 * mult + headSpace);
328
217
  animationTarget.translateY(-2);
329
218
  animationTarget.translateZ(30);
330
219
  }
331
-
332
220
  _gsap.default.to(cam.position, _objectSpread({
333
221
  duration: 0.9,
334
222
  ease: 'power3.easeInOut',
@@ -348,28 +236,25 @@ var DialogComponent = function DialogComponent(_ref) {
348
236
  onZoomEnd.current();
349
237
  onZoomEnd.current = null;
350
238
  }
351
-
352
239
  raycast.set(cam.getWorldPosition(new _three.Vector3(0, 0, 0)), cam.getWorldDirection(new _three.Vector3()));
353
240
  var objects = raycast.intersectObjects(scene.children, true);
354
241
  changedMats.current = objects.filter(function (o) {
355
242
  return o.distance < 10;
356
- }); // Make objects invisible in front of the camera
243
+ });
357
244
 
245
+ // Make objects invisible in front of the camera
358
246
  if (changedMats.current.length) {
359
247
  changedMats.current.forEach(function (o) {
360
248
  var object = o.object;
361
249
  object.material.side = 0;
362
250
  });
363
251
  }
364
-
365
252
  zoomStarted.current = false;
366
-
367
253
  if (lastSet.current) {
368
254
  emitEvent({
369
255
  type: 'success'
370
256
  });
371
257
  }
372
-
373
258
  if (!messagePosition.current.child) {
374
259
  cam.copy(defaultCamera);
375
260
  }
@@ -378,87 +263,43 @@ var DialogComponent = function DialogComponent(_ref) {
378
263
  } else if (zoomStarted.current) {
379
264
  zoomStarted.current = false;
380
265
  }
381
- }; // Reset currentEmotion to defaultAnim
382
-
383
-
384
- var resetAnims = (0, _react.useCallback)(function () {
385
- scene.traverseVisible(function (node) {
386
- if (charactersInvolved.includes(node.elementUid)) {
387
- executeDefaultAnimation(node);
388
- }
389
- });
390
- }, [scene, charactersInvolved]);
266
+ };
391
267
  var resetCameraView = (0, _react.useCallback)(function () {
392
268
  messagePosition.current.child = null;
393
269
  messagePosition.current.parent = null;
394
-
395
270
  if (zoomInActor) {
396
271
  animateCameraTransition();
397
272
  }
398
273
  }, [zoomInActor]);
399
-
274
+ var startTalking = function startTalking() {
275
+ if (!(talkingCharacter !== null && talkingCharacter !== void 0 && talkingCharacter.emotion)) return;
276
+ var emotion = talkingCharacter.emotion;
277
+ startAnimation(talkingCharacter.uid, "".concat(emotion, "_talking"));
278
+ };
400
279
  var resetTalkingAnimation = function resetTalkingAnimation() {
401
- var element = getCurrentVisible(talkingCharacter === null || talkingCharacter === void 0 ? void 0 : talkingCharacter.uid);
402
-
403
- if (!element) {
404
- startTalking(false);
405
- return;
406
- }
407
-
408
- if (!element.isTalking) {
409
- return;
410
- }
411
-
412
- var _element$userData = element.userData,
413
- mixer = _element$userData.mixer,
414
- defaultAnim = _element$userData.defaultAnim,
415
- emotionClip = _element$userData.emotionClip;
416
-
417
- if (defaultAnim && emotionClip) {
418
- var emotionAction = mixer.clipAction(emotionClip, element);
419
- var defaultAction = mixer.clipAction(defaultAnim, element);
420
- mixer.stopAllAction();
421
- (0, _helpers.executeCrossFade)(emotionAction, defaultAction, crossFadeDuration);
422
- element.isTalking = false;
423
- }
424
-
425
- startTalking(false);
426
- }; // Execute talking animation
427
-
428
-
429
- (0, _react.useEffect)(function () {
430
- var element = getCurrentVisible(talkingCharacter === null || talkingCharacter === void 0 ? void 0 : talkingCharacter.uid);
431
-
432
- if (element && currentMessage.show) {
433
- if (talking) {
434
- var _talkingCharacter$cha, _talkingCharacter$cha2, _talkingCharacter$cha3, _talkingCharacter$cha4;
435
-
436
- (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);
437
- } else {
438
- resetTalkingAnimation();
439
- }
440
- }
441
- }, [talkingCharacter, talking, currentMessage.show]);
280
+ if (!(talkingCharacter !== null && talkingCharacter !== void 0 && talkingCharacter.uid)) return;
281
+ var emotion = talkingCharacter.emotion;
282
+ startAnimation(talkingCharacter.uid, emotion);
283
+ };
442
284
  var finishConversation = (0, _react.useCallback)(function () {
443
285
  lastSet.current = true;
444
286
  changeLine(0);
287
+ resetActives();
445
288
  setCurrentMessage({
446
289
  show: false
447
290
  });
448
291
  resetCameraView();
449
- resetAnims();
450
-
451
292
  if (!zoomInActor) {
452
293
  emitEvent({
453
294
  type: 'success'
454
295
  });
455
296
  }
456
- }, [camera, emitEvent, resetAnims, resetCameraView, zoomInActor]); // Reset anim after unmount
297
+ }, [camera, emitEvent, resetCameraView, zoomInActor]);
457
298
 
299
+ // Reset anim after unmount
458
300
  (0, _react.useEffect)(function () {
459
301
  return function () {
460
302
  lastTalking.current = {};
461
- resetAnims();
462
303
  };
463
304
  }, []);
464
305
  var handleBranchDirection = (0, _react.useCallback)(function () {
@@ -470,20 +311,16 @@ var DialogComponent = function DialogComponent(_ref) {
470
311
  var foundEdge = foundEdges.length === 1 ? foundEdges[0] : foundEdges.find(function (edge) {
471
312
  return edge[keys[1]] === lastNodeId;
472
313
  });
473
-
474
314
  if (!(foundEdge !== null && foundEdge !== void 0 && foundEdge[keys[0]])) {
475
315
  return;
476
- } // if going backwards remove last edge from history
477
-
478
-
316
+ }
317
+ // if going backwards remove last edge from history
479
318
  if (!forward) {
480
319
  setEdgesHistory(edgesHistory.slice(0, edgesHistory.length - 1));
481
320
  }
482
-
483
321
  var destination = lines.findIndex(function (l) {
484
322
  return l.id === foundEdge[keys[1]];
485
323
  });
486
-
487
324
  if (destination >= 0) {
488
325
  setCurrentMessage({
489
326
  show: false
@@ -510,7 +347,6 @@ var DialogComponent = function DialogComponent(_ref) {
510
347
  var destinationEdge = lines.findIndex(function (l) {
511
348
  return l.id === (currentEdge === null || currentEdge === void 0 ? void 0 : currentEdge.toId);
512
349
  });
513
-
514
350
  if (destinationEdge >= 0) {
515
351
  if ((currentEdge === null || currentEdge === void 0 ? void 0 : currentEdge.fromId) === (currentEdge === null || currentEdge === void 0 ? void 0 : currentEdge.toId)) {
516
352
  reset();
@@ -532,9 +368,7 @@ var DialogComponent = function DialogComponent(_ref) {
532
368
  }, [currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.id, edges, finishConversation, lines]);
533
369
  var backLine = (0, _react.useCallback)(function () {
534
370
  lastTalking.current = _objectSpread({}, talkingCharacter);
535
- resetTalkingAnimation();
536
371
  setAudioFailed(false);
537
-
538
372
  if (isBranched) {
539
373
  handleBranchDirection(false);
540
374
  } else if (!previousLineWasDecision()) {
@@ -553,10 +387,8 @@ var DialogComponent = function DialogComponent(_ref) {
553
387
  }, [handleBranchDirection, emitEvent, isBranched, lastLine, line, talkingCharacter]);
554
388
  var nextLine = (0, _react.useCallback)(function (choice, reset) {
555
389
  lastTalking.current = _objectSpread({}, talkingCharacter);
556
- resetTalkingAnimation();
557
390
  setEdgesHistory([].concat(_toConsumableArray(edgesHistory), [currentLineData.id]));
558
391
  setAudioFailed(false);
559
-
560
392
  if (isBranched) {
561
393
  if (choice) {
562
394
  handleDecisionBranch(choice, reset);
@@ -579,53 +411,44 @@ var DialogComponent = function DialogComponent(_ref) {
579
411
  finishConversation();
580
412
  }
581
413
  }, [emitEvent, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.decision, isBranched, line, lines.length, handleDecisionBranch, handleBranchDirection, finishConversation, talkingCharacter]);
582
-
583
414
  var manualBackLine = function manualBackLine() {
584
415
  setAutomatic(false);
585
416
  backLine();
586
417
  };
587
-
588
418
  var isEndNode = function isEndNode() {
589
419
  if (isBranched) {
590
420
  return currentLineData && currentLineData.type !== 'conversationalDecision' && !edges.find(function (edge) {
591
421
  return edge.fromId === currentLineData.id;
592
422
  });
593
423
  }
594
-
595
424
  return line === lines.length - 1;
596
425
  };
597
-
598
426
  var manualNextLine = function manualNextLine() {
599
427
  if (isEndNode()) {
600
- startTalking(false);
601
428
  finishConversation();
602
429
  } else {
603
430
  setAutomatic(false);
604
431
  nextLine();
605
432
  }
606
- }; // Calculate start node
607
-
433
+ };
608
434
 
435
+ // Calculate start node
609
436
  (0, _react.useEffect)(function () {
610
437
  if (isBranched && !mounted) {
611
438
  var defaultBranch = progress === null || progress === void 0 ? void 0 : progress.line;
612
-
613
439
  if (defaultBranch >= 0) {
614
440
  setMounted(true);
615
441
  changeLine(defaultBranch);
616
442
  return;
617
443
  }
618
-
619
444
  var startNodes = lines.filter(function (node) {
620
445
  return !edges.find(function (edge) {
621
446
  return edge.toId === node.id;
622
447
  });
623
448
  });
624
-
625
449
  if (startNodes.length) {
626
450
  var initialNode = startNodes[0];
627
451
  var newInitiaIndexlNode = lines.indexOf(initialNode);
628
-
629
452
  if (newInitiaIndexlNode >= 0) {
630
453
  setMounted(true);
631
454
  changeLine(newInitiaIndexlNode);
@@ -633,7 +456,6 @@ var DialogComponent = function DialogComponent(_ref) {
633
456
  }
634
457
  }
635
458
  }, [edges, isBranched, lines, mounted]);
636
-
637
459
  var moveBubble = function moveBubble(element) {
638
460
  if (lastTalking.current.uid === element.uid) return;
639
461
  var target = new _three.Object3D();
@@ -644,8 +466,9 @@ var DialogComponent = function DialogComponent(_ref) {
644
466
  var yDistance = zoomInActor ? 2.5 : 2;
645
467
  var xDistance = zoomInActor ? 1.2 : 1.5;
646
468
  target.translateY(yDistance);
647
- target.translateX(xDistance); // Check if character is left or right in the screen
469
+ target.translateX(xDistance);
648
470
 
471
+ // Check if character is left or right in the screen
649
472
  var vector = new _three.Vector3();
650
473
  vector.setFromMatrixPosition(head.matrixWorld);
651
474
  var p = vector.project(camera);
@@ -656,9 +479,9 @@ var DialogComponent = function DialogComponent(_ref) {
656
479
  parent: element,
657
480
  isLeft: isLeft
658
481
  };
659
- }; // Position bubble over talking character/and switch emotions
660
-
482
+ };
661
483
 
484
+ // Position bubble over talking character/and switch emotions
662
485
  (0, _react.useEffect)(function () {
663
486
  if (isVoiceOver) {
664
487
  resetCameraView();
@@ -684,84 +507,48 @@ var DialogComponent = function DialogComponent(_ref) {
684
507
  var notInvolvedParticipants = charactersInvolved.filter(function (charUid) {
685
508
  return !currentParticipants.includes(charUid);
686
509
  });
687
- notInvolvedParticipants.forEach(function (uid) {
688
- var element = getCurrentVisible(uid);
689
-
690
- if (element) {
691
- executeDefaultAnimation(element);
692
- }
693
- }); // Check not talking elements emotion
694
-
695
- slottedCharacters.forEach(function (slot) {
696
- var element = getCurrentVisible(slot.uid);
697
-
698
- if (element) {
699
- loadEmotion(slot, element, function (mixer, action, defaultAction) {
700
- var startAction = element.userData.lastEmotion ? element.userData.lastEmotion : defaultAction;
701
-
702
- if (startAction !== action && action) {
703
- var clip = action.getClip();
704
- var actionS = mixer.existingAction(clip, element);
510
+ notInvolvedParticipants.forEach(function (c) {
511
+ startAnimation(c, 'idle');
512
+ });
705
513
 
706
- if (!actionS.isRunning()) {
707
- (0, _helpers.executeCrossFade)(startAction, action, crossFadeDuration);
708
- }
709
- }
710
- });
711
- }
514
+ // Check not talking elements emotion
515
+ slottedCharacters.forEach(function (c) {
516
+ startAnimation(c.uid, c.emotion);
712
517
  });
713
518
  var element = getCurrentVisible(talkingCharacter.uid);
714
519
  var object = actors.find(function (a) {
715
520
  return a.uid === talkingCharacter.uid;
716
521
  });
717
-
718
522
  if (element && !lastSet.current) {
719
- loadEmotion(talkingCharacter, element, function (mixer, action, defaultAction) {
720
- var startAction = element.userData.lastEmotion ? element.userData.lastEmotion : defaultAction;
721
-
722
- if (startAction && action && startAction !== action) {
723
- var clip = action.getClip();
724
- var actionS = mixer.existingAction(clip, element);
725
-
726
- if (!actionS.isRunning()) {
727
- (0, _helpers.executeCrossFade)(startAction, action, crossFadeDuration);
728
- element.userData.defaultAnim = action.getClip();
523
+ setTimeout(function () {
524
+ if (talkingCharacter.uid === element.uid) {
525
+ moveBubble(element);
526
+ startAnimation(talkingCharacter.uid, talkingCharacter.emotion);
527
+ var setMessage = function setMessage() {
528
+ var _talkingCharacter$cha;
529
+ setCurrentMessage({
530
+ text: talkingCharacter.text,
531
+ name: talkingCharacter.alias || ((_talkingCharacter$cha = talkingCharacter.character) === null || _talkingCharacter$cha === void 0 ? void 0 : _talkingCharacter$cha.name),
532
+ inScene: true,
533
+ thinkful: talkingCharacter.emotion.includes('think'),
534
+ avatar: getAvatarURL(talkingCharacter),
535
+ show: true
536
+ });
537
+ };
538
+ if (zoomInActor) {
539
+ onZoomEnd.current = setMessage;
540
+ animateCameraTransition();
541
+ } else {
542
+ setMessage();
729
543
  }
730
544
  }
731
-
732
- setTimeout(function () {
733
- if (talkingCharacter.uid === element.uid) {
734
- moveBubble(element);
735
-
736
- var setMessage = function setMessage() {
737
- var _talkingCharacter$cha5;
738
-
739
- setCurrentMessage({
740
- text: talkingCharacter.text,
741
- name: talkingCharacter.alias || ((_talkingCharacter$cha5 = talkingCharacter.character) === null || _talkingCharacter$cha5 === void 0 ? void 0 : _talkingCharacter$cha5.name),
742
- inScene: true,
743
- thinkful: talkingCharacter.emotion.includes('think'),
744
- avatar: getAvatarURL(talkingCharacter),
745
- show: true
746
- });
747
- };
748
-
749
- if (zoomInActor) {
750
- onZoomEnd.current = setMessage;
751
- animateCameraTransition();
752
- } else {
753
- setMessage();
754
- }
755
- }
756
- }, 150);
757
- });
545
+ }, 150);
758
546
  } else {
759
- var _talkingCharacter$cha6;
760
-
547
+ var _talkingCharacter$cha2;
761
548
  resetCameraView();
762
549
  setCurrentMessage({
763
550
  text: talkingCharacter.text,
764
- name: talkingCharacter.alias || ((_talkingCharacter$cha6 = talkingCharacter.character) === null || _talkingCharacter$cha6 === void 0 ? void 0 : _talkingCharacter$cha6.name) || (object === null || object === void 0 ? void 0 : object.name),
551
+ name: talkingCharacter.alias || ((_talkingCharacter$cha2 = talkingCharacter.character) === null || _talkingCharacter$cha2 === void 0 ? void 0 : _talkingCharacter$cha2.name) || (object === null || object === void 0 ? void 0 : object.name),
765
552
  left: false,
766
553
  top: talkingCharacter.text.length > maxCharacterToSwitch,
767
554
  inScene: false,
@@ -777,8 +564,9 @@ var DialogComponent = function DialogComponent(_ref) {
777
564
  });
778
565
  }
779
566
  }
780
- }, [actors, currentLineData, zoomInActor, getCurrentVisible, translate, getAvatarURL, loadEmotion, resetCameraView, isDecision, isVoiceOver, charactersInvolved]); // Sound logic
567
+ }, [actors, currentLineData, zoomInActor, getCurrentVisible, translate, getAvatarURL, resetCameraView, isDecision, isVoiceOver, charactersInvolved]);
781
568
 
569
+ // Sound logic
782
570
  var stopEkho = (0, _useEkho.default)({
783
571
  audioType: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType,
784
572
  volume: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioVolume,
@@ -792,16 +580,14 @@ var DialogComponent = function DialogComponent(_ref) {
792
580
  pauseTTS: pause,
793
581
  onStart: function onStart() {
794
582
  var _talkingCharacter$emo;
795
-
796
583
  if (talkingCharacter !== null && talkingCharacter !== void 0 && (_talkingCharacter$emo = talkingCharacter.emotion) !== null && _talkingCharacter$emo !== void 0 && _talkingCharacter$emo.includes('think')) return;
797
- startTalking(true);
584
+ startTalking();
798
585
  },
799
586
  onError: function onError() {
800
587
  setAudioFailed(true);
801
588
  },
802
589
  onFinish: function onFinish() {
803
- startTalking(false);
804
-
590
+ resetTalkingAnimation();
805
591
  if (autoPlayCond && !pause) {
806
592
  nextLine();
807
593
  }
@@ -816,26 +602,24 @@ var DialogComponent = function DialogComponent(_ref) {
816
602
  (0, _react.useEffect)(function () {
817
603
  if (((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed) && currentMessage !== null && currentMessage !== void 0 && currentMessage.show && !(talkingCharacter !== null && talkingCharacter !== void 0 && talkingCharacter.emotion.includes('think'))) {
818
604
  var _currentMessage$text;
819
-
820
- startTalking(true);
605
+ startTalking();
821
606
  var time = characterMs * ((currentMessage === null || currentMessage === void 0 ? void 0 : (_currentMessage$text = currentMessage.text) === null || _currentMessage$text === void 0 ? void 0 : _currentMessage$text.length) || 0);
822
607
  setTimeout(function () {
823
- startTalking(false);
608
+ resetTalkingAnimation();
824
609
  }, time < minMs ? minMs : time);
825
610
  }
826
- }, [audioFailed, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, talkingCharacter === null || talkingCharacter === void 0 ? void 0 : talkingCharacter.emotion, currentMessage]); // Autoplay logic
611
+ }, [audioFailed, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, talkingCharacter === null || talkingCharacter === void 0 ? void 0 : talkingCharacter.emotion, currentMessage]);
827
612
 
613
+ // Autoplay logic
828
614
  (0, _react.useEffect)(function () {
829
615
  if (autoPlayCond && currentMessage.show && ((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed) && !pause) {
830
616
  var _currentMessage$text2;
831
-
832
- var time = characterMs * ((currentMessage === null || currentMessage === void 0 ? void 0 : (_currentMessage$text2 = currentMessage.text) === null || _currentMessage$text2 === void 0 ? void 0 : _currentMessage$text2.length) || 0); // if it's not last node
833
-
617
+ var time = characterMs * ((currentMessage === null || currentMessage === void 0 ? void 0 : (_currentMessage$text2 = currentMessage.text) === null || _currentMessage$text2 === void 0 ? void 0 : _currentMessage$text2.length) || 0);
618
+ // if it's not last node
834
619
  if (!isEndNode()) {
835
620
  start(nextLine, time < minMs ? minMs : time);
836
621
  }
837
622
  }
838
-
839
623
  return function () {
840
624
  stop();
841
625
  };
@@ -846,7 +630,6 @@ var DialogComponent = function DialogComponent(_ref) {
846
630
  }, [line, previousLineWasDecision]);
847
631
  keyboardControl(isDecision || disableBackButton || !currentMessage.show ? null : manualBackLine, isDecision || !currentMessage.show ? null : manualNextLine);
848
632
  var container = document.querySelector('.screens--container');
849
-
850
633
  if (isDecision) {
851
634
  var decisionPayload = _objectSpread(_objectSpread({}, currentLineData.payload), {}, {
852
635
  inheritProps: {
@@ -867,10 +650,8 @@ var DialogComponent = function DialogComponent(_ref) {
867
650
  zoomStarted.current = false;
868
651
  }
869
652
  });
870
-
871
653
  return /*#__PURE__*/_react.default.createElement(_DialogDecision.default, decisionPayload);
872
654
  }
873
-
874
655
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, currentMessage.text ? /*#__PURE__*/_react.default.createElement(_BubbleWrapper.default, {
875
656
  translate: translate,
876
657
  currentMessage: currentMessage
@@ -909,6 +690,5 @@ var DialogComponent = function DialogComponent(_ref) {
909
690
  className: (0, _LangIsRtl.default)() ? 'icon-back' : 'icon-next'
910
691
  })))));
911
692
  };
912
-
913
693
  var _default = DialogComponent;
914
694
  exports.default = _default;