@xeokit/xeokit-sdk 2.3.0-beta-31 → 2.3.0-beta-32

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.
@@ -57891,7 +57891,7 @@ class TrianglesBatchingColorTextureRenderer {
57891
57891
 
57892
57892
  _getHash() {
57893
57893
  const scene = this._scene;
57894
- return [scene._lightsState.getHash(), scene._sectionPlanesState.getHash(), (this._withSAO ? "sao" : "nosao")].join(";");
57894
+ return [scene.gammaOutput, scene._lightsState.getHash(), scene._sectionPlanesState.getHash(), (this._withSAO ? "sao" : "nosao")].join(";");
57895
57895
  }
57896
57896
 
57897
57897
  drawLayer(frameCtx, batchingLayer, renderPass) {
@@ -58028,6 +58028,8 @@ class TrianglesBatchingColorTextureRenderer {
58028
58028
  this._uViewMatrix = program.getLocation("viewMatrix");
58029
58029
  this._uProjMatrix = program.getLocation("projMatrix");
58030
58030
 
58031
+ this._uGammaFactor = program.getLocation("gammaFactor");
58032
+
58031
58033
  this._uLightAmbient = program.getLocation("lightAmbient");
58032
58034
  this._uLightColor = [];
58033
58035
  this._uLightDir = [];
@@ -58125,6 +58127,10 @@ class TrianglesBatchingColorTextureRenderer {
58125
58127
  const logDepthBufFC = 2.0 / (Math.log(project.far + 1.0) / Math.LN2);
58126
58128
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
58127
58129
  }
58130
+
58131
+ if (this._uGammaFactor) {
58132
+ gl.uniform1f(this._uGammaFactor, scene.gammaFactor);
58133
+ }
58128
58134
  }
58129
58135
 
58130
58136
  _buildShader() {
@@ -58215,6 +58221,7 @@ class TrianglesBatchingColorTextureRenderer {
58215
58221
 
58216
58222
  _buildFragmentShader() {
58217
58223
  const scene = this._scene;
58224
+ const gammaOutput = scene.gammaOutput; // If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
58218
58225
  const lightsState = scene._lightsState;
58219
58226
  const sectionPlanesState = scene._sectionPlanesState;
58220
58227
  const clipping = sectionPlanesState.sectionPlanes.length > 0;
@@ -58249,6 +58256,21 @@ class TrianglesBatchingColorTextureRenderer {
58249
58256
  src.push(" return dot( v, unPackFactors );");
58250
58257
  src.push("}");
58251
58258
  }
58259
+ src.push("uniform float gammaFactor;");
58260
+ src.push("vec4 linearToLinear( in vec4 value ) {");
58261
+ src.push(" return value;");
58262
+ src.push("}");
58263
+ src.push("vec4 sRGBToLinear( in vec4 value ) {");
58264
+ src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");
58265
+ src.push("}");
58266
+ src.push("vec4 gammaToLinear( in vec4 value) {");
58267
+ src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");
58268
+ src.push("}");
58269
+ if (gammaOutput) {
58270
+ src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");
58271
+ src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");
58272
+ src.push("}");
58273
+ }
58252
58274
  if (clipping) {
58253
58275
  src.push("in vec4 vWorldPosition;");
58254
58276
  src.push("in vec4 vFlags2;");
@@ -58341,7 +58363,11 @@ class TrianglesBatchingColorTextureRenderer {
58341
58363
  }
58342
58364
 
58343
58365
  src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
58344
- src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
58366
+ if (gammaOutput) {
58367
+ src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");
58368
+ } else {
58369
+ src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
58370
+ }
58345
58371
  src.push("float opacity = color.a;");
58346
58372
 
58347
58373
  if (this._withSAO) {
@@ -58359,6 +58385,10 @@ class TrianglesBatchingColorTextureRenderer {
58359
58385
  src.push(" outColor = vec4(colorTexel.rgb, opacity);");
58360
58386
  }
58361
58387
 
58388
+ if (gammaOutput) {
58389
+ src.push("outColor = linearToGamma(outColor, gammaFactor);");
58390
+ }
58391
+
58362
58392
  if (scene.logarithmicDepthBufferEnabled) {
58363
58393
  src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
58364
58394
  }
@@ -65817,7 +65847,7 @@ class TrianglesInstancingColorTextureRenderer {
65817
65847
 
65818
65848
  _getHash() {
65819
65849
  const scene = this._scene;
65820
- return [scene._lightsState.getHash(), scene._sectionPlanesState.getHash(), (this._withSAO ? "sao" : "nosao")].join(";");
65850
+ return [scene.gammaOutput, scene._lightsState.getHash(), scene._sectionPlanesState.getHash(), (this._withSAO ? "sao" : "nosao")].join(";");
65821
65851
  }
65822
65852
 
65823
65853
  drawLayer(frameCtx, instancingLayer, renderPass) {
@@ -65974,6 +66004,8 @@ class TrianglesInstancingColorTextureRenderer {
65974
66004
  this._uViewMatrix = program.getLocation("viewMatrix");
65975
66005
  this._uProjMatrix = program.getLocation("projMatrix");
65976
66006
 
66007
+ this._uGammaFactor = program.getLocation("gammaFactor");
66008
+
65977
66009
  this._uLightAmbient = program.getLocation("lightAmbient");
65978
66010
  this._uLightColor = [];
65979
66011
  this._uLightDir = [];
@@ -66073,6 +66105,10 @@ class TrianglesInstancingColorTextureRenderer {
66073
66105
  const logDepthBufFC = 2.0 / (Math.log(project.far + 1.0) / Math.LN2);
66074
66106
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
66075
66107
  }
66108
+
66109
+ if (this._uGammaFactor) {
66110
+ gl.uniform1f(this._uGammaFactor, scene.gammaFactor);
66111
+ }
66076
66112
  }
66077
66113
 
66078
66114
  _buildShader() {
@@ -66169,6 +66205,7 @@ class TrianglesInstancingColorTextureRenderer {
66169
66205
 
66170
66206
  _buildFragmentShader() {
66171
66207
  const scene = this._scene;
66208
+ const gammaOutput = scene.gammaOutput; // If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
66172
66209
  const sectionPlanesState = scene._sectionPlanesState;
66173
66210
  const lightsState = scene._lightsState;
66174
66211
  let i;
@@ -66204,7 +66241,21 @@ class TrianglesInstancingColorTextureRenderer {
66204
66241
  src.push(" return dot( v, unPackFactors );");
66205
66242
  src.push("}");
66206
66243
  }
66207
-
66244
+ src.push("uniform float gammaFactor;");
66245
+ src.push("vec4 linearToLinear( in vec4 value ) {");
66246
+ src.push(" return value;");
66247
+ src.push("}");
66248
+ src.push("vec4 sRGBToLinear( in vec4 value ) {");
66249
+ src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");
66250
+ src.push("}");
66251
+ src.push("vec4 gammaToLinear( in vec4 value) {");
66252
+ src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");
66253
+ src.push("}");
66254
+ if (gammaOutput) {
66255
+ src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");
66256
+ src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");
66257
+ src.push("}");
66258
+ }
66208
66259
  if (clipping) {
66209
66260
  src.push("in vec4 vWorldPosition;");
66210
66261
  src.push("in vec4 vFlags2;");
@@ -66296,7 +66347,11 @@ class TrianglesInstancingColorTextureRenderer {
66296
66347
  }
66297
66348
 
66298
66349
  src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
66299
- src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
66350
+ if (gammaOutput) {
66351
+ src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");
66352
+ } else {
66353
+ src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
66354
+ }
66300
66355
  src.push("float opacity = color.a;");
66301
66356
 
66302
66357
  if (this._withSAO) {
@@ -66313,6 +66368,10 @@ class TrianglesInstancingColorTextureRenderer {
66313
66368
  src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb, opacity);");
66314
66369
  }
66315
66370
 
66371
+ if (gammaOutput) {
66372
+ src.push("outColor = linearToGamma(outColor, gammaFactor);");
66373
+ }
66374
+
66316
66375
  if (scene.logarithmicDepthBufferEnabled) {
66317
66376
  src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
66318
66377
  }
@@ -79829,6 +79888,7 @@ class VBOSceneModel extends Component {
79829
79888
  const image = new Image();
79830
79889
  image.onload = () => {
79831
79890
  texture.setImage(image, {minFilter, magFilter, wrapS, wrapT, flipY: cfg.flipY, encoding});
79891
+ this.glRedraw();
79832
79892
  };
79833
79893
  image.src = cfg.src; // URL or Base64 string
79834
79894
  break;
@@ -57887,7 +57887,7 @@ class TrianglesBatchingColorTextureRenderer {
57887
57887
 
57888
57888
  _getHash() {
57889
57889
  const scene = this._scene;
57890
- return [scene._lightsState.getHash(), scene._sectionPlanesState.getHash(), (this._withSAO ? "sao" : "nosao")].join(";");
57890
+ return [scene.gammaOutput, scene._lightsState.getHash(), scene._sectionPlanesState.getHash(), (this._withSAO ? "sao" : "nosao")].join(";");
57891
57891
  }
57892
57892
 
57893
57893
  drawLayer(frameCtx, batchingLayer, renderPass) {
@@ -58024,6 +58024,8 @@ class TrianglesBatchingColorTextureRenderer {
58024
58024
  this._uViewMatrix = program.getLocation("viewMatrix");
58025
58025
  this._uProjMatrix = program.getLocation("projMatrix");
58026
58026
 
58027
+ this._uGammaFactor = program.getLocation("gammaFactor");
58028
+
58027
58029
  this._uLightAmbient = program.getLocation("lightAmbient");
58028
58030
  this._uLightColor = [];
58029
58031
  this._uLightDir = [];
@@ -58121,6 +58123,10 @@ class TrianglesBatchingColorTextureRenderer {
58121
58123
  const logDepthBufFC = 2.0 / (Math.log(project.far + 1.0) / Math.LN2);
58122
58124
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
58123
58125
  }
58126
+
58127
+ if (this._uGammaFactor) {
58128
+ gl.uniform1f(this._uGammaFactor, scene.gammaFactor);
58129
+ }
58124
58130
  }
58125
58131
 
58126
58132
  _buildShader() {
@@ -58211,6 +58217,7 @@ class TrianglesBatchingColorTextureRenderer {
58211
58217
 
58212
58218
  _buildFragmentShader() {
58213
58219
  const scene = this._scene;
58220
+ const gammaOutput = scene.gammaOutput; // If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
58214
58221
  const lightsState = scene._lightsState;
58215
58222
  const sectionPlanesState = scene._sectionPlanesState;
58216
58223
  const clipping = sectionPlanesState.sectionPlanes.length > 0;
@@ -58245,6 +58252,21 @@ class TrianglesBatchingColorTextureRenderer {
58245
58252
  src.push(" return dot( v, unPackFactors );");
58246
58253
  src.push("}");
58247
58254
  }
58255
+ src.push("uniform float gammaFactor;");
58256
+ src.push("vec4 linearToLinear( in vec4 value ) {");
58257
+ src.push(" return value;");
58258
+ src.push("}");
58259
+ src.push("vec4 sRGBToLinear( in vec4 value ) {");
58260
+ src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");
58261
+ src.push("}");
58262
+ src.push("vec4 gammaToLinear( in vec4 value) {");
58263
+ src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");
58264
+ src.push("}");
58265
+ if (gammaOutput) {
58266
+ src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");
58267
+ src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");
58268
+ src.push("}");
58269
+ }
58248
58270
  if (clipping) {
58249
58271
  src.push("in vec4 vWorldPosition;");
58250
58272
  src.push("in vec4 vFlags2;");
@@ -58337,7 +58359,11 @@ class TrianglesBatchingColorTextureRenderer {
58337
58359
  }
58338
58360
 
58339
58361
  src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
58340
- src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
58362
+ if (gammaOutput) {
58363
+ src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");
58364
+ } else {
58365
+ src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
58366
+ }
58341
58367
  src.push("float opacity = color.a;");
58342
58368
 
58343
58369
  if (this._withSAO) {
@@ -58355,6 +58381,10 @@ class TrianglesBatchingColorTextureRenderer {
58355
58381
  src.push(" outColor = vec4(colorTexel.rgb, opacity);");
58356
58382
  }
58357
58383
 
58384
+ if (gammaOutput) {
58385
+ src.push("outColor = linearToGamma(outColor, gammaFactor);");
58386
+ }
58387
+
58358
58388
  if (scene.logarithmicDepthBufferEnabled) {
58359
58389
  src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
58360
58390
  }
@@ -65813,7 +65843,7 @@ class TrianglesInstancingColorTextureRenderer {
65813
65843
 
65814
65844
  _getHash() {
65815
65845
  const scene = this._scene;
65816
- return [scene._lightsState.getHash(), scene._sectionPlanesState.getHash(), (this._withSAO ? "sao" : "nosao")].join(";");
65846
+ return [scene.gammaOutput, scene._lightsState.getHash(), scene._sectionPlanesState.getHash(), (this._withSAO ? "sao" : "nosao")].join(";");
65817
65847
  }
65818
65848
 
65819
65849
  drawLayer(frameCtx, instancingLayer, renderPass) {
@@ -65970,6 +66000,8 @@ class TrianglesInstancingColorTextureRenderer {
65970
66000
  this._uViewMatrix = program.getLocation("viewMatrix");
65971
66001
  this._uProjMatrix = program.getLocation("projMatrix");
65972
66002
 
66003
+ this._uGammaFactor = program.getLocation("gammaFactor");
66004
+
65973
66005
  this._uLightAmbient = program.getLocation("lightAmbient");
65974
66006
  this._uLightColor = [];
65975
66007
  this._uLightDir = [];
@@ -66069,6 +66101,10 @@ class TrianglesInstancingColorTextureRenderer {
66069
66101
  const logDepthBufFC = 2.0 / (Math.log(project.far + 1.0) / Math.LN2);
66070
66102
  gl.uniform1f(this._uLogDepthBufFC, logDepthBufFC);
66071
66103
  }
66104
+
66105
+ if (this._uGammaFactor) {
66106
+ gl.uniform1f(this._uGammaFactor, scene.gammaFactor);
66107
+ }
66072
66108
  }
66073
66109
 
66074
66110
  _buildShader() {
@@ -66165,6 +66201,7 @@ class TrianglesInstancingColorTextureRenderer {
66165
66201
 
66166
66202
  _buildFragmentShader() {
66167
66203
  const scene = this._scene;
66204
+ const gammaOutput = scene.gammaOutput; // If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
66168
66205
  const sectionPlanesState = scene._sectionPlanesState;
66169
66206
  const lightsState = scene._lightsState;
66170
66207
  let i;
@@ -66200,7 +66237,21 @@ class TrianglesInstancingColorTextureRenderer {
66200
66237
  src.push(" return dot( v, unPackFactors );");
66201
66238
  src.push("}");
66202
66239
  }
66203
-
66240
+ src.push("uniform float gammaFactor;");
66241
+ src.push("vec4 linearToLinear( in vec4 value ) {");
66242
+ src.push(" return value;");
66243
+ src.push("}");
66244
+ src.push("vec4 sRGBToLinear( in vec4 value ) {");
66245
+ src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");
66246
+ src.push("}");
66247
+ src.push("vec4 gammaToLinear( in vec4 value) {");
66248
+ src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");
66249
+ src.push("}");
66250
+ if (gammaOutput) {
66251
+ src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");
66252
+ src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");
66253
+ src.push("}");
66254
+ }
66204
66255
  if (clipping) {
66205
66256
  src.push("in vec4 vWorldPosition;");
66206
66257
  src.push("in vec4 vFlags2;");
@@ -66292,7 +66343,11 @@ class TrianglesInstancingColorTextureRenderer {
66292
66343
  }
66293
66344
 
66294
66345
  src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");
66295
- src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
66346
+ if (gammaOutput) {
66347
+ src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");
66348
+ } else {
66349
+ src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");
66350
+ }
66296
66351
  src.push("float opacity = color.a;");
66297
66352
 
66298
66353
  if (this._withSAO) {
@@ -66309,6 +66364,10 @@ class TrianglesInstancingColorTextureRenderer {
66309
66364
  src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb, opacity);");
66310
66365
  }
66311
66366
 
66367
+ if (gammaOutput) {
66368
+ src.push("outColor = linearToGamma(outColor, gammaFactor);");
66369
+ }
66370
+
66312
66371
  if (scene.logarithmicDepthBufferEnabled) {
66313
66372
  src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");
66314
66373
  }
@@ -79825,6 +79884,7 @@ class VBOSceneModel extends Component {
79825
79884
  const image = new Image();
79826
79885
  image.onload = () => {
79827
79886
  texture.setImage(image, {minFilter, magFilter, wrapS, wrapT, flipY: cfg.flipY, encoding});
79887
+ this.glRedraw();
79828
79888
  };
79829
79889
  image.src = cfg.src; // URL or Base64 string
79830
79890
  break;
@@ -16258,12 +16258,13 @@ gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,batchingLayer._state.posi
16258
16258
  src.push("if (int(flags.w) != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
16259
16259
  src.push(" } else {");src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vWorldPosition = worldPosition;");if(clipping){src.push(" vFlags2 = flags2;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching pick flat normals fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("in vec4 vWorldPosition;");if(clipping){src.push("in vec4 vFlags2;");for(var i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push("uniform bool sectionPlaneActive"+i+";");src.push("uniform vec3 sectionPlanePos"+i+";");src.push("uniform vec3 sectionPlaneDir"+i+";");}}src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (float(vFlags2.x) > 0.0);");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push(" vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push(" vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push(" outColor = vec4((worldNormal * 0.5) + 0.5, 1.0);");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesBatchingPickNormalsFlatRenderer;}();var tempVec4$4=math.vec4();var tempVec3a$H=math.vec3();/**
16260
16260
  * @private
16261
- */var TrianglesBatchingColorTextureRenderer=/*#__PURE__*/function(){function TrianglesBatchingColorTextureRenderer(scene,withSAO){_classCallCheck(this,TrianglesBatchingColorTextureRenderer);this._scene=scene;this._withSAO=withSAO;this._hash=this._getHash();this._allocate();}_createClass(TrianglesBatchingColorTextureRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,batchingLayer,renderPass){var maxTextureUnits=WEBGL_INFO.MAX_TEXTURE_IMAGE_UNITS;var scene=this._scene;var camera=scene.camera;var model=batchingLayer.model;var gl=scene.canvas.gl;var state=batchingLayer._state;var origin=batchingLayer._state.origin;var textureSet=state.textureSet;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uViewMatrix,false,origin?createRTCViewMat(camera.viewMatrix,origin):camera.viewMatrix);gl.uniformMatrix4fv(this._uWorldMatrix,false,model.worldMatrix);var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=batchingLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$H);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,state.positionsDecodeMatrix);if(this._uUVDecodeMatrix){gl.uniformMatrix3fv(this._uUVDecodeMatrix,false,state.uvDecodeMatrix);}this._aPosition.bindArrayBuffer(state.positionsBuf);if(this._aUV){this._aUV.bindArrayBuffer(state.uvBuf);}if(this._aColor){this._aColor.bindArrayBuffer(state.colorsBuf);}if(this._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);}if(this._aFlags2){this._aFlags2.bindArrayBuffer(state.flags2Buf);}if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);}if(textureSet){if(textureSet.colorTexture){this._program.bindTexture(this._uColorMap,textureSet.colorTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}}if(this._withSAO){var sao=scene.sao;var saoEnabled=sao.possible;if(saoEnabled){var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;tempVec4$4[0]=viewportWidth;tempVec4$4[1]=viewportHeight;tempVec4$4[2]=sao.blendCutoff;tempVec4$4[3]=sao.blendFactor;gl.uniform4fv(this._uSAOParams,tempVec4$4);this._program.bindTexture(this._uOcclusionTexture,frameCtx.occlusionTexture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}}state.indicesBuf.bind();gl.drawElements(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0);frameCtx.drawElements++;}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uUVDecodeMatrix=program.getLocation("uvDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uLightAmbient=program.getLocation("lightAmbient");this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];var lights=lightsState.lights;var light;for(var _i191=0,len=lights.length;_i191<len;_i191++){light=lights[_i191];switch(light.type){case"dir":this._uLightColor[_i191]=program.getLocation("lightColor"+_i191);this._uLightPos[_i191]=null;this._uLightDir[_i191]=program.getLocation("lightDir"+_i191);break;case"point":this._uLightColor[_i191]=program.getLocation("lightColor"+_i191);this._uLightPos[_i191]=program.getLocation("lightPos"+_i191);this._uLightDir[_i191]=null;this._uLightAttenuation[_i191]=program.getLocation("lightAttenuation"+_i191);break;case"spot":this._uLightColor[_i191]=program.getLocation("lightColor"+_i191);this._uLightPos[_i191]=program.getLocation("lightPos"+_i191);this._uLightDir[_i191]=program.getLocation("lightDir"+_i191);this._uLightAttenuation[_i191]=program.getLocation("lightAttenuation"+_i191);break;}}this._uSectionPlanes=[];for(var _i192=0,_len31=scene._sectionPlanesState.sectionPlanes.length;_i192<_len31;_i192++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i192),pos:program.getLocation("sectionPlanePos"+_i192),dir:program.getLocation("sectionPlaneDir"+_i192)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aUV=program.getAttribute("uv");this._aColor=program.getAttribute("color");this._aFlags=program.getAttribute("flags");this._aFlags2=program.getAttribute("flags2");this._uColorMap="uColorMap";if(this._withSAO){this._uOcclusionTexture="uOcclusionTexture";this._uSAOParams=program.getLocation("uSAOParams");}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var lightsState=scene._lightsState;var lights=lightsState.lights;var project=scene.camera.project;program.bind();gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,scene._lightsState.getAmbientColorAndIntensity());}for(var _i193=0,len=lights.length;_i193<len;_i193++){var light=lights[_i193];if(this._uLightColor[_i193]){gl.uniform4f(this._uLightColor[_i193],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i193]){gl.uniform3fv(this._uLightPos[_i193],light.pos);if(this._uLightAttenuation[_i193]){gl.uniform1f(this._uLightAttenuation[_i193],light.attenuation);}}if(this._uLightDir[_i193]){gl.uniform3fv(this._uLightDir[_i193],light.dir);}}if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching color texture vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in vec2 uv;");src.push("in vec4 flags;");src.push("in vec4 flags2;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 positionsDecodeMatrix;");src.push("uniform mat3 uvDecodeMatrix;");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out vec4 vFlags2;");}src.push("out vec4 vViewPosition;");src.push("out vec4 vColor;");src.push("out vec2 vUV;");src.push("void main(void) {");// flags.x = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
16261
+ */var TrianglesBatchingColorTextureRenderer=/*#__PURE__*/function(){function TrianglesBatchingColorTextureRenderer(scene,withSAO){_classCallCheck(this,TrianglesBatchingColorTextureRenderer);this._scene=scene;this._withSAO=withSAO;this._hash=this._getHash();this._allocate();}_createClass(TrianglesBatchingColorTextureRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene.gammaOutput,scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,batchingLayer,renderPass){var maxTextureUnits=WEBGL_INFO.MAX_TEXTURE_IMAGE_UNITS;var scene=this._scene;var camera=scene.camera;var model=batchingLayer.model;var gl=scene.canvas.gl;var state=batchingLayer._state;var origin=batchingLayer._state.origin;var textureSet=state.textureSet;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uViewMatrix,false,origin?createRTCViewMat(camera.viewMatrix,origin):camera.viewMatrix);gl.uniformMatrix4fv(this._uWorldMatrix,false,model.worldMatrix);var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=batchingLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$H);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,state.positionsDecodeMatrix);if(this._uUVDecodeMatrix){gl.uniformMatrix3fv(this._uUVDecodeMatrix,false,state.uvDecodeMatrix);}this._aPosition.bindArrayBuffer(state.positionsBuf);if(this._aUV){this._aUV.bindArrayBuffer(state.uvBuf);}if(this._aColor){this._aColor.bindArrayBuffer(state.colorsBuf);}if(this._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);}if(this._aFlags2){this._aFlags2.bindArrayBuffer(state.flags2Buf);}if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);}if(textureSet){if(textureSet.colorTexture){this._program.bindTexture(this._uColorMap,textureSet.colorTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}}if(this._withSAO){var sao=scene.sao;var saoEnabled=sao.possible;if(saoEnabled){var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;tempVec4$4[0]=viewportWidth;tempVec4$4[1]=viewportHeight;tempVec4$4[2]=sao.blendCutoff;tempVec4$4[3]=sao.blendFactor;gl.uniform4fv(this._uSAOParams,tempVec4$4);this._program.bindTexture(this._uOcclusionTexture,frameCtx.occlusionTexture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}}state.indicesBuf.bind();gl.drawElements(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0);frameCtx.drawElements++;}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uUVDecodeMatrix=program.getLocation("uvDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uGammaFactor=program.getLocation("gammaFactor");this._uLightAmbient=program.getLocation("lightAmbient");this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];var lights=lightsState.lights;var light;for(var _i191=0,len=lights.length;_i191<len;_i191++){light=lights[_i191];switch(light.type){case"dir":this._uLightColor[_i191]=program.getLocation("lightColor"+_i191);this._uLightPos[_i191]=null;this._uLightDir[_i191]=program.getLocation("lightDir"+_i191);break;case"point":this._uLightColor[_i191]=program.getLocation("lightColor"+_i191);this._uLightPos[_i191]=program.getLocation("lightPos"+_i191);this._uLightDir[_i191]=null;this._uLightAttenuation[_i191]=program.getLocation("lightAttenuation"+_i191);break;case"spot":this._uLightColor[_i191]=program.getLocation("lightColor"+_i191);this._uLightPos[_i191]=program.getLocation("lightPos"+_i191);this._uLightDir[_i191]=program.getLocation("lightDir"+_i191);this._uLightAttenuation[_i191]=program.getLocation("lightAttenuation"+_i191);break;}}this._uSectionPlanes=[];for(var _i192=0,_len31=scene._sectionPlanesState.sectionPlanes.length;_i192<_len31;_i192++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i192),pos:program.getLocation("sectionPlanePos"+_i192),dir:program.getLocation("sectionPlaneDir"+_i192)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aUV=program.getAttribute("uv");this._aColor=program.getAttribute("color");this._aFlags=program.getAttribute("flags");this._aFlags2=program.getAttribute("flags2");this._uColorMap="uColorMap";if(this._withSAO){this._uOcclusionTexture="uOcclusionTexture";this._uSAOParams=program.getLocation("uSAOParams");}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var lightsState=scene._lightsState;var lights=lightsState.lights;var project=scene.camera.project;program.bind();gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,scene._lightsState.getAmbientColorAndIntensity());}for(var _i193=0,len=lights.length;_i193<len;_i193++){var light=lights[_i193];if(this._uLightColor[_i193]){gl.uniform4f(this._uLightColor[_i193],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i193]){gl.uniform3fv(this._uLightPos[_i193],light.pos);if(this._uLightAttenuation[_i193]){gl.uniform1f(this._uLightAttenuation[_i193],light.attenuation);}}if(this._uLightDir[_i193]){gl.uniform3fv(this._uLightDir[_i193],light.dir);}}if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching color texture vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in vec2 uv;");src.push("in vec4 flags;");src.push("in vec4 flags2;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 positionsDecodeMatrix;");src.push("uniform mat3 uvDecodeMatrix;");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out vec4 vFlags2;");}src.push("out vec4 vViewPosition;");src.push("out vec4 vColor;");src.push("out vec2 vUV;");src.push("void main(void) {");// flags.x = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
16262
16262
  // renderPass = COLOR_OPAQUE
16263
16263
  src.push("if (int(flags.x) != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
16264
- src.push("} else {");src.push("vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");if(scene.entityOffsetsEnabled){src.push("worldPosition.xyz = worldPosition.xyz + offset;");}src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vViewPosition = viewPosition;");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var lightsState=scene._lightsState;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching color texture fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform sampler2D uColorMap;");if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in vec4 vFlags2;");for(var _i194=0,len=sectionPlanesState.sectionPlanes.length;_i194<len;_i194++){src.push("uniform bool sectionPlaneActive"+_i194+";");src.push("uniform vec3 sectionPlanePos"+_i194+";");src.push("uniform vec3 sectionPlaneDir"+_i194+";");}}src.push("uniform mat4 viewMatrix;");src.push("uniform vec4 lightAmbient;");for(var _i195=0,_len32=lightsState.lights.length;_i195<_len32;_i195++){var light=lightsState.lights[_i195];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i195+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i195+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i195+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i195+";");src.push("uniform vec3 lightDir"+_i195+";");}}src.push("in vec4 vViewPosition;");src.push("in vec4 vColor;");src.push("in vec2 vUV;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (float(vFlags2.x) > 0.0);");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i196=0,_len33=sectionPlanesState.sectionPlanes.length;_i196<_len33;_i196++){src.push("if (sectionPlaneActive"+_i196+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i196+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i196+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");for(var _i197=0,_len34=lightsState.lights.length;_i197<_len34;_i197++){var _light6=lightsState.lights[_i197];if(_light6.type==="ambient"){continue;}if(_light6.type==="dir"){if(_light6.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i197+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i197+", 0.0)).xyz);");}}else if(_light6.type==="point"){if(_light6.space==="view"){src.push("viewLightDir = -normalize(lightPos"+_i197+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+_i197+", 0.0)).xyz);");}}else if(_light6.type==="spot"){if(_light6.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i197+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i197+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i197+".rgb * lightColor"+_i197+".a);");}src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");src.push("float opacity = color.a;");if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
16264
+ src.push("} else {");src.push("vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");if(scene.entityOffsetsEnabled){src.push("worldPosition.xyz = worldPosition.xyz + offset;");}src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vViewPosition = viewPosition;");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var gammaOutput=scene.gammaOutput;// If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
16265
+ var lightsState=scene._lightsState;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Triangles batching color texture fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform sampler2D uColorMap;");if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}src.push("uniform float gammaFactor;");src.push("vec4 linearToLinear( in vec4 value ) {");src.push(" return value;");src.push("}");src.push("vec4 sRGBToLinear( in vec4 value ) {");src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");src.push("}");src.push("vec4 gammaToLinear( in vec4 value) {");src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");src.push("}");if(gammaOutput){src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in vec4 vFlags2;");for(var _i194=0,len=sectionPlanesState.sectionPlanes.length;_i194<len;_i194++){src.push("uniform bool sectionPlaneActive"+_i194+";");src.push("uniform vec3 sectionPlanePos"+_i194+";");src.push("uniform vec3 sectionPlaneDir"+_i194+";");}}src.push("uniform mat4 viewMatrix;");src.push("uniform vec4 lightAmbient;");for(var _i195=0,_len32=lightsState.lights.length;_i195<_len32;_i195++){var light=lightsState.lights[_i195];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i195+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i195+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i195+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i195+";");src.push("uniform vec3 lightDir"+_i195+";");}}src.push("in vec4 vViewPosition;");src.push("in vec4 vColor;");src.push("in vec2 vUV;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (float(vFlags2.x) > 0.0);");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i196=0,_len33=sectionPlanesState.sectionPlanes.length;_i196<_len33;_i196++){src.push("if (sectionPlaneActive"+_i196+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i196+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i196+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");for(var _i197=0,_len34=lightsState.lights.length;_i197<_len34;_i197++){var _light6=lightsState.lights[_i197];if(_light6.type==="ambient"){continue;}if(_light6.type==="dir"){if(_light6.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i197+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i197+", 0.0)).xyz);");}}else if(_light6.type==="point"){if(_light6.space==="view"){src.push("viewLightDir = -normalize(lightPos"+_i197+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+_i197+", 0.0)).xyz);");}}else if(_light6.type==="spot"){if(_light6.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i197+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i197+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i197+".rgb * lightColor"+_i197+".a);");}src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");if(gammaOutput){src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");}else{src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");}src.push("float opacity = color.a;");if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
16265
16266
  // Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
16266
- src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(colorTexel.rgb * ambient, opacity);");}else{src.push(" outColor = vec4(colorTexel.rgb, opacity);");}if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesBatchingColorTextureRenderer;}();/**
16267
+ src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(colorTexel.rgb * ambient, opacity);");}else{src.push(" outColor = vec4(colorTexel.rgb, opacity);");}if(gammaOutput){src.push("outColor = linearToGamma(outColor, gammaFactor);");}if(scene.logarithmicDepthBufferEnabled){src.push("gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesBatchingColorTextureRenderer;}();/**
16267
16268
  * @private
16268
16269
  */var TrianglesBatchingRenderers=/*#__PURE__*/function(){function TrianglesBatchingRenderers(scene){_classCallCheck(this,TrianglesBatchingRenderers);this._scene=scene;}_createClass(TrianglesBatchingRenderers,[{key:"_compile",value:function _compile(){if(this._colorRenderer&&!this._colorRenderer.getValid()){this._colorRenderer.destroy();this._colorRenderer=null;}if(this._colorRendererWithSAO&&!this._colorRendererWithSAO.getValid()){this._colorRendererWithSAO.destroy();this._colorRendererWithSAO=null;}if(this._flatColorRenderer&&!this._flatColorRenderer.getValid()){this._flatColorRenderer.destroy();this._flatColorRenderer=null;}if(this._flatColorRendererWithSAO&&!this._flatColorRendererWithSAO.getValid()){this._flatColorRendererWithSAO.destroy();this._flatColorRendererWithSAO=null;}if(this._colorTextureRenderer&&!this._colorTextureRenderer.getValid()){this._colorTextureRenderer.destroy();this._colorTextureRenderer=null;}if(this._colorTextureRendererWithSAO&&!this._colorTextureRendererWithSAO.getValid()){this._colorTextureRendererWithSAO.destroy();this._colorTextureRendererWithSAO=null;}if(this._pbrRenderer&&!this._pbrRenderer.getValid()){this._pbrRenderer.destroy();this._pbrRenderer=null;}if(this._pbrRendererWithSAO&&!this._pbrRendererWithSAO.getValid()){this._pbrRendererWithSAO.destroy();this._pbrRendererWithSAO=null;}if(this._depthRenderer&&!this._depthRenderer.getValid()){this._depthRenderer.destroy();this._depthRenderer=null;}if(this._normalsRenderer&&!this._normalsRenderer.getValid()){this._normalsRenderer.destroy();this._normalsRenderer=null;}if(this._silhouetteRenderer&&!this._silhouetteRenderer.getValid()){this._silhouetteRenderer.destroy();this._silhouetteRenderer=null;}if(this._edgesRenderer&&!this._edgesRenderer.getValid()){this._edgesRenderer.destroy();this._edgesRenderer=null;}if(this._edgesColorRenderer&&!this._edgesColorRenderer.getValid()){this._edgesColorRenderer.destroy();this._edgesColorRenderer=null;}if(this._pickMeshRenderer&&!this._pickMeshRenderer.getValid()){this._pickMeshRenderer.destroy();this._pickMeshRenderer=null;}if(this._pickDepthRenderer&&!this._pickDepthRenderer.getValid()){this._pickDepthRenderer.destroy();this._pickDepthRenderer=null;}if(this._pickNormalsRenderer&&this._pickNormalsRenderer.getValid()===false){this._pickNormalsRenderer.destroy();this._pickNormalsRenderer=null;}if(this._pickNormalsFlatRenderer&&this._pickNormalsFlatRenderer.getValid()===false){this._pickNormalsFlatRenderer.destroy();this._pickNormalsFlatRenderer=null;}if(this._occlusionRenderer&&this._occlusionRenderer.getValid()===false){this._occlusionRenderer.destroy();this._occlusionRenderer=null;}if(this._shadowRenderer&&!this._shadowRenderer.getValid()){this._shadowRenderer.destroy();this._shadowRenderer=null;}}},{key:"colorRenderer",get:function get(){if(!this._colorRenderer){this._colorRenderer=new TrianglesBatchingColorRenderer(this._scene,false);}return this._colorRenderer;}},{key:"colorRendererWithSAO",get:function get(){if(!this._colorRendererWithSAO){this._colorRendererWithSAO=new TrianglesBatchingColorRenderer(this._scene,true);}return this._colorRendererWithSAO;}},{key:"flatColorRenderer",get:function get(){if(!this._flatColorRenderer){this._flatColorRenderer=new TrianglesBatchingFlatColorRenderer(this._scene,false);}return this._flatColorRenderer;}},{key:"flatColorRendererWithSAO",get:function get(){if(!this._flatColorRendererWithSAO){this._flatColorRendererWithSAO=new TrianglesBatchingFlatColorRenderer(this._scene,true);}return this._flatColorRendererWithSAO;}},{key:"colorTextureRenderer",get:function get(){if(!this._colorTextureRenderer){this._colorTextureRenderer=new TrianglesBatchingColorTextureRenderer(this._scene,false);}return this._colorTextureRenderer;}},{key:"colorTextureRendererWithSAO",get:function get(){if(!this._colorTextureRendererWithSAO){this._colorTextureRendererWithSAO=new TrianglesBatchingColorTextureRenderer(this._scene,true);}return this._colorTextureRendererWithSAO;}},{key:"pbrRenderer",get:function get(){if(!this._pbrRenderer){this._pbrRenderer=new TrianglesBatchingPBRRenderer(this._scene,false);}return this._pbrRenderer;}},{key:"pbrRendererWithSAO",get:function get(){if(!this._pbrRendererWithSAO){this._pbrRendererWithSAO=new TrianglesBatchingPBRRenderer(this._scene,true);}return this._pbrRendererWithSAO;}},{key:"silhouetteRenderer",get:function get(){if(!this._silhouetteRenderer){this._silhouetteRenderer=new TrianglesBatchingSilhouetteRenderer(this._scene);}return this._silhouetteRenderer;}},{key:"depthRenderer",get:function get(){if(!this._depthRenderer){this._depthRenderer=new TrianglesBatchingDepthRenderer(this._scene);}return this._depthRenderer;}},{key:"normalsRenderer",get:function get(){if(!this._normalsRenderer){this._normalsRenderer=new TrianglesBatchingNormalsRenderer(this._scene);}return this._normalsRenderer;}},{key:"edgesRenderer",get:function get(){if(!this._edgesRenderer){this._edgesRenderer=new TrianglesBatchingEdgesRenderer(this._scene);}return this._edgesRenderer;}},{key:"edgesColorRenderer",get:function get(){if(!this._edgesColorRenderer){this._edgesColorRenderer=new TrianglesBatchingEdgesColorRenderer(this._scene);}return this._edgesColorRenderer;}},{key:"pickMeshRenderer",get:function get(){if(!this._pickMeshRenderer){this._pickMeshRenderer=new TrianglesBatchingPickMeshRenderer(this._scene);}return this._pickMeshRenderer;}},{key:"pickNormalsRenderer",get:function get(){if(!this._pickNormalsRenderer){this._pickNormalsRenderer=new TrianglesBatchingPickNormalsRenderer(this._scene);}return this._pickNormalsRenderer;}},{key:"pickNormalsFlatRenderer",get:function get(){if(!this._pickNormalsFlatRenderer){this._pickNormalsFlatRenderer=new TrianglesBatchingPickNormalsFlatRenderer(this._scene);}return this._pickNormalsFlatRenderer;}},{key:"pickDepthRenderer",get:function get(){if(!this._pickDepthRenderer){this._pickDepthRenderer=new TrianglesBatchingPickDepthRenderer(this._scene);}return this._pickDepthRenderer;}},{key:"occlusionRenderer",get:function get(){if(!this._occlusionRenderer){this._occlusionRenderer=new TrianglesBatchingOcclusionRenderer(this._scene);}return this._occlusionRenderer;}},{key:"shadowRenderer",get:function get(){if(!this._shadowRenderer){this._shadowRenderer=new TrianglesBatchingShadowRenderer(this._scene);}return this._shadowRenderer;}},{key:"_destroy",value:function _destroy(){if(this._colorRenderer){this._colorRenderer.destroy();}if(this._colorRendererWithSAO){this._colorRendererWithSAO.destroy();}if(this._flatColorRenderer){this._flatColorRenderer.destroy();}if(this._flatColorRendererWithSAO){this._flatColorRendererWithSAO.destroy();}if(this._colorTextureRenderer){this._colorTextureRenderer.destroy();}if(this._colorTextureRendererWithSAO){this._colorTextureRendererWithSAO.destroy();}if(this._pbrRenderer){this._pbrRenderer.destroy();}if(this._pbrRendererWithSAO){this._pbrRendererWithSAO.destroy();}if(this._depthRenderer){this._depthRenderer.destroy();}if(this._normalsRenderer){this._normalsRenderer.destroy();}if(this._silhouetteRenderer){this._silhouetteRenderer.destroy();}if(this._edgesRenderer){this._edgesRenderer.destroy();}if(this._edgesColorRenderer){this._edgesColorRenderer.destroy();}if(this._pickMeshRenderer){this._pickMeshRenderer.destroy();}if(this._pickDepthRenderer){this._pickDepthRenderer.destroy();}if(this._pickNormalsRenderer){this._pickNormalsRenderer.destroy();}if(this._pickNormalsFlatRenderer){this._pickNormalsFlatRenderer.destroy();}if(this._occlusionRenderer){this._occlusionRenderer.destroy();}if(this._shadowRenderer){this._shadowRenderer.destroy();}}}]);return TrianglesBatchingRenderers;}();var cachdRenderers={};/**
16269
16270
  * @private
@@ -16527,14 +16528,15 @@ src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.pu
16527
16528
  src.push("if (int(flags.w) != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
16528
16529
  src.push("} else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vWorldPosition = worldPosition;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Batched geometry normals fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("in vec4 vWorldPosition;");if(clipping){src.push("in vec4 vFlags2;");for(var _i266=0;_i266<sectionPlanesState.sectionPlanes.length;_i266++){src.push("uniform bool sectionPlaneActive"+_i266+";");src.push("uniform vec3 sectionPlanePos"+_i266+";");src.push("uniform vec3 sectionPlaneDir"+_i266+";");}}src.push("in vec3 vWorldNormal;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (float(vFlags2.x) > 0.0);");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.sectionPlanes.length;i++){src.push("if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push(" vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push(" vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push(" outColor = vec4((worldNormal * 0.5) + 0.5, 1.0);");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesInstancingPickNormalsFlatRenderer;}();var tempVec4=math.vec4();var tempVec3a$r=math.vec3();/**
16529
16530
  * @private
16530
- */var TrianglesInstancingColorTextureRenderer=/*#__PURE__*/function(){function TrianglesInstancingColorTextureRenderer(scene,withSAO){_classCallCheck(this,TrianglesInstancingColorTextureRenderer);this._scene=scene;this._withSAO=withSAO;this._hash=this._getHash();this._allocate();}_createClass(TrianglesInstancingColorTextureRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,instancingLayer,renderPass){var maxTextureUnits=WEBGL_INFO.MAX_TEXTURE_IMAGE_UNITS;var model=instancingLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=instancingLayer._state;var geometry=state.geometry;var origin=instancingLayer._state.origin;var textureSet=state.textureSet;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uViewMatrix,false,origin?createRTCViewMat(camera.viewMatrix,origin):camera.viewMatrix);gl.uniformMatrix4fv(this._uWorldMatrix,false,model.worldMatrix);var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=instancingLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$r);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometry.positionsDecodeMatrix);if(this._uUVDecodeMatrix){gl.uniformMatrix3fv(this._uUVDecodeMatrix,false,geometry.uvDecodeMatrix);}this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelMatrixCol0.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,1);this._aPosition.bindArrayBuffer(geometry.positionsBuf);this._aUV.bindArrayBuffer(geometry.uvBuf);this._aColor.bindArrayBuffer(state.colorsBuf);gl.vertexAttribDivisor(this._aColor.location,1);this._aFlags.bindArrayBuffer(state.flagsBuf);gl.vertexAttribDivisor(this._aFlags.location,1);if(this._aFlags2){this._aFlags2.bindArrayBuffer(state.flags2Buf);gl.vertexAttribDivisor(this._aFlags2.location,1);}if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);gl.vertexAttribDivisor(this._aOffset.location,1);}geometry.indicesBuf.bind();gl.drawElementsInstanced(gl.TRIANGLES,geometry.indicesBuf.numItems,geometry.indicesBuf.itemType,0,state.numInstances);frameCtx.drawElements++;gl.vertexAttribDivisor(this._aModelMatrixCol0.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,0);gl.vertexAttribDivisor(this._aColor.location,0);gl.vertexAttribDivisor(this._aFlags.location,0);if(this._aFlags2){// Won't be in shader when not clipping
16531
- gl.vertexAttribDivisor(this._aFlags2.location,0);}if(this._aOffset){gl.vertexAttribDivisor(this._aOffset.location,0);}if(textureSet){if(textureSet.colorTexture){this._program.bindTexture(this._uColorMap,textureSet.colorTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}}if(this._withSAO){var sao=scene.sao;var saoEnabled=sao.possible;if(saoEnabled){var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;tempVec4[0]=viewportWidth;tempVec4[1]=viewportHeight;tempVec4[2]=sao.blendCutoff;tempVec4[3]=sao.blendFactor;gl.uniform4fv(this._uSAOParams,tempVec4);this._program.bindTexture(this._uOcclusionTexture,frameCtx.occlusionTexture,0);}}}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uUVDecodeMatrix=program.getLocation("uvDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uLightAmbient=program.getLocation("lightAmbient");this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];var lights=lightsState.lights;var light;for(var _i267=0,len=lights.length;_i267<len;_i267++){light=lights[_i267];switch(light.type){case"dir":this._uLightColor[_i267]=program.getLocation("lightColor"+_i267);this._uLightPos[_i267]=null;this._uLightDir[_i267]=program.getLocation("lightDir"+_i267);break;case"point":this._uLightColor[_i267]=program.getLocation("lightColor"+_i267);this._uLightPos[_i267]=program.getLocation("lightPos"+_i267);this._uLightDir[_i267]=null;this._uLightAttenuation[_i267]=program.getLocation("lightAttenuation"+_i267);break;case"spot":this._uLightColor[_i267]=program.getLocation("lightColor"+_i267);this._uLightPos[_i267]=program.getLocation("lightPos"+_i267);this._uLightDir[_i267]=program.getLocation("lightDir"+_i267);this._uLightAttenuation[_i267]=program.getLocation("lightAttenuation"+_i267);break;}}this._uSectionPlanes=[];for(var _i268=0,_len60=scene._sectionPlanesState.sectionPlanes.length;_i268<_len60;_i268++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i268),pos:program.getLocation("sectionPlanePos"+_i268),dir:program.getLocation("sectionPlaneDir"+_i268)});}this._aPosition=program.getAttribute("position");this._aColor=program.getAttribute("color");this._aUV=program.getAttribute("uv");this._aFlags=program.getAttribute("flags");this._aFlags2=program.getAttribute("flags2");this._aOffset=program.getAttribute("offset");this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");this._uColorMap="uColorMap";this._uOcclusionTexture="uOcclusionTexture";this._uSAOParams=program.getLocation("uSAOParams");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;var lights=lightsState.lights;var project=scene.camera.project;this._program.bind();gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,scene._lightsState.getAmbientColorAndIntensity());}for(var _i269=0,len=lights.length;_i269<len;_i269++){var light=lights[_i269];if(this._uLightColor[_i269]){gl.uniform4f(this._uLightColor[_i269],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i269]){gl.uniform3fv(this._uLightPos[_i269],light.pos);if(this._uLightAttenuation[_i269]){gl.uniform1f(this._uLightAttenuation[_i269],light.attenuation);}}if(this._uLightDir[_i269]){gl.uniform3fv(this._uLightDir[_i269],light.dir);}}if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry drawing vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in vec2 uv;");src.push("in vec4 flags;");src.push("in vec4 flags2;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 modelMatrixCol0;");// Modeling matrix
16531
+ */var TrianglesInstancingColorTextureRenderer=/*#__PURE__*/function(){function TrianglesInstancingColorTextureRenderer(scene,withSAO){_classCallCheck(this,TrianglesInstancingColorTextureRenderer);this._scene=scene;this._withSAO=withSAO;this._hash=this._getHash();this._allocate();}_createClass(TrianglesInstancingColorTextureRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene.gammaOutput,scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,instancingLayer,renderPass){var maxTextureUnits=WEBGL_INFO.MAX_TEXTURE_IMAGE_UNITS;var model=instancingLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=instancingLayer._state;var geometry=state.geometry;var origin=instancingLayer._state.origin;var textureSet=state.textureSet;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uViewMatrix,false,origin?createRTCViewMat(camera.viewMatrix,origin):camera.viewMatrix);gl.uniformMatrix4fv(this._uWorldMatrix,false,model.worldMatrix);var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=instancingLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$r);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}}}gl.uniformMatrix4fv(this._uPositionsDecodeMatrix,false,geometry.positionsDecodeMatrix);if(this._uUVDecodeMatrix){gl.uniformMatrix3fv(this._uUVDecodeMatrix,false,geometry.uvDecodeMatrix);}this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelMatrixCol0.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,1);this._aPosition.bindArrayBuffer(geometry.positionsBuf);this._aUV.bindArrayBuffer(geometry.uvBuf);this._aColor.bindArrayBuffer(state.colorsBuf);gl.vertexAttribDivisor(this._aColor.location,1);this._aFlags.bindArrayBuffer(state.flagsBuf);gl.vertexAttribDivisor(this._aFlags.location,1);if(this._aFlags2){this._aFlags2.bindArrayBuffer(state.flags2Buf);gl.vertexAttribDivisor(this._aFlags2.location,1);}if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);gl.vertexAttribDivisor(this._aOffset.location,1);}geometry.indicesBuf.bind();gl.drawElementsInstanced(gl.TRIANGLES,geometry.indicesBuf.numItems,geometry.indicesBuf.itemType,0,state.numInstances);frameCtx.drawElements++;gl.vertexAttribDivisor(this._aModelMatrixCol0.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,0);gl.vertexAttribDivisor(this._aColor.location,0);gl.vertexAttribDivisor(this._aFlags.location,0);if(this._aFlags2){// Won't be in shader when not clipping
16532
+ gl.vertexAttribDivisor(this._aFlags2.location,0);}if(this._aOffset){gl.vertexAttribDivisor(this._aOffset.location,0);}if(textureSet){if(textureSet.colorTexture){this._program.bindTexture(this._uColorMap,textureSet.colorTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}}if(this._withSAO){var sao=scene.sao;var saoEnabled=sao.possible;if(saoEnabled){var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;tempVec4[0]=viewportWidth;tempVec4[1]=viewportHeight;tempVec4[2]=sao.blendCutoff;tempVec4[3]=sao.blendFactor;gl.uniform4fv(this._uSAOParams,tempVec4);this._program.bindTexture(this._uOcclusionTexture,frameCtx.occlusionTexture,0);}}}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uPositionsDecodeMatrix=program.getLocation("positionsDecodeMatrix");this._uUVDecodeMatrix=program.getLocation("uvDecodeMatrix");this._uWorldMatrix=program.getLocation("worldMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uGammaFactor=program.getLocation("gammaFactor");this._uLightAmbient=program.getLocation("lightAmbient");this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];var lights=lightsState.lights;var light;for(var _i267=0,len=lights.length;_i267<len;_i267++){light=lights[_i267];switch(light.type){case"dir":this._uLightColor[_i267]=program.getLocation("lightColor"+_i267);this._uLightPos[_i267]=null;this._uLightDir[_i267]=program.getLocation("lightDir"+_i267);break;case"point":this._uLightColor[_i267]=program.getLocation("lightColor"+_i267);this._uLightPos[_i267]=program.getLocation("lightPos"+_i267);this._uLightDir[_i267]=null;this._uLightAttenuation[_i267]=program.getLocation("lightAttenuation"+_i267);break;case"spot":this._uLightColor[_i267]=program.getLocation("lightColor"+_i267);this._uLightPos[_i267]=program.getLocation("lightPos"+_i267);this._uLightDir[_i267]=program.getLocation("lightDir"+_i267);this._uLightAttenuation[_i267]=program.getLocation("lightAttenuation"+_i267);break;}}this._uSectionPlanes=[];for(var _i268=0,_len60=scene._sectionPlanesState.sectionPlanes.length;_i268<_len60;_i268++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i268),pos:program.getLocation("sectionPlanePos"+_i268),dir:program.getLocation("sectionPlaneDir"+_i268)});}this._aPosition=program.getAttribute("position");this._aColor=program.getAttribute("color");this._aUV=program.getAttribute("uv");this._aFlags=program.getAttribute("flags");this._aFlags2=program.getAttribute("flags2");this._aOffset=program.getAttribute("offset");this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");this._uColorMap="uColorMap";this._uOcclusionTexture="uOcclusionTexture";this._uSAOParams=program.getLocation("uSAOParams");if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;var lights=lightsState.lights;var project=scene.camera.project;this._program.bind();gl.uniformMatrix4fv(this._uProjMatrix,false,project.matrix);if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,scene._lightsState.getAmbientColorAndIntensity());}for(var _i269=0,len=lights.length;_i269<len;_i269++){var light=lights[_i269];if(this._uLightColor[_i269]){gl.uniform4f(this._uLightColor[_i269],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i269]){gl.uniform3fv(this._uLightPos[_i269],light.pos);if(this._uLightAttenuation[_i269]){gl.uniform1f(this._uLightAttenuation[_i269],light.attenuation);}}if(this._uLightDir[_i269]){gl.uniform3fv(this._uLightDir[_i269],light.dir);}}if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry drawing vertex shader");src.push("uniform int renderPass;");src.push("in vec3 position;");src.push("in vec4 color;");src.push("in vec2 uv;");src.push("in vec4 flags;");src.push("in vec4 flags2;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in vec4 modelMatrixCol0;");// Modeling matrix
16532
16533
  src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform mat4 worldMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform mat4 positionsDecodeMatrix;");src.push("uniform mat3 uvDecodeMatrix;");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}if(clipping){src.push("out vec4 vWorldPosition;");src.push("out vec4 vFlags2;");}src.push("out vec4 vViewPosition;");src.push("out vec4 vColor;");src.push("out vec2 vUV;");src.push("void main(void) {");// flags.x = NOT_RENDERED | COLOR_OPAQUE | COLOR_TRANSPARENT
16533
16534
  // renderPass = COLOR_OPAQUE | COLOR_TRANSPARENT
16534
16535
  src.push("if (int(flags.x) != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
16535
- src.push("} else {");src.push("vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push("worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vViewPosition = viewPosition;");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var lightsState=scene._lightsState;var i;var len;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform sampler2D uColorMap;");if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in vec4 vFlags2;");for(var _i270=0,_len61=sectionPlanesState.sectionPlanes.length;_i270<_len61;_i270++){src.push("uniform bool sectionPlaneActive"+_i270+";");src.push("uniform vec3 sectionPlanePos"+_i270+";");src.push("uniform vec3 sectionPlaneDir"+_i270+";");}}src.push("uniform mat4 viewMatrix;");src.push("uniform vec4 lightAmbient;");for(i=0,len=lightsState.lights.length;i<len;i++){var light=lightsState.lights[i];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+i+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+i+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+i+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+i+";");src.push("uniform vec3 lightDir"+i+";");}}src.push("in vec4 vViewPosition;");src.push("in vec4 vColor;");src.push("in vec2 vUV;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (float(vFlags2.x) > 0.0);");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i271=0,_len62=sectionPlanesState.sectionPlanes.length;_i271<_len62;_i271++){src.push("if (sectionPlaneActive"+_i271+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i271+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i271+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");for(i=0,len=lightsState.lights.length;i<len;i++){var _light9=lightsState.lights[i];if(_light9.type==="ambient"){continue;}if(_light9.type==="dir"){if(_light9.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else if(_light9.type==="point"){if(_light9.space==="view"){src.push("viewLightDir = -normalize(lightPos"+i+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+i+", 0.0)).xyz);");}}else if(_light9.type==="spot"){if(_light9.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+i+".rgb * lightColor"+i+".a);");}src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");src.push("float opacity = color.a;");if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
16536
+ src.push("} else {");src.push("vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push("worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vViewPosition = viewPosition;");src.push("vColor = vec4(float(color.r) / 255.0, float(color.g) / 255.0, float(color.b) / 255.0, float(color.a) / 255.0);");src.push("vUV = (uvDecodeMatrix * vec3(uv, 1.0)).xy;");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var gammaOutput=scene.gammaOutput;// If set, then it expects that all textures and colors need to be outputted in premultiplied gamma. Default is false.
16537
+ var sectionPlanesState=scene._sectionPlanesState;var lightsState=scene._lightsState;var i;var len;var clipping=sectionPlanesState.sectionPlanes.length>0;var src=[];src.push("#version 300 es");src.push("// Instancing geometry drawing fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform sampler2D uColorMap;");if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}src.push("uniform float gammaFactor;");src.push("vec4 linearToLinear( in vec4 value ) {");src.push(" return value;");src.push("}");src.push("vec4 sRGBToLinear( in vec4 value ) {");src.push(" return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );");src.push("}");src.push("vec4 gammaToLinear( in vec4 value) {");src.push(" return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );");src.push("}");if(gammaOutput){src.push("vec4 linearToGamma( in vec4 value, in float gammaFactor ) {");src.push(" return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("in vec4 vFlags2;");for(var _i270=0,_len61=sectionPlanesState.sectionPlanes.length;_i270<_len61;_i270++){src.push("uniform bool sectionPlaneActive"+_i270+";");src.push("uniform vec3 sectionPlanePos"+_i270+";");src.push("uniform vec3 sectionPlaneDir"+_i270+";");}}src.push("uniform mat4 viewMatrix;");src.push("uniform vec4 lightAmbient;");for(i=0,len=lightsState.lights.length;i<len;i++){var light=lightsState.lights[i];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+i+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+i+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+i+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+i+";");src.push("uniform vec3 lightDir"+i+";");}}src.push("in vec4 vViewPosition;");src.push("in vec4 vColor;");src.push("in vec2 vUV;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (float(vFlags2.x) > 0.0);");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i271=0,_len62=sectionPlanesState.sectionPlanes.length;_i271<_len62;_i271++){src.push("if (sectionPlaneActive"+_i271+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i271+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i271+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");src.push("vec3 xTangent = dFdx( vViewPosition.xyz );");src.push("vec3 yTangent = dFdy( vViewPosition.xyz );");src.push("vec3 viewNormal = normalize( cross( xTangent, yTangent ) );");for(i=0,len=lightsState.lights.length;i<len;i++){var _light9=lightsState.lights[i];if(_light9.type==="ambient"){continue;}if(_light9.type==="dir"){if(_light9.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else if(_light9.type==="point"){if(_light9.space==="view"){src.push("viewLightDir = -normalize(lightPos"+i+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+i+", 0.0)).xyz);");}}else if(_light9.type==="spot"){if(_light9.space==="view"){src.push("viewLightDir = normalize(lightDir"+i+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+i+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+i+".rgb * lightColor"+i+".a);");}src.push("vec4 color = vec4((lightAmbient.rgb * lightAmbient.a * vColor.rgb) + (reflectedColor * vColor.rgb), vColor.a);");if(gammaOutput){src.push("vec4 colorTexel = color * sRGBToLinear(texture(uColorMap, vUV));");}else{src.push("vec4 colorTexel = color * texture(uColorMap, vUV);");}src.push("float opacity = color.a;");if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
16536
16538
  // Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
16537
- src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb * ambient, opacity);");}else{src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb, opacity);");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesInstancingColorTextureRenderer;}();/**
16539
+ src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb * ambient, opacity);");}else{src.push(" outColor = vec4(vColor.rgb * colorTexel.rgb, opacity);");}if(gammaOutput){src.push("outColor = linearToGamma(outColor, gammaFactor);");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesInstancingColorTextureRenderer;}();/**
16538
16540
  * @private
16539
16541
  */var TrianglesInstancingRenderers=/*#__PURE__*/function(){function TrianglesInstancingRenderers(scene){_classCallCheck(this,TrianglesInstancingRenderers);this._scene=scene;}_createClass(TrianglesInstancingRenderers,[{key:"_compile",value:function _compile(){if(this._colorRenderer&&!this._colorRenderer.getValid()){this._colorRenderer.destroy();this._colorRenderer=null;}if(this._colorRendererWithSAO&&!this._colorRendererWithSAO.getValid()){this._colorRendererWithSAO.destroy();this._colorRendererWithSAO=null;}if(this._flatColorRenderer&&!this._flatColorRenderer.getValid()){this._flatColorRenderer.destroy();this._flatColorRenderer=null;}if(this._flatColorRendererWithSAO&&!this._flatColorRendererWithSAO.getValid()){this._flatColorRendererWithSAO.destroy();this._flatColorRendererWithSAO=null;}if(this._pbrRenderer&&!this._pbrRenderer.getValid()){this._pbrRenderer.destroy();this._pbrRenderer=null;}if(this._pbrRendererWithSAO&&!this._pbrRendererWithSAO.getValid()){this._pbrRendererWithSAO.destroy();this._pbrRendererWithSAO=null;}if(this._colorTextureRenderer&&!this._colorTextureRenderer.getValid()){this._colorTextureRenderer.destroy();this._colorTextureRenderer=null;}if(this._colorTextureRendererWithSAO&&!this._colorTextureRendererWithSAO.getValid()){this._colorTextureRendererWithSAO.destroy();this._colorTextureRendererWithSAO=null;}if(this._depthRenderer&&!this._depthRenderer.getValid()){this._depthRenderer.destroy();this._depthRenderer=null;}if(this._normalsRenderer&&!this._normalsRenderer.getValid()){this._normalsRenderer.destroy();this._normalsRenderer=null;}if(this._silhouetteRenderer&&!this._silhouetteRenderer.getValid()){this._silhouetteRenderer.destroy();this._silhouetteRenderer=null;}if(this._edgesRenderer&&!this._edgesRenderer.getValid()){this._edgesRenderer.destroy();this._edgesRenderer=null;}if(this._edgesColorRenderer&&!this._edgesColorRenderer.getValid()){this._edgesColorRenderer.destroy();this._edgesColorRenderer=null;}if(this._pickMeshRenderer&&!this._pickMeshRenderer.getValid()){this._pickMeshRenderer.destroy();this._pickMeshRenderer=null;}if(this._pickDepthRenderer&&!this._pickDepthRenderer.getValid()){this._pickDepthRenderer.destroy();this._pickDepthRenderer=null;}if(this._pickNormalsRenderer&&this._pickNormalsRenderer.getValid()===false){this._pickNormalsRenderer.destroy();this._pickNormalsRenderer=null;}if(this._pickNormalsFlatRenderer&&!this._pickNormalsFlatRenderer.getValid()){this._pickNormalsFlatRenderer.destroy();this._pickNormalsFlatRenderer=null;}if(this._occlusionRenderer&&this._occlusionRenderer.getValid()===false){this._occlusionRenderer.destroy();this._occlusionRenderer=null;}if(this._shadowRenderer&&!this._shadowRenderer.getValid()){this._shadowRenderer.destroy();this._shadowRenderer=null;}}},{key:"colorRenderer",get:function get(){if(!this._colorRenderer){this._colorRenderer=new TrianglesInstancingColorRenderer(this._scene,false);}return this._colorRenderer;}},{key:"colorRendererWithSAO",get:function get(){if(!this._colorRendererWithSAO){this._colorRendererWithSAO=new TrianglesInstancingColorRenderer(this._scene,true);}return this._colorRendererWithSAO;}},{key:"flatColorRenderer",get:function get(){if(!this._flatColorRenderer){this._flatColorRenderer=new TrianglesInstancingFlatColorRenderer(this._scene,false);}return this._flatColorRenderer;}},{key:"flatColorRendererWithSAO",get:function get(){if(!this._flatColorRendererWithSAO){this._flatColorRendererWithSAO=new TrianglesInstancingFlatColorRenderer(this._scene,true);}return this._flatColorRendererWithSAO;}},{key:"pbrRenderer",get:function get(){if(!this._pbrRenderer){this._pbrRenderer=new TrianglesInstancingPBRRenderer(this._scene,false);}return this._pbrRenderer;}},{key:"pbrRendererWithSAO",get:function get(){if(!this._pbrRendererWithSAO){this._pbrRendererWithSAO=new TrianglesInstancingPBRRenderer(this._scene,true);}return this._pbrRendererWithSAO;}},{key:"colorTextureRenderer",get:function get(){if(!this._colorTextureRenderer){this._colorTextureRenderer=new TrianglesInstancingColorTextureRenderer(this._scene,false);}return this._colorTextureRenderer;}},{key:"colorTextureRendererWithSAO",get:function get(){if(!this._colorTextureRendererWithSAO){this._colorTextureRendererWithSAO=new TrianglesInstancingColorTextureRenderer(this._scene,true);}return this._colorTextureRendererWithSAO;}},{key:"silhouetteRenderer",get:function get(){if(!this._silhouetteRenderer){this._silhouetteRenderer=new TrianglesInstancingSilhouetteRenderer(this._scene);}return this._silhouetteRenderer;}},{key:"depthRenderer",get:function get(){if(!this._depthRenderer){this._depthRenderer=new TrianglesInstancingDepthRenderer(this._scene);}return this._depthRenderer;}},{key:"normalsRenderer",get:function get(){if(!this._normalsRenderer){this._normalsRenderer=new TrianglesInstancingNormalsRenderer(this._scene);}return this._normalsRenderer;}},{key:"edgesRenderer",get:function get(){if(!this._edgesRenderer){this._edgesRenderer=new TrianglesInstancingEdgesRenderer(this._scene);}return this._edgesRenderer;}},{key:"edgesColorRenderer",get:function get(){if(!this._edgesColorRenderer){this._edgesColorRenderer=new TrianglesInstancingEdgesColorRenderer(this._scene);}return this._edgesColorRenderer;}},{key:"pickMeshRenderer",get:function get(){if(!this._pickMeshRenderer){this._pickMeshRenderer=new TrianglesInstancingPickMeshRenderer(this._scene);}return this._pickMeshRenderer;}},{key:"pickNormalsRenderer",get:function get(){if(!this._pickNormalsRenderer){this._pickNormalsRenderer=new TrianglesInstancingPickNormalsRenderer(this._scene);}return this._pickNormalsRenderer;}},{key:"pickNormalsFlatRenderer",get:function get(){if(!this._pickNormalsFlatRenderer){this._pickNormalsFlatRenderer=new TrianglesInstancingPickNormalsFlatRenderer(this._scene);}return this._pickNormalsFlatRenderer;}},{key:"pickDepthRenderer",get:function get(){if(!this._pickDepthRenderer){this._pickDepthRenderer=new TrianglesInstancingPickDepthRenderer(this._scene);}return this._pickDepthRenderer;}},{key:"occlusionRenderer",get:function get(){if(!this._occlusionRenderer){this._occlusionRenderer=new TrianglesInstancingOcclusionRenderer(this._scene);}return this._occlusionRenderer;}},{key:"shadowRenderer",get:function get(){if(!this._shadowRenderer){this._shadowRenderer=new TrianglesInstancingShadowRenderer(this._scene);}return this._shadowRenderer;}},{key:"_destroy",value:function _destroy(){if(this._colorRenderer){this._colorRenderer.destroy();}if(this._colorRendererWithSAO){this._colorRendererWithSAO.destroy();}if(this._flatColorRenderer){this._flatColorRenderer.destroy();}if(this._flatColorRendererWithSAO){this._flatColorRendererWithSAO.destroy();}if(this._pbrRenderer){this._pbrRenderer.destroy();}if(this._pbrRendererWithSAO){this._pbrRendererWithSAO.destroy();}if(this._colorTextureRenderer){this._colorTextureRenderer.destroy();}if(this._colorTextureRendererWithSAO){this._colorTextureRendererWithSAO.destroy();}if(this._depthRenderer){this._depthRenderer.destroy();}if(this._normalsRenderer){this._normalsRenderer.destroy();}if(this._silhouetteRenderer){this._silhouetteRenderer.destroy();}if(this._edgesRenderer){this._edgesRenderer.destroy();}if(this._edgesColorRenderer){this._edgesColorRenderer.destroy();}if(this._pickMeshRenderer){this._pickMeshRenderer.destroy();}if(this._pickDepthRenderer){this._pickDepthRenderer.destroy();}if(this._pickNormalsRenderer){this._pickNormalsRenderer.destroy();}if(this._pickNormalsFlatRenderer){this._pickNormalsFlatRenderer.destroy();}if(this._occlusionRenderer){this._occlusionRenderer.destroy();}if(this._shadowRenderer){this._shadowRenderer.destroy();}}}]);return TrianglesInstancingRenderers;}();var cachedRenderers$4={};/**
16540
16542
  * @private
@@ -18896,7 +18898,7 @@ var defaultColorTexture=new VBOSceneModelTexture({id:defaultColorTextureId,textu
18896
18898
  * @param {Number} [cfg.encoding=LinearEncoding] Encoding format. Supported values are {@link LinearEncoding} and {@link sRGBEncoding}.
18897
18899
  */},{key:"createTexture",value:function createTexture(cfg){var _this81=this;var textureId=cfg.id;if(textureId===undefined||textureId===null){this.error("Config missing: id");return;}if(this._textures[textureId]){this.error("Texture already created: "+textureId);return;}if(!cfg.src&&!cfg.image&&!cfg.buffers){this.error("Param expected: `src`, `image' or 'buffers'");return null;}var minFilter=cfg.minFilter||LinearMipmapLinearFilter;if(minFilter!==LinearFilter&&minFilter!==LinearMipMapNearestFilter&&minFilter!==LinearMipmapLinearFilter&&minFilter!==NearestMipMapLinearFilter&&minFilter!==NearestMipMapNearestFilter){this.error("[createTexture] Unsupported value for 'minFilter' - \n supported values are LinearFilter, LinearMipMapNearestFilter, NearestMipMapNearestFilter, \n NearestMipMapLinearFilter and LinearMipmapLinearFilter. Defaulting to LinearMipmapLinearFilter.");minFilter=LinearMipmapLinearFilter;}var magFilter=cfg.magFilter||LinearFilter;if(magFilter!==LinearFilter&&magFilter!==NearestFilter){this.error("[createTexture] Unsupported value for 'magFilter' - supported values are LinearFilter and NearestFilter. Defaulting to LinearFilter.");magFilter=LinearFilter;}var wrapS=cfg.wrapS||RepeatWrapping;if(wrapS!==ClampToEdgeWrapping&&wrapS!==MirroredRepeatWrapping&&wrapS!==RepeatWrapping){this.error("[createTexture] Unsupported value for 'wrapS' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping.");wrapS=RepeatWrapping;}var wrapT=cfg.wrapT||RepeatWrapping;if(wrapT!==ClampToEdgeWrapping&&wrapT!==MirroredRepeatWrapping&&wrapT!==RepeatWrapping){this.error("[createTexture] Unsupported value for 'wrapT' - supported values are ClampToEdgeWrapping, MirroredRepeatWrapping and RepeatWrapping. Defaulting to RepeatWrapping.");wrapT=RepeatWrapping;}var encoding=cfg.encoding||LinearEncoding;if(encoding!==LinearEncoding&&encoding!==sRGBEncoding){this.error("[createTexture] Unsupported value for 'encoding' - supported values are LinearEncoding and sRGBEncoding. Defaulting to LinearEncoding.");encoding=LinearEncoding;}var texture=new Texture2D({gl:this.scene.canvas.gl});if(cfg.preloadColor){texture.setPreloadColor(cfg.preloadColor);}if(cfg.image){// Ignore transcoder for Images
18898
18900
  var _image4=cfg.image;_image4.crossOrigin="Anonymous";texture.setImage(_image4,{minFilter:minFilter,magFilter:magFilter,wrapS:wrapS,wrapT:wrapT,flipY:cfg.flipY,encoding:encoding});}else if(cfg.src){var ext=cfg.src.split('.').pop();switch(ext){// Don't transcode recognized image file types
18899
- case"jpeg":case"jpg":case"png":case"gif":var _image5=new Image();_image5.onload=function(){texture.setImage(_image5,{minFilter:minFilter,magFilter:magFilter,wrapS:wrapS,wrapT:wrapT,flipY:cfg.flipY,encoding:encoding});};_image5.src=cfg.src;// URL or Base64 string
18901
+ case"jpeg":case"jpg":case"png":case"gif":var _image5=new Image();_image5.onload=function(){texture.setImage(_image5,{minFilter:minFilter,magFilter:magFilter,wrapS:wrapS,wrapT:wrapT,flipY:cfg.flipY,encoding:encoding});_this81.glRedraw();};_image5.src=cfg.src;// URL or Base64 string
18900
18902
  break;default:// Assume other file types need transcoding
18901
18903
  if(!this._textureTranscoder){this.error("Can't create texture from 'src' - VBOSceneModel needs to be configured with a TextureTranscoder for this file type ('".concat(ext,"')"));}else{utils.loadArraybuffer(cfg.src,function(arrayBuffer){if(!arrayBuffer.byteLength){_this81.error("Can't create texture from 'src': file data is zero length");return;}_this81._textureTranscoder.transcode([arrayBuffer],texture).then(function(){_this81.glRedraw();});},function(errMsg){this.error("Can't create texture from 'src': ".concat(errMsg));});}break;}}else if(cfg.buffers){// Buffers implicitly require transcoding
18902
18904
  if(!this._textureTranscoder){this.error("Can't create texture from 'buffers' - VBOSceneModel needs to be configured with a TextureTranscoder for this option");}else{this._textureTranscoder.transcode(cfg.buffers,texture).then(function(){_this81.glRedraw();});}}this._textures[textureId]=new VBOSceneModelTexture({id:textureId,texture:texture});}/**