playcanvas 1.51.3 → 1.51.7

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,7 +1,7 @@
1
1
  /**
2
2
  * @license
3
- * PlayCanvas Engine v1.51.3 revision 6095baac1
4
- * Copyright 2011-2021 PlayCanvas Ltd. All rights reserved.
3
+ * PlayCanvas Engine v1.51.7 revision f3750a326
4
+ * Copyright 2011-2022 PlayCanvas Ltd. All rights reserved.
5
5
  */
6
6
  (function (global, factory) {
7
7
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license
3
- * PlayCanvas Engine v1.51.3 revision 6095baac1 (DEBUG PROFILER)
4
- * Copyright 2011-2021 PlayCanvas Ltd. All rights reserved.
3
+ * PlayCanvas Engine v1.51.7 revision f3750a326 (DEBUG PROFILER)
4
+ * Copyright 2011-2022 PlayCanvas Ltd. All rights reserved.
5
5
  */
6
6
  (function (global, factory) {
7
7
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -634,8 +634,8 @@
634
634
  return result;
635
635
  }();
636
636
 
637
- var version = "1.51.3";
638
- var revision = "6095baac1";
637
+ var version = "1.51.7";
638
+ var revision = "f3750a326";
639
639
  var config = {};
640
640
  var common = {};
641
641
  var apps = {};
@@ -6076,7 +6076,7 @@
6076
6076
 
6077
6077
  var ambientConstantPS = "void addAmbient() {\n\tdDiffuseLight += light_globalAmbient;\n}\n";
6078
6078
 
6079
- var ambientEnvPS = "#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\n\nvoid addAmbient() {\n\tvec3 dir = cubeMapRotate(dNormalW) * vec3(-1.0, 1.0, 1.0);\n\tvec2 uv = mapUv(toSphericalUv(dir), vec4(128.0, 256.0 + 128.0, 64.0, 32.0) / atlasSize);\n\n\tvec4 raw = texture2D(texture_envAtlas, uv);\n\tvec3 linear = $DECODE(raw);\n\tdDiffuseLight += processEnvironment(linear);\n}\n";
6079
+ var ambientEnvPS = "#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\n\nvoid addAmbient() {\n\tvec3 dir = normalize(cubeMapRotate(dNormalW) * vec3(-1.0, 1.0, 1.0));\n\tvec2 uv = mapUv(toSphericalUv(dir), vec4(128.0, 256.0 + 128.0, 64.0, 32.0) / atlasSize);\n\n\tvec4 raw = texture2D(texture_envAtlas, uv);\n\tvec3 linear = $DECODE(raw);\n\tdDiffuseLight += processEnvironment(linear);\n}\n";
6080
6080
 
6081
6081
  var ambientSHPS = "uniform vec3 ambientSH[9];\n\nvoid addAmbient() {\n\tvec3 n = cubeMapRotate(dNormalW);\n\n\tvec3 color =\n\t\tambientSH[0] +\n\t\tambientSH[1] * n.x +\n\t\tambientSH[2] * n.y +\n\t\tambientSH[3] * n.z +\n\t\tambientSH[4] * n.x * n.z +\n\t\tambientSH[5] * n.z * n.y +\n\t\tambientSH[6] * n.y * n.x +\n\t\tambientSH[7] * (3.0 * n.z * n.z - 1.0) +\n\t\tambientSH[8] * (n.x * n.x - n.y * n.y);\n\n\tdDiffuseLight += processEnvironment(max(color, vec3(0.0)));\n}\n";
6082
6082
 
@@ -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) - 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);\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";
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\t// accessing the shiny (top level) reflection - perform manual mipmap lookup\n\tfloat level2 = shinyMipLevel(uv * atlasSize);\n\tfloat ilevel2 = floor(level2);\n\n\tvec2 uv0, uv1;\n\tfloat weight;\n\tif (ilevel == 0.0) {\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);\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
 
@@ -11453,7 +11453,7 @@
11453
11453
  var numSamples = samples.length;
11454
11454
  var w = Math.min(numSamples, 512);
11455
11455
  var h = Math.ceil(numSamples / w);
11456
- var data = new Uint8ClampedArray(w * h * 4);
11456
+ var data = new Uint8Array(w * h * 4);
11457
11457
  var off = 0;
11458
11458
 
11459
11459
  for (var i = 0; i < numSamples; ++i) {
@@ -11651,29 +11651,6 @@
11651
11651
  });
11652
11652
  };
11653
11653
 
11654
- var generateMipmaps = function generateMipmaps(target) {
11655
- var device = target.device;
11656
- Debug.pushGpuMarker(device, "genMipmaps");
11657
- var result = new Texture(device, {
11658
- name: target.name + '-mipmaps',
11659
- cubemap: target.cubemap,
11660
- width: target.width,
11661
- height: target.height,
11662
- format: target.format,
11663
- type: target.type,
11664
- addressU: target.addressU,
11665
- addressV: target.addressV,
11666
- fixCubemapSeams: target.fixCubemapSeams,
11667
- mipmaps: true
11668
- });
11669
- reprojectTexture(target, result, {
11670
- numSamples: 1
11671
- });
11672
- target.destroy();
11673
- Debug.popGpuMarker(device);
11674
- return result;
11675
- };
11676
-
11677
11654
  var EnvLighting = function () {
11678
11655
  function EnvLighting() {}
11679
11656
 
@@ -11691,12 +11668,24 @@
11691
11668
  EnvLighting.generateLightingSource = function generateLightingSource(source) {
11692
11669
  var device = source.device;
11693
11670
  Debug.pushGpuMarker(device, "genLightingSource");
11694
- var result = createCubemap(device, 128, lightingSourcePixelFormat(device), false);
11671
+ var format = lightingSourcePixelFormat(device);
11672
+ var result = new Texture(device, {
11673
+ name: "lighting-source",
11674
+ cubemap: true,
11675
+ width: 128,
11676
+ height: 128,
11677
+ format: format,
11678
+ type: format === PIXELFORMAT_R8_G8_B8_A8 ? TEXTURETYPE_RGBM : TEXTURETYPE_DEFAULT,
11679
+ addressU: ADDRESS_CLAMP_TO_EDGE,
11680
+ addressV: ADDRESS_CLAMP_TO_EDGE,
11681
+ fixCubemapSeams: false,
11682
+ mipmaps: true
11683
+ });
11695
11684
  reprojectTexture(source, result, {
11696
11685
  numSamples: source.mipmaps ? 1 : 1024
11697
11686
  });
11698
11687
  Debug.popGpuMarker(device);
11699
- return generateMipmaps(result);
11688
+ return result;
11700
11689
  };
11701
11690
 
11702
11691
  EnvLighting.generateAtlas = function generateAtlas(source, options) {
@@ -12041,10 +12030,15 @@
12041
12030
  }
12042
12031
 
12043
12032
  meshInstance._material = null;
12044
- var defaultMaterial = DefaultMaterial.get(meshInstance.mesh.device);
12045
12033
 
12046
- if (this !== defaultMaterial) {
12047
- meshInstance.material = defaultMaterial;
12034
+ if (meshInstance.mesh) {
12035
+ var defaultMaterial = DefaultMaterial.get(meshInstance.mesh.device);
12036
+
12037
+ if (this !== defaultMaterial) {
12038
+ meshInstance.material = defaultMaterial;
12039
+ }
12040
+ } else {
12041
+ Debug.warn('pc.Material: MeshInstance mesh is null, default material cannot be assigned to the MeshInstance');
12048
12042
  }
12049
12043
  }
12050
12044
  };
@@ -12351,9 +12345,8 @@
12351
12345
  options.toneMap = stdMat.useGammaTonemap ? scene.toneMapping : -1;
12352
12346
  options.useRgbm = stdMat.emissiveMap && stdMat.emissiveMap.type === TEXTURETYPE_RGBM || stdMat.lightMap && stdMat.lightMap.type === TEXTURETYPE_RGBM;
12353
12347
  options.fixSeams = stdMat.cubeMap ? stdMat.cubeMap.fixCubemapSeams : false;
12354
- options.skyboxIntensity = scene.skyboxIntensity !== 1;
12355
- options.useCubeMapRotation = !stdMat.cubeMap && stdMat.useSkybox && scene && scene.skyboxRotation && !scene.skyboxRotation.equals(Quat.IDENTITY);
12356
12348
  var isPhong = stdMat.shadingModel === SPECULAR_PHONG;
12349
+ var usingSceneEnv = false;
12357
12350
 
12358
12351
  if (stdMat.envAtlas && !isPhong) {
12359
12352
  options.reflectionSource = 'envAtlas';
@@ -12367,6 +12360,7 @@
12367
12360
  } else if (stdMat.useSkybox && scene.envAtlas && !isPhong) {
12368
12361
  options.reflectionSource = 'envAtlas';
12369
12362
  options.reflectionEncoding = scene.envAtlas.encoding;
12363
+ usingSceneEnv = true;
12370
12364
  } else {
12371
12365
  options.reflectionSource = null;
12372
12366
  options.reflectionEncoding = null;
@@ -12386,6 +12380,9 @@
12386
12380
  options.ambientEncoding = null;
12387
12381
  }
12388
12382
  }
12383
+
12384
+ options.skyboxIntensity = usingSceneEnv && scene.skyboxIntensity !== 1;
12385
+ options.useCubeMapRotation = usingSceneEnv && scene.skyboxRotation && !scene.skyboxRotation.equals(Quat.IDENTITY);
12389
12386
  };
12390
12387
 
12391
12388
  _proto._updateLightOptions = function _updateLightOptions(options, stdMat, objDefs, sortedLights, staticLightList) {
@@ -34469,7 +34466,7 @@
34469
34466
  };
34470
34467
 
34471
34468
  _proto2._getParser = function _getParser(url) {
34472
- var ext = path.getExtension(this._getUrlWithoutParams(url)).toLowerCase().replace('.', '');
34469
+ var ext = url ? path.getExtension(this._getUrlWithoutParams(url)).toLowerCase().replace('.', '') : null;
34473
34470
  return this.parsers[ext] || this.glbParser;
34474
34471
  };
34475
34472
 
@@ -46855,7 +46852,7 @@
46855
46852
  this._currTransitionTime += dt;
46856
46853
 
46857
46854
  if (this._currTransitionTime <= this._totalTransitionTime) {
46858
- var interpolatedTime = this._totalTransitionTime === 0 ? this._currTransitionTime / this._totalTransitionTime : 1;
46855
+ var interpolatedTime = this._totalTransitionTime !== 0 ? this._currTransitionTime / this._totalTransitionTime : 1;
46859
46856
 
46860
46857
  for (var i = 0; i < this._transitionPreviousStates.length; i++) {
46861
46858
  state = this._findState(this._transitionPreviousStates[i].name);
@@ -68077,7 +68074,7 @@
68077
68074
  if (this._hasAsset()) {
68078
68075
  var asset = this._assets.get(this._asset);
68079
68076
 
68080
- assetDuration = asset.resource ? asset.resource.duration : 0;
68077
+ assetDuration = asset != null && asset.resource ? asset.resource.duration : 0;
68081
68078
  }
68082
68079
 
68083
68080
  if (this._duration != null) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license
3
- * PlayCanvas Engine v1.51.3 revision 6095baac1
4
- * Copyright 2011-2021 PlayCanvas Ltd. All rights reserved.
3
+ * PlayCanvas Engine v1.51.7 revision f3750a326
4
+ * Copyright 2011-2022 PlayCanvas Ltd. All rights reserved.
5
5
  */
6
6
  (function (global, factory) {
7
7
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -634,8 +634,8 @@
634
634
  return result;
635
635
  }();
636
636
 
637
- var version = "1.51.3";
638
- var revision = "6095baac1";
637
+ var version = "1.51.7";
638
+ var revision = "f3750a326";
639
639
  var config = {};
640
640
  var common = {};
641
641
  var apps = {};
@@ -6006,7 +6006,7 @@
6006
6006
 
6007
6007
  var ambientConstantPS = "void addAmbient() {\n\tdDiffuseLight += light_globalAmbient;\n}\n";
6008
6008
 
6009
- var ambientEnvPS = "#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nvoid addAmbient() {\n\tvec3 dir = cubeMapRotate(dNormalW) * vec3(-1.0, 1.0, 1.0);\n\tvec2 uv = mapUv(toSphericalUv(dir), vec4(128.0, 256.0 + 128.0, 64.0, 32.0) / atlasSize);\n\tvec4 raw = texture2D(texture_envAtlas, uv);\n\tvec3 linear = $DECODE(raw);\n\tdDiffuseLight += processEnvironment(linear);\n}\n";
6009
+ var ambientEnvPS = "#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nvoid addAmbient() {\n\tvec3 dir = normalize(cubeMapRotate(dNormalW) * vec3(-1.0, 1.0, 1.0));\n\tvec2 uv = mapUv(toSphericalUv(dir), vec4(128.0, 256.0 + 128.0, 64.0, 32.0) / atlasSize);\n\tvec4 raw = texture2D(texture_envAtlas, uv);\n\tvec3 linear = $DECODE(raw);\n\tdDiffuseLight += processEnvironment(linear);\n}\n";
6010
6010
 
6011
6011
  var ambientSHPS = "uniform vec3 ambientSH[9];\nvoid addAmbient() {\n\tvec3 n = cubeMapRotate(dNormalW);\n\tvec3 color =\n\t\tambientSH[0] +\n\t\tambientSH[1] * n.x +\n\t\tambientSH[2] * n.y +\n\t\tambientSH[3] * n.z +\n\t\tambientSH[4] * n.x * n.z +\n\t\tambientSH[5] * n.z * n.y +\n\t\tambientSH[6] * n.y * n.x +\n\t\tambientSH[7] * (3.0 * n.z * n.z - 1.0) +\n\t\tambientSH[8] * (n.x * n.x - n.y * n.y);\n\tdDiffuseLight += processEnvironment(max(color, vec3(0.0)));\n}\n";
6012
6012
 
@@ -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) - 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);\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";
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\tfloat level2 = shinyMipLevel(uv * atlasSize);\n\tfloat ilevel2 = floor(level2);\n\tvec2 uv0, uv1;\n\tfloat weight;\n\tif (ilevel == 0.0) {\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);\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
 
@@ -11352,7 +11352,7 @@
11352
11352
  var numSamples = samples.length;
11353
11353
  var w = Math.min(numSamples, 512);
11354
11354
  var h = Math.ceil(numSamples / w);
11355
- var data = new Uint8ClampedArray(w * h * 4);
11355
+ var data = new Uint8Array(w * h * 4);
11356
11356
  var off = 0;
11357
11357
 
11358
11358
  for (var i = 0; i < numSamples; ++i) {
@@ -11545,27 +11545,6 @@
11545
11545
  });
11546
11546
  };
11547
11547
 
11548
- var generateMipmaps = function generateMipmaps(target) {
11549
- var device = target.device;
11550
- var result = new Texture(device, {
11551
- name: target.name + '-mipmaps',
11552
- cubemap: target.cubemap,
11553
- width: target.width,
11554
- height: target.height,
11555
- format: target.format,
11556
- type: target.type,
11557
- addressU: target.addressU,
11558
- addressV: target.addressV,
11559
- fixCubemapSeams: target.fixCubemapSeams,
11560
- mipmaps: true
11561
- });
11562
- reprojectTexture(target, result, {
11563
- numSamples: 1
11564
- });
11565
- target.destroy();
11566
- return result;
11567
- };
11568
-
11569
11548
  var EnvLighting = function () {
11570
11549
  function EnvLighting() {}
11571
11550
 
@@ -11580,11 +11559,23 @@
11580
11559
 
11581
11560
  EnvLighting.generateLightingSource = function generateLightingSource(source) {
11582
11561
  var device = source.device;
11583
- var result = createCubemap(device, 128, lightingSourcePixelFormat(device), false);
11562
+ var format = lightingSourcePixelFormat(device);
11563
+ var result = new Texture(device, {
11564
+ name: "lighting-source",
11565
+ cubemap: true,
11566
+ width: 128,
11567
+ height: 128,
11568
+ format: format,
11569
+ type: format === PIXELFORMAT_R8_G8_B8_A8 ? TEXTURETYPE_RGBM : TEXTURETYPE_DEFAULT,
11570
+ addressU: ADDRESS_CLAMP_TO_EDGE,
11571
+ addressV: ADDRESS_CLAMP_TO_EDGE,
11572
+ fixCubemapSeams: false,
11573
+ mipmaps: true
11574
+ });
11584
11575
  reprojectTexture(source, result, {
11585
11576
  numSamples: source.mipmaps ? 1 : 1024
11586
11577
  });
11587
- return generateMipmaps(result);
11578
+ return result;
11588
11579
  };
11589
11580
 
11590
11581
  EnvLighting.generateAtlas = function generateAtlas(source, options) {
@@ -11910,10 +11901,13 @@
11910
11901
  }
11911
11902
 
11912
11903
  meshInstance._material = null;
11913
- var defaultMaterial = DefaultMaterial.get(meshInstance.mesh.device);
11914
11904
 
11915
- if (this !== defaultMaterial) {
11916
- meshInstance.material = defaultMaterial;
11905
+ if (meshInstance.mesh) {
11906
+ var defaultMaterial = DefaultMaterial.get(meshInstance.mesh.device);
11907
+
11908
+ if (this !== defaultMaterial) {
11909
+ meshInstance.material = defaultMaterial;
11910
+ }
11917
11911
  }
11918
11912
  }
11919
11913
  };
@@ -12220,9 +12214,8 @@
12220
12214
  options.toneMap = stdMat.useGammaTonemap ? scene.toneMapping : -1;
12221
12215
  options.useRgbm = stdMat.emissiveMap && stdMat.emissiveMap.type === TEXTURETYPE_RGBM || stdMat.lightMap && stdMat.lightMap.type === TEXTURETYPE_RGBM;
12222
12216
  options.fixSeams = stdMat.cubeMap ? stdMat.cubeMap.fixCubemapSeams : false;
12223
- options.skyboxIntensity = scene.skyboxIntensity !== 1;
12224
- options.useCubeMapRotation = !stdMat.cubeMap && stdMat.useSkybox && scene && scene.skyboxRotation && !scene.skyboxRotation.equals(Quat.IDENTITY);
12225
12217
  var isPhong = stdMat.shadingModel === SPECULAR_PHONG;
12218
+ var usingSceneEnv = false;
12226
12219
 
12227
12220
  if (stdMat.envAtlas && !isPhong) {
12228
12221
  options.reflectionSource = 'envAtlas';
@@ -12236,6 +12229,7 @@
12236
12229
  } else if (stdMat.useSkybox && scene.envAtlas && !isPhong) {
12237
12230
  options.reflectionSource = 'envAtlas';
12238
12231
  options.reflectionEncoding = scene.envAtlas.encoding;
12232
+ usingSceneEnv = true;
12239
12233
  } else {
12240
12234
  options.reflectionSource = null;
12241
12235
  options.reflectionEncoding = null;
@@ -12255,6 +12249,9 @@
12255
12249
  options.ambientEncoding = null;
12256
12250
  }
12257
12251
  }
12252
+
12253
+ options.skyboxIntensity = usingSceneEnv && scene.skyboxIntensity !== 1;
12254
+ options.useCubeMapRotation = usingSceneEnv && scene.skyboxRotation && !scene.skyboxRotation.equals(Quat.IDENTITY);
12258
12255
  };
12259
12256
 
12260
12257
  _proto._updateLightOptions = function _updateLightOptions(options, stdMat, objDefs, sortedLights, staticLightList) {
@@ -33959,7 +33956,7 @@
33959
33956
  };
33960
33957
 
33961
33958
  _proto2._getParser = function _getParser(url) {
33962
- var ext = path.getExtension(this._getUrlWithoutParams(url)).toLowerCase().replace('.', '');
33959
+ var ext = url ? path.getExtension(this._getUrlWithoutParams(url)).toLowerCase().replace('.', '') : null;
33963
33960
  return this.parsers[ext] || this.glbParser;
33964
33961
  };
33965
33962
 
@@ -46293,7 +46290,7 @@
46293
46290
  this._currTransitionTime += dt;
46294
46291
 
46295
46292
  if (this._currTransitionTime <= this._totalTransitionTime) {
46296
- var interpolatedTime = this._totalTransitionTime === 0 ? this._currTransitionTime / this._totalTransitionTime : 1;
46293
+ var interpolatedTime = this._totalTransitionTime !== 0 ? this._currTransitionTime / this._totalTransitionTime : 1;
46297
46294
 
46298
46295
  for (var i = 0; i < this._transitionPreviousStates.length; i++) {
46299
46296
  state = this._findState(this._transitionPreviousStates[i].name);
@@ -67431,7 +67428,7 @@
67431
67428
  if (this._hasAsset()) {
67432
67429
  var asset = this._assets.get(this._asset);
67433
67430
 
67434
- assetDuration = asset.resource ? asset.resource.duration : 0;
67431
+ assetDuration = asset != null && asset.resource ? asset.resource.duration : 0;
67435
67432
  }
67436
67433
 
67437
67434
  if (this._duration != null) {