Skip to content
This repository was archived by the owner on Jan 27, 2021. It is now read-only.

Commit c91c71f

Browse files
committed
docs: added comments
re #60
1 parent e17287a commit c91c71f

File tree

8 files changed

+85
-234
lines changed

8 files changed

+85
-234
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
# hexo-helper-live2d
1919

20-
# Important! 3.0 is under developement, informations below CANNOT WORK PROPERLY. Please visit https://www.npmjs.com/package/hexo-helper-live2d for USEABLE VERSION.
21-
2220
[简体中文文档](./README.zh-CN.md)
2321

2422
<br>

README.zh-CN.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
# hexo-helper-live2d
1919

20-
# 3.0 正在开发,以下内容无法使用,请访问 https://www.npmjs.com/package/hexo-helper-live2d 获取来可用版本。
21-
2220
[English README](./README.md) by [@gwzz](https://github.com/gwzz) & [@xiazeyu](https://github.com/xiazeyu)
2321

2422
<br>

src/L2DMatrix44Study.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[tr]
2+
0:ScaleX
3+
1:
4+
2:scale
5+
3:
6+
4:
7+
5:ScaleY
8+
6:
9+
7:
10+
8:
11+
9:
12+
10:
13+
11:
14+
12:shiftX(translateX)
15+
13:shiftY(translateY)
16+
14:
17+
15:

src/cDefine.js

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,41 @@
55
*/
66

77
var cDefine = {
8-
9-
DEBUG_LOG : false,
10-
DEBUG_MOUSE_LOG : false,
11-
// DEBUG_DRAW_HIT_AREA : false,
12-
// DEBUG_DRAW_ALPHA_MODEL : false,
13-
14-
15-
VIEW_MAX_SCALE : 2, // 2
16-
VIEW_MIN_SCALE : 0.8, // 0.8
17-
18-
VIEW_LOGICAL_LEFT : -1, // -1
19-
VIEW_LOGICAL_RIGHT : 1, // 1
20-
21-
VIEW_LOGICAL_MAX_LEFT : -2, // -2
22-
VIEW_LOGICAL_MAX_RIGHT : 2, // 2
23-
VIEW_LOGICAL_MAX_BOTTOM : -2, // -2
24-
VIEW_LOGICAL_MAX_TOP : 2, // 2
25-
26-
27-
PRIORITY_NONE : 0, // 0
28-
PRIORITY_IDLE : 1, // 1
29-
PRIORITY_NORMAL : 2, // 2
30-
PRIORITY_FORCE : 3, // 3
31-
32-
MOTION_GROUP_IDLE : "idle",
33-
MOTION_GROUP_TAP_BODY : "tap_body",
34-
MOTION_GROUP_FLICK_HEAD : "flick_head",
35-
MOTION_GROUP_PINCH_IN : "pinch_in",
36-
MOTION_GROUP_PINCH_OUT : "pinch_out",
37-
MOTION_GROUP_SHAKE : "shake",
38-
39-
40-
HIT_AREA_HEAD : "head",
41-
HIT_AREA_BODY : "body"
42-
8+
// above are output log settings
9+
DEBUG_LOG : false, // false, output events
10+
DEBUG_MOUSE_LOG : false, // false, output mouse tracking
11+
// These two commented definitions havn't been achieved yet.
12+
//
13+
// DEBUG_DRAW_HIT_AREA : false, // # 63
14+
// DEBUG_DRAW_ALPHA_MODEL : false, // #63
15+
16+
// above are viewMatrix value settings
17+
VIEW_LOGICAL_LEFT : -1, // -1, the left abscissa of viewMatrix
18+
VIEW_LOGICAL_RIGHT : 1, // 1, the right abscissa of viewMatrix
19+
VIEW_LOGICAL_MAX_LEFT : -2, // -2, the max left abscissa of viewMatrix
20+
VIEW_LOGICAL_MAX_RIGHT : 2, // 2, the max right abscissa of viewMatrix
21+
VIEW_LOGICAL_MAX_BOTTOM : -2, // -2, the max bottom abscissa of viewMatrix
22+
VIEW_LOGICAL_MAX_TOP : 2, // 2, the max top abscissa of viewMatrix
23+
24+
// above are the motions priority settings.
25+
PRIORITY_NONE : 0, // 0,do nothing
26+
PRIORITY_IDLE : 1, // 1, idle motions
27+
PRIORITY_NORMAL : 2, // 2, normal motions
28+
PRIORITY_FORCE : 3, // 3, force to show motion
29+
30+
// above are the index to the motions in model.json
31+
// #43
32+
MOTION_GROUP_IDLE : "idle",
33+
MOTION_GROUP_TAP_BODY : "tap_body",
34+
MOTION_GROUP_FLICK_HEAD : "flick_head", // unused
35+
MOTION_GROUP_PINCH_IN : "pinch_in", // unused
36+
MOTION_GROUP_PINCH_OUT : "pinch_out", // unused
37+
MOTION_GROUP_SHAKE : "shake", // unused
38+
39+
// above are the index to the hit areas in model.json
40+
// #43
41+
HIT_AREA_HEAD : "head",
42+
HIT_AREA_BODY : "body"
4343
};
4444

4545
module.exports = cDefine;

src/cLive2DApp.js

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let headPos = 0.5;
2222
let opacityDefault = 0.7;
2323
let opacityHover = 1;
2424

25-
export function loadlive2d(iID, iModelUrl, iHeadPos, iOpacityDefault, iOpacityHover) {
25+
export function loadlive2d(settings) {
2626
headPos = typeof iHeadPos === 'undefined' ? 0.5 : iHeadPos;
2727
opacityDefault = typeof iOpacityDefault === 'undefined' ? 0.7 : iOpacityDefault;
2828
opacityHover = typeof iOpacityHover === 'undefined' ? 1 : iOpacityHover;
@@ -39,15 +39,15 @@ function init(modelUrl) {
3939
let width = canvas.width;
4040
let height = canvas.height;
4141
// 以下为实际显示大小
42-
// let sWidth = parseInt(canvas.style.width);
43-
// let sHeight = parseInt(canvas.style.height);
42+
// #32
43+
let sWidth = parseInt(canvas.style.width);
44+
let sHeight = parseInt(canvas.style.height);
4445

4546
dragMgr = new L2DTargetPoint();
46-
// 绘图相关..暂时看不懂
4747
let ratio = height / width;
4848
let left = cDefine.VIEW_LOGICAL_LEFT;
4949
let right = cDefine.VIEW_LOGICAL_RIGHT;
50-
let bottom = -ratio;
50+
let bottom = -(ratio);
5151
let top = ratio;
5252

5353
viewMatrix = new L2DViewMatrix();
@@ -58,20 +58,19 @@ function init(modelUrl) {
5858
cDefine.VIEW_LOGICAL_MAX_RIGHT,
5959
cDefine.VIEW_LOGICAL_MAX_BOTTOM,
6060
cDefine.VIEW_LOGICAL_MAX_TOP);
61-
// 这2行可能没用
62-
viewMatrix.setMaxScale(cDefine.VIEW_MAX_SCALE);
63-
viewMatrix.setMinScale(cDefine.VIEW_MIN_SCALE);
6461

6562
projMatrix = new L2DMatrix44();
6663
projMatrix.multScale(1, (width / height));
6764

6865
deviceToScreen = new L2DMatrix44();
69-
deviceToScreen.multTranslate(-width / 2.0, -height / 2.0);
70-
deviceToScreen.multScale(2 / width, -2 / width);
66+
// deviceToScreen.multTranslate(-width / 2.0, -height / 2.0); // old codes
67+
// deviceToScreen.multScale(2 / width, -2 / width); // old codes
68+
deviceToScreen.multTranslate(-sWidth / 2.0, -sHeight / 2.0); // #32
69+
deviceToScreen.multScale(2 / sWidth, -2 / sHeight); // #32
7170

7271
gl = getWebGLContext();
7372
setContext(gl);
74-
if (!gl) { // 检测是否成功创造WebGL元素
73+
if (!gl) { // Check if WebGL element is created successfully.
7574
console.error("Failed to create WebGL context.");
7675
if(!window.WebGLRenderingContext){
7776
console.error("Your browser don't support WebGL, check https://get.webgl.org/ for futher information.");
@@ -134,31 +133,11 @@ function changeModel(modelurl) // 更换模型
134133
live2DMgr.count++; // 现在仍有多模型支持,稍后可以精简
135134
live2DMgr.changeModel(gl, modelurl);
136135
}
137-
/*
138-
function modelScaling(scale)
139-
{
140-
let isMaxScale = viewMatrix.isMaxScale();
141-
let isMinScale = viewMatrix.isMinScale();
142136

143-
viewMatrix.adjustScale(0, 0, scale);
144-
145-
if (!isMaxScale)
146-
{
147-
if (viewMatrix.isMaxScale())
148-
{
149-
live2DMgr.maxScaleEvent();
150-
}
151-
}
152-
153-
if (!isMinScale)
154-
{
155-
if (viewMatrix.isMinScale())
156-
{
157-
live2DMgr.minScaleEvent();
158-
}
159-
}
137+
function modelScaling(scale) {
138+
viewMatrix.adjustScale(0, 0, scale);
160139
}
161-
*//*
140+
/*
162141
function transformRange(center, transform, range)
163142
{
164143
let a = {

src/cManager.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -73,30 +73,6 @@ cManager.prototype.setDrag = function (x, y) {
7373
}
7474
}
7575

76-
77-
78-
cManager.prototype.maxScaleEvent = function () {
79-
if (cDefine.DEBUG_LOG)
80-
console.log("Max scale event.");
81-
for (var i = 0; i < this.models.length; i++) {
82-
this.models[i].startRandomMotion(cDefine.MOTION_GROUP_PINCH_IN,
83-
cDefine.PRIORITY_NORMAL);
84-
}
85-
}
86-
87-
88-
89-
cManager.prototype.minScaleEvent = function () {
90-
if (cDefine.DEBUG_LOG)
91-
console.log("Min scale event.");
92-
for (var i = 0; i < this.models.length; i++) {
93-
this.models[i].startRandomMotion(cDefine.MOTION_GROUP_PINCH_OUT,
94-
cDefine.PRIORITY_NORMAL);
95-
}
96-
}
97-
98-
99-
10076
cManager.prototype.tapEvent = function (x, y) {
10177
if (cDefine.DEBUG_LOG)
10278
console.log("tapEvent view x:" + x + " y:" + y);

0 commit comments

Comments
 (0)