@gamelearn/arcade-components 2.29.3 → 2.29.4-hotfix-animationsv2
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 +107 -107
- package/dist/components/auto-evaluation-component/components/AutoEvaluation.js +1 -1
- package/dist/components/conversational-pro-component/components/scene/Panel.js +1 -1
- package/dist/components/dialog-component/components/DialogComponent.js +35 -9
- package/dist/helpers/index.js +57 -3
- package/dist/helpers/useStateMachine.js +61 -41
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
# Arcade Components
|
|
2
|
-
> librería de componentes para Arcade (aka engine 2.0)
|
|
3
|
-
|
|
4
|
-
[](https://www.npmjs.com/package/arcade-components) [](https://standardjs.com)
|
|
5
|
-
|
|
6
|
-
## Install
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
yarn add @gamelearn/arcade-components
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## Usage
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
```jsx
|
|
16
|
-
import React, { Component } from 'react';
|
|
17
|
-
|
|
18
|
-
import { Button } from 'arcade-components';
|
|
19
|
-
|
|
20
|
-
export default class App extends Component {
|
|
21
|
-
render() {
|
|
22
|
-
return (
|
|
23
|
-
<div>
|
|
24
|
-
<Button>Enjoy</Button>
|
|
25
|
-
</div>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Generar version hotfix para arcade/master-stg
|
|
33
|
-
|
|
34
|
-
Para generar una version hotfix nos vamos al commit que desplego la version que utiliza actualmente arcade/master-stg y creamos una rama sobre ella.
|
|
35
|
-
|
|
36
|
-
Generamos los cambios o hacemos cherrypick de ellos si ya estan creados y una vez terminemos con los cambios tendremos que cambiar la version del package.json a una tal que asi :
|
|
37
|
-
|
|
38
|
-
`"version": "1.3.5-fix-1",`
|
|
39
|
-
|
|
40
|
-
Habiendo cambiado ya la version para publicarla ejecutamos:
|
|
41
|
-
* `npm run publish-hotfix`
|
|
42
|
-
|
|
43
|
-
Una vez publicada en npm ir a la versión master de arcade y sustituir la versión de arcade-components.
|
|
44
|
-
|
|
45
|
-
## Available Scripts
|
|
46
|
-
|
|
47
|
-
Para ver Storybook en local
|
|
48
|
-
|
|
49
|
-
### `yarn start`
|
|
50
|
-
|
|
51
|
-
Para compilar la librería a dist
|
|
52
|
-
|
|
53
|
-
### `yarn compile`
|
|
54
|
-
|
|
55
|
-
Para dejar a babel observando cambios y ejecuntando auto-compilación puedes pasarle --watch
|
|
56
|
-
|
|
57
|
-
`yarn compile --watch`
|
|
58
|
-
|
|
59
|
-
### `yarn generate <componentName>`
|
|
60
|
-
|
|
61
|
-
Para añadir un componente nuevo se recomienda usar el generador automático que hara el scaffolding básico de dicho componente, coge el nombre como primer parámetro y si lo llamas sin parámetro te lo preguntará por el prompt.
|
|
62
|
-
|
|
63
|
-
`yarn generate`
|
|
64
|
-
|
|
65
|
-
## How to link arcade-components in other repos (WIP)
|
|
66
|
-
|
|
67
|
-
Para trabajar con arcade-components en local si necesidad de subir a git ni a npm no podemos trabajar con `yarn link` ya que da un error con los hooks de react.
|
|
68
|
-
|
|
69
|
-
Cómo solución alternativa podemos instalar `yalc` que permite publicar el paquete en local e importarlo desde `arcade`.
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
yarn global add yalc
|
|
73
|
-
```
|
|
74
|
-
Si teneis problemas instalándolo en global :
|
|
75
|
-
yarn global add yalc --prefix /usr/local
|
|
76
|
-
|
|
77
|
-
Para generar el paquete en el store local:
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
yarn
|
|
81
|
-
yarn compile
|
|
82
|
-
yalc publish o yarn yalc publish
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
Si queremos escuchar los cambios y que se vayan publicando en el store de yalc se puede hacer directamente con:
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
yarn watch
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
Después, en el repositorio de `arcade` tendremos que linkar el paquete generado de la siguiente forma:
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
yalc link @gamelearn/arcade-components
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
Y voilá, ya podremos trabajar con arcade y arcade-components en local sin publicar nada.
|
|
98
|
-
|
|
99
|
-
Una vez terminemos de trabajar con el paquete linkado en `arcade`, no nos olvidemos de borrar el link:
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
yalc remove --all
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## License
|
|
106
|
-
|
|
107
|
-
UNLICENSED © [gamelearn](https://github.com/gamelearn)
|
|
1
|
+
# Arcade Components
|
|
2
|
+
> librería de componentes para Arcade (aka engine 2.0)
|
|
3
|
+
|
|
4
|
+
[](https://www.npmjs.com/package/arcade-components) [](https://standardjs.com)
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
yarn add @gamelearn/arcade-components
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
##
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
import React, { Component } from 'react';
|
|
17
|
+
|
|
18
|
+
import { Button } from 'arcade-components';
|
|
19
|
+
|
|
20
|
+
export default class App extends Component {
|
|
21
|
+
render() {
|
|
22
|
+
return (
|
|
23
|
+
<div>
|
|
24
|
+
<Button>Enjoy</Button>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Generar version hotfix para arcade/master-stg
|
|
33
|
+
|
|
34
|
+
Para generar una version hotfix nos vamos al commit que desplego la version que utiliza actualmente arcade/master-stg y creamos una rama sobre ella.
|
|
35
|
+
|
|
36
|
+
Generamos los cambios o hacemos cherrypick de ellos si ya estan creados y una vez terminemos con los cambios tendremos que cambiar la version del package.json a una tal que asi :
|
|
37
|
+
|
|
38
|
+
`"version": "1.3.5-fix-1",`
|
|
39
|
+
|
|
40
|
+
Habiendo cambiado ya la version para publicarla ejecutamos:
|
|
41
|
+
* `npm run publish-hotfix`
|
|
42
|
+
|
|
43
|
+
Una vez publicada en npm ir a la versión master de arcade y sustituir la versión de arcade-components.
|
|
44
|
+
|
|
45
|
+
## Available Scripts
|
|
46
|
+
|
|
47
|
+
Para ver Storybook en local
|
|
48
|
+
|
|
49
|
+
### `yarn start`
|
|
50
|
+
|
|
51
|
+
Para compilar la librería a dist
|
|
52
|
+
|
|
53
|
+
### `yarn compile`
|
|
54
|
+
|
|
55
|
+
Para dejar a babel observando cambios y ejecuntando auto-compilación puedes pasarle --watch
|
|
56
|
+
|
|
57
|
+
`yarn compile --watch`
|
|
58
|
+
|
|
59
|
+
### `yarn generate <componentName>`
|
|
60
|
+
|
|
61
|
+
Para añadir un componente nuevo se recomienda usar el generador automático que hara el scaffolding básico de dicho componente, coge el nombre como primer parámetro y si lo llamas sin parámetro te lo preguntará por el prompt.
|
|
62
|
+
|
|
63
|
+
`yarn generate`
|
|
64
|
+
|
|
65
|
+
## How to link arcade-components in other repos (WIP)
|
|
66
|
+
|
|
67
|
+
Para trabajar con arcade-components en local si necesidad de subir a git ni a npm no podemos trabajar con `yarn link` ya que da un error con los hooks de react.
|
|
68
|
+
|
|
69
|
+
Cómo solución alternativa podemos instalar `yalc` que permite publicar el paquete en local e importarlo desde `arcade`.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
yarn global add yalc
|
|
73
|
+
```
|
|
74
|
+
Si teneis problemas instalándolo en global :
|
|
75
|
+
yarn global add yalc --prefix /usr/local
|
|
76
|
+
|
|
77
|
+
Para generar el paquete en el store local:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
yarn
|
|
81
|
+
yarn compile
|
|
82
|
+
yalc publish o yarn yalc publish
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Si queremos escuchar los cambios y que se vayan publicando en el store de yalc se puede hacer directamente con:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
yarn watch
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Después, en el repositorio de `arcade` tendremos que linkar el paquete generado de la siguiente forma:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
yalc link @gamelearn/arcade-components
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Y voilá, ya podremos trabajar con arcade y arcade-components en local sin publicar nada.
|
|
98
|
+
|
|
99
|
+
Una vez terminemos de trabajar con el paquete linkado en `arcade`, no nos olvidemos de borrar el link:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
yalc remove --all
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
UNLICENSED © [gamelearn](https://github.com/gamelearn)
|
|
@@ -195,7 +195,7 @@ var AutoEvaluation = function AutoEvaluation(_ref) {
|
|
|
195
195
|
setPhase('end');
|
|
196
196
|
play('click-ui');
|
|
197
197
|
},
|
|
198
|
-
className: "gat--btn gat--btn__primary auto-evaluation__button not-transition "
|
|
198
|
+
className: "gat--btn gat--btn__primary auto-evaluation__button not-transition\r "
|
|
199
199
|
}, /*#__PURE__*/_react.default.createElement("span", null, translate('auto-evaluation.end'))) : /*#__PURE__*/_react.default.createElement("button", {
|
|
200
200
|
type: "button",
|
|
201
201
|
onClick: function onClick() {
|
|
@@ -68,7 +68,7 @@ function Panel(_ref) {
|
|
|
68
68
|
var emotionAction = mixer.clipAction(emotionClip, model.current);
|
|
69
69
|
var defaultAction = mixer.clipAction(defaultAnim, model.current);
|
|
70
70
|
mixer.stopAllAction();
|
|
71
|
-
(0, _helpers.
|
|
71
|
+
(0, _helpers.executeCrossFadeOld)(emotionAction, defaultAction);
|
|
72
72
|
setTalking(false);
|
|
73
73
|
}
|
|
74
74
|
}, []);
|
|
@@ -272,23 +272,35 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
272
272
|
}
|
|
273
273
|
}, [zoomInActor]);
|
|
274
274
|
var startTalking = function startTalking() {
|
|
275
|
-
if (!(talkingCharacter !== null && talkingCharacter !== void 0 && talkingCharacter.emotion)) return;
|
|
276
|
-
var emotion = talkingCharacter.emotion
|
|
277
|
-
|
|
275
|
+
if (!(talkingCharacter !== null && talkingCharacter !== void 0 && talkingCharacter.emotion) || lastSet.current) return;
|
|
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
|
-
if (!(talkingCharacter !== null && talkingCharacter !== void 0 && talkingCharacter.uid)) return;
|
|
281
|
-
var emotion = talkingCharacter.emotion
|
|
282
|
-
|
|
286
|
+
if (!(talkingCharacter !== null && talkingCharacter !== void 0 && talkingCharacter.uid) || lastSet.current) return;
|
|
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;
|
|
286
298
|
changeLine(0);
|
|
287
|
-
resetActives();
|
|
288
299
|
setCurrentMessage({
|
|
289
300
|
show: false
|
|
290
301
|
});
|
|
291
302
|
resetCameraView();
|
|
303
|
+
resetActives();
|
|
292
304
|
if (!zoomInActor) {
|
|
293
305
|
emitEvent({
|
|
294
306
|
type: 'success'
|
|
@@ -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()) {
|
|
@@ -389,6 +402,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
389
402
|
lastTalking.current = _objectSpread({}, talkingCharacter);
|
|
390
403
|
setEdgesHistory([].concat(_toConsumableArray(edgesHistory), [currentLineData.id]));
|
|
391
404
|
setAudioFailed(false);
|
|
405
|
+
resetTalkingAnimation();
|
|
392
406
|
if (isBranched) {
|
|
393
407
|
if (choice) {
|
|
394
408
|
handleDecisionBranch(choice, reset);
|
|
@@ -513,7 +527,12 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
513
527
|
|
|
514
528
|
// Check not talking elements emotion
|
|
515
529
|
slottedCharacters.forEach(function (c) {
|
|
516
|
-
|
|
530
|
+
var sceneElement = getCurrentVisible(c.uid);
|
|
531
|
+
if (sceneElement) {
|
|
532
|
+
var isSeated = sceneElement.isSeated;
|
|
533
|
+
var includesSeated = c.emotion.includes('seated');
|
|
534
|
+
startAnimation(c.uid, isSeated && !includesSeated ? "".concat(c.emotion, "-seated") : c.emotion);
|
|
535
|
+
}
|
|
517
536
|
});
|
|
518
537
|
var element = getCurrentVisible(talkingCharacter.uid);
|
|
519
538
|
var object = actors.find(function (a) {
|
|
@@ -522,8 +541,15 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
522
541
|
if (element && !lastSet.current) {
|
|
523
542
|
setTimeout(function () {
|
|
524
543
|
if (talkingCharacter.uid === element.uid) {
|
|
544
|
+
var _userData$active, _userData$active2;
|
|
525
545
|
moveBubble(element);
|
|
526
|
-
|
|
546
|
+
var isSeated = element.isSeated,
|
|
547
|
+
userData = element.userData;
|
|
548
|
+
var emotion = talkingCharacter.emotion;
|
|
549
|
+
var includesSeated = emotion.includes('seated');
|
|
550
|
+
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))) {
|
|
551
|
+
startAnimation(talkingCharacter.uid, isSeated && !includesSeated ? "".concat(emotion, "-seated") : emotion);
|
|
552
|
+
}
|
|
527
553
|
var setMessage = function setMessage() {
|
|
528
554
|
var _talkingCharacter$cha;
|
|
529
555
|
setCurrentMessage({
|
package/dist/helpers/index.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.activateAction = activateAction;
|
|
7
|
-
exports.mixWithTalkingClip = exports.getRandomIndex = exports.getObjectPosition = exports.formatMessage = exports.executeCrossFade = exports.cameraFitAnyObject = void 0;
|
|
7
|
+
exports.mixWithTalkingClip = exports.getRandomIndex = exports.getObjectPosition = exports.formatMessage = exports.executeTalkingAnimation = exports.executeCrossFadeOld = exports.executeCrossFade = exports.cameraFitAnyObject = void 0;
|
|
8
8
|
exports.prepareCrossfade = prepareCrossfade;
|
|
9
9
|
exports.resetActions = resetActions;
|
|
10
10
|
exports.setWeight = exports.screenToVector = exports.roundFloat = void 0;
|
|
@@ -12,12 +12,14 @@ exports.syncCrossfade = syncCrossfade;
|
|
|
12
12
|
exports.zAxis = exports.yAxis = exports.xAxis = exports.vectorTranslateZ = exports.vectorTranslateY = exports.vectorTranslateX = exports.vectorTranslateOnAxis = exports.vectorToScreen = exports.usePrevious = void 0;
|
|
13
13
|
var _react = require("react");
|
|
14
14
|
var _three = require("three");
|
|
15
|
+
var _GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader");
|
|
15
16
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
16
17
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
18
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
18
19
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
19
20
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
20
21
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
22
|
+
var loader = new _GLTFLoader.GLTFLoader();
|
|
21
23
|
var xAxis = new _three.Vector3(1, 0, 0);
|
|
22
24
|
exports.xAxis = xAxis;
|
|
23
25
|
var yAxis = new _three.Vector3(0, 1, 0);
|
|
@@ -172,6 +174,17 @@ function resetActions(mixer, active) {
|
|
|
172
174
|
}
|
|
173
175
|
});
|
|
174
176
|
}
|
|
177
|
+
var executeCrossFadeOld = function executeCrossFadeOld(startAction, endAction) {
|
|
178
|
+
if (startAction === endAction) return;
|
|
179
|
+
if (!startAction || !endAction) return;
|
|
180
|
+
startAction.play();
|
|
181
|
+
startAction.reset();
|
|
182
|
+
endAction.reset();
|
|
183
|
+
setWeight(endAction, 1);
|
|
184
|
+
endAction.crossFadeFrom(startAction, crossFadeDuration, true);
|
|
185
|
+
endAction.play();
|
|
186
|
+
};
|
|
187
|
+
exports.executeCrossFadeOld = executeCrossFadeOld;
|
|
175
188
|
var executeCrossFade = function executeCrossFade(startAction, endAction) {
|
|
176
189
|
if (endAction) {
|
|
177
190
|
setWeight(endAction, 1);
|
|
@@ -187,8 +200,49 @@ var executeCrossFade = function executeCrossFade(startAction, endAction) {
|
|
|
187
200
|
}
|
|
188
201
|
};
|
|
189
202
|
exports.executeCrossFade = executeCrossFade;
|
|
203
|
+
var executeTalkingAnimation = function executeTalkingAnimation(target, talkingURL) {
|
|
204
|
+
if (target && talkingURL) {
|
|
205
|
+
var tracks = [];
|
|
206
|
+
var _target$userData = target.userData,
|
|
207
|
+
mixer = _target$userData.mixer,
|
|
208
|
+
defaultAnim = _target$userData.defaultAnim;
|
|
209
|
+
var cloned = defaultAnim.clone();
|
|
210
|
+
var onLoad = function onLoad(anim) {
|
|
211
|
+
var talkingClip = anim === null || anim === void 0 ? void 0 : anim.animations[0];
|
|
212
|
+
if (talkingClip) {
|
|
213
|
+
var _cloned$tracks;
|
|
214
|
+
tracks = talkingClip.tracks.filter(function (track) {
|
|
215
|
+
return bones.find(function (bone) {
|
|
216
|
+
return track.name.includes(bone);
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
cloned.tracks = cloned.tracks.filter(function (track) {
|
|
220
|
+
return !bones.find(function (bone) {
|
|
221
|
+
return track.name.includes(bone);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
(_cloned$tracks = cloned.tracks).push.apply(_cloned$tracks, _toConsumableArray(tracks));
|
|
225
|
+
target.userData.emotionClip = cloned;
|
|
226
|
+
cloned.resetDuration();
|
|
227
|
+
var talkingSubClip = cloned;
|
|
228
|
+
if (cloned.duration > 4) {
|
|
229
|
+
talkingSubClip = _three.AnimationUtils.subclip(cloned, 'shortTalking', 0, 120, 30);
|
|
230
|
+
}
|
|
231
|
+
var defaultAction = mixer.clipAction(defaultAnim, target);
|
|
232
|
+
var emotionAction = mixer.clipAction(talkingSubClip, target);
|
|
233
|
+
emotionAction.loop = _three.LoopPingPong;
|
|
234
|
+
mixer.stopAllAction();
|
|
235
|
+
executeCrossFadeOld(defaultAction, emotionAction, crossFadeDuration);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
loader.load(talkingURL, function (anim) {
|
|
239
|
+
onLoad(anim);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
exports.executeTalkingAnimation = executeTalkingAnimation;
|
|
190
244
|
var mixWithTalkingClip = function mixWithTalkingClip(target, talking, action) {
|
|
191
|
-
var _cloned$
|
|
245
|
+
var _cloned$tracks2;
|
|
192
246
|
var mixer = target.userData.mixer;
|
|
193
247
|
var talkingClip = talking.clone();
|
|
194
248
|
var cloned = action.clone();
|
|
@@ -202,7 +256,7 @@ var mixWithTalkingClip = function mixWithTalkingClip(target, talking, action) {
|
|
|
202
256
|
return track.name.includes(bone);
|
|
203
257
|
});
|
|
204
258
|
});
|
|
205
|
-
(_cloned$
|
|
259
|
+
(_cloned$tracks2 = cloned.tracks).push.apply(_cloned$tracks2, _toConsumableArray(tracks));
|
|
206
260
|
cloned.resetDuration();
|
|
207
261
|
var clip = cloned;
|
|
208
262
|
clip.name = "".concat(cloned.name, "_talking");
|
|
@@ -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,17 +53,20 @@ function useStateMachine(lines) {
|
|
|
70
53
|
_step2;
|
|
71
54
|
try {
|
|
72
55
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
73
|
-
var _slot$
|
|
56
|
+
var _slot$character;
|
|
74
57
|
var slot = _step2.value;
|
|
75
58
|
if (!slot.uid) continue;
|
|
59
|
+
var animations = (_slot$character = slot.character) === null || _slot$character === void 0 ? void 0 : _slot$character.resource.animations;
|
|
76
60
|
if (!urls[slot.uid]) {
|
|
77
|
-
|
|
78
|
-
urls[slot.uid] = _defineProperty({}, slot.emotion, (_slot$character = slot.character) === null || _slot$character === void 0 ? void 0 : _slot$character.resource.animations[slot.emotion].url);
|
|
61
|
+
urls[slot.uid] = _defineProperty({}, slot.emotion, animations[slot.emotion].url);
|
|
79
62
|
} else {
|
|
80
|
-
|
|
81
|
-
|
|
63
|
+
urls[slot.uid] = _objectSpread(_objectSpread({}, urls[slot.uid]), {}, _defineProperty({}, slot.emotion, animations[slot.emotion].url));
|
|
64
|
+
}
|
|
65
|
+
if (!slot.emotion.includes('seated')) {
|
|
66
|
+
var _animations;
|
|
67
|
+
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));
|
|
82
68
|
}
|
|
83
|
-
urls[slot.uid].talking =
|
|
69
|
+
urls[slot.uid].talking = animations.talking.url;
|
|
84
70
|
}
|
|
85
71
|
} catch (err) {
|
|
86
72
|
_iterator2.e(err);
|
|
@@ -95,8 +81,37 @@ function useStateMachine(lines) {
|
|
|
95
81
|
}
|
|
96
82
|
return urls;
|
|
97
83
|
}, [lines]);
|
|
84
|
+
var uids = (0, _react.useMemo)(function () {
|
|
85
|
+
var set = new Set();
|
|
86
|
+
var _iterator3 = _createForOfIteratorHelper(lines),
|
|
87
|
+
_step3;
|
|
88
|
+
try {
|
|
89
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
90
|
+
var line = _step3.value;
|
|
91
|
+
if (!line.slots) continue;
|
|
92
|
+
var _iterator4 = _createForOfIteratorHelper(line.slots),
|
|
93
|
+
_step4;
|
|
94
|
+
try {
|
|
95
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
96
|
+
var slot = _step4.value;
|
|
97
|
+
if (!slot.uid) continue;
|
|
98
|
+
set.add(slot.uid);
|
|
99
|
+
}
|
|
100
|
+
} catch (err) {
|
|
101
|
+
_iterator4.e(err);
|
|
102
|
+
} finally {
|
|
103
|
+
_iterator4.f();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
} catch (err) {
|
|
107
|
+
_iterator3.e(err);
|
|
108
|
+
} finally {
|
|
109
|
+
_iterator3.f();
|
|
110
|
+
}
|
|
111
|
+
return Array.from(set);
|
|
112
|
+
}, [lines]);
|
|
98
113
|
var resetActives = function resetActives() {
|
|
99
|
-
|
|
114
|
+
uids.forEach(function (uid) {
|
|
100
115
|
startAnimation(uid, 'idle');
|
|
101
116
|
});
|
|
102
117
|
};
|
|
@@ -122,16 +137,20 @@ function useStateMachine(lines) {
|
|
|
122
137
|
} else {
|
|
123
138
|
var _root$userData = root.userData,
|
|
124
139
|
mixer = _root$userData.mixer,
|
|
125
|
-
actionList = _root$userData.actionList
|
|
126
|
-
|
|
127
|
-
if (emotion ===
|
|
128
|
-
|
|
140
|
+
actionList = _root$userData.actionList,
|
|
141
|
+
active = _root$userData.active;
|
|
142
|
+
if (emotion === active) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
var startAction = actionList[active];
|
|
129
146
|
var endAction = actionList[emotion];
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
147
|
+
if (startAction && endAction) {
|
|
148
|
+
(0, _.resetActions)(mixer, startAction);
|
|
149
|
+
(0, _.executeCrossFade)(startAction, endAction);
|
|
150
|
+
root.userData.active = emotion;
|
|
151
|
+
}
|
|
133
152
|
}
|
|
134
|
-
}, [scene, loaded
|
|
153
|
+
}, [scene, loaded]);
|
|
135
154
|
var processAnimations = (0, _react.useCallback)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
136
155
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
137
156
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -157,7 +176,7 @@ function useStateMachine(lines) {
|
|
|
157
176
|
if (!actionList.idle) {
|
|
158
177
|
defaultAction = mixer.existingAction(defaultAnim, root);
|
|
159
178
|
actionList.idle = defaultAction;
|
|
160
|
-
|
|
179
|
+
root.userData.active = 'idle';
|
|
161
180
|
}
|
|
162
181
|
loadEmotion = /*#__PURE__*/function () {
|
|
163
182
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(emotion) {
|
|
@@ -180,6 +199,7 @@ function useStateMachine(lines) {
|
|
|
180
199
|
if (emotion !== 'talking' && actionList.talking) {
|
|
181
200
|
clone = clip.clone();
|
|
182
201
|
clone.name = "".concat(emotion, "_talking");
|
|
202
|
+
actionList.talking.reset();
|
|
183
203
|
talkingClip = actionList.talking.getClip();
|
|
184
204
|
_action = (0, _.mixWithTalkingClip)(root, talkingClip, clone);
|
|
185
205
|
(0, _.activateAction)(_action, 0);
|
|
@@ -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.29.
|
|
5
|
+
"version": "2.29.4-hotfix-animationsv2",
|
|
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",
|