Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

组件可以动态生成吗 #2319

Closed
2535744721 opened this issue Jul 26, 2023 · 6 comments
Closed

组件可以动态生成吗 #2319

2535744721 opened this issue Jul 26, 2023 · 6 comments
Labels
insufficient information Further information is requested / 信息不足,请补充信息

Comments

@2535744721
Copy link

自定义组件可以动态生成吗

@JackLian
Copy link
Collaborator

详细描述下,看不太懂

@JackLian JackLian added the insufficient information Further information is requested / 信息不足,请补充信息 label Jul 26, 2023
@github-actions
Copy link

你好 @2535744721,由于缺乏必要的信息(如 bug 重现步骤、引擎版本信息 等),无法定位问题,请按照 issue bug 模板 补全信息,也可以通过阅读 引擎的 issue 说明 了解什么类型的 issue 可以获得更好、更快的支持。

@2535744721
Copy link
Author

物料 里自己写组件,想动态生成snippets里的信息,可以吗
const snippets: IPublicTypeSnippet[] = [
{
"title": "Box",
"screenshot": "/public/screenshots/box.png",
"schema": {
"componentName": "Box",
"props": {
defaultTransform: [0, 0.5, 0]
}
}
}
];

@JackLian
Copy link
Collaborator

要怎么个动态,什么环节动态,描述清楚一点吧...

@2535744721
Copy link
Author

新开发一个属于自己的组件,然后的场景是3d场景,一个模型对应一个组件,但我要做的是把导入的模型信息自动生成在snippets里面。 下面是我的box 模型信息,写在meta.ts里面的
import { IPublicTypeComponentMetadata, IPublicTypeSnippet } from '@alilc/lowcode-types';
const BoxMeta: IPublicTypeComponentMetadata = {
group: "模型",
category: "基础几何",
"componentName": "Box",
"title": "Box",
"docUrl": "",
"screenshot": "/public/screenshots/box.png",
"devMode": "proCode",
"npm": {
"package": "@zhoufantest/ioc-material",
"version": "0.1.0",
"exportName": "Box",
"main": "src\index.tsx",
"destructuring": true,
"subName": ""
},
"configure": {
"props": [
{
name: 'object',
title: '对象',
type: 'group',
display: 'block',
items: [
{
name: 'castShadow',
title: '透射阴影',
setter: 'BoolSetter',
},
{
name: 'receiveShadow',
title: '接受阴影',
setter: 'BoolSetter',
},
{
name: 'position',
title: '坐标',
setter: {
componentName: 'ObjectSetter',
props: {
config: {
items: [
{
name: '0',
title: 'X',
setter: 'NumberSetter'
},
{
name: '1',
title: 'Y',
setter: 'NumberSetter'
},
{
name: '2',
title: 'Z',
setter: 'NumberSetter'
}
]
}
}
}
},
]
},
{
name: 'material',
title: '材质',
type: 'group',
display: 'block',
items: [
{
"title": {
"label": {
"type": "i18n",
"en-US": "color",
"zh-CN": "颜色"
}
},
"name": "material.color",
"setter": 'ColorSetter'
},{
"title": {
"label": {
"type": "i18n",
"en-US": "roughness",
"zh-CN": "粗糙度"
}
},
"name": "material.roughness",
"setter": {
componentName: 'NumberSetter',
props: {
min: 0,
max: 1,
step: 0.01
}
}
},{
"title": {
"label": {
"type": "i18n",
"en-US": "color",
"zh-CN": "金属度"
}
},
"name": "material.metalness",
"setter": {
componentName: 'NumberSetter',
props: {
min: 0,
max: 1,
step: 0.01
}
}
},{
"title": {
"label": {
"type": "i18n",
"en-US": "emissive",
"zh-CN": "自发光"
}
},
"name": "material.emissive",
"setter": "ColorSetter"
},{
"title": {
"label": {
"type": "i18n",
"en-US": "emissiveIntensity",
"zh-CN": "自发光强度"
}
},
"name": "material.emissiveIntensity",
setter: {
componentName: 'NumberSetter',
props: {
step: 0.01
}
},
},
]
}

],
"supports": {
  "style": false,
    // 支持循环设置
    "loop": false,
    // 支持条件设置
    "condition": false,
},
"component": {}

}
};
const snippets: IPublicTypeSnippet[] = [
{
"title": "Box",
"screenshot": "/public/screenshots/box.png",
"schema": {
"componentName": "Box",
"props": {
defaultTransform: [0, 0.5, 0]
}
}
}
];

export default {
...BoxMeta,
snippets
};
上面信息是已经在物料里写好的组件,然后我有一个sphere模型,然后我想把模型信息生成到snippets中,如下:
const snippets: IPublicTypeSnippet[] = [
{
"title": "Box",
"screenshot": "/public/screenshots/box.png",
"schema": {
"componentName": "Box",
"props": {
defaultTransform: [0, 0.5, 0]
}
}
},
{
"title": "sphere",
"screenshot": "/public/screenshots/sphere.png",
"schema": {
"componentName": "Sphere",
"props": {
defaultTransform: [0, 0.5, 0]
}
}
}
];
但加入的snippets中我不想手动写进去,想问snippets里面的信息可以动态生成吗

@JackLian
Copy link
Collaborator

是你开发meta时候不想手写还是说开发时候还没法写,如果是不想手写,那你自己做个工具去生成就好了,如果是必须要在设计器内才知道以什么规则动态生成,那就写个插件处理,参考 https://lowcode-engine.cn/site/docs/api/material#registermetadatatransducer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
insufficient information Further information is requested / 信息不足,请补充信息
Projects
None yet
Development

No branches or pull requests

2 participants