@gamelearn/arcade-components 1.18.5 → 1.19.0
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.
|
@@ -134,16 +134,19 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
134
134
|
var lastLine = lines[line - 1];
|
|
135
135
|
var lastSet = (0, _react.useRef)(false);
|
|
136
136
|
var isBranched = !!edges;
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
|
|
138
|
+
var _ref2 = currentLine || {},
|
|
139
|
+
voiceOver = _ref2.voiceOver,
|
|
140
|
+
decision = _ref2.decision;
|
|
141
|
+
|
|
139
142
|
var translate = (0, _react.useCallback)(function (id) {
|
|
140
143
|
return emitEvent({
|
|
141
144
|
type: 'translate',
|
|
142
145
|
payload: id
|
|
143
146
|
});
|
|
144
147
|
}, [emitEvent]);
|
|
145
|
-
var isVoiceOver = voiceOver || currentLine.type === 'conversationalNarration';
|
|
146
|
-
var isDecision = decision || currentLine.type === 'conversationalDecision';
|
|
148
|
+
var isVoiceOver = voiceOver || (currentLine === null || currentLine === void 0 ? void 0 : currentLine.type) === 'conversationalNarration';
|
|
149
|
+
var isDecision = decision || (currentLine === null || currentLine === void 0 ? void 0 : currentLine.type) === 'conversationalDecision';
|
|
147
150
|
var getCurrentVisible = (0, _react.useCallback)(function (uid) {
|
|
148
151
|
var object;
|
|
149
152
|
scene.traverseVisible(function (node) {
|
|
@@ -240,7 +243,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
240
243
|
var forward = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
241
244
|
var keys = forward ? ['fromId', 'toId'] : ['toId', 'fromId'];
|
|
242
245
|
var foundEdge = edges.find(function (edge) {
|
|
243
|
-
return edge[keys[0]] === currentLine.id;
|
|
246
|
+
return edge[keys[0]] === (currentLine === null || currentLine === void 0 ? void 0 : currentLine.id);
|
|
244
247
|
});
|
|
245
248
|
|
|
246
249
|
if (!(foundEdge !== null && foundEdge !== void 0 && foundEdge[keys[0]])) {
|
|
@@ -259,7 +262,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
259
262
|
finishConversation();
|
|
260
263
|
}
|
|
261
264
|
}
|
|
262
|
-
}, [currentLine.id, edges, finishConversation, lines]);
|
|
265
|
+
}, [currentLine === null || currentLine === void 0 ? void 0 : currentLine.id, edges, finishConversation, lines]);
|
|
263
266
|
var backLine = (0, _react.useCallback)(function () {
|
|
264
267
|
setAudioFailed(false);
|
|
265
268
|
|
|
@@ -275,7 +278,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
275
278
|
var handleDecisionBranch = (0, _react.useCallback)(function (choice, reset) {
|
|
276
279
|
var currentId = [3, 2, 1][choice.id];
|
|
277
280
|
var optionsEdges = edges.filter(function (edge) {
|
|
278
|
-
return edge.fromId === currentLine.id;
|
|
281
|
+
return edge.fromId === (currentLine === null || currentLine === void 0 ? void 0 : currentLine.id);
|
|
279
282
|
});
|
|
280
283
|
var currentEdge = optionsEdges.find(function (edge) {
|
|
281
284
|
return parseInt(edge.fromPointIndex) === currentId;
|
|
@@ -296,7 +299,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
296
299
|
} else {
|
|
297
300
|
finishConversation();
|
|
298
301
|
}
|
|
299
|
-
}, [currentLine.id, edges, finishConversation, lines]);
|
|
302
|
+
}, [currentLine === null || currentLine === void 0 ? void 0 : currentLine.id, edges, finishConversation, lines]);
|
|
300
303
|
var nextLine = (0, _react.useCallback)(function (choice, reset) {
|
|
301
304
|
setAudioFailed(false);
|
|
302
305
|
|
|
@@ -333,8 +336,8 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
333
336
|
} else if (isVoiceOver) {
|
|
334
337
|
resetCameraView();
|
|
335
338
|
setCurrentMessage({
|
|
336
|
-
text: currentLine.text,
|
|
337
|
-
name: currentLine.alias || currentLine.name || "[ ".concat(translate('storylines.misc.voiceOver'), " ]"),
|
|
339
|
+
text: currentLine === null || currentLine === void 0 ? void 0 : currentLine.text,
|
|
340
|
+
name: (currentLine === null || currentLine === void 0 ? void 0 : currentLine.alias) || (currentLine === null || currentLine === void 0 ? void 0 : currentLine.name) || "[ ".concat(translate('storylines.misc.voiceOver'), " ]"),
|
|
338
341
|
left: false,
|
|
339
342
|
inScene: false,
|
|
340
343
|
voiceOver: true,
|
|
@@ -344,10 +347,10 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
344
347
|
show: true
|
|
345
348
|
});
|
|
346
349
|
} else if (!lastSet.current) {
|
|
347
|
-
var talkingCharacter = currentLine.slots.find(function (slot) {
|
|
350
|
+
var talkingCharacter = currentLine === null || currentLine === void 0 ? void 0 : currentLine.slots.find(function (slot) {
|
|
348
351
|
return slot.talking;
|
|
349
352
|
});
|
|
350
|
-
var slottedCharacters = currentLine.slots.filter(function (slot) {
|
|
353
|
+
var slottedCharacters = currentLine === null || currentLine === void 0 ? void 0 : currentLine.slots.filter(function (slot) {
|
|
351
354
|
return slot.uid && !slot.talking;
|
|
352
355
|
}); // Check not talking elements emotion
|
|
353
356
|
|
|
@@ -379,64 +382,45 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
379
382
|
if (startAction && action && startAction !== action) {
|
|
380
383
|
mixer.stopAllAction();
|
|
381
384
|
(0, _helpers.executeCrossFade)(startAction, action, crossFadeDuration);
|
|
382
|
-
}
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
if (talkingCharacter.uid === element.uid) {
|
|
389
|
+
var showArrowTop = talkingCharacter.text.length > maxCharacterToSwitch;
|
|
390
|
+
var head = element.getObjectByName('Head_M');
|
|
391
|
+
var target = new _three.Object3D();
|
|
392
|
+
head.getWorldPosition(target.position);
|
|
393
|
+
target.applyQuaternion(camera.quaternion);
|
|
394
|
+
target.translateX(1.25);
|
|
395
|
+
var distance = camera.position.distanceTo(target.position);
|
|
396
|
+
target.translateY(distance > 70 && !zoomInActor ? 0 : 3);
|
|
397
|
+
messagePosition.current = {
|
|
398
|
+
pos: target.position.toArray(),
|
|
399
|
+
child: head,
|
|
400
|
+
parent: element
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
if (zoomInActor) {
|
|
404
|
+
animationStart.current = true;
|
|
405
|
+
} // Ugly timeout to wait for zoom in ( maybe use tween (?))
|
|
383
406
|
|
|
384
407
|
|
|
385
408
|
setTimeout(function () {
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
if (distanceToCam > 400) {
|
|
402
|
-
distanceMultiplier = size.y / 2;
|
|
403
|
-
|
|
404
|
-
if (distanceToCam > 600) {
|
|
405
|
-
distanceMultiplier = size.y / 1.5;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
var baseY = 3 * distanceMultiplier;
|
|
411
|
-
target.translateY(showArrowTop ? 1.25 : baseY);
|
|
412
|
-
messagePosition.current = {
|
|
413
|
-
pos: target.position.toArray(),
|
|
414
|
-
child: head,
|
|
415
|
-
parent: element
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
if (zoomInActor) {
|
|
419
|
-
animationStart.current = true;
|
|
420
|
-
} // Ugly timeout to wait for zoom in ( maybe use tween (?))
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
setTimeout(function () {
|
|
424
|
-
var _talkingCharacter$cha;
|
|
425
|
-
|
|
426
|
-
setCurrentMessage({
|
|
427
|
-
text: talkingCharacter.text,
|
|
428
|
-
name: talkingCharacter.alias || ((_talkingCharacter$cha = talkingCharacter.character) === null || _talkingCharacter$cha === void 0 ? void 0 : _talkingCharacter$cha.name),
|
|
429
|
-
left: true,
|
|
430
|
-
top: showArrowTop,
|
|
431
|
-
inScene: true,
|
|
432
|
-
thinkful: talkingCharacter.emotion === 'thinkful',
|
|
433
|
-
avatar: '',
|
|
434
|
-
show: true
|
|
435
|
-
});
|
|
436
|
-
}, zoomInActor ? 1200 : 0);
|
|
437
|
-
}
|
|
438
|
-
}, 1000 * crossFadeDuration);
|
|
439
|
-
});
|
|
409
|
+
var _talkingCharacter$cha;
|
|
410
|
+
|
|
411
|
+
distance = camera.position.distanceTo(target.position);
|
|
412
|
+
setCurrentMessage({
|
|
413
|
+
text: talkingCharacter.text,
|
|
414
|
+
name: talkingCharacter.alias || ((_talkingCharacter$cha = talkingCharacter.character) === null || _talkingCharacter$cha === void 0 ? void 0 : _talkingCharacter$cha.name),
|
|
415
|
+
left: true,
|
|
416
|
+
top: showArrowTop || distance > 70,
|
|
417
|
+
inScene: true,
|
|
418
|
+
thinkful: talkingCharacter.emotion === 'thinkful',
|
|
419
|
+
avatar: '',
|
|
420
|
+
show: true
|
|
421
|
+
});
|
|
422
|
+
}, zoomInActor ? 1200 : 0);
|
|
423
|
+
}
|
|
440
424
|
} else {
|
|
441
425
|
var _talkingCharacter$cha2;
|
|
442
426
|
|
|
@@ -460,9 +444,9 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
460
444
|
}
|
|
461
445
|
}
|
|
462
446
|
}, [actors, camera, currentLine, zoomInActor, getCurrentVisible, translate, getAvatarURL, loadEmotion, resetCameraView, isDecision, isVoiceOver]);
|
|
463
|
-
var autoPlayCond = automatic && !currentLine.decision;
|
|
464
|
-
var audio = Object.keys(currentLine.audio || {}).length;
|
|
465
|
-
var voice = Object.keys(currentLine.voice || {}).length; // Sound logic
|
|
447
|
+
var autoPlayCond = automatic && !(currentLine !== null && currentLine !== void 0 && currentLine.decision);
|
|
448
|
+
var audio = Object.keys((currentLine === null || currentLine === void 0 ? void 0 : currentLine.audio) || {}).length;
|
|
449
|
+
var voice = Object.keys((currentLine === null || currentLine === void 0 ? void 0 : currentLine.voice) || {}).length; // Sound logic
|
|
466
450
|
|
|
467
451
|
var stopEkho = (0, _useEkho.default)({
|
|
468
452
|
audioType: currentLine === null || currentLine === void 0 ? void 0 : currentLine.audioType,
|
|
@@ -499,12 +483,12 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
499
483
|
}, [currentMessage, nextLine, start, stop, currentLine === null || currentLine === void 0 ? void 0 : currentLine.audioType, autoPlayCond, audio, voice, audioFailed]); // Positioning logic
|
|
500
484
|
|
|
501
485
|
var checkBubblePosition = (0, _react.useCallback)(function () {
|
|
502
|
-
if (bubbleRef.current && currentLine.slots) {
|
|
503
|
-
var talkingCharacter = currentLine.slots.find(function (slot) {
|
|
486
|
+
if (bubbleRef.current && currentLine !== null && currentLine !== void 0 && currentLine.slots) {
|
|
487
|
+
var talkingCharacter = currentLine === null || currentLine === void 0 ? void 0 : currentLine.slots.find(function (slot) {
|
|
504
488
|
return slot.talking;
|
|
505
489
|
});
|
|
506
490
|
var bubbleRect = bubbleRef.current.getBoundingClientRect();
|
|
507
|
-
var x = bubbleRect.x + bubbleRect.width
|
|
491
|
+
var x = bubbleRect.x + bubbleRect.width;
|
|
508
492
|
var y = bubbleRect.y - bubbleRect.height;
|
|
509
493
|
|
|
510
494
|
if ((x < 0 || x > window.innerWidth) && currentMessage.inScene) {
|
|
@@ -520,7 +504,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
520
504
|
var distanceX = bubbleRect.width + bubbleRect.width / divider;
|
|
521
505
|
bubbleRef.current.parentNode.style.transform = "translate3d(-".concat(distanceX, "px, -").concat(bubbleRect.height, "px, 0px)");
|
|
522
506
|
bubbleRect = bubbleRef.current.getBoundingClientRect();
|
|
523
|
-
var completeOutside = x > window.innerWidth + bubbleRect.width || y < -bubbleRect.height || y > window.innerHeight || x < -bubbleRect.width;
|
|
507
|
+
var completeOutside = x > window.innerWidth + bubbleRect.width || y < -bubbleRect.height || y > window.innerHeight || x < -bubbleRect.width || bubbleRect.x < 10;
|
|
524
508
|
|
|
525
509
|
if (completeOutside) {
|
|
526
510
|
bubbleRef.current.parentNode.style.transform = '';
|
|
@@ -547,8 +531,8 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
547
531
|
checkBubblePosition();
|
|
548
532
|
}, [checkBubblePosition]); // Animate Camera
|
|
549
533
|
|
|
550
|
-
(0, _fiber.useFrame)(function (
|
|
551
|
-
var cam =
|
|
534
|
+
(0, _fiber.useFrame)(function (_ref3, delta) {
|
|
535
|
+
var cam = _ref3.camera;
|
|
552
536
|
|
|
553
537
|
if (animationStart.current) {
|
|
554
538
|
var targetPosition = messagePosition.current.child ? messagePosition.current.pos : defaultCamera.current.position.toArray();
|
|
@@ -640,7 +624,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
640
624
|
}, /*#__PURE__*/_react.default.createElement(_SpeechBubbleComponent.default, {
|
|
641
625
|
ref: bubbleRef,
|
|
642
626
|
message: currentMessage
|
|
643
|
-
}))) : null,
|
|
627
|
+
}))) : null, /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.HtmlPro, {
|
|
644
628
|
style: {
|
|
645
629
|
width: '100vw',
|
|
646
630
|
height: '100vh'
|
|
@@ -666,7 +650,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
666
650
|
onClick: manualNextLine
|
|
667
651
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
668
652
|
className: (0, _LangIsRtl.default)() ? 'icon-back' : 'icon-next'
|
|
669
|
-
}))))
|
|
653
|
+
})))));
|
|
670
654
|
};
|
|
671
655
|
|
|
672
656
|
var _default = DialogComponent;
|