2021-04-04 19:21:17 +08:00
|
|
|
export enum DataType {
|
|
|
|
Number,
|
|
|
|
String,
|
|
|
|
Text,
|
|
|
|
Vec2,
|
|
|
|
Vec3,
|
|
|
|
Enum,
|
|
|
|
Bool,
|
|
|
|
Color,
|
|
|
|
}
|
|
|
|
|
|
|
|
class Info {
|
|
|
|
public type: DataType = DataType.Number;
|
2021-04-05 18:38:44 +08:00
|
|
|
public data: any;
|
2021-04-04 19:21:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export class TextData extends Info {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.type = DataType.Text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-05 18:38:44 +08:00
|
|
|
export class ColorData extends Info {
|
|
|
|
constructor(color: string) {
|
|
|
|
super();
|
|
|
|
this.type = DataType.Color;
|
|
|
|
this.data = color;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-04 19:21:17 +08:00
|
|
|
export class StringData extends Info {
|
2021-04-05 18:38:44 +08:00
|
|
|
constructor(data: string) {
|
2021-04-04 19:21:17 +08:00
|
|
|
super();
|
|
|
|
this.type = DataType.String;
|
2021-04-05 18:38:44 +08:00
|
|
|
this.data = data;
|
2021-04-04 19:21:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class NumberData extends Info {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.type = DataType.Number;
|
2021-04-05 18:38:44 +08:00
|
|
|
this.data = 1;
|
2021-04-04 19:21:17 +08:00
|
|
|
}
|
2021-04-05 18:38:44 +08:00
|
|
|
}
|
2021-04-04 19:21:17 +08:00
|
|
|
|
2021-04-05 18:38:44 +08:00
|
|
|
export class BoolData extends Info {
|
|
|
|
constructor(bol: boolean) {
|
|
|
|
super();
|
|
|
|
this.type = DataType.Bool;
|
|
|
|
this.data = bol;
|
|
|
|
}
|
2021-04-04 19:21:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export class Vec2Data extends Info {
|
2021-04-05 18:38:44 +08:00
|
|
|
constructor() {
|
2021-04-04 19:21:17 +08:00
|
|
|
super();
|
|
|
|
this.type = DataType.Vec2
|
2021-04-05 18:38:44 +08:00
|
|
|
this.data = [];
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
add(info: Property) {
|
|
|
|
this.data.push(info);
|
|
|
|
return this;
|
2021-04-04 19:21:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Vec3Data extends Info {
|
|
|
|
|
2021-04-05 18:38:44 +08:00
|
|
|
constructor() {
|
2021-04-04 19:21:17 +08:00
|
|
|
super();
|
2021-04-05 18:38:44 +08:00
|
|
|
this.type = DataType.Vec3;
|
|
|
|
this.data = [];
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
add(info: Property) {
|
|
|
|
this.data.push(info);
|
|
|
|
return this;
|
2021-04-04 19:21:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class EnumData extends Info {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.type = DataType.Enum;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-04-05 18:38:44 +08:00
|
|
|
export class Property {
|
|
|
|
public name: string = 'property';
|
|
|
|
public value: Info = new Info();
|
|
|
|
|
|
|
|
constructor(name: string, info: Info) {
|
|
|
|
this.name = name;
|
|
|
|
this.value = info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Group {
|
|
|
|
public name: string = 'group';
|
|
|
|
public data: Array<Property> = [];
|
|
|
|
|
|
|
|
constructor(name: string) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
addProperty(property: Property) {
|
|
|
|
this.data.push(property)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-04 19:21:17 +08:00
|
|
|
class NodeInfo {
|
|
|
|
public type: string = ''; // 类型
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class CompInfo {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export const testData = [
|
|
|
|
{
|
|
|
|
name: "group1",
|
|
|
|
data: [
|
|
|
|
{name: "uuid", value: {type: DataType.String, data: 'abc'}},
|
|
|
|
{name: "opacity", value: {type: DataType.Number, data: 100}},
|
|
|
|
|
|
|
|
{
|
|
|
|
name: "size",
|
|
|
|
value: {
|
|
|
|
type: DataType.Vec2,
|
|
|
|
data: [
|
|
|
|
{name: "X", value: {type: DataType.Number, data: 100}},
|
|
|
|
{name: "Y", value: {type: DataType.Number, data: 200}},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "position",
|
|
|
|
value: {
|
|
|
|
type: DataType.Vec3,
|
|
|
|
data: [
|
|
|
|
{name: "X", value: {type: DataType.Number, data: 100}},
|
|
|
|
{name: "Y", value: {type: DataType.Number, data: 200}},
|
|
|
|
{name: "Z", value: {type: DataType.Number, data: 300}},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "layout",
|
|
|
|
value: {
|
|
|
|
type: DataType.Enum,
|
|
|
|
data: 1,
|
|
|
|
values: [
|
|
|
|
{name: "horizontal", value: 1},
|
|
|
|
{name: "vertical", value: 2},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "text",
|
|
|
|
value: {
|
|
|
|
type: DataType.Text,
|
|
|
|
data: 'aaaaaaaaafsf',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "group2",
|
|
|
|
data: [
|
|
|
|
{
|
|
|
|
name: "bool", value: {
|
|
|
|
type: DataType.Bool,
|
|
|
|
data: true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'color',
|
|
|
|
value: {
|
|
|
|
type: DataType.Color,
|
|
|
|
data: '#ff0000'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|