@flow3d/preset-industrial
v0.1.0
Published
Industrial domain preset for Flow3D — node kinds, styles and labels for plant / process flow scenes.
Maintainers
Readme
@flow3d/preset-industrial
Flow3D 的工业领域预设(M4 交付)。提供一套面向工厂 / 工艺流程图的节点词汇、流词汇与运行状态样式。
本包是唯一被允许出现行业术语的包(见
docs/03ADR-001)。core 的 ESLint 规则flow3d/no-domain-terms在此不生效——本包的存在正是为了承载这些词汇,并向使用者示范 「如何为自己的行业写一套 preset」。预设只产出纯数据(DomainPreset),不引入任何three依赖;渲染由FlowScene在应用层完成。
安装
pnpm add @flow3d/preset-industrial快速开始
import { createDefaultRegistry, FlowScene } from '@flow3d/core';
import { installIndustrial } from '@flow3d/preset-industrial';
const reg = createDefaultRegistry();
installIndustrial(reg); // 注册 nodeKinds / flowKinds / states
const scene = new FlowScene({ registry: reg });
await scene.load({
version: '1.0',
presets: ['industrial'], // 文档引用已注册的预设
nodes: [
{ id: 't1', kind: 'tank' },
{ id: 'p1', kind: 'pump' },
],
flows: [{ from: 't1', to: 'p1', kind: 'process' }],
});installIndustrial(reg, options?) 是推荐入口;若只想读取纯数据,也可直接导入
industrialPreset 对象自行处理。
节点词汇(nodeKinds)
| kind | label | 默认几何 | 端口(anchor) |
| --------------- | ------ | ------------------ | --------------------------------------------------- |
| tank | 储罐 | 圆柱 r1.2×h2.4 | inlet(top) / outlet(bottom) |
| reactor | 反应釜 | 圆柱 r1.4×h2.8 | feed(top) / product(bottom) |
| pump | 泵 | 方体 1³ | inlet(-x) / outlet(+x) |
| valve | 阀门 | 扁方体 0.6³ | inlet(-x) / outlet(+x) |
| sensor | 传感器 | 小方体 0.5³ | probe(+y) |
| heatExchanger | 换热器 | 长方体 1.6×1.2×1.2 | in-a(-x) / out-a(+x) / in-b(-z) / out-b(+z) |
| compressor | 压缩机 | 方体 1.4×1×1 | suction(-x) / discharge(+x) |
| pipe | 管段 | 长条盒 2×0.3×0.3 | inlet(-x) / outlet(+x) |
无 kind 且未显式给 source 的节点,会回退到 defaults.node.source(一个灰色 1³ 方体),
不会触发 E_NODE_SOURCE_MISSING。
流词汇(flowKinds)
| kind | label | 渲染 | 动画 |
| --------- | -------- | ------------------- | -------------- |
| process | 工艺流 | tube 蓝 #2e86de | speed 1.2 |
| steam | 蒸汽 | tube 浅灰 #bdc3c7 | speed 0.9 |
| gas | 气体 | tube 青绿 #1abc9c | speed 1.6 |
| control | 控制信号 | line 琥珀 #f39c12 | 无(静态细线) |
流的默认渲染(无 kind 时)来自 defaults.flow.render:tube,width 0.12。
状态样式(states)
状态名可用于节点 / 流的 state 字段,由渲染层映射为颜色(与发光)。
| state | nodeColor | 说明 |
| ------------- | --------- | ---------------- |
| running | #27ae60 | 运行 |
| warning | #f39c12 | 告警 |
| fault | #e74c3c | 故障(带自发光) |
| idle | #95a5a6 | 停机 |
| maintenance | #2980b9 | 维护中 |
设计依据
见仓库 docs/01-Flow3D-技术设计文档.md §5.13 与 docs/03-Flow3D-实现确定性附录.md §2.21。
任何实现细节以这两份文档为准。本包单测位于 packages/preset-industrial/test/unit。
License
MIT
