@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,25 +1,58 @@
1
1
  import { Engine } from "../Engines/engine.js";
2
2
  import { RawTexture } from "./Textures/rawTexture.js";
3
3
  import { MaterialPluginBase } from "./materialPluginBase.js";
4
- import { TmpVectors } from "../Maths/math.vector.js";
4
+ import { Vector2, TmpVectors } from "../Maths/math.vector.js";
5
5
  import { Color3 } from "../Maths/math.color.js";
6
6
  import { MaterialDefines } from "./materialDefines.js";
7
- import { DeepCopier } from "../Misc/deepCopier.js";
8
7
  import { RegisterClass } from "../Misc/typeStore.js";
8
+ /**
9
+ * Material types for GreasedLine
10
+ * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#materialtype}
11
+ */
9
12
  export var GreasedLineMeshMaterialType;
10
13
  (function (GreasedLineMeshMaterialType) {
14
+ /**
15
+ * StandardMaterial
16
+ */
11
17
  GreasedLineMeshMaterialType[GreasedLineMeshMaterialType["MATERIAL_TYPE_STANDARD"] = 0] = "MATERIAL_TYPE_STANDARD";
18
+ /**
19
+ * PBR Material
20
+ */
12
21
  GreasedLineMeshMaterialType[GreasedLineMeshMaterialType["MATERIAL_TYPE_PBR"] = 1] = "MATERIAL_TYPE_PBR";
13
22
  })(GreasedLineMeshMaterialType || (GreasedLineMeshMaterialType = {}));
23
+ /**
24
+ * Color blending mode of the @see GreasedLineMaterial and the base material
25
+ * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colormode}
26
+ */
14
27
  export var GreasedLineMeshColorMode;
15
28
  (function (GreasedLineMeshColorMode) {
29
+ /**
30
+ * Color blending mode SET
31
+ */
16
32
  GreasedLineMeshColorMode[GreasedLineMeshColorMode["COLOR_MODE_SET"] = 0] = "COLOR_MODE_SET";
33
+ /**
34
+ * Color blending mode ADD
35
+ */
17
36
  GreasedLineMeshColorMode[GreasedLineMeshColorMode["COLOR_MODE_ADD"] = 1] = "COLOR_MODE_ADD";
37
+ /**
38
+ * Color blending mode ADD
39
+ */
18
40
  GreasedLineMeshColorMode[GreasedLineMeshColorMode["COLOR_MODE_MULTIPLY"] = 2] = "COLOR_MODE_MULTIPLY";
19
41
  })(GreasedLineMeshColorMode || (GreasedLineMeshColorMode = {}));
42
+ /**
43
+ * Color distribution type of the @see colors.
44
+ * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colordistributiontype}
45
+ *
46
+ */
20
47
  export var GreasedLineMeshColorDistributionType;
21
48
  (function (GreasedLineMeshColorDistributionType) {
49
+ /**
50
+ * Colors distributed between segments of the line
51
+ */
22
52
  GreasedLineMeshColorDistributionType[GreasedLineMeshColorDistributionType["COLOR_DISTRIBUTION_TYPE_SEGMENT"] = 0] = "COLOR_DISTRIBUTION_TYPE_SEGMENT";
53
+ /**
54
+ * Colors distributed along the line ingoring the segments
55
+ */
23
56
  GreasedLineMeshColorDistributionType[GreasedLineMeshColorDistributionType["COLOR_DISTRIBUTION_TYPE_LINE"] = 1] = "COLOR_DISTRIBUTION_TYPE_LINE";
24
57
  })(GreasedLineMeshColorDistributionType || (GreasedLineMeshColorDistributionType = {}));
25
58
  /**
@@ -50,25 +83,39 @@ export class MaterialGreasedLineDefines extends MaterialDefines {
50
83
  */
51
84
  export class GreasedLinePluginMaterial extends MaterialPluginBase {
52
85
  constructor(material, _scene, options) {
53
- var _a, _b, _c;
54
- options = options !== null && options !== void 0 ? options : {};
86
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
87
+ options = options || {
88
+ color: GreasedLinePluginMaterial.DEFAULT_COLOR,
89
+ };
55
90
  const defines = new MaterialGreasedLineDefines();
56
91
  defines.GREASED_LINE_HAS_COLOR = !!options.color;
57
92
  defines.GREASED_LINE_SIZE_ATTENUATION = (_a = options.sizeAttenuation) !== null && _a !== void 0 ? _a : false;
58
93
  defines.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = options.colorDistributionType === GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE;
59
94
  super(material, GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME, 200, defines);
60
95
  this._scene = _scene;
61
- this._dashArray = 0;
62
- this._options = options;
63
96
  this._scene = (_b = this._scene) !== null && _b !== void 0 ? _b : material.getScene();
64
97
  this._engine = this._scene.getEngine();
65
- if (options.colors) {
66
- this._createColorsTexture(`${material.name}-colors-texture`, options.colors);
98
+ this.visibility = (_c = options.visibility) !== null && _c !== void 0 ? _c : 1;
99
+ this.useDash = (_d = options.useDash) !== null && _d !== void 0 ? _d : false;
100
+ this.dashRatio = (_e = options.dashRatio) !== null && _e !== void 0 ? _e : 0.5;
101
+ this.dashOffset = (_f = options.dashOffset) !== null && _f !== void 0 ? _f : 0;
102
+ this.width = options.width ? options.width : options.sizeAttenuation ? GreasedLinePluginMaterial.DEFAULT_WIDTH_ATTENUATED : GreasedLinePluginMaterial.DEFAULT_WIDTH;
103
+ this._sizeAttenuation = (_g = options.sizeAttenuation) !== null && _g !== void 0 ? _g : false;
104
+ this.colorMode = (_h = options.colorMode) !== null && _h !== void 0 ? _h : GreasedLineMeshColorMode.COLOR_MODE_SET;
105
+ this._color = (_j = options.color) !== null && _j !== void 0 ? _j : null;
106
+ this.useColors = (_k = options.useColors) !== null && _k !== void 0 ? _k : false;
107
+ this._colorsDistributionType = (_l = options.colorDistributionType) !== null && _l !== void 0 ? _l : GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_SEGMENT;
108
+ this.colorsSampling = (_m = options.colorsSampling) !== null && _m !== void 0 ? _m : RawTexture.NEAREST_NEAREST;
109
+ this._colors = (_o = options.colors) !== null && _o !== void 0 ? _o : null;
110
+ this.dashCount = (_p = options.dashCount) !== null && _p !== void 0 ? _p : 1; // calculate the _dashArray value, call the setter
111
+ this.resolution = (_q = options.resolution) !== null && _q !== void 0 ? _q : new Vector2(this._engine.getRenderWidth(), this._engine.getRenderHeight()); // calculate aspect call the setter
112
+ if (this._colors) {
113
+ this._createColorsTexture(`${material.name}-colors-texture`, this._colors);
67
114
  }
68
115
  else {
116
+ this._color = (_r = this._color) !== null && _r !== void 0 ? _r : GreasedLinePluginMaterial.DEFAULT_COLOR;
69
117
  GreasedLinePluginMaterial._PrepareEmptyColorsTexture(_scene);
70
118
  }
71
- this.setDashCount((_c = options.dashCount) !== null && _c !== void 0 ? _c : 1); // calculate the _dashArray value
72
119
  this._enable(true); // always enabled
73
120
  }
74
121
  /**
@@ -106,14 +153,14 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
106
153
  const ubo = [
107
154
  { name: "grl_projection", size: 16, type: "mat4" },
108
155
  { name: "grl_singleColor", size: 3, type: "vec3" },
109
- { name: "grl_resolution_lineWidth", size: 3, type: "vec3" },
156
+ { name: "grl_aspect_lineWidth", size: 3, type: "vec3" },
110
157
  { name: "grl_dashOptions", size: 4, type: "vec4" },
111
158
  { name: "grl_colorMode_visibility_colorsWidth_useColors", size: 4, type: "vec4" },
112
159
  ];
113
160
  return {
114
161
  ubo,
115
162
  vertex: `
116
- uniform vec3 grl_resolution_lineWidth;
163
+ uniform vec3 grl_aspect_lineWidth;
117
164
  uniform mat4 grl_projection;
118
165
  `,
119
166
  fragment: `
@@ -133,7 +180,7 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
133
180
  * @param uniformBuffer
134
181
  */
135
182
  bindForSubMesh(uniformBuffer) {
136
- var _a, _b, _c, _d, _e, _f, _g;
183
+ var _a;
137
184
  const activeCamera = this._scene.activeCamera;
138
185
  if (activeCamera) {
139
186
  const projection = activeCamera.getProjectionMatrix();
@@ -143,32 +190,26 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
143
190
  throw Error("GreasedLinePluginMaterial requires an active camera.");
144
191
  }
145
192
  const resolutionLineWidth = TmpVectors.Vector3[0];
146
- if (this._options.resolution) {
147
- resolutionLineWidth.x = this._options.resolution.x;
148
- resolutionLineWidth.y = this._options.resolution.y;
149
- }
150
- else {
151
- resolutionLineWidth.x = this._engine.getRenderWidth();
152
- resolutionLineWidth.y = this._engine.getRenderHeight();
153
- }
154
- resolutionLineWidth.z = this._options.width ? this._options.width : this._options.sizeAttenuation ? 1 : 0.1;
155
- uniformBuffer.updateVector3("grl_resolution_lineWidth", resolutionLineWidth);
193
+ resolutionLineWidth.x = this._aspect;
194
+ // TODO: y free
195
+ resolutionLineWidth.z = this.width;
196
+ uniformBuffer.updateVector3("grl_aspect_lineWidth", resolutionLineWidth);
156
197
  const dashOptions = TmpVectors.Vector4[0];
157
- dashOptions.x = GreasedLinePluginMaterial._BooleanToNumber(this._options.useDash);
158
- dashOptions.y = (_a = this._dashArray) !== null && _a !== void 0 ? _a : 0;
159
- dashOptions.z = (_b = this._options.dashOffset) !== null && _b !== void 0 ? _b : 0;
160
- dashOptions.w = (_c = this._options.dashRatio) !== null && _c !== void 0 ? _c : 0.5;
198
+ dashOptions.x = GreasedLinePluginMaterial._BooleanToNumber(this.useDash);
199
+ dashOptions.y = this._dashArray;
200
+ dashOptions.z = this.dashOffset;
201
+ dashOptions.w = this.dashRatio;
161
202
  uniformBuffer.updateVector4("grl_dashOptions", dashOptions);
162
203
  const colorModeVisibilityColorsWidthUseColors = TmpVectors.Vector4[1];
163
- colorModeVisibilityColorsWidthUseColors.x = (_d = this._options.colorMode) !== null && _d !== void 0 ? _d : GreasedLineMeshColorMode.COLOR_MODE_SET;
164
- colorModeVisibilityColorsWidthUseColors.y = (_e = this._options.visibility) !== null && _e !== void 0 ? _e : 1;
204
+ colorModeVisibilityColorsWidthUseColors.x = this.colorMode;
205
+ colorModeVisibilityColorsWidthUseColors.y = this.visibility;
165
206
  colorModeVisibilityColorsWidthUseColors.z = this._colorsTexture ? this._colorsTexture.getSize().width : 0;
166
- colorModeVisibilityColorsWidthUseColors.w = GreasedLinePluginMaterial._BooleanToNumber(this._options.useColors);
207
+ colorModeVisibilityColorsWidthUseColors.w = GreasedLinePluginMaterial._BooleanToNumber(this.useColors);
167
208
  uniformBuffer.updateVector4("grl_colorMode_visibility_colorsWidth_useColors", colorModeVisibilityColorsWidthUseColors);
168
- if (this._options.color) {
169
- uniformBuffer.updateColor3("grl_singleColor", (_f = this._options.color) !== null && _f !== void 0 ? _f : Color3.White());
209
+ if (this._color) {
210
+ uniformBuffer.updateColor3("grl_singleColor", this._color);
170
211
  }
171
- uniformBuffer.setTexture("grl_colors", (_g = this._colorsTexture) !== null && _g !== void 0 ? _g : GreasedLinePluginMaterial._EmptyColorsTexture);
212
+ uniformBuffer.setTexture("grl_colors", (_a = this._colorsTexture) !== null && _a !== void 0 ? _a : GreasedLinePluginMaterial._EmptyColorsTexture);
172
213
  }
173
214
  /**
174
215
  * Prepare the defines
@@ -178,10 +219,9 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
178
219
  */
179
220
  prepareDefines(defines, _scene, _mesh) {
180
221
  var _a;
181
- const options = this._options;
182
- defines.GREASED_LINE_HAS_COLOR = !!options.color;
183
- defines.GREASED_LINE_SIZE_ATTENUATION = (_a = options.sizeAttenuation) !== null && _a !== void 0 ? _a : false;
184
- defines.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = options.colorDistributionType === GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE;
222
+ defines.GREASED_LINE_HAS_COLOR = !!this._color;
223
+ defines.GREASED_LINE_SIZE_ATTENUATION = (_a = this._sizeAttenuation) !== null && _a !== void 0 ? _a : false;
224
+ defines.GREASED_LINE_COLOR_DISTRIBUTION_TYPE_LINE = this._colorsDistributionType === GreasedLineMeshColorDistributionType.COLOR_DISTRIBUTION_TYPE_LINE;
185
225
  }
186
226
  /**
187
227
  * Get the class name
@@ -222,8 +262,9 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
222
262
  `,
223
263
  // eslint-disable-next-line @typescript-eslint/naming-convention
224
264
  CUSTOM_VERTEX_MAIN_END: `
225
- vec2 grlResolution = grl_resolution_lineWidth.xy;
226
- float grlBaseWidth = grl_resolution_lineWidth.z;
265
+
266
+ float grlAspect = grl_aspect_lineWidth.x;
267
+ float grlBaseWidth = grl_aspect_lineWidth.z;
227
268
 
228
269
  grlColorPointer = grl_colorPointers;
229
270
 
@@ -233,7 +274,6 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
233
274
  vec3 grlNext = grl_nextAndCounters.xyz;
234
275
  grlCounters = grl_nextAndCounters.w;
235
276
 
236
- float grlAspect = grlResolution.x / grlResolution.y;
237
277
 
238
278
  mat4 grlMatrix = viewProjection * world;
239
279
  vec4 grlFinalPosition = grlMatrix * vec4( positionUpdated , 1.0 );
@@ -357,9 +397,8 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
357
397
  * @param colors Uint8Array of colors
358
398
  */
359
399
  _createColorsTexture(name, colors) {
360
- var _a;
361
400
  const colorsArray = GreasedLinePluginMaterial._Color3toRGBAUint8(colors);
362
- this._colorsTexture = new RawTexture(colorsArray, colors.length, 1, Engine.TEXTUREFORMAT_RGBA, this._scene, false, true, (_a = this._options.colorsSampling) !== null && _a !== void 0 ? _a : RawTexture.NEAREST_NEAREST);
401
+ this._colorsTexture = new RawTexture(colorsArray, colors.length, 1, Engine.TEXTUREFORMAT_RGBA, this._scene, false, true, this.colorsSampling);
363
402
  this._colorsTexture.name = name;
364
403
  }
365
404
  /**
@@ -371,11 +410,16 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
371
410
  super.dispose();
372
411
  }
373
412
  /**
374
- * Sets whether to use the colors option to colorize the line.
375
- * @param value true if use the colors, otherwise false
413
+ * Returns the colors used to colorize the line
414
+ */
415
+ get colors() {
416
+ return this._colors;
417
+ }
418
+ /**
419
+ * Sets the colors used to colorize the line
376
420
  */
377
- setUseColors(value) {
378
- this._options.useColors = value;
421
+ set colors(value) {
422
+ this.setColors(value);
379
423
  }
380
424
  /**
381
425
  * Creates or updates the colors texture
@@ -386,12 +430,12 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
386
430
  */
387
431
  setColors(colors, lazy = false, forceUpdate = false) {
388
432
  var _a, _b, _c, _d;
433
+ const origColorsCount = (_b = (_a = this._colors) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
434
+ this._colors = colors;
389
435
  if (colors === null || colors.length === 0) {
390
- (_a = this._colorsTexture) === null || _a === void 0 ? void 0 : _a.dispose();
436
+ (_c = this._colorsTexture) === null || _c === void 0 ? void 0 : _c.dispose();
391
437
  return;
392
438
  }
393
- const origColorsCount = (_c = (_b = this._options.colors) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
394
- this._options.colors = colors;
395
439
  if (lazy && !forceUpdate) {
396
440
  return;
397
441
  }
@@ -408,90 +452,92 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
408
452
  * Updates the material. Use when material created in lazy mode.
409
453
  */
410
454
  updateLazy() {
411
- if (this._options.colors) {
412
- this.setColors(this._options.colors, false, true);
455
+ if (this._colors) {
456
+ this.setColors(this._colors, false, true);
413
457
  }
414
458
  }
415
459
  /**
416
- * Gets the plugin material options
417
- * @returns the plugin material options @see GreasedLineMaterialOptions
418
- */
419
- getOptions() {
420
- return this._options;
421
- }
422
- /**
423
- * Sets the line length visibility.
424
- * 0 - 0% of the line will be visible
425
- * 1 - 100% of the line will be visible
426
- * @param value
427
- */
428
- setVisibility(value) {
429
- this._options.visibility = value;
430
- }
431
- /**
432
- * Turns on/off dashmode
433
- * @param value
460
+ * Gets the number of dashes in the line
434
461
  */
435
- setUseDash(value) {
436
- this._options.useDash = value;
462
+ get dashCount() {
463
+ return this._dashCount;
437
464
  }
438
465
  /**
439
- * Sets the dash array.
440
- * @param value dash array
466
+ * Sets the number of dashes in the line
467
+ * @param value dash
441
468
  */
442
- setDashCount(value) {
443
- this._options.dashCount = value;
469
+ set dashCount(value) {
470
+ this._dashCount = value;
444
471
  this._dashArray = 1 / value;
445
472
  }
446
473
  /**
447
- * Sets the dash ratio
448
- * @param value dash length ratio 0..1 (0.5 = half empty, half drawn)
474
+ * 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
449
475
  */
450
- setDashRatio(value) {
451
- this._options.dashRatio = value;
476
+ get sizeAttenuation() {
477
+ return this._sizeAttenuation;
452
478
  }
453
479
  /**
454
- * Sets the dash offset
455
- * @param value the dashes will be offset by this value
480
+ * Turn on/off attenuation of the width option and widths array.
481
+ * @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
456
482
  */
457
- setDashOffset(value) {
458
- this._options.dashOffset = value;
483
+ set sizeAttenuation(value) {
484
+ this._sizeAttenuation = value;
485
+ this.markAllDefinesAsDirty();
459
486
  }
460
487
  /**
461
- * Sets line base width. At each point the line width is calculated by widths[pointIndex] * width
462
- * @param value base width
488
+ * Gets the color of the line
463
489
  */
464
- setWidth(value) {
465
- this._options.width = value;
490
+ get color() {
491
+ return this.color;
466
492
  }
467
493
  /**
468
- * Turn on/off attenuation of the width option and widths array.
469
- * @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
494
+ * Sets the color of the line
495
+ * @param value Color3 or null to clear the color. You need to clear the color if you use colors and useColors = true
470
496
  */
471
- setSizeAttenuation(value) {
472
- this._options.sizeAttenuation = value;
473
- this.markAllDefinesAsDirty();
497
+ set color(value) {
498
+ this.setColor(value);
474
499
  }
475
500
  /**
476
501
  * Sets the color of the line. If set the whole line will be mixed with this color according to the colorMode option.
477
502
  * @param value color
478
503
  */
479
504
  setColor(value, doNotMarkDirty = false) {
480
- if ((this._options.color === undefined && value !== undefined) || (this._options.color !== undefined && value === undefined)) {
481
- this._options.color = value;
505
+ if ((this._color === null && value !== null) || (this._color !== null && value === null)) {
506
+ this._color = value;
482
507
  !doNotMarkDirty && this.markAllDefinesAsDirty();
483
508
  }
484
509
  else {
485
- this._options.color = value;
510
+ this._color = value;
486
511
  }
487
512
  }
488
513
  /**
489
- * Sets the mixing mode of the color paramater. Default value is GreasedLineMeshColorMode.SET
490
- * @see GreasedLineMeshColorMode
491
- * @param value color mode
514
+ * Gets the color distributiopn type
492
515
  */
493
- setColorMode(value) {
494
- this._options.colorMode = value;
516
+ get colorsDistributionType() {
517
+ return this._colorsDistributionType;
518
+ }
519
+ /**
520
+ * Sets the color distribution type
521
+ * @see GreasedLineMeshColorDistributionType
522
+ * @param value color distribution type
523
+ */
524
+ set colorsDistributionType(value) {
525
+ this._colorsDistributionType = value;
526
+ this.markAllDefinesAsDirty();
527
+ }
528
+ /**
529
+ * Gets the resolution
530
+ */
531
+ get resolution() {
532
+ return this._resolution;
533
+ }
534
+ /**
535
+ * Sets the resolution
536
+ * @param value resolution of the screen for GreasedLine
537
+ */
538
+ set resolution(value) {
539
+ this._aspect = value.x / value.y;
540
+ this._resolution = value;
495
541
  }
496
542
  /**
497
543
  * Serializes this plugin material
@@ -499,8 +545,23 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
499
545
  */
500
546
  serialize() {
501
547
  const serializationObject = super.serialize();
502
- serializationObject.materialOptions = {};
503
- DeepCopier.DeepCopy(this._options, serializationObject.materialOptions);
548
+ const greasedLineMaterialOptions = {
549
+ colorDistributionType: this._colorsDistributionType,
550
+ colorsSampling: this.colorsSampling,
551
+ colorMode: this.colorMode,
552
+ dashCount: this._dashCount,
553
+ dashOffset: this.dashOffset,
554
+ dashRatio: this.dashRatio,
555
+ resolution: this._resolution,
556
+ sizeAttenuation: this._sizeAttenuation,
557
+ useColors: this.useColors,
558
+ useDash: this.useDash,
559
+ visibility: this.visibility,
560
+ width: this.width,
561
+ };
562
+ this._colors && (greasedLineMaterialOptions.colors = this._colors);
563
+ this._color && (greasedLineMaterialOptions.color = this._color);
564
+ serializationObject.greasedLineMaterialOptions = greasedLineMaterialOptions;
504
565
  return serializationObject;
505
566
  }
506
567
  /**
@@ -512,24 +573,27 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
512
573
  parse(source, scene, rootUrl) {
513
574
  var _a;
514
575
  super.parse(source, scene, rootUrl);
515
- this._options = source.materialOptions;
576
+ const greasedLineMaterialOptions = source.greasedLineMaterialOptions;
516
577
  (_a = this._colorsTexture) === null || _a === void 0 ? void 0 : _a.dispose();
517
- if (this._options.colors) {
518
- this._createColorsTexture(`${this._material.name}-colors-texture`, this._options.colors);
578
+ if (greasedLineMaterialOptions.colors) {
579
+ this._createColorsTexture(`${this._material.name}-colors-texture`, greasedLineMaterialOptions.colors);
519
580
  }
520
581
  else {
521
582
  GreasedLinePluginMaterial._PrepareEmptyColorsTexture(scene);
522
583
  }
523
- this._options.color && this.setColor(this._options.color, true);
524
- this._options.colorMode && this.setColorMode(this._options.colorMode);
525
- this._options.useColors && this.setUseColors(this._options.useColors);
526
- this._options.visibility && this.setVisibility(this._options.visibility);
527
- this._options.useDash && this.setUseDash(this._options.useDash);
528
- this._options.dashCount && this.setDashCount(this._options.dashCount);
529
- this._options.dashRatio && this.setDashRatio(this._options.dashRatio);
530
- this._options.dashOffset && this.setDashOffset(this._options.dashOffset);
531
- this._options.width && this.setWidth(this._options.width);
532
- this._options.sizeAttenuation && this.setSizeAttenuation(this._options.sizeAttenuation);
584
+ greasedLineMaterialOptions.color && this.setColor(greasedLineMaterialOptions.color, true);
585
+ greasedLineMaterialOptions.colorDistributionType && (this.colorsDistributionType = greasedLineMaterialOptions.colorDistributionType);
586
+ greasedLineMaterialOptions.colorsSampling && (this.colorsSampling = greasedLineMaterialOptions.colorsSampling);
587
+ greasedLineMaterialOptions.colorMode && (this.colorMode = greasedLineMaterialOptions.colorMode);
588
+ greasedLineMaterialOptions.useColors && (this.useColors = greasedLineMaterialOptions.useColors);
589
+ greasedLineMaterialOptions.visibility && (this.visibility = greasedLineMaterialOptions.visibility);
590
+ greasedLineMaterialOptions.useDash && (this.useDash = greasedLineMaterialOptions.useDash);
591
+ greasedLineMaterialOptions.dashCount && (this.dashCount = greasedLineMaterialOptions.dashCount);
592
+ greasedLineMaterialOptions.dashRatio && (this.dashRatio = greasedLineMaterialOptions.dashRatio);
593
+ greasedLineMaterialOptions.dashOffset && (this.dashOffset = greasedLineMaterialOptions.dashOffset);
594
+ greasedLineMaterialOptions.width && (this.width = greasedLineMaterialOptions.width);
595
+ greasedLineMaterialOptions.sizeAttenuation && (this.sizeAttenuation = greasedLineMaterialOptions.sizeAttenuation);
596
+ greasedLineMaterialOptions.resolution && (this.resolution = greasedLineMaterialOptions.resolution);
533
597
  this.markAllDefinesAsDirty();
534
598
  }
535
599
  /**
@@ -549,5 +613,17 @@ export class GreasedLinePluginMaterial extends MaterialPluginBase {
549
613
  * Plugin name
550
614
  */
551
615
  GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME = "GreasedLinePluginMaterial";
616
+ /**
617
+ * Default line color for newly created lines
618
+ */
619
+ GreasedLinePluginMaterial.DEFAULT_COLOR = Color3.White();
620
+ /**
621
+ * Default line width when sizeAttenuation is true
622
+ */
623
+ GreasedLinePluginMaterial.DEFAULT_WIDTH_ATTENUATED = 1;
624
+ /**
625
+ * Defaule line width
626
+ */
627
+ GreasedLinePluginMaterial.DEFAULT_WIDTH = 0.1;
552
628
  RegisterClass(`BABYLON.${GreasedLinePluginMaterial.GREASED_LINE_MATERIAL_NAME}`, GreasedLinePluginMaterial);
553
629
  //# sourceMappingURL=greasedLinePluginMaterial.js.map