@gamelearn/arcade-components 0.25.2 → 0.25.3
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.
|
@@ -17,10 +17,20 @@ var _three = require("three");
|
|
|
17
17
|
|
|
18
18
|
var _GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader");
|
|
19
19
|
|
|
20
|
+
var _decisionComponent = _interopRequireDefault(require("../../decision-component"));
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
20
24
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
21
25
|
|
|
22
26
|
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
27
|
|
|
28
|
+
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
|
+
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
33
|
+
|
|
24
34
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
25
35
|
|
|
26
36
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -37,6 +47,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
37
47
|
var emitEvent = _ref.emitEvent,
|
|
38
48
|
lines = _ref.lines,
|
|
39
49
|
actors = _ref.actors,
|
|
50
|
+
soundActions = _ref.soundActions,
|
|
40
51
|
enableZoom = _ref.enableZoom;
|
|
41
52
|
|
|
42
53
|
var _useState = (0, _react.useState)(0),
|
|
@@ -68,10 +79,12 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
68
79
|
var currentLine = lines[line];
|
|
69
80
|
var lastLine = lines[line - 1];
|
|
70
81
|
var resetAnims = (0, _react.useCallback)(function (end) {
|
|
71
|
-
var
|
|
82
|
+
var _currentLine$slots, _lastLine$slots;
|
|
83
|
+
|
|
84
|
+
var slottedCharacters = (_currentLine$slots = currentLine.slots) === null || _currentLine$slots === void 0 ? void 0 : _currentLine$slots.filter(function (slot) {
|
|
72
85
|
return slot.uid;
|
|
73
86
|
});
|
|
74
|
-
var lastSlotterCharacters = lastLine === null || lastLine === void 0 ? void 0 : lastLine.slots.filter(function (slot) {
|
|
87
|
+
var lastSlotterCharacters = lastLine === null || lastLine === void 0 ? void 0 : (_lastLine$slots = lastLine.slots) === null || _lastLine$slots === void 0 ? void 0 : _lastLine$slots.filter(function (slot) {
|
|
75
88
|
return slot.uid;
|
|
76
89
|
});
|
|
77
90
|
|
|
@@ -99,28 +112,35 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
99
112
|
}
|
|
100
113
|
});
|
|
101
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
|
+
|
|
118
|
+
if (line < lines.length - 1) {
|
|
119
|
+
changeLine(line + 1);
|
|
120
|
+
} else {
|
|
121
|
+
messagePosition.current = defaultCamera.current.position.clone().add(new _three.Vector3(0, 5, -35));
|
|
122
|
+
animationStart.current = true;
|
|
123
|
+
setCurrentMessage({
|
|
124
|
+
text: ''
|
|
125
|
+
});
|
|
126
|
+
setTimeout(function () {
|
|
127
|
+
camera.copy(defaultCamera.current);
|
|
128
|
+
emitEvent({
|
|
129
|
+
type: 'success'
|
|
130
|
+
});
|
|
131
|
+
}, 2000);
|
|
132
|
+
}
|
|
133
|
+
}, [camera, emitEvent, line, lines.length, resetAnims]);
|
|
102
134
|
var onKeyCallback = (0, _react.useCallback)(function (e) {
|
|
103
135
|
if (e.keyCode === 32) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (line < lines.length - 1) {
|
|
107
|
-
changeLine(line + 1);
|
|
108
|
-
} else {
|
|
109
|
-
messagePosition.current = defaultCamera.current.position.clone().add(new _three.Vector3(0, 5, -35));
|
|
110
|
-
animationStart.current = true;
|
|
111
|
-
setCurrentMessage({
|
|
112
|
-
text: ''
|
|
113
|
-
});
|
|
114
|
-
setTimeout(function () {
|
|
115
|
-
camera.copy(defaultCamera.current);
|
|
116
|
-
emitEvent({
|
|
117
|
-
type: 'success'
|
|
118
|
-
});
|
|
119
|
-
}, 2000);
|
|
120
|
-
}
|
|
136
|
+
nextLine();
|
|
121
137
|
}
|
|
122
|
-
}, [
|
|
138
|
+
}, [nextLine]);
|
|
123
139
|
(0, _react.useEffect)(function () {
|
|
140
|
+
setCurrentMessage({
|
|
141
|
+
text: ''
|
|
142
|
+
});
|
|
143
|
+
if (currentLine.decision) return;
|
|
124
144
|
var talkingCharacter = currentLine.slots.find(function (slot) {
|
|
125
145
|
return slot.talking;
|
|
126
146
|
});
|
|
@@ -178,7 +198,22 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
178
198
|
}
|
|
179
199
|
}
|
|
180
200
|
});
|
|
181
|
-
|
|
201
|
+
|
|
202
|
+
var decisionPayload = _objectSpread(_objectSpread({}, currentLine.payload), {}, {
|
|
203
|
+
onFinish: nextLine,
|
|
204
|
+
emitEvent: emitEvent,
|
|
205
|
+
soundActions: soundActions
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, currentLine.decision ? /*#__PURE__*/_react.default.createElement(_drei.Html, {
|
|
209
|
+
style: {
|
|
210
|
+
width: '100vw',
|
|
211
|
+
height: '100vh'
|
|
212
|
+
},
|
|
213
|
+
calculatePosition: function calculatePosition() {
|
|
214
|
+
return [0, 0];
|
|
215
|
+
}
|
|
216
|
+
}, /*#__PURE__*/_react.default.createElement(_decisionComponent.default, decisionPayload)) : null, currentMessage.text ? /*#__PURE__*/_react.default.createElement(_drei.Html, {
|
|
182
217
|
position: messagePosition.current,
|
|
183
218
|
zIndexRange: [3, 0],
|
|
184
219
|
sprite: true
|
|
@@ -203,7 +238,7 @@ var DialogComponent = function DialogComponent(_ref) {
|
|
|
203
238
|
wordWrap: 'break-word',
|
|
204
239
|
overflow: 'auto'
|
|
205
240
|
}
|
|
206
|
-
}, currentMessage.text))) : null;
|
|
241
|
+
}, currentMessage.text))) : null);
|
|
207
242
|
};
|
|
208
243
|
|
|
209
244
|
var _default = DialogComponent;
|