@gamelearn/arcade-components 0.25.31 → 0.25.34
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/conversational-pro-component/components/ConversationalProComponent.js +5 -4
- package/dist/components/decision-component/components/DecisionBody.js +5 -4
- package/dist/components/decision-component/components/DecisionComponent.js +10 -6
- package/dist/components/dialog-component/components/DialogComponent.js +356 -118
- package/dist/components/dialog-component/components/SpeechBubbleComponent.js +52 -0
- package/dist/components/dialog-component/mocks/mockForStory.js +36 -52
- package/dist/components/image-click-puzzle-component/components/ImageClickPuzzleComponent.js +16 -0
- package/dist/helpers/HtmlPro.js +34 -0
- package/dist/helpers/index.js +71 -8
- package/package.json +2 -2
package/dist/components/conversational-pro-component/components/ConversationalProComponent.js
CHANGED
|
@@ -290,19 +290,20 @@ var ConversationProViewer = function ConversationProViewer(_ref) {
|
|
|
290
290
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
291
291
|
className: "conversation--layer"
|
|
292
292
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
293
|
-
className: "conversation
|
|
293
|
+
className: "conversation",
|
|
294
294
|
style: backgroundImage ? {
|
|
295
295
|
backgroundImage: "url(\"".concat(backgroundImage, "\")")
|
|
296
|
-
} :
|
|
296
|
+
} : null
|
|
297
297
|
}, /*#__PURE__*/_react.default.createElement(_SlotList.default, listProps), /*#__PURE__*/_react.default.createElement("div", {
|
|
298
298
|
className: "conversation--body"
|
|
299
299
|
}, currentMessage ? /*#__PURE__*/_react.default.createElement(_Message.default, {
|
|
300
300
|
current: currentMessage,
|
|
301
301
|
translate: translate
|
|
302
302
|
}) : null, /*#__PURE__*/_react.default.createElement("div", {
|
|
303
|
-
className: "conversation--controls
|
|
303
|
+
className: "conversation--controls"
|
|
304
304
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
305
|
-
className: "gat--btn__round ".concat(currentLine > 0 && !lastLine.decision ? '' : '
|
|
305
|
+
className: "gat--btn__round ".concat(currentLine > 0 && !lastLine.decision ? '' : 'disabled'),
|
|
306
|
+
disabled: currentLine > 0 && !lastLine.decision ? '' : true,
|
|
306
307
|
type: "button",
|
|
307
308
|
onClick: handleClickBack
|
|
308
309
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
@@ -44,7 +44,8 @@ var DecisionBody = function DecisionBody(_ref) {
|
|
|
44
44
|
currentSelectedChoice = _ref.currentSelectedChoice,
|
|
45
45
|
children = _ref.children,
|
|
46
46
|
translate = _ref.translate,
|
|
47
|
-
hasRewards = _ref.hasRewards
|
|
47
|
+
hasRewards = _ref.hasRewards,
|
|
48
|
+
inScene = _ref.inScene;
|
|
48
49
|
|
|
49
50
|
var _useState = (0, _react.useState)(currentSelectedChoice),
|
|
50
51
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -73,7 +74,7 @@ var DecisionBody = function DecisionBody(_ref) {
|
|
|
73
74
|
var BasicDecision = function BasicDecision(_ref2) {
|
|
74
75
|
var defaultChildren = _ref2.children;
|
|
75
76
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
76
|
-
className: "popup popup__large popup__basicDecision
|
|
77
|
+
className: "popup popup__large popup__basicDecision ".concat(showingResults && currentSelectedChoice.feedback ? 'popup__feedback' : '')
|
|
77
78
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
78
79
|
className: "popup--info"
|
|
79
80
|
}, showingResults ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, defaultChildren, !currentSelectedChoice.feedback && hasRewards.length === 0 && /*#__PURE__*/_react.default.createElement("span", {
|
|
@@ -95,13 +96,13 @@ var DecisionBody = function DecisionBody(_ref) {
|
|
|
95
96
|
|
|
96
97
|
var ComplexDecision = function ComplexDecision() {
|
|
97
98
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
98
|
-
className: "conversation--body"
|
|
99
|
+
className: "conversation--body ".concat(inScene ? 'conversation--body--inScene' : '')
|
|
99
100
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
100
101
|
className: "conversation--message"
|
|
101
102
|
}, question !== '' && /*#__PURE__*/_react.default.createElement("span", {
|
|
102
103
|
className: "conversation--main__text"
|
|
103
104
|
}, question), /*#__PURE__*/_react.default.createElement(_Options.default, optionsProps)), /*#__PURE__*/_react.default.createElement("div", {
|
|
104
|
-
className: "conversation--controls
|
|
105
|
+
className: "conversation--controls conversation--controls--fixedbottom"
|
|
105
106
|
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
106
107
|
className: "gat--btn__round disabled",
|
|
107
108
|
type: "button"
|
|
@@ -54,7 +54,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
54
54
|
var DecisionComponent = function DecisionComponent(_ref) {
|
|
55
55
|
var emitEvent = _ref.emitEvent,
|
|
56
56
|
soundActions = _ref.soundActions,
|
|
57
|
-
|
|
57
|
+
inScene = _ref.inScene,
|
|
58
|
+
props = _objectWithoutProperties(_ref, ["emitEvent", "soundActions", "inScene"]);
|
|
58
59
|
|
|
59
60
|
var _props$inheritProps = props.inheritProps,
|
|
60
61
|
inheritProps = _props$inheritProps === void 0 ? {} : _props$inheritProps,
|
|
@@ -119,6 +120,7 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
119
120
|
currentSelectedChoice: resultChoice,
|
|
120
121
|
hasRewards: resultChoice.rewards || [],
|
|
121
122
|
failed: failed,
|
|
123
|
+
inScene: inScene,
|
|
122
124
|
changeOption: function changeOption(option) {
|
|
123
125
|
playSound('click-ui');
|
|
124
126
|
setResultChoice(option);
|
|
@@ -196,14 +198,16 @@ var DecisionComponent = function DecisionComponent(_ref) {
|
|
|
196
198
|
};
|
|
197
199
|
|
|
198
200
|
var CharactersWrapper = function CharactersWrapper(_ref4) {
|
|
199
|
-
var _inheritProps$backgro;
|
|
201
|
+
var _inheritProps$backgro, _inheritProps$backgro2;
|
|
200
202
|
|
|
201
203
|
var children = _ref4.children;
|
|
204
|
+
var style = {};
|
|
205
|
+
style = (_inheritProps$backgro = inheritProps.background) !== null && _inheritProps$backgro !== void 0 && _inheritProps$backgro.img ? {
|
|
206
|
+
backgroundImage: "url(\"".concat((_inheritProps$backgro2 = inheritProps.background.img) === null || _inheritProps$backgro2 === void 0 ? void 0 : _inheritProps$backgro2.url, "\")")
|
|
207
|
+
} : null;
|
|
202
208
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
203
|
-
className: "conversation
|
|
204
|
-
style:
|
|
205
|
-
backgroundImage: "url(\"".concat((_inheritProps$backgro = inheritProps.background.img) === null || _inheritProps$backgro === void 0 ? void 0 : _inheritProps$backgro.url, "\")")
|
|
206
|
-
} : {}
|
|
209
|
+
className: "conversation ".concat(inScene ? 'conversation--inScene' : ''),
|
|
210
|
+
style: style
|
|
207
211
|
}, /*#__PURE__*/_react.default.createElement(_SlotList.default, listProps, children), /*#__PURE__*/_react.default.createElement(_DecisionBody.default, bodyProps));
|
|
208
212
|
};
|
|
209
213
|
|
|
@@ -9,22 +9,28 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
|
-
var _drei = require("@react-three/drei");
|
|
13
|
-
|
|
14
12
|
var _fiber = require("@react-three/fiber");
|
|
15
13
|
|
|
16
14
|
var _three = require("three");
|
|
17
15
|
|
|
18
16
|
var _GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader");
|
|
19
17
|
|
|
18
|
+
var _SpeechBubbleComponent = _interopRequireDefault(require("./SpeechBubbleComponent"));
|
|
19
|
+
|
|
20
20
|
var _decisionComponent = _interopRequireDefault(require("../../decision-component"));
|
|
21
21
|
|
|
22
|
+
var _helpers = require("../../../helpers");
|
|
23
|
+
|
|
24
|
+
var _HtmlPro = _interopRequireDefault(require("../../../helpers/HtmlPro"));
|
|
25
|
+
|
|
22
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
27
|
|
|
24
28
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
25
29
|
|
|
26
30
|
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; }
|
|
27
31
|
|
|
32
|
+
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); }
|
|
33
|
+
|
|
28
34
|
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; }
|
|
29
35
|
|
|
30
36
|
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; }
|
|
@@ -43,25 +49,38 @@ function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "und
|
|
|
43
49
|
|
|
44
50
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
45
51
|
|
|
52
|
+
var crossFadeDuration = 0.5;
|
|
53
|
+
|
|
46
54
|
var DialogComponent = function DialogComponent(_ref) {
|
|
47
55
|
var emitEvent = _ref.emitEvent,
|
|
48
56
|
lines = _ref.lines,
|
|
49
57
|
actors = _ref.actors,
|
|
50
58
|
soundActions = _ref.soundActions,
|
|
51
|
-
|
|
59
|
+
zoomInActor = _ref.zoomInActor,
|
|
60
|
+
autoPlay = _ref.autoPlay;
|
|
52
61
|
|
|
53
62
|
var _useState = (0, _react.useState)(0),
|
|
54
63
|
_useState2 = _slicedToArray(_useState, 2),
|
|
55
64
|
line = _useState2[0],
|
|
56
65
|
changeLine = _useState2[1];
|
|
57
66
|
|
|
58
|
-
var _useState3 = (0, _react.useState)(
|
|
67
|
+
var _useState3 = (0, _react.useState)(true),
|
|
68
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
69
|
+
automatic = _useState4[0],
|
|
70
|
+
setAutomatic = _useState4[1];
|
|
71
|
+
|
|
72
|
+
var _useState5 = (0, _react.useState)({
|
|
59
73
|
text: '',
|
|
60
|
-
name: ''
|
|
74
|
+
name: '',
|
|
75
|
+
left: false,
|
|
76
|
+
inScene: false,
|
|
77
|
+
thinkful: false,
|
|
78
|
+
voiceOver: false,
|
|
79
|
+
avatar: ''
|
|
61
80
|
}),
|
|
62
|
-
|
|
63
|
-
currentMessage =
|
|
64
|
-
setCurrentMessage =
|
|
81
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
82
|
+
currentMessage = _useState6[0],
|
|
83
|
+
setCurrentMessage = _useState6[1];
|
|
65
84
|
|
|
66
85
|
var _useThree = (0, _fiber.useThree)(function (state) {
|
|
67
86
|
return [state.camera, state.scene];
|
|
@@ -73,172 +92,391 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
73
92
|
var loader = (0, _react.useMemo)(function () {
|
|
74
93
|
return new _GLTFLoader.GLTFLoader();
|
|
75
94
|
}, []);
|
|
76
|
-
var messagePosition = (0, _react.useRef)(new _three.Vector3());
|
|
77
95
|
var defaultCamera = (0, _react.useRef)(camera.clone());
|
|
96
|
+
var messagePosition = (0, _react.useRef)({
|
|
97
|
+
pos: [0, 0, 0],
|
|
98
|
+
child: null
|
|
99
|
+
});
|
|
78
100
|
var animationStart = (0, _react.useRef)(false);
|
|
101
|
+
var bubbleRef = (0, _react.useRef)();
|
|
102
|
+
var groupRef = (0, _react.useRef)();
|
|
103
|
+
var animationTarget = (0, _react.useRef)(new _three.Vector3());
|
|
79
104
|
var currentLine = lines[line];
|
|
80
105
|
var lastLine = lines[line - 1];
|
|
81
|
-
var
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
106
|
+
var lastSet = (0, _react.useRef)(false);
|
|
107
|
+
var translate = (0, _react.useCallback)(function (id) {
|
|
108
|
+
return emitEvent({
|
|
109
|
+
type: 'translate',
|
|
110
|
+
payload: id
|
|
86
111
|
});
|
|
87
|
-
|
|
88
|
-
|
|
112
|
+
}, [emitEvent]);
|
|
113
|
+
var getCurrentVisible = (0, _react.useCallback)(function (uid) {
|
|
114
|
+
var object;
|
|
115
|
+
scene.traverseVisible(function (node) {
|
|
116
|
+
if (node.uid === uid && !object) {
|
|
117
|
+
object = node;
|
|
118
|
+
}
|
|
89
119
|
});
|
|
120
|
+
return object;
|
|
121
|
+
}, [scene]);
|
|
122
|
+
var getAvatarURL = (0, _react.useCallback)(function (slot) {
|
|
123
|
+
var _slot$character, _slot$character$resou;
|
|
124
|
+
|
|
125
|
+
var object = actors.find(function (element) {
|
|
126
|
+
if (element.uid === slot.uid) {
|
|
127
|
+
return element;
|
|
128
|
+
}
|
|
90
129
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
130
|
+
return '';
|
|
131
|
+
});
|
|
132
|
+
return ((_slot$character = slot.character) === null || _slot$character === void 0 ? void 0 : (_slot$character$resou = _slot$character.resource) === null || _slot$character$resou === void 0 ? void 0 : _slot$character$resou.url) || (object === null || object === void 0 ? void 0 : object.completeUrl) || '';
|
|
133
|
+
}, [actors]);
|
|
134
|
+
var loadEmotion = (0, _react.useCallback)(function (slot, element) {
|
|
135
|
+
var _slot$character2;
|
|
136
|
+
|
|
137
|
+
var onLoadAnim = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
|
|
138
|
+
var animation = (_slot$character2 = slot.character) === null || _slot$character2 === void 0 ? void 0 : _slot$character2.resource.animations[slot.emotion];
|
|
139
|
+
|
|
140
|
+
if (animation) {
|
|
141
|
+
var mixer = element.userData.mixer;
|
|
142
|
+
loader.load(animation === null || animation === void 0 ? void 0 : animation.url, function (anim) {
|
|
143
|
+
var emotionClip = anim.animations[0];
|
|
144
|
+
var defaultClip = element.userData.defaultAnim;
|
|
145
|
+
var emotionAction = mixer.clipAction(emotionClip, element);
|
|
146
|
+
var defaultAction = mixer.clipAction(defaultClip, element);
|
|
147
|
+
|
|
148
|
+
if (element.userData.currentEmotion) {
|
|
149
|
+
element.userData.lastEmotion = element.userData.currentEmotion;
|
|
100
150
|
}
|
|
151
|
+
|
|
152
|
+
element.userData.currentEmotion = emotionAction;
|
|
153
|
+
onLoadAnim(mixer, emotionAction, defaultAction);
|
|
101
154
|
});
|
|
102
155
|
}
|
|
156
|
+
}, [loader]); // Reset currentEmotion to defaultAnim
|
|
157
|
+
|
|
158
|
+
var executeAnimation = function executeAnimation(element) {
|
|
159
|
+
var mixer = element.userData.mixer;
|
|
160
|
+
var startAction = mixer.clipAction(element.userData.currentEmotion.getClip(), element);
|
|
161
|
+
var defaultAction = mixer.clipAction(element.userData.defaultAnim, element);
|
|
103
162
|
|
|
104
|
-
|
|
105
|
-
|
|
163
|
+
if (element.userData.currentEmotion !== defaultAction) {
|
|
164
|
+
mixer.stopAllAction();
|
|
165
|
+
(0, _helpers.executeCrossFade)(startAction, defaultAction, crossFadeDuration);
|
|
106
166
|
|
|
107
|
-
if (element) {
|
|
108
|
-
|
|
109
|
-
mixer.stopAllAction();
|
|
110
|
-
var action = mixer.clipAction(element.userData.defaultAnim, element);
|
|
111
|
-
action.play();
|
|
167
|
+
if (element.userData.currentEmotion) {
|
|
168
|
+
element.userData.lastEmotion = element.userData.currentEmotion;
|
|
112
169
|
}
|
|
113
|
-
});
|
|
114
|
-
}, [lastLine === null || lastLine === void 0 ? void 0 : lastLine.slots, currentLine, scene]);
|
|
115
|
-
var nextLine = (0, _react.useCallback)(function () {
|
|
116
|
-
resetAnims(line >= lines.length - 1);
|
|
117
170
|
|
|
171
|
+
element.userData.currentEmotion = defaultAction;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
var resetAnims = (0, _react.useCallback)(function () {
|
|
176
|
+
var end = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
177
|
+
|
|
178
|
+
if (end) {
|
|
179
|
+
scene.traverseVisible(function (node) {
|
|
180
|
+
if (node.userData.mixer && node.userData.currentEmotion) {
|
|
181
|
+
executeAnimation(node);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
} else if (lastLine !== null && lastLine !== void 0 && lastLine.slots) {
|
|
185
|
+
var slottedCharacters = lastLine.slots.filter(function (slot) {
|
|
186
|
+
return slot.uid;
|
|
187
|
+
});
|
|
188
|
+
slottedCharacters.forEach(function (slot) {
|
|
189
|
+
var element = getCurrentVisible(slot.uid);
|
|
190
|
+
|
|
191
|
+
if (element && element.userData.currentEmotion) {
|
|
192
|
+
executeAnimation(element);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}, [getCurrentVisible, lastLine === null || lastLine === void 0 ? void 0 : lastLine.slots, scene]);
|
|
197
|
+
var backLine = (0, _react.useCallback)(function () {
|
|
198
|
+
if (lastLine && !lastLine.decision) {
|
|
199
|
+
changeLine(line - 1);
|
|
200
|
+
}
|
|
201
|
+
}, [lastLine, line]);
|
|
202
|
+
var nextLine = (0, _react.useCallback)(function () {
|
|
118
203
|
if (line < lines.length - 1) {
|
|
119
204
|
changeLine(line + 1);
|
|
120
205
|
} else {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
setCurrentMessage({
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
206
|
+
resetAnims(true);
|
|
207
|
+
lastSet.current = true;
|
|
208
|
+
setCurrentMessage({});
|
|
209
|
+
messagePosition.current.pos = defaultCamera.current.position.clone().add(new _three.Vector3(0, 5, -35)).toArray();
|
|
210
|
+
|
|
211
|
+
if (zoomInActor) {
|
|
212
|
+
animationStart.current = true;
|
|
213
|
+
} else {
|
|
127
214
|
camera.copy(defaultCamera.current);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
setTimeout(function () {
|
|
128
218
|
emitEvent({
|
|
129
219
|
type: 'success'
|
|
130
220
|
});
|
|
131
|
-
},
|
|
221
|
+
}, currentLine.decision ? 0 : 700);
|
|
132
222
|
}
|
|
133
|
-
}, [camera, emitEvent, line, lines.length, resetAnims]);
|
|
134
|
-
|
|
135
|
-
if (e.keyCode === 32) {
|
|
136
|
-
nextLine();
|
|
137
|
-
}
|
|
138
|
-
}, [nextLine]);
|
|
223
|
+
}, [camera, currentLine.decision, emitEvent, line, lines.length, resetAnims, zoomInActor]); // Position bubble over talking character/and switch emotions
|
|
224
|
+
|
|
139
225
|
(0, _react.useEffect)(function () {
|
|
140
|
-
setCurrentMessage({
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
226
|
+
setCurrentMessage({});
|
|
227
|
+
|
|
228
|
+
if (currentLine.decision) {
|
|
229
|
+
messagePosition.current.child = null;
|
|
230
|
+
messagePosition.current.parent = null;
|
|
231
|
+
return;
|
|
232
|
+
} else if (currentLine.voiceOver) {
|
|
233
|
+
messagePosition.current.child = null;
|
|
234
|
+
messagePosition.current.parent = null;
|
|
235
|
+
setCurrentMessage({
|
|
236
|
+
text: currentLine.text,
|
|
237
|
+
name: currentLine.alias || "[ ".concat(translate('storylines.misc.voiceOver'), " ]"),
|
|
238
|
+
left: false,
|
|
239
|
+
inScene: false,
|
|
240
|
+
voiceOver: true,
|
|
241
|
+
thinkful: false,
|
|
242
|
+
avatar: ''
|
|
243
|
+
});
|
|
244
|
+
} else if (!lastSet.current) {
|
|
245
|
+
var talkingCharacter = currentLine.slots.find(function (slot) {
|
|
246
|
+
return slot.talking;
|
|
247
|
+
});
|
|
248
|
+
var slottedCharacters = currentLine.slots.filter(function (slot) {
|
|
249
|
+
return slot.uid && !slot.talking;
|
|
250
|
+
});
|
|
251
|
+
resetAnims(false); // Check not talking elements emotion
|
|
252
|
+
|
|
253
|
+
slottedCharacters.forEach(function (slot) {
|
|
254
|
+
var element = getCurrentVisible(slot.uid);
|
|
255
|
+
|
|
256
|
+
if (element) {
|
|
257
|
+
loadEmotion(slot, element, function (mixer, action, defaultAction) {
|
|
258
|
+
var startAction = element.userData.lastEmotion ? element.userData.lastEmotion : defaultAction;
|
|
259
|
+
|
|
260
|
+
if (startAction !== action) {
|
|
261
|
+
mixer.stopAllAction();
|
|
262
|
+
(0, _helpers.executeCrossFade)(startAction, action, crossFadeDuration);
|
|
171
263
|
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}); // Talking element logic
|
|
172
267
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
268
|
+
if (talkingCharacter) {
|
|
269
|
+
var element = getCurrentVisible(talkingCharacter.uid);
|
|
270
|
+
var object = actors.find(function (a) {
|
|
271
|
+
return a.uid === talkingCharacter.uid;
|
|
178
272
|
});
|
|
273
|
+
|
|
274
|
+
if (element && !lastSet.current) {
|
|
275
|
+
loadEmotion(talkingCharacter, element, function (mixer, action, defaultAction) {
|
|
276
|
+
var startAction = element.userData.lastEmotion ? element.userData.lastEmotion : defaultAction;
|
|
277
|
+
|
|
278
|
+
if (startAction !== action) {
|
|
279
|
+
mixer.stopAllAction();
|
|
280
|
+
(0, _helpers.executeCrossFade)(startAction, action, crossFadeDuration);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (talkingCharacter.uid === element.uid) {
|
|
284
|
+
var head = element.getObjectByName('Head_M');
|
|
285
|
+
var box = new _three.Box3().setFromObject(element);
|
|
286
|
+
var bodySize = box.getSize(new _three.Vector3());
|
|
287
|
+
var headPos = head.getWorldPosition(new _three.Vector3());
|
|
288
|
+
headPos.add(new _three.Vector3(bodySize.x - 10, 5, 0));
|
|
289
|
+
messagePosition.current = {
|
|
290
|
+
pos: headPos.toArray(),
|
|
291
|
+
child: head,
|
|
292
|
+
parent: element
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
if (zoomInActor) {
|
|
296
|
+
animationStart.current = true;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
setTimeout(function () {
|
|
300
|
+
var _talkingCharacter$cha;
|
|
301
|
+
|
|
302
|
+
setCurrentMessage({
|
|
303
|
+
text: talkingCharacter.text,
|
|
304
|
+
name: talkingCharacter.alias || ((_talkingCharacter$cha = talkingCharacter.character) === null || _talkingCharacter$cha === void 0 ? void 0 : _talkingCharacter$cha.name),
|
|
305
|
+
left: true,
|
|
306
|
+
inScene: true,
|
|
307
|
+
thinkful: talkingCharacter.emotion === 'thinkful',
|
|
308
|
+
avatar: ''
|
|
309
|
+
});
|
|
310
|
+
}, zoomInActor ? 700 : 0);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
} else {
|
|
314
|
+
var _talkingCharacter$cha2;
|
|
315
|
+
|
|
316
|
+
messagePosition.current.child = null;
|
|
317
|
+
messagePosition.current.parent = null;
|
|
318
|
+
if (zoomInActor) animationStart.current = true;
|
|
319
|
+
setCurrentMessage({
|
|
320
|
+
text: talkingCharacter.text,
|
|
321
|
+
name: talkingCharacter.alias || ((_talkingCharacter$cha2 = talkingCharacter.character) === null || _talkingCharacter$cha2 === void 0 ? void 0 : _talkingCharacter$cha2.name) || object.name,
|
|
322
|
+
left: false,
|
|
323
|
+
inScene: false,
|
|
324
|
+
thinkful: talkingCharacter.emotion === 'thinkful',
|
|
325
|
+
avatar: getAvatarURL(talkingCharacter)
|
|
326
|
+
});
|
|
327
|
+
}
|
|
179
328
|
}
|
|
180
|
-
}
|
|
181
|
-
}, [camera, currentLine,
|
|
329
|
+
}
|
|
330
|
+
}, [actors, camera, currentLine, zoomInActor, getCurrentVisible, translate, getAvatarURL, loadEmotion, resetAnims]); // Autoplay logic
|
|
331
|
+
|
|
182
332
|
(0, _react.useEffect)(function () {
|
|
183
|
-
|
|
333
|
+
var timeout;
|
|
334
|
+
|
|
335
|
+
if (autoPlay) {
|
|
336
|
+
if (line >= lines.length - 1 && automatic) {
|
|
337
|
+
setAutomatic(false);
|
|
338
|
+
} else if (automatic && currentMessage.text && !currentLine.decision) {
|
|
339
|
+
timeout = setTimeout(function () {
|
|
340
|
+
nextLine();
|
|
341
|
+
}, 70 * currentMessage.text.length);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
184
345
|
return function () {
|
|
185
|
-
|
|
346
|
+
if (timeout) clearTimeout(timeout);
|
|
186
347
|
};
|
|
187
|
-
}, [
|
|
348
|
+
}, [currentMessage, nextLine, autoPlay, lines.length, automatic, line, currentLine.decision]); //Positioning logic
|
|
349
|
+
|
|
350
|
+
(0, _react.useEffect)(function () {
|
|
351
|
+
if (bubbleRef.current && currentLine.slots) {
|
|
352
|
+
var talkingCharacter = currentLine.slots.find(function (slot) {
|
|
353
|
+
return slot.talking;
|
|
354
|
+
});
|
|
355
|
+
var bubbleRect = bubbleRef.current.getBoundingClientRect();
|
|
356
|
+
var x = bubbleRect.x + bubbleRect.width;
|
|
357
|
+
var y = bubbleRect.y - bubbleRect.height;
|
|
358
|
+
|
|
359
|
+
if ((x < 0 || x > window.innerWidth || y < 0 || y > window.innerHeight) && currentMessage.inScene) {
|
|
360
|
+
var child = messagePosition.current.child;
|
|
361
|
+
var headPos = child.getWorldPosition(new _three.Vector3());
|
|
362
|
+
|
|
363
|
+
if (child.isBone) {
|
|
364
|
+
groupRef.current.position.copy(headPos);
|
|
365
|
+
var completeOutside = x > window.innerWidth + bubbleRect.width || y < -bubbleRect.height || y > window.innerHeight || x < -bubbleRect.width;
|
|
366
|
+
var distanceX = bubbleRect.width + bubbleRect.width / 4;
|
|
367
|
+
bubbleRef.current.parentNode.style.transform = "translate3d(-".concat(distanceX, "px, -").concat(bubbleRect.height / 2, "px, 0px)");
|
|
368
|
+
groupRef.current.updateMatrixWorld();
|
|
369
|
+
|
|
370
|
+
if (completeOutside) {
|
|
371
|
+
bubbleRef.current.parentNode.style.transform = '';
|
|
372
|
+
messagePosition.current.child = null;
|
|
373
|
+
messagePosition.current.parent = null;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
setCurrentMessage(function (old) {
|
|
377
|
+
return _objectSpread(_objectSpread({}, old), {}, {
|
|
378
|
+
left: false,
|
|
379
|
+
inScene: !completeOutside,
|
|
380
|
+
avatar: getAvatarURL(talkingCharacter)
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
} else {
|
|
385
|
+
bubbleRef.current.parentNode.style.transform = '';
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}, [currentMessage.text, camera, currentLine.slots, getAvatarURL, currentMessage.inScene]); // Animate Camera
|
|
389
|
+
|
|
188
390
|
(0, _fiber.useFrame)(function (_ref2, delta) {
|
|
189
391
|
var camera = _ref2.camera;
|
|
190
392
|
|
|
191
393
|
if (animationStart.current) {
|
|
192
|
-
var
|
|
193
|
-
target
|
|
194
|
-
|
|
394
|
+
var toPosition = messagePosition.current.child ? messagePosition.current.pos : defaultCamera.current.position.toArray();
|
|
395
|
+
var target = animationTarget.current.fromArray(toPosition);
|
|
396
|
+
|
|
397
|
+
if (messagePosition.current.parent) {
|
|
398
|
+
var size = messagePosition.current.parent.bbox.getSize(new _three.Vector3());
|
|
399
|
+
var offset = new _three.Vector3();
|
|
400
|
+
offset.add((0, _helpers.vectorTranslateZ)(size.z + 10, camera));
|
|
401
|
+
offset.add((0, _helpers.vectorTranslateY)(-size.y / 3, camera));
|
|
402
|
+
target.add(offset);
|
|
403
|
+
}
|
|
195
404
|
|
|
196
405
|
if (target.distanceTo(camera.position) < 1) {
|
|
197
406
|
animationStart.current = false;
|
|
407
|
+
|
|
408
|
+
if (lastSet.current || !messagePosition.current.child) {
|
|
409
|
+
camera.copy(defaultCamera.current);
|
|
410
|
+
}
|
|
411
|
+
} else {
|
|
412
|
+
camera.position.lerp(target, delta * 2.5);
|
|
198
413
|
}
|
|
199
414
|
}
|
|
200
415
|
});
|
|
201
416
|
|
|
202
417
|
var decisionPayload = _objectSpread(_objectSpread({}, currentLine.payload), {}, {
|
|
418
|
+
inheritProps: {
|
|
419
|
+
slots: [],
|
|
420
|
+
disableBackground: true
|
|
421
|
+
},
|
|
203
422
|
onFinish: nextLine,
|
|
204
423
|
emitEvent: emitEvent,
|
|
205
424
|
soundActions: soundActions
|
|
206
425
|
});
|
|
207
426
|
|
|
208
|
-
|
|
427
|
+
var cleanStyle = {
|
|
428
|
+
width: '100vw',
|
|
429
|
+
height: '100vh',
|
|
430
|
+
position: 'static'
|
|
431
|
+
};
|
|
432
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, currentLine.decision ? /*#__PURE__*/_react.default.createElement(_HtmlPro.default, {
|
|
433
|
+
zIndexRange: [3, 0],
|
|
434
|
+
style: cleanStyle,
|
|
435
|
+
calculatePosition: function calculatePosition() {
|
|
436
|
+
return [0, 0];
|
|
437
|
+
}
|
|
438
|
+
}, /*#__PURE__*/_react.default.createElement(_decisionComponent.default, _extends({
|
|
439
|
+
inScene: true
|
|
440
|
+
}, decisionPayload))) : null, currentMessage.text ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("group", {
|
|
441
|
+
ref: groupRef,
|
|
442
|
+
position: messagePosition.current.pos
|
|
443
|
+
}, /*#__PURE__*/_react.default.createElement(_HtmlPro.default, {
|
|
444
|
+
zIndexRange: [3, 0],
|
|
445
|
+
calculatePosition: currentMessage.inScene ? undefined : function () {
|
|
446
|
+
return [0, 0];
|
|
447
|
+
},
|
|
448
|
+
style: currentMessage.inScene ? {
|
|
449
|
+
position: 'static'
|
|
450
|
+
} : cleanStyle
|
|
451
|
+
}, /*#__PURE__*/_react.default.createElement(_SpeechBubbleComponent.default, {
|
|
452
|
+
ref: bubbleRef,
|
|
453
|
+
message: currentMessage
|
|
454
|
+
}))), /*#__PURE__*/_react.default.createElement(_HtmlPro.default, {
|
|
209
455
|
style: {
|
|
210
456
|
width: '100vw',
|
|
211
457
|
height: '100vh'
|
|
212
458
|
},
|
|
459
|
+
zIndexRange: [3, 0],
|
|
460
|
+
onOcclude: function onOcclude() {},
|
|
213
461
|
calculatePosition: function calculatePosition() {
|
|
214
462
|
return [0, 0];
|
|
215
463
|
}
|
|
216
|
-
}, /*#__PURE__*/_react.default.createElement(_decisionComponent.default, decisionPayload)) : null, currentMessage.text ? /*#__PURE__*/_react.default.createElement(_drei.Html, {
|
|
217
|
-
position: messagePosition.current,
|
|
218
|
-
zIndexRange: [3, 0],
|
|
219
|
-
sprite: true
|
|
220
464
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
padding: '5px',
|
|
228
|
-
width: '240px',
|
|
229
|
-
maxWidth: '400px'
|
|
230
|
-
}
|
|
465
|
+
className: "dialog-component-controls"
|
|
466
|
+
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
467
|
+
disabled: line <= 0 || (lastLine === null || lastLine === void 0 ? void 0 : lastLine.decision),
|
|
468
|
+
type: "button",
|
|
469
|
+
onClick: backLine,
|
|
470
|
+
className: "gat--btn__round ".concat(line <= 0 || lastLine !== null && lastLine !== void 0 && lastLine.decision ? 'disabled' : '')
|
|
231
471
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
}, currentMessage.text))) : null);
|
|
472
|
+
className: "icon-back"
|
|
473
|
+
})), /*#__PURE__*/_react.default.createElement("button", {
|
|
474
|
+
className: "gat--btn__round",
|
|
475
|
+
type: "button",
|
|
476
|
+
onClick: nextLine
|
|
477
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
478
|
+
className: "icon-next"
|
|
479
|
+
}))))) : null);
|
|
242
480
|
};
|
|
243
481
|
|
|
244
482
|
var _default = DialogComponent;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
var SpeechBubbleComponent = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
13
|
+
var message = _ref.message;
|
|
14
|
+
|
|
15
|
+
var getAvatar = function getAvatar() {
|
|
16
|
+
var avatarUrl = message.avatar;
|
|
17
|
+
var idx = avatarUrl.lastIndexOf('/');
|
|
18
|
+
|
|
19
|
+
if (avatarUrl.includes('object')) {
|
|
20
|
+
return avatarUrl.slice(0, idx).concat('/mini-thumbnail.png');
|
|
21
|
+
} else if (avatarUrl.includes('character')) {
|
|
22
|
+
return avatarUrl.slice(0, idx).concat('/mini-face.png');
|
|
23
|
+
} else {
|
|
24
|
+
return avatarUrl;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
29
|
+
ref: ref,
|
|
30
|
+
className: "\n speech-bubble\n ".concat(message.left && message.inScene ? 'speech-bubble--arrow-left' : '', "\n ").concat(!message.left && message.inScene ? 'speech-bubble--arrow-right' : '', "\n ").concat(message.thinkful || message.voiceOver ? 'speech-bubble--italic' : '', "\n ")
|
|
31
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
32
|
+
className: "speech-bubble__content"
|
|
33
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
34
|
+
className: "speech-bubble__header"
|
|
35
|
+
}, message.thinkful ? /*#__PURE__*/_react.default.createElement("div", {
|
|
36
|
+
className: "icon-bubble-thinkful-black"
|
|
37
|
+
}) : null, message.voiceOver ? /*#__PURE__*/_react.default.createElement("div", {
|
|
38
|
+
className: "icon-narrator"
|
|
39
|
+
}) : null, !message.inScene && message.avatar ? /*#__PURE__*/_react.default.createElement("div", {
|
|
40
|
+
className: "speech-bubble__avatar"
|
|
41
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
42
|
+
src: getAvatar(),
|
|
43
|
+
alt: message.name
|
|
44
|
+
})) : null, /*#__PURE__*/_react.default.createElement("div", {
|
|
45
|
+
className: "speech-bubble__title"
|
|
46
|
+
}, message.name)), message.text ? /*#__PURE__*/_react.default.createElement("div", {
|
|
47
|
+
className: "speech-bubble__text"
|
|
48
|
+
}, message.text) : null)));
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
var _default = SpeechBubbleComponent;
|
|
52
|
+
exports.default = _default;
|
|
@@ -28,12 +28,13 @@ var mockProps = {
|
|
|
28
28
|
emitEvent: _mocker.emitEvent,
|
|
29
29
|
soundActions: _mocker.soundActions,
|
|
30
30
|
setShowPoints: _mocker.setShowPoints,
|
|
31
|
+
autoPlay: false,
|
|
31
32
|
lines: [{
|
|
32
33
|
flex: true,
|
|
33
34
|
slots: [{
|
|
34
35
|
emotion: '',
|
|
35
36
|
text: '',
|
|
36
|
-
uid:
|
|
37
|
+
uid: null,
|
|
37
38
|
talking: false,
|
|
38
39
|
alias: 'paco',
|
|
39
40
|
text_labelId: 'text_0_0_nlrZh8Np',
|
|
@@ -61,10 +62,15 @@ var mockProps = {
|
|
|
61
62
|
alias_labelId: 'alias_0_3_nlrZjLWB'
|
|
62
63
|
}, {
|
|
63
64
|
emotion: 'neutral',
|
|
64
|
-
text: '
|
|
65
|
-
uid: '
|
|
65
|
+
text: 'En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho tiempo que vivía un hidalgo de los de lanza en astillero, adarga antigua, rocín flaco. En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho tiempo que vivía un hidalgo de los de lanza en astillero, adarga an',
|
|
66
|
+
uid: 'snHJhg',
|
|
66
67
|
talking: true,
|
|
67
|
-
|
|
68
|
+
character: {
|
|
69
|
+
resource: {
|
|
70
|
+
animations: animations
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
alias: 'Manolo',
|
|
68
74
|
text_labelId: 'text_0_4_nlrZjUV9',
|
|
69
75
|
alias_labelId: 'alias_0_4_nlrZj81d'
|
|
70
76
|
}],
|
|
@@ -77,7 +83,7 @@ var mockProps = {
|
|
|
77
83
|
slots: [{
|
|
78
84
|
emotion: '',
|
|
79
85
|
text: '',
|
|
80
|
-
uid:
|
|
86
|
+
uid: null,
|
|
81
87
|
talking: false,
|
|
82
88
|
alias: 'paco',
|
|
83
89
|
text_labelId: 'text_0_0_nlrZh8Np',
|
|
@@ -106,9 +112,14 @@ var mockProps = {
|
|
|
106
112
|
}, {
|
|
107
113
|
emotion: 'neutral',
|
|
108
114
|
text: 'Hola!',
|
|
109
|
-
|
|
115
|
+
character: {
|
|
116
|
+
resource: {
|
|
117
|
+
animations: animations
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
uid: 'jLKRKJ',
|
|
110
121
|
talking: true,
|
|
111
|
-
alias: '
|
|
122
|
+
alias: 'Manolo',
|
|
112
123
|
text_labelId: 'text_0_4_nlrZjUV9',
|
|
113
124
|
alias_labelId: 'alias_0_4_nlrZj81d'
|
|
114
125
|
}],
|
|
@@ -121,7 +132,7 @@ var mockProps = {
|
|
|
121
132
|
slots: [{
|
|
122
133
|
emotion: '',
|
|
123
134
|
text: '',
|
|
124
|
-
uid:
|
|
135
|
+
uid: null,
|
|
125
136
|
talking: false,
|
|
126
137
|
alias: 'paco',
|
|
127
138
|
text_labelId: 'text_0_0_nlrZh8Np',
|
|
@@ -150,9 +161,14 @@ var mockProps = {
|
|
|
150
161
|
}, {
|
|
151
162
|
emotion: 'neutral',
|
|
152
163
|
text: 'Hola!',
|
|
153
|
-
uid: '
|
|
164
|
+
uid: 'snHJhg',
|
|
165
|
+
character: {
|
|
166
|
+
resource: {
|
|
167
|
+
animations: animations
|
|
168
|
+
}
|
|
169
|
+
},
|
|
154
170
|
talking: true,
|
|
155
|
-
alias: '
|
|
171
|
+
alias: 'Manolo',
|
|
156
172
|
text_labelId: 'text_0_4_nlrZjUV9',
|
|
157
173
|
alias_labelId: 'alias_0_4_nlrZj81d'
|
|
158
174
|
}],
|
|
@@ -203,7 +219,7 @@ var mockProps = {
|
|
|
203
219
|
slots: [{
|
|
204
220
|
emotion: 'angry',
|
|
205
221
|
text: '',
|
|
206
|
-
uid:
|
|
222
|
+
uid: null,
|
|
207
223
|
talking: false,
|
|
208
224
|
alias: 'paco',
|
|
209
225
|
text_labelId: 'text_0_0_nlrZh8Np',
|
|
@@ -232,9 +248,14 @@ var mockProps = {
|
|
|
232
248
|
}, {
|
|
233
249
|
emotion: 'neutral',
|
|
234
250
|
text: 'Hola!',
|
|
235
|
-
uid: '
|
|
251
|
+
uid: 'snHJhg',
|
|
236
252
|
talking: true,
|
|
237
|
-
|
|
253
|
+
character: {
|
|
254
|
+
resource: {
|
|
255
|
+
animations: animations
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
alias: 'Manolo',
|
|
238
259
|
text_labelId: 'text_0_4_nlrZjUV9',
|
|
239
260
|
alias_labelId: 'alias_0_4_nlrZj81d'
|
|
240
261
|
}],
|
|
@@ -250,45 +271,8 @@ var mockProps = {
|
|
|
250
271
|
url: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/58dccfba26561500117caf53/image/605369a5901f3e00123b81ca/b27bb40dcb1189d14012131a35b48a36.jpeg'
|
|
251
272
|
}
|
|
252
273
|
},
|
|
253
|
-
characters: [
|
|
254
|
-
|
|
255
|
-
resourceId: '5f68d7b6a373890011a78a11',
|
|
256
|
-
resource: {
|
|
257
|
-
url: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/5981fca94d82290bcbe957fe/object/5eff09c2085be00011aae087/pr0238_yacht_001.glb'
|
|
258
|
-
},
|
|
259
|
-
type: 'object',
|
|
260
|
-
uid: 'DbKslR'
|
|
261
|
-
}, {
|
|
262
|
-
name: 'Male senior dark-skinned 01',
|
|
263
|
-
resourceId: '5f5214cec39e26001123797f',
|
|
264
|
-
resource: {
|
|
265
|
-
url: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/5981fca94d82290bcbe957fe/character/5f5214cec39e26001123797f/ch0112_philip_001.glb',
|
|
266
|
-
animations: animations
|
|
267
|
-
},
|
|
268
|
-
type: 'character',
|
|
269
|
-
uid: 'kjTHqi'
|
|
270
|
-
}, {
|
|
271
|
-
name: 'Female senior light-skinned 01',
|
|
272
|
-
resourceId: '5f5214cec39e26001123797f',
|
|
273
|
-
resource: {
|
|
274
|
-
url: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/5981fca94d82290bcbe957fe/character/5f60759328beb100113b694c/ch0116_bima_001_rig_v01_llaveronuevo.glb',
|
|
275
|
-
animations: {
|
|
276
|
-
neutral: {
|
|
277
|
-
resource: {}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
type: 'character',
|
|
282
|
-
uid: 'kjTHqt'
|
|
283
|
-
}, {
|
|
284
|
-
name: 'Taxi',
|
|
285
|
-
resourceId: '5f5214cec39e26001123797f',
|
|
286
|
-
resource: {
|
|
287
|
-
url: 'https://min.int.gamelearn.io/cooked.gl-lms-storage/clients/5981fca94d82290bcbe957fe/object/5e53b649ef1f60000fb9cc1c/draco_pr0065_car_004.glb'
|
|
288
|
-
},
|
|
289
|
-
type: 'object',
|
|
290
|
-
uid: 'kjTHqx'
|
|
291
|
-
}]
|
|
274
|
+
characters: [],
|
|
275
|
+
actors: []
|
|
292
276
|
};
|
|
293
277
|
exports.mockProps = mockProps;
|
|
294
278
|
var mockScene = {
|
package/dist/components/image-click-puzzle-component/components/ImageClickPuzzleComponent.js
CHANGED
|
@@ -14,7 +14,23 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
14
14
|
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); }
|
|
15
15
|
|
|
16
16
|
var ImageClickPuzzleComponent = function ImageClickPuzzleComponent(props) {
|
|
17
|
+
var finish = function finish(rw, success) {
|
|
18
|
+
if (success) {
|
|
19
|
+
props.emitEvent({
|
|
20
|
+
type: 'addPoints',
|
|
21
|
+
payload: rw
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
props.emitEvent({
|
|
25
|
+
type: 'addPoints',
|
|
26
|
+
payload: rw,
|
|
27
|
+
finish: false
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
17
32
|
return /*#__PURE__*/_react.default.createElement(_imageClickWrapperComponent.default, _extends({}, props, {
|
|
33
|
+
emitFinish: finish,
|
|
18
34
|
name: "image-click-puzzle"
|
|
19
35
|
}));
|
|
20
36
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _drei = require("@react-three/drei");
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
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); }
|
|
15
|
+
|
|
16
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
17
|
+
|
|
18
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
19
|
+
|
|
20
|
+
var HtmlPro = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
21
|
+
var calculatePosition = _ref.calculatePosition,
|
|
22
|
+
children = _ref.children,
|
|
23
|
+
props = _objectWithoutProperties(_ref, ["calculatePosition", "children"]);
|
|
24
|
+
|
|
25
|
+
return calculatePosition ? /*#__PURE__*/_react.default.createElement(_drei.Html, _extends({
|
|
26
|
+
ref: ref,
|
|
27
|
+
calculatePosition: calculatePosition
|
|
28
|
+
}, props), children) : /*#__PURE__*/_react.default.createElement(_drei.Html, _extends({
|
|
29
|
+
ref: ref
|
|
30
|
+
}, props), children);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var _default = HtmlPro;
|
|
34
|
+
exports.default = _default;
|
package/dist/helpers/index.js
CHANGED
|
@@ -3,12 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.executeCrossFade = exports.getObjectPosition = exports.cameraFitAnyObject = exports.roundFloat = exports.usePrevious = exports.formatMessage = void 0;
|
|
6
|
+
exports.executeCrossFade = exports.screenToVector = exports.vectorToScreen = exports.getObjectPosition = exports.cameraFitAnyObject = exports.roundFloat = exports.vectorTranslateY = exports.vectorTranslateX = exports.vectorTranslateZ = exports.vectorTranslateOnAxis = exports.usePrevious = exports.formatMessage = exports.zAxis = exports.yAxis = exports.xAxis = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
|
|
10
10
|
var _three = require("three");
|
|
11
11
|
|
|
12
|
+
var xAxis = new _three.Vector3(1, 0, 0);
|
|
13
|
+
exports.xAxis = xAxis;
|
|
14
|
+
var yAxis = new _three.Vector3(0, 1, 0);
|
|
15
|
+
exports.yAxis = yAxis;
|
|
16
|
+
var zAxis = new _three.Vector3(0, 0, 1);
|
|
17
|
+
exports.zAxis = zAxis;
|
|
18
|
+
|
|
12
19
|
var formatMessage = function formatMessage(text) {
|
|
13
20
|
var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
14
21
|
var result = text;
|
|
@@ -30,6 +37,31 @@ var usePrevious = function usePrevious(value) {
|
|
|
30
37
|
|
|
31
38
|
exports.usePrevious = usePrevious;
|
|
32
39
|
|
|
40
|
+
var vectorTranslateOnAxis = function vectorTranslateOnAxis(axis, amount, object) {
|
|
41
|
+
var result = axis.clone().applyQuaternion(object.quaternion);
|
|
42
|
+
return result.multiplyScalar(amount).clone();
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.vectorTranslateOnAxis = vectorTranslateOnAxis;
|
|
46
|
+
|
|
47
|
+
var vectorTranslateZ = function vectorTranslateZ(amount, object) {
|
|
48
|
+
return vectorTranslateOnAxis(zAxis, amount, object);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
exports.vectorTranslateZ = vectorTranslateZ;
|
|
52
|
+
|
|
53
|
+
var vectorTranslateX = function vectorTranslateX(amount, object) {
|
|
54
|
+
return vectorTranslateOnAxis(xAxis, amount, object);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
exports.vectorTranslateX = vectorTranslateX;
|
|
58
|
+
|
|
59
|
+
var vectorTranslateY = function vectorTranslateY(amount, object) {
|
|
60
|
+
return vectorTranslateOnAxis(yAxis, amount, object);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
exports.vectorTranslateY = vectorTranslateY;
|
|
64
|
+
|
|
33
65
|
var roundFloat = function roundFloat(number, decimals) {
|
|
34
66
|
return parseFloat(number.toFixed(decimals));
|
|
35
67
|
};
|
|
@@ -39,6 +71,8 @@ exports.roundFloat = roundFloat;
|
|
|
39
71
|
var cameraFitAnyObject = function cameraFitAnyObject(object, camera) {
|
|
40
72
|
var uOff = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
41
73
|
var controls = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
74
|
+
var clone = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
75
|
+
var clonedCamera = camera.clone();
|
|
42
76
|
var offset = uOff || 1.25;
|
|
43
77
|
var boundingBox = new _three.Box3();
|
|
44
78
|
boundingBox.setFromObject(object);
|
|
@@ -46,27 +80,33 @@ var cameraFitAnyObject = function cameraFitAnyObject(object, camera) {
|
|
|
46
80
|
var center = new _three.Vector3(0, boundingBoxCenter.y, 0);
|
|
47
81
|
var size = boundingBox.getSize(new _three.Vector3());
|
|
48
82
|
var maxDim = Math.max(size.x, size.y, size.z);
|
|
49
|
-
var fov =
|
|
83
|
+
var fov = clonedCamera.fov * (Math.PI / 180);
|
|
50
84
|
var cameraZ = Math.abs(maxDim * Math.sqrt(2) / 2 * Math.tan(fov * 2));
|
|
51
85
|
cameraZ *= offset;
|
|
52
86
|
var objectWorldPosition = new _three.Vector3();
|
|
53
87
|
objectWorldPosition.setFromMatrixPosition(object.matrixWorld);
|
|
54
88
|
var directionVector = new _three.Vector3(1, 1, 1);
|
|
55
89
|
var unitDirectionVector = directionVector.normalize();
|
|
56
|
-
|
|
57
|
-
|
|
90
|
+
clonedCamera.position.copy(unitDirectionVector.multiplyScalar(cameraZ));
|
|
91
|
+
clonedCamera.lookAt(objectWorldPosition);
|
|
58
92
|
var minZ = boundingBox.min.z;
|
|
59
93
|
var cameraToFarEdge = minZ < 0 ? -minZ + cameraZ : cameraZ - minZ;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
94
|
+
clonedCamera.far = cameraToFarEdge * 3;
|
|
95
|
+
clonedCamera.near = 0.01;
|
|
96
|
+
clonedCamera.updateProjectionMatrix();
|
|
97
|
+
clonedCamera.lookAt(center);
|
|
64
98
|
|
|
65
99
|
if (controls) {
|
|
66
100
|
controls.target = center;
|
|
67
101
|
controls.maxDistance = cameraToFarEdge * 2;
|
|
68
102
|
controls.saveState();
|
|
69
103
|
}
|
|
104
|
+
|
|
105
|
+
if (clone) {
|
|
106
|
+
return clonedCamera;
|
|
107
|
+
} else {
|
|
108
|
+
camera.copy(clonedCamera);
|
|
109
|
+
}
|
|
70
110
|
};
|
|
71
111
|
|
|
72
112
|
exports.cameraFitAnyObject = cameraFitAnyObject;
|
|
@@ -87,6 +127,28 @@ var getObjectPosition = function getObjectPosition(object, camera, canvas) {
|
|
|
87
127
|
|
|
88
128
|
exports.getObjectPosition = getObjectPosition;
|
|
89
129
|
|
|
130
|
+
var vectorToScreen = function vectorToScreen(vector, camera) {
|
|
131
|
+
var width = window.innerWidth,
|
|
132
|
+
height = window.innerHeight;
|
|
133
|
+
var widthHalf = width / 2,
|
|
134
|
+
heightHalf = height / 2;
|
|
135
|
+
var pos = vector.clone();
|
|
136
|
+
pos.project(camera);
|
|
137
|
+
pos.x = pos.x * widthHalf + widthHalf;
|
|
138
|
+
pos.y = -(pos.y * heightHalf) + heightHalf;
|
|
139
|
+
return pos;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
exports.vectorToScreen = vectorToScreen;
|
|
143
|
+
|
|
144
|
+
var screenToVector = function screenToVector(vector, camera) {
|
|
145
|
+
var clone = vector.clone();
|
|
146
|
+
clone.z = -1;
|
|
147
|
+
return clone.unproject(camera);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
exports.screenToVector = screenToVector;
|
|
151
|
+
|
|
90
152
|
var setWeight = function setWeight(action, weight) {
|
|
91
153
|
action.enabled = true;
|
|
92
154
|
action.setEffectiveTimeScale(1);
|
|
@@ -94,6 +156,7 @@ var setWeight = function setWeight(action, weight) {
|
|
|
94
156
|
};
|
|
95
157
|
|
|
96
158
|
var executeCrossFade = function executeCrossFade(startAction, endAction, duration) {
|
|
159
|
+
if (startAction === endAction) return;
|
|
97
160
|
startAction.play();
|
|
98
161
|
startAction.reset();
|
|
99
162
|
endAction.reset();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gamelearn/arcade-components",
|
|
3
3
|
"license": "Gamelearn",
|
|
4
|
-
"version": "0.25.
|
|
4
|
+
"version": "0.25.34",
|
|
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.2.
|
|
62
|
+
"@gamelearn/arcade-styles": "0.2.4",
|
|
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",
|