@gamelearn/arcade-components 2.41.0 → 3.0.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.
- package/README.md +8 -5
- package/dist/arcade-components.cjs +91984 -0
- package/dist/arcade-components.js +91968 -0
- package/package.json +74 -73
- package/dist/components/animation-component/components/AnimationComponent.js +0 -98
- package/dist/components/animation-component/index.js +0 -10
- package/dist/components/animation-component/mocks/mockForStory.js +0 -26
- package/dist/components/auto-evaluation-component/components/AutoEvaluation.js +0 -215
- package/dist/components/auto-evaluation-component/components/EndScreen.js +0 -43
- package/dist/components/auto-evaluation-component/components/StartScreen.js +0 -32
- package/dist/components/auto-evaluation-component/index.js +0 -10
- package/dist/components/auto-evaluation-component/mocks/mockForStory.js +0 -38
- package/dist/components/cards-selector-puzzle-component/components/Board/index.js +0 -159
- package/dist/components/cards-selector-puzzle-component/components/Card/index.js +0 -115
- package/dist/components/cards-selector-puzzle-component/components/CardsSelectorPuzzleComponent.js +0 -289
- package/dist/components/cards-selector-puzzle-component/index.js +0 -10
- package/dist/components/cards-selector-puzzle-component/mocks/mockForStory.js +0 -446
- package/dist/components/cartel-component/components/CartelComponent.js +0 -124
- package/dist/components/cartel-component/index.js +0 -10
- package/dist/components/chained-image-click-puzzle-component/components/ChainedImageClickPuzzleComponent.js +0 -80
- package/dist/components/chained-image-click-puzzle-component/components/CurrentImagePuzzle.js +0 -182
- package/dist/components/chained-image-click-puzzle-component/index.js +0 -10
- package/dist/components/chained-image-click-puzzle-component/mocks/mockForStory.js +0 -413
- package/dist/components/comic-component/components/ComicComponent.js +0 -201
- package/dist/components/comic-component/components/Slide.js +0 -31
- package/dist/components/comic-component/components/Vignette.js +0 -70
- package/dist/components/comic-component/index.js +0 -10
- package/dist/components/comic-component/mocks/mockForStory.js +0 -314
- package/dist/components/conversational-component/components/ConversationalComponent.js +0 -101
- package/dist/components/conversational-component/index.js +0 -10
- package/dist/components/conversational-pro-component/components/ConversationalProComponent.js +0 -543
- package/dist/components/conversational-pro-component/components/Message.js +0 -37
- package/dist/components/conversational-pro-component/components/Slot.js +0 -92
- package/dist/components/conversational-pro-component/components/SlotList.js +0 -162
- package/dist/components/conversational-pro-component/components/scene/Panel.js +0 -179
- package/dist/components/conversational-pro-component/components/scene/Panels.js +0 -46
- package/dist/components/conversational-pro-component/components/scene/index.js +0 -77
- package/dist/components/conversational-pro-component/index.js +0 -10
- package/dist/components/conversational-pro-component/mocks/mockForStory.js +0 -1529
- package/dist/components/cracker-puzzle-component/components/CrackerPuzzleComponent.js +0 -261
- package/dist/components/cracker-puzzle-component/components/DrawGrid/index.js +0 -33
- package/dist/components/cracker-puzzle-component/components/DrawItem/index.js +0 -48
- package/dist/components/cracker-puzzle-component/components/DrawRow/index.js +0 -43
- package/dist/components/cracker-puzzle-component/components/colors.js +0 -12
- package/dist/components/cracker-puzzle-component/components/helpers.js +0 -133
- package/dist/components/cracker-puzzle-component/index.js +0 -10
- package/dist/components/cracker-puzzle-component/mocks/mockForStory.js +0 -277
- package/dist/components/decision-component/components/DecisionBody.js +0 -116
- package/dist/components/decision-component/components/DecisionComponent.js +0 -248
- package/dist/components/decision-component/components/Feedback.js +0 -40
- package/dist/components/decision-component/components/Options.js +0 -74
- package/dist/components/decision-component/index.js +0 -10
- package/dist/components/decision-component/mocks/mockForStory.js +0 -166
- package/dist/components/dialog-component/components/BubbleWrapper.js +0 -39
- package/dist/components/dialog-component/components/DialogComponent.js +0 -779
- package/dist/components/dialog-component/components/DialogDecision.js +0 -44
- package/dist/components/dialog-component/components/SpeechBubbleComponent.js +0 -66
- package/dist/components/dialog-component/index.js +0 -10
- package/dist/components/dialog-component/mocks/mockForStory.js +0 -550
- package/dist/components/drag-item-puzzle-component/components/DragItemPuzzleComponent.js +0 -359
- package/dist/components/drag-item-puzzle-component/index.js +0 -10
- package/dist/components/drag-item-puzzle-component/mocks/mockForStory.js +0 -74
- package/dist/components/feedback-component/components/FeedbackComponent.js +0 -126
- package/dist/components/feedback-component/index.js +0 -10
- package/dist/components/feedback-component/mocks/mockForStory.js +0 -52
- package/dist/components/frame-click-puzzle-component/components/Counter/index.js +0 -24
- package/dist/components/frame-click-puzzle-component/components/CurrentFramePuzzle.js +0 -196
- package/dist/components/frame-click-puzzle-component/components/FrameClickPuzzleComponent.js +0 -178
- package/dist/components/frame-click-puzzle-component/components/Tooltip/index.js +0 -23
- package/dist/components/frame-click-puzzle-component/index.js +0 -10
- package/dist/components/frame-click-puzzle-component/mocks/mockForStory.js +0 -717
- package/dist/components/hacker-puzzle-component/components/HackerPuzzleComponent.js +0 -255
- package/dist/components/hacker-puzzle-component/components/languages.js +0 -13
- package/dist/components/hacker-puzzle-component/index.js +0 -10
- package/dist/components/hacker-puzzle-component/mocks/mockForStory.js +0 -103
- package/dist/components/hanged-puzzle-component/components/HangedPuzzleComponent.js +0 -488
- package/dist/components/hanged-puzzle-component/index.js +0 -10
- package/dist/components/hanged-puzzle-component/mocks/mockForStory.js +0 -61
- package/dist/components/hanged-puzzle-component/utils.js +0 -64
- package/dist/components/image-click-puzzle-component/components/ImageClickPuzzleComponent.js +0 -40
- package/dist/components/image-click-puzzle-component/index.js +0 -10
- package/dist/components/image-click-puzzle-component/mocks/mockForStory.js +0 -427
- package/dist/components/image-click-wrapper-component/components/CountDown/index.js +0 -18
- package/dist/components/image-click-wrapper-component/components/ImageClickWrapperComponent.js +0 -472
- package/dist/components/image-click-wrapper-component/components/TimerDialog/index.js +0 -26
- package/dist/components/image-click-wrapper-component/index.js +0 -10
- package/dist/components/image-click-wrapper-component/mocks/mockForStory.js +0 -432
- package/dist/components/image-component/components/ImageComponent.js +0 -83
- package/dist/components/image-component/index.js +0 -10
- package/dist/components/image-component/mocks/mockForStory.js +0 -52
- package/dist/components/index.js +0 -260
- package/dist/components/inventory-item/components/InventoryItem.js +0 -120
- package/dist/components/inventory-item/index.js +0 -10
- package/dist/components/inventory-item/mocks/mockForStory.js +0 -29
- package/dist/components/keyboard-puzzle-component/components/KeyboardPuzzleComponent.js +0 -275
- package/dist/components/keyboard-puzzle-component/index.js +0 -10
- package/dist/components/keyboard-puzzle-component/mocks/mockForStory.js +0 -40
- package/dist/components/konva-components/Area/index.js +0 -170
- package/dist/components/konva-components/KonvaMapper.js +0 -185
- package/dist/components/lectures-component/components/LectureButtons.js +0 -40
- package/dist/components/lectures-component/components/LecturesComponent.js +0 -157
- package/dist/components/lectures-component/index.js +0 -10
- package/dist/components/lectures-component/mocks/mockForStory.js +0 -39
- package/dist/components/login-puzzle-component/components/LoginPuzzleComponent.js +0 -243
- package/dist/components/login-puzzle-component/index.js +0 -10
- package/dist/components/login-puzzle-component/mocks/mockForStory.js +0 -38
- package/dist/components/notice-component/components/NoticeComponent.js +0 -96
- package/dist/components/notice-component/index.js +0 -10
- package/dist/components/notice-component/mocks/mockForStory.js +0 -20
- package/dist/components/pattern-component/components/PatternComponent.js +0 -78
- package/dist/components/pattern-component/index.js +0 -10
- package/dist/components/pattern-component/mocks/mockForStory.js +0 -35
- package/dist/components/pdf-component/components/PdfComponent.js +0 -122
- package/dist/components/pdf-component/components/PdfVisor.js +0 -187
- package/dist/components/pdf-component/index.js +0 -20
- package/dist/components/pdf-component/mocks/mockForProps.js +0 -38
- package/dist/components/referral-component/components/EmailPill.js +0 -26
- package/dist/components/referral-component/components/ReferralComponent.js +0 -115
- package/dist/components/referral-component/components/StepOne.js +0 -170
- package/dist/components/referral-component/components/StepTwo.js +0 -57
- package/dist/components/referral-component/index.js +0 -10
- package/dist/components/referral-component/mocks/mockForStory.js +0 -40
- package/dist/components/survey-component/components/ApplicableBox.js +0 -49
- package/dist/components/survey-component/components/OpinionBox.js +0 -45
- package/dist/components/survey-component/components/SurveyComponent.js +0 -150
- package/dist/components/survey-component/components/TextBox.js +0 -40
- package/dist/components/survey-component/index.js +0 -10
- package/dist/components/survey-component/mocks/mockForStory.js +0 -14
- package/dist/components/terminal-puzzle-component/components/FilesGroup/Item.js +0 -28
- package/dist/components/terminal-puzzle-component/components/FilesGroup/index.js +0 -76
- package/dist/components/terminal-puzzle-component/components/Image/index.js +0 -22
- package/dist/components/terminal-puzzle-component/components/TerminalPuzzleComponent.js +0 -216
- package/dist/components/terminal-puzzle-component/components/Visor/index.js +0 -129
- package/dist/components/terminal-puzzle-component/components/utils/index.js +0 -26
- package/dist/components/terminal-puzzle-component/index.js +0 -10
- package/dist/components/terminal-puzzle-component/mocks/mockForStory.js +0 -188
- package/dist/components/test-component/components/Container.js +0 -211
- package/dist/components/test-component/components/Feedbacks.js +0 -48
- package/dist/components/test-component/components/Questions.js +0 -145
- package/dist/components/test-component/components/Results.js +0 -208
- package/dist/components/test-component/components/TestComponent.js +0 -302
- package/dist/components/test-component/index.js +0 -10
- package/dist/components/test-component/mocks/mockForStory.js +0 -113
- package/dist/components/text-click-puzzle-component/components/TextClickPuzzleComponent.js +0 -387
- package/dist/components/text-click-puzzle-component/index.js +0 -10
- package/dist/components/text-click-puzzle-component/mocks/mockForStory.js +0 -485
- package/dist/components/text-click-puzzle-component/utils/index.js +0 -76
- package/dist/components/url-component/components/UrlComponent.js +0 -88
- package/dist/components/url-component/index.js +0 -10
- package/dist/components/url-component/mocks/mockForProps.js +0 -20
- package/dist/components/video-component/components/VideoComponent.js +0 -73
- package/dist/components/video-component/index.js +0 -10
- package/dist/components/video-component/mocks/mockForStory.js +0 -94
- package/dist/components/video-visor/components/VideoControllers/BufferBar.js +0 -108
- package/dist/components/video-visor/components/VideoControllers/ControlButtons.js +0 -31
- package/dist/components/video-visor/components/VideoControllers/FinishedVideoButtons.js +0 -32
- package/dist/components/video-visor/components/VideoControllers/PlayInitButton.js +0 -37
- package/dist/components/video-visor/components/VideoControllers/SkipButton.js +0 -37
- package/dist/components/video-visor/components/VideoControllers/Timer.js +0 -37
- package/dist/components/video-visor/components/VideoControllers/VolumeBar.js +0 -92
- package/dist/components/video-visor/components/VideoControllers/index.js +0 -122
- package/dist/components/video-visor/components/VideoVisor.js +0 -271
- package/dist/components/video-visor/index.js +0 -10
- package/dist/components/video-visor/mocks/mockForStory.js +0 -42
- package/dist/components/web-builder-puzzle-component/Popups/PopupColorComponent/index.js +0 -87
- package/dist/components/web-builder-puzzle-component/Popups/PopupImageComponent/index.js +0 -94
- package/dist/components/web-builder-puzzle-component/Popups/PopupTextComponent/index.js +0 -114
- package/dist/components/web-builder-puzzle-component/Popups/index.js +0 -27
- package/dist/components/web-builder-puzzle-component/Templates/Bank.js +0 -98
- package/dist/components/web-builder-puzzle-component/Templates/Facebook.js +0 -37
- package/dist/components/web-builder-puzzle-component/Templates/resourcePath.js +0 -9
- package/dist/components/web-builder-puzzle-component/components/EditButton/index.js +0 -28
- package/dist/components/web-builder-puzzle-component/components/Feedback/index.js +0 -41
- package/dist/components/web-builder-puzzle-component/components/PublishButton/index.js +0 -29
- package/dist/components/web-builder-puzzle-component/components/WebBuilderBody/BankBody.js +0 -118
- package/dist/components/web-builder-puzzle-component/components/WebBuilderBody/FacebookBody.js +0 -149
- package/dist/components/web-builder-puzzle-component/components/WebBuilderBody/index.js +0 -25
- package/dist/components/web-builder-puzzle-component/components/WebBuilderFront/index.js +0 -89
- package/dist/components/web-builder-puzzle-component/components/WebBuilderHeader/BankHeader.js +0 -84
- package/dist/components/web-builder-puzzle-component/components/WebBuilderHeader/FacebookHeader.js +0 -38
- package/dist/components/web-builder-puzzle-component/components/WebBuilderHeader/index.js +0 -40
- package/dist/components/web-builder-puzzle-component/components/WebBuilderPuzzleComponent.js +0 -302
- package/dist/components/web-builder-puzzle-component/components/WebBuilderTopBar/index.js +0 -30
- package/dist/components/web-builder-puzzle-component/index.js +0 -10
- package/dist/components/web-builder-puzzle-component/mocks/mockForStory.js +0 -27
- package/dist/components/writer-puzzle-component/components/ElectionComponent.js +0 -69
- package/dist/components/writer-puzzle-component/components/FeedbackComponent.js +0 -97
- package/dist/components/writer-puzzle-component/components/FeedbackElement.js +0 -32
- package/dist/components/writer-puzzle-component/components/FinishedTextComponent.js +0 -25
- package/dist/components/writer-puzzle-component/components/FixedComponent.js +0 -120
- package/dist/components/writer-puzzle-component/components/SingleElection.js +0 -85
- package/dist/components/writer-puzzle-component/components/WriterPuzzleComponent.js +0 -450
- package/dist/components/writer-puzzle-component/index.js +0 -10
- package/dist/components/writer-puzzle-component/mocks/mockForStory.js +0 -1194
- package/dist/components/zoom-test/components/ZoomTest.js +0 -73
- package/dist/components/zoom-test/index.js +0 -10
- package/dist/components/zoom-test/mocks/mockForStory.js +0 -21
- package/dist/helpers/LangIsRtl.js +0 -16
- package/dist/helpers/LightSet.js +0 -35
- package/dist/helpers/LodController.js +0 -28
- package/dist/helpers/deviceDetection.js +0 -21
- package/dist/helpers/drawLOD.js +0 -310
- package/dist/helpers/index.js +0 -268
- package/dist/helpers/lodStats.js +0 -55
- package/dist/helpers/mocker.js +0 -116
- package/dist/helpers/useEkho.js +0 -172
- package/dist/helpers/useGLB.js +0 -57
- package/dist/helpers/useStateMachine.js +0 -277
- package/dist/helpers/useTimeout.js +0 -32
- package/dist/helpers/useWindowSize.js +0 -44
- package/dist/index.js +0 -16
- package/dist/test/testSceneWrapper.js +0 -31
|
@@ -1,779 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
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
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _fiber = require("@react-three/fiber");
|
|
10
|
-
var _three = require("three");
|
|
11
|
-
var _arcadeThreeCore = require("@gamelearn/arcade-three-core");
|
|
12
|
-
var _gsap = _interopRequireDefault(require("gsap"));
|
|
13
|
-
var _useTimeout2 = _interopRequireDefault(require("../../../helpers/useTimeout"));
|
|
14
|
-
var _useEkho = _interopRequireDefault(require("../../../helpers/useEkho"));
|
|
15
|
-
var _LangIsRtl = _interopRequireDefault(require("../../../helpers/LangIsRtl"));
|
|
16
|
-
var _BubbleWrapper = _interopRequireDefault(require("./BubbleWrapper"));
|
|
17
|
-
var _DialogDecision = _interopRequireDefault(require("./DialogDecision"));
|
|
18
|
-
var _useStateMachine2 = _interopRequireDefault(require("../../../helpers/useStateMachine"));
|
|
19
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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); }
|
|
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; }
|
|
22
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
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."); }
|
|
24
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
25
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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; }
|
|
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; }
|
|
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); }
|
|
31
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
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."); }
|
|
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); }
|
|
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 */
|
|
37
|
-
var characterMs = 75;
|
|
38
|
-
var minMs = 1400;
|
|
39
|
-
var headSize = 2;
|
|
40
|
-
var raycast = new _three.Raycaster();
|
|
41
|
-
var animationTarget = new _three.Object3D();
|
|
42
|
-
var maxCharacterToSwitch = 70;
|
|
43
|
-
raycast.firstHitOnly = true;
|
|
44
|
-
var DialogComponent = function DialogComponent(_ref) {
|
|
45
|
-
var _currentLineData$slot;
|
|
46
|
-
var keyboardControl = _ref.keyboardControl,
|
|
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
|
-
autoEnd = _ref.autoEnd,
|
|
55
|
-
pause = _ref.pause,
|
|
56
|
-
progress = _ref.progress;
|
|
57
|
-
var defaultLine = (progress === null || progress === void 0 ? void 0 : progress.line) || 0;
|
|
58
|
-
var _useState = (0, _react.useState)(defaultLine),
|
|
59
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
60
|
-
line = _useState2[0],
|
|
61
|
-
changeLine = _useState2[1];
|
|
62
|
-
var _useState3 = (0, _react.useState)(!!autoPlay),
|
|
63
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
64
|
-
automatic = _useState4[0],
|
|
65
|
-
setAutomatic = _useState4[1];
|
|
66
|
-
var _useState5 = (0, _react.useState)(false),
|
|
67
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
68
|
-
mounted = _useState6[0],
|
|
69
|
-
setMounted = _useState6[1];
|
|
70
|
-
var _useState7 = (0, _react.useState)(false),
|
|
71
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
72
|
-
audioFailed = _useState8[0],
|
|
73
|
-
setAudioFailed = _useState8[1];
|
|
74
|
-
var scene = (0, _fiber.useThree)(function (state) {
|
|
75
|
-
return state.scene;
|
|
76
|
-
});
|
|
77
|
-
var camera = (0, _fiber.useThree)(function (state) {
|
|
78
|
-
return state.camera;
|
|
79
|
-
});
|
|
80
|
-
var _useTimeout = (0, _useTimeout2.default)(),
|
|
81
|
-
start = _useTimeout.start,
|
|
82
|
-
stop = _useTimeout.stop;
|
|
83
|
-
var changedMats = (0, _react.useRef)([]);
|
|
84
|
-
var defaultCamera = (0, _react.useMemo)(function () {
|
|
85
|
-
return camera.clone();
|
|
86
|
-
}, []);
|
|
87
|
-
var actualCamera = (0, _react.useRef)(camera);
|
|
88
|
-
var messagePosition = (0, _react.useRef)({
|
|
89
|
-
pos: [0, 0, 0],
|
|
90
|
-
child: null
|
|
91
|
-
});
|
|
92
|
-
var currentLineData = lines[line];
|
|
93
|
-
var lastLine = lines[line - 1];
|
|
94
|
-
var lastSet = (0, _react.useRef)(false);
|
|
95
|
-
var isBranched = !!edges;
|
|
96
|
-
var onZoomEnd = (0, _react.useRef)(function () {});
|
|
97
|
-
var _ref2 = currentLineData || {},
|
|
98
|
-
voiceOver = _ref2.voiceOver,
|
|
99
|
-
decision = _ref2.decision;
|
|
100
|
-
var lastTalking = (0, _react.useRef)({});
|
|
101
|
-
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) {
|
|
102
|
-
return slot.talking;
|
|
103
|
-
});
|
|
104
|
-
var zoomStarted = (0, _react.useRef)(false);
|
|
105
|
-
var _useStateMachine = (0, _useStateMachine2.default)(lines),
|
|
106
|
-
startAnimation = _useStateMachine.startAnimation,
|
|
107
|
-
resetActives = _useStateMachine.resetActives;
|
|
108
|
-
var autoPlayCond = automatic && !(currentLineData !== null && currentLineData !== void 0 && currentLineData.decision);
|
|
109
|
-
var audio = Object.keys((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audio) || {}).length;
|
|
110
|
-
var voice = Object.keys((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.voice) || {}).length;
|
|
111
|
-
var isVoiceOver = voiceOver || (currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.type) === 'conversationalNarration';
|
|
112
|
-
var isDecision = decision || (currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.type) === 'conversationalDecision';
|
|
113
|
-
|
|
114
|
-
// Force camera update (r3f selector not updating)
|
|
115
|
-
(0, _fiber.useFrame)(function (_ref3) {
|
|
116
|
-
var sceneCam = _ref3.camera;
|
|
117
|
-
actualCamera.current = sceneCam;
|
|
118
|
-
});
|
|
119
|
-
var _useState9 = (0, _react.useState)({
|
|
120
|
-
text: '',
|
|
121
|
-
name: '',
|
|
122
|
-
inScene: false,
|
|
123
|
-
thinkful: false,
|
|
124
|
-
voiceOver: false,
|
|
125
|
-
avatar: '',
|
|
126
|
-
show: false
|
|
127
|
-
}),
|
|
128
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
129
|
-
currentMessage = _useState10[0],
|
|
130
|
-
setCurrentMessage = _useState10[1];
|
|
131
|
-
var charactersInvolved = (0, _react.useMemo)(function () {
|
|
132
|
-
return lines.reduce(function (acc, current) {
|
|
133
|
-
if (current.slots) {
|
|
134
|
-
var participants = current.slots.filter(function (slot) {
|
|
135
|
-
return slot.uid;
|
|
136
|
-
});
|
|
137
|
-
participants.forEach(function (currentParticipant) {
|
|
138
|
-
if (!acc.includes(currentParticipant.uid)) acc.push(currentParticipant.uid);
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
return acc;
|
|
142
|
-
}, []);
|
|
143
|
-
}, [lines]);
|
|
144
|
-
var translate = (0, _react.useCallback)(function (id) {
|
|
145
|
-
return emitEvent({
|
|
146
|
-
type: 'translate',
|
|
147
|
-
payload: id
|
|
148
|
-
});
|
|
149
|
-
}, [emitEvent]);
|
|
150
|
-
var _useState11 = (0, _react.useState)([]),
|
|
151
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
|
152
|
-
edgesHistory = _useState12[0],
|
|
153
|
-
setEdgesHistory = _useState12[1];
|
|
154
|
-
var lastNodeId = (0, _react.useMemo)(function () {
|
|
155
|
-
return edgesHistory[edgesHistory.length - 1];
|
|
156
|
-
}, [edgesHistory]);
|
|
157
|
-
var findLastLineBranched = (0, _react.useCallback)(function () {
|
|
158
|
-
var lastEdge = edges.find(function (edge) {
|
|
159
|
-
return edge.fromId === lastNodeId;
|
|
160
|
-
}) || edges.find(function (edge) {
|
|
161
|
-
return edge.toId === lastNodeId;
|
|
162
|
-
});
|
|
163
|
-
var lastL = lines.find(function (l) {
|
|
164
|
-
return l.id === (lastEdge === null || lastEdge === void 0 ? void 0 : lastEdge.fromId);
|
|
165
|
-
});
|
|
166
|
-
if (!lastNodeId && (progress === null || progress === void 0 ? void 0 : progress.line) >= 0) {
|
|
167
|
-
return {
|
|
168
|
-
decision: true
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
return lastL;
|
|
172
|
-
}, [edges, lines, lastNodeId]);
|
|
173
|
-
var previousLineWasDecision = (0, _react.useCallback)(function () {
|
|
174
|
-
if (isBranched) {
|
|
175
|
-
// if we have edges, we need to check if the previous line was a decision
|
|
176
|
-
var _lastL = findLastLineBranched();
|
|
177
|
-
return _lastL === null || _lastL === void 0 ? void 0 : _lastL.decision;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// if there is no branching, the previous line is the previous one
|
|
181
|
-
var lastL = lines[line - 1] ? lines[line - 1] : {};
|
|
182
|
-
return line > 0 && (lastL === null || lastL === void 0 ? void 0 : lastL.decision);
|
|
183
|
-
}, [currentLineData, isBranched, lines, lastNodeId, edges]);
|
|
184
|
-
var getCurrentVisible = (0, _react.useCallback)(function (uid) {
|
|
185
|
-
if (!uid) return null;
|
|
186
|
-
var object;
|
|
187
|
-
scene.traverseVisible(function (node) {
|
|
188
|
-
if (node.uid === uid && !object) {
|
|
189
|
-
object = node;
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
return object;
|
|
193
|
-
}, [scene]);
|
|
194
|
-
var getAvatarURL = (0, _react.useCallback)(function (slot) {
|
|
195
|
-
var _slot$character, _slot$character$resou;
|
|
196
|
-
var object = actors.find(function (element) {
|
|
197
|
-
if ((element === null || element === void 0 ? void 0 : element.uid) === (slot === null || slot === void 0 ? void 0 : slot.uid)) {
|
|
198
|
-
return element;
|
|
199
|
-
}
|
|
200
|
-
return '';
|
|
201
|
-
});
|
|
202
|
-
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) || '';
|
|
203
|
-
}, [actors]);
|
|
204
|
-
|
|
205
|
-
// Starts camera transition
|
|
206
|
-
var animateCameraTransition = function animateCameraTransition() {
|
|
207
|
-
if (!zoomStarted.current) {
|
|
208
|
-
var cam = actualCamera.current;
|
|
209
|
-
var targetPosition = messagePosition.current.child ? messagePosition.current.pos : defaultCamera.position.toArray();
|
|
210
|
-
animationTarget.position.fromArray(targetPosition);
|
|
211
|
-
if (messagePosition.current.parent) {
|
|
212
|
-
if (!animationTarget.quaternion.equals(cam.quaternion)) {
|
|
213
|
-
animationTarget.applyQuaternion(cam.quaternion);
|
|
214
|
-
}
|
|
215
|
-
var mult = messagePosition.current.isLeft ? -1 : 1;
|
|
216
|
-
var headSpace = headSize * mult;
|
|
217
|
-
animationTarget.translateX(-10 * mult + headSpace);
|
|
218
|
-
animationTarget.translateY(-2);
|
|
219
|
-
animationTarget.translateZ(30);
|
|
220
|
-
}
|
|
221
|
-
_gsap.default.to(cam.position, _objectSpread({
|
|
222
|
-
duration: 0.9,
|
|
223
|
-
ease: 'power3.easeInOut',
|
|
224
|
-
onStart: function onStart() {
|
|
225
|
-
zoomStarted.current = true;
|
|
226
|
-
},
|
|
227
|
-
onUpdate: function onUpdate() {
|
|
228
|
-
if (changedMats.current.length) {
|
|
229
|
-
changedMats.current.forEach(function (o) {
|
|
230
|
-
var object = o.object;
|
|
231
|
-
object.material.visible = true;
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
},
|
|
235
|
-
onComplete: function onComplete() {
|
|
236
|
-
if (onZoomEnd.current) {
|
|
237
|
-
onZoomEnd.current();
|
|
238
|
-
onZoomEnd.current = null;
|
|
239
|
-
}
|
|
240
|
-
raycast.set(cam.getWorldPosition(new _three.Vector3(0, 0, 0)), cam.getWorldDirection(new _three.Vector3()));
|
|
241
|
-
var objects = raycast.intersectObjects(scene.children, true);
|
|
242
|
-
changedMats.current = objects.filter(function (o) {
|
|
243
|
-
return o.distance < 10;
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
// Make objects invisible in front of the camera
|
|
247
|
-
if (changedMats.current.length) {
|
|
248
|
-
changedMats.current.forEach(function (o) {
|
|
249
|
-
var object = o.object;
|
|
250
|
-
object.material.side = 0;
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
zoomStarted.current = false;
|
|
254
|
-
if (lastSet.current) {
|
|
255
|
-
emitEvent({
|
|
256
|
-
type: 'success'
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
if (!messagePosition.current.child) {
|
|
260
|
-
cam.copy(defaultCamera);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}, animationTarget.position));
|
|
264
|
-
} else if (zoomStarted.current) {
|
|
265
|
-
zoomStarted.current = false;
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
var resetCameraView = (0, _react.useCallback)(function () {
|
|
269
|
-
messagePosition.current.child = null;
|
|
270
|
-
messagePosition.current.parent = null;
|
|
271
|
-
if (zoomInActor) {
|
|
272
|
-
animateCameraTransition();
|
|
273
|
-
}
|
|
274
|
-
}, [zoomInActor]);
|
|
275
|
-
var startTalking = function startTalking() {
|
|
276
|
-
if (!(talkingCharacter !== null && talkingCharacter !== void 0 && talkingCharacter.emotion) || lastSet.current) return;
|
|
277
|
-
var emotion = talkingCharacter.emotion,
|
|
278
|
-
uid = talkingCharacter.uid;
|
|
279
|
-
var sceneElement = getCurrentVisible(uid);
|
|
280
|
-
if (sceneElement) {
|
|
281
|
-
var isSeated = sceneElement.isSeated;
|
|
282
|
-
var includesSeated = emotion.includes('seated');
|
|
283
|
-
startAnimation(uid, isSeated && !includesSeated ? "".concat(emotion, "-seated_talking") : "".concat(emotion, "_talking"));
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
var resetTalkingAnimation = function resetTalkingAnimation() {
|
|
287
|
-
if (!(talkingCharacter !== null && talkingCharacter !== void 0 && talkingCharacter.uid) || lastSet.current) return;
|
|
288
|
-
var emotion = talkingCharacter.emotion,
|
|
289
|
-
uid = talkingCharacter.uid;
|
|
290
|
-
var sceneElement = getCurrentVisible(uid);
|
|
291
|
-
if (sceneElement) {
|
|
292
|
-
var isSeated = sceneElement.isSeated;
|
|
293
|
-
var includesSeated = emotion.includes('seated');
|
|
294
|
-
startAnimation(uid, isSeated && !includesSeated ? "".concat(emotion, "-seated") : emotion);
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
var finishConversation = (0, _react.useCallback)(function () {
|
|
298
|
-
lastSet.current = true;
|
|
299
|
-
changeLine(0);
|
|
300
|
-
setCurrentMessage({
|
|
301
|
-
show: false
|
|
302
|
-
});
|
|
303
|
-
resetCameraView();
|
|
304
|
-
resetActives();
|
|
305
|
-
if (!zoomInActor) {
|
|
306
|
-
emitEvent({
|
|
307
|
-
type: 'success'
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
}, [camera, emitEvent, resetCameraView, zoomInActor]);
|
|
311
|
-
|
|
312
|
-
// Reset anim after unmount
|
|
313
|
-
(0, _react.useEffect)(function () {
|
|
314
|
-
return function () {
|
|
315
|
-
lastTalking.current = {};
|
|
316
|
-
};
|
|
317
|
-
}, []);
|
|
318
|
-
var handleBranchDirection = (0, _react.useCallback)(function () {
|
|
319
|
-
var forward = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
320
|
-
var keys = forward ? ['fromId', 'toId'] : ['toId', 'fromId'];
|
|
321
|
-
var foundEdges = edges.filter(function (edge) {
|
|
322
|
-
return edge[keys[0]] === currentLineData.id;
|
|
323
|
-
});
|
|
324
|
-
var foundEdge = foundEdges.length === 1 ? foundEdges[0] : foundEdges.find(function (edge) {
|
|
325
|
-
return edge[keys[1]] === lastNodeId;
|
|
326
|
-
});
|
|
327
|
-
if (!(foundEdge !== null && foundEdge !== void 0 && foundEdge[keys[0]])) {
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
// if going backwards remove last edge from history
|
|
331
|
-
if (!forward) {
|
|
332
|
-
setEdgesHistory(edgesHistory.slice(0, edgesHistory.length - 1));
|
|
333
|
-
}
|
|
334
|
-
var destination = lines.findIndex(function (l) {
|
|
335
|
-
return l.id === foundEdge[keys[1]];
|
|
336
|
-
});
|
|
337
|
-
if (destination >= 0) {
|
|
338
|
-
setCurrentMessage({
|
|
339
|
-
show: false
|
|
340
|
-
});
|
|
341
|
-
changeLine(destination);
|
|
342
|
-
emitEvent({
|
|
343
|
-
type: 'notifyProgress',
|
|
344
|
-
payload: {
|
|
345
|
-
line: destination
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
} else {
|
|
349
|
-
finishConversation();
|
|
350
|
-
}
|
|
351
|
-
}, [currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.id, emitEvent, edges, finishConversation, lines]);
|
|
352
|
-
var handleDecisionBranch = (0, _react.useCallback)(function (choice, reset) {
|
|
353
|
-
var currentId = [3, 2, 1][choice.id];
|
|
354
|
-
var optionsEdges = edges.filter(function (edge) {
|
|
355
|
-
return edge.fromId === (currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.id);
|
|
356
|
-
});
|
|
357
|
-
var currentEdge = optionsEdges.find(function (edge) {
|
|
358
|
-
return parseInt(edge.fromPointIndex) === currentId;
|
|
359
|
-
});
|
|
360
|
-
var destinationEdge = lines.findIndex(function (l) {
|
|
361
|
-
return l.id === (currentEdge === null || currentEdge === void 0 ? void 0 : currentEdge.toId);
|
|
362
|
-
});
|
|
363
|
-
if (destinationEdge >= 0) {
|
|
364
|
-
if ((currentEdge === null || currentEdge === void 0 ? void 0 : currentEdge.fromId) === (currentEdge === null || currentEdge === void 0 ? void 0 : currentEdge.toId)) {
|
|
365
|
-
reset();
|
|
366
|
-
} else {
|
|
367
|
-
setCurrentMessage({
|
|
368
|
-
show: false
|
|
369
|
-
});
|
|
370
|
-
changeLine(destinationEdge);
|
|
371
|
-
emitEvent({
|
|
372
|
-
type: 'notifyProgress',
|
|
373
|
-
payload: {
|
|
374
|
-
line: destinationEdge
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
} else {
|
|
379
|
-
finishConversation();
|
|
380
|
-
}
|
|
381
|
-
}, [currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.id, edges, finishConversation, lines]);
|
|
382
|
-
var backLine = (0, _react.useCallback)(function () {
|
|
383
|
-
lastTalking.current = _objectSpread({}, talkingCharacter);
|
|
384
|
-
setAudioFailed(false);
|
|
385
|
-
resetTalkingAnimation();
|
|
386
|
-
if (isBranched) {
|
|
387
|
-
handleBranchDirection(false);
|
|
388
|
-
} else if (!previousLineWasDecision()) {
|
|
389
|
-
var next = line - 1;
|
|
390
|
-
setCurrentMessage({
|
|
391
|
-
show: false
|
|
392
|
-
});
|
|
393
|
-
changeLine(next);
|
|
394
|
-
emitEvent({
|
|
395
|
-
type: 'notifyProgress',
|
|
396
|
-
payload: {
|
|
397
|
-
line: next
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
}, [handleBranchDirection, emitEvent, isBranched, lastLine, line, talkingCharacter]);
|
|
402
|
-
var decisionNotifyProgress = (0, _react.useCallback)(function (choice) {
|
|
403
|
-
if (isBranched) {
|
|
404
|
-
if (choice) {
|
|
405
|
-
var currentId = [3, 2, 1][choice.id];
|
|
406
|
-
var optionsEdges = edges.filter(function (edge) {
|
|
407
|
-
return edge.fromId === currentLineData.id;
|
|
408
|
-
});
|
|
409
|
-
var currentEdge = optionsEdges.find(function (edge) {
|
|
410
|
-
return parseInt(edge.fromPointIndex) === currentId;
|
|
411
|
-
});
|
|
412
|
-
if (currentEdge) {
|
|
413
|
-
var destinationEdge = lines.findIndex(function (l) {
|
|
414
|
-
return l.id === currentEdge.toId;
|
|
415
|
-
});
|
|
416
|
-
if (destinationEdge >= 0) {
|
|
417
|
-
emitEvent({
|
|
418
|
-
type: 'notifyProgress',
|
|
419
|
-
payload: {
|
|
420
|
-
line: destinationEdge
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
} else {
|
|
425
|
-
emitEvent({
|
|
426
|
-
type: 'saveNode'
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
} else if (line < lines.length - 1) {
|
|
431
|
-
var next = line + 1;
|
|
432
|
-
emitEvent({
|
|
433
|
-
type: 'notifyProgress',
|
|
434
|
-
payload: {
|
|
435
|
-
line: next
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
} else {
|
|
439
|
-
emitEvent({
|
|
440
|
-
type: 'saveNode'
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
}, [edges, line, lines, emitEvent, currentLineData.id, isBranched]);
|
|
444
|
-
var nextLine = (0, _react.useCallback)(function (choice, reset) {
|
|
445
|
-
lastTalking.current = _objectSpread({}, talkingCharacter);
|
|
446
|
-
setEdgesHistory([].concat(_toConsumableArray(edgesHistory), [currentLineData.id]));
|
|
447
|
-
setAudioFailed(false);
|
|
448
|
-
resetTalkingAnimation();
|
|
449
|
-
if (isBranched) {
|
|
450
|
-
if (choice) {
|
|
451
|
-
handleDecisionBranch(choice, reset);
|
|
452
|
-
} else {
|
|
453
|
-
handleBranchDirection();
|
|
454
|
-
}
|
|
455
|
-
} else if (line < lines.length - 1) {
|
|
456
|
-
var next = line + 1;
|
|
457
|
-
setCurrentMessage({
|
|
458
|
-
show: false
|
|
459
|
-
});
|
|
460
|
-
changeLine(next);
|
|
461
|
-
emitEvent({
|
|
462
|
-
type: 'notifyProgress',
|
|
463
|
-
payload: {
|
|
464
|
-
line: next
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
} else if (autoEnd) {
|
|
468
|
-
finishConversation();
|
|
469
|
-
} else if (currentLineData.decision) {
|
|
470
|
-
finishConversation();
|
|
471
|
-
}
|
|
472
|
-
}, [emitEvent, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.decision, isBranched, line, lines.length, handleDecisionBranch, handleBranchDirection, finishConversation, talkingCharacter]);
|
|
473
|
-
var manualBackLine = function manualBackLine() {
|
|
474
|
-
setAutomatic(false);
|
|
475
|
-
backLine();
|
|
476
|
-
};
|
|
477
|
-
var isEndNode = function isEndNode() {
|
|
478
|
-
if (isBranched) {
|
|
479
|
-
return currentLineData && currentLineData.type !== 'conversationalDecision' && !edges.find(function (edge) {
|
|
480
|
-
return edge.fromId === currentLineData.id;
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
return line === lines.length - 1;
|
|
484
|
-
};
|
|
485
|
-
var manualNextLine = function manualNextLine() {
|
|
486
|
-
if (isEndNode()) {
|
|
487
|
-
finishConversation();
|
|
488
|
-
} else {
|
|
489
|
-
setAutomatic(false);
|
|
490
|
-
nextLine();
|
|
491
|
-
}
|
|
492
|
-
};
|
|
493
|
-
|
|
494
|
-
// Calculate start node
|
|
495
|
-
(0, _react.useEffect)(function () {
|
|
496
|
-
if (isBranched && !mounted) {
|
|
497
|
-
var defaultBranch = progress === null || progress === void 0 ? void 0 : progress.line;
|
|
498
|
-
if (defaultBranch >= 0) {
|
|
499
|
-
setMounted(true);
|
|
500
|
-
changeLine(defaultBranch);
|
|
501
|
-
return;
|
|
502
|
-
}
|
|
503
|
-
var startNodes = lines.filter(function (node) {
|
|
504
|
-
return !edges.find(function (edge) {
|
|
505
|
-
return edge.toId === node.id;
|
|
506
|
-
});
|
|
507
|
-
});
|
|
508
|
-
if (startNodes.length) {
|
|
509
|
-
var initialNode = startNodes[0];
|
|
510
|
-
var newInitiaIndexlNode = lines.indexOf(initialNode);
|
|
511
|
-
if (newInitiaIndexlNode >= 0) {
|
|
512
|
-
setMounted(true);
|
|
513
|
-
changeLine(newInitiaIndexlNode);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
}, [edges, isBranched, lines, mounted]);
|
|
518
|
-
var moveBubble = function moveBubble(element) {
|
|
519
|
-
if (lastTalking.current.uid === element.uid) return;
|
|
520
|
-
var target = new _three.Object3D();
|
|
521
|
-
var head = element.getObjectByName('Head_M');
|
|
522
|
-
head.updateMatrixWorld();
|
|
523
|
-
target.applyMatrix4(head.matrixWorld);
|
|
524
|
-
target.applyQuaternion(camera.quaternion);
|
|
525
|
-
var yDistance = zoomInActor ? 2.5 : 2;
|
|
526
|
-
var xDistance = zoomInActor ? 1.2 : 1.5;
|
|
527
|
-
target.translateY(yDistance);
|
|
528
|
-
target.translateX(xDistance);
|
|
529
|
-
|
|
530
|
-
// Check if character is left or right in the screen
|
|
531
|
-
var vector = new _three.Vector3();
|
|
532
|
-
vector.setFromMatrixPosition(head.matrixWorld);
|
|
533
|
-
var p = vector.project(camera);
|
|
534
|
-
var isLeft = p.x < 0;
|
|
535
|
-
messagePosition.current = {
|
|
536
|
-
pos: target.position.toArray(),
|
|
537
|
-
child: head,
|
|
538
|
-
parent: element,
|
|
539
|
-
isLeft: isLeft
|
|
540
|
-
};
|
|
541
|
-
};
|
|
542
|
-
var setUIContainerToItsDefaultZIndex = function setUIContainerToItsDefaultZIndex(value) {
|
|
543
|
-
emitEvent({
|
|
544
|
-
type: 'resetZIndexUIContainer',
|
|
545
|
-
payload: value
|
|
546
|
-
});
|
|
547
|
-
};
|
|
548
|
-
|
|
549
|
-
// Position bubble over talking character/and switch emotions
|
|
550
|
-
(0, _react.useEffect)(function () {
|
|
551
|
-
if (isVoiceOver) {
|
|
552
|
-
resetCameraView();
|
|
553
|
-
setCurrentMessage({
|
|
554
|
-
text: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.text,
|
|
555
|
-
name: (currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.alias) || (currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.name) || "[ ".concat(translate('storylines.misc.voiceOver'), " ]"),
|
|
556
|
-
inScene: false,
|
|
557
|
-
voiceOver: true,
|
|
558
|
-
thinkful: false,
|
|
559
|
-
top: false,
|
|
560
|
-
avatar: getAvatarURL(talkingCharacter),
|
|
561
|
-
show: true
|
|
562
|
-
});
|
|
563
|
-
} else if (!lastSet.current && !isDecision) {
|
|
564
|
-
// Talking element logic
|
|
565
|
-
if (talkingCharacter) {
|
|
566
|
-
var slottedCharacters = currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.slots.filter(function (slot) {
|
|
567
|
-
return slot.uid && !slot.talking;
|
|
568
|
-
});
|
|
569
|
-
var currentParticipants = [].concat(_toConsumableArray(slottedCharacters.map(function (slot) {
|
|
570
|
-
return slot.uid;
|
|
571
|
-
}) || []), [talkingCharacter === null || talkingCharacter === void 0 ? void 0 : talkingCharacter.uid]);
|
|
572
|
-
var notInvolvedParticipants = charactersInvolved.filter(function (charUid) {
|
|
573
|
-
return !currentParticipants.includes(charUid);
|
|
574
|
-
});
|
|
575
|
-
notInvolvedParticipants.forEach(function (c) {
|
|
576
|
-
startAnimation(c, 'idle');
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
// Check not talking elements emotion
|
|
580
|
-
slottedCharacters.forEach(function (c) {
|
|
581
|
-
var sceneElement = getCurrentVisible(c.uid);
|
|
582
|
-
if (sceneElement) {
|
|
583
|
-
var isSeated = sceneElement.isSeated;
|
|
584
|
-
var includesSeated = c.emotion.includes('seated');
|
|
585
|
-
startAnimation(c.uid, isSeated && !includesSeated ? "".concat(c.emotion, "-seated") : c.emotion);
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
var element = getCurrentVisible(talkingCharacter.uid);
|
|
589
|
-
var object = actors.find(function (a) {
|
|
590
|
-
return a.uid === talkingCharacter.uid;
|
|
591
|
-
});
|
|
592
|
-
if (element && !lastSet.current) {
|
|
593
|
-
setTimeout(function () {
|
|
594
|
-
if (talkingCharacter.uid === element.uid) {
|
|
595
|
-
var _userData$active, _userData$active2;
|
|
596
|
-
moveBubble(element);
|
|
597
|
-
var isSeated = element.isSeated,
|
|
598
|
-
userData = element.userData;
|
|
599
|
-
var emotion = talkingCharacter.emotion;
|
|
600
|
-
var includesSeated = emotion.includes('seated');
|
|
601
|
-
if (!((_userData$active = userData.active) !== null && _userData$active !== void 0 && _userData$active.includes('talking')) && !((_userData$active2 = userData.active) !== null && _userData$active2 !== void 0 && _userData$active2.includes(emotion))) {
|
|
602
|
-
startAnimation(talkingCharacter.uid, isSeated && !includesSeated ? "".concat(emotion, "-seated") : emotion);
|
|
603
|
-
}
|
|
604
|
-
var setMessage = function setMessage() {
|
|
605
|
-
var _talkingCharacter$cha;
|
|
606
|
-
setCurrentMessage({
|
|
607
|
-
text: talkingCharacter.text,
|
|
608
|
-
name: talkingCharacter.alias || ((_talkingCharacter$cha = talkingCharacter.character) === null || _talkingCharacter$cha === void 0 ? void 0 : _talkingCharacter$cha.name),
|
|
609
|
-
inScene: true,
|
|
610
|
-
thinkful: talkingCharacter.emotion.includes('think'),
|
|
611
|
-
avatar: getAvatarURL(talkingCharacter),
|
|
612
|
-
show: true
|
|
613
|
-
});
|
|
614
|
-
};
|
|
615
|
-
if (zoomInActor) {
|
|
616
|
-
onZoomEnd.current = setMessage;
|
|
617
|
-
animateCameraTransition();
|
|
618
|
-
} else {
|
|
619
|
-
setMessage();
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
}, 150);
|
|
623
|
-
} else {
|
|
624
|
-
var _talkingCharacter$cha2;
|
|
625
|
-
resetCameraView();
|
|
626
|
-
setCurrentMessage({
|
|
627
|
-
text: talkingCharacter.text,
|
|
628
|
-
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),
|
|
629
|
-
left: false,
|
|
630
|
-
top: talkingCharacter.text.length > maxCharacterToSwitch,
|
|
631
|
-
inScene: false,
|
|
632
|
-
thinkful: talkingCharacter.emotion.includes('think'),
|
|
633
|
-
avatar: getAvatarURL(talkingCharacter),
|
|
634
|
-
show: true
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
} else {
|
|
638
|
-
resetCameraView();
|
|
639
|
-
setCurrentMessage({
|
|
640
|
-
show: true
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
}, [actors, currentLineData, zoomInActor, getCurrentVisible, translate, getAvatarURL, resetCameraView, isDecision, isVoiceOver, charactersInvolved]);
|
|
645
|
-
|
|
646
|
-
// Sound logic
|
|
647
|
-
var stopEkho = (0, _useEkho.default)({
|
|
648
|
-
audioType: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType,
|
|
649
|
-
volume: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioVolume,
|
|
650
|
-
voice: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.voice,
|
|
651
|
-
started: currentMessage.show,
|
|
652
|
-
text: currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.text,
|
|
653
|
-
audio: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audio,
|
|
654
|
-
slide: line,
|
|
655
|
-
soundActions: soundActions,
|
|
656
|
-
emitEvent: emitEvent,
|
|
657
|
-
pauseTTS: pause,
|
|
658
|
-
onStart: function onStart() {
|
|
659
|
-
var _talkingCharacter$emo;
|
|
660
|
-
if (talkingCharacter !== null && talkingCharacter !== void 0 && (_talkingCharacter$emo = talkingCharacter.emotion) !== null && _talkingCharacter$emo !== void 0 && _talkingCharacter$emo.includes('think')) return;
|
|
661
|
-
startTalking();
|
|
662
|
-
},
|
|
663
|
-
onError: function onError() {
|
|
664
|
-
setAudioFailed(true);
|
|
665
|
-
},
|
|
666
|
-
onFinish: function onFinish() {
|
|
667
|
-
resetTalkingAnimation();
|
|
668
|
-
if (autoPlayCond && !pause) {
|
|
669
|
-
nextLine();
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
});
|
|
673
|
-
(0, _react.useEffect)(function () {
|
|
674
|
-
stopEkho();
|
|
675
|
-
return function () {
|
|
676
|
-
stopEkho();
|
|
677
|
-
};
|
|
678
|
-
}, [line, stopEkho]);
|
|
679
|
-
(0, _react.useEffect)(function () {
|
|
680
|
-
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'))) {
|
|
681
|
-
var _currentMessage$text;
|
|
682
|
-
startTalking();
|
|
683
|
-
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);
|
|
684
|
-
setTimeout(function () {
|
|
685
|
-
resetTalkingAnimation();
|
|
686
|
-
}, time < minMs ? minMs : time);
|
|
687
|
-
}
|
|
688
|
-
}, [audioFailed, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, talkingCharacter === null || talkingCharacter === void 0 ? void 0 : talkingCharacter.emotion, currentMessage]);
|
|
689
|
-
|
|
690
|
-
// Autoplay logic
|
|
691
|
-
(0, _react.useEffect)(function () {
|
|
692
|
-
if (autoPlayCond && currentMessage.show && ((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed) && !pause) {
|
|
693
|
-
var _currentMessage$text2;
|
|
694
|
-
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);
|
|
695
|
-
if (!isEndNode() || isEndNode() && autoEnd) {
|
|
696
|
-
start(nextLine, time < minMs ? minMs : time);
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
return function () {
|
|
700
|
-
stop();
|
|
701
|
-
};
|
|
702
|
-
}, [currentMessage, nextLine, start, autoEnd, stop, currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType, autoPlayCond, audio, voice, audioFailed]);
|
|
703
|
-
var disableBackButton = (0, _react.useMemo)(function () {
|
|
704
|
-
var disabled = line === 0 || previousLineWasDecision();
|
|
705
|
-
return disabled;
|
|
706
|
-
}, [line, previousLineWasDecision]);
|
|
707
|
-
keyboardControl(isDecision || disableBackButton || !currentMessage.show ? null : manualBackLine, isDecision || !currentMessage.show ? null : manualNextLine);
|
|
708
|
-
var container = document.querySelector('.screens--container');
|
|
709
|
-
if (isDecision) {
|
|
710
|
-
var decisionPayload = _objectSpread(_objectSpread({}, currentLineData.payload), {}, {
|
|
711
|
-
decisionNumber: lines.filter(function (l) {
|
|
712
|
-
return l.decision;
|
|
713
|
-
}).findIndex(function (l) {
|
|
714
|
-
return l.id === currentLineData.id;
|
|
715
|
-
}) + 1,
|
|
716
|
-
inheritProps: {
|
|
717
|
-
slots: [],
|
|
718
|
-
disableBackground: true
|
|
719
|
-
},
|
|
720
|
-
required: !isBranched,
|
|
721
|
-
branched: isBranched,
|
|
722
|
-
onAddPoints: decisionNotifyProgress,
|
|
723
|
-
onFinish: nextLine,
|
|
724
|
-
emitEvent: emitEvent,
|
|
725
|
-
pause: pause,
|
|
726
|
-
soundActions: soundActions,
|
|
727
|
-
keyboardControl: keyboardControl,
|
|
728
|
-
onMount: function onMount() {
|
|
729
|
-
resetCameraView();
|
|
730
|
-
setUIContainerToItsDefaultZIndex(true);
|
|
731
|
-
},
|
|
732
|
-
onUnMount: function onUnMount() {
|
|
733
|
-
zoomStarted.current = false;
|
|
734
|
-
setUIContainerToItsDefaultZIndex(false);
|
|
735
|
-
}
|
|
736
|
-
});
|
|
737
|
-
return /*#__PURE__*/_react.default.createElement(_DialogDecision.default, decisionPayload);
|
|
738
|
-
}
|
|
739
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, currentMessage.text ? /*#__PURE__*/_react.default.createElement(_BubbleWrapper.default, {
|
|
740
|
-
translate: translate,
|
|
741
|
-
currentMessage: currentMessage
|
|
742
|
-
}) : null, /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.HtmlPro, {
|
|
743
|
-
wrapperClass: "htmlpro-wrap-100-h",
|
|
744
|
-
style: {
|
|
745
|
-
width: '100vw',
|
|
746
|
-
height: '100%',
|
|
747
|
-
position: 'static'
|
|
748
|
-
},
|
|
749
|
-
portal: container ? {
|
|
750
|
-
current: container
|
|
751
|
-
} : undefined,
|
|
752
|
-
zIndexRange: [6, 6],
|
|
753
|
-
onOcclude: function onOcclude() {},
|
|
754
|
-
calculatePosition: function calculatePosition() {
|
|
755
|
-
return [0, 0];
|
|
756
|
-
}
|
|
757
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
758
|
-
dir: (0, _LangIsRtl.default)() ? 'rtl' : 'ltr',
|
|
759
|
-
className: "dialog-component-controls"
|
|
760
|
-
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
761
|
-
type: "button",
|
|
762
|
-
onClick: manualBackLine,
|
|
763
|
-
disabled: disableBackButton || !currentMessage.show,
|
|
764
|
-
className: "gat--btn__round ".concat(disableBackButton || !currentMessage.show ? 'disabled' : ''),
|
|
765
|
-
"aria-label": (0, _LangIsRtl.default)() ? translate('storylines.misc.forward') : translate('storylines.misc.rewind')
|
|
766
|
-
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
767
|
-
className: (0, _LangIsRtl.default)() ? 'icon-next' : 'icon-back'
|
|
768
|
-
})), /*#__PURE__*/_react.default.createElement("button", {
|
|
769
|
-
type: "button",
|
|
770
|
-
onClick: manualNextLine,
|
|
771
|
-
disabled: !currentMessage.show,
|
|
772
|
-
className: "gat--btn__round \n ".concat(!currentMessage.show ? 'disabled' : '', "\n ").concat(automatic && isEndNode() ? 'glowing-animation' : ''),
|
|
773
|
-
"aria-label": (0, _LangIsRtl.default)() ? translate('storylines.misc.rewind') : translate('storylines.misc.forward')
|
|
774
|
-
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
775
|
-
className: (0, _LangIsRtl.default)() ? 'icon-back' : 'icon-next'
|
|
776
|
-
})))));
|
|
777
|
-
};
|
|
778
|
-
var _default = DialogComponent;
|
|
779
|
-
exports.default = _default;
|