@gamelearn/arcade-components 2.41.1 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -6
- package/dist/arcade-components.cjs +274 -0
- package/dist/arcade-components.js +57929 -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 -361
- 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/useGLB.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _reactPromiseSuspense = _interopRequireDefault(require("react-promise-suspense"));
|
|
8
|
-
var _GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader");
|
|
9
|
-
var _DRACOLoader = require("three/examples/jsm/loaders/DRACOLoader");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
// We need this to reuse GLTF and DRACO loaders for Arcade working
|
|
12
|
-
// in Mobile devices, drei.useGLTF instances new loaders every time is
|
|
13
|
-
// used
|
|
14
|
-
|
|
15
|
-
// const dracoDecoderPath = 'https://www.gstatic.com/draco/v1/decoders/';
|
|
16
|
-
var dracoDecoderPath = 'https://www.gstatic.com/draco/versioned/decoders/1.4.2/';
|
|
17
|
-
// Changed to specific version because 1.4.3 seems to have issues
|
|
18
|
-
// TODO: Maybe download those files to statics.gamelearn
|
|
19
|
-
|
|
20
|
-
var whiteImage = new Image();
|
|
21
|
-
whiteImage.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=';
|
|
22
|
-
var dracoLoader = new _DRACOLoader.DRACOLoader();
|
|
23
|
-
var gltfLoader = new _GLTFLoader.GLTFLoader();
|
|
24
|
-
dracoLoader.setDecoderPath(dracoDecoderPath);
|
|
25
|
-
gltfLoader.setDRACOLoader(dracoLoader);
|
|
26
|
-
var treatGeometry = function treatGeometry(res) {
|
|
27
|
-
res.scene.traverse(function (obj) {
|
|
28
|
-
if (obj.isMesh || obj.isSkinnedMesh) {
|
|
29
|
-
var keys = Object.keys(obj.material);
|
|
30
|
-
keys.forEach(function (key) {
|
|
31
|
-
var value = obj.material[key];
|
|
32
|
-
if (value && value.isTexture) {
|
|
33
|
-
obj.material[key].image = whiteImage;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
obj.material.needsUpdate = true;
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
var fetchGlb = function fetchGlb(originalUrl) {
|
|
41
|
-
var isTexturableObject = originalUrl.includes('/character/') || originalUrl.includes('/object/') || originalUrl.includes('/gl_asset/');
|
|
42
|
-
var url = isTexturableObject ? originalUrl.replace('.glb', '.geometry.glb') : originalUrl;
|
|
43
|
-
return new Promise(function (resolve, reject) {
|
|
44
|
-
gltfLoader.load(url, function (result) {
|
|
45
|
-
treatGeometry(result);
|
|
46
|
-
// result.scene.userData.url = originalUrl;
|
|
47
|
-
resolve(result);
|
|
48
|
-
}, null, function (error) {
|
|
49
|
-
return reject(error);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
var useGLB = function useGLB(url) {
|
|
54
|
-
return (0, _reactPromiseSuspense.default)(fetchGlb, [url]);
|
|
55
|
-
};
|
|
56
|
-
var _default = useGLB;
|
|
57
|
-
exports.default = _default;
|
|
@@ -1,277 +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
|
-
var _GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader");
|
|
10
|
-
var _fiber = require("@react-three/fiber");
|
|
11
|
-
var _ = require(".");
|
|
12
|
-
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; }
|
|
13
|
-
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); } }
|
|
14
|
-
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); }); }; }
|
|
15
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
16
|
-
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."); }
|
|
17
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
18
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
19
|
-
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; }
|
|
20
|
-
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; }
|
|
21
|
-
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; }
|
|
22
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
23
|
-
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); }
|
|
24
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
25
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
26
|
-
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."); }
|
|
27
|
-
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); }
|
|
28
|
-
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; }
|
|
29
|
-
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; } }
|
|
30
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /* eslint-disable no-restricted-syntax */
|
|
31
|
-
var loader = new _GLTFLoader.GLTFLoader();
|
|
32
|
-
function useStateMachine(lines) {
|
|
33
|
-
var scene = (0, _fiber.useThree)(function (s) {
|
|
34
|
-
return s.scene;
|
|
35
|
-
});
|
|
36
|
-
var _useState = (0, _react.useState)(false),
|
|
37
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
-
loaded = _useState2[0],
|
|
39
|
-
setLoaded = _useState2[1];
|
|
40
|
-
var _useState3 = (0, _react.useState)([]),
|
|
41
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
42
|
-
queue = _useState4[0],
|
|
43
|
-
setQueue = _useState4[1];
|
|
44
|
-
var data = (0, _react.useMemo)(function () {
|
|
45
|
-
var urls = {};
|
|
46
|
-
var _iterator = _createForOfIteratorHelper(lines),
|
|
47
|
-
_step;
|
|
48
|
-
try {
|
|
49
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
50
|
-
var line = _step.value;
|
|
51
|
-
if (!line.slots) continue;
|
|
52
|
-
var _iterator2 = _createForOfIteratorHelper(line.slots),
|
|
53
|
-
_step2;
|
|
54
|
-
try {
|
|
55
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
56
|
-
var _slot$character;
|
|
57
|
-
var slot = _step2.value;
|
|
58
|
-
if (!slot.uid) continue;
|
|
59
|
-
var animations = (_slot$character = slot.character) === null || _slot$character === void 0 ? void 0 : _slot$character.resource.animations;
|
|
60
|
-
if (!animations) continue;
|
|
61
|
-
if (!urls[slot.uid]) {
|
|
62
|
-
urls[slot.uid] = _defineProperty({}, slot.emotion, animations[slot.emotion].url);
|
|
63
|
-
} else {
|
|
64
|
-
urls[slot.uid] = _objectSpread(_objectSpread({}, urls[slot.uid]), {}, _defineProperty({}, slot.emotion, animations[slot.emotion].url));
|
|
65
|
-
}
|
|
66
|
-
if (!slot.emotion.includes('seated')) {
|
|
67
|
-
var _animations;
|
|
68
|
-
urls[slot.uid] = _objectSpread(_objectSpread({}, urls[slot.uid]), {}, _defineProperty({}, "".concat(slot.emotion, "-seated"), ((_animations = animations["".concat(slot.emotion, "-seated")]) === null || _animations === void 0 ? void 0 : _animations.url) || animations['idle-seated'].url));
|
|
69
|
-
}
|
|
70
|
-
urls[slot.uid].talking = animations.talking.url;
|
|
71
|
-
}
|
|
72
|
-
} catch (err) {
|
|
73
|
-
_iterator2.e(err);
|
|
74
|
-
} finally {
|
|
75
|
-
_iterator2.f();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
} catch (err) {
|
|
79
|
-
_iterator.e(err);
|
|
80
|
-
} finally {
|
|
81
|
-
_iterator.f();
|
|
82
|
-
}
|
|
83
|
-
return urls;
|
|
84
|
-
}, [lines]);
|
|
85
|
-
var uids = (0, _react.useMemo)(function () {
|
|
86
|
-
var set = new Set();
|
|
87
|
-
var _iterator3 = _createForOfIteratorHelper(lines),
|
|
88
|
-
_step3;
|
|
89
|
-
try {
|
|
90
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
91
|
-
var line = _step3.value;
|
|
92
|
-
if (!line.slots) continue;
|
|
93
|
-
var _iterator4 = _createForOfIteratorHelper(line.slots),
|
|
94
|
-
_step4;
|
|
95
|
-
try {
|
|
96
|
-
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
97
|
-
var slot = _step4.value;
|
|
98
|
-
if (!slot.uid) continue;
|
|
99
|
-
set.add(slot.uid);
|
|
100
|
-
}
|
|
101
|
-
} catch (err) {
|
|
102
|
-
_iterator4.e(err);
|
|
103
|
-
} finally {
|
|
104
|
-
_iterator4.f();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
} catch (err) {
|
|
108
|
-
_iterator3.e(err);
|
|
109
|
-
} finally {
|
|
110
|
-
_iterator3.f();
|
|
111
|
-
}
|
|
112
|
-
return Array.from(set);
|
|
113
|
-
}, [lines]);
|
|
114
|
-
var resetActives = function resetActives() {
|
|
115
|
-
uids.forEach(function (uid) {
|
|
116
|
-
startAnimation(uid, 'idle');
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
(0, _react.useEffect)(function () {
|
|
120
|
-
if (loaded && queue.length) {
|
|
121
|
-
queue.forEach(function (q) {
|
|
122
|
-
startAnimation(q.uid, q.emotion);
|
|
123
|
-
});
|
|
124
|
-
setQueue([]);
|
|
125
|
-
}
|
|
126
|
-
}, [queue, loaded, startAnimation]);
|
|
127
|
-
var startAnimation = (0, _react.useCallback)(function (uid, emotion) {
|
|
128
|
-
var root = scene.getObjectByProperty('uid', uid);
|
|
129
|
-
if (!root) return;
|
|
130
|
-
if (!loaded) {
|
|
131
|
-
var q = {
|
|
132
|
-
uid: uid,
|
|
133
|
-
emotion: emotion
|
|
134
|
-
};
|
|
135
|
-
setQueue(function (s) {
|
|
136
|
-
return s.includes(q) ? s : [].concat(_toConsumableArray(s), [q]);
|
|
137
|
-
});
|
|
138
|
-
} else {
|
|
139
|
-
var _root$userData = root.userData,
|
|
140
|
-
mixer = _root$userData.mixer,
|
|
141
|
-
actionList = _root$userData.actionList,
|
|
142
|
-
active = _root$userData.active;
|
|
143
|
-
if (emotion === active) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
var startAction = actionList[active];
|
|
147
|
-
var endAction = actionList[emotion];
|
|
148
|
-
if (startAction && endAction) {
|
|
149
|
-
(0, _.resetActions)(mixer, startAction);
|
|
150
|
-
(0, _.executeCrossFade)(startAction, endAction);
|
|
151
|
-
root.userData.active = emotion;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}, [scene, loaded]);
|
|
155
|
-
var processAnimations = (0, _react.useCallback)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
156
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
157
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
158
|
-
case 0:
|
|
159
|
-
_context4.next = 2;
|
|
160
|
-
return Promise.all(Object.keys(data).map( /*#__PURE__*/function () {
|
|
161
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(uid) {
|
|
162
|
-
var actions, root, _root$userData2, mixer, defaultAnim, actionList, defaultAction, loadEmotion;
|
|
163
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
164
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
165
|
-
case 0:
|
|
166
|
-
actions = _objectSpread({}, data[uid]);
|
|
167
|
-
root = scene.getObjectByProperty('uid', uid);
|
|
168
|
-
if (root) {
|
|
169
|
-
_context3.next = 4;
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
return _context3.abrupt("return");
|
|
173
|
-
case 4:
|
|
174
|
-
_root$userData2 = root.userData, mixer = _root$userData2.mixer, defaultAnim = _root$userData2.defaultAnim;
|
|
175
|
-
if (!root.userData.actionList) root.userData.actionList = {};
|
|
176
|
-
actionList = root.userData.actionList;
|
|
177
|
-
if (!actionList.idle) {
|
|
178
|
-
defaultAction = mixer.existingAction(defaultAnim, root);
|
|
179
|
-
actionList.idle = defaultAction;
|
|
180
|
-
root.userData.active = 'idle';
|
|
181
|
-
}
|
|
182
|
-
loadEmotion = /*#__PURE__*/function () {
|
|
183
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(emotion) {
|
|
184
|
-
var url, gltf, clip, clone, talkingClip, _action, action;
|
|
185
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
186
|
-
while (1) switch (_context.prev = _context.next) {
|
|
187
|
-
case 0:
|
|
188
|
-
if (!actionList[emotion]) {
|
|
189
|
-
_context.next = 2;
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
return _context.abrupt("return");
|
|
193
|
-
case 2:
|
|
194
|
-
url = actions[emotion];
|
|
195
|
-
_context.next = 5;
|
|
196
|
-
return loader.loadAsync(url);
|
|
197
|
-
case 5:
|
|
198
|
-
gltf = _context.sent;
|
|
199
|
-
clip = gltf.animations[0];
|
|
200
|
-
if (emotion !== 'talking' && actionList.talking) {
|
|
201
|
-
clone = clip.clone();
|
|
202
|
-
clone.name = "".concat(emotion, "_talking");
|
|
203
|
-
actionList.talking.reset();
|
|
204
|
-
talkingClip = actionList.talking.getClip();
|
|
205
|
-
_action = (0, _.mixWithTalkingClip)(root, talkingClip, clone);
|
|
206
|
-
(0, _.activateAction)(_action, 0);
|
|
207
|
-
actionList[clone.name] = _action;
|
|
208
|
-
}
|
|
209
|
-
clip.name = emotion;
|
|
210
|
-
action = mixer.clipAction(clip, root);
|
|
211
|
-
(0, _.activateAction)(action, 0);
|
|
212
|
-
actionList[clip.name] = action;
|
|
213
|
-
case 12:
|
|
214
|
-
case "end":
|
|
215
|
-
return _context.stop();
|
|
216
|
-
}
|
|
217
|
-
}, _callee);
|
|
218
|
-
}));
|
|
219
|
-
return function loadEmotion(_x3) {
|
|
220
|
-
return _ref3.apply(this, arguments);
|
|
221
|
-
};
|
|
222
|
-
}();
|
|
223
|
-
if (!(!actionList.talking && actions.talking)) {
|
|
224
|
-
_context3.next = 12;
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
_context3.next = 12;
|
|
228
|
-
return loadEmotion('talking');
|
|
229
|
-
case 12:
|
|
230
|
-
_context3.next = 14;
|
|
231
|
-
return Promise.all(Object.keys(actions).map( /*#__PURE__*/function () {
|
|
232
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(emotion) {
|
|
233
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
234
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
235
|
-
case 0:
|
|
236
|
-
_context2.next = 2;
|
|
237
|
-
return loadEmotion(emotion);
|
|
238
|
-
case 2:
|
|
239
|
-
case "end":
|
|
240
|
-
return _context2.stop();
|
|
241
|
-
}
|
|
242
|
-
}, _callee2);
|
|
243
|
-
}));
|
|
244
|
-
return function (_x4) {
|
|
245
|
-
return _ref4.apply(this, arguments);
|
|
246
|
-
};
|
|
247
|
-
}()));
|
|
248
|
-
case 14:
|
|
249
|
-
case "end":
|
|
250
|
-
return _context3.stop();
|
|
251
|
-
}
|
|
252
|
-
}, _callee3);
|
|
253
|
-
}));
|
|
254
|
-
return function (_x2) {
|
|
255
|
-
return _ref2.apply(this, arguments);
|
|
256
|
-
};
|
|
257
|
-
}()));
|
|
258
|
-
case 2:
|
|
259
|
-
setLoaded(true);
|
|
260
|
-
case 3:
|
|
261
|
-
case "end":
|
|
262
|
-
return _context4.stop();
|
|
263
|
-
}
|
|
264
|
-
}, _callee4);
|
|
265
|
-
})), [data, scene]);
|
|
266
|
-
|
|
267
|
-
// Load emotions
|
|
268
|
-
(0, _react.useEffect)(function () {
|
|
269
|
-
processAnimations();
|
|
270
|
-
}, [processAnimations]);
|
|
271
|
-
return {
|
|
272
|
-
startAnimation: startAnimation,
|
|
273
|
-
resetActives: resetActives
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
var _default = useStateMachine;
|
|
277
|
-
exports.default = _default;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var useTimeout = function useTimeout() {
|
|
9
|
-
var timeout = (0, _react.useRef)();
|
|
10
|
-
var start = function start(fn, ms) {
|
|
11
|
-
timeout.current = setTimeout(fn, ms);
|
|
12
|
-
};
|
|
13
|
-
var stop = function stop() {
|
|
14
|
-
if (timeout.current) {
|
|
15
|
-
clearTimeout(timeout.current);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
(0, _react.useEffect)(function () {
|
|
19
|
-
return function () {
|
|
20
|
-
if (timeout.current) {
|
|
21
|
-
clearTimeout(timeout.current);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
}, []);
|
|
25
|
-
return {
|
|
26
|
-
start: start,
|
|
27
|
-
stop: stop,
|
|
28
|
-
running: !!timeout.current
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
var _default = useTimeout;
|
|
32
|
-
exports.default = _default;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.useWindowSize = exports.default = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
-
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."); }
|
|
10
|
-
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); }
|
|
11
|
-
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; }
|
|
12
|
-
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; } }
|
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
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); }
|
|
15
|
-
// Hook
|
|
16
|
-
var useWindowSize = function useWindowSize() {
|
|
17
|
-
var isClient = (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object';
|
|
18
|
-
var _useState = (0, _react.useState)({
|
|
19
|
-
width: isClient ? window.innerWidth : undefined,
|
|
20
|
-
height: isClient ? window.innerHeight : undefined
|
|
21
|
-
}),
|
|
22
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
-
windowSize = _useState2[0],
|
|
24
|
-
setWindowSize = _useState2[1];
|
|
25
|
-
(0, _react.useEffect)(function () {
|
|
26
|
-
if (!isClient) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
function handleResize() {
|
|
30
|
-
setWindowSize({
|
|
31
|
-
width: isClient ? window.innerWidth : undefined,
|
|
32
|
-
height: isClient ? window.innerHeight : undefined
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
window.addEventListener('resize', handleResize);
|
|
36
|
-
return function () {
|
|
37
|
-
return window.removeEventListener('resize', handleResize);
|
|
38
|
-
};
|
|
39
|
-
}, [isClient]);
|
|
40
|
-
return windowSize;
|
|
41
|
-
};
|
|
42
|
-
exports.useWindowSize = useWindowSize;
|
|
43
|
-
var _default = useWindowSize;
|
|
44
|
-
exports.default = _default;
|
package/dist/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _components = require("./components");
|
|
7
|
-
Object.keys(_components).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _components[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function get() {
|
|
13
|
-
return _components[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.mockScene = exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _arcadeThreeCore = require("@gamelearn/arcade-three-core");
|
|
9
|
-
var _bg001_street = _interopRequireDefault(require("./mocks/bg001_street.json"));
|
|
10
|
-
var _characters = require("./mocks/characters.json");
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
var mockScene = {
|
|
13
|
-
background: _bg001_street.default,
|
|
14
|
-
elements: _characters.elements,
|
|
15
|
-
scene: {
|
|
16
|
-
loadingText: 'Cargando... {percent}%'
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
exports.mockScene = mockScene;
|
|
20
|
-
var SceneWrapper = function SceneWrapper(_ref) {
|
|
21
|
-
var children = _ref.children;
|
|
22
|
-
return /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.Renderer, mockScene.scene, /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.Debugger, null), /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.LodWrapper, {
|
|
23
|
-
progressive: true
|
|
24
|
-
}, /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.BackgroundWrapper, {
|
|
25
|
-
objects: Object.values(mockScene.background)
|
|
26
|
-
}), /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.ElementsWrapper, {
|
|
27
|
-
elements: _characters.elements
|
|
28
|
-
}), children));
|
|
29
|
-
};
|
|
30
|
-
var _default = SceneWrapper;
|
|
31
|
-
exports.default = _default;
|