@gamelearn/arcade-components 0.21.10 → 0.22.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.
- package/dist/components/arcade-render/element/AnimateElement.js +11 -7
- package/dist/components/conversational-pro-component/components/ConversationalProComponent.js +37 -13
- package/dist/components/conversational-pro-component/components/SlotList.js +49 -16
- package/dist/components/conversational-pro-component/components/scene/Panels.js +4 -4
- package/dist/components/text-click-puzzle-component/components/TextClickPuzzleComponent.js +1 -0
- package/package.json +1 -1
|
@@ -37,15 +37,19 @@ var AnimateElement = function AnimateElement(_ref) {
|
|
|
37
37
|
|
|
38
38
|
var _useAnimations = (0, _drei.useAnimations)(animations),
|
|
39
39
|
ref = _useAnimations.ref,
|
|
40
|
-
mixer = _useAnimations.mixer
|
|
41
|
-
actions = _useAnimations.actions;
|
|
40
|
+
mixer = _useAnimations.mixer;
|
|
42
41
|
|
|
43
42
|
(0, _react.useEffect)(function () {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
if (ref.current) {
|
|
44
|
+
mixer.stopAllAction();
|
|
45
|
+
var clip = animations[0];
|
|
46
|
+
|
|
47
|
+
if (clip) {
|
|
48
|
+
var action = mixer.clipAction(clip, ref.current);
|
|
49
|
+
action.play();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}, [mixer, ref, animations]);
|
|
49
53
|
return /*#__PURE__*/_react.default.createElement("primitive", _extends({
|
|
50
54
|
ref: ref,
|
|
51
55
|
object: model,
|
package/dist/components/conversational-pro-component/components/ConversationalProComponent.js
CHANGED
|
@@ -21,8 +21,6 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
21
21
|
|
|
22
22
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
|
|
23
23
|
|
|
24
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
25
|
-
|
|
26
24
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
27
25
|
|
|
28
26
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -47,6 +45,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
47
45
|
var emitEvent = _ref.emitEvent,
|
|
48
46
|
lines = _ref.lines,
|
|
49
47
|
characters = _ref.characters,
|
|
48
|
+
actors = _ref.actors,
|
|
50
49
|
background = _ref.background,
|
|
51
50
|
soundActions = _ref.soundActions,
|
|
52
51
|
lodSettings = _ref.lodSettings;
|
|
@@ -92,6 +91,32 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
92
91
|
return line.slots;
|
|
93
92
|
});
|
|
94
93
|
var lastLine = lines[currentLine - 1] ? lines[currentLine - 1] : {};
|
|
94
|
+
var hasCharacters = !currentLineData.decision && currentLineData.slots.filter(function (slot) {
|
|
95
|
+
return slot.uid;
|
|
96
|
+
}).length;
|
|
97
|
+
var currentSlots = [];
|
|
98
|
+
|
|
99
|
+
if (currentLineData.slots) {
|
|
100
|
+
currentSlots = currentLineData.slots;
|
|
101
|
+
} else if (leftWithSlots) {
|
|
102
|
+
currentSlots = leftWithSlots.slots;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
var currentCharacters = currentSlots.filter(function (slot) {
|
|
106
|
+
return slot.uid;
|
|
107
|
+
}).map(function (slot) {
|
|
108
|
+
var character = (characters || actors || []).find(function (c) {
|
|
109
|
+
return c.uid === slot.uid;
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
if (character) {
|
|
113
|
+
slot.resource = character.resource;
|
|
114
|
+
slot.type = character.type;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (!slot.resource) slot.resource = {};
|
|
118
|
+
return slot;
|
|
119
|
+
});
|
|
95
120
|
|
|
96
121
|
if (voiceOver) {
|
|
97
122
|
var rightWithSlots = lines.slice(currentLine).find(function (line) {
|
|
@@ -103,14 +128,14 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
103
128
|
voiceOverSlots = lineWithSlots.slots;
|
|
104
129
|
isFlex = lineWithSlots.flex;
|
|
105
130
|
}
|
|
106
|
-
} else if (!decision) {
|
|
131
|
+
} else if (!decision && hasCharacters) {
|
|
107
132
|
currentLineData.slots.forEach(function (slot) {
|
|
108
|
-
var indx =
|
|
133
|
+
var indx = currentCharacters.findIndex(function (char) {
|
|
109
134
|
return char.uid === slot.uid;
|
|
110
135
|
});
|
|
111
136
|
|
|
112
137
|
if (indx >= 0) {
|
|
113
|
-
|
|
138
|
+
currentCharacters[indx].emotion = slot.emotion;
|
|
114
139
|
}
|
|
115
140
|
});
|
|
116
141
|
|
|
@@ -118,10 +143,10 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
118
143
|
var notFlexedPosition = currentLineData.slots.findIndex(function (char) {
|
|
119
144
|
return char.uid === currentMessage.uid;
|
|
120
145
|
});
|
|
121
|
-
var flexedPosition =
|
|
146
|
+
var flexedPosition = currentCharacters.findIndex(function (char) {
|
|
122
147
|
return char.uid === currentMessage.uid;
|
|
123
148
|
});
|
|
124
|
-
|
|
149
|
+
currentCharacters.forEach(function (c) {
|
|
125
150
|
if (c.uid === currentMessage.uid) c.name = currentMessage.alias;
|
|
126
151
|
});
|
|
127
152
|
currentMessage.position = isFlex ? flexedPosition : notFlexedPosition;
|
|
@@ -129,7 +154,9 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
129
154
|
}
|
|
130
155
|
|
|
131
156
|
var listProps = {
|
|
132
|
-
characters:
|
|
157
|
+
characters: currentCharacters,
|
|
158
|
+
lodSettings: lodSettings,
|
|
159
|
+
actors: actors,
|
|
133
160
|
currentMessage: currentMessage || {},
|
|
134
161
|
slots: !voiceOver ? currentLineData.slots : voiceOverSlots,
|
|
135
162
|
flex: isFlex
|
|
@@ -171,7 +198,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
171
198
|
emitEvent: emitEvent,
|
|
172
199
|
soundActions: soundActions,
|
|
173
200
|
inheritProps: {
|
|
174
|
-
characters:
|
|
201
|
+
characters: currentCharacters,
|
|
175
202
|
background: background,
|
|
176
203
|
flex: leftWithSlots ? leftWithSlots.flex : true,
|
|
177
204
|
slots: !leftWithSlots ? [] : leftWithSlots.slots
|
|
@@ -189,10 +216,7 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
189
216
|
style: backgroundImage ? {
|
|
190
217
|
backgroundImage: "url(\"".concat(backgroundImage, "\")")
|
|
191
218
|
} : {}
|
|
192
|
-
}, /*#__PURE__*/_react.default.createElement(_SlotList.default,
|
|
193
|
-
characters: characters,
|
|
194
|
-
lodSettings: lodSettings
|
|
195
|
-
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
219
|
+
}, /*#__PURE__*/_react.default.createElement(_SlotList.default, listProps), /*#__PURE__*/_react.default.createElement("div", {
|
|
196
220
|
className: "conversation--body"
|
|
197
221
|
}, currentMessage ? /*#__PURE__*/_react.default.createElement(_Message.default, {
|
|
198
222
|
current: currentMessage,
|
|
@@ -7,8 +7,6 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
10
|
var _Slot = _interopRequireDefault(require("./Slot"));
|
|
13
11
|
|
|
14
12
|
var _scene = _interopRequireDefault(require("./scene"));
|
|
@@ -19,6 +17,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
19
17
|
|
|
20
18
|
var SlotList = function SlotList(_ref) {
|
|
21
19
|
var characters = _ref.characters,
|
|
20
|
+
actors = _ref.actors,
|
|
22
21
|
lodSettings = _ref.lodSettings,
|
|
23
22
|
currentMessage = _ref.currentMessage,
|
|
24
23
|
flex = _ref.flex,
|
|
@@ -37,6 +36,33 @@ var SlotList = function SlotList(_ref) {
|
|
|
37
36
|
};
|
|
38
37
|
};
|
|
39
38
|
|
|
39
|
+
var gameChars = slots.reduce(function (acc, current) {
|
|
40
|
+
var actor = actors === null || actors === void 0 ? void 0 : actors.find(function (a) {
|
|
41
|
+
return a.uid === current.uid;
|
|
42
|
+
});
|
|
43
|
+
var char = Object.assign({}, current);
|
|
44
|
+
|
|
45
|
+
if (current.character) {
|
|
46
|
+
char.name = current.alias || current.character.name;
|
|
47
|
+
char.resource = char.character.resource;
|
|
48
|
+
delete char.character;
|
|
49
|
+
char.type = 'character';
|
|
50
|
+
acc.push(char);
|
|
51
|
+
} else if (actor) {
|
|
52
|
+
var resource = actor.resource;
|
|
53
|
+
char.name = current.alias || current.name;
|
|
54
|
+
char.resource = resource;
|
|
55
|
+
char.type = actor.type;
|
|
56
|
+
acc.push(char);
|
|
57
|
+
} else if (!flex) {
|
|
58
|
+
acc.push(null);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return acc;
|
|
62
|
+
}, []);
|
|
63
|
+
var hasGameChars = gameChars.length && gameChars.some(function (c) {
|
|
64
|
+
return c;
|
|
65
|
+
});
|
|
40
66
|
var currentChars = characters.filter(function (c) {
|
|
41
67
|
return slots.find(function (s) {
|
|
42
68
|
return c.uid === s.uid;
|
|
@@ -44,6 +70,25 @@ var SlotList = function SlotList(_ref) {
|
|
|
44
70
|
});
|
|
45
71
|
|
|
46
72
|
var Slots = function Slots() {
|
|
73
|
+
if (hasGameChars) {
|
|
74
|
+
return gameChars.map(function (character, index) {
|
|
75
|
+
if (!character) {
|
|
76
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
77
|
+
key: "void_".concat(index),
|
|
78
|
+
className: "conversation--character__item void ".concat(index)
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return /*#__PURE__*/_react.default.createElement(_Slot.default, _extends({
|
|
83
|
+
key: character.uid + index
|
|
84
|
+
}, characterProps({
|
|
85
|
+
character: character,
|
|
86
|
+
active: character.talking,
|
|
87
|
+
slot: index
|
|
88
|
+
})));
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
47
92
|
if (flex) {
|
|
48
93
|
return currentChars.map(function (character, index) {
|
|
49
94
|
var active = currentMessage.position === index;
|
|
@@ -57,7 +102,7 @@ var SlotList = function SlotList(_ref) {
|
|
|
57
102
|
});
|
|
58
103
|
}
|
|
59
104
|
|
|
60
|
-
return slots.length > 0
|
|
105
|
+
return slots.length > 0 ? slots.map(function (el, index) {
|
|
61
106
|
var character = characters.find(function (char) {
|
|
62
107
|
return char.uid === el.uid;
|
|
63
108
|
});
|
|
@@ -84,7 +129,7 @@ var SlotList = function SlotList(_ref) {
|
|
|
84
129
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
85
130
|
className: "conversation--characters"
|
|
86
131
|
}, /*#__PURE__*/_react.default.createElement(_scene.default, {
|
|
87
|
-
characters: currentChars,
|
|
132
|
+
characters: hasGameChars ? gameChars : currentChars,
|
|
88
133
|
slots: slots,
|
|
89
134
|
flex: flex,
|
|
90
135
|
currentMessage: currentMessage,
|
|
@@ -92,18 +137,6 @@ var SlotList = function SlotList(_ref) {
|
|
|
92
137
|
}), children ? children : /*#__PURE__*/_react.default.createElement(Slots, null));
|
|
93
138
|
};
|
|
94
139
|
|
|
95
|
-
SlotList.propTypes = {
|
|
96
|
-
characters: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
97
|
-
name: _propTypes.default.string,
|
|
98
|
-
url: _propTypes.default.string
|
|
99
|
-
})),
|
|
100
|
-
currentMessage: _propTypes.default.shape({
|
|
101
|
-
emotion: _propTypes.default.string,
|
|
102
|
-
position: _propTypes.default.number
|
|
103
|
-
}),
|
|
104
|
-
flex: _propTypes.default.bool,
|
|
105
|
-
slots: _propTypes.default.arrayOf(_propTypes.default.shape({}))
|
|
106
|
-
};
|
|
107
140
|
SlotList.defaultProps = {
|
|
108
141
|
characters: [],
|
|
109
142
|
currentMessage: {},
|
|
@@ -18,15 +18,15 @@ var Panels = function Panels(_ref) {
|
|
|
18
18
|
flex = _ref.flex,
|
|
19
19
|
lodSettings = _ref.lodSettings;
|
|
20
20
|
return slots.map(function (slot, slotPosition) {
|
|
21
|
+
var currentCharacter = null;
|
|
21
22
|
var characterPos = characters.findIndex(function (c) {
|
|
22
|
-
return c.uid === slot.uid;
|
|
23
|
+
return c && c.uid === slot.uid;
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
if (characterPos >= 0) {
|
|
26
27
|
var currentPosition = !flex ? slotPosition : characterPos;
|
|
27
|
-
|
|
28
|
-
currentCharacter.
|
|
29
|
-
currentCharacter.slot = slotPosition;
|
|
28
|
+
currentCharacter = Object.assign({}, characters[characterPos]);
|
|
29
|
+
currentCharacter.slot = currentPosition;
|
|
30
30
|
return /*#__PURE__*/_react.default.createElement(_Panel.default, {
|
|
31
31
|
key: "".concat(currentCharacter.uid, "_").concat(slotPosition, "_").concat(characterPos),
|
|
32
32
|
character: currentCharacter,
|
|
@@ -193,6 +193,7 @@ var TextClickPuzzleComponent = function TextClickPuzzleComponent(_ref) {
|
|
|
193
193
|
setFeedbackData(function (prevState) {
|
|
194
194
|
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
195
195
|
show: true,
|
|
196
|
+
result: 'success',
|
|
196
197
|
text: specificFeedback.desc,
|
|
197
198
|
timeout: false
|
|
198
199
|
});
|