three-stdlib 2.6.3 → 2.6.4
Sign up to get free protection for your applications and to get access to all the features.
- package/index.cjs.js +1 -1
- package/loaders/AMFLoader.js +1 -3
- package/loaders/ColladaLoader.cjs.js +1 -1
- package/loaders/ColladaLoader.js +58 -35
- package/loaders/EXRLoader.cjs.js +1 -1
- package/loaders/EXRLoader.js +197 -262
- package/loaders/FBXLoader.cjs.js +1 -1
- package/loaders/FBXLoader.js +41 -90
- package/loaders/GLTFLoader.cjs.js +1 -1
- package/loaders/GLTFLoader.js +160 -72
- package/loaders/HDRCubeTextureLoader.cjs.js +1 -1
- package/loaders/HDRCubeTextureLoader.js +2 -2
- package/loaders/RGBELoader.cjs.js +1 -1
- package/loaders/RGBELoader.js +10 -9
- package/loaders/RGBMLoader.cjs.js +1 -1
- package/loaders/RGBMLoader.js +181 -257
- package/loaders/SVGLoader.cjs.js +1 -1
- package/loaders/SVGLoader.js +46 -30
- package/loaders/VRMLLoader.cjs.js +1 -1
- package/loaders/VRMLLoader.js +2 -1
- package/package.json +1 -1
package/loaders/GLTFLoader.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Loader, LoaderUtils, FileLoader, Color, SpotLight, PointLight, DirectionalLight, MeshBasicMaterial, MeshPhysicalMaterial, Vector2, sRGBEncoding, TangentSpaceNormalMap, ImageBitmapLoader, TextureLoader, InterleavedBuffer, InterleavedBufferAttribute, BufferAttribute,
|
1
|
+
import { Loader, LoaderUtils, FileLoader, Color, SpotLight, PointLight, DirectionalLight, MeshBasicMaterial, MeshPhysicalMaterial, Vector2, sRGBEncoding, TangentSpaceNormalMap, Quaternion, ImageBitmapLoader, TextureLoader, InterleavedBuffer, InterleavedBufferAttribute, BufferAttribute, LinearFilter, LinearMipmapLinearFilter, RepeatWrapping, PointsMaterial, Material, LineBasicMaterial, MeshStandardMaterial, DoubleSide, RGBFormat, PropertyBinding, BufferGeometry, SkinnedMesh, Mesh, LineSegments, Line, LineLoop, Points, Group, PerspectiveCamera, MathUtils, OrthographicCamera, InterpolateLinear, AnimationClip, Bone, Object3D, Matrix4, Skeleton, TriangleFanDrawMode, NearestFilter, NearestMipmapNearestFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, ClampToEdgeWrapping, MirroredRepeatWrapping, InterpolateDiscrete, FrontSide, Texture, TriangleStripDrawMode, VectorKeyframeTrack, QuaternionKeyframeTrack, NumberKeyframeTrack, Box3, Vector3, Sphere, Interpolant } from 'three';
|
2
2
|
|
3
3
|
class GLTFLoader extends Loader {
|
4
4
|
constructor(manager) {
|
@@ -16,6 +16,9 @@ class GLTFLoader extends Loader {
|
|
16
16
|
this.register(function (parser) {
|
17
17
|
return new GLTFTextureWebPExtension(parser);
|
18
18
|
});
|
19
|
+
this.register(function (parser) {
|
20
|
+
return new GLTFMaterialsSheenExtension(parser);
|
21
|
+
});
|
19
22
|
this.register(function (parser) {
|
20
23
|
return new GLTFMaterialsTransmissionExtension(parser);
|
21
24
|
});
|
@@ -207,6 +210,13 @@ class GLTFLoader extends Loader {
|
|
207
210
|
parser.parse(onLoad, onError);
|
208
211
|
}
|
209
212
|
|
213
|
+
parseAsync(data, path) {
|
214
|
+
const scope = this;
|
215
|
+
return new Promise(function (resolve, reject) {
|
216
|
+
scope.parse(data, path, resolve, reject);
|
217
|
+
});
|
218
|
+
}
|
219
|
+
|
210
220
|
}
|
211
221
|
/* GLTFREGISTRY */
|
212
222
|
|
@@ -242,6 +252,7 @@ const EXTENSIONS = {
|
|
242
252
|
KHR_MATERIALS_CLEARCOAT: 'KHR_materials_clearcoat',
|
243
253
|
KHR_MATERIALS_IOR: 'KHR_materials_ior',
|
244
254
|
KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS: 'KHR_materials_pbrSpecularGlossiness',
|
255
|
+
KHR_MATERIALS_SHEEN: 'KHR_materials_sheen',
|
245
256
|
KHR_MATERIALS_SPECULAR: 'KHR_materials_specular',
|
246
257
|
KHR_MATERIALS_TRANSMISSION: 'KHR_materials_transmission',
|
247
258
|
KHR_MATERIALS_UNLIT: 'KHR_materials_unlit',
|
@@ -439,15 +450,68 @@ class GLTFMaterialsClearcoatExtension {
|
|
439
450
|
pending.push(parser.assignTexture(materialParams, 'clearcoatNormalMap', extension.clearcoatNormalTexture));
|
440
451
|
|
441
452
|
if (extension.clearcoatNormalTexture.scale !== undefined) {
|
442
|
-
const scale = extension.clearcoatNormalTexture.scale;
|
443
|
-
|
444
|
-
materialParams.clearcoatNormalScale = new Vector2(scale, -scale);
|
453
|
+
const scale = extension.clearcoatNormalTexture.scale;
|
454
|
+
materialParams.clearcoatNormalScale = new Vector2(scale, scale);
|
445
455
|
}
|
446
456
|
}
|
447
457
|
|
448
458
|
return Promise.all(pending);
|
449
459
|
}
|
450
460
|
|
461
|
+
}
|
462
|
+
/**
|
463
|
+
* Sheen Materials Extension
|
464
|
+
*
|
465
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_sheen
|
466
|
+
*/
|
467
|
+
|
468
|
+
|
469
|
+
class GLTFMaterialsSheenExtension {
|
470
|
+
constructor(parser) {
|
471
|
+
this.parser = parser;
|
472
|
+
this.name = EXTENSIONS.KHR_MATERIALS_SHEEN;
|
473
|
+
}
|
474
|
+
|
475
|
+
getMaterialType(materialIndex) {
|
476
|
+
const parser = this.parser;
|
477
|
+
const materialDef = parser.json.materials[materialIndex];
|
478
|
+
if (!materialDef.extensions || !materialDef.extensions[this.name]) return null;
|
479
|
+
return MeshPhysicalMaterial;
|
480
|
+
}
|
481
|
+
|
482
|
+
extendMaterialParams(materialIndex, materialParams) {
|
483
|
+
const parser = this.parser;
|
484
|
+
const materialDef = parser.json.materials[materialIndex];
|
485
|
+
|
486
|
+
if (!materialDef.extensions || !materialDef.extensions[this.name]) {
|
487
|
+
return Promise.resolve();
|
488
|
+
}
|
489
|
+
|
490
|
+
const pending = [];
|
491
|
+
materialParams.sheenColor = new Color(0, 0, 0);
|
492
|
+
materialParams.sheenRoughness = 0;
|
493
|
+
materialParams.sheen = 1;
|
494
|
+
const extension = materialDef.extensions[this.name];
|
495
|
+
|
496
|
+
if (extension.sheenColorFactor !== undefined) {
|
497
|
+
materialParams.sheenColor.fromArray(extension.sheenColorFactor);
|
498
|
+
}
|
499
|
+
|
500
|
+
if (extension.sheenRoughnessFactor !== undefined) {
|
501
|
+
materialParams.sheenRoughness = extension.sheenRoughnessFactor;
|
502
|
+
}
|
503
|
+
|
504
|
+
if (extension.sheenColorTexture !== undefined) {
|
505
|
+
pending.push(parser.assignTexture(materialParams, 'sheenColorMap', extension.sheenColorTexture));
|
506
|
+
}
|
507
|
+
|
508
|
+
if (extension.sheenRoughnessTexture !== undefined) {
|
509
|
+
pending.push(parser.assignTexture(materialParams, 'sheenRoughnessMap', extension.sheenRoughnessTexture));
|
510
|
+
}
|
511
|
+
|
512
|
+
return Promise.all(pending);
|
513
|
+
}
|
514
|
+
|
451
515
|
}
|
452
516
|
/**
|
453
517
|
* Transmission Materials Extension
|
@@ -531,7 +595,7 @@ class GLTFMaterialsVolumeExtension {
|
|
531
595
|
|
532
596
|
materialParams.attenuationDistance = extension.attenuationDistance || 0;
|
533
597
|
const colorArray = extension.attenuationColor || [1, 1, 1];
|
534
|
-
materialParams.
|
598
|
+
materialParams.attenuationColor = new Color(colorArray[0], colorArray[1], colorArray[2]);
|
535
599
|
return Promise.all(pending);
|
536
600
|
}
|
537
601
|
|
@@ -607,10 +671,10 @@ class GLTFMaterialsSpecularExtension {
|
|
607
671
|
}
|
608
672
|
|
609
673
|
const colorArray = extension.specularColorFactor || [1, 1, 1];
|
610
|
-
materialParams.
|
674
|
+
materialParams.specularColor = new Color(colorArray[0], colorArray[1], colorArray[2]);
|
611
675
|
|
612
676
|
if (extension.specularColorTexture !== undefined) {
|
613
|
-
pending.push(parser.assignTexture(materialParams, '
|
677
|
+
pending.push(parser.assignTexture(materialParams, 'specularColorMap', extension.specularColorTexture).then(function (texture) {
|
614
678
|
texture.encoding = sRGBEncoding;
|
615
679
|
}));
|
616
680
|
}
|
@@ -928,7 +992,7 @@ class GLTFTextureTransformExtension {
|
|
928
992
|
/**
|
929
993
|
* Specular-Glossiness Extension
|
930
994
|
*
|
931
|
-
* Specification: https://github.com/KhronosGroup/glTF/tree/
|
995
|
+
* Specification: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness
|
932
996
|
*/
|
933
997
|
|
934
998
|
/**
|
@@ -947,7 +1011,7 @@ class GLTFMeshStandardSGMaterial extends MeshStandardMaterial {
|
|
947
1011
|
const glossinessMapParsFragmentChunk = ['#ifdef USE_GLOSSINESSMAP', ' uniform sampler2D glossinessMap;', '#endif'].join('\n');
|
948
1012
|
const specularMapFragmentChunk = ['vec3 specularFactor = specular;', '#ifdef USE_SPECULARMAP', ' vec4 texelSpecular = texture2D( specularMap, vUv );', ' texelSpecular = sRGBToLinear( texelSpecular );', ' // reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture', ' specularFactor *= texelSpecular.rgb;', '#endif'].join('\n');
|
949
1013
|
const glossinessMapFragmentChunk = ['float glossinessFactor = glossiness;', '#ifdef USE_GLOSSINESSMAP', ' vec4 texelGlossiness = texture2D( glossinessMap, vUv );', ' // reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture', ' glossinessFactor *= texelGlossiness.a;', '#endif'].join('\n');
|
950
|
-
const lightPhysicalFragmentChunk = ['PhysicalMaterial material;', 'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );', 'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );', 'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );', 'material.
|
1014
|
+
const lightPhysicalFragmentChunk = ['PhysicalMaterial material;', 'material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );', 'vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );', 'float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );', 'material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.', 'material.roughness += geometryRoughness;', 'material.roughness = min( material.roughness, 1.0 );', 'material.specularColor = specularFactor;'].join('\n');
|
951
1015
|
const uniforms = {
|
952
1016
|
specular: {
|
953
1017
|
value: new Color().setHex(0xffffff)
|
@@ -1196,6 +1260,19 @@ GLTFCubicSplineInterpolant.prototype.interpolate_ = function (i1, t0, t, t1) {
|
|
1196
1260
|
|
1197
1261
|
return result;
|
1198
1262
|
};
|
1263
|
+
|
1264
|
+
const _q = new Quaternion();
|
1265
|
+
|
1266
|
+
class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant {
|
1267
|
+
interpolate_(i1, t0, t, t1) {
|
1268
|
+
const result = super.interpolate_(i1, t0, t, t1);
|
1269
|
+
|
1270
|
+
_q.fromArray(result).normalize().toArray(result);
|
1271
|
+
|
1272
|
+
return result;
|
1273
|
+
}
|
1274
|
+
|
1275
|
+
}
|
1199
1276
|
/*********************************/
|
1200
1277
|
|
1201
1278
|
/********** INTERNALS ************/
|
@@ -1284,30 +1361,10 @@ const ALPHA_MODES = {
|
|
1284
1361
|
MASK: 'MASK',
|
1285
1362
|
BLEND: 'BLEND'
|
1286
1363
|
};
|
1287
|
-
/* UTILITY FUNCTIONS */
|
1288
|
-
|
1289
|
-
function resolveURL(url, path) {
|
1290
|
-
// Invalid URL
|
1291
|
-
if (typeof url !== 'string' || url === '') return ''; // Host Relative URL
|
1292
|
-
|
1293
|
-
if (/^https?:\/\//i.test(path) && /^\//.test(url)) {
|
1294
|
-
path = path.replace(/(^https?:\/\/[^\/]+).*/i, '$1');
|
1295
|
-
} // Absolute URL http://,https://,//
|
1296
|
-
|
1297
|
-
|
1298
|
-
if (/^(https?:)?\/\//i.test(url)) return url; // Data URI
|
1299
|
-
|
1300
|
-
if (/^data:.*,.*$/i.test(url)) return url; // Blob URL
|
1301
|
-
|
1302
|
-
if (/^blob:.*$/i.test(url)) return url; // Relative URL
|
1303
|
-
|
1304
|
-
return path + url;
|
1305
|
-
}
|
1306
1364
|
/**
|
1307
1365
|
* Specification: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#default-material
|
1308
1366
|
*/
|
1309
1367
|
|
1310
|
-
|
1311
1368
|
function createDefaultMaterial(cache) {
|
1312
1369
|
if (cache['DefaultMaterial'] === undefined) {
|
1313
1370
|
cache['DefaultMaterial'] = new MeshStandardMaterial({
|
@@ -1504,7 +1561,7 @@ class GLTFParser {
|
|
1504
1561
|
this.nodeNamesUsed = {}; // Use an ImageBitmapLoader if imageBitmaps are supported. Moves much of the
|
1505
1562
|
// expensive work of uploading a texture to the GPU off the main thread.
|
1506
1563
|
|
1507
|
-
if (typeof createImageBitmap !== 'undefined' && /Firefox/.test(navigator.userAgent) === false) {
|
1564
|
+
if (typeof createImageBitmap !== 'undefined' && /Firefox|Safari/.test(navigator.userAgent) === false) {
|
1508
1565
|
this.textureLoader = new ImageBitmapLoader(this.options.manager);
|
1509
1566
|
} else {
|
1510
1567
|
this.textureLoader = new TextureLoader(this.options.manager);
|
@@ -1627,7 +1684,22 @@ class GLTFParser {
|
|
1627
1684
|
|
1628
1685
|
_getNodeRef(cache, index, object) {
|
1629
1686
|
if (cache.refs[index] <= 1) return object;
|
1630
|
-
const ref = object.clone();
|
1687
|
+
const ref = object.clone(); // Propagates mappings to the cloned object, prevents mappings on the
|
1688
|
+
// original object from being lost.
|
1689
|
+
|
1690
|
+
const updateMappings = (original, clone) => {
|
1691
|
+
const mappings = this.associations.get(original);
|
1692
|
+
|
1693
|
+
if (mappings != null) {
|
1694
|
+
this.associations.set(clone, mappings);
|
1695
|
+
}
|
1696
|
+
|
1697
|
+
for (const [i, child] of original.children.entries()) {
|
1698
|
+
updateMappings(child, clone.children[i]);
|
1699
|
+
}
|
1700
|
+
};
|
1701
|
+
|
1702
|
+
updateMappings(object, ref);
|
1631
1703
|
ref.name += '_instance_' + cache.uses[index]++;
|
1632
1704
|
return ref;
|
1633
1705
|
}
|
@@ -1774,7 +1846,7 @@ class GLTFParser {
|
|
1774
1846
|
|
1775
1847
|
const options = this.options;
|
1776
1848
|
return new Promise(function (resolve, reject) {
|
1777
|
-
loader.load(resolveURL(bufferDef.uri, options.path), resolve, undefined, function () {
|
1849
|
+
loader.load(LoaderUtils.resolveURL(bufferDef.uri, options.path), resolve, undefined, function () {
|
1778
1850
|
reject(new Error('THREE.GLTFLoader: Failed to load buffer "' + bufferDef.uri + '".'));
|
1779
1851
|
});
|
1780
1852
|
});
|
@@ -1927,24 +1999,10 @@ class GLTFParser {
|
|
1927
1999
|
const URL = self.URL || self.webkitURL;
|
1928
2000
|
let sourceURI = source.uri || '';
|
1929
2001
|
let isObjectURL = false;
|
1930
|
-
let hasAlpha = true;
|
1931
|
-
const isJPEG = sourceURI.search(/\.jpe?g($|\?)/i) > 0 || sourceURI.search(/^data\:image\/jpeg/) === 0;
|
1932
|
-
if (source.mimeType === 'image/jpeg' || isJPEG) hasAlpha = false;
|
1933
2002
|
|
1934
2003
|
if (source.bufferView !== undefined) {
|
1935
2004
|
// Load binary image data from bufferView, if provided.
|
1936
2005
|
sourceURI = parser.getDependency('bufferView', source.bufferView).then(function (bufferView) {
|
1937
|
-
if (source.mimeType === 'image/png') {
|
1938
|
-
// Inspect the PNG 'IHDR' chunk to determine whether the image could have an
|
1939
|
-
// alpha channel. This check is conservative — the image could have an alpha
|
1940
|
-
// channel with all values == 1, and the indexed type (colorType == 3) only
|
1941
|
-
// sometimes contains alpha.
|
1942
|
-
//
|
1943
|
-
// https://en.wikipedia.org/wiki/Portable_Network_Graphics#File_header
|
1944
|
-
const colorType = new DataView(bufferView, 25, 1).getUint8(0, false);
|
1945
|
-
hasAlpha = colorType === 6 || colorType === 4 || colorType === 3;
|
1946
|
-
}
|
1947
|
-
|
1948
2006
|
isObjectURL = true;
|
1949
2007
|
const blob = new Blob([bufferView], {
|
1950
2008
|
type: source.mimeType
|
@@ -1968,7 +2026,7 @@ class GLTFParser {
|
|
1968
2026
|
};
|
1969
2027
|
}
|
1970
2028
|
|
1971
|
-
loader.load(resolveURL(sourceURI, options.path), onLoad, undefined, reject);
|
2029
|
+
loader.load(LoaderUtils.resolveURL(sourceURI, options.path), onLoad, undefined, reject);
|
1972
2030
|
});
|
1973
2031
|
}).then(function (texture) {
|
1974
2032
|
// Clean up resources and configure Texture.
|
@@ -1977,9 +2035,7 @@ class GLTFParser {
|
|
1977
2035
|
}
|
1978
2036
|
|
1979
2037
|
texture.flipY = false;
|
1980
|
-
if (textureDef.name) texture.name = textureDef.name;
|
1981
|
-
|
1982
|
-
if (!hasAlpha) texture.format = RGBFormat;
|
2038
|
+
if (textureDef.name) texture.name = textureDef.name;
|
1983
2039
|
const samplers = json.samplers || {};
|
1984
2040
|
const sampler = samplers[textureDef.sampler] || {};
|
1985
2041
|
texture.magFilter = WEBGL_FILTERS[sampler.magFilter] || LinearFilter;
|
@@ -1987,8 +2043,7 @@ class GLTFParser {
|
|
1987
2043
|
texture.wrapS = WEBGL_WRAPPINGS[sampler.wrapS] || RepeatWrapping;
|
1988
2044
|
texture.wrapT = WEBGL_WRAPPINGS[sampler.wrapT] || RepeatWrapping;
|
1989
2045
|
parser.associations.set(texture, {
|
1990
|
-
|
1991
|
-
index: textureIndex
|
2046
|
+
textures: textureIndex
|
1992
2047
|
});
|
1993
2048
|
return texture;
|
1994
2049
|
}).catch(function () {
|
@@ -2043,7 +2098,7 @@ class GLTFParser {
|
|
2043
2098
|
assignFinalMaterial(mesh) {
|
2044
2099
|
const geometry = mesh.geometry;
|
2045
2100
|
let material = mesh.material;
|
2046
|
-
const
|
2101
|
+
const useDerivativeTangents = geometry.attributes.tangent === undefined;
|
2047
2102
|
const useVertexColors = geometry.attributes.color !== undefined;
|
2048
2103
|
const useFlatShading = geometry.attributes.normal === undefined;
|
2049
2104
|
|
@@ -2077,10 +2132,10 @@ class GLTFParser {
|
|
2077
2132
|
} // Clone the material if it will be modified
|
2078
2133
|
|
2079
2134
|
|
2080
|
-
if (
|
2135
|
+
if (useDerivativeTangents || useVertexColors || useFlatShading) {
|
2081
2136
|
let cacheKey = 'ClonedMaterial:' + material.uuid + ':';
|
2082
2137
|
if (material.isGLTFSpecularGlossinessMaterial) cacheKey += 'specular-glossiness:';
|
2083
|
-
if (
|
2138
|
+
if (useDerivativeTangents) cacheKey += 'derivative-tangents:';
|
2084
2139
|
if (useVertexColors) cacheKey += 'vertex-colors:';
|
2085
2140
|
if (useFlatShading) cacheKey += 'flat-shading:';
|
2086
2141
|
let cachedMaterial = this.cache.get(cacheKey);
|
@@ -2090,7 +2145,7 @@ class GLTFParser {
|
|
2090
2145
|
if (useVertexColors) cachedMaterial.vertexColors = true;
|
2091
2146
|
if (useFlatShading) cachedMaterial.flatShading = true;
|
2092
2147
|
|
2093
|
-
if (
|
2148
|
+
if (useDerivativeTangents) {
|
2094
2149
|
// https://github.com/mrdoob/three.js/issues/11438#issuecomment-507003995
|
2095
2150
|
if (cachedMaterial.normalScale) cachedMaterial.normalScale.y *= -1;
|
2096
2151
|
if (cachedMaterial.clearcoatNormalScale) cachedMaterial.clearcoatNormalScale.y *= -1;
|
@@ -2185,6 +2240,7 @@ class GLTFParser {
|
|
2185
2240
|
|
2186
2241
|
materialParams.depthWrite = false;
|
2187
2242
|
} else {
|
2243
|
+
materialParams.format = RGBFormat;
|
2188
2244
|
materialParams.transparent = false;
|
2189
2245
|
|
2190
2246
|
if (alphaMode === ALPHA_MODES.MASK) {
|
@@ -2193,12 +2249,12 @@ class GLTFParser {
|
|
2193
2249
|
}
|
2194
2250
|
|
2195
2251
|
if (materialDef.normalTexture !== undefined && materialType !== MeshBasicMaterial) {
|
2196
|
-
pending.push(parser.assignTexture(materialParams, 'normalMap', materialDef.normalTexture));
|
2197
|
-
|
2198
|
-
materialParams.normalScale = new Vector2(1, -1);
|
2252
|
+
pending.push(parser.assignTexture(materialParams, 'normalMap', materialDef.normalTexture));
|
2253
|
+
materialParams.normalScale = new Vector2(1, 1);
|
2199
2254
|
|
2200
2255
|
if (materialDef.normalTexture.scale !== undefined) {
|
2201
|
-
|
2256
|
+
const scale = materialDef.normalTexture.scale;
|
2257
|
+
materialParams.normalScale.set(scale, scale);
|
2202
2258
|
}
|
2203
2259
|
}
|
2204
2260
|
|
@@ -2233,8 +2289,7 @@ class GLTFParser {
|
|
2233
2289
|
if (material.emissiveMap) material.emissiveMap.encoding = sRGBEncoding;
|
2234
2290
|
assignExtrasToUserData(material, materialDef);
|
2235
2291
|
parser.associations.set(material, {
|
2236
|
-
|
2237
|
-
index: materialIndex
|
2292
|
+
materials: materialIndex
|
2238
2293
|
});
|
2239
2294
|
if (materialDef.extensions) addUnknownExtensionsToUserData(extensions, material, materialDef);
|
2240
2295
|
return material;
|
@@ -2379,11 +2434,21 @@ class GLTFParser {
|
|
2379
2434
|
meshes.push(mesh);
|
2380
2435
|
}
|
2381
2436
|
|
2437
|
+
for (let i = 0, il = meshes.length; i < il; i++) {
|
2438
|
+
parser.associations.set(meshes[i], {
|
2439
|
+
meshes: meshIndex,
|
2440
|
+
primitives: i
|
2441
|
+
});
|
2442
|
+
}
|
2443
|
+
|
2382
2444
|
if (meshes.length === 1) {
|
2383
2445
|
return meshes[0];
|
2384
2446
|
}
|
2385
2447
|
|
2386
2448
|
const group = new Group();
|
2449
|
+
parser.associations.set(group, {
|
2450
|
+
meshes: meshIndex
|
2451
|
+
});
|
2387
2452
|
|
2388
2453
|
for (let i = 0, il = meshes.length; i < il; i++) {
|
2389
2454
|
group.add(meshes[i]);
|
@@ -2512,9 +2577,8 @@ class GLTFParser {
|
|
2512
2577
|
const targetNames = [];
|
2513
2578
|
|
2514
2579
|
if (PATH_PROPERTIES[target.path] === PATH_PROPERTIES.weights) {
|
2515
|
-
// Node may be a Group (glTF mesh with several primitives) or a Mesh.
|
2516
2580
|
node.traverse(function (object) {
|
2517
|
-
if (object.
|
2581
|
+
if (object.morphTargetInfluences) {
|
2518
2582
|
targetNames.push(object.name ? object.name : object.uuid);
|
2519
2583
|
}
|
2520
2584
|
});
|
@@ -2543,7 +2607,8 @@ class GLTFParser {
|
|
2543
2607
|
// A CUBICSPLINE keyframe in glTF has three output values for each input value,
|
2544
2608
|
// representing inTangent, splineVertex, and outTangent. As a result, track.getValueSize()
|
2545
2609
|
// must be divided by three to get the interpolant's sampleSize argument.
|
2546
|
-
|
2610
|
+
const interpolantType = this instanceof QuaternionKeyframeTrack ? GLTFCubicSplineQuaternionInterpolant : GLTFCubicSplineInterpolant;
|
2611
|
+
return new interpolantType(this.times, this.values, this.getValueSize() / 3, result);
|
2547
2612
|
}; // Mark as CUBICSPLINE. `track.getInterpolation()` doesn't support custom interpolants.
|
2548
2613
|
|
2549
2614
|
|
@@ -2664,10 +2729,11 @@ class GLTFParser {
|
|
2664
2729
|
}
|
2665
2730
|
}
|
2666
2731
|
|
2667
|
-
parser.associations.
|
2668
|
-
|
2669
|
-
|
2670
|
-
|
2732
|
+
if (!parser.associations.has(node)) {
|
2733
|
+
parser.associations.set(node, {});
|
2734
|
+
}
|
2735
|
+
|
2736
|
+
parser.associations.get(node).nodes = nodeIndex;
|
2671
2737
|
return node;
|
2672
2738
|
});
|
2673
2739
|
}
|
@@ -2693,17 +2759,39 @@ class GLTFParser {
|
|
2693
2759
|
const pending = [];
|
2694
2760
|
|
2695
2761
|
for (let i = 0, il = nodeIds.length; i < il; i++) {
|
2696
|
-
pending.push(
|
2762
|
+
pending.push(buildNodeHierarchy(nodeIds[i], scene, json, parser));
|
2697
2763
|
}
|
2698
2764
|
|
2699
2765
|
return Promise.all(pending).then(function () {
|
2766
|
+
// Removes dangling associations, associations that reference a node that
|
2767
|
+
// didn't make it into the scene.
|
2768
|
+
const reduceAssociations = node => {
|
2769
|
+
const reducedAssociations = new Map();
|
2770
|
+
|
2771
|
+
for (const [key, value] of parser.associations) {
|
2772
|
+
if (key instanceof Material || key instanceof Texture) {
|
2773
|
+
reducedAssociations.set(key, value);
|
2774
|
+
}
|
2775
|
+
}
|
2776
|
+
|
2777
|
+
node.traverse(node => {
|
2778
|
+
const mappings = parser.associations.get(node);
|
2779
|
+
|
2780
|
+
if (mappings != null) {
|
2781
|
+
reducedAssociations.set(node, mappings);
|
2782
|
+
}
|
2783
|
+
});
|
2784
|
+
return reducedAssociations;
|
2785
|
+
};
|
2786
|
+
|
2787
|
+
parser.associations = reduceAssociations(scene);
|
2700
2788
|
return scene;
|
2701
2789
|
});
|
2702
2790
|
}
|
2703
2791
|
|
2704
2792
|
}
|
2705
2793
|
|
2706
|
-
function
|
2794
|
+
function buildNodeHierarchy(nodeId, parentObject, json, parser) {
|
2707
2795
|
const nodeDef = json.nodes[nodeId];
|
2708
2796
|
return parser.getDependency('node', nodeId).then(function (node) {
|
2709
2797
|
if (nodeDef.skin === undefined) return node; // build skeleton here as well
|
@@ -2755,7 +2843,7 @@ function buildNodeHierachy(nodeId, parentObject, json, parser) {
|
|
2755
2843
|
|
2756
2844
|
for (let i = 0, il = children.length; i < il; i++) {
|
2757
2845
|
const child = children[i];
|
2758
|
-
pending.push(
|
2846
|
+
pending.push(buildNodeHierarchy(child, node, json, parser));
|
2759
2847
|
}
|
2760
2848
|
}
|
2761
2849
|
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("./RGBELoader.cjs.js");class a extends e.Loader{constructor(
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three"),t=require("./RGBELoader.cjs.js");class a extends e.Loader{constructor(a){super(a),this.hdrLoader=new t.RGBELoader,this.type=e.HalfFloatType}load(t,a,r,i){Array.isArray(t)||(console.warn("THREE.HDRCubeTextureLoader signature has changed. Use .setDataType() instead."),this.setDataType(t),t=a,a=r,r=i,i=arguments[4]);const s=new e.CubeTexture;switch(s.type=this.type,s.type){case e.FloatType:case e.HalfFloatType:s.encoding=e.LinearEncoding,s.format=e.RGBFormat,s.minFilter=e.LinearFilter,s.magFilter=e.LinearFilter,s.generateMipmaps=!1}const n=this;let o=0;function d(a,r,i,d){new e.FileLoader(n.manager).setPath(n.path).setResponseType("arraybuffer").setWithCredentials(n.withCredentials).load(t[a],(function(t){o++;const i=n.hdrLoader.parse(t);if(i){if(void 0!==i.data){const t=new e.DataTexture(i.data,i.width,i.height);t.type=s.type,t.encoding=s.encoding,t.format=s.format,t.minFilter=s.minFilter,t.magFilter=s.magFilter,t.generateMipmaps=s.generateMipmaps,s.images[a]=t}6===o&&(s.needsUpdate=!0,r&&r(s))}}),i,d)}for(let e=0;e<t.length;e++)d(e,a,r,i);return s}setDataType(e){return this.type=e,this.hdrLoader.setDataType(e),this}}exports.HDRCubeTextureLoader=a;
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import { Loader,
|
1
|
+
import { Loader, HalfFloatType, CubeTexture, LinearEncoding, RGBFormat, LinearFilter, FloatType, FileLoader, DataTexture } from 'three';
|
2
2
|
import { RGBELoader } from './RGBELoader.js';
|
3
3
|
|
4
4
|
class HDRCubeTextureLoader extends Loader {
|
5
5
|
constructor(manager) {
|
6
6
|
super(manager);
|
7
7
|
this.hdrLoader = new RGBELoader();
|
8
|
-
this.type =
|
8
|
+
this.type = HalfFloatType;
|
9
9
|
}
|
10
10
|
|
11
11
|
load(urls, onLoad, onProgress, onError) {
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");class t extends e.DataTextureLoader{constructor(
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");class t extends e.DataTextureLoader{constructor(t){super(t),this.type=e.HalfFloatType}parse(t){const r=function(e,t){switch(e){case 1:console.error("THREE.RGBELoader Read Error: "+(t||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(t||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(t||""));break;default:case 4:console.error("THREE.RGBELoader: Error: "+(t||""))}return-1},a=function(e,t,r){t=t||1024;let a=e.pos,n=-1,o=0,s="",i=String.fromCharCode.apply(null,new Uint16Array(e.subarray(a,a+128)));for(;0>(n=i.indexOf("\n"))&&o<t&&a<e.byteLength;)s+=i,o+=i.length,a+=128,i+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(a,a+128)));return-1<n&&(!1!==r&&(e.pos+=o+n+1),s+i.slice(0,n))},n=function(e,t,r,a){const n=e[t+3],o=Math.pow(2,n-128)/255;r[a+0]=e[t+0]*o,r[a+1]=e[t+1]*o,r[a+2]=e[t+2]*o},o=function(t,r,a,n){const o=t[r+3],s=Math.pow(2,o-128)/255;a[n+0]=e.DataUtils.toHalfFloat(Math.min(t[r+0]*s,65504)),a[n+1]=e.DataUtils.toHalfFloat(Math.min(t[r+1]*s,65504)),a[n+2]=e.DataUtils.toHalfFloat(Math.min(t[r+2]*s,65504))},s=new Uint8Array(t);s.pos=0;const i=function(e){const t=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,n=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,o=/^\s*FORMAT=(\S+)\s*$/,s=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,i={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,c;if(e.pos>=e.byteLength||!(l=a(e)))return r(1,"no header found");if(!(c=l.match(/^#\?(\S+)/)))return r(3,"bad initial token");for(i.valid|=1,i.programtype=c[1],i.string+=l+"\n";l=a(e),!1!==l;)if(i.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(t))&&(i.gamma=parseFloat(c[1],10)),(c=l.match(n))&&(i.exposure=parseFloat(c[1],10)),(c=l.match(o))&&(i.valid|=2,i.format=c[1]),(c=l.match(s))&&(i.valid|=4,i.height=parseInt(c[1],10),i.width=parseInt(c[2],10)),2&i.valid&&4&i.valid)break}else i.comments+=l+"\n";return 2&i.valid?4&i.valid?i:r(3,"missing image size specifier"):r(3,"missing format specifier")}(s);if(-1!==i){const t=i.width,a=i.height,l=function(e,t,a){const n=t;if(n<8||n>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(n!==(e[2]<<8|e[3]))return r(3,"wrong scanline width");const o=new Uint8Array(4*t*a);if(!o.length)return r(4,"unable to allocate buffer space");let s=0,i=0;const l=4*n,c=new Uint8Array(4),f=new Uint8Array(l);let p=a;for(;p>0&&i<e.byteLength;){if(i+4>e.byteLength)return r(1);if(c[0]=e[i++],c[1]=e[i++],c[2]=e[i++],c[3]=e[i++],2!=c[0]||2!=c[1]||(c[2]<<8|c[3])!=n)return r(3,"bad rgbe scanline format");let t,a=0;for(;a<l&&i<e.byteLength;){t=e[i++];const n=t>128;if(n&&(t-=128),0===t||a+t>l)return r(3,"bad scanline data");if(n){const r=e[i++];for(let e=0;e<t;e++)f[a++]=r}else f.set(e.subarray(i,i+t),a),a+=t,i+=t}const d=n;for(let e=0;e<d;e++){let t=0;o[s]=f[e+t],t+=n,o[s+1]=f[e+t],t+=n,o[s+2]=f[e+t],t+=n,o[s+3]=f[e+t],s+=4}p--}return o}(s.subarray(s.pos),t,a);if(-1!==l){let r,s,c,f;switch(this.type){case e.FloatType:f=l.length/4;const t=new Float32Array(3*f);for(let e=0;e<f;e++)n(l,4*e,t,3*e);r=t,s=e.RGBFormat,c=e.FloatType;break;case e.HalfFloatType:f=l.length/4;const a=new Uint16Array(3*f);for(let e=0;e<f;e++)o(l,4*e,a,3*e);r=a,s=e.RGBFormat,c=e.HalfFloatType;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type)}return{width:t,height:a,data:r,header:i.string,gamma:i.gamma,exposure:i.exposure,format:s,type:c}}}return null}setDataType(e){return this.type=e,this}load(t,r,a,n){return super.load(t,(function(t,a){switch(t.type){case e.FloatType:case e.HalfFloatType:t.encoding=e.LinearEncoding,t.minFilter=e.LinearFilter,t.magFilter=e.LinearFilter,t.generateMipmaps=!1,t.flipY=!0}r&&r(t,a)}),a,n)}}exports.RGBELoader=t;
|
package/loaders/RGBELoader.js
CHANGED
@@ -5,7 +5,7 @@ import { DataTextureLoader, HalfFloatType, FloatType, DataUtils, RGBFormat, Line
|
|
5
5
|
class RGBELoader extends DataTextureLoader {
|
6
6
|
constructor(manager) {
|
7
7
|
super(manager);
|
8
|
-
this.type =
|
8
|
+
this.type = HalfFloatType;
|
9
9
|
} // adapted from http://www.graphics.cornell.edu/~bjw/rgbe.html
|
10
10
|
|
11
11
|
|
@@ -285,10 +285,11 @@ class RGBELoader extends DataTextureLoader {
|
|
285
285
|
|
286
286
|
const RGBEByteToRGBHalf = function (sourceArray, sourceOffset, destArray, destOffset) {
|
287
287
|
const e = sourceArray[sourceOffset + 3];
|
288
|
-
const scale = Math.pow(2.0, e - 128.0) / 255.0;
|
289
|
-
|
290
|
-
destArray[destOffset +
|
291
|
-
destArray[destOffset +
|
288
|
+
const scale = Math.pow(2.0, e - 128.0) / 255.0; // clamping to 65504, the maximum representable value in float16
|
289
|
+
|
290
|
+
destArray[destOffset + 0] = DataUtils.toHalfFloat(Math.min(sourceArray[sourceOffset + 0] * scale, 65504));
|
291
|
+
destArray[destOffset + 1] = DataUtils.toHalfFloat(Math.min(sourceArray[sourceOffset + 1] * scale, 65504));
|
292
|
+
destArray[destOffset + 2] = DataUtils.toHalfFloat(Math.min(sourceArray[sourceOffset + 2] * scale, 65504));
|
292
293
|
};
|
293
294
|
|
294
295
|
const byteArray = new Uint8Array(buffer);
|
@@ -306,8 +307,8 @@ class RGBELoader extends DataTextureLoader {
|
|
306
307
|
|
307
308
|
switch (this.type) {
|
308
309
|
case FloatType:
|
309
|
-
numElements = image_rgba_data.length / 4
|
310
|
-
const floatArray = new Float32Array(numElements);
|
310
|
+
numElements = image_rgba_data.length / 4;
|
311
|
+
const floatArray = new Float32Array(numElements * 3);
|
311
312
|
|
312
313
|
for (let j = 0; j < numElements; j++) {
|
313
314
|
RGBEByteToRGBFloat(image_rgba_data, j * 4, floatArray, j * 3);
|
@@ -319,8 +320,8 @@ class RGBELoader extends DataTextureLoader {
|
|
319
320
|
break;
|
320
321
|
|
321
322
|
case HalfFloatType:
|
322
|
-
numElements = image_rgba_data.length / 4
|
323
|
-
const halfArray = new Uint16Array(numElements);
|
323
|
+
numElements = image_rgba_data.length / 4;
|
324
|
+
const halfArray = new Uint16Array(numElements * 3);
|
324
325
|
|
325
326
|
for (let j = 0; j < numElements; j++) {
|
326
327
|
RGBEByteToRGBHalf(image_rgba_data, j * 4, halfArray, j * 3);
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");class r extends e.DataTextureLoader{constructor(r){super(r),this.type=e.HalfFloatType,this.maxRange=7}setDataType(e){return this.type=e,this}setMaxRange(e){return this.maxRange=e,this}loadCubemap(r,t,a,n){const i=new e.CubeTexture;let f=0;const o=this;function s(e){o.load(r[e],(function(r){i.images[e]=r,f++,6===f&&(i.needsUpdate=!0,t&&t(i))}),void 0,n)}for(let e=0;e<r.length;++e)s(e);return i.type=this.type,i.format=e.RGBAFormat,i.minFilter=e.LinearFilter,i.generateMipmaps=!1,i}parse(r){const t=i.decode(r),a=i.toRGBA8(t)[0],n=new Uint8Array(a),f=t.width*t.height*4,o=this.type===e.HalfFloatType?new Uint16Array(f):new Float32Array(f);for(let r=0;r<n.length;r+=4){const t=n[r+0]/255,a=n[r+1]/255,i=n[r+2]/255,f=n[r+3]/255;this.type===e.HalfFloatType?(o[r+0]=e.DataUtils.toHalfFloat(Math.min(t*f*this.maxRange,65504)),o[r+1]=e.DataUtils.toHalfFloat(Math.min(a*f*this.maxRange,65504)),o[r+2]=e.DataUtils.toHalfFloat(Math.min(i*f*this.maxRange,65504)),o[r+3]=e.DataUtils.toHalfFloat(1)):(o[r+0]=t*f*this.maxRange,o[r+1]=a*f*this.maxRange,o[r+2]=i*f*this.maxRange,o[r+3]=1)}return{width:t.width,height:t.height,data:o,format:e.RGBAFormat,type:this.type,flipY:!0}}}var t,a,n,i={};i.toRGBA8=function(e){var r=e.width,t=e.height;if(null==e.tabs.acTL)return[i.toRGBA8.decodeImage(e.data,r,t,e).buffer];var a=[];null==e.frames[0].data&&(e.frames[0].data=e.data);for(var n=r*t*4,f=new Uint8Array(n),o=new Uint8Array(n),s=new Uint8Array(n),l=0;l<e.frames.length;l++){var d=e.frames[l],c=d.rect.x,h=d.rect.y,u=d.rect.width,v=d.rect.height,p=i.toRGBA8.decodeImage(d.data,u,v,e);if(0!=l)for(var g=0;g<n;g++)s[g]=f[g];if(0==d.blend?i._copyTile(p,u,v,f,r,t,c,h,0):1==d.blend&&i._copyTile(p,u,v,f,r,t,c,h,1),a.push(f.buffer.slice(0)),0==d.dispose);else if(1==d.dispose)i._copyTile(o,u,v,f,r,t,c,h,0);else if(2==d.dispose)for(g=0;g<n;g++)f[g]=s[g]}return a},i.toRGBA8.decodeImage=function(e,r,t,a){var n=r*t,f=i.decode._getBPP(a),o=Math.ceil(r*f/8),s=new Uint8Array(4*n),l=new Uint32Array(s.buffer),d=a.ctype,c=a.depth,h=i._bin.readUshort;if(6==d){var u=n<<2;if(8==c)for(var v=0;v<u;v+=4)s[v]=e[v],s[v+1]=e[v+1],s[v+2]=e[v+2],s[v+3]=e[v+3];if(16==c)for(v=0;v<u;v++)s[v]=e[v<<1]}else if(2==d){var p=a.tabs.tRNS;if(null==p){if(8==c)for(v=0;v<n;v++){var g=3*v;l[v]=255<<24|e[g+2]<<16|e[g+1]<<8|e[g]}if(16==c)for(v=0;v<n;v++){g=6*v;l[v]=255<<24|e[g+4]<<16|e[g+2]<<8|e[g]}}else{var w=p[0],y=p[1],b=p[2];if(8==c)for(v=0;v<n;v++){var m=v<<2;g=3*v;l[v]=255<<24|e[g+2]<<16|e[g+1]<<8|e[g],e[g]==w&&e[g+1]==y&&e[g+2]==b&&(s[m+3]=0)}if(16==c)for(v=0;v<n;v++){m=v<<2,g=6*v;l[v]=255<<24|e[g+4]<<16|e[g+2]<<8|e[g],h(e,g)==w&&h(e,g+2)==y&&h(e,g+4)==b&&(s[m+3]=0)}}}else if(3==d){var _=a.tabs.PLTE,H=a.tabs.tRNS,U=H?H.length:0;if(1==c)for(var A=0;A<t;A++){var R=A*o,I=A*r;for(v=0;v<r;v++){m=I+v<<2;var T=3*(x=e[R+(v>>3)]>>7-((7&v)<<0)&1);s[m]=_[T],s[m+1]=_[T+1],s[m+2]=_[T+2],s[m+3]=x<U?H[x]:255}}if(2==c)for(A=0;A<t;A++)for(R=A*o,I=A*r,v=0;v<r;v++){m=I+v<<2,T=3*(x=e[R+(v>>2)]>>6-((3&v)<<1)&3);s[m]=_[T],s[m+1]=_[T+1],s[m+2]=_[T+2],s[m+3]=x<U?H[x]:255}if(4==c)for(A=0;A<t;A++)for(R=A*o,I=A*r,v=0;v<r;v++){m=I+v<<2,T=3*(x=e[R+(v>>1)]>>4-((1&v)<<2)&15);s[m]=_[T],s[m+1]=_[T+1],s[m+2]=_[T+2],s[m+3]=x<U?H[x]:255}if(8==c)for(v=0;v<n;v++){var x;m=v<<2,T=3*(x=e[v]);s[m]=_[T],s[m+1]=_[T+1],s[m+2]=_[T+2],s[m+3]=x<U?H[x]:255}}else if(4==d){if(8==c)for(v=0;v<n;v++){m=v<<2;var C=e[B=v<<1];s[m]=C,s[m+1]=C,s[m+2]=C,s[m+3]=e[B+1]}if(16==c)for(v=0;v<n;v++){var B;m=v<<2,C=e[B=v<<2];s[m]=C,s[m+1]=C,s[m+2]=C,s[m+3]=e[B+2]}}else if(0==d)for(w=a.tabs.tRNS?a.tabs.tRNS:-1,A=0;A<t;A++){var M=A*o,S=A*r;if(1==c)for(var D=0;D<r;D++){var F=(C=255*(e[M+(D>>>3)]>>>7-(7&D)&1))==255*w?0:255;l[S+D]=F<<24|C<<16|C<<8|C}else if(2==c)for(D=0;D<r;D++){F=(C=85*(e[M+(D>>>2)]>>>6-((3&D)<<1)&3))==85*w?0:255;l[S+D]=F<<24|C<<16|C<<8|C}else if(4==c)for(D=0;D<r;D++){F=(C=17*(e[M+(D>>>1)]>>>4-((1&D)<<2)&15))==17*w?0:255;l[S+D]=F<<24|C<<16|C<<8|C}else if(8==c)for(D=0;D<r;D++){F=(C=e[M+D])==w?0:255;l[S+D]=F<<24|C<<16|C<<8|C}else if(16==c)for(D=0;D<r;D++){C=e[M+(D<<1)],F=h(e,M+(D<<v))==w?0:255;l[S+D]=F<<24|C<<16|C<<8|C}}return s},i.decode=function(e){for(var r,t=new Uint8Array(e),a=8,n=i._bin,f=n.readUshort,o=n.readUint,s={tabs:{},frames:[]},l=new Uint8Array(t.length),d=0,c=0,h=[137,80,78,71,13,10,26,10],u=0;u<8;u++)if(t[u]!=h[u])throw"The input is not a PNG file!";for(;a<t.length;){var v=n.readUint(t,a);a+=4;var p=n.readASCII(t,a,4);if(a+=4,"IHDR"==p)i.decode._IHDR(t,a,s);else if("CgBI"==p)s.tabs[p]=t.slice(a,a+4);else if("IDAT"==p){for(u=0;u<v;u++)l[d+u]=t[a+u];d+=v}else if("acTL"==p)s.tabs[p]={num_frames:o(t,a),num_plays:o(t,a+4)},r=new Uint8Array(t.length);else if("fcTL"==p){var g;if(0!=c)(g=s.frames[s.frames.length-1]).data=i.decode._decompress(s,r.slice(0,c),g.rect.width,g.rect.height),c=0;var w={x:o(t,a+12),y:o(t,a+16),width:o(t,a+4),height:o(t,a+8)},y=f(t,a+22);y=f(t,a+20)/(0==y?100:y);var b={rect:w,delay:Math.round(1e3*y),dispose:t[a+24],blend:t[a+25]};s.frames.push(b)}else if("fdAT"==p){for(u=0;u<v-4;u++)r[c+u]=t[a+u+4];c+=v-4}else if("pHYs"==p)s.tabs[p]=[n.readUint(t,a),n.readUint(t,a+4),t[a+8]];else if("cHRM"==p){s.tabs[p]=[];for(u=0;u<8;u++)s.tabs[p].push(n.readUint(t,a+4*u))}else if("tEXt"==p||"zTXt"==p){null==s.tabs[p]&&(s.tabs[p]={});var m=n.nextZero(t,a),_=n.readASCII(t,a,m-a),H=a+v-m-1;if("tEXt"==p)I=n.readASCII(t,m+1,H);else{var U=i.decode._inflate(t.slice(m+2,m+2+H));I=n.readUTF8(U,0,U.length)}s.tabs[p][_]=I}else if("iTXt"==p){null==s.tabs[p]&&(s.tabs[p]={});m=0;var A=a;m=n.nextZero(t,A);_=n.readASCII(t,A,m-A);var R=t[A=m+1];A+=2,m=n.nextZero(t,A),n.readASCII(t,A,m-A),A=m+1,m=n.nextZero(t,A),n.readUTF8(t,A,m-A);var I;H=v-((A=m+1)-a);if(0==R)I=n.readUTF8(t,A,H);else{U=i.decode._inflate(t.slice(A,A+H));I=n.readUTF8(U,0,U.length)}s.tabs[p][_]=I}else if("PLTE"==p)s.tabs[p]=n.readBytes(t,a,v);else if("hIST"==p){var T=s.tabs.PLTE.length/3;s.tabs[p]=[];for(u=0;u<T;u++)s.tabs[p].push(f(t,a+2*u))}else if("tRNS"==p)3==s.ctype?s.tabs[p]=n.readBytes(t,a,v):0==s.ctype?s.tabs[p]=f(t,a):2==s.ctype&&(s.tabs[p]=[f(t,a),f(t,a+2),f(t,a+4)]);else if("gAMA"==p)s.tabs[p]=n.readUint(t,a)/1e5;else if("sRGB"==p)s.tabs[p]=t[a];else if("bKGD"==p)0==s.ctype||4==s.ctype?s.tabs[p]=[f(t,a)]:2==s.ctype||6==s.ctype?s.tabs[p]=[f(t,a),f(t,a+2),f(t,a+4)]:3==s.ctype&&(s.tabs[p]=t[a]);else if("IEND"==p)break;a+=v,n.readUint(t,a),a+=4}0!=c&&((g=s.frames[s.frames.length-1]).data=i.decode._decompress(s,r.slice(0,c),g.rect.width,g.rect.height),c=0);return s.data=i.decode._decompress(s,l,s.width,s.height),delete s.compress,delete s.interlace,delete s.filter,s},i.decode._decompress=function(e,r,t,a){var n=i.decode._getBPP(e),f=Math.ceil(t*n/8),o=new Uint8Array((f+1+e.interlace)*a);return r=e.tabs.CgBI?i.inflateRaw(r,o):i.decode._inflate(r,o),0==e.interlace?r=i.decode._filterZero(r,e,0,t,a):1==e.interlace&&(r=i.decode._readInterlace(r,e)),r},i.decode._inflate=function(e,r){return i.inflateRaw(new Uint8Array(e.buffer,2,e.length-6),r)},i.inflateRaw=((n={}).H={},n.H.N=function(e,r){var t,a,i=Uint8Array,f=0,o=0,s=0,l=0,d=0,c=0,h=0,u=0,v=0;if(3==e[0]&&0==e[1])return r||new i(0);var p=n.H,g=p.b,w=p.e,y=p.R,b=p.n,m=p.A,_=p.Z,H=p.m,U=null==r;for(U&&(r=new i(e.length>>>2<<5));0==f;)if(f=g(e,v,1),o=g(e,v+1,2),v+=3,0!=o){if(U&&(r=n.H.W(r,u+(1<<17))),1==o&&(t=H.J,a=H.h,c=511,h=31),2==o){s=w(e,v,5)+257,l=w(e,v+5,5)+1,d=w(e,v+10,4)+4,v+=14;for(var A=1,R=0;R<38;R+=2)H.Q[R]=0,H.Q[R+1]=0;for(R=0;R<d;R++){var I=w(e,v+3*R,3);H.Q[1+(H.X[R]<<1)]=I,I>A&&(A=I)}v+=3*d,b(H.Q,A),m(H.Q,A,H.u),t=H.w,a=H.d,v=y(H.u,(1<<A)-1,s+l,e,v,H.v);var T=p.V(H.v,0,s,H.C);c=(1<<T)-1;var x=p.V(H.v,s,l,H.D);h=(1<<x)-1,b(H.C,T),m(H.C,T,t),b(H.D,x),m(H.D,x,a)}for(;;){var C=t[_(e,v)&c];v+=15&C;var B=C>>>4;if(B>>>8==0)r[u++]=B;else{if(256==B)break;var M=u+B-254;if(B>264){var S=H.q[B-257];M=u+(S>>>3)+w(e,v,7&S),v+=7&S}var D=a[_(e,v)&h];v+=15&D;var F=D>>>4,P=H.c[F],G=(P>>>4)+g(e,v,15&P);for(v+=15&P;u<M;)r[u]=r[u++-G],r[u]=r[u++-G],r[u]=r[u++-G],r[u]=r[u++-G];u=M}}}else{0!=(7&v)&&(v+=8-(7&v));var Z=4+(v>>>3),L=e[Z-4]|e[Z-3]<<8;U&&(r=n.H.W(r,u+L)),r.set(new i(e.buffer,e.byteOffset+Z,L),u),v=Z+L<<3,u+=L}return r.length==u?r:r.slice(0,u)},n.H.W=function(e,r){var t=e.length;if(r<=t)return e;var a=new Uint8Array(t<<1);return a.set(e,0),a},n.H.R=function(e,r,t,a,i,f){for(var o=n.H.e,s=n.H.Z,l=0;l<t;){var d=e[s(a,i)&r];i+=15&d;var c=d>>>4;if(c<=15)f[l]=c,l++;else{var h=0,u=0;16==c?(u=3+o(a,i,2),i+=2,h=f[l-1]):17==c?(u=3+o(a,i,3),i+=3):18==c&&(u=11+o(a,i,7),i+=7);for(var v=l+u;l<v;)f[l]=h,l++}}return i},n.H.V=function(e,r,t,a){for(var n=0,i=0,f=a.length>>>1;i<t;){var o=e[i+r];a[i<<1]=0,a[1+(i<<1)]=o,o>n&&(n=o),i++}for(;i<f;)a[i<<1]=0,a[1+(i<<1)]=0,i++;return n},n.H.n=function(e,r){for(var t,a,i,f,o=n.H.m,s=e.length,l=o.j,d=0;d<=r;d++)l[d]=0;for(d=1;d<s;d+=2)l[e[d]]++;var c=o.K;for(t=0,l[0]=0,a=1;a<=r;a++)t=t+l[a-1]<<1,c[a]=t;for(i=0;i<s;i+=2)0!=(f=e[i+1])&&(e[i]=c[f],c[f]++)},n.H.A=function(e,r,t){for(var a=e.length,i=n.H.m.r,f=0;f<a;f+=2)if(0!=e[f+1])for(var o=f>>1,s=e[f+1],l=o<<4|s,d=r-s,c=e[f]<<d,h=c+(1<<d);c!=h;)t[i[c]>>>15-r]=l,c++},n.H.l=function(e,r){for(var t=n.H.m.r,a=15-r,i=0;i<e.length;i+=2){var f=e[i]<<r-e[i+1];e[i]=t[f]>>>a}},n.H.M=function(e,r,t){t<<=7&r;var a=r>>>3;e[a]|=t,e[a+1]|=t>>>8},n.H.I=function(e,r,t){t<<=7&r;var a=r>>>3;e[a]|=t,e[a+1]|=t>>>8,e[a+2]|=t>>>16},n.H.e=function(e,r,t){return(e[r>>>3]|e[1+(r>>>3)]<<8)>>>(7&r)&(1<<t)-1},n.H.b=function(e,r,t){return(e[r>>>3]|e[1+(r>>>3)]<<8|e[2+(r>>>3)]<<16)>>>(7&r)&(1<<t)-1},n.H.Z=function(e,r){return(e[r>>>3]|e[1+(r>>>3)]<<8|e[2+(r>>>3)]<<16)>>>(7&r)},n.H.i=function(e,r){return(e[r>>>3]|e[1+(r>>>3)]<<8|e[2+(r>>>3)]<<16|e[3+(r>>>3)]<<24)>>>(7&r)},n.H.m=(t=Uint16Array,a=Uint32Array,{K:new t(16),j:new t(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new t(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new a(32),J:new t(512),_:[],h:new t(32),$:[],w:new t(32768),C:[],v:[],d:new t(32768),D:[],u:new t(512),Q:[],r:new t(32768),s:new a(286),Y:new a(30),a:new a(19),t:new a(15e3),k:new t(65536),g:new t(32768)}),function(){for(var e=n.H.m,r=0;r<32768;r++){var t=r;t=(4278255360&(t=(4042322160&(t=(3435973836&(t=(2863311530&t)>>>1|(1431655765&t)<<1))>>>2|(858993459&t)<<2))>>>4|(252645135&t)<<4))>>>8|(16711935&t)<<8,e.r[r]=(t>>>16|t<<16)>>>17}function a(e,r,t){for(;0!=r--;)e.push(0,t)}for(r=0;r<32;r++)e.q[r]=e.S[r]<<3|e.T[r],e.c[r]=e.p[r]<<4|e.z[r];a(e._,144,8),a(e._,112,9),a(e._,24,7),a(e._,8,8),n.H.n(e._,9),n.H.A(e._,9,e.J),n.H.l(e._,9),a(e.$,32,5),n.H.n(e.$,5),n.H.A(e.$,5,e.h),n.H.l(e.$,5),a(e.Q,19,0),a(e.C,286,0),a(e.D,30,0),a(e.v,320,0)}(),n.H.N),i.decode._readInterlace=function(e,r){for(var t=r.width,a=r.height,n=i.decode._getBPP(r),f=n>>3,o=Math.ceil(t*n/8),s=new Uint8Array(a*o),l=0,d=[0,0,4,0,2,0,1],c=[0,4,0,2,0,1,0],h=[8,8,8,4,4,2,2],u=[8,8,4,4,2,2,1],v=0;v<7;){for(var p=h[v],g=u[v],w=0,y=0,b=d[v];b<a;)b+=p,y++;for(var m=c[v];m<t;)m+=g,w++;var _=Math.ceil(w*n/8);i.decode._filterZero(e,r,l,w,y);for(var H=0,U=d[v];U<a;){for(var A=c[v],R=l+H*_<<3;A<t;){var I;if(1==n)I=(I=e[R>>3])>>7-(7&R)&1,s[U*o+(A>>3)]|=I<<7-((7&A)<<0);if(2==n)I=(I=e[R>>3])>>6-(7&R)&3,s[U*o+(A>>2)]|=I<<6-((3&A)<<1);if(4==n)I=(I=e[R>>3])>>4-(7&R)&15,s[U*o+(A>>1)]|=I<<4-((1&A)<<2);if(n>=8)for(var T=U*o+A*f,x=0;x<f;x++)s[T+x]=e[(R>>3)+x];R+=n,A+=g}H++,U+=p}w*y!=0&&(l+=y*(1+_)),v+=1}return s},i.decode._getBPP=function(e){return[1,null,3,1,2,null,4][e.ctype]*e.depth},i.decode._filterZero=function(e,r,t,a,n){var f=i.decode._getBPP(r),o=Math.ceil(a*f/8),s=i.decode._paeth;f=Math.ceil(f/8);var l=0,d=1,c=e[t],h=0;if(c>1&&(e[t]=[0,0,1][c-2]),3==c)for(h=f;h<o;h++)e[h+1]=e[h+1]+(e[h+1-f]>>>1)&255;for(var u=0;u<n;u++)if(h=0,0==(c=e[(d=(l=t+u*o)+u+1)-1]))for(;h<o;h++)e[l+h]=e[d+h];else if(1==c){for(;h<f;h++)e[l+h]=e[d+h];for(;h<o;h++)e[l+h]=e[d+h]+e[l+h-f]}else if(2==c)for(;h<o;h++)e[l+h]=e[d+h]+e[l+h-o];else if(3==c){for(;h<f;h++)e[l+h]=e[d+h]+(e[l+h-o]>>>1);for(;h<o;h++)e[l+h]=e[d+h]+(e[l+h-o]+e[l+h-f]>>>1)}else{for(;h<f;h++)e[l+h]=e[d+h]+s(0,e[l+h-o],0);for(;h<o;h++)e[l+h]=e[d+h]+s(e[l+h-f],e[l+h-o],e[l+h-f-o])}return e},i.decode._paeth=function(e,r,t){var a=e+r-t,n=a-e,i=a-r,f=a-t;return n*n<=i*i&&n*n<=f*f?e:i*i<=f*f?r:t},i.decode._IHDR=function(e,r,t){var a=i._bin;t.width=a.readUint(e,r),r+=4,t.height=a.readUint(e,r),r+=4,t.depth=e[r],r++,t.ctype=e[r],r++,t.compress=e[r],r++,t.filter=e[r],r++,t.interlace=e[r],r++},i._bin={nextZero:function(e,r){for(;0!=e[r];)r++;return r},readUshort:function(e,r){return e[r]<<8|e[r+1]},writeUshort:function(e,r,t){e[r]=t>>8&255,e[r+1]=255&t},readUint:function(e,r){return 16777216*e[r]+(e[r+1]<<16|e[r+2]<<8|e[r+3])},writeUint:function(e,r,t){e[r]=t>>24&255,e[r+1]=t>>16&255,e[r+2]=t>>8&255,e[r+3]=255&t},readASCII:function(e,r,t){for(var a="",n=0;n<t;n++)a+=String.fromCharCode(e[r+n]);return a},writeASCII:function(e,r,t){for(var a=0;a<t.length;a++)e[r+a]=t.charCodeAt(a)},readBytes:function(e,r,t){for(var a=[],n=0;n<t;n++)a.push(e[r+n]);return a},pad:function(e){return e.length<2?"0"+e:e},readUTF8:function(e,r,t){for(var a,n="",f=0;f<t;f++)n+="%"+i._bin.pad(e[r+f].toString(16));try{a=decodeURIComponent(n)}catch(a){return i._bin.readASCII(e,r,t)}return a}},i._copyTile=function(e,r,t,a,n,i,f,o,s){for(var l=Math.min(r,n),d=Math.min(t,i),c=0,h=0,u=0;u<d;u++)for(var v=0;v<l;v++)if(f>=0&&o>=0?(c=u*r+v<<2,h=(o+u)*n+f+v<<2):(c=(-o+u)*r-f+v<<2,h=u*n+v<<2),0==s)a[h]=e[c],a[h+1]=e[c+1],a[h+2]=e[c+2],a[h+3]=e[c+3];else if(1==s){var p=e[c+3]*(1/255),g=e[c]*p,w=e[c+1]*p,y=e[c+2]*p,b=a[h+3]*(1/255),m=a[h]*b,_=a[h+1]*b,H=a[h+2]*b,U=1-p,A=p+b*U,R=0==A?0:1/A;a[h+3]=255*A,a[h+0]=(g+m*U)*R,a[h+1]=(w+_*U)*R,a[h+2]=(y+H*U)*R}else if(2==s){p=e[c+3],g=e[c],w=e[c+1],y=e[c+2],b=a[h+3],m=a[h],_=a[h+1],H=a[h+2];p==b&&g==m&&w==_&&y==H?(a[h]=0,a[h+1]=0,a[h+2]=0,a[h+3]=0):(a[h]=g,a[h+1]=w,a[h+2]=y,a[h+3]=p)}else if(3==s){p=e[c+3],g=e[c],w=e[c+1],y=e[c+2],b=a[h+3],m=a[h],_=a[h+1],H=a[h+2];if(p==b&&g==m&&w==_&&y==H)continue;if(p<220&&b>20)return!1}return!0},exports.RGBMLoader=r;
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");class r extends e.DataTextureLoader{constructor(r){super(r),this.type=e.HalfFloatType,this.maxRange=7}setDataType(e){return this.type=e,this}setMaxRange(e){return this.maxRange=e,this}loadCubemap(r,t,a,n){const i=new e.CubeTexture;let f=0;const o=this;function s(e){o.load(r[e],(function(r){i.images[e]=r,f++,6===f&&(i.needsUpdate=!0,t&&t(i))}),void 0,n)}for(let e=0;e<r.length;++e)s(e);return i.type=this.type,i.format=e.RGBAFormat,i.minFilter=e.LinearFilter,i.generateMipmaps=!1,i}parse(r){const t=i.decode(r),a=i.toRGBA8(t)[0],n=new Uint8Array(a),f=t.width*t.height*4,o=this.type===e.HalfFloatType?new Uint16Array(f):new Float32Array(f);for(let r=0;r<n.length;r+=4){const t=n[r+0]/255,a=n[r+1]/255,i=n[r+2]/255,f=n[r+3]/255;this.type===e.HalfFloatType?(o[r+0]=e.DataUtils.toHalfFloat(Math.min(t*f*this.maxRange,65504)),o[r+1]=e.DataUtils.toHalfFloat(Math.min(a*f*this.maxRange,65504)),o[r+2]=e.DataUtils.toHalfFloat(Math.min(i*f*this.maxRange,65504)),o[r+3]=e.DataUtils.toHalfFloat(1)):(o[r+0]=t*f*this.maxRange,o[r+1]=a*f*this.maxRange,o[r+2]=i*f*this.maxRange,o[r+3]=1)}return{width:t.width,height:t.height,data:o,format:e.RGBAFormat,type:this.type,flipY:!0}}}var t,a,n,i={};i.toRGBA8=function(e){var r=e.width,t=e.height;if(null==e.tabs.acTL)return[i.toRGBA8.decodeImage(e.data,r,t,e).buffer];var a=[];null==e.frames[0].data&&(e.frames[0].data=e.data);for(var n=r*t*4,f=new Uint8Array(n),o=new Uint8Array(n),s=new Uint8Array(n),l=0;l<e.frames.length;l++){var d=e.frames[l],c=d.rect.x,h=d.rect.y,u=d.rect.width,v=d.rect.height,p=i.toRGBA8.decodeImage(d.data,u,v,e);if(0!=l)for(var g=0;g<n;g++)s[g]=f[g];if(0==d.blend?i._copyTile(p,u,v,f,r,t,c,h,0):1==d.blend&&i._copyTile(p,u,v,f,r,t,c,h,1),a.push(f.buffer.slice(0)),0==d.dispose);else if(1==d.dispose)i._copyTile(o,u,v,f,r,t,c,h,0);else if(2==d.dispose)for(g=0;g<n;g++)f[g]=s[g]}return a},i.toRGBA8.decodeImage=function(e,r,t,a){var n=r*t,f=i.decode._getBPP(a),o=Math.ceil(r*f/8),s=new Uint8Array(4*n),l=new Uint32Array(s.buffer),d=a.ctype,c=a.depth,h=i._bin.readUshort;if(6==d){var u=n<<2;if(8==c)for(var v=0;v<u;v+=4)s[v]=e[v],s[v+1]=e[v+1],s[v+2]=e[v+2],s[v+3]=e[v+3];if(16==c)for(v=0;v<u;v++)s[v]=e[v<<1]}else if(2==d){var p=a.tabs.tRNS;if(null==p){if(8==c)for(v=0;v<n;v++){var g=3*v;l[v]=255<<24|e[g+2]<<16|e[g+1]<<8|e[g]}if(16==c)for(v=0;v<n;v++){g=6*v;l[v]=255<<24|e[g+4]<<16|e[g+2]<<8|e[g]}}else{var w=p[0],y=p[1],b=p[2];if(8==c)for(v=0;v<n;v++){var m=v<<2;g=3*v;l[v]=255<<24|e[g+2]<<16|e[g+1]<<8|e[g],e[g]==w&&e[g+1]==y&&e[g+2]==b&&(s[m+3]=0)}if(16==c)for(v=0;v<n;v++){m=v<<2,g=6*v;l[v]=255<<24|e[g+4]<<16|e[g+2]<<8|e[g],h(e,g)==w&&h(e,g+2)==y&&h(e,g+4)==b&&(s[m+3]=0)}}}else if(3==d){var _=a.tabs.PLTE,H=a.tabs.tRNS,U=H?H.length:0;if(1==c)for(var A=0;A<t;A++){var R=A*o,I=A*r;for(v=0;v<r;v++){m=I+v<<2;var T=3*(x=e[R+(v>>3)]>>7-((7&v)<<0)&1);s[m]=_[T],s[m+1]=_[T+1],s[m+2]=_[T+2],s[m+3]=x<U?H[x]:255}}if(2==c)for(A=0;A<t;A++)for(R=A*o,I=A*r,v=0;v<r;v++){m=I+v<<2,T=3*(x=e[R+(v>>2)]>>6-((3&v)<<1)&3);s[m]=_[T],s[m+1]=_[T+1],s[m+2]=_[T+2],s[m+3]=x<U?H[x]:255}if(4==c)for(A=0;A<t;A++)for(R=A*o,I=A*r,v=0;v<r;v++){m=I+v<<2,T=3*(x=e[R+(v>>1)]>>4-((1&v)<<2)&15);s[m]=_[T],s[m+1]=_[T+1],s[m+2]=_[T+2],s[m+3]=x<U?H[x]:255}if(8==c)for(v=0;v<n;v++){var x;m=v<<2,T=3*(x=e[v]);s[m]=_[T],s[m+1]=_[T+1],s[m+2]=_[T+2],s[m+3]=x<U?H[x]:255}}else if(4==d){if(8==c)for(v=0;v<n;v++){m=v<<2;var C=e[B=v<<1];s[m]=C,s[m+1]=C,s[m+2]=C,s[m+3]=e[B+1]}if(16==c)for(v=0;v<n;v++){var B;m=v<<2,C=e[B=v<<2];s[m]=C,s[m+1]=C,s[m+2]=C,s[m+3]=e[B+2]}}else if(0==d)for(w=a.tabs.tRNS?a.tabs.tRNS:-1,A=0;A<t;A++){var M=A*o,S=A*r;if(1==c)for(var D=0;D<r;D++){var F=(C=255*(e[M+(D>>>3)]>>>7-(7&D)&1))==255*w?0:255;l[S+D]=F<<24|C<<16|C<<8|C}else if(2==c)for(D=0;D<r;D++){F=(C=85*(e[M+(D>>>2)]>>>6-((3&D)<<1)&3))==85*w?0:255;l[S+D]=F<<24|C<<16|C<<8|C}else if(4==c)for(D=0;D<r;D++){F=(C=17*(e[M+(D>>>1)]>>>4-((1&D)<<2)&15))==17*w?0:255;l[S+D]=F<<24|C<<16|C<<8|C}else if(8==c)for(D=0;D<r;D++){F=(C=e[M+D])==w?0:255;l[S+D]=F<<24|C<<16|C<<8|C}else if(16==c)for(D=0;D<r;D++){C=e[M+(D<<1)],F=h(e,M+(D<<1))==w?0:255;l[S+D]=F<<24|C<<16|C<<8|C}}return s},i.decode=function(e){for(var r,t=new Uint8Array(e),a=8,n=i._bin,f=n.readUshort,o=n.readUint,s={tabs:{},frames:[]},l=new Uint8Array(t.length),d=0,c=0,h=[137,80,78,71,13,10,26,10],u=0;u<8;u++)if(t[u]!=h[u])throw"The input is not a PNG file!";for(;a<t.length;){var v=n.readUint(t,a);a+=4;var p=n.readASCII(t,a,4);if(a+=4,"IHDR"==p)i.decode._IHDR(t,a,s);else if("CgBI"==p)s.tabs[p]=t.slice(a,a+4);else if("IDAT"==p){for(u=0;u<v;u++)l[d+u]=t[a+u];d+=v}else if("acTL"==p)s.tabs[p]={num_frames:o(t,a),num_plays:o(t,a+4)},r=new Uint8Array(t.length);else if("fcTL"==p){var g;if(0!=c)(g=s.frames[s.frames.length-1]).data=i.decode._decompress(s,r.slice(0,c),g.rect.width,g.rect.height),c=0;var w={x:o(t,a+12),y:o(t,a+16),width:o(t,a+4),height:o(t,a+8)},y=f(t,a+22);y=f(t,a+20)/(0==y?100:y);var b={rect:w,delay:Math.round(1e3*y),dispose:t[a+24],blend:t[a+25]};s.frames.push(b)}else if("fdAT"==p){for(u=0;u<v-4;u++)r[c+u]=t[a+u+4];c+=v-4}else if("pHYs"==p)s.tabs[p]=[n.readUint(t,a),n.readUint(t,a+4),t[a+8]];else if("cHRM"==p){s.tabs[p]=[];for(u=0;u<8;u++)s.tabs[p].push(n.readUint(t,a+4*u))}else if("tEXt"==p||"zTXt"==p){null==s.tabs[p]&&(s.tabs[p]={});var m=n.nextZero(t,a),_=n.readASCII(t,a,m-a),H=a+v-m-1;if("tEXt"==p)I=n.readASCII(t,m+1,H);else{var U=i.decode._inflate(t.slice(m+2,m+2+H));I=n.readUTF8(U,0,U.length)}s.tabs[p][_]=I}else if("iTXt"==p){null==s.tabs[p]&&(s.tabs[p]={});m=0;var A=a;m=n.nextZero(t,A);_=n.readASCII(t,A,m-A);var R=t[A=m+1];A+=2,m=n.nextZero(t,A),n.readASCII(t,A,m-A),A=m+1,m=n.nextZero(t,A),n.readUTF8(t,A,m-A);var I;H=v-((A=m+1)-a);if(0==R)I=n.readUTF8(t,A,H);else{U=i.decode._inflate(t.slice(A,A+H));I=n.readUTF8(U,0,U.length)}s.tabs[p][_]=I}else if("PLTE"==p)s.tabs[p]=n.readBytes(t,a,v);else if("hIST"==p){var T=s.tabs.PLTE.length/3;s.tabs[p]=[];for(u=0;u<T;u++)s.tabs[p].push(f(t,a+2*u))}else if("tRNS"==p)3==s.ctype?s.tabs[p]=n.readBytes(t,a,v):0==s.ctype?s.tabs[p]=f(t,a):2==s.ctype&&(s.tabs[p]=[f(t,a),f(t,a+2),f(t,a+4)]);else if("gAMA"==p)s.tabs[p]=n.readUint(t,a)/1e5;else if("sRGB"==p)s.tabs[p]=t[a];else if("bKGD"==p)0==s.ctype||4==s.ctype?s.tabs[p]=[f(t,a)]:2==s.ctype||6==s.ctype?s.tabs[p]=[f(t,a),f(t,a+2),f(t,a+4)]:3==s.ctype&&(s.tabs[p]=t[a]);else if("IEND"==p)break;a+=v,n.readUint(t,a),a+=4}0!=c&&((g=s.frames[s.frames.length-1]).data=i.decode._decompress(s,r.slice(0,c),g.rect.width,g.rect.height));return s.data=i.decode._decompress(s,l,s.width,s.height),delete s.compress,delete s.interlace,delete s.filter,s},i.decode._decompress=function(e,r,t,a){var n=i.decode._getBPP(e),f=Math.ceil(t*n/8),o=new Uint8Array((f+1+e.interlace)*a);return r=e.tabs.CgBI?i.inflateRaw(r,o):i.decode._inflate(r,o),0==e.interlace?r=i.decode._filterZero(r,e,0,t,a):1==e.interlace&&(r=i.decode._readInterlace(r,e)),r},i.decode._inflate=function(e,r){return i.inflateRaw(new Uint8Array(e.buffer,2,e.length-6),r)},i.inflateRaw=((n={}).H={},n.H.N=function(e,r){var t,a,i=Uint8Array,f=0,o=0,s=0,l=0,d=0,c=0,h=0,u=0,v=0;if(3==e[0]&&0==e[1])return r||new i(0);var p=n.H,g=p.b,w=p.e,y=p.R,b=p.n,m=p.A,_=p.Z,H=p.m,U=null==r;for(U&&(r=new i(e.length>>>2<<5));0==f;)if(f=g(e,v,1),o=g(e,v+1,2),v+=3,0!=o){if(U&&(r=n.H.W(r,u+(1<<17))),1==o&&(t=H.J,a=H.h,c=511,h=31),2==o){s=w(e,v,5)+257,l=w(e,v+5,5)+1,d=w(e,v+10,4)+4,v+=14;for(var A=1,R=0;R<38;R+=2)H.Q[R]=0,H.Q[R+1]=0;for(R=0;R<d;R++){var I=w(e,v+3*R,3);H.Q[1+(H.X[R]<<1)]=I,I>A&&(A=I)}v+=3*d,b(H.Q,A),m(H.Q,A,H.u),t=H.w,a=H.d,v=y(H.u,(1<<A)-1,s+l,e,v,H.v);var T=p.V(H.v,0,s,H.C);c=(1<<T)-1;var x=p.V(H.v,s,l,H.D);h=(1<<x)-1,b(H.C,T),m(H.C,T,t),b(H.D,x),m(H.D,x,a)}for(;;){var C=t[_(e,v)&c];v+=15&C;var B=C>>>4;if(B>>>8==0)r[u++]=B;else{if(256==B)break;var M=u+B-254;if(B>264){var S=H.q[B-257];M=u+(S>>>3)+w(e,v,7&S),v+=7&S}var D=a[_(e,v)&h];v+=15&D;var F=D>>>4,P=H.c[F],G=(P>>>4)+g(e,v,15&P);for(v+=15&P;u<M;)r[u]=r[u++-G],r[u]=r[u++-G],r[u]=r[u++-G],r[u]=r[u++-G];u=M}}}else{0!=(7&v)&&(v+=8-(7&v));var Z=4+(v>>>3),L=e[Z-4]|e[Z-3]<<8;U&&(r=n.H.W(r,u+L)),r.set(new i(e.buffer,e.byteOffset+Z,L),u),v=Z+L<<3,u+=L}return r.length==u?r:r.slice(0,u)},n.H.W=function(e,r){var t=e.length;if(r<=t)return e;var a=new Uint8Array(t<<1);return a.set(e,0),a},n.H.R=function(e,r,t,a,i,f){for(var o=n.H.e,s=n.H.Z,l=0;l<t;){var d=e[s(a,i)&r];i+=15&d;var c=d>>>4;if(c<=15)f[l]=c,l++;else{var h=0,u=0;16==c?(u=3+o(a,i,2),i+=2,h=f[l-1]):17==c?(u=3+o(a,i,3),i+=3):18==c&&(u=11+o(a,i,7),i+=7);for(var v=l+u;l<v;)f[l]=h,l++}}return i},n.H.V=function(e,r,t,a){for(var n=0,i=0,f=a.length>>>1;i<t;){var o=e[i+r];a[i<<1]=0,a[1+(i<<1)]=o,o>n&&(n=o),i++}for(;i<f;)a[i<<1]=0,a[1+(i<<1)]=0,i++;return n},n.H.n=function(e,r){for(var t,a,i,f,o=n.H.m,s=e.length,l=o.j,d=0;d<=r;d++)l[d]=0;for(d=1;d<s;d+=2)l[e[d]]++;var c=o.K;for(t=0,l[0]=0,a=1;a<=r;a++)t=t+l[a-1]<<1,c[a]=t;for(i=0;i<s;i+=2)0!=(f=e[i+1])&&(e[i]=c[f],c[f]++)},n.H.A=function(e,r,t){for(var a=e.length,i=n.H.m.r,f=0;f<a;f+=2)if(0!=e[f+1])for(var o=f>>1,s=e[f+1],l=o<<4|s,d=r-s,c=e[f]<<d,h=c+(1<<d);c!=h;)t[i[c]>>>15-r]=l,c++},n.H.l=function(e,r){for(var t=n.H.m.r,a=15-r,i=0;i<e.length;i+=2){var f=e[i]<<r-e[i+1];e[i]=t[f]>>>a}},n.H.M=function(e,r,t){t<<=7&r;var a=r>>>3;e[a]|=t,e[a+1]|=t>>>8},n.H.I=function(e,r,t){t<<=7&r;var a=r>>>3;e[a]|=t,e[a+1]|=t>>>8,e[a+2]|=t>>>16},n.H.e=function(e,r,t){return(e[r>>>3]|e[1+(r>>>3)]<<8)>>>(7&r)&(1<<t)-1},n.H.b=function(e,r,t){return(e[r>>>3]|e[1+(r>>>3)]<<8|e[2+(r>>>3)]<<16)>>>(7&r)&(1<<t)-1},n.H.Z=function(e,r){return(e[r>>>3]|e[1+(r>>>3)]<<8|e[2+(r>>>3)]<<16)>>>(7&r)},n.H.i=function(e,r){return(e[r>>>3]|e[1+(r>>>3)]<<8|e[2+(r>>>3)]<<16|e[3+(r>>>3)]<<24)>>>(7&r)},n.H.m=(t=Uint16Array,a=Uint32Array,{K:new t(16),j:new t(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new t(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new a(32),J:new t(512),_:[],h:new t(32),$:[],w:new t(32768),C:[],v:[],d:new t(32768),D:[],u:new t(512),Q:[],r:new t(32768),s:new a(286),Y:new a(30),a:new a(19),t:new a(15e3),k:new t(65536),g:new t(32768)}),function(){for(var e=n.H.m,r=0;r<32768;r++){var t=r;t=(4278255360&(t=(4042322160&(t=(3435973836&(t=(2863311530&t)>>>1|(1431655765&t)<<1))>>>2|(858993459&t)<<2))>>>4|(252645135&t)<<4))>>>8|(16711935&t)<<8,e.r[r]=(t>>>16|t<<16)>>>17}function a(e,r,t){for(;0!=r--;)e.push(0,t)}for(r=0;r<32;r++)e.q[r]=e.S[r]<<3|e.T[r],e.c[r]=e.p[r]<<4|e.z[r];a(e._,144,8),a(e._,112,9),a(e._,24,7),a(e._,8,8),n.H.n(e._,9),n.H.A(e._,9,e.J),n.H.l(e._,9),a(e.$,32,5),n.H.n(e.$,5),n.H.A(e.$,5,e.h),n.H.l(e.$,5),a(e.Q,19,0),a(e.C,286,0),a(e.D,30,0),a(e.v,320,0)}(),n.H.N),i.decode._readInterlace=function(e,r){for(var t=r.width,a=r.height,n=i.decode._getBPP(r),f=n>>3,o=Math.ceil(t*n/8),s=new Uint8Array(a*o),l=0,d=[0,0,4,0,2,0,1],c=[0,4,0,2,0,1,0],h=[8,8,8,4,4,2,2],u=[8,8,4,4,2,2,1],v=0;v<7;){for(var p=h[v],g=u[v],w=0,y=0,b=d[v];b<a;)b+=p,y++;for(var m=c[v];m<t;)m+=g,w++;var _=Math.ceil(w*n/8);i.decode._filterZero(e,r,l,w,y);for(var H=0,U=d[v];U<a;){for(var A=c[v],R=l+H*_<<3;A<t;){var I;if(1==n)I=(I=e[R>>3])>>7-(7&R)&1,s[U*o+(A>>3)]|=I<<7-((7&A)<<0);if(2==n)I=(I=e[R>>3])>>6-(7&R)&3,s[U*o+(A>>2)]|=I<<6-((3&A)<<1);if(4==n)I=(I=e[R>>3])>>4-(7&R)&15,s[U*o+(A>>1)]|=I<<4-((1&A)<<2);if(n>=8)for(var T=U*o+A*f,x=0;x<f;x++)s[T+x]=e[(R>>3)+x];R+=n,A+=g}H++,U+=p}w*y!=0&&(l+=y*(1+_)),v+=1}return s},i.decode._getBPP=function(e){return[1,null,3,1,2,null,4][e.ctype]*e.depth},i.decode._filterZero=function(e,r,t,a,n){var f=i.decode._getBPP(r),o=Math.ceil(a*f/8),s=i.decode._paeth;f=Math.ceil(f/8);var l,d,c=e[t],h=0;if(c>1&&(e[t]=[0,0,1][c-2]),3==c)for(h=f;h<o;h++)e[h+1]=e[h+1]+(e[h+1-f]>>>1)&255;for(var u=0;u<n;u++)if(h=0,0==(c=e[(d=(l=t+u*o)+u+1)-1]))for(;h<o;h++)e[l+h]=e[d+h];else if(1==c){for(;h<f;h++)e[l+h]=e[d+h];for(;h<o;h++)e[l+h]=e[d+h]+e[l+h-f]}else if(2==c)for(;h<o;h++)e[l+h]=e[d+h]+e[l+h-o];else if(3==c){for(;h<f;h++)e[l+h]=e[d+h]+(e[l+h-o]>>>1);for(;h<o;h++)e[l+h]=e[d+h]+(e[l+h-o]+e[l+h-f]>>>1)}else{for(;h<f;h++)e[l+h]=e[d+h]+s(0,e[l+h-o],0);for(;h<o;h++)e[l+h]=e[d+h]+s(e[l+h-f],e[l+h-o],e[l+h-f-o])}return e},i.decode._paeth=function(e,r,t){var a=e+r-t,n=a-e,i=a-r,f=a-t;return n*n<=i*i&&n*n<=f*f?e:i*i<=f*f?r:t},i.decode._IHDR=function(e,r,t){var a=i._bin;t.width=a.readUint(e,r),r+=4,t.height=a.readUint(e,r),r+=4,t.depth=e[r],r++,t.ctype=e[r],r++,t.compress=e[r],r++,t.filter=e[r],r++,t.interlace=e[r],r++},i._bin={nextZero:function(e,r){for(;0!=e[r];)r++;return r},readUshort:function(e,r){return e[r]<<8|e[r+1]},writeUshort:function(e,r,t){e[r]=t>>8&255,e[r+1]=255&t},readUint:function(e,r){return 16777216*e[r]+(e[r+1]<<16|e[r+2]<<8|e[r+3])},writeUint:function(e,r,t){e[r]=t>>24&255,e[r+1]=t>>16&255,e[r+2]=t>>8&255,e[r+3]=255&t},readASCII:function(e,r,t){for(var a="",n=0;n<t;n++)a+=String.fromCharCode(e[r+n]);return a},writeASCII:function(e,r,t){for(var a=0;a<t.length;a++)e[r+a]=t.charCodeAt(a)},readBytes:function(e,r,t){for(var a=[],n=0;n<t;n++)a.push(e[r+n]);return a},pad:function(e){return e.length<2?"0"+e:e},readUTF8:function(e,r,t){for(var a,n="",f=0;f<t;f++)n+="%"+i._bin.pad(e[r+f].toString(16));try{a=decodeURIComponent(n)}catch(a){return i._bin.readASCII(e,r,t)}return a}},i._copyTile=function(e,r,t,a,n,i,f,o,s){for(var l=Math.min(r,n),d=Math.min(t,i),c=0,h=0,u=0;u<d;u++)for(var v=0;v<l;v++)if(f>=0&&o>=0?(c=u*r+v<<2,h=(o+u)*n+f+v<<2):(c=(-o+u)*r-f+v<<2,h=u*n+v<<2),0==s)a[h]=e[c],a[h+1]=e[c+1],a[h+2]=e[c+2],a[h+3]=e[c+3];else if(1==s){var p=e[c+3]*(1/255),g=e[c]*p,w=e[c+1]*p,y=e[c+2]*p,b=a[h+3]*(1/255),m=a[h]*b,_=a[h+1]*b,H=a[h+2]*b,U=1-p,A=p+b*U,R=0==A?0:1/A;a[h+3]=255*A,a[h+0]=(g+m*U)*R,a[h+1]=(w+_*U)*R,a[h+2]=(y+H*U)*R}else if(2==s){p=e[c+3],g=e[c],w=e[c+1],y=e[c+2],b=a[h+3],m=a[h],_=a[h+1],H=a[h+2];p==b&&g==m&&w==_&&y==H?(a[h]=0,a[h+1]=0,a[h+2]=0,a[h+3]=0):(a[h]=g,a[h+1]=w,a[h+2]=y,a[h+3]=p)}else if(3==s){p=e[c+3],g=e[c],w=e[c+1],y=e[c+2],b=a[h+3],m=a[h],_=a[h+1],H=a[h+2];if(p==b&&g==m&&w==_&&y==H)continue;if(p<220&&b>20)return!1}return!0},exports.RGBMLoader=r;
|