@gamelearn/arcade-components 0.25.34 → 0.25.35
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.
|
@@ -100,7 +100,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
100
100
|
var animationStart = (0, _react.useRef)(false);
|
|
101
101
|
var bubbleRef = (0, _react.useRef)();
|
|
102
102
|
var groupRef = (0, _react.useRef)();
|
|
103
|
-
var animationTarget = (0, _react.useRef)(new _three.
|
|
103
|
+
var animationTarget = (0, _react.useRef)(new _three.Object3D());
|
|
104
104
|
var currentLine = lines[line];
|
|
105
105
|
var lastLine = lines[line - 1];
|
|
106
106
|
var lastSet = (0, _react.useRef)(false);
|
|
@@ -220,18 +220,21 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
220
220
|
});
|
|
221
221
|
}, currentLine.decision ? 0 : 700);
|
|
222
222
|
}
|
|
223
|
-
}, [camera, currentLine.decision, emitEvent, line, lines.length, resetAnims, zoomInActor]);
|
|
223
|
+
}, [camera, currentLine.decision, emitEvent, line, lines.length, resetAnims, zoomInActor]);
|
|
224
|
+
var resetCameraView = (0, _react.useCallback)(function () {
|
|
225
|
+
messagePosition.current.child = null;
|
|
226
|
+
messagePosition.current.parent = null;
|
|
227
|
+
if (zoomInActor) animationStart.current = true;
|
|
228
|
+
}, [zoomInActor]); // Position bubble over talking character/and switch emotions
|
|
224
229
|
|
|
225
230
|
(0, _react.useEffect)(function () {
|
|
226
231
|
setCurrentMessage({});
|
|
227
232
|
|
|
228
233
|
if (currentLine.decision) {
|
|
229
|
-
|
|
230
|
-
messagePosition.current.parent = null;
|
|
234
|
+
resetCameraView();
|
|
231
235
|
return;
|
|
232
236
|
} else if (currentLine.voiceOver) {
|
|
233
|
-
|
|
234
|
-
messagePosition.current.parent = null;
|
|
237
|
+
resetCameraView();
|
|
235
238
|
setCurrentMessage({
|
|
236
239
|
text: currentLine.text,
|
|
237
240
|
name: currentLine.alias || "[ ".concat(translate('storylines.misc.voiceOver'), " ]"),
|
|
@@ -285,7 +288,8 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
285
288
|
var box = new _three.Box3().setFromObject(element);
|
|
286
289
|
var bodySize = box.getSize(new _three.Vector3());
|
|
287
290
|
var headPos = head.getWorldPosition(new _three.Vector3());
|
|
288
|
-
headPos.add(
|
|
291
|
+
headPos.add((0, _helpers.vectorTranslateX)(bodySize.x / 8, camera));
|
|
292
|
+
headPos.add((0, _helpers.vectorTranslateY)(bodySize.y / 6, camera));
|
|
289
293
|
messagePosition.current = {
|
|
290
294
|
pos: headPos.toArray(),
|
|
291
295
|
child: head,
|
|
@@ -313,9 +317,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
313
317
|
} else {
|
|
314
318
|
var _talkingCharacter$cha2;
|
|
315
319
|
|
|
316
|
-
|
|
317
|
-
messagePosition.current.parent = null;
|
|
318
|
-
if (zoomInActor) animationStart.current = true;
|
|
320
|
+
resetCameraView();
|
|
319
321
|
setCurrentMessage({
|
|
320
322
|
text: talkingCharacter.text,
|
|
321
323
|
name: talkingCharacter.alias || ((_talkingCharacter$cha2 = talkingCharacter.character) === null || _talkingCharacter$cha2 === void 0 ? void 0 : _talkingCharacter$cha2.name) || object.name,
|
|
@@ -327,7 +329,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
327
329
|
}
|
|
328
330
|
}
|
|
329
331
|
}
|
|
330
|
-
}, [actors, camera, currentLine, zoomInActor, getCurrentVisible, translate, getAvatarURL, loadEmotion, resetAnims]); // Autoplay logic
|
|
332
|
+
}, [actors, camera, currentLine, zoomInActor, getCurrentVisible, translate, getAvatarURL, loadEmotion, resetAnims, resetCameraView]); // Autoplay logic
|
|
331
333
|
|
|
332
334
|
(0, _react.useEffect)(function () {
|
|
333
335
|
var timeout;
|
|
@@ -353,15 +355,14 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
353
355
|
return slot.talking;
|
|
354
356
|
});
|
|
355
357
|
var bubbleRect = bubbleRef.current.getBoundingClientRect();
|
|
356
|
-
var x = bubbleRect.x + bubbleRect.width;
|
|
357
|
-
var y = bubbleRect.y - bubbleRect.height;
|
|
358
|
+
var x = bubbleRect.x + bubbleRect.width / 2;
|
|
359
|
+
var y = bubbleRect.y - bubbleRect.height / 2;
|
|
358
360
|
|
|
359
361
|
if ((x < 0 || x > window.innerWidth || y < 0 || y > window.innerHeight) && currentMessage.inScene) {
|
|
360
362
|
var child = messagePosition.current.child;
|
|
361
|
-
var headPos = child.getWorldPosition(new _three.Vector3());
|
|
362
363
|
|
|
363
|
-
if (child
|
|
364
|
-
groupRef.current.position.
|
|
364
|
+
if (child) {
|
|
365
|
+
groupRef.current.position.fromArray(messagePosition.current.pos);
|
|
365
366
|
var completeOutside = x > window.innerWidth + bubbleRect.width || y < -bubbleRect.height || y > window.innerHeight || x < -bubbleRect.width;
|
|
366
367
|
var distanceX = bubbleRect.width + bubbleRect.width / 4;
|
|
367
368
|
bubbleRef.current.parentNode.style.transform = "translate3d(-".concat(distanceX, "px, -").concat(bubbleRect.height / 2, "px, 0px)");
|
|
@@ -391,25 +392,27 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
391
392
|
var camera = _ref2.camera;
|
|
392
393
|
|
|
393
394
|
if (animationStart.current) {
|
|
394
|
-
var
|
|
395
|
-
|
|
395
|
+
var targetPosition = messagePosition.current.child ? messagePosition.current.pos : defaultCamera.current.position.toArray();
|
|
396
|
+
animationTarget.current.position.fromArray(targetPosition);
|
|
396
397
|
|
|
397
398
|
if (messagePosition.current.parent) {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
399
|
+
if (!animationTarget.current.quaternion.equals(camera.quaternion)) {
|
|
400
|
+
animationTarget.current.applyQuaternion(camera.quaternion);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
animationTarget.current.translateX(12);
|
|
404
|
+
animationTarget.current.translateY(-5);
|
|
405
|
+
animationTarget.current.translateZ(30);
|
|
403
406
|
}
|
|
404
407
|
|
|
405
|
-
if (
|
|
408
|
+
if (animationTarget.current.position.distanceTo(camera.position) < 1) {
|
|
406
409
|
animationStart.current = false;
|
|
407
410
|
|
|
408
411
|
if (lastSet.current || !messagePosition.current.child) {
|
|
409
412
|
camera.copy(defaultCamera.current);
|
|
410
413
|
}
|
|
411
414
|
} else {
|
|
412
|
-
camera.position.lerp(
|
|
415
|
+
camera.position.lerp(animationTarget.current.position, delta * 2.5);
|
|
413
416
|
}
|
|
414
417
|
}
|
|
415
418
|
});
|