Skip to content

Commit 1bb202f

Browse files
Rebuild
1 parent ef1f177 commit 1bb202f

File tree

13 files changed

+273
-351
lines changed

13 files changed

+273
-351
lines changed

build/cubism2/LAppLive2DManager.js

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3-
return new (P || (P = Promise))(function (resolve, reject) {
4-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7-
step((generator = generator.apply(thisArg, _arguments || [])).next());
8-
});
9-
};
101
import { Live2DFramework } from './Live2DFramework.js';
112
import LAppModel from './LAppModel.js';
123
import PlatformManager from './PlatformManager.js';
@@ -28,40 +19,36 @@ class LAppLive2DManager {
2819
this.model = null;
2920
}
3021
}
31-
changeModel(gl, modelSettingPath) {
32-
return __awaiter(this, void 0, void 0, function* () {
33-
return new Promise((resolve, reject) => {
34-
if (this.reloading)
35-
return;
36-
this.reloading = true;
37-
const oldModel = this.model;
38-
const newModel = new LAppModel();
39-
newModel.load(gl, modelSettingPath, () => {
40-
if (oldModel) {
41-
oldModel.release(gl);
42-
}
43-
this.model = newModel;
44-
this.reloading = false;
45-
resolve();
46-
});
47-
});
48-
});
49-
}
50-
changeModelWithJSON(gl, modelSettingPath, modelSetting) {
51-
return __awaiter(this, void 0, void 0, function* () {
22+
async changeModel(gl, modelSettingPath) {
23+
return new Promise((resolve, reject) => {
5224
if (this.reloading)
5325
return;
5426
this.reloading = true;
5527
const oldModel = this.model;
5628
const newModel = new LAppModel();
57-
yield newModel.loadModelSetting(modelSettingPath, modelSetting);
58-
if (oldModel) {
59-
oldModel.release(gl);
60-
}
61-
this.model = newModel;
62-
this.reloading = false;
29+
newModel.load(gl, modelSettingPath, () => {
30+
if (oldModel) {
31+
oldModel.release(gl);
32+
}
33+
this.model = newModel;
34+
this.reloading = false;
35+
resolve();
36+
});
6337
});
6438
}
39+
async changeModelWithJSON(gl, modelSettingPath, modelSetting) {
40+
if (this.reloading)
41+
return;
42+
this.reloading = true;
43+
const oldModel = this.model;
44+
const newModel = new LAppModel();
45+
await newModel.loadModelSetting(modelSettingPath, modelSetting);
46+
if (oldModel) {
47+
oldModel.release(gl);
48+
}
49+
this.model = newModel;
50+
this.reloading = false;
51+
}
6552
setDrag(x, y) {
6653
if (this.model) {
6754
this.model.setDrag(x, y);

build/cubism2/LAppModel.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3-
return new (P || (P = Promise))(function (resolve, reject) {
4-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7-
step((generator = generator.apply(thisArg, _arguments || [])).next());
8-
});
9-
};
101
import { L2DBaseModel, Live2DFramework, L2DEyeBlink } from './Live2DFramework.js';
112
import ModelSettingJson from './utils/ModelSettingJson.js';
123
import LAppDefine from './LAppDefine.js';
@@ -97,15 +88,13 @@ class LAppModel extends L2DBaseModel {
9788
}
9889
});
9990
}
100-
loadModelSetting(modelSettingPath, modelSetting) {
101-
return __awaiter(this, void 0, void 0, function* () {
102-
this.setUpdating(true);
103-
this.setInitialized(false);
104-
this.modelHomeDir = modelSettingPath.substring(0, modelSettingPath.lastIndexOf('/') + 1);
105-
this.modelSetting = new ModelSettingJson();
106-
this.modelSetting.json = modelSetting;
107-
yield new Promise(resolve => this.loadJSON(resolve));
108-
});
91+
async loadModelSetting(modelSettingPath, modelSetting) {
92+
this.setUpdating(true);
93+
this.setInitialized(false);
94+
this.modelHomeDir = modelSettingPath.substring(0, modelSettingPath.lastIndexOf('/') + 1);
95+
this.modelSetting = new ModelSettingJson();
96+
this.modelSetting.json = modelSetting;
97+
await new Promise(resolve => this.loadJSON(resolve));
10998
}
11099
load(gl, modelSettingPath, callback) {
111100
this.setUpdating(true);
@@ -231,10 +220,10 @@ class LAppModel extends L2DBaseModel {
231220
}
232221
}
233222
setExpression(name) {
234-
var _a;
223+
var _b;
235224
const motion = this.expressions[name];
236225
logger.trace('Expression : ' + name);
237-
(_a = this.expressionManager) === null || _a === void 0 ? void 0 : _a.startMotion(motion, false);
226+
(_b = this.expressionManager) === null || _b === void 0 ? void 0 : _b.startMotion(motion, false);
238227
}
239228
draw(gl) {
240229
MatrixStack.push();

build/cubism2/index.js

Lines changed: 37 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3-
return new (P || (P = Promise))(function (resolve, reject) {
4-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7-
step((generator = generator.apply(thisArg, _arguments || [])).next());
8-
});
9-
};
101
import { L2DMatrix44, L2DTargetPoint, L2DViewMatrix } from './Live2DFramework.js';
112
import LAppDefine from './LAppDefine.js';
123
import MatrixStack from './utils/MatrixStack.js';
@@ -60,37 +51,35 @@ class Cubism2Model {
6051
this.canvas.addEventListener('touchmove', this._boundTouchEvent, false);
6152
}
6253
}
63-
init(canvasId, modelSettingPath, modelSetting) {
64-
return __awaiter(this, void 0, void 0, function* () {
65-
this.initL2dCanvas(canvasId);
66-
const width = this.canvas.width;
67-
const height = this.canvas.height;
68-
this.dragMgr = new L2DTargetPoint();
69-
const ratio = height / width;
70-
const left = LAppDefine.VIEW_LOGICAL_LEFT;
71-
const right = LAppDefine.VIEW_LOGICAL_RIGHT;
72-
const bottom = -ratio;
73-
const top = ratio;
74-
this.viewMatrix = new L2DViewMatrix();
75-
this.viewMatrix.setScreenRect(left, right, bottom, top);
76-
this.viewMatrix.setMaxScreenRect(LAppDefine.VIEW_LOGICAL_MAX_LEFT, LAppDefine.VIEW_LOGICAL_MAX_RIGHT, LAppDefine.VIEW_LOGICAL_MAX_BOTTOM, LAppDefine.VIEW_LOGICAL_MAX_TOP);
77-
this.viewMatrix.setMaxScale(LAppDefine.VIEW_MAX_SCALE);
78-
this.viewMatrix.setMinScale(LAppDefine.VIEW_MIN_SCALE);
79-
this.projMatrix = new L2DMatrix44();
80-
this.projMatrix.multScale(1, width / height);
81-
this.deviceToScreen = new L2DMatrix44();
82-
this.deviceToScreen.multTranslate(-width / 2.0, -height / 2.0);
83-
this.deviceToScreen.multScale(2 / width, -2 / width);
84-
this.gl = this.canvas.getContext('webgl2', { premultipliedAlpha: true, preserveDrawingBuffer: true });
85-
if (!this.gl) {
86-
logger.error('Failed to create WebGL context.');
87-
return;
88-
}
89-
Live2D.setGL(this.gl);
90-
this.gl.clearColor(0.0, 0.0, 0.0, 0.0);
91-
yield this.changeModelWithJSON(modelSettingPath, modelSetting);
92-
this.startDraw();
93-
});
54+
async init(canvasId, modelSettingPath, modelSetting) {
55+
this.initL2dCanvas(canvasId);
56+
const width = this.canvas.width;
57+
const height = this.canvas.height;
58+
this.dragMgr = new L2DTargetPoint();
59+
const ratio = height / width;
60+
const left = LAppDefine.VIEW_LOGICAL_LEFT;
61+
const right = LAppDefine.VIEW_LOGICAL_RIGHT;
62+
const bottom = -ratio;
63+
const top = ratio;
64+
this.viewMatrix = new L2DViewMatrix();
65+
this.viewMatrix.setScreenRect(left, right, bottom, top);
66+
this.viewMatrix.setMaxScreenRect(LAppDefine.VIEW_LOGICAL_MAX_LEFT, LAppDefine.VIEW_LOGICAL_MAX_RIGHT, LAppDefine.VIEW_LOGICAL_MAX_BOTTOM, LAppDefine.VIEW_LOGICAL_MAX_TOP);
67+
this.viewMatrix.setMaxScale(LAppDefine.VIEW_MAX_SCALE);
68+
this.viewMatrix.setMinScale(LAppDefine.VIEW_MIN_SCALE);
69+
this.projMatrix = new L2DMatrix44();
70+
this.projMatrix.multScale(1, width / height);
71+
this.deviceToScreen = new L2DMatrix44();
72+
this.deviceToScreen.multTranslate(-width / 2.0, -height / 2.0);
73+
this.deviceToScreen.multScale(2 / width, -2 / width);
74+
this.gl = this.canvas.getContext('webgl2', { premultipliedAlpha: true, preserveDrawingBuffer: true });
75+
if (!this.gl) {
76+
logger.error('Failed to create WebGL context.');
77+
return;
78+
}
79+
Live2D.setGL(this.gl);
80+
this.gl.clearColor(0.0, 0.0, 0.0, 0.0);
81+
await this.changeModelWithJSON(modelSettingPath, modelSetting);
82+
this.startDraw();
9483
}
9584
destroy() {
9685
if (this.canvas) {
@@ -148,15 +137,11 @@ class Cubism2Model {
148137
}
149138
MatrixStack.pop();
150139
}
151-
changeModel(modelSettingPath) {
152-
return __awaiter(this, void 0, void 0, function* () {
153-
yield this.live2DMgr.changeModel(this.gl, modelSettingPath);
154-
});
140+
async changeModel(modelSettingPath) {
141+
await this.live2DMgr.changeModel(this.gl, modelSettingPath);
155142
}
156-
changeModelWithJSON(modelSettingPath, modelSetting) {
157-
return __awaiter(this, void 0, void 0, function* () {
158-
yield this.live2DMgr.changeModelWithJSON(this.gl, modelSettingPath, modelSetting);
159-
});
143+
async changeModelWithJSON(modelSettingPath, modelSetting) {
144+
await this.live2DMgr.changeModelWithJSON(this.gl, modelSettingPath, modelSetting);
160145
}
161146
modelScaling(scale) {
162147
const isMaxScale = this.viewMatrix.isMaxScale();
@@ -174,7 +159,7 @@ class Cubism2Model {
174159
}
175160
}
176161
modelTurnHead(event) {
177-
var _a;
162+
var _b;
178163
const rect = this.canvas.getBoundingClientRect();
179164
const { vx, vy } = normalizePoint(event.clientX, event.clientY, rect.left + rect.width / 2, rect.top + rect.height / 2, window.innerWidth, window.innerHeight);
180165
logger.trace('onMouseDown device( x:' +
@@ -188,12 +173,12 @@ class Cubism2Model {
188173
')');
189174
this.dragMgr.setPoint(vx, vy);
190175
this.live2DMgr.tapEvent(vx, vy);
191-
if ((_a = this.live2DMgr) === null || _a === void 0 ? void 0 : _a.model.hitTest(LAppDefine.HIT_AREA_BODY, vx, vy)) {
176+
if ((_b = this.live2DMgr) === null || _b === void 0 ? void 0 : _b.model.hitTest(LAppDefine.HIT_AREA_BODY, vx, vy)) {
192177
window.dispatchEvent(new Event('live2d:tapbody'));
193178
}
194179
}
195180
followPointer(event) {
196-
var _a;
181+
var _b;
197182
const rect = this.canvas.getBoundingClientRect();
198183
const { vx, vy } = normalizePoint(event.clientX, event.clientY, rect.left + rect.width / 2, rect.top + rect.height / 2, window.innerWidth, window.innerHeight);
199184
logger.trace('onMouseMove device( x:' +
@@ -206,7 +191,7 @@ class Cubism2Model {
206191
vy +
207192
')');
208193
this.dragMgr.setPoint(vx, vy);
209-
if ((_a = this.live2DMgr) === null || _a === void 0 ? void 0 : _a.model.hitTest(LAppDefine.HIT_AREA_BODY, vx, vy)) {
194+
if ((_b = this.live2DMgr) === null || _b === void 0 ? void 0 : _b.model.hitTest(LAppDefine.HIT_AREA_BODY, vx, vy)) {
210195
window.dispatchEvent(new Event('live2d:hoverbody'));
211196
}
212197
}

build/message.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ function welcomeMessage(time, welcomeTemplate, referrerTemplate) {
4444
}
4545
function i18n(template, ...args) {
4646
return template.replace(/\$(\d+)/g, (_, idx) => {
47-
var _a;
47+
var _b;
4848
const i = parseInt(idx, 10) - 1;
49-
return (_a = args[i]) !== null && _a !== void 0 ? _a : '';
49+
return (_b = args[i]) !== null && _b !== void 0 ? _b : '';
5050
});
5151
}
5252
export { showMessage, welcomeMessage, i18n };

0 commit comments

Comments
 (0)