@gamelearn/arcade-components 1.26.0 → 1.26.1-hotfix-2-video
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/dialog-component/components/BubbleWrapper.js +58 -0
- package/dist/components/dialog-component/components/DialogComponent.js +20 -35
- package/dist/components/dialog-component/components/SpeechBubbleComponent.js +33 -5
- package/dist/components/video-visor/components/VideoVisor.js +1 -3
- package/dist/helpers/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
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); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _arcadeThreeCore = require("@gamelearn/arcade-three-core");
|
|
13
|
+
|
|
14
|
+
var _SpeechBubbleComponent = _interopRequireDefault(require("./SpeechBubbleComponent"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
var cleanStyle = {
|
|
23
|
+
width: '100vw',
|
|
24
|
+
height: '100vh',
|
|
25
|
+
position: 'static'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var BubbleWrapper = function BubbleWrapper(_ref) {
|
|
29
|
+
var onLoad = _ref.onLoad,
|
|
30
|
+
position = _ref.position,
|
|
31
|
+
currentMessage = _ref.currentMessage;
|
|
32
|
+
var group = (0, _react.useRef)();
|
|
33
|
+
var bubble = (0, _react.useRef)();
|
|
34
|
+
|
|
35
|
+
var onBubbleBuild = function onBubbleBuild() {
|
|
36
|
+
onLoad(group, bubble);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return /*#__PURE__*/_react.default.createElement("group", {
|
|
40
|
+
ref: group,
|
|
41
|
+
position: position
|
|
42
|
+
}, /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.HtmlPro, {
|
|
43
|
+
zIndexRange: [2, 2],
|
|
44
|
+
calculatePosition: currentMessage.inScene ? undefined : function () {
|
|
45
|
+
return [0, 0];
|
|
46
|
+
},
|
|
47
|
+
style: currentMessage.inScene ? {
|
|
48
|
+
position: 'static'
|
|
49
|
+
} : cleanStyle
|
|
50
|
+
}, /*#__PURE__*/_react.default.createElement(_SpeechBubbleComponent.default, {
|
|
51
|
+
ref: bubble,
|
|
52
|
+
onLoad: onBubbleBuild,
|
|
53
|
+
message: currentMessage
|
|
54
|
+
})));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var _default = BubbleWrapper;
|
|
58
|
+
exports.default = _default;
|
|
@@ -19,8 +19,6 @@ var _arcadeThreeCore = require("@gamelearn/arcade-three-core");
|
|
|
19
19
|
|
|
20
20
|
var _gsap = _interopRequireDefault(require("gsap"));
|
|
21
21
|
|
|
22
|
-
var _SpeechBubbleComponent = _interopRequireDefault(require("./SpeechBubbleComponent"));
|
|
23
|
-
|
|
24
22
|
var _decisionComponent = _interopRequireDefault(require("../../decision-component"));
|
|
25
23
|
|
|
26
24
|
var _helpers = require("../../../helpers");
|
|
@@ -33,6 +31,8 @@ var _useEkho = _interopRequireDefault(require("../../../helpers/useEkho"));
|
|
|
33
31
|
|
|
34
32
|
var _LangIsRtl = _interopRequireDefault(require("../../../helpers/LangIsRtl"));
|
|
35
33
|
|
|
34
|
+
var _BubbleWrapper = _interopRequireDefault(require("./BubbleWrapper"));
|
|
35
|
+
|
|
36
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
37
|
|
|
38
38
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -151,8 +151,6 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
151
151
|
animationRunning = _useState12[0],
|
|
152
152
|
setAnimationRunning = _useState12[1];
|
|
153
153
|
|
|
154
|
-
var bubbleRef = (0, _react.useRef)();
|
|
155
|
-
var groupRef = (0, _react.useRef)();
|
|
156
154
|
var animationTarget = (0, _react.useRef)(new _three.Object3D());
|
|
157
155
|
var currentLine = lines[line];
|
|
158
156
|
var lastLine = lines[line - 1];
|
|
@@ -394,13 +392,13 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
394
392
|
target.applyQuaternion(camera.quaternion);
|
|
395
393
|
var distance = camera.position.distanceTo(target.position);
|
|
396
394
|
var staticDisplay = distance > 70 && !zoomInActor && !showArrowTop;
|
|
397
|
-
target.translateY(staticDisplay || showArrowTop ?
|
|
395
|
+
target.translateY(staticDisplay || showArrowTop ? -1 : 0); // Detectar posicion de personaje a izq o derecha de pantalla
|
|
398
396
|
|
|
399
397
|
var vector = new _three.Vector3();
|
|
400
398
|
vector.setFromMatrixPosition(head.matrixWorld);
|
|
401
399
|
var p = vector.project(defaultCamera);
|
|
402
|
-
target.translateX(headSize);
|
|
403
400
|
var isLeft = p.x < 0;
|
|
401
|
+
target.translateX(-1);
|
|
404
402
|
messagePosition.current = {
|
|
405
403
|
pos: target.position.toArray(),
|
|
406
404
|
child: head,
|
|
@@ -571,16 +569,16 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
571
569
|
};
|
|
572
570
|
}, [currentMessage, nextLine, start, stop, currentLine === null || currentLine === void 0 ? void 0 : currentLine.audioType, autoPlayCond, audio, voice, audioFailed]); // Positioning Bubble Message logic
|
|
573
571
|
|
|
574
|
-
var checkBubbleBounds = (0, _react.useCallback)(function () {
|
|
575
|
-
if (
|
|
572
|
+
var checkBubbleBounds = (0, _react.useCallback)(function (group, bubble) {
|
|
573
|
+
if (currentLine !== null && currentLine !== void 0 && currentLine.slots && currentMessage.show && bubble !== null && bubble !== void 0 && bubble.current) {
|
|
576
574
|
var talkingCharacter = currentLine === null || currentLine === void 0 ? void 0 : currentLine.slots.find(function (slot) {
|
|
577
575
|
return slot.talking;
|
|
578
576
|
});
|
|
579
|
-
var bubbleRect =
|
|
577
|
+
var bubbleRect = bubble.current.getBoundingClientRect();
|
|
580
578
|
var x = bubbleRect.x + bubbleRect.width;
|
|
581
579
|
var y = bubbleRect.y - bubbleRect.height;
|
|
582
580
|
|
|
583
|
-
if (!messagePosition.current.isLeft || (x < 0 || x > window.innerWidth) && currentMessage.inScene) {
|
|
581
|
+
if (!messagePosition.current.isLeft && zoomInActor || (x < 0 || x > window.innerWidth) && currentMessage.inScene) {
|
|
584
582
|
var _messagePosition$curr = messagePosition.current,
|
|
585
583
|
child = _messagePosition$curr.child,
|
|
586
584
|
parent = _messagePosition$curr.parent;
|
|
@@ -589,17 +587,17 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
589
587
|
var target = new _three.Object3D();
|
|
590
588
|
child.getWorldPosition(target.position);
|
|
591
589
|
target.applyQuaternion(camera.quaternion);
|
|
592
|
-
|
|
593
|
-
|
|
590
|
+
group.current.position.copy(target.position);
|
|
591
|
+
group.current.updateMatrixWorld();
|
|
594
592
|
moveBubble(parent, target, false);
|
|
595
593
|
var divider = isMobile ? 10 : 6;
|
|
596
594
|
var distanceX = bubbleRect.width + bubbleRect.width / divider;
|
|
597
|
-
|
|
598
|
-
bubbleRect =
|
|
595
|
+
bubble.current.parentNode.style.transform = "translate3d(-".concat(distanceX, "px, -").concat(bubbleRect.height, "px, 0px)");
|
|
596
|
+
bubbleRect = bubble.current.getBoundingClientRect();
|
|
599
597
|
var completeOutside = x > window.innerWidth + bubbleRect.width || y < -bubbleRect.height || y > window.innerHeight || x < -bubbleRect.width || bubbleRect.x < 10;
|
|
600
598
|
|
|
601
599
|
if (completeOutside) {
|
|
602
|
-
|
|
600
|
+
bubble.current.parentNode.style.transform = '';
|
|
603
601
|
messagePosition.current.child = null;
|
|
604
602
|
messagePosition.current.parent = null;
|
|
605
603
|
}
|
|
@@ -615,13 +613,10 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
615
613
|
});
|
|
616
614
|
}
|
|
617
615
|
} else {
|
|
618
|
-
|
|
616
|
+
bubble.current.parentNode.style.transform = '';
|
|
619
617
|
}
|
|
620
618
|
}
|
|
621
619
|
}, [camera.quaternion, currentLine === null || currentLine === void 0 ? void 0 : currentLine.slots, currentMessage.inScene, getAvatarURL]);
|
|
622
|
-
(0, _react.useEffect)(function () {
|
|
623
|
-
checkBubbleBounds();
|
|
624
|
-
}, [checkBubbleBounds]);
|
|
625
620
|
(0, _react.useEffect)(function () {
|
|
626
621
|
if (animationRunning) {
|
|
627
622
|
var cam = camera;
|
|
@@ -638,7 +633,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
638
633
|
|
|
639
634
|
messagePosition.current.pos[0] -= headSpace;
|
|
640
635
|
animationTarget.current.translateX(-10 + headSpace);
|
|
641
|
-
animationTarget.current.translateY(
|
|
636
|
+
animationTarget.current.translateY(0);
|
|
642
637
|
animationTarget.current.translateZ(30);
|
|
643
638
|
}
|
|
644
639
|
|
|
@@ -716,21 +711,11 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
716
711
|
} // 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥
|
|
717
712
|
|
|
718
713
|
|
|
719
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, currentMessage.text ? /*#__PURE__*/_react.default.createElement(
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
calculatePosition: currentMessage.inScene ? undefined : function () {
|
|
725
|
-
return [0, 0];
|
|
726
|
-
},
|
|
727
|
-
style: currentMessage.inScene ? {
|
|
728
|
-
position: 'static'
|
|
729
|
-
} : cleanStyle
|
|
730
|
-
}, /*#__PURE__*/_react.default.createElement(_SpeechBubbleComponent.default, {
|
|
731
|
-
ref: bubbleRef,
|
|
732
|
-
message: currentMessage
|
|
733
|
-
}))) : null, /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.HtmlPro, {
|
|
714
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, currentMessage.text ? /*#__PURE__*/_react.default.createElement(_BubbleWrapper.default, {
|
|
715
|
+
position: messagePosition.current.pos,
|
|
716
|
+
currentMessage: currentMessage,
|
|
717
|
+
onLoad: checkBubbleBounds
|
|
718
|
+
}) : null, /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.HtmlPro, {
|
|
734
719
|
style: {
|
|
735
720
|
width: '100vw',
|
|
736
721
|
height: '100vh'
|
|
@@ -1,16 +1,38 @@
|
|
|
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); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.default = void 0;
|
|
7
9
|
|
|
8
|
-
var _react =
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
+
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
|
|
16
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
|
+
|
|
18
|
+
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."); }
|
|
9
19
|
|
|
10
|
-
function
|
|
20
|
+
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); }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
25
|
+
|
|
26
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
27
|
|
|
12
28
|
var SpeechBubbleComponent = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
13
|
-
var message = _ref.message
|
|
29
|
+
var message = _ref.message,
|
|
30
|
+
onLoad = _ref.onLoad;
|
|
31
|
+
|
|
32
|
+
var _useState = (0, _react.useState)(false),
|
|
33
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
+
mounted = _useState2[0],
|
|
35
|
+
setMounted = _useState2[1];
|
|
14
36
|
|
|
15
37
|
var getAvatar = function getAvatar() {
|
|
16
38
|
var avatarUrl = message.avatar;
|
|
@@ -27,7 +49,13 @@ var SpeechBubbleComponent = /*#__PURE__*/_react.default.forwardRef(function (_re
|
|
|
27
49
|
return avatarUrl;
|
|
28
50
|
};
|
|
29
51
|
|
|
30
|
-
|
|
52
|
+
(0, _react.useLayoutEffect)(function () {
|
|
53
|
+
if (!mounted) {
|
|
54
|
+
onLoad();
|
|
55
|
+
setMounted(true);
|
|
56
|
+
}
|
|
57
|
+
}, [onLoad, mounted]);
|
|
58
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
31
59
|
dir: "auto",
|
|
32
60
|
ref: ref,
|
|
33
61
|
className: "\n speech-bubble\n ".concat(message.left && message.inScene ? 'speech-bubble--arrow-left' : '', "\n ").concat(!message.left && message.inScene ? 'speech-bubble--arrow-right' : '', "\n ").concat(message.top && message.inScene ? 'arrow-top' : '', "\n ").concat(message.thinkful || message.voiceOver ? 'speech-bubble--italic' : '', "\n ")
|
|
@@ -48,7 +76,7 @@ var SpeechBubbleComponent = /*#__PURE__*/_react.default.forwardRef(function (_re
|
|
|
48
76
|
className: "speech-bubble__title"
|
|
49
77
|
}, message.name)), message.text ? /*#__PURE__*/_react.default.createElement("div", {
|
|
50
78
|
className: "speech-bubble__text"
|
|
51
|
-
}, message.text) : null))
|
|
79
|
+
}, message.text) : null));
|
|
52
80
|
});
|
|
53
81
|
|
|
54
82
|
var _default = SpeechBubbleComponent;
|
|
@@ -274,9 +274,7 @@ var VideoVisor = function VideoVisor(_ref) {
|
|
|
274
274
|
onEnded: onEnded,
|
|
275
275
|
onError: onError,
|
|
276
276
|
onPlaying: onPlaying
|
|
277
|
-
}, videoProps), /*#__PURE__*/_react.default.createElement("
|
|
278
|
-
kind: "captions"
|
|
279
|
-
})), loading ? /*#__PURE__*/_react.default.createElement("div", {
|
|
277
|
+
}, videoProps)), loading ? /*#__PURE__*/_react.default.createElement("div", {
|
|
280
278
|
className: "video-loading-container",
|
|
281
279
|
style: {
|
|
282
280
|
top: 0,
|
package/dist/helpers/index.js
CHANGED
|
@@ -158,6 +158,7 @@ var setWeight = function setWeight(action, weight) {
|
|
|
158
158
|
|
|
159
159
|
var executeCrossFade = function executeCrossFade(startAction, endAction, duration) {
|
|
160
160
|
if (startAction === endAction) return;
|
|
161
|
+
if (!startAction || !endAction) return;
|
|
161
162
|
startAction.play();
|
|
162
163
|
startAction.reset();
|
|
163
164
|
endAction.reset();
|