Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ktx2 integration #9536

Closed
wants to merge 19 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Incremental changes made based on PR, loadKTX2Spec still fails
YVin3D committed Jul 22, 2020
commit b03dc277fffba54c6122ab4a6215789df96e70c8
72 changes: 70 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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

4 changes: 2 additions & 2 deletions Source/Core/VulkanConstants.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Enum containing Vulkan Constant values by name.
* for use when needing VK Formats
*
* 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.
*
* @exports VulkanConstants
* @enum {Number}
* @private
*/
var VulkanConstants = {
VK_FORMAT_UNDEFINED: 0,
5 changes: 4 additions & 1 deletion Source/Scene/Model.js
Original file line number Diff line number Diff line change
@@ -172,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}
* </li><li>
* {@link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md|KHR_texture_transform}
* </li><li>
* {@link https://github.com/KhronosGroup/glTF/pull/1751|KHR_texture_basisu}
* </li>
* </ul>
* </p>
@@ -1933,7 +1935,8 @@ function parseTextures(model, context, supportsWebP, supportsBasis) {
imageId = texture.extensions.EXT_texture_webp.source;
} else if (
defined(texture.extensions) &&
defined(texture.extensions.KHR_texture_basisu)
defined(texture.extensions.KHR_texture_basisu) &&
FeatureDetection.supportsBasis
) {
imageId = texture.extensions.KHR_texture_basisu.source;
}
Binary file removed Specs/Data/Images/Green4x4.crn
Binary file not shown.
Binary file removed Specs/Data/Images/Green4x4_Basis255.ktx2
Binary file not shown.
Binary file removed Specs/Data/Images/Green4x4_UASTC.ktx2
Binary file not shown.
Binary file added Specs/Data/Images/Green64x64_Basis255.ktx2
Binary file not shown.
Binary file added Specs/Data/Images/Green64x64_UASTC.ktx2
Binary file not shown.
Binary file removed Specs/Data/Images/White64x64_Basis255.ktx2
Binary file not shown.
142 changes: 24 additions & 118 deletions Specs/Renderer/TextureSpec.js
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import { TextureMagnificationFilter } from "../../Source/Cesium.js";
import { TextureMinificationFilter } from "../../Source/Cesium.js";
import { TextureWrap } from "../../Source/Cesium.js";
import createContext from "../createContext.js";
import { FeatureDetection } from "../../Source/Cesium.js";
import { when } from "../../Source/Cesium.js";

describe(
@@ -26,8 +27,7 @@ describe(
var red16x16Image;

var greenKTX2Image;
var whiteBasisKTX2Image;
// var greenUASTCKTX2Image;
var greenBasisKTX2Image;

var fs =
"uniform sampler2D u_texture;" +
@@ -91,17 +91,11 @@ describe(
})
);

// promises.push(
// loadKTX2("./Data/Images/Green4x4_UASTC.ktx2").then(function (image) {
// greenUASTCKTX2Image = image;
// })
// );

promises.push(
loadKTX2("./Data/Images/White64x64_Basis255.ktx2").then(function (
loadKTX2("./Data/Images/Green64x64_Basis255.ktx2").then(function (
image
) {
whiteBasisKTX2Image = image;
greenBasisKTX2Image = image;
})
);

@@ -436,42 +430,18 @@ describe(
}
});

// it("draws the expected DXT compressed texture color", function () {
// if (!context.s3tc) {
// return;
// }

// texture = new Texture({
// context: context,
// pixelFormat: greenDXTImage.internalFormat,
// source: {
// width: greenDXTImage.width,
// height: greenDXTImage.height,
// arrayBufferView: greenDXTImage.bufferView,
// },
// });

// expect(texture.sizeInBytes).toBe(8);

// expect({
// context: context,
// fragmentShader: fs,
// uniformMap: uniformMap,
// }).contextToRender([0, 255, 0, 255]);
// });

it("draws the expected Basis compressed texture color", function () {
if (!context.pvrtc) {
return;
}

texture = new Texture({
context: context,
pixelFormat: whiteBasisKTX2Image.internalFormat,
pixelFormat: greenBasisKTX2Image.internalFormat,
source: {
width: whiteBasisKTX2Image.width,
height: whiteBasisKTX2Image.height,
arrayBufferView: whiteBasisKTX2Image.bufferView,
width: greenBasisKTX2Image.width,
height: greenBasisKTX2Image.height,
arrayBufferView: greenBasisKTX2Image.bufferView,
},
});

@@ -481,7 +451,7 @@ describe(
context: context,
fragmentShader: fs,
uniformMap: uniformMap,
}).contextToRender([255, 255, 255, 255]);
}).contextToRender([0, 255, 0, 255]);
});

it("draws the expected KTX2 compressed texture color", function () {
@@ -1125,70 +1095,6 @@ describe(
}).toThrowDeveloperError();
});

// it("throws when creating compressed texture when s3tc is unsupported", function () {
// if (!context.s3tc) {
// expect(function () {
// texture = new Texture({
// context: context,
// width: greenDXTImage.width,
// height: greenDXTImage.height,
// pixelFormat: greenDXTImage.internalFormat,
// source: {
// arrayBufferView: greenDXTImage.bufferView,
// },
// });
// }).toThrowDeveloperError();
// }
// });

// it("throws when creating compressed texture when pvrtc is unsupported", function () {
// if (!context.pvrtc) {
// expect(function () {
// texture = new Texture({
// context: context,
// width: greenPVRImage.width,
// height: greenPVRImage.height,
// pixelFormat: greenPVRImage.internalFormat,
// source: {
// arrayBufferView: greenPVRImage.bufferView,
// },
// });
// }).toThrowDeveloperError();
// }
// });

// it("throws when creating compressed texture when etc1 is unsupported", function () {
// if (!context.etc1) {
// expect(function () {
// texture = new Texture({
// context: context,
// width: greenETC1Image.width,
// height: greenETC1Image.height,
// pixelFormat: greenETC1Image.internalFormat,
// source: {
// arrayBufferView: greenETC1Image.bufferView,
// },
// });
// }).toThrowDeveloperError();
// }
// });

// it("throws when creating compressed texture and the array buffer is not the right length", function () {
// if (context.s3tc) {
// expect(function () {
// texture = new Texture({
// context: context,
// width: greenDXTImage.width + 1,
// height: greenDXTImage.height,
// pixelFormat: greenDXTImage.internalFormat,
// source: {
// arrayBufferView: greenDXTImage.bufferView,
// },
// });
// }).toThrowDeveloperError();
// }
// });

it("throws when creating from the framebuffer with an invalid pixel format", function () {
expect(function () {
texture = Texture.fromFramebuffer({
@@ -1270,14 +1176,14 @@ describe(
});

it("throws when copying to a texture from the framebuffer with a compressed pixel format", function () {
if (context.s3tc || context.pvrtc || context.etc1) {
if (FeatureDetection.supportsBasis) {
texture = new Texture({
context: context,
width: whiteBasisKTX2Image.width,
height: whiteBasisKTX2Image.height,
pixelFormat: whiteBasisKTX2Image.internalFormat,
width: greenBasisKTX2Image.width,
height: greenBasisKTX2Image.height,
pixelFormat: greenBasisKTX2Image.internalFormat,
source: {
arrayBufferView: whiteBasisKTX2Image.bufferView,
arrayBufferView: greenBasisKTX2Image.bufferView,
},
});

@@ -1465,14 +1371,14 @@ describe(
});

it("throws when copyFrom is given a source with a compressed pixel format", function () {
if (context.s3tc || context.pvrtc || context.etc1) {
if (FeatureDetection.supportsBasis) {
texture = new Texture({
context: context,
width: whiteBasisKTX2Image.width,
height: whiteBasisKTX2Image.height,
pixelFormat: whiteBasisKTX2Image.internalFormat,
width: greenBasisKTX2Image.width,
height: greenBasisKTX2Image.height,
pixelFormat: greenBasisKTX2Image.internalFormat,
source: {
arrayBufferView: whiteBasisKTX2Image.bufferView,
arrayBufferView: greenBasisKTX2Image.bufferView,
},
});

@@ -1500,14 +1406,14 @@ describe(
});

it("throws when generating mipmaps with a compressed pixel format", function () {
if (context.s3tc || context.pvrtc || context.etc1) {
if (FeatureDetection.supportsBasis) {
texture = new Texture({
context: context,
width: whiteBasisKTX2Image.width,
height: whiteBasisKTX2Image.height,
pixelFormat: whiteBasisKTX2Image.internalFormat,
width: greenBasisKTX2Image.width,
height: greenBasisKTX2Image.height,
pixelFormat: greenBasisKTX2Image.internalFormat,
source: {
arrayBufferView: whiteBasisKTX2Image.bufferView,
arrayBufferView: greenBasisKTX2Image.bufferView,
},
});

4 changes: 2 additions & 2 deletions Specs/Scene/MaterialSpec.js
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ import { Resource } from "../../Source/Cesium.js";
import { Material } from "../../Source/Cesium.js";
import { MaterialAppearance } from "../../Source/Cesium.js";
import { PolylineCollection } from "../../Source/Cesium.js";
import { FeatureDetection } from "../../Source/Cesium.js";
import { Primitive } from "../../Source/Cesium.js";
import { TextureMagnificationFilter } from "../../Source/Cesium.js";
import { TextureMinificationFilter } from "../../Source/Cesium.js";
@@ -369,8 +370,7 @@ describe(

it("creates a material with an ktx compressed image uniform", function () {
var compressedUrl;
var context = scene.context;
if (context.s3tc || context.etc1 || context.pvrtc) {
if (FeatureDetection.supportsBasis) {
compressedUrl = "./Data/Images/Green4x4.ktx2";
} else {
return;
3 changes: 1 addition & 2 deletions gulpfile.cjs
Original file line number Diff line number Diff line change
@@ -73,7 +73,6 @@ var sourceFiles = [
"!Source/ThirdParty/Workers/**",
"!Source/ThirdParty/google-earth-dbroot-parser.js",
"!Source/ThirdParty/pako_inflate.js",
"!Source/ThirdParty/crunch.js",
];

var watchedFiles = [
@@ -125,7 +124,7 @@ function rollupWarning(message) {
// Ignore eval warnings in third-party code we don't have control over
if (
message.code === "EVAL" &&
/(protobuf-minimal|crunch)\.js$/.test(message.loc.file)
/(protobuf-minimal)\.js$/.test(message.loc.file)
) {
return;
}