@gamelearn/arcade-components 1.22.9 → 1.22.10-hotfix-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/comic-component/components/ComicComponent.js +1 -4
- package/dist/components/conversational-pro-component/components/ConversationalProComponent.js +2 -5
- package/dist/components/dialog-component/components/DialogComponent.js +95 -57
- package/dist/helpers/useEkho.js +7 -10
- package/package.json +1 -1
|
@@ -120,7 +120,7 @@ var ComicComponent = function ComicComponent(_ref) {
|
|
|
120
120
|
goToPreviousSlide();
|
|
121
121
|
};
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
(0, _useEkho.default)({
|
|
124
124
|
audioType: slides === null || slides === void 0 ? void 0 : (_slides$slideCount = slides[slideCount]) === null || _slides$slideCount === void 0 ? void 0 : _slides$slideCount.audioType,
|
|
125
125
|
voice: slides === null || slides === void 0 ? void 0 : (_slides$slideCount2 = slides[slideCount]) === null || _slides$slideCount2 === void 0 ? void 0 : _slides$slideCount2.voice,
|
|
126
126
|
text: slides === null || slides === void 0 ? void 0 : (_slides$slideCount3 = slides[slideCount]) === null || _slides$slideCount3 === void 0 ? void 0 : (_slides$slideCount3$v = _slides$slideCount3.vignettes[0].textData) === null || _slides$slideCount3$v === void 0 ? void 0 : _slides$slideCount3$v.text,
|
|
@@ -137,9 +137,6 @@ var ComicComponent = function ComicComponent(_ref) {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
});
|
|
140
|
-
(0, _react.useEffect)(function () {
|
|
141
|
-
stopEkho();
|
|
142
|
-
}, [slideCount, stopEkho]);
|
|
143
140
|
(0, _react.useEffect)(function () {
|
|
144
141
|
if (automatic && ((slide === null || slide === void 0 ? void 0 : slide.audioType) === 'none' || audioFailed)) {
|
|
145
142
|
var _slide$vignettes$, _slide$vignettes$$tex;
|
package/dist/components/conversational-pro-component/components/ConversationalProComponent.js
CHANGED
|
@@ -313,7 +313,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
313
313
|
|
|
314
314
|
var autoplayCond = automatic && !isDecision;
|
|
315
315
|
var disableBackButton = currentLine === 0 || previousLineWasDecision || currentLine > 0 && (lastLine === null || lastLine === void 0 ? void 0 : lastLine.decision);
|
|
316
|
-
|
|
316
|
+
(0, _useEkho.default)({
|
|
317
317
|
audioType: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType,
|
|
318
318
|
voice: currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.voice,
|
|
319
319
|
started: started,
|
|
@@ -329,10 +329,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
329
329
|
handleClickNext();
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
|
-
});
|
|
333
|
-
(0, _react.useEffect)(function () {
|
|
334
|
-
stopEkho();
|
|
335
|
-
}, [currentLine, stopEkho]); // Autoplay logic
|
|
332
|
+
}); // Autoplay logic
|
|
336
333
|
|
|
337
334
|
(0, _react.useEffect)(function () {
|
|
338
335
|
if (autoplayCond && ((currentLineData === null || currentLineData === void 0 ? void 0 : currentLineData.audioType) === 'none' || audioFailed)) {
|
|
@@ -45,6 +45,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
45
45
|
|
|
46
46
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
47
47
|
|
|
48
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
49
|
+
|
|
50
|
+
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."); }
|
|
51
|
+
|
|
52
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
53
|
+
|
|
54
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
55
|
+
|
|
48
56
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
49
57
|
|
|
50
58
|
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."); }
|
|
@@ -145,6 +153,20 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
145
153
|
voiceOver = _ref2.voiceOver,
|
|
146
154
|
decision = _ref2.decision;
|
|
147
155
|
|
|
156
|
+
var charactersInvolved = (0, _react.useMemo)(function () {
|
|
157
|
+
return lines.reduce(function (acc, current) {
|
|
158
|
+
if (current.slots) {
|
|
159
|
+
var participants = current.slots.filter(function (slot) {
|
|
160
|
+
return slot.uid;
|
|
161
|
+
});
|
|
162
|
+
participants.forEach(function (currentParticipant) {
|
|
163
|
+
if (!acc.includes(currentParticipant.uid)) acc.push(currentParticipant.uid);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return acc;
|
|
168
|
+
}, []);
|
|
169
|
+
}, [lines]);
|
|
148
170
|
var translate = (0, _react.useCallback)(function (id) {
|
|
149
171
|
return emitEvent({
|
|
150
172
|
type: 'translate',
|
|
@@ -184,10 +206,10 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
184
206
|
var _slot$character2;
|
|
185
207
|
|
|
186
208
|
var onLoadAnim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
|
|
187
|
-
var animation = (_slot$character2 = slot.character) === null || _slot$character2 === void 0 ? void 0 : _slot$character2.resource.animations[slot.emotion];
|
|
209
|
+
var animation = (_slot$character2 = slot.character) === null || _slot$character2 === void 0 ? void 0 : _slot$character2.resource.animations[element.isSeated ? "".concat(slot.emotion, "-seated") : slot.emotion];
|
|
188
210
|
var mixer = element.userData.mixer;
|
|
189
211
|
|
|
190
|
-
if (animation && animation.url
|
|
212
|
+
if (animation && animation.url) {
|
|
191
213
|
loader.load(animation.url, function (anim) {
|
|
192
214
|
var emotionClip = anim.animations[0];
|
|
193
215
|
var defaultClip = element.userData.defaultAnim;
|
|
@@ -206,31 +228,31 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
206
228
|
}
|
|
207
229
|
}, [loader]);
|
|
208
230
|
|
|
209
|
-
var
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
231
|
+
var executeDefaultAnimation = function executeDefaultAnimation(element) {
|
|
232
|
+
if (element.userData.mixer && element.userData.currentEmotion) {
|
|
233
|
+
var mixer = element.userData.mixer;
|
|
234
|
+
var startAction = mixer.clipAction(element.userData.currentEmotion.getClip(), element);
|
|
235
|
+
var defaultAction = mixer.clipAction(element.userData.defaultAnim, element);
|
|
213
236
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
237
|
+
if (element.userData.currentEmotion !== defaultAction) {
|
|
238
|
+
setTimeout(function () {
|
|
239
|
+
mixer.stopAllAction();
|
|
240
|
+
(0, _helpers.executeCrossFade)(startAction, defaultAction, crossFadeDuration / Math.floor(Math.random() * 3));
|
|
218
241
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
242
|
+
if (element.userData.currentEmotion) {
|
|
243
|
+
element.userData.lastEmotion = element.userData.currentEmotion;
|
|
244
|
+
}
|
|
222
245
|
|
|
223
|
-
|
|
224
|
-
|
|
246
|
+
element.userData.currentEmotion = defaultAction;
|
|
247
|
+
}, Math.floor(Math.random() * 3) * 500);
|
|
248
|
+
}
|
|
225
249
|
}
|
|
226
250
|
}; // Reset currentEmotion to defaultAnim
|
|
227
251
|
|
|
228
252
|
|
|
229
253
|
var resetAnims = (0, _react.useCallback)(function () {
|
|
230
254
|
scene.traverseVisible(function (node) {
|
|
231
|
-
|
|
232
|
-
executeAnimation(node);
|
|
233
|
-
}
|
|
255
|
+
return executeDefaultAnimation(node);
|
|
234
256
|
});
|
|
235
257
|
}, [scene]);
|
|
236
258
|
var resetCameraView = (0, _react.useCallback)(function () {
|
|
@@ -387,6 +409,19 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
387
409
|
});
|
|
388
410
|
var slottedCharacters = currentLine === null || currentLine === void 0 ? void 0 : currentLine.slots.filter(function (slot) {
|
|
389
411
|
return slot.uid && !slot.talking;
|
|
412
|
+
});
|
|
413
|
+
var currentParticipants = [].concat(_toConsumableArray(slottedCharacters.map(function (slot) {
|
|
414
|
+
return slot.uid;
|
|
415
|
+
}) || []), [talkingCharacter.uid]);
|
|
416
|
+
var notInvolvedParticipants = charactersInvolved.filter(function (charUid) {
|
|
417
|
+
return !currentParticipants.includes(charUid);
|
|
418
|
+
});
|
|
419
|
+
notInvolvedParticipants.forEach(function (uid) {
|
|
420
|
+
var element = getCurrentVisible(uid);
|
|
421
|
+
|
|
422
|
+
if (element) {
|
|
423
|
+
executeDefaultAnimation(element);
|
|
424
|
+
}
|
|
390
425
|
}); // Check not talking elements emotion
|
|
391
426
|
|
|
392
427
|
slottedCharacters.forEach(function (slot) {
|
|
@@ -420,45 +455,45 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
420
455
|
mixer.stopAllAction();
|
|
421
456
|
(0, _helpers.executeCrossFade)(startAction, action, crossFadeDuration);
|
|
422
457
|
}
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
if (talkingCharacter.uid === element.uid) {
|
|
426
|
-
var showArrowTop = talkingCharacter.text.length > maxCharacterToSwitch;
|
|
427
|
-
var head = element.getObjectByName('Head_M');
|
|
428
|
-
var target = new _three.Object3D();
|
|
429
|
-
head.getWorldPosition(target.position);
|
|
430
|
-
target.applyQuaternion(camera.quaternion);
|
|
431
|
-
target.translateX(1.25);
|
|
432
|
-
var distance = camera.position.distanceTo(target.position);
|
|
433
|
-
var staticDisplay = distance > 70 && !zoomInActor && !showArrowTop;
|
|
434
|
-
target.translateY(staticDisplay || showArrowTop ? 0 : 3);
|
|
435
|
-
messagePosition.current = {
|
|
436
|
-
pos: target.position.toArray(),
|
|
437
|
-
child: head,
|
|
438
|
-
parent: element
|
|
439
|
-
};
|
|
440
|
-
|
|
441
|
-
if (zoomInActor) {
|
|
442
|
-
animationStart.current = true;
|
|
443
|
-
} // Ugly timeout to wait for zoom in ( maybe use tween (?))
|
|
444
458
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
var
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
|
|
459
|
+
if (talkingCharacter.uid === element.uid) {
|
|
460
|
+
var showArrowTop = talkingCharacter.text.length > maxCharacterToSwitch;
|
|
461
|
+
var head = element.getObjectByName('Head_M');
|
|
462
|
+
var target = new _three.Object3D();
|
|
463
|
+
head.getWorldPosition(target.position);
|
|
464
|
+
target.applyQuaternion(camera.quaternion);
|
|
465
|
+
target.translateX(1.25);
|
|
466
|
+
var distance = camera.position.distanceTo(target.position);
|
|
467
|
+
var staticDisplay = distance > 70 && !zoomInActor && !showArrowTop;
|
|
468
|
+
target.translateY(staticDisplay || showArrowTop ? 0 : 3);
|
|
469
|
+
messagePosition.current = {
|
|
470
|
+
pos: target.position.toArray(),
|
|
471
|
+
child: head,
|
|
472
|
+
parent: element
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
if (zoomInActor) {
|
|
476
|
+
animationStart.current = true;
|
|
477
|
+
} // Ugly timeout to wait for zoom in ( maybe use tween (?))
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
setTimeout(function () {
|
|
481
|
+
var _talkingCharacter$cha;
|
|
482
|
+
|
|
483
|
+
distance = camera.position.distanceTo(target.position);
|
|
484
|
+
setCurrentMessage({
|
|
485
|
+
text: talkingCharacter.text,
|
|
486
|
+
name: talkingCharacter.alias || ((_talkingCharacter$cha = talkingCharacter.character) === null || _talkingCharacter$cha === void 0 ? void 0 : _talkingCharacter$cha.name),
|
|
487
|
+
left: true,
|
|
488
|
+
top: showArrowTop || distance > 70,
|
|
489
|
+
inScene: true,
|
|
490
|
+
thinkful: talkingCharacter.emotion === 'thinkful',
|
|
491
|
+
avatar: '',
|
|
492
|
+
show: true
|
|
493
|
+
});
|
|
494
|
+
}, zoomInActor ? 1200 : 0);
|
|
495
|
+
}
|
|
496
|
+
});
|
|
462
497
|
} else {
|
|
463
498
|
var _talkingCharacter$cha2;
|
|
464
499
|
|
|
@@ -481,7 +516,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
481
516
|
});
|
|
482
517
|
}
|
|
483
518
|
}
|
|
484
|
-
}, [actors, camera, currentLine, zoomInActor, getCurrentVisible, translate, getAvatarURL, loadEmotion, resetCameraView, isDecision, isVoiceOver]);
|
|
519
|
+
}, [actors, camera, currentLine, zoomInActor, getCurrentVisible, translate, getAvatarURL, loadEmotion, resetCameraView, isDecision, isVoiceOver, charactersInvolved]);
|
|
485
520
|
var autoPlayCond = automatic && !(currentLine !== null && currentLine !== void 0 && currentLine.decision);
|
|
486
521
|
var audio = Object.keys((currentLine === null || currentLine === void 0 ? void 0 : currentLine.audio) || {}).length;
|
|
487
522
|
var voice = Object.keys((currentLine === null || currentLine === void 0 ? void 0 : currentLine.voice) || {}).length; // Sound logic
|
|
@@ -505,6 +540,9 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
505
540
|
});
|
|
506
541
|
(0, _react.useEffect)(function () {
|
|
507
542
|
stopEkho();
|
|
543
|
+
return function () {
|
|
544
|
+
stopEkho();
|
|
545
|
+
};
|
|
508
546
|
}, [line, stopEkho]); // Autoplay logic
|
|
509
547
|
|
|
510
548
|
(0, _react.useEffect)(function () {
|
package/dist/helpers/useEkho.js
CHANGED
|
@@ -7,12 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
|
|
10
|
-
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; }
|
|
11
|
-
|
|
12
|
-
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; }
|
|
13
|
-
|
|
14
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
-
|
|
16
10
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
17
11
|
|
|
18
12
|
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); }); }; }
|
|
@@ -163,9 +157,10 @@ var useEkho = function useEkho(_ref) {
|
|
|
163
157
|
}(), [emitEvent, onError, setCurrentPlaying]);
|
|
164
158
|
var stopCurrentAudio = (0, _react.useCallback)(function () {
|
|
165
159
|
if (currentPlaying.current.url) {
|
|
166
|
-
currentPlaying.current =
|
|
167
|
-
url: ''
|
|
168
|
-
|
|
160
|
+
currentPlaying.current = {
|
|
161
|
+
url: '',
|
|
162
|
+
cc: 'tts'
|
|
163
|
+
};
|
|
169
164
|
stop(currentPlaying.current.cc);
|
|
170
165
|
}
|
|
171
166
|
}, [stop]);
|
|
@@ -176,6 +171,8 @@ var useEkho = function useEkho(_ref) {
|
|
|
176
171
|
}, [noAudio, stopCurrentAudio]);
|
|
177
172
|
(0, _react.useEffect)(function () {
|
|
178
173
|
if (isMounted && started) {
|
|
174
|
+
stopCurrentAudio();
|
|
175
|
+
|
|
179
176
|
if (audioType === 'voice' && voice !== null && voice !== void 0 && voice.id) {
|
|
180
177
|
var voiceId = getVoice(voice);
|
|
181
178
|
playSpeech({
|
|
@@ -188,7 +185,7 @@ var useEkho = function useEkho(_ref) {
|
|
|
188
185
|
onError();
|
|
189
186
|
}
|
|
190
187
|
}
|
|
191
|
-
}, [getVoice, playSpeech, isMounted, voice, text, audioType, audio === null || audio === void 0 ? void 0 : audio.url, audio, setCurrentPlaying, onError, started]);
|
|
188
|
+
}, [getVoice, playSpeech, isMounted, voice, text, audioType, audio === null || audio === void 0 ? void 0 : audio.url, audio, setCurrentPlaying, onError, started, stopCurrentAudio]);
|
|
192
189
|
return stopCurrentAudio;
|
|
193
190
|
};
|
|
194
191
|
|