@gamelearn/arcade-components 2.27.0 → 2.29.2
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/animation-component/components/AnimationComponent.js +10 -28
- package/dist/components/animation-component/index.js +0 -3
- package/dist/components/animation-component/mocks/mockForStory.js +0 -3
- package/dist/components/auto-evaluation-component/components/AutoEvaluation.js +30 -71
- package/dist/components/auto-evaluation-component/components/EndScreen.js +1 -9
- package/dist/components/auto-evaluation-component/components/StartScreen.js +2 -6
- package/dist/components/auto-evaluation-component/index.js +0 -3
- package/dist/components/auto-evaluation-component/mocks/mockForStory.js +0 -2
- package/dist/components/cards-selector-puzzle-component/components/Board/index.js +23 -55
- package/dist/components/cards-selector-puzzle-component/components/Card/index.js +4 -23
- package/dist/components/cards-selector-puzzle-component/components/CardsSelectorPuzzleComponent.js +41 -92
- package/dist/components/cards-selector-puzzle-component/index.js +0 -3
- package/dist/components/cards-selector-puzzle-component/mocks/mockForStory.js +4 -10
- package/dist/components/cartel-component/components/CartelComponent.js +16 -42
- package/dist/components/cartel-component/index.js +0 -3
- package/dist/components/chained-image-click-puzzle-component/components/ChainedImageClickPuzzleComponent.js +20 -38
- package/dist/components/chained-image-click-puzzle-component/components/CurrentImagePuzzle.js +25 -64
- package/dist/components/chained-image-click-puzzle-component/index.js +0 -3
- package/dist/components/chained-image-click-puzzle-component/mocks/mockForStory.js +1 -2
- package/dist/components/comic-component/components/ComicComponent.js +37 -81
- package/dist/components/comic-component/components/Slide.js +2 -7
- package/dist/components/comic-component/components/Vignette.js +7 -23
- package/dist/components/comic-component/index.js +0 -3
- package/dist/components/comic-component/mocks/mockForStory.js +1 -2
- package/dist/components/conversational-component/components/ConversationalComponent.js +15 -39
- package/dist/components/conversational-component/index.js +0 -3
- package/dist/components/conversational-pro-component/components/ConversationalProComponent.js +54 -137
- package/dist/components/conversational-pro-component/components/Message.js +1 -9
- package/dist/components/conversational-pro-component/components/Slot.js +3 -20
- package/dist/components/conversational-pro-component/components/SlotList.js +16 -40
- package/dist/components/conversational-pro-component/components/scene/Panel.js +12 -54
- package/dist/components/conversational-pro-component/components/scene/Panels.js +10 -17
- package/dist/components/conversational-pro-component/components/scene/index.js +11 -30
- package/dist/components/conversational-pro-component/index.js +0 -3
- package/dist/components/conversational-pro-component/mocks/mockForStory.js +1 -2
- package/dist/components/cracker-puzzle-component/components/CrackerPuzzleComponent.js +35 -89
- package/dist/components/cracker-puzzle-component/components/DrawGrid/index.js +3 -7
- package/dist/components/cracker-puzzle-component/components/DrawItem/index.js +4 -9
- package/dist/components/cracker-puzzle-component/components/DrawRow/index.js +4 -9
- package/dist/components/cracker-puzzle-component/components/helpers.js +15 -55
- package/dist/components/cracker-puzzle-component/index.js +0 -3
- package/dist/components/cracker-puzzle-component/mocks/mockForStory.js +0 -2
- package/dist/components/decision-component/components/DecisionBody.js +26 -48
- package/dist/components/decision-component/components/DecisionComponent.js +22 -70
- package/dist/components/decision-component/components/Feedback.js +2 -11
- package/dist/components/decision-component/components/Options.js +12 -31
- package/dist/components/decision-component/index.js +0 -3
- package/dist/components/decision-component/mocks/mockForStory.js +0 -2
- package/dist/components/dialog-component/components/BubbleWrapper.js +1 -7
- package/dist/components/dialog-component/components/DialogComponent.js +118 -338
- package/dist/components/dialog-component/components/DialogDecision.js +3 -13
- package/dist/components/dialog-component/components/SpeechBubbleComponent.js +6 -24
- package/dist/components/dialog-component/index.js +0 -3
- package/dist/components/dialog-component/mocks/mockForStory.js +1 -5
- package/dist/components/drag-item-puzzle-component/components/DragItemPuzzleComponent.js +34 -90
- package/dist/components/drag-item-puzzle-component/components/Messages.js +0 -4
- package/dist/components/drag-item-puzzle-component/index.js +0 -3
- package/dist/components/drag-item-puzzle-component/mocks/mockForStory.js +1 -2
- package/dist/components/feedback-component/components/FeedbackComponent.js +34 -52
- package/dist/components/feedback-component/index.js +0 -3
- package/dist/components/feedback-component/mocks/mockForStory.js +1 -2
- package/dist/components/frame-click-puzzle-component/components/Counter/index.js +3 -8
- package/dist/components/frame-click-puzzle-component/components/CurrentFramePuzzle.js +36 -68
- package/dist/components/frame-click-puzzle-component/components/FrameClickPuzzleComponent.js +33 -68
- package/dist/components/frame-click-puzzle-component/components/Tooltip/index.js +0 -6
- package/dist/components/frame-click-puzzle-component/index.js +0 -3
- package/dist/components/frame-click-puzzle-component/mocks/mockForStory.js +1 -2
- package/dist/components/hacker-puzzle-component/components/HackerPuzzleComponent.js +29 -69
- package/dist/components/hacker-puzzle-component/index.js +0 -3
- package/dist/components/hacker-puzzle-component/mocks/mockForStory.js +0 -2
- package/dist/components/hanged-puzzle-component/components/HangedPuzzleComponent.js +48 -123
- package/dist/components/hanged-puzzle-component/index.js +0 -3
- package/dist/components/hanged-puzzle-component/mocks/mockForStory.js +0 -3
- package/dist/components/hanged-puzzle-component/utils.js +0 -20
- package/dist/components/image-click-puzzle-component/components/ImageClickPuzzleComponent.js +1 -8
- package/dist/components/image-click-puzzle-component/index.js +0 -3
- package/dist/components/image-click-puzzle-component/mocks/mockForStory.js +0 -2
- package/dist/components/image-click-wrapper-component/components/CountDown/index.js +0 -4
- package/dist/components/image-click-wrapper-component/components/ImageClickWrapperComponent.js +67 -134
- package/dist/components/image-click-wrapper-component/components/TimerDialog/index.js +2 -6
- package/dist/components/image-click-wrapper-component/index.js +0 -3
- package/dist/components/image-click-wrapper-component/mocks/mockForStory.js +0 -2
- package/dist/components/image-component/components/ImageComponent.js +14 -33
- package/dist/components/image-component/index.js +0 -3
- package/dist/components/image-component/mocks/mockForStory.js +0 -2
- package/dist/components/index.js +0 -39
- package/dist/components/inventory-item/components/InventoryItem.js +9 -35
- package/dist/components/inventory-item/index.js +0 -3
- package/dist/components/inventory-item/mocks/mockForStory.js +0 -3
- package/dist/components/keyboard-puzzle-component/components/KeyboardPuzzleComponent.js +33 -75
- package/dist/components/keyboard-puzzle-component/index.js +0 -3
- package/dist/components/keyboard-puzzle-component/mocks/mockForStory.js +0 -2
- package/dist/components/konva-components/Area/index.js +15 -44
- package/dist/components/konva-components/KonvaMapper.js +19 -42
- package/dist/components/lectures-component/components/LectureButtons.js +12 -13
- package/dist/components/lectures-component/components/LecturesComponent.js +29 -55
- package/dist/components/lectures-component/index.js +0 -3
- package/dist/components/lectures-component/mocks/mockForStory.js +6 -9
- package/dist/components/login-puzzle-component/components/LoginPuzzleComponent.js +38 -80
- package/dist/components/login-puzzle-component/index.js +0 -3
- package/dist/components/login-puzzle-component/mocks/mockForStory.js +0 -2
- package/dist/components/notice-component/components/NoticeComponent.js +8 -21
- package/dist/components/notice-component/index.js +0 -3
- package/dist/components/notice-component/mocks/mockForStory.js +0 -2
- package/dist/components/pattern-component/components/PatternComponent.js +8 -24
- package/dist/components/pattern-component/index.js +0 -3
- package/dist/components/pattern-component/mocks/mockForStory.js +0 -2
- package/dist/components/pdf-component/components/PdfComponent.js +23 -55
- package/dist/components/pdf-component/components/PdfVisor.js +22 -58
- package/dist/components/pdf-component/index.js +0 -3
- package/dist/components/pdf-component/mocks/mockForProps.js +1 -2
- package/dist/components/referral-component/components/EmailPill.js +2 -6
- package/dist/components/referral-component/components/ReferralComponent.js +30 -59
- package/dist/components/referral-component/components/StepOne.js +14 -48
- package/dist/components/referral-component/components/StepTwo.js +8 -23
- package/dist/components/referral-component/index.js +0 -3
- package/dist/components/referral-component/mocks/mockForStory.js +0 -2
- package/dist/components/survey-component/components/ApplicableBox.js +8 -15
- package/dist/components/survey-component/components/OpinionBox.js +8 -15
- package/dist/components/survey-component/components/SurveyComponent.js +13 -40
- package/dist/components/survey-component/components/TextBox.js +7 -13
- package/dist/components/survey-component/index.js +0 -3
- package/dist/components/survey-component/mocks/mockForStory.js +0 -2
- package/dist/components/terminal-puzzle-component/components/FilesGroup/Item.js +1 -6
- package/dist/components/terminal-puzzle-component/components/FilesGroup/index.js +4 -10
- package/dist/components/terminal-puzzle-component/components/Image/index.js +2 -6
- package/dist/components/terminal-puzzle-component/components/TerminalPuzzleComponent.js +26 -65
- package/dist/components/terminal-puzzle-component/components/Visor/index.js +15 -35
- package/dist/components/terminal-puzzle-component/components/utils/index.js +0 -3
- package/dist/components/terminal-puzzle-component/index.js +0 -3
- package/dist/components/terminal-puzzle-component/mocks/mockForStory.js +1 -2
- package/dist/components/test-component/components/Container.js +26 -60
- package/dist/components/test-component/components/Feedbacks.js +3 -13
- package/dist/components/test-component/components/Questions.js +11 -45
- package/dist/components/test-component/components/Results.js +28 -52
- package/dist/components/test-component/components/TestComponent.js +59 -110
- package/dist/components/test-component/index.js +0 -3
- package/dist/components/test-component/mocks/mockForStory.js +4 -8
- package/dist/components/text-click-puzzle-component/components/TextClickPuzzleComponent.js +58 -95
- package/dist/components/text-click-puzzle-component/index.js +0 -3
- package/dist/components/text-click-puzzle-component/mocks/mockForStory.js +1 -2
- package/dist/components/text-click-puzzle-component/utils/index.js +6 -31
- package/dist/components/url-component/components/UrlComponent.js +16 -34
- package/dist/components/url-component/index.js +0 -3
- package/dist/components/url-component/mocks/mockForProps.js +0 -2
- package/dist/components/video-component/components/VideoComponent.js +11 -25
- package/dist/components/video-component/index.js +0 -3
- package/dist/components/video-component/mocks/mockForStory.js +0 -2
- package/dist/components/video-visor/components/VideoControllers/BufferBar.js +10 -37
- package/dist/components/video-visor/components/VideoControllers/ControlButtons.js +2 -6
- package/dist/components/video-visor/components/VideoControllers/FinishedVideoButtons.js +1 -5
- package/dist/components/video-visor/components/VideoControllers/PlayInitButton.js +2 -8
- package/dist/components/video-visor/components/VideoControllers/SkipButton.js +5 -9
- package/dist/components/video-visor/components/VideoControllers/Timer.js +0 -5
- package/dist/components/video-visor/components/VideoControllers/VolumeBar.js +4 -20
- package/dist/components/video-visor/components/VideoControllers/index.js +17 -29
- package/dist/components/video-visor/components/VideoVisor.js +38 -92
- package/dist/components/video-visor/index.js +0 -3
- package/dist/components/video-visor/mocks/mockForStory.js +1 -2
- package/dist/components/web-builder-puzzle-component/Popups/PopupColorComponent/index.js +11 -28
- package/dist/components/web-builder-puzzle-component/Popups/PopupImageComponent/index.js +10 -27
- package/dist/components/web-builder-puzzle-component/Popups/PopupTextComponent/index.js +13 -36
- package/dist/components/web-builder-puzzle-component/Popups/index.js +0 -4
- package/dist/components/web-builder-puzzle-component/Templates/Facebook.js +0 -2
- package/dist/components/web-builder-puzzle-component/components/EditButton/index.js +1 -5
- package/dist/components/web-builder-puzzle-component/components/Feedback/index.js +3 -7
- package/dist/components/web-builder-puzzle-component/components/PublishButton/index.js +1 -5
- package/dist/components/web-builder-puzzle-component/components/WebBuilderBody/BankBody.js +5 -12
- package/dist/components/web-builder-puzzle-component/components/WebBuilderBody/FacebookBody.js +5 -11
- package/dist/components/web-builder-puzzle-component/components/WebBuilderBody/index.js +0 -7
- package/dist/components/web-builder-puzzle-component/components/WebBuilderFront/index.js +5 -14
- package/dist/components/web-builder-puzzle-component/components/WebBuilderHeader/BankHeader.js +5 -13
- package/dist/components/web-builder-puzzle-component/components/WebBuilderHeader/FacebookHeader.js +3 -8
- package/dist/components/web-builder-puzzle-component/components/WebBuilderHeader/index.js +3 -10
- package/dist/components/web-builder-puzzle-component/components/WebBuilderPuzzleComponent.js +47 -112
- package/dist/components/web-builder-puzzle-component/components/WebBuilderTopBar/index.js +3 -9
- package/dist/components/web-builder-puzzle-component/index.js +0 -3
- package/dist/components/web-builder-puzzle-component/mocks/mockForStory.js +0 -3
- package/dist/components/writer-puzzle-component/components/ElectionComponent.js +13 -30
- package/dist/components/writer-puzzle-component/components/FeedbackComponent.js +14 -30
- package/dist/components/writer-puzzle-component/components/FeedbackElement.js +2 -6
- package/dist/components/writer-puzzle-component/components/FinishedTextComponent.js +1 -6
- package/dist/components/writer-puzzle-component/components/FixedComponent.js +17 -52
- package/dist/components/writer-puzzle-component/components/SingleElection.js +13 -41
- package/dist/components/writer-puzzle-component/components/WriterPuzzleComponent.js +63 -145
- package/dist/components/writer-puzzle-component/index.js +0 -3
- package/dist/components/writer-puzzle-component/mocks/mockForStory.js +10 -7
- package/dist/components/zoom-test/components/ZoomTest.js +7 -25
- package/dist/components/zoom-test/index.js +0 -3
- package/dist/components/zoom-test/mocks/mockForStory.js +0 -4
- package/dist/helpers/LangIsRtl.js +0 -4
- package/dist/helpers/LightSet.js +0 -4
- package/dist/helpers/LodController.js +1 -10
- package/dist/helpers/deviceDetection.js +2 -5
- package/dist/helpers/drawLOD.js +11 -53
- package/dist/helpers/index.js +73 -102
- package/dist/helpers/lodStats.js +2 -10
- package/dist/helpers/mocker.js +1 -20
- package/dist/helpers/useEkho.js +64 -91
- package/dist/helpers/useGLB.js +5 -13
- package/dist/helpers/useStateMachine.js +257 -0
- package/dist/helpers/useTimeout.js +0 -6
- package/dist/helpers/useWindowSize.js +8 -22
- package/dist/index.js +0 -2
- package/dist/test/testSceneWrapper.js +0 -8
- package/package.json +3 -2
|
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var LangIsRtl = function LangIsRtl() {
|
|
9
8
|
var langsRtl = ['ar', 'fa', 'he', 'ku', 'ur'];
|
|
10
9
|
var currentLang = document.querySelector('html').getAttribute('lang');
|
|
11
|
-
|
|
12
10
|
if (langsRtl.includes(currentLang)) {
|
|
13
11
|
return true;
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
return false;
|
|
17
14
|
};
|
|
18
|
-
|
|
19
15
|
var _default = LangIsRtl;
|
|
20
16
|
exports.default = _default;
|
package/dist/helpers/LightSet.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
var LightSet = function LightSet() {
|
|
13
10
|
return /*#__PURE__*/_react.default.createElement("group", null, /*#__PURE__*/_react.default.createElement("pointLight", {
|
|
14
11
|
position: [-2.29, 17.35, 2.56],
|
|
@@ -34,6 +31,5 @@ var LightSet = function LightSet() {
|
|
|
34
31
|
position: [0, 500, 0]
|
|
35
32
|
}));
|
|
36
33
|
};
|
|
37
|
-
|
|
38
34
|
var _default = LightSet;
|
|
39
35
|
exports.default = _default;
|
|
@@ -4,25 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _drei = require("@react-three/drei");
|
|
9
|
-
|
|
10
8
|
var _react = require("react");
|
|
11
|
-
|
|
12
9
|
var _fiber = require("@react-three/fiber");
|
|
13
|
-
|
|
14
10
|
var _drawLOD = _interopRequireDefault(require("./drawLOD"));
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
12
|
var LodController = function LodController() {
|
|
19
13
|
var scene = (0, _fiber.useThree)(function (state) {
|
|
20
14
|
return state.scene;
|
|
21
15
|
});
|
|
22
|
-
|
|
23
16
|
var _useProgress = (0, _drei.useProgress)(),
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
active = _useProgress.active;
|
|
26
18
|
(0, _react.useEffect)(function () {
|
|
27
19
|
if (!active) {
|
|
28
20
|
setTimeout(function () {
|
|
@@ -32,6 +24,5 @@ var LodController = function LodController() {
|
|
|
32
24
|
}, [active, scene]);
|
|
33
25
|
return null;
|
|
34
26
|
};
|
|
35
|
-
|
|
36
27
|
var _default = LodController;
|
|
37
28
|
exports.default = _default;
|
|
@@ -4,14 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DeviceDetection = exports.BrowserDetection = void 0;
|
|
7
|
-
|
|
8
7
|
var DeviceDetection = function DeviceDetection() {
|
|
9
|
-
return navigator.userAgent.match(/(android)/i) || ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform) ||
|
|
8
|
+
return navigator.userAgent.match(/(android)/i) || ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform) ||
|
|
9
|
+
// iPad on iOS 13 detection
|
|
10
10
|
navigator.userAgent.includes('Mac') && 'ontouchend' in document;
|
|
11
11
|
};
|
|
12
|
-
|
|
13
12
|
exports.DeviceDetection = DeviceDetection;
|
|
14
|
-
|
|
15
13
|
var BrowserDetection = function BrowserDetection() {
|
|
16
14
|
var ua = navigator.userAgent.toLowerCase();
|
|
17
15
|
var isFirefox = ua.indexOf('firefox') > -1;
|
|
@@ -20,5 +18,4 @@ var BrowserDetection = function BrowserDetection() {
|
|
|
20
18
|
if (isFirefox) res = 'firefox';else if (isSafari) res = 'safari';
|
|
21
19
|
return res;
|
|
22
20
|
};
|
|
23
|
-
|
|
24
21
|
exports.BrowserDetection = BrowserDetection;
|
package/dist/helpers/drawLOD.js
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var THREE = _interopRequireWildcard(require("three"));
|
|
11
|
-
|
|
12
9
|
var _lodStats = _interopRequireDefault(require("./lodStats"));
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
-
|
|
18
12
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
|
|
19
|
-
|
|
20
13
|
var loadingManager = new THREE.LoadingManager();
|
|
21
14
|
var imgLoader = new THREE.ImageLoader(loadingManager);
|
|
22
15
|
var pureGlbMode = false;
|
|
@@ -43,7 +36,6 @@ var blueImage = new Image();
|
|
|
43
36
|
blueImage.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPj/HwADBwIAMCbHYQAAAABJRU5ErkJggg==';
|
|
44
37
|
var whiteImage = new Image();
|
|
45
38
|
whiteImage.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=';
|
|
46
|
-
|
|
47
39
|
function roundedRectangle(ctx, rect, radius) {
|
|
48
40
|
var pi = Math.PI;
|
|
49
41
|
var x1 = rect[0];
|
|
@@ -53,11 +45,8 @@ function roundedRectangle(ctx, rect, radius) {
|
|
|
53
45
|
var cr = radius;
|
|
54
46
|
ctx.beginPath();
|
|
55
47
|
ctx.arc(x1 + cr, y1 + cr, cr, pi, 1.5 * pi); // upper left corner
|
|
56
|
-
|
|
57
48
|
ctx.arc(x2 - cr, y1 + cr, cr, 1.5 * pi, 0); // upper right corner
|
|
58
|
-
|
|
59
49
|
ctx.arc(x2 - cr, y2 - cr, cr, 0, 0.5 * pi); // lower right corner
|
|
60
|
-
|
|
61
50
|
ctx.arc(x1 + cr, y2 - cr, cr, 0.5 * pi, pi); // lower left corner
|
|
62
51
|
|
|
63
52
|
ctx.closePath();
|
|
@@ -65,23 +54,25 @@ function roundedRectangle(ctx, rect, radius) {
|
|
|
65
54
|
ctx.lineWidth = 20;
|
|
66
55
|
ctx.stroke();
|
|
67
56
|
}
|
|
68
|
-
|
|
69
57
|
function makeTextSprite(message, opts) {
|
|
70
58
|
var parameters = opts || {};
|
|
71
59
|
var fontface = parameters.fontface || 'Helvetica';
|
|
72
60
|
var fontsize = parameters.fontsize || 120;
|
|
73
61
|
var canvas = document.createElement('canvas');
|
|
74
62
|
var context = canvas.getContext('2d');
|
|
75
|
-
context.font = "".concat(fontsize, "px ").concat(fontface);
|
|
63
|
+
context.font = "".concat(fontsize, "px ").concat(fontface);
|
|
64
|
+
|
|
65
|
+
// get size data (height depends only on font size)
|
|
76
66
|
// var metrics = context.measureText(message);
|
|
77
67
|
// var textWidth = metrics.width;
|
|
78
|
-
// text color
|
|
79
68
|
|
|
69
|
+
// text color
|
|
80
70
|
context.fillStyle = 'rgba(255,255,255,1.0)';
|
|
81
71
|
roundedRectangle(context, [0, 0, canvas.width, canvas.height], 25);
|
|
82
72
|
context.fillStyle = 'rgba(255, 255, 255, 1.0)';
|
|
83
|
-
context.fillText(message, 0, fontsize);
|
|
73
|
+
context.fillText(message, 0, fontsize);
|
|
84
74
|
|
|
75
|
+
// canvas contents will be used for a texture
|
|
85
76
|
var texture = new THREE.Texture(canvas);
|
|
86
77
|
texture.minFilter = THREE.LinearFilter;
|
|
87
78
|
texture.needsUpdate = true;
|
|
@@ -94,6 +85,7 @@ function makeTextSprite(message, opts) {
|
|
|
94
85
|
sprite.center.set(0.5, 0.5);
|
|
95
86
|
return sprite;
|
|
96
87
|
}
|
|
88
|
+
|
|
97
89
|
/*
|
|
98
90
|
const texturablesDone = (params) => {
|
|
99
91
|
params.texturableElements.forEach((elem) => {
|
|
@@ -102,31 +94,28 @@ const texturablesDone = (params) => {
|
|
|
102
94
|
}
|
|
103
95
|
*/
|
|
104
96
|
|
|
105
|
-
|
|
106
97
|
var materialize = function materialize(params, lod) {
|
|
107
98
|
var totalLods = 0;
|
|
108
99
|
var doneLods = 0;
|
|
109
|
-
|
|
110
100
|
var checkPromises = function checkPromises() {
|
|
111
101
|
if (doneLods >= totalLods) {
|
|
112
102
|
if (progressiveMode) {
|
|
113
103
|
var currentIndex = progressiveOrder.indexOf(lod);
|
|
114
104
|
var lastIndex = progressiveOrder.indexOf(params.currentLOD);
|
|
115
|
-
|
|
116
105
|
if (currentIndex < lastIndex) {
|
|
117
106
|
materialize(params, progressiveOrder[currentIndex + 1]);
|
|
118
|
-
} else {
|
|
107
|
+
} else {
|
|
108
|
+
// texturablesDone(params);
|
|
119
109
|
}
|
|
120
|
-
} else {
|
|
110
|
+
} else {
|
|
111
|
+
// texturablesDone(params);
|
|
121
112
|
}
|
|
122
113
|
}
|
|
123
114
|
};
|
|
124
|
-
|
|
125
115
|
params.texturableElements.forEach(function (elem) {
|
|
126
116
|
if (params.texturesDistance && elem.distanceToCam > lodDistances[lod]) {
|
|
127
117
|
return;
|
|
128
118
|
}
|
|
129
|
-
|
|
130
119
|
var jsonUrl = elem.userData.url.replace('.glb', '.json');
|
|
131
120
|
fetch(jsonUrl).then(function (response) {
|
|
132
121
|
return response.json();
|
|
@@ -136,7 +125,6 @@ var materialize = function materialize(params, lod) {
|
|
|
136
125
|
obj.material.wireframe = false;
|
|
137
126
|
if (!obj.material.isDone) obj.material.isDone = {};
|
|
138
127
|
obj.material.isDone[lod] = true;
|
|
139
|
-
|
|
140
128
|
if (materials[obj.material.name]) {
|
|
141
129
|
materials[obj.material.name].forEach(function (item) {
|
|
142
130
|
var imgSrc = "".concat(elem.userData.url, ".textures.").concat(lod, ".").concat(item.positionInArray, ".png");
|
|
@@ -144,32 +132,24 @@ var materialize = function materialize(params, lod) {
|
|
|
144
132
|
if (params.showStats) {
|
|
145
133
|
statsTextures(lod, imgSrc, result);
|
|
146
134
|
}
|
|
147
|
-
|
|
148
135
|
obj.material[item.key].image = result;
|
|
149
|
-
|
|
150
136
|
if (params.rgbSimulation) {
|
|
151
137
|
var image;
|
|
152
|
-
|
|
153
138
|
switch (lod) {
|
|
154
139
|
case 'divideby64':
|
|
155
140
|
image = redImage;
|
|
156
141
|
break;
|
|
157
|
-
|
|
158
142
|
case 'divideby16':
|
|
159
143
|
image = greenImage;
|
|
160
144
|
break;
|
|
161
|
-
|
|
162
145
|
case 'divideby4':
|
|
163
146
|
image = blueImage;
|
|
164
147
|
break;
|
|
165
|
-
|
|
166
148
|
default:
|
|
167
149
|
image = result;
|
|
168
150
|
}
|
|
169
|
-
|
|
170
151
|
obj.material[item.key].image = image;
|
|
171
152
|
}
|
|
172
|
-
|
|
173
153
|
obj.material[item.key].needsUpdate = true;
|
|
174
154
|
doneLods += 1;
|
|
175
155
|
checkPromises();
|
|
@@ -182,7 +162,6 @@ var materialize = function materialize(params, lod) {
|
|
|
182
162
|
});
|
|
183
163
|
});
|
|
184
164
|
};
|
|
185
|
-
|
|
186
165
|
var updateSceneLods = function updateSceneLods(params) {
|
|
187
166
|
if (!pureGlbMode && !pureGeometryMode) {
|
|
188
167
|
if (progressiveMode) {
|
|
@@ -192,22 +171,18 @@ var updateSceneLods = function updateSceneLods(params) {
|
|
|
192
171
|
}
|
|
193
172
|
}
|
|
194
173
|
};
|
|
195
|
-
|
|
196
174
|
var invalidateOutOfFrustum = function invalidateOutOfFrustum(params) {
|
|
197
175
|
params.texturableElements = params.texturableElements.filter(function (elem) {
|
|
198
176
|
var bbox = new THREE.Box3().setFromObject(elem);
|
|
199
177
|
var insideFrustum = params.frustum.intersectsBox(bbox);
|
|
200
178
|
elem.bbox = bbox;
|
|
201
|
-
|
|
202
179
|
if (params.showHelpers) {
|
|
203
180
|
var boundingHelper = new THREE.Box3Helper(bbox, insideFrustum ? 0x00ff00 : 0xff0000);
|
|
204
181
|
params.helpers.add(boundingHelper);
|
|
205
182
|
}
|
|
206
|
-
|
|
207
183
|
return insideFrustum;
|
|
208
184
|
});
|
|
209
185
|
};
|
|
210
|
-
|
|
211
186
|
var checkDistances = function checkDistances(params) {
|
|
212
187
|
params.texturableElements.forEach(function (elem) {
|
|
213
188
|
var center = new THREE.Vector3();
|
|
@@ -215,7 +190,6 @@ var checkDistances = function checkDistances(params) {
|
|
|
215
190
|
var bsphere = elem.bbox.getBoundingSphere(new THREE.Sphere(center));
|
|
216
191
|
var distance = params.camera.position.distanceTo(center) - bsphere.radius;
|
|
217
192
|
elem.distanceToCam = distance;
|
|
218
|
-
|
|
219
193
|
if (params.showHelpers) {
|
|
220
194
|
var sphere = new THREE.Mesh(new THREE.SphereGeometry(bsphere.radius, 32, 32), new THREE.MeshStandardMaterial({
|
|
221
195
|
color: 0xffffff,
|
|
@@ -232,7 +206,6 @@ var checkDistances = function checkDistances(params) {
|
|
|
232
206
|
}
|
|
233
207
|
});
|
|
234
208
|
};
|
|
235
|
-
|
|
236
209
|
var statsGeometries = function statsGeometries(params) {
|
|
237
210
|
params.texturableElements.forEach(function (item) {
|
|
238
211
|
var url = item.userData.url.replace('.glb', '.geometry.glb');
|
|
@@ -246,7 +219,6 @@ var statsGeometries = function statsGeometries(params) {
|
|
|
246
219
|
});
|
|
247
220
|
});
|
|
248
221
|
};
|
|
249
|
-
|
|
250
222
|
var statsTextures = function statsTextures(lod, url) {
|
|
251
223
|
fetch(url).then(function (response) {
|
|
252
224
|
return response.blob();
|
|
@@ -257,7 +229,6 @@ var statsTextures = function statsTextures(lod, url) {
|
|
|
257
229
|
(0, _lodStats.default)(obj);
|
|
258
230
|
});
|
|
259
231
|
};
|
|
260
|
-
|
|
261
232
|
var setTexturableElements = function setTexturableElements(params) {
|
|
262
233
|
params.texturableElements = [];
|
|
263
234
|
params.scene.traverse(function (item) {
|
|
@@ -268,12 +239,10 @@ var setTexturableElements = function setTexturableElements(params) {
|
|
|
268
239
|
(0, _lodStats.default)({
|
|
269
240
|
reset: true
|
|
270
241
|
});
|
|
271
|
-
|
|
272
242
|
if (params.showStats) {
|
|
273
243
|
statsGeometries(params);
|
|
274
244
|
}
|
|
275
245
|
};
|
|
276
|
-
|
|
277
246
|
var getHelpers = function getHelpers(scene) {
|
|
278
247
|
var helper = null;
|
|
279
248
|
scene.children.forEach(function (item) {
|
|
@@ -283,20 +252,16 @@ var getHelpers = function getHelpers(scene) {
|
|
|
283
252
|
});
|
|
284
253
|
return helper;
|
|
285
254
|
};
|
|
286
|
-
|
|
287
255
|
var drawLOD = function drawLOD(scene, camera, settings) {
|
|
288
256
|
var currentCamera = camera;
|
|
289
|
-
|
|
290
257
|
if (!currentCamera.parent) {
|
|
291
258
|
scene.traverse(function (node) {
|
|
292
259
|
var _node$userData;
|
|
293
|
-
|
|
294
260
|
if (node.isPerspectiveCamera && (_node$userData = node.userData) !== null && _node$userData !== void 0 && _node$userData.defaultCamera) {
|
|
295
261
|
currentCamera = node;
|
|
296
262
|
}
|
|
297
263
|
});
|
|
298
264
|
}
|
|
299
|
-
|
|
300
265
|
var params = {};
|
|
301
266
|
params.currentLOD = settings !== null && settings !== void 0 && settings.currentLOD ? settings.currentLOD : currentLOD;
|
|
302
267
|
params.rgbSimulation = settings !== null && settings !== void 0 && settings.rgbSimulation ? settings.rgbSimulation : rgbSimulation;
|
|
@@ -314,7 +279,6 @@ var drawLOD = function drawLOD(scene, camera, settings) {
|
|
|
314
279
|
params.scene.add(params.helpers);
|
|
315
280
|
params.camera = currentCamera;
|
|
316
281
|
params.frustum = null;
|
|
317
|
-
|
|
318
282
|
if (params.texturesFrustum || params.texturesDistance) {
|
|
319
283
|
if (params.camera) {
|
|
320
284
|
params.camera.updateMatrixWorld();
|
|
@@ -325,7 +289,6 @@ var drawLOD = function drawLOD(scene, camera, settings) {
|
|
|
325
289
|
params.texturesFrustum = false;
|
|
326
290
|
params.texturesDistance = false;
|
|
327
291
|
}
|
|
328
|
-
|
|
329
292
|
if (params.showHelpers) {
|
|
330
293
|
var helper = new THREE.CameraHelper(params.camera.clone());
|
|
331
294
|
params.helpers.add(helper);
|
|
@@ -334,19 +297,14 @@ var drawLOD = function drawLOD(scene, camera, settings) {
|
|
|
334
297
|
params.helpers.add(axesHelper);
|
|
335
298
|
}
|
|
336
299
|
}
|
|
337
|
-
|
|
338
300
|
setTexturableElements(params);
|
|
339
|
-
|
|
340
301
|
if (params.texturesFrustum) {
|
|
341
302
|
invalidateOutOfFrustum(params);
|
|
342
303
|
}
|
|
343
|
-
|
|
344
304
|
if (params.texturesDistance) {
|
|
345
305
|
checkDistances(params);
|
|
346
306
|
}
|
|
347
|
-
|
|
348
307
|
updateSceneLods(params);
|
|
349
308
|
};
|
|
350
|
-
|
|
351
309
|
var _default = drawLOD;
|
|
352
310
|
exports.default = _default;
|
package/dist/helpers/index.js
CHANGED
|
@@ -3,26 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.activateAction = activateAction;
|
|
7
|
+
exports.mixWithTalkingClip = exports.getRandomIndex = exports.getObjectPosition = exports.formatMessage = exports.executeCrossFade = exports.cameraFitAnyObject = void 0;
|
|
8
|
+
exports.prepareCrossfade = prepareCrossfade;
|
|
9
|
+
exports.resetActions = resetActions;
|
|
10
|
+
exports.setWeight = exports.screenToVector = exports.roundFloat = void 0;
|
|
11
|
+
exports.syncCrossfade = syncCrossfade;
|
|
12
|
+
exports.zAxis = exports.yAxis = exports.xAxis = exports.vectorTranslateZ = exports.vectorTranslateY = exports.vectorTranslateX = exports.vectorTranslateOnAxis = exports.vectorToScreen = exports.usePrevious = void 0;
|
|
8
13
|
var _react = require("react");
|
|
9
|
-
|
|
10
14
|
var _three = require("three");
|
|
11
|
-
|
|
12
|
-
var _GLTFLoader = require("three/examples/jsm/loaders/GLTFLoader");
|
|
13
|
-
|
|
14
15
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
15
|
-
|
|
16
16
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
|
-
|
|
18
17
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
19
|
-
|
|
20
18
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
21
|
-
|
|
22
19
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
23
|
-
|
|
24
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
25
|
-
|
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
26
21
|
var xAxis = new _three.Vector3(1, 0, 0);
|
|
27
22
|
exports.xAxis = xAxis;
|
|
28
23
|
var yAxis = new _three.Vector3(0, 1, 0);
|
|
@@ -31,8 +26,6 @@ var zAxis = new _three.Vector3(0, 0, 1);
|
|
|
31
26
|
exports.zAxis = zAxis;
|
|
32
27
|
var crossFadeDuration = 0.2;
|
|
33
28
|
var bones = ['Jaw_M', 'Head_M', 'L_lip_jnt', 'HeadEnd_M', 'Neck_M', 'R_lip_jnt', 'joint4', 'transform1', 'lowerTeeths', 'upperTeeths'];
|
|
34
|
-
var loader = new _GLTFLoader.GLTFLoader();
|
|
35
|
-
|
|
36
29
|
var formatMessage = function formatMessage(text) {
|
|
37
30
|
var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
38
31
|
var result = text;
|
|
@@ -41,15 +34,11 @@ var formatMessage = function formatMessage(text) {
|
|
|
41
34
|
});
|
|
42
35
|
return result;
|
|
43
36
|
};
|
|
44
|
-
|
|
45
37
|
exports.formatMessage = formatMessage;
|
|
46
|
-
|
|
47
38
|
var getRandomIndex = function getRandomIndex(length) {
|
|
48
39
|
return Math.floor(Math.random() * length);
|
|
49
40
|
};
|
|
50
|
-
|
|
51
41
|
exports.getRandomIndex = getRandomIndex;
|
|
52
|
-
|
|
53
42
|
var usePrevious = function usePrevious(value) {
|
|
54
43
|
var ref = (0, _react.useRef)();
|
|
55
44
|
(0, _react.useEffect)(function () {
|
|
@@ -57,40 +46,28 @@ var usePrevious = function usePrevious(value) {
|
|
|
57
46
|
}, [value]);
|
|
58
47
|
return ref.current;
|
|
59
48
|
};
|
|
60
|
-
|
|
61
49
|
exports.usePrevious = usePrevious;
|
|
62
|
-
|
|
63
50
|
var vectorTranslateOnAxis = function vectorTranslateOnAxis(axis, amount, object) {
|
|
64
51
|
var result = axis.clone().applyQuaternion(object.quaternion);
|
|
65
52
|
return result.multiplyScalar(amount).clone();
|
|
66
53
|
};
|
|
67
|
-
|
|
68
54
|
exports.vectorTranslateOnAxis = vectorTranslateOnAxis;
|
|
69
|
-
|
|
70
55
|
var vectorTranslateZ = function vectorTranslateZ(amount, object) {
|
|
71
56
|
return vectorTranslateOnAxis(zAxis, amount, object);
|
|
72
57
|
};
|
|
73
|
-
|
|
74
58
|
exports.vectorTranslateZ = vectorTranslateZ;
|
|
75
|
-
|
|
76
59
|
var vectorTranslateX = function vectorTranslateX(amount, object) {
|
|
77
60
|
return vectorTranslateOnAxis(xAxis, amount, object);
|
|
78
61
|
};
|
|
79
|
-
|
|
80
62
|
exports.vectorTranslateX = vectorTranslateX;
|
|
81
|
-
|
|
82
63
|
var vectorTranslateY = function vectorTranslateY(amount, object) {
|
|
83
64
|
return vectorTranslateOnAxis(yAxis, amount, object);
|
|
84
65
|
};
|
|
85
|
-
|
|
86
66
|
exports.vectorTranslateY = vectorTranslateY;
|
|
87
|
-
|
|
88
67
|
var roundFloat = function roundFloat(number, decimals) {
|
|
89
68
|
return parseFloat(number.toFixed(decimals));
|
|
90
69
|
};
|
|
91
|
-
|
|
92
70
|
exports.roundFloat = roundFloat;
|
|
93
|
-
|
|
94
71
|
var cameraFitAnyObject = function cameraFitAnyObject(object, camera) {
|
|
95
72
|
var uOff = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
96
73
|
var controls = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
@@ -118,23 +95,18 @@ var cameraFitAnyObject = function cameraFitAnyObject(object, camera) {
|
|
|
118
95
|
clonedCamera.near = 0.01;
|
|
119
96
|
clonedCamera.updateProjectionMatrix();
|
|
120
97
|
clonedCamera.lookAt(center);
|
|
121
|
-
|
|
122
98
|
if (controls) {
|
|
123
99
|
controls.target = center;
|
|
124
100
|
controls.maxDistance = cameraToFarEdge * 2;
|
|
125
101
|
controls.saveState();
|
|
126
102
|
}
|
|
127
|
-
|
|
128
103
|
if (clone) {
|
|
129
104
|
return clonedCamera;
|
|
130
105
|
}
|
|
131
|
-
|
|
132
106
|
camera.copy(clonedCamera);
|
|
133
107
|
return null;
|
|
134
108
|
};
|
|
135
|
-
|
|
136
109
|
exports.cameraFitAnyObject = cameraFitAnyObject;
|
|
137
|
-
|
|
138
110
|
var getObjectPosition = function getObjectPosition(object, camera, canvas) {
|
|
139
111
|
if (!object) return null;
|
|
140
112
|
var point = new _three.Vector3();
|
|
@@ -144,13 +116,11 @@ var getObjectPosition = function getObjectPosition(object, camera, canvas) {
|
|
|
144
116
|
camera.updateMatrixWorld();
|
|
145
117
|
p.project(camera);
|
|
146
118
|
var clientHeight = canvas.clientHeight,
|
|
147
|
-
|
|
119
|
+
clientWidth = canvas.clientWidth;
|
|
148
120
|
var position = new _three.Vector2((p.x * clientWidth + clientWidth) / 2, (-p.y * clientHeight + clientHeight) / 2);
|
|
149
121
|
return position;
|
|
150
122
|
};
|
|
151
|
-
|
|
152
123
|
exports.getObjectPosition = getObjectPosition;
|
|
153
|
-
|
|
154
124
|
var vectorToScreen = function vectorToScreen(vector, camera) {
|
|
155
125
|
var width = window.innerWidth;
|
|
156
126
|
var height = window.innerHeight;
|
|
@@ -162,84 +132,85 @@ var vectorToScreen = function vectorToScreen(vector, camera) {
|
|
|
162
132
|
pos.y = -(pos.y * heightHalf) + heightHalf;
|
|
163
133
|
return pos;
|
|
164
134
|
};
|
|
165
|
-
|
|
166
135
|
exports.vectorToScreen = vectorToScreen;
|
|
167
|
-
|
|
168
136
|
var screenToVector = function screenToVector(vector, camera) {
|
|
169
137
|
var clone = vector.clone();
|
|
170
138
|
clone.z = -1;
|
|
171
139
|
return clone.unproject(camera);
|
|
172
140
|
};
|
|
173
|
-
|
|
174
141
|
exports.screenToVector = screenToVector;
|
|
175
|
-
|
|
176
142
|
var setWeight = function setWeight(action, weight) {
|
|
177
143
|
action.enabled = true;
|
|
178
144
|
action.setEffectiveTimeScale(1);
|
|
179
145
|
action.setEffectiveWeight(weight);
|
|
180
146
|
};
|
|
181
|
-
|
|
147
|
+
exports.setWeight = setWeight;
|
|
148
|
+
function activateAction(action, weight) {
|
|
149
|
+
setWeight(action, weight);
|
|
150
|
+
action.play();
|
|
151
|
+
}
|
|
152
|
+
function prepareCrossfade(root, startAction, endAction) {
|
|
153
|
+
var mixer = root.userData.mixer;
|
|
154
|
+
if (!startAction || !endAction) {
|
|
155
|
+
executeCrossFade(startAction, endAction);
|
|
156
|
+
} else {
|
|
157
|
+
syncCrossfade(mixer, startAction, endAction);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function syncCrossfade(mixer, startAction, endAction) {
|
|
161
|
+
mixer.addEventListener('loop', onLoopFinished);
|
|
162
|
+
function onLoopFinished(event) {
|
|
163
|
+
if (event.action === startAction) {
|
|
164
|
+
mixer.removeEventListener('loop', onLoopFinished);
|
|
165
|
+
executeCrossFade(startAction, endAction);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function resetActions(mixer, active) {
|
|
170
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
171
|
+
mixer._actions.forEach(function (action) {
|
|
172
|
+
if (action !== active) {
|
|
173
|
+
action.fadeOut(crossFadeDuration);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
182
177
|
var executeCrossFade = function executeCrossFade(startAction, endAction) {
|
|
183
|
-
if (
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
178
|
+
if (endAction) {
|
|
179
|
+
setWeight(endAction, 1);
|
|
180
|
+
endAction.time = 0;
|
|
181
|
+
if (startAction) {
|
|
182
|
+
startAction.syncWith(endAction);
|
|
183
|
+
startAction.crossFadeTo(endAction, crossFadeDuration, true);
|
|
184
|
+
} else {
|
|
185
|
+
endAction.fadeIn(crossFadeDuration);
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
startAction.fadeOut(crossFadeDuration);
|
|
189
|
+
}
|
|
191
190
|
};
|
|
192
|
-
|
|
193
191
|
exports.executeCrossFade = executeCrossFade;
|
|
194
|
-
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
var onLoad = function onLoad(anim) {
|
|
204
|
-
var talkingClip = anim === null || anim === void 0 ? void 0 : anim.animations[0];
|
|
205
|
-
|
|
206
|
-
if (talkingClip) {
|
|
207
|
-
var _cloned$tracks;
|
|
208
|
-
|
|
209
|
-
tracks = talkingClip.tracks.filter(function (track) {
|
|
210
|
-
return bones.find(function (bone) {
|
|
211
|
-
return track.name.includes(bone);
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
cloned.tracks = cloned.tracks.filter(function (track) {
|
|
215
|
-
return !bones.find(function (bone) {
|
|
216
|
-
return track.name.includes(bone);
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
(_cloned$tracks = cloned.tracks).push.apply(_cloned$tracks, _toConsumableArray(tracks));
|
|
221
|
-
|
|
222
|
-
target.userData.emotionClip = cloned;
|
|
223
|
-
cloned.resetDuration();
|
|
224
|
-
var talkingSubClip = cloned;
|
|
225
|
-
|
|
226
|
-
if (cloned.duration > 4) {
|
|
227
|
-
talkingSubClip = _three.AnimationUtils.subclip(cloned, 'shortTalking', 0, 120, 30);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
var defaultAction = mixer.clipAction(defaultAnim, target);
|
|
231
|
-
var emotionAction = mixer.clipAction(talkingSubClip, target);
|
|
232
|
-
emotionAction.loop = _three.LoopPingPong;
|
|
233
|
-
mixer.stopAllAction();
|
|
234
|
-
target.isTalking = true;
|
|
235
|
-
executeCrossFade(defaultAction, emotionAction, crossFadeDuration);
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
loader.load(talkingURL, function (anim) {
|
|
240
|
-
onLoad(anim);
|
|
192
|
+
var mixWithTalkingClip = function mixWithTalkingClip(target, talking, action) {
|
|
193
|
+
var _cloned$tracks;
|
|
194
|
+
var mixer = target.userData.mixer;
|
|
195
|
+
var talkingClip = talking.clone();
|
|
196
|
+
var cloned = action.clone();
|
|
197
|
+
var tracks = talkingClip.tracks.filter(function (track) {
|
|
198
|
+
return bones.find(function (bone) {
|
|
199
|
+
return track.name.includes(bone);
|
|
241
200
|
});
|
|
201
|
+
});
|
|
202
|
+
cloned.tracks = cloned.tracks.filter(function (track) {
|
|
203
|
+
return !bones.find(function (bone) {
|
|
204
|
+
return track.name.includes(bone);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
(_cloned$tracks = cloned.tracks).push.apply(_cloned$tracks, _toConsumableArray(tracks));
|
|
208
|
+
cloned.resetDuration();
|
|
209
|
+
var clip = cloned;
|
|
210
|
+
clip.name = "".concat(cloned.name, "_talking");
|
|
211
|
+
if (cloned.duration > 4) {
|
|
212
|
+
clip = _three.AnimationUtils.subclip(cloned, clip.name, 0, 120, 30);
|
|
242
213
|
}
|
|
214
|
+
return mixer.clipAction(clip, target);
|
|
243
215
|
};
|
|
244
|
-
|
|
245
|
-
exports.executeTalkingAnimation = executeTalkingAnimation;
|
|
216
|
+
exports.mixWithTalkingClip = mixWithTalkingClip;
|