@gamelearn/arcade-components 2.1.0 → 2.2.0

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.
@@ -57,7 +57,8 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
57
57
  setResolveAction = _ref.setResolveAction,
58
58
  soundActions = _ref.soundActions,
59
59
  setSelected = _ref.setSelected,
60
- selected = _ref.selected;
60
+ selected = _ref.selected,
61
+ pause = _ref.pause;
61
62
  var accRewards = (0, _react.useRef)([]);
62
63
  var correctClicked = (0, _react.useRef)(0);
63
64
  var currentSelected = (0, _react.useRef)(0);
@@ -202,7 +203,8 @@ var CurrentImageClickPuzzle = function CurrentImageClickPuzzle(_ref) {
202
203
  emitEvent: emitEvent,
203
204
  disableExit: disableExit,
204
205
  soundActions: soundActions,
205
- setResolveAction: setResolveAction
206
+ setResolveAction: setResolveAction,
207
+ pause: pause
206
208
  }));
207
209
  };
208
210
 
@@ -62,6 +62,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
62
62
  var _background$img, _currentLineData$slot3, _currentMessage$text;
63
63
 
64
64
  var emitEvent = _ref.emitEvent,
65
+ pause = _ref.pause,
65
66
  lines = _ref.lines,
66
67
  edges = _ref.edges,
67
68
  characters = _ref.characters,
@@ -182,7 +183,8 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
182
183
  actors: actors,
183
184
  currentMessage: currentMessage || {},
184
185
  slots: !isVoiceOver ? currentLineData.slots : voiceOverSlots,
185
- flex: isFlex
186
+ flex: isFlex,
187
+ pause: pause
186
188
  }; // Recupera la antigua linea de la conversacion para conservar los personajes en voice-over
187
189
 
188
190
  var leftWithSlots = lines.slice(0, currentLine + 1).reverse().find(function (line) {
@@ -382,7 +384,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
382
384
  handleClickBack();
383
385
  };
384
386
 
385
- var autoplayCond = automatic && !isDecision;
387
+ var autoplayCond = automatic && !isDecision && !pause;
386
388
  var disableBackButton = currentLine === 0 || previousLineWasDecision();
387
389
  (0, _useEkho.default)({
388
390
  audioType: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType,
@@ -393,6 +395,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
393
395
  audio: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audio,
394
396
  soundActions: soundActions,
395
397
  emitEvent: emitEvent,
398
+ pause: pause,
396
399
  onStart: function onStart() {
397
400
  var _currentMessage$emoti;
398
401
 
@@ -29,7 +29,8 @@ var SlotList = function SlotList(_ref) {
29
29
  currentMessage = _ref.currentMessage,
30
30
  flex = _ref.flex,
31
31
  slots = _ref.slots,
32
- children = _ref.children;
32
+ children = _ref.children,
33
+ pause = _ref.pause;
33
34
 
34
35
  var characterProps = function characterProps(_ref2) {
35
36
  var character = _ref2.character,
@@ -144,7 +145,8 @@ var SlotList = function SlotList(_ref) {
144
145
  flex: flex,
145
146
  currentMessage: currentMessage,
146
147
  lodSettings: lodSettings,
147
- ttsStarted: ttsStarted
148
+ ttsStarted: ttsStarted,
149
+ pause: pause
148
150
  }), children || /*#__PURE__*/_react.default.createElement(Slots, null));
149
151
  };
150
152
 
@@ -29,6 +29,18 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
29
29
 
30
30
  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; }
31
31
 
32
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
33
+
34
+ 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."); }
35
+
36
+ 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); }
37
+
38
+ 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; }
39
+
40
+ 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; }
41
+
42
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
43
+
32
44
  var isMobile = (0, _deviceDetection.DeviceDetection)();
33
45
  var defaultCamPos = [0, 14.63, 16];
34
46
 
@@ -41,6 +53,12 @@ function Panel(_ref) {
41
53
  var cameraRef = (0, _react.useRef)(null);
42
54
  var sceneRef = (0, _react.useRef)(null);
43
55
  var isCharacter = character.type === 'character';
56
+
57
+ var _useState = (0, _react.useState)(false),
58
+ _useState2 = _slicedToArray(_useState, 2),
59
+ talking = _useState2[0],
60
+ setTalking = _useState2[1];
61
+
44
62
  var model = (0, _react.useRef)();
45
63
  var defaultClip = (0, _react.useRef)();
46
64
  var emotion = (0, _react.useMemo)(function () {
@@ -58,27 +76,36 @@ function Panel(_ref) {
58
76
 
59
77
  return {};
60
78
  }, [character.emotion, character === null || character === void 0 ? void 0 : (_character$resource4 = character.resource) === null || _character$resource4 === void 0 ? void 0 : _character$resource4.animations, isCharacter]);
79
+ var resetAnimation = (0, _react.useCallback)(function () {
80
+ var _model$current$userDa = model.current.userData,
81
+ mixer = _model$current$userDa.mixer,
82
+ defaultAnim = _model$current$userDa.defaultAnim,
83
+ emotionClip = _model$current$userDa.emotionClip;
84
+
85
+ if (defaultAnim && emotionClip) {
86
+ var emotionAction = mixer.clipAction(emotionClip, model.current);
87
+ var defaultAction = mixer.clipAction(defaultAnim, model.current);
88
+ mixer.stopAllAction();
89
+ (0, _helpers.executeCrossFade)(emotionAction, defaultAction);
90
+ setTalking(false);
91
+ }
92
+ }, []);
61
93
  (0, _react.useEffect)(function () {
62
- if (model.current && active) {
63
- if (ttsStarted) {
64
- var _character$resource5, _character$resource5$, _character$resource5$2;
65
-
66
- (0, _helpers.executeTalkingAnimation)(model.current, character === null || character === void 0 ? void 0 : (_character$resource5 = character.resource) === null || _character$resource5 === void 0 ? void 0 : (_character$resource5$ = _character$resource5.animations) === null || _character$resource5$ === void 0 ? void 0 : (_character$resource5$2 = _character$resource5$.talking) === null || _character$resource5$2 === void 0 ? void 0 : _character$resource5$2.url);
67
- } else {
68
- var _model$current$userDa = model.current.userData,
69
- mixer = _model$current$userDa.mixer,
70
- defaultAnim = _model$current$userDa.defaultAnim,
71
- emotionClip = _model$current$userDa.emotionClip;
72
-
73
- if (defaultAnim && emotionClip) {
74
- var emotionAction = mixer.clipAction(emotionClip, model.current);
75
- var defaultAction = mixer.clipAction(defaultAnim, model.current);
76
- mixer.stopAllAction();
77
- (0, _helpers.executeCrossFade)(emotionAction, defaultAction);
94
+ if (model.current) {
95
+ if (active) {
96
+ if (ttsStarted) {
97
+ var _character$resource5, _character$resource5$, _character$resource5$2;
98
+
99
+ (0, _helpers.executeTalkingAnimation)(model.current, character === null || character === void 0 ? void 0 : (_character$resource5 = character.resource) === null || _character$resource5 === void 0 ? void 0 : (_character$resource5$ = _character$resource5.animations) === null || _character$resource5$ === void 0 ? void 0 : (_character$resource5$2 = _character$resource5$.talking) === null || _character$resource5$2 === void 0 ? void 0 : _character$resource5$2.url);
100
+ setTalking(true);
101
+ } else {
102
+ resetAnimation();
78
103
  }
104
+ } else if (talking) {
105
+ resetAnimation();
79
106
  }
80
107
  }
81
- }, [character === null || character === void 0 ? void 0 : (_character$resource6 = character.resource) === null || _character$resource6 === void 0 ? void 0 : (_character$resource6$ = _character$resource6.animations) === null || _character$resource6$ === void 0 ? void 0 : (_character$resource6$2 = _character$resource6$.talking) === null || _character$resource6$2 === void 0 ? void 0 : _character$resource6$2.url, ttsStarted, active]);
108
+ }, [character === null || character === void 0 ? void 0 : (_character$resource6 = character.resource) === null || _character$resource6 === void 0 ? void 0 : (_character$resource6$ = _character$resource6.animations) === null || _character$resource6$ === void 0 ? void 0 : (_character$resource6$2 = _character$resource6$.talking) === null || _character$resource6$2 === void 0 ? void 0 : _character$resource6$2.url, ttsStarted, active, resetAnimation, talking]);
82
109
  var onLoadElement = (0, _react.useCallback)(function (object) {
83
110
  if (cameraRef.current) {
84
111
  var boundingBox = new _three.Box3();
@@ -79,8 +79,13 @@ var Scene = function Scene(props) {
79
79
  var gl = _ref3.gl;
80
80
  gl.setClearColor('white', 0);
81
81
  gl.physicallyCorrectLights = true;
82
+ },
83
+ frameloop: "demand"
84
+ }, /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.SettingsController, {
85
+ current: {
86
+ animate: props.pause
82
87
  }
83
- }, /*#__PURE__*/_react.default.createElement(_react.Suspense, {
88
+ }), /*#__PURE__*/_react.default.createElement(_react.Suspense, {
84
89
  fallback: null
85
90
  }, /*#__PURE__*/_react.default.createElement(PanelsWrapper, props)));
86
91
  };
@@ -87,7 +87,8 @@ var DialogComponent = function DialogComponent(_ref) {
87
87
  edges = _ref.edges,
88
88
  soundActions = _ref.soundActions,
89
89
  zoomInActor = _ref.zoomInActor,
90
- autoPlay = _ref.autoPlay;
90
+ autoPlay = _ref.autoPlay,
91
+ pause = _ref.pause;
91
92
 
92
93
  var _useState = (0, _react.useState)(0),
93
94
  _useState2 = _slicedToArray(_useState, 2),
@@ -639,6 +640,7 @@ var DialogComponent = function DialogComponent(_ref) {
639
640
  audio: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audio,
640
641
  soundActions: soundActions,
641
642
  emitEvent: emitEvent,
643
+ pause: pause,
642
644
  onStart: function onStart() {
643
645
  var _talkingCharacter$emo;
644
646
 
@@ -651,7 +653,7 @@ var DialogComponent = function DialogComponent(_ref) {
651
653
  onFinish: function onFinish() {
652
654
  startTalking(false);
653
655
 
654
- if (autoPlayCond) {
656
+ if (autoPlayCond && !pause) {
655
657
  nextLine();
656
658
  }
657
659
  }
@@ -675,7 +677,7 @@ var DialogComponent = function DialogComponent(_ref) {
675
677
  }, [audioFailed, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, talkingCharacter === null || talkingCharacter === void 0 ? void 0 : talkingCharacter.emotion, currentMessage]); // Autoplay logic
676
678
 
677
679
  (0, _react.useEffect)(function () {
678
- if (autoPlayCond && currentMessage.show && ((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed)) {
680
+ if (autoPlayCond && currentMessage.show && ((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed) && !pause) {
679
681
  var _currentMessage$text2;
680
682
 
681
683
  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
@@ -817,6 +819,7 @@ var DialogComponent = function DialogComponent(_ref) {
817
819
  branched: isBranched,
818
820
  onFinish: nextLine,
819
821
  emitEvent: emitEvent,
822
+ pause: pause,
820
823
  soundActions: soundActions
821
824
  });
822
825
 
@@ -61,7 +61,8 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
61
61
  firstTryForFrame = _ref.firstTryForFrame,
62
62
  setPuzzlesAutoCompleted = _ref.setPuzzlesAutoCompleted,
63
63
  puzzlesAutoCompleted = _ref.puzzlesAutoCompleted,
64
- emitOpenPopupCounterInfo = _ref.emitOpenPopupCounterInfo;
64
+ emitOpenPopupCounterInfo = _ref.emitOpenPopupCounterInfo,
65
+ pause = _ref.pause;
65
66
 
66
67
  var _soundActions = _slicedToArray(soundActions, 1),
67
68
  playSound = _soundActions[0];
@@ -194,7 +195,8 @@ var CurrentFramePuzzle = function CurrentFramePuzzle(_ref) {
194
195
  emitResetPuzzle: handleResetPuzzle,
195
196
  firstTryForFrame: firstTryForFrame,
196
197
  puzzlesAutoCompleted: puzzlesAutoCompleted,
197
- emitOpenPopupCounterInfo: emitOpenPopupCounterInfo
198
+ emitOpenPopupCounterInfo: emitOpenPopupCounterInfo,
199
+ pause: pause
198
200
  }));
199
201
  };
200
202
 
@@ -48,7 +48,8 @@ var FrameImageClickComponent = function FrameImageClickComponent(_ref) {
48
48
  soundActions = _ref.soundActions,
49
49
  disableExit = _ref.disableExit,
50
50
  setResolveAction = _ref.setResolveAction,
51
- setInfo = _ref.setInfo;
51
+ setInfo = _ref.setInfo,
52
+ pause = _ref.pause;
52
53
 
53
54
  var _useState = (0, _react.useState)({}),
54
55
  _useState2 = _slicedToArray(_useState, 2),
@@ -161,7 +162,8 @@ var FrameImageClickComponent = function FrameImageClickComponent(_ref) {
161
162
  emitResetPuzzle: resetPuzzle,
162
163
  setPuzzlesAutoCompleted: setPuzzlesAutoCompleted,
163
164
  puzzlesAutoCompleted: puzzlesAutoCompleted,
164
- emitOpenPopupCounterInfo: onInitPuzzle
165
+ emitOpenPopupCounterInfo: onInitPuzzle,
166
+ pause: pause
165
167
  };
166
168
  return /*#__PURE__*/_react.default.createElement("div", {
167
169
  className: "puzzle-frame"
@@ -88,7 +88,8 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
88
88
  emitResetPuzzle = props.emitResetPuzzle,
89
89
  firstTryForFrame = props.firstTryForFrame,
90
90
  puzzlesAutoCompleted = props.puzzlesAutoCompleted,
91
- emitOpenPopupCounterInfo = props.emitOpenPopupCounterInfo;
91
+ emitOpenPopupCounterInfo = props.emitOpenPopupCounterInfo,
92
+ pause = props.pause;
92
93
 
93
94
  var _useState = (0, _react.useState)([]),
94
95
  _useState2 = _slicedToArray(_useState, 2),
@@ -167,6 +168,13 @@ var ImageClickWrapperComponent = function ImageClickWrapperComponent(props) {
167
168
  shape: 'poly'
168
169
  }, area);
169
170
  });
171
+ (0, _react.useEffect)(function () {
172
+ if (pause) {
173
+ clearInterval(intervalForCountDown.current);
174
+ } else {
175
+ startCountDown();
176
+ }
177
+ }, [pause, startCountDown]);
170
178
  var startCountDown = (0, _react.useCallback)(function () {
171
179
  var timeout = setInterval(function () {
172
180
  setCountDownTime(function (t) {
@@ -47,7 +47,8 @@ var Container = function Container(_ref) {
47
47
  updateForm = _ref.updateForm,
48
48
  disabled = _ref.disabled,
49
49
  translate = _ref.translate,
50
- soundActions = _ref.soundActions;
50
+ soundActions = _ref.soundActions,
51
+ paused = _ref.paused;
51
52
 
52
53
  var _useState = (0, _react.useState)(0),
53
54
  _useState2 = _slicedToArray(_useState, 2),
@@ -65,7 +66,7 @@ var Container = function Container(_ref) {
65
66
  play = _soundActions[0];
66
67
 
67
68
  (0, _react.useEffect)(function () {
68
- if (time >= 0 && !disabled) {
69
+ if (time >= 0 && !disabled && !paused) {
69
70
  var timeout = setInterval(function () {
70
71
  if (!feedback) {
71
72
  setTime(function (t) {
@@ -80,7 +81,7 @@ var Container = function Container(_ref) {
80
81
  }
81
82
 
82
83
  return undefined;
83
- }, [disabled, feedback, saveInterval, setTime, time]);
84
+ }, [disabled, feedback, paused, saveInterval, setTime, time]);
84
85
 
85
86
  var nextPage = function nextPage() {
86
87
  play('click-ui');
@@ -52,7 +52,8 @@ var TestComponent = function TestComponent(_ref) {
52
52
  emitEvent = _ref.emitEvent,
53
53
  soundActions = _ref.soundActions,
54
54
  audio = _ref.audio,
55
- required = _ref.required;
55
+ required = _ref.required,
56
+ pause = _ref.pause;
56
57
  var questions = test.questions;
57
58
  var indicators = emitEvent({
58
59
  type: 'loadIndicators'
@@ -255,6 +256,7 @@ var TestComponent = function TestComponent(_ref) {
255
256
  tries: tries,
256
257
  answerPage: answerPage,
257
258
  setTime: setTime,
259
+ paused: pause,
258
260
  saveInterval: saveInterval,
259
261
  disabled: view !== 'test',
260
262
  answered: answeredPage || view !== 'test',
@@ -30,7 +30,7 @@ exports.yAxis = yAxis;
30
30
  var zAxis = new _three.Vector3(0, 0, 1);
31
31
  exports.zAxis = zAxis;
32
32
  var crossFadeDuration = 0.2;
33
- var bones = ['Jaw_M', 'Head_M', 'L_lip_jnt', 'R_lip_jnt', 'joint4', 'transform1', 'lowerTeeths', 'upperTeeths'];
33
+ var bones = ['Jaw_M', 'Head_M', 'L_lip_jnt', 'HeadEnd_M', 'Neck_M', 'R_lip_jnt', 'joint4', 'transform1', 'lowerTeeths', 'upperTeeths'];
34
34
  var loader = new _GLTFLoader.GLTFLoader();
35
35
 
36
36
  var formatMessage = function formatMessage(text) {
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.1.0",
5
+ "version": "2.2.0",
6
6
  "main": "dist/index.js",
7
7
  "files": [
8
8
  "dist",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@babel/runtime": "^7.18.6",
17
- "@gamelearn/arcade-styles": "2.1.0",
17
+ "@gamelearn/arcade-styles": "2.1.1",
18
18
  "@gamelearn/arcade-three-core": "1.17.1",
19
19
  "@react-three/drei": "9.4.3",
20
20
  "@react-three/fiber": "8.0.17",