@gamelearn/arcade-components 1.27.9 → 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
@@ -10,7 +10,7 @@ yarn add @gamelearn/arcade-components
10
10
  ```
11
11
 
12
12
  ## Usage
13
-
13
+
14
14
  ```jsx
15
15
  import React, { Component } from 'react';
16
16
 
@@ -140,7 +140,7 @@ var ComicComponent = function ComicComponent(_ref) {
140
140
  });
141
141
  (0, _react.useEffect)(function () {
142
142
  if (automatic) {
143
- if (slide !== null && slide !== void 0 && slide.slideTimer && (slide === null || slide === void 0 ? void 0 : slide.audio) === null) {
143
+ if (slide !== null && slide !== void 0 && slide.slideTimer) {
144
144
  start(goToNextSlide, slide.slideTimer * 1000);
145
145
  } else if ((slide === null || slide === void 0 ? void 0 : slide.audioType) === 'none' || audioFailed) {
146
146
  var _slide$vignettes$, _slide$vignettes$$tex;
@@ -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, target, showArrowTop) {
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
- target.translateY(staticDisplay || showArrowTop ? -1 : 0); // Detectar posicion de personaje a izq o derecha de pantalla
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(defaultCamera);
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
- setTimeout(function () {
478
- if (talkingCharacter.uid === element.uid) {
479
- var showArrowTop = talkingCharacter.text.length > maxCharacterToSwitch;
480
- var target = new _three.Object3D();
481
- moveBubble(element, target, showArrowTop);
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
- }, crossFadeDuration * 100);
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 _messagePosition$curr = messagePosition.current,
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
- moveBubble(parent, target, false);
593
- var divider = isMobile ? 10 : 6;
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(0);
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.visible = false;
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
- checkBubbleBounds();
679
+ if (bubbleRef.current && groupRef.current) {
680
+ checkBubbleBounds(groupRef, bubbleRef);
681
+ }
680
682
  }
681
683
  });
682
684
  var container = document.querySelector('.screens--container');
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@gamelearn/arcade-components",
3
3
  "author": "Gamelearn",
4
4
  "license": "unlicense",
5
- "version": "1.27.9",
5
+ "version": "1.27.11",
6
6
  "main": "dist/index.js",
7
7
  "files": [
8
8
  "dist",