@babylonjs/core 6.11.0 → 6.11.2

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.
Files changed (35) hide show
  1. package/Culling/ray.js +2 -2
  2. package/Culling/ray.js.map +1 -1
  3. package/Engines/thinEngine.js +2 -2
  4. package/Engines/thinEngine.js.map +1 -1
  5. package/Materials/PBR/pbrBaseMaterial.d.ts +5 -0
  6. package/Materials/PBR/pbrBaseMaterial.js +6 -1
  7. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  8. package/Materials/PBR/pbrMaterial.d.ts +4 -0
  9. package/Materials/PBR/pbrMaterial.js +8 -0
  10. package/Materials/PBR/pbrMaterial.js.map +1 -1
  11. package/Materials/greasedLinePluginMaterial.d.ts +129 -41
  12. package/Materials/greasedLinePluginMaterial.js +190 -114
  13. package/Materials/greasedLinePluginMaterial.js.map +1 -1
  14. package/Materials/materialHelper.d.ts +2 -1
  15. package/Materials/materialHelper.js +3 -1
  16. package/Materials/materialHelper.js.map +1 -1
  17. package/Materials/standardMaterial.d.ts +6 -0
  18. package/Materials/standardMaterial.js +9 -1
  19. package/Materials/standardMaterial.js.map +1 -1
  20. package/Meshes/Builders/greasedLineBuilder.d.ts +45 -1
  21. package/Meshes/Builders/greasedLineBuilder.js +59 -20
  22. package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
  23. package/Meshes/greasedLineMesh.d.ts +24 -11
  24. package/Meshes/greasedLineMesh.js +64 -24
  25. package/Meshes/greasedLineMesh.js.map +1 -1
  26. package/Misc/greasedLineTools.d.ts +11 -2
  27. package/Misc/greasedLineTools.js +18 -5
  28. package/Misc/greasedLineTools.js.map +1 -1
  29. package/Particles/gpuParticleSystem.js +1 -1
  30. package/Particles/gpuParticleSystem.js.map +1 -1
  31. package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js +5 -0
  32. package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js.map +1 -1
  33. package/Shaders/default.fragment.js +4 -1
  34. package/Shaders/default.fragment.js.map +1 -1
  35. package/package.json +2 -2
@@ -1,4 +1,3 @@
1
- import { Color3 } from "../../Maths/math.color";
2
1
  import type { GreasedLineMaterialOptions } from "../../Materials/greasedLinePluginMaterial";
3
2
  import { StandardMaterial } from "./../../Materials/standardMaterial";
4
3
  import { PBRMaterial } from "../../Materials/PBR/pbrMaterial";
@@ -6,20 +5,65 @@ import type { Nullable } from "../../types";
6
5
  import type { GreasedLineMeshOptions } from "../greasedLineMesh";
7
6
  import { GreasedLineMesh } from "../greasedLineMesh";
8
7
  import type { Scene } from "../../scene";
8
+ import type { Color3 } from "../../Maths/math.color.js";
9
+ /**
10
+ * How are the colors distributed along the color table
11
+ * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colors-and-colordistribution}
12
+ */
9
13
  export declare enum GreasedLineMeshColorDistribution {
14
+ /**
15
+ * Do no modify the color table
16
+ */
10
17
  COLOR_DISTRIBUTION_NONE = 0,
18
+ /**
19
+ * Repeat the colors until the color table is full
20
+ */
11
21
  COLOR_DISTRIBUTION_REPEAT = 1,
22
+ /**
23
+ * Distribute the colors evenly through the color table
24
+ */
12
25
  COLOR_DISTRIBUTION_EVEN = 2,
26
+ /**
27
+ * Put the colors to start of the color table a fill the rest with the default color
28
+ */
13
29
  COLOR_DISTRIBUTION_START = 3,
30
+ /**
31
+ * Put the colors to the end of the color table and fill the rest with the default color
32
+ */
14
33
  COLOR_DISTRIBUTION_END = 4,
34
+ /**
35
+ * Put the colors to start and to the end of the color table and fill the gap between with the default color
36
+ */
15
37
  COLOR_DISTRIBUTION_START_END = 5
16
38
  }
39
+ /**
40
+ * How are the widths distributed along the width table
41
+ * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#widths-and-widthdistribution}
42
+ */
17
43
  export declare enum GreasedLineMeshWidthDistribution {
44
+ /**
45
+ * Do no modify the width table
46
+ */
18
47
  WIDTH_DISTRIBUTION_NONE = 0,
48
+ /**
49
+ * Repeat the widths until the width table is full
50
+ */
19
51
  WIDTH_DISTRIBUTION_REPEAT = 1,
52
+ /**
53
+ * Distribute the widths evenly through the width table
54
+ */
20
55
  WIDTH_DISTRIBUTION_EVEN = 2,
56
+ /**
57
+ * Put the widths to start of the width table a fill the rest with the default width
58
+ */
21
59
  WIDTH_DISTRIBUTION_START = 3,
60
+ /**
61
+ * Put the widths to the end of the width table and fill the rest with the default width
62
+ */
22
63
  WIDTH_DISTRIBUTION_END = 4,
64
+ /**
65
+ * Put the widths to start and to the end of the width table and fill the gap between with the default width
66
+ */
23
67
  WIDTH_DISTRIBUTION_START_END = 5
24
68
  }
25
69
  /**
@@ -1,25 +1,68 @@
1
- import { Color3 } from "../../Maths/math.color.js";
2
- import { GreasedLineMeshColorMode, GreasedLineMeshMaterialType, GreasedLinePluginMaterial } from "../../Materials/greasedLinePluginMaterial.js";
1
+ import { GreasedLineMeshMaterialType, GreasedLinePluginMaterial } from "../../Materials/greasedLinePluginMaterial.js";
3
2
  import { StandardMaterial } from "./../../Materials/standardMaterial.js";
4
3
  import { PBRMaterial } from "../../Materials/PBR/pbrMaterial.js";
5
4
  import { GreasedLineMesh } from "../greasedLineMesh.js";
6
5
  import { EngineStore } from "../../Engines/engineStore.js";
6
+ /**
7
+ * How are the colors distributed along the color table
8
+ * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colors-and-colordistribution}
9
+ */
7
10
  export var GreasedLineMeshColorDistribution;
8
11
  (function (GreasedLineMeshColorDistribution) {
12
+ /**
13
+ * Do no modify the color table
14
+ */
9
15
  GreasedLineMeshColorDistribution[GreasedLineMeshColorDistribution["COLOR_DISTRIBUTION_NONE"] = 0] = "COLOR_DISTRIBUTION_NONE";
16
+ /**
17
+ * Repeat the colors until the color table is full
18
+ */
10
19
  GreasedLineMeshColorDistribution[GreasedLineMeshColorDistribution["COLOR_DISTRIBUTION_REPEAT"] = 1] = "COLOR_DISTRIBUTION_REPEAT";
20
+ /**
21
+ * Distribute the colors evenly through the color table
22
+ */
11
23
  GreasedLineMeshColorDistribution[GreasedLineMeshColorDistribution["COLOR_DISTRIBUTION_EVEN"] = 2] = "COLOR_DISTRIBUTION_EVEN";
24
+ /**
25
+ * Put the colors to start of the color table a fill the rest with the default color
26
+ */
12
27
  GreasedLineMeshColorDistribution[GreasedLineMeshColorDistribution["COLOR_DISTRIBUTION_START"] = 3] = "COLOR_DISTRIBUTION_START";
28
+ /**
29
+ * Put the colors to the end of the color table and fill the rest with the default color
30
+ */
13
31
  GreasedLineMeshColorDistribution[GreasedLineMeshColorDistribution["COLOR_DISTRIBUTION_END"] = 4] = "COLOR_DISTRIBUTION_END";
32
+ /**
33
+ * Put the colors to start and to the end of the color table and fill the gap between with the default color
34
+ */
14
35
  GreasedLineMeshColorDistribution[GreasedLineMeshColorDistribution["COLOR_DISTRIBUTION_START_END"] = 5] = "COLOR_DISTRIBUTION_START_END";
15
36
  })(GreasedLineMeshColorDistribution || (GreasedLineMeshColorDistribution = {}));
37
+ /**
38
+ * How are the widths distributed along the width table
39
+ * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#widths-and-widthdistribution}
40
+ */
16
41
  export var GreasedLineMeshWidthDistribution;
17
42
  (function (GreasedLineMeshWidthDistribution) {
43
+ /**
44
+ * Do no modify the width table
45
+ */
18
46
  GreasedLineMeshWidthDistribution[GreasedLineMeshWidthDistribution["WIDTH_DISTRIBUTION_NONE"] = 0] = "WIDTH_DISTRIBUTION_NONE";
47
+ /**
48
+ * Repeat the widths until the width table is full
49
+ */
19
50
  GreasedLineMeshWidthDistribution[GreasedLineMeshWidthDistribution["WIDTH_DISTRIBUTION_REPEAT"] = 1] = "WIDTH_DISTRIBUTION_REPEAT";
51
+ /**
52
+ * Distribute the widths evenly through the width table
53
+ */
20
54
  GreasedLineMeshWidthDistribution[GreasedLineMeshWidthDistribution["WIDTH_DISTRIBUTION_EVEN"] = 2] = "WIDTH_DISTRIBUTION_EVEN";
55
+ /**
56
+ * Put the widths to start of the width table a fill the rest with the default width
57
+ */
21
58
  GreasedLineMeshWidthDistribution[GreasedLineMeshWidthDistribution["WIDTH_DISTRIBUTION_START"] = 3] = "WIDTH_DISTRIBUTION_START";
59
+ /**
60
+ * Put the widths to the end of the width table and fill the rest with the default width
61
+ */
22
62
  GreasedLineMeshWidthDistribution[GreasedLineMeshWidthDistribution["WIDTH_DISTRIBUTION_END"] = 4] = "WIDTH_DISTRIBUTION_END";
63
+ /**
64
+ * Put the widths to start and to the end of the width table and fill the gap between with the default width
65
+ */
23
66
  GreasedLineMeshWidthDistribution[GreasedLineMeshWidthDistribution["WIDTH_DISTRIBUTION_START_END"] = 5] = "WIDTH_DISTRIBUTION_START_END";
24
67
  })(GreasedLineMeshWidthDistribution || (GreasedLineMeshWidthDistribution = {}));
25
68
  /**
@@ -47,7 +90,7 @@ export function CreateGreasedLineMaterial(name, options, scene) {
47
90
  * @returns instance of GreasedLineMesh
48
91
  */
49
92
  export function CreateGreasedLine(name, options, materialOptions, scene) {
50
- var _a, _b, _c, _d, _e, _f;
93
+ var _a, _b, _c, _d, _e;
51
94
  scene = (scene !== null && scene !== void 0 ? scene : EngineStore.LastCreatedScene);
52
95
  let instance;
53
96
  const allPoints = GreasedLineMesh.ConvertPoints(options.points);
@@ -59,13 +102,13 @@ export function CreateGreasedLine(name, options, materialOptions, scene) {
59
102
  }
60
103
  options.widthDistribution = (_a = options.widthDistribution) !== null && _a !== void 0 ? _a : GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START;
61
104
  materialOptions = materialOptions !== null && materialOptions !== void 0 ? materialOptions : {
62
- color: Color3.White(),
105
+ color: GreasedLinePluginMaterial.DEFAULT_COLOR,
63
106
  };
64
107
  materialOptions.createAndAssignMaterial = (_b = materialOptions.createAndAssignMaterial) !== null && _b !== void 0 ? _b : true;
65
108
  materialOptions.colorDistribution = (_c = materialOptions === null || materialOptions === void 0 ? void 0 : materialOptions.colorDistribution) !== null && _c !== void 0 ? _c : GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START;
66
109
  const widths = CompleteGreasedLineWidthTable(length, (_d = options.widths) !== null && _d !== void 0 ? _d : [], options.widthDistribution);
67
110
  const colors = (materialOptions === null || materialOptions === void 0 ? void 0 : materialOptions.colors)
68
- ? CompleteGreasedLineColorTable(length, materialOptions.colors, materialOptions.colorDistribution, (_e = materialOptions.color) !== null && _e !== void 0 ? _e : Color3.White())
111
+ ? CompleteGreasedLineColorTable(length, materialOptions.colors, materialOptions.colorDistribution, (_e = materialOptions.color) !== null && _e !== void 0 ? _e : GreasedLinePluginMaterial.DEFAULT_COLOR)
69
112
  : undefined;
70
113
  // create new mesh if instance is not defined
71
114
  if (!options.instance) {
@@ -89,17 +132,11 @@ export function CreateGreasedLine(name, options, materialOptions, scene) {
89
132
  visibility: materialOptions.visibility,
90
133
  width: materialOptions.width,
91
134
  color: materialOptions.color,
92
- colorMode: (_f = materialOptions.colorMode) !== null && _f !== void 0 ? _f : GreasedLineMeshColorMode.COLOR_MODE_SET,
135
+ colorMode: materialOptions.colorMode,
93
136
  colorsSampling: materialOptions.colorsSampling,
94
137
  colorDistributionType: materialOptions.colorDistributionType,
138
+ colors,
95
139
  };
96
- if (colors) {
97
- initialMaterialOptions.colors = colors;
98
- }
99
- else if (!materialOptions.color) {
100
- // if we don't have a color table nor a color assign it a default white color
101
- initialMaterialOptions.color = Color3.White();
102
- }
103
140
  if (materialOptions.createAndAssignMaterial) {
104
141
  const material = materialOptions.materialType === GreasedLineMeshMaterialType.MATERIAL_TYPE_PBR ? new PBRMaterial(name, scene) : new StandardMaterial(name, scene);
105
142
  new GreasedLinePluginMaterial(material, scene, initialMaterialOptions);
@@ -110,16 +147,17 @@ export function CreateGreasedLine(name, options, materialOptions, scene) {
110
147
  else {
111
148
  // update the data on the mesh instance
112
149
  instance = options.instance;
113
- const currentWidths = instance.options.widths;
150
+ const currentWidths = instance.widths;
114
151
  if (currentWidths) {
115
- const newWidths = [...currentWidths];
116
- newWidths.push(...widths);
117
- instance.setSegmentWidths(newWidths);
152
+ const newWidths = currentWidths.slice();
153
+ for (const w of widths) {
154
+ newWidths.push(w);
155
+ }
156
+ instance.widths = newWidths;
118
157
  }
119
158
  else {
120
- instance.setSegmentWidths(widths);
159
+ instance.widths = widths;
121
160
  }
122
- instance.options.instance = instance;
123
161
  instance.addPoints(allPoints);
124
162
  }
125
163
  // add colors
@@ -127,7 +165,7 @@ export function CreateGreasedLine(name, options, materialOptions, scene) {
127
165
  if (colors && options.instance) {
128
166
  if (options.instance.material instanceof StandardMaterial || instance.material instanceof PBRMaterial) {
129
167
  if (options.instance.greasedLineMaterial) {
130
- const currentColors = options.instance.greasedLineMaterial.getOptions().colors;
168
+ const currentColors = options.instance.greasedLineMaterial.colors;
131
169
  if (currentColors) {
132
170
  const newColors = currentColors.concat(colors);
133
171
  options.instance.greasedLineMaterial.setColors(newColors, instance.isLazy());
@@ -327,4 +365,5 @@ export function CompleteGreasedLineColorTable(pointCount, colors, colorDistribut
327
365
  }
328
366
  return colorsData;
329
367
  }
368
+ ``;
330
369
  //# sourceMappingURL=greasedLineBuilder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"greasedLineBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/greasedLineBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAC7I,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAG9D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,CAAN,IAAY,gCAOX;AAPD,WAAY,gCAAgC;IACxC,6HAA2B,C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KAAK,CAAC,CAAC,CAAC,CAAC;gBAExB,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAE3B,CAAC,IAAI,iBAAiB,CAAC;aAC1B;SACJ;aAAM,IAAI,iBAAiB,KAAK,gCAAgC,CAAC,uBAAuB,EAAE;YACvF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACpC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;aAC9B;SACJ;KACJ;SAAM;QACH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE;YACjC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9B;KACJ;IAED,OAAO,UAAU,CAAC;AACtB,CAAC","sourcesContent":["import { Color3 } from \"../../Maths/math.color\";\r\nimport type { GreasedLineMaterialOptions } from \"../../Materials/greasedLinePluginMaterial\";\r\nimport { GreasedLineMeshColorMode, GreasedLineMeshMaterialType, GreasedLinePluginMaterial } from \"../../Materials/greasedLinePluginMaterial\";\r\nimport { StandardMaterial } from \"./../../Materials/standardMaterial\";\r\nimport { PBRMaterial } from \"../../Materials/PBR/pbrMaterial\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { GreasedLineMeshOptions } from \"../greasedLineMesh\";\r\nimport { GreasedLineMesh } from \"../greasedLineMesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { EngineStore } from \"../../Engines/engineStore\";\r\n\r\nexport enum GreasedLineMeshColorDistribution {\r\n COLOR_DISTRIBUTION_NONE = 0,\r\n COLOR_DISTRIBUTION_REPEAT = 1,\r\n COLOR_DISTRIBUTION_EVEN = 2,\r\n COLOR_DISTRIBUTION_START = 3,\r\n COLOR_DISTRIBUTION_END = 4,\r\n COLOR_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\nexport enum GreasedLineMeshWidthDistribution {\r\n WIDTH_DISTRIBUTION_NONE = 0,\r\n WIDTH_DISTRIBUTION_REPEAT = 1,\r\n WIDTH_DISTRIBUTION_EVEN = 2,\r\n WIDTH_DISTRIBUTION_START = 3,\r\n WIDTH_DISTRIBUTION_END = 4,\r\n WIDTH_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * Material options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMaterialBuilderOptions extends GreasedLineMaterialOptions {\r\n /**\r\n * If set to true a new material will be created and a new material plugin will be attached\r\n * to the material. The material will be set on the mesh. If the instance option is specified in the mesh options,\r\n * no material will be created/assigned. Defaults to true.\r\n */\r\n createAndAssignMaterial?: boolean;\r\n /**\r\n * Distribution of the colors if the color table contains fewer entries than needed. Defaults to GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START\r\n * @see CompleteGreasedLineColorTable\r\n */\r\n colorDistribution?: GreasedLineMeshColorDistribution;\r\n}\r\n\r\n/**\r\n * Line mesh options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMeshBuilderOptions extends GreasedLineMeshOptions {\r\n /**\r\n * Distribution of the widths if the width table contains fewer entries than needed. Defaults to GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START\r\n * @see CompleteGreasedLineWidthTable\r\n */\r\n widthDistribution?: GreasedLineMeshWidthDistribution;\r\n}\r\n\r\n/**\r\n * Builder class for create GreasedLineMeshes\r\n */\r\n\r\n/**\r\n * Creates a new @see GreasedLinePluginMaterial\r\n * @param name name of the material\r\n * @param options material options @see GreasedLineMaterialOptions\r\n * @param scene scene or null to use the last scene\r\n * @returns StandardMaterial or PBRMaterial with the @see GreasedLinePluginMaterial attached to it\r\n */\r\nexport function CreateGreasedLineMaterial(name: string, options: GreasedLineMaterialOptions, scene: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n const material = options.materialType === GreasedLineMeshMaterialType.MATERIAL_TYPE_PBR ? new PBRMaterial(name, scene) : new StandardMaterial(name, scene);\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n\r\n return material;\r\n}\r\n/**\r\n * Creates a GreasedLine mesh\r\n * @param name name of the mesh\r\n * @param options options for the mesh\r\n * @param materialOptions material options for the mesh\r\n * @param scene scene where the mesh will be created\r\n * @returns instance of GreasedLineMesh\r\n */\r\nexport function CreateGreasedLine(name: string, options: GreasedLineMeshBuilderOptions, materialOptions?: Nullable<GreasedLineMaterialBuilderOptions>, scene?: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let instance;\r\n const allPoints = GreasedLineMesh.ConvertPoints(options.points);\r\n\r\n let length = 0;\r\n if (Array.isArray(allPoints[0])) {\r\n allPoints.forEach((points) => {\r\n length += points.length / 3;\r\n });\r\n }\r\n\r\n options.widthDistribution = options.widthDistribution ?? GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START;\r\n\r\n materialOptions = materialOptions ?? {\r\n color: Color3.White(),\r\n };\r\n materialOptions.createAndAssignMaterial = materialOptions.createAndAssignMaterial ?? true;\r\n materialOptions.colorDistribution = materialOptions?.colorDistribution ?? GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START;\r\n\r\n const widths = CompleteGreasedLineWidthTable(length, options.widths ?? [], options.widthDistribution);\r\n\r\n const colors = materialOptions?.colors\r\n ? CompleteGreasedLineColorTable(length, materialOptions.colors, materialOptions.colorDistribution, materialOptions.color ?? Color3.White())\r\n : undefined;\r\n\r\n // create new mesh if instance is not defined\r\n if (!options.instance) {\r\n const initialGreasedLineOptions: GreasedLineMeshOptions = {\r\n points: allPoints,\r\n updatable: options.updatable,\r\n widths,\r\n lazy: options.lazy,\r\n };\r\n\r\n instance = new GreasedLineMesh(name, scene, initialGreasedLineOptions);\r\n\r\n if (materialOptions) {\r\n const initialMaterialOptions: GreasedLineMaterialOptions = {\r\n materialType: materialOptions.materialType,\r\n dashCount: materialOptions.dashCount,\r\n dashOffset: materialOptions.dashOffset,\r\n dashRatio: materialOptions.dashRatio,\r\n resolution: materialOptions.resolution,\r\n sizeAttenuation: materialOptions.sizeAttenuation,\r\n useColors: materialOptions.useColors,\r\n useDash: materialOptions.useDash,\r\n visibility: materialOptions.visibility,\r\n width: materialOptions.width,\r\n color: materialOptions.color,\r\n colorMode: materialOptions.colorMode ?? GreasedLineMeshColorMode.COLOR_MODE_SET,\r\n colorsSampling: materialOptions.colorsSampling,\r\n colorDistributionType: materialOptions.colorDistributionType,\r\n };\r\n\r\n if (colors) {\r\n initialMaterialOptions.colors = colors;\r\n } else if (!materialOptions.color) {\r\n // if we don't have a color table nor a color assign it a default white color\r\n initialMaterialOptions.color = Color3.White();\r\n }\r\n\r\n if (materialOptions.createAndAssignMaterial) {\r\n const material = materialOptions.materialType === GreasedLineMeshMaterialType.MATERIAL_TYPE_PBR ? new PBRMaterial(name, scene) : new StandardMaterial(name, scene);\r\n new GreasedLinePluginMaterial(material, scene, initialMaterialOptions);\r\n instance.material = material;\r\n }\r\n }\r\n } else {\r\n // update the data on the mesh instance\r\n instance = options.instance;\r\n const currentWidths = instance.options.widths;\r\n\r\n if (currentWidths) {\r\n const newWidths = [...currentWidths];\r\n newWidths.push(...widths);\r\n instance.setSegmentWidths(newWidths);\r\n } else {\r\n instance.setSegmentWidths(widths);\r\n }\r\n instance.options.instance = instance;\r\n instance.addPoints(allPoints);\r\n }\r\n\r\n // add colors\r\n // it will merge if any colors already on the instance\r\n if (colors && options.instance) {\r\n if (options.instance.material instanceof StandardMaterial || instance.material instanceof PBRMaterial) {\r\n if (options.instance.greasedLineMaterial) {\r\n const currentColors = options.instance.greasedLineMaterial.getOptions().colors;\r\n if (currentColors) {\r\n const newColors = currentColors.concat(colors);\r\n options.instance.greasedLineMaterial.setColors(newColors, instance.isLazy());\r\n }\r\n }\r\n }\r\n }\r\n\r\n return instance;\r\n}\r\n\r\n/**\r\n * Completes the width table/fills the missing entries. It means it creates a width entry for every point of the line mesh.\r\n * You can provide more points the widths when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMeshWidthDistribution.REPEAT - the width table will be repeatedly copied to the empty values [wL, wU] = [wL, wU, wL, wU, wL, wU, wL, wU, ...]\r\n * GreasedLineMeshWidthDistribution.EVEN - the width table will be evenly copied to the empty values [wL, wU] = [wL, wL, wL, wL, wU, wU, wU, wU]\r\n * GreasedLineMeshWidthDistribution.START - the width table will be copied at the start of the empty values\r\n * and rest will be filled width the default width upper and default width lower values [wU, wL] = [wL, wU, dwL, dwU, dwL, dwU, dwL, dwU]\r\n * GreasedLineMeshWidthDistribution.END - the width table will be copied at the end of the empty values\r\n * and rest will be filled width the default values [wL, wU] = [wL, wU, dwL, dwU, dwL, dwU, wL, wU]\r\n * @param pointCount number of points of the line mesh\r\n * @param widths array of widths [widhtLower, widthUpper, widthLower, widthUpper ...]. Two widths (lower/upper) per point.\r\n * @param widthsDistribution how to distribute widths if the widths array has fewer entries than pointCount\r\n * @param defaultWidthUpper the default value which will be used to fill empty width entries - upper width\r\n * @param defaultWidthLower the default value which will be used to fill empty width entries - lower width\r\n * @returns completed width table.\r\n */\r\nexport function CompleteGreasedLineWidthTable(\r\n pointCount: number,\r\n widths: number[],\r\n widthsDistribution: GreasedLineMeshWidthDistribution,\r\n defaultWidthUpper = 1,\r\n defaultWidthLower = 1\r\n): number[] {\r\n const missingCount = pointCount - widths.length / 2;\r\n\r\n const widthsData: number[] = [];\r\n if (missingCount < 0) {\r\n return widths.slice(0, pointCount * 2);\r\n }\r\n\r\n // is the width table shorter than the point table?\r\n if (missingCount > 0) {\r\n // it is, fill in the missing elements\r\n if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(widths.length / 2);\r\n\r\n // start sector\r\n for (let i = 0, j = 0; i < halfCount - 1; i++) {\r\n widthsData.push(widths[j++]);\r\n widthsData.push(widths[j++]);\r\n }\r\n\r\n // middle sector\r\n const widthL = widths[halfCount / 2];\r\n const widthU = widths[halfCount / 2 + 1];\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(widthU);\r\n widthsData.push(widthL);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n widthsData.push(widths[i++]);\r\n widthsData.push(widths[i++]);\r\n\r\n if (i === widths.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const widthsectorLength = widths.length / ((pointCount - 1) * 2);\r\n for (let x = 0; x < pointCount; x++) {\r\n const i = Math.floor(j);\r\n\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n\r\n j += widthsectorLength;\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < widths.length; i++) {\r\n widthsData.push(widths[i]);\r\n }\r\n }\r\n\r\n return widthsData;\r\n}\r\n\r\n/**\r\n * Completes the color table/fill the missing color entries. It means it creates a color entry for every point of the line mesh.\r\n * You can provide more points the colors when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMesColorhDistribution.REPEAT - the color table will be repeatedly copied to the empty values [c1, c2] = [c1, c2, c1, c2, c1, c2, c1, c2]\r\n * GreasedLineMesColorhDistribution.EVEN - the color table will be evenly copied to the empty values [c1, c2] = [c1, c1, c1, c1, c2, c2, c2, c2]\r\n * GreasedLineMesColorhDistribution.START - the color table will be copied at the start of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, dc, dc]\r\n * GreasedLineMesColorhDistribution.START_END - the color table will be copied at the start and the end of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, c1, c2]\r\n * @param pointCount number of points of the line mesh\r\n * @param colors array of Color3 for the color table\r\n * @param colorDistribution how to distribute colors if the colors array has fewer entries than pointCount\r\n * @param defaultColor default color to be used to fill empty entries in the color table\r\n * @returns completed array of Color3s\r\n */\r\nexport function CompleteGreasedLineColorTable(pointCount: number, colors: Color3[], colorDistribution: GreasedLineMeshColorDistribution, defaultColor: Color3): Color3[] {\r\n const missingCount = pointCount - colors.length;\r\n if (missingCount < 0) {\r\n return colors.slice(0, pointCount);\r\n }\r\n\r\n const colorsData: Color3[] = [];\r\n // is the color table shorter than the point table?\r\n if (missingCount > 0) {\r\n // it is, fill in the missing elements\r\n if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(colors.length / 2);\r\n\r\n // start sector\r\n for (let i = 0; i < halfCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // middle sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n colorsData.push(colors[i]);\r\n\r\n i++;\r\n\r\n if (i === colors.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const colorSectorLength = colors.length / (pointCount - 1);\r\n for (let x = 0; x < pointCount - 1; x++) {\r\n const i = Math.floor(j);\r\n\r\n colorsData.push(colors[i]);\r\n\r\n j += colorSectorLength;\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_NONE) {\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < pointCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n\r\n return colorsData;\r\n}\r\n"]}
1
+ {"version":3,"file":"greasedLineBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/greasedLineBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACnH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oC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AAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;gBACrC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAExB,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;gBAE3B,CAAC,IAAI,iBAAiB,CAAC;aAC1B;SACJ;aAAM,IAAI,iBAAiB,KAAK,gCAAgC,CAAC,uBAAuB,EAAE;YACvF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACpC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;aAC9B;SACJ;KACJ;SAAM;QACH,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAE;YACjC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9B;KACJ;IAED,OAAO,UAAU,CAAC;AACtB,CAAC;AACD,EAAE,CAAC","sourcesContent":["import type { GreasedLineMaterialOptions } from \"../../Materials/greasedLinePluginMaterial\";\r\nimport { GreasedLineMeshMaterialType, GreasedLinePluginMaterial } from \"../../Materials/greasedLinePluginMaterial\";\r\nimport { StandardMaterial } from \"./../../Materials/standardMaterial\";\r\nimport { PBRMaterial } from \"../../Materials/PBR/pbrMaterial\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { GreasedLineMeshOptions } from \"../greasedLineMesh\";\r\nimport { GreasedLineMesh } from \"../greasedLineMesh\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { EngineStore } from \"../../Engines/engineStore\";\r\nimport type { Color3 } from \"core/Maths/math.color\";\r\n\r\n/**\r\n * How are the colors distributed along the color table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colors-and-colordistribution}\r\n */\r\nexport enum GreasedLineMeshColorDistribution {\r\n /**\r\n * Do no modify the color table\r\n */\r\n COLOR_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the colors until the color table is full\r\n */\r\n COLOR_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the colors evenly through the color table\r\n */\r\n COLOR_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the colors to start of the color table a fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the colors to the end of the color table and fill the rest with the default color\r\n */\r\n COLOR_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the colors to start and to the end of the color table and fill the gap between with the default color\r\n */\r\n COLOR_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * How are the widths distributed along the width table\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#widths-and-widthdistribution}\r\n */\r\nexport enum GreasedLineMeshWidthDistribution {\r\n /**\r\n * Do no modify the width table\r\n */\r\n WIDTH_DISTRIBUTION_NONE = 0,\r\n /**\r\n * Repeat the widths until the width table is full\r\n */\r\n WIDTH_DISTRIBUTION_REPEAT = 1,\r\n /**\r\n * Distribute the widths evenly through the width table\r\n */\r\n WIDTH_DISTRIBUTION_EVEN = 2,\r\n /**\r\n * Put the widths to start of the width table a fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START = 3,\r\n /**\r\n * Put the widths to the end of the width table and fill the rest with the default width\r\n */\r\n WIDTH_DISTRIBUTION_END = 4,\r\n /**\r\n * Put the widths to start and to the end of the width table and fill the gap between with the default width\r\n */\r\n WIDTH_DISTRIBUTION_START_END = 5,\r\n}\r\n\r\n/**\r\n * Material options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMaterialBuilderOptions extends GreasedLineMaterialOptions {\r\n /**\r\n * If set to true a new material will be created and a new material plugin will be attached\r\n * to the material. The material will be set on the mesh. If the instance option is specified in the mesh options,\r\n * no material will be created/assigned. Defaults to true.\r\n */\r\n createAndAssignMaterial?: boolean;\r\n /**\r\n * Distribution of the colors if the color table contains fewer entries than needed. Defaults to GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START\r\n * @see CompleteGreasedLineColorTable\r\n */\r\n colorDistribution?: GreasedLineMeshColorDistribution;\r\n}\r\n\r\n/**\r\n * Line mesh options for GreasedLineBuilder\r\n */\r\nexport interface GreasedLineMeshBuilderOptions extends GreasedLineMeshOptions {\r\n /**\r\n * Distribution of the widths if the width table contains fewer entries than needed. Defaults to GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START\r\n * @see CompleteGreasedLineWidthTable\r\n */\r\n widthDistribution?: GreasedLineMeshWidthDistribution;\r\n}\r\n\r\n/**\r\n * Builder class for create GreasedLineMeshes\r\n */\r\n\r\n/**\r\n * Creates a new @see GreasedLinePluginMaterial\r\n * @param name name of the material\r\n * @param options material options @see GreasedLineMaterialOptions\r\n * @param scene scene or null to use the last scene\r\n * @returns StandardMaterial or PBRMaterial with the @see GreasedLinePluginMaterial attached to it\r\n */\r\nexport function CreateGreasedLineMaterial(name: string, options: GreasedLineMaterialOptions, scene: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n const material = options.materialType === GreasedLineMeshMaterialType.MATERIAL_TYPE_PBR ? new PBRMaterial(name, scene) : new StandardMaterial(name, scene);\r\n new GreasedLinePluginMaterial(material, scene, options);\r\n\r\n return material;\r\n}\r\n/**\r\n * Creates a GreasedLine mesh\r\n * @param name name of the mesh\r\n * @param options options for the mesh\r\n * @param materialOptions material options for the mesh\r\n * @param scene scene where the mesh will be created\r\n * @returns instance of GreasedLineMesh\r\n */\r\nexport function CreateGreasedLine(name: string, options: GreasedLineMeshBuilderOptions, materialOptions?: Nullable<GreasedLineMaterialBuilderOptions>, scene?: Nullable<Scene>) {\r\n scene = <Scene>(scene ?? EngineStore.LastCreatedScene);\r\n\r\n let instance;\r\n const allPoints = GreasedLineMesh.ConvertPoints(options.points);\r\n\r\n let length = 0;\r\n if (Array.isArray(allPoints[0])) {\r\n allPoints.forEach((points) => {\r\n length += points.length / 3;\r\n });\r\n }\r\n\r\n options.widthDistribution = options.widthDistribution ?? GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START;\r\n\r\n materialOptions = materialOptions ?? {\r\n color: GreasedLinePluginMaterial.DEFAULT_COLOR,\r\n };\r\n materialOptions.createAndAssignMaterial = materialOptions.createAndAssignMaterial ?? true;\r\n materialOptions.colorDistribution = materialOptions?.colorDistribution ?? GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START;\r\n\r\n const widths = CompleteGreasedLineWidthTable(length, options.widths ?? [], options.widthDistribution);\r\n\r\n const colors = materialOptions?.colors\r\n ? CompleteGreasedLineColorTable(length, materialOptions.colors, materialOptions.colorDistribution, materialOptions.color ?? GreasedLinePluginMaterial.DEFAULT_COLOR)\r\n : undefined;\r\n\r\n // create new mesh if instance is not defined\r\n if (!options.instance) {\r\n const initialGreasedLineOptions: GreasedLineMeshOptions = {\r\n points: allPoints,\r\n updatable: options.updatable,\r\n widths,\r\n lazy: options.lazy,\r\n };\r\n\r\n instance = new GreasedLineMesh(name, scene, initialGreasedLineOptions);\r\n\r\n if (materialOptions) {\r\n const initialMaterialOptions: GreasedLineMaterialOptions = {\r\n materialType: materialOptions.materialType,\r\n dashCount: materialOptions.dashCount,\r\n dashOffset: materialOptions.dashOffset,\r\n dashRatio: materialOptions.dashRatio,\r\n resolution: materialOptions.resolution,\r\n sizeAttenuation: materialOptions.sizeAttenuation,\r\n useColors: materialOptions.useColors,\r\n useDash: materialOptions.useDash,\r\n visibility: materialOptions.visibility,\r\n width: materialOptions.width,\r\n color: materialOptions.color,\r\n colorMode: materialOptions.colorMode,\r\n colorsSampling: materialOptions.colorsSampling,\r\n colorDistributionType: materialOptions.colorDistributionType,\r\n colors,\r\n };\r\n\r\n if (materialOptions.createAndAssignMaterial) {\r\n const material = materialOptions.materialType === GreasedLineMeshMaterialType.MATERIAL_TYPE_PBR ? new PBRMaterial(name, scene) : new StandardMaterial(name, scene);\r\n new GreasedLinePluginMaterial(material, scene, initialMaterialOptions);\r\n instance.material = material;\r\n }\r\n }\r\n } else {\r\n // update the data on the mesh instance\r\n instance = options.instance;\r\n const currentWidths = instance.widths;\r\n\r\n if (currentWidths) {\r\n const newWidths = currentWidths.slice();\r\n for (const w of widths) {\r\n newWidths.push(w);\r\n }\r\n instance.widths = newWidths;\r\n } else {\r\n instance.widths = widths;\r\n }\r\n instance.addPoints(allPoints);\r\n }\r\n\r\n // add colors\r\n // it will merge if any colors already on the instance\r\n if (colors && options.instance) {\r\n if (options.instance.material instanceof StandardMaterial || instance.material instanceof PBRMaterial) {\r\n if (options.instance.greasedLineMaterial) {\r\n const currentColors = options.instance.greasedLineMaterial.colors;\r\n if (currentColors) {\r\n const newColors = currentColors.concat(colors);\r\n options.instance.greasedLineMaterial.setColors(newColors, instance.isLazy());\r\n }\r\n }\r\n }\r\n }\r\n\r\n return instance;\r\n}\r\n\r\n/**\r\n * Completes the width table/fills the missing entries. It means it creates a width entry for every point of the line mesh.\r\n * You can provide more points the widths when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMeshWidthDistribution.REPEAT - the width table will be repeatedly copied to the empty values [wL, wU] = [wL, wU, wL, wU, wL, wU, wL, wU, ...]\r\n * GreasedLineMeshWidthDistribution.EVEN - the width table will be evenly copied to the empty values [wL, wU] = [wL, wL, wL, wL, wU, wU, wU, wU]\r\n * GreasedLineMeshWidthDistribution.START - the width table will be copied at the start of the empty values\r\n * and rest will be filled width the default width upper and default width lower values [wU, wL] = [wL, wU, dwL, dwU, dwL, dwU, dwL, dwU]\r\n * GreasedLineMeshWidthDistribution.END - the width table will be copied at the end of the empty values\r\n * and rest will be filled width the default values [wL, wU] = [wL, wU, dwL, dwU, dwL, dwU, wL, wU]\r\n * @param pointCount number of points of the line mesh\r\n * @param widths array of widths [widhtLower, widthUpper, widthLower, widthUpper ...]. Two widths (lower/upper) per point.\r\n * @param widthsDistribution how to distribute widths if the widths array has fewer entries than pointCount\r\n * @param defaultWidthUpper the default value which will be used to fill empty width entries - upper width\r\n * @param defaultWidthLower the default value which will be used to fill empty width entries - lower width\r\n * @returns completed width table.\r\n */\r\nexport function CompleteGreasedLineWidthTable(\r\n pointCount: number,\r\n widths: number[],\r\n widthsDistribution: GreasedLineMeshWidthDistribution,\r\n defaultWidthUpper = 1,\r\n defaultWidthLower = 1\r\n): number[] {\r\n const missingCount = pointCount - widths.length / 2;\r\n\r\n const widthsData: number[] = [];\r\n if (missingCount < 0) {\r\n return widths.slice(0, pointCount * 2);\r\n }\r\n\r\n // is the width table shorter than the point table?\r\n if (missingCount > 0) {\r\n // it is, fill in the missing elements\r\n if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(widths.length / 2);\r\n\r\n // start sector\r\n for (let i = 0, j = 0; i < halfCount - 1; i++) {\r\n widthsData.push(widths[j++]);\r\n widthsData.push(widths[j++]);\r\n }\r\n\r\n // middle sector\r\n const widthL = widths[halfCount / 2];\r\n const widthU = widths[halfCount / 2 + 1];\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(widthU);\r\n widthsData.push(widthL);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount; i++) {\r\n widthsData.push(defaultWidthUpper);\r\n widthsData.push(defaultWidthLower);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < widths.length; i += 2) {\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n widthsData.push(widths[i++]);\r\n widthsData.push(widths[i++]);\r\n\r\n if (i === widths.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (widthsDistribution === GreasedLineMeshWidthDistribution.WIDTH_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const widthsectorLength = widths.length / ((pointCount - 1) * 2);\r\n for (let x = 0; x < pointCount; x++) {\r\n const i = Math.floor(j);\r\n\r\n widthsData.push(widths[i]);\r\n widthsData.push(widths[i + 1]);\r\n\r\n j += widthsectorLength;\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < widths.length; i++) {\r\n widthsData.push(widths[i]);\r\n }\r\n }\r\n\r\n return widthsData;\r\n}\r\n\r\n/**\r\n * Completes the color table/fill the missing color entries. It means it creates a color entry for every point of the line mesh.\r\n * You can provide more points the colors when creating the mesh. This function will fill the empty entries.\r\n * The algorithm used to fill the empty entries can be\r\n * GreasedLineMesColorhDistribution.REPEAT - the color table will be repeatedly copied to the empty values [c1, c2] = [c1, c2, c1, c2, c1, c2, c1, c2]\r\n * GreasedLineMesColorhDistribution.EVEN - the color table will be evenly copied to the empty values [c1, c2] = [c1, c1, c1, c1, c2, c2, c2, c2]\r\n * GreasedLineMesColorhDistribution.START - the color table will be copied at the start of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, dc, dc]\r\n * GreasedLineMesColorhDistribution.START_END - the color table will be copied at the start and the end of the empty values\r\n * and rest will be filled color the default color value [c1, c2] = [c1, c2, dc, dc, dc, dc, c1, c2]\r\n * @param pointCount number of points of the line mesh\r\n * @param colors array of Color3 for the color table\r\n * @param colorDistribution how to distribute colors if the colors array has fewer entries than pointCount\r\n * @param defaultColor default color to be used to fill empty entries in the color table\r\n * @returns completed array of Color3s\r\n */\r\nexport function CompleteGreasedLineColorTable(pointCount: number, colors: Color3[], colorDistribution: GreasedLineMeshColorDistribution, defaultColor: Color3): Color3[] {\r\n const missingCount = pointCount - colors.length;\r\n if (missingCount < 0) {\r\n return colors.slice(0, pointCount);\r\n }\r\n\r\n const colorsData: Color3[] = [];\r\n // is the color table shorter than the point table?\r\n if (missingCount > 0) {\r\n // it is, fill in the missing elements\r\n if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START_END) {\r\n const halfCount = Math.floor(colors.length / 2);\r\n\r\n // start sector\r\n for (let i = 0; i < halfCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // middle sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = halfCount; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_START) {\r\n // start sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < missingCount; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_END) {\r\n // start sector\r\n for (let i = 0; i < missingCount - 1; i++) {\r\n colorsData.push(defaultColor);\r\n }\r\n\r\n // end sector\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_REPEAT) {\r\n let i = 0;\r\n for (let x = 0; x < pointCount; x++) {\r\n colorsData.push(colors[i]);\r\n\r\n i++;\r\n\r\n if (i === colors.length) {\r\n i = 0;\r\n }\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_EVEN) {\r\n let j = 0;\r\n const colorSectorLength = colors.length / (pointCount - 1);\r\n for (let x = 0; x < pointCount - 1; x++) {\r\n const i = Math.floor(j);\r\n\r\n colorsData.push(colors[i]);\r\n\r\n j += colorSectorLength;\r\n }\r\n } else if (colorDistribution === GreasedLineMeshColorDistribution.COLOR_DISTRIBUTION_NONE) {\r\n for (let i = 0; i < colors.length; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n } else {\r\n for (let i = 0; i < pointCount; i++) {\r\n colorsData.push(colors[i]);\r\n }\r\n }\r\n\r\n return colorsData;\r\n}\r\n``;\r\n"]}
@@ -54,13 +54,14 @@ export declare class GreasedLineMesh extends Mesh {
54
54
  readonly name: string;
55
55
  private _options;
56
56
  private _vertexPositions;
57
- private _offsets?;
58
- private _colorPointers;
59
57
  private _previousAndSide;
60
58
  private _nextAndCounters;
61
59
  private _indices;
62
60
  private _uvs;
63
61
  private _points;
62
+ private _offsets;
63
+ private _colorPointers;
64
+ private _widths;
64
65
  private _offsetsBuffer?;
65
66
  private _widthsBuffer?;
66
67
  private _colorPointersBuffer?;
@@ -100,29 +101,40 @@ export declare class GreasedLineMesh extends Mesh {
100
101
  */
101
102
  isLazy(): boolean;
102
103
  /**
103
- *
104
- * @returns options of the line
104
+ * Return the the points offsets
105
105
  */
106
- get options(): GreasedLineMeshOptions;
106
+ get offsets(): number[];
107
107
  /**
108
- * Sets point offets
108
+ * Sets point offests
109
109
  * @param offsets offset table [x,y,z, x,y,z, ....]
110
110
  */
111
- setOffsets(offsets: number[]): void;
111
+ set offsets(offsets: number[]);
112
+ /**
113
+ * Gets widths at each line point like [widthLower, widthUpper, widthLower, widthUpper, ...]
114
+ */
115
+ get widths(): number[];
112
116
  /**
113
117
  * Sets widths at each line point
114
- * @param widths width table [widthUpper,widthLower, widthUpper,widthLower, ...]
118
+ * @param widths width table [widthLower, widthUpper, widthLower, widthUpper ...]
115
119
  */
116
- setSegmentWidths(widths: number[]): void;
120
+ set widths(widths: number[]);
121
+ /**
122
+ * Gets the color pointer. Each vertex need a color pointer. These color pointers points to the colors in the color table @see colors
123
+ */
124
+ get colorPointers(): number[];
117
125
  /**
118
126
  * Sets the color pointer
119
- * @param colorPointers arra of color pointer in the colors array. One pointer for every vertex is needed.
127
+ * @param colorPointers array of color pointer in the colors array. One pointer for every vertex is needed.
120
128
  */
121
- setColorPointers(colorPointers: number[]): void;
129
+ set colorPointers(colorPointers: number[]);
122
130
  /**
123
131
  * Gets the pluginMaterial associated with line
124
132
  */
125
133
  get greasedLineMaterial(): GreasedLinePluginMaterial;
134
+ /**
135
+ * Return copy the points.
136
+ */
137
+ get points(): number[][];
126
138
  /**
127
139
  * Adds new points to the line. It doesn't rerenders the line if in lazy mode.
128
140
  * @param points points table
@@ -134,6 +146,7 @@ export declare class GreasedLineMesh extends Mesh {
134
146
  * @param points points table
135
147
  */
136
148
  setPoints(points: number[][]): void;
149
+ private _createLineOptions;
137
150
  /**
138
151
  * Clones the GreasedLineMesh.
139
152
  * @param name new line name
@@ -31,9 +31,9 @@ export class GreasedLineMesh extends Mesh {
31
31
  this._uvs = [];
32
32
  this._points = [];
33
33
  this._colorPointers = (_c = _options.colorPointers) !== null && _c !== void 0 ? _c : [];
34
+ this._widths = (_d = _options.widths) !== null && _d !== void 0 ? _d : new Array(_options.points.length).fill(1);
34
35
  this._previousAndSide = [];
35
36
  this._nextAndCounters = [];
36
- _options.widths = (_d = _options.widths) !== null && _d !== void 0 ? _d : new Array(_options.points.length).fill(1);
37
37
  if (_options.points) {
38
38
  this.addPoints(GreasedLineMesh.ConvertPoints(_options.points));
39
39
  }
@@ -112,17 +112,17 @@ export class GreasedLineMesh extends Mesh {
112
112
  return this._lazy;
113
113
  }
114
114
  /**
115
- *
116
- * @returns options of the line
115
+ * Return the the points offsets
117
116
  */
118
- get options() {
119
- return this._options;
117
+ get offsets() {
118
+ return this._offsets;
120
119
  }
121
120
  /**
122
- * Sets point offets
121
+ * Sets point offests
123
122
  * @param offsets offset table [x,y,z, x,y,z, ....]
124
123
  */
125
- setOffsets(offsets) {
124
+ set offsets(offsets) {
125
+ this._offsets = offsets;
126
126
  if (!this._offsetsBuffer) {
127
127
  this._createOffsetsBuffer(offsets);
128
128
  }
@@ -130,21 +130,34 @@ export class GreasedLineMesh extends Mesh {
130
130
  this._offsetsBuffer && this._offsetsBuffer.update(offsets);
131
131
  }
132
132
  }
133
+ /**
134
+ * Gets widths at each line point like [widthLower, widthUpper, widthLower, widthUpper, ...]
135
+ */
136
+ get widths() {
137
+ return this._widths;
138
+ }
133
139
  /**
134
140
  * Sets widths at each line point
135
- * @param widths width table [widthUpper,widthLower, widthUpper,widthLower, ...]
141
+ * @param widths width table [widthLower, widthUpper, widthLower, widthUpper ...]
136
142
  */
137
- setSegmentWidths(widths) {
138
- this._options.widths = widths;
143
+ set widths(widths) {
144
+ this._widths = widths;
139
145
  if (!this._lazy) {
140
146
  this._widthsBuffer && this._widthsBuffer.update(widths);
141
147
  }
142
148
  }
149
+ /**
150
+ * Gets the color pointer. Each vertex need a color pointer. These color pointers points to the colors in the color table @see colors
151
+ */
152
+ get colorPointers() {
153
+ return this._colorPointers;
154
+ }
143
155
  /**
144
156
  * Sets the color pointer
145
- * @param colorPointers arra of color pointer in the colors array. One pointer for every vertex is needed.
157
+ * @param colorPointers array of color pointer in the colors array. One pointer for every vertex is needed.
146
158
  */
147
- setColorPointers(colorPointers) {
159
+ set colorPointers(colorPointers) {
160
+ this._colorPointers = colorPointers;
148
161
  if (!this._lazy) {
149
162
  this._colorPointersBuffer && this._colorPointersBuffer.update(colorPointers);
150
163
  }
@@ -156,13 +169,22 @@ export class GreasedLineMesh extends Mesh {
156
169
  var _a, _b;
157
170
  return (_b = (_a = this.material) === null || _a === void 0 ? void 0 : _a.pluginManager) === null || _b === void 0 ? void 0 : _b.getPlugin(GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME);
158
171
  }
172
+ /**
173
+ * Return copy the points.
174
+ */
175
+ get points() {
176
+ const pointsCopy = [];
177
+ DeepCopier.DeepCopy(this._points, pointsCopy);
178
+ return pointsCopy;
179
+ }
159
180
  /**
160
181
  * Adds new points to the line. It doesn't rerenders the line if in lazy mode.
161
182
  * @param points points table
162
183
  */
163
184
  addPoints(points) {
164
- const numberPoints = points;
165
- this._points.push(...numberPoints);
185
+ for (const p of points) {
186
+ this._points.push(p);
187
+ }
166
188
  if (!this._lazy) {
167
189
  this.setPoints(this._points);
168
190
  }
@@ -212,14 +234,20 @@ export class GreasedLineMesh extends Mesh {
212
234
  const side = [];
213
235
  let uvs = [];
214
236
  this._preprocess(positions, previous, next, side, uvs);
215
- this._vertexPositions.push(...positions);
216
- this._indices.push(...indices);
237
+ for (const vp of positions) {
238
+ this._vertexPositions.push(vp);
239
+ }
240
+ for (const i of indices) {
241
+ this._indices.push(i);
242
+ }
217
243
  for (let i = 0; i < side.length; i++) {
218
244
  this._previousAndSide.push(previous[i * 3], previous[i * 3 + 1], previous[i * 3 + 2], side[i]);
219
245
  this._nextAndCounters.push(next[i * 3], next[i * 3 + 1], next[i * 3 + 2], counters[i]);
220
246
  }
221
247
  uvs = (_a = this._options.uvs) !== null && _a !== void 0 ? _a : uvs;
222
- this._uvs.push(...uvs);
248
+ for (const uv of uvs) {
249
+ this._uvs.push(uv);
250
+ }
223
251
  });
224
252
  if (!this._lazy) {
225
253
  if (!this._options.colorPointers) {
@@ -229,6 +257,17 @@ export class GreasedLineMesh extends Mesh {
229
257
  this.refreshBoundingInfo();
230
258
  }
231
259
  }
260
+ _createLineOptions() {
261
+ const lineOptions = {
262
+ points: this._points,
263
+ colorPointers: this._colorPointers,
264
+ lazy: this._lazy,
265
+ updatable: this._updatable,
266
+ uvs: this._uvs,
267
+ widths: this._widths,
268
+ };
269
+ return lineOptions;
270
+ }
232
271
  /**
233
272
  * Clones the GreasedLineMesh.
234
273
  * @param name new line name
@@ -236,9 +275,10 @@ export class GreasedLineMesh extends Mesh {
236
275
  * @returns cloned line
237
276
  */
238
277
  clone(name = `${this.name}-cloned`, newParent) {
239
- const lineOptions = {};
240
- DeepCopier.DeepCopy(this._options, lineOptions, ["instance"]);
241
- const cloned = new GreasedLineMesh(name, this._scene, lineOptions);
278
+ const lineOptions = this._createLineOptions();
279
+ const deepCopiedLineOptions = {};
280
+ DeepCopier.DeepCopy(lineOptions, deepCopiedLineOptions, ["instance"]);
281
+ const cloned = new GreasedLineMesh(name, this._scene, deepCopiedLineOptions);
242
282
  if (newParent) {
243
283
  cloned.parent = newParent;
244
284
  }
@@ -252,7 +292,7 @@ export class GreasedLineMesh extends Mesh {
252
292
  serialize(serializationObject) {
253
293
  super.serialize(serializationObject);
254
294
  serializationObject.type = this.getClassName();
255
- serializationObject.lineOptions = this._options;
295
+ serializationObject.lineOptions = this._createLineOptions();
256
296
  }
257
297
  /**
258
298
  * Parses a serialized GreasedLineMesh
@@ -307,8 +347,8 @@ export class GreasedLineMesh extends Mesh {
307
347
  }
308
348
  const indices = this.getIndices();
309
349
  const positions = this.getVerticesData(VertexBuffer.PositionKind);
310
- const widths = this._options.widths;
311
- const lineWidth = (_b = (_a = this.greasedLineMaterial) === null || _a === void 0 ? void 0 : _a.getOptions().width) !== null && _b !== void 0 ? _b : 1;
350
+ const widths = this._widths;
351
+ const lineWidth = (_b = (_a = this.greasedLineMaterial) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 1;
312
352
  const intersects = [];
313
353
  if (indices && positions && widths) {
314
354
  let i = 0, l = 0;
@@ -416,7 +456,7 @@ export class GreasedLineMesh extends Mesh {
416
456
  this.setVerticesBuffer(previousAndSideBuffer.createVertexBuffer("grl_previousAndSide", 0, 4));
417
457
  const nextAndCountersBuffer = new Buffer(engine, this._nextAndCounters, false, 4);
418
458
  this.setVerticesBuffer(nextAndCountersBuffer.createVertexBuffer("grl_nextAndCounters", 0, 4));
419
- const widthBuffer = new Buffer(engine, this._options.widths, this._updatable, 1);
459
+ const widthBuffer = new Buffer(engine, this._widths, this._updatable, 1);
420
460
  this.setVerticesBuffer(widthBuffer.createVertexBuffer("grl_widths", 0, 1));
421
461
  this._widthsBuffer = widthBuffer;
422
462
  const colorPointersBuffer = new Buffer(engine, this._colorPointers, this._updatable, 1);