playcanvas 1.53.1 → 1.53.4

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.53.1 revision 9dc78dbcd
3
+ * PlayCanvas Engine v1.53.4 revision 25b117788
4
4
  * Copyright 2011-2022 PlayCanvas Ltd. All rights reserved.
5
5
  */
6
6
  (function (global, factory) {
@@ -20970,12 +20970,12 @@ declare class AnimComponent extends Component {
20970
20970
  * Removes all layers from the anim component.
20971
20971
  */
20972
20972
  removeStateGraph(): void;
20973
- resetStateGraph(): void;
20974
20973
  /**
20975
20974
  * Reset all of the components layers and parameters to their initial states. If a layer was
20976
20975
  * playing before it will continue playing.
20977
20976
  */
20978
20977
  reset(): void;
20978
+ unbind(): void;
20979
20979
  /**
20980
20980
  * Rebind all of the components layers.
20981
20981
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * PlayCanvas Engine v1.53.1 revision 9dc78dbcd (DEBUG PROFILER)
3
+ * PlayCanvas Engine v1.53.4 revision 25b117788 (DEBUG PROFILER)
4
4
  * Copyright 2011-2022 PlayCanvas Ltd. All rights reserved.
5
5
  */
6
6
  (function (global, factory) {
@@ -586,8 +586,8 @@
586
586
  };
587
587
  };
588
588
 
589
- var version = "1.53.1";
590
- var revision = "9dc78dbcd";
589
+ var version = "1.53.4";
590
+ var revision = "25b117788";
591
591
  var config = {};
592
592
  var common = {};
593
593
  var apps = {};
@@ -6094,7 +6094,7 @@
6094
6094
 
6095
6095
  var bakeLmEndPS = "\tgl_FragColor.rgb = dDiffuseLight;\n\tgl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(0.5));\n\tgl_FragColor.rgb /= 8.0;\n\tgl_FragColor.a = clamp( max( max( gl_FragColor.r, gl_FragColor.g ), max( gl_FragColor.b, 1.0 / 255.0 ) ), 0.0,1.0 );\n\tgl_FragColor.a = ceil(gl_FragColor.a * 255.0) / 255.0;\n\tgl_FragColor.rgb /= gl_FragColor.a;\n";
6096
6096
 
6097
- var basePS = "uniform vec3 view_position;\n\nuniform vec3 light_globalAmbient;\n\nuniform float textureBias;\n\nfloat square(float x) {\n\treturn x*x;\n}\n\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\n\nvec3 saturate(vec3 x) {\n\treturn clamp(x, vec3(0.0), vec3(1.0));\n}\n";
6097
+ var basePS = "uniform vec3 view_position;\n\nuniform vec3 light_globalAmbient;\n\nfloat square(float x) {\n\treturn x*x;\n}\n\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\n\nvec3 saturate(vec3 x) {\n\treturn clamp(x, vec3(0.0), vec3(1.0));\n}\n";
6098
6098
 
6099
6099
  var baseVS = "attribute vec3 vertex_position;\nattribute vec3 vertex_normal;\nattribute vec4 vertex_tangent;\nattribute vec2 vertex_texCoord0;\nattribute vec2 vertex_texCoord1;\nattribute vec4 vertex_color;\n\nuniform mat4 matrix_viewProjection;\nuniform mat4 matrix_model;\nuniform mat3 matrix_normal;\n\nvec3 dPositionW;\nmat4 dModelMatrix;\nmat3 dNormalMatrix;\n";
6100
6100
 
@@ -6108,11 +6108,11 @@
6108
6108
 
6109
6109
  var blurVSMPS = "varying vec2 vUv0;\n\nuniform sampler2D source;\nuniform vec2 pixelOffset;\n\n#ifdef GAUSS\nuniform float weight[SAMPLES];\n#endif\n\n#ifdef PACKED\nfloat decodeFloatRG(vec2 rg) {\n\treturn rg.y*(1.0/255.0) + rg.x;\n}\n\nvec2 encodeFloatRG( float v ) {\n\tvec2 enc = vec2(1.0, 255.0) * v;\n\tenc = fract(enc);\n\tenc -= enc.yy * vec2(1.0/255.0, 1.0/255.0);\n\treturn enc;\n}\n#endif\n\nvoid main(void) {\n\tvec3 moments = vec3(0.0);\n\tvec2 uv = vUv0 - pixelOffset * (float(SAMPLES) * 0.5);\n\tfor (int i=0; i<SAMPLES; i++) {\n\t\tvec4 c = texture2D(source, uv + pixelOffset * float(i));\n\n\t\t#ifdef PACKED\n\t\tc.xy = vec2(decodeFloatRG(c.xy), decodeFloatRG(c.zw));\n\t\t#endif\n\n\t\t#ifdef GAUSS\n\t\tmoments += c.xyz * weight[i];\n\t\t#else\n\t\tmoments += c.xyz;\n\t\t#endif\n\t}\n\n\t#ifndef GAUSS\n\tmoments /= float(SAMPLES);\n\t#endif\n\n\t#ifdef PACKED\n\tgl_FragColor = vec4(encodeFloatRG(moments.x), encodeFloatRG(moments.y));\n\t#else\n\tgl_FragColor = vec4(moments.x, moments.y, moments.z, 1.0);\n\t#endif\n}\n";
6110
6110
 
6111
- var clearCoatPS = "#ifdef MAPFLOAT\nuniform float material_clearCoat;\n#endif\n\n#ifdef MAPTEXTURE\nuniform sampler2D texture_clearCoatMap;\n#endif\n\nvoid getClearCoat() {\n\tccSpecularity = 1.0;\n\n\t#ifdef MAPFLOAT\n\tccSpecularity *= material_clearCoat;\n\t#endif\n\n\t#ifdef MAPTEXTURE\n\tccSpecularity *= texture2D(texture_clearCoatMap, $UV).$CH;\n\t#endif\n\n\t#ifdef MAPVERTEX\n\tccSpecularity *= saturate(vVertexColor.$VC);\n\t#endif\n}\n";
6111
+ var clearCoatPS = "#ifdef MAPFLOAT\nuniform float material_clearCoat;\n#endif\n\n#ifdef MAPTEXTURE\nuniform sampler2D texture_clearCoatMap;\n#endif\n\nvoid getClearCoat() {\n\tccSpecularity = 1.0;\n\n\t#ifdef MAPFLOAT\n\tccSpecularity *= material_clearCoat;\n\t#endif\n\n\t#ifdef MAPTEXTURE\n\tccSpecularity *= texture2D(texture_clearCoatMap, $UV, textureBias).$CH;\n\t#endif\n\n\t#ifdef MAPVERTEX\n\tccSpecularity *= saturate(vVertexColor.$VC);\n\t#endif\n}\n";
6112
6112
 
6113
- var clearCoatGlossPS = "#ifdef MAPFLOAT\nuniform float material_clearCoatGlossiness;\n#endif\n\n#ifdef MAPTEXTURE\nuniform sampler2D texture_clearCoatGlossMap;\n#endif\n\nvoid getClearCoatGlossiness() {\n\tccGlossiness = 1.0;\n\n\t#ifdef MAPFLOAT\n\tccGlossiness *= material_clearCoatGlossiness;\n\t#endif\n\n\t#ifdef MAPTEXTURE\n\tccGlossiness *= texture2D(texture_clearCoatGlossMap, $UV).$CH;\n\t#endif\n\n\t#ifdef MAPVERTEX\n\tccGlossiness *= saturate(vVertexColor.$VC);\n\t#endif\n\n\tccGlossiness += 0.0000001;\n}\n";
6113
+ var clearCoatGlossPS = "#ifdef MAPFLOAT\nuniform float material_clearCoatGlossiness;\n#endif\n\n#ifdef MAPTEXTURE\nuniform sampler2D texture_clearCoatGlossMap;\n#endif\n\nvoid getClearCoatGlossiness() {\n\tccGlossiness = 1.0;\n\n\t#ifdef MAPFLOAT\n\tccGlossiness *= material_clearCoatGlossiness;\n\t#endif\n\n\t#ifdef MAPTEXTURE\n\tccGlossiness *= texture2D(texture_clearCoatGlossMap, $UV, textureBias).$CH;\n\t#endif\n\n\t#ifdef MAPVERTEX\n\tccGlossiness *= saturate(vVertexColor.$VC);\n\t#endif\n\n\tccGlossiness += 0.0000001;\n}\n";
6114
6114
 
6115
- var clearCoatNormalPS = "#ifdef MAPTEXTURE\nuniform sampler2D texture_clearCoatNormalMap;\nuniform float material_clearCoatBumpiness;\n#endif\n\nvoid getClearCoatNormal() {\n\t#ifdef MAPTEXTURE\n\tvec3 normalMap = unpackNormal(texture2D(texture_clearCoatNormalMap, $UV));\n\tnormalMap = normalize(mix(vec3(0.0, 0.0, 1.0), normalMap, material_clearCoatBumpiness));\n\tccNormalW = dTBN * normalMap;\n\t#else\n\tccNormalW = normalize(dVertexNormalW);\n\t#endif\n\n\tccReflDirW = normalize(-reflect(dViewDirW, ccNormalW));\n}\n";
6115
+ var clearCoatNormalPS = "#ifdef MAPTEXTURE\nuniform sampler2D texture_clearCoatNormalMap;\nuniform float material_clearCoatBumpiness;\n#endif\n\nvoid getClearCoatNormal() {\n\t#ifdef MAPTEXTURE\n\tvec3 normalMap = unpackNormal(texture2D(texture_clearCoatNormalMap, $UV, textureBias));\n\tnormalMap = normalize(mix(vec3(0.0, 0.0, 1.0), normalMap, material_clearCoatBumpiness));\n\tccNormalW = dTBN * normalMap;\n\t#else\n\tccNormalW = normalize(dVertexNormalW);\n\t#endif\n\n\tccReflDirW = normalize(-reflect(dViewDirW, ccNormalW));\n}\n";
6116
6116
 
6117
6117
  var clusteredLightUtilsPS = "// Converts unnormalized direction vector to a cubemap face index [0..5] and uv coordinates within the face in [0..1] range.\n// Additionally offset to a tile in atlas within 3x3 subdivision is provided\nvec2 getCubemapFaceCoordinates(const vec3 dir, out float faceIndex, out vec2 tileOffset)\n{\n\tvec3 vAbs = abs(dir);\n\tfloat ma;\n\tvec2 uv;\n\tif (vAbs.z >= vAbs.x && vAbs.z >= vAbs.y) { // front / back\n\n\t\tfaceIndex = dir.z < 0.0 ? 5.0 : 4.0;\n\t\tma = 0.5 / vAbs.z;\n\t\tuv = vec2(dir.z < 0.0 ? -dir.x : dir.x, -dir.y);\n\n\t\ttileOffset.x = 2.0;\n\t\ttileOffset.y = dir.z < 0.0 ? 1.0 : 0.0;\n\n\t} else if(vAbs.y >= vAbs.x) { // top index 2, bottom index 3\n\n\t\tfaceIndex = dir.y < 0.0 ? 3.0 : 2.0;\n\t\tma = 0.5 / vAbs.y;\n\t\tuv = vec2(dir.x, dir.y < 0.0 ? -dir.z : dir.z);\n\n\t\ttileOffset.x = 1.0;\n\t\ttileOffset.y = dir.y < 0.0 ? 1.0 : 0.0;\n\n\t} else {\t// left / right\n\n\t\tfaceIndex = dir.x < 0.0 ? 1.0 : 0.0;\n\t\tma = 0.5 / vAbs.x;\n\t\tuv = vec2(dir.x < 0.0 ? dir.z : -dir.z, -dir.y);\n\n\t\ttileOffset.x = 0.0;\n\t\ttileOffset.y = dir.x < 0.0 ? 1.0 : 0.0;\n\n\t}\n\treturn uv * ma + 0.5;\n}\n\n// converts unnormalized direction vector to a texture coordinate for a cubemap face stored within texture atlas described by the viewport\nvec2 getCubemapAtlasCoordinates(const vec3 omniAtlasViewport, float shadowEdgePixels, float shadowTextureResolution, const vec3 dir) {\n\n\tfloat faceIndex;\n\tvec2 tileOffset;\n\tvec2 uv = getCubemapFaceCoordinates(dir, faceIndex, tileOffset);\n\n\t// move uv coordinates inwards inside to compensate for larger fov when rendering shadow into atlas\n\tfloat atlasFaceSize = omniAtlasViewport.z;\n\tfloat tileSize = shadowTextureResolution * atlasFaceSize;\n\tfloat offset = shadowEdgePixels / tileSize;\n\tuv = uv * vec2(1.0 - offset * 2.0) + vec2(offset * 1.0);\n\n\t// scale uv coordinates to cube face area within the viewport\n\tuv *= atlasFaceSize;\n\n\t// offset into face of the atlas (3x3 grid)\n\tuv += tileOffset * atlasFaceSize;\n\n\t// offset into the atlas viewport\n\tuv += omniAtlasViewport.xy;\n\n\treturn uv;\n}\n";
6118
6118
 
@@ -6150,13 +6150,13 @@
6150
6150
 
6151
6151
  var diffusePS = "#ifdef MAPCOLOR\nuniform vec3 material_diffuse;\n#endif\n\n#ifdef MAPTEXTURE\nuniform sampler2D texture_diffuseMap;\n#endif\n\nvoid getAlbedo() {\n\tdAlbedo = vec3(1.0);\n\n\t#ifdef MAPCOLOR\n\tdAlbedo *= material_diffuse.rgb;\n\t#endif\n\n\t#ifdef MAPTEXTURE\n\tdAlbedo *= gammaCorrectInput(addAlbedoDetail(texture2D(texture_diffuseMap, $UV, textureBias).$CH));\n\t#endif\n\n\t#ifdef MAPVERTEX\n\tdAlbedo *= gammaCorrectInput(saturate(vVertexColor.$VC));\n\t#endif\n}\n";
6152
6152
 
6153
- var diffuseDetailMapPS = "#ifdef MAPTEXTURE\nuniform sampler2D texture_diffuseDetailMap;\n#endif\n\nvec3 addAlbedoDetail(vec3 albedo) {\n\t#ifdef MAPTEXTURE\n\tvec3 albedoDetail = vec3(texture2D(texture_diffuseDetailMap, $UV).$CH);\n\treturn detailMode_$DETAILMODE(albedo, albedoDetail);\n\t#else\n\treturn albedo;\n\t#endif\n}\n";
6153
+ var diffuseDetailMapPS = "#ifdef MAPTEXTURE\nuniform sampler2D texture_diffuseDetailMap;\n#endif\n\nvec3 addAlbedoDetail(vec3 albedo) {\n\t#ifdef MAPTEXTURE\n\tvec3 albedoDetail = vec3(texture2D(texture_diffuseDetailMap, $UV, textureBias).$CH);\n\treturn detailMode_$DETAILMODE(albedo, albedoDetail);\n\t#else\n\treturn albedo;\n\t#endif\n}\n";
6154
6154
 
6155
6155
  var dilatePS = "#define SHADER_NAME Dilate\n\nvarying vec2 vUv0;\n\nuniform sampler2D source;\nuniform vec2 pixelOffset;\n\nvoid main(void) {\n\tvec4 c = texture2D(source, vUv0);\n\tc = c.a>0.0? c : texture2D(source, vUv0 - pixelOffset);\n\tc = c.a>0.0? c : texture2D(source, vUv0 + vec2(0, -pixelOffset.y));\n\tc = c.a>0.0? c : texture2D(source, vUv0 + vec2(pixelOffset.x, -pixelOffset.y));\n\tc = c.a>0.0? c : texture2D(source, vUv0 + vec2(-pixelOffset.x, 0));\n\tc = c.a>0.0? c : texture2D(source, vUv0 + vec2(pixelOffset.x, 0));\n\tc = c.a>0.0? c : texture2D(source, vUv0 + vec2(-pixelOffset.x, pixelOffset.y));\n\tc = c.a>0.0? c : texture2D(source, vUv0 + vec2(0, pixelOffset.y));\n\tc = c.a>0.0? c : texture2D(source, vUv0 + pixelOffset);\n\tgl_FragColor = c;\n}\n";
6156
6156
 
6157
6157
  var bilateralDeNoisePS = "// bilateral filter, based on https://www.shadertoy.com/view/4dfGDH# and\n// http://people.csail.mit.edu/sparis/bf_course/course_notes.pdf\n\n// A bilateral filter is a non-linear, edge-preserving, and noise-reducing smoothing filter for images.\n// It replaces the intensity of each pixel with a weighted average of intensity values from nearby pixels.\n// This weight can be based on a Gaussian distribution. Crucially, the weights depend not only on\n// Euclidean distance of pixels, but also on the radiometric differences (e.g., range differences, such\n// as color intensity, depth distance, etc.). This preserves sharp edges.\n\n#define SHADER_NAME BilateralDeNoise\n\nfloat normpdf3(in vec3 v, in float sigma) {\n\treturn 0.39894 * exp(-0.5 * dot(v, v) / (sigma * sigma)) / sigma;\n}\n\nvec3 decodeRGBM(vec4 rgbm) {\n\tvec3 color = (8.0 * rgbm.a) * rgbm.rgb;\n\treturn color * color;\n}\n\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\n\nvec4 encodeRGBM(vec3 color) { // modified RGBM\n\tvec4 encoded;\n\tencoded.rgb = pow(color.rgb, vec3(0.5));\n\tencoded.rgb *= 1.0 / 8.0;\n\n\tencoded.a = saturate( max( max( encoded.r, encoded.g ), max( encoded.b, 1.0 / 255.0 ) ) );\n\tencoded.a = ceil(encoded.a * 255.0) / 255.0;\n\n\tencoded.rgb /= encoded.a;\n\treturn encoded;\n}\n\n// filter size\n#define MSIZE 15\n\nvarying vec2 vUv0;\nuniform sampler2D source;\nuniform vec2 pixelOffset;\nuniform vec2 sigmas;\nuniform float bZnorm;\nuniform float kernel[MSIZE];\n\nvoid main(void) {\n\t\n\tvec4 pixelRgbm = texture2D(source, vUv0);\n\n\t// lightmap specific optimization - skip pixels that were not baked\n\t// this also allows dilate filter that work on the output of this to work correctly, as it depends on .a being zero\n\t// to dilate, which the following blur filter would otherwise modify\n\tif (pixelRgbm.a <= 0.0) {\n\t\tgl_FragColor = pixelRgbm;\n\t\treturn ;\n\t}\n\n\t// range sigma - controls blurriness based on a pixel distance\n\tfloat sigma = sigmas.x;\n\n\t// domain sigma - controls blurriness based on a pixel similarity (to preserve edges)\n\tfloat bSigma = sigmas.y;\n\n\tvec3 pixelHdr = decodeRGBM(pixelRgbm);\n\tvec3 accumulatedHdr = vec3(0.0);\n\tfloat accumulatedFactor = 0.0;\n\n\t// read out the texels\n\tconst int kSize = (MSIZE-1)/2;\n\tfor (int i = -kSize; i <= kSize; ++i) {\n\t\tfor (int j = -kSize; j <= kSize; ++j) {\n\t\t\t\n\t\t\t// sample the pixel with offset\n\t\t\tvec2 coord = vUv0 + vec2(float(i), float(j)) * pixelOffset;\n\t\t\tvec4 rgbm = texture2D(source, coord);\n\n\t\t\t// lightmap - only use baked pixels\n\t\t\tif (rgbm.a > 0.0) {\n\t\t\t\tvec3 hdr = decodeRGBM(rgbm);\n\n\t\t\t\t// bilateral factors\n\t\t\t\tfloat factor = kernel[kSize + j] * kernel[kSize + i];\n\t\t\t\tfactor *= normpdf3(hdr - pixelHdr, bSigma) * bZnorm;\n\n\t\t\t\t// accumulate\n\t\t\t\taccumulatedHdr += factor * hdr;\n\t\t\t\taccumulatedFactor += factor;\n\t\t\t}\n\t\t}\n\t}\n\n\tgl_FragColor = encodeRGBM(accumulatedHdr / accumulatedFactor);\n}\n";
6158
6158
 
6159
- var emissivePS = "#ifdef MAPCOLOR\nuniform vec3 material_emissive;\n#endif\n\n#ifdef MAPFLOAT\nuniform float material_emissiveIntensity;\n#endif\n\n#ifdef MAPTEXTURE\nuniform sampler2D texture_emissiveMap;\n#endif\n\nvec3 getEmission() {\n\tvec3 emission = vec3(1.0);\n\n\t#ifdef MAPFLOAT\n\temission *= material_emissiveIntensity;\n\t#endif\n\n\t#ifdef MAPCOLOR\n\temission *= material_emissive;\n\t#endif\n\n\t#ifdef MAPTEXTURE\n\temission *= $texture2DSAMPLE(texture_emissiveMap, $UV).$CH;\n\t#endif\n\n\t#ifdef MAPVERTEX\n\temission *= gammaCorrectInput(saturate(vVertexColor.$VC));\n\t#endif\n\n\treturn emission;\n}\n";
6159
+ var emissivePS = "#ifdef MAPCOLOR\nuniform vec3 material_emissive;\n#endif\n\n#ifdef MAPFLOAT\nuniform float material_emissiveIntensity;\n#endif\n\n#ifdef MAPTEXTURE\nuniform sampler2D texture_emissiveMap;\n#endif\n\nvec3 getEmission() {\n\tvec3 emission = vec3(1.0);\n\n\t#ifdef MAPFLOAT\n\temission *= material_emissiveIntensity;\n\t#endif\n\n\t#ifdef MAPCOLOR\n\temission *= material_emissive;\n\t#endif\n\n\t#ifdef MAPTEXTURE\n\temission *= $texture2DSAMPLE(texture_emissiveMap, $UV, textureBias).$CH;\n\t#endif\n\n\t#ifdef MAPVERTEX\n\temission *= gammaCorrectInput(saturate(vVertexColor.$VC));\n\t#endif\n\n\treturn emission;\n}\n";
6160
6160
 
6161
6161
  var endPS = "\t#ifdef CLEARCOAT\n\tgl_FragColor.rgb = combineColorCC();\n\t#else\n\tgl_FragColor.rgb = combineColor();\n\t#endif \n\n\tgl_FragColor.rgb += getEmission();\n\tgl_FragColor.rgb = addFog(gl_FragColor.rgb);\n\n\t#ifndef HDR\n\tgl_FragColor.rgb = toneMap(gl_FragColor.rgb);\n\tgl_FragColor.rgb = gammaCorrectOutput(gl_FragColor.rgb);\n\t#endif\n";
6162
6162
 
@@ -6202,7 +6202,7 @@
6202
6202
 
6203
6203
  var gles3VS = "#define attribute in\n#define varying out\n#define texture2D texture\n#define GL2\n#define VERTEXSHADER\n";
6204
6204
 
6205
- var glossPS = "#ifdef MAPFLOAT\nuniform float material_shininess;\n#endif\n\n#ifdef MAPTEXTURE\nuniform sampler2D texture_glossMap;\n#endif\n\nvoid getGlossiness() {\n\tdGlossiness = 1.0;\n\n\t#ifdef MAPFLOAT\n\tdGlossiness *= material_shininess;\n\t#endif\n\n\t#ifdef MAPTEXTURE\n\tdGlossiness *= texture2D(texture_glossMap, $UV).$CH;\n\t#endif\n\n\t#ifdef MAPVERTEX\n\tdGlossiness *= saturate(vVertexColor.$VC);\n\t#endif\n\n\tdGlossiness += 0.0000001;\n}\n";
6205
+ var glossPS = "#ifdef MAPFLOAT\nuniform float material_shininess;\n#endif\n\n#ifdef MAPTEXTURE\nuniform sampler2D texture_glossMap;\n#endif\n\nvoid getGlossiness() {\n\tdGlossiness = 1.0;\n\n\t#ifdef MAPFLOAT\n\tdGlossiness *= material_shininess;\n\t#endif\n\n\t#ifdef MAPTEXTURE\n\tdGlossiness *= texture2D(texture_glossMap, $UV, textureBias).$CH;\n\t#endif\n\n\t#ifdef MAPVERTEX\n\tdGlossiness *= saturate(vVertexColor.$VC);\n\t#endif\n\n\tdGlossiness += 0.0000001;\n}\n";
6206
6206
 
6207
6207
  var instancingVS = "attribute vec4 instance_line1;\nattribute vec4 instance_line2;\nattribute vec4 instance_line3;\nattribute vec4 instance_line4;\n";
6208
6208
 
@@ -6210,9 +6210,9 @@
6210
6210
 
6211
6211
  var lightDirPointPS = "void getLightDirPoint(vec3 lightPosW) {\n\tdLightDirW = vPositionW - lightPosW;\n\tdLightDirNormW = normalize(dLightDirW);\n\tdLightPosW = lightPosW;\n}\n";
6212
6212
 
6213
- var lightmapDirPS = "uniform sampler2D texture_lightMap;\nuniform sampler2D texture_dirLightMap;\n\nvoid addLightMap() {\n\tvec3 color = $texture2DSAMPLE(texture_lightMap, $UV).$CH;\n\tvec3 dir = texture2D(texture_dirLightMap, $UV).xyz;\n\tif (dot(dir, vec3(1.0)) < 0.00001) {\n\t\tdDiffuseLight += color;\n\t} else {\n\t\tdLightDirNormW = normalize(dir * 2.0 - vec3(1.0));\n\n\t\tfloat vlight = saturate(dot(dLightDirNormW, -dVertexNormalW));\n\t\tfloat flight = saturate(dot(dLightDirNormW, -dNormalW));\n\t\tfloat nlight = (flight / max(vlight, 0.01)) * 0.5;\n\n\t\tdDiffuseLight += color * nlight * 2.0;\n\t}\n\n\tdSpecularLight += color * getLightSpecular();\n}\n";
6213
+ var lightmapDirPS = "uniform sampler2D texture_lightMap;\nuniform sampler2D texture_dirLightMap;\n\nvoid addLightMap() {\n\tvec3 color = $texture2DSAMPLE(texture_lightMap, $UV, textureBias).$CH;\n\tvec3 dir = texture2D(texture_dirLightMap, $UV, textureBias).xyz;\n\tif (dot(dir, vec3(1.0)) < 0.00001) {\n\t\tdDiffuseLight += color;\n\t} else {\n\t\tdLightDirNormW = normalize(dir * 2.0 - vec3(1.0));\n\n\t\tfloat vlight = saturate(dot(dLightDirNormW, -dVertexNormalW));\n\t\tfloat flight = saturate(dot(dLightDirNormW, -dNormalW));\n\t\tfloat nlight = (flight / max(vlight, 0.01)) * 0.5;\n\n\t\tdDiffuseLight += color * nlight * 2.0;\n\t}\n\n\tdSpecularLight += color * getLightSpecular();\n}\n";
6214
6214
 
6215
- var lightmapSinglePS = "#ifdef MAPTEXTURE\nuniform sampler2D texture_lightMap;\n#endif\n\nvoid addLightMap() {\n\tvec3 lm = vec3(1.0);\n\n\t#ifdef MAPTEXTURE\n\tlm *= $texture2DSAMPLE(texture_lightMap, $UV).$CH;\n\t#endif\n\n\t#ifdef MAPVERTEX\n\tlm *= saturate(vVertexColor.$VC);\n\t#endif\n\t\n\tdDiffuseLight += lm;\n}\n";
6215
+ var lightmapSinglePS = "#ifdef MAPTEXTURE\nuniform sampler2D texture_lightMap;\n#endif\n\nvoid addLightMap() {\n\tvec3 lm = vec3(1.0);\n\n\t#ifdef MAPTEXTURE\n\tlm *= $texture2DSAMPLE(texture_lightMap, $UV, textureBias).$CH;\n\t#endif\n\n\t#ifdef MAPVERTEX\n\tlm *= saturate(vVertexColor.$VC);\n\t#endif\n\t\n\tdDiffuseLight += lm;\n}\n";
6216
6216
 
6217
6217
  var lightmapSingleVertPS = "void addLightMap() {\n\tdDiffuseLight += saturate(vVertexColor.$CH);\n}\n";
6218
6218
 
@@ -6362,7 +6362,7 @@
6362
6362
 
6363
6363
  var reprojectPS = "// This shader requires the following #DEFINEs:\n//\n// PROCESS_FUNC - must be one of reproject, prefilter\n// DECODE_FUNC - must be one of decodeRGBM, decodeRGBE, decodeGamma or decodeLinear\n// ENCODE_FUNC - must be one of encodeRGBM, encodeRGBE, encideGamma or encodeLinear\n// SOURCE_FUNC - must be one of sampleCubemap, sampleEquirect, sampleOctahedral\n// TARGET_FUNC - must be one of getDirectionCubemap, getDirectionEquirect, getDirectionOctahedral\n//\n// When filtering:\n// NUM_SAMPLES - number of samples\n//\n// SUPPORTS_TEXLOD - whether supports texlod is supported\n\nvarying vec2 vUv0;\n\n// source\nuniform sampler2D sourceTex;\nuniform samplerCube sourceCube;\n\n// samples\nuniform sampler2D samplesTex;\nuniform vec2 samplesTexInverseSize;\n\n// params:\n// x - target cubemap face 0..6\n// y - specular power (when prefiltering)\n// z - source cubemap seam scale (0 to disable)\n// w - target cubemap size for seam calc (0 to disable)\nuniform vec4 params;\n\n// params2:\n// x - target image total pixels\n// y - source cubemap size\nuniform vec2 params2;\n\nfloat targetFace() { return params.x; }\nfloat specularPower() { return params.y; }\nfloat sourceCubeSeamScale() { return params.z; }\nfloat targetCubeSeamScale() { return params.w; }\n\nfloat targetTotalPixels() { return params2.x; }\nfloat sourceTotalPixels() { return params2.y; }\n\nfloat PI = 3.141592653589793;\n\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\n\n//-- supported codings\n\nvec3 decodeLinear(vec4 source) {\n\treturn source.rgb;\n}\n\nvec4 encodeLinear(vec3 source) {\n\treturn vec4(source, 1.0);\n}\n\nvec3 decodeGamma(vec4 source) {\n\treturn pow(source.xyz, vec3(2.2));\n}\n\nvec4 encodeGamma(vec3 source) {\n\treturn vec4(pow(source + 0.0000001, vec3(1.0 / 2.2)), 1.0);\n}\n\nvec3 decodeRGBM(vec4 rgbm) {\n\tvec3 color = (8.0 * rgbm.a) * rgbm.rgb;\n\treturn color * color;\n}\n\nvec4 encodeRGBM(vec3 source) { // modified RGBM\n\tvec4 result;\n\tresult.rgb = pow(source.rgb, vec3(0.5));\n\tresult.rgb *= 1.0 / 8.0;\n\n\tresult.a = saturate( max( max( result.r, result.g ), max( result.b, 1.0 / 255.0 ) ) );\n\tresult.a = ceil(result.a * 255.0) / 255.0;\n\n\tresult.rgb /= result.a;\n\treturn result;\n}\n\nvec3 decodeRGBE(vec4 source) {\n\tif (source.a == 0.0) {\n\t\treturn vec3(0.0, 0.0, 0.0);\n\t} else {\n\t\treturn source.xyz * pow(2.0, source.w * 255.0 - 128.0);\n\t}\n}\n\nvec4 encodeRGBE(vec3 source) {\n\tfloat maxVal = max(source.x, max(source.y, source.z));\n\tif (maxVal < 1e-32) {\n\t\treturn vec4(0, 0, 0, 0);\n\t} else {\n\t\tfloat e = ceil(log2(maxVal));\n\t\treturn vec4(source / pow(2.0, e), (e + 128.0) / 255.0);\n\t}\n}\n\n//-- supported projections\n\nvec3 modifySeams(vec3 dir, float scale) {\n\tvec3 adir = abs(dir);\n\tfloat M = max(max(adir.x, adir.y), adir.z);\n\treturn dir / M * vec3(\n\t\tadir.x == M ? 1.0 : scale,\n\t\tadir.y == M ? 1.0 : scale,\n\t\tadir.z == M ? 1.0 : scale\n\t);\n}\n\nvec2 toSpherical(vec3 dir) {\n\treturn vec2(dir.xz == vec2(0.0) ? 0.0 : atan(dir.x, dir.z), asin(dir.y));\n}\n\nvec3 fromSpherical(vec2 uv) {\n\treturn vec3(cos(uv.y) * sin(uv.x),\n\t\t\t\tsin(uv.y),\n\t\t\t\tcos(uv.y) * cos(uv.x));\n}\n\nvec3 getDirectionEquirect() {\n\treturn fromSpherical((vec2(vUv0.x, 1.0 - vUv0.y) * 2.0 - 1.0) * vec2(PI, PI * 0.5));\n}\n\nvec4 sampleEquirect(vec2 sph) {\n\tvec2 uv = sph / vec2(PI * 2.0, PI) + 0.5;\n\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n}\n\nvec4 sampleEquirect(vec3 dir) {\n\treturn sampleEquirect(toSpherical(dir));\n}\n\nvec4 sampleCubemap(vec3 dir) {\n\treturn textureCube(sourceCube, modifySeams(dir, 1.0 - sourceCubeSeamScale()));\n}\n\nvec4 sampleCubemap(vec2 sph) {\n\treturn sampleCubemap(fromSpherical(sph));\n}\n\nvec4 sampleEquirect(vec2 sph, float mipLevel) {\n\tvec2 uv = sph / vec2(PI * 2.0, PI) + 0.5;\n#ifdef SUPPORTS_TEXLOD\n\treturn texture2DLodEXT(sourceTex, vec2(uv.x, 1.0 - uv.y), mipLevel);\n#else\n\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n#endif\n}\n\nvec4 sampleEquirect(vec3 dir, float mipLevel) {\n\treturn sampleEquirect(toSpherical(dir), mipLevel);\n}\n\nvec4 sampleCubemap(vec3 dir, float mipLevel) {\n#ifdef SUPPORTS_TEXLOD\n\treturn textureCubeLodEXT(sourceCube, modifySeams(dir, 1.0 - exp2(mipLevel) * sourceCubeSeamScale()), mipLevel);\n#else\n\treturn textureCube(sourceCube, modifySeams(dir, 1.0 - exp2(mipLevel) * sourceCubeSeamScale()));\n#endif\n}\n\nvec4 sampleCubemap(vec2 sph, float mipLevel) {\n\treturn sampleCubemap(fromSpherical(sph), mipLevel);\n}\n\n// octahedral code, based on http://jcgt.org/published/0003/02/01\n// \"Survey of Efficient Representations for Independent Unit Vectors\" by Cigolle, Donow, Evangelakos, Mara, McGuire, Meyer\n\nfloat signNotZero(float k){\n\treturn(k >= 0.0) ? 1.0 : -1.0;\n}\n\nvec2 signNotZero(vec2 v) {\n\treturn vec2(signNotZero(v.x), signNotZero(v.y));\n}\n\n// Returns a unit vector. Argument o is an octahedral vector packed via octEncode, on the [-1, +1] square\nvec3 octDecode(vec2 o) {\n\tvec3 v = vec3(o.x, 1.0 - abs(o.x) - abs(o.y), o.y);\n\tif (v.y < 0.0) {\n\t\tv.xz = (1.0 - abs(v.zx)) * signNotZero(v.xz);\n\t}\n\treturn normalize(v);\n}\n\nvec3 getDirectionOctahedral() {\n\treturn octDecode(vec2(vUv0.x, 1.0 - vUv0.y) * 2.0 - 1.0);\n}\n\n// Assumes that v is a unit vector. The result is an octahedral vector on the [-1, +1] square\nvec2 octEncode(in vec3 v) {\n\tfloat l1norm = abs(v.x) + abs(v.y) + abs(v.z);\n\tvec2 result = v.xz * (1.0 / l1norm);\n\tif (v.y < 0.0) {\n\t\tresult = (1.0 - abs(result.yx)) * signNotZero(result.xy);\n\t}\n\treturn result;\n}\n\nvec4 sampleOctahedral(vec3 dir) {\n\tvec2 uv = octEncode(dir) * 0.5 + 0.5;\n\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n}\n\nvec4 sampleOctahedral(vec2 sph) {\n\treturn sampleOctahedral(fromSpherical(sph));\n}\n\nvec4 sampleOctahedral(vec3 dir, float mipLevel) {\n\tvec2 uv = octEncode(dir) * 0.5 + 0.5;\n#ifdef SUPPORTS_TEXLOD\n\treturn texture2DLodEXT(sourceTex, vec2(uv.x, 1.0 - uv.y), mipLevel);\n#else\n\treturn texture2D(sourceTex, vec2(uv.x, 1.0 - uv.y));\n#endif\n}\n\nvec4 sampleOctahedral(vec2 sph, float mipLevel) {\n\treturn sampleOctahedral(fromSpherical(sph), mipLevel);\n}\n\n/////////////////////////////////////////////////////////////////////\n\nvec3 getDirectionCubemap() {\n\tvec2 st = vUv0 * 2.0 - 1.0;\n\tfloat face = targetFace();\n\n\tvec3 vec;\n\tif (face == 0.0) {\n\t\tvec = vec3(1, -st.y, -st.x);\n\t} else if (face == 1.0) {\n\t\tvec = vec3(-1, -st.y, st.x);\n\t} else if (face == 2.0) {\n\t\tvec = vec3(st.x, 1, st.y);\n\t} else if (face == 3.0) {\n\t\tvec = vec3(st.x, -1, -st.y);\n\t} else if (face == 4.0) {\n\t\tvec = vec3(st.x, -st.y, 1);\n\t} else {\n\t\tvec = vec3(-st.x, -st.y, -1);\n\t}\n\n\treturn normalize(modifySeams(vec, 1.0 / (1.0 - targetCubeSeamScale())));\n}\n\nmat3 matrixFromVector(vec3 n) { // frisvad\n\tfloat a = 1.0 / (1.0 + n.z);\n\tfloat b = -n.x * n.y * a;\n\tvec3 b1 = vec3(1.0 - n.x * n.x * a, b, -n.x);\n\tvec3 b2 = vec3(b, 1.0 - n.y * n.y * a, -n.y);\n\treturn mat3(b1, b2, n);\n}\n\nmat3 matrixFromVectorSlow(vec3 n) {\n\tvec3 up = (1.0 - abs(n.y) <= 0.0000001) ? vec3(0.0, 0.0, n.y > 0.0 ? 1.0 : -1.0) : vec3(0.0, 1.0, 0.0);\n\tvec3 x = normalize(cross(up, n));\n\tvec3 y = cross(n, x);\n\treturn mat3(x, y, n);\n}\n\nvec4 reproject() {\n\tif (NUM_SAMPLES <= 1) {\n\t\t// single sample\n\t\treturn ENCODE_FUNC(DECODE_FUNC(SOURCE_FUNC(TARGET_FUNC())));\n\t} else {\n\t\t// multi sample\n\t\tvec2 sph = toSpherical(TARGET_FUNC());\n\t\tvec2 sphu = dFdx(sph);\n\t\tvec2 sphv = dFdy(sph);\n\n\t\t// TODO: check this declaration works on old devices.\n\t\t// might need to be placed globally or be made a #define\n\t\tconst float NUM_SAMPLES_SQRT = sqrt(float(NUM_SAMPLES));\n\n\t\tvec3 result = vec3(0.0);\n\t\tfor (float u = 0.0; u < NUM_SAMPLES_SQRT; ++u) {\n\t\t\tfor (float v = 0.0; v < NUM_SAMPLES_SQRT; ++v) {\n\t\t\t\tresult += DECODE_FUNC(SOURCE_FUNC(sph +\n\t\t\t\t\t\t\t\t\t\t\t\t sphu * (u / NUM_SAMPLES_SQRT - 0.5) +\n\t\t\t\t\t\t\t\t\t\t\t\t sphv * (v / NUM_SAMPLES_SQRT - 0.5)));\n\t\t\t}\n\t\t}\n\t\treturn ENCODE_FUNC(result / (NUM_SAMPLES_SQRT * NUM_SAMPLES_SQRT));\n\t}\n}\n\nvec4 unpackFloat = vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0);\n\nvoid unpackSample(int i, out vec3 L, out float mipLevel) {\n\tfloat u = (float(i * 4) + 0.5) * samplesTexInverseSize.x;\n\tfloat v = (floor(u) + 0.5) * samplesTexInverseSize.y;\n\n\tvec4 raw;\n\traw.x = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat); u += samplesTexInverseSize.x;\n\traw.y = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat); u += samplesTexInverseSize.x;\n\traw.z = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat); u += samplesTexInverseSize.x;\n\traw.w = dot(texture2D(samplesTex, vec2(u, v)), unpackFloat);\n\n\tL.xyz = raw.xyz * 2.0 - 1.0;\n\tmipLevel = raw.w * 8.0;\n}\n\n// convolve an environment given pre-generated samples\nvec4 prefilterSamples() {\n\t// construct vector space given target direction\n\tmat3 vecSpace = matrixFromVectorSlow(TARGET_FUNC());\n\n\tvec3 L;\n\tfloat mipLevel;\n\n\tvec3 result = vec3(0.0);\n\tfloat totalWeight = 0.0;\n\tfor (int i = 0; i < NUM_SAMPLES; ++i) {\n\t\tunpackSample(i, L, mipLevel);\n\t\tresult += DECODE_FUNC(SOURCE_FUNC(vecSpace * L, mipLevel)) * L.z;\n\t\ttotalWeight += L.z;\n\t}\n\n\treturn ENCODE_FUNC(result / totalWeight);\n}\n\n// unweighted version of prefilterSamples\nvec4 prefilterSamplesUnweighted() {\n\t// construct vector space given target direction\n\tmat3 vecSpace = matrixFromVectorSlow(TARGET_FUNC());\n\n\tvec3 L;\n\tfloat mipLevel;\n\n\tvec3 result = vec3(0.0);\n\tfloat totalWeight = 0.0;\n\tfor (int i = 0; i < NUM_SAMPLES; ++i) {\n\t\tunpackSample(i, L, mipLevel);\n\t\tresult += DECODE_FUNC(SOURCE_FUNC(vecSpace * L, mipLevel));\n\t}\n\n\treturn ENCODE_FUNC(result / float(NUM_SAMPLES));\n}\n\nvoid main(void) {\n\tgl_FragColor = PROCESS_FUNC();\n}\n";
6364
6364
 
6365
- var rgbmPS = "vec3 texture2DRGBM(sampler2D tex, vec2 uv) {\n\treturn decodeRGBM(texture2D(tex, uv));\n}\n\nvec3 textureCubeRGBM(samplerCube tex, vec3 uvw) {\n\treturn decodeRGBM(textureCube(tex, uvw));\n}\n";
6365
+ var rgbmPS = "vec3 texture2DRGBM(sampler2D tex, vec2 uv) {\n\treturn decodeRGBM(texture2D(tex, uv));\n}\n\nvec3 texture2DRGBM(sampler2D tex, vec2 uv, float bias) {\n\treturn decodeRGBM(texture2D(tex, uv, bias));\n}\n\nvec3 textureCubeRGBM(samplerCube tex, vec3 uvw) {\n\treturn decodeRGBM(textureCube(tex, uvw));\n}\n";
6366
6366
 
6367
6367
  var screenDepthPS = "uniform highp sampler2D uDepthMap;\n\n#ifndef SCREENSIZE\n#define SCREENSIZE\nuniform vec4 uScreenSize;\n#endif\n\n#ifndef VIEWMATRIX\n#define VIEWMATRIX\nuniform mat4 matrix_view;\n#endif\n\n#ifndef CAMERAPLANES\n#define CAMERAPLANES\nuniform vec4 camera_params; // 1 / camera_far,\t camera_far,\t (1 - f / n) / 2,\t\t(1 + f / n) / 2\n#endif\n\n#ifdef GL2\nfloat linearizeDepth(float z) {\n\tz = z * 2.0 - 1.0;\n\treturn 1.0 / (camera_params.z * z + camera_params.w);\n}\n#else\n#ifndef UNPACKFLOAT\n#define UNPACKFLOAT\nfloat unpackFloat(vec4 rgbaDepth) {\n\tconst vec4 bitShift = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);\n\treturn dot(rgbaDepth, bitShift);\n}\n#endif\n#endif\n\n// Retrieves rendered linear camera depth by UV\nfloat getLinearScreenDepth(vec2 uv) {\n\t#ifdef GL2\n\treturn linearizeDepth(texture2D(uDepthMap, uv).r) * camera_params.y;\n\t#else\n\treturn unpackFloat(texture2D(uDepthMap, uv)) * camera_params.y;\n\t#endif\n}\n\n#ifndef VERTEXSHADER\n// Retrieves rendered linear camera depth under the current pixel\nfloat getLinearScreenDepth() {\n\tvec2 uv = gl_FragCoord.xy * uScreenSize.zw;\n\treturn getLinearScreenDepth(uv);\n}\n#endif\n\n// Generates linear camera depth for the given world position\nfloat getLinearDepth(vec3 pos) {\n\treturn -(matrix_view * vec4(pos, 1.0)).z;\n}\n";
6368
6368
 
@@ -9818,7 +9818,7 @@
9818
9818
  if (isMainPass && options.nineSlicedMode === SPRITE_RENDERMODE_SLICED) {
9819
9819
  expression = "nineSlicedUv";
9820
9820
  } else if (isMainPass && options.nineSlicedMode === SPRITE_RENDERMODE_TILED) {
9821
- expression = "nineSlicedUv, -1000.0";
9821
+ expression = "nineSlicedUv";
9822
9822
  } else {
9823
9823
  if (transformId === 0) {
9824
9824
  expression = "vUv" + uvChannel;
@@ -9973,6 +9973,12 @@
9973
9973
  code += chunks.baseNineSlicedTiledPS;
9974
9974
  }
9975
9975
 
9976
+ if (options.nineSlicedMode === SPRITE_RENDERMODE_TILED) {
9977
+ code += "const float textureBias = -1000.0;\n";
9978
+ } else {
9979
+ code += "uniform float textureBias;\n";
9980
+ }
9981
+
9976
9982
  return code;
9977
9983
  },
9978
9984
  _decodeFunc: function _decodeFunc(textureFormat) {
@@ -11019,10 +11025,10 @@
11019
11025
  }
11020
11026
 
11021
11027
  if (options.fresnelModel > 0) code += " getFresnel();\n";
11028
+ }
11022
11029
 
11023
- if (useAo) {
11024
- code += " getAO();\n";
11025
- }
11030
+ if (useAo) {
11031
+ code += " getAO();\n";
11026
11032
  }
11027
11033
 
11028
11034
  if (addAmbient) {
@@ -30677,6 +30683,68 @@
30677
30683
  };
30678
30684
  };
30679
30685
 
30686
+ var flipTexCoordVs = function flipTexCoordVs(vertexBuffer) {
30687
+ var i, j;
30688
+ var floatOffsets = [];
30689
+ var shortOffsets = [];
30690
+ var byteOffsets = [];
30691
+
30692
+ for (i = 0; i < vertexBuffer.format.elements.length; ++i) {
30693
+ var element = vertexBuffer.format.elements[i];
30694
+
30695
+ if (element.name === SEMANTIC_TEXCOORD0 || element.name === SEMANTIC_TEXCOORD1) {
30696
+ switch (element.dataType) {
30697
+ case TYPE_FLOAT32:
30698
+ floatOffsets.push({
30699
+ offset: element.offset / 4 + 1,
30700
+ stride: element.stride / 4
30701
+ });
30702
+ break;
30703
+
30704
+ case TYPE_UINT16:
30705
+ shortOffsets.push({
30706
+ offset: element.offset / 2 + 1,
30707
+ stride: element.stride / 2
30708
+ });
30709
+ break;
30710
+
30711
+ case TYPE_UINT8:
30712
+ byteOffsets.push({
30713
+ offset: element.offset + 1,
30714
+ stride: element.stride
30715
+ });
30716
+ break;
30717
+ }
30718
+ }
30719
+ }
30720
+
30721
+ var flip = function flip(offsets, type, one) {
30722
+ var typedArray = new type(vertexBuffer.storage);
30723
+
30724
+ for (i = 0; i < offsets.length; ++i) {
30725
+ var index = offsets[i].offset;
30726
+ var stride = offsets[i].stride;
30727
+
30728
+ for (j = 0; j < vertexBuffer.numVertices; ++j) {
30729
+ typedArray[index] = one - typedArray[index];
30730
+ index += stride;
30731
+ }
30732
+ }
30733
+ };
30734
+
30735
+ if (floatOffsets.length > 0) {
30736
+ flip(floatOffsets, Float32Array, 1.0);
30737
+ }
30738
+
30739
+ if (shortOffsets.length > 0) {
30740
+ flip(shortOffsets, Uint16Array, 65535);
30741
+ }
30742
+
30743
+ if (byteOffsets.length > 0) {
30744
+ flip(byteOffsets, Uint8Array, 255);
30745
+ }
30746
+ };
30747
+
30680
30748
  var cloneTexture = function cloneTexture(texture) {
30681
30749
  var shallowCopyLevels = function shallowCopyLevels(texture) {
30682
30750
  var result = [];
@@ -30711,7 +30779,7 @@
30711
30779
  return result;
30712
30780
  };
30713
30781
 
30714
- var createVertexBufferInternal = function createVertexBufferInternal(device, sourceDesc) {
30782
+ var createVertexBufferInternal = function createVertexBufferInternal(device, sourceDesc, flipV) {
30715
30783
  var positionDesc = sourceDesc[SEMANTIC_POSITION];
30716
30784
 
30717
30785
  if (!positionDesc) {
@@ -30786,11 +30854,15 @@
30786
30854
  }
30787
30855
  }
30788
30856
 
30857
+ if (flipV) {
30858
+ flipTexCoordVs(vertexBuffer);
30859
+ }
30860
+
30789
30861
  vertexBuffer.unlock();
30790
30862
  return vertexBuffer;
30791
30863
  };
30792
30864
 
30793
- var createVertexBuffer = function createVertexBuffer(device, attributes, indices, accessors, bufferViews, vertexBufferDict) {
30865
+ var createVertexBuffer = function createVertexBuffer(device, attributes, indices, accessors, bufferViews, flipV, vertexBufferDict) {
30794
30866
  var useAttributes = {};
30795
30867
  var attribIds = [];
30796
30868
 
@@ -30831,14 +30903,14 @@
30831
30903
  generateNormals(sourceDesc, indices);
30832
30904
  }
30833
30905
 
30834
- vb = createVertexBufferInternal(device, sourceDesc);
30906
+ vb = createVertexBufferInternal(device, sourceDesc, flipV);
30835
30907
  vertexBufferDict[vbKey] = vb;
30836
30908
  }
30837
30909
 
30838
30910
  return vb;
30839
30911
  };
30840
30912
 
30841
- var createVertexBufferDraco = function createVertexBufferDraco(device, outputGeometry, extDraco, decoder, decoderModule, indices) {
30913
+ var createVertexBufferDraco = function createVertexBufferDraco(device, outputGeometry, extDraco, decoder, decoderModule, indices, flipV) {
30842
30914
  var numPoints = outputGeometry.num_points();
30843
30915
 
30844
30916
  var extractDracoAttributeInfo = function extractDracoAttributeInfo(uniqueId) {
@@ -30911,7 +30983,7 @@
30911
30983
  generateNormals(sourceDesc, indices);
30912
30984
  }
30913
30985
 
30914
- return createVertexBufferInternal(device, sourceDesc);
30986
+ return createVertexBufferInternal(device, sourceDesc, flipV);
30915
30987
  };
30916
30988
 
30917
30989
  var createSkin = function createSkin(device, gltfSkin, accessors, bufferViews, nodes, glbSkins) {
@@ -30961,7 +31033,7 @@
30961
31033
  var tempMat = new Mat4();
30962
31034
  var tempVec$1 = new Vec3();
30963
31035
 
30964
- var createMesh = function createMesh(device, gltfMesh, accessors, bufferViews, callback, vertexBufferDict) {
31036
+ var createMesh = function createMesh(device, gltfMesh, accessors, bufferViews, callback, flipV, vertexBufferDict) {
30965
31037
  var meshes = [];
30966
31038
  gltfMesh.primitives.forEach(function (primitive) {
30967
31039
  var primitiveType, vertexBuffer, numIndices;
@@ -31026,7 +31098,7 @@
31026
31098
  decoderModule._free(ptr);
31027
31099
  }
31028
31100
 
31029
- vertexBuffer = createVertexBufferDraco(device, outputGeometry, extDraco, decoder, decoderModule, indices);
31101
+ vertexBuffer = createVertexBufferDraco(device, outputGeometry, extDraco, decoder, decoderModule, indices, flipV);
31030
31102
  decoderModule.destroy(outputGeometry);
31031
31103
  decoderModule.destroy(decoder);
31032
31104
  decoderModule.destroy(buffer);
@@ -31040,7 +31112,7 @@
31040
31112
 
31041
31113
  if (!vertexBuffer) {
31042
31114
  indices = primitive.hasOwnProperty('indices') ? getAccessorData(accessors[primitive.indices], bufferViews, true) : null;
31043
- vertexBuffer = createVertexBuffer(device, primitive.attributes, indices, accessors, bufferViews, vertexBufferDict);
31115
+ vertexBuffer = createVertexBuffer(device, primitive.attributes, indices, accessors, bufferViews, flipV, vertexBufferDict);
31044
31116
  primitiveType = getPrimitiveType(primitive);
31045
31117
  }
31046
31118
 
@@ -31123,7 +31195,7 @@
31123
31195
  return meshes;
31124
31196
  };
31125
31197
 
31126
- var createMaterial = function createMaterial(gltfMaterial, textures) {
31198
+ var createMaterial = function createMaterial(gltfMaterial, textures, flipV) {
31127
31199
  var glossChunk = ["#ifdef MAPFLOAT", "uniform float material_shininess;", "#endif", "", "#ifdef MAPTEXTURE", "uniform sampler2D texture_glossMap;", "#endif", "", "void getGlossiness() {", " dGlossiness = 1.0;", "", "#ifdef MAPFLOAT", " dGlossiness *= material_shininess;", "#endif", "", "#ifdef MAPTEXTURE", " dGlossiness *= texture2D(texture_glossMap, $UV, textureBias).$CH;", "#endif", "", "#ifdef MAPVERTEX", " dGlossiness *= saturate(vVertexColor.$VC);", "#endif", "", " dGlossiness = 1.0 - dGlossiness;", "", " dGlossiness += 0.0000001;", "}"].join('\n');
31128
31200
  var specularChunk = ["#ifdef MAPCOLOR", "uniform vec3 material_specular;", "#endif", "", "#ifdef MAPTEXTURE", "uniform sampler2D texture_specularMap;", "#endif", "", "void getSpecularity() {", " dSpecularity = vec3(1.0);", "", " #ifdef MAPCOLOR", " dSpecularity *= material_specular;", " #endif", "", " #ifdef MAPTEXTURE", " vec3 srgb = texture2D(texture_specularMap, $UV, textureBias).$CH;", " dSpecularity *= vec3(pow(srgb.r, 2.2), pow(srgb.g, 2.2), pow(srgb.b, 2.2));", " #endif", "", " #ifdef MAPVERTEX", " dSpecularity *= saturate(vVertexColor.$VC);", " #endif", "}"].join('\n');
31129
31201
  var clearCoatGlossChunk = ["#ifdef MAPFLOAT", "uniform float material_clearCoatGlossiness;", "#endif", "", "#ifdef MAPTEXTURE", "uniform sampler2D texture_clearCoatGlossMap;", "#endif", "", "void getClearCoatGlossiness() {", " ccGlossiness = 1.0;", "", "#ifdef MAPFLOAT", " ccGlossiness *= material_clearCoatGlossiness;", "#endif", "", "#ifdef MAPTEXTURE", " ccGlossiness *= texture2D(texture_clearCoatGlossMap, $UV, textureBias).$CH;", "#endif", "", "#ifdef MAPVERTEX", " ccGlossiness *= saturate(vVertexColor.$VC);", "#endif", "", " ccGlossiness = 1.0 - ccGlossiness;", "", " ccGlossiness += 0.0000001;", "}"].join('\n');
@@ -31612,18 +31684,18 @@
31612
31684
  });
31613
31685
  };
31614
31686
 
31615
- var createMeshes = function createMeshes(device, gltf, bufferViews, callback) {
31687
+ var createMeshes = function createMeshes(device, gltf, bufferViews, callback, flipV) {
31616
31688
  if (!gltf.hasOwnProperty('meshes') || gltf.meshes.length === 0 || !gltf.hasOwnProperty('accessors') || gltf.accessors.length === 0 || !gltf.hasOwnProperty('bufferViews') || gltf.bufferViews.length === 0) {
31617
31689
  return [];
31618
31690
  }
31619
31691
 
31620
31692
  var vertexBufferDict = {};
31621
31693
  return gltf.meshes.map(function (gltfMesh) {
31622
- return createMesh(device, gltfMesh, gltf.accessors, bufferViews, callback, vertexBufferDict);
31694
+ return createMesh(device, gltfMesh, gltf.accessors, bufferViews, callback, flipV, vertexBufferDict);
31623
31695
  });
31624
31696
  };
31625
31697
 
31626
- var createMaterials = function createMaterials(gltf, textures, options) {
31698
+ var createMaterials = function createMaterials(gltf, textures, options, flipV) {
31627
31699
  if (!gltf.hasOwnProperty('materials') || gltf.materials.length === 0) {
31628
31700
  return [];
31629
31701
  }
@@ -31636,7 +31708,7 @@
31636
31708
  preprocess(gltfMaterial);
31637
31709
  }
31638
31710
 
31639
- var material = process(gltfMaterial, textures);
31711
+ var material = process(gltfMaterial, textures, flipV);
31640
31712
 
31641
31713
  if (postprocess) {
31642
31714
  postprocess(gltfMaterial, material);
@@ -31837,10 +31909,7 @@
31837
31909
  preprocess(gltf);
31838
31910
  }
31839
31911
 
31840
- if (gltf.asset && gltf.asset.generator === 'PlayCanvas') {
31841
- Debug.warn("glTF model may have flipped UVs. Please reconvert.");
31842
- }
31843
-
31912
+ var flipV = gltf.asset && gltf.asset.generator === 'PlayCanvas';
31844
31913
  var nodes = createNodes(gltf, options);
31845
31914
  var scenes = createScenes(gltf, nodes);
31846
31915
  var lights = createLights(gltf, nodes, options);
@@ -31848,8 +31917,8 @@
31848
31917
  var animations = createAnimations(gltf, nodes, bufferViews, options);
31849
31918
  var materials = createMaterials(gltf, textureAssets.map(function (textureAsset) {
31850
31919
  return textureAsset.resource;
31851
- }), options);
31852
- var meshes = createMeshes(device, gltf, bufferViews, callback);
31920
+ }), options, flipV);
31921
+ var meshes = createMeshes(device, gltf, bufferViews, callback, flipV);
31853
31922
  var skins = createSkins(device, gltf, nodes, bufferViews);
31854
31923
  var renders = [];
31855
31924
 
@@ -47702,8 +47771,6 @@
47702
47771
  };
47703
47772
 
47704
47773
  _proto.removeStateGraph = function removeStateGraph() {
47705
- var _this2 = this;
47706
-
47707
47774
  this._stateGraph = null;
47708
47775
  this._stateGraphAsset = null;
47709
47776
  this._animationAssets = {};
@@ -47711,21 +47778,10 @@
47711
47778
  this._layerIndices = {};
47712
47779
  this._parameters = {};
47713
47780
  this._playing = false;
47714
- Object.keys(this._targets).forEach(function (targetKey) {
47715
- _this2._targets[targetKey].unbind();
47716
- });
47781
+ this.unbind();
47717
47782
  this._targets = {};
47718
47783
  };
47719
47784
 
47720
- _proto.resetStateGraph = function resetStateGraph() {
47721
- this.removeStateGraph();
47722
-
47723
- if (this.stateGraphAsset) {
47724
- var stateGraph = this.system.app.assets.get(this.stateGraphAsset).resource;
47725
- this.loadStateGraph(stateGraph);
47726
- }
47727
- };
47728
-
47729
47785
  _proto.reset = function reset() {
47730
47786
  this._parameters = Object.assign({}, this._stateGraph.parameters);
47731
47787
 
@@ -47738,6 +47794,16 @@
47738
47794
  }
47739
47795
  };
47740
47796
 
47797
+ _proto.unbind = function unbind() {
47798
+ var _this2 = this;
47799
+
47800
+ if (!this._normalizeWeights) {
47801
+ Object.keys(this._targets).forEach(function (targetKey) {
47802
+ _this2._targets[targetKey].unbind();
47803
+ });
47804
+ }
47805
+ };
47806
+
47741
47807
  _proto.rebind = function rebind() {
47742
47808
  this._targets = {};
47743
47809
 
@@ -48014,7 +48080,7 @@
48014
48080
  },
48015
48081
  set: function set(value) {
48016
48082
  this._normalizeWeights = value;
48017
- this.resetStateGraph();
48083
+ this.unbind();
48018
48084
  }
48019
48085
  }, {
48020
48086
  key: "animationAssets",
@@ -60056,11 +60122,7 @@
60056
60122
  if (this.entity.animation) this.entity.animation.setModel(this._model);
60057
60123
 
60058
60124
  if (this.entity.anim) {
60059
- if (this.entity.anim.playing) {
60060
- this.entity.anim.rebind();
60061
- } else {
60062
- this.entity.anim.resetStateGraph();
60063
- }
60125
+ this.entity.anim.rebind();
60064
60126
  }
60065
60127
 
60066
60128
  if (this.type === 'asset') {