@gamelearn/arcade-components 1.2.0 → 1.2.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.
@@ -88,7 +88,8 @@ var DialogComponent = function DialogComponent(_ref) {
88
88
  inScene: false,
89
89
  thinkful: false,
90
90
  voiceOver: false,
91
- avatar: ''
91
+ avatar: '',
92
+ show: false
92
93
  }),
93
94
  _useState6 = _slicedToArray(_useState5, 2),
94
95
  currentMessage = _useState6[0],
@@ -180,7 +181,7 @@ var DialogComponent = function DialogComponent(_ref) {
180
181
  }
181
182
  }
182
183
  }, _callee);
183
- })), [currentLine.voice, getVoice, currentMessage.text, emitEvent]);
184
+ })), [currentLine === null || currentLine === void 0 ? void 0 : currentLine.voice, getVoice, currentMessage.text, emitEvent]);
184
185
  var getCurrentVisible = (0, _react.useCallback)(function (uid) {
185
186
  var object;
186
187
  scene.traverseVisible(function (node) {
@@ -294,7 +295,7 @@ var DialogComponent = function DialogComponent(_ref) {
294
295
  camera.copy(defaultCamera.current);
295
296
  }, currentLine.decision ? 0 : 1200);
296
297
  }
297
- }, [camera, currentLine.decision, emitEvent, line, lines.length, resetAnims, resetCameraView]); // Position bubble over talking character/and switch emotions
298
+ }, [camera, currentLine === null || currentLine === void 0 ? void 0 : currentLine.decision, emitEvent, line, lines.length, resetAnims, resetCameraView]); // Position bubble over talking character/and switch emotions
298
299
 
299
300
  (0, _react.useEffect)(function () {
300
301
  if (currentLine.decision) {
@@ -308,7 +309,8 @@ var DialogComponent = function DialogComponent(_ref) {
308
309
  inScene: false,
309
310
  voiceOver: true,
310
311
  thinkful: false,
311
- avatar: ''
312
+ avatar: '',
313
+ show: true
312
314
  });
313
315
  } else if (!lastSet.current) {
314
316
  var talkingCharacter = currentLine.slots.find(function (slot) {
@@ -378,7 +380,8 @@ var DialogComponent = function DialogComponent(_ref) {
378
380
  left: true,
379
381
  inScene: true,
380
382
  thinkful: talkingCharacter.emotion === 'thinkful',
381
- avatar: ''
383
+ avatar: '',
384
+ show: true
382
385
  });
383
386
  }, zoomInActor ? 1200 : 0);
384
387
  }
@@ -394,9 +397,15 @@ var DialogComponent = function DialogComponent(_ref) {
394
397
  left: false,
395
398
  inScene: false,
396
399
  thinkful: talkingCharacter.emotion === 'thinkful',
397
- avatar: getAvatarURL(talkingCharacter)
400
+ avatar: getAvatarURL(talkingCharacter),
401
+ show: true
398
402
  });
399
403
  }
404
+ } else {
405
+ resetCameraView();
406
+ setCurrentMessage({
407
+ show: true
408
+ });
400
409
  }
401
410
  }
402
411
  }, [actors, camera, currentLine, zoomInActor, getCurrentVisible, translate, getAvatarURL, loadEmotion, resetAnims, resetCameraView]); // Sound logic
@@ -423,8 +432,13 @@ var DialogComponent = function DialogComponent(_ref) {
423
432
  if (autoPlay) {
424
433
  if (line >= lines.length - 1 && automatic) {
425
434
  setAutomatic(false);
426
- } else if (automatic && currentMessage.text && !currentLine.decision) {
427
- var time = 75 * (currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.text.length);
435
+ } else if (automatic && currentMessage.show && !currentLine.decision) {
436
+ var time = 0;
437
+
438
+ if (currentMessage.text) {
439
+ time = 75 * (currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.text.length);
440
+ }
441
+
428
442
  timeout = setTimeout(function () {
429
443
  nextLine();
430
444
  }, time < 1400 ? 1400 : time);
@@ -434,7 +448,7 @@ var DialogComponent = function DialogComponent(_ref) {
434
448
  return function () {
435
449
  if (timeout) clearTimeout(timeout);
436
450
  };
437
- }, [currentMessage, nextLine, autoPlay, lines.length, automatic, line, currentLine.decision, currentLine === null || currentLine === void 0 ? void 0 : currentLine.audioType, currentLine === null || currentLine === void 0 ? void 0 : (_currentLine$audio4 = currentLine.audio) === null || _currentLine$audio4 === void 0 ? void 0 : _currentLine$audio4.url]); // Positioning logic
451
+ }, [currentMessage, nextLine, autoPlay, lines.length, automatic, line, currentLine === null || currentLine === void 0 ? void 0 : currentLine.decision, currentLine === null || currentLine === void 0 ? void 0 : currentLine.audioType, currentLine === null || currentLine === void 0 ? void 0 : (_currentLine$audio4 = currentLine.audio) === null || _currentLine$audio4 === void 0 ? void 0 : _currentLine$audio4.url]); // Positioning logic
438
452
 
439
453
  var checkBubblePosition = (0, _react.useCallback)(function () {
440
454
  if (bubbleRef.current && currentLine.slots) {
@@ -470,7 +484,8 @@ var DialogComponent = function DialogComponent(_ref) {
470
484
  return _objectSpread(_objectSpread({}, old), {}, {
471
485
  left: false,
472
486
  inScene: !completeOutside,
473
- avatar: getAvatarURL(talkingCharacter)
487
+ avatar: getAvatarURL(talkingCharacter),
488
+ show: true
474
489
  });
475
490
  });
476
491
  }
@@ -478,7 +493,7 @@ var DialogComponent = function DialogComponent(_ref) {
478
493
  bubbleRef.current.parentNode.style.transform = '';
479
494
  }
480
495
  }
481
- }, [camera.quaternion, currentLine.slots, currentMessage.inScene, getAvatarURL]);
496
+ }, [camera.quaternion, currentLine === null || currentLine === void 0 ? void 0 : currentLine.slots, currentMessage.inScene, getAvatarURL]);
482
497
  (0, _react.useEffect)(function () {
483
498
  checkBubblePosition();
484
499
  }, [checkBubblePosition]); // Animate Camera
@@ -561,7 +576,7 @@ var DialogComponent = function DialogComponent(_ref) {
561
576
  }, decisionPayload)));
562
577
  }
563
578
 
564
- return currentMessage.text ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("group", {
579
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, currentMessage.text ? /*#__PURE__*/_react.default.createElement("group", {
565
580
  ref: groupRef,
566
581
  position: messagePosition.current.pos
567
582
  }, /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.HtmlPro, {
@@ -575,7 +590,7 @@ var DialogComponent = function DialogComponent(_ref) {
575
590
  }, /*#__PURE__*/_react.default.createElement(_SpeechBubbleComponent.default, {
576
591
  ref: bubbleRef,
577
592
  message: currentMessage
578
- }))), /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.HtmlPro, {
593
+ }))) : null, currentMessage.show ? /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.HtmlPro, {
579
594
  style: {
580
595
  width: '100vw',
581
596
  height: '100vh'
@@ -600,7 +615,7 @@ var DialogComponent = function DialogComponent(_ref) {
600
615
  onClick: nextLine
601
616
  }, /*#__PURE__*/_react.default.createElement("span", {
602
617
  className: "icon-next"
603
- }))))) : null;
618
+ })))) : null);
604
619
  };
605
620
 
606
621
  var _default = DialogComponent;
@@ -148,7 +148,7 @@ var TestComponent = function TestComponent(_ref) {
148
148
 
149
149
  (0, _react.useEffect)(function () {
150
150
  if (audio !== null && audio !== void 0 && audio.url) {
151
- playSound(audio.url);
151
+ playSound(audio.url, 'test_bg');
152
152
  }
153
153
  }, [playSound, audio]);
154
154
  (0, _react.useEffect)(function () {
@@ -169,7 +169,7 @@ var TestComponent = function TestComponent(_ref) {
169
169
  answerPage(false);
170
170
  setTimeOver(true);
171
171
  changeView('results');
172
- stop();
172
+ stop('test_bg');
173
173
  }
174
174
  }, [interval, stop, time]);
175
175
 
@@ -186,7 +186,7 @@ var TestComponent = function TestComponent(_ref) {
186
186
  }
187
187
  });
188
188
  setShowingResult(parsedShowingResult);
189
- stop();
189
+ stop('test_bg');
190
190
  };
191
191
 
192
192
  var finishTest = function finishTest() {
@@ -225,7 +225,7 @@ var TestComponent = function TestComponent(_ref) {
225
225
  setResult({});
226
226
  setTime(countdown.time);
227
227
  setTimeOver(false);
228
- stop();
228
+ stop('test_bg');
229
229
  };
230
230
 
231
231
  var translate = function translate(id, values) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gamelearn/arcade-components",
3
3
  "license": "Gamelearn",
4
- "version": "1.2.0",
4
+ "version": "1.2.2",
5
5
  "main": "dist/index.js",
6
6
  "files": [
7
7
  "dist",