Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

Commit 5f13a2b

Browse files
committed
feat(config): new config
1 parent cb6f7d9 commit 5f13a2b

File tree

7 files changed

+60
-83
lines changed

7 files changed

+60
-83
lines changed

src/SettingsTip.txt

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/cDefine.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@
55
*/
66

77
var cDefine = {
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-
// #63
13-
// DEBUG_DRAW_HIT_AREA : false, // # 63
14-
// DEBUG_DRAW_ALPHA_MODEL : false, // #63
15-
168
// above are viewMatrix value settings
179
VIEW_LOGICAL_LEFT : -1, // -1, the left abscissa of viewMatrix
1810
VIEW_LOGICAL_RIGHT : 1, // 1, the right abscissa of viewMatrix

src/cLive2DApp.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
DrawDataID,
1515
BaseDataID,
1616
ParamID
17-
} from './lib/live2d.core';*/
17+
} from './lib/live2d.min';*/
1818
import './lib/live2d.min.js';
1919
import { createCanvas, initCanvas } from "./lib/canvasManager";
2020
import { device } from 'current-device';
@@ -41,6 +41,7 @@ let opacityHover = 1;
4141

4242
export default () => {
4343
console.log('Finally!~');
44+
Live2D.init();
4445
/*
4546
headPos = typeof iHeadPos === 'undefined' ? 0.5 : iHeadPos;
4647
opacityDefault = typeof iOpacityDefault === 'undefined' ? 0.7 : iOpacityDefault;

src/index.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
// Celebrate for the 3.0 version! //
55
////////////////////////////////////
66

7+
// Created by xiazeyu.
8+
79
/**
810
* @description The entry file
911
*/
@@ -12,32 +14,31 @@
1214

1315
import device from 'current-device';
1416
import config from './lib/configManager.js';
17+
1518
/**
1619
* The public entry point
1720
* @param {Object} userConfig User's config
1821
*/
1922

20-
function getWebPackPublicPath(){
21-
let runtimePublicPath;
22-
__webpack_public_path__ = runtimePublicPath;
23-
}
24-
2523
export function init(userConfig){
24+
2625
if (process.env.NODE_ENV === 'development') {
27-
console.log('Hey that, you are now in DEV.');
28-
}/*
26+
console.log('Hey that, you are now in DEV MODE.');
27+
}
2928
try{
30-
config.checkConfig(userConfig);
29+
config.applyConfig(userConfig);
3130
}catch(err){
3231
console.error(err);
3332
}
34-
config.applyConfig(userConfig);
33+
3534
if((!config.options.mobile.show)&&(device.mobile())){
3635
return;
37-
}*/
36+
}
37+
3838
import(/* webpackMode: "lazy" */ './cLive2DApp').then(_ => {
3939
_.default();
4040
}).catch(err => {
4141
console.error(err);
4242
});
43+
4344
}

src/lib/configManager.js

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,49 @@
1-
// Modified by xiazeyu.
1+
// Created by xiazeyu.
22

33
/**
44
* @description The container of configeration.
55
*/
66

77

8-
class Config{
9-
constructor(
10-
modelPath, modelWidth, modelHeight,
11-
modelScaling, AASetting, mobileShow,
12-
mobileScaling, position, horizontalOffset,
13-
verticalOffset, horizontalHeadPos, verticalHeadPos,
14-
opacityDefault, opacityHover, canvasID,
15-
divID,
16-
){};
17-
}
18-
19-
/**
20-
* default options
21-
* @type {Object}
22-
* @param {[type]} [varname] [description]
23-
*/
24-
25-
const defaultOptions = {
26-
modelPath: 'https://raw.githubusercontent.com/EYHN/hexo-helper-live2d/master/assets/z16/z16.model.json',
27-
modelWidth: 150,
28-
modelHeight: 300,
29-
modelScaling: 1,
30-
AASetting: 2,
31-
mobileShow: true,
32-
mobileScaling: 0.5,
33-
position: 'right',
34-
horizontalOffset: 0,
35-
verticalOffset: -20,
36-
horizontalHeadPos: 0.5,
37-
verticalHeadPos: 0.618,
38-
opacityDefault: 0.7,
39-
opacityHover: 0.1,
40-
canvasID: 'live2DCanvas',
41-
divID: 'hexo-helper-live2d'
42-
}
43-
448
let currConfig = {};
459

46-
function checkUserConfig(inUserConfig){
47-
if(( this.position != 'left' ) && ( this.position != 'right' )){
48-
console.error('L2D: Invalid position setting');
49-
}
10+
const defaultOptions = {
11+
model: {
12+
jsonPath: '',
13+
hHeadPos: 0.5, // horizontalHeadPos
14+
vHeadPos: 0.618, // verticalHeadPos
15+
myDefine: {},
16+
},
17+
display: {
18+
AA: 2, // antialiasing Grade 抗锯齿等级
19+
widght: 150,
20+
height: 300,
21+
scale: 1,
22+
position: 'right',
23+
hOffset: 0, // horizontalOffset
24+
vOffset: -20, // verticalOffset
25+
},
26+
mobile: {
27+
show: true,
28+
scale: 0.5,
29+
motion: false,
30+
},
31+
name: {
32+
canvas: 'live2dcanvas',
33+
div: 'live2d-widget',
34+
},
35+
react: {
36+
opacityDefault: 0.7,
37+
opacityOnHover: 0.2,
38+
myFunc: () => {console.log('(undefined) ┑( ̄Д  ̄)┍');},
39+
messageFunc: () => {console.log('(undefined) ┑( ̄Д  ̄)┍');},
40+
},
41+
debug: {
42+
log: false,
43+
mouseLog: false,
44+
mouseFunc: () => {console.log('(undefined) ┑( ̄Д  ̄)┍');}, // only works when debug.mouseLog is on
45+
},
46+
checked: false,
5047
}
5148

5249
function applyConfig(inUserConfig){
@@ -58,7 +55,12 @@ function applyConfig(inUserConfig){
5855
);
5956
}
6057

61-
export {/*
58+
function checkUserConfig(inUserConfig){
59+
if(( this.position != 'left' ) && ( this.position != 'right' )){
60+
console.error('L2D: Invalid position setting');
61+
}
62+
}
63+
export {
6264
applyConfig,
63-
currConfig,*/
65+
currConfig,
6466
}

src/lib/live2d.core.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
2-
* @description Shimming for Live2D core library
3-
* https://doc.webpack-china.org/guides/shimming/
2+
* @description Fix global expose for Live2D core library
43
*/
54

65

webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ module.exports = env => {return{
8484
options: {
8585
minimize: true,
8686
},
87-
}],
87+
}],
8888
},
8989
]
9090
},

0 commit comments

Comments
 (0)