@gamelearn/arcade-components 2.31.1 → 2.31.3

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.
@@ -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
- startAnimation(talkingCharacter.uid, "".concat(emotion, "_talking"));
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
- startAnimation(talkingCharacter.uid, emotion);
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;
@@ -369,6 +381,7 @@ var DialogComponent = function DialogComponent(_ref) {
369
381
  var backLine = (0, _react.useCallback)(function () {
370
382
  lastTalking.current = _objectSpread({}, talkingCharacter);
371
383
  setAudioFailed(false);
384
+ resetTalkingAnimation();
372
385
  if (isBranched) {
373
386
  handleBranchDirection(false);
374
387
  } else if (!previousLineWasDecision()) {
@@ -427,6 +440,7 @@ var DialogComponent = function DialogComponent(_ref) {
427
440
  lastTalking.current = _objectSpread({}, talkingCharacter);
428
441
  setEdgesHistory([].concat(_toConsumableArray(edgesHistory), [currentLineData.id]));
429
442
  setAudioFailed(false);
443
+ resetTalkingAnimation();
430
444
  if (isBranched) {
431
445
  if (choice) {
432
446
  handleDecisionBranch(choice, reset);
@@ -551,7 +565,12 @@ var DialogComponent = function DialogComponent(_ref) {
551
565
 
552
566
  // Check not talking elements emotion
553
567
  slottedCharacters.forEach(function (c) {
554
- startAnimation(c.uid, c.emotion);
568
+ var sceneElement = getCurrentVisible(c.uid);
569
+ if (sceneElement) {
570
+ var isSeated = sceneElement.isSeated;
571
+ var includesSeated = c.emotion.includes('seated');
572
+ startAnimation(c.uid, isSeated && !includesSeated ? "".concat(c.emotion, "-seated") : c.emotion);
573
+ }
555
574
  });
556
575
  var element = getCurrentVisible(talkingCharacter.uid);
557
576
  var object = actors.find(function (a) {
@@ -560,8 +579,15 @@ var DialogComponent = function DialogComponent(_ref) {
560
579
  if (element && !lastSet.current) {
561
580
  setTimeout(function () {
562
581
  if (talkingCharacter.uid === element.uid) {
582
+ var _userData$active, _userData$active2;
563
583
  moveBubble(element);
564
- startAnimation(talkingCharacter.uid, talkingCharacter.emotion);
584
+ var isSeated = element.isSeated,
585
+ userData = element.userData;
586
+ var emotion = talkingCharacter.emotion;
587
+ var includesSeated = emotion.includes('seated');
588
+ if (!((_userData$active = userData.active) !== null && _userData$active !== void 0 && _userData$active.includes('talking')) && !((_userData$active2 = userData.active) !== null && _userData$active2 !== void 0 && _userData$active2.includes(emotion))) {
589
+ startAnimation(talkingCharacter.uid, isSeated && !includesSeated ? "".concat(emotion, "-seated") : emotion);
590
+ }
565
591
  var setMessage = function setMessage() {
566
592
  var _talkingCharacter$cha;
567
593
  setCurrentMessage({
@@ -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
- urls[slot.uid].talking = (_slot$character3 = slot.character) === null || _slot$character3 === void 0 ? void 0 : _slot$character3.resource.animations.talking.url;
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
- Object.keys(active).forEach(function (uid) {
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
- var currentActive = active[uid];
127
- if (emotion === currentActive) return;
128
- var startAction = actionList[currentActive];
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
- setActive(uid, emotion);
131
- (0, _.resetActions)(mixer, startAction);
132
- (0, _.executeCrossFade)(startAction, endAction);
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, active, setActive]);
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
- setActive(uid, 'idle');
180
+ root.userData.active = 'idle';
161
181
  }
162
182
  loadEmotion = /*#__PURE__*/function () {
163
183
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(emotion) {
@@ -180,6 +200,7 @@ function useStateMachine(lines) {
180
200
  if (emotion !== 'talking' && actionList.talking) {
181
201
  clone = clip.clone();
182
202
  clone.name = "".concat(emotion, "_talking");
203
+ actionList.talking.reset();
183
204
  talkingClip = actionList.talking.getClip();
184
205
  _action = (0, _.mixWithTalkingClip)(root, talkingClip, clone);
185
206
  (0, _.activateAction)(_action, 0);
@@ -241,7 +262,7 @@ function useStateMachine(lines) {
241
262
  return _context4.stop();
242
263
  }
243
264
  }, _callee4);
244
- })), [data, scene, setActive]);
265
+ })), [data, scene]);
245
266
 
246
267
  // Load emotions
247
268
  (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.1",
5
+ "version": "2.31.3",
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",