diff --git a/Apps/SampleData/Cesium3DTiles/Tilesets/KTX2Tileset/Balloon.b3dm b/Apps/SampleData/Cesium3DTiles/Tilesets/KTX2Tileset/Balloon.b3dm
new file mode 100644
index 00000000000..b197fbd512d
Binary files /dev/null and b/Apps/SampleData/Cesium3DTiles/Tilesets/KTX2Tileset/Balloon.b3dm differ
diff --git a/Apps/SampleData/Cesium3DTiles/Tilesets/KTX2Tileset/tileset.json b/Apps/SampleData/Cesium3DTiles/Tilesets/KTX2Tileset/tileset.json
new file mode 100644
index 00000000000..04227cdf310
--- /dev/null
+++ b/Apps/SampleData/Cesium3DTiles/Tilesets/KTX2Tileset/tileset.json
@@ -0,0 +1,39 @@
+{
+ "asset": {
+ "version": "1.0"
+ },
+ "geometricError": 70,
+ "root": {
+ "transform": [
+ -0.8608332815512961,
+ -0.026091425783012157,
+ -0.5082177671768633,
+ 0,
+ 0.324224005982592,
+ -0.7978680937788927,
+ -0.5082177671768631,
+ 0,
+ -0.39223061496806577,
+ -0.6022671686471426,
+ 0.6952908760019272,
+ 0,
+ -2506152.030937531,
+ -3848177.6543499078,
+ 4412811.205275625,
+ 1
+ ],
+ "refine": "REPLACE",
+ "boundingVolume": {
+ "sphere": [
+ 0,
+ 0,
+ 0,
+ 100
+ ]
+ },
+ "geometricError": 0,
+ "content": {
+ "uri": "Balloon.b3dm"
+ }
+ }
+}
\ No newline at end of file
diff --git a/Apps/SampleData/EnvironmentMap/kiara_6_afternoon_2k_ibl.ktx b/Apps/SampleData/EnvironmentMap/kiara_6_afternoon_2k_ibl.ktx
deleted file mode 100644
index 7a8880d0411..00000000000
Binary files a/Apps/SampleData/EnvironmentMap/kiara_6_afternoon_2k_ibl.ktx and /dev/null differ
diff --git a/Apps/SampleData/EnvironmentMap/kiara_6_afternoon_2k_ibl.ktx2 b/Apps/SampleData/EnvironmentMap/kiara_6_afternoon_2k_ibl.ktx2
new file mode 100644
index 00000000000..df2b3930e7b
Binary files /dev/null and b/Apps/SampleData/EnvironmentMap/kiara_6_afternoon_2k_ibl.ktx2 differ
diff --git a/Apps/SampleData/models/CesiumBalloonKTX2/CesiumBalloonKTX2.glb b/Apps/SampleData/models/CesiumBalloonKTX2/CesiumBalloonKTX2.glb
new file mode 100644
index 00000000000..b117d0114d6
Binary files /dev/null and b/Apps/SampleData/models/CesiumBalloonKTX2/CesiumBalloonKTX2.glb differ
diff --git a/Apps/Sandcastle/gallery/3D Models.html b/Apps/Sandcastle/gallery/3D Models.html
index 1db0cc2d8d1..7a243f7c683 100644
--- a/Apps/Sandcastle/gallery/3D Models.html
+++ b/Apps/Sandcastle/gallery/3D Models.html
@@ -124,6 +124,15 @@
);
},
},
+ {
+ text: "KTX2 Compressed Balloon",
+ onselect: function () {
+ createModel(
+ "../../SampleData/models/CesiumBalloonKTX2/CesiumBalloonKTX2.glb",
+ 1000.0
+ );
+ },
+ },
];
Sandcastle.addToolbarMenu(options);
diff --git a/Apps/Sandcastle/gallery/Image-Based Lighting.html b/Apps/Sandcastle/gallery/Image-Based Lighting.html
index 9b827c3387a..a9ff829a63c 100644
--- a/Apps/Sandcastle/gallery/Image-Based Lighting.html
+++ b/Apps/Sandcastle/gallery/Image-Based Lighting.html
@@ -66,13 +66,14 @@
}
var environmentMapURL =
- "https://cesium.com/assets/kiara_6_afternoon_2k_ibl.ktx";
+ "../../SampleData/EnvironmentMap/kiara_6_afternoon_2k_ibl.ktx2";
var modelURL = "../../SampleData/models/Pawns/Pawns.glb";
// This environment map was processed using Google's Filament project. To process your own:
// 1 - Download the Filament release (https://github.com/google/filament/releases).
// 2 - Run `cmgen --type=ktx --deploy=/path/to/output /path/to/image.hdr`. Other formats are also supported. Run `cmgen --help` for all options.
- // 3 - Take the generated coefficients and the KTX file and load them in CesiumJS as shown below.
+ // 3 - Take the generated coefficients and the KTX file and convert them using the ktx2ktx2 converter.
+ // 4 - Converter can be found here: https://github.com/KhronosGroup/KTX-Software/tree/master/tools/ktx2ktx2
var L00 = new Cesium.Cartesian3(
0.170455150831422,
diff --git a/Apps/Sandcastle/gallery/Materials.html b/Apps/Sandcastle/gallery/Materials.html
index ff2071f62b6..886993292be 100644
--- a/Apps/Sandcastle/gallery/Materials.html
+++ b/Apps/Sandcastle/gallery/Materials.html
@@ -221,14 +221,7 @@
function applyCompressedTextureMaterial(primitive, scene) {
Sandcastle.declare(applyCompressedTextureMaterial); // For highlighting in Sandcastle.
- var compressedImageUrl;
- if (scene.getCompressedTextureFormatSupported("s3tc")) {
- compressedImageUrl = "../images/LogoDXT1.ktx";
- } else if (scene.getCompressedTextureFormatSupported("etc1")) {
- compressedImageUrl = "../images/LogoETC1.ktx";
- } else if (scene.getCompressedTextureFormatSupported("pvrtc")) {
- compressedImageUrl = "../images/LogoPVR.ktx";
- }
+ var compressedImageUrl = "../images/Logo.ktx2";
primitive.appearance.material = new Cesium.Material({
fabric: {
diff --git a/Apps/Sandcastle/images/Logo.ktx2 b/Apps/Sandcastle/images/Logo.ktx2
new file mode 100644
index 00000000000..bf23f1f2abc
Binary files /dev/null and b/Apps/Sandcastle/images/Logo.ktx2 differ
diff --git a/Apps/Sandcastle/images/LogoDXT1.ktx b/Apps/Sandcastle/images/LogoDXT1.ktx
deleted file mode 100644
index 73598d1c8d3..00000000000
Binary files a/Apps/Sandcastle/images/LogoDXT1.ktx and /dev/null differ
diff --git a/Apps/Sandcastle/images/LogoETC1.ktx b/Apps/Sandcastle/images/LogoETC1.ktx
deleted file mode 100644
index 9d8b88d7f54..00000000000
Binary files a/Apps/Sandcastle/images/LogoETC1.ktx and /dev/null differ
diff --git a/Apps/Sandcastle/images/LogoPVR.ktx b/Apps/Sandcastle/images/LogoPVR.ktx
deleted file mode 100644
index fd3461c7bbb..00000000000
Binary files a/Apps/Sandcastle/images/LogoPVR.ktx and /dev/null differ
diff --git a/CHANGES.md b/CHANGES.md
index 38a8a9bd0d9..8026fb71633 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,15 +1,83 @@
# Change Log
-### 1.71.0 - 2020-07-01
+### 1.72 - 2020-08-03
+
+##### Breaking Changes :mega:
+
+- CesiumJS no longer ships with a default Mapbox access token and Mapbox imagery layers have been removed from the `BaseLayerPicker` defaults. If you are using `MapboxImageryProvider` or `MapboxStyleImageryProvider`, use `options.accessToken` when initializing the imagery provider.
+
+- CesiumJS no longer supports KTX and Crunch textures, use the [`ktx2ktx2`](https://github.com/KhronosGroup/KTX-Software) converter tool to update existing KTX files. [#9040](https://github.com/CesiumGS/cesium/issues/9040)
+
+##### Additions :tada:
+
+- CesiumJS now supports KTX2 textures compressed using Basis compression. UASTC textures not yet supported. [#9040](https://github.com/CesiumGS/cesium/issues/9040)
+
+##### Deprecated :hourglass_flowing_sand:
+
+- `MapboxApi.defaultAccessToken` was deprecated and will be removed in CesiumJS 1.73. Pass your access token directly to the MapboxImageryProvider or MapboxStyleImageryProvider constructors.
+- `BingMapxApi` was deprecated and will be removed in CesiumJS 1.73. Pass your access key directly to the BingMapsImageryProvider or BingMapsGeocoderService constructors.
+
+##### Fixes :wrench:
+
+- Fixed `Color.fromCssColorString` when color string contains spaces. [#9015](https://github.com/CesiumGS/cesium/issues/9015)
+- Fixed 3D Tileset replacement refinement when leaf is empty. [#8996](https://github.com/CesiumGS/cesium/pull/8996)
+- Fixed a bug in the assessment of terrain tile visibility [#9033](https://github.com/CesiumGS/cesium/issues/9033)
+- Fixed vertical polylines with `arcType: ArcType.RHUMB`, including lines drawn via GeoJSON. [#9028](https://github.com/CesiumGS/cesium/pull/9028)
+- Fixed wall rendering when underground [#9041](https://github.com/CesiumGS/cesium/pull/9041)
+- Fixed issue where a side of the wall was missing if the first position and the last position were equal [#9044](https://github.com/CesiumGS/cesium/pull/9044)
+- Fixed `translucencyByDistance` for label outline color [#9003](https://github.com/CesiumGS/cesium/pull/9003)
+- Fixed return value for `SampledPositionProperty.removeSample` [#9017](https://github.com/CesiumGS/cesium/pull/9017)
+- Fixed issue where wall doesn't have correct texture coordinates when there are duplicate positions input [#9042](https://github.com/CesiumGS/cesium/issues/9042)
+
+### 1.71 - 2020-07-01
+
+##### Breaking Changes :mega:
+
+- Updated `WallGeometry` to respect the order of positions passed in, instead of making the positions respect a counter clockwise winding order. This will only affect the look of walls with an image material. If this changed the way your wall is drawing, reverse the order of the positions. [#8955](https://github.com/CesiumGS/cesium/pull/8955/)
+
+##### Additions :tada:
+
+- Added `backFaceCulling` property to `Cesium3DTileset` and `Model` to support viewing the underside or interior of a tileset or model. [#8981](https://github.com/CesiumGS/cesium/pull/8981)
+- Added `Ellipsoid.surfaceArea` for computing the approximate surface area of a rectangle on the surface of an ellipsoid. [#8986](https://github.com/CesiumGS/cesium/pull/8986)
+- Added support for PolylineVolume in CZML. [#8841](https://github.com/CesiumGS/cesium/pull/8841)
+- Added `Color.toCssHexString` for getting the CSS hex string equivalent for a color. [#8987](https://github.com/CesiumGS/cesium/pull/8987)
+
+##### Fixes :wrench:
+
+- Fixed issue where tileset was not playing glTF animations. [#8962](https://github.com/CesiumGS/cesium/issues/8962)
+- Fixed a divide-by-zero bug in `Ellipsoid.geodeticSurfaceNormal` when given the origin as input. `undefined` is returned instead. [#8986](https://github.com/CesiumGS/cesium/pull/8986)
+- Fixed error with `WallGeometry` when there were adjacent positions with very close values. [#8952](https://github.com/CesiumGS/cesium/pull/8952)
+- Fixed artifact for skinned model when log depth is enabled. [#6447](https://github.com/CesiumGS/cesium/issues/6447)
+- Fixed a bug where certain rhumb arc polylines would lead to a crash. [#8787](https://github.com/CesiumGS/cesium/pull/8787)
+- Fixed handling of Label's backgroundColor and backgroundPadding option [#8949](https://github.com/CesiumGS/cesium/pull/8949)
+- Fixed several bugs when rendering CesiumJS in a WebGL 2 context. [#797](https://github.com/CesiumGS/cesium/issues/797)
+- Fixed a bug where switching from perspective to orthographic caused triangles to overlap each other incorrectly. [#8346](https://github.com/CesiumGS/cesium/issues/8346)
+- Fixed a bug where switching to orthographic camera on the first frame caused the zoom level to be incorrect. [#8853](https://github.com/CesiumGS/cesium/pull/8853)
+- Fixed `scene.pickFromRay` intersection inaccuracies. [#8439](https://github.com/CesiumGS/cesium/issues/8439)
+- Fixed a bug where a null or undefined name property passed to the `Entity` constructor would throw an exception.[#8832](https://github.com/CesiumGS/cesium/pull/8832)
+- Fixed JSDoc and TypeScript type definitions for `ScreenSpaceEventHandler.getInputAction` which listed incorrect return type. [#9002](https://github.com/CesiumGS/cesium/pull/9002)
+- Improved the style of the error panel. [#8739](https://github.com/CesiumGS/cesium/issues/8739)
+- Fixed animation widget SVG icons not appearing in iOS 13.5.1. [#8993](https://github.com/CesiumGS/cesium/pull/8993)
+
+### 1.70.1 - 2020-06-10
##### Additions :tada:
- Add a `toString` method to the `Resource` class in case an instance gets logged as a string. [#8722](https://github.com/CesiumGS/cesium/issues/8722)
+- Exposed `Transforms.rotationMatrixFromPositionVelocity` method from Cesium's private API. [#8927](https://github.com/CesiumGS/cesium/issues/8927)
##### Fixes :wrench:
-- Fixed a bug with handling of PixelFormat's flipY. [#8893](https://github.com/CesiumGS/cesium/pull/8893)
+- Fixed JSDoc and TypeScript type definitions for all `ImageryProvider` types, which were missing `defaultNightAlpha` and `defaultDayAlpha` properties. [#8908](https://github.com/CesiumGS/cesium/pull/8908)
+- Fixed JSDoc and TypeScript for `MaterialProperty`, which were missing the ability to take primitive types in their constructor. [#8904](https://github.com/CesiumGS/cesium/pull/8904)
+- Fixed JSDoc and TypeScript type definitions to allow the creation of `GeometryInstance` instances using `XXXGeometry` classes. [#8941](https://github.com/CesiumGS/cesium/pull/8941).
+- Fixed JSDoc and TypeScript for `buildModuleUrl`, which was accidentally excluded from the official CesiumJS API. [#8923](https://github.com/CesiumGS/cesium/pull/8923)
+- Fixed JSDoc and TypeScript type definitions for `EllipsoidGeodesic` which incorrectly listed `result` as required. [#8904](https://github.com/CesiumGS/cesium/pull/8904)
+- Fixed JSDoc and TypeScript type definitions for `EllipsoidTangentPlane.fromPoints`, which takes an array of `Cartesian3`, not a single instance. [#8928](https://github.com/CesiumGS/cesium/pull/8928)
+- Fixed JSDoc and TypeScript type definitions for `EntityCollection.getById` and `CompositeEntityCollection.getById`, which can both return undefined. [#8928](https://github.com/CesiumGS/cesium/pull/8928)
+- Fixed JSDoc and TypeScript type definitions for `Viewer` options parameters.
- Fixed a memory leak where some 3D Tiles requests were being unintentionally retained after the requests were cancelled. [#8843](https://github.com/CesiumGS/cesium/pull/8843)
+- Fixed a bug with handling of PixelFormat's flipY. [#8893](https://github.com/CesiumGS/cesium/pull/8893)
### 1.70.0 - 2020-06-01
diff --git a/Documentation/Contributors/KTX2ModuleManagement/README.md b/Documentation/Contributors/KTX2ModuleManagement/README.md
new file mode 100644
index 00000000000..1e74f1f0ca7
--- /dev/null
+++ b/Documentation/Contributors/KTX2ModuleManagement/README.md
@@ -0,0 +1,54 @@
+## Updating the KTX2 Transcoder Module
+
+We use a custom build of the `msc_basis_transcoder` tool in Khronos's [KTX-Software](https://github.com/KhronosGroup/KTX-Software/) project to allow for IE11 compatability.
+
+Updating the transcoder requires building both the web assembly version and Javascript fallback.
+
+These directions were written against https://github.com/KhronosGroup/KTX-Software/commit/78790b5ea9c9f432a8e877fbc8cfd977617bb775.
+
+### Web Assembly Build
+
+Follow the instructions at https://github.com/KhronosGroup/KTX-Software/blob/master/BUILDING.md#webemscripten.
+
+You will need a make tool as well as emscripten.
+
+- Preferably, use Linux or [the Linux Subsystem for Windows 10](https://docs.microsoft.com/en-us/windows/wsl/install-win10) and `make` to build.
+- Optionally, [MSYS2](http://www.msys2.org/). Follow installation instructions and add the path to MSYS2's usr/bin to your `PATH`. For example, if the path is `C:\msys64\usr\bin`, run `PATH=%PATH%;C:\msys64\usr\bin`.
+
+### Javascript fallback build
+
+As of this writing, `KTX-Software` does not provide an official configuration parameter for configuring the build to Javascript/asm.js instead of web assembly. An issue is open here: https://github.com/KhronosGroup/KTX-Software/issues/332
+
+You will need to edit the project's `CMakeLists.txt` to include the required configuration flags.
+
+1. Make a separate build directory for the Javascript fallback.
+2. in `KTX-Software/CMakeLists.txt`, locate the variable `KTX_EMC_LINK_FLAGS`
+3. add emscripten flags `WASM=0`, `LEGACY_VM_SUPPORT=1`, and `--memory-init-file 0`, ie.
+
+```
+set(
+ KTX_EMC_LINK_FLAGS
+ --bind
+ "SHELL:--source-map-base ./"
+ "SHELL:-s ALLOW_MEMORY_GROWTH=1"
+ "SHELL:-s ASSERTIONS=0"
+ "SHELL:-s MALLOC=emmalloc"
+ "SHELL:-s MODULARIZE=1"
+ "SHELL:-s FULL_ES3=1"
+ "SHELL:-s WASM=0" # for asm.js
+ "SHELL:-s LEGACY_VM_SUPPORT=1" # for asm.js
+ "SHELL: --memory-init-file 0" # for asm.js
+)
+```
+
+4. Configure and build in the new directory. Be aware that the directions in the `KTX-Software` assume directory names, make sure to use the new directory, ie.
+
+```bash
+cd path/to/new/build/dir && cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="path/to/emsdk/Emscripten.cmake" && cmake --build
+```
+
+### Adding to Cesium
+
+Note that both builds will produce a file called `msc_basis_transcoder.js`. Rename the web assembly version (the smaller file with a corresponding `msc_basis_transcoder.wasm`) before placing both in `Source/ThirdParty/Workers`.
+
+Place `msc_basis_transcoder.wasm` in `Source/ThirdParty`.
diff --git a/LICENSE.md b/LICENSE.md
index 0c99e6fa6fa..faaff8b8485 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -556,58 +556,58 @@ https://github.com/mourner/quickselect
> TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
> THIS SOFTWARE.
-### crunch
+## KTX-software
-https://github.com/BinomialLLC/crunch
+https://github.com/KhronosGroup/KTX-Software
-> crunch/crnlib uses the ZLIB license:
-> http://opensource.org/licenses/Zlib
+> (Apache License)
>
-> Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC
+> With the exception of the files listed explicitly below, the source is made
+> available under the Apache License, Version 2.0 (the "License"); you may not
+> use these files except in compliance with the License. You may obtain a copy of
+> the License at
>
-> This software is provided 'as-is', without any express or implied
-> warranty. In no event will the authors be held liable for any damages
-> arising from the use of this software.
+> http://www.apache.org/licenses/LICENSE-2.0
>
-> Permission is granted to anyone to use this software for any purpose,
-> including commercial applications, and to alter it and redistribute it
-> freely, subject to the following restrictions:
+> Unless required by applicable law or agreed to in writing, software
+> distributed under the License is distributed on an "AS IS" BASIS,
+> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+> See the License for the specific language governing permissions and
+> limitations under the License.
>
-> 1. The origin of this software must not be misrepresented; you must not
-> claim that you wrote the original software. If you use this software
-> in a product, an acknowledgment in the product documentation would be
-> appreciated but is not required.
+> libKTX is the work of Mark Callow based on work by Georg Kolling and Jacob
+> Ström with contributions borrowed from Troy Hanson, Johannes van Waveren,
+> Lode Vandevenne and Rich Geldreich. The source contains code
>
-> 2. Altered source versions must be plainly marked as such, and must not be
-> misrepresented as being the original software.
+> © 2010 ~ 2019 The Khronos Group Inc.
+> © 2008 and © 2010 HI Corporation
+> © 2005 Ericsson AB
+> © 2003-2010, Troy D. Hanson
+> © 2015-2020 Mark Callow
+> © 2016 Oculus VR, LLC.
+> © 2019 Binomial LLC. All Rights Reserved.
+> © 2005-2019 Lode Vandevenne
+> © 2019 Andreas Atteneder
>
-> 3. This notice may not be removed or altered from any source distribution.
-
-### crunch_lib.cpp
-
-https://github.com/Apress/html5-game-dev-insights/blob/master/jones_ch21/crunch_webgl/crunch_js/crunch_lib.cpp
-
-> Copyright (c) 2013, Evan Parker, Brandon Jones. All rights reserved.
+> The KTX load tests are the work of Mark Callow with a few small portions
+> borrowed from Sascha Willems' Vulkan examples and use Sam Lantinga's libSDL for
+> portability. The source contains code
>
-> Redistribution and use in source and binary forms, with or without modification,
-> are permitted provided that the following conditions are met:
+> © 2013 The Khronos Group Inc.
+> © 2008 and © 2010 HI Corporation
+> © 1997-2018 Sam Lantinga
+> © 2016 Sascha Willems
+> © 2015-2020 Mark Callow
>
-> - Redistributions of source code must retain the above copyright notice, this
-> list of conditions and the following disclaimer.
-> - Redistributions in binary form must reproduce the above copyright notice,
-> this list of conditions and the following disclaimer in the documentation
-> and/or other materials provided with the distribution.
+> `texturetests` and `unittests` are the work of Mark Callow and are based on gtest. The source contains code
>
-> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-> ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-> WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-> DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
-> ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-> (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-> LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
-> ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-> (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-> SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \*/
+> © 2010-2020 Mark Callow
+> © 2006 Google Inc.
+>
+> `transcodetests` are the work of and were contributed by Andreas Atteneder.
+> The source contains code
+>
+> © 2019 Andreas Atteneder
### texture-tester
diff --git a/Source/Core/FeatureDetection.js b/Source/Core/FeatureDetection.js
index 7cc66fa3f56..2145ea8d73f 100644
--- a/Source/Core/FeatureDetection.js
+++ b/Source/Core/FeatureDetection.js
@@ -181,6 +181,10 @@ function supportsPointerEvents() {
return hasPointerEvents;
}
+function supportsBasis(context) {
+ return context.etc1 || context.s3tc || context.pvrtc;
+}
+
var imageRenderingValueResult;
var supportsImageRenderingPixelatedResult;
function supportsImageRenderingPixelated() {
@@ -304,6 +308,7 @@ var FeatureDetection = {
supportsPointerEvents: supportsPointerEvents,
supportsImageRenderingPixelated: supportsImageRenderingPixelated,
supportsWebP: supportsWebP,
+ supportsBasis: supportsBasis,
imageRenderingValue: imageRenderingValue,
typedArrayTypes: typedArrayTypes,
};
diff --git a/Source/Core/VulkanConstants.js b/Source/Core/VulkanConstants.js
new file mode 100644
index 00000000000..91b2c907209
--- /dev/null
+++ b/Source/Core/VulkanConstants.js
@@ -0,0 +1,287 @@
+/**
+ * Enum containing Vulkan Constant values by name.
+ *
+ * These match the constants from the [Vulkan 1.2]{@link https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#formats-definition}
+ * specifications.
+ *
+ * @enum {Number}
+ * @private
+ */
+var VulkanConstants = {
+ VK_FORMAT_UNDEFINED: 0,
+ VK_FORMAT_R4G4_UNORM_PACK8: 1,
+ VK_FORMAT_R4G4B4A4_UNORM_PACK16: 2,
+ VK_FORMAT_B4G4R4A4_UNORM_PACK16: 3,
+ VK_FORMAT_R5G6B5_UNORM_PACK16: 4,
+ VK_FORMAT_B5G6R5_UNORM_PACK16: 5,
+ VK_FORMAT_R5G5B5A1_UNORM_PACK16: 6,
+ VK_FORMAT_B5G5R5A1_UNORM_PACK16: 7,
+ VK_FORMAT_A1R5G5B5_UNORM_PACK16: 8,
+ VK_FORMAT_R8_UNORM: 9,
+ VK_FORMAT_R8_SNORM: 10,
+ VK_FORMAT_R8_USCALED: 11,
+ VK_FORMAT_R8_SSCALED: 12,
+ VK_FORMAT_R8_UINT: 13,
+ VK_FORMAT_R8_SINT: 14,
+ VK_FORMAT_R8_SRGB: 15,
+ VK_FORMAT_R8G8_UNORM: 16,
+ VK_FORMAT_R8G8_SNORM: 17,
+ VK_FORMAT_R8G8_USCALED: 18,
+ VK_FORMAT_R8G8_SSCALED: 19,
+ VK_FORMAT_R8G8_UINT: 20,
+ VK_FORMAT_R8G8_SINT: 21,
+ VK_FORMAT_R8G8_SRGB: 22,
+ VK_FORMAT_R8G8B8_UNORM: 23,
+ VK_FORMAT_R8G8B8_SNORM: 24,
+ VK_FORMAT_R8G8B8_USCALED: 25,
+ VK_FORMAT_R8G8B8_SSCALED: 26,
+ VK_FORMAT_R8G8B8_UINT: 27,
+ VK_FORMAT_R8G8B8_SINT: 28,
+ VK_FORMAT_R8G8B8_SRGB: 29,
+ VK_FORMAT_B8G8R8_UNORM: 30,
+ VK_FORMAT_B8G8R8_SNORM: 31,
+ VK_FORMAT_B8G8R8_USCALED: 32,
+ VK_FORMAT_B8G8R8_SSCALED: 33,
+ VK_FORMAT_B8G8R8_UINT: 34,
+ VK_FORMAT_B8G8R8_SINT: 35,
+ VK_FORMAT_B8G8R8_SRGB: 36,
+ VK_FORMAT_R8G8B8A8_UNORM: 37,
+ VK_FORMAT_R8G8B8A8_SNORM: 38,
+ VK_FORMAT_R8G8B8A8_USCALED: 39,
+ VK_FORMAT_R8G8B8A8_SSCALED: 40,
+ VK_FORMAT_R8G8B8A8_UINT: 41,
+ VK_FORMAT_R8G8B8A8_SINT: 42,
+ VK_FORMAT_R8G8B8A8_SRGB: 43,
+ VK_FORMAT_B8G8R8A8_UNORM: 44,
+ VK_FORMAT_B8G8R8A8_SNORM: 45,
+ VK_FORMAT_B8G8R8A8_USCALED: 46,
+ VK_FORMAT_B8G8R8A8_SSCALED: 47,
+ VK_FORMAT_B8G8R8A8_UINT: 48,
+ VK_FORMAT_B8G8R8A8_SINT: 49,
+ VK_FORMAT_B8G8R8A8_SRGB: 50,
+ VK_FORMAT_A8B8G8R8_UNORM_PACK32: 51,
+ VK_FORMAT_A8B8G8R8_SNORM_PACK32: 52,
+ VK_FORMAT_A8B8G8R8_USCALED_PACK32: 53,
+ VK_FORMAT_A8B8G8R8_SSCALED_PACK32: 54,
+ VK_FORMAT_A8B8G8R8_UINT_PACK32: 55,
+ VK_FORMAT_A8B8G8R8_SINT_PACK32: 56,
+ VK_FORMAT_A8B8G8R8_SRGB_PACK32: 57,
+ VK_FORMAT_A2R10G10B10_UNORM_PACK32: 58,
+ VK_FORMAT_A2R10G10B10_SNORM_PACK32: 59,
+ VK_FORMAT_A2R10G10B10_USCALED_PACK32: 60,
+ VK_FORMAT_A2R10G10B10_SSCALED_PACK32: 61,
+ VK_FORMAT_A2R10G10B10_UINT_PACK32: 62,
+ VK_FORMAT_A2R10G10B10_SINT_PACK32: 63,
+ VK_FORMAT_A2B10G10R10_UNORM_PACK32: 64,
+ VK_FORMAT_A2B10G10R10_SNORM_PACK32: 65,
+ VK_FORMAT_A2B10G10R10_USCALED_PACK32: 66,
+ VK_FORMAT_A2B10G10R10_SSCALED_PACK32: 67,
+ VK_FORMAT_A2B10G10R10_UINT_PACK32: 68,
+ VK_FORMAT_A2B10G10R10_SINT_PACK32: 69,
+ VK_FORMAT_R16_UNORM: 70,
+ VK_FORMAT_R16_SNORM: 71,
+ VK_FORMAT_R16_USCALED: 72,
+ VK_FORMAT_R16_SSCALED: 73,
+ VK_FORMAT_R16_UINT: 74,
+ VK_FORMAT_R16_SINT: 75,
+ VK_FORMAT_R16_SFLOAT: 76,
+ VK_FORMAT_R16G16_UNORM: 77,
+ VK_FORMAT_R16G16_SNORM: 78,
+ VK_FORMAT_R16G16_USCALED: 79,
+ VK_FORMAT_R16G16_SSCALED: 80,
+ VK_FORMAT_R16G16_UINT: 81,
+ VK_FORMAT_R16G16_SINT: 82,
+ VK_FORMAT_R16G16_SFLOAT: 83,
+ VK_FORMAT_R16G16B16_UNORM: 84,
+ VK_FORMAT_R16G16B16_SNORM: 85,
+ VK_FORMAT_R16G16B16_USCALED: 86,
+ VK_FORMAT_R16G16B16_SSCALED: 87,
+ VK_FORMAT_R16G16B16_UINT: 88,
+ VK_FORMAT_R16G16B16_SINT: 89,
+ VK_FORMAT_R16G16B16_SFLOAT: 90,
+ VK_FORMAT_R16G16B16A16_UNORM: 91,
+ VK_FORMAT_R16G16B16A16_SNORM: 92,
+ VK_FORMAT_R16G16B16A16_USCALED: 93,
+ VK_FORMAT_R16G16B16A16_SSCALED: 94,
+ VK_FORMAT_R16G16B16A16_UINT: 95,
+ VK_FORMAT_R16G16B16A16_SINT: 96,
+ VK_FORMAT_R16G16B16A16_SFLOAT: 97,
+ VK_FORMAT_R32_UINT: 98,
+ VK_FORMAT_R32_SINT: 99,
+ VK_FORMAT_R32_SFLOAT: 100,
+ VK_FORMAT_R32G32_UINT: 101,
+ VK_FORMAT_R32G32_SINT: 102,
+ VK_FORMAT_R32G32_SFLOAT: 103,
+ VK_FORMAT_R32G32B32_UINT: 104,
+ VK_FORMAT_R32G32B32_SINT: 105,
+ VK_FORMAT_R32G32B32_SFLOAT: 106,
+ VK_FORMAT_R32G32B32A32_UINT: 107,
+ VK_FORMAT_R32G32B32A32_SINT: 108,
+ VK_FORMAT_R32G32B32A32_SFLOAT: 109,
+ VK_FORMAT_R64_UINT: 110,
+ VK_FORMAT_R64_SINT: 111,
+ VK_FORMAT_R64_SFLOAT: 112,
+ VK_FORMAT_R64G64_UINT: 113,
+ VK_FORMAT_R64G64_SINT: 114,
+ VK_FORMAT_R64G64_SFLOAT: 115,
+ VK_FORMAT_R64G64B64_UINT: 116,
+ VK_FORMAT_R64G64B64_SINT: 117,
+ VK_FORMAT_R64G64B64_SFLOAT: 118,
+ VK_FORMAT_R64G64B64A64_UINT: 119,
+ VK_FORMAT_R64G64B64A64_SINT: 120,
+ VK_FORMAT_R64G64B64A64_SFLOAT: 121,
+ VK_FORMAT_B10G11R11_UFLOAT_PACK32: 122,
+ VK_FORMAT_E5B9G9R9_UFLOAT_PACK32: 123,
+ VK_FORMAT_D16_UNORM: 124,
+ VK_FORMAT_X8_D24_UNORM_PACK32: 125,
+ VK_FORMAT_D32_SFLOAT: 126,
+ VK_FORMAT_S8_UINT: 127,
+ VK_FORMAT_D16_UNORM_S8_UINT: 128,
+ VK_FORMAT_D24_UNORM_S8_UINT: 129,
+ VK_FORMAT_D32_SFLOAT_S8_UINT: 130,
+ VK_FORMAT_BC1_RGB_UNORM_BLOCK: 131,
+ VK_FORMAT_BC1_RGB_SRGB_BLOCK: 132,
+ VK_FORMAT_BC1_RGBA_UNORM_BLOCK: 133,
+ VK_FORMAT_BC1_RGBA_SRGB_BLOCK: 134,
+ VK_FORMAT_BC2_UNORM_BLOCK: 135,
+ VK_FORMAT_BC2_SRGB_BLOCK: 136,
+ VK_FORMAT_BC3_UNORM_BLOCK: 137,
+ VK_FORMAT_BC3_SRGB_BLOCK: 138,
+ VK_FORMAT_BC4_UNORM_BLOCK: 139,
+ VK_FORMAT_BC4_SNORM_BLOCK: 140,
+ VK_FORMAT_BC5_UNORM_BLOCK: 141,
+ VK_FORMAT_BC5_SNORM_BLOCK: 142,
+ VK_FORMAT_BC6H_UFLOAT_BLOCK: 143,
+ VK_FORMAT_BC6H_SFLOAT_BLOCK: 144,
+ VK_FORMAT_BC7_UNORM_BLOCK: 145,
+ VK_FORMAT_BC7_SRGB_BLOCK: 146,
+ VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: 147,
+ VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: 148,
+ VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: 149,
+ VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: 150,
+ VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK: 151,
+ VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK: 152,
+ VK_FORMAT_EAC_R11_UNORM_BLOCK: 153,
+ VK_FORMAT_EAC_R11_SNORM_BLOCK: 154,
+ VK_FORMAT_EAC_R11G11_UNORM_BLOCK: 155,
+ VK_FORMAT_EAC_R11G11_SNORM_BLOCK: 156,
+ VK_FORMAT_ASTC_4x4_UNORM_BLOCK: 157,
+ VK_FORMAT_ASTC_4x4_SRGB_BLOCK: 158,
+ VK_FORMAT_ASTC_5x4_UNORM_BLOCK: 159,
+ VK_FORMAT_ASTC_5x4_SRGB_BLOCK: 160,
+ VK_FORMAT_ASTC_5x5_UNORM_BLOCK: 161,
+ VK_FORMAT_ASTC_5x5_SRGB_BLOCK: 162,
+ VK_FORMAT_ASTC_6x5_UNORM_BLOCK: 163,
+ VK_FORMAT_ASTC_6x5_SRGB_BLOCK: 164,
+ VK_FORMAT_ASTC_6x6_UNORM_BLOCK: 165,
+ VK_FORMAT_ASTC_6x6_SRGB_BLOCK: 166,
+ VK_FORMAT_ASTC_8x5_UNORM_BLOCK: 167,
+ VK_FORMAT_ASTC_8x5_SRGB_BLOCK: 168,
+ VK_FORMAT_ASTC_8x6_UNORM_BLOCK: 169,
+ VK_FORMAT_ASTC_8x6_SRGB_BLOCK: 170,
+ VK_FORMAT_ASTC_8x8_UNORM_BLOCK: 171,
+ VK_FORMAT_ASTC_8x8_SRGB_BLOCK: 172,
+ VK_FORMAT_ASTC_10x5_UNORM_BLOCK: 173,
+ VK_FORMAT_ASTC_10x5_SRGB_BLOCK: 174,
+ VK_FORMAT_ASTC_10x6_UNORM_BLOCK: 175,
+ VK_FORMAT_ASTC_10x6_SRGB_BLOCK: 176,
+ VK_FORMAT_ASTC_10x8_UNORM_BLOCK: 177,
+ VK_FORMAT_ASTC_10x8_SRGB_BLOCK: 178,
+ VK_FORMAT_ASTC_10x10_UNORM_BLOCK: 179,
+ VK_FORMAT_ASTC_10x10_SRGB_BLOCK: 180,
+ VK_FORMAT_ASTC_12x10_UNORM_BLOCK: 181,
+ VK_FORMAT_ASTC_12x10_SRGB_BLOCK: 182,
+ VK_FORMAT_ASTC_12x12_UNORM_BLOCK: 183,
+ VK_FORMAT_ASTC_12x12_SRGB_BLOCK: 184,
+ VK_FORMAT_G8B8G8R8_422_UNORM: 1000156000,
+ VK_FORMAT_B8G8R8G8_422_UNORM: 1000156001,
+ VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM: 1000156002,
+ VK_FORMAT_G8_B8R8_2PLANE_420_UNORM: 1000156003,
+ VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM: 1000156004,
+ VK_FORMAT_G8_B8R8_2PLANE_422_UNORM: 1000156005,
+ VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM: 1000156006,
+ VK_FORMAT_R10X6_UNORM_PACK16: 1000156007,
+ VK_FORMAT_R10X6G10X6_UNORM_2PACK16: 1000156008,
+ VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16: 1000156009,
+ VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16: 1000156010,
+ VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16: 1000156011,
+ VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16: 1000156012,
+ VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16: 1000156013,
+ VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16: 1000156014,
+ VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16: 1000156015,
+ VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16: 1000156016,
+ VK_FORMAT_R12X4_UNORM_PACK16: 1000156017,
+ VK_FORMAT_R12X4G12X4_UNORM_2PACK16: 1000156018,
+ VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16: 1000156019,
+ VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16: 1000156020,
+ VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16: 1000156021,
+ VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16: 1000156022,
+ VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16: 1000156023,
+ VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16: 1000156024,
+ VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16: 1000156025,
+ VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16: 1000156026,
+ VK_FORMAT_G16B16G16R16_422_UNORM: 1000156027,
+ VK_FORMAT_B16G16R16G16_422_UNORM: 1000156028,
+ VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM: 1000156029,
+ VK_FORMAT_G16_B16R16_2PLANE_420_UNORM: 1000156030,
+ VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM: 1000156031,
+ VK_FORMAT_G16_B16R16_2PLANE_422_UNORM: 1000156032,
+ VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM: 1000156033,
+ VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG: 1000054000,
+ VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG: 1000054001,
+ VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG: 1000054002,
+ VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG: 1000054003,
+ VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG: 1000054004,
+ VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG: 1000054005,
+ VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG: 1000054006,
+ VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG: 1000054007,
+ VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT: 1000066000,
+ VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT: 1000066001,
+ VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT: 1000066002,
+ VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT: 1000066003,
+ VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT: 1000066004,
+ VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT: 1000066005,
+ VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT: 1000066006,
+ VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT: 1000066007,
+ VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK_EXT: 1000066008,
+ VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK_EXT: 1000066009,
+ VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK_EXT: 1000066010,
+ VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK_EXT: 1000066011,
+ VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK_EXT: 1000066012,
+ VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT: 1000066013,
+ VK_FORMAT_G8B8G8R8_422_UNORM_KHR: 1000156000,
+ VK_FORMAT_B8G8R8G8_422_UNORM_KHR: 1000156001,
+ VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM_KHR: 1000156002,
+ VK_FORMAT_G8_B8R8_2PLANE_420_UNORM_KHR: 1000156003,
+ VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM_KHR: 1000156004,
+ VK_FORMAT_G8_B8R8_2PLANE_422_UNORM_KHR: 1000156005,
+ VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM_KHR: 1000156006,
+ VK_FORMAT_R10X6_UNORM_PACK16_KHR: 1000156007,
+ VK_FORMAT_R10X6G10X6_UNORM_2PACK16_KHR: 1000156008,
+ VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16_KHR: 1000156009,
+ VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16_KHR: 1000156010,
+ VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16_KHR: 1000156011,
+ VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_KHR: 1000156012,
+ VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_KHR: 1000156013,
+ VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16_KHR: 1000156014,
+ VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16_KHR: 1000156015,
+ VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16_KHR: 1000156016,
+ VK_FORMAT_R12X4_UNORM_PACK16_KHR: 1000156017,
+ VK_FORMAT_R12X4G12X4_UNORM_2PACK16_KHR: 1000156018,
+ VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16_KHR: 1000156019,
+ VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16_KHR: 1000156020,
+ VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16_KHR: 1000156021,
+ VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_KHR: 1000156022,
+ VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_KHR: 1000156023,
+ VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16_KHR: 1000156024,
+ VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16_KHR: 1000156025,
+ VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16_KHR: 1000156026,
+ VK_FORMAT_G16B16G16R16_422_UNORM_KHR: 1000156027,
+ VK_FORMAT_B16G16R16G16_422_UNORM_KHR: 1000156028,
+ VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM_KHR: 1000156029,
+ VK_FORMAT_G16_B16R16_2PLANE_420_UNORM_KHR: 1000156030,
+ VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM_KHR: 1000156031,
+ VK_FORMAT_G16_B16R16_2PLANE_422_UNORM_KHR: 1000156032,
+ VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM_KHR: 1000156033,
+};
+export default Object.freeze(VulkanConstants);
diff --git a/Source/Core/getUint64FromDataView.js b/Source/Core/getUint64FromDataView.js
new file mode 100644
index 00000000000..562ca5298e0
--- /dev/null
+++ b/Source/Core/getUint64FromDataView.js
@@ -0,0 +1,34 @@
+/**
+ * Javascript does not support Uint64, so reading a Uint64 value is not implemented as
+ * a method for DataViews. UInt64 values can be read up to Number.MAX_SAFE_INTEGER, or (2^53) - 1,
+ * which is also 9007199254740991.
+ *
+ * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
+ * for more information.
+ *
+ * @function
+ * @param {DataView} view DataView from which a Uint64 needs to be read.
+ * @param {Number} byteOffset Byte offset into the DataView at which to read the Uint64.
+ * @param {Boolean} littleEndian Whether the DataView is big or little endian.
+ *
+ * @returns {Number} The uint64 result.
+ */
+function getUint64FromDataView(view, byteOffset, littleEndian) {
+ // split 64-bit number into two 32-bit parts
+ var left = view.getUint32(byteOffset, littleEndian);
+ var right = view.getUint32(byteOffset + 4, littleEndian);
+
+ // combine the two 32-bit values
+ var combined = littleEndian
+ ? left + Math.pow(2, 32) * right
+ : Math.pow(2, 32) * left + right;
+
+ if (!combined > Number.MAX_SAFE_INTEGER) {
+ //9007199254740991) { // MAX_SAFE_INTEGER not available in IE11
+ console.warn(combined, "exceeds MAX_SAFE_INTEGER. Precision may be lost");
+ }
+
+ return combined;
+}
+
+export default getUint64FromDataView;
diff --git a/Source/Core/loadCRN.js b/Source/Core/loadCRN.js
deleted file mode 100644
index c7676364cc1..00000000000
--- a/Source/Core/loadCRN.js
+++ /dev/null
@@ -1,90 +0,0 @@
-import when from "../ThirdParty/when.js";
-import CompressedTextureBuffer from "./CompressedTextureBuffer.js";
-import defined from "./defined.js";
-import DeveloperError from "./DeveloperError.js";
-import Resource from "./Resource.js";
-import TaskProcessor from "./TaskProcessor.js";
-
-var transcodeTaskProcessor = new TaskProcessor(
- "transcodeCRNToDXT",
- Number.POSITIVE_INFINITY
-);
-
-/**
- * Asynchronously loads and parses the given URL to a CRN file or parses the raw binary data of a CRN file.
- * Returns a promise that will resolve to an object containing the image buffer, width, height and format once loaded,
- * or reject if the URL failed to load or failed to parse the data. The data is loaded
- * using XMLHttpRequest, which means that in order to make requests to another origin,
- * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
- *
- * @function loadCRN
- *
- * @param {Resource|String|ArrayBuffer} resourceOrUrlOrBuffer The URL of the binary data or an ArrayBuffer.
- * @returns {Promise.
- * The following are part of the KTX format specification but are not supported:
- * request.throttle
is true and the request does not have high enough priority.
- *
- * @exception {RuntimeError} Unsupported compressed format.
- *
- * @example
- * // load a single URL asynchronously
- * Cesium.loadCRN('some/url').then(function(textureData) {
- * var width = textureData.width;
- * var height = textureData.height;
- * var format = textureData.internalFormat;
- * var arrayBufferView = textureData.bufferView;
- * // use the data to create a texture
- * }).otherwise(function(error) {
- * // an error occurred
- * });
- *
- * @see {@link https://github.com/BinomialLLC/crunch|crunch DXTc texture compression and transcoding library}
- * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}
- * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}
- */
-function loadCRN(resourceOrUrlOrBuffer) {
- //>>includeStart('debug', pragmas.debug);
- if (!defined(resourceOrUrlOrBuffer)) {
- throw new DeveloperError("resourceOrUrlOrBuffer is required.");
- }
- //>>includeEnd('debug');
-
- var loadPromise;
- if (
- resourceOrUrlOrBuffer instanceof ArrayBuffer ||
- ArrayBuffer.isView(resourceOrUrlOrBuffer)
- ) {
- loadPromise = when.resolve(resourceOrUrlOrBuffer);
- } else {
- var resource = Resource.createIfNeeded(resourceOrUrlOrBuffer);
- loadPromise = resource.fetchArrayBuffer();
- }
-
- if (!defined(loadPromise)) {
- return undefined;
- }
-
- return loadPromise
- .then(function (data) {
- if (!defined(data)) {
- return;
- }
- var transferrableObjects = [];
- if (data instanceof ArrayBuffer) {
- transferrableObjects.push(data);
- } else if (
- data.byteOffset === 0 &&
- data.byteLength === data.buffer.byteLength
- ) {
- transferrableObjects.push(data.buffer);
- } else {
- // data is a view of an array buffer. need to copy so it is transferrable to web worker
- data = data.slice(0, data.length);
- transferrableObjects.push(data.buffer);
- }
-
- return transcodeTaskProcessor.scheduleTask(data, transferrableObjects);
- })
- .then(function (compressedTextureBuffer) {
- return CompressedTextureBuffer.clone(compressedTextureBuffer);
- });
-}
-export default loadCRN;
diff --git a/Source/Core/loadKTX.js b/Source/Core/loadKTX.js
deleted file mode 100644
index 6fdab8ae14e..00000000000
--- a/Source/Core/loadKTX.js
+++ /dev/null
@@ -1,274 +0,0 @@
-import when from "../ThirdParty/when.js";
-import Check from "./Check.js";
-import CompressedTextureBuffer from "./CompressedTextureBuffer.js";
-import defined from "./defined.js";
-import PixelFormat from "./PixelFormat.js";
-import Resource from "./Resource.js";
-import RuntimeError from "./RuntimeError.js";
-import WebGLConstants from "./WebGLConstants.js";
-
-/**
- * Asynchronously loads and parses the given URL to a KTX file or parses the raw binary data of a KTX file.
- * Returns a promise that will resolve to an object containing the image buffer, width, height and format once loaded,
- * or reject if the URL failed to load or failed to parse the data. The data is loaded
- * using XMLHttpRequest, which means that in order to make requests to another origin,
- * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
- *
- *
- *
request.throttle
is true and the request does not have high enough priority.
- *
- * @exception {RuntimeError} Invalid KTX file.
- * @exception {RuntimeError} File is the wrong endianness.
- * @exception {RuntimeError} glInternalFormat is not a valid format.
- * @exception {RuntimeError} glType must be zero when the texture is compressed.
- * @exception {RuntimeError} The type size for compressed textures must be 1.
- * @exception {RuntimeError} glFormat must be zero when the texture is compressed.
- * @exception {RuntimeError} Generating mipmaps for a compressed texture is unsupported.
- * @exception {RuntimeError} The base internal format must be the same as the format for uncompressed textures.
- * @exception {RuntimeError} 3D textures are not supported.
- * @exception {RuntimeError} Texture arrays are not supported.
- * @exception {RuntimeError} Cubemaps are not supported.
- *
- * @example
- * // load a single URL asynchronously
- * Cesium.loadKTX('some/url').then(function(ktxData) {
- * var width = ktxData.width;
- * var height = ktxData.height;
- * var format = ktxData.internalFormat;
- * var arrayBufferView = ktxData.bufferView;
- * // use the data to create a texture
- * }).otherwise(function(error) {
- * // an error occurred
- * });
- *
- * @see {@link https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/|KTX file format}
- * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}
- * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}
- */
-function loadKTX(resourceOrUrlOrBuffer) {
- //>>includeStart('debug', pragmas.debug);
- Check.defined("resourceOrUrlOrBuffer", resourceOrUrlOrBuffer);
- //>>includeEnd('debug');
-
- var loadPromise;
- if (
- resourceOrUrlOrBuffer instanceof ArrayBuffer ||
- ArrayBuffer.isView(resourceOrUrlOrBuffer)
- ) {
- loadPromise = when.resolve(resourceOrUrlOrBuffer);
- } else {
- var resource = Resource.createIfNeeded(resourceOrUrlOrBuffer);
- loadPromise = resource.fetchArrayBuffer();
- }
-
- if (!defined(loadPromise)) {
- return undefined;
- }
-
- return loadPromise.then(function (data) {
- if (defined(data)) {
- return parseKTX(data);
- }
- });
-}
-
-var fileIdentifier = [
- 0xab,
- 0x4b,
- 0x54,
- 0x58,
- 0x20,
- 0x31,
- 0x31,
- 0xbb,
- 0x0d,
- 0x0a,
- 0x1a,
- 0x0a,
-];
-var endiannessTest = 0x04030201;
-var faceOrder = [
- "positiveX",
- "negativeX",
- "positiveY",
- "negativeY",
- "positiveZ",
- "negativeZ",
-];
-
-var sizeOfUint32 = 4;
-
-function parseKTX(data) {
- var byteBuffer = new Uint8Array(data);
-
- var isKTX = true;
- var i;
- for (i = 0; i < fileIdentifier.length; ++i) {
- if (fileIdentifier[i] !== byteBuffer[i]) {
- isKTX = false;
- break;
- }
- }
-
- if (!isKTX) {
- throw new RuntimeError("Invalid KTX file.");
- }
-
- var view;
- var byteOffset;
-
- if (defined(data.buffer)) {
- view = new DataView(data.buffer);
- byteOffset = data.byteOffset;
- } else {
- view = new DataView(data);
- byteOffset = 0;
- }
-
- byteOffset += 12; // skip identifier
-
- var endianness = view.getUint32(byteOffset, true);
- byteOffset += sizeOfUint32;
- if (endianness !== endiannessTest) {
- throw new RuntimeError("File is the wrong endianness.");
- }
-
- var glType = view.getUint32(byteOffset, true);
- byteOffset += sizeOfUint32;
- var glTypeSize = view.getUint32(byteOffset, true);
- byteOffset += sizeOfUint32;
- var glFormat = view.getUint32(byteOffset, true);
- byteOffset += sizeOfUint32;
- var glInternalFormat = view.getUint32(byteOffset, true);
- byteOffset += sizeOfUint32;
- var glBaseInternalFormat = view.getUint32(byteOffset, true);
- byteOffset += sizeOfUint32;
- var pixelWidth = view.getUint32(byteOffset, true);
- byteOffset += sizeOfUint32;
- var pixelHeight = view.getUint32(byteOffset, true);
- byteOffset += sizeOfUint32;
- var pixelDepth = view.getUint32(byteOffset, true);
- byteOffset += sizeOfUint32;
- var numberOfArrayElements = view.getUint32(byteOffset, true);
- byteOffset += sizeOfUint32;
- var numberOfFaces = view.getUint32(byteOffset, true);
- byteOffset += sizeOfUint32;
- var numberOfMipmapLevels = view.getUint32(byteOffset, true);
- byteOffset += sizeOfUint32;
- var bytesOfKeyValueByteSize = view.getUint32(byteOffset, true);
- byteOffset += sizeOfUint32;
-
- // skip metadata
- byteOffset += bytesOfKeyValueByteSize;
-
- var imageSize = view.getUint32(byteOffset, true);
- byteOffset += sizeOfUint32;
-
- var texture;
- if (defined(data.buffer)) {
- texture = new Uint8Array(data.buffer, byteOffset, imageSize);
- } else {
- texture = new Uint8Array(data, byteOffset, imageSize);
- }
-
- // Some tools use a sized internal format.
- // See table 2: https://www.opengl.org/sdk/docs/man/html/glTexImage2D.xhtml
- if (glInternalFormat === WebGLConstants.RGB8) {
- glInternalFormat = PixelFormat.RGB;
- } else if (glInternalFormat === WebGLConstants.RGBA8) {
- glInternalFormat = PixelFormat.RGBA;
- }
-
- if (!PixelFormat.validate(glInternalFormat)) {
- throw new RuntimeError("glInternalFormat is not a valid format.");
- }
-
- if (PixelFormat.isCompressedFormat(glInternalFormat)) {
- if (glType !== 0) {
- throw new RuntimeError(
- "glType must be zero when the texture is compressed."
- );
- }
- if (glTypeSize !== 1) {
- throw new RuntimeError(
- "The type size for compressed textures must be 1."
- );
- }
- if (glFormat !== 0) {
- throw new RuntimeError(
- "glFormat must be zero when the texture is compressed."
- );
- }
- } else if (glType !== WebGLConstants.UNSIGNED_BYTE) {
- throw new RuntimeError("Only unsigned byte buffers are supported.");
- } else if (glBaseInternalFormat !== glFormat) {
- throw new RuntimeError(
- "The base internal format must be the same as the format for uncompressed textures."
- );
- }
-
- if (pixelDepth !== 0) {
- throw new RuntimeError("3D textures are unsupported.");
- }
-
- if (numberOfArrayElements !== 0) {
- throw new RuntimeError("Texture arrays are unsupported.");
- }
-
- var offset = texture.byteOffset;
- var mipmaps = new Array(numberOfMipmapLevels);
- for (i = 0; i < numberOfMipmapLevels; ++i) {
- var level = (mipmaps[i] = {});
- for (var j = 0; j < numberOfFaces; ++j) {
- var width = pixelWidth >> i;
- var height = pixelHeight >> i;
- var levelSize = PixelFormat.isCompressedFormat(glInternalFormat)
- ? PixelFormat.compressedTextureSizeInBytes(
- glInternalFormat,
- width,
- height
- )
- : PixelFormat.textureSizeInBytes(
- glInternalFormat,
- glType,
- width,
- height
- );
- var levelBuffer = new Uint8Array(texture.buffer, offset, levelSize);
- level[faceOrder[j]] = new CompressedTextureBuffer(
- glInternalFormat,
- width,
- height,
- levelBuffer
- );
- offset += levelSize;
- }
- offset += 3 - ((offset + 3) % 4) + 4;
- }
-
- var result = mipmaps;
- if (numberOfFaces === 1) {
- for (i = 0; i < numberOfMipmapLevels; ++i) {
- result[i] = result[i][faceOrder[0]];
- }
- }
- if (numberOfMipmapLevels === 1) {
- result = result[0];
- }
-
- return result;
-}
-export default loadKTX;
diff --git a/Source/Core/loadKTX2.js b/Source/Core/loadKTX2.js
new file mode 100644
index 00000000000..f3b36db1a0d
--- /dev/null
+++ b/Source/Core/loadKTX2.js
@@ -0,0 +1,110 @@
+import arraySlice from "./arraySlice.js";
+import Check from "./Check.js";
+import defined from "./defined.js";
+import Resource from "./Resource.js";
+import RuntimeError from "./RuntimeError.js";
+import KTX2Transcoder from "../Scene/KTX2Transcoder.js";
+import when from "../ThirdParty/when.js";
+
+/**
+ * Stores the supported formats that KTX2 can transcode to. Called during context creation.
+ *
+ * @param {Boolean} etc1 Whether or not ETC1 is supported
+ * @param {Boolean} s3tc Whether or not S3TC is supported
+ * @param {Boolean} pvrtc Whether or not PVRTC is supported
+ * @private
+ * */
+var supportedTranscoderFormats;
+
+loadKTX2.setKTX2SupportedFormats = function (etc1, s3tc, pvrtc) {
+ supportedTranscoderFormats = {
+ etc1: etc1,
+ s3tc: s3tc,
+ pvrtc: pvrtc,
+ };
+};
+
+/**
+ * Asynchronously loads and parses the given URL to a KTX2 file or parses the raw binary data of a KTX2 file.
+ * Returns a promise that will resolve to an object containing the image buffer, width, height and format once loaded,
+ * or reject if the URL failed to load or failed to parse the data. The data is loaded
+ * using XMLHttpRequest, which means that in order to make requests to another origin,
+ * the server must have Cross-Origin Resource Sharing (CORS) headers enabled.
+ * + * The following are part of the KTX2 format specification but are not supported: + *
request.throttle
is true and the request does not have high enough priority.
+ *
+ * @exception {RuntimeError} Invalid KTX2 file.
+ * @exception {RuntimeError} File is the wrong endianness.
+ * @exception {RuntimeError} glInternalFormat is not a valid format.
+ * @exception {RuntimeError} glType must be zero when the texture is compressed.
+ * @exception {RuntimeError} The type size for compressed textures must be 1.
+ * @exception {RuntimeError} glFormat must be zero when the texture is compressed.
+ * @exception {RuntimeError} Generating mipmaps for a compressed texture is unsupported.
+ * @exception {RuntimeError} The base internal format must be the same as the format for uncompressed textures.
+ * @exception {RuntimeError} 3D textures are not supported.
+ * @exception {RuntimeError} Texture arrays are not supported.
+ * @exception {RuntimeError} Cubemaps are not supported.
+ *
+ * @example
+ * // load a single URL asynchronously
+ * Cesium.loadKTX2('some/url').then(function(ktx2Data) {
+ * var width = ktx2Data.width;
+ * var height = ktx2Data.height;
+ * var format = ktx2Data.internalFormat;
+ * var arrayBufferView = ktx2Data.bufferView;
+ * // use the data to create a texture
+ * }).otherwise(function(error) {
+ * // an error occurred
+ * });
+ *
+ * @see {@link hhttp://github.khronos.org/KTX-Specification/|KTX file format}
+ * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}
+ * @see {@link http://wiki.commonjs.org/wiki/Promises/A|CommonJS Promises/A}
+ * @private
+ */
+function loadKTX2(resourceOrUrlOrBuffer) {
+ //>>includeStart('debug', pragmas.debug);
+ Check.defined("resourceOrUrlOrBuffer", resourceOrUrlOrBuffer);
+ //>>includeEnd('debug');
+
+ var loadPromise;
+ if (
+ resourceOrUrlOrBuffer instanceof ArrayBuffer ||
+ ArrayBuffer.isView(resourceOrUrlOrBuffer)
+ ) {
+ loadPromise = when.resolve(resourceOrUrlOrBuffer);
+ } else {
+ var resource = Resource.createIfNeeded(resourceOrUrlOrBuffer);
+ loadPromise = resource.fetchArrayBuffer();
+ }
+
+ if (!defined(loadPromise)) {
+ return undefined;
+ }
+
+ // load module then return
+ return loadPromise.then(function (data) {
+ if (defined(data)) {
+ // data array can be a view of a shared buffer,
+ // so make a copy that can be given to the worker.
+ var copy = arraySlice(data);
+ return KTX2Transcoder.transcode(copy, supportedTranscoderFormats);
+ }
+ return when.reject(new RuntimeError("failed to load KTX2 data."));
+ });
+}
+
+export default loadKTX2;
diff --git a/Source/Renderer/Context.js b/Source/Renderer/Context.js
index fff292a24b7..d37b1d4b558 100644
--- a/Source/Renderer/Context.js
+++ b/Source/Renderer/Context.js
@@ -18,6 +18,7 @@ import ViewportQuadVS from "../Shaders/ViewportQuadVS.js";
import BufferUsage from "./BufferUsage.js";
import ClearCommand from "./ClearCommand.js";
import ContextLimits from "./ContextLimits.js";
+import loadKTX2 from "../Core/loadKTX2.js";
import CubeMap from "./CubeMap.js";
import DrawCommand from "./DrawCommand.js";
import PassState from "./PassState.js";
@@ -315,6 +316,7 @@ function Context(canvas, options) {
"WEBKIT_WEBGL_compressed_texture_pvrtc",
]);
this._etc1 = !!getExtension(gl, ["WEBGL_compressed_texture_etc1"]);
+ loadKTX2.setKTX2SupportedFormats(this._etc1, this._s3tc, this._pvrtc);
var textureFilterAnisotropic = options.allowTextureFilterAnisotropic
? getExtension(gl, [
diff --git a/Source/Scene/ImageryProvider.js b/Source/Scene/ImageryProvider.js
index 616bcbcbe8f..cbbdbc1b9fc 100644
--- a/Source/Scene/ImageryProvider.js
+++ b/Source/Scene/ImageryProvider.js
@@ -1,8 +1,7 @@
import Check from "../Core/Check.js";
import defined from "../Core/defined.js";
import DeveloperError from "../Core/DeveloperError.js";
-import loadCRN from "../Core/loadCRN.js";
-import loadKTX from "../Core/loadKTX.js";
+import loadKTX2 from "../Core/loadKTX2.js";
import Resource from "../Core/Resource.js";
/**
@@ -336,8 +335,7 @@ ImageryProvider.prototype.pickFeatures = function (
DeveloperError.throwInstantiationError();
};
-var ktxRegex = /\.ktx$/i;
-var crnRegex = /\.crn$/i;
+var ktx2Regex = /\.ktx2$/i;
/**
* Loads an image from a given URL. If the server referenced by the URL already has
@@ -358,10 +356,8 @@ ImageryProvider.loadImage = function (imageryProvider, url) {
var resource = Resource.createIfNeeded(url);
- if (ktxRegex.test(resource.url)) {
- return loadKTX(resource);
- } else if (crnRegex.test(resource.url)) {
- return loadCRN(resource);
+ if (ktx2Regex.test(resource.url)) {
+ return loadKTX2(resource);
} else if (
defined(imageryProvider) &&
defined(imageryProvider.tileDiscardPolicy)
diff --git a/Source/Scene/KTX2Transcoder.js b/Source/Scene/KTX2Transcoder.js
new file mode 100644
index 00000000000..0e8f9f047ed
--- /dev/null
+++ b/Source/Scene/KTX2Transcoder.js
@@ -0,0 +1,78 @@
+import CompressedTextureBuffer from "../Core/CompressedTextureBuffer.js";
+import defined from "../Core/defined.js";
+import TaskProcessor from "../Core/TaskProcessor.js";
+
+/**
+ * Transcodes KTX2 textures using web workers.
+ *
+ * @private
+ */
+function KTX2Transcoder() {}
+
+KTX2Transcoder._transcodeTaskProcessor = new TaskProcessor(
+ "transcodeKTX2",
+ Number.POSITIVE_INFINITY // KTX2 transcoding is used in place of Resource.fetchImage, so it can't reject as "just soooo busy right now"
+);
+
+KTX2Transcoder._readyPromise = undefined;
+
+function makeReadyPromise() {
+ var readyPromise = KTX2Transcoder._transcodeTaskProcessor
+ .initWebAssemblyModule({
+ modulePath: "ThirdParty/Workers/msc_basis_transcoder_wrapper.js",
+ wasmBinaryFile: "ThirdParty/msc_basis_transcoder.wasm",
+ fallbackModulePath: "ThirdParty/Workers/msc_basis_transcoder.js",
+ })
+ .then(function () {
+ return KTX2Transcoder._transcodeTaskProcessor;
+ });
+ KTX2Transcoder._readyPromise = readyPromise;
+}
+
+KTX2Transcoder.transcode = function (ktx2Buffer, supportedTargetFormats) {
+ if (!defined(KTX2Transcoder._readyPromise)) {
+ makeReadyPromise();
+ }
+
+ return KTX2Transcoder._readyPromise
+ .then(function (taskProcessor) {
+ var parameters = {
+ supportedTargetFormats: supportedTargetFormats,
+ ktx2Buffer: ktx2Buffer,
+ };
+ return taskProcessor.scheduleTask(parameters, [ktx2Buffer.buffer]);
+ })
+ .then(function (result) {
+ var levelsLength = result.length;
+ var faceKeys = Object.keys(result[0]);
+ var faceKeysLength = faceKeys.length;
+
+ var i;
+ for (i = 0; i < levelsLength; i++) {
+ var faces = result[i];
+ for (var j = 0; j < faceKeysLength; j++) {
+ var face = faces[faceKeys[j]];
+ faces[faceKeys[j]] = new CompressedTextureBuffer(
+ face.internalFormat,
+ face.width,
+ face.height,
+ face.levelBuffer
+ );
+ }
+ }
+
+ // Cleaning up parsed result if it's a single image
+ if (faceKeysLength === 1) {
+ for (i = 0; i < levelsLength; ++i) {
+ result[i] = result[i][faceKeys[0]];
+ }
+
+ if (levelsLength === 1) {
+ result = result[0];
+ }
+ }
+ return result;
+ });
+};
+
+export default KTX2Transcoder;
diff --git a/Source/Scene/Material.js b/Source/Scene/Material.js
index 4b882b71ce4..ecc536e8394 100644
--- a/Source/Scene/Material.js
+++ b/Source/Scene/Material.js
@@ -7,8 +7,7 @@ import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import destroyObject from "../Core/destroyObject.js";
import DeveloperError from "../Core/DeveloperError.js";
-import loadCRN from "../Core/loadCRN.js";
-import loadKTX from "../Core/loadKTX.js";
+import loadKTX2 from "../Core/loadKTX2.js";
import Matrix2 from "../Core/Matrix2.js";
import Matrix3 from "../Core/Matrix3.js";
import Matrix4 from "../Core/Matrix4.js";
@@ -771,8 +770,7 @@ var matrixMap = {
mat4: Matrix4,
};
-var ktxRegex = /\.ktx$/i;
-var crnRegex = /\.crn$/i;
+var ktx2Regex = /\.ktx2$/i;
function createTexture2DUpdateFunction(uniformId) {
var oldUniformValue;
@@ -872,13 +870,12 @@ function createTexture2DUpdateFunction(uniformId) {
: Resource.createIfNeeded(uniformValue);
var promise;
- if (ktxRegex.test(resource.url)) {
- promise = loadKTX(resource);
- } else if (crnRegex.test(resource.url)) {
- promise = loadCRN(resource);
+ if (ktx2Regex.test(resource.url)) {
+ promise = loadKTX2(resource.url);
} else {
promise = resource.fetchImage();
}
+
when(promise, function (image) {
material._loadedImages.push({
id: uniformId,
diff --git a/Source/Scene/Model.js b/Source/Scene/Model.js
index f337048d58c..cf1fa2fe12d 100644
--- a/Source/Scene/Model.js
+++ b/Source/Scene/Model.js
@@ -19,9 +19,8 @@ import getAbsoluteUri from "../Core/getAbsoluteUri.js";
import getMagic from "../Core/getMagic.js";
import getStringFromTypedArray from "../Core/getStringFromTypedArray.js";
import IndexDatatype from "../Core/IndexDatatype.js";
-import loadCRN from "../Core/loadCRN.js";
import loadImageFromTypedArray from "../Core/loadImageFromTypedArray.js";
-import loadKTX from "../Core/loadKTX.js";
+import loadKTX2 from "../Core/loadKTX2.js";
import CesiumMath from "../Core/Math.js";
import Matrix3 from "../Core/Matrix3.js";
import Matrix4 from "../Core/Matrix4.js";
@@ -173,6 +172,8 @@ var uriToGuid = {};
* {@link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_techniques_webgl/README.md|KHR_techniques_webgl}
* true
, if a duplicate element is found its index is returned and element
is not added to the array.
- *
- * @private
- */
- function addToArray(array, element, checkDuplicates) {
- checkDuplicates = defaultValue(checkDuplicates, false);
- if (checkDuplicates) {
- var index = array.indexOf(element);
- if (index > -1) {
- return index;
- }
+/**
+ * Adds an element to an array and returns the element's index.
+ *
+ * @param {Array} array The array to add to.
+ * @param {Object} element The element to add.
+ * @param {Boolean} [checkDuplicates=false] When true
, if a duplicate element is found its index is returned and element
is not added to the array.
+ *
+ * @private
+ */
+function addToArray(array, element, checkDuplicates) {
+ checkDuplicates = defaultValue(checkDuplicates, false);
+ if (checkDuplicates) {
+ var index = array.indexOf(element);
+ if (index > -1) {
+ return index;
}
-
- array.push(element);
- return array.length - 1;
}
- export default addToArray;
+ array.push(element);
+ return array.length - 1;
+}
+
+export default addToArray;
diff --git a/Source/ThirdParty/GltfPipeline/findAccessorMinMax.js b/Source/ThirdParty/GltfPipeline/findAccessorMinMax.js
index 721415f3724..66efe0712bf 100644
--- a/Source/ThirdParty/GltfPipeline/findAccessorMinMax.js
+++ b/Source/ThirdParty/GltfPipeline/findAccessorMinMax.js
@@ -5,60 +5,60 @@ import arrayFill from '../../Core/arrayFill.js'
import ComponentDatatype from '../../Core/ComponentDatatype.js'
import defined from '../../Core/defined.js'
- /**
- * Finds the min and max values of the accessor.
- *
- * @param {Object} gltf A javascript object containing a glTF asset.
- * @param {Object} accessor The accessor object from the glTF asset to read.
- * @returns {{min: Array, max: Array}} min holding the array of minimum values and max holding the array of maximum values.
- *
- * @private
- */
- function findAccessorMinMax(gltf, accessor) {
- var bufferViews = gltf.bufferViews;
- var buffers = gltf.buffers;
- var bufferViewId = accessor.bufferView;
- var numberOfComponents = numberOfComponentsForType(accessor.type);
+/**
+ * Finds the min and max values of the accessor.
+ *
+ * @param {Object} gltf A javascript object containing a glTF asset.
+ * @param {Object} accessor The accessor object from the glTF asset to read.
+ * @returns {{min: Array, max: Array}} min holding the array of minimum values and max holding the array of maximum values.
+ *
+ * @private
+ */
+function findAccessorMinMax(gltf, accessor) {
+ var bufferViews = gltf.bufferViews;
+ var buffers = gltf.buffers;
+ var bufferViewId = accessor.bufferView;
+ var numberOfComponents = numberOfComponentsForType(accessor.type);
- // According to the spec, when bufferView is not defined, accessor must be initialized with zeros
- if (!defined(accessor.bufferView)) {
- return {
- min: arrayFill(new Array(numberOfComponents), 0.0),
- max: arrayFill(new Array(numberOfComponents), 0.0)
- };
- }
+ // According to the spec, when bufferView is not defined, accessor must be initialized with zeros
+ if (!defined(accessor.bufferView)) {
+ return {
+ min: arrayFill(new Array(numberOfComponents), 0.0),
+ max: arrayFill(new Array(numberOfComponents), 0.0)
+ };
+ }
- var min = arrayFill(new Array(numberOfComponents), Number.POSITIVE_INFINITY);
- var max = arrayFill(new Array(numberOfComponents), Number.NEGATIVE_INFINITY);
+ var min = arrayFill(new Array(numberOfComponents), Number.POSITIVE_INFINITY);
+ var max = arrayFill(new Array(numberOfComponents), Number.NEGATIVE_INFINITY);
- var bufferView = bufferViews[bufferViewId];
- var bufferId = bufferView.buffer;
- var buffer = buffers[bufferId];
- var source = buffer.extras._pipeline.source;
+ var bufferView = bufferViews[bufferViewId];
+ var bufferId = bufferView.buffer;
+ var buffer = buffers[bufferId];
+ var source = buffer.extras._pipeline.source;
- var count = accessor.count;
- var byteStride = getAccessorByteStride(gltf, accessor);
- var byteOffset = accessor.byteOffset + bufferView.byteOffset + source.byteOffset;
- var componentType = accessor.componentType;
- var componentTypeByteLength = ComponentDatatype.getSizeInBytes(componentType);
- var dataView = new DataView(source.buffer);
- var components = new Array(numberOfComponents);
- var componentReader = getComponentReader(componentType);
+ var count = accessor.count;
+ var byteStride = getAccessorByteStride(gltf, accessor);
+ var byteOffset = accessor.byteOffset + bufferView.byteOffset + source.byteOffset;
+ var componentType = accessor.componentType;
+ var componentTypeByteLength = ComponentDatatype.getSizeInBytes(componentType);
+ var dataView = new DataView(source.buffer);
+ var components = new Array(numberOfComponents);
+ var componentReader = getComponentReader(componentType);
- for (var i = 0; i < count; i++) {
- componentReader(dataView, byteOffset, numberOfComponents, componentTypeByteLength, components);
- for (var j = 0; j < numberOfComponents; j++) {
- var value = components[j];
- min[j] = Math.min(min[j], value);
- max[j] = Math.max(max[j], value);
- }
- byteOffset += byteStride;
+ for (var i = 0; i < count; i++) {
+ componentReader(dataView, byteOffset, numberOfComponents, componentTypeByteLength, components);
+ for (var j = 0; j < numberOfComponents; j++) {
+ var value = components[j];
+ min[j] = Math.min(min[j], value);
+ max[j] = Math.max(max[j], value);
}
-
- return {
- min: min,
- max: max
- };
+ byteOffset += byteStride;
}
- export default findAccessorMinMax;
+ return {
+ min: min,
+ max: max
+ };
+}
+
+export default findAccessorMinMax;
diff --git a/Source/ThirdParty/GltfPipeline/forEachTextureInMaterial.js b/Source/ThirdParty/GltfPipeline/forEachTextureInMaterial.js
new file mode 100644
index 00000000000..030c7fe448c
--- /dev/null
+++ b/Source/ThirdParty/GltfPipeline/forEachTextureInMaterial.js
@@ -0,0 +1,134 @@
+import defined from '../../Core/defined.js'
+import Check from '../../Core/Check.js'
+import ForEach from './ForEach.js'
+
+/**
+ * Calls the provider handler function on each texture used by the material.
+ * Mimics the behavior of functions in gltf-pipeline ForEach.
+ * @param {Object} material The glTF material.
+ * @param {forEachTextureInMaterial~handler} handler Function that is called for each texture in the material.
+ */
+function forEachTextureInMaterial(material, handler) {
+ Check.typeOf.object('material', material);
+ Check.defined('handler', handler);
+
+ // Metallic roughness
+ var pbrMetallicRoughness = material.pbrMetallicRoughness;
+ if (defined(pbrMetallicRoughness)) {
+ if (defined(pbrMetallicRoughness.baseColorTexture)) {
+ var textureInfo = pbrMetallicRoughness.baseColorTexture;
+ var value = handler(textureInfo.index, textureInfo);
+ if (defined(value)) {
+ return value;
+ }
+ }
+ if (defined(pbrMetallicRoughness.metallicRoughnessTexture)) {
+ var textureInfo = pbrMetallicRoughness.metallicRoughnessTexture;
+ var value = handler(textureInfo.index, textureInfo);
+ if (defined(value)) {
+ return value;
+ }
+ }
+ }
+
+ if (defined(material.extensions)) {
+ // Spec gloss extension
+ var pbrSpecularGlossiness = material.extensions.KHR_materials_pbrSpecularGlossiness;
+ if (defined(pbrSpecularGlossiness)) {
+ if (defined(pbrSpecularGlossiness.diffuseTexture)) {
+ var textureInfo = pbrSpecularGlossiness.diffuseTexture;
+ var value = handler(textureInfo.index, textureInfo);
+ if (defined(value)) {
+ return value;
+ }
+ }
+ if (defined(pbrSpecularGlossiness.specularGlossinessTexture)) {
+ var textureInfo = pbrSpecularGlossiness.specularGlossinessTexture;
+ var value = handler(textureInfo.index, textureInfo);
+ if (defined(value)) {
+ return value;
+ }
+ }
+ }
+
+ // Materials common extension (may be present in models converted from glTF 1.0)
+ var materialsCommon = material.extensions.KHR_materials_common;
+ if (defined(materialsCommon)) {
+ var diffuse = materialsCommon.values.diffuse;
+ var ambient = materialsCommon.values.ambient;
+ var emission = materialsCommon.values.emission;
+ var specular = materialsCommon.values.specular;
+ if (defined(diffuse) && defined(diffuse.index)) {
+ var value = handler(diffuse.index, diffuse);
+ if (defined(value)) {
+ return value;
+ }
+ }
+ if (defined(ambient) && defined(ambient.index)) {
+ var value = handler(ambient.index, ambient);
+ if (defined(value)) {
+ return value;
+ }
+ }
+ if (defined(emission) && defined(emission.index)) {
+ var value = handler(emission.index, emission);
+ if (defined(value)) {
+ return value;
+ }
+ }
+ if (defined(specular) && defined(specular.index)) {
+ var value = handler(specular.index, specular);
+ if (defined(value)) {
+ return value;
+ }
+ }
+ }
+ }
+
+ // KHR_techniques_webgl extension
+ var value = ForEach.materialValue(material, function (materialValue) {
+ if (defined(materialValue.index)) {
+ var value = handler(materialValue.index, materialValue);
+ if (defined(value)) {
+ return value;
+ }
+ }
+ });
+ if (defined(value)) {
+ return value;
+ }
+
+ // Top level textures
+ if (defined(material.emissiveTexture)) {
+ var textureInfo = material.emissiveTexture;
+ var value = handler(textureInfo.index, textureInfo);
+ if (defined(value)) {
+ return value;
+ }
+ }
+
+ if (defined(material.normalTexture)) {
+ var textureInfo = material.normalTexture;
+ var value = handler(textureInfo.index, textureInfo);
+ if (defined(value)) {
+ return value;
+ }
+ }
+
+ if (defined(material.occlusionTexture)) {
+ var textureInfo = material.occlusionTexture;
+ var value = handler(textureInfo.index, textureInfo);
+ if (defined(value)) {
+ return value;
+ }
+ }
+}
+
+/**
+ * Function that is called for each texture in the material. If this function returns a value the for each stops and returns that value.
+ * @callback forEachTextureInMaterial~handler
+ * @param {Number} The texture index.
+ * @param {Object} The texture info object.
+ */
+
+export default forEachTextureInMaterial;
diff --git a/Source/ThirdParty/GltfPipeline/getAccessorByteStride.js b/Source/ThirdParty/GltfPipeline/getAccessorByteStride.js
index c0bbecb2249..e854462e5e5 100644
--- a/Source/ThirdParty/GltfPipeline/getAccessorByteStride.js
+++ b/Source/ThirdParty/GltfPipeline/getAccessorByteStride.js
@@ -2,25 +2,25 @@ import numberOfComponentsForType from './numberOfComponentsForType.js'
import ComponentDatatype from '../../Core/ComponentDatatype.js'
import defined from '../../Core/defined.js'
- /**
- * Returns the byte stride of the provided accessor.
- * If the byteStride is 0, it is calculated based on type and componentType
- *
- * @param {Object} gltf A javascript object containing a glTF asset.
- * @param {Object} accessor The accessor.
- * @returns {Number} The byte stride of the accessor.
- *
- * @private
- */
- function getAccessorByteStride(gltf, accessor) {
- var bufferViewId = accessor.bufferView;
- if (defined(bufferViewId)) {
- var bufferView = gltf.bufferViews[bufferViewId];
- if (defined(bufferView.byteStride) && bufferView.byteStride > 0) {
- return bufferView.byteStride;
- }
+/**
+ * Returns the byte stride of the provided accessor.
+ * If the byteStride is 0, it is calculated based on type and componentType
+ *
+ * @param {Object} gltf A javascript object containing a glTF asset.
+ * @param {Object} accessor The accessor.
+ * @returns {Number} The byte stride of the accessor.
+ *
+ * @private
+ */
+function getAccessorByteStride(gltf, accessor) {
+ var bufferViewId = accessor.bufferView;
+ if (defined(bufferViewId)) {
+ var bufferView = gltf.bufferViews[bufferViewId];
+ if (defined(bufferView.byteStride) && bufferView.byteStride > 0) {
+ return bufferView.byteStride;
}
- return ComponentDatatype.getSizeInBytes(accessor.componentType) * numberOfComponentsForType(accessor.type);
}
+ return ComponentDatatype.getSizeInBytes(accessor.componentType) * numberOfComponentsForType(accessor.type);
+}
- export default getAccessorByteStride;
+export default getAccessorByteStride;
diff --git a/Source/ThirdParty/GltfPipeline/getComponentReader.js b/Source/ThirdParty/GltfPipeline/getComponentReader.js
index ff406b46d39..d104f570832 100644
--- a/Source/ThirdParty/GltfPipeline/getComponentReader.js
+++ b/Source/ThirdParty/GltfPipeline/getComponentReader.js
@@ -1,75 +1,75 @@
import ComponentDatatype from '../../Core/ComponentDatatype.js'
- /**
- * Returns a function to read and convert data from a DataView into an array.
- *
- * @param {Number} componentType Type to convert the data to.
- * @returns {ComponentReader} Function that reads and converts data.
- *
- * @private
- */
- function getComponentReader(componentType) {
- switch (componentType) {
- case ComponentDatatype.BYTE:
- return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
- for (var i = 0; i < numberOfComponents; ++i) {
- result[i] = dataView.getInt8(byteOffset + i * componentTypeByteLength);
- }
- };
- case ComponentDatatype.UNSIGNED_BYTE:
- return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
- for (var i = 0; i < numberOfComponents; ++i) {
- result[i] = dataView.getUint8(byteOffset + i * componentTypeByteLength);
- }
- };
- case ComponentDatatype.SHORT:
- return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
- for (var i = 0; i < numberOfComponents; ++i) {
- result[i] = dataView.getInt16(byteOffset + i * componentTypeByteLength, true);
- }
- };
- case ComponentDatatype.UNSIGNED_SHORT:
- return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
- for (var i = 0; i < numberOfComponents; ++i) {
- result[i] = dataView.getUint16(byteOffset + i * componentTypeByteLength, true);
- }
- };
- case ComponentDatatype.INT:
- return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
- for (var i = 0; i < numberOfComponents; ++i) {
- result[i] = dataView.getInt32(byteOffset + i * componentTypeByteLength, true);
- }
- };
- case ComponentDatatype.UNSIGNED_INT:
- return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
- for (var i = 0; i < numberOfComponents; ++i) {
- result[i] = dataView.getUint32(byteOffset + i * componentTypeByteLength, true);
- }
- };
- case ComponentDatatype.FLOAT:
- return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
- for (var i = 0; i < numberOfComponents; ++i) {
- result[i] = dataView.getFloat32(byteOffset + i * componentTypeByteLength, true);
- }
- };
- case ComponentDatatype.DOUBLE:
- return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
- for (var i = 0; i < numberOfComponents; ++i) {
- result[i] = dataView.getFloat64(byteOffset + i * componentTypeByteLength, true);
- }
- };
- }
+/**
+ * Returns a function to read and convert data from a DataView into an array.
+ *
+ * @param {Number} componentType Type to convert the data to.
+ * @returns {ComponentReader} Function that reads and converts data.
+ *
+ * @private
+ */
+function getComponentReader(componentType) {
+ switch (componentType) {
+ case ComponentDatatype.BYTE:
+ return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
+ for (var i = 0; i < numberOfComponents; ++i) {
+ result[i] = dataView.getInt8(byteOffset + i * componentTypeByteLength);
+ }
+ };
+ case ComponentDatatype.UNSIGNED_BYTE:
+ return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
+ for (var i = 0; i < numberOfComponents; ++i) {
+ result[i] = dataView.getUint8(byteOffset + i * componentTypeByteLength);
+ }
+ };
+ case ComponentDatatype.SHORT:
+ return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
+ for (var i = 0; i < numberOfComponents; ++i) {
+ result[i] = dataView.getInt16(byteOffset + i * componentTypeByteLength, true);
+ }
+ };
+ case ComponentDatatype.UNSIGNED_SHORT:
+ return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
+ for (var i = 0; i < numberOfComponents; ++i) {
+ result[i] = dataView.getUint16(byteOffset + i * componentTypeByteLength, true);
+ }
+ };
+ case ComponentDatatype.INT:
+ return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
+ for (var i = 0; i < numberOfComponents; ++i) {
+ result[i] = dataView.getInt32(byteOffset + i * componentTypeByteLength, true);
+ }
+ };
+ case ComponentDatatype.UNSIGNED_INT:
+ return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
+ for (var i = 0; i < numberOfComponents; ++i) {
+ result[i] = dataView.getUint32(byteOffset + i * componentTypeByteLength, true);
+ }
+ };
+ case ComponentDatatype.FLOAT:
+ return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
+ for (var i = 0; i < numberOfComponents; ++i) {
+ result[i] = dataView.getFloat32(byteOffset + i * componentTypeByteLength, true);
+ }
+ };
+ case ComponentDatatype.DOUBLE:
+ return function (dataView, byteOffset, numberOfComponents, componentTypeByteLength, result) {
+ for (var i = 0; i < numberOfComponents; ++i) {
+ result[i] = dataView.getFloat64(byteOffset + i * componentTypeByteLength, true);
+ }
+ };
}
+}
- /**
- * A callback function that logs messages.
- * @callback ComponentReader
- *
- * @param {DataView} dataView The data view to read from.
- * @param {Number} byteOffset The byte offset applied when reading from the data view.
- * @param {Number} numberOfComponents The number of components to read.
- * @param {Number} componentTypeByteLength The byte length of each component.
- * @param {Number} result An array storing the components that are read.
- */
+/**
+ * A callback function that logs messages.
+ * @callback ComponentReader
+ *
+ * @param {DataView} dataView The data view to read from.
+ * @param {Number} byteOffset The byte offset applied when reading from the data view.
+ * @param {Number} numberOfComponents The number of components to read.
+ * @param {Number} componentTypeByteLength The byte length of each component.
+ * @param {Number} result An array storing the components that are read.
+ */
- export default getComponentReader;
+export default getComponentReader;
diff --git a/Source/ThirdParty/GltfPipeline/hasExtension.js b/Source/ThirdParty/GltfPipeline/hasExtension.js
index 50b8524c3ac..6c5ec0c0cd4 100644
--- a/Source/ThirdParty/GltfPipeline/hasExtension.js
+++ b/Source/ThirdParty/GltfPipeline/hasExtension.js
@@ -1,16 +1,16 @@
import defined from '../../Core/defined.js'
- /**
- * Checks whether the glTF has the given extension.
- *
- * @param {Object} gltf A javascript object containing a glTF asset.
- * @param {String} extension The name of the extension.
- * @returns {Boolean} Whether the glTF has the given extension.
- *
- * @private
- */
- function hasExtension(gltf, extension) {
- return defined(gltf.extensionsUsed) && (gltf.extensionsUsed.indexOf(extension) >= 0);
- }
+/**
+ * Checks whether the glTF has the given extension.
+ *
+ * @param {Object} gltf A javascript object containing a glTF asset.
+ * @param {String} extension The name of the extension.
+ * @returns {Boolean} Whether the glTF has the given extension.
+ *
+ * @private
+ */
+function hasExtension(gltf, extension) {
+ return defined(gltf.extensionsUsed) && (gltf.extensionsUsed.indexOf(extension) >= 0);
+}
- export default hasExtension;
+export default hasExtension;
diff --git a/Source/ThirdParty/GltfPipeline/moveTechniqueRenderStates.js b/Source/ThirdParty/GltfPipeline/moveTechniqueRenderStates.js
index c6f9847c993..68c2fea4c5d 100644
--- a/Source/ThirdParty/GltfPipeline/moveTechniqueRenderStates.js
+++ b/Source/ThirdParty/GltfPipeline/moveTechniqueRenderStates.js
@@ -4,126 +4,126 @@ import defaultValue from '../../Core/defaultValue.js'
import defined from '../../Core/defined.js'
import WebGLConstants from '../../Core/WebGLConstants.js'
- var defaultBlendEquation = [
- WebGLConstants.FUNC_ADD,
- WebGLConstants.FUNC_ADD
- ];
-
- var defaultBlendFactors = [
- WebGLConstants.ONE,
- WebGLConstants.ZERO,
- WebGLConstants.ONE,
- WebGLConstants.ZERO
- ];
-
- function isStateEnabled(renderStates, state) {
- var enabled = renderStates.enable;
- if (!defined(enabled)) {
- return false;
- }
+var defaultBlendEquation = [
+ WebGLConstants.FUNC_ADD,
+ WebGLConstants.FUNC_ADD
+];
+
+var defaultBlendFactors = [
+ WebGLConstants.ONE,
+ WebGLConstants.ZERO,
+ WebGLConstants.ONE,
+ WebGLConstants.ZERO
+];
+
+function isStateEnabled(renderStates, state) {
+ var enabled = renderStates.enable;
+ if (!defined(enabled)) {
+ return false;
+ }
- return (enabled.indexOf(state) > -1);
+ return (enabled.indexOf(state) > -1);
+}
+
+var supportedBlendFactors = [
+ WebGLConstants.ZERO,
+ WebGLConstants.ONE,
+ WebGLConstants.SRC_COLOR,
+ WebGLConstants.ONE_MINUS_SRC_COLOR,
+ WebGLConstants.SRC_ALPHA,
+ WebGLConstants.ONE_MINUS_SRC_ALPHA,
+ WebGLConstants.DST_ALPHA,
+ WebGLConstants.ONE_MINUS_DST_ALPHA,
+ WebGLConstants.DST_COLOR,
+ WebGLConstants.ONE_MINUS_DST_COLOR
+];
+
+// If any of the blend factors are not supported, return the default
+function getSupportedBlendFactors(value, defaultValue) {
+ if (!defined(value)) {
+ return defaultValue;
}
- var supportedBlendFactors = [
- WebGLConstants.ZERO,
- WebGLConstants.ONE,
- WebGLConstants.SRC_COLOR,
- WebGLConstants.ONE_MINUS_SRC_COLOR,
- WebGLConstants.SRC_ALPHA,
- WebGLConstants.ONE_MINUS_SRC_ALPHA,
- WebGLConstants.DST_ALPHA,
- WebGLConstants.ONE_MINUS_DST_ALPHA,
- WebGLConstants.DST_COLOR,
- WebGLConstants.ONE_MINUS_DST_COLOR
- ];
-
- // If any of the blend factors are not supported, return the default
- function getSupportedBlendFactors(value, defaultValue) {
- if (!defined(value)) {
+ for (var i = 0; i < 4; i++) {
+ if (supportedBlendFactors.indexOf(value[i]) === -1) {
return defaultValue;
}
-
- for (var i = 0; i < 4; i++) {
- if (supportedBlendFactors.indexOf(value[i]) === -1) {
- return defaultValue;
- }
- }
-
- return value;
}
- /**
- * Move glTF 1.0 technique render states to glTF 2.0 materials properties and KHR_blend extension.
- *
- * @param {Object} gltf A javascript object containing a glTF asset.
- * @returns {Object} The updated glTF asset.
- *
- * @private
- */
- function moveTechniqueRenderStates(gltf) {
- var blendingForTechnique = {};
- var materialPropertiesForTechnique = {};
- var techniquesLegacy = gltf.techniques;
- if (!defined(techniquesLegacy)) {
- return gltf;
- }
-
- ForEach.technique(gltf, function (techniqueLegacy, techniqueIndex) {
- var renderStates = techniqueLegacy.states;
- if (defined(renderStates)) {
- var materialProperties = materialPropertiesForTechnique[techniqueIndex] = {};
-
- // If BLEND is enabled, the material should have alpha mode BLEND
- if (isStateEnabled(renderStates, WebGLConstants.BLEND)) {
- materialProperties.alphaMode = 'BLEND';
-
- var blendFunctions = renderStates.functions;
- if (defined(blendFunctions) && (defined(blendFunctions.blendEquationSeparate)
- || defined(blendFunctions.blendFuncSeparate))) {
- blendingForTechnique[techniqueIndex] = {
- blendEquation: defaultValue(blendFunctions.blendEquationSeparate, defaultBlendEquation),
- blendFactors: getSupportedBlendFactors(blendFunctions.blendFuncSeparate, defaultBlendFactors)
- };
- }
- }
+ return value;
+}
+
+/**
+ * Move glTF 1.0 technique render states to glTF 2.0 materials properties and KHR_blend extension.
+ *
+ * @param {Object} gltf A javascript object containing a glTF asset.
+ * @returns {Object} The updated glTF asset.
+ *
+ * @private
+ */
+function moveTechniqueRenderStates(gltf) {
+ var blendingForTechnique = {};
+ var materialPropertiesForTechnique = {};
+ var techniquesLegacy = gltf.techniques;
+ if (!defined(techniquesLegacy)) {
+ return gltf;
+ }
- // If CULL_FACE is not enabled, the material should be doubleSided
- if (!isStateEnabled(renderStates, WebGLConstants.CULL_FACE)) {
- materialProperties.doubleSided = true;
+ ForEach.technique(gltf, function (techniqueLegacy, techniqueIndex) {
+ var renderStates = techniqueLegacy.states;
+ if (defined(renderStates)) {
+ var materialProperties = materialPropertiesForTechnique[techniqueIndex] = {};
+
+ // If BLEND is enabled, the material should have alpha mode BLEND
+ if (isStateEnabled(renderStates, WebGLConstants.BLEND)) {
+ materialProperties.alphaMode = 'BLEND';
+
+ var blendFunctions = renderStates.functions;
+ if (defined(blendFunctions) && (defined(blendFunctions.blendEquationSeparate)
+ || defined(blendFunctions.blendFuncSeparate))) {
+ blendingForTechnique[techniqueIndex] = {
+ blendEquation: defaultValue(blendFunctions.blendEquationSeparate, defaultBlendEquation),
+ blendFactors: getSupportedBlendFactors(blendFunctions.blendFuncSeparate, defaultBlendFactors)
+ };
}
-
- delete techniqueLegacy.states;
}
- });
- if (Object.keys(blendingForTechnique).length > 0) {
- if (!defined(gltf.extensions)) {
- gltf.extensions = {};
+ // If CULL_FACE is not enabled, the material should be doubleSided
+ if (!isStateEnabled(renderStates, WebGLConstants.CULL_FACE)) {
+ materialProperties.doubleSided = true;
}
- addExtensionsUsed(gltf, 'KHR_blend');
+ delete techniqueLegacy.states;
}
+ });
- ForEach.material(gltf, function (material) {
- if (defined(material.technique)) {
- var materialProperties = materialPropertiesForTechnique[material.technique];
- ForEach.objectLegacy(materialProperties, function (value, property) {
- material[property] = value;
- });
+ if (Object.keys(blendingForTechnique).length > 0) {
+ if (!defined(gltf.extensions)) {
+ gltf.extensions = {};
+ }
- var blending = blendingForTechnique[material.technique];
- if (defined(blending)) {
- if (!defined(material.extensions)) {
- material.extensions = {};
- }
+ addExtensionsUsed(gltf, 'KHR_blend');
+ }
- material.extensions.KHR_blend = blending;
+ ForEach.material(gltf, function (material) {
+ if (defined(material.technique)) {
+ var materialProperties = materialPropertiesForTechnique[material.technique];
+ ForEach.objectLegacy(materialProperties, function (value, property) {
+ material[property] = value;
+ });
+
+ var blending = blendingForTechnique[material.technique];
+ if (defined(blending)) {
+ if (!defined(material.extensions)) {
+ material.extensions = {};
}
+
+ material.extensions.KHR_blend = blending;
}
- });
+ }
+ });
- return gltf;
- }
+ return gltf;
+}
- export default moveTechniqueRenderStates;
+export default moveTechniqueRenderStates;
diff --git a/Source/ThirdParty/GltfPipeline/moveTechniquesToExtension.js b/Source/ThirdParty/GltfPipeline/moveTechniquesToExtension.js
index 96c7631a6fc..89dd2611d93 100644
--- a/Source/ThirdParty/GltfPipeline/moveTechniquesToExtension.js
+++ b/Source/ThirdParty/GltfPipeline/moveTechniquesToExtension.js
@@ -4,60 +4,66 @@ import addToArray from './addToArray.js'
import ForEach from './ForEach.js'
import defined from '../../Core/defined.js'
- /**
- * Move glTF 1.0 material techniques to glTF 2.0 KHR_techniques_webgl extension.
- *
- * @param {Object} gltf A javascript object containing a glTF asset.
- * @returns {Object} The updated glTF asset.
- *
- * @private
- */
- function moveTechniquesToExtension(gltf) {
- var techniquesLegacy = gltf.techniques;
- var mappedUniforms = {};
- var updatedTechniqueIndices = {};
- if (defined(techniquesLegacy)) {
- var extension = {
- programs: [],
- shaders: [],
- techniques: []
+/**
+ * Move glTF 1.0 material techniques to glTF 2.0 KHR_techniques_webgl extension.
+ *
+ * @param {Object} gltf A javascript object containing a glTF asset.
+ * @returns {Object} The updated glTF asset.
+ *
+ * @private
+ */
+function moveTechniquesToExtension(gltf) {
+ var techniquesLegacy = gltf.techniques;
+ var mappedUniforms = {};
+ var updatedTechniqueIndices = {};
+ var seenPrograms = {};
+ if (defined(techniquesLegacy)) {
+ var extension = {
+ programs: [],
+ shaders: [],
+ techniques: []
+ };
+
+ // Some 1.1 models have a glExtensionsUsed property that can be transferred to program.glExtensions
+ var glExtensions = gltf.glExtensionsUsed;
+ delete gltf.glExtensionsUsed;
+
+ ForEach.technique(gltf, function (techniqueLegacy, techniqueId) {
+ var technique = {
+ name: techniqueLegacy.name,
+ program: undefined,
+ attributes: {},
+ uniforms: {}
};
- // Some 1.1 models have a glExtensionsUsed property that can be transferred to program.glExtensions
- var glExtensions = gltf.glExtensionsUsed;
- delete gltf.glExtensionsUsed;
+ var parameterLegacy;
+ ForEach.techniqueAttribute(techniqueLegacy, function (parameterName, attributeName) {
+ parameterLegacy = techniqueLegacy.parameters[parameterName];
+ technique.attributes[attributeName] = {
+ semantic: parameterLegacy.semantic
+ };
+ });
- ForEach.technique(gltf, function (techniqueLegacy, techniqueIndex) {
- var technique = {
- name: techniqueLegacy.name,
- program: undefined,
- attributes: {},
- uniforms: {}
+ ForEach.techniqueUniform(techniqueLegacy, function (parameterName, uniformName) {
+ parameterLegacy = techniqueLegacy.parameters[parameterName];
+ technique.uniforms[uniformName] = {
+ count: parameterLegacy.count,
+ node: parameterLegacy.node,
+ type: parameterLegacy.type,
+ semantic: parameterLegacy.semantic,
+ value: parameterLegacy.value
};
- var parameterLegacy;
- ForEach.techniqueAttribute(techniqueLegacy, function (parameterName, attributeName) {
- parameterLegacy = techniqueLegacy.parameters[parameterName];
- technique.attributes[attributeName] = {
- semantic: parameterLegacy.semantic
- };
- });
-
- ForEach.techniqueUniform(techniqueLegacy, function (parameterName, uniformName) {
- parameterLegacy = techniqueLegacy.parameters[parameterName];
- technique.uniforms[uniformName] = {
- count: parameterLegacy.count,
- node: parameterLegacy.node,
- type: parameterLegacy.type,
- semantic: parameterLegacy.semantic,
- value: parameterLegacy.value
- };
-
- // Store the name of the uniform to update material values.
- mappedUniforms[parameterName] = uniformName;
- });
+ // Store the name of the uniform to update material values.
+ if (!defined(mappedUniforms[techniqueId])) {
+ mappedUniforms[techniqueId] = {};
+ }
+ mappedUniforms[techniqueId][parameterName] = uniformName;
+ });
+ if (!defined(seenPrograms[techniqueLegacy.program])) {
var programLegacy = gltf.programs[techniqueLegacy.program];
+
var program = {
name: programLegacy.name,
fragmentShader: undefined,
@@ -72,53 +78,57 @@ import defined from '../../Core/defined.js'
program.vertexShader = addToArray(extension.shaders, vs, true);
technique.program = addToArray(extension.programs, program);
+ seenPrograms[techniqueLegacy.program] = technique.program;
+ } else {
+ technique.program = seenPrograms[techniqueLegacy.program];
+ }
- // Store the index of the new technique to reference instead.
- updatedTechniqueIndices[techniqueIndex] = addToArray(extension.techniques, technique);
- });
-
- if (extension.techniques.length > 0) {
- if (!defined(gltf.extensions)) {
- gltf.extensions = {};
- }
+ // Store the index of the new technique to reference instead.
+ updatedTechniqueIndices[techniqueId] = addToArray(extension.techniques, technique);
+ });
- gltf.extensions.KHR_techniques_webgl = extension;
- addExtensionsUsed(gltf, 'KHR_techniques_webgl');
- addExtensionsRequired(gltf, 'KHR_techniques_webgl');
+ if (extension.techniques.length > 0) {
+ if (!defined(gltf.extensions)) {
+ gltf.extensions = {};
}
- }
- ForEach.material(gltf, function (material) {
- if (defined(material.technique)) {
- var materialExtension = {
- technique: updatedTechniqueIndices[material.technique]
- };
-
- ForEach.objectLegacy(material.values, function (value, parameterName) {
- if (!defined(materialExtension.values)) {
- materialExtension.values = {};
- }
+ gltf.extensions.KHR_techniques_webgl = extension;
+ addExtensionsUsed(gltf, 'KHR_techniques_webgl');
+ addExtensionsRequired(gltf, 'KHR_techniques_webgl');
+ }
+ }
- var uniformName = mappedUniforms[parameterName];
- materialExtension.values[uniformName] = value;
- });
+ ForEach.material(gltf, function (material) {
+ if (defined(material.technique)) {
+ var materialExtension = {
+ technique: updatedTechniqueIndices[material.technique]
+ };
- if (!defined(material.extensions)) {
- material.extensions = {};
+ ForEach.objectLegacy(material.values, function (value, parameterName) {
+ if (!defined(materialExtension.values)) {
+ materialExtension.values = {};
}
- material.extensions.KHR_techniques_webgl = materialExtension;
+ var uniformName = mappedUniforms[material.technique][parameterName];
+ materialExtension.values[uniformName] = value;
+ });
+
+ if (!defined(material.extensions)) {
+ material.extensions = {};
}
- delete material.technique;
- delete material.values;
- });
+ material.extensions.KHR_techniques_webgl = materialExtension;
+ }
- delete gltf.techniques;
- delete gltf.programs;
- delete gltf.shaders;
+ delete material.technique;
+ delete material.values;
+ });
- return gltf;
- }
+ delete gltf.techniques;
+ delete gltf.programs;
+ delete gltf.shaders;
+
+ return gltf;
+}
- export default moveTechniquesToExtension;
+export default moveTechniquesToExtension;
diff --git a/Source/ThirdParty/GltfPipeline/numberOfComponentsForType.js b/Source/ThirdParty/GltfPipeline/numberOfComponentsForType.js
index 36af8038a64..d211357f063 100644
--- a/Source/ThirdParty/GltfPipeline/numberOfComponentsForType.js
+++ b/Source/ThirdParty/GltfPipeline/numberOfComponentsForType.js
@@ -1,29 +1,29 @@
- /**
- * Utility function for retrieving the number of components in a given type.
- *
- * @param {String} type glTF type
- * @returns {Number} The number of components in that type.
- *
- * @private
- */
- function numberOfComponentsForType(type) {
- switch (type) {
- case 'SCALAR':
- return 1;
- case 'VEC2':
- return 2;
- case 'VEC3':
- return 3;
- case 'VEC4':
- case 'MAT2':
- return 4;
- case 'MAT3':
- return 9;
- case 'MAT4':
- return 16;
- }
+/**
+ * Utility function for retrieving the number of components in a given type.
+ *
+ * @param {String} type glTF type
+ * @returns {Number} The number of components in that type.
+ *
+ * @private
+ */
+function numberOfComponentsForType(type) {
+ switch (type) {
+ case 'SCALAR':
+ return 1;
+ case 'VEC2':
+ return 2;
+ case 'VEC3':
+ return 3;
+ case 'VEC4':
+ case 'MAT2':
+ return 4;
+ case 'MAT3':
+ return 9;
+ case 'MAT4':
+ return 16;
}
+}
- export default numberOfComponentsForType;
+export default numberOfComponentsForType;
diff --git a/Source/ThirdParty/GltfPipeline/parseGlb.js b/Source/ThirdParty/GltfPipeline/parseGlb.js
index 937bf6ec283..9580b53cce1 100644
--- a/Source/ThirdParty/GltfPipeline/parseGlb.js
+++ b/Source/ThirdParty/GltfPipeline/parseGlb.js
@@ -6,110 +6,110 @@ import getMagic from '../../Core/getMagic.js'
import getStringFromTypedArray from '../../Core/getStringFromTypedArray.js'
import RuntimeError from '../../Core/RuntimeError.js'
- var sizeOfUint32 = 4;
+var sizeOfUint32 = 4;
- /**
- * Convert a binary glTF to glTF.
- *
- * The returned glTF has pipeline extras included. The embedded binary data is stored in gltf.buffers[0].extras._pipeline.source.
- *
- * @param {Buffer} glb The glb data to parse.
- * @returns {Object} A javascript object containing a glTF asset with pipeline extras included.
- *
- * @private
- */
- function parseGlb(glb) {
- // Check that the magic string is present
- var magic = getMagic(glb);
- if (magic !== 'glTF') {
- throw new RuntimeError('File is not valid binary glTF');
- }
-
- var header = readHeader(glb, 0, 5);
- var version = header[1];
- if (version !== 1 && version !== 2) {
- throw new RuntimeError('Binary glTF version is not 1 or 2');
- }
+/**
+ * Convert a binary glTF to glTF.
+ *
+ * The returned glTF has pipeline extras included. The embedded binary data is stored in gltf.buffers[0].extras._pipeline.source.
+ *
+ * @param {Buffer} glb The glb data to parse.
+ * @returns {Object} A javascript object containing a glTF asset with pipeline extras included.
+ *
+ * @private
+ */
+function parseGlb(glb) {
+ // Check that the magic string is present
+ var magic = getMagic(glb);
+ if (magic !== 'glTF') {
+ throw new RuntimeError('File is not valid binary glTF');
+ }
- if (version === 1) {
- return parseGlbVersion1(glb, header);
- }
+ var header = readHeader(glb, 0, 5);
+ var version = header[1];
+ if (version !== 1 && version !== 2) {
+ throw new RuntimeError('Binary glTF version is not 1 or 2');
+ }
- return parseGlbVersion2(glb, header);
+ if (version === 1) {
+ return parseGlbVersion1(glb, header);
}
- function readHeader(glb, byteOffset, count) {
- var dataView = new DataView(glb.buffer);
- var header = new Array(count);
- for (var i = 0; i < count; ++i) {
- header[i] = dataView.getUint32(glb.byteOffset + byteOffset + i * sizeOfUint32, true);
- }
- return header;
+ return parseGlbVersion2(glb, header);
+}
+
+function readHeader(glb, byteOffset, count) {
+ var dataView = new DataView(glb.buffer);
+ var header = new Array(count);
+ for (var i = 0; i < count; ++i) {
+ header[i] = dataView.getUint32(glb.byteOffset + byteOffset + i * sizeOfUint32, true);
}
+ return header;
+}
- function parseGlbVersion1(glb, header) {
- var length = header[2];
- var contentLength = header[3];
- var contentFormat = header[4];
+function parseGlbVersion1(glb, header) {
+ var length = header[2];
+ var contentLength = header[3];
+ var contentFormat = header[4];
- // Check that the content format is 0, indicating that it is JSON
- if (contentFormat !== 0) {
- throw new RuntimeError('Binary glTF scene format is not JSON');
- }
+ // Check that the content format is 0, indicating that it is JSON
+ if (contentFormat !== 0) {
+ throw new RuntimeError('Binary glTF scene format is not JSON');
+ }
- var jsonStart = 20;
- var binaryStart = jsonStart + contentLength;
+ var jsonStart = 20;
+ var binaryStart = jsonStart + contentLength;
- var contentString = getStringFromTypedArray(glb, jsonStart, contentLength);
- var gltf = JSON.parse(contentString);
- addPipelineExtras(gltf);
+ var contentString = getStringFromTypedArray(glb, jsonStart, contentLength);
+ var gltf = JSON.parse(contentString);
+ addPipelineExtras(gltf);
- var binaryBuffer = glb.subarray(binaryStart, length);
+ var binaryBuffer = glb.subarray(binaryStart, length);
- var buffers = gltf.buffers;
- if (defined(buffers) && Object.keys(buffers).length > 0) {
- // In some older models, the binary glTF buffer is named KHR_binary_glTF
- var binaryGltfBuffer = defaultValue(buffers.binary_glTF, buffers.KHR_binary_glTF);
- if (defined(binaryGltfBuffer)) {
- binaryGltfBuffer.extras._pipeline.source = binaryBuffer;
- }
+ var buffers = gltf.buffers;
+ if (defined(buffers) && Object.keys(buffers).length > 0) {
+ // In some older models, the binary glTF buffer is named KHR_binary_glTF
+ var binaryGltfBuffer = defaultValue(buffers.binary_glTF, buffers.KHR_binary_glTF);
+ if (defined(binaryGltfBuffer)) {
+ binaryGltfBuffer.extras._pipeline.source = binaryBuffer;
}
- // Remove the KHR_binary_glTF extension
- removeExtensionsUsed(gltf, 'KHR_binary_glTF');
- return gltf;
}
+ // Remove the KHR_binary_glTF extension
+ removeExtensionsUsed(gltf, 'KHR_binary_glTF');
+ return gltf;
+}
- function parseGlbVersion2(glb, header) {
- var length = header[2];
- var byteOffset = 12;
- var gltf;
- var binaryBuffer;
- while (byteOffset < length) {
- var chunkHeader = readHeader(glb, byteOffset, 2);
- var chunkLength = chunkHeader[0];
- var chunkType = chunkHeader[1];
- byteOffset += 8;
- var chunkBuffer = glb.subarray(byteOffset, byteOffset + chunkLength);
- byteOffset += chunkLength;
- // Load JSON chunk
- if (chunkType === 0x4E4F534A) {
- var jsonString = getStringFromTypedArray(chunkBuffer);
- gltf = JSON.parse(jsonString);
- addPipelineExtras(gltf);
- }
- // Load Binary chunk
- else if (chunkType === 0x004E4942) {
- binaryBuffer = chunkBuffer;
- }
+function parseGlbVersion2(glb, header) {
+ var length = header[2];
+ var byteOffset = 12;
+ var gltf;
+ var binaryBuffer;
+ while (byteOffset < length) {
+ var chunkHeader = readHeader(glb, byteOffset, 2);
+ var chunkLength = chunkHeader[0];
+ var chunkType = chunkHeader[1];
+ byteOffset += 8;
+ var chunkBuffer = glb.subarray(byteOffset, byteOffset + chunkLength);
+ byteOffset += chunkLength;
+ // Load JSON chunk
+ if (chunkType === 0x4E4F534A) {
+ var jsonString = getStringFromTypedArray(chunkBuffer);
+ gltf = JSON.parse(jsonString);
+ addPipelineExtras(gltf);
}
- if (defined(gltf) && defined(binaryBuffer)) {
- var buffers = gltf.buffers;
- if (defined(buffers) && buffers.length > 0) {
- var buffer = buffers[0];
- buffer.extras._pipeline.source = binaryBuffer;
- }
+ // Load Binary chunk
+ else if (chunkType === 0x004E4942) {
+ binaryBuffer = chunkBuffer;
+ }
+ }
+ if (defined(gltf) && defined(binaryBuffer)) {
+ var buffers = gltf.buffers;
+ if (defined(buffers) && buffers.length > 0) {
+ var buffer = buffers[0];
+ buffer.extras._pipeline.source = binaryBuffer;
}
- return gltf;
}
+ return gltf;
+}
- export default parseGlb;
+export default parseGlb;
diff --git a/Source/ThirdParty/GltfPipeline/readAccessorPacked.js b/Source/ThirdParty/GltfPipeline/readAccessorPacked.js
index 6225e4f545b..bd51a15a0ca 100644
--- a/Source/ThirdParty/GltfPipeline/readAccessorPacked.js
+++ b/Source/ThirdParty/GltfPipeline/readAccessorPacked.js
@@ -5,43 +5,43 @@ import arrayFill from '../../Core/arrayFill.js'
import ComponentDatatype from '../../Core/ComponentDatatype.js'
import defined from '../../Core/defined.js'
- /**
- * Returns the accessor data in a contiguous array.
- *
- * @param {Object} gltf A javascript object containing a glTF asset.
- * @param {Object} accessor The accessor.
- * @returns {Array} The accessor values in a contiguous array.
- *
- * @private
- */
- function readAccessorPacked(gltf, accessor) {
- var byteStride = getAccessorByteStride(gltf, accessor);
- var componentTypeByteLength = ComponentDatatype.getSizeInBytes(accessor.componentType);
- var numberOfComponents = numberOfComponentsForType(accessor.type);
- var count = accessor.count;
- var values = new Array(numberOfComponents * count);
+/**
+ * Returns the accessor data in a contiguous array.
+ *
+ * @param {Object} gltf A javascript object containing a glTF asset.
+ * @param {Object} accessor The accessor.
+ * @returns {Array} The accessor values in a contiguous array.
+ *
+ * @private
+ */
+function readAccessorPacked(gltf, accessor) {
+ var byteStride = getAccessorByteStride(gltf, accessor);
+ var componentTypeByteLength = ComponentDatatype.getSizeInBytes(accessor.componentType);
+ var numberOfComponents = numberOfComponentsForType(accessor.type);
+ var count = accessor.count;
+ var values = new Array(numberOfComponents * count);
- if (!defined(accessor.bufferView)) {
- arrayFill(values, 0);
- return values;
- }
+ if (!defined(accessor.bufferView)) {
+ arrayFill(values, 0);
+ return values;
+ }
- var bufferView = gltf.bufferViews[accessor.bufferView];
- var source = gltf.buffers[bufferView.buffer].extras._pipeline.source;
- var byteOffset = accessor.byteOffset + bufferView.byteOffset + source.byteOffset;
+ var bufferView = gltf.bufferViews[accessor.bufferView];
+ var source = gltf.buffers[bufferView.buffer].extras._pipeline.source;
+ var byteOffset = accessor.byteOffset + bufferView.byteOffset + source.byteOffset;
- var dataView = new DataView(source.buffer);
- var components = new Array(numberOfComponents);
- var componentReader = getComponentReader(accessor.componentType);
+ var dataView = new DataView(source.buffer);
+ var components = new Array(numberOfComponents);
+ var componentReader = getComponentReader(accessor.componentType);
- for (var i = 0; i < count; ++i) {
- componentReader(dataView, byteOffset, numberOfComponents, componentTypeByteLength, components);
- for (var j = 0; j < numberOfComponents; ++j) {
- values[i * numberOfComponents + j] = components[j];
- }
- byteOffset += byteStride;
+ for (var i = 0; i < count; ++i) {
+ componentReader(dataView, byteOffset, numberOfComponents, componentTypeByteLength, components);
+ for (var j = 0; j < numberOfComponents; ++j) {
+ values[i * numberOfComponents + j] = components[j];
}
- return values;
+ byteOffset += byteStride;
}
+ return values;
+}
- export default readAccessorPacked;
+export default readAccessorPacked;
diff --git a/Source/ThirdParty/GltfPipeline/removeExtensionsRequired.js b/Source/ThirdParty/GltfPipeline/removeExtensionsRequired.js
index ba60c821152..baa5315a14e 100644
--- a/Source/ThirdParty/GltfPipeline/removeExtensionsRequired.js
+++ b/Source/ThirdParty/GltfPipeline/removeExtensionsRequired.js
@@ -1,24 +1,24 @@
import defined from '../../Core/defined.js'
- /**
- * Removes an extension from gltf.extensionsRequired if it is present.
- *
- * @param {Object} gltf A javascript object containing a glTF asset.
- * @param {String} extension The extension to remove.
- *
- * @private
- */
- function removeExtensionsRequired(gltf, extension) {
- var extensionsRequired = gltf.extensionsRequired;
- if (defined(extensionsRequired)) {
- var index = extensionsRequired.indexOf(extension);
- if (index >= 0) {
- extensionsRequired.splice(index, 1);
- }
- if (extensionsRequired.length === 0) {
- delete gltf.extensionsRequired;
- }
+/**
+ * Removes an extension from gltf.extensionsRequired if it is present.
+ *
+ * @param {Object} gltf A javascript object containing a glTF asset.
+ * @param {String} extension The extension to remove.
+ *
+ * @private
+ */
+function removeExtensionsRequired(gltf, extension) {
+ var extensionsRequired = gltf.extensionsRequired;
+ if (defined(extensionsRequired)) {
+ var index = extensionsRequired.indexOf(extension);
+ if (index >= 0) {
+ extensionsRequired.splice(index, 1);
+ }
+ if (extensionsRequired.length === 0) {
+ delete gltf.extensionsRequired;
}
}
+}
- export default removeExtensionsRequired;
+export default removeExtensionsRequired;
diff --git a/Source/ThirdParty/GltfPipeline/removeExtensionsUsed.js b/Source/ThirdParty/GltfPipeline/removeExtensionsUsed.js
index 83f8aad1ee3..eb4313b1e7c 100644
--- a/Source/ThirdParty/GltfPipeline/removeExtensionsUsed.js
+++ b/Source/ThirdParty/GltfPipeline/removeExtensionsUsed.js
@@ -1,26 +1,26 @@
import removeExtensionsRequired from './removeExtensionsRequired.js'
import defined from '../../Core/defined.js'
- /**
- * Removes an extension from gltf.extensionsUsed and gltf.extensionsRequired if it is present.
- *
- * @param {Object} gltf A javascript object containing a glTF asset.
- * @param {String} extension The extension to remove.
- *
- * @private
- */
- function removeExtensionsUsed(gltf, extension) {
- var extensionsUsed = gltf.extensionsUsed;
- if (defined(extensionsUsed)) {
- var index = extensionsUsed.indexOf(extension);
- if (index >= 0) {
- extensionsUsed.splice(index, 1);
- }
- removeExtensionsRequired(gltf, extension);
- if (extensionsUsed.length === 0) {
- delete gltf.extensionsUsed;
- }
+/**
+ * Removes an extension from gltf.extensionsUsed and gltf.extensionsRequired if it is present.
+ *
+ * @param {Object} gltf A javascript object containing a glTF asset.
+ * @param {String} extension The extension to remove.
+ *
+ * @private
+ */
+function removeExtensionsUsed(gltf, extension) {
+ var extensionsUsed = gltf.extensionsUsed;
+ if (defined(extensionsUsed)) {
+ var index = extensionsUsed.indexOf(extension);
+ if (index >= 0) {
+ extensionsUsed.splice(index, 1);
+ }
+ removeExtensionsRequired(gltf, extension);
+ if (extensionsUsed.length === 0) {
+ delete gltf.extensionsUsed;
}
}
+}
- export default removeExtensionsUsed;
+export default removeExtensionsUsed;
diff --git a/Source/ThirdParty/GltfPipeline/removePipelineExtras.js b/Source/ThirdParty/GltfPipeline/removePipelineExtras.js
index 25fcbf760e8..7ffa353eb3b 100644
--- a/Source/ThirdParty/GltfPipeline/removePipelineExtras.js
+++ b/Source/ThirdParty/GltfPipeline/removePipelineExtras.js
@@ -1,45 +1,42 @@
import ForEach from './ForEach.js'
import defined from '../../Core/defined.js'
- /**
- * Iterate through the objects within the glTF and delete their pipeline extras object.
- *
- * @param {Object} gltf A javascript object containing a glTF asset.
- * @returns {Object} glTF with no pipeline extras.
- *
- * @private
- */
- function removePipelineExtras(gltf) {
- ForEach.shader(gltf, function(shader) {
- removeExtras(shader);
- });
- ForEach.buffer(gltf, function(buffer) {
- removeExtras(buffer);
- });
- ForEach.image(gltf, function (image) {
- removeExtras(image);
- ForEach.compressedImage(image, function(compressedImage) {
- removeExtras(compressedImage);
- });
- });
+/**
+ * Iterate through the objects within the glTF and delete their pipeline extras object.
+ *
+ * @param {Object} gltf A javascript object containing a glTF asset.
+ * @returns {Object} glTF with no pipeline extras.
+ *
+ * @private
+ */
+function removePipelineExtras(gltf) {
+ ForEach.shader(gltf, function(shader) {
+ removeExtras(shader);
+ });
+ ForEach.buffer(gltf, function(buffer) {
+ removeExtras(buffer);
+ });
+ ForEach.image(gltf, function (image) {
+ removeExtras(image);
+ });
- removeExtras(gltf);
+ removeExtras(gltf);
- return gltf;
- }
+ return gltf;
+}
- function removeExtras(object) {
- if (!defined(object.extras)) {
- return;
- }
+function removeExtras(object) {
+ if (!defined(object.extras)) {
+ return;
+ }
- if (defined(object.extras._pipeline)) {
- delete object.extras._pipeline;
- }
+ if (defined(object.extras._pipeline)) {
+ delete object.extras._pipeline;
+ }
- if (Object.keys(object.extras).length === 0) {
- delete object.extras;
- }
+ if (Object.keys(object.extras).length === 0) {
+ delete object.extras;
}
+}
- export default removePipelineExtras;
+export default removePipelineExtras;
diff --git a/Source/ThirdParty/GltfPipeline/removeUnusedElements.js b/Source/ThirdParty/GltfPipeline/removeUnusedElements.js
index 628be650185..912a58416a9 100644
--- a/Source/ThirdParty/GltfPipeline/removeUnusedElements.js
+++ b/Source/ThirdParty/GltfPipeline/removeUnusedElements.js
@@ -1,428 +1,521 @@
import ForEach from './ForEach.js'
+import forEachTextureInMaterial from './forEachTextureInMaterial.js'
import hasExtension from './hasExtension.js'
import defaultValue from '../../Core/defaultValue.js'
import defined from '../../Core/defined.js'
- var allElementTypes = ['mesh', 'node', 'material', 'accessor', 'bufferView', 'buffer'];
-
- /**
- * Removes unused elements from gltf.
- *
- * @param {Object} gltf A javascript object containing a glTF asset.
- * @param {String[]} [elementTypes=['mesh', 'node', 'material', 'accessor', 'bufferView', 'buffer']] Element types to be removed. Needs to be a subset of ['mesh', 'node', 'material', 'accessor', 'bufferView', 'buffer'], other items will be ignored.
- *
- * @private
- */
- function removeUnusedElements(gltf, elementTypes) {
- elementTypes = defaultValue(elementTypes, allElementTypes);
- allElementTypes.forEach(function(type) {
- if (elementTypes.indexOf(type) > -1) {
- removeUnusedElementsByType(gltf, type);
- }
- });
- return gltf;
- }
-
- var TypeToGltfElementName = {
- accessor: 'accessors',
- buffer: 'buffers',
- bufferView: 'bufferViews',
- node: 'nodes',
- material: 'materials',
- mesh: 'meshes'
- };
-
- function removeUnusedElementsByType(gltf, type) {
- var name = TypeToGltfElementName[type];
- var arrayOfObjects = gltf[name];
-
- if (defined(arrayOfObjects)) {
- var removed = 0;
- var usedIds = getListOfElementsIdsInUse[type](gltf);
- var length = arrayOfObjects.length;
-
- for (var i = 0; i < length; ++i) {
- if (!usedIds[i]) {
- Remove[type](gltf, i - removed);
- removed++;
- }
+var allElementTypes = ['mesh', 'node', 'material', 'accessor', 'bufferView', 'buffer', 'texture', 'sampler', 'image'];
+
+/**
+ * Removes unused elements from gltf.
+ *
+ * @param {Object} gltf A javascript object containing a glTF asset.
+ * @param {String[]} [elementTypes=['mesh', 'node', 'material', 'accessor', 'bufferView', 'buffer']] Element types to be removed. Needs to be a subset of ['mesh', 'node', 'material', 'accessor', 'bufferView', 'buffer'], other items will be ignored.
+ *
+ * @private
+ */
+function removeUnusedElements(gltf, elementTypes) {
+ elementTypes = defaultValue(elementTypes, allElementTypes);
+ allElementTypes.forEach(function(type) {
+ if (elementTypes.indexOf(type) > -1) {
+ removeUnusedElementsByType(gltf, type);
+ }
+ });
+ return gltf;
+}
+
+var TypeToGltfElementName = {
+ accessor: 'accessors',
+ buffer: 'buffers',
+ bufferView: 'bufferViews',
+ image: 'images',
+ node: 'nodes',
+ material: 'materials',
+ mesh: 'meshes',
+ sampler: 'samplers',
+ texture: 'textures'
+};
+
+function removeUnusedElementsByType(gltf, type) {
+ var name = TypeToGltfElementName[type];
+ var arrayOfObjects = gltf[name];
+
+ if (defined(arrayOfObjects)) {
+ var removed = 0;
+ var usedIds = getListOfElementsIdsInUse[type](gltf);
+ var length = arrayOfObjects.length;
+
+ for (var i = 0; i < length; ++i) {
+ if (!usedIds[i]) {
+ Remove[type](gltf, i - removed);
+ removed++;
}
}
}
+}
+
+/**
+ * Contains functions for removing elements from a glTF hierarchy.
+ * Since top-level glTF elements are arrays, when something is removed, referring
+ * indices need to be updated.
+ * @constructor
+ *
+ * @private
+ */
+function Remove() {}
+
+Remove.accessor = function(gltf, accessorId) {
+ var accessors = gltf.accessors;
+
+ accessors.splice(accessorId, 1);
+
+ ForEach.mesh(gltf, function(mesh) {
+ ForEach.meshPrimitive(mesh, function(primitive) {
+ // Update accessor ids for the primitives.
+ ForEach.meshPrimitiveAttribute(primitive, function(attributeAccessorId, semantic) {
+ if (attributeAccessorId > accessorId) {
+ primitive.attributes[semantic]--;
+ }
+ });
- /**
- * Contains functions for removing elements from a glTF hierarchy.
- * Since top-level glTF elements are arrays, when something is removed, referring
- * indices need to be updated.
- * @constructor
- *
- * @private
- */
- function Remove() {}
-
- Remove.accessor = function(gltf, accessorId) {
- var accessors = gltf.accessors;
-
- accessors.splice(accessorId, 1);
-
- ForEach.mesh(gltf, function(mesh) {
- ForEach.meshPrimitive(mesh, function(primitive) {
- // Update accessor ids for the primitives.
- ForEach.meshPrimitiveAttribute(primitive, function(attributeAccessorId, semantic) {
+ // Update accessor ids for the targets.
+ ForEach.meshPrimitiveTarget(primitive, function(target) {
+ ForEach.meshPrimitiveTargetAttribute(target, function(attributeAccessorId, semantic) {
if (attributeAccessorId > accessorId) {
- primitive.attributes[semantic]--;
+ target[semantic]--;
}
});
-
- // Update accessor ids for the targets.
- ForEach.meshPrimitiveTarget(primitive, function(target) {
- ForEach.meshPrimitiveTargetAttribute(target, function(attributeAccessorId, semantic) {
- if (attributeAccessorId > accessorId) {
- target[semantic]--;
- }
- });
- });
- var indices = primitive.indices;
- if (defined(indices) && indices > accessorId) {
- primitive.indices--;
- }
});
+ var indices = primitive.indices;
+ if (defined(indices) && indices > accessorId) {
+ primitive.indices--;
+ }
});
+ });
+
+ ForEach.skin(gltf, function(skin) {
+ if (defined(skin.inverseBindMatrices) && skin.inverseBindMatrices > accessorId) {
+ skin.inverseBindMatrices--;
+ }
+ });
- ForEach.skin(gltf, function(skin) {
- if (defined(skin.inverseBindMatrices) && skin.inverseBindMatrices > accessorId) {
- skin.inverseBindMatrices--;
+ ForEach.animation(gltf, function(animation) {
+ ForEach.animationSampler(animation, function(sampler) {
+ if (defined(sampler.input) && sampler.input > accessorId) {
+ sampler.input--;
+ }
+ if (defined(sampler.output) && sampler.output > accessorId) {
+ sampler.output--;
}
});
+ });
+};
- ForEach.animation(gltf, function(animation) {
- ForEach.animationSampler(animation, function(sampler) {
- if (defined(sampler.input) && sampler.input > accessorId) {
- sampler.input--;
- }
- if (defined(sampler.output) && sampler.output > accessorId) {
- sampler.output--;
+Remove.buffer = function(gltf, bufferId) {
+ var buffers = gltf.buffers;
+
+ buffers.splice(bufferId, 1);
+
+ ForEach.bufferView(gltf, function(bufferView) {
+ if (defined(bufferView.buffer) && bufferView.buffer > bufferId) {
+ bufferView.buffer--;
+ }
+ });
+};
+
+Remove.bufferView = function(gltf, bufferViewId) {
+ var bufferViews = gltf.bufferViews;
+
+ bufferViews.splice(bufferViewId, 1);
+
+ ForEach.accessor(gltf, function(accessor) {
+ if (defined(accessor.bufferView) && accessor.bufferView > bufferViewId) {
+ accessor.bufferView--;
+ }
+ });
+
+ ForEach.shader(gltf, function(shader) {
+ if (defined(shader.bufferView) && shader.bufferView > bufferViewId) {
+ shader.bufferView--;
+ }
+ });
+
+ ForEach.image(gltf, function(image) {
+ if (defined(image.bufferView) && image.bufferView > bufferViewId) {
+ image.bufferView--;
+ }
+ });
+
+ if (hasExtension(gltf, 'KHR_draco_mesh_compression')) {
+ ForEach.mesh(gltf, function(mesh) {
+ ForEach.meshPrimitive(mesh, function(primitive) {
+ if (defined(primitive.extensions) &&
+ defined(primitive.extensions.KHR_draco_mesh_compression)) {
+ if (primitive.extensions.KHR_draco_mesh_compression.bufferView > bufferViewId) {
+ primitive.extensions.KHR_draco_mesh_compression.bufferView--;
+ }
}
});
});
- };
-
- Remove.buffer = function(gltf, bufferId) {
- var buffers = gltf.buffers;
+ }
+};
- buffers.splice(bufferId, 1);
+Remove.image = function(gltf, imageId) {
+ var images = gltf.images;
+ images.splice(imageId, 1);
- ForEach.bufferView(gltf, function(bufferView) {
- if (defined(bufferView.buffer) && bufferView.buffer > bufferId) {
- bufferView.buffer--;
+ ForEach.texture(gltf, function (texture) {
+ if (defined(texture.source)) {
+ if (texture.source > imageId) {
+ --texture.source;
}
- });
- };
+ }
+ var ext = texture.extensions;
+ if (defined(ext) && defined(ext.EXT_texture_webp) && ext.EXT_texture_webp.source > imageId) {
+ --texture.extensions.EXT_texture_webp.source;
+ } else if (defined(ext) && defined(ext.KHR_texture_basisu) && ext.KHR_texture_basisu.source > imageId) {
+ --texture.extensions.KHR_texture_basisu.source;
+ }
+ });
+};
+
+Remove.mesh = function(gltf, meshId) {
+ var meshes = gltf.meshes;
+ meshes.splice(meshId, 1);
+
+ ForEach.node(gltf, function(node) {
+ if (defined(node.mesh)) {
+ if (node.mesh > meshId) {
+ node.mesh--;
+ } else if (node.mesh === meshId) {
+ // Remove reference to deleted mesh
+ delete node.mesh;
+ }
+ }
+ });
+};
- Remove.bufferView = function(gltf, bufferViewId) {
- var bufferViews = gltf.bufferViews;
+Remove.node = function(gltf, nodeId) {
+ var nodes = gltf.nodes;
+ nodes.splice(nodeId, 1);
- bufferViews.splice(bufferViewId, 1);
+ // Shift all node references
+ ForEach.skin(gltf, function(skin) {
+ if (defined(skin.skeleton) && skin.skeleton > nodeId) {
+ skin.skeleton--;
+ }
- ForEach.accessor(gltf, function(accessor) {
- if (defined(accessor.bufferView) && accessor.bufferView > bufferViewId) {
- accessor.bufferView--;
- }
+ skin.joints = skin.joints.map(function(x) {
+ return x > nodeId ? x - 1 : x;
});
-
- ForEach.shader(gltf, function(shader) {
- if (defined(shader.bufferView) && shader.bufferView > bufferViewId) {
- shader.bufferView--;
+ });
+ ForEach.animation(gltf, function(animation) {
+ ForEach.animationChannel(animation, function(channel) {
+ if (defined(channel.target) && defined(channel.target.node) && (channel.target.node > nodeId)) {
+ channel.target.node--;
}
});
-
- ForEach.image(gltf, function(image) {
- if (defined(image.bufferView) && image.bufferView > bufferViewId) {
- image.bufferView--;
+ });
+ ForEach.technique(gltf, function(technique) {
+ ForEach.techniqueUniform(technique, function(uniform) {
+ if (defined(uniform.node) && uniform.node > nodeId) {
+ uniform.node--;
}
- ForEach.compressedImage(image, function(compressedImage) {
- var compressedImageBufferView = compressedImage.bufferView;
- if (defined(compressedImageBufferView) && compressedImageBufferView > bufferViewId) {
- compressedImage.bufferView--;
- }
- });
});
-
- if (hasExtension(gltf, 'KHR_draco_mesh_compression')) {
- ForEach.mesh(gltf, function(mesh) {
- ForEach.meshPrimitive(mesh, function(primitive) {
- if (defined(primitive.extensions) &&
- defined(primitive.extensions.KHR_draco_mesh_compression)) {
- if (primitive.extensions.KHR_draco_mesh_compression.bufferView > bufferViewId) {
- primitive.extensions.KHR_draco_mesh_compression.bufferView--;
- }
- }
- });
- });
+ });
+ ForEach.node(gltf, function(node) {
+ if (!defined(node.children)) {
+ return;
}
- };
-
- Remove.mesh = function(gltf, meshId) {
- var meshes = gltf.meshes;
- meshes.splice(meshId, 1);
- ForEach.node(gltf, function(node) {
- if (defined(node.mesh)) {
- if (node.mesh > meshId) {
- node.mesh--;
- } else if (node.mesh === meshId) {
- // Remove reference to deleted mesh
- delete node.mesh;
- }
+ node.children = node.children
+ .filter(function(x) {
+ return x !== nodeId; // Remove
+ })
+ .map(function(x) {
+ return x > nodeId ? x - 1 : x; // Shift indices
+ });
+ });
+ ForEach.scene(gltf, function(scene) {
+ scene.nodes = scene.nodes
+ .filter(function(x) {
+ return x !== nodeId; // Remove
+ })
+ .map(function(x) {
+ return x > nodeId ? x - 1 : x; // Shift indices
+ });
+ });
+};
+
+Remove.material = function(gltf, materialId) {
+ var materials = gltf.materials;
+ materials.splice(materialId, 1);
+
+ // Shift other material ids
+ ForEach.mesh(gltf, function(mesh) {
+ ForEach.meshPrimitive(mesh, function(primitive) {
+ if (defined(primitive.material) && primitive.material > materialId) {
+ primitive.material--;
}
});
- };
+ });
+};
- Remove.node = function(gltf, nodeId) {
- var nodes = gltf.nodes;
- nodes.splice(nodeId, 1);
+Remove.sampler = function(gltf, samplerId) {
+ var samplers = gltf.samplers;
+ samplers.splice(samplerId, 1);
- // Shift all node references
- ForEach.skin(gltf, function(skin) {
- if (defined(skin.skeleton) && skin.skeleton > nodeId) {
- skin.skeleton--;
+ ForEach.texture(gltf, function (texture) {
+ if (defined(texture.sampler)) {
+ if (texture.sampler > samplerId) {
+ --texture.sampler;
}
+ }
+ });
+};
- skin.joints = skin.joints.map(function(x) {
- return x > nodeId ? x - 1 : x;
- });
+Remove.texture = function(gltf, textureId) {
+ var textures = gltf.textures;
+ textures.splice(textureId, 1);
+
+ ForEach.material(gltf, function (material) {
+ forEachTextureInMaterial(material, function (textureIndex, textureInfo) {
+ if (textureInfo.index > textureId) {
+ --textureInfo.index;
+ }
});
- ForEach.animation(gltf, function(animation) {
- ForEach.animationChannel(animation, function(channel) {
- if (defined(channel.target) && defined(channel.target.node) && (channel.target.node > nodeId)) {
- channel.target.node--;
- }
+ });
+};
+
+/**
+ * Contains functions for getting a list of element ids in use by the glTF asset.
+ * @constructor
+ *
+ * @private
+ */
+function getListOfElementsIdsInUse() {}
+
+getListOfElementsIdsInUse.accessor = function(gltf) {
+ // Calculate accessor's that are currently in use.
+ var usedAccessorIds = {};
+
+ ForEach.mesh(gltf, function(mesh) {
+ ForEach.meshPrimitive(mesh, function(primitive) {
+ ForEach.meshPrimitiveAttribute(primitive, function(accessorId) {
+ usedAccessorIds[accessorId] = true;
});
- });
- ForEach.technique(gltf, function(technique) {
- ForEach.techniqueUniform(technique, function(uniform) {
- if (defined(uniform.node) && uniform.node > nodeId) {
- uniform.node--;
- }
+ ForEach.meshPrimitiveTarget(primitive, function(target) {
+ ForEach.meshPrimitiveTargetAttribute(target, function(accessorId) {
+ usedAccessorIds[accessorId] = true;
+ });
});
- });
- ForEach.node(gltf, function(node) {
- if (!defined(node.children)) {
- return;
+ var indices = primitive.indices;
+ if (defined(indices)) {
+ usedAccessorIds[indices] = true;
}
+ });
+ });
- node.children = node.children
- .filter(function(x) {
- return x !== nodeId; // Remove
- })
- .map(function(x) {
- return x > nodeId ? x - 1 : x; // Shift indices
- });
+ ForEach.skin(gltf, function(skin) {
+ if (defined(skin.inverseBindMatrices)) {
+ usedAccessorIds[skin.inverseBindMatrices] = true;
+ }
+ });
+
+ ForEach.animation(gltf, function(animation) {
+ ForEach.animationSampler(animation, function(sampler) {
+ if (defined(sampler.input)) {
+ usedAccessorIds[sampler.input] = true;
+ }
+ if (defined(sampler.output)) {
+ usedAccessorIds[sampler.output] = true;
+ }
});
- ForEach.scene(gltf, function(scene) {
- scene.nodes = scene.nodes
- .filter(function(x) {
- return x !== nodeId; // Remove
- })
- .map(function(x) {
- return x > nodeId ? x - 1 : x; // Shift indices
+ });
+
+ if (hasExtension(gltf, 'EXT_mesh_gpu_instancing')) {
+ ForEach.node(gltf, function(node) {
+ if (defined(node.extensions) && defined(node.extensions.EXT_mesh_gpu_instancing)) {
+ Object.keys(node.extensions.EXT_mesh_gpu_instancing.attributes).forEach(function(key) {
+ var attributeAccessorId = node.extensions.EXT_mesh_gpu_instancing.attributes[key];
+ usedAccessorIds[attributeAccessorId] = true;
});
+ }
});
- };
+ }
- Remove.material = function(gltf, materialId) {
- var materials = gltf.materials;
- materials.splice(materialId, 1);
+ return usedAccessorIds;
+};
- // Shift other material ids
- ForEach.mesh(gltf, function(mesh) {
- ForEach.meshPrimitive(mesh, function(primitive) {
- if (defined(primitive.material) && primitive.material > materialId) {
- primitive.material--;
- }
- });
- });
- };
+getListOfElementsIdsInUse.buffer = function(gltf) {
+ // Calculate buffer's that are currently in use.
+ var usedBufferIds = {};
- /**
- * Contains functions for getting a list of element ids in use by the glTF asset.
- * @constructor
- *
- * @private
- */
- function getListOfElementsIdsInUse() {}
+ ForEach.bufferView(gltf, function(bufferView) {
+ if (defined(bufferView.buffer)) {
+ usedBufferIds[bufferView.buffer] = true;
+ }
+ });
- getListOfElementsIdsInUse.accessor = function(gltf) {
- // Calculate accessor's that are currently in use.
- var usedAccessorIds = {};
+ return usedBufferIds;
+};
+getListOfElementsIdsInUse.bufferView = function(gltf) {
+ // Calculate bufferView's that are currently in use.
+ var usedBufferViewIds = {};
+
+ ForEach.accessor(gltf, function(accessor) {
+ if (defined(accessor.bufferView)) {
+ usedBufferViewIds[accessor.bufferView] = true;
+ }
+ });
+
+ ForEach.shader(gltf, function(shader) {
+ if (defined(shader.bufferView)) {
+ usedBufferViewIds[shader.bufferView] = true;
+ }
+ });
+
+ ForEach.image(gltf, function(image) {
+ if (defined(image.bufferView)) {
+ usedBufferViewIds[image.bufferView] = true;
+ }
+ });
+
+ if (hasExtension(gltf, 'KHR_draco_mesh_compression')) {
ForEach.mesh(gltf, function(mesh) {
ForEach.meshPrimitive(mesh, function(primitive) {
- ForEach.meshPrimitiveAttribute(primitive, function(accessorId) {
- usedAccessorIds[accessorId] = true;
- });
- ForEach.meshPrimitiveTarget(primitive, function(target) {
- ForEach.meshPrimitiveTargetAttribute(target, function(accessorId) {
- usedAccessorIds[accessorId] = true;
- });
- });
- var indices = primitive.indices;
- if (defined(indices)) {
- usedAccessorIds[indices] = true;
+ if (defined(primitive.extensions) &&
+ defined(primitive.extensions.KHR_draco_mesh_compression)) {
+ usedBufferViewIds[primitive.extensions.KHR_draco_mesh_compression.bufferView] = true;
}
});
});
+ }
- ForEach.skin(gltf, function(skin) {
- if (defined(skin.inverseBindMatrices)) {
- usedAccessorIds[skin.inverseBindMatrices] = true;
- }
- });
+ return usedBufferViewIds;
+};
- ForEach.animation(gltf, function(animation) {
- ForEach.animationSampler(animation, function(sampler) {
- if (defined(sampler.input)) {
- usedAccessorIds[sampler.input] = true;
- }
- if (defined(sampler.output)) {
- usedAccessorIds[sampler.output] = true;
- }
- });
- });
+getListOfElementsIdsInUse.image = function(gltf) {
+ var usedImageIds = {};
- return usedAccessorIds;
- };
+ ForEach.texture(gltf, function (texture) {
+ if (defined(texture.source)) {
+ usedImageIds[texture.source] = true;
+ }
- getListOfElementsIdsInUse.buffer = function(gltf) {
- // Calculate buffer's that are currently in use.
- var usedBufferIds = {};
+ if (defined(texture.extensions) && defined(texture.extensions.EXT_texture_webp)) {
+ usedImageIds[texture.extensions.EXT_texture_webp.source] = true;
+ } else if (defined(texture.extensions) && defined(texture.extensions.KHR_texture_basisu)) {
+ usedImageIds[texture.extensions.KHR_texture_basisu.source] = true;
+ }
- ForEach.bufferView(gltf, function(bufferView) {
- if (defined(bufferView.buffer)) {
- usedBufferIds[bufferView.buffer] = true;
+ });
+ return usedImageIds;
+};
+
+getListOfElementsIdsInUse.mesh = function(gltf) {
+ var usedMeshIds = {};
+ ForEach.node(gltf, function(node) {
+ if (defined(node.mesh && defined(gltf.meshes))) {
+ var mesh = gltf.meshes[node.mesh];
+ if (defined(mesh) && defined(mesh.primitives) && (mesh.primitives.length > 0)) {
+ usedMeshIds[node.mesh] = true;
}
- });
-
- return usedBufferIds;
- };
+ }
+ });
+
+ return usedMeshIds;
+};
+
+// Check if node is empty. It is considered empty if neither referencing
+// mesh, camera, extensions and has no children
+function nodeIsEmpty(gltf, nodeId, usedNodeIds) {
+ var node = gltf.nodes[nodeId];
+ if (defined(node.mesh) || defined(node.camera) || defined(node.skin)
+ || defined(node.weights) || defined(node.extras)
+ || (defined(node.extensions) && Object.keys(node.extensions).length !== 0)
+ || defined(usedNodeIds[nodeId])) {
+ return false;
+ }
- getListOfElementsIdsInUse.bufferView = function(gltf) {
- // Calculate bufferView's that are currently in use.
- var usedBufferViewIds = {};
+ // Empty if no children or children are all empty nodes
+ return !defined(node.children)
+ || node.children.filter(function(n) {
+ return !nodeIsEmpty(gltf, n, usedNodeIds);
+ }).length === 0;
+}
+
+getListOfElementsIdsInUse.node = function(gltf) {
+ var usedNodeIds = {};
+ ForEach.skin(gltf, function(skin) {
+ if (defined(skin.skeleton)) {
+ usedNodeIds[skin.skeleton] = true;
+ }
- ForEach.accessor(gltf, function(accessor) {
- if (defined(accessor.bufferView)) {
- usedBufferViewIds[accessor.bufferView] = true;
- }
+ ForEach.skinJoint(skin, function(joint) {
+ usedNodeIds[joint] = true;
});
-
- ForEach.shader(gltf, function(shader) {
- if (defined(shader.bufferView)) {
- usedBufferViewIds[shader.bufferView] = true;
+ });
+ ForEach.animation(gltf, function(animation) {
+ ForEach.animationChannel(animation, function(channel) {
+ if (defined(channel.target) && defined(channel.target.node)) {
+ usedNodeIds[channel.target.node] = true;
}
});
-
- ForEach.image(gltf, function(image) {
- if (defined(image.bufferView)) {
- usedBufferViewIds[image.bufferView] = true;
+ });
+ ForEach.technique(gltf, function(technique) {
+ ForEach.techniqueUniform(technique, function(uniform) {
+ if (defined(uniform.node)) {
+ usedNodeIds[uniform.node] = true;
}
- ForEach.compressedImage(image, function(compressedImage) {
- if (defined(compressedImage.bufferView)) {
- usedBufferViewIds[compressedImage.bufferView] = true;
- }
- });
});
-
- if (hasExtension(gltf, 'KHR_draco_mesh_compression')) {
- ForEach.mesh(gltf, function(mesh) {
- ForEach.meshPrimitive(mesh, function(primitive) {
- if (defined(primitive.extensions) &&
- defined(primitive.extensions.KHR_draco_mesh_compression)) {
- usedBufferViewIds[primitive.extensions.KHR_draco_mesh_compression.bufferView] = true;
- }
- });
- });
+ });
+ ForEach.node(gltf, function(node, nodeId) {
+ if (!nodeIsEmpty(gltf, nodeId, usedNodeIds)) {
+ usedNodeIds[nodeId] = true;
}
+ });
- return usedBufferViewIds;
- };
+ return usedNodeIds;
+};
- getListOfElementsIdsInUse.mesh = function(gltf) {
- var usedMeshIds = {};
- ForEach.node(gltf, function(node) {
- if (defined(node.mesh && defined(gltf.meshes))) {
- var mesh = gltf.meshes[node.mesh];
- if (defined(mesh) && defined(mesh.primitives) && (mesh.primitives.length > 0)) {
- usedMeshIds[node.mesh] = true;
- }
+getListOfElementsIdsInUse.material = function(gltf) {
+ var usedMaterialIds = {};
+
+ ForEach.mesh(gltf, function(mesh) {
+ ForEach.meshPrimitive(mesh, function(primitive) {
+ if (defined(primitive.material)) {
+ usedMaterialIds[primitive.material] = true;
}
});
+ });
- return usedMeshIds;
- };
-
- // Check if node is empty. It is considered empty if neither referencing
- // mesh, camera, extensions and has no children
- function nodeIsEmpty(gltf, node) {
- if (defined(node.mesh) || defined(node.camera) || defined(node.skin)
- || defined(node.weights) || defined(node.extras)
- || (defined(node.extensions) && node.extensions.length !== 0)) {
- return false;
- }
+ return usedMaterialIds;
+};
- // Empty if no children or children are all empty nodes
- return !defined(node.children)
- || node.children.filter(function(n) {
- return !nodeIsEmpty(gltf, gltf.nodes[n]);
- }).length === 0;
- }
+getListOfElementsIdsInUse.texture = function(gltf) {
+ var usedTextureIds = {};
- getListOfElementsIdsInUse.node = function(gltf) {
- var usedNodeIds = {};
- ForEach.node(gltf, function(node, nodeId) {
- if (!nodeIsEmpty(gltf, node)) {
- usedNodeIds[nodeId] = true;
- }
+ ForEach.material(gltf, function(material) {
+ forEachTextureInMaterial(material, function(textureId) {
+ usedTextureIds[textureId] = true;
});
- ForEach.skin(gltf, function(skin) {
- if (defined(skin.skeleton)) {
- usedNodeIds[skin.skeleton] = true;
- }
+ });
- ForEach.skinJoint(skin, function(joint) {
- usedNodeIds[joint] = true;
- });
- });
- ForEach.animation(gltf, function(animation) {
- ForEach.animationChannel(animation, function(channel) {
- if (defined(channel.target) && defined(channel.target.node)) {
- usedNodeIds[channel.target.node] = true;
- }
- });
- });
- ForEach.technique(gltf, function(technique) {
- ForEach.techniqueUniform(technique, function(uniform) {
- if (defined(uniform.node)) {
- usedNodeIds[uniform.node] = true;
- }
- });
- });
-
- return usedNodeIds;
- };
+ return usedTextureIds;
+};
- getListOfElementsIdsInUse.material = function(gltf) {
- var usedMaterialIds = {};
+getListOfElementsIdsInUse.sampler = function(gltf) {
+ var usedSamplerIds = {};
- ForEach.mesh(gltf, function(mesh) {
- ForEach.meshPrimitive(mesh, function(primitive) {
- if (defined(primitive.material)) {
- usedMaterialIds[primitive.material] = true;
- }
- });
- });
+ ForEach.texture(gltf, function (texture) {
+ if (defined(texture.sampler)) {
+ usedSamplerIds[texture.sampler] = true;
+ }
+ });
- return usedMaterialIds;
- };
+ return usedSamplerIds;
+};
- export default removeUnusedElements;
+export default removeUnusedElements;
diff --git a/Source/ThirdParty/GltfPipeline/updateAccessorComponentTypes.js b/Source/ThirdParty/GltfPipeline/updateAccessorComponentTypes.js
index 1efcb7bfe76..585c1b1ad90 100644
--- a/Source/ThirdParty/GltfPipeline/updateAccessorComponentTypes.js
+++ b/Source/ThirdParty/GltfPipeline/updateAccessorComponentTypes.js
@@ -4,45 +4,45 @@ import readAccessorPacked from './readAccessorPacked.js'
import ComponentDatatype from '../../Core/ComponentDatatype.js'
import WebGLConstants from '../../Core/WebGLConstants.js'
- /**
- * Update accessors referenced by JOINTS_0 and WEIGHTS_0 attributes to use correct component types.
- *
- * @param {Object} gltf A javascript object containing a glTF asset.
- * @returns {Object} The glTF asset with compressed meshes.
- *
- * @private
- */
- function updateAccessorComponentTypes(gltf) {
- var componentType;
- ForEach.accessorWithSemantic(gltf, 'JOINTS_0', function(accessorId) {
- var accessor = gltf.accessors[accessorId];
- componentType = accessor.componentType;
- if (componentType === WebGLConstants.BYTE) {
- convertType(gltf, accessor, ComponentDatatype.UNSIGNED_BYTE);
- } else if (componentType !== WebGLConstants.UNSIGNED_BYTE
- && componentType !== WebGLConstants.UNSIGNED_SHORT) {
- convertType(gltf, accessor, ComponentDatatype.UNSIGNED_SHORT);
- }
- });
- ForEach.accessorWithSemantic(gltf, 'WEIGHTS_0', function(accessorId) {
- var accessor = gltf.accessors[accessorId];
- componentType = accessor.componentType;
- if (componentType === WebGLConstants.BYTE) {
- convertType(gltf, accessor, ComponentDatatype.UNSIGNED_BYTE);
- } else if (componentType === WebGLConstants.SHORT) {
- convertType(gltf, accessor, ComponentDatatype.UNSIGNED_SHORT);
- }
- });
+/**
+ * Update accessors referenced by JOINTS_0 and WEIGHTS_0 attributes to use correct component types.
+ *
+ * @param {Object} gltf A javascript object containing a glTF asset.
+ * @returns {Object} The glTF asset with compressed meshes.
+ *
+ * @private
+ */
+function updateAccessorComponentTypes(gltf) {
+ var componentType;
+ ForEach.accessorWithSemantic(gltf, 'JOINTS_0', function(accessorId) {
+ var accessor = gltf.accessors[accessorId];
+ componentType = accessor.componentType;
+ if (componentType === WebGLConstants.BYTE) {
+ convertType(gltf, accessor, ComponentDatatype.UNSIGNED_BYTE);
+ } else if (componentType !== WebGLConstants.UNSIGNED_BYTE
+ && componentType !== WebGLConstants.UNSIGNED_SHORT) {
+ convertType(gltf, accessor, ComponentDatatype.UNSIGNED_SHORT);
+ }
+ });
+ ForEach.accessorWithSemantic(gltf, 'WEIGHTS_0', function(accessorId) {
+ var accessor = gltf.accessors[accessorId];
+ componentType = accessor.componentType;
+ if (componentType === WebGLConstants.BYTE) {
+ convertType(gltf, accessor, ComponentDatatype.UNSIGNED_BYTE);
+ } else if (componentType === WebGLConstants.SHORT) {
+ convertType(gltf, accessor, ComponentDatatype.UNSIGNED_SHORT);
+ }
+ });
- return gltf;
- }
+ return gltf;
+}
- function convertType(gltf, accessor, updatedComponentType) {
- var typedArray = ComponentDatatype.createTypedArray(updatedComponentType, readAccessorPacked(gltf, accessor));
- var newBuffer = new Uint8Array(typedArray.buffer);
- accessor.bufferView = addBuffer(gltf, newBuffer);
- accessor.componentType = updatedComponentType;
- accessor.byteOffset = 0;
- }
+function convertType(gltf, accessor, updatedComponentType) {
+ var typedArray = ComponentDatatype.createTypedArray(updatedComponentType, readAccessorPacked(gltf, accessor));
+ var newBuffer = new Uint8Array(typedArray.buffer);
+ accessor.bufferView = addBuffer(gltf, newBuffer);
+ accessor.componentType = updatedComponentType;
+ accessor.byteOffset = 0;
+}
- export default updateAccessorComponentTypes;
+export default updateAccessorComponentTypes;
diff --git a/Source/ThirdParty/GltfPipeline/updateVersion.js b/Source/ThirdParty/GltfPipeline/updateVersion.js
index dc4f91cf1cd..61f32ccd868 100644
--- a/Source/ThirdParty/GltfPipeline/updateVersion.js
+++ b/Source/ThirdParty/GltfPipeline/updateVersion.js
@@ -18,919 +18,905 @@ import Matrix4 from '../../Core/Matrix4.js'
import Quaternion from '../../Core/Quaternion.js'
import WebGLConstants from '../../Core/WebGLConstants.js'
- var updateFunctions = {
- '0.8': glTF08to10,
- '1.0': glTF10to20,
- '2.0': undefined
- };
-
- /**
- * Update the glTF version to the latest version (2.0), or targetVersion if specified.
- * Applies changes made to the glTF spec between revisions so that the core library
- * only has to handle the latest version.
- *
- * @param {Object} gltf A javascript object containing a glTF asset.
- * @param {Object} [options] Options for updating the glTF.
- * @param {String} [options.targetVersion] The glTF will be upgraded until it hits the specified version.
- * @returns {Object} The updated glTF asset.
- *
- * @private
- */
- function updateVersion(gltf, options) {
- options = defaultValue(options, defaultValue.EMPTY_OBJECT);
- var targetVersion = options.targetVersion;
- var version = gltf.version;
-
- gltf.asset = defaultValue(gltf.asset, {
- version: '1.0'
- });
-
- gltf.asset.version = defaultValue(gltf.asset.version, '1.0');
- version = defaultValue(version, gltf.asset.version).toString();
-
- // Invalid version
+var updateFunctions = {
+ '0.8': glTF08to10,
+ '1.0': glTF10to20,
+ '2.0': undefined
+};
+
+/**
+ * Update the glTF version to the latest version (2.0), or targetVersion if specified.
+ * Applies changes made to the glTF spec between revisions so that the core library
+ * only has to handle the latest version.
+ *
+ * @param {Object} gltf A javascript object containing a glTF asset.
+ * @param {Object} [options] Options for updating the glTF.
+ * @param {String} [options.targetVersion] The glTF will be upgraded until it hits the specified version.
+ * @returns {Object} The updated glTF asset.
+ *
+ * @private
+ */
+function updateVersion(gltf, options) {
+ options = defaultValue(options, defaultValue.EMPTY_OBJECT);
+ var targetVersion = options.targetVersion;
+ var version = gltf.version;
+
+ gltf.asset = defaultValue(gltf.asset, {
+ version: '1.0'
+ });
+
+ gltf.asset.version = defaultValue(gltf.asset.version, '1.0');
+ version = defaultValue(version, gltf.asset.version).toString();
+
+ // Invalid version
+ if (!Object.prototype.hasOwnProperty.call(updateFunctions, version)) {
+ // Try truncating trailing version numbers, could be a number as well if it is 0.8
+ if (defined(version)) {
+ version = version.substring(0, 3);
+ }
+ // Default to 1.0 if it cannot be determined
if (!Object.prototype.hasOwnProperty.call(updateFunctions, version)) {
- // Try truncating trailing version numbers, could be a number as well if it is 0.8
- if (defined(version)) {
- version = version.substring(0, 3);
- }
- // Default to 1.0 if it cannot be determined
- if (!Object.prototype.hasOwnProperty.call(updateFunctions, version)) {
- version = '1.0';
- }
+ version = '1.0';
}
+ }
- var updateFunction = updateFunctions[version];
+ var updateFunction = updateFunctions[version];
- while (defined(updateFunction)) {
- if (version === targetVersion) {
- break;
- }
- updateFunction(gltf, options);
- version = gltf.asset.version;
- updateFunction = updateFunctions[version];
+ while (defined(updateFunction)) {
+ if (version === targetVersion) {
+ break;
}
- return gltf;
+ updateFunction(gltf, options);
+ version = gltf.asset.version;
+ updateFunction = updateFunctions[version];
}
-
- function updateInstanceTechniques(gltf) {
- var materials = gltf.materials;
- for (var materialId in materials) {
- if (Object.prototype.hasOwnProperty.call(materials, materialId)) {
- var material = materials[materialId];
- var instanceTechnique = material.instanceTechnique;
- if (defined(instanceTechnique)) {
- material.technique = instanceTechnique.technique;
- material.values = instanceTechnique.values;
- delete material.instanceTechnique;
- }
+ return gltf;
+}
+
+function updateInstanceTechniques(gltf) {
+ var materials = gltf.materials;
+ for (var materialId in materials) {
+ if (Object.prototype.hasOwnProperty.call(materials, materialId)) {
+ var material = materials[materialId];
+ var instanceTechnique = material.instanceTechnique;
+ if (defined(instanceTechnique)) {
+ material.technique = instanceTechnique.technique;
+ material.values = instanceTechnique.values;
+ delete material.instanceTechnique;
}
}
}
-
- function setPrimitiveModes(gltf) {
- var meshes = gltf.meshes;
- for (var meshId in meshes) {
- if (Object.prototype.hasOwnProperty.call(meshes, meshId)) {
- var mesh = meshes[meshId];
- var primitives = mesh.primitives;
- if (defined(primitives)) {
- var primitivesLength = primitives.length;
- for (var i = 0; i < primitivesLength; ++i) {
- var primitive = primitives[i];
- var defaultMode = defaultValue(primitive.primitive, WebGLConstants.TRIANGLES);
- primitive.mode = defaultValue(primitive.mode, defaultMode);
- delete primitive.primitive;
- }
+}
+
+function setPrimitiveModes(gltf) {
+ var meshes = gltf.meshes;
+ for (var meshId in meshes) {
+ if (Object.prototype.hasOwnProperty.call(meshes, meshId)) {
+ var mesh = meshes[meshId];
+ var primitives = mesh.primitives;
+ if (defined(primitives)) {
+ var primitivesLength = primitives.length;
+ for (var i = 0; i < primitivesLength; ++i) {
+ var primitive = primitives[i];
+ var defaultMode = defaultValue(primitive.primitive, WebGLConstants.TRIANGLES);
+ primitive.mode = defaultValue(primitive.mode, defaultMode);
+ delete primitive.primitive;
}
}
}
}
-
- function updateNodes(gltf) {
- var nodes = gltf.nodes;
- var axis = new Cartesian3();
- var quat = new Quaternion();
- for (var nodeId in nodes) {
- if (Object.prototype.hasOwnProperty.call(nodes, nodeId)) {
- var node = nodes[nodeId];
- if (defined(node.rotation)) {
- var rotation = node.rotation;
- Cartesian3.fromArray(rotation, 0, axis);
- Quaternion.fromAxisAngle(axis, rotation[3], quat);
- node.rotation = [quat.x, quat.y, quat.z, quat.w];
- }
- var instanceSkin = node.instanceSkin;
- if (defined(instanceSkin)) {
- node.skeletons = instanceSkin.skeletons;
- node.skin = instanceSkin.skin;
- node.meshes = instanceSkin.meshes;
- delete node.instanceSkin;
- }
+}
+
+function updateNodes(gltf) {
+ var nodes = gltf.nodes;
+ var axis = new Cartesian3();
+ var quat = new Quaternion();
+ for (var nodeId in nodes) {
+ if (Object.prototype.hasOwnProperty.call(nodes, nodeId)) {
+ var node = nodes[nodeId];
+ if (defined(node.rotation)) {
+ var rotation = node.rotation;
+ Cartesian3.fromArray(rotation, 0, axis);
+ Quaternion.fromAxisAngle(axis, rotation[3], quat);
+ node.rotation = [quat.x, quat.y, quat.z, quat.w];
+ }
+ var instanceSkin = node.instanceSkin;
+ if (defined(instanceSkin)) {
+ node.skeletons = instanceSkin.skeletons;
+ node.skin = instanceSkin.skin;
+ node.meshes = instanceSkin.meshes;
+ delete node.instanceSkin;
}
}
}
-
- function updateAnimations(gltf) {
- var animations = gltf.animations;
- var accessors = gltf.accessors;
- var bufferViews = gltf.bufferViews;
- var buffers = gltf.buffers;
- var updatedAccessors = {};
- var axis = new Cartesian3();
- var quat = new Quaternion();
- for (var animationId in animations) {
- if (Object.prototype.hasOwnProperty.call(animations, animationId)) {
- var animation = animations[animationId];
- var channels = animation.channels;
- var parameters = animation.parameters;
- var samplers = animation.samplers;
- if (defined(channels)) {
- var channelsLength = channels.length;
- for (var i = 0; i < channelsLength; ++i) {
- var channel = channels[i];
- if (channel.target.path === 'rotation') {
- var accessorId = parameters[samplers[channel.sampler].output];
- if (defined(updatedAccessors[accessorId])) {
- continue;
- }
- updatedAccessors[accessorId] = true;
- var accessor = accessors[accessorId];
- var bufferView = bufferViews[accessor.bufferView];
- var buffer = buffers[bufferView.buffer];
- var source = buffer.extras._pipeline.source;
- var byteOffset = source.byteOffset + bufferView.byteOffset + accessor.byteOffset;
- var componentType = accessor.componentType;
- var count = accessor.count;
- var componentsLength = numberOfComponentsForType(accessor.type);
- var length = accessor.count * componentsLength;
- var typedArray = ComponentDatatype.createArrayBufferView(componentType, source.buffer, byteOffset, length);
-
- for (var j = 0; j < count; j++) {
- var offset = j * componentsLength;
- Cartesian3.unpack(typedArray, offset, axis);
- var angle = typedArray[offset + 3];
- Quaternion.fromAxisAngle(axis, angle, quat);
- Quaternion.pack(quat, typedArray, offset);
- }
+}
+
+function updateAnimations(gltf) {
+ var animations = gltf.animations;
+ var accessors = gltf.accessors;
+ var bufferViews = gltf.bufferViews;
+ var buffers = gltf.buffers;
+ var updatedAccessors = {};
+ var axis = new Cartesian3();
+ var quat = new Quaternion();
+ for (var animationId in animations) {
+ if (Object.prototype.hasOwnProperty.call(animations, animationId)) {
+ var animation = animations[animationId];
+ var channels = animation.channels;
+ var parameters = animation.parameters;
+ var samplers = animation.samplers;
+ if (defined(channels)) {
+ var channelsLength = channels.length;
+ for (var i = 0; i < channelsLength; ++i) {
+ var channel = channels[i];
+ if (channel.target.path === 'rotation') {
+ var accessorId = parameters[samplers[channel.sampler].output];
+ if (defined(updatedAccessors[accessorId])) {
+ continue;
+ }
+ updatedAccessors[accessorId] = true;
+ var accessor = accessors[accessorId];
+ var bufferView = bufferViews[accessor.bufferView];
+ var buffer = buffers[bufferView.buffer];
+ var source = buffer.extras._pipeline.source;
+ var byteOffset = source.byteOffset + bufferView.byteOffset + accessor.byteOffset;
+ var componentType = accessor.componentType;
+ var count = accessor.count;
+ var componentsLength = numberOfComponentsForType(accessor.type);
+ var length = accessor.count * componentsLength;
+ var typedArray = ComponentDatatype.createArrayBufferView(componentType, source.buffer, byteOffset, length);
+
+ for (var j = 0; j < count; j++) {
+ var offset = j * componentsLength;
+ Cartesian3.unpack(typedArray, offset, axis);
+ var angle = typedArray[offset + 3];
+ Quaternion.fromAxisAngle(axis, angle, quat);
+ Quaternion.pack(quat, typedArray, offset);
}
}
}
}
}
}
-
- function removeTechniquePasses(gltf) {
- var techniques = gltf.techniques;
- for (var techniqueId in techniques) {
- if (Object.prototype.hasOwnProperty.call(techniques, techniqueId)) {
- var technique = techniques[techniqueId];
- var passes = technique.passes;
- if (defined(passes)) {
- var passName = defaultValue(technique.pass, 'defaultPass');
- if (Object.prototype.hasOwnProperty.call(passes, passName)) {
- var pass = passes[passName];
- var instanceProgram = pass.instanceProgram;
- technique.attributes = defaultValue(technique.attributes, instanceProgram.attributes);
- technique.program = defaultValue(technique.program, instanceProgram.program);
- technique.uniforms = defaultValue(technique.uniforms, instanceProgram.uniforms);
- technique.states = defaultValue(technique.states, pass.states);
- }
- delete technique.passes;
- delete technique.pass;
- }
+}
+
+function removeTechniquePasses(gltf) {
+ var techniques = gltf.techniques;
+ for (var techniqueId in techniques) {
+ if (Object.prototype.hasOwnProperty.call(techniques, techniqueId)) {
+ var technique = techniques[techniqueId];
+ var passes = technique.passes;
+ if (defined(passes)) {
+ var passName = defaultValue(technique.pass, 'defaultPass');
+ if (Object.prototype.hasOwnProperty.call(passes, passName)) {
+ var pass = passes[passName];
+ var instanceProgram = pass.instanceProgram;
+ technique.attributes = defaultValue(technique.attributes, instanceProgram.attributes);
+ technique.program = defaultValue(technique.program, instanceProgram.program);
+ technique.uniforms = defaultValue(technique.uniforms, instanceProgram.uniforms);
+ technique.states = defaultValue(technique.states, pass.states);
+ }
+ delete technique.passes;
+ delete technique.pass;
}
}
}
+}
- function glTF08to10(gltf) {
- if (!defined(gltf.asset)) {
- gltf.asset = {};
- }
- var asset = gltf.asset;
- asset.version = '1.0';
- // Profile should be an object, not a string
- if (typeof asset.profile === 'string') {
- var split = asset.profile.split(' ');
- asset.profile = {
- api: split[0],
- version: split[1]
- };
- } else {
- asset.profile = {};
- }
-
- // Version property should be in asset, not on the root element
- if (defined(gltf.version)) {
- delete gltf.version;
- }
- // material.instanceTechnique properties should be directly on the material
- updateInstanceTechniques(gltf);
- // primitive.primitive should be primitive.mode
- setPrimitiveModes(gltf);
- // Node rotation should be quaternion, not axis-angle
- // node.instanceSkin is deprecated
- updateNodes(gltf);
- // Animations that target rotations should be quaternion, not axis-angle
- updateAnimations(gltf);
- // technique.pass and techniques.passes are deprecated
- removeTechniquePasses(gltf);
- // gltf.allExtensions -> extensionsUsed
- if (defined(gltf.allExtensions)) {
- gltf.extensionsUsed = gltf.allExtensions;
- delete gltf.allExtensions;
- }
- // gltf.lights -> khrMaterialsCommon.lights
- if (defined(gltf.lights)) {
- var extensions = defaultValue(gltf.extensions, {});
- gltf.extensions = extensions;
- var materialsCommon = defaultValue(extensions.KHR_materials_common, {});
- extensions.KHR_materials_common = materialsCommon;
- materialsCommon.lights = gltf.lights;
- delete gltf.lights;
- addExtensionsUsed(gltf, 'KHR_materials_common');
- }
+function glTF08to10(gltf) {
+ if (!defined(gltf.asset)) {
+ gltf.asset = {};
+ }
+ var asset = gltf.asset;
+ asset.version = '1.0';
+ // Profile should be an object, not a string
+ if (typeof asset.profile === 'string') {
+ var split = asset.profile.split(' ');
+ asset.profile = {
+ api: split[0],
+ version: split[1]
+ };
+ } else {
+ asset.profile = {};
}
- function removeAnimationSamplersIndirection(gltf) {
- var animations = gltf.animations;
- for (var animationId in animations) {
- if (Object.prototype.hasOwnProperty.call(animations, animationId)) {
- var animation = animations[animationId];
- var parameters = animation.parameters;
- if (defined(parameters)) {
- var samplers = animation.samplers;
- for (var samplerId in samplers) {
- if (Object.prototype.hasOwnProperty.call(samplers, samplerId)) {
- var sampler = samplers[samplerId];
- sampler.input = parameters[sampler.input];
- sampler.output = parameters[sampler.output];
- }
+ // Version property should be in asset, not on the root element
+ if (defined(gltf.version)) {
+ delete gltf.version;
+ }
+ // material.instanceTechnique properties should be directly on the material
+ updateInstanceTechniques(gltf);
+ // primitive.primitive should be primitive.mode
+ setPrimitiveModes(gltf);
+ // Node rotation should be quaternion, not axis-angle
+ // node.instanceSkin is deprecated
+ updateNodes(gltf);
+ // Animations that target rotations should be quaternion, not axis-angle
+ updateAnimations(gltf);
+ // technique.pass and techniques.passes are deprecated
+ removeTechniquePasses(gltf);
+ // gltf.allExtensions -> extensionsUsed
+ if (defined(gltf.allExtensions)) {
+ gltf.extensionsUsed = gltf.allExtensions;
+ delete gltf.allExtensions;
+ }
+ // gltf.lights -> khrMaterialsCommon.lights
+ if (defined(gltf.lights)) {
+ var extensions = defaultValue(gltf.extensions, {});
+ gltf.extensions = extensions;
+ var materialsCommon = defaultValue(extensions.KHR_materials_common, {});
+ extensions.KHR_materials_common = materialsCommon;
+ materialsCommon.lights = gltf.lights;
+ delete gltf.lights;
+ addExtensionsUsed(gltf, 'KHR_materials_common');
+ }
+}
+
+function removeAnimationSamplersIndirection(gltf) {
+ var animations = gltf.animations;
+ for (var animationId in animations) {
+ if (Object.prototype.hasOwnProperty.call(animations, animationId)) {
+ var animation = animations[animationId];
+ var parameters = animation.parameters;
+ if (defined(parameters)) {
+ var samplers = animation.samplers;
+ for (var samplerId in samplers) {
+ if (Object.prototype.hasOwnProperty.call(samplers, samplerId)) {
+ var sampler = samplers[samplerId];
+ sampler.input = parameters[sampler.input];
+ sampler.output = parameters[sampler.output];
}
- delete animation.parameters;
}
+ delete animation.parameters;
}
}
}
-
- function objectToArray(object, mapping) {
- var array = [];
- for (var id in object) {
- if (Object.prototype.hasOwnProperty.call(object, id)) {
- var value = object[id];
- mapping[id] = array.length;
- array.push(value);
- if (!defined(value.name)) {
- value.name = id;
- }
+}
+
+function objectToArray(object, mapping) {
+ var array = [];
+ for (var id in object) {
+ if (Object.prototype.hasOwnProperty.call(object, id)) {
+ var value = object[id];
+ mapping[id] = array.length;
+ array.push(value);
+ if (!defined(value.name)) {
+ value.name = id;
}
}
- return array;
}
+ return array;
+}
+
+function objectsToArrays(gltf) {
+ var i;
+ var globalMapping = {
+ accessors: {},
+ animations: {},
+ buffers: {},
+ bufferViews: {},
+ cameras: {},
+ images: {},
+ materials: {},
+ meshes: {},
+ nodes: {},
+ programs: {},
+ samplers: {},
+ scenes: {},
+ shaders: {},
+ skins: {},
+ textures: {},
+ techniques: {}
+ };
- function objectsToArrays(gltf) {
- var i;
- var globalMapping = {
- accessors: {},
- animations: {},
- buffers: {},
- bufferViews: {},
- cameras: {},
- images: {},
- materials: {},
- meshes: {},
- nodes: {},
- programs: {},
- samplers: {},
- scenes: {},
- shaders: {},
- skins: {},
- textures: {},
- techniques: {}
- };
-
- // Map joint names to id names
- var jointName;
- var jointNameToId = {};
- var nodes = gltf.nodes;
- for (var id in nodes) {
- if (Object.prototype.hasOwnProperty.call(nodes, id)) {
- jointName = nodes[id].jointName;
- if (defined(jointName)) {
- jointNameToId[jointName] = id;
- }
+ // Map joint names to id names
+ var jointName;
+ var jointNameToId = {};
+ var nodes = gltf.nodes;
+ for (var id in nodes) {
+ if (Object.prototype.hasOwnProperty.call(nodes, id)) {
+ jointName = nodes[id].jointName;
+ if (defined(jointName)) {
+ jointNameToId[jointName] = id;
}
}
+ }
- // Convert top level objects to arrays
- for (var topLevelId in gltf) {
- if (Object.prototype.hasOwnProperty.call(gltf, topLevelId) && defined(globalMapping[topLevelId])) {
- var objectMapping = {};
- var object = gltf[topLevelId];
- gltf[topLevelId] = objectToArray(object, objectMapping);
- globalMapping[topLevelId] = objectMapping;
- }
+ // Convert top level objects to arrays
+ for (var topLevelId in gltf) {
+ if (Object.prototype.hasOwnProperty.call(gltf, topLevelId) && defined(globalMapping[topLevelId])) {
+ var objectMapping = {};
+ var object = gltf[topLevelId];
+ gltf[topLevelId] = objectToArray(object, objectMapping);
+ globalMapping[topLevelId] = objectMapping;
}
+ }
- // Remap joint names to array indexes
- for (jointName in jointNameToId) {
- if (Object.prototype.hasOwnProperty.call(jointNameToId, jointName)) {
- jointNameToId[jointName] = globalMapping.nodes[jointNameToId[jointName]];
- }
+ // Remap joint names to array indexes
+ for (jointName in jointNameToId) {
+ if (Object.prototype.hasOwnProperty.call(jointNameToId, jointName)) {
+ jointNameToId[jointName] = globalMapping.nodes[jointNameToId[jointName]];
}
+ }
- // Fix references
- if (defined(gltf.scene)) {
- gltf.scene = globalMapping.scenes[gltf.scene];
+ // Fix references
+ if (defined(gltf.scene)) {
+ gltf.scene = globalMapping.scenes[gltf.scene];
+ }
+ ForEach.bufferView(gltf, function(bufferView) {
+ if (defined(bufferView.buffer)) {
+ bufferView.buffer = globalMapping.buffers[bufferView.buffer];
}
- ForEach.bufferView(gltf, function(bufferView) {
- if (defined(bufferView.buffer)) {
- bufferView.buffer = globalMapping.buffers[bufferView.buffer];
- }
- });
- ForEach.accessor(gltf, function(accessor) {
- if (defined(accessor.bufferView)) {
- accessor.bufferView = globalMapping.bufferViews[accessor.bufferView];
- }
- });
- ForEach.shader(gltf, function(shader) {
- var extensions = shader.extensions;
- if (defined(extensions)) {
- var binaryGltf = extensions.KHR_binary_glTF;
- if (defined(binaryGltf)) {
- shader.bufferView = globalMapping.bufferViews[binaryGltf.bufferView];
- delete extensions.KHR_binary_glTF;
- }
- if (Object.keys(extensions).length === 0) {
- delete shader.extensions;
- }
+ });
+ ForEach.accessor(gltf, function(accessor) {
+ if (defined(accessor.bufferView)) {
+ accessor.bufferView = globalMapping.bufferViews[accessor.bufferView];
+ }
+ });
+ ForEach.shader(gltf, function(shader) {
+ var extensions = shader.extensions;
+ if (defined(extensions)) {
+ var binaryGltf = extensions.KHR_binary_glTF;
+ if (defined(binaryGltf)) {
+ shader.bufferView = globalMapping.bufferViews[binaryGltf.bufferView];
+ delete extensions.KHR_binary_glTF;
+ }
+ if (Object.keys(extensions).length === 0) {
+ delete shader.extensions;
}
- });
- ForEach.program(gltf, function(program) {
- if (defined(program.vertexShader)) {
- program.vertexShader = globalMapping.shaders[program.vertexShader];
+ }
+ });
+ ForEach.program(gltf, function(program) {
+ if (defined(program.vertexShader)) {
+ program.vertexShader = globalMapping.shaders[program.vertexShader];
+ }
+ if (defined(program.fragmentShader)) {
+ program.fragmentShader = globalMapping.shaders[program.fragmentShader];
+ }
+ });
+ ForEach.technique(gltf, function(technique) {
+ if (defined(technique.program)) {
+ technique.program = globalMapping.programs[technique.program];
+ }
+ ForEach.techniqueParameter(technique, function(parameter) {
+ if (defined(parameter.node)) {
+ parameter.node = globalMapping.nodes[parameter.node];
}
- if (defined(program.fragmentShader)) {
- program.fragmentShader = globalMapping.shaders[program.fragmentShader];
+ var value = parameter.value;
+ if (typeof value === 'string') {
+ parameter.value = {
+ index: globalMapping.textures[value]
+ };
}
});
- ForEach.technique(gltf, function(technique) {
- if (defined(technique.program)) {
- technique.program = globalMapping.programs[technique.program];
+ });
+ ForEach.mesh(gltf, function(mesh) {
+ ForEach.meshPrimitive(mesh, function(primitive) {
+ if (defined(primitive.indices)) {
+ primitive.indices = globalMapping.accessors[primitive.indices];
}
- ForEach.techniqueParameter(technique, function(parameter) {
- if (defined(parameter.node)) {
- parameter.node = globalMapping.nodes[parameter.node];
- }
- var value = parameter.value;
- if (typeof value === 'string') {
- parameter.value = {
- index: globalMapping.textures[value]
- };
- }
- });
- });
- ForEach.mesh(gltf, function(mesh) {
- ForEach.meshPrimitive(mesh, function(primitive) {
- if (defined(primitive.indices)) {
- primitive.indices = globalMapping.accessors[primitive.indices];
- }
- ForEach.meshPrimitiveAttribute(primitive, function(accessorId, semantic) {
- primitive.attributes[semantic] = globalMapping.accessors[accessorId];
- });
- if (defined(primitive.material)) {
- primitive.material = globalMapping.materials[primitive.material];
- }
+ ForEach.meshPrimitiveAttribute(primitive, function(accessorId, semantic) {
+ primitive.attributes[semantic] = globalMapping.accessors[accessorId];
});
- });
- ForEach.node(gltf, function(node) {
- var children = node.children;
- if (defined(children)) {
- var childrenLength = children.length;
- for (i = 0; i < childrenLength; ++i) {
- children[i] = globalMapping.nodes[children[i]];
- }
- }
- if (defined(node.meshes)) {
- // Split out meshes on nodes
- var meshes = node.meshes;
- var meshesLength = meshes.length;
- if (meshesLength > 0) {
- node.mesh = globalMapping.meshes[meshes[0]];
- for (i = 1; i < meshesLength; ++i) {
- var meshNode = {
- mesh: globalMapping.meshes[meshes[i]]
- };
- var meshNodeId = addToArray(gltf.nodes, meshNode);
- if (!defined(children)) {
- children = [];
- node.children = children;
- }
- children.push(meshNodeId);
- }
- }
- delete node.meshes;
- }
- if (defined(node.camera)) {
- node.camera = globalMapping.cameras[node.camera];
- }
- if (defined(node.skin)) {
- node.skin = globalMapping.skins[node.skin];
- }
- if (defined(node.skeletons)) {
- // Assign skeletons to skins
- var skeletons = node.skeletons;
- var skeletonsLength = skeletons.length;
- if ((skeletonsLength > 0) && defined(node.skin)) {
- var skin = gltf.skins[node.skin];
- skin.skeleton = globalMapping.nodes[skeletons[0]];
- }
- delete node.skeletons;
- }
- if (defined(node.jointName)) {
- delete node.jointName;
- }
- });
- ForEach.skin(gltf, function(skin) {
- if (defined(skin.inverseBindMatrices)) {
- skin.inverseBindMatrices = globalMapping.accessors[skin.inverseBindMatrices];
- }
- var jointNames = skin.jointNames;
- if (defined(jointNames)) {
- var joints = [];
- var jointNamesLength = jointNames.length;
- for (i = 0; i < jointNamesLength; ++i) {
- joints[i] = jointNameToId[jointNames[i]];
- }
- skin.joints = joints;
- delete skin.jointNames;
+ if (defined(primitive.material)) {
+ primitive.material = globalMapping.materials[primitive.material];
}
});
- ForEach.scene(gltf, function(scene) {
- var sceneNodes = scene.nodes;
- if (defined(sceneNodes)) {
- var sceneNodesLength = sceneNodes.length;
- for (i = 0; i < sceneNodesLength; ++i) {
- sceneNodes[i] = globalMapping.nodes[sceneNodes[i]];
- }
+ });
+ ForEach.node(gltf, function(node) {
+ var children = node.children;
+ if (defined(children)) {
+ var childrenLength = children.length;
+ for (i = 0; i < childrenLength; ++i) {
+ children[i] = globalMapping.nodes[children[i]];
}
- });
- ForEach.animation(gltf, function(animation) {
- var samplerMapping = {};
- animation.samplers = objectToArray(animation.samplers, samplerMapping);
- ForEach.animationSampler(animation, function(sampler) {
- sampler.input = globalMapping.accessors[sampler.input];
- sampler.output = globalMapping.accessors[sampler.output];
- });
- ForEach.animationChannel(animation, function(channel) {
- channel.sampler = samplerMapping[channel.sampler];
- var target = channel.target;
- if (defined(target)) {
- target.node = globalMapping.nodes[target.id];
- delete target.id;
- }
- });
- });
- ForEach.material(gltf, function(material) {
- if (defined(material.technique)) {
- material.technique = globalMapping.techniques[material.technique];
- }
- ForEach.materialValue(material, function(value, name) {
- if (typeof value === 'string') {
- material.values[name] = {
- index: globalMapping.textures[value]
+ }
+ if (defined(node.meshes)) {
+ // Split out meshes on nodes
+ var meshes = node.meshes;
+ var meshesLength = meshes.length;
+ if (meshesLength > 0) {
+ node.mesh = globalMapping.meshes[meshes[0]];
+ for (i = 1; i < meshesLength; ++i) {
+ var meshNode = {
+ mesh: globalMapping.meshes[meshes[i]]
};
- }
- });
- var extensions = material.extensions;
- if (defined(extensions)) {
- var materialsCommon = extensions.KHR_materials_common;
- if (defined(materialsCommon)) {
- ForEach.materialValue(materialsCommon, function(value, name) {
- if (typeof value === 'string') {
- materialsCommon.values[name] = {
- index: globalMapping.textures[value]
- };
- }
- });
+ var meshNodeId = addToArray(gltf.nodes, meshNode);
+ if (!defined(children)) {
+ children = [];
+ node.children = children;
+ }
+ children.push(meshNodeId);
}
}
- });
- ForEach.image(gltf, function(image) {
- var extensions = image.extensions;
- if (defined(extensions)) {
- var binaryGltf = extensions.KHR_binary_glTF;
- if (defined(binaryGltf)) {
- image.bufferView = globalMapping.bufferViews[binaryGltf.bufferView];
- image.mimeType = binaryGltf.mimeType;
- delete extensions.KHR_binary_glTF;
- }
- if (Object.keys(extensions).length === 0) {
- delete image.extensions;
- }
+ delete node.meshes;
+ }
+ if (defined(node.camera)) {
+ node.camera = globalMapping.cameras[node.camera];
+ }
+ if (defined(node.skin)) {
+ node.skin = globalMapping.skins[node.skin];
+ }
+ if (defined(node.skeletons)) {
+ // Assign skeletons to skins
+ var skeletons = node.skeletons;
+ var skeletonsLength = skeletons.length;
+ if ((skeletonsLength > 0) && defined(node.skin)) {
+ var skin = gltf.skins[node.skin];
+ skin.skeleton = globalMapping.nodes[skeletons[0]];
+ }
+ delete node.skeletons;
+ }
+ if (defined(node.jointName)) {
+ delete node.jointName;
+ }
+ });
+ ForEach.skin(gltf, function(skin) {
+ if (defined(skin.inverseBindMatrices)) {
+ skin.inverseBindMatrices = globalMapping.accessors[skin.inverseBindMatrices];
+ }
+ var jointNames = skin.jointNames;
+ if (defined(jointNames)) {
+ var joints = [];
+ var jointNamesLength = jointNames.length;
+ for (i = 0; i < jointNamesLength; ++i) {
+ joints[i] = jointNameToId[jointNames[i]];
+ }
+ skin.joints = joints;
+ delete skin.jointNames;
+ }
+ });
+ ForEach.scene(gltf, function(scene) {
+ var sceneNodes = scene.nodes;
+ if (defined(sceneNodes)) {
+ var sceneNodesLength = sceneNodes.length;
+ for (i = 0; i < sceneNodesLength; ++i) {
+ sceneNodes[i] = globalMapping.nodes[sceneNodes[i]];
}
- ForEach.compressedImage(image, function(compressedImage) {
- var compressedExtensions = compressedImage.extensions;
- if (defined(compressedExtensions)) {
- var compressedBinaryGltf = compressedExtensions.KHR_binary_glTF;
- if (defined(compressedBinaryGltf)) {
- compressedImage.bufferView = globalMapping.bufferViews[compressedBinaryGltf.bufferView];
- compressedImage.mimeType = compressedBinaryGltf.mimeType;
- delete compressedExtensions.KHR_binary_glTF;
- }
- if (Object.keys(extensions).length === 0) {
- delete compressedImage.extensions;
+ }
+ });
+ ForEach.animation(gltf, function(animation) {
+ var samplerMapping = {};
+ animation.samplers = objectToArray(animation.samplers, samplerMapping);
+ ForEach.animationSampler(animation, function(sampler) {
+ sampler.input = globalMapping.accessors[sampler.input];
+ sampler.output = globalMapping.accessors[sampler.output];
+ });
+ ForEach.animationChannel(animation, function(channel) {
+ channel.sampler = samplerMapping[channel.sampler];
+ var target = channel.target;
+ if (defined(target)) {
+ target.node = globalMapping.nodes[target.id];
+ delete target.id;
+ }
+ });
+ });
+ ForEach.material(gltf, function(material) {
+ if (defined(material.technique)) {
+ material.technique = globalMapping.techniques[material.technique];
+ }
+ ForEach.materialValue(material, function(value, name) {
+ if (typeof value === 'string') {
+ material.values[name] = {
+ index: globalMapping.textures[value]
+ };
+ }
+ });
+ var extensions = material.extensions;
+ if (defined(extensions)) {
+ var materialsCommon = extensions.KHR_materials_common;
+ if (defined(materialsCommon)) {
+ ForEach.materialValue(materialsCommon, function(value, name) {
+ if (typeof value === 'string') {
+ materialsCommon.values[name] = {
+ index: globalMapping.textures[value]
+ };
}
- }
- });
- });
- ForEach.texture(gltf, function(texture) {
- if (defined(texture.sampler)) {
- texture.sampler = globalMapping.samplers[texture.sampler];
+ });
}
- if (defined(texture.source)) {
- texture.source = globalMapping.images[texture.source];
+ }
+ });
+ ForEach.image(gltf, function(image) {
+ var extensions = image.extensions;
+ if (defined(extensions)) {
+ var binaryGltf = extensions.KHR_binary_glTF;
+ if (defined(binaryGltf)) {
+ image.bufferView = globalMapping.bufferViews[binaryGltf.bufferView];
+ image.mimeType = binaryGltf.mimeType;
+ delete extensions.KHR_binary_glTF;
+ }
+ if (Object.keys(extensions).length === 0) {
+ delete image.extensions;
}
- });
- }
+ }
+ });
+ ForEach.texture(gltf, function(texture) {
+ if (defined(texture.sampler)) {
+ texture.sampler = globalMapping.samplers[texture.sampler];
+ }
+ if (defined(texture.source)) {
+ texture.source = globalMapping.images[texture.source];
+ }
+ });
+}
- function removeAnimationSamplerNames(gltf) {
- ForEach.animation(gltf, function(animation) {
- ForEach.animationSampler(animation, function(sampler) {
- delete sampler.name;
- });
+function removeAnimationSamplerNames(gltf) {
+ ForEach.animation(gltf, function(animation) {
+ ForEach.animationSampler(animation, function(sampler) {
+ delete sampler.name;
});
- }
+ });
+}
- function removeEmptyArrays(gltf) {
- for (var topLevelId in gltf) {
- if (Object.prototype.hasOwnProperty.call(gltf, topLevelId)) {
- var array = gltf[topLevelId];
- if (Array.isArray(array) && array.length === 0) {
- delete gltf[topLevelId];
- }
+function removeEmptyArrays(gltf) {
+ for (var topLevelId in gltf) {
+ if (Object.prototype.hasOwnProperty.call(gltf, topLevelId)) {
+ var array = gltf[topLevelId];
+ if (Array.isArray(array) && array.length === 0) {
+ delete gltf[topLevelId];
}
}
- ForEach.node(gltf, function(node) {
- if (defined(node.children) && node.children.length === 0) {
- delete node.children;
- }
- });
- }
-
- function stripAsset(gltf) {
- var asset = gltf.asset;
- delete asset.profile;
- delete asset.premultipliedAlpha;
}
-
- var knownExtensions = {
- CESIUM_RTC: true,
- KHR_materials_common: true,
- WEB3D_quantized_attributes: true
- };
- function requireKnownExtensions(gltf) {
- var extensionsUsed = gltf.extensionsUsed;
- gltf.extensionsRequired = defaultValue(gltf.extensionsRequired, []);
- if (defined(extensionsUsed)) {
- var extensionsUsedLength = extensionsUsed.length;
- for (var i = 0; i < extensionsUsedLength; ++i) {
- var extension = extensionsUsed[i];
- if (defined(knownExtensions[extension])) {
- gltf.extensionsRequired.push(extension);
- }
+ ForEach.node(gltf, function(node) {
+ if (defined(node.children) && node.children.length === 0) {
+ delete node.children;
+ }
+ });
+}
+
+function stripAsset(gltf) {
+ var asset = gltf.asset;
+ delete asset.profile;
+ delete asset.premultipliedAlpha;
+}
+
+var knownExtensions = {
+ CESIUM_RTC: true,
+ KHR_materials_common: true,
+ WEB3D_quantized_attributes: true
+};
+function requireKnownExtensions(gltf) {
+ var extensionsUsed = gltf.extensionsUsed;
+ gltf.extensionsRequired = defaultValue(gltf.extensionsRequired, []);
+ if (defined(extensionsUsed)) {
+ var extensionsUsedLength = extensionsUsed.length;
+ for (var i = 0; i < extensionsUsedLength; ++i) {
+ var extension = extensionsUsed[i];
+ if (defined(knownExtensions[extension])) {
+ gltf.extensionsRequired.push(extension);
}
}
}
-
- function removeBufferType(gltf) {
- ForEach.buffer(gltf, function(buffer) {
- delete buffer.type;
- });
- }
-
- function removeTextureProperties(gltf) {
- ForEach.texture(gltf, function(texture) {
- delete texture.format;
- delete texture.internalFormat;
- delete texture.target;
- delete texture.type;
- });
- }
-
- function requireAttributeSetIndex(gltf) {
- ForEach.mesh(gltf, function(mesh) {
- ForEach.meshPrimitive(mesh, function(primitive) {
- ForEach.meshPrimitiveAttribute(primitive, function(accessorId, semantic) {
- if (semantic === 'TEXCOORD') {
- primitive.attributes.TEXCOORD_0 = accessorId;
- } else if (semantic === 'COLOR') {
- primitive.attributes.COLOR_0 = accessorId;
- }
- });
- delete primitive.attributes.TEXCOORD;
- delete primitive.attributes.COLOR;
- });
- });
- ForEach.technique(gltf, function(technique) {
- ForEach.techniqueParameter(technique, function(parameter) {
- var semantic = parameter.semantic;
- if (defined(semantic)) {
- if (semantic === 'TEXCOORD') {
- parameter.semantic = 'TEXCOORD_0';
- } else if (semantic === 'COLOR') {
- parameter.semantic = 'COLOR_0';
- }
+}
+
+function removeBufferType(gltf) {
+ ForEach.buffer(gltf, function(buffer) {
+ delete buffer.type;
+ });
+}
+
+function removeTextureProperties(gltf) {
+ ForEach.texture(gltf, function(texture) {
+ delete texture.format;
+ delete texture.internalFormat;
+ delete texture.target;
+ delete texture.type;
+ });
+}
+
+function requireAttributeSetIndex(gltf) {
+ ForEach.mesh(gltf, function(mesh) {
+ ForEach.meshPrimitive(mesh, function(primitive) {
+ ForEach.meshPrimitiveAttribute(primitive, function(accessorId, semantic) {
+ if (semantic === 'TEXCOORD') {
+ primitive.attributes.TEXCOORD_0 = accessorId;
+ } else if (semantic === 'COLOR') {
+ primitive.attributes.COLOR_0 = accessorId;
}
});
- });
- }
-
- var knownSemantics = {
- POSITION: true,
- NORMAL: true,
- TANGENT: true
- };
- var indexedSemantics = {
- COLOR: 'COLOR',
- JOINT : 'JOINTS',
- JOINTS: 'JOINTS',
- TEXCOORD: 'TEXCOORD',
- WEIGHT: 'WEIGHTS',
- WEIGHTS: 'WEIGHTS'
- };
- function underscoreApplicationSpecificSemantics(gltf) {
- var mappedSemantics = {};
- ForEach.mesh(gltf, function(mesh) {
- ForEach.meshPrimitive(mesh, function(primitive) {
- /*eslint-disable no-unused-vars*/
- ForEach.meshPrimitiveAttribute(primitive, function(accessorId, semantic) {
- if (semantic.charAt(0) !== '_') {
- var setIndex = semantic.search(/_[0-9]+/g);
- var strippedSemantic = semantic;
- var suffix = '_0';
- if (setIndex >= 0) {
- strippedSemantic = semantic.substring(0, setIndex);
- suffix = semantic.substring(setIndex);
- }
- var newSemantic;
- var indexedSemantic = indexedSemantics[strippedSemantic];
- if (defined(indexedSemantic)) {
- newSemantic = indexedSemantic + suffix;
- mappedSemantics[semantic] = newSemantic;
- } else if (!defined(knownSemantics[strippedSemantic])) {
- newSemantic = '_' + semantic;
- mappedSemantics[semantic] = newSemantic;
- }
+ delete primitive.attributes.TEXCOORD;
+ delete primitive.attributes.COLOR;
+ });
+ });
+ ForEach.technique(gltf, function(technique) {
+ ForEach.techniqueParameter(technique, function(parameter) {
+ var semantic = parameter.semantic;
+ if (defined(semantic)) {
+ if (semantic === 'TEXCOORD') {
+ parameter.semantic = 'TEXCOORD_0';
+ } else if (semantic === 'COLOR') {
+ parameter.semantic = 'COLOR_0';
+ }
+ }
+ });
+ });
+}
+
+var knownSemantics = {
+ POSITION: true,
+ NORMAL: true,
+ TANGENT: true
+};
+var indexedSemantics = {
+ COLOR: 'COLOR',
+ JOINT : 'JOINTS',
+ JOINTS: 'JOINTS',
+ TEXCOORD: 'TEXCOORD',
+ WEIGHT: 'WEIGHTS',
+ WEIGHTS: 'WEIGHTS'
+};
+function underscoreApplicationSpecificSemantics(gltf) {
+ var mappedSemantics = {};
+ ForEach.mesh(gltf, function(mesh) {
+ ForEach.meshPrimitive(mesh, function(primitive) {
+ /*eslint-disable no-unused-vars*/
+ ForEach.meshPrimitiveAttribute(primitive, function(accessorId, semantic) {
+ if (semantic.charAt(0) !== '_') {
+ var setIndex = semantic.search(/_[0-9]+/g);
+ var strippedSemantic = semantic;
+ var suffix = '_0';
+ if (setIndex >= 0) {
+ strippedSemantic = semantic.substring(0, setIndex);
+ suffix = semantic.substring(setIndex);
}
- });
- for (var semantic in mappedSemantics) {
- if (Object.prototype.hasOwnProperty.call(mappedSemantics, semantic)) {
- var mappedSemantic = mappedSemantics[semantic];
- var accessorId = primitive.attributes[semantic];
- if (defined(accessorId)) {
- delete primitive.attributes[semantic];
- primitive.attributes[mappedSemantic] = accessorId;
- }
+ var newSemantic;
+ var indexedSemantic = indexedSemantics[strippedSemantic];
+ if (defined(indexedSemantic)) {
+ newSemantic = indexedSemantic + suffix;
+ mappedSemantics[semantic] = newSemantic;
+ } else if (!defined(knownSemantics[strippedSemantic])) {
+ newSemantic = '_' + semantic;
+ mappedSemantics[semantic] = newSemantic;
}
}
});
- });
- ForEach.technique(gltf, function(technique) {
- ForEach.techniqueParameter(technique, function(parameter) {
- var mappedSemantic = mappedSemantics[parameter.semantic];
- if (defined(mappedSemantic)) {
- parameter.semantic = mappedSemantic;
- }
- });
- });
- }
-
- function clampCameraParameters(gltf) {
- ForEach.camera(gltf, function(camera) {
- var perspective = camera.perspective;
- if (defined(perspective)) {
- var aspectRatio = perspective.aspectRatio;
- if (defined(aspectRatio) && aspectRatio === 0.0) {
- delete perspective.aspectRatio;
- }
- var yfov = perspective.yfov;
- if (defined(yfov) && yfov === 0.0) {
- perspective.yfov = 1.0;
+ for (var semantic in mappedSemantics) {
+ if (Object.prototype.hasOwnProperty.call(mappedSemantics, semantic)) {
+ var mappedSemantic = mappedSemantics[semantic];
+ var accessorId = primitive.attributes[semantic];
+ if (defined(accessorId)) {
+ delete primitive.attributes[semantic];
+ primitive.attributes[mappedSemantic] = accessorId;
+ }
}
}
});
- }
-
- function computeAccessorByteStride(gltf, accessor) {
- return (defined(accessor.byteStride) && accessor.byteStride !== 0) ? accessor.byteStride : getAccessorByteStride(gltf, accessor);
- }
-
- function requireByteLength(gltf) {
- ForEach.buffer(gltf, function(buffer) {
- if (!defined(buffer.byteLength)) {
- buffer.byteLength = buffer.extras._pipeline.source.length;
+ });
+ ForEach.technique(gltf, function(technique) {
+ ForEach.techniqueParameter(technique, function(parameter) {
+ var mappedSemantic = mappedSemantics[parameter.semantic];
+ if (defined(mappedSemantic)) {
+ parameter.semantic = mappedSemantic;
}
});
- ForEach.accessor(gltf, function(accessor) {
- var bufferViewId = accessor.bufferView;
- if (defined(bufferViewId)) {
- var bufferView = gltf.bufferViews[bufferViewId];
- var accessorByteStride = computeAccessorByteStride(gltf, accessor);
- var accessorByteEnd = accessor.byteOffset + accessor.count * accessorByteStride;
- bufferView.byteLength = Math.max(defaultValue(bufferView.byteLength, 0), accessorByteEnd);
- }
- });
- }
+ });
+}
- function moveByteStrideToBufferView(gltf) {
- var i;
- var j;
- var bufferView;
- var bufferViews = gltf.bufferViews;
-
- var bufferViewHasVertexAttributes = {};
- ForEach.accessorContainingVertexAttributeData(gltf, function(accessorId) {
- var accessor = gltf.accessors[accessorId];
- if (defined(accessor.bufferView)) {
- bufferViewHasVertexAttributes[accessor.bufferView] = true;
+function clampCameraParameters(gltf) {
+ ForEach.camera(gltf, function(camera) {
+ var perspective = camera.perspective;
+ if (defined(perspective)) {
+ var aspectRatio = perspective.aspectRatio;
+ if (defined(aspectRatio) && aspectRatio === 0.0) {
+ delete perspective.aspectRatio;
}
- });
-
- // Map buffer views to a list of accessors
- var bufferViewMap = {};
- ForEach.accessor(gltf, function(accessor) {
- if (defined(accessor.bufferView)) {
- bufferViewMap[accessor.bufferView] = defaultValue(bufferViewMap[accessor.bufferView], []);
- bufferViewMap[accessor.bufferView].push(accessor);
+ var yfov = perspective.yfov;
+ if (defined(yfov) && yfov === 0.0) {
+ perspective.yfov = 1.0;
}
- });
+ }
+ });
+}
- // Split accessors with different byte strides
- for (var bufferViewId in bufferViewMap) {
- if (Object.prototype.hasOwnProperty.call(bufferViewMap, bufferViewId)) {
- bufferView = bufferViews[bufferViewId];
- var accessors = bufferViewMap[bufferViewId];
- accessors.sort(function(a, b) {
- return a.byteOffset - b.byteOffset;
- });
- var currentByteOffset = 0;
- var currentIndex = 0;
- var accessorsLength = accessors.length;
- for (i = 0; i < accessorsLength; ++i) {
- var accessor = accessors[i];
- var accessorByteStride = computeAccessorByteStride(gltf, accessor);
- var accessorByteOffset = accessor.byteOffset;
- var accessorByteLength = accessor.count * accessorByteStride;
- delete accessor.byteStride;
-
- var hasNextAccessor = (i < accessorsLength - 1);
- var nextAccessorByteStride = hasNextAccessor ? computeAccessorByteStride(gltf, accessors[i + 1]) : undefined;
- if (accessorByteStride !== nextAccessorByteStride) {
- var newBufferView = clone(bufferView, true);
- if (bufferViewHasVertexAttributes[bufferViewId]) {
- newBufferView.byteStride = accessorByteStride;
- }
- newBufferView.byteOffset += currentByteOffset;
- newBufferView.byteLength = accessorByteOffset + accessorByteLength - currentByteOffset;
- var newBufferViewId = addToArray(bufferViews, newBufferView);
- for (j = currentIndex; j <= i; ++j) {
- accessor = accessors[j];
- accessor.bufferView = newBufferViewId;
- accessor.byteOffset = accessor.byteOffset - currentByteOffset;
- }
- // Set current byte offset to next accessor's byte offset
- currentByteOffset = hasNextAccessor ? accessors[i + 1].byteOffset : undefined;
- currentIndex = i + 1;
+function computeAccessorByteStride(gltf, accessor) {
+ return (defined(accessor.byteStride) && accessor.byteStride !== 0) ? accessor.byteStride : getAccessorByteStride(gltf, accessor);
+}
+
+function requireByteLength(gltf) {
+ ForEach.buffer(gltf, function(buffer) {
+ if (!defined(buffer.byteLength)) {
+ buffer.byteLength = buffer.extras._pipeline.source.length;
+ }
+ });
+ ForEach.accessor(gltf, function(accessor) {
+ var bufferViewId = accessor.bufferView;
+ if (defined(bufferViewId)) {
+ var bufferView = gltf.bufferViews[bufferViewId];
+ var accessorByteStride = computeAccessorByteStride(gltf, accessor);
+ var accessorByteEnd = accessor.byteOffset + accessor.count * accessorByteStride;
+ bufferView.byteLength = Math.max(defaultValue(bufferView.byteLength, 0), accessorByteEnd);
+ }
+ });
+}
+
+function moveByteStrideToBufferView(gltf) {
+ var i;
+ var j;
+ var bufferView;
+ var bufferViews = gltf.bufferViews;
+
+ var bufferViewHasVertexAttributes = {};
+ ForEach.accessorContainingVertexAttributeData(gltf, function(accessorId) {
+ var accessor = gltf.accessors[accessorId];
+ if (defined(accessor.bufferView)) {
+ bufferViewHasVertexAttributes[accessor.bufferView] = true;
+ }
+ });
+
+ // Map buffer views to a list of accessors
+ var bufferViewMap = {};
+ ForEach.accessor(gltf, function(accessor) {
+ if (defined(accessor.bufferView)) {
+ bufferViewMap[accessor.bufferView] = defaultValue(bufferViewMap[accessor.bufferView], []);
+ bufferViewMap[accessor.bufferView].push(accessor);
+ }
+ });
+
+ // Split accessors with different byte strides
+ for (var bufferViewId in bufferViewMap) {
+ if (Object.prototype.hasOwnProperty.call(bufferViewMap, bufferViewId)) {
+ bufferView = bufferViews[bufferViewId];
+ var accessors = bufferViewMap[bufferViewId];
+ accessors.sort(function(a, b) {
+ return a.byteOffset - b.byteOffset;
+ });
+ var currentByteOffset = 0;
+ var currentIndex = 0;
+ var accessorsLength = accessors.length;
+ for (i = 0; i < accessorsLength; ++i) {
+ var accessor = accessors[i];
+ var accessorByteStride = computeAccessorByteStride(gltf, accessor);
+ var accessorByteOffset = accessor.byteOffset;
+ var accessorByteLength = accessor.count * accessorByteStride;
+ delete accessor.byteStride;
+
+ var hasNextAccessor = (i < accessorsLength - 1);
+ var nextAccessorByteStride = hasNextAccessor ? computeAccessorByteStride(gltf, accessors[i + 1]) : undefined;
+ if (accessorByteStride !== nextAccessorByteStride) {
+ var newBufferView = clone(bufferView, true);
+ if (bufferViewHasVertexAttributes[bufferViewId]) {
+ newBufferView.byteStride = accessorByteStride;
}
+ newBufferView.byteOffset += currentByteOffset;
+ newBufferView.byteLength = accessorByteOffset + accessorByteLength - currentByteOffset;
+ var newBufferViewId = addToArray(bufferViews, newBufferView);
+ for (j = currentIndex; j <= i; ++j) {
+ accessor = accessors[j];
+ accessor.bufferView = newBufferViewId;
+ accessor.byteOffset = accessor.byteOffset - currentByteOffset;
+ }
+ // Set current byte offset to next accessor's byte offset
+ currentByteOffset = hasNextAccessor ? accessors[i + 1].byteOffset : undefined;
+ currentIndex = i + 1;
}
}
}
-
- // Remove unused buffer views
- removeUnusedElements(gltf, ['accessor', 'bufferView', 'buffer']);
- }
-
- function requirePositionAccessorMinMax(gltf) {
- ForEach.accessorWithSemantic(gltf, 'POSITION', function(accessorId) {
- var accessor = gltf.accessors[accessorId];
- if (!defined(accessor.min) || !defined(accessor.max)) {
- var minMax = findAccessorMinMax(gltf, accessor);
- accessor.min = minMax.min;
- accessor.max = minMax.max;
- }
- });
- }
-
- function isNodeEmpty(node) {
- return (!defined(node.children) || node.children.length === 0) &&
- (!defined(node.meshes) || node.meshes.length === 0) &&
- !defined(node.camera) && !defined(node.skin) && !defined(node.skeletons) && !defined(node.jointName) &&
- (!defined(node.translation) || Cartesian3.fromArray(node.translation).equals(Cartesian3.ZERO)) &&
- (!defined(node.scale) || Cartesian3.fromArray(node.scale).equals(new Cartesian3(1.0, 1.0, 1.0))) &&
- (!defined(node.rotation) || Cartesian4.fromArray(node.rotation).equals(new Cartesian4(0.0, 0.0, 0.0, 1.0))) &&
- (!defined(node.matrix) || Matrix4.fromColumnMajorArray(node.matrix).equals(Matrix4.IDENTITY)) &&
- !defined(node.extensions) && !defined(node.extras);
}
- function deleteNode(gltf, nodeId) {
- // Remove from list of nodes in scene
- ForEach.scene(gltf, function(scene) {
- var sceneNodes = scene.nodes;
- if (defined(sceneNodes)) {
- var sceneNodesLength = sceneNodes.length;
- for (var i = sceneNodesLength; i >= 0; --i) {
- if (sceneNodes[i] === nodeId) {
- sceneNodes.splice(i, 1);
- return;
- }
+ // Remove unused buffer views
+ removeUnusedElements(gltf, ['accessor', 'bufferView', 'buffer']);
+}
+
+function requirePositionAccessorMinMax(gltf) {
+ ForEach.accessorWithSemantic(gltf, 'POSITION', function(accessorId) {
+ var accessor = gltf.accessors[accessorId];
+ if (!defined(accessor.min) || !defined(accessor.max)) {
+ var minMax = findAccessorMinMax(gltf, accessor);
+ accessor.min = minMax.min;
+ accessor.max = minMax.max;
+ }
+ });
+}
+
+function isNodeEmpty(node) {
+ return (!defined(node.children) || node.children.length === 0) &&
+ (!defined(node.meshes) || node.meshes.length === 0) &&
+ !defined(node.camera) && !defined(node.skin) && !defined(node.skeletons) && !defined(node.jointName) &&
+ (!defined(node.translation) || Cartesian3.fromArray(node.translation).equals(Cartesian3.ZERO)) &&
+ (!defined(node.scale) || Cartesian3.fromArray(node.scale).equals(new Cartesian3(1.0, 1.0, 1.0))) &&
+ (!defined(node.rotation) || Cartesian4.fromArray(node.rotation).equals(new Cartesian4(0.0, 0.0, 0.0, 1.0))) &&
+ (!defined(node.matrix) || Matrix4.fromColumnMajorArray(node.matrix).equals(Matrix4.IDENTITY)) &&
+ !defined(node.extensions) && !defined(node.extras);
+}
+
+function deleteNode(gltf, nodeId) {
+ // Remove from list of nodes in scene
+ ForEach.scene(gltf, function(scene) {
+ var sceneNodes = scene.nodes;
+ if (defined(sceneNodes)) {
+ var sceneNodesLength = sceneNodes.length;
+ for (var i = sceneNodesLength; i >= 0; --i) {
+ if (sceneNodes[i] === nodeId) {
+ sceneNodes.splice(i, 1);
+ return;
}
}
- });
+ }
+ });
- // Remove parent node's reference to this node, and delete the parent if also empty
- ForEach.node(gltf, function(parentNode, parentNodeId) {
- if (defined(parentNode.children)) {
- var index = parentNode.children.indexOf(nodeId);
- if (index > -1) {
- parentNode.children.splice(index, 1);
+ // Remove parent node's reference to this node, and delete the parent if also empty
+ ForEach.node(gltf, function(parentNode, parentNodeId) {
+ if (defined(parentNode.children)) {
+ var index = parentNode.children.indexOf(nodeId);
+ if (index > -1) {
+ parentNode.children.splice(index, 1);
- if (isNodeEmpty(parentNode)) {
- deleteNode(gltf, parentNodeId);
- }
+ if (isNodeEmpty(parentNode)) {
+ deleteNode(gltf, parentNodeId);
}
}
- });
+ }
+ });
- delete gltf.nodes[nodeId];
- }
+ delete gltf.nodes[nodeId];
+}
- function removeEmptyNodes(gltf) {
- ForEach.node(gltf, function(node, nodeId) {
- if (isNodeEmpty(node)) {
- deleteNode(gltf, nodeId);
- }
- });
+function removeEmptyNodes(gltf) {
+ ForEach.node(gltf, function(node, nodeId) {
+ if (isNodeEmpty(node)) {
+ deleteNode(gltf, nodeId);
+ }
+ });
- return gltf;
- }
+ return gltf;
+}
- function requireAnimationAccessorMinMax(gltf) {
- ForEach.animation(gltf, function(animation) {
- ForEach.animationSampler(animation, function(sampler) {
- var accessor = gltf.accessors[sampler.input];
- if (!defined(accessor.min) || !defined(accessor.max)) {
- var minMax = findAccessorMinMax(gltf, accessor);
- accessor.min = minMax.min;
- accessor.max = minMax.max;
- }
- });
+function requireAnimationAccessorMinMax(gltf) {
+ ForEach.animation(gltf, function(animation) {
+ ForEach.animationSampler(animation, function(sampler) {
+ var accessor = gltf.accessors[sampler.input];
+ if (!defined(accessor.min) || !defined(accessor.max)) {
+ var minMax = findAccessorMinMax(gltf, accessor);
+ accessor.min = minMax.min;
+ accessor.max = minMax.max;
+ }
});
- }
-
- function glTF10to20(gltf) {
- gltf.asset = defaultValue(gltf.asset, {});
- gltf.asset.version = '2.0';
- // material.instanceTechnique properties should be directly on the material. instanceTechnique is a gltf 0.8 property but is seen in some 1.0 models.
- updateInstanceTechniques(gltf);
- // animation.samplers now refers directly to accessors and animation.parameters should be removed
- removeAnimationSamplersIndirection(gltf);
- // Remove empty nodes and re-assign referencing indices
- removeEmptyNodes(gltf);
- // Top-level objects are now arrays referenced by index instead of id
- objectsToArrays(gltf);
- // Animation.sampler objects cannot have names
- removeAnimationSamplerNames(gltf);
- // asset.profile no longer exists
- stripAsset(gltf);
- // Move known extensions from extensionsUsed to extensionsRequired
- requireKnownExtensions(gltf);
- // bufferView.byteLength and buffer.byteLength are required
- requireByteLength(gltf);
- // byteStride moved from accessor to bufferView
- moveByteStrideToBufferView(gltf);
- // accessor.min and accessor.max must be defined for accessors containing POSITION attributes
- requirePositionAccessorMinMax(gltf);
- // An animation sampler's input accessor must have min and max properties defined
- requireAnimationAccessorMinMax(gltf);
- // buffer.type is unnecessary and should be removed
- removeBufferType(gltf);
- // Remove format, internalFormat, target, and type
- removeTextureProperties(gltf);
- // TEXCOORD and COLOR attributes must be written with a set index (TEXCOORD_#)
- requireAttributeSetIndex(gltf);
- // Add underscores to application-specific parameters
- underscoreApplicationSpecificSemantics(gltf);
- // Accessors referenced by JOINTS_0 and WEIGHTS_0 attributes must have correct component types
- updateAccessorComponentTypes(gltf);
- // Clamp camera parameters
- clampCameraParameters(gltf);
- // Move legacy technique render states to material properties and add KHR_blend extension blending functions
- moveTechniqueRenderStates(gltf);
- // Add material techniques to KHR_techniques_webgl extension, removing shaders, programs, and techniques
- moveTechniquesToExtension(gltf);
- // Remove empty arrays
- removeEmptyArrays(gltf);
- }
-
- export default updateVersion;
+ });
+}
+
+function glTF10to20(gltf) {
+ gltf.asset = defaultValue(gltf.asset, {});
+ gltf.asset.version = '2.0';
+ // material.instanceTechnique properties should be directly on the material. instanceTechnique is a gltf 0.8 property but is seen in some 1.0 models.
+ updateInstanceTechniques(gltf);
+ // animation.samplers now refers directly to accessors and animation.parameters should be removed
+ removeAnimationSamplersIndirection(gltf);
+ // Remove empty nodes and re-assign referencing indices
+ removeEmptyNodes(gltf);
+ // Top-level objects are now arrays referenced by index instead of id
+ objectsToArrays(gltf);
+ // Animation.sampler objects cannot have names
+ removeAnimationSamplerNames(gltf);
+ // asset.profile no longer exists
+ stripAsset(gltf);
+ // Move known extensions from extensionsUsed to extensionsRequired
+ requireKnownExtensions(gltf);
+ // bufferView.byteLength and buffer.byteLength are required
+ requireByteLength(gltf);
+ // byteStride moved from accessor to bufferView
+ moveByteStrideToBufferView(gltf);
+ // accessor.min and accessor.max must be defined for accessors containing POSITION attributes
+ requirePositionAccessorMinMax(gltf);
+ // An animation sampler's input accessor must have min and max properties defined
+ requireAnimationAccessorMinMax(gltf);
+ // buffer.type is unnecessary and should be removed
+ removeBufferType(gltf);
+ // Remove format, internalFormat, target, and type
+ removeTextureProperties(gltf);
+ // TEXCOORD and COLOR attributes must be written with a set index (TEXCOORD_#)
+ requireAttributeSetIndex(gltf);
+ // Add underscores to application-specific parameters
+ underscoreApplicationSpecificSemantics(gltf);
+ // Accessors referenced by JOINTS_0 and WEIGHTS_0 attributes must have correct component types
+ updateAccessorComponentTypes(gltf);
+ // Clamp camera parameters
+ clampCameraParameters(gltf);
+ // Move legacy technique render states to material properties and add KHR_blend extension blending functions
+ moveTechniqueRenderStates(gltf);
+ // Add material techniques to KHR_techniques_webgl extension, removing shaders, programs, and techniques
+ moveTechniquesToExtension(gltf);
+ // Remove empty arrays
+ removeEmptyArrays(gltf);
+}
+
+export default updateVersion;
diff --git a/Source/ThirdParty/Workers/msc_basis_transcoder.js b/Source/ThirdParty/Workers/msc_basis_transcoder.js
new file mode 100644
index 00000000000..6ae2e916975
--- /dev/null
+++ b/Source/ThirdParty/Workers/msc_basis_transcoder.js
@@ -0,0 +1,44 @@
+
+var MSC_TRANSCODER = (function() {
+ var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
+ if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
+ return (
+function(MSC_TRANSCODER) {
+ MSC_TRANSCODER = MSC_TRANSCODER || {};
+
+var Module=typeof MSC_TRANSCODER!=="undefined"?MSC_TRANSCODER:{};var Promise=function(){function noop(){}function bind(fn,thisArg){return function(){fn.apply(thisArg,arguments)}}function Promise(fn){if(!(this instanceof Promise))throw new TypeError("Promises must be constructed via new");if(typeof fn!=="function")throw new TypeError("not a function");this._state=0;this._handled=false;this._value=undefined;this._deferreds=[];doResolve(fn,this)}function handle(self,deferred){while(self._state===3){self=self._value}if(self._state===0){self._deferreds.push(deferred);return}self._handled=true;Promise._immediateFn(function(){var cb=self._state===1?deferred.onFulfilled:deferred.onRejected;if(cb===null){(self._state===1?resolve:reject)(deferred.promise,self._value);return}var ret;try{ret=cb(self._value)}catch(e){reject(deferred.promise,e);return}resolve(deferred.promise,ret)})}function resolve(self,newValue){try{if(newValue===self)throw new TypeError("A promise cannot be resolved with itself.");if(newValue&&(typeof newValue==="object"||typeof newValue==="function")){var then=newValue.then;if(newValue instanceof Promise){self._state=3;self._value=newValue;finale(self);return}else if(typeof then==="function"){doResolve(bind(then,newValue),self);return}}self._state=1;self._value=newValue;finale(self)}catch(e){reject(self,e)}}function reject(self,newValue){self._state=2;self._value=newValue;finale(self)}function finale(self){if(self._state===2&&self._deferreds.length===0){Promise._immediateFn(function(){if(!self._handled){Promise._unhandledRejectionFn(self._value)}})}for(var i=0,len=self._deferreds.length;i>>0?0:q)|0;z=z-B|0;t=t>>>B|0;f=0}h[i[qa>>2]+(O<<2)>>1]=Q;if(Y&(p|0)==2){break da}}ma:{if(fa){fa=fa+ -1|0;f=(i[a+16>>2]-i[a+12>>2]|0)/11|0;B=f;break ma}na:{oa:{if(i[a+104>>2]!=i[a+100>>2]){B=e;if(z>>>0<16){while(1){D=0;if(B>>>0>>0){D=j[B|0];e=B+1|0;B=e}t=D< >>0<8;z=z+8|0;if(f){continue}break}}D=i[i[a+112>>2]+((t&1023)<<2)>>2];if((D|0)>-1){break oa}f=i[a+124>>2];B=10;while(1){p=t>>>B|0;B=B+1|0;D=h[f+((p&1)+(D^-1)<<1)>>1];if((D|0)<0){continue}break}f=D;break na}break j}B=D>>>16|0;f=D&65535}z=z-B|0;t=t>>>B|0;pa:{qa:{if((f|0)==(ra|0)){if(i[a+140>>2]==i[a+136>>2]){break j}B=e;if(z>>>0<16){while(1){D=0;if(B>>>0 >>0){D=j[B|0];e=B+1|0;B=e}t=D< >>0<8;z=z+8|0;if(f){continue}break}}D=i[i[a+148>>2]+((t&1023)<<2)>>2];if((D|0)>-1){break qa}f=i[a+160>>2];B=10;while(1){p=t>>>B|0;B=B+1|0;D=h[f+((p&1)+(D^-1)<<1)>>1];if((D|0)<0){continue}break}f=D;break pa}fa=0;B=(i[a+16>>2]-i[a+12>>2]|0)/11|0;if((f|0)>=(B|0)){break ma}if(!i[a+172>>2]){break da}p=i[C+12>>2];i[C+12>>2]=p+1;q=p<<2;p=i[C>>2];i[q+p>>2]=f;q=i[C+4>>2]-p>>2;p=i[C+12>>2];if((q|0)!=(p|0)){break da}i[C+12>>2]=p>>>1;break da}B=D>>>16|0;f=D&65535}z=z-B|0;t=t>>>B|0;if((f|0)==63){if(!(z>>>0>7)){B=0;if(e>>>0 >>0){B=j[e|0];e=e+1|0}t=B< >>8|0;ra:{if(!(t&128)){t=B;break ra}sa:{if(z>>>0>=8){z=e+ -16|0;break sa}s=0;if(D>>>0 >>0){s=j[D|0];D=D+1|0}B=s< >>8|0;f=B<<7&16256|f;if(!(B&128)){break ra}ta:{if(z>>>0>=8){z=z+ -8|0;break ta}B=0;if(D>>>0 >>0){B=j[D|0];D=D+1|0}t=B< >>8|0;f=t<<14&2080768|f;if(!(t&128)){t=B;break ra}ua:{if(z>>>0>=8){z=z+ -8|0;break ua}s=0;if(D>>>0 >>0){s=j[D|0];D=D+1|0}B=s< >>8|0;f=B<<21&266338304|f;if(!(B&128)){t=s;break ra}va:{if(z>>>0>=8){z=z+ -8|0;break va}B=0;if(D>>>0 >>0){B=j[D|0];D=D+1|0}s=B< >>8|0;f=s<<28|f;break ra}break i}e=D}fa=f+3|0;if(fa>>>0>$>>>0){if(ja){break C}break p}fa=f+2|0;f=(i[a+16>>2]-i[a+12>>2]|0)/11|0;B=f}if(!i[a+172>>2]){break ca}p=f-B|0;q=i[C>>2];if((p|0)>=i[C+4>>2]-q>>2){if(ja){break C}break p}s=q+(p<<2)|0;f=i[s>>2];if(!p){break da}p=q+(p<<1&-4)|0;q=i[p>>2];i[p>>2]=f;i[s>>2]=q}wa:{E=i[a>>2];if(Q>>>0>2]-E>>3>>>0){L=i[a+12>>2];if(f>>>0<(i[a+16>>2]-L|0)/11>>>0){break wa}}if(ja){break C}break p}if(Y){i[i[oa>>2]+(O+aa<<2)>>2]=f<<16|Q}u=(J|0)<4?J:4;F=L+o(f,11)|0;s=E+(Q<<3)|0;xa:{ya:{switch(l|0){case 0:f=j[s+4|0];if(f>>>0>=8){break g}p=o(O+_|0,m)+b|0;q=j[s|0];X=X&7|(q>>>0<31?q<<3:-8);q=j[s+1|0];ga=ga&7|(q>>>0<31?q:31)<<3;q=j[s+2|0];ia=ia&7|(q>>>0<31?q:31)<<3;W=W&3|f<<5|f<<2;i[p>>2]=X&255|(ga&255)<<8|(ia&255)<<16|W<<24;i[p+4>>2]=j[F+4|0]|j[F+5|0]<<8|(j[F+6|0]<<16|j[F+7|0]<<24);break D;case 2:p=o(O+_|0,m)+b|0;f=j[s+4|0];q=j[F+8|0];u=j[F+9|0];if((q|0)==(u|0)){if(q>>>0>=4){break f}u=j[s+2|0];B=u>>>2|0;u=u<<3;D=j[s+1|0];E=D<<3|D>>>2;f=i[((f<<4)+(q<<2)|0)+28352>>2];s=j[s|0];D=f+(s<<3|s>>>2)|0;za:{if(D>>>0<256){break za}q=(D|0)>-1;D=255;if(q){break za}D=0}q=u|B;s=f+E|0;Aa:{if(s>>>0<256){break Aa}u=(s|0)>-1;s=255;if(u){break Aa}s=0}E=f+q|0;Ba:{if(E>>>0<256){break Ba}f=(E|0)>-1;E=255;if(f){break Ba}E=0}f=170;q=E<<1;s=s<<1;u=D<<1;E=j[q+300769|0]|(j[s+301793|0]<<5|j[u+300769|0]<<11);D=j[q+300768|0]|(j[s+301792|0]<<5|j[u+300768|0]<<11);Ca:{if(!(na|(E|0)!=(D|0))){if(!D){f=85;D=0;s=1;break Ca}E=D+ -1|0;f=0}if(D>>>0>=E>>>0){s=D;D=E;break Ca}f=f|85;s=E}g[p+2|0]=D;g[p|0]=s;f=o(f,16843009);g[p+4|0]=f;g[p+5|0]=f>>>8;g[p+6|0]=f>>>16;g[p+7|0]=f>>>24;g[p+3|0]=D>>>8;g[p+1|0]=s>>>8;break D}Da:{Ea:{if(!((u|0)!=3|f>>>0<7|(j[F+10|0]!=2|q))){Fa(C- -64|0,s,f);D=1;q=j[(j[C+78|0]<<1)+301280|0]|(j[(j[C+77|0]<<1)+302304|0]<<5|j[(j[C+76|0]<<1)+301280|0]<<11);s=j[(j[C+66|0]<<1)+301280|0]|(j[(j[C+65|0]<<1)+302304|0]<<5|j[(j[C+64|0]<<1)+301280|0]<<11);if((q|0)==(s|0)){if(!s){s=0;E=1;f=1;break Da}D=0;q=s+ -1|0}f=0;if(s>>>0 >>0){break Ea}E=s;s=q;break Da}u=o(i[((q<<4)+(u<<2)|0)+302816>>2],10);B=f<<5;f=u+o(B+j[s|0]|0,60)<<2;I=f;q=u+o(B+j[s+2|0]|0,60)<<2;s=u+o(B+j[s+1|0]|0,60)<<2;u=k[q+91094>>1]+(k[s+152534>>1]+k[f+91094>>1]|0)|0;B=k[q+91090>>1]+(k[s+152530>>1]+k[f+91090>>1]|0)|0;D=u>>>0>>0;E=k[q+91098>>1]+(k[s+152538>>1]+k[f+91098>>1]|0)|0;u=D?u:B;B=E>>>0>>0;H=B?2:D;D=k[q+91102>>1]+(k[s+152542>>1]+k[f+91102>>1]|0)|0;u=B?E:u;B=D>>>0>>0;H=B?3:H;E=k[q+91106>>1]+(k[s+152546>>1]+k[f+91106>>1]|0)|0;u=B?D:u;B=E>>>0>>0;H=B?4:H;D=k[q+91110>>1]+(k[s+152550>>1]+k[f+91110>>1]|0)|0;u=B?E:u;B=D>>>0>>0;H=B?5:H;E=k[q+91114>>1]+(k[s+152554>>1]+k[f+91114>>1]|0)|0;u=B?D:u;B=E>>>0>>0;H=B?6:H;D=k[q+91118>>1]+(k[s+152558>>1]+k[f+91118>>1]|0)|0;u=B?E:u;B=D>>>0>>0;H=B?7:H;E=k[q+91122>>1]+(k[s+152562>>1]+k[f+91122>>1]|0)|0;u=B?D:u;B=E>>>0>>0;B=k[q+91126>>1]+(k[s+152566>>1]+k[f+91126>>1]|0)>>>0<(B?E:u)>>>0?9:B?8:H;f=B<<2;u=I+f|0;D=f+q|0;f=f+s|0;q=j[u+91088|0]<<11&63488|j[D+91088|0]|j[f+152528|0]<<5;s=j[D+91089|0]|j[u+91089|0]<<11&63488|j[f+152529|0]<<5;f=q>>>0>>0;u=f?q:s;g[p+2|0]=u;q=f?s:q;g[p|0]=q;g[p+3|0]=u>>>8;g[p+1|0]=q>>>8;if((q|0)!=(u|0)){break xa}f=p;B=f;if(na){p=0}else{s=q?q:1;g[p|0]=s;u=q?q+ -1|0:0;g[p+2|0]=u;g[p+1|0]=s>>>8;g[p+3|0]=u>>>8;p=q?0:85}p=o(p,16843009);g[B+4|0]=p;g[f+5|0]=p>>>8;g[f+6|0]=p>>>16;g[f+7|0]=p>>>24;break D}f=1;D=0;E=q}g[p+2|0]=s;g[p|0]=E;g[p+3|0]=s>>>8;g[p+1|0]=E>>>8;q=j[p+4|0]&-4|((j[F|0]&3)==3?D:f);g[p+4|0]=q;q=q&-15|((j[F|0]&12)==12?D:f)<<2;g[p+4|0]=q;q=q&-59|((j[F|0]&48)==48?D:f)<<4;g[p+4|0]=q;g[p+4|0]=q&21|(j[F|0]>191?D:f)<<6;q=j[p+5|0]&-4|((j[F+1|0]&3)==3?D:f);g[p+5|0]=q;q=q&-15|((j[F+1|0]&12)==12?D:f)<<2;g[p+5|0]=q;q=q&-59|((j[F+1|0]&48)==48?D:f)<<4;g[p+5|0]=q;g[p+5|0]=q&21|(j[F+1|0]>191?D:f)<<6;q=j[p+6|0]&-4|((j[F+2|0]&3)==3?D:f);g[p+6|0]=q;q=q&-15|((j[F+2|0]&12)==12?D:f)<<2;g[p+6|0]=q;q=q&-59|((j[F+2|0]&48)==48?D:f)<<4;g[p+6|0]=q;g[p+6|0]=q&21|(j[F+2|0]>191?D:f)<<6;q=j[p+7|0]&-4|((j[F+3|0]&3)==3?D:f);g[p+7|0]=q;q=q&-15|((j[F+3|0]&12)==12?D:f)<<2;g[p+7|0]=q;q=q&-59|((j[F+3|0]&48)==48?D:f)<<4;g[p+7|0]=q;g[p+7|0]=q&21|(j[F+3|0]>191?D:f)<<6;break D;case 4:f=o(O+_|0,m)+b|0;B=j[s+4|0];u=j[F+8|0];p=j[F+9|0];if((u|0)==(p|0)){if(u>>>0>=4){break e}p=j[s|0];D=i[((B<<4)+(u<<2)|0)+28352>>2]+(p<<3|p>>>2)|0;Fa:{if(D>>>0<256){break Fa}p=(D|0)>-1;D=255;if(p){break Fa}D=0}g[f+2|0]=0;g[f+3|0]=0;g[f+4|0]=0;g[f+5|0]=0;g[f+1|0]=D;g[f|0]=D;g[f+6|0]=0;g[f+7|0]=0;break D}Ga:{Ha:{if(j[F+10|0]!=2){q=0;switch(u|0){case 1:break Ga;case 0:break Ha;default:break E}}Fa(C- -64|0,s,B);q=j[(C- -64|0)+(u<<2)|0];g[f+1|0]=j[(C- -64|0)+(p<<2)|0];g[f|0]=q;q=j[f+2|0]&248|(p|0)==(j[F|0]&3);g[f+2|0]=q;q=q&193|((p|0)==(j[F|0]>>>2&3))<<3;g[f+2|0]=q;s=j[F|0];u=j[f+3|0];g[f+3|0]=u&254;g[f+2|0]=q&9|((p|0)==(s>>>4&3))<<6;q=u&240|((p|0)==(j[F|0]>>>6|0))<<1;g[f+3|0]=q;q=q&130|((p|0)==(j[F+1|0]&3))<<4;g[f+3|0]=q;s=j[F+1|0];u=j[f+4|0];g[f+4|0]=u&252;g[f+3|0]=q&18|((p|0)==(s>>>2&3))<<7;q=((p|0)==(j[F+1|0]>>>4&3))<<2;g[f+4|0]=q|u&224;g[f+4|0]=q|((p|0)==(j[F+1|0]>>>6|0))<<5;q=j[f+5|0]&248|(p|0)==(j[F+2|0]&3);g[f+5|0]=q;q=q&193|((p|0)==(j[F+2|0]>>>2&3))<<3;g[f+5|0]=q;s=j[F+2|0];u=j[f+6|0];g[f+6|0]=u&254;g[f+5|0]=q&9|((p|0)==(s>>>4&3))<<6;q=u&240|((p|0)==(j[F+2|0]>>>6|0))<<1;g[f+6|0]=q;q=q&130|((p|0)==(j[F+3|0]&3))<<4;g[f+6|0]=q;s=j[F+3|0];u=j[f+7|0];g[f+7|0]=u&252;g[f+6|0]=q&18|((p|0)==(s>>>2&3))<<7;q=((p|0)==(j[F+3|0]>>>4&3))<<2;g[f+7|0]=q|u&224;g[f+7|0]=q|((p|0)==(j[F+3|0]>>>6|0))<<5;break D}q=(p|0)==3?0:((p|0)==2)<<1;break E}q=(p|0)==3?1:(p|0)==2?3:0;break E;case 6:u=j[s+4|0];if(u>>>0>=8){break g}p=j[s|0];X=X&7|(p>>>0<31?p<<3:-8);p=j[s+1|0];ga=ga&7|(p>>>0<31?p:31)<<3;q=ga&255;p=q>>>24|0;B=X&255|q<<8;q=p;f=B;p=j[s+2|0];ia=ia&7|(p>>>0<31?p:31)<<3;B=ia&255;p=B>>>16|0;B=f|B<<16;D=p|q;W=W&3|u<<5|u<<2;q=W&255;p=q>>>8|0;q=q<<24|B;u=j[F+4|0]|(p|D)|j[F+5|0]<<8|j[F+6|0]<<16;p=j[F+7|0]<<24;G=O+aa|0;f=(G<<3)+ja|0;i[f>>2]=q;i[f+4>>2]=p|u;f=j[s+2|0];p=f>>>2|0;q=f<<3;f=j[s+1|0];u=f<<3|f>>>2;E=j[F+9|0];H=j[s+4|0]<<4;f=i[(H+(j[F+8|0]<<2)|0)+28352>>2];s=j[s|0];s=(s<<3|s>>>2)&255;B=f+s|0;Ia:{if(B>>>0<256){break Ia}D=(B|0)>-1;B=255;if(D){break Ia}B=0}p=p|q;q=u&255;D=q+f|0;Ja:{if(D>>>0<256){break Ja}u=(D|0)>-1;D=255;if(u){break Ja}D=0}u=p&255;f=u+f|0;Ka:{if(f>>>0<256){break Ka}p=(f|0)>-1;f=255;if(p){break Ka}f=0}p=i[(H+(E<<2)|0)+28352>>2];s=p+s|0;La:{if(s>>>0<256){break La}E=(s|0)>-1;s=255;if(E){break La}s=0}E=p+q|0;Ma:{if(E>>>0<256){break Ma}q=(E|0)>-1;E=255;if(q){break Ma}E=0}q=p+u|0;Na:{if(q>>>0<256){break Na}p=(q|0)>-1;q=255;if(p){break Na}q=0}if((B&255)>>>0>(s&255)>>>0){break ba}if((E&255)>>>0<(D&255)>>>0){break aa}if((q&255)>>>0<(f&255)>>>0){break $}f=j[f+218400|0]<<1|j[D+218144|0]<<5|j[B+218144|0]<<10|32768;if(f>>>0>=65536){break _}p=j[q+218736|0]|j[E+218736|0]<<5|j[s+218736|0]<<10|32768;if(p>>>0>=65536){break Z}i[(G<<2)+xa>>2]=f|p<<16;break D;case 7:if(!y){break Y}u=j[s+4|0];if(u>>>0>=8){break g}p=j[s|0];X=X&7|(p>>>0<31?p<<3:-8);p=j[s+1|0];ga=ga&7|(p>>>0<31?p:31)<<3;q=ga&255;p=q>>>24|0;B=X&255|q<<8;q=p;f=B;p=j[s+2|0];ia=ia&7|(p>>>0<31?p:31)<<3;B=ia&255;p=B>>>16|0;B=f|B<<16;G=p|q;W=W&3|u<<5|u<<2;q=W&255;p=q>>>8|0;q=q<<24|B;u=j[F|0]|(p|G)|j[F+1|0]<<8|j[F+2|0]<<16;p=j[F+3|0]<<24;D=O+aa|0;f=(D<<3)+ja|0;i[f>>2]=q;i[f+4>>2]=p|u;f=j[s+2|0];q=f>>>2|0;u=f<<3;f=j[s+1|0];B=f<<3|f>>>2;G=j[F+9|0];H=j[s+4|0]<<4;p=i[(H+(j[F+8|0]<<2)|0)+28352>>2];f=j[s|0];I=(f<<3|f>>>2)&255;f=p+I|0;Oa:{if(f>>>0<256){break Oa}s=(f|0)>-1;f=255;if(s){break Oa}f=0}q=q|u;B=B&255;s=B+p|0;Pa:{if(s>>>0<256){break Pa}u=(s|0)>-1;s=255;if(u){break Pa}s=0}q=q&255;u=q+p|0;Qa:{if(u>>>0<256){break Qa}p=(u|0)>-1;u=255;if(p){break Qa}u=0}p=i[(H+(G<<2)|0)+28352>>2];G=p+I|0;Ra:{if(G>>>0<256){break Ra}H=(G|0)>-1;G=255;if(H){break Ra}G=0}H=p+B|0;Sa:{if(H>>>0<256){break Sa}B=(H|0)>-1;H=255;if(B){break Sa}H=0}I=p+q|0;Ta:{if(I>>>0<256){break Ta}p=(I|0)>-1;I=255;if(p){break Ta}I=0}if((f&255)>>>0>(G&255)>>>0){break X}if((H&255)>>>0<(s&255)>>>0){break W}if((I&255)>>>0<(u&255)>>>0){break V}p=D<<2;q=p+y|0;B=L+o(k[q+2>>1],11)|0;D=j[B+9|0];q=E+(k[q>>1]<<3)|0;E=j[q+4|0]<<4;q=j[q+1|0];q=(q<<3|q>>>2)&255;B=i[(E+(j[B+8|0]<<2)|0)+28352>>2]+q|0;Ua:{if(B>>>0<256){break Ua}K=(B|0)>-1;B=255;if(K){break Ua}B=0}D=q+i[(E+(D<<2)|0)+28352>>2]|0;Va:{if(D>>>0<256){break Va}q=(D|0)>-1;D=255;if(q){break Va}D=0}if(B>>>0>D>>>0){break U}Wa:{if((B&255)==255){q=j[s+218144|0];f=j[f+218144|0];if((q|f)>>>0>=32){break T}f=f<<10|q<<5|j[u+218400|0]<<1|32768;if(f>>>0<65536){break Wa}break h}q=j[s+218400|0];f=j[f+218400|0];if((q|f)>>>0>15){break S}s=j[u+219504|0];u=j[B+219248|0];if((s|u)>>>0>=8){break S}f=f<<8|u<<12|q<<4|s<<1;if(f>>>0>=65536){break h}}Xa:{if(D+ -239>>>0<=16){u=j[I+218736|0];q=j[H+218736|0];s=j[G+218736|0];if((u|(q|s))>>>0>=32){break R}B=u|(s<<10|q<<5)|32768;if(B>>>0<65536){break Xa}break h}u=j[I+218992|0];q=j[H+218992|0];s=j[G+218992|0];if((u|(q|s))>>>0>=16){break Q}B=u|(q<<4|s<<8)|j[D+219904|0]<<12;if(B>>>0>=65536){break h}}i[p+xa>>2]=B<<16|f;break D;case 8:case 9:q=o(O+_|0,m)+b|0;f=q;i[f+8>>2]=3;i[f+12>>2]=0;i[f>>2]=32;i[f+4>>2]=-262144;u=j[s+4|0];D=j[F+9|0];L=j[F+8|0];f=j[s+2|0];p=j[s+1|0];s=j[s|0];Ya:{switch(j[F+10|0]+ -1|0){case 0:if(L>>>0>=4){break f}D=f>>>2|0;E=f<<3;p=p<<3|p>>>2;f=i[((u<<4)+(L<<2)|0)+28352>>2];B=f+(s<<3|s>>>2)|0;Za:{if(B>>>0<256){break Za}s=(B|0)>-1;B=255;if(s){break Za}B=0}s=D|E;D=f+p|0;_a:{if(D>>>0<256){break _a}p=(D|0)>-1;D=255;if(p){break _a}D=0}f=f+s|0;$a:{if(f>>>0<256){break $a}p=(f|0)>-1;f=255;if(p){break $a}f=0}E=B<<1;u=j[E+220161|0];p=u>>>24|0;B=u<<8;u=p;s=B;D=D<<1;B=j[D+220161|0];p=B>>>10|0;B=s|B<<22;u=p|u;s=B;B=f<<1;p=j[B+220161|0]<<4;f=s&532709120;u=(p|u)&2032;s=f;f=j[E+220160|0]&127;p=f>>>17|0;f=s|f<<15;u=p|u;s=f;f=j[D+220160|0]&127;p=f>>>3|0;f=s|f<<29;u=p|u;p=j[B+220160|0]<<11;i[q>>2]=f|32;i[q+4>>2]=p|u|-262144;B=31;D=66;s=2147483647;E=715827883;while(1){f=q+(D>>>3|0)|0;p=f;u=j[f|0];f=D&7;g[p|0]=u&(s<>>0>>0?f:B;D=f+D|0;s=s>>>f|0;E=E>>>f|0;B=B-f|0;if(B){continue}break}break D;case 1:g[C+131|0]=255;g[C+130|0]=f;g[C+129|0]=p;g[C+128|0]=s;Fa(C- -64|0,C+128|0,u);E=(C- -64|0)+(L<<2)|0;u=j[E+1|0]>>>1|0;s=u;p=s>>>10|0;B=s<<22;s=p;f=B;B=j[E|0]>>>1|0;p=B>>>24|0;G=f|B<<8;s=p|s;f=G;G=j[E+2|0]>>>1|0;p=G<<4;E=f|0;K=p|s;D=(C- -64|0)+(D<<2)|0;H=j[D|0]>>>1|0;s=H;p=s>>>17|0;ba=i[q>>2]&255|(s<<15|E);p=i[q+4>>2]&-262144|(p|K);M=p;s=p;I=j[D+1|0]>>>1|0;E=I;p=E>>>3|0;E=E<<29|ba;s=p|s;K=j[D+2|0]>>>1|0;p=K<<11;f=q;i[f>>2]=E;i[f+4>>2]=p|s;D=0;s=j[F|0];E=(L|0)==(s&3)?0:3;if(E&2){s=u;p=s>>>3|0;s=s<<29;u=p;p=B>>>17|0;s=B<<15|s;u=p|u|G<<11;B=s;s=H;p=s>>>24|0;s=B|s<<8;u=p|u;B=s;s=I;p=s>>>10|0;i[q>>2]=ba&255|(B|s<<22);i[f+4>>2]=M&-262144|(p|u|K<<4);D=3;E=0;s=j[F|0]}f=D^3;p=s&255;s=((L|0)==(p>>>6|0)?D:f)<<5|E|((L|0)==(p>>>2&3)?D:f)<<1|((L|0)==(p>>>4&3)?D:f)<<3;p=j[F+1|0];s=s|((L|0)==(p&3)?D:f)<<7|((L|0)==(p>>>6|0)?D:f)<<13|((L|0)==(p>>>2&3)?D:f)<<9|((L|0)==(p>>>4&3)?D:f)<<11;p=j[F+2|0];s=s|((L|0)==(p&3)?D:f)<<15|((L|0)==(p>>>6|0)?D:f)<<21|((L|0)==(p>>>2&3)?D:f)<<17|((L|0)==(p>>>4&3)?D:f)<<19;p=j[F+3|0];s=s|((L|0)==(p&3)?D:f)<<23|((L|0)==(p>>>6|0)?D:f)<<29|((L|0)==(p>>>2&3)?D:f)<<25|((L|0)==(p>>>4&3)?D:f)<<27;if((s|0)<=-1){break d}B=31;D=66;E=2147483647;while(1){f=q+(D>>>3|0)|0;p=f;u=j[f|0];f=D&7;g[p|0]=u&(E< >>0>>0?f:B;D=f+D|0;E=E>>>f|0;s=s>>>f|0;B=B-f|0;if(B){continue}break}break D;default:break Ya}}B=o(i[((L<<4)+(D<<2)|0)+321824>>2],10);u=u<<5;f=B+o(u+f|0,60)<<2;D=f+220672|0;p=B+o(p+u|0,60)<<2;E=p+220672|0;s=B+o(s+u|0,60)<<2;u=s+220672|0;B=k[f+220678>>1]+(k[p+220678>>1]+k[s+220678>>1]|0)|0;G=k[f+220674>>1]+(k[p+220674>>1]+k[s+220674>>1]|0)|0;H=B>>>0 >>0;I=k[f+220682>>1]+(k[p+220682>>1]+k[s+220682>>1]|0)|0;B=H?B:G;G=I>>>0>>0;M=G?2:H;H=k[f+220686>>1]+(k[p+220686>>1]+k[s+220686>>1]|0)|0;B=G?I:B;G=H>>>0>>0;M=G?3:M;I=k[f+220690>>1]+(k[p+220690>>1]+k[s+220690>>1]|0)|0;B=G?H:B;G=I>>>0>>0;M=G?4:M;H=k[f+220694>>1]+(k[p+220694>>1]+k[s+220694>>1]|0)|0;B=G?I:B;G=H>>>0>>0;M=G?5:M;I=k[f+220698>>1]+(k[p+220698>>1]+k[s+220698>>1]|0)|0;B=G?H:B;G=I>>>0>>0;M=G?6:M;H=k[f+220702>>1]+(k[p+220702>>1]+k[s+220702>>1]|0)|0;B=G?I:B;G=H>>>0>>0;M=G?7:M;I=k[f+220706>>1]+(k[p+220706>>1]+k[s+220706>>1]|0)|0;B=G?H:B;G=I>>>0>>0;B=(k[f+220710>>1]+(k[p+220710>>1]+k[s+220710>>1]|0)>>>0<(G?I:B)>>>0?9:G?8:M)<<2;ab:{if(j[(B|j[F|0]&3)+290864|0]&2){G=u+B|0;f=j[G+1|0];p=f>>>24|0;u=f<<8;f=p;s=u;E=B+E|0;u=j[E+1|0];p=u>>>10|0;u=s|u<<22;p=f|p;f=B+D|0;D=(p|j[f+1|0]<<4)&2032;s=u&532709120;u=j[G|0]&127;p=u>>>17|0;u=s|u<<15;G=p|D;s=u;u=j[E|0]&127;p=u>>>3|0;D=s|u<<29|32;p=p|G|-262144;E=p;i[q>>2]=D;i[q+4>>2]=p;s=3;break ab}G=u+B|0;s=j[G|0];p=s>>>24|0;u=s<<8;s=p;f=u;E=B+E|0;u=j[E|0];p=u>>>10|0;u=f|u<<22;s=p|s;f=u;u=B+D|0;p=j[u|0]<<4;D=f&532709120;H=(p|s)&2032;s=j[G+1|0]&127;p=s>>>17|0;s=s<<15|D;G=p|H;f=s;s=j[E+1|0]&127;p=s>>>3|0;D=f|s<<29|32;p=p|G|-262144;E=p;f=q;i[f>>2]=D;i[f+4>>2]=p;f=u+1|0;s=0}p=j[f|0]<<11;i[q>>2]=D;i[q+4>>2]=p|E;f=B+290864|0;p=j[F+3|0];u=j[F+2|0];B=(s^j[f+(p>>>2&3)|0])<<25|(s^j[f+(p>>>4&3)|0])<<27|(s^j[f+(p&3)|0])<<23|(s^j[f+(u>>>6|0)|0])<<21|(s^j[f+(u>>>4&3)|0])<<19|(s^j[f+(u>>>2&3)|0])<<17|(s^j[f+(u&3)|0])<<15;u=j[F+1|0];B=B|(s^j[f+(u>>>6|0)|0])<<13|(s^j[f+(u>>>4&3)|0])<<11|(s^j[f+(u>>>2&3)|0])<<9|(s^j[f+(u&3)|0])<<7;u=j[F|0];s=B|(s^j[f+(u>>>6|0)|0])<<5|(s^j[f+(u>>>4&3)|0])<<3|s^j[f+(u&3)|0]|(s^j[f+(u>>>2&3)|0])<<1|(s^j[f+(p>>>6|0)|0])<<29;if((s|0)<=-1){break d}B=31;D=66;E=2147483647;while(1){f=q+(D>>>3|0)|0;p=f;u=j[f|0];f=D&7;g[p|0]=u&(E< >>0>>0?f:B;D=f+D|0;E=E>>>f|0;s=s>>>f|0;B=B-f|0;if(B){continue}break}break D;case 10:f=o(O+_|0,m)+b|0;p=j[s+4|0];u=j[F+9|0];I=j[F+8|0];bb:{switch(j[F+10|0]+ -1|0){case 0:if(I>>>0>=4){break e}q=i[((p<<4)+(I<<2)|0)+28352>>2];p=j[s|0];B=q+(p<<3|p>>>2)|0;cb:{if(B>>>0<256){break cb}p=(B|0)>-1;B=255;if(p){break cb}B=0}p=i[f+12>>2];i[f+8>>2]=i[f+8>>2]&-4|B>>>6;i[f+12>>2]=p;s=i[f+4>>2]&262143;p=B<<26;i[f>>2]=i[f>>2];i[f+4>>2]=B<<18&66846720|(p|s);break D;case 1:q=j[s+1|0];q=q<<3|q>>>2;p=p<<4;E=q+i[p+28352>>2]|0;db:{if(E>>>0<256){break db}s=(E|0)>-1;E=255;if(s){break db}E=0}i[C+32>>2]=E;E=q+i[p+28356>>2]|0;eb:{if(E>>>0<256){break eb}s=(E|0)>-1;E=255;if(s){break eb}E=0}i[C+36>>2]=E;E=q+i[p+28360>>2]|0;fb:{if(E>>>0<256){break fb}s=(E|0)>-1;E=255;if(s){break fb}E=0}i[C+40>>2]=E;D=q+i[p+28364>>2]|0;gb:{if(D>>>0<256){break gb}p=(D|0)>-1;D=255;if(p){break gb}D=0}i[C+44>>2]=D;s=i[(C+32|0)+(I<<2)>>2];E=i[f+12>>2];K=i[f+8>>2]&-4;u=i[(C+32|0)+(u<<2)>>2];i[f+8>>2]=K|u>>>6&3;i[f+12>>2]=E;p=i[f+4>>2]&262143;L=p;ba=i[f>>2];i[f>>2]=ba;i[f+4>>2]=(s&255)<<18|p|u<<26;D=0;G=j[F|0];H=(I|0)==(G&3)?0:3;if(H&2){i[f+8>>2]=s>>>6&3|K;i[f+12>>2]=E;i[f>>2]=ba;i[f+4>>2]=L|((u&255)<<18|s<<26);G=j[F|0];H=0;D=3}p=D^3;q=j[F+3|0];s=G&255;u=((I|0)==(s>>>6|0)?D:p)<<5|H|((I|0)==(s>>>2&3)?D:p)<<1|((I|0)==(s>>>4&3)?D:p)<<3;s=j[F+1|0];u=u|((I|0)==(s&3)?D:p)<<7|((I|0)==(s>>>6|0)?D:p)<<13|((I|0)==(s>>>2&3)?D:p)<<9|((I|0)==(s>>>4&3)?D:p)<<11;s=j[F+2|0];s=((I|0)==(q&3)?D:p)<<23|(u|((I|0)==(s&3)?D:p)<<15|((I|0)==(s>>>6|0)?D:p)<<21|((I|0)==(s>>>2&3)?D:p)<<17|((I|0)==(s>>>4&3)?D:p)<<19)|((I|0)==(q>>>6|0)?D:p)<<29|((I|0)==(q>>>2&3)?D:p)<<25|((I|0)==(q>>>4&3)?D:p)<<27;if((s|0)<=-1){break d}B=31;D=97;E=2147483647;while(1){p=f+(D>>>3|0)|0;q=p;u=j[p|0];p=D&7;g[q|0]=u&(E< >>0>>0?p:B;D=p+D|0;E=E>>>p|0;s=s>>>p|0;B=B-p|0;if(B){continue}break}break D;default:break bb}}H=i[f+12>>2];K=i[f+8>>2]&-4;B=o((i[((I<<4)+(u<<2)|0)+321888>>2]+o(p,192)|0)+o(j[s|0],6)|0,3);s=j[B+282161|0];i[f+8>>2]=K|s>>>6;i[f+12>>2]=H;p=i[f+4>>2]&262143;I=p;ba=j[B+282160|0];E=ba;G=E<<18|p;L=i[f>>2];i[f>>2]=L;q=s;i[f+4>>2]=q<<26|G;B=j[B+282162|0];D=j[F|0];p=B>>>(D<<1&6)|0;G=p&3;if(p&2){i[f>>2]=L;i[f+4>>2]=I|(q<<18|E<<26);i[f+8>>2]=(ba&192)>>>6|K;i[f+12>>2]=H;G=G^3;D=j[F|0];B=B^255}p=j[F+3|0];q=j[F+2|0];s=j[F+1|0];s=B>>>(p<<1&6)<<23&25165824|(B>>>(q<<1&6)<<15&98304|(B>>>(s<<1&6)<<7&384|(B>>>(D>>>5&6)<<5&96|(B>>>(D>>>3&6)<<3&24|(B>>>(D>>>1&6)<<1&6|G)))|B>>>(s>>>1&6)<<9&1536|B>>>(s>>>3&6)<<11&6144|B>>>(s>>>5&6)<<13&24576)|B>>>(q>>>1&6)<<17&393216|B>>>(q>>>3&6)<<19&1572864|B>>>(q>>>5&6)<<21&6291456)|B>>>(p>>>1&6)<<25&100663296|B>>>(p>>>3&6)<<27&402653184|B>>>(p>>>5&6)<<29&1610612736;if((s|0)<=-1){break d}B=31;D=97;E=2147483647;while(1){p=f+(D>>>3|0)|0;q=p;u=j[p|0];p=D&7;g[q|0]=u&(E<
>>0>>0?p:B;D=p+D|0;E=E>>>p|0;s=s>>>p|0;B=B-p|0;if(B){continue}break}break D;case 11:f=o(O+_|0,m)+b|0;B=j[s+4|0];hb:{ib:{u=j[F+8|0];p=j[F+9|0];if((u|0)!=(p|0)){q=0;switch(u|0){case 1:break hb;case 0:break ib;default:break F}}if(u>>>0>=4){break e}p=j[s|0];B=i[((B<<4)+(u<<2)|0)+28352>>2]+(p<<3|p>>>2)|0;jb:{if(B>>>0<256){break jb}p=(B|0)>-1;B=255;if(p){break jb}B=0}h[f>>1]=B|7424;p=k[145594]|k[145595]<<16;h[f+2>>1]=p;h[f+4>>1]=p>>>16;h[f+6>>1]=k[145596];break D}q=(p|0)==3?0:((p|0)==2)<<1;break F}q=(p|0)==3?1:(p|0)==2?3:0;break F;case 12:h[C+136>>1]=0;K=o(O+_|0,m)+b|0;H=255;f=1;kb:{if(!w){break kb}q=L+o(k[K+2>>1],11)|0;f=j[q+10|0];if((f|0)!=1){break kb}p=E+(k[K>>1]<<3)|0;f=j[p+1|0];f=f<<3|f>>>2;p=j[p+4|0]<<4;G=f+i[p+28352>>2]|0;lb:{if(G>>>0<256){break lb}u=(G|0)>-1;G=255;if(u){break lb}G=0}i[C+32>>2]=G;G=f+i[p+28356>>2]|0;mb:{if(G>>>0<256){break mb}u=(G|0)>-1;G=255;if(u){break mb}G=0}i[C+36>>2]=G;G=f+i[p+28360>>2]|0;nb:{if(G>>>0<256){break nb}u=(G|0)>-1;G=255;if(u){break nb}G=0}i[C+40>>2]=G;B=f+i[p+28364>>2]|0;ob:{if(B>>>0<256){break ob}f=(B|0)>-1;B=255;if(f){break ob}B=0}i[C+44>>2]=B;H=i[(C+32|0)+(j[q+8|0]<<2)>>2];f=1}B=j[F+9|0];p=j[F+8|0];u=j[s+4|0];q=j[F+10|0];if(!((f|0)!=1|(q|0)!=1)){if(p>>>0>=4){break f}f=j[s+2|0];q=f>>>2|0;D=f<<3;f=j[s+1|0];E=f<<3|f>>>2;f=j[s|0];s=f<<3|f>>>2;f=i[((u<<4)+(p<<2)|0)+28352>>2];B=s+f|0;pb:{if(B>>>0<256){break pb}p=(B|0)>-1;B=255;if(p){break pb}B=0}p=q|D;q=f+E|0;qb:{if(q>>>0<256){break qb}s=(q|0)>-1;q=255;if(s){break qb}q=0}u=f+p|0;rb:{if(u>>>0<256){break rb}f=(u|0)>-1;u=255;if(f){break rb}u=0}i[K+12>>2]=0;i[K+4>>2]=-1;i[K+8>>2]=0;g[K|0]=-516;g[K+1|0]=16777213;g[K+2|0]=65535;g[K+3|0]=255;s=B<<8|B;f=16;B=64;while(1){p=K+(B>>3)|0;E=p;D=j[p|0];p=B&7;g[E|0]=D|s<
>>p|0;B=p+B|0;f=f-p|0;if(f){continue}break}s=q<<8|q;f=16;while(1){p=K+(B>>3)|0;q=p;E=j[p|0];p=B&7;g[q|0]=E|s<
>>p|0;B=p+B|0;f=f-p|0;if(f){continue}break}s=u<<8|u;f=16;while(1){p=K+(B>>3)|0;q=p;u=j[p|0];p=B&7;g[q|0]=u|s<
>>p|0;B=p+B|0;f=f-p|0;if(f){continue}break}s=H<<8|H;f=16;while(1){p=K+(B>>3)|0;q=p;u=j[p|0];p=B&7;g[q|0]=u|s<
>>p|0;B=p+B|0;f=f-p|0;if(f){continue}break}break D}sb:{tb:{ub:{if(!(f>>>0>2|q>>>0>2)){Fa(C- -64|0,s,u);q=(C- -64|0)+(p<<2)|0;f=j[q|0];g[C+128|0]=f;p=j[q+1|0];g[C+130|0]=p;q=j[q+2|0];g[C+132|0]=q;u=(C- -64|0)+(B<<2)|0;s=j[u|0];g[C+129|0]=s;G=j[u+1|0];g[C+131|0]=G;H=j[u+2|0];g[C+133|0]=H;ba=(s+G|0)+H|0;M=q+(f+p|0)|0;vb:{if(ba>>>0>=M>>>0){I=H;H=q;D=G;G=p;u=s;s=f;break vb}g[C+133|0]=q;g[C+132|0]=H;g[C+131|0]=p;g[C+130|0]=G;g[C+129|0]=f;g[C+128|0]=s;I=q;D=p;u=f}if(!w){break ub}q=L+o(k[K+2>>1],11)|0;f=j[q+9|0];ua=j[q+8|0];p=E+(k[K>>1]<<3)|0;E=j[p+1|0];E=E<<3|E>>>2;L=j[p+4|0]<<4;p=E+i[L+28352>>2]|0;wb:{if(p>>>0<256){break wb}va=(p|0)>-1;p=255;if(va){break wb}p=0}i[C+16>>2]=p;p=E+i[L+28356>>2]|0;xb:{if(p>>>0<256){break xb}va=(p|0)>-1;p=255;if(va){break xb}p=0}i[C+20>>2]=p;p=E+i[L+28360>>2]|0;yb:{if(p>>>0<256){break yb}va=(p|0)>-1;p=255;if(va){break yb}p=0}i[C+24>>2]=p;E=E+i[L+28364>>2]|0;zb:{if(E>>>0<256){break zb}p=(E|0)>-1;E=255;if(p){break zb}E=0}i[C+28>>2]=E;L=i[(C+16|0)+(ua<<2)>>2];g[C+134|0]=L;E=i[(C+16|0)+(f<<2)>>2];g[C+135|0]=E;p=j[q|0];g[C+139|0]=(f|0)==(p&3);g[C+145|0]=(f|0)==(p>>>6|0);g[C+141|0]=(f|0)==(p>>>2&3);g[C+143|0]=(f|0)==(p>>>4&3);p=j[q+1|0];g[C+147|0]=(f|0)==(p&3);g[C+153|0]=(f|0)==(p>>>6|0);g[C+149|0]=(f|0)==(p>>>2&3);g[C+151|0]=(f|0)==(p>>>4&3);p=j[q+2|0];g[C+155|0]=(f|0)==(p&3);g[C+161|0]=(f|0)==(p>>>6|0);g[C+157|0]=(f|0)==(p>>>2&3);g[C+159|0]=(f|0)==(p>>>4&3);p=j[q+3|0];g[C+163|0]=(f|0)==(p&3);g[C+169|0]=(f|0)==(p>>>6|0);g[C+165|0]=(f|0)==(p>>>2&3);g[C+167|0]=(f|0)==(p>>>4&3);E=E&255;q=L&255;break tb}if(w){E=E+(k[K>>1]<<3)|0;D=j[E+4|0];q=L+o(k[K+2>>1],11)|0;G=j[q+8|0];f=j[q+9|0];if((G|0)==(f|0)){q=j[E+1|0];q=q<<3|q>>>2;f=D<<4;H=q+i[f+28352>>2]|0;Ab:{if(H>>>0<256){break Ab}D=(H|0)>-1;H=255;if(D){break Ab}H=0}i[C+64>>2]=H;H=q+i[f+28356>>2]|0;Bb:{if(H>>>0<256){break Bb}D=(H|0)>-1;H=255;if(D){break Bb}H=0}i[C+68>>2]=H;H=q+i[f+28360>>2]|0;Cb:{if(H>>>0<256){break Cb}D=(H|0)>-1;H=255;if(D){break Cb}H=0}i[C+72>>2]=H;f=q+i[f+28364>>2]|0;Db:{if(f>>>0<256){break Db}q=(f|0)>-1;f=255;if(q){break Db}f=0}i[C+76>>2]=f;g[C+169|0]=1;g[C+167|0]=1;g[C+165|0]=1;g[C+163|0]=1;g[C+161|0]=1;g[C+159|0]=1;g[C+157|0]=1;g[C+155|0]=1;g[C+153|0]=1;g[C+151|0]=1;g[C+149|0]=1;g[C+147|0]=1;g[C+145|0]=1;g[C+143|0]=1;g[C+141|0]=1;g[C+139|0]=1;h[C+134>>1]=k[(i[(C- -64|0)+(G<<2)>>2]<<1)+323744>>1];break H}if((f|0)!=3|D>>>0<7|(j[q+10|0]!=2|G)){break sb}Fa(C- -64|0,E,D);g[C+134|0]=j[j[C+65|0]+324256|0];g[C+135|0]=j[j[C+77|0]+324256|0];D=j[q|0];g[C+139|0]=(f|0)==(D&3)?3:0;g[C+145|0]=(f|0)==(D>>>6|0)?3:0;g[C+141|0]=(f|0)==(D>>>2&3)?3:0;g[C+143|0]=(f|0)==(D>>>4&3)?3:0;D=j[q+1|0];g[C+147|0]=(f|0)==(D&3)?3:0;g[C+153|0]=(f|0)==(D>>>6|0)?3:0;g[C+149|0]=(f|0)==(D>>>2&3)?3:0;g[C+151|0]=(f|0)==(D>>>4&3)?3:0;D=j[q+2|0];g[C+155|0]=(f|0)==(D&3)?3:0;g[C+161|0]=(f|0)==(D>>>6|0)?3:0;g[C+157|0]=(f|0)==(D>>>2&3)?3:0;g[C+159|0]=(f|0)==(D>>>4&3)?3:0;q=j[q+3|0];g[C+163|0]=(f|0)==(q&3)?3:0;g[C+169|0]=(f|0)==(q>>>6|0)?3:0;g[C+165|0]=(f|0)==(q>>>2&3)?3:0;g[C+167|0]=(f|0)==(q>>>4&3)?3:0;break H}g[C+169|0]=0;g[C+167|0]=0;g[C+165|0]=0;g[C+163|0]=0;g[C+161|0]=0;g[C+159|0]=0;g[C+157|0]=0;g[C+155|0]=0;g[C+153|0]=0;g[C+151|0]=0;g[C+149|0]=0;g[C+147|0]=0;g[C+145|0]=0;g[C+143|0]=0;g[C+141|0]=0;g[C+139|0]=0;h[C+134>>1]=257;break H}g[C+169|0]=0;g[C+167|0]=0;g[C+165|0]=0;g[C+163|0]=0;g[C+161|0]=0;g[C+159|0]=0;g[C+157|0]=0;g[C+155|0]=0;g[C+153|0]=0;g[C+151|0]=0;g[C+149|0]=0;g[C+147|0]=0;g[C+145|0]=0;g[C+143|0]=0;g[C+141|0]=0;g[C+139|0]=0;h[C+134>>1]=65535;E=255;q=255}f=ba>>>0
>>0;p=j[F|0];g[C+144|0]=f^(B|0)==(p>>>6|0);L=f^(B|0)==(p&3);g[C+138|0]=L;g[C+142|0]=f^(B|0)==(p>>>4&3);g[C+140|0]=f^(B|0)==(p>>>2&3);p=j[F+1|0];g[C+152|0]=f^(B|0)==(p>>>6|0);g[C+146|0]=f^(B|0)==(p&3);g[C+150|0]=f^(B|0)==(p>>>4&3);g[C+148|0]=f^(B|0)==(p>>>2&3);p=j[F+2|0];g[C+160|0]=f^(B|0)==(p>>>6|0);g[C+154|0]=f^(B|0)==(p&3);g[C+158|0]=f^(B|0)==(p>>>4&3);g[C+156|0]=f^(B|0)==(p>>>2&3);p=j[F+3|0];g[C+168|0]=f^(B|0)==(p>>>6|0);g[C+162|0]=f^(B|0)==(p&3);g[C+166|0]=f^(B|0)==(p>>>4&3);g[C+164|0]=f^(B|0)==(p>>>2&3);i[K+12>>2]=0;g[K+11|0]=192;g[K+3|0]=0;g[K+4|0]=0;g[K+5|0]=0;g[K+6|0]=0;g[K+7|0]=0;g[K+8|0]=0;g[K+9|0]=0;g[K+10|0]=0;g[K+2|0]=1;g[K|0]=33857;g[K+1|0]=132;f=8;B=17;break G}G=i[((G<<4)+(f<<2)|0)+323488>>2];E=j[E+1|0];f=j[(G+(o(E,48)+o(D,6)|0)|0)+321952|0]<<2;h[C+134>>1]=k[(f+(o(E+(D<<5)|0,60)+o(G,10)<<2)|0)+29104>>1];f=f+290864|0;D=j[q|0];g[C+139|0]=j[f+(D&3)|0];g[C+145|0]=j[f+(D>>>6|0)|0];g[C+143|0]=j[f+(D>>>4&3)|0];g[C+141|0]=j[f+(D>>>2&3)|0];D=j[q+1|0];g[C+153|0]=j[f+(D>>>6|0)|0];g[C+147|0]=j[f+(D&3)|0];g[C+151|0]=j[f+(D>>>4&3)|0];g[C+149|0]=j[f+(D>>>2&3)|0];D=j[q+2|0];g[C+161|0]=j[f+(D>>>6|0)|0];g[C+155|0]=j[f+(D&3)|0];g[C+159|0]=j[f+(D>>>4&3)|0];g[C+157|0]=j[f+(D>>>2&3)|0];q=j[q+3|0];g[C+169|0]=j[f+(q>>>6|0)|0];g[C+163|0]=j[f+(q&3)|0];g[C+167|0]=j[f+(q>>>4&3)|0];g[C+165|0]=j[f+(q>>>2&3)|0];break H;case 13:A(19820,19512,8353,19588);x();case 15:A(19820,19512,8368,19588);x();case 20:p=o(O+_|0,m)+b|0;h[p+2>>1]=f;h[p>>1]=Q;break D;case 23:if((m|0)!=4){break P}p=j[s+1|0];p=p<<3|p>>>2;f=j[s+4|0]<<4;s=p+i[f+28352>>2]|0;Eb:{if(s>>>0<256){break Eb}q=(s|0)>-1;s=255;if(q){break Eb}s=0}q=O<<2;i[C+128>>2]=s;s=p+i[f+28356>>2]|0;Fb:{if(s>>>0<256){break Fb}B=(s|0)>-1;s=255;if(B){break Fb}s=0}B=q+ca|0;i[C+132>>2]=s;s=p+i[f+28360>>2]|0;Gb:{if(s>>>0<256){break Gb}D=(s|0)>-1;s=255;if(D){break Gb}s=0}B=B<<2;q=v-q|0;i[C+136>>2]=s;D=p+i[f+28364>>2]|0;Hb:{if(D>>>0<256){break Hb}f=(D|0)>-1;D=255;if(f){break Hb}D=0}f=b+B|0;i[C+140>>2]=D;if((q|0)<=3){if((P|0)==(ma|0)){break D}E=0;if(!q){break D}while(1){p=j[F+E|0];D=0;while(1){g[(D<<2|3)+f|0]=i[(C+128|(p>>>(D<<1)&3)<<2)>>2];D=D+1|0;if((u|0)!=(D|0)){continue}break}f=f+pa|0;E=E+1|0;if((Z|0)!=(E|0)){continue}break}break D}D=0;if((P|0)==(ma|0)){break D}while(1){p=j[D+F|0];g[f+3|0]=i[(C+128|(p&3)<<2)>>2];g[f+7|0]=i[(C+128|p&12)>>2];g[f+11|0]=i[(C+128|p>>>2&12)>>2];g[f+15|0]=i[(C+128|p>>>4&12)>>2];f=f+pa|0;D=D+1|0;if((Z|0)!=(D|0)){continue}break}break D;case 21:if((m|0)!=4){break O}Fa(C+128|0,s,j[s+4|0]);if((P|0)==(ma|0)){break D}f=O<<2;if((f|0)==(v|0)){break D}f=(f+ca<<2)+b|0;G=0;while(1){s=j[F+G|0];D=0;while(1){p=D<<2;q=C+128|(s>>>(D<<1)&3)<<2;g[p+f|0]=j[q|0];g[(p|1)+f|0]=j[q+1|0];g[(p|2)+f|0]=j[q+2|0];D=D+1|0;if((u|0)!=(D|0)){continue}break}f=f+pa|0;G=G+1|0;if((Z|0)!=(G|0)){continue}break}break D;case 22:if((m|0)!=4){break N}Fa(C+128|0,s,j[s+4|0]);if((P|0)==(ma|0)){break D}f=O<<2;if((f|0)==(v|0)){break D}D=(f+ca<<2)+b|0;G=0;while(1){s=j[F+G|0];f=0;while(1){p=f<<2;q=C+128|(s>>>(f<<1)&3)<<2;g[p+D|0]=j[q|0];g[(p|1)+D|0]=j[q+1|0];g[(p|2)+D|0]=j[q+2|0];g[(p|3)+D|0]=255;f=f+1|0;if((u|0)!=(f|0)){continue}break}D=D+pa|0;G=G+1|0;if((Z|0)!=(G|0)){continue}break}break D;case 24:case 25:if((m|0)!=2){break M}Fa(C+128|0,s,j[s+4|0]);p=C;Ib:{if((l|0)!=24){f=o(j[C+129|0],63)+128|0;q=(f>>>8|0)+f>>>3&8160;f=o(j[C+130|0],31)+128|0;q=q|(f>>>8|0)+f<<3&63488;f=o(j[C+128|0],31)+128|0;h[C+64>>1]=q|(f>>>8|0)+f>>>8;f=o(j[C+133|0],63)+128|0;q=(f>>>8|0)+f>>>3&8160;f=o(j[C+134|0],31)+128|0;q=q|(f>>>8|0)+f<<3&63488;f=o(j[C+132|0],31)+128|0;h[C+66>>1]=q|(f>>>8|0)+f>>>8;f=o(j[C+137|0],63)+128|0;q=(f>>>8|0)+f>>>3&8160;f=o(j[C+138|0],31)+128|0;q=q|(f>>>8|0)+f<<3&63488;f=o(j[C+136|0],31)+128|0;h[C+68>>1]=q|(f>>>8|0)+f>>>8;f=o(j[C+141|0],63)+128|0;q=(f>>>8|0)+f>>>3&8160;f=o(j[C+142|0],31)+128|0;D=q|(f>>>8|0)+f<<3&260096;f=ea;break Ib}f=o(j[C+129|0],63)+128|0;q=(f>>>8|0)+f>>>3&8160;f=o(j[C+128|0],31)+128|0;q=q|(f>>>8|0)+f<<3&63488;f=o(j[C+130|0],31)+128|0;h[C+64>>1]=q|(f>>>8|0)+f>>>8;f=o(j[C+133|0],63)+128|0;q=(f>>>8|0)+f>>>3&8160;f=o(j[C+132|0],31)+128|0;q=q|(f>>>8|0)+f<<3&63488;f=o(j[C+134|0],31)+128|0;h[C+66>>1]=q|(f>>>8|0)+f>>>8;f=o(j[C+137|0],63)+128|0;q=(f>>>8|0)+f>>>3&8160;f=o(j[C+136|0],31)+128|0;q=q|(f>>>8|0)+f<<3&63488;f=o(j[C+138|0],31)+128|0;h[C+68>>1]=q|(f>>>8|0)+f>>>8;f=o(j[C+141|0],63)+128|0;q=(f>>>8|0)+f>>>3&8160;f=o(j[C+140|0],31)+128|0;D=q|(f>>>8|0)+f<<3&260096;f=ka}f=o(j[f|0],31)+128|0;h[p+70>>1]=(f>>>8|0)+f>>>8|D;if((P|0)==(ma|0)){break D}f=O<<2;if((f|0)==(v|0)){break D}s=(f+ca<<1)+b|0;q=0;while(1){f=j[q+F|0];D=0;while(1){p=D<<1;h[p+s>>1]=k[(C- -64|0)+((f>>>p&3)<<1)>>1];D=D+1|0;if((u|0)!=(D|0)){continue}break}s=s+la|0;q=q+1|0;if((Z|0)!=(q|0)){continue}break}break D;case 26:if((m|0)!=2){break L}Fa(C+128|0,s,j[s+4|0]);f=o(j[C+130|0],15)+128|0;q=(f>>>8|0)+f>>>4&1008;f=o(j[C+128|0],15)+128|0;p=(f>>>8|0)+f<<4&61440;f=o(j[C+129|0],15)+128|0;h[C+64>>1]=q|(p|(f>>>8|0)+f&16128);f=o(j[C+134|0],15)+128|0;q=(f>>>8|0)+f>>>4&1008;f=o(j[C+132|0],15)+128|0;p=(f>>>8|0)+f<<4&61440;f=o(j[C+133|0],15)+128|0;h[C+66>>1]=q|(p|(f>>>8|0)+f&16128);f=o(j[C+138|0],15)+128|0;q=(f>>>8|0)+f>>>4&1008;f=o(j[C+136|0],15)+128|0;p=(f>>>8|0)+f<<4&61440;f=o(j[C+137|0],15)+128|0;h[C+68>>1]=q|(p|(f>>>8|0)+f&16128);f=o(j[C+142|0],15)+128|0;q=(f>>>8|0)+f>>>4&1008;f=o(j[C+140|0],15)+128|0;p=(f>>>8|0)+f<<4&61440;f=o(j[C+141|0],15)+128|0;h[C+70>>1]=q|(p|(f>>>8|0)+f&16128);if((P|0)==(ma|0)){break D}f=O<<2;if((f|0)==(v|0)){break D}E=(f+ca<<1)+b|0;G=0;while(1){f=j[F+G|0];D=0;while(1){p=D<<1;q=p+E|0;h[q>>1]=k[(C- -64|0)+((f>>>p&3)<<1)>>1]|k[q>>1]&15;D=D+1|0;if((u|0)!=(D|0)){continue}break}E=E+la|0;G=G+1|0;if((Z|0)!=(G|0)){continue}break}break D;case 28:if((m|0)!=2){break K}Fa(C+128|0,s,j[s+4|0]);f=o(j[C+129|0],15)+128|0;p=(f>>>8|0)+f&16128;f=o(j[C+128|0],15)+128|0;p=p|(f>>>8|0)+f<<4&61440;f=o(j[C+130|0],15)+128|0;h[C+64>>1]=p|((f>>>8|0)+f&16128)>>>4|15;f=o(j[C+133|0],15)+128|0;p=(f>>>8|0)+f&16128;f=o(j[C+132|0],15)+128|0;p=p|(f>>>8|0)+f<<4&61440;f=o(j[C+134|0],15)+128|0;h[C+66>>1]=p|((f>>>8|0)+f&16128)>>>4|15;f=o(j[C+137|0],15)+128|0;p=(f>>>8|0)+f&16128;f=o(j[C+136|0],15)+128|0;p=p|(f>>>8|0)+f<<4&61440;f=o(j[C+138|0],15)+128|0;h[C+68>>1]=p|((f>>>8|0)+f&16128)>>>4|15;f=o(j[C+141|0],15)+128|0;p=(f>>>8|0)+f&16128;f=o(j[C+140|0],15)+128|0;p=p|(f>>>8|0)+f<<4&61440;f=o(j[C+142|0],15)+128|0;h[C+70>>1]=p|((f>>>8|0)+f&16128)>>>4|15;if((P|0)==(ma|0)){break D}f=O<<2;if((f|0)==(v|0)){break D}s=(f+ca<<1)+b|0;q=0;while(1){f=j[q+F|0];D=0;while(1){p=D<<1;h[p+s>>1]=k[(C- -64|0)+((f>>>p&3)<<1)>>1];D=D+1|0;if((u|0)!=(D|0)){continue}break}s=s+la|0;q=q+1|0;if((Z|0)!=(q|0)){continue}break}break D;case 27:if((m|0)!=2){break J}Fa(C+128|0,s,j[s+4|0]);f=o(j[C+129|0],15)+128|0;h[C+64>>1]=(f>>>8|0)+f>>>8;f=o(j[C+133|0],15)+128|0;h[C+66>>1]=(f>>>8|0)+f>>>8;f=o(j[C+137|0],15)+128|0;h[C+68>>1]=(f>>>8|0)+f>>>8;f=o(j[C+141|0],15)+128|0;h[C+70>>1]=(f>>>8|0)+f>>>8;if((P|0)==(ma|0)){break D}f=O<<2;if((f|0)==(v|0)){break D}s=(f+ca<<1)+b|0;q=0;while(1){f=j[q+F|0];D=0;while(1){p=D<<1;h[p+s>>1]=k[(C- -64|0)+((f>>>p&3)<<1)>>1];D=D+1|0;if((u|0)!=(D|0)){continue}break}s=s+la|0;q=q+1|0;if((Z|0)!=(q|0)){continue}break}break D;case 18:f=o(O+_|0,m)+b|0;B=j[s+4|0];Jb:{Kb:{u=j[F+8|0];p=j[F+9|0];if((u|0)!=(p|0)){q=0;switch(u|0){case 1:break Jb;case 0:break Kb;default:break I}}if(u>>>0>=4){break e}p=j[s|0];B=i[((B<<4)+(u<<2)|0)+28352>>2]+(p<<3|p>>>2)|0;Lb:{if(B>>>0<256){break Lb}p=(B|0)>-1;B=255;if(p){break Lb}B=0}h[f>>1]=B|7424;p=k[145594]|k[145595]<<16;g[f+2|0]=p;g[f+3|0]=p>>>8;g[f+4|0]=p>>>16;g[f+5|0]=p>>>24;p=k[145596];g[f+6|0]=p;g[f+7|0]=p>>>8;break D}q=(p|0)==3?0:((p|0)==2)<<1;break I}q=(p|0)==3?1:(p|0)==2?3:0;break I;case 16:case 17:break D;default:break ya}}A(19820,19512,8657,19588);x()}f=(B<<8)+(f?305440:302880)|0;g[p+4|0]=j[f+j[F|0]|0];g[p+5|0]=j[f+j[F+1|0]|0];g[p+6|0]=j[f+j[F+2|0]|0];g[p+7|0]=j[f+j[F+3|0]|0];break D}A(19604,19512,8125,19588);x()}A(19636,19512,8239,19588);x()}A(19677,19512,8240,19588);x()}A(19718,19512,8241,19588);x()}A(218689,19512,3092,218115);x()}A(218689,19512,3123,218706);x()}A(19759,19512,8258,19588);x()}A(19636,19512,8275,19588);x()}A(19677,19512,8276,19588);x()}A(19718,19512,8277,19588);x()}A(19773,19512,8290,19588);x()}A(219777,19512,3147,219760);x()}A(219810,19512,3164,219760);x()}A(218656,19512,3154,219760);x()}A(219853,19512,3171,219760);x()}A(19822,19512,8400,19588);x()}A(19822,19512,8440,19588);x()}A(19822,19512,8469,19588);x()}A(19880,19512,8500,19588);x()}A(19880,19512,8543,19588);x()}A(19880,19512,8583,19588);x()}A(19880,19512,8614,19588);x()}p=j[s|0]+(B<<5)<<4|q<<2;q=j[p+291201|0];h[f>>1]=q<<12|j[p+291200|0]|q<<4&3840;D=k[p+291202>>1];u=j[F|0];p=(D>>>o(u&3,3)&7)<<13;B=D>>>o(u>>>6|0,3)<<9&3584;s=p;p=(D>>>o(u>>>2&3,3)&7)<<1;u=D>>>o(u>>>4&3,3)<<21&14680064|B;s=p|s;q=j[F+1|0];p=(D>>>o(q&3,3)&7)<<10;B=D>>>o(q>>>6|0,3)<<6&448|u;E=j[F+3|0];G=j[F+2|0];g[f+7|0]=B|(D>>>o(E>>>6|0,3)&7|D>>>o(G>>>6|0,3)<<3&56);s=p|s;u=D>>>o(q>>>4&3,3)<<18&1835008;q=D>>>o(q>>>2&3,3)&7;p=q>>>2|0;q=u|(q<<30|B);p=p|s|(D>>>o(G&3,3)&7)<<7;g[f+2|0]=p>>>8;g[f+3|0]=p|(D>>>o(E&3,3)&7)<<4;q=D>>>o(G>>>2&3,3)<<27&939524096|q;B=q|D>>>o(G>>>4&3,3)<<15&229376;g[f+5|0]=(p&65535)<<16|B>>>16;g[f+4|0]=(p&16777215)<<8|(D>>>o(E>>>2&3,3)<<24&117440512|q)>>>24;g[f+6|0]=(p&255)<<24|(D>>>o(E>>>4&3,3)<<12&28672|B)>>>8;break D}Mb:{if((p|0)==(B|0)){Fa(C- -64|0,s,u);B=1;f=(C- -64|0)+(p<<2)|0;q=j[f|0]<<1;p=j[q+323744|0];g[C+128|0]=p;q=j[q+323745|0];g[C+129|0]=q;u=j[f+1|0]<<1;s=j[u+323744|0];g[C+130|0]=s;u=j[u+323745|0];g[C+131|0]=u;D=j[f+2|0]<<1;f=j[D+323744|0];g[C+132|0]=f;D=j[D+323745|0];g[C+133|0]=D;if((i[(D<<2)+323552>>2]+(i[(u<<2)+323552>>2]+i[(q<<2)+323552>>2]|0)|0)<(i[(f<<2)+323552>>2]+(i[(s<<2)+323552>>2]+i[(p<<2)+323552>>2]|0)|0)){g[C+133|0]=f;g[C+132|0]=D;g[C+131|0]=s;g[C+130|0]=u;g[C+129|0]=p;g[C+128|0]=q;B=2}g[C+168|0]=B;g[C+166|0]=B;g[C+164|0]=B;g[C+162|0]=B;g[C+160|0]=B;g[C+158|0]=B;g[C+156|0]=B;g[C+154|0]=B;g[C+152|0]=B;g[C+150|0]=B;g[C+148|0]=B;g[C+146|0]=B;g[C+144|0]=B;g[C+142|0]=B;g[C+140|0]=B;g[C+138|0]=B;break Mb}if(!(j[F+10|0]!=2|u>>>0<7|(j[F+8|0]|j[F+9|0]!=3))){Fa(C- -64|0,s,u);f=j[j[C+64|0]+324256|0];g[C+128|0]=f;q=j[j[C+76|0]+324256|0];g[C+129|0]=q;s=j[j[C+65|0]+324256|0];g[C+130|0]=s;u=j[j[C+77|0]+324256|0];g[C+131|0]=u;B=j[j[C+66|0]+324256|0];g[C+132|0]=B;D=j[j[C+78|0]+324256|0];g[C+133|0]=D;if((i[(D<<2)+323552>>2]+(i[(u<<2)+323552>>2]+i[(q<<2)+323552>>2]|0)|0)<(i[(B<<2)+323552>>2]+(i[(s<<2)+323552>>2]+i[(f<<2)+323552>>2]|0)|0)){g[C+133|0]=B;g[C+132|0]=D;g[C+131|0]=s;g[C+130|0]=u;g[C+129|0]=f;g[C+128|0]=q;f=j[F|0];g[C+144|0]=(p|0)==(f>>>6|0)?3:0;g[C+138|0]=(p|0)==(f&3)?3:0;g[C+142|0]=(p|0)==(f>>>4&3)?3:0;g[C+140|0]=(p|0)==(f>>>2&3)?3:0;f=j[F+1|0];g[C+152|0]=(p|0)==(f>>>6|0)?3:0;g[C+146|0]=(p|0)==(f&3)?3:0;g[C+150|0]=(p|0)==(f>>>4&3)?3:0;g[C+148|0]=(p|0)==(f>>>2&3)?3:0;f=j[F+2|0];g[C+160|0]=(p|0)==(f>>>6|0)?3:0;g[C+154|0]=(p|0)==(f&3)?3:0;g[C+158|0]=(p|0)==(f>>>4&3)?3:0;g[C+156|0]=(p|0)==(f>>>2&3)?3:0;f=j[F+3|0];g[C+162|0]=(p|0)==(f&3)?3:0;g[C+166|0]=(p|0)==(f>>>4&3)?3:0;g[C+164|0]=(p|0)==(f>>>2&3)?3:0;g[C+168|0]=(p|0)==(f>>>6|0)?3:0;break Mb}f=j[F|0];g[C+144|0]=(p|0)==(f>>>6|0)?0:3;g[C+138|0]=(p|0)==(f&3)?0:3;g[C+142|0]=(p|0)==(f>>>4&3)?0:3;g[C+140|0]=(p|0)==(f>>>2&3)?0:3;f=j[F+1|0];g[C+152|0]=(p|0)==(f>>>6|0)?0:3;g[C+146|0]=(p|0)==(f&3)?0:3;g[C+150|0]=(p|0)==(f>>>4&3)?0:3;g[C+148|0]=(p|0)==(f>>>2&3)?0:3;f=j[F+2|0];g[C+160|0]=(p|0)==(f>>>6|0)?0:3;g[C+154|0]=(p|0)==(f&3)?0:3;g[C+158|0]=(p|0)==(f>>>4&3)?0:3;g[C+156|0]=(p|0)==(f>>>2&3)?0:3;f=j[F+3|0];g[C+162|0]=(p|0)==(f&3)?0:3;g[C+166|0]=(p|0)==(f>>>4&3)?0:3;g[C+164|0]=(p|0)==(f>>>2&3)?0:3;g[C+168|0]=(p|0)==(f>>>6|0)?0:3;break Mb}q=u<<5;u=o(i[((p<<4)+(B<<2)|0)+323488>>2],10);f=o(q+j[s+2|0]|0,60)+u<<2;p=u+o(q+j[s+1|0]|0,60)<<2;q=u+o(q+j[s|0]|0,60)<<2;u=k[f+29110>>1]+(k[p+29110>>1]+k[q+29110>>1]|0)|0;B=k[f+29106>>1]+(k[p+29106>>1]+k[q+29106>>1]|0)|0;s=u>>>0>>0;I=f;E=s;D=k[f+29114>>1]+(k[p+29114>>1]+k[q+29114>>1]|0)|0;s=s?u:B;u=D>>>0 >>0;E=u?2:E;B=k[f+29118>>1]+(k[p+29118>>1]+k[q+29118>>1]|0)|0;s=u?D:s;u=B>>>0>>0;E=u?3:E;D=k[f+29122>>1]+(k[p+29122>>1]+k[q+29122>>1]|0)|0;s=u?B:s;u=D>>>0>>0;E=u?4:E;B=k[f+29126>>1]+(k[p+29126>>1]+k[q+29126>>1]|0)|0;s=u?D:s;u=B>>>0>>0;E=u?5:E;D=k[f+29130>>1]+(k[p+29130>>1]+k[q+29130>>1]|0)|0;s=u?B:s;u=D>>>0>>0;E=u?6:E;B=k[f+29134>>1]+(k[p+29134>>1]+k[q+29134>>1]|0)|0;s=u?D:s;u=B>>>0>>0;E=u?7:E;D=k[f+29138>>1]+(k[p+29138>>1]+k[q+29138>>1]|0)|0;s=u?B:s;u=D>>>0>>0;f=(k[f+29142>>1]+(k[p+29142>>1]+k[q+29142>>1]|0)>>>0<(u?D:s)>>>0?9:u?8:E)<<2;u=I+f|0;s=j[u+29105|0];g[C+133|0]=s;u=j[u+29104|0];g[C+132|0]=u;B=f+p|0;p=j[B+29105|0];g[C+131|0]=p;B=j[B+29104|0];g[C+130|0]=B;D=f+q|0;q=j[D+29105|0];g[C+129|0]=q;D=j[D+29104|0];g[C+128|0]=D;if((i[(s<<2)+323552>>2]+(i[(p<<2)+323552>>2]+i[(q<<2)+323552>>2]|0)|0)>=(i[(u<<2)+323552>>2]+(i[(B<<2)+323552>>2]+i[(D<<2)+323552>>2]|0)|0)){f=f+290864|0;p=j[F|0];g[C+144|0]=j[f+(p>>>6|0)|0];g[C+138|0]=j[f+(p&3)|0];g[C+142|0]=j[f+(p>>>4&3)|0];g[C+140|0]=j[f+(p>>>2&3)|0];p=j[F+1|0];g[C+152|0]=j[f+(p>>>6|0)|0];g[C+146|0]=j[f+(p&3)|0];g[C+150|0]=j[f+(p>>>4&3)|0];g[C+148|0]=j[f+(p>>>2&3)|0];p=j[F+2|0];g[C+160|0]=j[f+(p>>>6|0)|0];g[C+154|0]=j[f+(p&3)|0];g[C+158|0]=j[f+(p>>>4&3)|0];g[C+156|0]=j[f+(p>>>2&3)|0];p=j[F+3|0];g[C+168|0]=j[f+(p>>>6|0)|0];g[C+162|0]=j[f+(p&3)|0];g[C+166|0]=j[f+(p>>>4&3)|0];g[C+164|0]=j[f+(p>>>2&3)|0];break Mb}g[C+133|0]=u;g[C+132|0]=s;g[C+131|0]=B;g[C+130|0]=p;g[C+129|0]=D;g[C+128|0]=q;f=f+290864|0;p=j[F|0];g[C+144|0]=3-j[f+(p>>>6|0)|0];g[C+138|0]=3-j[f+(p&3)|0];g[C+142|0]=3-j[f+(p>>>4&3)|0];g[C+140|0]=3-j[f+(p>>>2&3)|0];p=j[F+1|0];g[C+152|0]=3-j[f+(p>>>6|0)|0];g[C+146|0]=3-j[f+(p&3)|0];g[C+150|0]=3-j[f+(p>>>4&3)|0];g[C+148|0]=3-j[f+(p>>>2&3)|0];p=j[F+2|0];g[C+160|0]=3-j[f+(p>>>6|0)|0];g[C+154|0]=3-j[f+(p&3)|0];g[C+158|0]=3-j[f+(p>>>4&3)|0];g[C+156|0]=3-j[f+(p>>>2&3)|0];p=j[F+3|0];g[C+168|0]=3-j[f+(p>>>6|0)|0];g[C+162|0]=3-j[f+(p&3)|0];g[C+166|0]=3-j[f+(p>>>4&3)|0];g[C+164|0]=3-j[f+(p>>>2&3)|0]}i[K+8>>2]=0;i[K+12>>2]=0;g[K+7|0]=192;B=0;g[K+3|0]=0;g[K+4|0]=0;g[K+5|0]=0;g[K+6|0]=0;g[K+2|0]=1;g[K|0]=33858;g[K+1|0]=132;i[C+64>>2]=17;ab(K,C+128|0,C- -64|0,4);ab(K,sa,C- -64|0,4);while(1){f=126-(B<<1)|0;p=K+(f>>>3|0)|0;g[p|0]=j[p|0]|j[j[(C+B|0)+138|0]+290904|0]<<(f&6);B=B+1|0;if((B|0)!=32){continue}break}break D}while(1){p=K+(B>>3)|0;M=p;ua=j[p|0];p=B&7;g[M|0]=ua|s<>>p|0;B=p+B|0;f=f-p|0;if(f){continue}break}f=8;while(1){p=K+(B>>3)|0;s=p;M=j[p|0];p=B&7;g[s|0]=M|u<
>>p|0;B=p+B|0;f=f-p|0;if(f){continue}break}f=8;while(1){p=K+(B>>3)|0;s=p;u=j[p|0];p=B&7;g[s|0]=u|G<
>>p|0;B=p+B|0;f=f-p|0;if(f){continue}break}f=8;while(1){p=K+(B>>3)|0;s=p;u=j[p|0];p=B&7;g[s|0]=u|D<
>>p|0;B=p+B|0;f=f-p|0;if(f){continue}break}f=8;while(1){p=K+(B>>3)|0;s=p;u=j[p|0];p=B&7;g[s|0]=u|H<
>>p|0;B=p+B|0;f=f-p|0;if(f){continue}break}s=8;f=8;while(1){p=K+(B>>3)|0;u=p;D=j[p|0];p=B&7;g[u|0]=D|I<
>>p|0;B=p+B|0;f=f-p|0;if(f){continue}break}while(1){f=K+(B>>3)|0;p=B&7;g[f|0]=j[f|0]|q<
>>p|0;B=p+B|0;s=s-p|0;if(s){continue}break}while(1){p=K+(B>>3)|0;q=p;s=j[p|0];p=B&7;g[q|0]=s|E<
>>p|0;B=p+B|0;f=f-p|0;if(f){continue}break}g[K+15|0]=j[K+15|0]|(L?-128:0);B=1;while(1){f=127-B|0;p=K+(f>>>3|0)|0;g[p|0]=j[p|0]|j[(C+B|0)+138|0]<<(f&7);B=B+1|0;if((B|0)!=32){continue}break}break D}p=j[s|0]+(B<<5)<<4|q<<2;q=j[p+286769|0];h[f>>1]=q<<12|j[p+286768|0]|q<<4&3840;D=k[p+286770>>1];u=j[F|0];p=(D>>>o(u&3,3)&7)<<13;B=D>>>o(u>>>6|0,3)<<9&3584;s=p;p=(D>>>o(u>>>2&3,3)&7)<<1;u=D>>>o(u>>>4&3,3)<<21&14680064|B;s=p|s;q=j[F+1|0];p=(D>>>o(q&3,3)&7)<<10;B=D>>>o(q>>>6|0,3)<<6&448|u;E=j[F+3|0];G=j[F+2|0];g[f+7|0]=B|(D>>>o(E>>>6|0,3)&7|D>>>o(G>>>6|0,3)<<3&56);s=p|s;u=D>>>o(q>>>4&3,3)<<18&1835008;q=D>>>o(q>>>2&3,3)&7;p=q>>>2|0;q=u|(q<<30|B);p=p|s|(D>>>o(G&3,3)&7)<<7;g[f+2|0]=p>>>8;g[f+3|0]=p|(D>>>o(E&3,3)&7)<<4;q=D>>>o(G>>>2&3,3)<<27&939524096|q;B=q|D>>>o(G>>>4&3,3)<<15&229376;g[f+5|0]=(p&65535)<<16|B>>>16;g[f+4|0]=(p&16777215)<<8|(D>>>o(E>>>2&3,3)<<24&117440512|q)>>>24;g[f+6|0]=(p&255)<<24|(D>>>o(E>>>4&3,3)<<12&28672|B)>>>8;break D}p=j[s|0]+(B<<5)<<4|q<<2;q=k[p+214e3>>1];g[f|0]=q;g[f+1|0]=q>>>8;p=k[p+214002>>1];s=p>>>o(j[F|0]&3,3)&7;q=j[f+2|0];g[f+2|0]=s|q&248;s=s|q&192;q=j[f+3|0]<<8;s=p>>>o(j[F|0]>>>2&3,3)<<3&56|(s|q);g[f+2|0]=s;q=p>>>o(j[F|0]>>>4&3,3)<<6&448|(s&63|q&65024);g[f+2|0]=q;g[f+3|0]=q>>>8;s=p>>>o(j[F|0]>>>6|0,3)<<1&14;q=q>>>8|0;g[f+3|0]=s|q&241;u=q&129;q=j[f+4|0]<<8;s=p>>>o(j[F+1|0]&3,3)<<4&112|(u|(q|s));g[f+3|0]=s;q=p>>>o(j[F+1|0]>>>2&3,3)<<7&896|(s&127|q&64512);g[f+3|0]=q;g[f+4|0]=q>>>8;q=p>>>o(j[F+1|0]>>>4&3,3)<<2&28|q>>>8&227;g[f+4|0]=q;g[f+4|0]=q&31|p>>>o(j[F+1|0]>>>6|0,3)<<5;s=p>>>o(j[F+2|0]&3,3)&7;q=j[f+5|0];g[f+5|0]=s|q&248;u=q&192;q=j[f+6|0]<<8;s=p>>>o(j[F+2|0]>>>2&3,3)<<3&56|(s|(u|q));g[f+5|0]=s;q=p>>>o(j[F+2|0]>>>4&3,3)<<6&448|(s&63|q&65024);g[f+5|0]=q;g[f+6|0]=q>>>8;s=q>>>8&241;q=j[f+7|0]<<8;s=s|(q|p>>>o(j[F+2|0]>>>6|0,3)<<1&14);g[f+6|0]=s;s=s&143|(q|p>>>o(j[F+3|0]&3,3)<<4&112);g[f+6|0]=s;u=s&127;s=p>>>o(j[F+3|0]>>>2&3,3)<<7;g[f+6|0]=u|s;q=(s&768|q&64512)>>>8|0;g[f+7|0]=q;q=q&227|p>>>o(j[F+3|0]>>>4&3,3)<<2&28;g[f+7|0]=q;g[f+7|0]=q&31|p>>>o(j[F+3|0]>>>6|0,3)<<5}J=J+ -4|0;O=O+1|0;u=O>>>0
>>0;if((c|0)!=(O|0)){continue}break o}break}wa(ja)}if(!(u&1)){break o}B=0;break m}T=T+ -4|0;R=R+1|0;if((R|0)!=(d|0)){continue}break}B=0;if(da){break m}}Nb:{Ob:{switch(l+ -6|0){case 0:if((d|0)<1){break Nb}G=c+ -1|0;a=G?32-r(G)|0:0;O=d+ -1|0;e=O?32-r(O)|0:0;Y=a>>>0 >>0?a:e;ka=Y<<1;V=-1< >2]=e;a=i[e+(G<<2)>>2];if(!(a&32768)){break b}l=f+(C+128|0)|0;n=a&30;i[l>>2]=(o(((a>>>10&31)+(a>>>5&31)|0)+(n>>>4|n)|0,255)>>>0)/31;Qb:{if((a|0)>=0){break Qb}f=f+(C- -64|0)|0;i[f>>2]=(o(((a>>>26&31)+(a>>>21&31)|0)+(a>>>16&31)|0,255)>>>0)/31;a=i[e>>2];if(!(a&32768)){break b}n=a&30;i[l+16>>2]=(o(((a>>>10&31)+(a>>>5&31)|0)+(n>>>4|n)|0,255)>>>0)/31;if((a|0)>-1){break Qb}i[f+16>>2]=(o(((a>>>26&31)+(a>>>21&31)|0)+(a>>>16&31)|0,255)>>>0)/31;a=i[e+U>>2];if(!(a&32768)){break b}e=a&30;i[l+32>>2]=(o(((a>>>10&31)+(a>>>5&31)|0)+(e>>>4|e)|0,255)>>>0)/31;if((a|0)>-1){break Qb}i[f+32>>2]=(o(((a>>>26&31)+(a>>>21&31)|0)+(a>>>16&31)|0,255)>>>0)/31;D=D+1|0;if((D|0)==3){break Pb}continue}break}break c}if((c|0)>=1){da=k[((E&255)<<1)+295296>>1]|k[(E>>>7&33554430)+295296>>1]<<16;_=E>>>Y< >2];p=i[C+72>>2];R=i[C+152>>2];l=i[C+136>>2];f=i[C+84>>2];z=i[C+68>>2];s=i[C+80>>2];J=i[C+64>>2];a=i[C+148>>2];t=i[C+132>>2];Q=i[C+144>>2];n=i[C+128>>2];P=i[C+60>>2];Z=i[C+56>>2];ma=i[C+52>>2];Rb:{while(1){v=Q;m=a;w=s;u=f;y=R;B=e;f=da|k[(q>>>7&33554430)+295296>>1]<<17|k[((q&255)<<1)+295296>>1]<<1;a=f;Sb:{if((c|0)==(d|0)){break Sb}f=f&V;a=f|q>>>Y< >>0>d>>>0){break Sb}a=f|_}I=(a<<3)+b|0;i[I+4>>2]=i[(na<<2)+xa>>2];D=(na<<3)+ja|0;a=i[D>>2];e=a>>>25&112;a=j[(a>>>19&31)+297152|0]+(j[(a>>>11&31)+297152|0]+j[(a>>>3&31)+297152|0]|0)<<4;i[C+44>>2]=i[e+295808>>2]+a;i[C+40>>2]=a+i[e+295812>>2];i[C+36>>2]=a+i[e+295820>>2];i[C+32>>2]=a+i[e+295816>>2];q=q+1|0;H=(G&q)<<2;a=i[H+ma>>2];if(a&32768){e=a&30;Q=(o(((a>>>10&31)+(a>>>5&31)|0)+(e>>>4|e)|0,255)>>>0)/31|0;if((a|0)>=0){break c}s=(o(((a>>>26&31)+(a>>>21&31)|0)+(a>>>16&31)|0,255)>>>0)/31|0;e=i[H+Z>>2];if(!(e&32768)){break b}a=e&30;a=(o(((e>>>10&31)+(e>>>5&31)|0)+(a>>>4|a)|0,255)>>>0)/31|0;if((e|0)>=0){break c}f=(o(((e>>>26&31)+(e>>>21&31)|0)+(e>>>16&31)|0,255)>>>0)/31|0;e=i[H+P>>2];if(!(e&32768)){break b}H=e&30;R=(o(((e>>>10&31)+(e>>>5&31)|0)+(H>>>4|H)|0,255)>>>0)/31|0;if((e|0)>=0){break c}ua=I;ea=j[D+5|0];K=j[D+7|0];H=ea&240|K>>>4;L=o(m,6);ca=L+o(v,6)|0;I=ca+(n+t<<1)|0;N=i[(C+32|0)+(j[H+295936|0]<<2)>>2]-I<<4;W=o(u,6);$=W+o(w,6)|0;F=$+(z+J<<1)|0;fa=(F|0)<(I|0);N=fa?0-N|0:N;I=F-I|0;I=fa?0-I|0:I;S=(N|0)>(o(I,13)|0)?12:(N|0)>I<<3?8:((N|0)>(o(I,3)|0))<<2;I=ea<<4&240|K&15;fa=n+v|0;ea=m+t|0;N=fa+ea<<2;K=i[(C+32|0)+(j[I+295936|0]<<2)>>2]-N<<4;T=0-K|0;M=K;X=w+J|0;K=u+z|0;ga=X+K<<2;ia=(ga|0)<(N|0);F=ia?T:M;N=ga-N|0;N=ia?0-N|0:N;M=S|((F|0)>(o(N,13)|0)?3:(F|0)>N<<3?2:(F|0)>(o(N,3)|0));N=(L+o(t,6)|0)+(fa<<1)|0;F=i[(C+32|0)+(j[I+296192|0]<<2)>>2]-N<<4;L=(W+o(z,6)|0)+(X<<1)|0;W=(L|0)<(N|0);F=W?0-F|0:F;N=L-N|0;N=W?0-N|0:N;S=M|((F|0)>(o(N,13)|0)?768:(F|0)>N<<3?512:((F|0)>(o(N,3)|0))<<8);X=o(v,3);W=o(m,9);fa=W+o(t,3)|0;n=X+(fa+n|0)|0;N=i[(C+32|0)+(j[H+296192|0]<<2)>>2]-n<<4;T=0-N|0;M=N;oa=o(w,3);ga=o(u,9);ia=ga+o(z,3)|0;N=oa+(ia+J|0)|0;F=(N|0)<(n|0);J=F?T:M;n=N-n|0;n=F?0-n|0:n;M=S|((J|0)>(o(n,13)|0)?3072:(J|0)>n<<3?2048:((J|0)>(o(n,3)|0))<<10);N=j[D+4|0];F=j[D+6|0];n=N<<4&240|F&15;D=m+v<<3;J=i[(C+32|0)+(j[n+295936|0]<<2)>>2]-D<<4;L=u+w<<3;pa=(L|0)<(D|0);J=pa?0-J|0:J;D=L-D|0;D=pa?0-D|0:D;M=M|((J|0)>(o(D,13)|0)?48:(J|0)>D<<3?32:((J|0)>(o(D,3)|0))<<4);D=N&240|F>>>4;J=(ca+(Q<<1)|0)+(a<<1)|0;N=i[(C+32|0)+(j[D+295936|0]<<2)>>2]-J<<4;F=($+(s<<1)|0)+(f<<1)|0;L=(F|0)<(J|0);N=L?0-N|0:N;J=F-J|0;J=L?0-J|0:J;S=M|((N|0)>(o(J,13)|0)?192:(N|0)>J<<3?128:((N|0)>(o(J,3)|0))<<6);J=o(m,12);F=J+(v<<2)|0;N=i[(C+32|0)+(j[n+296192|0]<<2)>>2]-F<<4;T=0-N|0;M=N;N=o(u,12);ca=N+(w<<2)|0;$=(ca|0)<(F|0);L=$?T:M;F=ca-F|0;F=$?0-F|0:F;M=S|((L|0)>(o(F,13)|0)?12288:(L|0)>F<<3?8192:((L|0)>(o(F,3)|0))<<12);ca=W+o(a,3)|0;F=(ca+X|0)+Q|0;L=i[(C+32|0)+(j[D+296192|0]<<2)>>2]-F<<4;W=ga+o(f,3)|0;$=(W+oa|0)+s|0;X=($|0)<(F|0);L=X?0-L|0:L;F=$-F|0;F=X?0-F|0:F;M=M|((L|0)>(o(F,13)|0)?49152:(L|0)>F<<3?32768:((L|0)>(o(F,3)|0))<<14);F=ea<<3;L=i[(C+32|0)+(j[I+296448|0]<<2)>>2]-F<<4;$=K<<3;X=($|0)<(F|0);L=X?0-L|0:L;F=$-F|0;F=X?0-F|0:F;S=M|((L|0)>(o(F,13)|0)?196608:(L|0)>F<<3?131072:((L|0)>(o(F,3)|0))<<16);t=J+(t<<2)|0;F=i[(C+32|0)+(j[H+296448|0]<<2)>>2]-t<<4;T=0-F|0;M=F;F=N+(z<<2)|0;L=(F|0)<(t|0);z=L?T:M;t=F-t|0;t=L?0-t|0:t;M=S|((z|0)>(o(t,13)|0)?786432:(z|0)>t<<3?524288:((z|0)>(o(t,3)|0))<<18);t=o(ea,6)+(l+y<<1)|0;z=i[(C+32|0)+(j[I+296704|0]<<2)>>2]-t<<4;I=o(K,6)+(p+B<<1)|0;ea=(I|0)<(t|0);z=ea?0-z|0:z;t=I-t|0;t=ea?0-t|0:t;S=M|((z|0)>(o(t,13)|0)?50331648:(z|0)>t<<3?33554432:((z|0)>(o(t,3)|0))<<24);t=o(y,3);l=fa+(t+l|0)|0;z=i[(C+32|0)+(j[H+296704|0]<<2)>>2]-l<<4;T=0-z|0;M=z;z=o(B,3);H=ia+(z+p|0)|0;I=(H|0)<(l|0);p=I?T:M;l=H-l|0;l=I?0-l|0:l;M=S|((p|0)>(o(l,13)|0)?201326592:(p|0)>l<<3?134217728:((p|0)>(o(l,3)|0))<<26);l=m<<4;p=i[(C+32|0)+(j[n+296448|0]<<2)>>2]-l<<4;H=u<<4;I=(H|0)<(l|0);p=I?0-p|0:p;l=H-l|0;l=I?0-l|0:l;M=M|((p|0)>(o(l,13)|0)?3145728:(p|0)>l<<3?2097152:((p|0)>(o(l,3)|0))<<20);l=J+(a<<2)|0;p=i[(C+32|0)+(j[D+296448|0]<<2)>>2]-l<<4;H=N+(f<<2)|0;I=(H|0)<(l|0);p=I?0-p|0:p;l=H-l|0;l=I?0-l|0:l;I=M|((p|0)>(o(l,13)|0)?12582912:(p|0)>l<<3?8388608:((p|0)>(o(l,3)|0))<<22);l=J+(y<<2)|0;n=i[(C+32|0)+(j[n+296704|0]<<2)>>2]-l<<4;p=N+(B<<2)|0;J=(p|0)<(l|0);n=J?0-n|0:n;l=p-l|0;l=J?0-l|0:l;N=I|((n|0)>(o(l,13)|0)?805306368:(n|0)>l<<3?536870912:((n|0)>(o(l,3)|0))<<28);l=(t+ca|0)+R|0;n=i[(C+32|0)+(j[D+296704|0]<<2)>>2]-l<<4;e=(o(((e>>>26&31)+(e>>>21&31)|0)+(e>>>16&31)|0,255)>>>0)/31|0;p=e+(z+W|0)|0;t=(p|0)<(l|0);n=t?0-n|0:n;l=p-l|0;l=t?0-l|0:l;i[ua>>2]=N|((n|0)>(o(l,13)|0)?-1073741824:(n|0)>l<<3?-2147483648:((n|0)>(o(l,3)|0))<<30);na=na+1|0;p=B;l=y;z=u;J=w;t=m;n=v;if((c|0)==(q|0)){break Rb}continue}break}break b}i[C+96>>2]=s;i[C+160>>2]=Q;i[C+164>>2]=a;i[C+100>>2]=f;i[C+168>>2]=R;i[C+104>>2]=e;i[C+144>>2]=Q;i[C+128>>2]=n;i[C+148>>2]=a;i[C+132>>2]=t;i[C+80>>2]=s;i[C+64>>2]=J;i[C+84>>2]=f;i[C+68>>2]=z;i[C+152>>2]=R;i[C+136>>2]=l;i[C+88>>2]=e;i[C+72>>2]=p}E=E+1|0;if((E|0)!=(d|0)){continue}break}break Nb;case 1:break Ob;default:break Nb}}if((d|0)<1){break Nb}ea=c+ -1|0;e=ea?32-r(ea)|0:0;F=d+ -1|0;f=F?32-r(F)|0:0;L=e>>>0 >>0?e:f;V=L<<1;ma=-1< >2];W=i[a>>2];$=(ea&1)<<2;na=0;ka=0;while(1){n=ka+ -1|0;D=0;while(1){f=D<<2;l=(o(F&n+D,c)<<2)+xa|0;i[f+(C+52|0)>>2]=l;e=i[l+(ea<<2)>>2];Tb:{if(e&32768){z=(e>>>1&15)+297184|0;t=(e>>>5&31)+297152|0;q=(e>>>10&31)+297152|0;m=255;break Tb}z=(e>>>1&7)+297200|0;t=(e>>>4&15)+297184|0;q=(e>>>8&15)+297184|0;m=j[(e>>>12&7)+297208|0]}a=f+(C+128|0)|0;i[a>>2]=j[z|0]+(j[q|0]+(m+j[t|0]|0)|0);m=e>>>16|0;Ub:{if((e|0)<=-1){z=(m&31)+297152|0;t=(e>>>21&31)+297152|0;B=255;m=(e>>>26&31)+297152|0;break Ub}z=(m&15)+297184|0;t=(e>>>20&15)+297184|0;B=j[(e>>>28|0)+297208|0];m=(e>>>24&15)+297184|0}e=f+(C- -64|0)|0;i[e>>2]=j[z|0]+(j[m|0]+(j[t|0]+B|0)|0);f=i[l>>2];Vb:{if(f&32768){z=(f>>>1&15)+297184|0;t=(f>>>5&31)+297152|0;q=(f>>>10&31)+297152|0;m=255;break Vb}z=(f>>>1&7)+297200|0;t=(f>>>4&15)+297184|0;q=(f>>>8&15)+297184|0;m=j[(f>>>12&7)+297208|0]}i[a+16>>2]=j[z|0]+(j[q|0]+(m+j[t|0]|0)|0);m=f>>>16|0;Wb:{if((f|0)<=-1){z=(m&31)+297152|0;t=(f>>>21&31)+297152|0;B=255;f=(f>>>26&31)+297152|0;break Wb}z=(m&15)+297184|0;t=(f>>>20&15)+297184|0;B=j[(f>>>28|0)+297208|0];f=(f>>>24&15)+297184|0}i[e+16>>2]=j[z|0]+(j[f|0]+(j[t|0]+B|0)|0);f=i[l+$>>2];Xb:{if(f&32768){z=(f>>>5&31)+297152|0;t=(f>>>10&31)+297152|0;q=255;l=(f>>>1&15)+297184|0;break Xb}z=(f>>>4&15)+297184|0;t=(f>>>8&15)+297184|0;q=j[(f>>>12&7)+297208|0];l=(f>>>1&7)+297200|0}i[a+32>>2]=j[l|0]+(j[t|0]+(j[z|0]+q|0)|0);a=f>>>16|0;Yb:{if((f|0)<=-1){E=(f>>>21&31)+297152|0;z=(f>>>26&31)+297152|0;B=255;a=(a&31)+297152|0;break Yb}E=(f>>>20&15)+297184|0;z=(f>>>24&15)+297184|0;B=j[(f>>>28|0)+297208|0];a=(a&15)+297184|0}i[e+32>>2]=j[a|0]+(j[z|0]+(j[E|0]+B|0)|0);D=D+1|0;if((D|0)!=3){continue}break}if((c|0)>=1){fa=k[((ka&255)<<1)+295296>>1]|k[(ka>>>7&33554430)+295296>>1]<<16;X=ka>>>L< >2];l=i[C+72>>2];p=i[C+152>>2];Y=i[C+136>>2];f=i[C+84>>2];t=i[C+68>>2];s=i[C+80>>2];J=i[C+64>>2];a=i[C+148>>2];q=i[C+132>>2];Q=i[C+144>>2];n=i[C+128>>2];ia=i[C+60>>2];oa=i[C+56>>2];pa=i[C+52>>2];while(1){w=Q;m=a;E=s;v=f;N=p;O=e;a=ga+(z<<2)|0;f=W+(k[a>>1]<<3)|0;_=k[a+2>>1];p=fa|k[(z>>>7&33554430)+295296>>1]<<17|k[((z&255)<<1)+295296>>1]<<1;a=p;Zb:{if((c|0)==(d|0)){break Zb}p=p&ma;a=p|z>>>L< >>0>d>>>0){break Zb}a=p|X}P=(a<<3)+b|0;i[P+4>>2]=i[(na<<2)+xa>>2];K=(na<<3)+ja|0;a=i[K>>2];e=a>>>25&112;a=j[(a>>>19&31)+297152|0]+(j[(a>>>11&31)+297152|0]+j[(a>>>3&31)+297152|0]|0)<<4;p=i[e+295820>>2]+a|0;p=(p|0)<12240?p:12240;i[C+44>>2]=(p|0)>0?p:0;p=a+i[e+295816>>2]|0;p=(p|0)<12240?p:12240;i[C+40>>2]=(p|0)>0?p:0;p=a+i[e+295812>>2]|0;p=(p|0)<12240?p:12240;i[C+36>>2]=(p|0)>0?p:0;a=a+i[e+295808>>2]|0;a=(a|0)<12240?a:12240;i[C+32>>2]=(a|0)>0?a:0;e=j[j[f+1|0]+297152|0]<<4;a=j[f+4|0]<<4;f=e+i[a+297036>>2]|0;f=(f|0)<4080?f:4080;i[C+28>>2]=(f|0)>0?f:0;f=e+i[a+297032>>2]|0;f=(f|0)<4080?f:4080;i[C+24>>2]=(f|0)>0?f:0;f=e+i[a+297028>>2]|0;f=(f|0)<4080?f:4080;i[C+20>>2]=(f|0)>0?f:0;a=e+i[a+297024>>2]|0;a=(a|0)<4080?a:4080;i[C+16>>2]=(a|0)>0?a:0;z=z+1|0;U=(ea&z)<<2;f=i[U+pa>>2];_b:{if(f&32768){s=(f>>>5&31)+297152|0;Q=(f>>>10&31)+297152|0;G=255;e=(f>>>1&15)+297184|0;break _b}s=(f>>>4&15)+297184|0;Q=(f>>>8&15)+297184|0;G=j[(f>>>12&7)+297208|0];e=(f>>>1&7)+297200|0}a=f>>>16|0;$b:{if((f|0)<=-1){R=(f>>>21&31)+297152|0;p=(f>>>26&31)+297152|0;H=255;a=(a&31)+297152|0;break $b}R=(f>>>20&15)+297184|0;p=(f>>>24&15)+297184|0;H=j[(f>>>28|0)+297208|0];a=(a&15)+297184|0}u=j[s|0];B=j[R|0];f=i[U+oa>>2];ac:{if(f&32768){I=(f>>>1&15)+297184|0;D=(f>>>5&31)+297152|0;R=255;s=(f>>>10&31)+297152|0;break ac}I=(f>>>1&7)+297200|0;D=(f>>>4&15)+297184|0;R=j[(f>>>12&7)+297208|0];s=(f>>>8&15)+297184|0}G=u+G|0;Q=j[Q|0];H=B+H|0;da=j[p|0];p=f>>>16|0;D=j[D|0]+R|0;s=j[s|0];bc:{if((f|0)<=-1){u=(f>>>21&31)+297152|0;R=(f>>>26&31)+297152|0;B=255;f=(p&31)+297152|0;break bc}u=(f>>>20&15)+297184|0;R=(f>>>24&15)+297184|0;B=j[(f>>>28|0)+297208|0];f=(p&15)+297184|0}G=G+Q|0;Q=j[e|0];H=H+da|0;a=j[a|0];da=s+D|0;I=j[I|0];B=j[R|0]+(j[u|0]+B|0)|0;f=j[f|0];e=i[U+ia>>2];cc:{if(e&32768){D=(e>>>1&15)+297184|0;u=(e>>>5&31)+297152|0;R=(e>>>10&31)+297152|0;p=255;break cc}D=(e>>>1&7)+297200|0;u=(e>>>4&15)+297184|0;R=(e>>>8&15)+297184|0;p=j[(e>>>12&7)+297208|0]}Q=G+Q|0;s=a+H|0;a=I+da|0;f=f+B|0;B=e>>>16|0;p=j[D|0]+(j[R|0]+(p+j[u|0]|0)|0)|0;dc:{if((e|0)<=-1){R=(B&31)+297152|0;da=255;I=(e>>>21&31)+297152|0;H=(e>>>26&31)+297152|0;break dc}R=(B&15)+297184|0;da=j[(e>>>28|0)+297208|0];I=(e>>>20&15)+297184|0;H=(e>>>24&15)+297184|0}ua=P;e=ca+o(_,11)|0;u=j[e|0];B=j[K+4|0];P=o(m,6);la=P+o(w,6)|0;D=la+(n+q<<1)|0;G=i[(C+16|u&12)>>2]+(i[(C+32|B&12)>>2]-D|0)<<4;Z=o(v,6);T=Z+o(E,6)|0;U=T+(t+J<<1)|0;_=(U|0)<(D|0);G=_?0-G|0:G;D=U-D|0;D=_?0-D|0:D;M=(G|0)>(o(D,13)|0)?12:(G|0)>D<<3?8:((G|0)>(o(D,3)|0))<<2;aa=n+w|0;U=m+q|0;D=aa+U<<2;G=i[(C+16|(u&3)<<2)>>2]+(i[(C+32|(B&3)<<2)>>2]-D|0)<<4;S=E+J|0;_=t+v|0;qa=S+_<<2;ba=(qa|0)<(D|0);G=ba?0-G|0:G;D=qa-D|0;D=ba?0-D|0:D;ta=M|((G|0)>(o(D,13)|0)?3:(G|0)>D<<3?2:(G|0)>(o(D,3)|0));D=j[e+1|0];G=j[K+5|0];P=(P+o(q,6)|0)+(aa<<1)|0;aa=i[(C+16|(D&3)<<2)>>2]+(i[(C+32|(G&3)<<2)>>2]-P|0)<<4;ba=0-aa|0;M=aa;aa=(Z+o(t,6)|0)+(S<<1)|0;S=(aa|0)<(P|0);Z=S?ba:M;P=aa-P|0;P=S?0-P|0:P;va=ta|((Z|0)>(o(P,13)|0)?768:(Z|0)>P<<3?512:((Z|0)>(o(P,3)|0))<<8);aa=o(w,3);P=o(m,9);Z=P+o(q,3)|0;n=aa+(Z+n|0)|0;S=i[(C+16|D&12)>>2]+(i[(C+32|G&12)>>2]-n|0)<<4;ta=0-S|0;M=S;ba=o(E,3);S=o(v,9);qa=S+o(t,3)|0;ra=ba+(qa+J|0)|0;sa=(ra|0)<(n|0);J=sa?ta:M;n=ra-n|0;n=sa?0-n|0:n;M=va|((J|0)>(o(n,13)|0)?3072:(J|0)>n<<3?2048:((J|0)>(o(n,3)|0))<<10);n=m+w<<3;J=i[(C+16|u>>>2&12)>>2]+(i[(C+32|B>>>2&12)>>2]-n|0)<<4;ra=v+E<<3;sa=(ra|0)<(n|0);J=sa?0-J|0:J;n=ra-n|0;n=sa?0-n|0:n;M=M|((J|0)>(o(n,13)|0)?48:(J|0)>n<<3?32:((J|0)>(o(n,3)|0))<<4);n=(la+(Q<<1)|0)+(a<<1)|0;u=i[(C+16|u>>>4&12)>>2]+(i[(C+32|B>>>4&12)>>2]-n|0)<<4;B=(T+(s<<1)|0)+(f<<1)|0;J=(B|0)<(n|0);u=J?0-u|0:u;n=B-n|0;n=J?0-n|0:n;ta=M|((u|0)>(o(n,13)|0)?192:(u|0)>n<<3?128:((u|0)>(o(n,3)|0))<<6);n=o(m,12);B=n+(w<<2)|0;u=i[(C+16|D>>>2&12)>>2]+(i[(C+32|G>>>2&12)>>2]-B|0)<<4;M=0-u|0;J=u;u=o(v,12);la=u+(E<<2)|0;T=(la|0)<(B|0);J=T?M:J;B=la-B|0;B=T?0-B|0:B;M=ta|((J|0)>(o(B,13)|0)?12288:(J|0)>B<<3?8192:((J|0)>(o(B,3)|0))<<12);P=P+o(a,3)|0;B=(P+aa|0)+Q|0;D=i[(C+16|D>>>4&12)>>2]+(i[(C+32|G>>>4&12)>>2]-B|0)<<4;la=S+o(f,3)|0;J=(la+ba|0)+s|0;G=(J|0)<(B|0);D=G?0-D|0:D;B=J-B|0;B=G?0-B|0:B;M=M|((D|0)>(o(B,13)|0)?49152:(D|0)>B<<3?32768:((D|0)>(o(B,3)|0))<<14);B=j[e+2|0];D=j[K+6|0];J=U<<3;G=i[(C+16|(B&3)<<2)>>2]+(i[(C+32|(D&3)<<2)>>2]-J|0)<<4;T=_<<3;aa=(T|0)<(J|0);G=aa?0-G|0:G;J=T-J|0;J=aa?0-J|0:J;S=M|((G|0)>(o(J,13)|0)?196608:(G|0)>J<<3?131072:((G|0)>(o(J,3)|0))<<16);q=n+(q<<2)|0;J=i[(C+16|B&12)>>2]+(i[(C+32|D&12)>>2]-q|0)<<4;T=0-J|0;M=J;J=u+(t<<2)|0;G=(J|0)<(q|0);t=G?T:M;q=J-q|0;q=G?0-q|0:q;M=S|((t|0)>(o(q,13)|0)?786432:(t|0)>q<<3?524288:((t|0)>(o(q,3)|0))<<18);e=j[e+3|0];q=j[K+7|0];t=o(U,6)+(N+Y<<1)|0;J=i[(C+16|(e&3)<<2)>>2]+(i[(C+32|(q&3)<<2)>>2]-t|0)<<4;G=o(_,6)+(l+O<<1)|0;K=(G|0)<(t|0);J=K?0-J|0:J;t=G-t|0;t=K?0-t|0:t;S=M|((J|0)>(o(t,13)|0)?50331648:(J|0)>t<<3?33554432:((J|0)>(o(t,3)|0))<<24);J=o(N,3);t=Z+(J+Y|0)|0;G=i[(C+16|e&12)>>2]+(i[(C+32|q&12)>>2]-t|0)<<4;T=0-G|0;M=G;G=o(O,3);Y=qa+(G+l|0)|0;K=(Y|0)<(t|0);l=K?T:M;t=Y-t|0;t=K?0-t|0:t;M=S|((l|0)>(o(t,13)|0)?201326592:(l|0)>t<<3?134217728:((l|0)>(o(t,3)|0))<<26);l=m<<4;t=i[(C+16|B>>>2&12)>>2]+(i[(C+32|D>>>2&12)>>2]-l|0)<<4;Y=v<<4;K=(Y|0)<(l|0);t=K?0-t|0:t;l=Y-l|0;l=K?0-l|0:l;Y=M|((t|0)>(o(l,13)|0)?3145728:(t|0)>l<<3?2097152:((t|0)>(o(l,3)|0))<<20);l=n+(a<<2)|0;t=i[(C+16|B>>>4&12)>>2]+(i[(C+32|D>>>4&12)>>2]-l|0)<<4;B=u+(f<<2)|0;D=(B|0)<(l|0);t=D?0-t|0:t;l=B-l|0;l=D?0-l|0:l;B=Y|((t|0)>(o(l,13)|0)?12582912:(t|0)>l<<3?8388608:((t|0)>(o(l,3)|0))<<22);l=n+(N<<2)|0;n=i[(C+16|e>>>2&12)>>2]+(i[(C+32|q>>>2&12)>>2]-l|0)<<4;t=u+(O<<2)|0;u=(t|0)<(l|0);n=u?0-n|0:n;l=t-l|0;l=u?0-l|0:l;B=B|((n|0)>(o(l,13)|0)?805306368:(n|0)>l<<3?536870912:((n|0)>(o(l,3)|0))<<28);l=(J+P|0)+p|0;e=i[(C+16|e>>>4&12)>>2]+(i[(C+32|q>>>4&12)>>2]-l|0)<<4;u=0-e|0;n=e;e=j[R|0]+(j[H|0]+(j[I|0]+da|0)|0)|0;q=e+(G+la|0)|0;t=(q|0)<(l|0);n=t?u:n;l=q-l|0;l=t?0-l|0:l;i[ua>>2]=B|((n|0)>(o(l,13)|0)?-1073741824:(n|0)>l<<3?-2147483648:((n|0)>(o(l,3)|0))<<30);na=na+1|0;l=O;Y=N;t=v;J=E;q=m;n=w;if((c|0)!=(z|0)){continue}break}i[C+96>>2]=s;i[C+160>>2]=Q;i[C+164>>2]=a;i[C+100>>2]=f;i[C+168>>2]=p;i[C+104>>2]=e;i[C+144>>2]=Q;i[C+128>>2]=n;i[C+148>>2]=a;i[C+132>>2]=q;i[C+80>>2]=s;i[C+64>>2]=J;i[C+84>>2]=f;i[C+68>>2]=t;i[C+152>>2]=p;i[C+136>>2]=Y;i[C+88>>2]=e;i[C+72>>2]=l}ka=ka+1|0;if((ka|0)!=(d|0)){continue}break}}B=1;if(!ja){break m}wa(ja)}a=i[C>>2];if(!a){break k}i[C+4>>2]=a;wa(a)}ha=C+192|0;return B}A(90786,90648,445,90809);x()}A(19820,90648,435,91026);x()}A(218689,19512,3176,219760);x()}A(91069,19512,377,91053);x()}A(213968,19512,827,213978);x()}A(213968,19512,842,218096);x()}A(282127,19512,3815,282112);x()}A(296960,19512,3319,296999);x()}A(296960,19512,3304,296976);x()}function lc(a,b){var c=0,d=0,e=0,f=0,l=0,n=0,r=0,s=p(0),t=p(0),u=0,v=0,w=p(0),y=p(0),z=0,B=0,C=p(0),D=0,E=0,F=0,G=p(0),H=0,I=0,J=0,K=p(0),L=p(0),M=p(0),N=p(0),O=p(0),P=0,Q=p(0),R=p(0),S=p(0),T=p(0),U=0,V=p(0);d=ha-48|0;ha=d;b=ya(b,0,96);f=i[a+104>>2];r=j[f+21824|0];a:{b:{c:{d:{switch(f|0){case 0:case 5:case 10:case 12:case 14:case 15:case 18:i[b>>2]=6;c=r<<9;s=p(p(j[(c|j[a+21|0]<<1)+308e3|0])/p(255));m[d+32>>2]=s;e:{if(f+ -15>>>0<=2){c=c+308e3|0;e=j[c+(j[a+22|0]<<1)|0];m[d+36>>2]=s;m[d+40>>2]=s;s=p(p(e>>>0)/p(255));m[d+16>>2]=s;m[d+20>>2]=s;m[d+24>>2]=s;m[d+44>>2]=p(j[c+(j[a+23|0]<<1)|0])/p(255);m[d+28>>2]=p(j[c+(j[a+24|0]<<1)|0])/p(255);e=f+ -8|0;l=4;break e}l=j[f+21920|0];c=c+308e3|0;m[d+36>>2]=p(j[c+(j[a+23|0]<<1)|0])/p(255);m[d+40>>2]=p(j[c+(j[a+25|0]<<1)|0])/p(255);m[d+16>>2]=p(j[c+(j[a+22|0]<<1)|0])/p(255);m[d+20>>2]=p(j[c+(j[a+24|0]<<1)|0])/p(255);m[d+24>>2]=p(j[c+(j[a+26|0]<<1)|0])/p(255);e=f+ -8|0;if(e>>>0<=6){c=(r<<9)+308e3|0;m[d+44>>2]=p(j[c+(j[a+27|0]<<1)|0])/p(255);m[d+28>>2]=p(j[c+(j[a+28|0]<<1)|0])/p(255);break e}i[d+28>>2]=1065353216;i[d+44>>2]=1065353216}Ma(l&255,7,d+32|0,d+16|0,d+4|0,d,d+8|0);i[b+40>>2]=i[d+4>>2];i[b+52>>2]=i[d>>2];if(e>>>0>=10){g[b+55|0]=127;g[b+43|0]=127}i[b+64>>2]=i[d+8>>2];i[b+68>>2]=i[d+12>>2];c=b;f:{g:{switch(f+ -5|0){case 9:g[b+8|0]=j[j[a+39|0]+25968|0];g[b+9|0]=j[j[a+40|0]+25968|0];g[b+10|0]=j[j[a+41|0]+25968|0];g[b+11|0]=j[j[a+42|0]+25968|0];g[b+12|0]=j[j[a+43|0]+25968|0];g[b+13|0]=j[j[a+44|0]+25968|0];g[b+14|0]=j[j[a+45|0]+25968|0];g[b+15|0]=j[j[a+46|0]+25968|0];g[b+16|0]=j[j[a+47|0]+25968|0];g[b+17|0]=j[j[a+48|0]+25968|0];g[b+18|0]=j[j[a+49|0]+25968|0];g[b+19|0]=j[j[a+50|0]+25968|0];g[b+20|0]=j[j[a+51|0]+25968|0];g[b+21|0]=j[j[a+52|0]+25968|0];g[b+22|0]=j[j[a+53|0]+25968|0];a=j[a+54|0]+25968|0;break f;case 13:g[b+8|0]=j[j[a+39|0]+25936|0];g[b+9|0]=j[j[a+40|0]+25936|0];g[b+10|0]=j[j[a+41|0]+25936|0];g[b+11|0]=j[j[a+42|0]+25936|0];g[b+12|0]=j[j[a+43|0]+25936|0];g[b+13|0]=j[j[a+44|0]+25936|0];g[b+14|0]=j[j[a+45|0]+25936|0];g[b+15|0]=j[j[a+46|0]+25936|0];g[b+16|0]=j[j[a+47|0]+25936|0];g[b+17|0]=j[j[a+48|0]+25936|0];g[b+18|0]=j[j[a+49|0]+25936|0];g[b+19|0]=j[j[a+50|0]+25936|0];g[b+20|0]=j[j[a+51|0]+25936|0];g[b+21|0]=j[j[a+52|0]+25936|0];g[b+22|0]=j[j[a+53|0]+25936|0];a=j[a+54|0]+25936|0;break f;default:g[b+8|0]=j[a+39|0];g[b+9|0]=j[a+40|0];g[b+10|0]=j[a+41|0];g[b+11|0]=j[a+42|0];g[b+12|0]=j[a+43|0];g[b+13|0]=j[a+44|0];g[b+14|0]=j[a+45|0];g[b+15|0]=j[a+46|0];g[b+16|0]=j[a+47|0];g[b+17|0]=j[a+48|0];g[b+18|0]=j[a+49|0];g[b+19|0]=j[a+50|0];g[b+20|0]=j[a+51|0];g[b+21|0]=j[a+52|0];g[b+22|0]=j[a+53|0];a=a+54|0;break f;case 0:case 7:break g}}g[b+8|0]=j[j[a+39|0]+25972|0];g[b+9|0]=j[j[a+40|0]+25972|0];g[b+10|0]=j[j[a+41|0]+25972|0];g[b+11|0]=j[j[a+42|0]+25972|0];g[b+12|0]=j[j[a+43|0]+25972|0];g[b+13|0]=j[j[a+44|0]+25972|0];g[b+14|0]=j[j[a+45|0]+25972|0];g[b+15|0]=j[j[a+46|0]+25972|0];g[b+16|0]=j[j[a+47|0]+25972|0];g[b+17|0]=j[j[a+48|0]+25972|0];g[b+18|0]=j[j[a+49|0]+25972|0];g[b+19|0]=j[j[a+50|0]+25972|0];g[b+20|0]=j[j[a+51|0]+25972|0];g[b+21|0]=j[j[a+52|0]+25972|0];g[b+22|0]=j[j[a+53|0]+25972|0];a=j[a+54|0]+25972|0}g[c+23|0]=j[a|0];break c;case 1:i[b>>2]=3;m[d+32>>2]=p(j[a+21|0])/p(255);m[d+36>>2]=p(j[a+23|0])/p(255);c=j[a+25|0];i[d+44>>2]=1065353216;m[d+40>>2]=p(c>>>0)/p(255);m[d+16>>2]=p(j[a+22|0])/p(255);m[d+20>>2]=p(j[a+24|0])/p(255);c=j[a+26|0];i[d+28>>2]=1065353216;m[d+24>>2]=p(c>>>0)/p(255);i[d+4>>2]=0;i[d>>2]=0;Ma(3,7,d+32|0,d+16|0,d+4|0,d,d+8|0);g[b+42|0]=j[d+6|0];h[b+40>>1]=k[d+4>>1];h[b+44>>1]=k[d+4>>1];g[b+46|0]=j[d+6|0];c=j[d|0];g[b+52|0]=c;g[b+56|0]=c;c=j[d+1|0];g[b+57|0]=c;g[b+53|0]=c;c=j[d+2|0];g[b+58|0]=c;g[b+54|0]=c;c=i[d+8>>2];i[b+64>>2]=c;e=i[d+12>>2];i[b+76>>2]=e;i[b+72>>2]=c;i[b+68>>2]=e;g[b+8|0]=j[a+39|0];g[b+9|0]=j[a+40|0];g[b+10|0]=j[a+41|0];g[b+11|0]=j[a+42|0];g[b+12|0]=j[a+43|0];g[b+13|0]=j[a+44|0];g[b+14|0]=j[a+45|0];g[b+15|0]=j[a+46|0];g[b+16|0]=j[a+47|0];g[b+17|0]=j[a+48|0];g[b+18|0]=j[a+49|0];g[b+19|0]=j[a+50|0];g[b+20|0]=j[a+51|0];g[b+21|0]=j[a+52|0];g[b+22|0]=j[a+53|0];g[b+23|0]=j[a+54|0];break c;case 2:i[b>>2]=1;c=i[a+108>>2];i[b+4>>2]=j[o(c,6)+2e4|0];i[d+44>>2]=1065353216;i[d+28>>2]=1065353216;U=43795755>>>c&1;J=a+21|0;r=0;while(1){f=o(r,6);c=f+J|0;e=j[c+4|0];l=j[c+5|0];f=j[(f|1)+J|0];u=j[c|0];n=j[c+2|0];c=j[c+3|0];i[d+8>>2]=0;i[d+4>>2]=0;K=p(p((c|c<<4)>>>0)/p(255));w=p(K*p(127));s=p(p(w*p(.5))+p(.5));h:{if(p(q(s)) 63?126:c<<1;s=p(p(p((((F&64)>>>6|F<<1)&253)>>>0)/p(255))-K);s=p(s*s);L=p(p((n|n<<4)>>>0)/p(255));y=p(L*p(127));t=p(p(y*p(.5))+p(.5));i:{if(p(q(t))
63?126:c<<1;t=p(p(p((((z&64)>>>6|z<<1)&253)>>>0)/p(255))-L);s=p(p(t*t)+s);M=p(p((u|u<<4)>>>0)/p(255));Q=p(M*p(127));t=p(p(Q*p(.5))+p(.5));j:{if(p(q(t))
63?126:c<<1;t=p(p(p((((B&64)>>>6|B<<1)&253)>>>0)/p(255))-M);G=p(t*t);N=p(p((f|f<<4)>>>0)/p(255));R=p(N*p(127));C=p(p(R*p(.5))+p(.5));k:{if(p(q(C))
63?126:c<<1;t=p(p(p((((D&64)>>>6|D<<1)&253)>>>0)/p(255))-N);t=p(p(p(G+p(t*t))+p(0))+s);C=p(p((l|l<<4)>>>0)/p(255));S=p(C*p(127));s=p(p(S*p(.5))+p(.5));l:{if(p(q(s))
63?126:c<<1;s=p(p(p((((E&64)>>>6|E<<1)&253)>>>0)/p(255))-C);V=p(s*s);O=p(p((e|e<<4)>>>0)/p(255));T=p(O*p(127));s=p(p(T*p(.5))+p(.5));m:{if(p(q(s))
63?126:c<<1;t=p(p(p((((c&64)>>>6|c<<1)&253)>>>0)/p(255))-O);t=p(G+p(p(t*t)+V));if(!(t
>>1|0;e=(c&255)>>>1|0;f=(F&255)>>>1|0;v=(z&255)>>>1|0;H=(D&255)>>>1|0;I=(B&255)>>>1|0;s=t}F=0;t=p(p(p(w+p(-1))*p(.5))+p(.5));n:{if(p(q(t))
63?127:c<<1|1;t=p(p(p((((z&64)>>>6|z<<1)&255)>>>0)/p(255))-K);t=p(t*t);w=p(p(p(y+p(-1))*p(.5))+p(.5));o:{if(p(q(w))
63?127:c<<1|1;w=p(p(p((((B&64)>>>6|B<<1)&255)>>>0)/p(255))-L);w=p(w*w);y=p(p(p(R+p(-1))*p(.5))+p(.5));p:{if(p(q(y))
63?127:c<<1|1;y=p(p(p((((D&64)>>>6|D<<1)&255)>>>0)/p(255))-N);y=p(y*y);t=p(w+t);w=p(p(p(Q+p(-1))*p(.5))+p(.5));q:{if(p(q(w))
63?127:c<<1|1;w=p(p(p((((E&64)>>>6|E<<1)&255)>>>0)/p(255))-M);t=p(p(p(p(w*w)+y)+p(0))+t);w=p(p(p(S+p(-1))*p(.5))+p(.5));r:{if(p(q(w))
63?127:c<<1|1;w=p(p(p((((P&64)>>>6|P<<1)&255)>>>0)/p(255))-C);w=p(w*w);G=t;y=p(p(p(T+p(-1))*p(.5))+p(.5));s:{if(p(q(y))
63?127:c<<1|1;t=p(p(p((((c&64)>>>6|c<<1)&255)>>>0)/p(255))-O);if(p(G+p(p(t*t)+w))
>>1|0;f=(z&254)>>>1|0;v=(B&254)>>>1|0;H=(D&254)>>>1|0;I=(E&254)>>>1|0;e=(c&254)>>>1|0}g[d+5|0]=f;g[d+9|0]=v;g[d+10|0]=e;g[d+6|0]=n;g[d+11|0]=u;g[d+7|0]=l;l=U?r:1-r|0;c=b+(l<<2)|0;g[c+42|0]=e;g[d+8|0]=I;g[d+4|0]=H;h[c+40>>1]=k[d+8>>1];g[c+54|0]=j[d+6|0];h[c+52>>1]=k[d+4>>1];i[(b+(l<<3)|0)- -64>>2]=F;r=r+1|0;if((r|0)!=2){continue}break}m[d+16>>2]=N;m[d+32>>2]=M;m[d+36>>2]=L;m[d+20>>2]=K;m[d+40>>2]=O;m[d+24>>2]=C;g[b+8|0]=j[a+39|0];g[b+9|0]=j[a+40|0];g[b+10|0]=j[a+41|0];g[b+11|0]=j[a+42|0];g[b+12|0]=j[a+43|0];g[b+13|0]=j[a+44|0];g[b+14|0]=j[a+45|0];g[b+15|0]=j[a+46|0];g[b+16|0]=j[a+47|0];g[b+17|0]=j[a+48|0];g[b+18|0]=j[a+49|0];g[b+19|0]=j[a+50|0];g[b+20|0]=j[a+51|0];g[b+21|0]=j[a+52|0];g[b+22|0]=j[a+53|0];g[b+23|0]=j[a+54|0];break c;case 9:case 16:i[b>>2]=7;c=i[a+108>>2];i[b+4>>2]=j[o(c,6)+2e4|0];H=(43795755>>>c^-1)&1;I=f+ -15>>>0>2;f=a+21|0;c=r<<9;n=c+308e3|0;u=1;while(1){z=d;t:{if(!I){v=l<<2;s=p(p(j[n+(j[v+f|0]<<1)|0])/p(255));m[d+32>>2]=s;J=j[n+(j[f+(v|1)|0]<<1)|0];m[d+36>>2]=s;m[d+40>>2]=s;s=p(p(J>>>0)/p(255));m[d+16>>2]=s;m[d+20>>2]=s;m[d+24>>2]=s;m[d+44>>2]=p(j[n+(j[f+(v|2)|0]<<1)|0])/p(255);e=v|3;break t}v=l<<3;m[d+32>>2]=p(j[n+(j[v+f|0]<<1)|0])/p(255);m[d+36>>2]=p(j[n+(j[f+(v|2)|0]<<1)|0])/p(255);m[d+40>>2]=p(j[n+(j[f+(v|4)|0]<<1)|0])/p(255);m[d+44>>2]=p(j[n+(j[f+(v|6)|0]<<1)|0])/p(255);m[d+16>>2]=p(j[n+(j[f+(v|1)|0]<<1)|0])/p(255);m[d+20>>2]=p(j[n+(j[f+(v|3)|0]<<1)|0])/p(255);m[d+24>>2]=p(j[n+(j[f+(v|5)|0]<<1)|0])/p(255);e=v|7}m[z+28>>2]=p(j[(j[(e+a|0)+21|0]<<1|c)+308e3|0])/p(255);i[d+8>>2]=0;i[d+12>>2]=0;i[d+4>>2]=0;i[d>>2]=0;Ma(4,5,d+32|0,d+16|0,d+4|0,d,d+8|0);e=l^H;r=b+(e<<2)|0;i[r+40>>2]=i[d+4>>2];i[r+52>>2]=i[d>>2];e=b+(e<<3)|0;i[e- -64>>2]=i[d+8>>2];i[e+68>>2]=i[d+12>>2];e=u&1;u=0;l=1;if(e){continue}break}g[b+8|0]=j[a+39|0];g[b+9|0]=j[a+40|0];g[b+10|0]=j[a+41|0];g[b+11|0]=j[a+42|0];g[b+12|0]=j[a+43|0];g[b+13|0]=j[a+44|0];g[b+14|0]=j[a+45|0];g[b+15|0]=j[a+46|0];g[b+16|0]=j[a+47|0];g[b+17|0]=j[a+48|0];g[b+18|0]=j[a+49|0];g[b+19|0]=j[a+50|0];g[b+20|0]=j[a+51|0];g[b+21|0]=j[a+52|0];g[b+22|0]=j[a+53|0];g[b+23|0]=j[a+54|0];break c;case 8:e=j[a+115|0]<<3;r=j[a+114|0]<<3;l=j[a+113|0]<<3;f=j[a+112|0]<<3;c=k[e+318756>>1]+(k[r+318756>>1]+(k[l+318756>>1]+k[f+318756>>1]|0)|0)|0;e=k[e+318752>>1]+(k[r+318752>>1]+(k[l+318752>>1]+k[f+318752>>1]|0)|0)|0;if(!(!e|!c)){i[b>>2]=5;g[b+40|0]=j[(j[a+112|0]<<2)+320802|0];g[b+52|0]=j[(j[a+112|0]<<2)+320803|0];g[b+41|0]=j[(j[a+113|0]<<2)+320802|0];g[b+53|0]=j[(j[a+113|0]<<2)+320803|0];g[b+42|0]=j[(j[a+114|0]<<2)+320802|0];c=j[(j[a+114|0]<<2)+320803|0];i[b+8>>2]=16843009;i[b+12>>2]=16843009;g[b+54|0]=c;i[b+16>>2]=16843009;i[b+20>>2]=16843009;g[b+43|0]=j[a+115|0];g[b+55|0]=j[a+115|0];break c}i[b>>2]=6;e=c>>>0>>0;c=e<<2;g[b+40|0]=j[(c|j[a+112|0]<<3)+318754|0];g[b+52|0]=j[(c|j[a+112|0]<<3)+318755|0];g[b+41|0]=j[(c|j[a+113|0]<<3)+318754|0];g[b+53|0]=j[(c|j[a+113|0]<<3)+318755|0];g[b+42|0]=j[(c|j[a+114|0]<<3)+318754|0];g[b+54|0]=j[(c|j[a+114|0]<<3)+318755|0];g[b+43|0]=j[(c|j[a+115|0]<<3)+318754|0];a=j[(c|j[a+115|0]<<3)+318755|0];i[b+68>>2]=e;i[b+64>>2]=e;g[b+55|0]=a;i[b+8>>2]=84215045;i[b+12>>2]=84215045;i[b+16>>2]=84215045;i[b+20>>2]=84215045;break c;case 7:i[b>>2]=2;c=o(i[a+108>>2],6);i[b+4>>2]=j[c+20192|0];c=j[c+20196|0];l=c&1;u:{v:{w:{x:{u=c>>>1|0;switch(u|0){case 0:break w;case 1:break x;default:break v}}c=(r<<9)+308e3|0;f=a+21|0;u=l?6:0;e=f+u|0;g[b+40|0]=(o(j[c+(j[e|0]<<1)|0],31)+127>>>0)/255;g[b+52|0]=(o(j[c+(j[f+(u|1)|0]<<1)|0],31)+127>>>0)/255;g[b+41|0]=(o(j[c+(j[e+2|0]<<1)|0],31)+127>>>0)/255;g[b+53|0]=(o(j[c+(j[e+3|0]<<1)|0],31)+127>>>0)/255;g[b+42|0]=(o(j[c+(j[e+4|0]<<1)|0],31)+127>>>0)/255;g[b+54|0]=(o(j[c+(j[e+5|0]<<1)|0],31)+127>>>0)/255;l=l?0:6;e=l+f|0;g[b+44|0]=(o(j[c+(j[e|0]<<1)|0],31)+127>>>0)/255;f=f+(l|1)|0;g[b+56|0]=(o(j[c+(j[f|0]<<1)|0],31)+127>>>0)/255;g[b+45|0]=(o(j[c+(j[e+2|0]<<1)|0],31)+127>>>0)/255;g[b+57|0]=(o(j[c+(j[e+3|0]<<1)|0],31)+127>>>0)/255;g[b+46|0]=(o(j[c+(j[e+4|0]<<1)|0],31)+127>>>0)/255;l=e+5|0;g[b+58|0]=(o(j[c+(j[l|0]<<1)|0],31)+127>>>0)/255;g[b+48|0]=(o(j[c+(j[e|0]<<1)|0],31)+127>>>0)/255;g[b+60|0]=(o(j[c+(j[f|0]<<1)|0],31)+127>>>0)/255;g[b+49|0]=(o(j[c+(j[e+2|0]<<1)|0],31)+127>>>0)/255;g[b+61|0]=(o(j[c+(j[e+3|0]<<1)|0],31)+127>>>0)/255;g[b+50|0]=(o(j[c+(j[e+4|0]<<1)|0],31)+127>>>0)/255;break u}c=(r<<9)+308e3|0;f=a+21|0;u=l?6:0;e=f+u|0;g[b+40|0]=(o(j[c+(j[e|0]<<1)|0],31)+127>>>0)/255;u=f+(u|1)|0;g[b+52|0]=(o(j[c+(j[u|0]<<1)|0],31)+127>>>0)/255;g[b+41|0]=(o(j[c+(j[e+2|0]<<1)|0],31)+127>>>0)/255;g[b+53|0]=(o(j[c+(j[e+3|0]<<1)|0],31)+127>>>0)/255;g[b+42|0]=(o(j[c+(j[e+4|0]<<1)|0],31)+127>>>0)/255;g[b+54|0]=(o(j[c+(j[e+5|0]<<1)|0],31)+127>>>0)/255;g[b+44|0]=(o(j[c+(j[e|0]<<1)|0],31)+127>>>0)/255;g[b+56|0]=(o(j[c+(j[u|0]<<1)|0],31)+127>>>0)/255;g[b+45|0]=(o(j[c+(j[e+2|0]<<1)|0],31)+127>>>0)/255;g[b+57|0]=(o(j[c+(j[e+3|0]<<1)|0],31)+127>>>0)/255;g[b+46|0]=(o(j[c+(j[e+4|0]<<1)|0],31)+127>>>0)/255;g[b+58|0]=(o(j[c+(j[e+5|0]<<1)|0],31)+127>>>0)/255;l=l?0:6;e=l+f|0;g[b+48|0]=(o(j[c+(j[e|0]<<1)|0],31)+127>>>0)/255;g[b+60|0]=(o(j[c+(j[f+(l|1)|0]<<1)|0],31)+127>>>0)/255;g[b+49|0]=(o(j[c+(j[e+2|0]<<1)|0],31)+127>>>0)/255;g[b+61|0]=(o(j[c+(j[e+3|0]<<1)|0],31)+127>>>0)/255;g[b+50|0]=(o(j[c+(j[e+4|0]<<1)|0],31)+127>>>0)/255;l=e+5|0;break u}c=(r<<9)+308e3|0;e=a+21|0;n=l?6:0;f=e+n|0;g[b+40|0]=(o(j[c+(j[f|0]<<1)|0],31)+127>>>0)/255;g[b+52|0]=(o(j[c+(j[e+(n|1)|0]<<1)|0],31)+127>>>0)/255;g[b+41|0]=(o(j[c+(j[f+2|0]<<1)|0],31)+127>>>0)/255;g[b+53|0]=(o(j[c+(j[f+3|0]<<1)|0],31)+127>>>0)/255;g[b+42|0]=(o(j[c+(j[f+4|0]<<1)|0],31)+127>>>0)/255;g[b+54|0]=(o(j[c+(j[f+5|0]<<1)|0],31)+127>>>0)/255;n=o(l^1,6);f=n+e|0;g[b+44|0]=(o(j[c+(j[f|0]<<1)|0],31)+127>>>0)/255;g[b+56|0]=(o(j[c+(j[e+(n|1)|0]<<1)|0],31)+127>>>0)/255;g[b+45|0]=(o(j[c+(j[f+2|0]<<1)|0],31)+127>>>0)/255;g[b+57|0]=(o(j[c+(j[f+3|0]<<1)|0],31)+127>>>0)/255;g[b+46|0]=(o(j[c+(j[f+4|0]<<1)|0],31)+127>>>0)/255;g[b+58|0]=(o(j[c+(j[f+5|0]<<1)|0],31)+127>>>0)/255;f=((u|0)!=2)<<1;f=o(l?1-f|0:f,6);l=f+e|0;g[b+48|0]=(o(j[c+(j[l|0]<<1)|0],31)+127>>>0)/255;g[b+60|0]=(o(j[c+(j[e+(f|1)|0]<<1)|0],31)+127>>>0)/255;g[b+49|0]=(o(j[c+(j[l+2|0]<<1)|0],31)+127>>>0)/255;g[b+61|0]=(o(j[c+(j[l+3|0]<<1)|0],31)+127>>>0)/255;g[b+50|0]=(o(j[c+(j[l+4|0]<<1)|0],31)+127>>>0)/255;l=l+5|0}e=1;g[b+62|0]=(o(j[(r<<9|j[l|0]<<1)+308e3|0],31)+127>>>0)/255;g[b+8|0]=j[a+39|0];g[b+9|0]=j[a+40|0];g[b+10|0]=j[a+41|0];g[b+11|0]=j[a+42|0];g[b+12|0]=j[a+43|0];g[b+13|0]=j[a+44|0];g[b+14|0]=j[a+45|0];g[b+15|0]=j[a+46|0];g[b+16|0]=j[a+47|0];g[b+17|0]=j[a+48|0];g[b+18|0]=j[a+49|0];g[b+19|0]=j[a+50|0];g[b+20|0]=j[a+51|0];g[b+21|0]=j[a+52|0];g[b+22|0]=j[a+53|0];g[b+23|0]=j[a+54|0];break a;case 6:case 11:case 13:case 17:i[b>>2]=5;c=i[a+16>>2];i[b+92>>2]=c+1&3;y:{z:{A:{B:{if(f+ -15>>>0<=2){if((c|0)!=3){break B}c=(r<<9)+308e3|0;e=(o(j[c+(j[a+21|0]<<1)|0],127)+127>>>0)/255|0;g[b+40|0]=e;r=j[c+(j[a+22|0]<<1)|0];g[b+41|0]=e;g[b+42|0]=e;e=(o(r,127)+127>>>0)/255|0;g[b+53|0]=e;g[b+52|0]=e;g[b+54|0]=e;g[b+43|0]=j[c+(j[a+23|0]<<1)|0];g[b+55|0]=j[c+(j[a+24|0]<<1)|0];break z}l=(r<<9)+308e3|0;u=j[l+(j[a+21|0]<<1)|0];n=j[l+(j[a+22|0]<<1)|0];if(c){n=(o(n&255,127)+127>>>0)/255|0;u=(o(u&255,127)+127>>>0)/255|0}c=b+(c?0:3)|0;g[c+52|0]=n;g[c+40|0]=u;e=j[l+(j[a+24|0]<<1)|0];l=j[l+(j[a+23|0]<<1)|0];c=i[a+16>>2]==1;u=c?3:1;if(!c){l=(o(l&255,127)+127>>>0)/255|0;e=(o(e&255,127)+127>>>0)/255|0}c=b+u|0;g[c+52|0]=e;g[c+40|0]=l;c=(r<<9)+308e3|0;e=j[c+(j[a+26|0]<<1)|0];l=j[c+(j[a+25|0]<<1)|0];c=i[a+16>>2]==2;u=c?3:2;if(!c){l=(o(l&255,127)+127>>>0)/255|0;e=(o(e&255,127)+127>>>0)/255|0}c=b+u|0;g[c+52|0]=e;g[c+40|0]=l;c=i[a+16>>2];e=255;l=255;if(f+ -8>>>0<=6){e=(r<<9)+308e3|0;l=j[e+(j[a+28|0]<<1)|0];e=j[e+(j[a+27|0]<<1)|0]}if(c>>>0>2){break A}l=(o(l,127)+127>>>0)/255|0;e=(o(e,127)+127>>>0)/255|0;break A}A(25980,19512,13208,26015);x()}c=b+c|0;g[c+52|0]=l;g[c+40|0]=e;if((f|0)==13){break y}}g[b+8|0]=j[a+39|0];g[b+24|0]=j[a+40|0];g[b+9|0]=j[a+41|0];g[b+25|0]=j[a+42|0];g[b+10|0]=j[a+43|0];g[b+26|0]=j[a+44|0];g[b+11|0]=j[a+45|0];g[b+27|0]=j[a+46|0];g[b+12|0]=j[a+47|0];g[b+28|0]=j[a+48|0];g[b+13|0]=j[a+49|0];g[b+29|0]=j[a+50|0];g[b+14|0]=j[a+51|0];g[b+30|0]=j[a+52|0];g[b+15|0]=j[a+53|0];g[b+31|0]=j[a+54|0];g[b+16|0]=j[a+55|0];g[b+32|0]=j[a+56|0];g[b+17|0]=j[a+57|0];g[b+33|0]=j[a+58|0];g[b+18|0]=j[a+59|0];g[b+34|0]=j[a+60|0];g[b+19|0]=j[a+61|0];g[b+35|0]=j[a+62|0];g[b+20|0]=j[a+63|0];g[b+36|0]=j[a- -64|0];g[b+21|0]=j[a+65|0];g[b+37|0]=j[a+66|0];g[b+22|0]=j[a+67|0];g[b+38|0]=j[a+68|0];g[b+23|0]=j[a+69|0];g[b+39|0]=j[a+70|0];break c}g[b+8|0]=j[a+39|0]?3:0;g[b+24|0]=j[a+40|0]?3:0;g[b+9|0]=j[a+41|0]?3:0;g[b+25|0]=j[a+42|0]?3:0;g[b+10|0]=j[a+43|0]?3:0;g[b+26|0]=j[a+44|0]?3:0;g[b+11|0]=j[a+45|0]?3:0;g[b+27|0]=j[a+46|0]?3:0;g[b+12|0]=j[a+47|0]?3:0;g[b+28|0]=j[a+48|0]?3:0;g[b+13|0]=j[a+49|0]?3:0;g[b+29|0]=j[a+50|0]?3:0;g[b+14|0]=j[a+51|0]?3:0;g[b+30|0]=j[a+52|0]?3:0;g[b+15|0]=j[a+53|0]?3:0;g[b+31|0]=j[a+54|0]?3:0;g[b+16|0]=j[a+55|0]?3:0;g[b+32|0]=j[a+56|0]?3:0;g[b+17|0]=j[a+57|0]?3:0;g[b+33|0]=j[a+58|0]?3:0;g[b+18|0]=j[a+59|0]?3:0;g[b+34|0]=j[a+60|0]?3:0;g[b+19|0]=j[a+61|0]?3:0;g[b+35|0]=j[a+62|0]?3:0;g[b+20|0]=j[a+63|0]?3:0;g[b+36|0]=j[a- -64|0]?3:0;g[b+21|0]=j[a+65|0]?3:0;g[b+37|0]=j[a+66|0]?3:0;g[b+22|0]=j[a+67|0]?3:0;g[b+38|0]=j[a+68|0]?3:0;g[b+23|0]=j[a+69|0]?3:0;g[b+39|0]=j[a+70|0]?3:0;break c;case 3:break b;case 4:break d;default:break a}}i[b>>2]=3;c=i[a+108>>2];i[b+4>>2]=j[o(c,6)+2e4|0];i[d+44>>2]=1065353216;i[d+28>>2]=1065353216;C:{if(43795755>>>c&1){c=(r<<9)+308e3|0;m[d+32>>2]=p(j[c+(j[a+21|0]<<1)|0])/p(255);m[d+16>>2]=p(j[c+(j[a+22|0]<<1)|0])/p(255);m[d+36>>2]=p(j[c+(j[a+23|0]<<1)|0])/p(255);m[d+20>>2]=p(j[c+(j[a+24|0]<<1)|0])/p(255);m[d+40>>2]=p(j[c+(j[a+25|0]<<1)|0])/p(255);m[d+24>>2]=p(j[c+(j[a+26|0]<<1)|0])/p(255);i[d+8>>2]=0;i[d+12>>2]=0;i[d+4>>2]=0;i[d>>2]=0;Ma(3,7,d+32|0,d+16|0,d+4|0,d,d+8|0);g[b+42|0]=j[d+6|0];h[b+40>>1]=k[d+4>>1];h[b+52>>1]=k[d>>1];g[b+54|0]=j[d+2|0];g[b+55|0]=127;g[b+43|0]=127;i[b+64>>2]=i[d+8>>2];i[b+68>>2]=i[d+12>>2];m[d+32>>2]=p(j[c+(j[a+27|0]<<1)|0])/p(255);m[d+16>>2]=p(j[c+(j[a+28|0]<<1)|0])/p(255);m[d+36>>2]=p(j[c+(j[a+29|0]<<1)|0])/p(255);m[d+20>>2]=p(j[c+(j[a+30|0]<<1)|0])/p(255);m[d+40>>2]=p(j[c+(j[a+31|0]<<1)|0])/p(255);m[d+24>>2]=p(j[c+(j[a+32|0]<<1)|0])/p(255);i[d+8>>2]=0;i[d+12>>2]=0;i[d+4>>2]=0;i[d>>2]=0;Ma(3,7,d+32|0,d+16|0,d+4|0,d,d+8|0);g[b+46|0]=j[d+6|0];h[b+44>>1]=k[d+4>>1];h[b+56>>1]=k[d>>1];g[b+58|0]=j[d+2|0];g[b+59|0]=127;g[b+47|0]=127;i[b+72>>2]=i[d+8>>2];i[b+76>>2]=i[d+12>>2];break C}c=(r<<9)+308e3|0;m[d+32>>2]=p(j[c+(j[a+21|0]<<1)|0])/p(255);m[d+16>>2]=p(j[c+(j[a+22|0]<<1)|0])/p(255);m[d+36>>2]=p(j[c+(j[a+23|0]<<1)|0])/p(255);m[d+20>>2]=p(j[c+(j[a+24|0]<<1)|0])/p(255);m[d+40>>2]=p(j[c+(j[a+25|0]<<1)|0])/p(255);m[d+24>>2]=p(j[c+(j[a+26|0]<<1)|0])/p(255);i[d+8>>2]=0;i[d+12>>2]=0;i[d+4>>2]=0;i[d>>2]=0;Ma(3,7,d+32|0,d+16|0,d+4|0,d,d+8|0);g[b+44|0]=j[d+4|0];g[b+56|0]=j[d|0];g[b+45|0]=j[d+5|0];g[b+57|0]=j[d+1|0];g[b+46|0]=j[d+6|0];e=j[d+2|0];g[b+59|0]=127;g[b+47|0]=127;g[b+58|0]=e;i[b+72>>2]=i[d+8>>2];i[b+76>>2]=i[d+12>>2];m[d+32>>2]=p(j[c+(j[a+27|0]<<1)|0])/p(255);m[d+16>>2]=p(j[c+(j[a+28|0]<<1)|0])/p(255);m[d+36>>2]=p(j[c+(j[a+29|0]<<1)|0])/p(255);m[d+20>>2]=p(j[c+(j[a+30|0]<<1)|0])/p(255);m[d+40>>2]=p(j[c+(j[a+31|0]<<1)|0])/p(255);m[d+24>>2]=p(j[c+(j[a+32|0]<<1)|0])/p(255);i[d+8>>2]=0;i[d+12>>2]=0;i[d+4>>2]=0;i[d>>2]=0;Ma(3,7,d+32|0,d+16|0,d+4|0,d,d+8|0);g[b+40|0]=j[d+4|0];g[b+52|0]=j[d|0];g[b+41|0]=j[d+5|0];g[b+53|0]=j[d+1|0];g[b+42|0]=j[d+6|0];c=j[d+2|0];g[b+55|0]=127;g[b+43|0]=127;g[b+54|0]=c;i[b+64>>2]=i[d+8>>2];i[b+68>>2]=i[d+12>>2]}g[b+8|0]=j[a+39|0];g[b+9|0]=j[a+40|0];g[b+10|0]=j[a+41|0];g[b+11|0]=j[a+42|0];g[b+12|0]=j[a+43|0];g[b+13|0]=j[a+44|0];g[b+14|0]=j[a+45|0];g[b+15|0]=j[a+46|0];g[b+16|0]=j[a+47|0];g[b+17|0]=j[a+48|0];g[b+18|0]=j[a+49|0];g[b+19|0]=j[a+50|0];g[b+20|0]=j[a+51|0];g[b+21|0]=j[a+52|0];g[b+22|0]=j[a+53|0];g[b+23|0]=j[a+54|0]}e=1;break a}i[b>>2]=2;l=o(i[a+108>>2],6);i[b+4>>2]=j[l+20320|0];e=1;c=(r<<9)+308e3|0;v=j[c+(j[a+22|0]<<1)|0];r=b+40|0;l=o(j[l+20324|0],3);u=j[l+20400|0]<<2;f=r+u|0;g[f|0]=(o(j[c+(j[a+21|0]<<1)|0],31)+127>>>0)/255;z=u;u=b+52|0;n=z+u|0;g[n|0]=(o(v,31)+127>>>0)/255;v=j[c+(j[a+24|0]<<1)|0];g[f+1|0]=(o(j[c+(j[a+23|0]<<1)|0],31)+127>>>0)/255;g[n+1|0]=(o(v,31)+127>>>0)/255;v=j[c+(j[a+26|0]<<1)|0];g[f+2|0]=(o(j[c+(j[a+25|0]<<1)|0],31)+127>>>0)/255;g[n+2|0]=(o(v,31)+127>>>0)/255;v=j[c+(j[a+28|0]<<1)|0];n=j[l+20401|0]<<2;f=n+r|0;g[f|0]=(o(j[c+(j[a+27|0]<<1)|0],31)+127>>>0)/255;n=n+u|0;g[n|0]=(o(v,31)+127>>>0)/255;v=j[c+(j[a+30|0]<<1)|0];g[f+1|0]=(o(j[c+(j[a+29|0]<<1)|0],31)+127>>>0)/255;g[n+1|0]=(o(v,31)+127>>>0)/255;v=j[c+(j[a+32|0]<<1)|0];g[f+2|0]=(o(j[c+(j[a+31|0]<<1)|0],31)+127>>>0)/255;g[n+2|0]=(o(v,31)+127>>>0)/255;f=j[c+(j[a+34|0]<<1)|0];l=j[l+20402|0]<<2;r=l+r|0;g[r|0]=(o(j[c+(j[a+33|0]<<1)|0],31)+127>>>0)/255;l=l+u|0;g[l|0]=(o(f,31)+127>>>0)/255;f=j[c+(j[a+36|0]<<1)|0];g[r+1|0]=(o(j[c+(j[a+35|0]<<1)|0],31)+127>>>0)/255;g[l+1|0]=(o(f,31)+127>>>0)/255;f=j[c+(j[a+38|0]<<1)|0];g[r+2|0]=(o(j[c+(j[a+37|0]<<1)|0],31)+127>>>0)/255;g[l+2|0]=(o(f,31)+127>>>0)/255;g[b+8|0]=j[a+39|0];g[b+9|0]=j[a+40|0];g[b+10|0]=j[a+41|0];g[b+11|0]=j[a+42|0];g[b+12|0]=j[a+43|0];g[b+13|0]=j[a+44|0];g[b+14|0]=j[a+45|0];g[b+15|0]=j[a+46|0];g[b+16|0]=j[a+47|0];g[b+17|0]=j[a+48|0];g[b+18|0]=j[a+49|0];g[b+19|0]=j[a+50|0];g[b+20|0]=j[a+51|0];g[b+21|0]=j[a+52|0];g[b+22|0]=j[a+53|0];g[b+23|0]=j[a+54|0]}ha=d+48|0;return e}function xc(a,b,c,d,e,f,k){var m=0,n=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,y=0,z=0,B=0,C=0;m=ha-352|0;ha=m;i[m+344>>2]=0;i[m+348>>2]=0;i[m+336>>2]=0;i[m+340>>2]=0;i[m+328>>2]=0;i[m+332>>2]=0;i[m+320>>2]=0;i[m+312>>2]=0;i[m+316>>2]=0;i[m+304>>2]=0;i[m+308>>2]=0;i[m+296>>2]=0;i[m+300>>2]=0;i[m+288>>2]=0;i[m+292>>2]=0;i[m+280>>2]=0;i[m+272>>2]=0;i[m+276>>2]=0;i[m+264>>2]=0;i[m+268>>2]=0;i[m+256>>2]=0;i[m+260>>2]=0;i[m+248>>2]=0;i[m+252>>2]=0;i[m+240>>2]=0;i[m+232>>2]=0;i[m+236>>2]=0;i[m+224>>2]=0;i[m+228>>2]=0;i[m+216>>2]=0;i[m+220>>2]=0;i[m+208>>2]=0;i[m+212>>2]=0;i[m+200>>2]=0;i[m+192>>2]=0;i[m+196>>2]=0;i[m+184>>2]=0;i[m+188>>2]=0;i[m+176>>2]=0;i[m+180>>2]=0;i[m+168>>2]=0;i[m+172>>2]=0;a:{b:{c:{d:{if(d?!c:0){break d}i[m+344>>2]=0;i[m+348>>2]=0;i[m+336>>2]=c;i[m+332>>2]=c;i[m+328>>2]=d;i[m+340>>2]=c+d;if(!Ha(m+328|0,m+288|0)){break d}if(!Ha(m+328|0,m+248|0)){break d}if(!Ha(m+328|0,m+208|0)){break d}if(!Ha(m+328|0,m+168|0)|i[m+292>>2]==i[m+288>>2]|(i[m+252>>2]==i[m+248>>2]|i[m+212>>2]==i[m+208>>2])){break d}if(i[m+172>>2]==i[m+168>>2]){break d}d=i[m+348>>2];e:{if(d){c=i[m+344>>2];break e}c=0;d=i[m+332>>2];if(d>>>0 >2]){i[m+332>>2]=d+1;c=j[d|0]}d=8;i[m+348>>2]=8;c=i[m+344>>2]|c;i[m+344>>2]=c}i[m+348>>2]=d+ -1;i[m+344>>2]=c>>>1;n=i[a>>2];d=i[a+4>>2]-n>>3;f:{if(d>>>0>>0){wc(a,b-d|0);break f}if(d>>>0<=b>>>0){break f}i[a+4>>2]=n+(b<<3)}i[m+160>>2]=1052688;if(b){w=c&1;B=w?1:3;while(1){g:{h:{if(i[m+172>>2]!=i[m+168>>2]){r=i[m+348>>2];if(r>>>0<16){break h}n=i[m+344>>2];break g}break c}d=i[m+332>>2];t=i[m+340>>2];c=r;while(1){p=0;if(d>>>0 >>0){n=d+1|0;i[m+332>>2]=n;p=j[d|0];d=n}r=c+8|0;i[m+348>>2]=r;n=i[m+344>>2]|p< >2]=n;p=c>>>0<8;c=r;if(p){continue}break}}d=i[i[m+180>>2]+((n&1023)<<2)>>2];i:{if((d|0)<=-1){c=10;p=i[m+192>>2];while(1){t=n>>>c|0;c=c+1|0;d=h[p+((t&1)+(d^-1)<<1)>>1];if((d|0)<0){continue}break}break i}c=d>>>16|0;d=d&65535}i[m+348>>2]=r-c;i[m+344>>2]=n>>>c;s=q<<3;y=d+y&7;g[(s+i[a>>2]|0)+4|0]=y;u=0;while(1){C=m;j:{k:{l:{m:{n:{o:{p:{z=(m+160|0)+u|0;v=j[z|0];if(v>>>0<=9){q:{r:{if(i[m+292>>2]!=i[m+288>>2]){r=i[m+348>>2];if(r>>>0<16){break r}n=i[m+344>>2];break q}break c}d=i[m+332>>2];t=i[m+340>>2];c=r;while(1){p=0;if(d>>>0 >>0){n=d+1|0;i[m+332>>2]=n;p=j[d|0];d=n}r=c+8|0;i[m+348>>2]=r;n=i[m+344>>2]|p< >2]=n;p=c>>>0<8;c=r;if(p){continue}break}}d=i[i[m+300>>2]+((n&1023)<<2)>>2];if((d|0)>-1){break p}c=10;p=i[m+312>>2];while(1){t=n>>>c|0;c=c+1|0;d=h[p+((t&1)+(d^-1)<<1)>>1];if((d|0)<0){continue}break}p=d;break k}if(v>>>0<=21){s:{t:{if(i[m+252>>2]!=i[m+248>>2]){r=i[m+348>>2];if(r>>>0<16){break t}n=i[m+344>>2];break s}break c}d=i[m+332>>2];t=i[m+340>>2];c=r;while(1){p=0;if(d>>>0 >>0){n=d+1|0;i[m+332>>2]=n;p=j[d|0];d=n}r=c+8|0;i[m+348>>2]=r;n=i[m+344>>2]|p< >2]=n;p=c>>>0<8;c=r;if(p){continue}break}}d=i[i[m+260>>2]+((n&1023)<<2)>>2];if((d|0)>-1){break o}c=10;p=i[m+272>>2];while(1){t=n>>>c|0;c=c+1|0;d=h[p+((t&1)+(d^-1)<<1)>>1];if((d|0)<0){continue}break}p=d;break l}u:{v:{if(i[m+212>>2]!=i[m+208>>2]){r=i[m+348>>2];if(r>>>0<16){break v}n=i[m+344>>2];break u}break c}d=i[m+332>>2];t=i[m+340>>2];c=r;while(1){p=0;if(d>>>0 >>0){n=d+1|0;i[m+332>>2]=n;p=j[d|0];d=n}r=c+8|0;i[m+348>>2]=r;n=i[m+344>>2]|p< >2]=n;p=c>>>0<8;c=r;if(p){continue}break}}d=i[i[m+220>>2]+((n&1023)<<2)>>2];if((d|0)>-1){break n}c=10;p=i[m+232>>2];while(1){t=n>>>c|0;c=c+1|0;d=h[p+((t&1)+(d^-1)<<1)>>1];if((d|0)<0){continue}break}break m}p=d&65535;c=d>>>16|0;break k}p=d&65535;c=d>>>16|0;break l}c=d>>>16|0;d=d&65535}p=d;i[m+344>>2]=n>>>c;c=r-c|0;break j}i[m+344>>2]=n>>>c;c=r-c|0;break j}i[m+344>>2]=n>>>c;c=r-c|0}i[C+348>>2]=c;c=p+v&31;g[(s+i[a>>2]|0)+u|0]=c;g[z|0]=c;u=u+1|0;if((B|0)!=(u|0)){continue}break}if(w){c=s+i[a>>2]|0;g[c+1|0]=j[c|0];c=s+i[a>>2]|0;g[c+2|0]=j[c|0]}q=q+1|0;if((q|0)!=(b|0)){continue}break}}r=a+12|0;c=i[a+12>>2];b=(i[a+16>>2]-c|0)/11|0;w:{if(b>>>0 >>0){vc(r,e-b|0);break w}if(b>>>0<=e>>>0){break w}i[a+16>>2]=c+o(e,11)}if(!f){p=0;if(k){break d}}i[m+344>>2]=0;i[m+348>>2]=0;i[m+336>>2]=f;i[m+332>>2]=f;i[m+328>>2]=k;b=f+k|0;i[m+340>>2]=b;c=0;i[m+152>>2]=0;i[m+144>>2]=0;i[m+148>>2]=0;i[m+136>>2]=0;i[m+140>>2]=0;i[m+128>>2]=0;i[m+132>>2]=0;i[m+120>>2]=0;i[m+124>>2]=0;x:{if((k|0)<1){d=f;break x}d=f+1|0;i[m+332>>2]=d;c=j[f|0]}i[m+348>>2]=7;f=c>>>1|0;i[m+344>>2]=f;y:{z:{if(c&1){i[m+348>>2]=3;k=c>>>5|0;i[m+344>>2]=k;c=0;if(d>>>0>>0){i[m+332>>2]=d+1;c=j[d|0]}i[m+348>>2]=7;i[m+344>>2]=c>>>1;i[m+112>>2]=0;i[m+104>>2]=0;i[m+108>>2]=0;i[m+96>>2]=0;i[m+100>>2]=0;i[m+88>>2]=0;i[m+92>>2]=0;i[m+80>>2]=0;i[m+84>>2]=0;A:{B:{C:{u=k|c<<3&8;if(u){if(!Ha(m+328|0,m+80|0)){break B}if(i[m+84>>2]==i[m+80>>2]){break C}}D:{if(!e){b=0;break D}t=f&15;b=1;q=0;while(1){k=0;if(t){k=zb(m+328|0,t)}if(u){E:{F:{if(i[m+84>>2]!=i[m+80>>2]){n=i[m+348>>2];if(n>>>0<16){break F}f=i[m+344>>2];break E}break c}d=i[m+332>>2];s=i[m+340>>2];c=n;while(1){p=0;if(d>>>0 >>0){f=d+1|0;i[m+332>>2]=f;p=j[d|0];d=f}n=c+8|0;i[m+348>>2]=n;f=i[m+344>>2]|p<>2]=f;p=c>>>0<8;c=n;if(p){continue}break}}d=i[i[m+92>>2]+((f&1023)<<2)>>2];G:{if((d|0)<=-1){c=10;p=i[m+104>>2];while(1){s=f>>>c|0;c=c+1|0;d=h[p+((s&1)+(d^-1)<<1)>>1];if((d|0)<0){continue}break}break G}c=d>>>16|0;d=d&65535}i[m+348>>2]=n-c;i[m+344>>2]=f>>>c}else{d=0}p=d;d=i[a+24>>2];c=i[d>>2];if(k>>>0>=i[d+4>>2]-c>>4>>>0){break D}H:{if(p>>>0<32768){g[m+36|0]=p&3;g[m+35|0]=p>>>14;g[m+27|0]=p>>>8&1;b=p&255;g[m+26|0]=b>>>7;g[m+34|0]=p>>>13&1;g[m+33|0]=p>>>12&1;g[m+32|0]=p>>>11&1;g[m+31|0]=p>>>10&1;g[m+25|0]=p>>>9&1;g[m+30|0]=b>>>2&1;g[m+29|0]=b>>>3&1;g[m+28|0]=b>>>6&1;g[m+24|0]=b>>>4&3;yb(m+40|0,c+(k<<4)|0,m+24|0);c=0;while(1){f=c<<2;k=j[f+(m+40|0)|0];if((k|c)>>>0>=4){break a}b=o(q,11);d=b+i[r>>2]|0;n=d+c|0;g[n|0]=k|j[n|0]&252;n=Yd(c);d=d-(c>>>3|0)|0;k=j[k+90991|0];g[d+7|0]=n&j[d+7|0]|(k&1)< >>1< >>0>3){break a}d=b+i[r>>2]|0;n=d+c|0;g[n|0]=j[n|0]&243|k<<2;n=c+4|0;d=d-(n>>>3|0)|0;p=16< >>1< >>0>3){break a}d=b+i[r>>2]|0;n=d+c|0;g[n|0]=j[n|0]&207|k<<4;n=c+8|0;d=d-(n>>>3|0)|0;n=n&7;p=Yd(n);k=j[k+90991|0];g[d+7|0]=p&j[d+7|0]|(k&1)< >>1< >>0>3){break a}d=b+i[r>>2]|0;k=d+c|0;g[k|0]=j[k|0]&63|f<<6;k=c+12|0;d=d-(k>>>3|0)|0;k=k&7;n=Yd(k);f=j[f+90991|0];g[d+7|0]=n&j[d+7|0]|(f&1)< >>1< >2]|0);q=q+1|0;b=q>>>0 >>0;if((e|0)!=(q|0)){continue}break}}a=i[m+104>>2];if(a){i[m+108>>2]=a;wa(a)}a=i[m+92>>2];if(a){i[m+96>>2]=a;wa(a)}a=i[m+80>>2];if(a){i[m+84>>2]=a;wa(a)}p=0;if(!(b&1)){break z}break y}a=i[m+104>>2];if(a){i[m+108>>2]=a;wa(a)}a=i[m+92>>2];if(a){i[m+96>>2]=a;wa(a)}a=i[m+80>>2];if(!a){break A}i[m+84>>2]=a;wa(a);break A}a=i[m+104>>2];if(a){i[m+108>>2]=a;wa(a)}a=i[m+92>>2];if(a){i[m+96>>2]=a;wa(a)}a=i[m+80>>2];if(!a){break A}i[m+84>>2]=a;wa(a)}p=0;break y}i[m+348>>2]=6;f=c>>>2|0;i[m+344>>2]=f;I:{J:{if(c&2){i[m+348>>2]=2;k=c>>>6|0;i[m+344>>2]=k;c=0;if(d>>>0>>0){i[m+332>>2]=d+1;c=j[d|0]}i[m+348>>2]=6;i[m+344>>2]=c>>>2;i[m+112>>2]=0;i[m+104>>2]=0;i[m+108>>2]=0;i[m+96>>2]=0;i[m+100>>2]=0;i[m+88>>2]=0;i[m+92>>2]=0;i[m+80>>2]=0;i[m+84>>2]=0;d=1;if(!Ha(m+328|0,m+80|0)|i[m+84>>2]==i[m+80>>2]){break I}i[m+72>>2]=0;b=m- -64|0;i[b>>2]=0;i[b+4>>2]=0;i[m+56>>2]=0;i[m+60>>2]=0;i[m+48>>2]=0;i[m+52>>2]=0;i[m+40>>2]=0;i[m+44>>2]=0;v=k|c<<2&12;if(v){if(!Ha(m+328|0,m+40|0)|i[m+44>>2]==i[m+40>>2]){break J}}d=0;if(!e){break J}t=f&15;u=0;k=0;b=0;while(1){if(!k){K:{L:{if(i[m+84>>2]!=i[m+80>>2]){n=i[m+348>>2];if(n>>>0<16){break L}f=i[m+344>>2];break K}break c}d=i[m+332>>2];k=i[m+340>>2];c=n;while(1){p=0;if(d>>>0 >>0){b=d+1|0;i[m+332>>2]=b;p=j[d|0];d=b}n=c+8|0;i[m+348>>2]=n;f=i[m+344>>2]|p< >2]=f;b=c>>>0<8;c=n;if(b){continue}break}}d=i[i[m+92>>2]+((f&1023)<<2)>>2];M:{if((d|0)<=-1){c=10;b=i[m+104>>2];while(1){k=f>>>c|0;c=c+1|0;d=h[b+((k&1)+(d^-1)<<1)>>1];if((d|0)<0){continue}break}b=d;break M}c=d>>>16|0;b=d&65535}i[m+348>>2]=n-c;i[m+344>>2]=f>>>c;k=8}c=0;N:{O:{P:{Q:{if(b&1){p=0;q=0;if(t){q=zb(m+328|0,t)}if(!v){break O}R:{S:{if(i[m+44>>2]!=i[m+40>>2]){n=i[m+348>>2];if(n>>>0<16){break S}f=i[m+344>>2];break R}break c}d=i[m+332>>2];s=i[m+340>>2];c=n;while(1){p=0;if(d>>>0 >>0){f=d+1|0;i[m+332>>2]=f;p=j[d|0];d=f}n=c+8|0;i[m+348>>2]=n;f=i[m+344>>2]|p<>2]=f;p=c>>>0<8;c=n;if(p){continue}break}}d=i[i[m+52>>2]+((f&1023)<<2)>>2];if((d|0)>-1){break Q}c=10;p=i[m+64>>2];while(1){s=f>>>c|0;c=c+1|0;d=h[p+((s&1)+(d^-1)<<1)>>1];if((d|0)<0){continue}break}break P}while(1){f=i[m+348>>2];T:{if(f>>>0>=8){d=i[m+344>>2];n=f;break T}d=0;n=i[m+332>>2];if(n>>>0 >2]){i[m+332>>2]=n+1;d=j[n|0]}n=f+8|0;i[m+348>>2]=n;d=i[m+344>>2]|d< >2]=d}i[m+348>>2]=n+ -8;i[m+344>>2]=d>>>8;n=o(u,11);f=n+i[r>>2]|0;p=f+c|0;q=d&3;g[p|0]=q|j[p|0]&252;p=Yd(c);f=f-(c>>>3|0)|0;q=j[q+90991|0];g[f+7|0]=p&j[f+7|0]|(q&1)< >>1< >2]|0;p=f+c|0;q=d>>>2&3;g[p|0]=j[p|0]&243|q<<2;p=c+4|0;f=f-(p>>>3|0)|0;s=16< >>1< >2]|0;p=f+c|0;s=d>>>4&3;g[p|0]=j[p|0]&207|s<<4;p=c+8|0;f=f-(p>>>3|0)|0;p=p&7;q=Yd(p);s=j[s+90991|0];g[f+7|0]=q&j[f+7|0]|(s&1)<
>>1<
>2]|0;n=f+c|0;g[n|0]=j[n|0]&63|d&192;n=c+12|0;f=f-(n>>>3|0)|0;n=n&7;p=Yd(n);d=j[(d>>>6&3)+90991|0];g[f+7|0]=p&j[f+7|0]|(d&1)<
>>1< >>16|0;d=d&65535}p=d;i[m+348>>2]=n-c;i[m+344>>2]=f>>>c}c=i[a+24>>2];d=i[c>>2];if(q>>>0>=i[c+4>>2]-d>>4>>>0){d=1;break J}if(p>>>0<32768){g[m+20|0]=p&3;g[m+19|0]=p>>>14;g[m+11|0]=p>>>8&1;c=p&255;g[m+10|0]=c>>>7;g[m+18|0]=p>>>13&1;g[m+17|0]=p>>>12&1;g[m+16|0]=p>>>11&1;g[m+15|0]=p>>>10&1;g[m+9|0]=p>>>9&1;g[m+14|0]=c>>>2&1;g[m+13|0]=c>>>3&1;g[m+12|0]=c>>>6&1;g[m+8|0]=c>>>4&3;yb(m+24|0,d+(q<<4)|0,m+8|0);c=0;while(1){f=c<<2;p=j[f+(m+24|0)|0];if((p|c)>>>0>=4){break a}n=o(u,11);d=n+i[r>>2]|0;q=d+c|0;g[q|0]=p|j[q|0]&252;q=Yd(c);d=d-(c>>>3|0)|0;p=j[p+90991|0];g[d+7|0]=q&j[d+7|0]|(p&1)< >>1< >>0>3){break a}d=n+i[r>>2]|0;q=d+c|0;g[q|0]=j[q|0]&243|p<<2;q=c+4|0;d=d-(q>>>3|0)|0;s=16< >>1< >>0>3){break a}d=n+i[r>>2]|0;q=d+c|0;g[q|0]=j[q|0]&207|p<<4;q=c+8|0;d=d-(q>>>3|0)|0;q=q&7;s=Yd(q);p=j[p+90991|0];g[d+7|0]=s&j[d+7|0]|(p&1)<>>1<>>0>3){break a}d=n+i[r>>2]|0;n=d+c|0;g[n|0]=j[n|0]&63|f<<6;n=c+12|0;d=d-(n>>>3|0)|0;n=n&7;p=Yd(n);f=j[f+90991|0];g[d+7|0]=p&j[d+7|0]|(f&1)<>>1< >>1|0;k=k+ -1|0;Va(i[r>>2]+o(u,11)|0);u=u+1|0;if((u|0)!=(e|0)){continue}break}d=0;break J}i[m+348>>2]=5;i[m+344>>2]=c>>>3;if(c&4){if(!e){break z}q=0;while(1){c=0;while(1){a=i[m+348>>2];U:{if(a>>>0>=8){d=i[m+344>>2];n=a;break U}d=0;b=i[m+332>>2];if(b>>>0 >2]){i[m+332>>2]=b+1;d=j[b|0]}n=a+8|0;i[m+348>>2]=n;d=i[m+344>>2]|d<>2]=d}i[m+348>>2]=n+ -8;i[m+344>>2]=d>>>8;a=o(q,11);b=a+i[r>>2]|0;f=b+c|0;k=d&3;g[f|0]=k|j[f|0]&252;f=Yd(c);b=b-(c>>>3|0)|0;k=j[k+90991|0];g[b+7|0]=f&j[b+7|0]|(k&1)< >>1< >2]|0;f=b+c|0;k=d>>>2&3;g[f|0]=j[f|0]&243|k<<2;f=c+4|0;b=b-(f>>>3|0)|0;n=16< >>1< >2]|0;f=b+c|0;n=d>>>4&3;g[f|0]=j[f|0]&207|n<<4;f=c+8|0;b=b-(f>>>3|0)|0;f=f&7;k=Yd(f);n=j[n+90991|0];g[b+7|0]=k&j[b+7|0]|(n&1)< >>1< >2]|0;f=b+c|0;g[f|0]=j[f|0]&63|d&192;f=c+12|0;b=b-(f>>>3|0)|0;f=f&7;k=Yd(f);d=j[(d>>>6&3)+90991|0];g[b+7|0]=k&j[b+7|0]|(d&1)< >>1< >2]|0);q=q+1|0;if((q|0)!=(e|0)){continue}break}break z}p=0;if(!Ha(m+328|0,m+120|0)){break y}V:{if(e>>>0>=2){if(i[m+124>>2]==i[m+120>>2]){break y}i[m+80>>2]=0;break V}i[m+80>>2]=0;if(!e){break z}}q=0;while(1){c=0;k=0;W:{if(!q){while(1){a=i[m+348>>2];X:{if(a>>>0>=8){d=i[m+344>>2];n=a;break X}d=0;b=i[m+332>>2];if(b>>>0 >2]){i[m+332>>2]=b+1;d=j[b|0]}n=a+8|0;i[m+348>>2]=n;d=i[m+344>>2]|d<>2]=d}g[(m+80|0)+c|0]=d;i[m+348>>2]=n+ -8;i[m+344>>2]=d>>>8;a=i[r>>2];b=a+c|0;f=d&3;g[b|0]=f|j[b|0]&252;b=Yd(c);a=a-(c>>>3|0)|0;f=j[f+90991|0];g[a+7|0]=b&j[a+7|0]|(f&1)< >>1< >2];b=a+c|0;f=d>>>2&3;g[b|0]=j[b|0]&243|f<<2;b=c+4|0;a=a-(b>>>3|0)|0;k=16< >>1<>2];b=a+c|0;k=d>>>4&3;g[b|0]=j[b|0]&207|k<<4;b=c+8|0;a=a-(b>>>3|0)|0;b=b&7;f=Yd(b);k=j[k+90991|0];g[a+7|0]=f&j[a+7|0]|(k&1)<>>1<>2];b=a+c|0;g[b|0]=j[b|0]&63|d&192;b=c+12|0;a=a-(b>>>3|0)|0;b=b&7;f=Yd(b);d=j[(d>>>6&3)+90991|0];g[a+7|0]=f&j[a+7|0]|(d&1)<>>1<>2];break W}while(1){Y:{Z:{if(i[m+124>>2]!=i[m+120>>2]){n=i[m+348>>2];if(n>>>0<16){break Z}f=i[m+344>>2];break Y}break c}d=i[m+332>>2];b=i[m+340>>2];c=n;while(1){p=0;if(d>>>0>>0){a=d+1|0;i[m+332>>2]=a;p=j[d|0];d=a}n=c+8|0;i[m+348>>2]=n;f=i[m+344>>2]|p< >2]=f;a=c>>>0<8;c=n;if(a){continue}break}}a=(m+80|0)+k|0;b=a;d=i[i[m+132>>2]+((f&1023)<<2)>>2];_:{if((d|0)<=-1){c=10;p=i[m+144>>2];while(1){t=f>>>c|0;c=c+1|0;d=h[p+((t&1)+(d^-1)<<1)>>1];if((d|0)<0){continue}break}break _}c=d>>>16|0;d=d&65535}a=j[a|0]^d;g[b|0]=a;i[m+348>>2]=n-c;i[m+344>>2]=f>>>c;b=o(q,11);c=b+i[r>>2]|0;d=c+k|0;f=a&3;g[d|0]=f|j[d|0]&252;d=Yd(k);c=c-(k>>>3|0)|0;f=j[f+90991|0];g[c+7|0]=d&j[c+7|0]|(f&1)< >>1< >2]|0;d=c+k|0;f=a>>>2&3;g[d|0]=j[d|0]&243|f<<2;d=k+4|0;c=c-(d>>>3|0)|0;n=16< >>1< >2]|0;d=c+k|0;n=a>>>4&3;g[d|0]=j[d|0]&207|n<<4;d=k+8|0;c=c-(d>>>3|0)|0;d=d&7;f=Yd(d);n=j[n+90991|0];g[c+7|0]=f&j[c+7|0]|(n&1)< >>1< >2]|0;d=c+k|0;g[d|0]=j[d|0]&63|a&192;d=k+12|0;c=c-(d>>>3|0)|0;d=d&7;f=Yd(d);a=j[(a>>>6&3)+90991|0];g[c+7|0]=f&j[c+7|0]|(a&1)< >>1< >2]|0}Va(a);q=q+1|0;if((q|0)!=(e|0)){continue}break}break z}a=i[m+64>>2];if(a){i[m+68>>2]=a;wa(a)}a=i[m+52>>2];if(a){i[m+56>>2]=a;wa(a)}a=i[m+40>>2];if(!a){break I}i[m+44>>2]=a;wa(a)}a=i[m+104>>2];if(a){i[m+108>>2]=a;wa(a)}a=i[m+92>>2];if(a){i[m+96>>2]=a;wa(a)}a=i[m+80>>2];if(a){i[m+84>>2]=a;wa(a)}p=0;if(d){break y}}p=1}a=i[m+144>>2];if(a){i[m+148>>2]=a;wa(a)}a=i[m+132>>2];if(a){i[m+136>>2]=a;wa(a)}a=i[m+120>>2];if(!a){break d}i[m+124>>2]=a;wa(a)}a=i[m+192>>2];if(a){i[m+196>>2]=a;wa(a)}a=i[m+180>>2];if(a){i[m+184>>2]=a;wa(a)}a=i[m+168>>2];if(a){i[m+172>>2]=a;wa(a)}a=i[m+232>>2];if(a){i[m+236>>2]=a;wa(a)}a=i[m+220>>2];if(a){i[m+224>>2]=a;wa(a)}a=i[m+208>>2];if(a){i[m+212>>2]=a;wa(a)}a=i[m+272>>2];if(a){i[m+276>>2]=a;wa(a)}a=i[m+260>>2];if(a){i[m+264>>2]=a;wa(a)}a=i[m+248>>2];if(a){i[m+252>>2]=a;wa(a)}a=i[m+312>>2];if(a){i[m+316>>2]=a;wa(a)}a=i[m+300>>2];if(a){i[m+304>>2]=a;wa(a)}a=i[m+288>>2];if(a){i[m+292>>2]=a;wa(a)}ha=m+352|0;return p}A(90786,90648,445,90809);x()}A(90960,29004,48,90981);x()}A(90995,90648,748,91013);x()}function nc(a,b){var c=0,d=0,e=0,f=0,l=0,m=0,n=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,y=0,z=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;d=ha-320|0;ha=d;a:{$=Ba(a,d+168|0,0,1);b:{if(!$){break b}a=i[d+272>>2];if((a|0)==8){p=k[(j[d+283|0]<<1)+26160>>1];a=p<<3;g[b+2|0]=a;g[b+1|0]=a;g[b|0]=a;a=i[(p>>>3&12)+26080>>2];g[b+4|0]=a;g[b+5|0]=a>>>8;g[b+6|0]=a>>>16;g[b+7|0]=a>>>24;a=p>>>7|0;g[b+3|0]=a<<5|a<<2|2;break b}Ea(a,i[d+276>>2],d+280|0,d+168|0,d+96|0);a=d;U=j[d+99|0];g[d+80|0]=U;X=j[d+103|0];g[d+81|0]=X;G=j[d+111|0];g[d+83|0]=G;F=j[d+119|0];g[d+85|0]=F;D=j[d+127|0];g[d+87|0]=D;H=j[d+135|0];g[d+89|0]=H;Y=j[d+131|0];g[d+88|0]=Y;y=j[d+123|0];g[d+86|0]=y;z=j[d+115|0];g[d+84|0]=z;L=j[d+107|0];g[d+82|0]=L;B=j[d+139|0];g[d+90|0]=B;u=j[d+143|0];g[d+91|0]=u;t=j[d+147|0];g[d+92|0]=t;r=j[d+151|0];g[d+93|0]=r;f=j[d+155|0];g[d+94|0]=f;m=j[d+159|0];g[d+95|0]=m;i[d+72>>2]=255;i[d+76>>2]=255;i[d+64>>2]=0;i[d+68>>2]=0;e=j[d+81|0];c=j[d+80|0];P=c>>>0 >>0?e:c;V=c>>>0>e>>>0?e:c;q=D+(G+(y+L|0)|0)|0;n=(F+(X+(z+U|0)|0)|0)+4|0;I=q+n>>>3|0;c=z-I|0;e=o(c,c);c=U-I|0;e=e+o(c,c)|0;c=X-I|0;e=e+o(c,c)|0;c=F-I|0;e=e+o(c,c)|0;c=L-I|0;e=e+o(c,c)|0;c=y-I|0;e=e+o(c,c)|0;c=G-I|0;e=e+o(c,c)|0;c=D-I|0;s=e+o(c,c)|0;l=(m+(u+(f+B|0)|0)|0)+4|0;e=r+(H+(t+Y|0)|0)|0;J=l+e>>>3|0;c=Y-J|0;s=s+o(c,c)|0;c=t-J|0;s=s+o(c,c)|0;c=H-J|0;s=s+o(c,c)|0;c=r-J|0;s=s+o(c,c)|0;c=B-J|0;s=s+o(c,c)|0;c=f-J|0;s=s+o(c,c)|0;c=u-J|0;s=s+o(c,c)|0;c=m-J|0;Z=s+o(c,c)|0;c=G;G=q+l>>>3|0;c=c-G|0;l=o(c,c);c=L-G|0;l=l+o(c,c)|0;c=y-G|0;l=l+o(c,c)|0;c=D-G|0;l=l+o(c,c)|0;c=B-G|0;l=l+o(c,c)|0;c=f-G|0;f=l+o(c,c)|0;c=u-G|0;f=f+o(c,c)|0;u=e+n>>>3|0;c=U-u|0;e=f+o(c,c)|0;c=X-u|0;e=e+o(c,c)|0;c=z-u|0;e=e+o(c,c)|0;c=F-u|0;e=e+o(c,c)|0;c=Y-u|0;e=e+o(c,c)|0;c=H-u|0;e=e+o(c,c)|0;c=t-u|0;e=e+o(c,c)|0;c=r-u|0;e=e+o(c,c)|0;c=m-G|0;_=e+o(c,c)|0;E=(Z|0)<(_|0);c:{if(!E){f=j[d+93|0];m=j[d+92|0];q=j[d+89|0];n=j[d+88|0];l=j[d+85|0];e=j[d+84|0];c=V>>>0>e>>>0?e:V;c=c>>>0>l>>>0?l:c;c=c>>>0>n>>>0?n:c;c=c>>>0>q>>>0?q:c;c=c>>>0>m>>>0?m:c;y=c>>>0>f>>>0?f:c;i[d+72>>2]=y;c=P>>>0 >>0?e:P;c=c>>>0 >>0?l:c;c=c>>>0 >>0?n:c;c=c>>>0 >>0?q:c;c=c>>>0>>0?m:c;D=c>>>0 >>0?f:c;i[d+64>>2]=D;t=j[d+95|0];r=j[d+94|0];f=j[d+91|0];m=j[d+90|0];q=j[d+87|0];n=j[d+86|0];l=j[d+83|0];e=j[d+82|0];c=e>>>0>l>>>0?l:e;c=c>>>0>n>>>0?n:c;c=c>>>0>q>>>0?q:c;c=c>>>0>m>>>0?m:c;c=c>>>0>f>>>0?f:c;c=c>>>0>r>>>0?r:c;z=c>>>0>t>>>0?t:c;i[d+76>>2]=z;c=e>>>0 >>0?l:e;c=c>>>0 >>0?n:c;c=c>>>0 >>0?q:c;c=c>>>0>>0?m:c;c=c>>>0 >>0?f:c;c=c>>>0 >>0?r:c;c=c>>>0 >>0?t:c;break c}f=j[d+87|0];m=j[d+86|0];q=j[d+85|0];n=j[d+84|0];l=j[d+83|0];e=j[d+82|0];c=V>>>0>e>>>0?e:V;c=c>>>0>l>>>0?l:c;c=c>>>0>n>>>0?n:c;c=c>>>0>q>>>0?q:c;c=c>>>0>m>>>0?m:c;y=c>>>0>f>>>0?f:c;i[d+72>>2]=y;c=P>>>0 >>0?e:P;c=c>>>0 >>0?l:c;c=c>>>0 >>0?n:c;c=c>>>0 >>0?q:c;c=c>>>0>>0?m:c;D=c>>>0 >>0?f:c;i[d+64>>2]=D;t=j[d+95|0];r=j[d+94|0];f=j[d+93|0];m=j[d+92|0];q=j[d+91|0];n=j[d+90|0];l=j[d+89|0];e=j[d+88|0];c=e>>>0>l>>>0?l:e;c=c>>>0>n>>>0?n:c;c=c>>>0>q>>>0?q:c;c=c>>>0>m>>>0?m:c;c=c>>>0>f>>>0?f:c;c=c>>>0>r>>>0?r:c;z=c>>>0>t>>>0?t:c;i[d+76>>2]=z;c=e>>>0 >>0?l:e;c=c>>>0 >>0?n:c;c=c>>>0 >>0?q:c;c=c>>>0>>0?m:c;c=c>>>0 >>0?f:c;c=c>>>0 >>0?r:c;c=c>>>0 >>0?t:c}i[a+68>>2]=c;a=D-y|0;i[d+56>>2]=a;e=c-z|0;i[d+60>>2]=e;g[b+3|0]=E;d:{e:{f:{g:{h:{i:{j:{k:{l:{m:{n:{o:{p:{q:{if((a|e)>>>0<=3){D=0;g[b+2|0]=0;h[b>>1]=0;z=0;F=0;y=0;while(1){r:{s:{switch(a|0){case 0:a=i[(d+72|0)+(v<<2)>>2];c=(a<<1)+26672|0;break r;case 1:a=i[(d+72|0)+(v<<2)>>2];c=(a<<1)+27184|0;break r;default:break s}}a=i[(d+72|0)+(v<<2)>>2];c=(a<<1)+27696|0}w=k[c>>1];p=w>>>3&31;if(p>>>0>=16){break q}i[d+44>>2]=w>>>14;i[d+40>>2]=w>>>12&3;i[d+36>>2]=w>>>10&3;i[d+32>>2]=w>>>8&3;E=(w&7)<<(v?2:5)|E;g[b+3|0]=E;p=p<<(!v<<2);D=p|D;g[b+2|0]=D;z=p|z;g[b+1|0]=z;Q=p|Q;g[b|0]=Q;B=v<<1;t:{if((Z|0)<(_|0)){w=(d+80|0)+(B<<2)|0;p=j[w|0];if(a>>>0>p>>>0){break p}f=i[(d- -64|0)+(v<<2)>>2];if(f>>>0 >>0){break p}q=p-a|0;if(q>>>0>=4){break o}p=j[w+1|0];if(a>>>0>p>>>0|f>>>0
>>0){break p}n=p-a|0;if(n>>>0>3){break o}p=j[w+2|0];if(a>>>0>p>>>0|f>>>0
>>0){break p}l=p-a|0;if(l>>>0>3){break o}p=j[w+3|0];if(a>>>0>p>>>0|f>>>0
>>0){break p}e=p-a|0;if(e>>>0>3){break o}u=B|1;m=(d+80|0)+(u<<2)|0;p=j[m|0];if(a>>>0>p>>>0|f>>>0
>>0){break p}c=p-a|0;if(c>>>0>3){break o}p=j[m+1|0];if(a>>>0>p>>>0|f>>>0
>>0){break p}w=p-a|0;if(w>>>0>3){break o}p=j[m+2|0];if(a>>>0>p>>>0|f>>>0
>>0){break p}p=p-a|0;if(p>>>0>3){break o}m=j[m+3|0];if(a>>>0>m>>>0|f>>>0
>>0){break p}M=m-a|0;if(M>>>0>=4){break o}K=u+12|0;t=j[i[(d+32|0)+(q<<2)>>2]+28292|0];r=j[i[(d+32|0)+(n<<2)>>2]+28292|0];f=B+4|0;m=j[i[(d+32|0)+(l<<2)>>2]+28292|0];q=B+8|0;n=j[i[(d+32|0)+(e<<2)>>2]+28292|0];l=B+12|0;e=j[i[(d+32|0)+(c<<2)>>2]+28292|0];c=j[i[(d+32|0)+(w<<2)>>2]+28292|0];w=u+4|0;p=j[i[(d+32|0)+(p<<2)>>2]+28292|0];a=u+8|0;F=(t&1)<>>1<>>1< >>1< >>1<>>1<>>1< >>1<>>0>p>>>0){break n}r=i[(d- -64|0)+(v<<2)>>2];if(r>>>0 >>0){break n}n=p-a|0;if(n>>>0>=4){break m}p=j[w+4|0];if(a>>>0>p>>>0|r>>>0
>>0){break n}l=p-a|0;if(l>>>0>3){break m}p=j[w+8|0];if(a>>>0>p>>>0|r>>>0
>>0){break n}e=p-a|0;if(e>>>0>3){break m}p=j[w+12|0];if(a>>>0>p>>>0|r>>>0
>>0){break n}c=p-a|0;if(c>>>0>3){break m}m=(d+80|0)+(B|1)|0;p=j[m|0];if(a>>>0>p>>>0|r>>>0
>>0){break n}w=p-a|0;if(w>>>0>3){break m}p=j[m+4|0];if(a>>>0>p>>>0|r>>>0
>>0){break n}p=p-a|0;if(p>>>0>3){break m}q=j[m+8|0];if(a>>>0>q>>>0|r>>>0
>>0){break n}f=q-a|0;if(f>>>0>3){break m}q=j[m+12|0];if(a>>>0>q>>>0|r>>>0>>0){break n}M=q-a|0;if(M>>>0>=4){break m}L=v<<3;K=L|7;B=L|1;u=B+1|0;t=L|5;r=t+1|0;m=j[i[(d+32|0)+(n<<2)>>2]+28292|0];q=j[i[(d+32|0)+(l<<2)>>2]+28292|0];n=j[i[(d+32|0)+(e<<2)>>2]+28292|0];l=j[i[(d+32|0)+(c<<2)>>2]+28292|0];e=L|3;c=j[i[(d+32|0)+(w<<2)>>2]+28292|0];w=L|4;p=j[i[(d+32|0)+(p<<2)>>2]+28292|0];a=j[i[(d+32|0)+(f<<2)>>2]+28292|0];F=(m&1)<>>1< >>1<>>1<>>1< >>1< >>1< >>1< >2]+28292|0];y=p|a>>>1< >2];continue}}Y=(Z|0)<(_|0);n=Y?J:G;q=((o(n,31)+127&65535)>>>0)/255|0;a=Y?I:u;e=((o(a,31)+127&65535)>>>0)/255|0;m=q-e|0;l=m+4|0;u:{if(l>>>0<=7){E=E|2;g[b+3|0]=E;a=e<<3;C=a|((m|0)<0?m+8|0:m);g[b|0]=C;v=a|e>>>2;a=q<<3|q>>>2;break u}e=((o(a,15)+127&65535)>>>0)/255|0;a=e<<4;n=((o(n,15)+127&65535)>>>0)/255|0;C=a|n;g[b|0]=C;v=a|e;a=n|n<<4}g[b+2|0]=C;g[b+1|0]=C;i[d+28>>2]=a;i[d+24>>2]=v;c=c-a|0;n=c>>31;a=a-z|0;e=a>>31;c=n^c+n;a=e^a+e;i[d+20>>2]=(c|0)>(a|0)?c:a;c=D-v|0;n=c>>31;a=v-y|0;e=a>>31;c=n^c+n;a=e^a+e;i[d+16>>2]=(c|0)>(a|0)?c:a;L=l>>>0<8;while(1){v:{w:{if(L){break w}n=K<<2;a=i[n+(d+56|0)>>2];if(a>>>0>3){break w}x:{y:{switch(a|0){case 0:a=i[n+(d+72|0)>>2];c=(a<<1)+26672|0;break x;case 1:a=i[n+(d+72|0)>>2];c=(a<<1)+27184|0;break x;default:break y}}a=i[n+(d+72|0)>>2];c=(a<<1)+27696|0}c=k[c>>1];e=c>>>3&31;if(e>>>0>=16){break l}i[d+44>>2]=c>>>14;i[d+40>>2]=c>>>12&3;i[d+36>>2]=c>>>10&3;i[d+32>>2]=c>>>8&3;E=(c&7)<<(K?2:5)|E;g[b+3|0]=E;c=!K<<2;l=15< >>0>c>>>0){break k}t=i[n+(d- -64|0)>>2];if(t>>>0 >>0){break k}f=c-a|0;if(f>>>0>=4){break j}c=j[e+1|0];if(a>>>0>c>>>0|t>>>0 >>0){break k}m=c-a|0;if(m>>>0>3){break j}c=j[e+2|0];if(a>>>0>c>>>0|t>>>0 >>0){break k}q=c-a|0;if(q>>>0>3){break j}c=j[e+3|0];if(a>>>0>c>>>0|t>>>0 >>0){break k}n=c-a|0;if(n>>>0>3){break j}z=y|1;r=(d+80|0)+(z<<2)|0;c=j[r|0];if(a>>>0>c>>>0|t>>>0 >>0){break k}l=c-a|0;if(l>>>0>3){break j}c=j[r+1|0];if(a>>>0>c>>>0|t>>>0 >>0){break k}e=c-a|0;if(e>>>0>3){break j}c=j[r+2|0];if(a>>>0>c>>>0|t>>>0 >>0){break k}c=c-a|0;if(c>>>0>3){break j}r=j[r+3|0];if(a>>>0>r>>>0|t>>>0 >>0){break k}D=r-a|0;if(D>>>0>=4){break j}C=z+12|0;B=j[i[(d+32|0)+(f<<2)>>2]+28292|0];u=j[i[(d+32|0)+(m<<2)>>2]+28292|0];t=y+4|0;r=j[i[(d+32|0)+(q<<2)>>2]+28292|0];f=y+8|0;m=j[i[(d+32|0)+(n<<2)>>2]+28292|0];q=y+12|0;n=j[i[(d+32|0)+(l<<2)>>2]+28292|0];l=j[i[(d+32|0)+(e<<2)>>2]+28292|0];e=z+4|0;c=j[i[(d+32|0)+(c<<2)>>2]+28292|0];a=z+8|0;F=(B&1)< >>1< >>1< >>1< >>1< >>1<>>1< >>1<>>0>c>>>0){break i}u=i[n+(d- -64|0)>>2];if(u>>>0 >>0){break i}m=c-a|0;if(m>>>0>=4){break h}c=j[e+4|0];if(a>>>0>c>>>0|u>>>0 >>0){break i}q=c-a|0;if(q>>>0>3){break h}c=j[e+8|0];if(a>>>0>c>>>0|u>>>0 >>0){break i}n=c-a|0;if(n>>>0>3){break h}c=j[e+12|0];if(a>>>0>c>>>0|u>>>0 >>0){break i}l=c-a|0;if(l>>>0>3){break h}r=(d+80|0)+(y|1)|0;c=j[r|0];if(a>>>0>c>>>0|u>>>0 >>0){break i}e=c-a|0;if(e>>>0>3){break h}c=j[r+4|0];if(a>>>0>c>>>0|u>>>0 >>0){break i}c=c-a|0;if(c>>>0>3){break h}f=j[r+8|0];if(a>>>0>f>>>0|u>>>0 >>0){break i}t=f-a|0;if(t>>>0>3){break h}f=j[r+12|0];if(a>>>0>f>>>0|u>>>0 >>0){break i}D=f-a|0;if(D>>>0>=4){break h}H=K<<3;C=H|7;y=H|1;z=y+1|0;B=H|5;u=B+1|0;r=j[i[(d+32|0)+(m<<2)>>2]+28292|0];f=j[i[(d+32|0)+(q<<2)>>2]+28292|0];m=j[i[(d+32|0)+(n<<2)>>2]+28292|0];q=j[i[(d+32|0)+(l<<2)>>2]+28292|0];n=H|3;l=j[i[(d+32|0)+(e<<2)>>2]+28292|0];e=H|4;c=j[i[(d+32|0)+(c<<2)>>2]+28292|0];a=j[i[(d+32|0)+(t<<2)>>2]+28292|0];F=(r&1)< >>1< >>1< >>1< >>1< >>1< >>1<>>1<>2]+28292|0];Q=c|a>>>1< >2];if(s>>>0>=256){break g}e=i[c+(d+16|0)>>2];A:{if(e>>>0<=51){a=e>>>0>22?14:15;a=e+ -4>>>0>35?a&13:a;a=e>>>0<9?a&11:a;a=e>>>0<12?a&7:a;break A}a=e>>>0>60?248:252;a=e>>>0>89?a&244:a;a=e>>>0>120?a&236:a;a=e>>>0>136?a&220:a;a=e>>>0>174?a&188:a}V=255-s|0;U=0-s|0;R=K<<3;I=R+(d+80|0)|0;X=I|3;G=I|2;F=I|1;W=K<<1;S=W|1;J=(d+80|0)+(S<<2)|0;D=J|3;H=J|2;y=J|1;B=c+(d+72|0)|0;u=c+(d- -64|0)|0;E=-1;P=0;z=0;while(1){if(a>>>P&1){e=P<<4;c=i[e+28352>>2];m=(c|0)>(U|0)?c:U;c=i[e+28356>>2];n=(c|0)>(U|0)?c:U;if((m|0)>(n|0)){break f}c=i[e+28360>>2];l=(c|0)<(V|0)?c:V;if((n|0)>(l|0)){break f}c=i[e+28364>>2];q=(c|0)<(V|0)?c:V;if((l|0)>(q|0)){break f}i[d+32>>2]=l;i[d+36>>2]=q;i[d+40>>2]=n;i[d+44>>2]=m;if((m|0)>(l|0)|(n|0)>(q|0)){break e}N=q+l|0;T=n+l|0;O=m+n|0;c=i[u>>2]-s<<1;B:{if((Z|0)<(_|0)){if((c|0)<(O|0)){i[d+8>>2]=50529027;i[d+12>>2]=50529027;c=m+(s-j[F|0]|0)|0;e=o(c,c);c=m+(s-j[I|0]|0)|0;e=e+o(c,c)|0;c=m+(s-j[G|0]|0)|0;e=e+o(c,c)|0;c=m+(s-j[X|0]|0)|0;v=e+o(c,c)|0;if(v>>>0>=E>>>0){break B}c=m+(s-j[J|0]|0)|0;e=o(c,c)+v|0;c=m+(s-j[y|0]|0)|0;e=e+o(c,c)|0;c=m+(s-j[H|0]|0)|0;e=e+o(c,c)|0;c=m+(s-j[D|0]|0)|0;v=e+o(c,c)|0;break B}if(i[B>>2]-s<<1<(N|0)){t=j[I|0]-s|0;c=t<<1;c=j[((((c|0)<(O|0))+((c|0)<(T|0))|0)+((c|0)<(N|0))|0)+297662|0];g[d+8|0]=c;r=i[(d+32|0)+(c<<2)>>2];f=j[F|0]-s|0;c=f<<1;c=j[((((c|0)<(O|0))+((c|0)<(T|0))|0)+((c|0)<(N|0))|0)+297662|0];g[d+9|0]=c;m=i[(d+32|0)+(c<<2)>>2];q=j[G|0]-s|0;c=q<<1;c=j[((((c|0)<(O|0))+((c|0)<(T|0))|0)+((c|0)<(N|0))|0)+297662|0];g[d+10|0]=c;n=i[(d+32|0)+(c<<2)>>2];l=j[X|0]-s|0;c=l<<1;e=j[((((c|0)<(O|0))+((c|0)<(T|0))|0)+((c|0)<(N|0))|0)+297662|0];g[d+11|0]=e;c=m-f|0;f=o(c,c);c=r-t|0;f=f+o(c,c)|0;c=n-q|0;f=f+o(c,c)|0;c=i[(d+32|0)+(e<<2)>>2]-l|0;v=f+o(c,c)|0;if(v>>>0>=E>>>0){break B}t=j[J|0]-s|0;c=t<<1;c=j[((((c|0)<(O|0))+((c|0)<(T|0))|0)+((c|0)<(N|0))|0)+297662|0];g[d+12|0]=c;r=i[(d+32|0)+(c<<2)>>2];l=j[D|0];e=j[H|0];f=j[y|0]-s|0;c=f<<1;c=j[((((c|0)<(O|0))+((c|0)<(T|0))|0)+((c|0)<(N|0))|0)+297662|0];g[d+13|0]=c;m=i[(d+32|0)+(c<<2)>>2];q=e-s|0;c=q<<1;c=j[((((c|0)<(O|0))+((c|0)<(T|0))|0)+((c|0)<(N|0))|0)+297662|0];g[d+14|0]=c;n=i[(d+32|0)+(c<<2)>>2];l=l-s|0;c=l<<1;e=j[((((c|0)<(O|0))+((c|0)<(T|0))|0)+((c|0)<(N|0))|0)+297662|0];g[d+15|0]=e;c=r-t|0;r=o(c,c)+v|0;c=m-f|0;f=r+o(c,c)|0;c=n-q|0;f=f+o(c,c)|0;c=i[(d+32|0)+(e<<2)>>2]-l|0;v=f+o(c,c)|0;break B}i[d+8>>2]=16843009;i[d+12>>2]=16843009;c=q+(s-j[F|0]|0)|0;e=o(c,c);c=q+(s-j[I|0]|0)|0;e=e+o(c,c)|0;c=q+(s-j[G|0]|0)|0;e=e+o(c,c)|0;c=q+(s-j[X|0]|0)|0;v=e+o(c,c)|0;if(v>>>0>=E>>>0){break B}c=q+(s-j[J|0]|0)|0;e=o(c,c)+v|0;c=q+(s-j[y|0]|0)|0;e=e+o(c,c)|0;c=q+(s-j[H|0]|0)|0;e=e+o(c,c)|0;c=q+(s-j[D|0]|0)|0;v=e+o(c,c)|0;break B}if((c|0)<(O|0)){i[d+8>>2]=50529027;i[d+12>>2]=50529027;C=0;v=0;while(1){e=(d+80|0)+(C<<2)|0;c=m+(s-j[e+S|0]|0)|0;f=o(c,c);c=m+(s-j[e+W|0]|0)|0;v=f+(o(c,c)+v|0)|0;if(v>>>0>=E>>>0){break B}c=C>>>0<3;C=C+1|0;if(c){continue}break}break B}C=0;v=0;if(i[B>>2]-s<<1>=(N|0)){i[d+8>>2]=16843009;i[d+12>>2]=16843009;while(1){e=(d+80|0)+(C<<2)|0;c=q+(s-j[e+S|0]|0)|0;f=o(c,c);c=q+(s-j[e+W|0]|0)|0;v=f+(o(c,c)+v|0)|0;if(v>>>0>=E>>>0){break B}c=C>>>0<3;C=C+1|0;if(c){continue}break}break B}while(1){l=C<<1;e=(d+80|0)+(C<<2)|0;n=j[e+W|0]-s|0;c=n<<1;c=j[((((c|0)<(O|0))+((c|0)<(T|0))|0)+((c|0)<(N|0))|0)+297662|0];g[l+(d+8|0)|0]=c;f=(d+8|0)+(l|1)|0;l=j[e+S|0]-s|0;e=l<<1;e=j[((((e|0)<(O|0))+((e|0)<(T|0))|0)+((e|0)<(N|0))|0)+297662|0];g[f|0]=e;c=i[(d+32|0)+(c<<2)>>2]-n|0;f=o(c,c)+v|0;c=i[(d+32|0)+(e<<2)>>2]-l|0;v=f+o(c,c)|0;if(v>>>0>=E>>>0){break B}c=C>>>0<3;C=C+1|0;if(c){continue}break}}c=v>>>0 >>0;z=c?P:z;w=c?i[d+8>>2]:w;E=c?v:E;p=c?i[d+12>>2]:p}P=P+1|0;if((P|0)!=8){continue}break}E=j[b+3|0]|z<<(K?2:5);g[b+3|0]=E;a=p;B=a>>>24|0;u=a>>>8|0;t=(a&16777215)<<8|w>>>24;l=(a&255)<<24|w>>>8;r=a>>>16|0;e=a;c=(a&65535)<<16|w>>>16;C:{if(Y){if(K>>>0<2){break C}break a}f=R|1;m=R|2;q=R|3;n=R|4;z=(w&1)< >>1&127)< >>17&127)< >>1&127)< >>17&127)< >>9&127)<>>25< >>9&127)< >>25< >>0>3){break a}f=w;m=W+4|0;q=W+8|0;n=W+12|0;z=(f&1)< >>1&127)< >>9&127)< >>17&127)< >>25<>>1&127)< >>9&127)<>>17&127)< >>25< >>8;h[b+6>>1]=(M<<8&16711680|M<<24)>>>16;break b}A(28208,19512,14079,28219);x()}A(28243,19512,14097,28219);x()}A(28285,19512,14099,28219);x()}A(28243,19512,14120,28219);x()}A(28285,19512,14122,28219);x()}A(28208,19512,14196,28219);x()}A(28243,19512,14220,28219);x()}A(28285,19512,14222,28219);x()}A(28243,19512,14243,28219);x()}A(28285,19512,14245,28219);x()}A(28305,19512,14269,28219);x()}A(28480,19512,14319,28219);x()}A(28519,19512,14327,28219);x()}g[b+5|0]=y;g[b+4|0]=y>>>8;h[b+6>>1]=(F<<8&16711680|F<<24)>>>16}ha=d+320|0;return $}A(28296,19512,14477,28219);x()}function Ba(a,b,c,d){var e=0,f=0,l=0,m=0,n=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,y=0,z=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0;u=ha-48|0;ha=u;a:{n=j[a|0]&127;b:{if((n|0)==69){break b}z=j[n+25568|0];i[b+104>>2]=z;n=i[(z<<3)+21604>>2];c:{if((z|0)==8){c=(n>>>3|0)+a|0;s=n&7;g[b+112|0]=j[c+1|0]<<8-s|j[c|0]>>>s;c=n+8|0;q=(c>>>3|0)+a|0;m=c&7;c=j[q|0]>>>m|0;s=b;if(m){c=c|j[q+1|0]<<8-m}g[s+113|0]=c;c=n+16|0;q=(c>>>3|0)+a|0;m=c&7;c=j[q|0]>>>m|0;if(m){c=c|j[q+1|0]<<8-m}g[s+114|0]=c;c=n+24|0;q=(c>>>3|0)+a|0;m=c&7;c=j[q|0]>>>m|0;if(m){c=c|j[q+1|0]<<8-m}g[s+115|0]=c;f=1;if(!d){break b}g[b+118|0]=0;c=n+32|0;g[b+119|0]=j[(c>>>3|0)+a|0]>>>(c&7)&1;c=n+33|0;d=(c>>>3|0)+a|0;c=c&7;f=j[d|0]>>>c|0;f=c>>>0>=6?j[d+1|0]<<8-c|f:f;i[b+124>>2]=0;i[b+120>>2]=f&7;c=n+36|0;s=(c>>>3|0)+a|0;m=c&7;c=j[s|0]>>>m|0;d=b;if((m|0)==7){c=c|j[s+1|0]<<1}i[d+136>>2]=c&3;c=n+38|0;m=(c>>>3|0)+a|0;s=c&7;c=j[m|0]>>>s|0;if(s>>>0>=4){c=c|j[m+1|0]<<8-s}i[d+140>>2]=c&31;c=n+43|0;m=(c>>>3|0)+a|0;s=c&7;c=j[m|0]>>>s|0;if(s>>>0>=4){c=c|j[m+1|0]<<8-s}i[d+144>>2]=c&31;c=a;a=n+48|0;c=c+(a>>>3|0)|0;a=a&7;e=j[c|0]>>>a|0;e=a>>>0>=4?j[c+1|0]<<8-a|e:e;i[b+128>>2]=0;i[b+132>>2]=0;i[b+148>>2]=e&31;break c}d:{if(d){g[b+116|0]=j[(n>>>3|0)+a|0]>>>(n&7)&1;d=n+1|0;w=7424>>>z&1;if(!w){l=j[(d>>>3|0)+a|0]>>>(d&7)&1;d=n+2|0}g[b+117|0]=l;g[b+118|0]=j[(d>>>3|0)+a|0]>>>(d&7)&1;n=d+1|0;g[b+119|0]=j[(n>>>3|0)+a|0]>>>(n&7)&1;n=d+2|0;if(n>>>0>=112){break a}e=(n>>>3|0)+a|0;B=n&7;n=j[e|0]>>>B|0;q=b;if(B>>>0>=6){n=n|j[e+1|0]<<8-B}i[q+120>>2]=n&7;n=d+5|0;if(n>>>0>=112){break a}e=(n>>>3|0)+a|0;B=n&7;n=j[e|0]>>>B|0;if(B>>>0>=6){n=n|j[e+1|0]<<8-B}i[q+124>>2]=n&7;e=d+8|0;l=0;if(!w){if(e>>>0>=112){break a}B=(e>>>3|0)+a|0;q=e&7;n=j[B|0]>>>q|0;if(q>>>0>=4){n=n|j[B+1|0]<<8-q}l=n&31;e=d+13|0}i[b+128>>2]=l;if(z+ -8>>>0<=9){if(e>>>0>=112){break a}B=(e>>>3|0)+a|0;q=e&7;d=j[B|0]>>>q|0;n=b;if(q){d=d|j[B+1|0]<<8-q}i[n+132>>2]=d&255;e=e+8|0;break d}i[b+132>>2]=0;break d}e=n+j[z+25696|0]|0}C=1;e:{f:{g:{h:{i:{j:{k:{l:{m:{n:{l=z>>>0>16;d=1;o:{if(l){break o}if(!(1< >>0>=112){break a}B=(e>>>3|0)+a|0;q=e&7;d=j[B|0]>>>q|0;n=b;if(q>>>0>=4){d=d|j[B+1|0]<<8-q}i[n+108>>2]=d&31;e=e+5|0;C=0;d=2}B=d;d=0;if(l){break l}if(1< >2];if(d>>>0>18){break b}d=o(d,6)+20194|0;break i}if(e>>>0>=112){break a}B=3;l=(e>>>3|0)+a|0;q=e&7;d=j[l|0]>>>q|0;n=b;if(q>>>0>=5){d=d|j[l+1|0]<<8-q}d=d&15;i[n+108>>2]=d;e=e+4|0;C=0;break j}d=i[b+108>>2];if(d>>>0>29){break b}d=k[o(d,6)+20002>>1]}w=1;switch(z+ -6|0){case 11:break g;case 0:case 5:case 7:break h;default:break e}}d=i[b+108>>2]}if(d>>>0>10){break b}d=o(d,6)+20322|0}d=k[d>>1];w=1;break e}if(e>>>0>=112){break a}f=(e>>>3|0)+a|0;l=e&7;n=j[f|0]>>>l|0;q=b;if((l|0)==7){n=n|j[f+1|0]<<1}i[q+16>>2]=n&3;e=e+2|0;break f}i[b+16>>2]=3}w=2;M=1}i[b+4>>2]=B;g[b+20|0]=M;i[b+8>>2]=d&65535;i[b+12>>2]=j[z+25728|0];i[b>>2]=j[z+21792|0];L=j[z+21920|0];G=o(L,B);y=G<<1;H=j[z+21824|0];v=i[o(H,12)+21952>>2];p:{q:{r:{s:{t:{u:{d=1497965>>>H&1;v:{if(!d){q=3;l=4;n=5;break v}if(1797559>>>H&1){break u}q=5;l=2;n=3}f=l+y|0;p=(f>>>0)/(n>>>0)|0;I=n>>>0>f>>>0;if(I){break s}t=d?7:8;r=p+ -1|0;f=y-o(r,n)|0;if(!d){D=f+ -1|0;E=(D<<2)+297868|0;d=0;while(1){l=(d|0)==(r|0)?8:t;l=(d|0)!=(r|0)|D>>>0>3?l:i[E>>2];if(e>>>0>111){break a}J=(e>>>3|0)+a|0;K=e&7;f=j[J|0]>>>K|0;F=(u+16|0)+(d<<2)|0;K=8-K|0;if(K>>>0 >>0){f=f|j[J+1|0]< >2]=(-1< >>H&1){break t}D=(f|0)==1?3:(f|0)==2?5:7;while(1){if(e>>>0>111){break a}E=(e>>>3|0)+a|0;f=e&7;l=j[E|0]>>>f|0;F=(u+16|0)+(d<<2)|0;J=8-f|0;f=(d|0)==(r|0)?D:t;if(J>>>0