bplinejs 0.0.101-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +215 -0
- package/docs/API.md +471 -0
- package/lib/Camera/index.d.ts +88 -0
- package/lib/Camera/index.js +178 -0
- package/lib/Camera/index.js.map +1 -0
- package/lib/Color/index.d.ts +99 -0
- package/lib/Color/index.js +178 -0
- package/lib/Color/index.js.map +1 -0
- package/lib/Geometry/Geo.d.ts +131 -0
- package/lib/Geometry/Geo.js +180 -0
- package/lib/Geometry/Geo.js.map +1 -0
- package/lib/Geometry/Poly2D.d.ts +53 -0
- package/lib/Geometry/Poly2D.js +133 -0
- package/lib/Geometry/Poly2D.js.map +1 -0
- package/lib/Geometry/Rect2d.d.ts +89 -0
- package/lib/Geometry/Rect2d.js +128 -0
- package/lib/Geometry/Rect2d.js.map +1 -0
- package/lib/Geometry/index.d.ts +6 -0
- package/lib/Geometry/index.js +4 -0
- package/lib/Group/index.d.ts +70 -0
- package/lib/Group/index.js +110 -0
- package/lib/Group/index.js.map +1 -0
- package/lib/ID.d.ts +6 -0
- package/lib/ID.js +15 -0
- package/lib/ID.js.map +1 -0
- package/lib/IMesh/index.d.ts +104 -0
- package/lib/IMesh/index.js +333 -0
- package/lib/IMesh/index.js.map +1 -0
- package/lib/Material/Material.d.ts +158 -0
- package/lib/Material/Material.js +229 -0
- package/lib/Material/Material.js.map +1 -0
- package/lib/Material/baseMaterial.d.ts +15 -0
- package/lib/Material/baseMaterial.js +24 -0
- package/lib/Material/baseMaterial.js.map +1 -0
- package/lib/Material/index.d.ts +4 -0
- package/lib/Material/index.js +3 -0
- package/lib/Material/shaders/base/poly/fragment.js +6 -0
- package/lib/Material/shaders/base/poly/fragment.js.map +1 -0
- package/lib/Material/shaders/base/poly/vertex.js +6 -0
- package/lib/Material/shaders/base/poly/vertex.js.map +1 -0
- package/lib/Material/shaders/base/rect/fragment.js +6 -0
- package/lib/Material/shaders/base/rect/fragment.js.map +1 -0
- package/lib/Material/shaders/base/rect/vertex.js +6 -0
- package/lib/Material/shaders/base/rect/vertex.js.map +1 -0
- package/lib/Material/shaders/line/fragment.js +6 -0
- package/lib/Material/shaders/line/fragment.js.map +1 -0
- package/lib/Material/shaders/line/vertex.js +6 -0
- package/lib/Material/shaders/line/vertex.js.map +1 -0
- package/lib/Mesh/index.d.ts +154 -0
- package/lib/Mesh/index.js +254 -0
- package/lib/Mesh/index.js.map +1 -0
- package/lib/Object/index.d.ts +95 -0
- package/lib/Object/index.js +212 -0
- package/lib/Object/index.js.map +1 -0
- package/lib/Raws/index.d.ts +87 -0
- package/lib/Raws/index.js +164 -0
- package/lib/Raws/index.js.map +1 -0
- package/lib/Render/BufferManager.d.ts +93 -0
- package/lib/Render/BufferManager.js +281 -0
- package/lib/Render/BufferManager.js.map +1 -0
- package/lib/Render/DepthManager.d.ts +22 -0
- package/lib/Render/DepthManager.js +95 -0
- package/lib/Render/DepthManager.js.map +1 -0
- package/lib/Render/DestroyManager.d.ts +74 -0
- package/lib/Render/DestroyManager.js +221 -0
- package/lib/Render/DestroyManager.js.map +1 -0
- package/lib/Render/DevelopmentValidator.d.ts +73 -0
- package/lib/Render/DevelopmentValidator.js +188 -0
- package/lib/Render/DevelopmentValidator.js.map +1 -0
- package/lib/Render/DrawCallManager.d.ts +58 -0
- package/lib/Render/DrawCallManager.js +267 -0
- package/lib/Render/DrawCallManager.js.map +1 -0
- package/lib/Render/PipelineManager.d.ts +46 -0
- package/lib/Render/PipelineManager.js +254 -0
- package/lib/Render/PipelineManager.js.map +1 -0
- package/lib/Render/SamplerManager.d.ts +26 -0
- package/lib/Render/SamplerManager.js +42 -0
- package/lib/Render/SamplerManager.js.map +1 -0
- package/lib/Render/SceneUpdate.d.ts +9 -0
- package/lib/Render/SceneUpdate.js +18 -0
- package/lib/Render/SceneUpdate.js.map +1 -0
- package/lib/Render/TextureManager.d.ts +33 -0
- package/lib/Render/TextureManager.js +152 -0
- package/lib/Render/TextureManager.js.map +1 -0
- package/lib/Render/index.d.ts +212 -0
- package/lib/Render/index.js +347 -0
- package/lib/Render/index.js.map +1 -0
- package/lib/Render/types.d.ts +191 -0
- package/lib/Scene/index.d.ts +124 -0
- package/lib/Scene/index.js +225 -0
- package/lib/Scene/index.js.map +1 -0
- package/lib/Style/EdgeStyle.d.ts +28 -0
- package/lib/Style/EdgeStyle.js +67 -0
- package/lib/Style/EdgeStyle.js.map +1 -0
- package/lib/Style/JoinStyle.d.ts +27 -0
- package/lib/Style/JoinStyle.js +53 -0
- package/lib/Style/JoinStyle.js.map +1 -0
- package/lib/Style/PartStyle.d.ts +50 -0
- package/lib/Style/PartStyle.js +92 -0
- package/lib/Style/PartStyle.js.map +1 -0
- package/lib/Style/PointsStyle.d.ts +43 -0
- package/lib/Style/PointsStyle.js +98 -0
- package/lib/Style/PointsStyle.js.map +1 -0
- package/lib/Style/SolidStyle.d.ts +37 -0
- package/lib/Style/SolidStyle.js +83 -0
- package/lib/Style/SolidStyle.js.map +1 -0
- package/lib/Style/TexturedStyle.d.ts +29 -0
- package/lib/Style/TexturedStyle.js +66 -0
- package/lib/Style/TexturedStyle.js.map +1 -0
- package/lib/Style/WireframeStyle.d.ts +7 -0
- package/lib/Style/WireframeStyle.js +13 -0
- package/lib/Style/WireframeStyle.js.map +1 -0
- package/lib/Style/WriteStyleData.d.ts +10 -0
- package/lib/Style/WriteStyleData.js +59 -0
- package/lib/Style/WriteStyleData.js.map +1 -0
- package/lib/Style/index.d.ts +50 -0
- package/lib/Style/index.js +92 -0
- package/lib/Style/index.js.map +1 -0
- package/lib/Style/types.d.ts +21 -0
- package/lib/Texture/Layers.d.ts +26 -0
- package/lib/Texture/Layers.js +42 -0
- package/lib/Texture/Layers.js.map +1 -0
- package/lib/Texture/index.d.ts +116 -0
- package/lib/Texture/index.js +198 -0
- package/lib/Texture/index.js.map +1 -0
- package/lib/global-types.d.ts +8 -0
- package/lib/index.d.ts +43 -0
- package/lib/index.js +34 -0
- package/package.json +130 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import Color from "../Color/index.js";
|
|
2
|
+
//#region src/scripts/Style/PartStyle.ts
|
|
3
|
+
/** 四个样式分区的共同基础,仅管理显示、颜色、透明度和订阅。 */
|
|
4
|
+
var PartStyle = class {
|
|
5
|
+
/** 分区身份。 */
|
|
6
|
+
area;
|
|
7
|
+
_subscribers = /* @__PURE__ */ new Set();
|
|
8
|
+
_enabled = false;
|
|
9
|
+
_color = new Color();
|
|
10
|
+
_opacity = 1;
|
|
11
|
+
/**
|
|
12
|
+
* 创建分区并订阅默认颜色。
|
|
13
|
+
* @param area 分区身份
|
|
14
|
+
*/
|
|
15
|
+
constructor(area) {
|
|
16
|
+
this.area = area;
|
|
17
|
+
this._color.add(this, "color");
|
|
18
|
+
}
|
|
19
|
+
/** 是否生成并显示该分区,默认关闭。 */
|
|
20
|
+
get enabled() {
|
|
21
|
+
return this._enabled;
|
|
22
|
+
}
|
|
23
|
+
/** @param value 是否启用该分区 */
|
|
24
|
+
set enabled(value) {
|
|
25
|
+
if (this._enabled === value) return;
|
|
26
|
+
this._enabled = value;
|
|
27
|
+
this.notify("enabled");
|
|
28
|
+
}
|
|
29
|
+
/** 该分区独立颜色,默认不透明白色。 */
|
|
30
|
+
get color() {
|
|
31
|
+
return this._color;
|
|
32
|
+
}
|
|
33
|
+
/** @param value 新颜色引用;先解绑旧颜色,再订阅新颜色 */
|
|
34
|
+
set color(value) {
|
|
35
|
+
if (this._color === value) return;
|
|
36
|
+
this._color.delete(this, "color");
|
|
37
|
+
this._color = value;
|
|
38
|
+
value.add(this, "color");
|
|
39
|
+
this.notify("color");
|
|
40
|
+
}
|
|
41
|
+
/** 该分区独立透明度,作用于最终输出 alpha。 */
|
|
42
|
+
get opacity() {
|
|
43
|
+
return this._opacity;
|
|
44
|
+
}
|
|
45
|
+
/** @param value 透明度,钳制到 0 到 1 */
|
|
46
|
+
set opacity(value) {
|
|
47
|
+
value = NormalizeSize(value);
|
|
48
|
+
value = Math.min(1, value);
|
|
49
|
+
if (this._opacity === value) return;
|
|
50
|
+
this._opacity = value;
|
|
51
|
+
this.notify("opacity");
|
|
52
|
+
}
|
|
53
|
+
/** @param subscriber 分区变化接收者 */
|
|
54
|
+
add(subscriber) {
|
|
55
|
+
this._subscribers.add(subscriber);
|
|
56
|
+
}
|
|
57
|
+
/** @param subscriber 要解除的接收者;不销毁对象或 GPU 缓存 */
|
|
58
|
+
delete(subscriber) {
|
|
59
|
+
this._subscribers.delete(subscriber);
|
|
60
|
+
}
|
|
61
|
+
/** 最终停止使用时解除颜色订阅及分区订阅;不销毁共享 Color。 */
|
|
62
|
+
dispose() {
|
|
63
|
+
this._color.delete(this, "color");
|
|
64
|
+
this._subscribers.clear();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 接收颜色的字段级通知。
|
|
68
|
+
* @param color 来源颜色
|
|
69
|
+
* @param field 颜色属性名
|
|
70
|
+
*/
|
|
71
|
+
onColorChange(color, field) {
|
|
72
|
+
if (field === "color" && color !== this._color) return;
|
|
73
|
+
this.notify(field);
|
|
74
|
+
}
|
|
75
|
+
/** @param field 实际变化的字段名 */
|
|
76
|
+
notify(field) {
|
|
77
|
+
for (const subscriber of [...this._subscribers]) subscriber.onPartChange(this.area, field);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* 验证尺寸参数并钳制负值;拒绝非有限值,避免污染几何和 GPU 数据。
|
|
82
|
+
* @param value 待验证数值
|
|
83
|
+
* @returns 非负有限值
|
|
84
|
+
*/
|
|
85
|
+
var NormalizeSize = (value) => {
|
|
86
|
+
if (!Number.isFinite(value)) throw new RangeError("Style values must be finite.");
|
|
87
|
+
return Math.max(0, value);
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
90
|
+
export { NormalizeSize, PartStyle as default };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=PartStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PartStyle.js","names":[],"sources":["../../src/scripts/Style/PartStyle.ts"],"sourcesContent":["import Color from \"../Color\";\nimport type { ColorSubscriber } from \"../Color\";\nimport type { PartSubscriber, StyleArea } from \"./types\";\n\n/** 四个样式分区的共同基础,仅管理显示、颜色、透明度和订阅。 */\nclass PartStyle implements ColorSubscriber {\n /** 分区身份。 */\n public readonly area: Exclude<StyleArea, \"whole\">;\n private readonly _subscribers = new Set<PartSubscriber>();\n private _enabled: boolean = false;\n private _color: Color = new Color();\n private _opacity: number = 1;\n\n /**\n * 创建分区并订阅默认颜色。\n * @param area 分区身份\n */\n public constructor(area: Exclude<StyleArea, \"whole\">) {\n this.area = area;\n this._color.add(this, \"color\");\n }\n /** 是否生成并显示该分区,默认关闭。 */\n public get enabled(): boolean { return this._enabled; }\n /** @param value 是否启用该分区 */\n public set enabled(value: boolean) {\n if (this._enabled === value) return;\n this._enabled = value;\n this.notify(\"enabled\");\n }\n /** 该分区独立颜色,默认不透明白色。 */\n public get color(): Color { return this._color; }\n /** @param value 新颜色引用;先解绑旧颜色,再订阅新颜色 */\n public set color(value: Color) {\n if (this._color === value) return;\n this._color.delete(this, \"color\");\n this._color = value;\n value.add(this, \"color\");\n this.notify(\"color\");\n }\n /** 该分区独立透明度,作用于最终输出 alpha。 */\n public get opacity(): number { return this._opacity; }\n /** @param value 透明度,钳制到 0 到 1 */\n public set opacity(value: number) {\n value = NormalizeSize(value);\n value = Math.min(1, value);\n if (this._opacity === value) return;\n this._opacity = value;\n this.notify(\"opacity\");\n }\n /** @param subscriber 分区变化接收者 */\n public add(subscriber: PartSubscriber): void { this._subscribers.add(subscriber); }\n /** @param subscriber 要解除的接收者;不销毁对象或 GPU 缓存 */\n public delete(subscriber: PartSubscriber): void { this._subscribers.delete(subscriber); }\n /** 最终停止使用时解除颜色订阅及分区订阅;不销毁共享 Color。 */\n public dispose(): void {\n this._color.delete(this, \"color\");\n this._subscribers.clear();\n }\n /**\n * 接收颜色的字段级通知。\n * @param color 来源颜色\n * @param field 颜色属性名\n */\n public onColorChange(color: Color, field: string): void {\n if (field === \"color\" && color !== this._color) return;\n this.notify(field);\n }\n /** @param field 实际变化的字段名 */\n protected notify(field: string): void {\n for (const subscriber of [...this._subscribers]) subscriber.onPartChange(this.area, field);\n }\n}\n/**\n * 验证尺寸参数并钳制负值;拒绝非有限值,避免污染几何和 GPU 数据。\n * @param value 待验证数值\n * @returns 非负有限值\n */\nexport const NormalizeSize = (value: number): number => {\n if (!Number.isFinite(value)) throw new RangeError(\"Style values must be finite.\");\n return Math.max(0, value);\n};\nexport default PartStyle;\n"],"mappings":";;;AAKA,IAAM,YAAN,MAA2C;;CAEvC;CACA,+BAAgC,IAAI,IAAoB;CACxD,WAA4B;CAC5B,SAAwB,IAAI,MAAM;CAClC,WAA2B;;;;;CAM3B,YAAmB,MAAmC;EAClD,KAAK,OAAO;EACZ,KAAK,OAAO,IAAI,MAAM,OAAO;CACjC;;CAEA,IAAW,UAAmB;EAAE,OAAO,KAAK;CAAU;;CAEtD,IAAW,QAAQ,OAAgB;EAC/B,IAAI,KAAK,aAAa,OAAO;EAC7B,KAAK,WAAW;EAChB,KAAK,OAAO,SAAS;CACzB;;CAEA,IAAW,QAAe;EAAE,OAAO,KAAK;CAAQ;;CAEhD,IAAW,MAAM,OAAc;EAC3B,IAAI,KAAK,WAAW,OAAO;EAC3B,KAAK,OAAO,OAAO,MAAM,OAAO;EAChC,KAAK,SAAS;EACd,MAAM,IAAI,MAAM,OAAO;EACvB,KAAK,OAAO,OAAO;CACvB;;CAEA,IAAW,UAAkB;EAAE,OAAO,KAAK;CAAU;;CAErD,IAAW,QAAQ,OAAe;EAC9B,QAAQ,cAAc,KAAK;EAC3B,QAAQ,KAAK,IAAI,GAAG,KAAK;EACzB,IAAI,KAAK,aAAa,OAAO;EAC7B,KAAK,WAAW;EAChB,KAAK,OAAO,SAAS;CACzB;;CAEA,IAAW,YAAkC;EAAE,KAAK,aAAa,IAAI,UAAU;CAAG;;CAElF,OAAc,YAAkC;EAAE,KAAK,aAAa,OAAO,UAAU;CAAG;;CAExF,UAAuB;EACnB,KAAK,OAAO,OAAO,MAAM,OAAO;EAChC,KAAK,aAAa,MAAM;CAC5B;;;;;;CAMA,cAAqB,OAAc,OAAqB;EACpD,IAAI,UAAU,WAAW,UAAU,KAAK,QAAQ;EAChD,KAAK,OAAO,KAAK;CACrB;;CAEA,OAAiB,OAAqB;EAClC,KAAK,MAAM,cAAc,CAAC,GAAG,KAAK,YAAY,GAAG,WAAW,aAAa,KAAK,MAAM,KAAK;CAC7F;AACJ;;;;;;AAMA,IAAa,iBAAiB,UAA0B;CACpD,IAAI,CAAC,OAAO,SAAS,KAAK,GAAG,MAAM,IAAI,WAAW,8BAA8B;CAChF,OAAO,KAAK,IAAI,GAAG,KAAK;AAC5B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import TexturedStyle from "./TexturedStyle";
|
|
2
|
+
import type { PixelAligned } from "./types";
|
|
3
|
+
/** 关键点样式;总开关与顶点/边中点选择分离。 */
|
|
4
|
+
declare class PointsStyle extends TexturedStyle {
|
|
5
|
+
/** 创建关闭的点型,默认选择顶点点位,UV 两轴固定不重复。 */
|
|
6
|
+
constructor();
|
|
7
|
+
private _pixelAligned;
|
|
8
|
+
/** px 固定像素,zoom 随相机缩放。 */
|
|
9
|
+
get pixelAligned(): PixelAligned;
|
|
10
|
+
/** @param value px 固定像素,zoom 随相机缩放。 */
|
|
11
|
+
set pixelAligned(value: PixelAligned);
|
|
12
|
+
private _vertices;
|
|
13
|
+
/** 是否生成顶点点位;仍受 enabled 总开关控制。 */
|
|
14
|
+
get vertices(): boolean;
|
|
15
|
+
/** @param value 是否生成顶点点位;仍受 enabled 总开关控制。 */
|
|
16
|
+
set vertices(value: boolean);
|
|
17
|
+
private _midpoints;
|
|
18
|
+
/** 是否生成边中点;仍受 enabled 总开关控制。 */
|
|
19
|
+
get midpoints(): boolean;
|
|
20
|
+
/** @param value 是否生成边中点;仍受 enabled 总开关控制。 */
|
|
21
|
+
set midpoints(value: boolean);
|
|
22
|
+
private _radius;
|
|
23
|
+
/** 点半径,默认 2。 */
|
|
24
|
+
get radius(): number;
|
|
25
|
+
/** @param value 点半径,默认 2。 */
|
|
26
|
+
set radius(value: number);
|
|
27
|
+
private _segments;
|
|
28
|
+
/** 点型边数,默认 4。 */
|
|
29
|
+
get segments(): number;
|
|
30
|
+
/** @param value 点型边数,默认 4。 */
|
|
31
|
+
set segments(value: number);
|
|
32
|
+
private _minPointsLength;
|
|
33
|
+
/** 顶点相邻边长度之和的严格下限。 */
|
|
34
|
+
get minPointsLength(): number;
|
|
35
|
+
/** @param value 顶点相邻边长度之和的严格下限。 */
|
|
36
|
+
set minPointsLength(value: number);
|
|
37
|
+
private _minEdgePointsLength;
|
|
38
|
+
/** 边中点所在边长度的严格下限。 */
|
|
39
|
+
get minEdgePointsLength(): number;
|
|
40
|
+
/** @param value 边中点所在边长度的严格下限。 */
|
|
41
|
+
set minEdgePointsLength(value: number);
|
|
42
|
+
}
|
|
43
|
+
export default PointsStyle;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { NormalizeSize } from "./PartStyle.js";
|
|
2
|
+
import TexturedStyle from "./TexturedStyle.js";
|
|
3
|
+
//#region src/scripts/Style/PointsStyle.ts
|
|
4
|
+
/** 关键点样式;总开关与顶点/边中点选择分离。 */
|
|
5
|
+
var PointsStyle = class extends TexturedStyle {
|
|
6
|
+
/** 创建关闭的点型,默认选择顶点点位,UV 两轴固定不重复。 */
|
|
7
|
+
constructor() {
|
|
8
|
+
super("points");
|
|
9
|
+
this.addressModeU = "clamp-to-edge";
|
|
10
|
+
this.addressModeV = "clamp-to-edge";
|
|
11
|
+
}
|
|
12
|
+
_pixelAligned = "px";
|
|
13
|
+
/** px 固定像素,zoom 随相机缩放。 */
|
|
14
|
+
get pixelAligned() {
|
|
15
|
+
return this._pixelAligned;
|
|
16
|
+
}
|
|
17
|
+
/** @param value px 固定像素,zoom 随相机缩放。 */
|
|
18
|
+
set pixelAligned(value) {
|
|
19
|
+
if (!["px", "zoom"].includes(value)) throw new TypeError("Invalid pixel alignment.");
|
|
20
|
+
if (this._pixelAligned === value) return;
|
|
21
|
+
this._pixelAligned = value;
|
|
22
|
+
this.notify("pixelAligned");
|
|
23
|
+
}
|
|
24
|
+
_vertices = true;
|
|
25
|
+
/** 是否生成顶点点位;仍受 enabled 总开关控制。 */
|
|
26
|
+
get vertices() {
|
|
27
|
+
return this._vertices;
|
|
28
|
+
}
|
|
29
|
+
/** @param value 是否生成顶点点位;仍受 enabled 总开关控制。 */
|
|
30
|
+
set vertices(value) {
|
|
31
|
+
if (this._vertices === value) return;
|
|
32
|
+
this._vertices = value;
|
|
33
|
+
this.notify("vertices");
|
|
34
|
+
}
|
|
35
|
+
_midpoints = false;
|
|
36
|
+
/** 是否生成边中点;仍受 enabled 总开关控制。 */
|
|
37
|
+
get midpoints() {
|
|
38
|
+
return this._midpoints;
|
|
39
|
+
}
|
|
40
|
+
/** @param value 是否生成边中点;仍受 enabled 总开关控制。 */
|
|
41
|
+
set midpoints(value) {
|
|
42
|
+
if (this._midpoints === value) return;
|
|
43
|
+
this._midpoints = value;
|
|
44
|
+
this.notify("midpoints");
|
|
45
|
+
}
|
|
46
|
+
_radius = 2;
|
|
47
|
+
/** 点半径,默认 2。 */
|
|
48
|
+
get radius() {
|
|
49
|
+
return this._radius;
|
|
50
|
+
}
|
|
51
|
+
/** @param value 点半径,默认 2。 */
|
|
52
|
+
set radius(value) {
|
|
53
|
+
value = NormalizeSize(value);
|
|
54
|
+
if (this._radius === value) return;
|
|
55
|
+
this._radius = value;
|
|
56
|
+
this.notify("radius");
|
|
57
|
+
}
|
|
58
|
+
_segments = 4;
|
|
59
|
+
/** 点型边数,默认 4。 */
|
|
60
|
+
get segments() {
|
|
61
|
+
return this._segments;
|
|
62
|
+
}
|
|
63
|
+
/** @param value 点型边数,默认 4。 */
|
|
64
|
+
set segments(value) {
|
|
65
|
+
if (!Number.isSafeInteger(value) || value < 3) throw new RangeError("Point segments must be an integer >= 3.");
|
|
66
|
+
if (this._segments === value) return;
|
|
67
|
+
this._segments = value;
|
|
68
|
+
this.notify("segments");
|
|
69
|
+
}
|
|
70
|
+
_minPointsLength = 6;
|
|
71
|
+
/** 顶点相邻边长度之和的严格下限。 */
|
|
72
|
+
get minPointsLength() {
|
|
73
|
+
return this._minPointsLength;
|
|
74
|
+
}
|
|
75
|
+
/** @param value 顶点相邻边长度之和的严格下限。 */
|
|
76
|
+
set minPointsLength(value) {
|
|
77
|
+
value = NormalizeSize(value);
|
|
78
|
+
if (this._minPointsLength === value) return;
|
|
79
|
+
this._minPointsLength = value;
|
|
80
|
+
this.notify("minPointsLength");
|
|
81
|
+
}
|
|
82
|
+
_minEdgePointsLength = 4;
|
|
83
|
+
/** 边中点所在边长度的严格下限。 */
|
|
84
|
+
get minEdgePointsLength() {
|
|
85
|
+
return this._minEdgePointsLength;
|
|
86
|
+
}
|
|
87
|
+
/** @param value 边中点所在边长度的严格下限。 */
|
|
88
|
+
set minEdgePointsLength(value) {
|
|
89
|
+
value = NormalizeSize(value);
|
|
90
|
+
if (this._minEdgePointsLength === value) return;
|
|
91
|
+
this._minEdgePointsLength = value;
|
|
92
|
+
this.notify("minEdgePointsLength");
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
export { PointsStyle as default };
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=PointsStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PointsStyle.js","names":[],"sources":["../../src/scripts/Style/PointsStyle.ts"],"sourcesContent":["import TexturedStyle from \"./TexturedStyle\";\nimport { NormalizeSize } from \"./PartStyle\";\nimport type { PixelAligned } from \"./types\";\n\n/** 关键点样式;总开关与顶点/边中点选择分离。 */\nclass PointsStyle extends TexturedStyle {\n /** 创建关闭的点型,默认选择顶点点位,UV 两轴固定不重复。 */\n public constructor() {\n super(\"points\");\n this.addressModeU = \"clamp-to-edge\";\n this.addressModeV = \"clamp-to-edge\";\n }\n\n private _pixelAligned: PixelAligned = \"px\";\n /** px 固定像素,zoom 随相机缩放。 */\n public get pixelAligned(): PixelAligned { return this._pixelAligned; }\n /** @param value px 固定像素,zoom 随相机缩放。 */\n public set pixelAligned(value: PixelAligned) {\n if (![\"px\", \"zoom\"].includes(value)) throw new TypeError(\"Invalid pixel alignment.\");\n if (this._pixelAligned === value) return;\n this._pixelAligned = value;\n this.notify(\"pixelAligned\");\n }\n\n\n private _vertices: boolean = true;\n /** 是否生成顶点点位;仍受 enabled 总开关控制。 */\n public get vertices(): boolean { return this._vertices; }\n /** @param value 是否生成顶点点位;仍受 enabled 总开关控制。 */\n public set vertices(value: boolean) {\n \n if (this._vertices === value) return;\n this._vertices = value;\n this.notify(\"vertices\");\n }\n\n\n private _midpoints: boolean = false;\n /** 是否生成边中点;仍受 enabled 总开关控制。 */\n public get midpoints(): boolean { return this._midpoints; }\n /** @param value 是否生成边中点;仍受 enabled 总开关控制。 */\n public set midpoints(value: boolean) {\n \n if (this._midpoints === value) return;\n this._midpoints = value;\n this.notify(\"midpoints\");\n }\n\n\n private _radius: number = 2;\n /** 点半径,默认 2。 */\n public get radius(): number { return this._radius; }\n /** @param value 点半径,默认 2。 */\n public set radius(value: number) {\n value = NormalizeSize(value);\n if (this._radius === value) return;\n this._radius = value;\n this.notify(\"radius\");\n }\n\n\n private _segments: number = 4;\n /** 点型边数,默认 4。 */\n public get segments(): number { return this._segments; }\n /** @param value 点型边数,默认 4。 */\n public set segments(value: number) {\n if (!Number.isSafeInteger(value) || value < 3) throw new RangeError(\"Point segments must be an integer >= 3.\");\n if (this._segments === value) return;\n this._segments = value;\n this.notify(\"segments\");\n }\n\n\n private _minPointsLength: number = 6;\n /** 顶点相邻边长度之和的严格下限。 */\n public get minPointsLength(): number { return this._minPointsLength; }\n /** @param value 顶点相邻边长度之和的严格下限。 */\n public set minPointsLength(value: number) {\n value = NormalizeSize(value);\n if (this._minPointsLength === value) return;\n this._minPointsLength = value;\n this.notify(\"minPointsLength\");\n }\n\n\n private _minEdgePointsLength: number = 4;\n /** 边中点所在边长度的严格下限。 */\n public get minEdgePointsLength(): number { return this._minEdgePointsLength; }\n /** @param value 边中点所在边长度的严格下限。 */\n public set minEdgePointsLength(value: number) {\n value = NormalizeSize(value);\n if (this._minEdgePointsLength === value) return;\n this._minEdgePointsLength = value;\n this.notify(\"minEdgePointsLength\");\n }\n\n}\nexport default PointsStyle;\n"],"mappings":";;;;AAKA,IAAM,cAAN,cAA0B,cAAc;;CAEpC,cAAqB;EACjB,MAAM,QAAQ;EACd,KAAK,eAAe;EACpB,KAAK,eAAe;CACxB;CAEA,gBAAsC;;CAEtC,IAAW,eAA6B;EAAE,OAAO,KAAK;CAAe;;CAErE,IAAW,aAAa,OAAqB;EACzC,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,SAAS,KAAK,GAAG,MAAM,IAAI,UAAU,0BAA0B;EACnF,IAAI,KAAK,kBAAkB,OAAO;EAClC,KAAK,gBAAgB;EACrB,KAAK,OAAO,cAAc;CAC9B;CAGA,YAA6B;;CAE7B,IAAW,WAAoB;EAAE,OAAO,KAAK;CAAW;;CAExD,IAAW,SAAS,OAAgB;EAEhC,IAAI,KAAK,cAAc,OAAO;EAC9B,KAAK,YAAY;EACjB,KAAK,OAAO,UAAU;CAC1B;CAGA,aAA8B;;CAE9B,IAAW,YAAqB;EAAE,OAAO,KAAK;CAAY;;CAE1D,IAAW,UAAU,OAAgB;EAEjC,IAAI,KAAK,eAAe,OAAO;EAC/B,KAAK,aAAa;EAClB,KAAK,OAAO,WAAW;CAC3B;CAGA,UAA0B;;CAE1B,IAAW,SAAiB;EAAE,OAAO,KAAK;CAAS;;CAEnD,IAAW,OAAO,OAAe;EAC7B,QAAQ,cAAc,KAAK;EAC3B,IAAI,KAAK,YAAY,OAAO;EAC5B,KAAK,UAAU;EACf,KAAK,OAAO,QAAQ;CACxB;CAGA,YAA4B;;CAE5B,IAAW,WAAmB;EAAE,OAAO,KAAK;CAAW;;CAEvD,IAAW,SAAS,OAAe;EAC/B,IAAI,CAAC,OAAO,cAAc,KAAK,KAAK,QAAQ,GAAG,MAAM,IAAI,WAAW,yCAAyC;EAC7G,IAAI,KAAK,cAAc,OAAO;EAC9B,KAAK,YAAY;EACjB,KAAK,OAAO,UAAU;CAC1B;CAGA,mBAAmC;;CAEnC,IAAW,kBAA0B;EAAE,OAAO,KAAK;CAAkB;;CAErE,IAAW,gBAAgB,OAAe;EACtC,QAAQ,cAAc,KAAK;EAC3B,IAAI,KAAK,qBAAqB,OAAO;EACrC,KAAK,mBAAmB;EACxB,KAAK,OAAO,iBAAiB;CACjC;CAGA,uBAAuC;;CAEvC,IAAW,sBAA8B;EAAE,OAAO,KAAK;CAAsB;;CAE7E,IAAW,oBAAoB,OAAe;EAC1C,QAAQ,cAAc,KAAK;EAC3B,IAAI,KAAK,yBAAyB,OAAO;EACzC,KAAK,uBAAuB;EAC5B,KAAK,OAAO,qBAAqB;CACrC;AAEJ"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Color from "../Color";
|
|
2
|
+
import TexturedStyle from "./TexturedStyle";
|
|
3
|
+
import type { BorderAlign, PixelAligned } from "./types";
|
|
4
|
+
/** 实体面样式,SDF 边框属于此分区,不与 EdgeStyle 共用参数。 */
|
|
5
|
+
declare class SolidStyle extends TexturedStyle {
|
|
6
|
+
private _borderColor;
|
|
7
|
+
/** 创建关闭的实体面样式。 */
|
|
8
|
+
constructor();
|
|
9
|
+
/** SDF 边框独立颜色。 */
|
|
10
|
+
get borderColor(): Color;
|
|
11
|
+
/** @param value SDF 边框颜色引用 */
|
|
12
|
+
set borderColor(value: Color);
|
|
13
|
+
/** 最终停止使用时解除 SDF 边框色与填充色的订阅。 */
|
|
14
|
+
dispose(): void;
|
|
15
|
+
/**
|
|
16
|
+
* 校验字段仍引用当前颜色,忽略已替换颜色发出的过期通知。
|
|
17
|
+
* @param color 来源颜色
|
|
18
|
+
* @param field 颜色字段
|
|
19
|
+
*/
|
|
20
|
+
onColorChange(color: Color, field: string): void;
|
|
21
|
+
private _borderWidth;
|
|
22
|
+
/** SDF 边框宽度,0 表示关闭 SDF 边框。 */
|
|
23
|
+
get borderWidth(): number;
|
|
24
|
+
/** @param value SDF 边框宽度,0 表示关闭 SDF 边框。 */
|
|
25
|
+
set borderWidth(value: number);
|
|
26
|
+
private _borderAlign;
|
|
27
|
+
/** 边框对齐:inset / normal / outset。 */
|
|
28
|
+
get borderAlign(): BorderAlign;
|
|
29
|
+
/** @param value 边框对齐:inset / normal / outset。 */
|
|
30
|
+
set borderAlign(value: BorderAlign);
|
|
31
|
+
private _pixelAligned;
|
|
32
|
+
/** px 固定像素,zoom 随相机缩放。 */
|
|
33
|
+
get pixelAligned(): PixelAligned;
|
|
34
|
+
/** @param value px 固定像素,zoom 随相机缩放。 */
|
|
35
|
+
set pixelAligned(value: PixelAligned);
|
|
36
|
+
}
|
|
37
|
+
export default SolidStyle;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import Color from "../Color/index.js";
|
|
2
|
+
import { NormalizeSize } from "./PartStyle.js";
|
|
3
|
+
import TexturedStyle from "./TexturedStyle.js";
|
|
4
|
+
//#region src/scripts/Style/SolidStyle.ts
|
|
5
|
+
/** 实体面样式,SDF 边框属于此分区,不与 EdgeStyle 共用参数。 */
|
|
6
|
+
var SolidStyle = class extends TexturedStyle {
|
|
7
|
+
_borderColor = new Color("#000000");
|
|
8
|
+
/** 创建关闭的实体面样式。 */
|
|
9
|
+
constructor() {
|
|
10
|
+
super("solid");
|
|
11
|
+
this._borderColor.add(this, "borderColor");
|
|
12
|
+
}
|
|
13
|
+
/** SDF 边框独立颜色。 */
|
|
14
|
+
get borderColor() {
|
|
15
|
+
return this._borderColor;
|
|
16
|
+
}
|
|
17
|
+
/** @param value SDF 边框颜色引用 */
|
|
18
|
+
set borderColor(value) {
|
|
19
|
+
if (this._borderColor === value) return;
|
|
20
|
+
this._borderColor.delete(this, "borderColor");
|
|
21
|
+
this._borderColor = value;
|
|
22
|
+
value.add(this, "borderColor");
|
|
23
|
+
this.notify("borderColor");
|
|
24
|
+
}
|
|
25
|
+
/** 最终停止使用时解除 SDF 边框色与填充色的订阅。 */
|
|
26
|
+
dispose() {
|
|
27
|
+
this._borderColor.delete(this, "borderColor");
|
|
28
|
+
super.dispose();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 校验字段仍引用当前颜色,忽略已替换颜色发出的过期通知。
|
|
32
|
+
* @param color 来源颜色
|
|
33
|
+
* @param field 颜色字段
|
|
34
|
+
*/
|
|
35
|
+
onColorChange(color, field) {
|
|
36
|
+
if (field === "borderColor" && color !== this._borderColor) return;
|
|
37
|
+
super.onColorChange(color, field);
|
|
38
|
+
}
|
|
39
|
+
_borderWidth = 0;
|
|
40
|
+
/** SDF 边框宽度,0 表示关闭 SDF 边框。 */
|
|
41
|
+
get borderWidth() {
|
|
42
|
+
return this._borderWidth;
|
|
43
|
+
}
|
|
44
|
+
/** @param value SDF 边框宽度,0 表示关闭 SDF 边框。 */
|
|
45
|
+
set borderWidth(value) {
|
|
46
|
+
value = NormalizeSize(value);
|
|
47
|
+
if (this._borderWidth === value) return;
|
|
48
|
+
this._borderWidth = value;
|
|
49
|
+
this.notify("borderWidth");
|
|
50
|
+
}
|
|
51
|
+
_borderAlign = "normal";
|
|
52
|
+
/** 边框对齐:inset / normal / outset。 */
|
|
53
|
+
get borderAlign() {
|
|
54
|
+
return this._borderAlign;
|
|
55
|
+
}
|
|
56
|
+
/** @param value 边框对齐:inset / normal / outset。 */
|
|
57
|
+
set borderAlign(value) {
|
|
58
|
+
if (![
|
|
59
|
+
"inset",
|
|
60
|
+
"normal",
|
|
61
|
+
"outset"
|
|
62
|
+
].includes(value)) throw new TypeError("Invalid border alignment.");
|
|
63
|
+
if (this._borderAlign === value) return;
|
|
64
|
+
this._borderAlign = value;
|
|
65
|
+
this.notify("borderAlign");
|
|
66
|
+
}
|
|
67
|
+
_pixelAligned = "px";
|
|
68
|
+
/** px 固定像素,zoom 随相机缩放。 */
|
|
69
|
+
get pixelAligned() {
|
|
70
|
+
return this._pixelAligned;
|
|
71
|
+
}
|
|
72
|
+
/** @param value px 固定像素,zoom 随相机缩放。 */
|
|
73
|
+
set pixelAligned(value) {
|
|
74
|
+
if (!["px", "zoom"].includes(value)) throw new TypeError("Invalid pixel alignment.");
|
|
75
|
+
if (this._pixelAligned === value) return;
|
|
76
|
+
this._pixelAligned = value;
|
|
77
|
+
this.notify("pixelAligned");
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
export { SolidStyle as default };
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=SolidStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SolidStyle.js","names":[],"sources":["../../src/scripts/Style/SolidStyle.ts"],"sourcesContent":["import Color from \"../Color\";\nimport TexturedStyle from \"./TexturedStyle\";\nimport { NormalizeSize } from \"./PartStyle\";\nimport type { BorderAlign, PixelAligned } from \"./types\";\n\n/** 实体面样式,SDF 边框属于此分区,不与 EdgeStyle 共用参数。 */\nclass SolidStyle extends TexturedStyle {\n private _borderColor: Color = new Color(\"#000000\");\n /** 创建关闭的实体面样式。 */\n public constructor() {\n super(\"solid\");\n this._borderColor.add(this, \"borderColor\");\n }\n /** SDF 边框独立颜色。 */\n public get borderColor(): Color { return this._borderColor; }\n /** @param value SDF 边框颜色引用 */\n public set borderColor(value: Color) {\n if (this._borderColor === value) return;\n this._borderColor.delete(this, \"borderColor\");\n this._borderColor = value;\n value.add(this, \"borderColor\");\n this.notify(\"borderColor\");\n }\n /** 最终停止使用时解除 SDF 边框色与填充色的订阅。 */\n public dispose(): void {\n this._borderColor.delete(this, \"borderColor\");\n super.dispose();\n }\n /**\n * 校验字段仍引用当前颜色,忽略已替换颜色发出的过期通知。\n * @param color 来源颜色\n * @param field 颜色字段\n */\n public onColorChange(color: Color, field: string): void {\n if (field === \"borderColor\" && color !== this._borderColor) return;\n super.onColorChange(color, field);\n }\n\n private _borderWidth: number = 0;\n /** SDF 边框宽度,0 表示关闭 SDF 边框。 */\n public get borderWidth(): number { return this._borderWidth; }\n /** @param value SDF 边框宽度,0 表示关闭 SDF 边框。 */\n public set borderWidth(value: number) {\n value = NormalizeSize(value);\n if (this._borderWidth === value) return;\n this._borderWidth = value;\n this.notify(\"borderWidth\");\n }\n\n private _borderAlign: BorderAlign = \"normal\";\n /** 边框对齐:inset / normal / outset。 */\n public get borderAlign(): BorderAlign { return this._borderAlign; }\n /** @param value 边框对齐:inset / normal / outset。 */\n public set borderAlign(value: BorderAlign) {\n if (![\"inset\", \"normal\", \"outset\"].includes(value)) throw new TypeError(\"Invalid border alignment.\");\n if (this._borderAlign === value) return;\n this._borderAlign = value;\n this.notify(\"borderAlign\");\n }\n\n private _pixelAligned: PixelAligned = \"px\";\n /** px 固定像素,zoom 随相机缩放。 */\n public get pixelAligned(): PixelAligned { return this._pixelAligned; }\n /** @param value px 固定像素,zoom 随相机缩放。 */\n public set pixelAligned(value: PixelAligned) {\n if (![\"px\", \"zoom\"].includes(value)) throw new TypeError(\"Invalid pixel alignment.\");\n if (this._pixelAligned === value) return;\n this._pixelAligned = value;\n this.notify(\"pixelAligned\");\n }\n\n}\nexport default SolidStyle;\n"],"mappings":";;;;;AAMA,IAAM,aAAN,cAAyB,cAAc;CACnC,eAA8B,IAAI,MAAM,SAAS;;CAEjD,cAAqB;EACjB,MAAM,OAAO;EACb,KAAK,aAAa,IAAI,MAAM,aAAa;CAC7C;;CAEA,IAAW,cAAqB;EAAE,OAAO,KAAK;CAAc;;CAE5D,IAAW,YAAY,OAAc;EACjC,IAAI,KAAK,iBAAiB,OAAO;EACjC,KAAK,aAAa,OAAO,MAAM,aAAa;EAC5C,KAAK,eAAe;EACpB,MAAM,IAAI,MAAM,aAAa;EAC7B,KAAK,OAAO,aAAa;CAC7B;;CAEA,UAAuB;EACnB,KAAK,aAAa,OAAO,MAAM,aAAa;EAC5C,MAAM,QAAQ;CAClB;;;;;;CAMA,cAAqB,OAAc,OAAqB;EACpD,IAAI,UAAU,iBAAiB,UAAU,KAAK,cAAc;EAC5D,MAAM,cAAc,OAAO,KAAK;CACpC;CAEA,eAA+B;;CAE/B,IAAW,cAAsB;EAAE,OAAO,KAAK;CAAc;;CAE7D,IAAW,YAAY,OAAe;EAClC,QAAQ,cAAc,KAAK;EAC3B,IAAI,KAAK,iBAAiB,OAAO;EACjC,KAAK,eAAe;EACpB,KAAK,OAAO,aAAa;CAC7B;CAEA,eAAoC;;CAEpC,IAAW,cAA2B;EAAE,OAAO,KAAK;CAAc;;CAElE,IAAW,YAAY,OAAoB;EACvC,IAAI,CAAC;GAAC;GAAS;GAAU;EAAQ,CAAC,CAAC,SAAS,KAAK,GAAG,MAAM,IAAI,UAAU,2BAA2B;EACnG,IAAI,KAAK,iBAAiB,OAAO;EACjC,KAAK,eAAe;EACpB,KAAK,OAAO,aAAa;CAC7B;CAEA,gBAAsC;;CAEtC,IAAW,eAA6B;EAAE,OAAO,KAAK;CAAe;;CAErE,IAAW,aAAa,OAAqB;EACzC,IAAI,CAAC,CAAC,MAAM,MAAM,CAAC,CAAC,SAAS,KAAK,GAAG,MAAM,IAAI,UAAU,0BAA0B;EACnF,IAAI,KAAK,kBAAkB,OAAO;EAClC,KAAK,gBAAgB;EACrB,KAAK,OAAO,cAAc;CAC9B;AAEJ"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference types="@webgpu/types" preserve="true" />
|
|
2
|
+
import PartStyle from "./PartStyle";
|
|
3
|
+
import type { TextureLike, TextureSubscriber } from "../Texture";
|
|
4
|
+
/** 面、实体边框和关键点使用的贴图参数,各分区独立持有。 */
|
|
5
|
+
declare class TexturedStyle extends PartStyle implements TextureSubscriber {
|
|
6
|
+
private _texture;
|
|
7
|
+
private _addressModeU;
|
|
8
|
+
private _addressModeV;
|
|
9
|
+
/** 当前贴图,undefined 使用白色后备贴图。 */
|
|
10
|
+
get texture(): TextureLike | undefined;
|
|
11
|
+
/** @param value 新贴图引用;纹理内部加载状态仍由 Texture 管理 */
|
|
12
|
+
set texture(value: TextureLike | undefined);
|
|
13
|
+
/**
|
|
14
|
+
* 图片内容变化向上通知,但不把它当作替换贴图引用。
|
|
15
|
+
* @param texture 发出变化的贴图
|
|
16
|
+
*/
|
|
17
|
+
onTextureChange(texture: TextureLike): void;
|
|
18
|
+
/** 最终停用时解绑贴图和颜色,不销毁共享资源。 */
|
|
19
|
+
dispose(): void;
|
|
20
|
+
/** U 方向贴图寻址方式。 */
|
|
21
|
+
get addressModeU(): GPUAddressMode;
|
|
22
|
+
/** @param value WebGPU 寻址方式 */
|
|
23
|
+
set addressModeU(value: GPUAddressMode);
|
|
24
|
+
/** V 方向贴图寻址方式。 */
|
|
25
|
+
get addressModeV(): GPUAddressMode;
|
|
26
|
+
/** @param value WebGPU 寻址方式 */
|
|
27
|
+
set addressModeV(value: GPUAddressMode);
|
|
28
|
+
}
|
|
29
|
+
export default TexturedStyle;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import PartStyle from "./PartStyle.js";
|
|
2
|
+
//#region src/scripts/Style/TexturedStyle.ts
|
|
3
|
+
/** 面、实体边框和关键点使用的贴图参数,各分区独立持有。 */
|
|
4
|
+
var TexturedStyle = class extends PartStyle {
|
|
5
|
+
_texture;
|
|
6
|
+
_addressModeU = "repeat";
|
|
7
|
+
_addressModeV = "repeat";
|
|
8
|
+
/** 当前贴图,undefined 使用白色后备贴图。 */
|
|
9
|
+
get texture() {
|
|
10
|
+
return this._texture;
|
|
11
|
+
}
|
|
12
|
+
/** @param value 新贴图引用;纹理内部加载状态仍由 Texture 管理 */
|
|
13
|
+
set texture(value) {
|
|
14
|
+
if (this._texture === value) return;
|
|
15
|
+
this._texture?.delete(this);
|
|
16
|
+
this._texture = value;
|
|
17
|
+
value?.add(this);
|
|
18
|
+
this.notify("texture");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 图片内容变化向上通知,但不把它当作替换贴图引用。
|
|
22
|
+
* @param texture 发出变化的贴图
|
|
23
|
+
*/
|
|
24
|
+
onTextureChange(texture) {
|
|
25
|
+
if (texture === this._texture) this.notify("textureData");
|
|
26
|
+
}
|
|
27
|
+
/** 最终停用时解绑贴图和颜色,不销毁共享资源。 */
|
|
28
|
+
dispose() {
|
|
29
|
+
this._texture?.delete(this);
|
|
30
|
+
super.dispose();
|
|
31
|
+
}
|
|
32
|
+
/** U 方向贴图寻址方式。 */
|
|
33
|
+
get addressModeU() {
|
|
34
|
+
return this._addressModeU;
|
|
35
|
+
}
|
|
36
|
+
/** @param value WebGPU 寻址方式 */
|
|
37
|
+
set addressModeU(value) {
|
|
38
|
+
if (![
|
|
39
|
+
"repeat",
|
|
40
|
+
"mirror-repeat",
|
|
41
|
+
"clamp-to-edge"
|
|
42
|
+
].includes(value)) throw new TypeError("Invalid address mode.");
|
|
43
|
+
if (this._addressModeU === value) return;
|
|
44
|
+
this._addressModeU = value;
|
|
45
|
+
this.notify("addressModeU");
|
|
46
|
+
}
|
|
47
|
+
/** V 方向贴图寻址方式。 */
|
|
48
|
+
get addressModeV() {
|
|
49
|
+
return this._addressModeV;
|
|
50
|
+
}
|
|
51
|
+
/** @param value WebGPU 寻址方式 */
|
|
52
|
+
set addressModeV(value) {
|
|
53
|
+
if (![
|
|
54
|
+
"repeat",
|
|
55
|
+
"mirror-repeat",
|
|
56
|
+
"clamp-to-edge"
|
|
57
|
+
].includes(value)) throw new TypeError("Invalid address mode.");
|
|
58
|
+
if (this._addressModeV === value) return;
|
|
59
|
+
this._addressModeV = value;
|
|
60
|
+
this.notify("addressModeV");
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
//#endregion
|
|
64
|
+
export { TexturedStyle as default };
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=TexturedStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TexturedStyle.js","names":[],"sources":["../../src/scripts/Style/TexturedStyle.ts"],"sourcesContent":["/// <reference types=\"@webgpu/types\" preserve=\"true\" />\nimport PartStyle from \"./PartStyle\";\nimport type { TextureLike, TextureSubscriber } from \"../Texture\";\n\n/** 面、实体边框和关键点使用的贴图参数,各分区独立持有。 */\nclass TexturedStyle extends PartStyle implements TextureSubscriber {\n private _texture: TextureLike | undefined;\n private _addressModeU: GPUAddressMode = \"repeat\";\n private _addressModeV: GPUAddressMode = \"repeat\";\n /** 当前贴图,undefined 使用白色后备贴图。 */\n public get texture(): TextureLike | undefined { return this._texture; }\n /** @param value 新贴图引用;纹理内部加载状态仍由 Texture 管理 */\n public set texture(value: TextureLike | undefined) {\n if (this._texture === value) return;\n this._texture?.delete(this);\n this._texture = value;\n value?.add(this);\n this.notify(\"texture\");\n }\n\n /**\n * 图片内容变化向上通知,但不把它当作替换贴图引用。\n * @param texture 发出变化的贴图\n */\n public onTextureChange(texture: TextureLike): void {\n if (texture === this._texture) this.notify(\"textureData\");\n }\n\n /** 最终停用时解绑贴图和颜色,不销毁共享资源。 */\n public override dispose(): void {\n this._texture?.delete(this);\n super.dispose();\n }\n\n /** U 方向贴图寻址方式。 */\n public get addressModeU(): GPUAddressMode { return this._addressModeU; }\n /** @param value WebGPU 寻址方式 */\n public set addressModeU(value: GPUAddressMode) {\n if (![\"repeat\", \"mirror-repeat\", \"clamp-to-edge\"].includes(value)) throw new TypeError(\"Invalid address mode.\");\n if (this._addressModeU === value) return;\n this._addressModeU = value;\n this.notify(\"addressModeU\");\n }\n\n /** V 方向贴图寻址方式。 */\n public get addressModeV(): GPUAddressMode { return this._addressModeV; }\n /** @param value WebGPU 寻址方式 */\n public set addressModeV(value: GPUAddressMode) {\n if (![\"repeat\", \"mirror-repeat\", \"clamp-to-edge\"].includes(value)) throw new TypeError(\"Invalid address mode.\");\n if (this._addressModeV === value) return;\n this._addressModeV = value;\n this.notify(\"addressModeV\");\n }\n}\nexport default TexturedStyle;\n"],"mappings":";;;AAKA,IAAM,gBAAN,cAA4B,UAAuC;CAC/D;CACA,gBAAwC;CACxC,gBAAwC;;CAExC,IAAW,UAAmC;EAAE,OAAO,KAAK;CAAU;;CAEtE,IAAW,QAAQ,OAAgC;EAC/C,IAAI,KAAK,aAAa,OAAO;EAC7B,KAAK,UAAU,OAAO,IAAI;EAC1B,KAAK,WAAW;EAChB,OAAO,IAAI,IAAI;EACf,KAAK,OAAO,SAAS;CACzB;;;;;CAMA,gBAAuB,SAA4B;EAC/C,IAAI,YAAY,KAAK,UAAU,KAAK,OAAO,aAAa;CAC5D;;CAGA,UAAgC;EAC5B,KAAK,UAAU,OAAO,IAAI;EAC1B,MAAM,QAAQ;CAClB;;CAGA,IAAW,eAA+B;EAAE,OAAO,KAAK;CAAe;;CAEvE,IAAW,aAAa,OAAuB;EAC3C,IAAI,CAAC;GAAC;GAAU;GAAiB;EAAe,CAAC,CAAC,SAAS,KAAK,GAAG,MAAM,IAAI,UAAU,uBAAuB;EAC9G,IAAI,KAAK,kBAAkB,OAAO;EAClC,KAAK,gBAAgB;EACrB,KAAK,OAAO,cAAc;CAC9B;;CAGA,IAAW,eAA+B;EAAE,OAAO,KAAK;CAAe;;CAEvE,IAAW,aAAa,OAAuB;EAC3C,IAAI,CAAC;GAAC;GAAU;GAAiB;EAAe,CAAC,CAAC,SAAS,KAAK,GAAG,MAAM,IAAI,UAAU,uBAAuB;EAC9G,IAAI,KAAK,kBAAkB,OAAO;EAClC,KAAK,gBAAgB;EACrB,KAAK,OAAO,cAAc;CAC9B;AACJ"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import PartStyle from "./PartStyle.js";
|
|
2
|
+
//#region src/scripts/Style/WireframeStyle.ts
|
|
3
|
+
/** 原生 line-list 样式,仅有独立开关、颜色和透明度,不提供无效的线宽选项。 */
|
|
4
|
+
var WireframeStyle = class extends PartStyle {
|
|
5
|
+
/** 创建默认关闭的原生线框。 */
|
|
6
|
+
constructor() {
|
|
7
|
+
super("wireframe");
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
//#endregion
|
|
11
|
+
export { WireframeStyle as default };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=WireframeStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WireframeStyle.js","names":[],"sources":["../../src/scripts/Style/WireframeStyle.ts"],"sourcesContent":["import PartStyle from \"./PartStyle\";\n\n/** 原生 line-list 样式,仅有独立开关、颜色和透明度,不提供无效的线宽选项。 */\nclass WireframeStyle extends PartStyle {\n /** 创建默认关闭的原生线框。 */\n public constructor() { super(\"wireframe\"); }\n}\nexport default WireframeStyle;\n"],"mappings":";;;AAGA,IAAM,iBAAN,cAA6B,UAAU;;CAEnC,cAAqB;EAAE,MAAM,WAAW;CAAG;AAC/C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type Style from "./index";
|
|
2
|
+
/** 每个实例样式的 float 数;WGSL 对应十一个 vec4。 */
|
|
3
|
+
export declare const STYLE_STRIDE: number;
|
|
4
|
+
/**
|
|
5
|
+
* 将一份 Style 写入连续实例数组,不分配目标数组,也不修改 Style。
|
|
6
|
+
* @param style 来源样式
|
|
7
|
+
* @param target 预分配的连续 Float32Array
|
|
8
|
+
* @param offset 起始 float 偏移,不是字节偏移
|
|
9
|
+
*/
|
|
10
|
+
export declare const WriteStyleData: (style: Style, target: Float32Array<ArrayBuffer>, offset?: number) => void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//#region src/scripts/Style/WriteStyleData.ts
|
|
2
|
+
/** 每个实例样式的 float 数;WGSL 对应十一个 vec4。 */
|
|
3
|
+
var STYLE_STRIDE = 44;
|
|
4
|
+
/**
|
|
5
|
+
* 将一份 Style 写入连续实例数组,不分配目标数组,也不修改 Style。
|
|
6
|
+
* @param style 来源样式
|
|
7
|
+
* @param target 预分配的连续 Float32Array
|
|
8
|
+
* @param offset 起始 float 偏移,不是字节偏移
|
|
9
|
+
*/
|
|
10
|
+
var WriteStyleData = (style, target, offset = 0) => {
|
|
11
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || offset + 44 > target.length) throw new RangeError("Style data offset exceeds the target capacity.");
|
|
12
|
+
target.fill(0, offset + 40, offset + 44);
|
|
13
|
+
const { solid, wireframe, edge, points } = style;
|
|
14
|
+
solid.color.writeTo(target, offset);
|
|
15
|
+
solid.borderColor.writeTo(target, offset + 4);
|
|
16
|
+
edge.color.writeTo(target, offset + 8);
|
|
17
|
+
points.color.writeTo(target, offset + 12);
|
|
18
|
+
wireframe.color.writeTo(target, offset + 16);
|
|
19
|
+
target.set([
|
|
20
|
+
solid.opacity,
|
|
21
|
+
solid.borderWidth,
|
|
22
|
+
Align(solid.borderAlign),
|
|
23
|
+
Number(solid.pixelAligned === "zoom")
|
|
24
|
+
], offset + 20);
|
|
25
|
+
target.set([
|
|
26
|
+
edge.opacity,
|
|
27
|
+
edge.width,
|
|
28
|
+
Align(edge.borderAlign),
|
|
29
|
+
Number(edge.pixelAligned === "zoom")
|
|
30
|
+
], offset + 24);
|
|
31
|
+
target.set([
|
|
32
|
+
points.opacity,
|
|
33
|
+
Number(points.pixelAligned === "zoom"),
|
|
34
|
+
0,
|
|
35
|
+
0
|
|
36
|
+
], offset + 28);
|
|
37
|
+
target.set([
|
|
38
|
+
wireframe.opacity,
|
|
39
|
+
0,
|
|
40
|
+
0,
|
|
41
|
+
0
|
|
42
|
+
], offset + 32);
|
|
43
|
+
target.set([
|
|
44
|
+
Number(solid.enabled),
|
|
45
|
+
Number(wireframe.enabled),
|
|
46
|
+
Number(edge.enabled),
|
|
47
|
+
Number(points.enabled)
|
|
48
|
+
], offset + 36);
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* 转换为 Shader 使用的边框外扩系数。
|
|
52
|
+
* @param value 对齐方式
|
|
53
|
+
* @returns 0、0.5 或 1
|
|
54
|
+
*/
|
|
55
|
+
var Align = (value) => value === "inset" ? 0 : value === "normal" ? .5 : 1;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { STYLE_STRIDE, WriteStyleData };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=WriteStyleData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WriteStyleData.js","names":[],"sources":["../../src/scripts/Style/WriteStyleData.ts"],"sourcesContent":["import type Style from \"./index\";\n\n/** 每个实例样式的 float 数;WGSL 对应十一个 vec4。 */\nexport const STYLE_STRIDE: number = 44;\n\n/**\n * 将一份 Style 写入连续实例数组,不分配目标数组,也不修改 Style。\n * @param style 来源样式\n * @param target 预分配的连续 Float32Array\n * @param offset 起始 float 偏移,不是字节偏移\n */\nexport const WriteStyleData = (style: Style, target: Float32Array<ArrayBuffer>, offset: number = 0): void => {\n if (!Number.isSafeInteger(offset) || offset < 0 || offset + STYLE_STRIDE > target.length) {\n throw new RangeError(\"Style data offset exceeds the target capacity.\");\n }\n target.fill(0, offset + 40, offset + 44);\n const { solid, wireframe, edge, points } = style;\n solid.color.writeTo(target, offset);\n solid.borderColor.writeTo(target, offset + 4);\n edge.color.writeTo(target, offset + 8);\n points.color.writeTo(target, offset + 12);\n wireframe.color.writeTo(target, offset + 16);\n target.set([solid.opacity, solid.borderWidth, Align(solid.borderAlign), Number(solid.pixelAligned === \"zoom\")], offset + 20);\n target.set([edge.opacity, edge.width, Align(edge.borderAlign), Number(edge.pixelAligned === \"zoom\")], offset + 24);\n target.set([points.opacity, Number(points.pixelAligned === \"zoom\"), 0, 0], offset + 28);\n target.set([wireframe.opacity, 0, 0, 0], offset + 32);\n target.set([Number(solid.enabled), Number(wireframe.enabled), Number(edge.enabled), Number(points.enabled)], offset + 36);\n};\n\n/**\n * 转换为 Shader 使用的边框外扩系数。\n * @param value 对齐方式\n * @returns 0、0.5 或 1\n */\nconst Align = (value: \"inset\" | \"normal\" | \"outset\"): number => value === \"inset\" ? 0 : value === \"normal\" ? 0.5 : 1;\n"],"mappings":";;AAGA,IAAa,eAAuB;;;;;;;AAQpC,IAAa,kBAAkB,OAAc,QAAmC,SAAiB,MAAY;CACzG,IAAI,CAAC,OAAO,cAAc,MAAM,KAAK,SAAS,KAAK,SAAA,KAAwB,OAAO,QAC9E,MAAM,IAAI,WAAW,gDAAgD;CAEzE,OAAO,KAAK,GAAG,SAAS,IAAI,SAAS,EAAE;CACvC,MAAM,EAAE,OAAO,WAAW,MAAM,WAAW;CAC3C,MAAM,MAAM,QAAQ,QAAQ,MAAM;CAClC,MAAM,YAAY,QAAQ,QAAQ,SAAS,CAAC;CAC5C,KAAK,MAAM,QAAQ,QAAQ,SAAS,CAAC;CACrC,OAAO,MAAM,QAAQ,QAAQ,SAAS,EAAE;CACxC,UAAU,MAAM,QAAQ,QAAQ,SAAS,EAAE;CAC3C,OAAO,IAAI;EAAC,MAAM;EAAS,MAAM;EAAa,MAAM,MAAM,WAAW;EAAG,OAAO,MAAM,iBAAiB,MAAM;CAAC,GAAG,SAAS,EAAE;CAC3H,OAAO,IAAI;EAAC,KAAK;EAAS,KAAK;EAAO,MAAM,KAAK,WAAW;EAAG,OAAO,KAAK,iBAAiB,MAAM;CAAC,GAAG,SAAS,EAAE;CACjH,OAAO,IAAI;EAAC,OAAO;EAAS,OAAO,OAAO,iBAAiB,MAAM;EAAG;EAAG;CAAC,GAAG,SAAS,EAAE;CACtF,OAAO,IAAI;EAAC,UAAU;EAAS;EAAG;EAAG;CAAC,GAAG,SAAS,EAAE;CACpD,OAAO,IAAI;EAAC,OAAO,MAAM,OAAO;EAAG,OAAO,UAAU,OAAO;EAAG,OAAO,KAAK,OAAO;EAAG,OAAO,OAAO,OAAO;CAAC,GAAG,SAAS,EAAE;AAC5H;;;;;;AAOA,IAAM,SAAS,UAAiD,UAAU,UAAU,IAAI,UAAU,WAAW,KAAM"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import SolidStyle from "./SolidStyle";
|
|
2
|
+
import WireframeStyle from "./WireframeStyle";
|
|
3
|
+
import EdgeStyle from "./EdgeStyle";
|
|
4
|
+
import PointsStyle from "./PointsStyle";
|
|
5
|
+
import JoinStyle from "./JoinStyle";
|
|
6
|
+
import type { PartSubscriber, StyleArea, StyleSubscriber } from "./types";
|
|
7
|
+
/** 共享样式;四个显示分区与节点连接样式独立持有参数,通过订阅链通知使用者。 */
|
|
8
|
+
declare class Style implements PartSubscriber {
|
|
9
|
+
private readonly _solid;
|
|
10
|
+
private readonly _wireframe;
|
|
11
|
+
private readonly _edge;
|
|
12
|
+
private readonly _points;
|
|
13
|
+
private readonly _join;
|
|
14
|
+
private readonly _subscribers;
|
|
15
|
+
private _version;
|
|
16
|
+
/** 构建四个关闭的显示分区及默认尖角连接,并订阅它们的变化。 */
|
|
17
|
+
constructor();
|
|
18
|
+
/** 实体面与 SDF 样式。 */
|
|
19
|
+
get solid(): SolidStyle;
|
|
20
|
+
/** 原生线框样式。 */
|
|
21
|
+
get wireframe(): WireframeStyle;
|
|
22
|
+
/** 实体三角面边框样式。 */
|
|
23
|
+
get edge(): EdgeStyle;
|
|
24
|
+
/** 关键点样式。 */
|
|
25
|
+
get points(): PointsStyle;
|
|
26
|
+
/** 多边形连接类型和精度,由 Geometry.style 决定,不随实例单独生成。 */
|
|
27
|
+
get join(): JoinStyle;
|
|
28
|
+
/** 任意分区变化时递增的单一版本。 */
|
|
29
|
+
get version(): number;
|
|
30
|
+
/** @param subscriber 几何、材质或未来实现通知协议的 IMesh */
|
|
31
|
+
add(subscriber: StyleSubscriber): void;
|
|
32
|
+
/** @param subscriber 解除订阅的对象,不销毁资源 */
|
|
33
|
+
delete(subscriber: StyleSubscriber): void;
|
|
34
|
+
/**
|
|
35
|
+
* 最终停止使用时释放整条订阅链,不销毁共享颜色、贴图或 GPU 缓存。
|
|
36
|
+
* 仅在所有 Geometry / Material 均停止使用该 Style 后调用,不应再复用。
|
|
37
|
+
*/
|
|
38
|
+
dispose(): void;
|
|
39
|
+
/**
|
|
40
|
+
* 将分区变化转发给使用者;接收者自行判断是否影响 CPU 几何。
|
|
41
|
+
* @param area 变化区域
|
|
42
|
+
* @param field 变化字段
|
|
43
|
+
*/
|
|
44
|
+
onPartChange(area: Exclude<StyleArea, "whole">, field: string): void;
|
|
45
|
+
}
|
|
46
|
+
export default Style;
|
|
47
|
+
export { SolidStyle, WireframeStyle, EdgeStyle, PointsStyle, JoinStyle };
|
|
48
|
+
export type { JoinType } from "./JoinStyle";
|
|
49
|
+
export { WriteStyleData, STYLE_STRIDE } from "./WriteStyleData";
|
|
50
|
+
export type { StyleArea, StyleChange, StyleSubscriber, BorderAlign, PixelAligned, PartSubscriber } from "./types";
|