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

Commit 62555a9

Browse files
committed
feat: marked unfinished files, rebuild file structure, config works
1 parent be5531d commit 62555a9

21 files changed

+76
-75
lines changed
File renamed without changes.
File renamed without changes.

src/cLive2DApp.js renamed to src/_cLive2DApp.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
DrawDataID,
1515
BaseDataID,
1616
ParamID
17-
} from './lib/live2d.min';*/
17+
} from './lib/live2d.min';*//*
1818
import './lib/live2d.min.js';
19-
import { config }from './lib/configManager.js';
2019
import { createCanvas, initCanvas } from "./lib/canvasManager";
2120
import { device } from 'current-device';
2221
import { L2DTargetPoint, L2DViewMatrix, L2DMatrix44 } from "./lib/Live2DFramework";
@@ -39,8 +38,13 @@ let lastMouseY = 0;
3938
let headPos = 0.5;
4039
let opacityDefault = 0.7;
4140
let opacityHover = 1;
41+
*/
42+
43+
import { config }from './config/configMgr.js';
4244

4345
export default () => {
46+
console.log('config:');
47+
console.log(config);
4448
/*
4549
headPos = typeof iHeadPos === 'undefined' ? 0.5 : iHeadPos;
4650
opacityDefault = typeof iOpacityDefault === 'undefined' ? 0.7 : iOpacityDefault;
@@ -348,15 +352,7 @@ function lookFront()
348352
function mouseEvent(e)
349353
{
350354
//e.preventDefault();
351-
if (e.type == "mousewheel") {
352-
// if (e.clientX < 0 || canvas.clientWidth < e.clientX ||
353-
// e.clientY < 0 || canvas.clientHeight < e.clientY)
354-
// {
355-
// return;
356-
// }
357-
// if (e.wheelDelta > 0) modelScaling(1.1);
358-
// else modelScaling(0.9);
359-
} else if (e.type == "mousedown") {
355+
if (e.type == "mousedown") {
360356
modelTapEvent(e);
361357
} else if (e.type == "mousemove") {
362358
modelTurnHead(e);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/lib/configManager.js renamed to src/config/configMgr.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* @description The container of configeration.
55
*/
66

7+
8+
'use strict';
9+
710
import _ from 'lodash';
811

912
let currConfig = {};
@@ -36,28 +39,27 @@ const defaultOptions = {
3639
react: {
3740
opacityDefault: 0.7,
3841
opacityOnHover: 0.2,
39-
myFunc: () => {console.log('(undefined) ┑( ̄Д  ̄)┍');},
40-
messageFunc: () => {console.log('(undefined) ┑( ̄Д  ̄)┍');},
42+
myFunc: (e) => {console.log('(undefined) ┑( ̄Д  ̄)┍');}, // e means the event
4143
},
4244
debug: {
4345
log: false,
4446
mouseLog: false,
4547
mouseFunc: (x, y) => {console.log(`MouseFunc: ${x},${x}`);}, // only works when debug.mouseLog is on
4648
},
47-
checked: true,
49+
_: true,
4850
}
4951

50-
function configApplyer(inUserConfig){
51-
console.log(_.defaults({ 'a'1 }, { 'a'3, 'b'2 }));
52-
if (!!!inUserConfig.checked) checkUserConfig(inUserConfig);
53-
// TBD.
54-
}
52+
function configApplyer(userConfig){
5553

56-
function checkUserConfig(inUserConfig){
57-
// TBD.
58-
}
54+
if (!(_.has(userConfig, '_'))){
55+
import(/* webpackMode: "lazy" */ './configValidater').then(f => {
56+
f.configValidater(userConfig);
57+
}).catch(err => {
58+
console.error(err);
59+
});
60+
}
5961

60-
function configDefaulter(){
62+
currConfig = _.defaultsDeep(userConfig, defaultOptions);
6163

6264
}
6365

src/config/configValidater.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Created by xiazeyu.
2+
3+
/**
4+
* @description the validater for user's config
5+
*/
6+
7+
8+
'use strict';
9+
10+
import _ from 'lodash';
11+
12+
function configValidater(userConfig){
13+
14+
if (process.env.NODE_ENV === 'development') console.log('config: validating config...');
15+
16+
if(_.has(userConfig, 'model')){
17+
if(_.has(userConfig.model, 'jsonPath')){
18+
if(!_.isString(userConfig.model.jsonPath)){
19+
throw 'userConfig.model.jsonPath should be a string.';
20+
}
21+
}
22+
}
23+
24+
}
25+
26+
export {
27+
configValidater,
28+
}

src/configValidater.js

Whitespace-only changes.

0 commit comments

Comments
 (0)