@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.
- package/Culling/ray.js +2 -2
- package/Culling/ray.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +5 -0
- package/Materials/PBR/pbrBaseMaterial.js +6 -1
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrMaterial.d.ts +4 -0
- package/Materials/PBR/pbrMaterial.js +8 -0
- package/Materials/PBR/pbrMaterial.js.map +1 -1
- package/Materials/greasedLinePluginMaterial.d.ts +129 -41
- package/Materials/greasedLinePluginMaterial.js +190 -114
- package/Materials/greasedLinePluginMaterial.js.map +1 -1
- package/Materials/materialHelper.d.ts +2 -1
- package/Materials/materialHelper.js +3 -1
- package/Materials/materialHelper.js.map +1 -1
- package/Materials/standardMaterial.d.ts +6 -0
- package/Materials/standardMaterial.js +9 -1
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/Builders/greasedLineBuilder.d.ts +45 -1
- package/Meshes/Builders/greasedLineBuilder.js +59 -20
- package/Meshes/Builders/greasedLineBuilder.js.map +1 -1
- package/Meshes/greasedLineMesh.d.ts +24 -11
- package/Meshes/greasedLineMesh.js +64 -24
- package/Meshes/greasedLineMesh.js.map +1 -1
- package/Misc/greasedLineTools.d.ts +11 -2
- package/Misc/greasedLineTools.js +18 -5
- package/Misc/greasedLineTools.js.map +1 -1
- package/Particles/gpuParticleSystem.js +1 -1
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js +5 -0
- package/Shaders/ShadersInclude/pbrBlockAlbedoOpacity.js.map +1 -1
- package/Shaders/default.fragment.js +4 -1
- package/Shaders/default.fragment.js.map +1 -1
- 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
|
|
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
|
-
|
|
66
|
-
|
|
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: "
|
|
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
|
|
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
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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.
|
|
158
|
-
dashOptions.y =
|
|
159
|
-
dashOptions.z =
|
|
160
|
-
dashOptions.w =
|
|
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 =
|
|
164
|
-
colorModeVisibilityColorsWidthUseColors.y =
|
|
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.
|
|
207
|
+
colorModeVisibilityColorsWidthUseColors.w = GreasedLinePluginMaterial._BooleanToNumber(this.useColors);
|
|
167
208
|
uniformBuffer.updateVector4("grl_colorMode_visibility_colorsWidth_useColors", colorModeVisibilityColorsWidthUseColors);
|
|
168
|
-
if (this.
|
|
169
|
-
uniformBuffer.updateColor3("grl_singleColor",
|
|
209
|
+
if (this._color) {
|
|
210
|
+
uniformBuffer.updateColor3("grl_singleColor", this._color);
|
|
170
211
|
}
|
|
171
|
-
uniformBuffer.setTexture("grl_colors", (
|
|
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
|
-
|
|
182
|
-
defines.
|
|
183
|
-
defines.
|
|
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
|
-
|
|
226
|
-
float
|
|
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,
|
|
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
|
-
*
|
|
375
|
-
|
|
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
|
-
|
|
378
|
-
this.
|
|
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
|
-
(
|
|
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.
|
|
412
|
-
this.setColors(this.
|
|
455
|
+
if (this._colors) {
|
|
456
|
+
this.setColors(this._colors, false, true);
|
|
413
457
|
}
|
|
414
458
|
}
|
|
415
459
|
/**
|
|
416
|
-
* Gets the
|
|
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
|
-
|
|
436
|
-
this.
|
|
462
|
+
get dashCount() {
|
|
463
|
+
return this._dashCount;
|
|
437
464
|
}
|
|
438
465
|
/**
|
|
439
|
-
* Sets the
|
|
440
|
-
* @param value dash
|
|
466
|
+
* Sets the number of dashes in the line
|
|
467
|
+
* @param value dash
|
|
441
468
|
*/
|
|
442
|
-
|
|
443
|
-
this.
|
|
469
|
+
set dashCount(value) {
|
|
470
|
+
this._dashCount = value;
|
|
444
471
|
this._dashArray = 1 / value;
|
|
445
472
|
}
|
|
446
473
|
/**
|
|
447
|
-
*
|
|
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
|
-
|
|
451
|
-
this.
|
|
476
|
+
get sizeAttenuation() {
|
|
477
|
+
return this._sizeAttenuation;
|
|
452
478
|
}
|
|
453
479
|
/**
|
|
454
|
-
*
|
|
455
|
-
* @param value the
|
|
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
|
-
|
|
458
|
-
this.
|
|
483
|
+
set sizeAttenuation(value) {
|
|
484
|
+
this._sizeAttenuation = value;
|
|
485
|
+
this.markAllDefinesAsDirty();
|
|
459
486
|
}
|
|
460
487
|
/**
|
|
461
|
-
*
|
|
462
|
-
* @param value base width
|
|
488
|
+
* Gets the color of the line
|
|
463
489
|
*/
|
|
464
|
-
|
|
465
|
-
this.
|
|
490
|
+
get color() {
|
|
491
|
+
return this.color;
|
|
466
492
|
}
|
|
467
493
|
/**
|
|
468
|
-
*
|
|
469
|
-
* @param value
|
|
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
|
-
|
|
472
|
-
this.
|
|
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.
|
|
481
|
-
this.
|
|
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.
|
|
510
|
+
this._color = value;
|
|
486
511
|
}
|
|
487
512
|
}
|
|
488
513
|
/**
|
|
489
|
-
*
|
|
490
|
-
* @see GreasedLineMeshColorMode
|
|
491
|
-
* @param value color mode
|
|
514
|
+
* Gets the color distributiopn type
|
|
492
515
|
*/
|
|
493
|
-
|
|
494
|
-
this.
|
|
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
|
-
|
|
503
|
-
|
|
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
|
-
|
|
576
|
+
const greasedLineMaterialOptions = source.greasedLineMaterialOptions;
|
|
516
577
|
(_a = this._colorsTexture) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
517
|
-
if (
|
|
518
|
-
this._createColorsTexture(`${this._material.name}-colors-texture`,
|
|
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
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
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
|