@babylonjs/core 5.55.0 → 5.56.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.
@@ -231,7 +231,7 @@ export class Effect {
231
231
  migratedFragmentCode = processFinalCode("fragment", migratedFragmentCode);
232
232
  }
233
233
  const finalShaders = ShaderProcessor.Finalize(migratedVertexCode, migratedFragmentCode, processorOptions);
234
- processorOptions = null; // avoid some GC leaks because of code below (related to proxyFunction(name).bind(this))
234
+ processorOptions = null;
235
235
  this._useFinalCode(finalShaders.vertexCode, finalShaders.fragmentCode, baseName);
236
236
  }, this._engine);
237
237
  }
@@ -253,27 +253,6 @@ export class Effect {
253
253
  shaderCodes[1] = fragmentCode;
254
254
  shadersLoaded();
255
255
  });
256
- const proxyFunction = function (functionName) {
257
- // check if the function exists in the pipelineContext
258
- return function () {
259
- if (this._pipelineContext) {
260
- const func = this._pipelineContext[functionName];
261
- func.apply(this._pipelineContext, arguments);
262
- }
263
- return this;
264
- };
265
- };
266
- ["Int?", "UInt?", "IntArray?", "UIntArray?", "Array?", "Color?", "Vector?", "Float?", "Matrices", "Matrix", "Matrix3x3", "Matrix2x2", "Quaternion", "DirectColor4"].forEach((functionName) => {
267
- const name = `set${functionName}`;
268
- if (name.endsWith("?")) {
269
- ["", 2, 3, 4].forEach((n) => {
270
- this[(name.slice(0, -1) + n)] = this[(name.slice(0, -1) + n)] || proxyFunction(name.slice(0, -1) + n).bind(this);
271
- });
272
- }
273
- else {
274
- this[name] = this[name] || proxyFunction(name).bind(this);
275
- }
276
- });
277
256
  }
278
257
  _useFinalCode(migratedVertexCode, migratedFragmentCode, baseName) {
279
258
  if (baseName) {
@@ -809,6 +788,178 @@ export class Effect {
809
788
  bindUniformBlock(blockName, index) {
810
789
  this._engine.bindUniformBlock(this._pipelineContext, blockName, index);
811
790
  }
791
+ /**
792
+ * Sets an integer value on a uniform variable.
793
+ * @param uniformName Name of the variable.
794
+ * @param value Value to be set.
795
+ * @returns this effect.
796
+ */
797
+ setInt(uniformName, value) {
798
+ this._pipelineContext.setInt(uniformName, value);
799
+ return this;
800
+ }
801
+ /**
802
+ * Sets an int2 value on a uniform variable.
803
+ * @param uniformName Name of the variable.
804
+ * @param x First int in int2.
805
+ * @param y Second int in int2.
806
+ * @returns this effect.
807
+ */
808
+ setInt2(uniformName, x, y) {
809
+ this._pipelineContext.setInt2(uniformName, x, y);
810
+ return this;
811
+ }
812
+ /**
813
+ * Sets an int3 value on a uniform variable.
814
+ * @param uniformName Name of the variable.
815
+ * @param x First int in int3.
816
+ * @param y Second int in int3.
817
+ * @param z Third int in int3.
818
+ * @returns this effect.
819
+ */
820
+ setInt3(uniformName, x, y, z) {
821
+ this._pipelineContext.setInt3(uniformName, x, y, z);
822
+ return this;
823
+ }
824
+ /**
825
+ * Sets an int4 value on a uniform variable.
826
+ * @param uniformName Name of the variable.
827
+ * @param x First int in int4.
828
+ * @param y Second int in int4.
829
+ * @param z Third int in int4.
830
+ * @param w Fourth int in int4.
831
+ * @returns this effect.
832
+ */
833
+ setInt4(uniformName, x, y, z, w) {
834
+ this._pipelineContext.setInt4(uniformName, x, y, z, w);
835
+ return this;
836
+ }
837
+ /**
838
+ * Sets an int array on a uniform variable.
839
+ * @param uniformName Name of the variable.
840
+ * @param array array to be set.
841
+ * @returns this effect.
842
+ */
843
+ setIntArray(uniformName, array) {
844
+ this._pipelineContext.setIntArray(uniformName, array);
845
+ return this;
846
+ }
847
+ /**
848
+ * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
849
+ * @param uniformName Name of the variable.
850
+ * @param array array to be set.
851
+ * @returns this effect.
852
+ */
853
+ setIntArray2(uniformName, array) {
854
+ this._pipelineContext.setIntArray2(uniformName, array);
855
+ return this;
856
+ }
857
+ /**
858
+ * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
859
+ * @param uniformName Name of the variable.
860
+ * @param array array to be set.
861
+ * @returns this effect.
862
+ */
863
+ setIntArray3(uniformName, array) {
864
+ this._pipelineContext.setIntArray3(uniformName, array);
865
+ return this;
866
+ }
867
+ /**
868
+ * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
869
+ * @param uniformName Name of the variable.
870
+ * @param array array to be set.
871
+ * @returns this effect.
872
+ */
873
+ setIntArray4(uniformName, array) {
874
+ this._pipelineContext.setIntArray4(uniformName, array);
875
+ return this;
876
+ }
877
+ /**
878
+ * Sets an unsigned integer value on a uniform variable.
879
+ * @param uniformName Name of the variable.
880
+ * @param value Value to be set.
881
+ * @returns this effect.
882
+ */
883
+ setUInt(uniformName, value) {
884
+ this._pipelineContext.setInt(uniformName, value);
885
+ return this;
886
+ }
887
+ /**
888
+ * Sets an unsigned int2 value on a uniform variable.
889
+ * @param uniformName Name of the variable.
890
+ * @param x First unsigned int in uint2.
891
+ * @param y Second unsigned int in uint2.
892
+ * @returns this effect.
893
+ */
894
+ setUInt2(uniformName, x, y) {
895
+ this._pipelineContext.setInt2(uniformName, x, y);
896
+ return this;
897
+ }
898
+ /**
899
+ * Sets an unsigned int3 value on a uniform variable.
900
+ * @param uniformName Name of the variable.
901
+ * @param x First unsigned int in uint3.
902
+ * @param y Second unsigned int in uint3.
903
+ * @param z Third unsigned int in uint3.
904
+ * @returns this effect.
905
+ */
906
+ setUInt3(uniformName, x, y, z) {
907
+ this._pipelineContext.setInt3(uniformName, x, y, z);
908
+ return this;
909
+ }
910
+ /**
911
+ * Sets an unsigned int4 value on a uniform variable.
912
+ * @param uniformName Name of the variable.
913
+ * @param x First unsigned int in uint4.
914
+ * @param y Second unsigned int in uint4.
915
+ * @param z Third unsigned int in uint4.
916
+ * @param w Fourth unsigned int in uint4.
917
+ * @returns this effect.
918
+ */
919
+ setUInt4(uniformName, x, y, z, w) {
920
+ this._pipelineContext.setInt4(uniformName, x, y, z, w);
921
+ return this;
922
+ }
923
+ /**
924
+ * Sets an unsigned int array on a uniform variable.
925
+ * @param uniformName Name of the variable.
926
+ * @param array array to be set.
927
+ * @returns this effect.
928
+ */
929
+ setUIntArray(uniformName, array) {
930
+ this._pipelineContext.setUIntArray(uniformName, array);
931
+ return this;
932
+ }
933
+ /**
934
+ * Sets an unsigned int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
935
+ * @param uniformName Name of the variable.
936
+ * @param array array to be set.
937
+ * @returns this effect.
938
+ */
939
+ setUIntArray2(uniformName, array) {
940
+ this._pipelineContext.setUIntArray2(uniformName, array);
941
+ return this;
942
+ }
943
+ /**
944
+ * Sets an unsigned int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
945
+ * @param uniformName Name of the variable.
946
+ * @param array array to be set.
947
+ * @returns this effect.
948
+ */
949
+ setUIntArray3(uniformName, array) {
950
+ this._pipelineContext.setUIntArray3(uniformName, array);
951
+ return this;
952
+ }
953
+ /**
954
+ * Sets an unsigned int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
955
+ * @param uniformName Name of the variable.
956
+ * @param array array to be set.
957
+ * @returns this effect.
958
+ */
959
+ setUIntArray4(uniformName, array) {
960
+ this._pipelineContext.setUIntArray4(uniformName, array);
961
+ return this;
962
+ }
812
963
  /**
813
964
  * Sets an float array on a uniform variable.
814
965
  * @param uniformName Name of the variable.
@@ -849,6 +1000,98 @@ export class Effect {
849
1000
  this._pipelineContext.setArray4(uniformName, array);
850
1001
  return this;
851
1002
  }
1003
+ /**
1004
+ * Sets an array on a uniform variable.
1005
+ * @param uniformName Name of the variable.
1006
+ * @param array array to be set.
1007
+ * @returns this effect.
1008
+ */
1009
+ setArray(uniformName, array) {
1010
+ this._pipelineContext.setArray(uniformName, array);
1011
+ return this;
1012
+ }
1013
+ /**
1014
+ * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
1015
+ * @param uniformName Name of the variable.
1016
+ * @param array array to be set.
1017
+ * @returns this effect.
1018
+ */
1019
+ setArray2(uniformName, array) {
1020
+ this._pipelineContext.setArray2(uniformName, array);
1021
+ return this;
1022
+ }
1023
+ /**
1024
+ * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
1025
+ * @param uniformName Name of the variable.
1026
+ * @param array array to be set.
1027
+ * @returns this effect.
1028
+ */
1029
+ setArray3(uniformName, array) {
1030
+ this._pipelineContext.setArray3(uniformName, array);
1031
+ return this;
1032
+ }
1033
+ /**
1034
+ * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
1035
+ * @param uniformName Name of the variable.
1036
+ * @param array array to be set.
1037
+ * @returns this effect.
1038
+ */
1039
+ setArray4(uniformName, array) {
1040
+ this._pipelineContext.setArray4(uniformName, array);
1041
+ return this;
1042
+ }
1043
+ /**
1044
+ * Sets matrices on a uniform variable.
1045
+ * @param uniformName Name of the variable.
1046
+ * @param matrices matrices to be set.
1047
+ * @returns this effect.
1048
+ */
1049
+ setMatrices(uniformName, matrices) {
1050
+ this._pipelineContext.setMatrices(uniformName, matrices);
1051
+ return this;
1052
+ }
1053
+ /**
1054
+ * Sets matrix on a uniform variable.
1055
+ * @param uniformName Name of the variable.
1056
+ * @param matrix matrix to be set.
1057
+ * @returns this effect.
1058
+ */
1059
+ setMatrix(uniformName, matrix) {
1060
+ this._pipelineContext.setMatrix(uniformName, matrix);
1061
+ return this;
1062
+ }
1063
+ /**
1064
+ * Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
1065
+ * @param uniformName Name of the variable.
1066
+ * @param matrix matrix to be set.
1067
+ * @returns this effect.
1068
+ */
1069
+ setMatrix3x3(uniformName, matrix) {
1070
+ // the cast is ok because it is gl.uniformMatrix3fv() which is called at the end, and this function accepts Float32Array and Array<number>
1071
+ this._pipelineContext.setMatrix3x3(uniformName, matrix);
1072
+ return this;
1073
+ }
1074
+ /**
1075
+ * Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
1076
+ * @param uniformName Name of the variable.
1077
+ * @param matrix matrix to be set.
1078
+ * @returns this effect.
1079
+ */
1080
+ setMatrix2x2(uniformName, matrix) {
1081
+ // the cast is ok because it is gl.uniformMatrix3fv() which is called at the end, and this function accepts Float32Array and Array<number>
1082
+ this._pipelineContext.setMatrix2x2(uniformName, matrix);
1083
+ return this;
1084
+ }
1085
+ /**
1086
+ * Sets a float on a uniform variable.
1087
+ * @param uniformName Name of the variable.
1088
+ * @param value value to be set.
1089
+ * @returns this effect.
1090
+ */
1091
+ setFloat(uniformName, value) {
1092
+ this._pipelineContext.setFloat(uniformName, value);
1093
+ return this;
1094
+ }
852
1095
  /**
853
1096
  * Sets a boolean on a uniform variable.
854
1097
  * @param uniformName Name of the variable.
@@ -859,12 +1102,120 @@ export class Effect {
859
1102
  this._pipelineContext.setInt(uniformName, bool ? 1 : 0);
860
1103
  return this;
861
1104
  }
1105
+ /**
1106
+ * Sets a Vector2 on a uniform variable.
1107
+ * @param uniformName Name of the variable.
1108
+ * @param vector2 vector2 to be set.
1109
+ * @returns this effect.
1110
+ */
1111
+ setVector2(uniformName, vector2) {
1112
+ this._pipelineContext.setVector2(uniformName, vector2);
1113
+ return this;
1114
+ }
1115
+ /**
1116
+ * Sets a float2 on a uniform variable.
1117
+ * @param uniformName Name of the variable.
1118
+ * @param x First float in float2.
1119
+ * @param y Second float in float2.
1120
+ * @returns this effect.
1121
+ */
1122
+ setFloat2(uniformName, x, y) {
1123
+ this._pipelineContext.setFloat2(uniformName, x, y);
1124
+ return this;
1125
+ }
1126
+ /**
1127
+ * Sets a Vector3 on a uniform variable.
1128
+ * @param uniformName Name of the variable.
1129
+ * @param vector3 Value to be set.
1130
+ * @returns this effect.
1131
+ */
1132
+ setVector3(uniformName, vector3) {
1133
+ this._pipelineContext.setVector3(uniformName, vector3);
1134
+ return this;
1135
+ }
1136
+ /**
1137
+ * Sets a float3 on a uniform variable.
1138
+ * @param uniformName Name of the variable.
1139
+ * @param x First float in float3.
1140
+ * @param y Second float in float3.
1141
+ * @param z Third float in float3.
1142
+ * @returns this effect.
1143
+ */
1144
+ setFloat3(uniformName, x, y, z) {
1145
+ this._pipelineContext.setFloat3(uniformName, x, y, z);
1146
+ return this;
1147
+ }
1148
+ /**
1149
+ * Sets a Vector4 on a uniform variable.
1150
+ * @param uniformName Name of the variable.
1151
+ * @param vector4 Value to be set.
1152
+ * @returns this effect.
1153
+ */
1154
+ setVector4(uniformName, vector4) {
1155
+ this._pipelineContext.setVector4(uniformName, vector4);
1156
+ return this;
1157
+ }
1158
+ /**
1159
+ * Sets a Quaternion on a uniform variable.
1160
+ * @param uniformName Name of the variable.
1161
+ * @param quaternion Value to be set.
1162
+ * @returns this effect.
1163
+ */
1164
+ setQuaternion(uniformName, quaternion) {
1165
+ this._pipelineContext.setQuaternion(uniformName, quaternion);
1166
+ return this;
1167
+ }
1168
+ /**
1169
+ * Sets a float4 on a uniform variable.
1170
+ * @param uniformName Name of the variable.
1171
+ * @param x First float in float4.
1172
+ * @param y Second float in float4.
1173
+ * @param z Third float in float4.
1174
+ * @param w Fourth float in float4.
1175
+ * @returns this effect.
1176
+ */
1177
+ setFloat4(uniformName, x, y, z, w) {
1178
+ this._pipelineContext.setFloat4(uniformName, x, y, z, w);
1179
+ return this;
1180
+ }
1181
+ /**
1182
+ * Sets a Color3 on a uniform variable.
1183
+ * @param uniformName Name of the variable.
1184
+ * @param color3 Value to be set.
1185
+ * @returns this effect.
1186
+ */
1187
+ setColor3(uniformName, color3) {
1188
+ this._pipelineContext.setColor3(uniformName, color3);
1189
+ return this;
1190
+ }
1191
+ /**
1192
+ * Sets a Color4 on a uniform variable.
1193
+ * @param uniformName Name of the variable.
1194
+ * @param color3 Value to be set.
1195
+ * @param alpha Alpha value to be set.
1196
+ * @returns this effect.
1197
+ */
1198
+ setColor4(uniformName, color3, alpha) {
1199
+ this._pipelineContext.setColor4(uniformName, color3, alpha);
1200
+ return this;
1201
+ }
1202
+ /**
1203
+ * Sets a Color4 on a uniform variable
1204
+ * @param uniformName defines the name of the variable
1205
+ * @param color4 defines the value to be set
1206
+ * @returns this effect.
1207
+ */
1208
+ setDirectColor4(uniformName, color4) {
1209
+ this._pipelineContext.setDirectColor4(uniformName, color4);
1210
+ return this;
1211
+ }
862
1212
  /**
863
1213
  * Release all associated resources.
864
1214
  **/
865
1215
  dispose() {
866
- var _a;
867
- (_a = this._pipelineContext) === null || _a === void 0 ? void 0 : _a.dispose();
1216
+ if (this._pipelineContext) {
1217
+ this._pipelineContext.dispose();
1218
+ }
868
1219
  this._engine._releaseEffect(this);
869
1220
  this._isDisposed = true;
870
1221
  }