playcanvas 1.51.0 → 1.51.1

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * PlayCanvas Engine v1.51.0 revision 094433dc7
3
+ * PlayCanvas Engine v1.51.1 revision a9e71aa59
4
4
  * Copyright 2011-2021 PlayCanvas Ltd. All rights reserved.
5
5
  */
6
6
  (function (global, factory) {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * PlayCanvas Engine v1.51.0 revision 094433dc7 (DEBUG PROFILER)
3
+ * PlayCanvas Engine v1.51.1 revision a9e71aa59 (DEBUG PROFILER)
4
4
  * Copyright 2011-2021 PlayCanvas Ltd. All rights reserved.
5
5
  */
6
6
  (function (global, factory) {
@@ -634,8 +634,8 @@
634
634
  return result;
635
635
  }();
636
636
 
637
- var version = "1.51.0";
638
- var revision = "094433dc7";
637
+ var version = "1.51.1";
638
+ var revision = "a9e71aa59";
639
639
  var config = {};
640
640
  var common = {};
641
641
  var apps = {};
@@ -6356,7 +6356,7 @@
6356
6356
 
6357
6357
  var reflectionCubePS = "uniform samplerCube texture_cubeMap;\nuniform float material_reflectivity;\n\nvec3 calcReflection(vec3 tReflDirW, float tGlossiness) {\n\tvec3 lookupVec = fixSeams(cubeMapProject(tReflDirW));\n\tlookupVec.x *= -1.0;\n\treturn $DECODE(textureCube(texture_cubeMap, lookupVec));\n}\n\nvoid addReflection() { \n\tdReflection += vec4(calcReflection(dReflDirW, dGlossiness), material_reflectivity);\n}\n";
6358
6358
 
6359
- var reflectionEnvPS = "#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nuniform float material_reflectivity;\n\n// calculate mip level for shiny reflection given equirect coords uv.\nfloat shinyMipLevel(vec2 uv) {\n\tvec2 dx = dFdx(uv);\n\tvec2 dy = dFdy(uv);\n\n\t// calculate second dF at 180 degrees\n\tvec2 uv2 = vec2(fract(uv.x + 0.5), uv.y);\n\tvec2 dx2 = dFdx(uv2);\n\tvec2 dy2 = dFdy(uv2);\n\n\t// calculate min of both sets of dF to handle discontinuity at the azim edge\n\tfloat maxd = min(max(dot(dx, dx), dot(dy, dy)), max(dot(dx2, dx2), dot(dy2, dy2)));\n\n\treturn clamp(0.5 * log2(maxd), 0.0, 10.0);\n}\n\nvec3 calcReflection(vec3 tReflDirW, float tGlossiness) {\n\tvec3 dir = cubeMapProject(tReflDirW) * vec3(-1.0, 1.0, 1.0);\n\tvec2 uv = toSphericalUv(dir);\n\n\tfloat level = saturate(1.0 - tGlossiness) * 5.0;\n\tfloat ilevel = floor(level);\n\n\tvec3 linear0;\n\tif (ilevel == 0.0) {\n\t\t// we're accessing the top level reflection - perform manual mipmap\n\t\tfloat level2 = shinyMipLevel(uv * atlasSize);\n\t\tfloat ilevel2 = floor(level2);\n\t\tvec3 linearA = $DECODE(texture2D(texture_envAtlas, mapMip(uv, ilevel2)));\n\t\tvec3 linearB = $DECODE(texture2D(texture_envAtlas, mapMip(uv, ilevel2 + 1.0)));\n\t\tlinear0 = mix(linearA, linearB, level2 - ilevel2);\n\t} else {\n\t\tlinear0 = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel)));\n\t}\n\tvec3 linear1 = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel + 1.0)));\n\n\treturn processEnvironment(mix(linear0, linear1, level - ilevel));\n}\n\nvoid addReflection() { \n\tdReflection += vec4(calcReflection(dReflDirW, dGlossiness), material_reflectivity);\n}\n";
6359
+ var reflectionEnvPS = "#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nuniform float material_reflectivity;\n\n// calculate mip level for shiny reflection given equirect coords uv.\nfloat shinyMipLevel(vec2 uv) {\n\tvec2 dx = dFdx(uv);\n\tvec2 dy = dFdy(uv);\n\n\t// calculate second dF at 180 degrees\n\tvec2 uv2 = vec2(fract(uv.x + 0.5), uv.y);\n\tvec2 dx2 = dFdx(uv2);\n\tvec2 dy2 = dFdy(uv2);\n\n\t// calculate min of both sets of dF to handle discontinuity at the azim edge\n\tfloat maxd = min(max(dot(dx, dx), dot(dy, dy)), max(dot(dx2, dx2), dot(dy2, dy2)));\n\n\treturn clamp(0.5 * log2(maxd) - 1.0, 0.0, 6.0);\n}\n\nvec3 calcReflection(vec3 tReflDirW, float tGlossiness) {\n\tvec3 dir = cubeMapProject(tReflDirW) * vec3(-1.0, 1.0, 1.0);\n\tvec2 uv = toSphericalUv(dir);\n\n\t// calculate roughness level\n\tfloat level = saturate(1.0 - tGlossiness) * 5.0;\n\tfloat ilevel = floor(level);\n\n\tvec2 uv0, uv1;\n\tfloat weight;\n\tif (ilevel == 0.0) {\n\t\t// accessing the shiny (top level) reflection - perform manual mipmap lookup\n\t\tfloat level2 = shinyMipLevel(uv * atlasSize);\n\t\tfloat ilevel2 = floor(level2);\n\t\tuv0 = mapMip(uv, ilevel2);\n\t\tuv1 = mapMip(uv, ilevel2 + 1.0);\n\t\tweight = level2 - ilevel2;\n\t} else {\n\t\t// accessing rough reflection - just sample the same part twice\n\t\tuv0 = uv1 = mapRoughnessUv(uv, ilevel + 1.0);\n\t\tweight = 0.0;\n\t}\n\n\tvec3 linearA = $DECODE(texture2D(texture_envAtlas, uv0));\n\tvec3 linearB = $DECODE(texture2D(texture_envAtlas, uv1));\n\tvec3 linear0 = mix(linearA, linearB, weight);\n\tvec3 linear1 = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel + 1.0)));\n\n\treturn processEnvironment(mix(linear0, linear1, level - ilevel));\n}\n\nvoid addReflection() { \n\tdReflection += vec4(calcReflection(dReflDirW, dGlossiness), material_reflectivity);\n}\n";
6360
6360
 
6361
6361
  var reflectionSpherePS = "#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\nuniform sampler2D texture_sphereMap;\nuniform float material_reflectivity;\n\nvec3 calcReflection(vec3 tReflDirW, float tGlossiness) {\n\tvec3 reflDirV = (mat3(matrix_view) * tReflDirW).xyz;\n\n\tfloat m = 2.0 * sqrt( dot(reflDirV.xy, reflDirV.xy) + (reflDirV.z+1.0)*(reflDirV.z+1.0) );\n\tvec2 sphereMapUv = reflDirV.xy / m + 0.5;\n\n\treturn $DECODE(texture2D(texture_sphereMap, sphereMapUv));\n}\n\nvoid addReflection() { \n\tdReflection += vec4(calcReflection(dReflDirW, dGlossiness), material_reflectivity);\n}\n";
6362
6362
 
@@ -10496,11 +10496,11 @@
10496
10496
  code += options.packedNormal ? chunks.normalXYPS : chunks.normalXYZPS;
10497
10497
 
10498
10498
  if (!options.hasTangents) {
10499
- var transformPropName = options.normalMap ? "normalMapTransform" : "clearCoatNormalMapTransform";
10499
+ var baseName = options.normalMap ? "normalMap" : "clearCoatNormalMap";
10500
10500
 
10501
- var normalMapUv = this._getUvSourceExpression(transformPropName, "normalMapUv", options);
10501
+ var uv = this._getUvSourceExpression(baseName + "Transform", baseName + "Uv", options);
10502
10502
 
10503
- tbn = tbn.replace(/\$UV/g, normalMapUv);
10503
+ tbn = tbn.replace(/\$UV/g, uv);
10504
10504
  }
10505
10505
 
10506
10506
  code += tbn;
@@ -49423,8 +49423,15 @@
49423
49423
 
49424
49424
  if (this._imageReference.hasComponent('element')) {
49425
49425
  this._isApplyingSprite = true;
49426
- this._imageReference.entity.element.spriteAsset = spriteAsset;
49427
- this._imageReference.entity.element.spriteFrame = spriteFrame;
49426
+
49427
+ if (this._imageReference.entity.element.spriteAsset !== spriteAsset) {
49428
+ this._imageReference.entity.element.spriteAsset = spriteAsset;
49429
+ }
49430
+
49431
+ if (this._imageReference.entity.element.spriteFrame !== spriteFrame) {
49432
+ this._imageReference.entity.element.spriteFrame = spriteFrame;
49433
+ }
49434
+
49428
49435
  this._isApplyingSprite = false;
49429
49436
  }
49430
49437
  };
@@ -49440,25 +49447,26 @@
49440
49447
  };
49441
49448
 
49442
49449
  _proto._applyTintImmediately = function _applyTintImmediately(tintColor) {
49443
- if (this._imageReference.hasComponent('element') && tintColor) {
49444
- this._isApplyingTint = true;
49445
- this._imageReference.entity.element.color = toColor3(tintColor);
49446
- this._imageReference.entity.element.opacity = tintColor.a;
49447
- this._isApplyingTint = false;
49448
- }
49450
+ if (!tintColor || !this._imageReference.hasComponent('element')) return;
49451
+ var color3 = toColor3(tintColor);
49452
+ this._isApplyingTint = true;
49453
+ if (!color3.equals(this._imageReference.entity.element.color)) this._imageReference.entity.element.color = color3;
49454
+ if (this._imageReference.entity.element.opacity != tintColor.a) this._imageReference.entity.element.opacity = tintColor.a;
49455
+ this._isApplyingTint = false;
49449
49456
  };
49450
49457
 
49451
49458
  _proto._applyTintWithTween = function _applyTintWithTween(tintColor) {
49452
- if (this._imageReference.hasComponent('element') && tintColor) {
49453
- var color = this._imageReference.entity.element.color;
49454
- var opacity = this._imageReference.entity.element.opacity;
49455
- this._tweenInfo = {
49456
- startTime: now(),
49457
- from: new Color(color.r, color.g, color.b, opacity),
49458
- to: tintColor.clone(),
49459
- lerpColor: new Color()
49460
- };
49461
- }
49459
+ if (!tintColor || !this._imageReference.hasComponent('element')) return;
49460
+ var color3 = toColor3(tintColor);
49461
+ var color = this._imageReference.entity.element.color;
49462
+ var opacity = this._imageReference.entity.element.opacity;
49463
+ if (color3.equals(color) && tintColor.a == opacity) return;
49464
+ this._tweenInfo = {
49465
+ startTime: now(),
49466
+ from: new Color(color.r, color.g, color.b, opacity),
49467
+ to: tintColor.clone(),
49468
+ lerpColor: new Color()
49469
+ };
49462
49470
  };
49463
49471
 
49464
49472
  _proto._updateTintTween = function _updateTintTween() {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * PlayCanvas Engine v1.51.0 revision 094433dc7
3
+ * PlayCanvas Engine v1.51.1 revision a9e71aa59
4
4
  * Copyright 2011-2021 PlayCanvas Ltd. All rights reserved.
5
5
  */
6
6
  (function (global, factory) {
@@ -634,8 +634,8 @@
634
634
  return result;
635
635
  }();
636
636
 
637
- var version = "1.51.0";
638
- var revision = "094433dc7";
637
+ var version = "1.51.1";
638
+ var revision = "a9e71aa59";
639
639
  var config = {};
640
640
  var common = {};
641
641
  var apps = {};
@@ -6286,7 +6286,7 @@
6286
6286
 
6287
6287
  var reflectionCubePS = "uniform samplerCube texture_cubeMap;\nuniform float material_reflectivity;\nvec3 calcReflection(vec3 tReflDirW, float tGlossiness) {\n\tvec3 lookupVec = fixSeams(cubeMapProject(tReflDirW));\n\tlookupVec.x *= -1.0;\n\treturn $DECODE(textureCube(texture_cubeMap, lookupVec));\n}\nvoid addReflection() {\n\tdReflection += vec4(calcReflection(dReflDirW, dGlossiness), material_reflectivity);\n}\n";
6288
6288
 
6289
- var reflectionEnvPS = "#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nuniform float material_reflectivity;\nfloat shinyMipLevel(vec2 uv) {\n\tvec2 dx = dFdx(uv);\n\tvec2 dy = dFdy(uv);\n\tvec2 uv2 = vec2(fract(uv.x + 0.5), uv.y);\n\tvec2 dx2 = dFdx(uv2);\n\tvec2 dy2 = dFdy(uv2);\n\tfloat maxd = min(max(dot(dx, dx), dot(dy, dy)), max(dot(dx2, dx2), dot(dy2, dy2)));\n\treturn clamp(0.5 * log2(maxd), 0.0, 10.0);\n}\nvec3 calcReflection(vec3 tReflDirW, float tGlossiness) {\n\tvec3 dir = cubeMapProject(tReflDirW) * vec3(-1.0, 1.0, 1.0);\n\tvec2 uv = toSphericalUv(dir);\n\tfloat level = saturate(1.0 - tGlossiness) * 5.0;\n\tfloat ilevel = floor(level);\n\tvec3 linear0;\n\tif (ilevel == 0.0) {\n\t\tfloat level2 = shinyMipLevel(uv * atlasSize);\n\t\tfloat ilevel2 = floor(level2);\n\t\tvec3 linearA = $DECODE(texture2D(texture_envAtlas, mapMip(uv, ilevel2)));\n\t\tvec3 linearB = $DECODE(texture2D(texture_envAtlas, mapMip(uv, ilevel2 + 1.0)));\n\t\tlinear0 = mix(linearA, linearB, level2 - ilevel2);\n\t} else {\n\t\tlinear0 = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel)));\n\t}\n\tvec3 linear1 = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel + 1.0)));\n\treturn processEnvironment(mix(linear0, linear1, level - ilevel));\n}\nvoid addReflection() {\n\tdReflection += vec4(calcReflection(dReflDirW, dGlossiness), material_reflectivity);\n}\n";
6289
+ var reflectionEnvPS = "#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nuniform float material_reflectivity;\nfloat shinyMipLevel(vec2 uv) {\n\tvec2 dx = dFdx(uv);\n\tvec2 dy = dFdy(uv);\n\tvec2 uv2 = vec2(fract(uv.x + 0.5), uv.y);\n\tvec2 dx2 = dFdx(uv2);\n\tvec2 dy2 = dFdy(uv2);\n\tfloat maxd = min(max(dot(dx, dx), dot(dy, dy)), max(dot(dx2, dx2), dot(dy2, dy2)));\n\treturn clamp(0.5 * log2(maxd) - 1.0, 0.0, 6.0);\n}\nvec3 calcReflection(vec3 tReflDirW, float tGlossiness) {\n\tvec3 dir = cubeMapProject(tReflDirW) * vec3(-1.0, 1.0, 1.0);\n\tvec2 uv = toSphericalUv(dir);\n\tfloat level = saturate(1.0 - tGlossiness) * 5.0;\n\tfloat ilevel = floor(level);\n\tvec2 uv0, uv1;\n\tfloat weight;\n\tif (ilevel == 0.0) {\n\t\tfloat level2 = shinyMipLevel(uv * atlasSize);\n\t\tfloat ilevel2 = floor(level2);\n\t\tuv0 = mapMip(uv, ilevel2);\n\t\tuv1 = mapMip(uv, ilevel2 + 1.0);\n\t\tweight = level2 - ilevel2;\n\t} else {\n\t\tuv0 = uv1 = mapRoughnessUv(uv, ilevel + 1.0);\n\t\tweight = 0.0;\n\t}\n\tvec3 linearA = $DECODE(texture2D(texture_envAtlas, uv0));\n\tvec3 linearB = $DECODE(texture2D(texture_envAtlas, uv1));\n\tvec3 linear0 = mix(linearA, linearB, weight);\n\tvec3 linear1 = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel + 1.0)));\n\treturn processEnvironment(mix(linear0, linear1, level - ilevel));\n}\nvoid addReflection() {\n\tdReflection += vec4(calcReflection(dReflDirW, dGlossiness), material_reflectivity);\n}\n";
6290
6290
 
6291
6291
  var reflectionSpherePS = "#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\nuniform sampler2D texture_sphereMap;\nuniform float material_reflectivity;\nvec3 calcReflection(vec3 tReflDirW, float tGlossiness) {\n\tvec3 reflDirV = (mat3(matrix_view) * tReflDirW).xyz;\n\tfloat m = 2.0 * sqrt( dot(reflDirV.xy, reflDirV.xy) + (reflDirV.z+1.0)*(reflDirV.z+1.0) );\n\tvec2 sphereMapUv = reflDirV.xy / m + 0.5;\n\treturn $DECODE(texture2D(texture_sphereMap, sphereMapUv));\n}\nvoid addReflection() {\n\tdReflection += vec4(calcReflection(dReflDirW, dGlossiness), material_reflectivity);\n}\n";
6292
6292
 
@@ -10395,11 +10395,11 @@
10395
10395
  code += options.packedNormal ? chunks.normalXYPS : chunks.normalXYZPS;
10396
10396
 
10397
10397
  if (!options.hasTangents) {
10398
- var transformPropName = options.normalMap ? "normalMapTransform" : "clearCoatNormalMapTransform";
10398
+ var baseName = options.normalMap ? "normalMap" : "clearCoatNormalMap";
10399
10399
 
10400
- var normalMapUv = this._getUvSourceExpression(transformPropName, "normalMapUv", options);
10400
+ var uv = this._getUvSourceExpression(baseName + "Transform", baseName + "Uv", options);
10401
10401
 
10402
- tbn = tbn.replace(/\$UV/g, normalMapUv);
10402
+ tbn = tbn.replace(/\$UV/g, uv);
10403
10403
  }
10404
10404
 
10405
10405
  code += tbn;
@@ -48850,8 +48850,15 @@
48850
48850
 
48851
48851
  if (this._imageReference.hasComponent('element')) {
48852
48852
  this._isApplyingSprite = true;
48853
- this._imageReference.entity.element.spriteAsset = spriteAsset;
48854
- this._imageReference.entity.element.spriteFrame = spriteFrame;
48853
+
48854
+ if (this._imageReference.entity.element.spriteAsset !== spriteAsset) {
48855
+ this._imageReference.entity.element.spriteAsset = spriteAsset;
48856
+ }
48857
+
48858
+ if (this._imageReference.entity.element.spriteFrame !== spriteFrame) {
48859
+ this._imageReference.entity.element.spriteFrame = spriteFrame;
48860
+ }
48861
+
48855
48862
  this._isApplyingSprite = false;
48856
48863
  }
48857
48864
  };
@@ -48867,25 +48874,26 @@
48867
48874
  };
48868
48875
 
48869
48876
  _proto._applyTintImmediately = function _applyTintImmediately(tintColor) {
48870
- if (this._imageReference.hasComponent('element') && tintColor) {
48871
- this._isApplyingTint = true;
48872
- this._imageReference.entity.element.color = toColor3(tintColor);
48873
- this._imageReference.entity.element.opacity = tintColor.a;
48874
- this._isApplyingTint = false;
48875
- }
48877
+ if (!tintColor || !this._imageReference.hasComponent('element')) return;
48878
+ var color3 = toColor3(tintColor);
48879
+ this._isApplyingTint = true;
48880
+ if (!color3.equals(this._imageReference.entity.element.color)) this._imageReference.entity.element.color = color3;
48881
+ if (this._imageReference.entity.element.opacity != tintColor.a) this._imageReference.entity.element.opacity = tintColor.a;
48882
+ this._isApplyingTint = false;
48876
48883
  };
48877
48884
 
48878
48885
  _proto._applyTintWithTween = function _applyTintWithTween(tintColor) {
48879
- if (this._imageReference.hasComponent('element') && tintColor) {
48880
- var color = this._imageReference.entity.element.color;
48881
- var opacity = this._imageReference.entity.element.opacity;
48882
- this._tweenInfo = {
48883
- startTime: now(),
48884
- from: new Color(color.r, color.g, color.b, opacity),
48885
- to: tintColor.clone(),
48886
- lerpColor: new Color()
48887
- };
48888
- }
48886
+ if (!tintColor || !this._imageReference.hasComponent('element')) return;
48887
+ var color3 = toColor3(tintColor);
48888
+ var color = this._imageReference.entity.element.color;
48889
+ var opacity = this._imageReference.entity.element.opacity;
48890
+ if (color3.equals(color) && tintColor.a == opacity) return;
48891
+ this._tweenInfo = {
48892
+ startTime: now(),
48893
+ from: new Color(color.r, color.g, color.b, opacity),
48894
+ to: tintColor.clone(),
48895
+ lerpColor: new Color()
48896
+ };
48889
48897
  };
48890
48898
 
48891
48899
  _proto._updateTintTween = function _updateTintTween() {