playcanvas 1.53.2 → 1.53.3
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.
- package/build/playcanvas-extras.js +1 -1
- package/build/playcanvas.dbg.js +96 -27
- package/build/playcanvas.js +96 -25
- package/build/playcanvas.min.js +2 -2
- package/build/playcanvas.mjs +96 -25
- package/build/playcanvas.prf.js +96 -25
- package/package.json +1 -1
- package/scripts/parsers/vox-parser.js +1 -1
package/build/playcanvas.dbg.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* PlayCanvas Engine v1.53.
|
|
3
|
+
* PlayCanvas Engine v1.53.3 revision 1d3ebde3b (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.
|
|
590
|
-
var revision = "
|
|
589
|
+
var version = "1.53.3";
|
|
590
|
+
var revision = "1d3ebde3b";
|
|
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\
|
|
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
|
|
|
@@ -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
|
|
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
|
-
|
|
11024
|
-
|
|
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
|
-
|
|
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
|
|
package/build/playcanvas.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* PlayCanvas Engine v1.53.
|
|
3
|
+
* PlayCanvas Engine v1.53.3 revision 1d3ebde3b
|
|
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.
|
|
590
|
-
var revision = "
|
|
589
|
+
var version = "1.53.3";
|
|
590
|
+
var revision = "1d3ebde3b";
|
|
591
591
|
var config = {};
|
|
592
592
|
var common = {};
|
|
593
593
|
var apps = {};
|
|
@@ -6019,7 +6019,7 @@
|
|
|
6019
6019
|
|
|
6020
6020
|
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";
|
|
6021
6021
|
|
|
6022
|
-
var basePS = "uniform vec3 view_position;\nuniform vec3 light_globalAmbient;\
|
|
6022
|
+
var basePS = "uniform vec3 view_position;\nuniform vec3 light_globalAmbient;\nfloat square(float x) {\n\treturn x*x;\n}\nfloat saturate(float x) {\n\treturn clamp(x, 0.0, 1.0);\n}\nvec3 saturate(vec3 x) {\n\treturn clamp(x, vec3(0.0), vec3(1.0));\n}\n";
|
|
6023
6023
|
|
|
6024
6024
|
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;\nuniform mat4 matrix_viewProjection;\nuniform mat4 matrix_model;\nuniform mat3 matrix_normal;\nvec3 dPositionW;\nmat4 dModelMatrix;\nmat3 dNormalMatrix;\n";
|
|
6025
6025
|
|
|
@@ -9703,7 +9703,7 @@
|
|
|
9703
9703
|
if (isMainPass && options.nineSlicedMode === SPRITE_RENDERMODE_SLICED) {
|
|
9704
9704
|
expression = "nineSlicedUv";
|
|
9705
9705
|
} else if (isMainPass && options.nineSlicedMode === SPRITE_RENDERMODE_TILED) {
|
|
9706
|
-
expression = "nineSlicedUv
|
|
9706
|
+
expression = "nineSlicedUv";
|
|
9707
9707
|
} else {
|
|
9708
9708
|
if (transformId === 0) {
|
|
9709
9709
|
expression = "vUv" + uvChannel;
|
|
@@ -9858,6 +9858,12 @@
|
|
|
9858
9858
|
code += chunks.baseNineSlicedTiledPS;
|
|
9859
9859
|
}
|
|
9860
9860
|
|
|
9861
|
+
if (options.nineSlicedMode === SPRITE_RENDERMODE_TILED) {
|
|
9862
|
+
code += "const float textureBias = -1000.0;\n";
|
|
9863
|
+
} else {
|
|
9864
|
+
code += "uniform float textureBias;\n";
|
|
9865
|
+
}
|
|
9866
|
+
|
|
9861
9867
|
return code;
|
|
9862
9868
|
},
|
|
9863
9869
|
_decodeFunc: function _decodeFunc(textureFormat) {
|
|
@@ -10904,10 +10910,10 @@
|
|
|
10904
10910
|
}
|
|
10905
10911
|
|
|
10906
10912
|
if (options.fresnelModel > 0) code += " getFresnel();\n";
|
|
10913
|
+
}
|
|
10907
10914
|
|
|
10908
|
-
|
|
10909
|
-
|
|
10910
|
-
}
|
|
10915
|
+
if (useAo) {
|
|
10916
|
+
code += " getAO();\n";
|
|
10911
10917
|
}
|
|
10912
10918
|
|
|
10913
10919
|
if (addAmbient) {
|
|
@@ -30038,6 +30044,68 @@
|
|
|
30038
30044
|
};
|
|
30039
30045
|
};
|
|
30040
30046
|
|
|
30047
|
+
var flipTexCoordVs = function flipTexCoordVs(vertexBuffer) {
|
|
30048
|
+
var i, j;
|
|
30049
|
+
var floatOffsets = [];
|
|
30050
|
+
var shortOffsets = [];
|
|
30051
|
+
var byteOffsets = [];
|
|
30052
|
+
|
|
30053
|
+
for (i = 0; i < vertexBuffer.format.elements.length; ++i) {
|
|
30054
|
+
var element = vertexBuffer.format.elements[i];
|
|
30055
|
+
|
|
30056
|
+
if (element.name === SEMANTIC_TEXCOORD0 || element.name === SEMANTIC_TEXCOORD1) {
|
|
30057
|
+
switch (element.dataType) {
|
|
30058
|
+
case TYPE_FLOAT32:
|
|
30059
|
+
floatOffsets.push({
|
|
30060
|
+
offset: element.offset / 4 + 1,
|
|
30061
|
+
stride: element.stride / 4
|
|
30062
|
+
});
|
|
30063
|
+
break;
|
|
30064
|
+
|
|
30065
|
+
case TYPE_UINT16:
|
|
30066
|
+
shortOffsets.push({
|
|
30067
|
+
offset: element.offset / 2 + 1,
|
|
30068
|
+
stride: element.stride / 2
|
|
30069
|
+
});
|
|
30070
|
+
break;
|
|
30071
|
+
|
|
30072
|
+
case TYPE_UINT8:
|
|
30073
|
+
byteOffsets.push({
|
|
30074
|
+
offset: element.offset + 1,
|
|
30075
|
+
stride: element.stride
|
|
30076
|
+
});
|
|
30077
|
+
break;
|
|
30078
|
+
}
|
|
30079
|
+
}
|
|
30080
|
+
}
|
|
30081
|
+
|
|
30082
|
+
var flip = function flip(offsets, type, one) {
|
|
30083
|
+
var typedArray = new type(vertexBuffer.storage);
|
|
30084
|
+
|
|
30085
|
+
for (i = 0; i < offsets.length; ++i) {
|
|
30086
|
+
var index = offsets[i].offset;
|
|
30087
|
+
var stride = offsets[i].stride;
|
|
30088
|
+
|
|
30089
|
+
for (j = 0; j < vertexBuffer.numVertices; ++j) {
|
|
30090
|
+
typedArray[index] = one - typedArray[index];
|
|
30091
|
+
index += stride;
|
|
30092
|
+
}
|
|
30093
|
+
}
|
|
30094
|
+
};
|
|
30095
|
+
|
|
30096
|
+
if (floatOffsets.length > 0) {
|
|
30097
|
+
flip(floatOffsets, Float32Array, 1.0);
|
|
30098
|
+
}
|
|
30099
|
+
|
|
30100
|
+
if (shortOffsets.length > 0) {
|
|
30101
|
+
flip(shortOffsets, Uint16Array, 65535);
|
|
30102
|
+
}
|
|
30103
|
+
|
|
30104
|
+
if (byteOffsets.length > 0) {
|
|
30105
|
+
flip(byteOffsets, Uint8Array, 255);
|
|
30106
|
+
}
|
|
30107
|
+
};
|
|
30108
|
+
|
|
30041
30109
|
var cloneTexture = function cloneTexture(texture) {
|
|
30042
30110
|
var shallowCopyLevels = function shallowCopyLevels(texture) {
|
|
30043
30111
|
var result = [];
|
|
@@ -30072,7 +30140,7 @@
|
|
|
30072
30140
|
return result;
|
|
30073
30141
|
};
|
|
30074
30142
|
|
|
30075
|
-
var createVertexBufferInternal = function createVertexBufferInternal(device, sourceDesc) {
|
|
30143
|
+
var createVertexBufferInternal = function createVertexBufferInternal(device, sourceDesc, flipV) {
|
|
30076
30144
|
var positionDesc = sourceDesc[SEMANTIC_POSITION];
|
|
30077
30145
|
|
|
30078
30146
|
if (!positionDesc) {
|
|
@@ -30147,11 +30215,15 @@
|
|
|
30147
30215
|
}
|
|
30148
30216
|
}
|
|
30149
30217
|
|
|
30218
|
+
if (flipV) {
|
|
30219
|
+
flipTexCoordVs(vertexBuffer);
|
|
30220
|
+
}
|
|
30221
|
+
|
|
30150
30222
|
vertexBuffer.unlock();
|
|
30151
30223
|
return vertexBuffer;
|
|
30152
30224
|
};
|
|
30153
30225
|
|
|
30154
|
-
var createVertexBuffer = function createVertexBuffer(device, attributes, indices, accessors, bufferViews, vertexBufferDict) {
|
|
30226
|
+
var createVertexBuffer = function createVertexBuffer(device, attributes, indices, accessors, bufferViews, flipV, vertexBufferDict) {
|
|
30155
30227
|
var useAttributes = {};
|
|
30156
30228
|
var attribIds = [];
|
|
30157
30229
|
|
|
@@ -30192,14 +30264,14 @@
|
|
|
30192
30264
|
generateNormals(sourceDesc, indices);
|
|
30193
30265
|
}
|
|
30194
30266
|
|
|
30195
|
-
vb = createVertexBufferInternal(device, sourceDesc);
|
|
30267
|
+
vb = createVertexBufferInternal(device, sourceDesc, flipV);
|
|
30196
30268
|
vertexBufferDict[vbKey] = vb;
|
|
30197
30269
|
}
|
|
30198
30270
|
|
|
30199
30271
|
return vb;
|
|
30200
30272
|
};
|
|
30201
30273
|
|
|
30202
|
-
var createVertexBufferDraco = function createVertexBufferDraco(device, outputGeometry, extDraco, decoder, decoderModule, indices) {
|
|
30274
|
+
var createVertexBufferDraco = function createVertexBufferDraco(device, outputGeometry, extDraco, decoder, decoderModule, indices, flipV) {
|
|
30203
30275
|
var numPoints = outputGeometry.num_points();
|
|
30204
30276
|
|
|
30205
30277
|
var extractDracoAttributeInfo = function extractDracoAttributeInfo(uniqueId) {
|
|
@@ -30272,7 +30344,7 @@
|
|
|
30272
30344
|
generateNormals(sourceDesc, indices);
|
|
30273
30345
|
}
|
|
30274
30346
|
|
|
30275
|
-
return createVertexBufferInternal(device, sourceDesc);
|
|
30347
|
+
return createVertexBufferInternal(device, sourceDesc, flipV);
|
|
30276
30348
|
};
|
|
30277
30349
|
|
|
30278
30350
|
var createSkin = function createSkin(device, gltfSkin, accessors, bufferViews, nodes, glbSkins) {
|
|
@@ -30322,7 +30394,7 @@
|
|
|
30322
30394
|
var tempMat = new Mat4();
|
|
30323
30395
|
var tempVec$1 = new Vec3();
|
|
30324
30396
|
|
|
30325
|
-
var createMesh = function createMesh(device, gltfMesh, accessors, bufferViews, callback, vertexBufferDict) {
|
|
30397
|
+
var createMesh = function createMesh(device, gltfMesh, accessors, bufferViews, callback, flipV, vertexBufferDict) {
|
|
30326
30398
|
var meshes = [];
|
|
30327
30399
|
gltfMesh.primitives.forEach(function (primitive) {
|
|
30328
30400
|
var primitiveType, vertexBuffer, numIndices;
|
|
@@ -30387,7 +30459,7 @@
|
|
|
30387
30459
|
decoderModule._free(ptr);
|
|
30388
30460
|
}
|
|
30389
30461
|
|
|
30390
|
-
vertexBuffer = createVertexBufferDraco(device, outputGeometry, extDraco, decoder, decoderModule, indices);
|
|
30462
|
+
vertexBuffer = createVertexBufferDraco(device, outputGeometry, extDraco, decoder, decoderModule, indices, flipV);
|
|
30391
30463
|
decoderModule.destroy(outputGeometry);
|
|
30392
30464
|
decoderModule.destroy(decoder);
|
|
30393
30465
|
decoderModule.destroy(buffer);
|
|
@@ -30399,7 +30471,7 @@
|
|
|
30399
30471
|
|
|
30400
30472
|
if (!vertexBuffer) {
|
|
30401
30473
|
indices = primitive.hasOwnProperty('indices') ? getAccessorData(accessors[primitive.indices], bufferViews, true) : null;
|
|
30402
|
-
vertexBuffer = createVertexBuffer(device, primitive.attributes, indices, accessors, bufferViews, vertexBufferDict);
|
|
30474
|
+
vertexBuffer = createVertexBuffer(device, primitive.attributes, indices, accessors, bufferViews, flipV, vertexBufferDict);
|
|
30403
30475
|
primitiveType = getPrimitiveType(primitive);
|
|
30404
30476
|
}
|
|
30405
30477
|
|
|
@@ -30478,7 +30550,7 @@
|
|
|
30478
30550
|
return meshes;
|
|
30479
30551
|
};
|
|
30480
30552
|
|
|
30481
|
-
var createMaterial = function createMaterial(gltfMaterial, textures) {
|
|
30553
|
+
var createMaterial = function createMaterial(gltfMaterial, textures, flipV) {
|
|
30482
30554
|
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');
|
|
30483
30555
|
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');
|
|
30484
30556
|
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');
|
|
@@ -30967,18 +31039,18 @@
|
|
|
30967
31039
|
});
|
|
30968
31040
|
};
|
|
30969
31041
|
|
|
30970
|
-
var createMeshes = function createMeshes(device, gltf, bufferViews, callback) {
|
|
31042
|
+
var createMeshes = function createMeshes(device, gltf, bufferViews, callback, flipV) {
|
|
30971
31043
|
if (!gltf.hasOwnProperty('meshes') || gltf.meshes.length === 0 || !gltf.hasOwnProperty('accessors') || gltf.accessors.length === 0 || !gltf.hasOwnProperty('bufferViews') || gltf.bufferViews.length === 0) {
|
|
30972
31044
|
return [];
|
|
30973
31045
|
}
|
|
30974
31046
|
|
|
30975
31047
|
var vertexBufferDict = {};
|
|
30976
31048
|
return gltf.meshes.map(function (gltfMesh) {
|
|
30977
|
-
return createMesh(device, gltfMesh, gltf.accessors, bufferViews, callback, vertexBufferDict);
|
|
31049
|
+
return createMesh(device, gltfMesh, gltf.accessors, bufferViews, callback, flipV, vertexBufferDict);
|
|
30978
31050
|
});
|
|
30979
31051
|
};
|
|
30980
31052
|
|
|
30981
|
-
var createMaterials = function createMaterials(gltf, textures, options) {
|
|
31053
|
+
var createMaterials = function createMaterials(gltf, textures, options, flipV) {
|
|
30982
31054
|
if (!gltf.hasOwnProperty('materials') || gltf.materials.length === 0) {
|
|
30983
31055
|
return [];
|
|
30984
31056
|
}
|
|
@@ -30991,7 +31063,7 @@
|
|
|
30991
31063
|
preprocess(gltfMaterial);
|
|
30992
31064
|
}
|
|
30993
31065
|
|
|
30994
|
-
var material = process(gltfMaterial, textures);
|
|
31066
|
+
var material = process(gltfMaterial, textures, flipV);
|
|
30995
31067
|
|
|
30996
31068
|
if (postprocess) {
|
|
30997
31069
|
postprocess(gltfMaterial, material);
|
|
@@ -31192,8 +31264,7 @@
|
|
|
31192
31264
|
preprocess(gltf);
|
|
31193
31265
|
}
|
|
31194
31266
|
|
|
31195
|
-
|
|
31196
|
-
|
|
31267
|
+
var flipV = gltf.asset && gltf.asset.generator === 'PlayCanvas';
|
|
31197
31268
|
var nodes = createNodes(gltf, options);
|
|
31198
31269
|
var scenes = createScenes(gltf, nodes);
|
|
31199
31270
|
var lights = createLights(gltf, nodes, options);
|
|
@@ -31201,8 +31272,8 @@
|
|
|
31201
31272
|
var animations = createAnimations(gltf, nodes, bufferViews, options);
|
|
31202
31273
|
var materials = createMaterials(gltf, textureAssets.map(function (textureAsset) {
|
|
31203
31274
|
return textureAsset.resource;
|
|
31204
|
-
}), options);
|
|
31205
|
-
var meshes = createMeshes(device, gltf, bufferViews, callback);
|
|
31275
|
+
}), options, flipV);
|
|
31276
|
+
var meshes = createMeshes(device, gltf, bufferViews, callback, flipV);
|
|
31206
31277
|
var skins = createSkins(device, gltf, nodes, bufferViews);
|
|
31207
31278
|
var renders = [];
|
|
31208
31279
|
|