@babylonjs/core 6.0.0 → 6.2.0

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 (75) hide show
  1. package/Animations/animatable.js +4 -0
  2. package/Animations/animatable.js.map +1 -1
  3. package/Animations/runtimeAnimation.d.ts +0 -1
  4. package/Animations/runtimeAnimation.js +0 -1
  5. package/Animations/runtimeAnimation.js.map +1 -1
  6. package/Collisions/pickingInfo.js +24 -9
  7. package/Collisions/pickingInfo.js.map +1 -1
  8. package/Engines/Extensions/engine.cubeTexture.js +1 -1
  9. package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
  10. package/Engines/Extensions/engine.multiRender.js +1 -1
  11. package/Engines/Extensions/engine.multiRender.js.map +1 -1
  12. package/Engines/Extensions/engine.rawTexture.js +1 -0
  13. package/Engines/Extensions/engine.rawTexture.js.map +1 -1
  14. package/Engines/engine.d.ts +97 -20
  15. package/Engines/thinEngine.d.ts +7 -1
  16. package/Engines/thinEngine.js +36 -19
  17. package/Engines/thinEngine.js.map +1 -1
  18. package/Gamepads/gamepadManager.js +2 -4
  19. package/Gamepads/gamepadManager.js.map +1 -1
  20. package/Layers/effectLayer.d.ts +15 -0
  21. package/Layers/effectLayer.js +21 -0
  22. package/Layers/effectLayer.js.map +1 -1
  23. package/Materials/Node/Blocks/index.d.ts +1 -0
  24. package/Materials/Node/Blocks/index.js +1 -0
  25. package/Materials/Node/Blocks/index.js.map +1 -1
  26. package/Materials/Node/Blocks/meshAttributeExistsBlock.d.ts +52 -0
  27. package/Materials/Node/Blocks/meshAttributeExistsBlock.js +199 -0
  28. package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -0
  29. package/Materials/Node/nodeMaterial.d.ts +1 -0
  30. package/Materials/Node/nodeMaterial.js +5 -1
  31. package/Materials/Node/nodeMaterial.js.map +1 -1
  32. package/Materials/Node/nodeMaterialConnectionPointCustomObject.d.ts +1 -1
  33. package/Materials/Node/nodeMaterialConnectionPointCustomObject.js +3 -1
  34. package/Materials/Node/nodeMaterialConnectionPointCustomObject.js.map +1 -1
  35. package/Materials/Textures/equiRectangularCubeTexture.d.ts +3 -1
  36. package/Materials/Textures/equiRectangularCubeTexture.js +3 -2
  37. package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
  38. package/Materials/Textures/hdrCubeTexture.d.ts +2 -1
  39. package/Materials/Textures/hdrCubeTexture.js +3 -2
  40. package/Materials/Textures/hdrCubeTexture.js.map +1 -1
  41. package/Materials/Textures/renderTargetTexture.js +1 -1
  42. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  43. package/Materials/material.js +1 -1
  44. package/Materials/material.js.map +1 -1
  45. package/Meshes/abstractMesh.js +4 -1
  46. package/Meshes/abstractMesh.js.map +1 -1
  47. package/Misc/HighDynamicRange/hdr.d.ts +1 -1
  48. package/Misc/HighDynamicRange/hdr.js +2 -2
  49. package/Misc/HighDynamicRange/hdr.js.map +1 -1
  50. package/Misc/HighDynamicRange/panoramaToCubemap.d.ts +1 -1
  51. package/Misc/HighDynamicRange/panoramaToCubemap.js +31 -23
  52. package/Misc/HighDynamicRange/panoramaToCubemap.js.map +1 -1
  53. package/Misc/dumpTools.js +1 -1
  54. package/Misc/dumpTools.js.map +1 -1
  55. package/Misc/tools.d.ts +5 -4
  56. package/Misc/tools.js +35 -6
  57. package/Misc/tools.js.map +1 -1
  58. package/Physics/v2/Plugins/havokPlugin.d.ts +4 -4
  59. package/Physics/v2/Plugins/havokPlugin.js +23 -5
  60. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  61. package/Physics/v2/physicsAggregate.d.ts +5 -1
  62. package/Physics/v2/physicsAggregate.js +4 -4
  63. package/Physics/v2/physicsAggregate.js.map +1 -1
  64. package/Physics/v2/physicsBody.d.ts +7 -2
  65. package/Physics/v2/physicsBody.js +5 -1
  66. package/Physics/v2/physicsBody.js.map +1 -1
  67. package/Rendering/prePassRenderer.d.ts +2 -0
  68. package/Rendering/prePassRenderer.js +12 -1
  69. package/Rendering/prePassRenderer.js.map +1 -1
  70. package/Shaders/ShadersInclude/screenSpaceRayTrace.js +1 -1
  71. package/Shaders/ShadersInclude/screenSpaceRayTrace.js.map +1 -1
  72. package/Shaders/glowMapGeneration.fragment.js +2 -2
  73. package/Shaders/glowMapGeneration.fragment.js.map +1 -1
  74. package/package.json +1 -1
  75. package/readme.md +2 -6
@@ -0,0 +1,199 @@
1
+ import { __decorate } from "../../../tslib.es6.js";
2
+ import { NodeMaterialBlock } from "../nodeMaterialBlock.js";
3
+ import { NodeMaterialBlockConnectionPointTypes } from "../Enums/nodeMaterialBlockConnectionPointTypes.js";
4
+ import { NodeMaterialBlockTargets } from "../Enums/nodeMaterialBlockTargets.js";
5
+ import { RegisterClass } from "../../../Misc/typeStore.js";
6
+ import { InputBlock } from "./Input/inputBlock.js";
7
+ import { MorphTargetsBlock } from "./Vertex/morphTargetsBlock.js";
8
+ import { PropertyTypeForEdition, editableInPropertyPage } from "../nodeMaterialDecorator.js";
9
+ export var MeshAttributeExistsBlockTypes;
10
+ (function (MeshAttributeExistsBlockTypes) {
11
+ MeshAttributeExistsBlockTypes[MeshAttributeExistsBlockTypes["None"] = 0] = "None";
12
+ MeshAttributeExistsBlockTypes[MeshAttributeExistsBlockTypes["Normal"] = 1] = "Normal";
13
+ MeshAttributeExistsBlockTypes[MeshAttributeExistsBlockTypes["Tangent"] = 2] = "Tangent";
14
+ MeshAttributeExistsBlockTypes[MeshAttributeExistsBlockTypes["VertexColor"] = 3] = "VertexColor";
15
+ MeshAttributeExistsBlockTypes[MeshAttributeExistsBlockTypes["UV1"] = 4] = "UV1";
16
+ MeshAttributeExistsBlockTypes[MeshAttributeExistsBlockTypes["UV2"] = 5] = "UV2";
17
+ MeshAttributeExistsBlockTypes[MeshAttributeExistsBlockTypes["UV3"] = 6] = "UV3";
18
+ MeshAttributeExistsBlockTypes[MeshAttributeExistsBlockTypes["UV4"] = 7] = "UV4";
19
+ MeshAttributeExistsBlockTypes[MeshAttributeExistsBlockTypes["UV5"] = 8] = "UV5";
20
+ MeshAttributeExistsBlockTypes[MeshAttributeExistsBlockTypes["UV6"] = 9] = "UV6";
21
+ })(MeshAttributeExistsBlockTypes || (MeshAttributeExistsBlockTypes = {}));
22
+ /**
23
+ * Block used to check if Mesh attribute of specified type exists
24
+ * and provide an alternative fallback input for to use in such case
25
+ */
26
+ export class MeshAttributeExistsBlock extends NodeMaterialBlock {
27
+ /**
28
+ * Creates a new MeshAttributeExistsBlock
29
+ * @param name defines the block name
30
+ */
31
+ constructor(name) {
32
+ super(name, NodeMaterialBlockTargets.Neutral);
33
+ /**
34
+ * Defines which mesh attribute to use
35
+ */
36
+ this.attributeType = MeshAttributeExistsBlockTypes.None;
37
+ this.registerInput("input", NodeMaterialBlockConnectionPointTypes.AutoDetect);
38
+ this.registerInput("fallback", NodeMaterialBlockConnectionPointTypes.AutoDetect);
39
+ this.registerOutput("output", NodeMaterialBlockConnectionPointTypes.BasedOnInput);
40
+ this._outputs[0]._typeConnectionSource = this._inputs[0];
41
+ this._linkConnectionTypes(0, 1);
42
+ // Try to auto determine attributeType
43
+ this._inputs[0].onConnectionObservable.add((other) => {
44
+ var _a;
45
+ if (this.attributeType) {
46
+ // But only if not already specified
47
+ return;
48
+ }
49
+ const sourceBlock = other.ownerBlock;
50
+ if (sourceBlock instanceof InputBlock && sourceBlock.isAttribute) {
51
+ switch (sourceBlock.name) {
52
+ case "color":
53
+ this.attributeType = MeshAttributeExistsBlockTypes.VertexColor;
54
+ break;
55
+ case "normal":
56
+ this.attributeType = MeshAttributeExistsBlockTypes.Normal;
57
+ break;
58
+ case "tangent":
59
+ this.attributeType = MeshAttributeExistsBlockTypes.Tangent;
60
+ break;
61
+ case "uv":
62
+ this.attributeType = MeshAttributeExistsBlockTypes.UV1;
63
+ break;
64
+ case "uv2":
65
+ this.attributeType = MeshAttributeExistsBlockTypes.UV2;
66
+ break;
67
+ case "uv3":
68
+ this.attributeType = MeshAttributeExistsBlockTypes.UV3;
69
+ break;
70
+ case "uv4":
71
+ this.attributeType = MeshAttributeExistsBlockTypes.UV4;
72
+ break;
73
+ case "uv5":
74
+ this.attributeType = MeshAttributeExistsBlockTypes.UV5;
75
+ break;
76
+ case "uv6":
77
+ this.attributeType = MeshAttributeExistsBlockTypes.UV6;
78
+ break;
79
+ }
80
+ }
81
+ else if (sourceBlock instanceof MorphTargetsBlock) {
82
+ switch ((_a = this.input.connectedPoint) === null || _a === void 0 ? void 0 : _a.name) {
83
+ case "normalOutput":
84
+ this.attributeType = MeshAttributeExistsBlockTypes.Normal;
85
+ break;
86
+ case "tangentOutput":
87
+ this.attributeType = MeshAttributeExistsBlockTypes.Tangent;
88
+ break;
89
+ case "uvOutput":
90
+ this.attributeType = MeshAttributeExistsBlockTypes.UV1;
91
+ break;
92
+ }
93
+ }
94
+ });
95
+ }
96
+ /**
97
+ * Gets the current class name
98
+ * @returns the class name
99
+ */
100
+ getClassName() {
101
+ return "MeshAttributeExistsBlock";
102
+ }
103
+ /**
104
+ * Gets the input component
105
+ */
106
+ get input() {
107
+ return this._inputs[0];
108
+ }
109
+ /**
110
+ * Gets the fallback component when speciefied attribute doesn't exist
111
+ */
112
+ get fallback() {
113
+ return this._inputs[1];
114
+ }
115
+ /**
116
+ * Gets the output component
117
+ */
118
+ get output() {
119
+ return this._outputs[0];
120
+ }
121
+ _buildBlock(state) {
122
+ super._buildBlock(state);
123
+ let attributeDefine = null;
124
+ switch (this.attributeType) {
125
+ case MeshAttributeExistsBlockTypes.VertexColor:
126
+ attributeDefine = "VERTEXCOLOR_NME";
127
+ break;
128
+ case MeshAttributeExistsBlockTypes.Normal:
129
+ attributeDefine = "NORMAL";
130
+ break;
131
+ case MeshAttributeExistsBlockTypes.Tangent:
132
+ attributeDefine = "TANGENT";
133
+ break;
134
+ case MeshAttributeExistsBlockTypes.UV1:
135
+ attributeDefine = "UV1";
136
+ break;
137
+ case MeshAttributeExistsBlockTypes.UV2:
138
+ attributeDefine = "UV2";
139
+ break;
140
+ case MeshAttributeExistsBlockTypes.UV3:
141
+ attributeDefine = "UV3";
142
+ break;
143
+ case MeshAttributeExistsBlockTypes.UV4:
144
+ attributeDefine = "UV4";
145
+ break;
146
+ case MeshAttributeExistsBlockTypes.UV5:
147
+ attributeDefine = "UV5";
148
+ break;
149
+ case MeshAttributeExistsBlockTypes.UV6:
150
+ attributeDefine = "UV6";
151
+ break;
152
+ }
153
+ const output = this._declareOutput(this.output, state);
154
+ if (attributeDefine) {
155
+ state.compilationString += `#ifdef ${attributeDefine}\r\n`;
156
+ }
157
+ state.compilationString += `${output} = ${this.input.associatedVariableName};\r\n`;
158
+ if (attributeDefine) {
159
+ state.compilationString += `#else\r\n`;
160
+ state.compilationString += `${output} = ${this.fallback.associatedVariableName};\r\n`;
161
+ state.compilationString += `#endif\r\n`;
162
+ }
163
+ return this;
164
+ }
165
+ serialize() {
166
+ const serializationObject = super.serialize();
167
+ serializationObject.attributeType = this.attributeType;
168
+ return serializationObject;
169
+ }
170
+ _deserialize(serializationObject, scene, rootUrl) {
171
+ var _a;
172
+ super._deserialize(serializationObject, scene, rootUrl);
173
+ this.attributeType = (_a = serializationObject.attributeType) !== null && _a !== void 0 ? _a : MeshAttributeExistsBlockTypes.None;
174
+ }
175
+ _dumpPropertiesCode() {
176
+ let codeString = super._dumpPropertiesCode();
177
+ codeString += `${this._codeVariableName}.attributeType = ${this.attributeType};\r\n`;
178
+ return codeString;
179
+ }
180
+ }
181
+ __decorate([
182
+ editableInPropertyPage("Attribute lookup", PropertyTypeForEdition.List, undefined, {
183
+ notifiers: { update: true },
184
+ options: [
185
+ { label: "(None)", value: MeshAttributeExistsBlockTypes.None },
186
+ { label: "Normal", value: MeshAttributeExistsBlockTypes.Normal },
187
+ { label: "Tangent", value: MeshAttributeExistsBlockTypes.Tangent },
188
+ { label: "Vertex Color", value: MeshAttributeExistsBlockTypes.VertexColor },
189
+ { label: "UV1", value: MeshAttributeExistsBlockTypes.UV1 },
190
+ { label: "UV2", value: MeshAttributeExistsBlockTypes.UV2 },
191
+ { label: "UV3", value: MeshAttributeExistsBlockTypes.UV3 },
192
+ { label: "UV4", value: MeshAttributeExistsBlockTypes.UV4 },
193
+ { label: "UV5", value: MeshAttributeExistsBlockTypes.UV5 },
194
+ { label: "UV6", value: MeshAttributeExistsBlockTypes.UV6 },
195
+ ],
196
+ })
197
+ ], MeshAttributeExistsBlock.prototype, "attributeType", void 0);
198
+ RegisterClass("BABYLON.MeshAttributeExistsBlock", MeshAttributeExistsBlock);
199
+ //# sourceMappingURL=meshAttributeExistsBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meshAttributeExistsBlock.js","sourceRoot":"","sources":["../../../../../../lts/core/generated/Materials/Node/Blocks/meshAttributeExistsBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAGvG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAG1F,MAAM,CAAN,IAAY,6BAWX;AAXD,WAAY,6BAA6B;IACrC,iFAAI,CAAA;IACJ,qFAAM,CAAA;IACN,uFAAO,CAAA;IACP,+FAAW,CAAA;IACX,+EAAG,CAAA;IACH,+EAAG,CAAA;IACH,+EAAG,CAAA;IACH,+EAAG,CAAA;IACH,+EAAG,CAAA;IACH,+EAAG,CAAA;AACP,CAAC,EAXW,6BAA6B,KAA7B,6BAA6B,QAWxC;AAED;;;GAGG;AACH,MAAM,OAAO,wBAAyB,SAAQ,iBAAiB;IAC3D;;;OAGG;IACH,YA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,EAAE;YAC1D,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,6BAA6B,CAAC,GAAG,EAAE;YAC1D,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,6BAA6B,CAAC,GAAG,EAAE;YAC1D,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,6BAA6B,CAAC,GAAG,EAAE;YAC1D,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,6BAA6B,CAAC,GAAG,EAAE;YAC1D,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,6BAA6B,CAAC,GAAG,EAAE;SAC7D;KACJ,CAAC;+DACwD;AA+F9D,aAAa,CAAC,kCAAkC,EAAE,wBAAwB,CAAC,CAAC","sourcesContent":["import { NodeMaterialBlock } from \"../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialBuildState } from \"../nodeMaterialBuildState\";\r\nimport type { NodeMaterialConnectionPoint } from \"../nodeMaterialBlockConnectionPoint\";\r\nimport { NodeMaterialBlockTargets } from \"../Enums/nodeMaterialBlockTargets\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { InputBlock } from \"./Input/inputBlock\";\r\nimport { MorphTargetsBlock } from \"./Vertex/morphTargetsBlock\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../nodeMaterialDecorator\";\r\nimport type { Scene } from \"core/scene\";\r\n\r\nexport enum MeshAttributeExistsBlockTypes {\r\n None,\r\n Normal,\r\n Tangent,\r\n VertexColor,\r\n UV1,\r\n UV2,\r\n UV3,\r\n UV4,\r\n UV5,\r\n UV6,\r\n}\r\n\r\n/**\r\n * Block used to check if Mesh attribute of specified type exists\r\n * and provide an alternative fallback input for to use in such case\r\n */\r\nexport class MeshAttributeExistsBlock extends NodeMaterialBlock {\r\n /**\r\n * Creates a new MeshAttributeExistsBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Neutral);\r\n\r\n this.registerInput(\"input\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"fallback\", NodeMaterialBlockConnectionPointTypes.AutoDetect);\r\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this._outputs[0]._typeConnectionSource = this._inputs[0];\r\n this._linkConnectionTypes(0, 1);\r\n\r\n // Try to auto determine attributeType\r\n this._inputs[0].onConnectionObservable.add((other) => {\r\n if (this.attributeType) {\r\n // But only if not already specified\r\n return;\r\n }\r\n const sourceBlock = other.ownerBlock;\r\n if (sourceBlock instanceof InputBlock && sourceBlock.isAttribute) {\r\n switch (sourceBlock.name) {\r\n case \"color\":\r\n this.attributeType = MeshAttributeExistsBlockTypes.VertexColor;\r\n break;\r\n case \"normal\":\r\n this.attributeType = MeshAttributeExistsBlockTypes.Normal;\r\n break;\r\n case \"tangent\":\r\n this.attributeType = MeshAttributeExistsBlockTypes.Tangent;\r\n break;\r\n case \"uv\":\r\n this.attributeType = MeshAttributeExistsBlockTypes.UV1;\r\n break;\r\n case \"uv2\":\r\n this.attributeType = MeshAttributeExistsBlockTypes.UV2;\r\n break;\r\n case \"uv3\":\r\n this.attributeType = MeshAttributeExistsBlockTypes.UV3;\r\n break;\r\n case \"uv4\":\r\n this.attributeType = MeshAttributeExistsBlockTypes.UV4;\r\n break;\r\n case \"uv5\":\r\n this.attributeType = MeshAttributeExistsBlockTypes.UV5;\r\n break;\r\n case \"uv6\":\r\n this.attributeType = MeshAttributeExistsBlockTypes.UV6;\r\n break;\r\n }\r\n } else if (sourceBlock instanceof MorphTargetsBlock) {\r\n switch (this.input.connectedPoint?.name) {\r\n case \"normalOutput\":\r\n this.attributeType = MeshAttributeExistsBlockTypes.Normal;\r\n break;\r\n case \"tangentOutput\":\r\n this.attributeType = MeshAttributeExistsBlockTypes.Tangent;\r\n break;\r\n case \"uvOutput\":\r\n this.attributeType = MeshAttributeExistsBlockTypes.UV1;\r\n break;\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public getClassName() {\r\n return \"MeshAttributeExistsBlock\";\r\n }\r\n\r\n /**\r\n * Defines which mesh attribute to use\r\n */\r\n @editableInPropertyPage(\"Attribute lookup\", PropertyTypeForEdition.List, undefined, {\r\n notifiers: { update: true },\r\n options: [\r\n { label: \"(None)\", value: MeshAttributeExistsBlockTypes.None },\r\n { label: \"Normal\", value: MeshAttributeExistsBlockTypes.Normal },\r\n { label: \"Tangent\", value: MeshAttributeExistsBlockTypes.Tangent },\r\n { label: \"Vertex Color\", value: MeshAttributeExistsBlockTypes.VertexColor },\r\n { label: \"UV1\", value: MeshAttributeExistsBlockTypes.UV1 },\r\n { label: \"UV2\", value: MeshAttributeExistsBlockTypes.UV2 },\r\n { label: \"UV3\", value: MeshAttributeExistsBlockTypes.UV3 },\r\n { label: \"UV4\", value: MeshAttributeExistsBlockTypes.UV4 },\r\n { label: \"UV5\", value: MeshAttributeExistsBlockTypes.UV5 },\r\n { label: \"UV6\", value: MeshAttributeExistsBlockTypes.UV6 },\r\n ],\r\n })\r\n public attributeType = MeshAttributeExistsBlockTypes.None;\r\n\r\n /**\r\n * Gets the input component\r\n */\r\n public get input(): NodeMaterialConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the fallback component when speciefied attribute doesn't exist\r\n */\r\n public get fallback(): NodeMaterialConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n let attributeDefine: null | string = null;\r\n switch (this.attributeType) {\r\n case MeshAttributeExistsBlockTypes.VertexColor:\r\n attributeDefine = \"VERTEXCOLOR_NME\";\r\n break;\r\n case MeshAttributeExistsBlockTypes.Normal:\r\n attributeDefine = \"NORMAL\";\r\n break;\r\n case MeshAttributeExistsBlockTypes.Tangent:\r\n attributeDefine = \"TANGENT\";\r\n break;\r\n case MeshAttributeExistsBlockTypes.UV1:\r\n attributeDefine = \"UV1\";\r\n break;\r\n case MeshAttributeExistsBlockTypes.UV2:\r\n attributeDefine = \"UV2\";\r\n break;\r\n case MeshAttributeExistsBlockTypes.UV3:\r\n attributeDefine = \"UV3\";\r\n break;\r\n case MeshAttributeExistsBlockTypes.UV4:\r\n attributeDefine = \"UV4\";\r\n break;\r\n case MeshAttributeExistsBlockTypes.UV5:\r\n attributeDefine = \"UV5\";\r\n break;\r\n case MeshAttributeExistsBlockTypes.UV6:\r\n attributeDefine = \"UV6\";\r\n break;\r\n }\r\n\r\n const output = this._declareOutput(this.output, state);\r\n if (attributeDefine) {\r\n state.compilationString += `#ifdef ${attributeDefine}\\r\\n`;\r\n }\r\n\r\n state.compilationString += `${output} = ${this.input.associatedVariableName};\\r\\n`;\r\n\r\n if (attributeDefine) {\r\n state.compilationString += `#else\\r\\n`;\r\n state.compilationString += `${output} = ${this.fallback.associatedVariableName};\\r\\n`;\r\n state.compilationString += `#endif\\r\\n`;\r\n }\r\n return this;\r\n }\r\n\r\n public serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.attributeType = this.attributeType;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public _deserialize(serializationObject: any, scene: Scene, rootUrl: string) {\r\n super._deserialize(serializationObject, scene, rootUrl);\r\n\r\n this.attributeType = serializationObject.attributeType ?? MeshAttributeExistsBlockTypes.None;\r\n }\r\n\r\n protected _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode();\r\n\r\n codeString += `${this._codeVariableName}.attributeType = ${this.attributeType};\\r\\n`;\r\n\r\n return codeString;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.MeshAttributeExistsBlock\", MeshAttributeExistsBlock);\r\n"]}
@@ -40,6 +40,7 @@ export interface INodeMaterialEditorOptions {
40
40
  export declare class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
41
41
  NORMAL: boolean;
42
42
  TANGENT: boolean;
43
+ VERTEXCOLOR_NME: boolean;
43
44
  UV1: boolean;
44
45
  UV2: boolean;
45
46
  UV3: boolean;
@@ -47,6 +47,7 @@ export class NodeMaterialDefines extends MaterialDefines {
47
47
  super();
48
48
  this.NORMAL = false;
49
49
  this.TANGENT = false;
50
+ this.VERTEXCOLOR_NME = false;
50
51
  this.UV1 = false;
51
52
  this.UV2 = false;
52
53
  this.UV3 = false;
@@ -599,15 +600,18 @@ export class NodeMaterial extends PushMaterial {
599
600
  _prepareDefinesForAttributes(mesh, defines) {
600
601
  const oldNormal = defines["NORMAL"];
601
602
  const oldTangent = defines["TANGENT"];
603
+ const oldColor = defines["VERTEXCOLOR_NME"];
602
604
  defines["NORMAL"] = mesh.isVerticesDataPresent(VertexBuffer.NormalKind);
603
605
  defines["TANGENT"] = mesh.isVerticesDataPresent(VertexBuffer.TangentKind);
606
+ const hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(VertexBuffer.ColorKind);
607
+ defines["VERTEXCOLOR_NME"] = hasVertexColors;
604
608
  let uvChanged = false;
605
609
  for (let i = 1; i <= 6; ++i) {
606
610
  const oldUV = defines["UV" + i];
607
611
  defines["UV" + i] = mesh.isVerticesDataPresent(`uv${i === 1 ? "" : i}`);
608
612
  uvChanged = uvChanged || defines["UV" + i] !== oldUV;
609
613
  }
610
- if (oldNormal !== defines["NORMAL"] || oldTangent !== defines["TANGENT"] || uvChanged) {
614
+ if (oldNormal !== defines["NORMAL"] || oldTangent !== defines["TANGENT"] || oldColor !== defines["VERTEXCOLOR_NME"] || uvChanged) {
611
615
  defines.markAsAttributesDirty();
612
616
  }
613
617
  }