@gamelearn/arcade-components 1.27.10 → 1.27.11
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
CHANGED
|
@@ -135,6 +135,8 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
135
135
|
start = _useTimeout.start,
|
|
136
136
|
stop = _useTimeout.stop;
|
|
137
137
|
|
|
138
|
+
var bubbleRef = (0, _react.useRef)();
|
|
139
|
+
var groupRef = (0, _react.useRef)();
|
|
138
140
|
var loader = (0, _react.useMemo)(function () {
|
|
139
141
|
return new _GLTFLoader.GLTFLoader();
|
|
140
142
|
}, []);
|
|
@@ -382,23 +384,25 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
382
384
|
}
|
|
383
385
|
}, [edges, isBranched, lines, mounted]);
|
|
384
386
|
|
|
385
|
-
var moveBubble = function moveBubble(element,
|
|
387
|
+
var moveBubble = function moveBubble(element, showArrowTop) {
|
|
388
|
+
var target = new _three.Object3D();
|
|
386
389
|
element.updateMatrix();
|
|
387
390
|
element.updateMatrixWorld();
|
|
388
391
|
var head = element.getObjectByName('Head_M');
|
|
389
|
-
head.updateMatrix();
|
|
390
392
|
head.updateMatrixWorld();
|
|
391
393
|
head.getWorldPosition(target.position);
|
|
392
394
|
target.applyQuaternion(camera.quaternion);
|
|
393
395
|
var distance = camera.position.distanceTo(target.position);
|
|
394
396
|
var staticDisplay = distance > 70 && !zoomInActor && !showArrowTop;
|
|
395
|
-
|
|
397
|
+
var yDistance = zoomInActor ? 2.5 : 2;
|
|
398
|
+
var xDistance = zoomInActor ? 1.2 : 1.5;
|
|
399
|
+
target.translateY(staticDisplay || showArrowTop ? 0 : yDistance);
|
|
400
|
+
target.translateX(xDistance); // Detectar posicion de personaje a izq o derecha de pantalla
|
|
396
401
|
|
|
397
402
|
var vector = new _three.Vector3();
|
|
398
403
|
vector.setFromMatrixPosition(head.matrixWorld);
|
|
399
|
-
var p = vector.project(
|
|
404
|
+
var p = vector.project(camera);
|
|
400
405
|
var isLeft = p.x < 0;
|
|
401
|
-
target.translateX(-1);
|
|
402
406
|
messagePosition.current = {
|
|
403
407
|
pos: target.position.toArray(),
|
|
404
408
|
child: head,
|
|
@@ -474,36 +478,32 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
474
478
|
(0, _helpers.executeCrossFade)(startAction, action, crossFadeDuration);
|
|
475
479
|
}
|
|
476
480
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
if (zoomInActor) {
|
|
484
|
-
setAnimationRunning(true);
|
|
485
|
-
} // Ugly timeout to wait for zoom in ( maybe use tween (?))
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
setTimeout(function () {
|
|
489
|
-
var _talkingCharacter$cha;
|
|
490
|
-
|
|
491
|
-
var _moveBubble = moveBubble(element, target, showArrowTop),
|
|
492
|
-
distance = _moveBubble.distance;
|
|
493
|
-
|
|
494
|
-
setCurrentMessage({
|
|
495
|
-
text: talkingCharacter.text,
|
|
496
|
-
name: talkingCharacter.alias || ((_talkingCharacter$cha = talkingCharacter.character) === null || _talkingCharacter$cha === void 0 ? void 0 : _talkingCharacter$cha.name),
|
|
497
|
-
left: true,
|
|
498
|
-
top: showArrowTop || distance > 70,
|
|
499
|
-
inScene: true,
|
|
500
|
-
thinkful: talkingCharacter.emotion === 'thinkful',
|
|
501
|
-
avatar: '',
|
|
502
|
-
show: true
|
|
503
|
-
});
|
|
504
|
-
}, zoomInActor ? 1200 : 0);
|
|
481
|
+
if (talkingCharacter.uid === element.uid) {
|
|
482
|
+
var showArrowTop = talkingCharacter.text.length > maxCharacterToSwitch;
|
|
483
|
+
moveBubble(element, showArrowTop);
|
|
484
|
+
|
|
485
|
+
if (zoomInActor) {
|
|
486
|
+
setAnimationRunning(true);
|
|
505
487
|
}
|
|
506
|
-
|
|
488
|
+
|
|
489
|
+
setTimeout(function () {
|
|
490
|
+
var _talkingCharacter$cha;
|
|
491
|
+
|
|
492
|
+
var _moveBubble = moveBubble(element, showArrowTop),
|
|
493
|
+
distance = _moveBubble.distance;
|
|
494
|
+
|
|
495
|
+
setCurrentMessage({
|
|
496
|
+
text: talkingCharacter.text,
|
|
497
|
+
name: talkingCharacter.alias || ((_talkingCharacter$cha = talkingCharacter.character) === null || _talkingCharacter$cha === void 0 ? void 0 : _talkingCharacter$cha.name),
|
|
498
|
+
left: true,
|
|
499
|
+
top: showArrowTop || distance > 70,
|
|
500
|
+
inScene: true,
|
|
501
|
+
thinkful: talkingCharacter.emotion === 'thinkful',
|
|
502
|
+
avatar: '',
|
|
503
|
+
show: true
|
|
504
|
+
});
|
|
505
|
+
}, zoomInActor ? 1200 : 0);
|
|
506
|
+
}
|
|
507
507
|
});
|
|
508
508
|
} else {
|
|
509
509
|
var _talkingCharacter$cha2;
|
|
@@ -570,6 +570,9 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
570
570
|
}, [currentMessage, nextLine, start, stop, currentLine === null || currentLine === void 0 ? void 0 : currentLine.audioType, autoPlayCond, audio, voice, audioFailed]); // Positioning Bubble Message logic
|
|
571
571
|
|
|
572
572
|
var checkBubbleBounds = (0, _react.useCallback)(function (group, bubble) {
|
|
573
|
+
groupRef.current = group === null || group === void 0 ? void 0 : group.current;
|
|
574
|
+
bubbleRef.current = bubble === null || bubble === void 0 ? void 0 : bubble.current;
|
|
575
|
+
|
|
573
576
|
if (currentLine !== null && currentLine !== void 0 && currentLine.slots && currentMessage.show && bubble !== null && bubble !== void 0 && bubble.current) {
|
|
574
577
|
var talkingCharacter = currentLine === null || currentLine === void 0 ? void 0 : currentLine.slots.find(function (slot) {
|
|
575
578
|
return slot.talking;
|
|
@@ -579,18 +582,15 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
579
582
|
var y = bubbleRect.y - bubbleRect.height;
|
|
580
583
|
|
|
581
584
|
if (!messagePosition.current.isLeft && zoomInActor || (x < 0 || x > window.innerWidth) && currentMessage.inScene) {
|
|
582
|
-
var
|
|
583
|
-
child = _messagePosition$curr.child,
|
|
584
|
-
parent = _messagePosition$curr.parent;
|
|
585
|
+
var child = messagePosition.current.child;
|
|
585
586
|
|
|
586
587
|
if (child) {
|
|
587
588
|
var target = new _three.Object3D();
|
|
588
589
|
child.getWorldPosition(target.position);
|
|
589
|
-
target.applyQuaternion(camera.quaternion);
|
|
590
590
|
group.current.position.copy(target.position);
|
|
591
591
|
group.current.updateMatrixWorld();
|
|
592
|
-
|
|
593
|
-
var divider = isMobile ? 10 :
|
|
592
|
+
var dividerWidth = bubbleRect.width > 250 ? 4 : 2.75;
|
|
593
|
+
var divider = isMobile ? 10 : dividerWidth;
|
|
594
594
|
var distanceX = bubbleRect.width + bubbleRect.width / divider;
|
|
595
595
|
bubble.current.parentNode.style.transform = "translate3d(-".concat(distanceX, "px, -").concat(bubbleRect.height, "px, 0px)");
|
|
596
596
|
bubbleRect = bubble.current.getBoundingClientRect();
|
|
@@ -632,8 +632,8 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
632
632
|
var headSpace = headSize * mult; // move bubble
|
|
633
633
|
|
|
634
634
|
messagePosition.current.pos[0] -= headSpace;
|
|
635
|
-
animationTarget.current.translateX(-10 + headSpace);
|
|
636
|
-
animationTarget.current.translateY(
|
|
635
|
+
animationTarget.current.translateX(-10 * mult + headSpace);
|
|
636
|
+
animationTarget.current.translateY(-2);
|
|
637
637
|
animationTarget.current.translateZ(30);
|
|
638
638
|
}
|
|
639
639
|
|
|
@@ -651,7 +651,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
651
651
|
if (changedMats.current.length) {
|
|
652
652
|
changedMats.current.forEach(function (o) {
|
|
653
653
|
var object = o.object;
|
|
654
|
-
object.material.
|
|
654
|
+
object.material.side = 0;
|
|
655
655
|
});
|
|
656
656
|
}
|
|
657
657
|
|
|
@@ -676,7 +676,9 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
676
676
|
});
|
|
677
677
|
}
|
|
678
678
|
|
|
679
|
-
|
|
679
|
+
if (bubbleRef.current && groupRef.current) {
|
|
680
|
+
checkBubbleBounds(groupRef, bubbleRef);
|
|
681
|
+
}
|
|
680
682
|
}
|
|
681
683
|
});
|
|
682
684
|
var container = document.querySelector('.screens--container');
|