@gamelearn/arcade-components 0.27.1 → 0.27.3
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.
|
@@ -58,6 +58,9 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
58
58
|
var isMobile = (0, _deviceDetection.DeviceDetection)();
|
|
59
59
|
var crossFadeDuration = 0.5; // Mobile always zoom in?
|
|
60
60
|
|
|
61
|
+
var raycast = new _three.Raycaster();
|
|
62
|
+
raycast.firstHitOnly = true;
|
|
63
|
+
|
|
61
64
|
var DialogComponent = function DialogComponent(_ref) {
|
|
62
65
|
var _currentLine$audio3, _currentLine$audio4;
|
|
63
66
|
|
|
@@ -100,6 +103,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
100
103
|
camera = _useThree2[0],
|
|
101
104
|
scene = _useThree2[1];
|
|
102
105
|
|
|
106
|
+
var changedMats = (0, _react.useRef)([]);
|
|
103
107
|
var loader = (0, _react.useMemo)(function () {
|
|
104
108
|
return new _GLTFLoader.GLTFLoader();
|
|
105
109
|
}, []);
|
|
@@ -207,10 +211,10 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
207
211
|
|
|
208
212
|
var onLoadAnim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
|
|
209
213
|
var animation = (_slot$character2 = slot.character) === null || _slot$character2 === void 0 ? void 0 : _slot$character2.resource.animations[slot.emotion];
|
|
214
|
+
var mixer = element.userData.mixer;
|
|
210
215
|
|
|
211
|
-
if (animation) {
|
|
212
|
-
|
|
213
|
-
loader.load(animation === null || animation === void 0 ? void 0 : animation.url, function (anim) {
|
|
216
|
+
if (animation && animation.url) {
|
|
217
|
+
loader.load(animation.url, function (anim) {
|
|
214
218
|
var emotionClip = anim.animations[0];
|
|
215
219
|
var defaultClip = element.userData.defaultAnim;
|
|
216
220
|
var emotionAction = mixer.clipAction(emotionClip, element);
|
|
@@ -223,6 +227,8 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
223
227
|
element.userData.currentEmotion = emotionAction;
|
|
224
228
|
onLoadAnim(mixer, emotionAction, defaultAction);
|
|
225
229
|
});
|
|
230
|
+
} else {
|
|
231
|
+
onLoadAnim();
|
|
226
232
|
}
|
|
227
233
|
}, [loader]); // Reset currentEmotion to defaultAnim
|
|
228
234
|
|
|
@@ -325,7 +331,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
325
331
|
loadEmotion(slot, element, function (mixer, action, defaultAction) {
|
|
326
332
|
var startAction = element.userData.lastEmotion ? element.userData.lastEmotion : defaultAction;
|
|
327
333
|
|
|
328
|
-
if (startAction !== action) {
|
|
334
|
+
if (startAction && action && startAction !== action) {
|
|
329
335
|
mixer.stopAllAction();
|
|
330
336
|
(0, _helpers.executeCrossFade)(startAction, action, crossFadeDuration);
|
|
331
337
|
}
|
|
@@ -343,7 +349,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
343
349
|
loadEmotion(talkingCharacter, element, function (mixer, action, defaultAction) {
|
|
344
350
|
var startAction = element.userData.lastEmotion ? element.userData.lastEmotion : defaultAction;
|
|
345
351
|
|
|
346
|
-
if (startAction !== action) {
|
|
352
|
+
if (startAction && action && startAction !== action) {
|
|
347
353
|
mixer.stopAllAction();
|
|
348
354
|
(0, _helpers.executeCrossFade)(startAction, action, crossFadeDuration);
|
|
349
355
|
} // Ugly timeout to wait an animation transition
|
|
@@ -423,7 +429,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
423
429
|
if (line >= lines.length - 1 && automatic) {
|
|
424
430
|
setAutomatic(false);
|
|
425
431
|
} else if (automatic && currentMessage.text && !currentLine.decision) {
|
|
426
|
-
var time =
|
|
432
|
+
var time = 75 * (currentMessage === null || currentMessage === void 0 ? void 0 : currentMessage.text.length);
|
|
427
433
|
timeout = setTimeout(function () {
|
|
428
434
|
nextLine();
|
|
429
435
|
}, time < 1400 ? 1400 : time);
|
|
@@ -494,13 +500,25 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
494
500
|
animationTarget.current.applyQuaternion(camera.quaternion);
|
|
495
501
|
}
|
|
496
502
|
|
|
497
|
-
animationTarget.current.translateX(
|
|
503
|
+
animationTarget.current.translateX(12);
|
|
498
504
|
animationTarget.current.translateY(-5);
|
|
499
505
|
animationTarget.current.translateZ(30);
|
|
500
506
|
}
|
|
501
507
|
|
|
502
508
|
if (animationTarget.current.position.distanceTo(camera.position) < 1) {
|
|
503
509
|
animationStart.current = false;
|
|
510
|
+
raycast.set(camera.getWorldPosition(new _three.Vector3(0, 0, 0)), camera.getWorldDirection(new _three.Vector3()));
|
|
511
|
+
var objects = raycast.intersectObjects(scene.children, true);
|
|
512
|
+
changedMats.current = objects.filter(function (o) {
|
|
513
|
+
return o.distance < 10;
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
if (changedMats.current.length) {
|
|
517
|
+
changedMats.current.forEach(function (o) {
|
|
518
|
+
var object = o.object;
|
|
519
|
+
object.material.visible = false;
|
|
520
|
+
});
|
|
521
|
+
}
|
|
504
522
|
|
|
505
523
|
if (lastSet.current || !messagePosition.current.child) {
|
|
506
524
|
camera.copy(defaultCamera.current);
|
|
@@ -508,6 +526,13 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
508
526
|
|
|
509
527
|
checkBubblePosition();
|
|
510
528
|
} else {
|
|
529
|
+
if (changedMats.current.length) {
|
|
530
|
+
changedMats.current.forEach(function (o) {
|
|
531
|
+
var object = o.object;
|
|
532
|
+
object.material.visible = true;
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
|
|
511
536
|
camera.position.lerp(animationTarget.current.position, delta * 2.5);
|
|
512
537
|
}
|
|
513
538
|
}
|
|
@@ -65,28 +65,38 @@ var LoginPuzzleComponent = function LoginPuzzleComponent(_ref) {
|
|
|
65
65
|
inputPassword = _useState4[0],
|
|
66
66
|
setPassword = _useState4[1];
|
|
67
67
|
|
|
68
|
-
var _useState5 = (0, _react.useState)(
|
|
68
|
+
var _useState5 = (0, _react.useState)(false),
|
|
69
69
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
inputPasswordFocus = _useState6[0],
|
|
71
|
+
setInputPasswordFocus = _useState6[1];
|
|
72
72
|
|
|
73
|
-
var _useState7 = (0, _react.useState)(
|
|
73
|
+
var _useState7 = (0, _react.useState)(''),
|
|
74
74
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
fakeHashes = _useState8[0],
|
|
76
|
+
setFakeHashes = _useState8[1];
|
|
77
77
|
|
|
78
|
-
var _useState9 = (0, _react.useState)(
|
|
78
|
+
var _useState9 = (0, _react.useState)(''),
|
|
79
79
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
successClass = _useState10[0],
|
|
81
|
+
setSuccessClass = _useState10[1];
|
|
82
|
+
|
|
83
|
+
var _useState11 = (0, _react.useState)(false),
|
|
84
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
85
|
+
finished = _useState12[0],
|
|
86
|
+
setFinished = _useState12[1];
|
|
87
|
+
|
|
88
|
+
var _useState13 = (0, _react.useState)(false),
|
|
89
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
90
|
+
errorMessage = _useState14[0],
|
|
91
|
+
setErrorMessage = _useState14[1];
|
|
82
92
|
|
|
83
93
|
var _soundActions = _slicedToArray(soundActions, 1),
|
|
84
94
|
playSound = _soundActions[0];
|
|
85
95
|
|
|
86
|
-
var
|
|
87
|
-
|
|
88
|
-
accRewards =
|
|
89
|
-
setRewards =
|
|
96
|
+
var _useState15 = (0, _react.useState)([]),
|
|
97
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
98
|
+
accRewards = _useState16[0],
|
|
99
|
+
setRewards = _useState16[1];
|
|
90
100
|
|
|
91
101
|
var imgURL = ((_image$img = image.img) === null || _image$img === void 0 ? void 0 : _image$img.url) || imagenPorDefecto;
|
|
92
102
|
|
|
@@ -126,6 +136,18 @@ var LoginPuzzleComponent = function LoginPuzzleComponent(_ref) {
|
|
|
126
136
|
}
|
|
127
137
|
};
|
|
128
138
|
|
|
139
|
+
var changeCharactersByHashes = function changeCharactersByHashes(e) {
|
|
140
|
+
var fakePassword = '';
|
|
141
|
+
|
|
142
|
+
if (e.length >= 0) {
|
|
143
|
+
for (var i = 0; i < e.length; i++) {
|
|
144
|
+
fakePassword += '•';
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
setFakeHashes(fakePassword);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
129
151
|
(0, _react.useEffect)(function () {
|
|
130
152
|
setResolveAction(function () {
|
|
131
153
|
var rewardsData = [].concat(_toConsumableArray(accRewards), _toConsumableArray(info.resolve.rewards));
|
|
@@ -152,7 +174,6 @@ var LoginPuzzleComponent = function LoginPuzzleComponent(_ref) {
|
|
|
152
174
|
}, translate('puzzle.user')), /*#__PURE__*/_react.default.createElement("div", {
|
|
153
175
|
className: "puzzle--login__group"
|
|
154
176
|
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
155
|
-
autoComplete: "off",
|
|
156
177
|
disabled: finished,
|
|
157
178
|
"data-testid": "username",
|
|
158
179
|
className: "puzzle--login__input ".concat(successClass),
|
|
@@ -170,18 +191,26 @@ var LoginPuzzleComponent = function LoginPuzzleComponent(_ref) {
|
|
|
170
191
|
}, /*#__PURE__*/_react.default.createElement("span", null, translate('puzzle.password'))), /*#__PURE__*/_react.default.createElement("div", {
|
|
171
192
|
className: "puzzle--login__group"
|
|
172
193
|
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
173
|
-
autoComplete: "off",
|
|
174
194
|
disabled: finished,
|
|
175
195
|
"data-testid": "password",
|
|
176
|
-
className: "puzzle--login__input ".concat(successClass),
|
|
177
|
-
type: "
|
|
196
|
+
className: "puzzle--login__input puzzle--login__input--fakepassword ".concat(successClass),
|
|
197
|
+
type: "text",
|
|
178
198
|
placeholder: translate('puzzle.password'),
|
|
199
|
+
onFocus: function onFocus(e) {
|
|
200
|
+
setInputPasswordFocus(true);
|
|
201
|
+
},
|
|
202
|
+
onBlur: function onBlur(e) {
|
|
203
|
+
setInputPasswordFocus(false);
|
|
204
|
+
},
|
|
179
205
|
onChange: function onChange(e) {
|
|
180
206
|
setPassword(e.target.value);
|
|
207
|
+
changeCharactersByHashes(e.target.value);
|
|
181
208
|
setSuccessClass('');
|
|
182
209
|
setErrorMessage(false);
|
|
183
210
|
}
|
|
184
|
-
}), /*#__PURE__*/_react.default.createElement("
|
|
211
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
212
|
+
className: "login-fakepassword" + (inputPasswordFocus ? " login-fakepassword--focus" : "") + (fakeHashes.length ? " login-fakepassword--fill" : "") + " ".concat(successClass ? successClass : '')
|
|
213
|
+
}, inputPassword ? fakeHashes : translate('puzzle.password')), /*#__PURE__*/_react.default.createElement("span", {
|
|
185
214
|
className: "icon-circle-check"
|
|
186
215
|
}, " ")))), /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("button", {
|
|
187
216
|
type: "button",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gamelearn/arcade-components",
|
|
3
3
|
"license": "Gamelearn",
|
|
4
|
-
"version": "0.27.
|
|
4
|
+
"version": "0.27.3",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@babel/cli": "7.12.10",
|
|
60
60
|
"@babel/preset-env": "7.12.11",
|
|
61
61
|
"@babel/preset-react": "7.12.10",
|
|
62
|
-
"@gamelearn/arcade-styles": "0.
|
|
62
|
+
"@gamelearn/arcade-styles": "0.4.1",
|
|
63
63
|
"@react-three/test-renderer": "6.0.6",
|
|
64
64
|
"@storybook/addon-actions": "6.1.11",
|
|
65
65
|
"@storybook/addon-essentials": "6.1.11",
|