@gamelearn/arcade-components 2.31.0 → 2.31.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/dist/components/conversational-pro-component/components/ConversationalProComponent.js +20 -15
- package/dist/components/decision-component/components/DecisionComponent.js +5 -1
- package/dist/components/dialog-component/components/DialogComponent.js +31 -6
- package/dist/helpers/useStateMachine.js +57 -37
- package/package.json +2 -3
package/dist/components/conversational-pro-component/components/ConversationalProComponent.js
CHANGED
|
@@ -476,22 +476,27 @@ var ConversationalProComponent = function ConversationalProComponent(_ref) {
|
|
|
476
476
|
}
|
|
477
477
|
}, [edges, isBranched, lines, mounted, progress === null || progress === void 0 ? void 0 : progress.line]);
|
|
478
478
|
keyboardControl(isDecision || disableBackButton ? null : manualClickBack, isDecision ? null : manualClickNext);
|
|
479
|
-
var decisionPayload = _objectSpread(_objectSpread({}, currentLineData.payload), {}, {
|
|
480
|
-
required: !isBranched,
|
|
481
|
-
branched: isBranched,
|
|
482
|
-
onAddPoints: decisionNotifyProgress,
|
|
483
|
-
onFinish: handleClickNext,
|
|
484
|
-
keyboardControl: keyboardControl,
|
|
485
|
-
emitEvent: emitEvent,
|
|
486
|
-
soundActions: soundActions,
|
|
487
|
-
inheritProps: {
|
|
488
|
-
characters: currentCharacters,
|
|
489
|
-
background: background,
|
|
490
|
-
flex: leftWithSlots ? leftWithSlots.flex : true,
|
|
491
|
-
slots: !leftWithSlots ? [] : leftWithSlots.slots
|
|
492
|
-
}
|
|
493
|
-
});
|
|
494
479
|
if (isDecision) {
|
|
480
|
+
var decisionPayload = _objectSpread(_objectSpread({}, currentLineData.payload), {}, {
|
|
481
|
+
decisionNumber: lines.filter(function (l) {
|
|
482
|
+
return l.decision;
|
|
483
|
+
}).findIndex(function (l) {
|
|
484
|
+
return l.id === lines[currentLine].id;
|
|
485
|
+
}) + 1,
|
|
486
|
+
required: !isBranched,
|
|
487
|
+
branched: isBranched,
|
|
488
|
+
onAddPoints: decisionNotifyProgress,
|
|
489
|
+
onFinish: handleClickNext,
|
|
490
|
+
keyboardControl: keyboardControl,
|
|
491
|
+
emitEvent: emitEvent,
|
|
492
|
+
soundActions: soundActions,
|
|
493
|
+
inheritProps: {
|
|
494
|
+
characters: currentCharacters,
|
|
495
|
+
background: background,
|
|
496
|
+
flex: leftWithSlots ? leftWithSlots.flex : true,
|
|
497
|
+
slots: !leftWithSlots ? [] : leftWithSlots.slots
|
|
498
|
+
}
|
|
499
|
+
});
|
|
495
500
|
return /*#__PURE__*/_react.default.createElement(_decisionComponent.default, decisionPayload);
|
|
496
501
|
}
|
|
497
502
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -34,6 +34,7 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
34
34
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
35
35
|
var _props$inheritProps = props.inheritProps,
|
|
36
36
|
inheritProps = _props$inheritProps === void 0 ? {} : _props$inheritProps,
|
|
37
|
+
decisionNumber = props.decisionNumber,
|
|
37
38
|
required = props.required,
|
|
38
39
|
question = props.question,
|
|
39
40
|
onAddPoints = props.onAddPoints,
|
|
@@ -78,7 +79,10 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
78
79
|
var emitGameData = function emitGameData(choice) {
|
|
79
80
|
emitEvent({
|
|
80
81
|
type: 'decisionJournal',
|
|
81
|
-
payload:
|
|
82
|
+
payload: {
|
|
83
|
+
choice: choice,
|
|
84
|
+
decisionNumber: decisionNumber
|
|
85
|
+
}
|
|
82
86
|
});
|
|
83
87
|
};
|
|
84
88
|
var onNext = function onNext(choice) {
|
|
@@ -273,13 +273,25 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
273
273
|
}, [zoomInActor]);
|
|
274
274
|
var startTalking = function startTalking() {
|
|
275
275
|
if (!(talkingCharacter !== null && talkingCharacter !== void 0 && talkingCharacter.emotion) || lastSet.current) return;
|
|
276
|
-
var emotion = talkingCharacter.emotion
|
|
277
|
-
|
|
276
|
+
var emotion = talkingCharacter.emotion,
|
|
277
|
+
uid = talkingCharacter.uid;
|
|
278
|
+
var sceneElement = getCurrentVisible(uid);
|
|
279
|
+
if (sceneElement) {
|
|
280
|
+
var isSeated = sceneElement.isSeated;
|
|
281
|
+
var includesSeated = emotion.includes('seated');
|
|
282
|
+
startAnimation(uid, isSeated && !includesSeated ? "".concat(emotion, "-seated_talking") : "".concat(emotion, "_talking"));
|
|
283
|
+
}
|
|
278
284
|
};
|
|
279
285
|
var resetTalkingAnimation = function resetTalkingAnimation() {
|
|
280
286
|
if (!(talkingCharacter !== null && talkingCharacter !== void 0 && talkingCharacter.uid) || lastSet.current) return;
|
|
281
|
-
var emotion = talkingCharacter.emotion
|
|
282
|
-
|
|
287
|
+
var emotion = talkingCharacter.emotion,
|
|
288
|
+
uid = talkingCharacter.uid;
|
|
289
|
+
var sceneElement = getCurrentVisible(uid);
|
|
290
|
+
if (sceneElement) {
|
|
291
|
+
var isSeated = sceneElement.isSeated;
|
|
292
|
+
var includesSeated = emotion.includes('seated');
|
|
293
|
+
startAnimation(uid, isSeated && !includesSeated ? "".concat(emotion, "-seated") : emotion);
|
|
294
|
+
}
|
|
283
295
|
};
|
|
284
296
|
var finishConversation = (0, _react.useCallback)(function () {
|
|
285
297
|
lastSet.current = true;
|
|
@@ -551,7 +563,12 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
551
563
|
|
|
552
564
|
// Check not talking elements emotion
|
|
553
565
|
slottedCharacters.forEach(function (c) {
|
|
554
|
-
|
|
566
|
+
var sceneElement = getCurrentVisible(c.uid);
|
|
567
|
+
if (sceneElement) {
|
|
568
|
+
var isSeated = sceneElement.isSeated;
|
|
569
|
+
var includesSeated = c.emotion.includes('seated');
|
|
570
|
+
startAnimation(c.uid, isSeated && !includesSeated ? "".concat(c.emotion, "-seated") : c.emotion);
|
|
571
|
+
}
|
|
555
572
|
});
|
|
556
573
|
var element = getCurrentVisible(talkingCharacter.uid);
|
|
557
574
|
var object = actors.find(function (a) {
|
|
@@ -561,7 +578,10 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
561
578
|
setTimeout(function () {
|
|
562
579
|
if (talkingCharacter.uid === element.uid) {
|
|
563
580
|
moveBubble(element);
|
|
564
|
-
|
|
581
|
+
var isSeated = element.isSeated;
|
|
582
|
+
var emotion = talkingCharacter.emotion;
|
|
583
|
+
var includesSeated = emotion.includes('seated');
|
|
584
|
+
startAnimation(talkingCharacter.uid, isSeated && !includesSeated ? "".concat(emotion, "-seated") : emotion);
|
|
565
585
|
var setMessage = function setMessage() {
|
|
566
586
|
var _talkingCharacter$cha;
|
|
567
587
|
setCurrentMessage({
|
|
@@ -670,6 +690,11 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
670
690
|
var container = document.querySelector('.screens--container');
|
|
671
691
|
if (isDecision) {
|
|
672
692
|
var decisionPayload = _objectSpread(_objectSpread({}, currentLineData.payload), {}, {
|
|
693
|
+
decisionNumber: lines.filter(function (l) {
|
|
694
|
+
return l.decision;
|
|
695
|
+
}).findIndex(function (l) {
|
|
696
|
+
return l.id === currentLineData.id;
|
|
697
|
+
}) + 1,
|
|
673
698
|
inheritProps: {
|
|
674
699
|
slots: [],
|
|
675
700
|
disableBackground: true
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
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); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
7
8
|
var _react = require("react");
|
|
8
9
|
var _GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader");
|
|
9
|
-
var _zustand = _interopRequireDefault(require("zustand"));
|
|
10
10
|
var _fiber = require("@react-three/fiber");
|
|
11
11
|
var _ = require(".");
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
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); }
|
|
14
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; }
|
|
15
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); } }
|
|
16
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); }); }; }
|
|
@@ -18,35 +16,20 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
|
|
|
18
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."); }
|
|
19
17
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
20
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); }
|
|
21
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; } } }; }
|
|
22
25
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
23
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."); }
|
|
24
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); }
|
|
25
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; }
|
|
26
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; } }
|
|
27
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
28
|
-
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; }
|
|
29
|
-
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; }
|
|
30
|
-
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; }
|
|
31
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
32
|
-
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); } /* eslint-disable no-restricted-syntax */
|
|
30
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /* eslint-disable no-restricted-syntax */
|
|
33
31
|
var loader = new _GLTFLoader.GLTFLoader();
|
|
34
|
-
var useAnimationFactory = (0, _zustand.default)(function (set) {
|
|
35
|
-
return {
|
|
36
|
-
active: {},
|
|
37
|
-
setActive: function setActive(uid, active) {
|
|
38
|
-
return set(function (s) {
|
|
39
|
-
return {
|
|
40
|
-
active: _objectSpread(_objectSpread({}, s.active), {}, _defineProperty({}, uid, active))
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
});
|
|
46
32
|
function useStateMachine(lines) {
|
|
47
|
-
var _useAnimationFactory = useAnimationFactory(),
|
|
48
|
-
active = _useAnimationFactory.active,
|
|
49
|
-
setActive = _useAnimationFactory.setActive;
|
|
50
33
|
var scene = (0, _fiber.useThree)(function (s) {
|
|
51
34
|
return s.scene;
|
|
52
35
|
});
|
|
@@ -70,7 +53,7 @@ function useStateMachine(lines) {
|
|
|
70
53
|
_step2;
|
|
71
54
|
try {
|
|
72
55
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
73
|
-
var _slot$character3;
|
|
56
|
+
var _slot$character3, _slot$character5;
|
|
74
57
|
var slot = _step2.value;
|
|
75
58
|
if (!slot.uid) continue;
|
|
76
59
|
if (!urls[slot.uid]) {
|
|
@@ -80,7 +63,11 @@ function useStateMachine(lines) {
|
|
|
80
63
|
var _slot$character2;
|
|
81
64
|
urls[slot.uid] = _objectSpread(_objectSpread({}, urls[slot.uid]), {}, _defineProperty({}, slot.emotion, (_slot$character2 = slot.character) === null || _slot$character2 === void 0 ? void 0 : _slot$character2.resource.animations[slot.emotion].url));
|
|
82
65
|
}
|
|
83
|
-
|
|
66
|
+
if (!slot.emotion.includes('seated') && (_slot$character3 = slot.character) !== null && _slot$character3 !== void 0 && _slot$character3.resource.animations["".concat(slot.emotion, "-seated")]) {
|
|
67
|
+
var _slot$character4;
|
|
68
|
+
urls[slot.uid] = _objectSpread(_objectSpread({}, urls[slot.uid]), {}, _defineProperty({}, "".concat(slot.emotion, "-seated"), (_slot$character4 = slot.character) === null || _slot$character4 === void 0 ? void 0 : _slot$character4.resource.animations["".concat(slot.emotion, "-seated")].url));
|
|
69
|
+
}
|
|
70
|
+
urls[slot.uid].talking = (_slot$character5 = slot.character) === null || _slot$character5 === void 0 ? void 0 : _slot$character5.resource.animations.talking.url;
|
|
84
71
|
}
|
|
85
72
|
} catch (err) {
|
|
86
73
|
_iterator2.e(err);
|
|
@@ -95,8 +82,37 @@ function useStateMachine(lines) {
|
|
|
95
82
|
}
|
|
96
83
|
return urls;
|
|
97
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]);
|
|
98
114
|
var resetActives = function resetActives() {
|
|
99
|
-
|
|
115
|
+
uids.forEach(function (uid) {
|
|
100
116
|
startAnimation(uid, 'idle');
|
|
101
117
|
});
|
|
102
118
|
};
|
|
@@ -122,16 +138,20 @@ function useStateMachine(lines) {
|
|
|
122
138
|
} else {
|
|
123
139
|
var _root$userData = root.userData,
|
|
124
140
|
mixer = _root$userData.mixer,
|
|
125
|
-
actionList = _root$userData.actionList
|
|
126
|
-
|
|
127
|
-
if (emotion ===
|
|
128
|
-
|
|
141
|
+
actionList = _root$userData.actionList,
|
|
142
|
+
active = _root$userData.active;
|
|
143
|
+
if (emotion === active) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
var startAction = actionList[active];
|
|
129
147
|
var endAction = actionList[emotion];
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
148
|
+
if (startAction && endAction) {
|
|
149
|
+
(0, _.resetActions)(mixer, startAction);
|
|
150
|
+
(0, _.executeCrossFade)(startAction, endAction);
|
|
151
|
+
root.userData.active = emotion;
|
|
152
|
+
}
|
|
133
153
|
}
|
|
134
|
-
}, [scene, loaded
|
|
154
|
+
}, [scene, loaded]);
|
|
135
155
|
var processAnimations = (0, _react.useCallback)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
136
156
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
137
157
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -157,7 +177,7 @@ function useStateMachine(lines) {
|
|
|
157
177
|
if (!actionList.idle) {
|
|
158
178
|
defaultAction = mixer.existingAction(defaultAnim, root);
|
|
159
179
|
actionList.idle = defaultAction;
|
|
160
|
-
|
|
180
|
+
root.userData.active = 'idle';
|
|
161
181
|
}
|
|
162
182
|
loadEmotion = /*#__PURE__*/function () {
|
|
163
183
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(emotion) {
|
|
@@ -241,7 +261,7 @@ function useStateMachine(lines) {
|
|
|
241
261
|
return _context4.stop();
|
|
242
262
|
}
|
|
243
263
|
}, _callee4);
|
|
244
|
-
})), [data, scene
|
|
264
|
+
})), [data, scene]);
|
|
245
265
|
|
|
246
266
|
// Load emotions
|
|
247
267
|
(0, _react.useEffect)(function () {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@gamelearn/arcade-components",
|
|
3
3
|
"author": "Gamelearn",
|
|
4
4
|
"license": "unlicense",
|
|
5
|
-
"version": "2.31.
|
|
5
|
+
"version": "2.31.2",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
"react-promise-suspense": "0.3.3",
|
|
36
36
|
"react-typist": "^2.0.5",
|
|
37
37
|
"three": "0.139.2",
|
|
38
|
-
"web-vitals": "0.2.4"
|
|
39
|
-
"zustand": "4.3.8"
|
|
38
|
+
"web-vitals": "0.2.4"
|
|
40
39
|
},
|
|
41
40
|
"scripts": {
|
|
42
41
|
"start": "npm run storybook",
|