@babylonjs/core 6.16.0 → 6.16.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 (145) hide show
  1. package/Bones/boneIKController.js +1 -0
  2. package/Bones/boneIKController.js.map +1 -1
  3. package/Debug/axesViewer.js +3 -3
  4. package/Debug/axesViewer.js.map +1 -1
  5. package/Decorators/nodeDecorator.d.ts +2 -1
  6. package/Decorators/nodeDecorator.js.map +1 -1
  7. package/Engines/thinEngine.js +2 -2
  8. package/Engines/thinEngine.js.map +1 -1
  9. package/Gizmos/planeDragGizmo.js +13 -5
  10. package/Gizmos/planeDragGizmo.js.map +1 -1
  11. package/Materials/Node/Blocks/Dual/sceneDepthBlock.js +7 -3
  12. package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
  13. package/Materials/Node/nodeMaterial.d.ts +1 -1
  14. package/Materials/Node/nodeMaterial.js +6 -2
  15. package/Materials/Node/nodeMaterial.js.map +1 -1
  16. package/Materials/greasedLinePluginMaterial.d.ts +96 -4
  17. package/Materials/greasedLinePluginMaterial.js +15 -6
  18. package/Materials/greasedLinePluginMaterial.js.map +1 -1
  19. package/Materials/greasedLineSimpleMaterial.d.ts +228 -0
  20. package/Materials/greasedLineSimpleMaterial.js +435 -0
  21. package/Materials/greasedLineSimpleMaterial.js.map +1 -0
  22. package/Materials/material.decalMapConfiguration.js +2 -0
  23. package/Materials/material.decalMapConfiguration.js.map +1 -1
  24. package/Materials/meshDebugPluginMaterial.d.ts +66 -17
  25. package/Materials/meshDebugPluginMaterial.js +65 -75
  26. package/Materials/meshDebugPluginMaterial.js.map +1 -1
  27. package/Maths/math.vector.js.map +1 -1
  28. package/Meshes/Builders/greasedLineBuilder.d.ts +3 -2
  29. package/Meshes/Builders/greasedLineBuilder.js +26 -15
  30. package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
  31. package/Meshes/Builders/textBuilder.d.ts +6 -0
  32. package/Meshes/Builders/textBuilder.js +5 -0
  33. package/Meshes/Builders/textBuilder.js.map +1 -1
  34. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.d.ts +2 -2
  35. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js +9 -3
  36. package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
  37. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js +1 -1
  38. package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -1
  39. package/Meshes/Node/Blocks/Set/setNormalsBlock.d.ts +1 -1
  40. package/Meshes/Node/Blocks/Set/setNormalsBlock.js +1 -1
  41. package/Meshes/Node/Blocks/Set/setNormalsBlock.js.map +1 -1
  42. package/Meshes/Node/Blocks/Set/setUVsBlock.js +1 -1
  43. package/Meshes/Node/Blocks/Set/setUVsBlock.js.map +1 -1
  44. package/Meshes/Node/Blocks/Sources/boxBlock.js +1 -1
  45. package/Meshes/Node/Blocks/Sources/boxBlock.js.map +1 -1
  46. package/Meshes/Node/Blocks/Sources/capsuleBlock.js +1 -1
  47. package/Meshes/Node/Blocks/Sources/capsuleBlock.js.map +1 -1
  48. package/Meshes/Node/Blocks/Sources/cylinderBlock.js +1 -1
  49. package/Meshes/Node/Blocks/Sources/cylinderBlock.js.map +1 -1
  50. package/Meshes/Node/Blocks/Sources/discBlock.d.ts +1 -1
  51. package/Meshes/Node/Blocks/Sources/discBlock.js +2 -2
  52. package/Meshes/Node/Blocks/Sources/discBlock.js.map +1 -1
  53. package/Meshes/Node/Blocks/Sources/gridBlock.js +1 -1
  54. package/Meshes/Node/Blocks/Sources/gridBlock.js.map +1 -1
  55. package/Meshes/Node/Blocks/Sources/icoSphereBlock.d.ts +3 -3
  56. package/Meshes/Node/Blocks/Sources/icoSphereBlock.js +4 -4
  57. package/Meshes/Node/Blocks/Sources/icoSphereBlock.js.map +1 -1
  58. package/Meshes/Node/Blocks/Sources/meshBlock.d.ts +1 -1
  59. package/Meshes/Node/Blocks/Sources/meshBlock.js +1 -1
  60. package/Meshes/Node/Blocks/Sources/meshBlock.js.map +1 -1
  61. package/Meshes/Node/Blocks/Sources/nullBlock.d.ts +22 -0
  62. package/Meshes/Node/Blocks/Sources/nullBlock.js +34 -0
  63. package/Meshes/Node/Blocks/Sources/nullBlock.js.map +1 -0
  64. package/Meshes/Node/Blocks/Sources/planeBlock.js +1 -1
  65. package/Meshes/Node/Blocks/Sources/planeBlock.js.map +1 -1
  66. package/Meshes/Node/Blocks/Sources/sphereBlock.js +1 -1
  67. package/Meshes/Node/Blocks/Sources/sphereBlock.js.map +1 -1
  68. package/Meshes/Node/Blocks/Sources/torusBlock.d.ts +1 -1
  69. package/Meshes/Node/Blocks/Sources/torusBlock.js +2 -2
  70. package/Meshes/Node/Blocks/Sources/torusBlock.js.map +1 -1
  71. package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js +1 -1
  72. package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
  73. package/Meshes/Node/Blocks/conditionBlock.d.ts +1 -1
  74. package/Meshes/Node/Blocks/conditionBlock.js +9 -6
  75. package/Meshes/Node/Blocks/conditionBlock.js.map +1 -1
  76. package/Meshes/Node/Blocks/debugBlock.js +1 -1
  77. package/Meshes/Node/Blocks/debugBlock.js.map +1 -1
  78. package/Meshes/Node/Blocks/geometryInputBlock.d.ts +1 -0
  79. package/Meshes/Node/Blocks/geometryInputBlock.js +33 -1
  80. package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
  81. package/Meshes/Node/Blocks/geometryOptimizeBlock.d.ts +43 -0
  82. package/Meshes/Node/Blocks/geometryOptimizeBlock.js +118 -0
  83. package/Meshes/Node/Blocks/geometryOptimizeBlock.js.map +1 -0
  84. package/Meshes/Node/Blocks/geometryOutputBlock.js +1 -0
  85. package/Meshes/Node/Blocks/geometryOutputBlock.js.map +1 -1
  86. package/Meshes/Node/Blocks/geometryTransformBlock.d.ts +8 -1
  87. package/Meshes/Node/Blocks/geometryTransformBlock.js +20 -1
  88. package/Meshes/Node/Blocks/geometryTransformBlock.js.map +1 -1
  89. package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +4 -1
  90. package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -1
  91. package/Meshes/Node/Blocks/{IntFloatConverterBlock.js → intFloatConverterBlock.js} +1 -1
  92. package/Meshes/Node/Blocks/{IntFloatConverterBlock.js.map → intFloatConverterBlock.js.map} +1 -1
  93. package/Meshes/Node/Blocks/mathBlock.d.ts +1 -1
  94. package/Meshes/Node/Blocks/mathBlock.js +6 -2
  95. package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
  96. package/Meshes/Node/Blocks/mergeGeometryBlock.js +1 -1
  97. package/Meshes/Node/Blocks/mergeGeometryBlock.js.map +1 -1
  98. package/Meshes/Node/Blocks/noiseBlock.js +2 -2
  99. package/Meshes/Node/Blocks/noiseBlock.js.map +1 -1
  100. package/Meshes/Node/Blocks/normalizeVectorBlock.d.ts +1 -1
  101. package/Meshes/Node/Blocks/normalizeVectorBlock.js +1 -1
  102. package/Meshes/Node/Blocks/normalizeVectorBlock.js.map +1 -1
  103. package/Meshes/Node/Blocks/randomBlock.d.ts +2 -2
  104. package/Meshes/Node/Blocks/randomBlock.js +7 -2
  105. package/Meshes/Node/Blocks/randomBlock.js.map +1 -1
  106. package/Meshes/Node/Blocks/vectorConverterBlock.d.ts +1 -0
  107. package/Meshes/Node/Blocks/vectorConverterBlock.js +35 -7
  108. package/Meshes/Node/Blocks/vectorConverterBlock.js.map +1 -1
  109. package/Meshes/Node/Enums/nodeGeometryConnectionPointTypes.d.ts +5 -5
  110. package/Meshes/Node/Enums/nodeGeometryConnectionPointTypes.js +5 -5
  111. package/Meshes/Node/Enums/nodeGeometryConnectionPointTypes.js.map +1 -1
  112. package/Meshes/Node/Enums/nodeGeometryContextualSources.d.ts +1 -3
  113. package/Meshes/Node/Enums/nodeGeometryContextualSources.js +0 -2
  114. package/Meshes/Node/Enums/nodeGeometryContextualSources.js.map +1 -1
  115. package/Meshes/Node/Interfaces/nodeGeometryExecutionContext.d.ts +1 -1
  116. package/Meshes/Node/Interfaces/nodeGeometryExecutionContext.js.map +1 -1
  117. package/Meshes/Node/index.d.ts +3 -1
  118. package/Meshes/Node/index.js +3 -1
  119. package/Meshes/Node/index.js.map +1 -1
  120. package/Meshes/Node/nodeGeometry.d.ts +3 -2
  121. package/Meshes/Node/nodeGeometry.js +10 -9
  122. package/Meshes/Node/nodeGeometry.js.map +1 -1
  123. package/Meshes/Node/nodeGeometryBlock.d.ts +7 -1
  124. package/Meshes/Node/nodeGeometryBlock.js +26 -6
  125. package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
  126. package/Meshes/Node/nodeGeometryBlockConnectionPoint.d.ts +1 -1
  127. package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
  128. package/Meshes/Node/nodeGeometryBuildState.d.ts +1 -1
  129. package/Meshes/Node/nodeGeometryBuildState.js +3 -3
  130. package/Meshes/Node/nodeGeometryBuildState.js.map +1 -1
  131. package/Meshes/greasedLineMesh.d.ts +4 -2
  132. package/Meshes/greasedLineMesh.js +26 -2
  133. package/Meshes/greasedLineMesh.js.map +1 -1
  134. package/Meshes/mesh.vertexData.js.map +1 -1
  135. package/Misc/greasedLineTools.d.ts +1 -1
  136. package/Misc/greasedLineTools.js +1 -1
  137. package/Misc/greasedLineTools.js.map +1 -1
  138. package/Shaders/greasedLine.fragment.d.ts +5 -0
  139. package/Shaders/greasedLine.fragment.js +16 -0
  140. package/Shaders/greasedLine.fragment.js.map +1 -0
  141. package/Shaders/greasedLine.vertex.d.ts +5 -0
  142. package/Shaders/greasedLine.vertex.js +19 -0
  143. package/Shaders/greasedLine.vertex.js.map +1 -0
  144. package/package.json +1 -1
  145. /package/Meshes/Node/Blocks/{IntFloatConverterBlock.d.ts → intFloatConverterBlock.d.ts} +0 -0
@@ -8,6 +8,94 @@ import type { Material } from "./material";
8
8
  import { MaterialDefines } from "./materialDefines";
9
9
  import type { AbstractMesh } from "../Meshes/abstractMesh";
10
10
  import type { BaseTexture } from "./Textures/baseTexture";
11
+ /**
12
+ * Interface which defines the available methods for a GreasedLineMaterial
13
+ */
14
+ export interface IGreasedLineMaterial {
15
+ /**
16
+ * Normalized value of how much of the line will be visible
17
+ * 0 - 0% of the line will be visible
18
+ * 1 - 100% of the line will be visible
19
+ */
20
+ visibility: number;
21
+ /**
22
+ * Line base width. At each point the line width is calculated by widths[pointIndex] * width
23
+ */
24
+ width: number;
25
+ /**
26
+ * Turns on/off dash mode
27
+ */
28
+ useDash: boolean;
29
+ /**
30
+ * @see GreasedLinePluginMaterial.setDashCount
31
+ * Number of dashes in the line.
32
+ * Defaults to 1.
33
+ */
34
+ dashCount: number;
35
+ /**
36
+ * Dash offset
37
+ */
38
+ dashOffset: number;
39
+ /**
40
+ * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.
41
+ */
42
+ dashRatio: number;
43
+ /**
44
+ * Whether to use the colors option to colorize the line
45
+ */
46
+ useColors: boolean;
47
+ /**
48
+ * The mixing mode of the color paramater. Default value is GreasedLineMeshColorMode.SET.
49
+ * MATERIAL_TYPE_SIMPLE mixes the color and colors of the greased line material.
50
+ * MATERIAL_TYPE_STANDARD and MATERIAL_TYPE_PBR mixes the color from the base material with the color and/or colors of the greased line material.
51
+ * @see GreasedLineMeshColorMode
52
+ */
53
+ colorMode: GreasedLineMeshColorMode;
54
+ /**
55
+ * Colors of the line segments.
56
+ * Defaults to empty.
57
+ */
58
+ colors: Nullable<Color3[]>;
59
+ /**
60
+ * If false then width units = scene units. If true then line will width be reduced.
61
+ * Defaults to false.
62
+ */
63
+ sizeAttenuation: boolean;
64
+ /**
65
+ * Color of the line. Applies to all line segments.
66
+ * Defaults to White.
67
+ */
68
+ color: Nullable<Color3>;
69
+ /**
70
+ * The method used to distribute the colors along the line.
71
+ * You can use segment distribution when each segment will use on color from the color table.
72
+ * Or you can use line distribution when the colors are distributed evenly along the line ignoring the segments.
73
+ */
74
+ colorsDistributionType: GreasedLineMeshColorDistributionType;
75
+ /**
76
+ * Defaults to engine.getRenderWidth() and engine.getRenderHeight()
77
+ * Rendering resolution
78
+ */
79
+ resolution: Vector2;
80
+ /**
81
+ * Allows to change the color without marking the material dirty.
82
+ * MATERIAL_TYPE_STANDARD and MATERIAL_TYPE_PBR material's shaders will get recompiled if there was no color set and you set a color or when there was a color set and you set it to null.
83
+ * @param value the color
84
+ * @param doNotMarkDirty the flag
85
+ */
86
+ setColor(value: Nullable<Color3>, doNotMarkDirty?: boolean): void;
87
+ /**
88
+ *
89
+ * @param colors colors array
90
+ * @param lazy if true the colors texture will not be updated
91
+ * @param forceNewTexture forces to create a new colors texture
92
+ */
93
+ setColors(colors: Nullable<Color3[]>, lazy: boolean, forceNewTexture?: boolean): void;
94
+ /**
95
+ * Creates and sets the colors texture from the colors array which was created in lazy mode
96
+ */
97
+ updateLazy(): void;
98
+ }
11
99
  /**
12
100
  * Material types for GreasedLine
13
101
  * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#materialtype}
@@ -20,7 +108,11 @@ export declare enum GreasedLineMeshMaterialType {
20
108
  /**
21
109
  * PBR Material
22
110
  */
23
- MATERIAL_TYPE_PBR = 1
111
+ MATERIAL_TYPE_PBR = 1,
112
+ /**
113
+ * Simple and fast shader material not supporting lightning nor textures
114
+ */
115
+ MATERIAL_TYPE_SIMPLE = 2
24
116
  }
25
117
  /**
26
118
  * Color blending mode of the @see GreasedLineMaterial and the base material
@@ -166,7 +258,7 @@ export declare class MaterialGreasedLineDefines extends MaterialDefines {
166
258
  /**
167
259
  * GreasedLinePluginMaterial for GreasedLineMesh
168
260
  */
169
- export declare class GreasedLinePluginMaterial extends MaterialPluginBase {
261
+ export declare class GreasedLinePluginMaterial extends MaterialPluginBase implements IGreasedLineMaterial {
170
262
  private _scene;
171
263
  /**
172
264
  * Plugin name
@@ -319,10 +411,10 @@ export declare class GreasedLinePluginMaterial extends MaterialPluginBase {
319
411
  * Creates or updates the colors texture
320
412
  * @param colors color table RGBA
321
413
  * @param lazy if lazy, the colors are not updated
322
- * @param forceUpdate force creation of a new texture
414
+ * @param forceNewTexture force creation of a new texture
323
415
  * @returns
324
416
  */
325
- setColors(colors: Nullable<Color3[]>, lazy?: boolean, forceUpdate?: boolean): void;
417
+ setColors(colors: Nullable<Color3[]>, lazy?: boolean, forceNewTexture?: boolean): void;
326
418
  /**
327
419
  * Updates the material. Use when material created in lazy mode.
328
420
  */
@@ -19,6 +19,10 @@ export var GreasedLineMeshMaterialType;
19
19
  * PBR Material
20
20
  */
21
21
  GreasedLineMeshMaterialType[GreasedLineMeshMaterialType["MATERIAL_TYPE_PBR"] = 1] = "MATERIAL_TYPE_PBR";
22
+ /**
23
+ * Simple and fast shader material not supporting lightning nor textures
24
+ */
25
+ GreasedLineMeshMaterialType[GreasedLineMeshMaterialType["MATERIAL_TYPE_SIMPLE"] = 2] = "MATERIAL_TYPE_SIMPLE";
22
26
  })(GreasedLineMeshMaterialType || (GreasedLineMeshMaterialType = {}));
23
27
  /**
24
28
  * Color blending mode of the @see GreasedLineMaterial and the base material
@@ -122,6 +126,11 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
122
126
  this._color = (_r = this._color) !== null && _r !== void 0 ? _r : GreasedLinePluginMaterial.DEFAULT_COLOR;
123
127
  GreasedLinePluginMaterial._PrepareEmptyColorsTexture(_scene);
124
128
  }
129
+ this._engine.onDisposeObservable.add(() => {
130
+ var _a;
131
+ (_a = GreasedLinePluginMaterial._EmptyColorsTexture) === null || _a === void 0 ? void 0 : _a.dispose();
132
+ GreasedLinePluginMaterial._EmptyColorsTexture = null;
133
+ });
125
134
  this._enable(true); // always enabled
126
135
  }
127
136
  /**
@@ -437,10 +446,10 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
437
446
  * Creates or updates the colors texture
438
447
  * @param colors color table RGBA
439
448
  * @param lazy if lazy, the colors are not updated
440
- * @param forceUpdate force creation of a new texture
449
+ * @param forceNewTexture force creation of a new texture
441
450
  * @returns
442
451
  */
443
- setColors(colors, lazy = false, forceUpdate = false) {
452
+ setColors(colors, lazy = false, forceNewTexture = false) {
444
453
  var _a, _b, _c, _d;
445
454
  const origColorsCount = (_b = (_a = this._colors) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
446
455
  this._colors = colors;
@@ -448,10 +457,10 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
448
457
  (_c = this._colorsTexture) === null || _c === void 0 ? void 0 : _c.dispose();
449
458
  return;
450
459
  }
451
- if (lazy && !forceUpdate) {
460
+ if (lazy && !forceNewTexture) {
452
461
  return;
453
462
  }
454
- if (this._colorsTexture && origColorsCount === colors.length && !forceUpdate) {
463
+ if (this._colorsTexture && origColorsCount === colors.length && !forceNewTexture) {
455
464
  const colorArray = GreasedLinePluginMaterial._Color3toRGBAUint8(colors);
456
465
  this._colorsTexture.update(colorArray);
457
466
  }
@@ -616,8 +625,8 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
616
625
  static _PrepareEmptyColorsTexture(scene) {
617
626
  if (!this._EmptyColorsTexture) {
618
627
  const colorsArray = new Uint8Array(4);
619
- this._EmptyColorsTexture = new RawTexture(colorsArray, 1, 1, Engine.TEXTUREFORMAT_RGBA, scene, false, false, RawTexture.NEAREST_NEAREST);
620
- this._EmptyColorsTexture.name = "grlEmptyColorsTexture";
628
+ GreasedLinePluginMaterial._EmptyColorsTexture = new RawTexture(colorsArray, 1, 1, Engine.TEXTUREFORMAT_RGBA, scene, false, false, RawTexture.NEAREST_NEAREST);
629
+ GreasedLinePluginMaterial._EmptyColorsTexture.name = "grlEmptyColorsTexture";
621
630
  }
622
631
  }
623
632
  }
@@ -1 +1 @@
1
- {"version":3,"file":"greasedLinePluginMaterial.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/greasedLinePluginMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3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,WAAW,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,kBAAkB,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;YACzI,IAAI,CAAC,mBAAmB,CAAC,IAAI,GAAG,uBAAuB,CAAC;SAC3D;IACL,CAAC;;AA9oBD;;GAEG;AACoB,oDAA0B,GAAG,2BAA2B,CAAC;AAEhF;;GAEG;AACW,uCAAa,GAAG,MAAM,CAAC,KAAK,EAAE,CAAC;AAC7C;;GAEG;AACW,kDAAwB,GAAG,CAAC,CAAC;AAC3C;;GAEG;AACW,uCAAa,GAAG,GAAG,CAAC;AAioBtC,aAAa,CAAC,WAAW,yBAAyB,CAAC,0BAA0B,EAAE,EAAE,yBAAyB,CAAC,CAAC","sourcesContent":["import { Engine } from \"../Engines/engine\";\r\nimport { RawTexture } from \"./Textures/rawTexture\";\r\nimport { MaterialPluginBase } from \"./materialPluginBase\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { UniformBuffer } from \"./uniformBuffer\";\r\nimport { Vector2, TmpVectors } from \"../Maths/math.vector\";\r\nimport { Color3 } from \"../Maths/math.color\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Material } from \"./material\";\r\nimport { MaterialDefines } from \"./materialDefines\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { BaseTexture } from \"./Textures/baseTexture\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\n\r\n/**\r\n * Material types for GreasedLine\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#materialtype}\r\n */\r\nexport enum GreasedLineMeshMaterialType {\r\n /**\r\n * StandardMaterial\r\n */\r\n MATERIAL_TYPE_STANDARD = 0,\r\n /**\r\n * PBR Material\r\n */\r\n MATERIAL_TYPE_PBR = 1,\r\n}\r\n\r\n/**\r\n * Color blending mode of the @see GreasedLineMaterial and the base material\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colormode}\r\n */\r\nexport enum GreasedLineMeshColorMode {\r\n /**\r\n * Color blending mode SET\r\n */\r\n COLOR_MODE_SET = 0,\r\n /**\r\n * Color blending mode ADD\r\n */\r\n COLOR_MODE_ADD = 1,\r\n /**\r\n * Color blending mode ADD\r\n */\r\n COLOR_MODE_MULTIPLY = 2,\r\n}\r\n\r\n/**\r\n * Color distribution type of the @see colors.\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colordistributiontype}\r\n *\r\n */\r\nexport enum GreasedLineMeshColorDistributionType {\r\n /**\r\n * Colors distributed between segments of the line\r\n */\r\n COLOR_DISTRIBUTION_TYPE_SEGMENT = 0,\r\n /**\r\n * Colors distributed along the line ingoring the segments\r\n */\r\n COLOR_DISTRIBUTION_TYPE_LINE = 1,\r\n}\r\n\r\n/**\r\n * Options for GreasedLineMaterial\r\n */\r\nexport interface GreasedLineMaterialOptions {\r\n /**\r\n * Line width. If sizeAttenuation os false scene units will be used for width.\r\n * Defaults to 0.1 if @see sizeAttenuation is false, or to 1 if it's true.\r\n */\r\n width?: number;\r\n /**\r\n * If false then width units = scene units. If true then line will width be reduced.\r\n * Defaults to false.\r\n */\r\n sizeAttenuation?: boolean;\r\n /**\r\n * Type of the material to use to render the line.\r\n * Defaults to StandardMaterial.\r\n */\r\n materialType?: GreasedLineMeshMaterialType;\r\n /**\r\n * Color of the line. Applies to all line segments.\r\n * Defaults to White.\r\n */\r\n color?: Color3;\r\n /**\r\n * Color mode of the line. Applies to all line segments.\r\n * The pixel color from the material shader will be modified with the value of @see color using the colorMode.\r\n * Defaults to @see GreasedLineMeshColorMode.SET\r\n */\r\n colorMode?: GreasedLineMeshColorMode;\r\n /**\r\n * Colors of the line segments.\r\n * Defaults to empty.\r\n */\r\n colors?: Color3[];\r\n /**\r\n * If true, @see colors are used, otherwise they're ignored.\r\n * Defaults to false.\r\n */\r\n useColors?: boolean;\r\n /**\r\n * Sampling type of the colors texture\r\n * Defaults to NEAREST_NEAREST.\r\n */\r\n colorsSampling?: number;\r\n /**\r\n * The method used to distribute the colors along the line.\r\n * You can use segment distribution when each segment will use on color from the color table.\r\n * Or you can use line distribution when the colors are distributed evenly along the line ignoring the segments.\r\n */\r\n colorDistributionType?: GreasedLineMeshColorDistributionType;\r\n /**\r\n * If true, dashing is used.\r\n * Defaults to false.\r\n */\r\n useDash?: boolean;\r\n /**\r\n * @see GreasedLinePluginMaterial.setDashCount\r\n * Number of dashes in the line.\r\n * Defaults to 1.\r\n */\r\n dashCount?: number;\r\n /**\r\n * Offset of the dashes along the line. 0 to 1.\r\n * Defaults to 0.\r\n * @see GreasedLinePluginMaterial.setDashOffset\r\n */\r\n dashOffset?: number;\r\n /**\r\n * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.\r\n * Defaults to 0.5.\r\n * @see GreasedLinePluginMaterial.setDashRatio\r\n */\r\n dashRatio?: number;\r\n /**\r\n * Sets the line length visibility.\r\n * 0 - 0% of the line will be visible.\r\n * 1 - 100% of the line will be visible.\r\n * @see GreasedLinePluginMaterial.setVisibility\r\n */\r\n visibility?: number;\r\n /**\r\n * Defaults to engine.getRenderWidth() and engine.getRenderHeight()\r\n * Rendering resolution\r\n */\r\n resolution?: Vector2;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class MaterialGreasedLineDefines extends MaterialDefines {\r\n /**\r\n * The material has a color option specified\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n GREASED_LINE_HAS_COLOR = false;\r\n /**\r\n * The material's size attenuation optiom\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n GREASED_LINE_SIZE_ATTENUATION = false;\r\n /**\r\n * The type of color distribution is set to line this value equals to true.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = false;\r\n /**\r\n * True if scene is in right handed coordinate system.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM = false;\r\n}\r\n\r\n/**\r\n * GreasedLinePluginMaterial for GreasedLineMesh\r\n */\r\nexport class GreasedLinePluginMaterial extends MaterialPluginBase {\r\n /**\r\n * Plugin name\r\n */\r\n public static readonly GREASED_LINE_MATERIAL_NAME = \"GreasedLinePluginMaterial\";\r\n\r\n /**\r\n * Default line color for newly created lines\r\n */\r\n public static DEFAULT_COLOR = Color3.White();\r\n /**\r\n * Default line width when sizeAttenuation is true\r\n */\r\n public static DEFAULT_WIDTH_ATTENUATED = 1;\r\n /**\r\n * Defaule line width\r\n */\r\n public static DEFAULT_WIDTH = 0.1;\r\n\r\n private static _EmptyColorsTexture: BaseTexture;\r\n\r\n /**\r\n * Whether to use the colors option to colorize the line\r\n */\r\n public useColors: boolean;\r\n\r\n /**\r\n * Normalized value of how much of the line will be visible\r\n * 0 - 0% of the line will be visible\r\n * 1 - 100% of the line will be visible\r\n */\r\n public visibility: number;\r\n\r\n /**\r\n * Dash offset\r\n */\r\n public dashOffset: number;\r\n\r\n /**\r\n * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.\r\n */\r\n public dashRatio: number;\r\n\r\n /**\r\n * Line base width. At each point the line width is calculated by widths[pointIndex] * width\r\n */\r\n public width: number;\r\n\r\n /**\r\n * The type of sampling of the colors texture. The values are the same when using with textures.\r\n */\r\n public colorsSampling: number;\r\n\r\n /**\r\n * Turns on/off dash mode\r\n */\r\n public useDash: boolean;\r\n\r\n /**\r\n * The mixing mode of the color paramater. Default value is GreasedLineMeshColorMode.SET\r\n * @see GreasedLineMeshColorMode\r\n */\r\n public colorMode: GreasedLineMeshColorMode;\r\n\r\n private _dashCount: number;\r\n private _dashArray: number;\r\n private _color: Nullable<Color3>;\r\n private _colors: Nullable<Color3[]>;\r\n private _colorsDistributionType: GreasedLineMeshColorDistributionType;\r\n private _resolution: Vector2;\r\n private _aspect: number;\r\n private _sizeAttenuation: boolean;\r\n\r\n private _colorsTexture?: RawTexture;\r\n\r\n private _engine: Engine;\r\n\r\n constructor(material: Material, private _scene: Scene, options?: GreasedLineMaterialOptions) {\r\n options = options || {\r\n color: GreasedLinePluginMaterial.DEFAULT_COLOR,\r\n };\r\n\r\n const defines = new MaterialGreasedLineDefines();\r\n defines.GREASED_LINE_HAS_COLOR = !!options.color;\r\n defines.GREASED_LINE_SIZE_ATTENUATION = options.sizeAttenuation ?? false;\r\n defines.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = options.colorDistributionType === GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE;\r\n defines.GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM = _scene.useRightHandedSystem;\r\n super(material, GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME, 200, defines);\r\n\r\n this._scene = this._scene ?? material.getScene();\r\n this._engine = this._scene.getEngine();\r\n\r\n this.visibility = options.visibility ?? 1;\r\n this.useDash = options.useDash ?? false;\r\n this.dashRatio = options.dashRatio ?? 0.5;\r\n this.dashOffset = options.dashOffset ?? 0;\r\n this.width = options.width ? options.width : options.sizeAttenuation ? GreasedLinePluginMaterial.DEFAULT_WIDTH_ATTENUATED : GreasedLinePluginMaterial.DEFAULT_WIDTH;\r\n this._sizeAttenuation = options.sizeAttenuation ?? false;\r\n this.colorMode = options.colorMode ?? GreasedLineMeshColorMode.COLOR_MODE_SET;\r\n this._color = options.color ?? null;\r\n this.useColors = options.useColors ?? false;\r\n this._colorsDistributionType = options.colorDistributionType ?? GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT;\r\n this.colorsSampling = options.colorsSampling ?? RawTexture.NEAREST_NEAREST;\r\n this._colors = options.colors ?? null;\r\n\r\n this.dashCount = options.dashCount ?? 1; // calculate the _dashArray value, call the setter\r\n this.resolution = options.resolution ?? new Vector2(this._engine.getRenderWidth(), this._engine.getRenderHeight()); // calculate aspect call the setter\r\n\r\n if (this._colors) {\r\n this._createColorsTexture(`${material.name}-colors-texture`, this._colors);\r\n } else {\r\n this._color = this._color ?? GreasedLinePluginMaterial.DEFAULT_COLOR;\r\n GreasedLinePluginMaterial._PrepareEmptyColorsTexture(_scene);\r\n }\r\n\r\n this._enable(true); // always enabled\r\n }\r\n\r\n /**\r\n * Get the shader attributes\r\n * @param attributes array which will be filled with the attributes\r\n */\r\n getAttributes(attributes: string[]) {\r\n attributes.push(\"grl_offsets\");\r\n attributes.push(\"grl_previousAndSide\");\r\n attributes.push(\"grl_nextAndCounters\");\r\n attributes.push(\"grl_widths\");\r\n attributes.push(\"grl_colorPointers\");\r\n }\r\n\r\n /**\r\n * Get the shader samplers\r\n * @param samplers\r\n */\r\n getSamplers(samplers: string[]) {\r\n samplers.push(\"grl_colors\");\r\n }\r\n\r\n /**\r\n * Get the shader textures\r\n * @param activeTextures\r\n */\r\n public getActiveTextures(activeTextures: BaseTexture[]): void {\r\n if (this._colorsTexture) {\r\n activeTextures.push(this._colorsTexture);\r\n }\r\n }\r\n\r\n /**\r\n * Get the shader uniforms\r\n * @returns uniforms\r\n */\r\n getUniforms() {\r\n const ubo = [\r\n { name: \"grl_projection\", size: 16, type: \"mat4\" },\r\n { name: \"grl_singleColor\", size: 3, type: \"vec3\" },\r\n { name: \"grl_aspect_resolution_lineWidth\", size: 4, type: \"vec4\" },\r\n { name: \"grl_dashOptions\", size: 4, type: \"vec4\" },\r\n { name: \"grl_colorMode_visibility_colorsWidth_useColors\", size: 4, type: \"vec4\" },\r\n ];\r\n\r\n return {\r\n ubo,\r\n vertex: `\r\n uniform vec4 grl_aspect_resolution_lineWidth;\r\n uniform mat4 grl_projection;\r\n `,\r\n fragment: `\r\n uniform vec4 grl_dashOptions;\r\n uniform vec4 grl_colorMode_visibility_colorsWidth_useColors;\r\n uniform vec3 grl_singleColor;\r\n `,\r\n };\r\n }\r\n\r\n // only getter, it doesn't make sense to use this plugin on a mesh other than GreasedLineMesh\r\n // and it doesn't make sense to disable it on the mesh\r\n get isEnabled() {\r\n return true;\r\n }\r\n\r\n /**\r\n * Bind the uniform buffer\r\n * @param uniformBuffer\r\n */\r\n bindForSubMesh(uniformBuffer: UniformBuffer) {\r\n const activeCamera = this._scene.activeCamera;\r\n\r\n if (activeCamera) {\r\n const projection = activeCamera.getProjectionMatrix();\r\n uniformBuffer.updateMatrix(\"grl_projection\", projection);\r\n } else {\r\n throw Error(\"GreasedLinePluginMaterial requires an active camera.\");\r\n }\r\n\r\n const resolutionLineWidth = TmpVectors.Vector4[0];\r\n resolutionLineWidth.x = this._aspect;\r\n resolutionLineWidth.y = this._resolution.x;\r\n resolutionLineWidth.z = this._resolution.y;\r\n resolutionLineWidth.w = this.width;\r\n uniformBuffer.updateVector4(\"grl_aspect_resolution_lineWidth\", resolutionLineWidth);\r\n\r\n const dashOptions = TmpVectors.Vector4[0];\r\n dashOptions.x = GreasedLinePluginMaterial._BooleanToNumber(this.useDash);\r\n dashOptions.y = this._dashArray;\r\n dashOptions.z = this.dashOffset;\r\n dashOptions.w = this.dashRatio;\r\n uniformBuffer.updateVector4(\"grl_dashOptions\", dashOptions);\r\n\r\n const colorModeVisibilityColorsWidthUseColors = TmpVectors.Vector4[1];\r\n colorModeVisibilityColorsWidthUseColors.x = this.colorMode;\r\n colorModeVisibilityColorsWidthUseColors.y = this.visibility;\r\n colorModeVisibilityColorsWidthUseColors.z = this._colorsTexture ? this._colorsTexture.getSize().width : 0;\r\n colorModeVisibilityColorsWidthUseColors.w = GreasedLinePluginMaterial._BooleanToNumber(this.useColors);\r\n uniformBuffer.updateVector4(\"grl_colorMode_visibility_colorsWidth_useColors\", colorModeVisibilityColorsWidthUseColors);\r\n\r\n if (this._color) {\r\n uniformBuffer.updateColor3(\"grl_singleColor\", this._color);\r\n }\r\n\r\n uniformBuffer.setTexture(\"grl_colors\", this._colorsTexture ?? GreasedLinePluginMaterial._EmptyColorsTexture);\r\n }\r\n\r\n /**\r\n * Prepare the defines\r\n * @param defines\r\n * @param _scene\r\n * @param _mesh\r\n */\r\n prepareDefines(defines: MaterialGreasedLineDefines, _scene: Scene, _mesh: AbstractMesh) {\r\n defines.GREASED_LINE_HAS_COLOR = !!this._color;\r\n defines.GREASED_LINE_SIZE_ATTENUATION = this._sizeAttenuation ?? false;\r\n defines.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = this._colorsDistributionType === GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE;\r\n defines.GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM = _scene.useRightHandedSystem;\r\n }\r\n\r\n /**\r\n * Get the class name\r\n * @returns class name\r\n */\r\n getClassName() {\r\n return GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME;\r\n }\r\n\r\n /**\r\n * Get shader code\r\n * @param shaderType vertex/fragment\r\n * @returns shader code\r\n */\r\n getCustomCode(shaderType: string): Nullable<{ [pointName: string]: string }> {\r\n if (shaderType === \"vertex\") {\r\n return {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_VERTEX_DEFINITIONS: `\r\n attribute vec4 grl_previousAndSide;\r\n attribute vec4 grl_nextAndCounters;\r\n attribute float grl_widths;\r\n attribute vec3 grl_offsets;\r\n attribute float grl_colorPointers;\r\n\r\n varying float grlCounters;\r\n varying float grlColorPointer;\r\n\r\n vec2 grlFix( vec4 i, float aspect ) {\r\n vec2 res = i.xy / i.w;\r\n res.x *= aspect;\r\n return res;\r\n }\r\n `,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_VERTEX_UPDATE_POSITION: `\r\n vec3 grlPositionOffset = grl_offsets;\r\n positionUpdated += grlPositionOffset;\r\n `,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_VERTEX_MAIN_END: `\r\n\r\n float grlAspect = grl_aspect_resolution_lineWidth.x;\r\n float grlBaseWidth = grl_aspect_resolution_lineWidth.w;\r\n\r\n grlColorPointer = grl_colorPointers;\r\n\r\n vec3 grlPrevious = grl_previousAndSide.xyz;\r\n float grlSide = grl_previousAndSide.w;\r\n\r\n vec3 grlNext = grl_nextAndCounters.xyz;\r\n grlCounters = grl_nextAndCounters.w;\r\n\r\n\r\n mat4 grlMatrix = viewProjection * world;\r\n vec4 grlFinalPosition = grlMatrix * vec4( positionUpdated , 1.0 );\r\n vec4 grlPrevPos = grlMatrix * vec4( grlPrevious + grlPositionOffset, 1.0 );\r\n vec4 grlNextPos = grlMatrix * vec4( grlNext + grlPositionOffset, 1.0 );\r\n\r\n vec2 grlCurrentP = grlFix( grlFinalPosition, grlAspect );\r\n vec2 grlPrevP = grlFix( grlPrevPos, grlAspect );\r\n vec2 grlNextP = grlFix( grlNextPos, grlAspect );\r\n\r\n float grlWidth = grlBaseWidth * grl_widths;\r\n\r\n vec2 grlDir;\r\n if( grlNextP == grlCurrentP ) grlDir = normalize( grlCurrentP - grlPrevP );\r\n else if( grlPrevP == grlCurrentP ) grlDir = normalize( grlNextP - grlCurrentP );\r\n else {\r\n vec2 grlDir1 = normalize( grlCurrentP - grlPrevP );\r\n vec2 grlDir2 = normalize( grlNextP - grlCurrentP );\r\n grlDir = normalize( grlDir1 + grlDir2 );\r\n }\r\n vec4 grlNormal = vec4( -grlDir.y, grlDir.x, 0., 1. );\r\n #ifdef GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM\r\n grlNormal.xy *= -.5 * grlWidth;\r\n #else\r\n grlNormal.xy *= .5 * grlWidth;\r\n #endif\r\n grlNormal *= grl_projection;\r\n #ifdef GREASED_LINE_SIZE_ATTENUATION\r\n grlNormal.xy *= grlFinalPosition.w;\r\n grlNormal.xy /= ( vec4( grl_aspect_resolution_lineWidth.yz, 0., 1. ) * grl_projection ).xy;\r\n #endif\r\n grlFinalPosition.xy += grlNormal.xy * grlSide;\r\n gl_Position = grlFinalPosition;\r\n\r\n vPositionW = vec3(grlFinalPosition);\r\n\r\n `,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"!gl_Position\\\\=viewProjection\\\\*worldPos;\": \"//\", // remove\r\n };\r\n }\r\n\r\n if (shaderType === \"fragment\") {\r\n return {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_FRAGMENT_DEFINITIONS: `\r\n varying float grlCounters;\r\n varying float grlColorPointer;\r\n uniform sampler2D grl_colors;\r\n `,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_FRAGMENT_MAIN_END: `\r\n float grlColorMode = grl_colorMode_visibility_colorsWidth_useColors.x;\r\n float grlVisibility = grl_colorMode_visibility_colorsWidth_useColors.y;\r\n float grlColorsWidth = grl_colorMode_visibility_colorsWidth_useColors.z;\r\n float grlUseColors = grl_colorMode_visibility_colorsWidth_useColors.w;\r\n\r\n float grlUseDash = grl_dashOptions.x;\r\n float grlDashArray = grl_dashOptions.y;\r\n float grlDashOffset = grl_dashOptions.z;\r\n float grlDashRatio = grl_dashOptions.w;\r\n\r\n gl_FragColor.a *= step(grlCounters, grlVisibility);\r\n if( gl_FragColor.a == 0. ) discard;\r\n\r\n if(grlUseDash == 1.){\r\n gl_FragColor.a *= ceil(mod(grlCounters + grlDashOffset, grlDashArray) - (grlDashArray * grlDashRatio));\r\n if (gl_FragColor.a == 0.) discard;\r\n }\r\n\r\n #ifdef GREASED_LINE_HAS_COLOR\r\n if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_SET}.) {\r\n gl_FragColor.rgb = grl_singleColor;\r\n } else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_ADD}.) {\r\n gl_FragColor.rgb += grl_singleColor;\r\n } else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY}.) {\r\n gl_FragColor.rgb *= grl_singleColor;\r\n }\r\n #else\r\n if (grlUseColors == 1.) {\r\n #ifdef GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE\r\n vec4 grlColor = texture2D(grl_colors, vec2(grlCounters, 0.), 0.);\r\n #else\r\n vec4 grlColor = texture2D(grl_colors, vec2(grlColorPointer/grlColorsWidth, 0.), 0.);\r\n #endif\r\n if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_SET}.) {\r\n gl_FragColor = grlColor;\r\n } else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_ADD}.) {\r\n gl_FragColor += grlColor;\r\n } else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY}.) {\r\n gl_FragColor *= grlColor;\r\n }\r\n }\r\n #endif\r\n `,\r\n };\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Converts boolean to number.\r\n * @param bool\r\n * @returns 1 if true, 0 if false.\r\n */\r\n private static _BooleanToNumber(bool?: boolean) {\r\n return bool ? 1 : 0;\r\n }\r\n\r\n /**\r\n * Converts an array of Color3 to Uint8Array\r\n * @param colors Arrray of Color3\r\n * @returns Uin8Array of colors [r, g, b, a, r, g, b, a, ...]\r\n */\r\n private static _Color3toRGBAUint8(colors: Color3[]) {\r\n const colorTable: Uint8Array = new Uint8Array(colors.length * 4);\r\n for (let i = 0, j = 0; i < colors.length; i++) {\r\n colorTable[j++] = colors[i].r * 255;\r\n colorTable[j++] = colors[i].g * 255;\r\n colorTable[j++] = colors[i].b * 255;\r\n colorTable[j++] = 255;\r\n }\r\n\r\n return colorTable;\r\n }\r\n\r\n /**\r\n * Creates a RawTexture from an RGBA color array and sets it on the plugin material instance.\r\n * @param name name of the texture\r\n * @param colors Uint8Array of colors\r\n */\r\n private _createColorsTexture(name: string, colors: Color3[]) {\r\n const colorsArray = GreasedLinePluginMaterial._Color3toRGBAUint8(colors);\r\n this._colorsTexture = new RawTexture(colorsArray, colors.length, 1, Engine.TEXTUREFORMAT_RGBA, this._scene, false, true, this.colorsSampling);\r\n this._colorsTexture.name = name;\r\n }\r\n\r\n /**\r\n * Disposes the plugin material.\r\n */\r\n public dispose(): void {\r\n this._colorsTexture?.dispose();\r\n super.dispose();\r\n }\r\n\r\n /**\r\n * Returns the colors used to colorize the line\r\n */\r\n get colors() {\r\n return this._colors;\r\n }\r\n\r\n /**\r\n * Sets the colors used to colorize the line\r\n */\r\n set colors(value: Nullable<Color3[]>) {\r\n this.setColors(value);\r\n }\r\n\r\n /**\r\n * Creates or updates the colors texture\r\n * @param colors color table RGBA\r\n * @param lazy if lazy, the colors are not updated\r\n * @param forceUpdate force creation of a new texture\r\n * @returns\r\n */\r\n public setColors(colors: Nullable<Color3[]>, lazy = false, forceUpdate = false): void {\r\n const origColorsCount = this._colors?.length ?? 0;\r\n\r\n this._colors = colors;\r\n\r\n if (colors === null || colors.length === 0) {\r\n this._colorsTexture?.dispose();\r\n return;\r\n }\r\n\r\n if (lazy && !forceUpdate) {\r\n return;\r\n }\r\n\r\n if (this._colorsTexture && origColorsCount === colors.length && !forceUpdate) {\r\n const colorArray = GreasedLinePluginMaterial._Color3toRGBAUint8(colors);\r\n this._colorsTexture.update(colorArray);\r\n } else {\r\n this._colorsTexture?.dispose();\r\n this._createColorsTexture(`${this._material.name}-colors-texture`, colors);\r\n }\r\n }\r\n\r\n /**\r\n * Updates the material. Use when material created in lazy mode.\r\n */\r\n public updateLazy() {\r\n if (this._colors) {\r\n this.setColors(this._colors, false, true);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the number of dashes in the line\r\n */\r\n get dashCount() {\r\n return this._dashCount;\r\n }\r\n /**\r\n * Sets the number of dashes in the line\r\n * @param value dash\r\n */\r\n set dashCount(value: number) {\r\n this._dashCount = value;\r\n this._dashArray = 1 / value;\r\n }\r\n\r\n /**\r\n * False means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines\r\n */\r\n get sizeAttenuation() {\r\n return this._sizeAttenuation;\r\n }\r\n\r\n /**\r\n * Turn on/off attenuation of the width option and widths array.\r\n * @param value false means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines\r\n */\r\n set sizeAttenuation(value: boolean) {\r\n this._sizeAttenuation = value;\r\n this.markAllDefinesAsDirty();\r\n }\r\n\r\n /**\r\n * Gets the color of the line\r\n */\r\n get color() {\r\n return this.color;\r\n }\r\n\r\n /**\r\n * Sets the color of the line\r\n * @param value Color3 or null to clear the color. You need to clear the color if you use colors and useColors = true\r\n */\r\n set color(value: Nullable<Color3>) {\r\n this.setColor(value);\r\n }\r\n\r\n /**\r\n * Sets the color of the line. If set the whole line will be mixed with this color according to the colorMode option.\r\n * @param value color\r\n */\r\n public setColor(value: Nullable<Color3>, doNotMarkDirty = false) {\r\n if ((this._color === null && value !== null) || (this._color !== null && value === null)) {\r\n this._color = value;\r\n !doNotMarkDirty && this.markAllDefinesAsDirty();\r\n } else {\r\n this._color = value;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the color distributiopn type\r\n */\r\n get colorsDistributionType() {\r\n return this._colorsDistributionType;\r\n }\r\n\r\n /**\r\n * Sets the color distribution type\r\n * @see GreasedLineMeshColorDistributionType\r\n * @param value color distribution type\r\n */\r\n set colorsDistributionType(value: GreasedLineMeshColorDistributionType) {\r\n this._colorsDistributionType = value;\r\n this.markAllDefinesAsDirty();\r\n }\r\n\r\n /**\r\n * Gets the resolution\r\n */\r\n get resolution() {\r\n return this._resolution;\r\n }\r\n\r\n /**\r\n * Sets the resolution\r\n * @param value resolution of the screen for GreasedLine\r\n */\r\n set resolution(value: Vector2) {\r\n this._aspect = value.x / value.y;\r\n this._resolution = value;\r\n }\r\n\r\n /**\r\n * Serializes this plugin material\r\n * @returns serializationObjec\r\n */\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n const greasedLineMaterialOptions: GreasedLineMaterialOptions = {\r\n colorDistributionType: this._colorsDistributionType,\r\n colorsSampling: this.colorsSampling,\r\n colorMode: this.colorMode,\r\n dashCount: this._dashCount,\r\n dashOffset: this.dashOffset,\r\n dashRatio: this.dashRatio,\r\n resolution: this._resolution,\r\n sizeAttenuation: this._sizeAttenuation,\r\n useColors: this.useColors,\r\n useDash: this.useDash,\r\n visibility: this.visibility,\r\n width: this.width,\r\n };\r\n\r\n this._colors && (greasedLineMaterialOptions.colors = this._colors);\r\n this._color && (greasedLineMaterialOptions.color = this._color);\r\n\r\n serializationObject.greasedLineMaterialOptions = greasedLineMaterialOptions;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parses a serialized objects\r\n * @param source serialized object\r\n * @param scene scene\r\n * @param rootUrl root url for textures\r\n */\r\n public parse(source: any, scene: Scene, rootUrl: string): void {\r\n super.parse(source, scene, rootUrl);\r\n const greasedLineMaterialOptions = <GreasedLineMaterialOptions>source.greasedLineMaterialOptions;\r\n\r\n this._colorsTexture?.dispose();\r\n\r\n if (greasedLineMaterialOptions.colors) {\r\n this._createColorsTexture(`${this._material.name}-colors-texture`, greasedLineMaterialOptions.colors);\r\n } else {\r\n GreasedLinePluginMaterial._PrepareEmptyColorsTexture(scene);\r\n }\r\n\r\n greasedLineMaterialOptions.color && this.setColor(greasedLineMaterialOptions.color, true);\r\n greasedLineMaterialOptions.colorDistributionType && (this.colorsDistributionType = greasedLineMaterialOptions.colorDistributionType);\r\n greasedLineMaterialOptions.colorsSampling && (this.colorsSampling = greasedLineMaterialOptions.colorsSampling);\r\n greasedLineMaterialOptions.colorMode && (this.colorMode = greasedLineMaterialOptions.colorMode);\r\n greasedLineMaterialOptions.useColors && (this.useColors = greasedLineMaterialOptions.useColors);\r\n greasedLineMaterialOptions.visibility && (this.visibility = greasedLineMaterialOptions.visibility);\r\n greasedLineMaterialOptions.useDash && (this.useDash = greasedLineMaterialOptions.useDash);\r\n greasedLineMaterialOptions.dashCount && (this.dashCount = greasedLineMaterialOptions.dashCount);\r\n greasedLineMaterialOptions.dashRatio && (this.dashRatio = greasedLineMaterialOptions.dashRatio);\r\n greasedLineMaterialOptions.dashOffset && (this.dashOffset = greasedLineMaterialOptions.dashOffset);\r\n greasedLineMaterialOptions.width && (this.width = greasedLineMaterialOptions.width);\r\n greasedLineMaterialOptions.sizeAttenuation && (this.sizeAttenuation = greasedLineMaterialOptions.sizeAttenuation);\r\n greasedLineMaterialOptions.resolution && (this.resolution = greasedLineMaterialOptions.resolution);\r\n\r\n this.markAllDefinesAsDirty();\r\n }\r\n\r\n /**\r\n * A minimum size texture for the colors sampler2D when there is no colors texture defined yet.\r\n * For fast switching using the useColors property without the need to use defines.\r\n * @param scene Scene\r\n */\r\n private static _PrepareEmptyColorsTexture(scene: Scene) {\r\n if (!this._EmptyColorsTexture) {\r\n const colorsArray = new Uint8Array(4);\r\n this._EmptyColorsTexture = new RawTexture(colorsArray, 1, 1, Engine.TEXTUREFORMAT_RGBA, scene, false, false, RawTexture.NEAREST_NEAREST);\r\n this._EmptyColorsTexture.name = \"grlEmptyColorsTexture\";\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(`BABYLON.${GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME}`, GreasedLinePluginMaterial);\r\n"]}
1
+ {"version":3,"file":"greasedLinePluginMaterial.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/greasedLinePluginMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AA0GlD;;;GAGG;AACH,MAAM,CAAN,IAAY,2BAaX;AAbD,WAAY,2BAA2B;IACnC;;OAEG;IACH,iHAA0B,CAAA;IAC1B;;OAEG;IACH,uGAAqB,CAAA;IACrB;;OAEG;IACH,6GAAwB,CAAA;AAC5B,CAAC,EAbW,2BAA2B,KAA3B,2BAA2B,QAatC;AAED;;;GAGG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AC,KAAK,EAAE,CAAC;AAC7C;;GAEG;AACW,kDAAwB,GAAG,CAAC,CAAC;AAC3C;;GAEG;AACW,uCAAa,GAAG,GAAG,CAAC;AAsoBtC,aAAa,CAAC,WAAW,yBAAyB,CAAC,0BAA0B,EAAE,EAAE,yBAAyB,CAAC,CAAC","sourcesContent":["import { Engine } from \"../Engines/engine\";\r\nimport { RawTexture } from \"./Textures/rawTexture\";\r\nimport { MaterialPluginBase } from \"./materialPluginBase\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { UniformBuffer } from \"./uniformBuffer\";\r\nimport { Vector2, TmpVectors } from \"../Maths/math.vector\";\r\nimport { Color3 } from \"../Maths/math.color\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Material } from \"./material\";\r\nimport { MaterialDefines } from \"./materialDefines\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { BaseTexture } from \"./Textures/baseTexture\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\n\r\n/**\r\n * Interface which defines the available methods for a GreasedLineMaterial\r\n */\r\nexport interface IGreasedLineMaterial {\r\n /**\r\n * Normalized value of how much of the line will be visible\r\n * 0 - 0% of the line will be visible\r\n * 1 - 100% of the line will be visible\r\n */\r\n visibility: number;\r\n\r\n /**\r\n * Line base width. At each point the line width is calculated by widths[pointIndex] * width\r\n */\r\n width: number;\r\n\r\n /**\r\n * Turns on/off dash mode\r\n */\r\n useDash: boolean;\r\n\r\n /**\r\n * @see GreasedLinePluginMaterial.setDashCount\r\n * Number of dashes in the line.\r\n * Defaults to 1.\r\n */\r\n dashCount: number;\r\n\r\n /**\r\n * Dash offset\r\n */\r\n dashOffset: number;\r\n\r\n /**\r\n * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.\r\n */\r\n dashRatio: number;\r\n\r\n /**\r\n * Whether to use the colors option to colorize the line\r\n */\r\n useColors: boolean;\r\n\r\n /**\r\n * The mixing mode of the color paramater. Default value is GreasedLineMeshColorMode.SET.\r\n * MATERIAL_TYPE_SIMPLE mixes the color and colors of the greased line material.\r\n * MATERIAL_TYPE_STANDARD and MATERIAL_TYPE_PBR mixes the color from the base material with the color and/or colors of the greased line material.\r\n * @see GreasedLineMeshColorMode\r\n */\r\n colorMode: GreasedLineMeshColorMode;\r\n\r\n /**\r\n * Colors of the line segments.\r\n * Defaults to empty.\r\n */\r\n colors: Nullable<Color3[]>;\r\n\r\n /**\r\n * If false then width units = scene units. If true then line will width be reduced.\r\n * Defaults to false.\r\n */\r\n sizeAttenuation: boolean;\r\n\r\n /**\r\n * Color of the line. Applies to all line segments.\r\n * Defaults to White.\r\n */\r\n color: Nullable<Color3>;\r\n\r\n /**\r\n * The method used to distribute the colors along the line.\r\n * You can use segment distribution when each segment will use on color from the color table.\r\n * Or you can use line distribution when the colors are distributed evenly along the line ignoring the segments.\r\n */\r\n colorsDistributionType: GreasedLineMeshColorDistributionType;\r\n\r\n /**\r\n * Defaults to engine.getRenderWidth() and engine.getRenderHeight()\r\n * Rendering resolution\r\n */\r\n resolution: Vector2;\r\n\r\n /**\r\n * Allows to change the color without marking the material dirty.\r\n * MATERIAL_TYPE_STANDARD and MATERIAL_TYPE_PBR material's shaders will get recompiled if there was no color set and you set a color or when there was a color set and you set it to null.\r\n * @param value the color\r\n * @param doNotMarkDirty the flag\r\n */\r\n setColor(value: Nullable<Color3>, doNotMarkDirty?: boolean): void;\r\n\r\n /**\r\n *\r\n * @param colors colors array\r\n * @param lazy if true the colors texture will not be updated\r\n * @param forceNewTexture forces to create a new colors texture\r\n */\r\n setColors(colors: Nullable<Color3[]>, lazy: boolean, forceNewTexture?: boolean): void;\r\n\r\n /**\r\n * Creates and sets the colors texture from the colors array which was created in lazy mode\r\n */\r\n updateLazy(): void;\r\n}\r\n\r\n/**\r\n * Material types for GreasedLine\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#materialtype}\r\n */\r\nexport enum GreasedLineMeshMaterialType {\r\n /**\r\n * StandardMaterial\r\n */\r\n MATERIAL_TYPE_STANDARD = 0,\r\n /**\r\n * PBR Material\r\n */\r\n MATERIAL_TYPE_PBR = 1,\r\n /**\r\n * Simple and fast shader material not supporting lightning nor textures\r\n */\r\n MATERIAL_TYPE_SIMPLE = 2,\r\n}\r\n\r\n/**\r\n * Color blending mode of the @see GreasedLineMaterial and the base material\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colormode}\r\n */\r\nexport enum GreasedLineMeshColorMode {\r\n /**\r\n * Color blending mode SET\r\n */\r\n COLOR_MODE_SET = 0,\r\n /**\r\n * Color blending mode ADD\r\n */\r\n COLOR_MODE_ADD = 1,\r\n /**\r\n * Color blending mode ADD\r\n */\r\n COLOR_MODE_MULTIPLY = 2,\r\n}\r\n\r\n/**\r\n * Color distribution type of the @see colors.\r\n * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colordistributiontype}\r\n *\r\n */\r\nexport enum GreasedLineMeshColorDistributionType {\r\n /**\r\n * Colors distributed between segments of the line\r\n */\r\n COLOR_DISTRIBUTION_TYPE_SEGMENT = 0,\r\n /**\r\n * Colors distributed along the line ingoring the segments\r\n */\r\n COLOR_DISTRIBUTION_TYPE_LINE = 1,\r\n}\r\n\r\n/**\r\n * Options for GreasedLineMaterial\r\n */\r\nexport interface GreasedLineMaterialOptions {\r\n /**\r\n * Line width. If sizeAttenuation os false scene units will be used for width.\r\n * Defaults to 0.1 if @see sizeAttenuation is false, or to 1 if it's true.\r\n */\r\n width?: number;\r\n /**\r\n * If false then width units = scene units. If true then line will width be reduced.\r\n * Defaults to false.\r\n */\r\n sizeAttenuation?: boolean;\r\n /**\r\n * Type of the material to use to render the line.\r\n * Defaults to StandardMaterial.\r\n */\r\n materialType?: GreasedLineMeshMaterialType;\r\n /**\r\n * Color of the line. Applies to all line segments.\r\n * Defaults to White.\r\n */\r\n color?: Color3;\r\n /**\r\n * Color mode of the line. Applies to all line segments.\r\n * The pixel color from the material shader will be modified with the value of @see color using the colorMode.\r\n * Defaults to @see GreasedLineMeshColorMode.SET\r\n */\r\n colorMode?: GreasedLineMeshColorMode;\r\n /**\r\n * Colors of the line segments.\r\n * Defaults to empty.\r\n */\r\n colors?: Color3[];\r\n /**\r\n * If true, @see colors are used, otherwise they're ignored.\r\n * Defaults to false.\r\n */\r\n useColors?: boolean;\r\n /**\r\n * Sampling type of the colors texture\r\n * Defaults to NEAREST_NEAREST.\r\n */\r\n colorsSampling?: number;\r\n /**\r\n * The method used to distribute the colors along the line.\r\n * You can use segment distribution when each segment will use on color from the color table.\r\n * Or you can use line distribution when the colors are distributed evenly along the line ignoring the segments.\r\n */\r\n colorDistributionType?: GreasedLineMeshColorDistributionType;\r\n /**\r\n * If true, dashing is used.\r\n * Defaults to false.\r\n */\r\n useDash?: boolean;\r\n /**\r\n * @see GreasedLinePluginMaterial.setDashCount\r\n * Number of dashes in the line.\r\n * Defaults to 1.\r\n */\r\n dashCount?: number;\r\n /**\r\n * Offset of the dashes along the line. 0 to 1.\r\n * Defaults to 0.\r\n * @see GreasedLinePluginMaterial.setDashOffset\r\n */\r\n dashOffset?: number;\r\n /**\r\n * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.\r\n * Defaults to 0.5.\r\n * @see GreasedLinePluginMaterial.setDashRatio\r\n */\r\n dashRatio?: number;\r\n /**\r\n * Sets the line length visibility.\r\n * 0 - 0% of the line will be visible.\r\n * 1 - 100% of the line will be visible.\r\n * @see GreasedLinePluginMaterial.setVisibility\r\n */\r\n visibility?: number;\r\n /**\r\n * Defaults to engine.getRenderWidth() and engine.getRenderHeight()\r\n * Rendering resolution\r\n */\r\n resolution?: Vector2;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class MaterialGreasedLineDefines extends MaterialDefines {\r\n /**\r\n * The material has a color option specified\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n GREASED_LINE_HAS_COLOR = false;\r\n /**\r\n * The material's size attenuation optiom\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n GREASED_LINE_SIZE_ATTENUATION = false;\r\n /**\r\n * The type of color distribution is set to line this value equals to true.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = false;\r\n /**\r\n * True if scene is in right handed coordinate system.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM = false;\r\n}\r\n\r\n/**\r\n * GreasedLinePluginMaterial for GreasedLineMesh\r\n */\r\nexport class GreasedLinePluginMaterial extends MaterialPluginBase implements IGreasedLineMaterial {\r\n /**\r\n * Plugin name\r\n */\r\n public static readonly GREASED_LINE_MATERIAL_NAME = \"GreasedLinePluginMaterial\";\r\n\r\n /**\r\n * Default line color for newly created lines\r\n */\r\n public static DEFAULT_COLOR = Color3.White();\r\n /**\r\n * Default line width when sizeAttenuation is true\r\n */\r\n public static DEFAULT_WIDTH_ATTENUATED = 1;\r\n /**\r\n * Defaule line width\r\n */\r\n public static DEFAULT_WIDTH = 0.1;\r\n\r\n private static _EmptyColorsTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Whether to use the colors option to colorize the line\r\n */\r\n public useColors: boolean;\r\n\r\n /**\r\n * Normalized value of how much of the line will be visible\r\n * 0 - 0% of the line will be visible\r\n * 1 - 100% of the line will be visible\r\n */\r\n public visibility: number;\r\n\r\n /**\r\n * Dash offset\r\n */\r\n public dashOffset: number;\r\n\r\n /**\r\n * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.\r\n */\r\n public dashRatio: number;\r\n\r\n /**\r\n * Line base width. At each point the line width is calculated by widths[pointIndex] * width\r\n */\r\n public width: number;\r\n\r\n /**\r\n * The type of sampling of the colors texture. The values are the same when using with textures.\r\n */\r\n public colorsSampling: number;\r\n\r\n /**\r\n * Turns on/off dash mode\r\n */\r\n public useDash: boolean;\r\n\r\n /**\r\n * The mixing mode of the color paramater. Default value is GreasedLineMeshColorMode.SET\r\n * @see GreasedLineMeshColorMode\r\n */\r\n public colorMode: GreasedLineMeshColorMode;\r\n\r\n private _dashCount: number;\r\n private _dashArray: number;\r\n private _color: Nullable<Color3>;\r\n private _colors: Nullable<Color3[]>;\r\n private _colorsDistributionType: GreasedLineMeshColorDistributionType;\r\n private _resolution: Vector2;\r\n private _aspect: number;\r\n private _sizeAttenuation: boolean;\r\n\r\n private _colorsTexture?: RawTexture;\r\n\r\n private _engine: Engine;\r\n\r\n constructor(material: Material, private _scene: Scene, options?: GreasedLineMaterialOptions) {\r\n options = options || {\r\n color: GreasedLinePluginMaterial.DEFAULT_COLOR,\r\n };\r\n\r\n const defines = new MaterialGreasedLineDefines();\r\n defines.GREASED_LINE_HAS_COLOR = !!options.color;\r\n defines.GREASED_LINE_SIZE_ATTENUATION = options.sizeAttenuation ?? false;\r\n defines.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = options.colorDistributionType === GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE;\r\n defines.GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM = _scene.useRightHandedSystem;\r\n super(material, GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME, 200, defines);\r\n\r\n this._scene = this._scene ?? material.getScene();\r\n this._engine = this._scene.getEngine();\r\n\r\n this.visibility = options.visibility ?? 1;\r\n this.useDash = options.useDash ?? false;\r\n this.dashRatio = options.dashRatio ?? 0.5;\r\n this.dashOffset = options.dashOffset ?? 0;\r\n this.width = options.width ? options.width : options.sizeAttenuation ? GreasedLinePluginMaterial.DEFAULT_WIDTH_ATTENUATED : GreasedLinePluginMaterial.DEFAULT_WIDTH;\r\n this._sizeAttenuation = options.sizeAttenuation ?? false;\r\n this.colorMode = options.colorMode ?? GreasedLineMeshColorMode.COLOR_MODE_SET;\r\n this._color = options.color ?? null;\r\n this.useColors = options.useColors ?? false;\r\n this._colorsDistributionType = options.colorDistributionType ?? GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT;\r\n this.colorsSampling = options.colorsSampling ?? RawTexture.NEAREST_NEAREST;\r\n this._colors = options.colors ?? null;\r\n\r\n this.dashCount = options.dashCount ?? 1; // calculate the _dashArray value, call the setter\r\n this.resolution = options.resolution ?? new Vector2(this._engine.getRenderWidth(), this._engine.getRenderHeight()); // calculate aspect call the setter\r\n\r\n if (this._colors) {\r\n this._createColorsTexture(`${material.name}-colors-texture`, this._colors);\r\n } else {\r\n this._color = this._color ?? GreasedLinePluginMaterial.DEFAULT_COLOR;\r\n GreasedLinePluginMaterial._PrepareEmptyColorsTexture(_scene);\r\n }\r\n\r\n this._engine.onDisposeObservable.add(() => {\r\n GreasedLinePluginMaterial._EmptyColorsTexture?.dispose();\r\n GreasedLinePluginMaterial._EmptyColorsTexture = null;\r\n });\r\n\r\n this._enable(true); // always enabled\r\n }\r\n\r\n /**\r\n * Get the shader attributes\r\n * @param attributes array which will be filled with the attributes\r\n */\r\n getAttributes(attributes: string[]) {\r\n attributes.push(\"grl_offsets\");\r\n attributes.push(\"grl_previousAndSide\");\r\n attributes.push(\"grl_nextAndCounters\");\r\n attributes.push(\"grl_widths\");\r\n attributes.push(\"grl_colorPointers\");\r\n }\r\n\r\n /**\r\n * Get the shader samplers\r\n * @param samplers\r\n */\r\n getSamplers(samplers: string[]) {\r\n samplers.push(\"grl_colors\");\r\n }\r\n\r\n /**\r\n * Get the shader textures\r\n * @param activeTextures\r\n */\r\n public getActiveTextures(activeTextures: BaseTexture[]): void {\r\n if (this._colorsTexture) {\r\n activeTextures.push(this._colorsTexture);\r\n }\r\n }\r\n\r\n /**\r\n * Get the shader uniforms\r\n * @returns uniforms\r\n */\r\n getUniforms() {\r\n const ubo = [\r\n { name: \"grl_projection\", size: 16, type: \"mat4\" },\r\n { name: \"grl_singleColor\", size: 3, type: \"vec3\" },\r\n { name: \"grl_aspect_resolution_lineWidth\", size: 4, type: \"vec4\" },\r\n { name: \"grl_dashOptions\", size: 4, type: \"vec4\" },\r\n { name: \"grl_colorMode_visibility_colorsWidth_useColors\", size: 4, type: \"vec4\" },\r\n ];\r\n\r\n return {\r\n ubo,\r\n vertex: `\r\n uniform vec4 grl_aspect_resolution_lineWidth;\r\n uniform mat4 grl_projection;\r\n `,\r\n fragment: `\r\n uniform vec4 grl_dashOptions;\r\n uniform vec4 grl_colorMode_visibility_colorsWidth_useColors;\r\n uniform vec3 grl_singleColor;\r\n `,\r\n };\r\n }\r\n\r\n // only getter, it doesn't make sense to use this plugin on a mesh other than GreasedLineMesh\r\n // and it doesn't make sense to disable it on the mesh\r\n get isEnabled() {\r\n return true;\r\n }\r\n\r\n /**\r\n * Bind the uniform buffer\r\n * @param uniformBuffer\r\n */\r\n bindForSubMesh(uniformBuffer: UniformBuffer) {\r\n const activeCamera = this._scene.activeCamera;\r\n\r\n if (activeCamera) {\r\n const projection = activeCamera.getProjectionMatrix();\r\n uniformBuffer.updateMatrix(\"grl_projection\", projection);\r\n } else {\r\n throw Error(\"GreasedLinePluginMaterial requires an active camera.\");\r\n }\r\n\r\n const resolutionLineWidth = TmpVectors.Vector4[0];\r\n resolutionLineWidth.x = this._aspect;\r\n resolutionLineWidth.y = this._resolution.x;\r\n resolutionLineWidth.z = this._resolution.y;\r\n resolutionLineWidth.w = this.width;\r\n uniformBuffer.updateVector4(\"grl_aspect_resolution_lineWidth\", resolutionLineWidth);\r\n\r\n const dashOptions = TmpVectors.Vector4[0];\r\n dashOptions.x = GreasedLinePluginMaterial._BooleanToNumber(this.useDash);\r\n dashOptions.y = this._dashArray;\r\n dashOptions.z = this.dashOffset;\r\n dashOptions.w = this.dashRatio;\r\n uniformBuffer.updateVector4(\"grl_dashOptions\", dashOptions);\r\n\r\n const colorModeVisibilityColorsWidthUseColors = TmpVectors.Vector4[1];\r\n colorModeVisibilityColorsWidthUseColors.x = this.colorMode;\r\n colorModeVisibilityColorsWidthUseColors.y = this.visibility;\r\n colorModeVisibilityColorsWidthUseColors.z = this._colorsTexture ? this._colorsTexture.getSize().width : 0;\r\n colorModeVisibilityColorsWidthUseColors.w = GreasedLinePluginMaterial._BooleanToNumber(this.useColors);\r\n uniformBuffer.updateVector4(\"grl_colorMode_visibility_colorsWidth_useColors\", colorModeVisibilityColorsWidthUseColors);\r\n\r\n if (this._color) {\r\n uniformBuffer.updateColor3(\"grl_singleColor\", this._color);\r\n }\r\n\r\n uniformBuffer.setTexture(\"grl_colors\", this._colorsTexture ?? GreasedLinePluginMaterial._EmptyColorsTexture);\r\n }\r\n\r\n /**\r\n * Prepare the defines\r\n * @param defines\r\n * @param _scene\r\n * @param _mesh\r\n */\r\n prepareDefines(defines: MaterialGreasedLineDefines, _scene: Scene, _mesh: AbstractMesh) {\r\n defines.GREASED_LINE_HAS_COLOR = !!this._color;\r\n defines.GREASED_LINE_SIZE_ATTENUATION = this._sizeAttenuation ?? false;\r\n defines.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = this._colorsDistributionType === GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE;\r\n defines.GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM = _scene.useRightHandedSystem;\r\n }\r\n\r\n /**\r\n * Get the class name\r\n * @returns class name\r\n */\r\n getClassName() {\r\n return GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME;\r\n }\r\n\r\n /**\r\n * Get shader code\r\n * @param shaderType vertex/fragment\r\n * @returns shader code\r\n */\r\n getCustomCode(shaderType: string): Nullable<{ [pointName: string]: string }> {\r\n if (shaderType === \"vertex\") {\r\n return {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_VERTEX_DEFINITIONS: `\r\n attribute vec4 grl_previousAndSide;\r\n attribute vec4 grl_nextAndCounters;\r\n attribute float grl_widths;\r\n attribute vec3 grl_offsets;\r\n attribute float grl_colorPointers;\r\n\r\n varying float grlCounters;\r\n varying float grlColorPointer;\r\n\r\n vec2 grlFix( vec4 i, float aspect ) {\r\n vec2 res = i.xy / i.w;\r\n res.x *= aspect;\r\n return res;\r\n }\r\n `,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_VERTEX_UPDATE_POSITION: `\r\n vec3 grlPositionOffset = grl_offsets;\r\n positionUpdated += grlPositionOffset;\r\n `,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_VERTEX_MAIN_END: `\r\n\r\n float grlAspect = grl_aspect_resolution_lineWidth.x;\r\n float grlBaseWidth = grl_aspect_resolution_lineWidth.w;\r\n\r\n grlColorPointer = grl_colorPointers;\r\n\r\n vec3 grlPrevious = grl_previousAndSide.xyz;\r\n float grlSide = grl_previousAndSide.w;\r\n\r\n vec3 grlNext = grl_nextAndCounters.xyz;\r\n grlCounters = grl_nextAndCounters.w;\r\n\r\n\r\n mat4 grlMatrix = viewProjection * world;\r\n vec4 grlFinalPosition = grlMatrix * vec4( positionUpdated , 1.0 );\r\n vec4 grlPrevPos = grlMatrix * vec4( grlPrevious + grlPositionOffset, 1.0 );\r\n vec4 grlNextPos = grlMatrix * vec4( grlNext + grlPositionOffset, 1.0 );\r\n\r\n vec2 grlCurrentP = grlFix( grlFinalPosition, grlAspect );\r\n vec2 grlPrevP = grlFix( grlPrevPos, grlAspect );\r\n vec2 grlNextP = grlFix( grlNextPos, grlAspect );\r\n\r\n float grlWidth = grlBaseWidth * grl_widths;\r\n\r\n vec2 grlDir;\r\n if( grlNextP == grlCurrentP ) grlDir = normalize( grlCurrentP - grlPrevP );\r\n else if( grlPrevP == grlCurrentP ) grlDir = normalize( grlNextP - grlCurrentP );\r\n else {\r\n vec2 grlDir1 = normalize( grlCurrentP - grlPrevP );\r\n vec2 grlDir2 = normalize( grlNextP - grlCurrentP );\r\n grlDir = normalize( grlDir1 + grlDir2 );\r\n }\r\n vec4 grlNormal = vec4( -grlDir.y, grlDir.x, 0., 1. );\r\n #ifdef GREASED_LNE_RIGHT_HANDED_COORDINATE_SYSTEM\r\n grlNormal.xy *= -.5 * grlWidth;\r\n #else\r\n grlNormal.xy *= .5 * grlWidth;\r\n #endif\r\n grlNormal *= grl_projection;\r\n #ifdef GREASED_LINE_SIZE_ATTENUATION\r\n grlNormal.xy *= grlFinalPosition.w;\r\n grlNormal.xy /= ( vec4( grl_aspect_resolution_lineWidth.yz, 0., 1. ) * grl_projection ).xy;\r\n #endif\r\n grlFinalPosition.xy += grlNormal.xy * grlSide;\r\n gl_Position = grlFinalPosition;\r\n\r\n vPositionW = vec3(grlFinalPosition);\r\n\r\n `,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n \"!gl_Position\\\\=viewProjection\\\\*worldPos;\": \"//\", // remove\r\n };\r\n }\r\n\r\n if (shaderType === \"fragment\") {\r\n return {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_FRAGMENT_DEFINITIONS: `\r\n varying float grlCounters;\r\n varying float grlColorPointer;\r\n uniform sampler2D grl_colors;\r\n `,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CUSTOM_FRAGMENT_MAIN_END: `\r\n float grlColorMode = grl_colorMode_visibility_colorsWidth_useColors.x;\r\n float grlVisibility = grl_colorMode_visibility_colorsWidth_useColors.y;\r\n float grlColorsWidth = grl_colorMode_visibility_colorsWidth_useColors.z;\r\n float grlUseColors = grl_colorMode_visibility_colorsWidth_useColors.w;\r\n\r\n float grlUseDash = grl_dashOptions.x;\r\n float grlDashArray = grl_dashOptions.y;\r\n float grlDashOffset = grl_dashOptions.z;\r\n float grlDashRatio = grl_dashOptions.w;\r\n\r\n gl_FragColor.a *= step(grlCounters, grlVisibility);\r\n if( gl_FragColor.a == 0. ) discard;\r\n\r\n if(grlUseDash == 1.){\r\n gl_FragColor.a *= ceil(mod(grlCounters + grlDashOffset, grlDashArray) - (grlDashArray * grlDashRatio));\r\n if (gl_FragColor.a == 0.) discard;\r\n }\r\n\r\n #ifdef GREASED_LINE_HAS_COLOR\r\n if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_SET}.) {\r\n gl_FragColor.rgb = grl_singleColor;\r\n } else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_ADD}.) {\r\n gl_FragColor.rgb += grl_singleColor;\r\n } else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY}.) {\r\n gl_FragColor.rgb *= grl_singleColor;\r\n }\r\n #else\r\n if (grlUseColors == 1.) {\r\n #ifdef GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE\r\n vec4 grlColor = texture2D(grl_colors, vec2(grlCounters, 0.), 0.);\r\n #else\r\n vec4 grlColor = texture2D(grl_colors, vec2(grlColorPointer/grlColorsWidth, 0.), 0.);\r\n #endif\r\n if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_SET}.) {\r\n gl_FragColor = grlColor;\r\n } else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_ADD}.) {\r\n gl_FragColor += grlColor;\r\n } else if (grlColorMode == ${GreasedLineMeshColorMode.COLOR_MODE_MULTIPLY}.) {\r\n gl_FragColor *= grlColor;\r\n }\r\n }\r\n #endif\r\n `,\r\n };\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Converts boolean to number.\r\n * @param bool\r\n * @returns 1 if true, 0 if false.\r\n */\r\n private static _BooleanToNumber(bool?: boolean) {\r\n return bool ? 1 : 0;\r\n }\r\n\r\n /**\r\n * Converts an array of Color3 to Uint8Array\r\n * @param colors Arrray of Color3\r\n * @returns Uin8Array of colors [r, g, b, a, r, g, b, a, ...]\r\n */\r\n private static _Color3toRGBAUint8(colors: Color3[]) {\r\n const colorTable: Uint8Array = new Uint8Array(colors.length * 4);\r\n for (let i = 0, j = 0; i < colors.length; i++) {\r\n colorTable[j++] = colors[i].r * 255;\r\n colorTable[j++] = colors[i].g * 255;\r\n colorTable[j++] = colors[i].b * 255;\r\n colorTable[j++] = 255;\r\n }\r\n\r\n return colorTable;\r\n }\r\n\r\n /**\r\n * Creates a RawTexture from an RGBA color array and sets it on the plugin material instance.\r\n * @param name name of the texture\r\n * @param colors Uint8Array of colors\r\n */\r\n private _createColorsTexture(name: string, colors: Color3[]) {\r\n const colorsArray = GreasedLinePluginMaterial._Color3toRGBAUint8(colors);\r\n this._colorsTexture = new RawTexture(colorsArray, colors.length, 1, Engine.TEXTUREFORMAT_RGBA, this._scene, false, true, this.colorsSampling);\r\n this._colorsTexture.name = name;\r\n }\r\n\r\n /**\r\n * Disposes the plugin material.\r\n */\r\n public dispose(): void {\r\n this._colorsTexture?.dispose();\r\n super.dispose();\r\n }\r\n\r\n /**\r\n * Returns the colors used to colorize the line\r\n */\r\n get colors() {\r\n return this._colors;\r\n }\r\n\r\n /**\r\n * Sets the colors used to colorize the line\r\n */\r\n set colors(value: Nullable<Color3[]>) {\r\n this.setColors(value);\r\n }\r\n\r\n /**\r\n * Creates or updates the colors texture\r\n * @param colors color table RGBA\r\n * @param lazy if lazy, the colors are not updated\r\n * @param forceNewTexture force creation of a new texture\r\n * @returns\r\n */\r\n public setColors(colors: Nullable<Color3[]>, lazy = false, forceNewTexture = false): void {\r\n const origColorsCount = this._colors?.length ?? 0;\r\n\r\n this._colors = colors;\r\n\r\n if (colors === null || colors.length === 0) {\r\n this._colorsTexture?.dispose();\r\n return;\r\n }\r\n\r\n if (lazy && !forceNewTexture) {\r\n return;\r\n }\r\n\r\n if (this._colorsTexture && origColorsCount === colors.length && !forceNewTexture) {\r\n const colorArray = GreasedLinePluginMaterial._Color3toRGBAUint8(colors);\r\n this._colorsTexture.update(colorArray);\r\n } else {\r\n this._colorsTexture?.dispose();\r\n this._createColorsTexture(`${this._material.name}-colors-texture`, colors);\r\n }\r\n }\r\n\r\n /**\r\n * Updates the material. Use when material created in lazy mode.\r\n */\r\n public updateLazy() {\r\n if (this._colors) {\r\n this.setColors(this._colors, false, true);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the number of dashes in the line\r\n */\r\n get dashCount() {\r\n return this._dashCount;\r\n }\r\n /**\r\n * Sets the number of dashes in the line\r\n * @param value dash\r\n */\r\n set dashCount(value: number) {\r\n this._dashCount = value;\r\n this._dashArray = 1 / value;\r\n }\r\n\r\n /**\r\n * False means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines\r\n */\r\n get sizeAttenuation() {\r\n return this._sizeAttenuation;\r\n }\r\n\r\n /**\r\n * Turn on/off attenuation of the width option and widths array.\r\n * @param value false means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines\r\n */\r\n set sizeAttenuation(value: boolean) {\r\n this._sizeAttenuation = value;\r\n this.markAllDefinesAsDirty();\r\n }\r\n\r\n /**\r\n * Gets the color of the line\r\n */\r\n get color() {\r\n return this.color;\r\n }\r\n\r\n /**\r\n * Sets the color of the line\r\n * @param value Color3 or null to clear the color. You need to clear the color if you use colors and useColors = true\r\n */\r\n set color(value: Nullable<Color3>) {\r\n this.setColor(value);\r\n }\r\n\r\n /**\r\n * Sets the color of the line. If set the whole line will be mixed with this color according to the colorMode option.\r\n * @param value color\r\n */\r\n public setColor(value: Nullable<Color3>, doNotMarkDirty = false) {\r\n if ((this._color === null && value !== null) || (this._color !== null && value === null)) {\r\n this._color = value;\r\n !doNotMarkDirty && this.markAllDefinesAsDirty();\r\n } else {\r\n this._color = value;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the color distributiopn type\r\n */\r\n get colorsDistributionType() {\r\n return this._colorsDistributionType;\r\n }\r\n\r\n /**\r\n * Sets the color distribution type\r\n * @see GreasedLineMeshColorDistributionType\r\n * @param value color distribution type\r\n */\r\n set colorsDistributionType(value: GreasedLineMeshColorDistributionType) {\r\n this._colorsDistributionType = value;\r\n this.markAllDefinesAsDirty();\r\n }\r\n\r\n /**\r\n * Gets the resolution\r\n */\r\n get resolution() {\r\n return this._resolution;\r\n }\r\n\r\n /**\r\n * Sets the resolution\r\n * @param value resolution of the screen for GreasedLine\r\n */\r\n set resolution(value: Vector2) {\r\n this._aspect = value.x / value.y;\r\n this._resolution = value;\r\n }\r\n\r\n /**\r\n * Serializes this plugin material\r\n * @returns serializationObjec\r\n */\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n const greasedLineMaterialOptions: GreasedLineMaterialOptions = {\r\n colorDistributionType: this._colorsDistributionType,\r\n colorsSampling: this.colorsSampling,\r\n colorMode: this.colorMode,\r\n dashCount: this._dashCount,\r\n dashOffset: this.dashOffset,\r\n dashRatio: this.dashRatio,\r\n resolution: this._resolution,\r\n sizeAttenuation: this._sizeAttenuation,\r\n useColors: this.useColors,\r\n useDash: this.useDash,\r\n visibility: this.visibility,\r\n width: this.width,\r\n };\r\n\r\n this._colors && (greasedLineMaterialOptions.colors = this._colors);\r\n this._color && (greasedLineMaterialOptions.color = this._color);\r\n\r\n serializationObject.greasedLineMaterialOptions = greasedLineMaterialOptions;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parses a serialized objects\r\n * @param source serialized object\r\n * @param scene scene\r\n * @param rootUrl root url for textures\r\n */\r\n public parse(source: any, scene: Scene, rootUrl: string): void {\r\n super.parse(source, scene, rootUrl);\r\n const greasedLineMaterialOptions = <GreasedLineMaterialOptions>source.greasedLineMaterialOptions;\r\n\r\n this._colorsTexture?.dispose();\r\n\r\n if (greasedLineMaterialOptions.colors) {\r\n this._createColorsTexture(`${this._material.name}-colors-texture`, greasedLineMaterialOptions.colors);\r\n } else {\r\n GreasedLinePluginMaterial._PrepareEmptyColorsTexture(scene);\r\n }\r\n\r\n greasedLineMaterialOptions.color && this.setColor(greasedLineMaterialOptions.color, true);\r\n greasedLineMaterialOptions.colorDistributionType && (this.colorsDistributionType = greasedLineMaterialOptions.colorDistributionType);\r\n greasedLineMaterialOptions.colorsSampling && (this.colorsSampling = greasedLineMaterialOptions.colorsSampling);\r\n greasedLineMaterialOptions.colorMode && (this.colorMode = greasedLineMaterialOptions.colorMode);\r\n greasedLineMaterialOptions.useColors && (this.useColors = greasedLineMaterialOptions.useColors);\r\n greasedLineMaterialOptions.visibility && (this.visibility = greasedLineMaterialOptions.visibility);\r\n greasedLineMaterialOptions.useDash && (this.useDash = greasedLineMaterialOptions.useDash);\r\n greasedLineMaterialOptions.dashCount && (this.dashCount = greasedLineMaterialOptions.dashCount);\r\n greasedLineMaterialOptions.dashRatio && (this.dashRatio = greasedLineMaterialOptions.dashRatio);\r\n greasedLineMaterialOptions.dashOffset && (this.dashOffset = greasedLineMaterialOptions.dashOffset);\r\n greasedLineMaterialOptions.width && (this.width = greasedLineMaterialOptions.width);\r\n greasedLineMaterialOptions.sizeAttenuation && (this.sizeAttenuation = greasedLineMaterialOptions.sizeAttenuation);\r\n greasedLineMaterialOptions.resolution && (this.resolution = greasedLineMaterialOptions.resolution);\r\n\r\n this.markAllDefinesAsDirty();\r\n }\r\n\r\n /**\r\n * A minimum size texture for the colors sampler2D when there is no colors texture defined yet.\r\n * For fast switching using the useColors property without the need to use defines.\r\n * @param scene Scene\r\n */\r\n private static _PrepareEmptyColorsTexture(scene: Scene) {\r\n if (!this._EmptyColorsTexture) {\r\n const colorsArray = new Uint8Array(4);\r\n GreasedLinePluginMaterial._EmptyColorsTexture = new RawTexture(colorsArray, 1, 1, Engine.TEXTUREFORMAT_RGBA, scene, false, false, RawTexture.NEAREST_NEAREST);\r\n GreasedLinePluginMaterial._EmptyColorsTexture.name = \"grlEmptyColorsTexture\";\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(`BABYLON.${GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME}`, GreasedLinePluginMaterial);\r\n"]}
@@ -0,0 +1,228 @@
1
+ import type { Scene } from "../scene";
2
+ import type { GreasedLineMaterialOptions, IGreasedLineMaterial } from "./greasedLinePluginMaterial";
3
+ import { GreasedLineMeshColorMode, GreasedLineMeshColorDistributionType } from "./greasedLinePluginMaterial";
4
+ import { ShaderMaterial } from "./shaderMaterial";
5
+ import type { Nullable } from "../types";
6
+ import { Color3 } from "../Maths/math.color";
7
+ import { Vector2 } from "../Maths/math.vector";
8
+ import "../Shaders/greasedLine.fragment";
9
+ import "../Shaders/greasedLine.vertex";
10
+ /**
11
+ * GreasedLineSimpleMaterial
12
+ */
13
+ export declare class GreasedLineSimpleMaterial extends ShaderMaterial implements IGreasedLineMaterial {
14
+ /**
15
+ * Default line color for newly created lines
16
+ */
17
+ static DEFAULT_COLOR: Color3;
18
+ /**
19
+ * Default line width when sizeAttenuation is true
20
+ */
21
+ static DEFAULT_WIDTH_ATTENUATED: number;
22
+ /**
23
+ * Defaule line width
24
+ */
25
+ static DEFAULT_WIDTH: number;
26
+ private static _EmptyColorsTexture;
27
+ private _visibility;
28
+ private _width;
29
+ private _useDash;
30
+ private _dashCount;
31
+ private _dashArray;
32
+ private _dashRatio;
33
+ private _dashOffset;
34
+ private _useColors;
35
+ private _color;
36
+ private _colors;
37
+ private _colorsDistributionType;
38
+ private _colorMode;
39
+ private _colorsSampling;
40
+ private _resolution;
41
+ private _sizeAttenuation;
42
+ private _colorsTexture?;
43
+ private _engine;
44
+ /**
45
+ * GreasedLineSimple material constructor
46
+ * @param name material name
47
+ * @param scene the scene
48
+ * @param options material options
49
+ */
50
+ constructor(name: string, scene: Scene, options: GreasedLineMaterialOptions);
51
+ /**
52
+ * Converts boolean to number.
53
+ * @param bool
54
+ * @returns 1 if true, 0 if false.
55
+ */
56
+ private static _BooleanToNumber;
57
+ /**
58
+ * Converts an array of Color3 to Uint8Array
59
+ * @param colors Arrray of Color3
60
+ * @returns Uin8Array of colors [r, g, b, a, r, g, b, a, ...]
61
+ */
62
+ private static _Color3toRGBAUint8;
63
+ /**
64
+ * Creates a RawTexture from an RGBA color array and sets it on the plugin material instance.
65
+ * @param name name of the texture
66
+ * @param colors Uint8Array of colors
67
+ */
68
+ private _createColorsTexture;
69
+ /**
70
+ * Disposes the plugin material.
71
+ */
72
+ dispose(): void;
73
+ private _setColorModeAndColorDistributionType;
74
+ /**
75
+ * Updates the material. Use when material created in lazy mode.
76
+ */
77
+ updateLazy(): void;
78
+ /**
79
+ * Returns the colors used to colorize the line
80
+ */
81
+ get colors(): Nullable<Color3[]>;
82
+ /**
83
+ * Sets the colors used to colorize the line
84
+ */
85
+ set colors(value: Nullable<Color3[]>);
86
+ /**
87
+ * Creates or updates the colors texture
88
+ * @param colors color table RGBA
89
+ * @param lazy if lazy, the colors are not updated
90
+ * @param forceNewTexture force creation of a new texture
91
+ * @returns
92
+ */
93
+ setColors(colors: Nullable<Color3[]>, lazy?: boolean, forceNewTexture?: boolean): void;
94
+ /**
95
+ * Line base width. At each point the line width is calculated by widths[pointIndex] * width
96
+ */
97
+ get width(): number;
98
+ /**
99
+ * Line base width. At each point the line width is calculated by widths[pointIndex] * width
100
+ */
101
+ set width(value: number);
102
+ /**
103
+ * Whether to use the colors option to colorize the line
104
+ */
105
+ get useColors(): boolean;
106
+ set useColors(value: boolean);
107
+ /**
108
+ * The type of sampling of the colors texture. The values are the same when using with textures.
109
+ */
110
+ get colorsSampling(): number;
111
+ /**
112
+ * The type of sampling of the colors texture. The values are the same when using with textures.
113
+ */
114
+ set colorsSampling(value: number);
115
+ /**
116
+ * Normalized value of how much of the line will be visible
117
+ * 0 - 0% of the line will be visible
118
+ * 1 - 100% of the line will be visible
119
+ */
120
+ get visibility(): number;
121
+ set visibility(value: number);
122
+ /**
123
+ * Turns on/off dash mode
124
+ */
125
+ get useDash(): boolean;
126
+ /**
127
+ * Turns on/off dash mode
128
+ */
129
+ set useDash(value: boolean);
130
+ /**
131
+ * Gets the dash offset
132
+ */
133
+ get dashOffset(): number;
134
+ /**
135
+ * Sets the dash offset
136
+ */
137
+ set dashOffset(value: number);
138
+ /**
139
+ * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.
140
+ */
141
+ get dashRatio(): number;
142
+ /**
143
+ * Length of the dash. 0 to 1. 0.5 means half empty, half drawn.
144
+ */
145
+ set dashRatio(value: number);
146
+ /**
147
+ * Gets the number of dashes in the line
148
+ */
149
+ get dashCount(): number;
150
+ /**
151
+ * Sets the number of dashes in the line
152
+ * @param value dash
153
+ */
154
+ set dashCount(value: number);
155
+ /**
156
+ * False means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines
157
+ */
158
+ get sizeAttenuation(): boolean;
159
+ /**
160
+ * Turn on/off attenuation of the width option and widths array.
161
+ * @param value false means 1 unit in width = 1 unit on scene, true means 1 unit in width is reduced on the screen to make better looking lines
162
+ */
163
+ set sizeAttenuation(value: boolean);
164
+ /**
165
+ * Gets the color of the line
166
+ */
167
+ get color(): Color3;
168
+ /**
169
+ * Sets the color of the line
170
+ * @param value Color3
171
+ */
172
+ set color(value: Color3);
173
+ /**
174
+ * Sets the color of the line. If set the whole line will be mixed with this color according to the colorMode option.
175
+ * The simple material always needs a color to be set. If you set it to null it will set the color to the default color (GreasedLineSimpleMaterial.DEFAULT_COLOR).
176
+ * @param value color
177
+ */
178
+ setColor(value: Nullable<Color3>): void;
179
+ /**
180
+ * Gets the color distributiopn type
181
+ */
182
+ get colorsDistributionType(): GreasedLineMeshColorDistributionType;
183
+ /**
184
+ * Sets the color distribution type
185
+ * @see GreasedLineMeshColorDistributionType
186
+ * @param value color distribution type
187
+ */
188
+ set colorsDistributionType(value: GreasedLineMeshColorDistributionType);
189
+ /**
190
+ * Gets the mixing mode of the color and colors paramaters. Default value is GreasedLineMeshColorMode.SET.
191
+ * MATERIAL_TYPE_SIMPLE mixes the color and colors of the greased line material.
192
+ * @see GreasedLineMeshColorMode
193
+ */
194
+ get colorMode(): GreasedLineMeshColorMode;
195
+ /**
196
+ * Sets the mixing mode of the color and colors paramaters. Default value is GreasedLineMeshColorMode.SET.
197
+ * MATERIAL_TYPE_SIMPLE mixes the color and colors of the greased line material.
198
+ * @see GreasedLineMeshColorMode
199
+ */
200
+ set colorMode(value: GreasedLineMeshColorMode);
201
+ /**
202
+ * Gets the resolution
203
+ */
204
+ get resolution(): Vector2;
205
+ /**
206
+ * Sets the resolution
207
+ * @param value resolution of the screen for GreasedLine
208
+ */
209
+ set resolution(value: Vector2);
210
+ /**
211
+ * Serializes this plugin material
212
+ * @returns serializationObjec
213
+ */
214
+ serialize(): any;
215
+ /**
216
+ * Parses a serialized objects
217
+ * @param source serialized object
218
+ * @param scene scene
219
+ * @param _rootUrl root url for textures
220
+ */
221
+ parse(source: any, scene: Scene, _rootUrl: string): void;
222
+ /**
223
+ * A minimum size texture for the colors sampler2D when there is no colors texture defined yet.
224
+ * For fast switching using the useColors property without the need to use defines.
225
+ * @param scene Scene
226
+ */
227
+ private static _PrepareEmptyColorsTexture;
228
+ }