@gamelearn/arcade-components 0.25.34 → 0.25.36
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);
|
|
@@ -194,6 +194,11 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
}, [getCurrentVisible, lastLine === null || lastLine === void 0 ? void 0 : lastLine.slots, scene]);
|
|
197
|
+
var resetCameraView = (0, _react.useCallback)(function () {
|
|
198
|
+
messagePosition.current.child = null;
|
|
199
|
+
messagePosition.current.parent = null;
|
|
200
|
+
if (zoomInActor) animationStart.current = true;
|
|
201
|
+
}, [zoomInActor]);
|
|
197
202
|
var backLine = (0, _react.useCallback)(function () {
|
|
198
203
|
if (lastLine && !lastLine.decision) {
|
|
199
204
|
changeLine(line - 1);
|
|
@@ -206,32 +211,24 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
206
211
|
resetAnims(true);
|
|
207
212
|
lastSet.current = true;
|
|
208
213
|
setCurrentMessage({});
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (zoomInActor) {
|
|
212
|
-
animationStart.current = true;
|
|
213
|
-
} else {
|
|
214
|
-
camera.copy(defaultCamera.current);
|
|
215
|
-
}
|
|
216
|
-
|
|
214
|
+
resetCameraView();
|
|
217
215
|
setTimeout(function () {
|
|
218
216
|
emitEvent({
|
|
219
217
|
type: 'success'
|
|
220
218
|
});
|
|
221
|
-
|
|
219
|
+
camera.copy(defaultCamera.current);
|
|
220
|
+
}, currentLine.decision ? 0 : 1200);
|
|
222
221
|
}
|
|
223
|
-
}, [camera, currentLine.decision, emitEvent, line, lines.length, resetAnims,
|
|
222
|
+
}, [camera, currentLine.decision, emitEvent, line, lines.length, resetAnims, resetCameraView]); // Position bubble over talking character/and switch emotions
|
|
224
223
|
|
|
225
224
|
(0, _react.useEffect)(function () {
|
|
226
225
|
setCurrentMessage({});
|
|
227
226
|
|
|
228
227
|
if (currentLine.decision) {
|
|
229
|
-
|
|
230
|
-
messagePosition.current.parent = null;
|
|
228
|
+
resetCameraView();
|
|
231
229
|
return;
|
|
232
230
|
} else if (currentLine.voiceOver) {
|
|
233
|
-
|
|
234
|
-
messagePosition.current.parent = null;
|
|
231
|
+
resetCameraView();
|
|
235
232
|
setCurrentMessage({
|
|
236
233
|
text: currentLine.text,
|
|
237
234
|
name: currentLine.alias || "[ ".concat(translate('storylines.misc.voiceOver'), " ]"),
|
|
@@ -285,7 +282,8 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
285
282
|
var box = new _three.Box3().setFromObject(element);
|
|
286
283
|
var bodySize = box.getSize(new _three.Vector3());
|
|
287
284
|
var headPos = head.getWorldPosition(new _three.Vector3());
|
|
288
|
-
headPos.add(
|
|
285
|
+
headPos.add((0, _helpers.vectorTranslateX)(bodySize.x / 8, camera));
|
|
286
|
+
headPos.add((0, _helpers.vectorTranslateY)(bodySize.y / 6, camera));
|
|
289
287
|
messagePosition.current = {
|
|
290
288
|
pos: headPos.toArray(),
|
|
291
289
|
child: head,
|
|
@@ -313,9 +311,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
313
311
|
} else {
|
|
314
312
|
var _talkingCharacter$cha2;
|
|
315
313
|
|
|
316
|
-
|
|
317
|
-
messagePosition.current.parent = null;
|
|
318
|
-
if (zoomInActor) animationStart.current = true;
|
|
314
|
+
resetCameraView();
|
|
319
315
|
setCurrentMessage({
|
|
320
316
|
text: talkingCharacter.text,
|
|
321
317
|
name: talkingCharacter.alias || ((_talkingCharacter$cha2 = talkingCharacter.character) === null || _talkingCharacter$cha2 === void 0 ? void 0 : _talkingCharacter$cha2.name) || object.name,
|
|
@@ -327,7 +323,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
327
323
|
}
|
|
328
324
|
}
|
|
329
325
|
}
|
|
330
|
-
}, [actors, camera, currentLine, zoomInActor, getCurrentVisible, translate, getAvatarURL, loadEmotion, resetAnims]); // Autoplay logic
|
|
326
|
+
}, [actors, camera, currentLine, zoomInActor, getCurrentVisible, translate, getAvatarURL, loadEmotion, resetAnims, resetCameraView]); // Autoplay logic
|
|
331
327
|
|
|
332
328
|
(0, _react.useEffect)(function () {
|
|
333
329
|
var timeout;
|
|
@@ -353,15 +349,14 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
353
349
|
return slot.talking;
|
|
354
350
|
});
|
|
355
351
|
var bubbleRect = bubbleRef.current.getBoundingClientRect();
|
|
356
|
-
var x = bubbleRect.x + bubbleRect.width;
|
|
357
|
-
var y = bubbleRect.y - bubbleRect.height;
|
|
352
|
+
var x = bubbleRect.x + bubbleRect.width / 2;
|
|
353
|
+
var y = bubbleRect.y - bubbleRect.height / 2;
|
|
358
354
|
|
|
359
355
|
if ((x < 0 || x > window.innerWidth || y < 0 || y > window.innerHeight) && currentMessage.inScene) {
|
|
360
356
|
var child = messagePosition.current.child;
|
|
361
|
-
var headPos = child.getWorldPosition(new _three.Vector3());
|
|
362
357
|
|
|
363
|
-
if (child
|
|
364
|
-
groupRef.current.position.
|
|
358
|
+
if (child) {
|
|
359
|
+
groupRef.current.position.fromArray(messagePosition.current.pos);
|
|
365
360
|
var completeOutside = x > window.innerWidth + bubbleRect.width || y < -bubbleRect.height || y > window.innerHeight || x < -bubbleRect.width;
|
|
366
361
|
var distanceX = bubbleRect.width + bubbleRect.width / 4;
|
|
367
362
|
bubbleRef.current.parentNode.style.transform = "translate3d(-".concat(distanceX, "px, -").concat(bubbleRect.height / 2, "px, 0px)");
|
|
@@ -391,25 +386,27 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
391
386
|
var camera = _ref2.camera;
|
|
392
387
|
|
|
393
388
|
if (animationStart.current) {
|
|
394
|
-
var
|
|
395
|
-
|
|
389
|
+
var targetPosition = messagePosition.current.child ? messagePosition.current.pos : defaultCamera.current.position.toArray();
|
|
390
|
+
animationTarget.current.position.fromArray(targetPosition);
|
|
396
391
|
|
|
397
392
|
if (messagePosition.current.parent) {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
393
|
+
if (!animationTarget.current.quaternion.equals(camera.quaternion)) {
|
|
394
|
+
animationTarget.current.applyQuaternion(camera.quaternion);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
animationTarget.current.translateX(12);
|
|
398
|
+
animationTarget.current.translateY(-5);
|
|
399
|
+
animationTarget.current.translateZ(30);
|
|
403
400
|
}
|
|
404
401
|
|
|
405
|
-
if (
|
|
402
|
+
if (animationTarget.current.position.distanceTo(camera.position) < 1) {
|
|
406
403
|
animationStart.current = false;
|
|
407
404
|
|
|
408
405
|
if (lastSet.current || !messagePosition.current.child) {
|
|
409
406
|
camera.copy(defaultCamera.current);
|
|
410
407
|
}
|
|
411
408
|
} else {
|
|
412
|
-
camera.position.lerp(
|
|
409
|
+
camera.position.lerp(animationTarget.current.position, delta * 2.5);
|
|
413
410
|
}
|
|
414
411
|
}
|
|
415
412
|
});
|