@gamelearn/arcade-components 1.20.1 → 1.21.0
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.
|
@@ -31,6 +31,8 @@ var AnimationComponent = function AnimationComponent(_ref) {
|
|
|
31
31
|
var animation = _ref.animation,
|
|
32
32
|
loopTimes = _ref.loopTimes,
|
|
33
33
|
resource = _ref.resource,
|
|
34
|
+
enableInteraction = _ref.enableInteraction,
|
|
35
|
+
makeDefault = _ref.makeDefault,
|
|
34
36
|
emitEvent = _ref.emitEvent;
|
|
35
37
|
|
|
36
38
|
var _useState = (0, _react.useState)(false),
|
|
@@ -46,7 +48,7 @@ var AnimationComponent = function AnimationComponent(_ref) {
|
|
|
46
48
|
}, []);
|
|
47
49
|
(0, _react.useEffect)(function () {
|
|
48
50
|
setMounted(false);
|
|
49
|
-
}, [resource.
|
|
51
|
+
}, [resource.uid, animation.url]);
|
|
50
52
|
(0, _react.useEffect)(function () {
|
|
51
53
|
if (!mounted) {
|
|
52
54
|
var object;
|
|
@@ -57,6 +59,10 @@ var AnimationComponent = function AnimationComponent(_ref) {
|
|
|
57
59
|
});
|
|
58
60
|
|
|
59
61
|
if (object) {
|
|
62
|
+
var canInteract = enableInteraction;
|
|
63
|
+
if (canInteract) emitEvent({
|
|
64
|
+
type: 'success'
|
|
65
|
+
});
|
|
60
66
|
loader.load(animation.url, function (gltf) {
|
|
61
67
|
var mixer = object.userData.mixer;
|
|
62
68
|
var defaultAnim = object.userData.defaultAnim;
|
|
@@ -68,7 +74,18 @@ var AnimationComponent = function AnimationComponent(_ref) {
|
|
|
68
74
|
|
|
69
75
|
var finishCallback = function finishCallback() {
|
|
70
76
|
(0, _helpers.executeCrossFade)(currentAction, oldAction, 0.5);
|
|
71
|
-
|
|
77
|
+
|
|
78
|
+
if (makeDefault) {
|
|
79
|
+
emitEvent({
|
|
80
|
+
type: 'saveAnimation',
|
|
81
|
+
payload: {
|
|
82
|
+
uid: resource.uid,
|
|
83
|
+
animation: animation.id
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!canInteract) emitEvent({
|
|
72
89
|
type: 'success'
|
|
73
90
|
});
|
|
74
91
|
mixer.removeEventListener('finished', finishCallback);
|
|
@@ -83,7 +100,7 @@ var AnimationComponent = function AnimationComponent(_ref) {
|
|
|
83
100
|
});
|
|
84
101
|
}
|
|
85
102
|
}
|
|
86
|
-
}, [scene, animation.url, loopTimes, emitEvent, mounted, loader, resource.uid]);
|
|
103
|
+
}, [scene, animation.url, loopTimes, emitEvent, mounted, loader, resource.uid, makeDefault, animation, resource, enableInteraction]);
|
|
87
104
|
return null;
|
|
88
105
|
};
|
|
89
106
|
|
|
@@ -200,14 +200,16 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
200
200
|
var defaultAction = mixer.clipAction(element.userData.defaultAnim, element);
|
|
201
201
|
|
|
202
202
|
if (element.userData.currentEmotion !== defaultAction) {
|
|
203
|
-
|
|
204
|
-
|
|
203
|
+
setTimeout(function () {
|
|
204
|
+
mixer.stopAllAction();
|
|
205
|
+
(0, _helpers.executeCrossFade)(startAction, defaultAction, crossFadeDuration / Math.floor(Math.random() * 3));
|
|
205
206
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
if (element.userData.currentEmotion) {
|
|
208
|
+
element.userData.lastEmotion = element.userData.currentEmotion;
|
|
209
|
+
}
|
|
209
210
|
|
|
210
|
-
|
|
211
|
+
element.userData.currentEmotion = defaultAction;
|
|
212
|
+
}, Math.floor(Math.random() * 3) * 500);
|
|
211
213
|
}
|
|
212
214
|
}; // Reset currentEmotion to defaultAnim
|
|
213
215
|
|
|
@@ -359,12 +361,14 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
359
361
|
|
|
360
362
|
if (element) {
|
|
361
363
|
loadEmotion(slot, element, function (mixer, action, defaultAction) {
|
|
362
|
-
|
|
364
|
+
setTimeout(function () {
|
|
365
|
+
var startAction = element.userData.lastEmotion ? element.userData.lastEmotion : defaultAction;
|
|
363
366
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
367
|
+
if (startAction && action && startAction !== action) {
|
|
368
|
+
mixer.stopAllAction();
|
|
369
|
+
(0, _helpers.executeCrossFade)(startAction, action, crossFadeDuration / Math.floor(Math.random() * 3));
|
|
370
|
+
}
|
|
371
|
+
}, Math.floor(Math.random() * 3) * 500);
|
|
368
372
|
});
|
|
369
373
|
}
|
|
370
374
|
}); // Talking element logic
|
|
@@ -601,7 +605,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
601
605
|
});
|
|
602
606
|
|
|
603
607
|
return /*#__PURE__*/_react.default.createElement(_arcadeThreeCore.HtmlPro, {
|
|
604
|
-
zIndexRange: [
|
|
608
|
+
zIndexRange: [6, 6],
|
|
605
609
|
style: cleanStyle,
|
|
606
610
|
calculatePosition: function calculatePosition() {
|
|
607
611
|
return [0, 0];
|
|
@@ -630,7 +634,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
630
634
|
width: '100vw',
|
|
631
635
|
height: '100vh'
|
|
632
636
|
},
|
|
633
|
-
zIndexRange: [
|
|
637
|
+
zIndexRange: [6, 6],
|
|
634
638
|
onOcclude: function onOcclude() {},
|
|
635
639
|
calculatePosition: function calculatePosition() {
|
|
636
640
|
return [0, 0];
|