!539 重构灯光初始化

pull/539/MERGE
ZoeLeeFZ 5 years ago committed by ChenX
parent 1c5f3647a8
commit 04c708f941

@ -1,10 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`changev 1`] = `"[3,101,1,2,1,false,0,1,\\"\\",2,2,false,0,1,\\"Line\\",5,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[2,3,4],[0,0,0],2,4,false,0,2,0,2,3,false,0,2,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",5,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[0,0,0],[0,0,0]],\\"\\",100,1,\\"ObjectAllDataHistoryRecord\\",1,1,\\"AllObjectData\\",1,[5,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[0,0,0],[0,0,0]],\\"\\",\\"\\",100,2,5,false,0,0,1,2,6,false,0,0]"`; exports[`changev 1`] = `"[4,101,1,2,1,false,0,1,\\"\\",2,2,false,0,1,\\"Line\\",6,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,true,1,[2,3,4],[0,0,0],2,4,false,0,2,0,2,3,false,0,2,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",2,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",6,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,true,1,[0,0,0],[0,0,0]],\\"\\",100,1,\\"ObjectAllDataHistoryRecord\\",1,1,\\"AllObjectData\\",1,[6,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,true,1,[0,0,0],[0,0,0]],\\"\\",\\"\\",100,2,5,false,0,0,1,2,6,false,0,0,1,2,7,false,0,1,\\"\\",2,8,false,0,0]"`;
exports[`创建 修改 撤销撤销 重做重做 撤销 重做 1`] = `"[3,101,1,2,1,false,0,1,\\"\\",2,2,false,0,1,\\"Line\\",5,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,2,3],[0,0,0],2,4,false,0,2,0,2,3,false,0,2,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",5,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,2,3],[0,0,0]],\\"\\",2,5,false,0,0,1,2,6,false,0,0]"`; exports[`创建 修改 撤销撤销 重做重做 撤销 重做 1`] = `"[4,101,1,2,1,false,0,1,\\"\\",2,2,false,0,1,\\"Line\\",6,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,true,1,[1,2,3],[0,0,0],2,4,false,0,2,0,2,3,false,0,2,0,1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",6,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,true,1,[1,2,3],[0,0,0]],\\"\\",2,5,false,0,0,1,2,6,false,0,0,1,2,7,false,0,1,\\"\\",2,8,false,0,0]"`;
exports[`创建 修改 撤销撤销 重做重做 撤销 重做 2`] = `"[\\"HistoricManage\\",1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",5,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[1,2,3],[0,0,0]],\\"\\"]"`; exports[`创建 修改 撤销撤销 重做重做 撤销 重做 2`] = `"[\\"HistoricManage\\",1,0,1,\\"CommandHistoryRecord\\",1,\\"\\",1,2,1,\\"HistorycRecord\\",1,\\"RemoveObjectData\\",1,0,\\"CreateObjectData\\",1,[\\"Line\\",6,2,100,false,1,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,true,1,[1,2,3],[0,0,0]],\\"\\"]"`;
exports[`测试创建 1`] = `"[\\"AllObjectData\\",1,[]]"`; exports[`测试创建 1`] = `"[\\"AllObjectData\\",1,[]]"`;
@ -16,7 +16,7 @@ exports[`测试创建 4`] = `"[\\"CreateObjectData\\",1,[]]"`;
exports[`测试创建 5`] = `"[\\"HistorycRecord\\",1,\\"\\",\\"\\",\\"\\"]"`; exports[`测试创建 5`] = `"[\\"HistorycRecord\\",1,\\"\\",\\"\\",\\"\\"]"`;
exports[`测试创建 6`] = `"[\\"Line\\",5,2,0,false,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,1,[0,0,0],[0,0,0]]"`; exports[`测试创建 6`] = `"[\\"Line\\",6,2,0,false,0,7,0,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],0,0,true,1,[0,0,0],[0,0,0]]"`;
exports[`测试创建 7`] = `"[\\"ObjectAllDataHistoryRecord\\",1,1,\\"\\",\\"\\",\\"\\",0]"`; exports[`测试创建 7`] = `"[\\"ObjectAllDataHistoryRecord\\",1,1,\\"\\",\\"\\",\\"\\",0]"`;

@ -2,7 +2,7 @@
exports[`wblockClone 1`] = ` exports[`wblockClone 1`] = `
Array [ Array [
3, 4,
102, 102,
1, 1,
2, 2,
@ -78,12 +78,24 @@ Array [
false, false,
0, 0,
0, 0,
1,
2,
7,
false,
0,
1,
"",
2,
8,
false,
0,
0,
] ]
`; `;
exports[`wblockClone 2`] = ` exports[`wblockClone 2`] = `
Array [ Array [
3, 4,
104, 104,
1, 1,
2, 2,
@ -195,12 +207,24 @@ Array [
false, false,
0, 0,
0, 0,
1,
2,
7,
false,
0,
1,
"",
2,
8,
false,
0,
0,
] ]
`; `;
exports[`wblockClone 3`] = ` exports[`wblockClone 3`] = `
Array [ Array [
3, 4,
102, 102,
1, 1,
2, 2,
@ -276,5 +300,17 @@ Array [
false, false,
0, 0,
0, 0,
1,
2,
7,
false,
0,
1,
"",
2,
8,
false,
0,
0,
] ]
`; `;

@ -34,7 +34,7 @@ Vector3 {
exports[`平行线倒角 5`] = ` exports[`平行线倒角 5`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -61,6 +61,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
73.34943322499446, 73.34943322499446,
1.0347589842802478, 1.0347589842802478,
@ -103,7 +104,7 @@ Vector3 {
exports[`平行线倒角 10`] = ` exports[`平行线倒角 10`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -130,6 +131,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
73.34943322499456, 73.34943322499456,
1.0347589842802496, 1.0347589842802496,
@ -172,7 +174,7 @@ Vector3 {
exports[`平行线倒角 15`] = ` exports[`平行线倒角 15`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -199,6 +201,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
73.34943322499446, 73.34943322499446,
5.248426322899339, 5.248426322899339,
@ -241,7 +244,7 @@ Vector3 {
exports[`平行线倒角 20`] = ` exports[`平行线倒角 20`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -268,6 +271,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
73.34943322499446, 73.34943322499446,
5.248426322899339, 5.248426322899339,
@ -310,7 +314,7 @@ Vector3 {
exports[`平行线倒角 25`] = ` exports[`平行线倒角 25`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -337,6 +341,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
73.34943322499475, 73.34943322499475,
2.6055553110751504, 2.6055553110751504,
@ -379,7 +384,7 @@ Vector3 {
exports[`平行线倒角 30`] = ` exports[`平行线倒角 30`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -406,6 +411,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
73.34943322499473, 73.34943322499473,
2.6055553110751504, 2.6055553110751504,
@ -448,7 +454,7 @@ Vector3 {
exports[`平行线倒角 35`] = ` exports[`平行线倒角 35`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -475,6 +481,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
73.34943322499475, 73.34943322499475,
3.6776299961044363, 3.6776299961044363,
@ -517,7 +524,7 @@ Vector3 {
exports[`平行线倒角 40`] = ` exports[`平行线倒角 40`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -544,6 +551,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
73.34943322499446, 73.34943322499446,
3.677629996104445, 3.677629996104445,
@ -586,7 +594,7 @@ Vector3 {
exports[`平行线倒角 45`] = ` exports[`平行线倒角 45`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -613,6 +621,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
73.34943322499451, 73.34943322499451,
3.7725575459849106, 3.7725575459849106,
@ -655,7 +664,7 @@ Vector3 {
exports[`平行线倒角 50`] = ` exports[`平行线倒角 50`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -682,6 +691,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
73.3494332249947, 73.3494332249947,
3.772557545984914, 3.772557545984914,
@ -724,7 +734,7 @@ Vector3 {
exports[`平行线倒角 55`] = ` exports[`平行线倒角 55`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -751,6 +761,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
73.34943322499451, 73.34943322499451,
2.510627761194676, 2.510627761194676,
@ -793,7 +804,7 @@ Vector3 {
exports[`平行线倒角 60`] = ` exports[`平行线倒角 60`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -820,6 +831,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
73.34943322499456, 73.34943322499456,
2.510627761194672, 2.510627761194672,
@ -862,7 +874,7 @@ Vector3 {
exports[`平行线倒角 65`] = ` exports[`平行线倒角 65`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -889,6 +901,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
19.138755980861262, 19.138755980861262,
3.141592653589793, 3.141592653589793,
@ -931,7 +944,7 @@ Vector3 {
exports[`平行线倒角 70`] = ` exports[`平行线倒角 70`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -958,6 +971,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
19.138755980861262, 19.138755980861262,
3.141592653589793, 3.141592653589793,
@ -1000,7 +1014,7 @@ Vector3 {
exports[`平行线倒角 75`] = ` exports[`平行线倒角 75`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -1027,6 +1041,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
19.138755980861262, 19.138755980861262,
3.141592653589793, 3.141592653589793,
@ -1069,7 +1084,7 @@ Vector3 {
exports[`平行线倒角 80`] = ` exports[`平行线倒角 80`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -1096,6 +1111,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
19.138755980861262, 19.138755980861262,
3.141592653589793, 3.141592653589793,
@ -1138,7 +1154,7 @@ Vector3 {
exports[`平行线倒角 85`] = ` exports[`平行线倒角 85`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -1165,6 +1181,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
25.71770334928226, 25.71770334928226,
3.141592653589793, 3.141592653589793,
@ -1207,7 +1224,7 @@ Vector3 {
exports[`平行线倒角 90`] = ` exports[`平行线倒角 90`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -1234,6 +1251,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
25.71770334928226, 25.71770334928226,
3.141592653589793, 3.141592653589793,
@ -1276,7 +1294,7 @@ Vector3 {
exports[`平行线倒角 95`] = ` exports[`平行线倒角 95`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -1303,6 +1321,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
25.71770334928226, 25.71770334928226,
0, 0,
@ -1345,7 +1364,7 @@ Vector3 {
exports[`平行线倒角 100`] = ` exports[`平行线倒角 100`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -1372,6 +1391,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
25.71770334928226, 25.71770334928226,
0, 0,
@ -1414,7 +1434,7 @@ Vector3 {
exports[`平行线倒角 105`] = ` exports[`平行线倒角 105`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -1441,6 +1461,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
19.138755980861163, 19.138755980861163,
3.7483983505742517, 3.7483983505742517,
@ -1483,7 +1504,7 @@ Vector3 {
exports[`平行线倒角 110`] = ` exports[`平行线倒角 110`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -1510,6 +1531,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
19.138755980861216, 19.138755980861216,
3.748398350574254, 3.748398350574254,
@ -1552,7 +1574,7 @@ Vector3 {
exports[`平行线倒角 115`] = ` exports[`平行线倒角 115`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -1579,6 +1601,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
19.13875598086116, 19.13875598086116,
2.534786956605342, 2.534786956605342,
@ -1621,7 +1644,7 @@ Vector3 {
exports[`平行线倒角 120`] = ` exports[`平行线倒角 120`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -1648,6 +1671,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
19.138755980861294, 19.138755980861294,
2.5347869566053394, 2.5347869566053394,
@ -1690,7 +1714,7 @@ Vector3 {
exports[`平行线倒角 125`] = ` exports[`平行线倒角 125`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -1717,6 +1741,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
25.71770334928209, 25.71770334928209,
3.7483983505742495, 3.7483983505742495,
@ -1759,7 +1784,7 @@ Vector3 {
exports[`平行线倒角 130`] = ` exports[`平行线倒角 130`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -1786,6 +1811,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
25.717703349282267, 25.717703349282267,
3.7483983505742486, 3.7483983505742486,
@ -1828,7 +1854,7 @@ Vector3 {
exports[`平行线倒角 135`] = ` exports[`平行线倒角 135`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -1855,6 +1881,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
25.717703349282235, 25.717703349282235,
0.606805696984454, 0.606805696984454,
@ -1897,7 +1924,7 @@ Vector3 {
exports[`平行线倒角 140`] = ` exports[`平行线倒角 140`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -1924,6 +1951,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
25.717703349282118, 25.717703349282118,
0.6068056969844523, 0.6068056969844523,
@ -1966,7 +1994,7 @@ Vector3 {
exports[`平行线倒角 145`] = ` exports[`平行线倒角 145`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -1993,6 +2021,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
45.20012262101521, 45.20012262101521,
4.71238898038469, 4.71238898038469,
@ -2035,7 +2064,7 @@ Vector3 {
exports[`平行线倒角 150`] = ` exports[`平行线倒角 150`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -2062,6 +2091,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
45.20012262101521, 45.20012262101521,
4.71238898038469, 4.71238898038469,
@ -2104,7 +2134,7 @@ Vector3 {
exports[`平行线倒角 155`] = ` exports[`平行线倒角 155`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -2131,6 +2161,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
45.20012262101521, 45.20012262101521,
1.570796326794897, 1.570796326794897,
@ -2173,7 +2204,7 @@ Vector3 {
exports[`平行线倒角 160`] = ` exports[`平行线倒角 160`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -2200,6 +2231,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
45.20012262101521, 45.20012262101521,
1.570796326794897, 1.570796326794897,
@ -2242,7 +2274,7 @@ Vector3 {
exports[`平行线倒角 165`] = ` exports[`平行线倒角 165`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -2269,6 +2301,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
58.10252336584995, 58.10252336584995,
3.141592653589793, 3.141592653589793,
@ -2311,7 +2344,7 @@ Vector3 {
exports[`平行线倒角 170`] = ` exports[`平行线倒角 170`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -2338,6 +2371,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
58.10252336584995, 58.10252336584995,
3.141592653589793, 3.141592653589793,
@ -2380,7 +2414,7 @@ Vector3 {
exports[`平行线倒角 175`] = ` exports[`平行线倒角 175`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -2407,6 +2441,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
58.10252336584995, 58.10252336584995,
0, 0,
@ -2449,7 +2484,7 @@ Vector3 {
exports[`平行线倒角 180`] = ` exports[`平行线倒角 180`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -2476,6 +2511,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
58.10252336584995, 58.10252336584995,
0, 0,
@ -2518,7 +2554,7 @@ Vector3 {
exports[`平行线倒角 185`] = ` exports[`平行线倒角 185`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -2545,6 +2581,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
82.31190810162093, 82.31190810162093,
3.141592653589793, 3.141592653589793,
@ -2587,7 +2624,7 @@ Vector3 {
exports[`平行线倒角 190`] = ` exports[`平行线倒角 190`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -2614,6 +2651,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
82.31190810162093, 82.31190810162093,
3.141592653589793, 3.141592653589793,
@ -2656,7 +2694,7 @@ Vector3 {
exports[`平行线倒角 195`] = ` exports[`平行线倒角 195`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -2683,6 +2721,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
82.31190810162093, 82.31190810162093,
3.141592653589793, 3.141592653589793,
@ -2725,7 +2764,7 @@ Vector3 {
exports[`平行线倒角 200`] = ` exports[`平行线倒角 200`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -2752,6 +2791,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
82.31190810162093, 82.31190810162093,
3.141592653589793, 3.141592653589793,
@ -2794,7 +2834,7 @@ Vector3 {
exports[`平行线倒角 205`] = ` exports[`平行线倒角 205`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -2821,6 +2861,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
51.64668743631091, 51.64668743631091,
3.1415926535897927, 3.1415926535897927,
@ -2863,7 +2904,7 @@ Vector3 {
exports[`平行线倒角 210`] = ` exports[`平行线倒角 210`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -2890,6 +2931,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
51.64668743631091, 51.64668743631091,
3.141592653589793, 3.141592653589793,
@ -2932,7 +2974,7 @@ Vector3 {
exports[`平行线倒角 215`] = ` exports[`平行线倒角 215`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -2959,6 +3001,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
51.64668743631091, 51.64668743631091,
0, 0,
@ -3001,7 +3044,7 @@ Vector3 {
exports[`平行线倒角 220`] = ` exports[`平行线倒角 220`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -3028,6 +3071,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
51.64668743631091, 51.64668743631091,
0, 0,
@ -3070,7 +3114,7 @@ Vector3 {
exports[`平行线倒角 225`] = ` exports[`平行线倒角 225`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -3097,6 +3141,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
51.98014101416747, 51.98014101416747,
4.71238898038469, 4.71238898038469,
@ -3139,7 +3184,7 @@ Vector3 {
exports[`平行线倒角 230`] = ` exports[`平行线倒角 230`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -3166,6 +3211,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
51.98014101416747, 51.98014101416747,
4.71238898038469, 4.71238898038469,
@ -3208,7 +3254,7 @@ Vector3 {
exports[`平行线倒角 235`] = ` exports[`平行线倒角 235`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -3235,6 +3281,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
51.98014101416747, 51.98014101416747,
1.570796326794897, 1.570796326794897,
@ -3277,7 +3324,7 @@ Vector3 {
exports[`平行线倒角 240`] = ` exports[`平行线倒角 240`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -3304,6 +3351,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
51.98014101416747, 51.98014101416747,
1.570796326794897, 1.570796326794897,
@ -3346,7 +3394,7 @@ Vector3 {
exports[`平行线倒角 245`] = ` exports[`平行线倒角 245`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -3373,6 +3421,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
304.88159012329635, 304.88159012329635,
3.6595501788556284, 3.6595501788556284,
@ -3415,7 +3464,7 @@ Vector3 {
exports[`平行线倒角 250`] = ` exports[`平行线倒角 250`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -3442,6 +3491,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
304.88159012329595, 304.88159012329595,
3.6595501788556346, 3.6595501788556346,
@ -3484,7 +3534,7 @@ Vector3 {
exports[`平行线倒角 255`] = ` exports[`平行线倒角 255`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -3511,6 +3561,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
304.88159012329635, 304.88159012329635,
2.6236351283239583, 2.6236351283239583,
@ -3553,7 +3604,7 @@ Vector3 {
exports[`平行线倒角 260`] = ` exports[`平行线倒角 260`] = `
Array [ Array [
5, 6,
2, 2,
0, 0,
false, false,
@ -3580,6 +3631,7 @@ Array [
], ],
0, 0,
0, 0,
true,
2, 2,
304.88159012329686, 304.88159012329686,
2.623635128323963, 2.623635128323963,

@ -31,7 +31,7 @@ export class DrawPointLight implements Command
if (ptRes.Status === PromptStatus.OK) if (ptRes.Status === PromptStatus.OK)
{ {
light.Distance = valRes.Distance; light.Distance = valRes.Distance;
app.Database.ModelSpace.Append(light); app.Database.Lights.Append(light);
} }
} }
} }
@ -49,7 +49,7 @@ export class DrawPointLight2 implements Command
if (ptRes.Status === PromptStatus.OK) if (ptRes.Status === PromptStatus.OK)
{ {
light.Position = ptRes.Point; light.Position = ptRes.Point;
app.Database.ModelSpace.Append(light); app.Database.Lights.Append(light);
} }
} }
} }

@ -30,7 +30,7 @@ export class DrawSpotLight implements Command
if (ptRes.Status === PromptStatus.OK) if (ptRes.Status === PromptStatus.OK)
{ {
light.Target = ptRes.Point; light.Target = ptRes.Point;
app.Database.ModelSpace.Append(light); app.Database.Lights.Append(light);
} }
} }
@ -49,7 +49,7 @@ export class DrawSpotLight2 implements Command
if (ptRes.Status === PromptStatus.OK) if (ptRes.Status === PromptStatus.OK)
{ {
this.update(light, ptRes.Point); this.update(light, ptRes.Point);
app.Database.ModelSpace.Append(light); app.Database.Lights.Append(light);
} }
} }
update(light: SpotLight, p: Vector3) update(light: SpotLight, p: Vector3)

@ -5,7 +5,6 @@ import { RequestStatus, uploadLogo } from '../Common/Request';
import { deflate, GetCurrentViewPreViewImage } from '../Common/SerializeMaterial'; import { deflate, GetCurrentViewPreViewImage } from '../Common/SerializeMaterial';
import { FileServer } from '../DatabaseServices/FileServer'; import { FileServer } from '../DatabaseServices/FileServer';
import { Command } from '../Editor/CommandMachine'; import { Command } from '../Editor/CommandMachine';
import { RightPanelStore } from '../UI/Store/RightPanelStore/RightPanelStore';
export class Save implements Command export class Save implements Command
{ {
@ -64,7 +63,6 @@ export class New implements Command
server.m_CurFileId = undefined; server.m_CurFileId = undefined;
app.CreateDocument(); app.CreateDocument();
RightPanelStore.GetInstance().lightStore.InitScene();
} }
} }

@ -47,7 +47,7 @@ export const ShopUrls = {
get: CURRENT_HOST + "/CAD-goodsList", get: CURRENT_HOST + "/CAD-goodsList",
} }
export const ResourcesCDN_HOST = "https://cdn.jsdelivr.net/gh/FishOrBear/CDNResources/"; export const ResourcesCDN_HOST = "https://cdn.qicad.com/";
export const ToplineUrls = { export const ToplineUrls = {
create: CURRENT_HOST + "/CAD-toplineCreate", create: CURRENT_HOST + "/CAD-toplineCreate",
get: CURRENT_HOST + "/CAD-toplineList", get: CURRENT_HOST + "/CAD-toplineList",

@ -14,7 +14,7 @@ export class BlockTableRecord extends SymbolTableRecord
constructor() constructor()
{ {
super(); super();
end(this.EntityCol, this.EntityCol.AppendEvent, (e) => { this.AppendEvent(e) }); end(this.EntityCol, this.EntityCol.AppendEvent, (e: Entity) => { this.AppendEvent(e) });
} }
SetOwnerDatabase(db: Database) SetOwnerDatabase(db: Database)

@ -1,6 +1,5 @@
import { MirroredRepeatWrapping, Vector3 } from 'three'; import { MirroredRepeatWrapping, Vector3 } from 'three';
import { HostApplicationServices } from '../ApplicationServices/HostApplicationServices'; import { HostApplicationServices } from '../ApplicationServices/HostApplicationServices';
import { ResourcesCDN_HOST } from '../Common/HostUrl';
import { DuplicateRecordCloning } from '../Common/Status'; import { DuplicateRecordCloning } from '../Common/Status';
import { BlockTable } from './BlockTable'; import { BlockTable } from './BlockTable';
import { BlockTableRecord } from './BlockTableRecord'; import { BlockTableRecord } from './BlockTableRecord';
@ -12,6 +11,9 @@ import { Entity } from './Entity/Entity';
import { GroupTable } from './GroupTable'; import { GroupTable } from './GroupTable';
import { HistoricManage } from './HistoricManage'; import { HistoricManage } from './HistoricManage';
import { IdMaping } from './IdMaping'; import { IdMaping } from './IdMaping';
import { AmbientLight } from './Lights/AmbientLight';
import { DirectionalLight } from './Lights/DirectionalLight';
import { HemisphereLight } from './Lights/HemisphereLight';
import { MaterialTable } from './MaterialTable'; import { MaterialTable } from './MaterialTable';
import { ObjectId } from './ObjectId'; import { ObjectId } from './ObjectId';
import { PhysicalMaterialRecord } from './PhysicalMaterialRecord'; import { PhysicalMaterialRecord } from './PhysicalMaterialRecord';
@ -36,6 +38,12 @@ export class Database
GroupTable: GroupTable; GroupTable: GroupTable;
ModelSpace: BlockTableRecord; ModelSpace: BlockTableRecord;
Lights: BlockTableRecord;
AmbientLight: AmbientLight;
SunLight: DirectionalLight;
HemisphereLight: HemisphereLight;
DefaultMaterial: PhysicalMaterialRecord; DefaultMaterial: PhysicalMaterialRecord;
private idIndex = 1; private idIndex = 1;
@ -47,18 +55,18 @@ export class Database
this.TextureTable = new TextureTable().SetOwnerDatabase(this); this.TextureTable = new TextureTable().SetOwnerDatabase(this);
this.TemplateTable = new TemplateTable().SetOwnerDatabase(this); this.TemplateTable = new TemplateTable().SetOwnerDatabase(this);
this.GroupTable = new GroupTable().SetOwnerDatabase(this); this.GroupTable = new GroupTable().SetOwnerDatabase(this);
this.Lights = new BlockTableRecord().SetOwnerDatabase(this);
this.hm = new HistoricManage().SetDefaultDb(this); this.hm = new HistoricManage().SetDefaultDb(this);
if (disableHistoric) if (disableHistoric)
this.hm.Enable = false; this.hm.Enable = false;
this.idIndex = 70;
if (buildDefaultDrawing) if (buildDefaultDrawing)
{ {
this.idIndex = 70;
this.DefaultMaterial = new PhysicalMaterialRecord(); this.DefaultMaterial = new PhysicalMaterialRecord();
this.DefaultMaterial.Name = "默认"; this.DefaultMaterial.Name = "默认";
let texture = new TextureTableRecord(); let texture = new TextureTableRecord();
texture.imageUrl = ResourcesCDN_HOST + "Default.jpg";
texture.WrapS = MirroredRepeatWrapping; texture.WrapS = MirroredRepeatWrapping;
texture.WrapT = MirroredRepeatWrapping; texture.WrapT = MirroredRepeatWrapping;
texture.repeatX = 1; texture.repeatX = 1;
@ -72,12 +80,28 @@ export class Database
texture.Update(); texture.Update();
this.SettingDefaultMaterial(); this.SettingDefaultMaterial();
//初始化灯光
this.InitLight();
} }
//100以内的id是系统保留id,默认初始化内部对象. //100以内的id是系统保留id,默认初始化内部对象.
this.idIndex = 100; this.idIndex = 100;
} }
private InitLight()
{
this.idIndex = 80;
this.AmbientLight = new AmbientLight();
this.SunLight = new DirectionalLight();
this.HemisphereLight = new HemisphereLight();
this.SunLight.Visible = false;
this.HemisphereLight.Visible = false;
this.Lights.Add(this.AmbientLight);
this.Lights.Add(this.SunLight);
this.Lights.Add(this.HemisphereLight);
}
SettingDefaultMaterial() SettingDefaultMaterial()
{ {
if (!this.defaultDatabase) if (!this.defaultDatabase)
@ -96,6 +120,7 @@ export class Database
this.TextureTable.Destroy(); this.TextureTable.Destroy();
this.TemplateTable.Destroy(); this.TemplateTable.Destroy();
this.GroupTable.Destroy(); this.GroupTable.Destroy();
this.Lights.Destroy();
this.hm.Destroy(); this.hm.Destroy();
this.hm.historyRecord.length = 0; this.hm.historyRecord.length = 0;
@ -105,6 +130,7 @@ export class Database
this.TextureTable.SetOwnerDatabase(this); this.TextureTable.SetOwnerDatabase(this);
this.TemplateTable.SetOwnerDatabase(this); this.TemplateTable.SetOwnerDatabase(this);
this.GroupTable.SetOwnerDatabase(this); this.GroupTable.SetOwnerDatabase(this);
this.Lights.SetOwnerDatabase(this);
this.hm.SetOwnerDatabase(this); this.hm.SetOwnerDatabase(this);
this.idIndex = 100; this.idIndex = 100;
} }
@ -114,7 +140,7 @@ export class Database
FileWrite(): CADFiler FileWrite(): CADFiler
{ {
let file = new CADFiler(); let file = new CADFiler();
file.Write(3);//ver; file.Write(4);//ver;
file.Write(this.idIndex); file.Write(this.idIndex);
this.ModelSpace.WriteFile(file); this.ModelSpace.WriteFile(file);
this.TextureTable.WriteFile(file); this.TextureTable.WriteFile(file);
@ -122,6 +148,7 @@ export class Database
this.hm.WriteFile(file); this.hm.WriteFile(file);
this.TemplateTable.WriteFile(file); this.TemplateTable.WriteFile(file);
this.GroupTable.WriteFile(file); this.GroupTable.WriteFile(file);
this.Lights.WriteFile(file);
return file; return file;
} }
@ -141,6 +168,19 @@ export class Database
this.TemplateTable.ReadFile(file); this.TemplateTable.ReadFile(file);
if (ver > 2) if (ver > 2)
this.GroupTable.ReadFile(file); this.GroupTable.ReadFile(file);
if (ver > 3)
{
this.Lights.ReadFile(file);
this.AmbientLight = this.Lights.Entitys[0] as AmbientLight;
this.SunLight = this.Lights.Entitys[1] as DirectionalLight;
this.HemisphereLight = this.Lights.Entitys[2] as HemisphereLight;
}
else
{
let index = this.idIndex;
this.InitLight();
this.idIndex = index;
}
this.SettingDefaultMaterial(); this.SettingDefaultMaterial();

@ -350,10 +350,13 @@ export class Entity extends CADObject
return this._Visible; return this._Visible;
} }
set Visible(v: boolean) set Visible(v: boolean)
{
if (v !== this._Visible)
{ {
this._Visible = v; this._Visible = v;
this.UpdateVisible(); this.UpdateVisible();
} }
}
private get IsVisible() private get IsVisible()
{ {
@ -527,17 +530,21 @@ export class Entity extends CADObject
if (ver > 4) if (ver > 4)
this.GourpId = file.ReadObjectId(); this.GourpId = file.ReadObjectId();
if (ver > 5)
this._Visible = file.Read();
} }
//对象将自身数据写入到文件. //对象将自身数据写入到文件.
WriteFile(file: CADFiler) WriteFile(file: CADFiler)
{ {
file.Write(5); file.Write(6);
super.WriteFile(file); super.WriteFile(file);
file.Write(this._Color); file.Write(this._Color);
file.WriteHardObjectId(this.materialId); file.WriteHardObjectId(this.materialId);
file.Write(this._Matrix.toArray()); file.Write(this._Matrix.toArray());
file.WriteHardObjectId(this.Template); file.WriteHardObjectId(this.Template);
file.WriteHardObjectId(this.GourpId); file.WriteHardObjectId(this.GourpId);
file.Write(this._Visible);
} }
//局部撤销 //局部撤销
ApplyPartialUndo(undoData: CADObject) ApplyPartialUndo(undoData: CADObject)

@ -63,8 +63,6 @@ export class FileServer extends Singleton
super(); super();
app.CommandReactor.OnCommandEnd((cmdName, changeObjects, createObjects) => app.CommandReactor.OnCommandEnd((cmdName, changeObjects, createObjects) =>
{ {
if (cmdName === "初始化灯光")
return;
if (cmdName === "SAVE") if (cmdName === "SAVE")
this.isSave = true; this.isSave = true;
else else
@ -88,7 +86,6 @@ export class FileServer extends Singleton
{ {
this.m_CurFileId = undefined; this.m_CurFileId = undefined;
app.CreateDocument(); app.CreateDocument();
RightPanelStore.GetInstance().lightStore.InitScene();
} }
this.isSave = true; this.isSave = true;
} }
@ -105,7 +102,6 @@ export class FileServer extends Singleton
this.m_CurFileId = fid; this.m_CurFileId = fid;
this.SaveCurrentFileInfo({ file_id: fid, name: info.name }); this.SaveCurrentFileInfo({ file_id: fid, name: info.name });
appUi.setDocumentName(info.name); appUi.setDocumentName(info.name);
RightPanelStore.GetInstance().lightStore.InitScene();
this.isSave = true; this.isSave = true;
} }
catch (error) catch (error)

@ -1,5 +1,5 @@
import { MirroredRepeatWrapping, Texture, Wrapping } from 'three'; import { MirroredRepeatWrapping, Texture, Wrapping } from 'three';
import { CURRENT_HOST } from '../Common/HostUrl'; import { CURRENT_HOST, ResourcesCDN_HOST } from '../Common/HostUrl';
import { LoadImageFromUrl } from '../Loader/ImageLoader'; import { LoadImageFromUrl } from '../Loader/ImageLoader';
import { Factory } from './CADFactory'; import { Factory } from './CADFactory';
import { CADFiler } from './CADFiler'; import { CADFiler } from './CADFiler';
@ -16,7 +16,7 @@ export class TextureTableRecord extends SymbolTableRecord
repeatX: number = 1; repeatX: number = 1;
repeatY: number = 1; repeatY: number = 1;
rotation: number = 0;//旋转 弧度deg rotation: number = 0;//旋转 弧度deg
imageUrl: string; imageUrl: string = "";
set WrapS(wrap: Wrapping) set WrapS(wrap: Wrapping)
{ {
@ -42,17 +42,18 @@ export class TextureTableRecord extends SymbolTableRecord
private texture: Texture = new Texture(); private texture: Texture = new Texture();
async Update() async Update()
{ {
//如果贴图没变不需要重复加载贴图 let imgUrl: string;
if (this.imageUrl) if (this.imageUrl.endsWith("Default.jpg") || !this.imageUrl)
{ {
let url = CURRENT_HOST + "/" + this.imageUrl; imgUrl = ResourcesCDN_HOST + "Default.jpg";
if (this.imageUrl.startsWith("https")) this.imageUrl = "";
url = this.imageUrl;
if (!this.texture.image
|| (this.texture.image && this.texture.image.src !== url)
)
this.texture.image = await LoadImageFromUrl(url);
} }
else
imgUrl = CURRENT_HOST + "/" + this.imageUrl;
if (!this.texture.image || (this.texture.image && this.texture.image.src !== imgUrl))
this.texture.image = await LoadImageFromUrl(imgUrl);
this.texture.wrapS = this.wrapS; this.texture.wrapS = this.wrapS;
this.texture.wrapT = this.wrapT; this.texture.wrapT = this.wrapT;
this.texture.anisotropy = 16; this.texture.anisotropy = 16;

@ -404,8 +404,15 @@ export class Viewer
} }
} }
down.progress = 1; down.progress = 1;
//灯光
for (let l of db.Lights.Entitys)
this._Scene.add(l.DrawObject);
this.UpdateRender(); this.UpdateRender();
} }
//灯光
for (let l of db.Lights.Entitys)
this._Scene.add(l.DrawObject);
begin(db.ModelSpace, db.ModelSpace.AppendEvent, (e: Entity) => begin(db.ModelSpace, db.ModelSpace.AppendEvent, (e: Entity) =>
{ {
this._Scene.add(e.DrawObject); this._Scene.add(e.DrawObject);
@ -415,6 +422,17 @@ export class Viewer
for (let en of db.ModelSpace.Entitys) for (let en of db.ModelSpace.Entitys)
en.GoodBye(); en.GoodBye();
}); });
begin(db.Lights, db.Lights.AppendEvent, (e: Entity) =>
{
this._Scene.add(e.DrawObject);
});
begin(db.Lights, db.Lights.Destroy, () =>
{
for (let en of db.Lights.Entitys)
en.GoodBye();
});
begin(userConfig, userConfig.SetRenderTypeEvent, async () => begin(userConfig, userConfig.SetRenderTypeEvent, async () =>
{ {
let i = 0; let i = 0;

@ -1,4 +1,4 @@
import { Alignment, Button, Classes, Divider, HTMLSelect, Intent, Label, NumericInput, Switch } from '@blueprintjs/core'; import { Alignment, Classes, Divider, HTMLSelect, Label, NumericInput, Switch } from '@blueprintjs/core';
import { observable } from 'mobx'; import { observable } from 'mobx';
import { inject, observer } from 'mobx-react'; import { inject, observer } from 'mobx-react';
import * as React from 'react'; import * as React from 'react';
@ -9,6 +9,9 @@ import { angle, equalv3 } from '../../../Geometry/GeUtils';
import { RightPanelStore } from '../../Store/RightPanelStore/RightPanelStore'; import { RightPanelStore } from '../../Store/RightPanelStore/RightPanelStore';
import { LightDataCom, LightModal } from '../Modal/LightModal'; import { LightDataCom, LightModal } from '../Modal/LightModal';
import { safeEval } from '../../../Common/eval'; import { safeEval } from '../../../Common/eval';
import { Light } from '../../../DatabaseServices/Lights/Light';
import { DirectionalLight } from '../../../DatabaseServices/Lights/DirectionalLight';
import { AmbientLight } from '../../../DatabaseServices/Lights/AmbientLight';
enum ETime enum ETime
{ {
@ -31,68 +34,10 @@ export class ScenePanel extends React.Component<{ store?: RightPanelStore }, {}>
angle: "60", angle: "60",
rotation: "300" rotation: "300"
} }
private SetSunPostion(angle: number, rotation: number)
{
let light = this.props.store.lightStore.m_DirectionalLight;
let pos = new Vector3(DefaultDist.dist * Math.cos(angle), 0, DefaultDist.dist * Math.sin(angle));
pos.applyMatrix4(new Matrix4().makeRotationZ(rotation));
light.Position = pos.add(light.Target);
app.Editor.UpdateScreen();
}
private handleSuntime = () =>
{
let dirLight = this.props.store.lightStore.m_DirectionalLight;
switch (this.sunState.time)
{
case ETime.Default:
dirLight.Intensity = 2;
this.sunState.angle = "60";
this.sunState.rotation = "300";
this.SetSunPostion(Math.PI / 3, Math.PI * 60 / 36);
break;
case ETime.Morning:
dirLight.Intensity = 2;
this.sunState.angle = "60";
this.sunState.rotation = "0";
this.SetSunPostion(Math.PI / 3, 0);
break;
case ETime.Noon:
dirLight.Intensity = 6;
this.sunState.angle = "90";
this.sunState.rotation = "0";
this.SetSunPostion(Math.PI / 2, 0);
break;
case ETime.Afternoon:
dirLight.Intensity = 4;
this.sunState.angle = "60";
this.sunState.rotation = "180";
this.SetSunPostion(Math.PI / 3, Math.PI);
break;
case ETime.Evening:
dirLight.Intensity = 2;
this.sunState.angle = "30";
this.sunState.rotation = "180";
this.SetSunPostion(Math.PI / 6, Math.PI);
break;
default:
break;
}
app.Editor.UpdateScreen();
}
private handleChangeSunAngle = (num: number) =>
{
this.sunState.angle = num.toString();
this.SetSunPostion(TMath.degToRad(num), TMath.degToRad(safeEval(this.sunState.rotation)));
}
private handleChangeSunRotation = (num: number) =>
{
this.sunState.rotation = num.toString();
this.SetSunPostion(TMath.degToRad(safeEval(this.sunState.angle)), TMath.degToRad(num));
}
UNSAFE_componentWillMount() UNSAFE_componentWillMount()
{ {
const sun = this.props.store.lightStore.m_DirectionalLight; const sun = app.Database.SunLight;;
if (equalv3(sun.Position, new Vector3())) if (equalv3(sun.Position, new Vector3()))
this.handleSuntime(); this.handleSuntime();
else else
@ -106,6 +51,7 @@ export class ScenePanel extends React.Component<{ store?: RightPanelStore }, {}>
render() render()
{ {
const lightStore = this.props.store.lightStore; const lightStore = this.props.store.lightStore;
let { SunLight, AmbientLight, HemisphereLight } = app.Database;
return ( return (
<div className="scene"> <div className="scene">
@ -124,21 +70,17 @@ export class ScenePanel extends React.Component<{ store?: RightPanelStore }, {}>
<Divider /> <Divider />
<Switch <Switch
large large
checked={lightStore.m_ShowAmbientLight}
label="环境光" label="环境光"
onChange={e => checked={lightStore.ShowAmbientLight}
{ onChange={e => this.triggleLightShow(e, AmbientLight)}
lightStore.m_ShowAmbientLight = !lightStore.m_ShowAmbientLight;
e.currentTarget.blur();
}}
alignIndicator={Alignment.RIGHT} alignIndicator={Alignment.RIGHT}
/> />
<div style={{ display: lightStore.m_ShowAmbientLight ? "block" : "none" }}> <div style={{ display: lightStore.ShowAmbientLight ? "block" : "none" }}>
<LightDataCom <LightDataCom
data={observable({ data={observable({
Intensity: lightStore.m_AmbientLight.Intensity.toString() Intensity: AmbientLight.Intensity.toString()
})} })}
light={lightStore.m_AmbientLight} light={AmbientLight}
pars={[["Intensity", "强度"]]} pars={[["Intensity", "强度"]]}
isShowPos={false} isShowPos={false}
isSelectTarget={false} isSelectTarget={false}
@ -147,21 +89,17 @@ export class ScenePanel extends React.Component<{ store?: RightPanelStore }, {}>
<Divider /> <Divider />
<Switch <Switch
large large
checked={lightStore.m_ShowHemiLight} checked={lightStore.ShowHemiLight}
label="半球光" label="半球光"
onChange={e => onChange={e => this.triggleLightShow(e, HemisphereLight)}
{
lightStore.m_ShowHemiLight = !lightStore.m_ShowHemiLight;
e.currentTarget.blur();
}}
alignIndicator={Alignment.RIGHT} alignIndicator={Alignment.RIGHT}
/> />
<div style={{ display: lightStore.m_ShowHemiLight ? "block" : "none" }}> <div style={{ display: lightStore.ShowHemiLight ? "block" : "none" }}>
<LightDataCom <LightDataCom
data={observable({ data={observable({
Intensity: lightStore.m_HemisphereLight.Intensity.toString() Intensity: HemisphereLight.Intensity.toString()
})} })}
light={lightStore.m_HemisphereLight} light={HemisphereLight}
pars={[["Intensity", "强度"]]} pars={[["Intensity", "强度"]]}
isShowPos={false} isShowPos={false}
isSelectTarget={false} isSelectTarget={false}
@ -170,16 +108,12 @@ export class ScenePanel extends React.Component<{ store?: RightPanelStore }, {}>
<Divider /> <Divider />
<Switch <Switch
large large
checked={lightStore.m_ShowDirLight} checked={lightStore.ShowSunLight}
label="太阳光" label="太阳光"
onChange={e => onChange={e => this.triggleLightShow(e, SunLight)}
{
lightStore.m_ShowDirLight = !lightStore.m_ShowDirLight;
e.currentTarget.blur();
}}
alignIndicator={Alignment.RIGHT} alignIndicator={Alignment.RIGHT}
/> />
<div style={{ display: lightStore.m_ShowDirLight ? "block" : "none" }}> <div style={{ display: lightStore.ShowSunLight ? "block" : "none" }}>
<HTMLSelect <HTMLSelect
options={[ETime.Default, ETime.Morning, ETime.Noon, ETime.Afternoon, ETime.Evening]} options={[ETime.Default, ETime.Morning, ETime.Noon, ETime.Afternoon, ETime.Evening]}
value={this.sunState.time} value={this.sunState.time}
@ -192,10 +126,10 @@ export class ScenePanel extends React.Component<{ store?: RightPanelStore }, {}>
/> />
<LightDataCom <LightDataCom
data={observable({ data={observable({
Intensity: lightStore.m_DirectionalLight.Intensity.toString() Intensity: SunLight.Intensity.toString()
})} })}
hideColor hideColor
light={lightStore.m_DirectionalLight} light={SunLight}
pars={[["Intensity", "强度"]]} pars={[["Intensity", "强度"]]}
isShowPos={false} isShowPos={false}
isSelectTarget={false} isSelectTarget={false}
@ -228,15 +162,86 @@ export class ScenePanel extends React.Component<{ store?: RightPanelStore }, {}>
</div> </div>
<Divider /> <Divider />
{ {
lightStore.currentSelectEnt ? <LightModal /> : null lightStore.currentSelectEnt && <LightModal />
} }
<div style={{ textAlign: "right" }}>
<Button
text="清除全部场景灯"
intent={Intent.DANGER}
onClick={() => lightStore.ClearSceneLights()}
/>
</div>
</div>) </div>)
} }
private SetSunPostion(angle: number, rotation: number)
{
let light = app.Database.SunLight;
let pos = new Vector3(DefaultDist.dist * Math.cos(angle), 0, DefaultDist.dist * Math.sin(angle));
pos.applyMatrix4(new Matrix4().makeRotationZ(rotation));
light.Position = pos.add(light.Target);
app.Editor.UpdateScreen();
}
private handleSuntime = () =>
{
let dirLight = app.Database.SunLight;
switch (this.sunState.time)
{
case ETime.Default:
dirLight.Intensity = 2;
this.sunState.angle = "60";
this.sunState.rotation = "300";
this.SetSunPostion(Math.PI / 3, Math.PI * 60 / 36);
break;
case ETime.Morning:
dirLight.Intensity = 2;
this.sunState.angle = "60";
this.sunState.rotation = "0";
this.SetSunPostion(Math.PI / 3, 0);
break;
case ETime.Noon:
dirLight.Intensity = 6;
this.sunState.angle = "90";
this.sunState.rotation = "0";
this.SetSunPostion(Math.PI / 2, 0);
break;
case ETime.Afternoon:
dirLight.Intensity = 4;
this.sunState.angle = "60";
this.sunState.rotation = "180";
this.SetSunPostion(Math.PI / 3, Math.PI);
break;
case ETime.Evening:
dirLight.Intensity = 2;
this.sunState.angle = "30";
this.sunState.rotation = "180";
this.SetSunPostion(Math.PI / 6, Math.PI);
break;
default:
break;
}
app.Editor.UpdateScreen();
}
private handleChangeSunAngle = (num: number) =>
{
this.sunState.angle = num.toString();
this.SetSunPostion(TMath.degToRad(num), TMath.degToRad(safeEval(this.sunState.rotation)));
}
private handleChangeSunRotation = (num: number) =>
{
this.sunState.rotation = num.toString();
this.SetSunPostion(TMath.degToRad(safeEval(this.sunState.angle)), TMath.degToRad(num));
}
private triggleLightShow = (e: React.FormEvent<HTMLInputElement>, light: Light) =>
{
const lightStore = this.props.store.lightStore;
if (light instanceof AmbientLight)
{
lightStore.ShowAmbientLight = !lightStore.ShowAmbientLight;
}
else if (light instanceof DirectionalLight)
{
lightStore.ShowSunLight = !lightStore.ShowSunLight;
}
else
{
lightStore.ShowHemiLight = !lightStore.ShowHemiLight;
}
light.Visible = e.currentTarget.checked;
app.Editor.UpdateScreen();
e.currentTarget.blur();
}
} }

@ -87,7 +87,6 @@ export class FilePanel extends React.Component<{ store?: TopPanelStore }, {}>
name, dir: currentDir name, dir: currentDir
}); });
app.CreateDocument(name); app.CreateDocument(name);
RightPanelStore.GetInstance().lightStore.InitScene();
} }
handleFile = async (name: string, currentDir: IDirectoryProps, callBack: () => void) => handleFile = async (name: string, currentDir: IDirectoryProps, callBack: () => void) =>
{ {

@ -1,15 +1,10 @@
import { autorun, observable } from "mobx"; import { observable } from "mobx";
import { DirectionalLight as TDirectionalLight, Light as TLight, PointLight, SpotLight } from 'three'; import { DirectionalLight as TDirectionalLight, PointLight, SpotLight } from 'three';
import { end } from "xaop"; import { end } from "xaop";
import { app } from "../../../ApplicationServices/Application"; import { app } from "../../../ApplicationServices/Application";
import { HostApplicationServices } from "../../../ApplicationServices/HostApplicationServices"; import { HostApplicationServices } from "../../../ApplicationServices/HostApplicationServices";
import { DirLightShadowArea } from "../../../Common/LightUtils"; import { DirLightShadowArea } from "../../../Common/LightUtils";
import { Entity } from "../../../DatabaseServices/Entity/Entity";
import { AmbientLight } from "../../../DatabaseServices/Lights/AmbientLight";
import { DirectionalLight } from "../../../DatabaseServices/Lights/DirectionalLight";
import { HemisphereLight } from "../../../DatabaseServices/Lights/HemisphereLight";
import { Light } from "../../../DatabaseServices/Lights/Light"; import { Light } from "../../../DatabaseServices/Lights/Light";
import { commandMachine } from "../../../Editor/CommandMachine";
export interface LightModalState export interface LightModalState
{ {
@ -31,12 +26,9 @@ export interface LightModalState
export class LightStore export class LightStore
{ {
@observable m_ShowAmbientLight = true; @observable ShowAmbientLight = true;
@observable m_ShowDirLight = false; @observable ShowSunLight = false;
@observable m_ShowHemiLight = false; @observable ShowHemiLight = false;
m_AmbientLight: AmbientLight = new AmbientLight();
m_DirectionalLight: DirectionalLight = new DirectionalLight();
m_HemisphereLight: HemisphereLight = new HemisphereLight();
@observable currentSelectEnt: Light = undefined; @observable currentSelectEnt: Light = undefined;
@observable title = ""; @observable title = "";
@observable pars: [string, string][] = []; @observable pars: [string, string][] = [];
@ -44,80 +36,8 @@ export class LightStore
@observable isShowShadow = false; @observable isShowShadow = false;
constructor() constructor()
{ {
commandMachine.CommandStart("初始化灯光");
autorun(() => this.TriggerLight(this.m_AmbientLight, this.m_ShowAmbientLight));
autorun(() => this.TriggerLight(this.m_DirectionalLight, this.m_ShowDirLight));
autorun(() => this.TriggerLight(this.m_HemisphereLight, this.m_ShowHemiLight));
commandMachine.CommandEnd();
this.WatchLightEvent(); this.WatchLightEvent();
} }
private TriggerLight(lg: Light, isShow: boolean)
{
if (isShow)
{
if (!lg.Id)
{
app.Database.ModelSpace.Append(lg);
}
else
{
let obj = lg.DrawObject;
let scene = app.Viewer.Scene;
if (!scene.children.includes(obj))
{
scene.add(obj);
}
lg.Erase(false);
}
}
else if (lg.Id)
{
lg.Erase();
}
this.UpdateDirLightShadowArea();
app.Editor.UpdateScreen();
}
InitScene()
{
commandMachine.CommandStart("初始化灯光");
this.isShowShadow = false;
this.m_ShowAmbientLight = true;
this.m_AmbientLight = new AmbientLight();
this.m_ShowDirLight = false;
this.m_DirectionalLight = new DirectionalLight();
this.m_ShowHemiLight = false;
this.m_HemisphereLight = new HemisphereLight();
app.Viewer.Scene.traverse(obj =>
{
if (obj.userData)
{
if (obj.userData.Entity instanceof AmbientLight)
{
this.m_AmbientLight = obj.userData.Entity;
this.m_ShowAmbientLight = !obj.userData.Entity.IsErase;
}
else if (obj.userData.Entity instanceof DirectionalLight)
{
this.m_DirectionalLight = obj.userData.Entity;
this.m_ShowDirLight = !obj.userData.Entity.IsErase;
}
else if (obj.userData.Entity instanceof HemisphereLight)
{
this.m_HemisphereLight = obj.userData.Entity;
this.m_ShowHemiLight = !obj.userData.Entity.IsErase;
}
}
})
if (!this.m_AmbientLight.Id)
{
app.Database.ModelSpace.Append(this.m_AmbientLight);
}
commandMachine.CommandEnd();
}
ShowShadowObject(isShow: boolean) ShowShadowObject(isShow: boolean)
{ {
HostApplicationServices.UseShadow = isShow; HostApplicationServices.UseShadow = isShow;
@ -131,70 +51,24 @@ export class LightStore
app.Editor.UpdateScreen(); app.Editor.UpdateScreen();
} }
ClearSceneLights()
{
if (!window.confirm("确定清除掉全部场景内的灯"))
return;
let lights: TLight[] = [];
app.Viewer.Scene.traverse(obj =>
{
if (obj.userData && obj.userData.Entity instanceof Light)
{
lights.push(obj as TLight);
}
})
app.Viewer.Scene.remove(...lights);
app.Editor.UpdateScreen();
this.m_ShowAmbientLight = false;
this.m_AmbientLight = new AmbientLight();
this.m_ShowDirLight = false;
this.m_DirectionalLight = new DirectionalLight();
this.m_ShowHemiLight = false;
this.m_HemisphereLight = new HemisphereLight();
}
private WatchLightEvent() private WatchLightEvent()
{ {
let lgStore = this; end(app.Database, app.Database.FileRead, () =>
end((new Entity()).EraseEvent, function (isErase: boolean)
{ {
lgStore.WatchLight(this, isErase); this.isShowShadow = false;
}); this.ShowAmbientLight = app.Database.AmbientLight.Visible;
end(app.Database.ModelSpace, app.Database.ModelSpace.AppendEvent, function (ent: Entity) this.ShowHemiLight = app.Database.HemisphereLight.Visible;
{ this.ShowSunLight = app.Database.SunLight.Visible;
lgStore.WatchLight(ent, false);
}); });
app.CommandReactor.OnCommandEnd((name, changeo, creawteo) => app.CommandReactor.OnCommandEnd((name, changeo, creawteo) =>
{ {
this.UpdateDirLightShadowArea(); this.UpdateDirLightShadowArea();
}); });
} }
private WatchLight(lg: Entity, IsErase: boolean)
{
if (IsErase && this.currentSelectEnt === lg)
this.currentSelectEnt = undefined;
if (lg instanceof DirectionalLight)
{
this.m_DirectionalLight = lg;
this.m_ShowDirLight = !lg.IsErase;
}
else if (lg instanceof HemisphereLight)
{
this.m_HemisphereLight = lg;
this.m_ShowHemiLight = !lg.IsErase;
}
else if (lg instanceof AmbientLight)
{
this.m_AmbientLight = lg;
this.m_ShowAmbientLight = !lg.IsErase;
}
}
private UpdateDirLightShadowArea() private UpdateDirLightShadowArea()
{ {
if (HostApplicationServices.UseShadow && this.m_ShowDirLight) if (HostApplicationServices.UseShadow && !app.Database.SunLight.IsErase)
DirLightShadowArea(this.m_DirectionalLight); DirLightShadowArea(app.Database.SunLight);
} }
} }

Loading…
Cancel
Save