@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
package/dist/helpers/index.js
DELETED
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.activateAction = activateAction;
|
|
7
|
-
exports.mixWithTalkingClip = exports.getRandomIndex = exports.getObjectPosition = exports.formatMessage = exports.executeTalkingAnimation = exports.executeCrossFadeOld = exports.executeCrossFade = exports.cameraFitAnyObject = void 0;
|
|
8
|
-
exports.prepareCrossfade = prepareCrossfade;
|
|
9
|
-
exports.resetActions = resetActions;
|
|
10
|
-
exports.setWeight = exports.screenToVector = exports.roundFloat = void 0;
|
|
11
|
-
exports.syncCrossfade = syncCrossfade;
|
|
12
|
-
exports.zAxis = exports.yAxis = exports.xAxis = exports.vectorTranslateZ = exports.vectorTranslateY = exports.vectorTranslateX = exports.vectorTranslateOnAxis = exports.vectorToScreen = exports.usePrevious = void 0;
|
|
13
|
-
var _react = require("react");
|
|
14
|
-
var _three = require("three");
|
|
15
|
-
var _GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader");
|
|
16
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
17
|
-
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."); }
|
|
18
|
-
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); }
|
|
19
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
20
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
21
|
-
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; }
|
|
22
|
-
var loader = new _GLTFLoader.GLTFLoader();
|
|
23
|
-
var xAxis = new _three.Vector3(1, 0, 0);
|
|
24
|
-
exports.xAxis = xAxis;
|
|
25
|
-
var yAxis = new _three.Vector3(0, 1, 0);
|
|
26
|
-
exports.yAxis = yAxis;
|
|
27
|
-
var zAxis = new _three.Vector3(0, 0, 1);
|
|
28
|
-
exports.zAxis = zAxis;
|
|
29
|
-
var crossFadeDuration = 0.2;
|
|
30
|
-
var bones = ['Jaw_M', 'Head_M', 'L_lip_jnt', 'HeadEnd_M', 'Neck_M', 'R_lip_jnt', 'joint4', 'transform1', 'lowerTeeths', 'upperTeeths'];
|
|
31
|
-
var formatMessage = function formatMessage(text) {
|
|
32
|
-
var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33
|
-
var result = text;
|
|
34
|
-
Object.keys(values).forEach(function (currentValue) {
|
|
35
|
-
result = result.replace("{".concat(currentValue, "}"), values[currentValue]);
|
|
36
|
-
});
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
exports.formatMessage = formatMessage;
|
|
40
|
-
var getRandomIndex = function getRandomIndex(length) {
|
|
41
|
-
return Math.floor(Math.random() * length);
|
|
42
|
-
};
|
|
43
|
-
exports.getRandomIndex = getRandomIndex;
|
|
44
|
-
var usePrevious = function usePrevious(value) {
|
|
45
|
-
var ref = (0, _react.useRef)();
|
|
46
|
-
(0, _react.useEffect)(function () {
|
|
47
|
-
ref.current = value;
|
|
48
|
-
}, [value]);
|
|
49
|
-
return ref.current;
|
|
50
|
-
};
|
|
51
|
-
exports.usePrevious = usePrevious;
|
|
52
|
-
var vectorTranslateOnAxis = function vectorTranslateOnAxis(axis, amount, object) {
|
|
53
|
-
var result = axis.clone().applyQuaternion(object.quaternion);
|
|
54
|
-
return result.multiplyScalar(amount).clone();
|
|
55
|
-
};
|
|
56
|
-
exports.vectorTranslateOnAxis = vectorTranslateOnAxis;
|
|
57
|
-
var vectorTranslateZ = function vectorTranslateZ(amount, object) {
|
|
58
|
-
return vectorTranslateOnAxis(zAxis, amount, object);
|
|
59
|
-
};
|
|
60
|
-
exports.vectorTranslateZ = vectorTranslateZ;
|
|
61
|
-
var vectorTranslateX = function vectorTranslateX(amount, object) {
|
|
62
|
-
return vectorTranslateOnAxis(xAxis, amount, object);
|
|
63
|
-
};
|
|
64
|
-
exports.vectorTranslateX = vectorTranslateX;
|
|
65
|
-
var vectorTranslateY = function vectorTranslateY(amount, object) {
|
|
66
|
-
return vectorTranslateOnAxis(yAxis, amount, object);
|
|
67
|
-
};
|
|
68
|
-
exports.vectorTranslateY = vectorTranslateY;
|
|
69
|
-
var roundFloat = function roundFloat(number, decimals) {
|
|
70
|
-
return parseFloat(number.toFixed(decimals));
|
|
71
|
-
};
|
|
72
|
-
exports.roundFloat = roundFloat;
|
|
73
|
-
var cameraFitAnyObject = function cameraFitAnyObject(object, camera) {
|
|
74
|
-
var uOff = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
75
|
-
var controls = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
76
|
-
var clone = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
77
|
-
var clonedCamera = camera.clone();
|
|
78
|
-
var offset = uOff || 1.25;
|
|
79
|
-
var boundingBox = new _three.Box3();
|
|
80
|
-
boundingBox.setFromObject(object);
|
|
81
|
-
var boundingBoxCenter = boundingBox.getCenter(new _three.Vector3());
|
|
82
|
-
var center = new _three.Vector3(0, boundingBoxCenter.y, 0);
|
|
83
|
-
var size = boundingBox.getSize(new _three.Vector3());
|
|
84
|
-
var maxDim = Math.max(size.x, size.y, size.z);
|
|
85
|
-
var fov = clonedCamera.fov * (Math.PI / 180);
|
|
86
|
-
var cameraZ = Math.abs(maxDim * Math.sqrt(2) / 2 * Math.tan(fov * 2));
|
|
87
|
-
cameraZ *= offset;
|
|
88
|
-
var objectWorldPosition = new _three.Vector3();
|
|
89
|
-
objectWorldPosition.setFromMatrixPosition(object.matrixWorld);
|
|
90
|
-
var directionVector = new _three.Vector3(1, 1, 1);
|
|
91
|
-
var unitDirectionVector = directionVector.normalize();
|
|
92
|
-
clonedCamera.position.copy(unitDirectionVector.multiplyScalar(cameraZ));
|
|
93
|
-
clonedCamera.lookAt(objectWorldPosition);
|
|
94
|
-
var minZ = boundingBox.min.z;
|
|
95
|
-
var cameraToFarEdge = minZ < 0 ? -minZ + cameraZ : cameraZ - minZ;
|
|
96
|
-
clonedCamera.far = cameraToFarEdge * 3;
|
|
97
|
-
clonedCamera.near = 0.01;
|
|
98
|
-
clonedCamera.updateProjectionMatrix();
|
|
99
|
-
clonedCamera.lookAt(center);
|
|
100
|
-
if (controls) {
|
|
101
|
-
controls.target = center;
|
|
102
|
-
controls.maxDistance = cameraToFarEdge * 2;
|
|
103
|
-
controls.saveState();
|
|
104
|
-
}
|
|
105
|
-
if (clone) {
|
|
106
|
-
return clonedCamera;
|
|
107
|
-
}
|
|
108
|
-
camera.copy(clonedCamera);
|
|
109
|
-
return null;
|
|
110
|
-
};
|
|
111
|
-
exports.cameraFitAnyObject = cameraFitAnyObject;
|
|
112
|
-
var getObjectPosition = function getObjectPosition(object, camera, canvas) {
|
|
113
|
-
if (!object) return null;
|
|
114
|
-
var point = new _three.Vector3();
|
|
115
|
-
var boundingBox = new _three.Box3().setFromObject(object);
|
|
116
|
-
boundingBox.getCenter(point);
|
|
117
|
-
var p = point.clone();
|
|
118
|
-
camera.updateMatrixWorld();
|
|
119
|
-
p.project(camera);
|
|
120
|
-
var clientHeight = canvas.clientHeight,
|
|
121
|
-
clientWidth = canvas.clientWidth;
|
|
122
|
-
var position = new _three.Vector2((p.x * clientWidth + clientWidth) / 2, (-p.y * clientHeight + clientHeight) / 2);
|
|
123
|
-
return position;
|
|
124
|
-
};
|
|
125
|
-
exports.getObjectPosition = getObjectPosition;
|
|
126
|
-
var vectorToScreen = function vectorToScreen(vector, camera) {
|
|
127
|
-
var width = window.innerWidth;
|
|
128
|
-
var height = window.innerHeight;
|
|
129
|
-
var widthHalf = width / 2;
|
|
130
|
-
var heightHalf = height / 2;
|
|
131
|
-
var pos = vector.clone();
|
|
132
|
-
pos.project(camera);
|
|
133
|
-
pos.x = pos.x * widthHalf + widthHalf;
|
|
134
|
-
pos.y = -(pos.y * heightHalf) + heightHalf;
|
|
135
|
-
return pos;
|
|
136
|
-
};
|
|
137
|
-
exports.vectorToScreen = vectorToScreen;
|
|
138
|
-
var screenToVector = function screenToVector(vector, camera) {
|
|
139
|
-
var clone = vector.clone();
|
|
140
|
-
clone.z = -1;
|
|
141
|
-
return clone.unproject(camera);
|
|
142
|
-
};
|
|
143
|
-
exports.screenToVector = screenToVector;
|
|
144
|
-
var setWeight = function setWeight(action, weight) {
|
|
145
|
-
action.enabled = true;
|
|
146
|
-
action.setEffectiveTimeScale(1);
|
|
147
|
-
action.setEffectiveWeight(weight);
|
|
148
|
-
};
|
|
149
|
-
exports.setWeight = setWeight;
|
|
150
|
-
function activateAction(action, weight) {
|
|
151
|
-
setWeight(action, weight);
|
|
152
|
-
action.play();
|
|
153
|
-
}
|
|
154
|
-
function prepareCrossfade(root, startAction, endAction) {
|
|
155
|
-
var mixer = root.userData.mixer;
|
|
156
|
-
if (!startAction || !endAction) {
|
|
157
|
-
executeCrossFade(startAction, endAction);
|
|
158
|
-
} else {
|
|
159
|
-
syncCrossfade(mixer, startAction, endAction);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
function syncCrossfade(mixer, startAction, endAction) {
|
|
163
|
-
mixer.addEventListener('loop', onLoopFinished);
|
|
164
|
-
function onLoopFinished() {
|
|
165
|
-
mixer.removeEventListener('loop', onLoopFinished);
|
|
166
|
-
executeCrossFade(startAction, endAction);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function resetActions(mixer, active) {
|
|
170
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
171
|
-
mixer._actions.forEach(function (action) {
|
|
172
|
-
if (action !== active) {
|
|
173
|
-
action.fadeOut(crossFadeDuration);
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
var executeCrossFadeOld = function executeCrossFadeOld(startAction, endAction) {
|
|
178
|
-
if (startAction === endAction) return;
|
|
179
|
-
if (!startAction || !endAction) return;
|
|
180
|
-
startAction.play();
|
|
181
|
-
startAction.reset();
|
|
182
|
-
endAction.reset();
|
|
183
|
-
setWeight(endAction, 1);
|
|
184
|
-
endAction.crossFadeFrom(startAction, crossFadeDuration, true);
|
|
185
|
-
endAction.play();
|
|
186
|
-
};
|
|
187
|
-
exports.executeCrossFadeOld = executeCrossFadeOld;
|
|
188
|
-
var executeCrossFade = function executeCrossFade(startAction, endAction) {
|
|
189
|
-
if (endAction) {
|
|
190
|
-
setWeight(endAction, 1);
|
|
191
|
-
endAction.time = 0;
|
|
192
|
-
if (startAction) {
|
|
193
|
-
startAction.syncWith(endAction);
|
|
194
|
-
startAction.crossFadeTo(endAction, crossFadeDuration, true);
|
|
195
|
-
} else {
|
|
196
|
-
endAction.fadeIn(crossFadeDuration);
|
|
197
|
-
}
|
|
198
|
-
} else {
|
|
199
|
-
startAction.fadeOut(crossFadeDuration);
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
exports.executeCrossFade = executeCrossFade;
|
|
203
|
-
var executeTalkingAnimation = function executeTalkingAnimation(target, talkingURL) {
|
|
204
|
-
if (target && talkingURL) {
|
|
205
|
-
var tracks = [];
|
|
206
|
-
var _target$userData = target.userData,
|
|
207
|
-
mixer = _target$userData.mixer,
|
|
208
|
-
defaultAnim = _target$userData.defaultAnim;
|
|
209
|
-
var cloned = defaultAnim.clone();
|
|
210
|
-
var onLoad = function onLoad(anim) {
|
|
211
|
-
var talkingClip = anim === null || anim === void 0 ? void 0 : anim.animations[0];
|
|
212
|
-
if (talkingClip) {
|
|
213
|
-
var _cloned$tracks;
|
|
214
|
-
tracks = talkingClip.tracks.filter(function (track) {
|
|
215
|
-
return bones.find(function (bone) {
|
|
216
|
-
return track.name.includes(bone);
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
cloned.tracks = cloned.tracks.filter(function (track) {
|
|
220
|
-
return !bones.find(function (bone) {
|
|
221
|
-
return track.name.includes(bone);
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
(_cloned$tracks = cloned.tracks).push.apply(_cloned$tracks, _toConsumableArray(tracks));
|
|
225
|
-
target.userData.emotionClip = cloned;
|
|
226
|
-
cloned.resetDuration();
|
|
227
|
-
var talkingSubClip = cloned;
|
|
228
|
-
if (cloned.duration > 4) {
|
|
229
|
-
talkingSubClip = _three.AnimationUtils.subclip(cloned, 'shortTalking', 0, 120, 30);
|
|
230
|
-
}
|
|
231
|
-
var defaultAction = mixer.clipAction(defaultAnim, target);
|
|
232
|
-
var emotionAction = mixer.clipAction(talkingSubClip, target);
|
|
233
|
-
emotionAction.loop = _three.LoopPingPong;
|
|
234
|
-
mixer.stopAllAction();
|
|
235
|
-
executeCrossFadeOld(defaultAction, emotionAction, crossFadeDuration);
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
loader.load(talkingURL, function (anim) {
|
|
239
|
-
onLoad(anim);
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
exports.executeTalkingAnimation = executeTalkingAnimation;
|
|
244
|
-
var mixWithTalkingClip = function mixWithTalkingClip(target, talking, action) {
|
|
245
|
-
var _cloned$tracks2;
|
|
246
|
-
var mixer = target.userData.mixer;
|
|
247
|
-
var talkingClip = talking.clone();
|
|
248
|
-
var cloned = action.clone();
|
|
249
|
-
var tracks = talkingClip.tracks.filter(function (track) {
|
|
250
|
-
return bones.find(function (bone) {
|
|
251
|
-
return track.name.includes(bone);
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
cloned.tracks = cloned.tracks.filter(function (track) {
|
|
255
|
-
return !bones.find(function (bone) {
|
|
256
|
-
return track.name.includes(bone);
|
|
257
|
-
});
|
|
258
|
-
});
|
|
259
|
-
(_cloned$tracks2 = cloned.tracks).push.apply(_cloned$tracks2, _toConsumableArray(tracks));
|
|
260
|
-
cloned.resetDuration();
|
|
261
|
-
var clip = cloned;
|
|
262
|
-
clip.name = "".concat(cloned.name, "_talking");
|
|
263
|
-
if (cloned.duration > 4) {
|
|
264
|
-
clip = _three.AnimationUtils.subclip(cloned, clip.name, 0, 120, 30);
|
|
265
|
-
}
|
|
266
|
-
return mixer.clipAction(clip, target);
|
|
267
|
-
};
|
|
268
|
-
exports.mixWithTalkingClip = mixWithTalkingClip;
|
package/dist/helpers/lodStats.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var lodStatsElement = null;
|
|
8
|
-
var geo = 0;
|
|
9
|
-
var divideby64 = 0;
|
|
10
|
-
var divideby16 = 0;
|
|
11
|
-
var divideby4 = 0;
|
|
12
|
-
var original = 0;
|
|
13
|
-
var style = 'float:left;margin:5px;padding:5px;';
|
|
14
|
-
function formatBytes(a) {
|
|
15
|
-
var b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
16
|
-
if (a === 0) {
|
|
17
|
-
return '0 Bytes';
|
|
18
|
-
}
|
|
19
|
-
var c = b < 0 ? 0 : b;
|
|
20
|
-
var d = Math.floor(Math.log(a) / Math.log(1024));
|
|
21
|
-
return "".concat(parseFloat((a / Math.pow(1024, d)).toFixed(c)), " ").concat(['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'][d]);
|
|
22
|
-
}
|
|
23
|
-
var lodStats = function lodStats(obj) {
|
|
24
|
-
if (!lodStatsElement) {
|
|
25
|
-
var root = document.getElementById('root');
|
|
26
|
-
var previous = document.getElementById('lodStats');
|
|
27
|
-
if (previous) {
|
|
28
|
-
root.removeChild(previous);
|
|
29
|
-
}
|
|
30
|
-
var div = document.createElement('div');
|
|
31
|
-
div.style = "border-radius:5px;color:white; background-color:black;\n position: fixed; top: 0px; left: 100px; opacity: 0.5; z-index: 10001;";
|
|
32
|
-
div.id = 'lodStats';
|
|
33
|
-
root.appendChild(div);
|
|
34
|
-
lodStatsElement = div;
|
|
35
|
-
}
|
|
36
|
-
if (obj.reset) {
|
|
37
|
-
lodStatsElement.innerHTML = '';
|
|
38
|
-
lodStatsElement = null;
|
|
39
|
-
geo = 0;
|
|
40
|
-
divideby64 = 0;
|
|
41
|
-
divideby16 = 0;
|
|
42
|
-
divideby4 = 0;
|
|
43
|
-
original = 0;
|
|
44
|
-
} else {
|
|
45
|
-
geo += obj.geometries ? obj.geometries : 0;
|
|
46
|
-
divideby64 += obj.divideby64 ? obj.divideby64 : 0;
|
|
47
|
-
divideby16 += obj.divideby16 ? obj.divideby16 : 0;
|
|
48
|
-
divideby4 += obj.divideby4 ? obj.divideby4 : 0;
|
|
49
|
-
original += obj.original ? obj.original : 0;
|
|
50
|
-
// rootProjection.innerHTML = `Geo: ${geo} d64: ${divideby64} d16: ${divideby16} d4: ${divideby4} original: ${original}`;
|
|
51
|
-
lodStatsElement.innerHTML = "\n <div style=\"".concat(style, "\"> \n <div>Geometries</div>\n <div>").concat(formatBytes(geo), "</div>\n </div>\n <div style=\"").concat(style, "\"> \n <div style=\"color:red\">DivideBy64</div>\n <div>").concat(formatBytes(divideby64), "</div>\n </div>\n <div style=\"").concat(style, "\"> \n <div style=\"color:green\">DivideBy16</div>\n <div>").concat(formatBytes(divideby16), "</div>\n </div>\n <div style=\"").concat(style, "\"> \n <div style=\"color:blue\">DivideBy4</div>\n <div>").concat(formatBytes(divideby4), "</div>\n </div>\n <div style=\"").concat(style, "\"> \n <div>Original</div>\n <div>").concat(formatBytes(original), "</div>\n </div>\n ");
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
var _default = lodStats;
|
|
55
|
-
exports.default = _default;
|
package/dist/helpers/mocker.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.translate = exports.soundActions = exports.setShowPoints = exports.onFinish = exports.noopSoundActions = exports.keyboardControl = exports.getSpeech = exports.functionOnClose = exports.emitEvent = void 0;
|
|
7
|
-
/* eslint-disable no-console */
|
|
8
|
-
/* eslint-disable no-prototype-builtins */
|
|
9
|
-
var emitEvent = function emitEvent(_ref) {
|
|
10
|
-
var type = _ref.type,
|
|
11
|
-
payload = _ref.payload;
|
|
12
|
-
if (type === 'translate') {
|
|
13
|
-
return payload;
|
|
14
|
-
}
|
|
15
|
-
if (type === 'loadIndicators') {
|
|
16
|
-
return {
|
|
17
|
-
score: [{
|
|
18
|
-
color: '#4e469e',
|
|
19
|
-
description: 'description_0_dY5ms0vf',
|
|
20
|
-
description_labelId: 'description_0_dY5ms0vf',
|
|
21
|
-
icon: 'font-indicator-bolsa',
|
|
22
|
-
id: 'ki4qrkam',
|
|
23
|
-
name: 'Indicator1',
|
|
24
|
-
name_labelId: 'name_0_dY5ms9T1',
|
|
25
|
-
points: 295,
|
|
26
|
-
type: 'score'
|
|
27
|
-
}, {
|
|
28
|
-
color: '#4e469e',
|
|
29
|
-
description: 'description_0_dY5ms0vf',
|
|
30
|
-
description_labelId: 'description_0_dY5ms0vf',
|
|
31
|
-
icon: 'font-indicator-bolsa',
|
|
32
|
-
id: 'ki4qrop',
|
|
33
|
-
name: 'Indicator1',
|
|
34
|
-
name_labelId: 'name_0_dY5ms9T1',
|
|
35
|
-
points: 300,
|
|
36
|
-
type: 'score'
|
|
37
|
-
}, {
|
|
38
|
-
color: '#4e469e',
|
|
39
|
-
description: 'description_0_dY5ms0vf',
|
|
40
|
-
description_labelId: 'description_0_dY5ms0vf',
|
|
41
|
-
icon: 'font-indicator-bolsa',
|
|
42
|
-
id: 'ki4qiuyi',
|
|
43
|
-
name: 'Indicator1',
|
|
44
|
-
name_labelId: 'name_0_dY5ms9T1',
|
|
45
|
-
points: 300,
|
|
46
|
-
type: 'score'
|
|
47
|
-
}],
|
|
48
|
-
skill: [{
|
|
49
|
-
color: '#559cac',
|
|
50
|
-
description: 'description_0_dY5msi7o',
|
|
51
|
-
description_labelId: 'description_0_dY5msi7o',
|
|
52
|
-
icon: 'font-indicator-microfono-2',
|
|
53
|
-
id: 'ki4qrkas',
|
|
54
|
-
name: 'competency2',
|
|
55
|
-
name_labelId: 'name_0_dY5mslgV',
|
|
56
|
-
points: 295,
|
|
57
|
-
type: 'skill'
|
|
58
|
-
}, {
|
|
59
|
-
color: '#559cac',
|
|
60
|
-
description: 'description_0_dY5msi7o',
|
|
61
|
-
description_labelId: 'description_0_dY5msi7o',
|
|
62
|
-
icon: 'font-indicator-microfono-2',
|
|
63
|
-
id: 'ki4qropi',
|
|
64
|
-
name: 'competency2',
|
|
65
|
-
name_labelId: 'name_0_dY5mslgV',
|
|
66
|
-
points: 295,
|
|
67
|
-
type: 'skill'
|
|
68
|
-
}],
|
|
69
|
-
grade: undefined
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
console.log('Emit event called:', type, 'payload:', payload);
|
|
73
|
-
return null;
|
|
74
|
-
};
|
|
75
|
-
exports.emitEvent = emitEvent;
|
|
76
|
-
var noopSoundActions = [function () {}, function () {}];
|
|
77
|
-
exports.noopSoundActions = noopSoundActions;
|
|
78
|
-
var audio = {
|
|
79
|
-
fail: new Audio('https://www.soundjay.com/buttons/button-10.mp3'),
|
|
80
|
-
'click-ui': new Audio('https://www.soundjay.com/buttons/button-16.mp3'),
|
|
81
|
-
score: new Audio('https://www.soundjay.com/mechanical/camera-shutter-click-01.mp3')
|
|
82
|
-
};
|
|
83
|
-
var soundActions = [function (sound) {
|
|
84
|
-
console.log('PlaySound called :', sound);
|
|
85
|
-
if (sound && audio.hasOwnProperty(sound)) {
|
|
86
|
-
audio[sound].play();
|
|
87
|
-
} else if (sound && sound.includes('http')) {
|
|
88
|
-
var exSound = new Audio(sound);
|
|
89
|
-
exSound.play();
|
|
90
|
-
}
|
|
91
|
-
}, function () {}, function () {}, function () {}];
|
|
92
|
-
exports.soundActions = soundActions;
|
|
93
|
-
var setShowPoints = function setShowPoints() {
|
|
94
|
-
var score = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
95
|
-
console.log('score', score);
|
|
96
|
-
};
|
|
97
|
-
exports.setShowPoints = setShowPoints;
|
|
98
|
-
var getSpeech = function getSpeech(payload) {
|
|
99
|
-
console.log('getSpeech', payload);
|
|
100
|
-
};
|
|
101
|
-
exports.getSpeech = getSpeech;
|
|
102
|
-
var translate = function translate(payload) {
|
|
103
|
-
return payload;
|
|
104
|
-
};
|
|
105
|
-
exports.translate = translate;
|
|
106
|
-
var functionOnClose = function functionOnClose() {
|
|
107
|
-
console.log('closing this');
|
|
108
|
-
};
|
|
109
|
-
exports.functionOnClose = functionOnClose;
|
|
110
|
-
var onFinish = function onFinish() {
|
|
111
|
-
var component = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'a component';
|
|
112
|
-
console.log('you just called onfinish from...', component);
|
|
113
|
-
};
|
|
114
|
-
exports.onFinish = onFinish;
|
|
115
|
-
var keyboardControl = function keyboardControl() {};
|
|
116
|
-
exports.keyboardControl = keyboardControl;
|
package/dist/helpers/useEkho.js
DELETED
|
@@ -1,172 +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 = require("react");
|
|
9
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
10
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
11
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
12
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
13
|
-
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."); }
|
|
14
|
-
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); }
|
|
15
|
-
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; }
|
|
16
|
-
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; } }
|
|
17
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
-
var noop = function noop() {};
|
|
19
|
-
|
|
20
|
-
/** Custom hook for use TTS and audio in the components */
|
|
21
|
-
var useEkho = function useEkho(_ref) {
|
|
22
|
-
var voice = _ref.voice,
|
|
23
|
-
text = _ref.text,
|
|
24
|
-
audioType = _ref.audioType,
|
|
25
|
-
_ref$loop = _ref.loop,
|
|
26
|
-
loop = _ref$loop === void 0 ? false : _ref$loop,
|
|
27
|
-
_ref$started = _ref.started,
|
|
28
|
-
started = _ref$started === void 0 ? true : _ref$started,
|
|
29
|
-
_ref$slide = _ref.slide,
|
|
30
|
-
slide = _ref$slide === void 0 ? 0 : _ref$slide,
|
|
31
|
-
audio = _ref.audio,
|
|
32
|
-
soundActions = _ref.soundActions,
|
|
33
|
-
emitEvent = _ref.emitEvent,
|
|
34
|
-
_ref$volume = _ref.volume,
|
|
35
|
-
volume = _ref$volume === void 0 ? 0.5 : _ref$volume,
|
|
36
|
-
_ref$onFinish = _ref.onFinish,
|
|
37
|
-
onFinish = _ref$onFinish === void 0 ? noop : _ref$onFinish,
|
|
38
|
-
_ref$onError = _ref.onError,
|
|
39
|
-
onError = _ref$onError === void 0 ? noop : _ref$onError,
|
|
40
|
-
_ref$onStart = _ref.onStart,
|
|
41
|
-
onStart = _ref$onStart === void 0 ? noop : _ref$onStart,
|
|
42
|
-
pauseTTS = _ref.pauseTTS;
|
|
43
|
-
var _soundActions = _slicedToArray(soundActions, 4),
|
|
44
|
-
playSound = _soundActions[0],
|
|
45
|
-
stop = _soundActions[1],
|
|
46
|
-
pause = _soundActions[2],
|
|
47
|
-
resume = _soundActions[3];
|
|
48
|
-
var noAudio = !audio && !voice;
|
|
49
|
-
var _useState = (0, _react.useState)(false),
|
|
50
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
51
|
-
isMounted = _useState2[0],
|
|
52
|
-
setIsMounted = _useState2[1];
|
|
53
|
-
var currentPlaying = (0, _react.useRef)({
|
|
54
|
-
url: '',
|
|
55
|
-
cc: 'tts'
|
|
56
|
-
});
|
|
57
|
-
var translate = (0, _react.useCallback)(function (id) {
|
|
58
|
-
return emitEvent({
|
|
59
|
-
type: 'translate',
|
|
60
|
-
payload: id
|
|
61
|
-
});
|
|
62
|
-
}, [emitEvent]);
|
|
63
|
-
|
|
64
|
-
// Get translated voices, todo: translate this in arcade translateProps i18n.helper.js
|
|
65
|
-
var getVoice = (0, _react.useCallback)(function (_ref2) {
|
|
66
|
-
var id = _ref2.id,
|
|
67
|
-
_ref2$type = _ref2.type,
|
|
68
|
-
type = _ref2$type === void 0 ? 'base' : _ref2$type;
|
|
69
|
-
var usedVoices = translate('usedVoices');
|
|
70
|
-
var gameChars = translate('gameCharacters');
|
|
71
|
-
if (type === 'base') {
|
|
72
|
-
return usedVoices === null || usedVoices === void 0 ? void 0 : usedVoices[id];
|
|
73
|
-
}
|
|
74
|
-
if (type === 'character') {
|
|
75
|
-
var _gameChars$id;
|
|
76
|
-
return gameChars === null || gameChars === void 0 ? void 0 : (_gameChars$id = gameChars[id]) === null || _gameChars$id === void 0 ? void 0 : _gameChars$id.voiceId;
|
|
77
|
-
}
|
|
78
|
-
return null;
|
|
79
|
-
}, [translate]);
|
|
80
|
-
var setCurrentPlaying = (0, _react.useCallback)(function (url) {
|
|
81
|
-
var cc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'tts';
|
|
82
|
-
if (currentPlaying.current.url === url && slide === currentPlaying.current.slide) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
currentPlaying.current = {
|
|
86
|
-
url: url,
|
|
87
|
-
cc: cc,
|
|
88
|
-
slide: slide
|
|
89
|
-
};
|
|
90
|
-
playSound(url, cc, loop, volume, onFinish, onStart);
|
|
91
|
-
}, [slide, playSound, loop, volume, onFinish, onStart]);
|
|
92
|
-
var playSpeech = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
93
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(payload) {
|
|
94
|
-
var url;
|
|
95
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
96
|
-
while (1) switch (_context.prev = _context.next) {
|
|
97
|
-
case 0:
|
|
98
|
-
if (!(isMounted && payload.voiceId && payload.text)) {
|
|
99
|
-
_context.next = 7;
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
_context.next = 3;
|
|
103
|
-
return emitEvent({
|
|
104
|
-
type: 'getSpeech',
|
|
105
|
-
payload: payload
|
|
106
|
-
});
|
|
107
|
-
case 3:
|
|
108
|
-
url = _context.sent;
|
|
109
|
-
if (!url) {
|
|
110
|
-
onError();
|
|
111
|
-
} else {
|
|
112
|
-
setCurrentPlaying(url);
|
|
113
|
-
}
|
|
114
|
-
_context.next = 8;
|
|
115
|
-
break;
|
|
116
|
-
case 7:
|
|
117
|
-
onError();
|
|
118
|
-
case 8:
|
|
119
|
-
case "end":
|
|
120
|
-
return _context.stop();
|
|
121
|
-
}
|
|
122
|
-
}, _callee);
|
|
123
|
-
}));
|
|
124
|
-
return function (_x2) {
|
|
125
|
-
return _ref3.apply(this, arguments);
|
|
126
|
-
};
|
|
127
|
-
}(), [emitEvent, isMounted, onError, setCurrentPlaying]);
|
|
128
|
-
var stopCurrentAudio = (0, _react.useCallback)(function () {
|
|
129
|
-
if (currentPlaying.current.url) {
|
|
130
|
-
stop(currentPlaying.current.cc);
|
|
131
|
-
}
|
|
132
|
-
}, [stop]);
|
|
133
|
-
|
|
134
|
-
// Setted when is mounted
|
|
135
|
-
(0, _react.useEffect)(function () {
|
|
136
|
-
setIsMounted(true);
|
|
137
|
-
return function () {
|
|
138
|
-
setIsMounted(false);
|
|
139
|
-
stopCurrentAudio();
|
|
140
|
-
};
|
|
141
|
-
}, [stopCurrentAudio]);
|
|
142
|
-
(0, _react.useEffect)(function () {
|
|
143
|
-
if (pauseTTS) {
|
|
144
|
-
pause();
|
|
145
|
-
} else {
|
|
146
|
-
resume();
|
|
147
|
-
}
|
|
148
|
-
}, [pause, pauseTTS, resume]);
|
|
149
|
-
(0, _react.useEffect)(function () {
|
|
150
|
-
if (noAudio) {
|
|
151
|
-
stopCurrentAudio();
|
|
152
|
-
}
|
|
153
|
-
}, [noAudio, stopCurrentAudio]);
|
|
154
|
-
(0, _react.useEffect)(function () {
|
|
155
|
-
if (isMounted && started) {
|
|
156
|
-
if (audioType === 'voice' && voice !== null && voice !== void 0 && voice.id) {
|
|
157
|
-
var voiceId = getVoice(voice);
|
|
158
|
-
playSpeech({
|
|
159
|
-
voiceId: voiceId,
|
|
160
|
-
text: text
|
|
161
|
-
});
|
|
162
|
-
} else if ((audioType === 'file' || !audioType) && audio) {
|
|
163
|
-
setCurrentPlaying(audio === null || audio === void 0 ? void 0 : audio.url);
|
|
164
|
-
} else {
|
|
165
|
-
onError();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}, [getVoice, playSpeech, isMounted, voice, text, audioType, audio === null || audio === void 0 ? void 0 : audio.url, audio, setCurrentPlaying, onError, started]);
|
|
169
|
-
return stopCurrentAudio;
|
|
170
|
-
};
|
|
171
|
-
var _default = useEkho;
|
|
172
|
-
exports.default = _default;
|