itowns 2.42.1-next.2 → 2.42.1-next.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/debug.js +1 -1
- package/dist/debug.js.map +1 -1
- package/dist/itowns.js +1 -1
- package/dist/itowns.js.map +1 -1
- package/dist/itowns_widgets.js +1 -1
- package/dist/itowns_widgets.js.map +1 -1
- package/examples/{.eslintrc.js → .eslintrc.cjs} +1 -1
- package/examples/effects_stereo.html +2 -2
- package/examples/entwine_simple_loader.html +24 -8
- package/examples/misc_collada.html +2 -2
- package/examples/misc_instancing.html +1 -1
- package/examples/source_file_gpx_3d.html +2 -2
- package/examples/source_stream_wfs_25d.html +11 -11
- package/examples/source_stream_wfs_3d.html +1 -1
- package/examples/vector_tile_3d_mesh.html +2 -2
- package/examples/vector_tile_raster_2d.html +1 -1
- package/examples/vector_tile_raster_3d.html +1 -1
- package/examples/view_25d_map.html +2 -2
- package/examples/view_3d_map.html +3 -3
- package/examples/view_3d_map_webxr.html +1 -1
- package/examples/view_3d_mns_map.html +3 -3
- package/examples/view_immersive.html +1 -1
- package/examples/view_multi_25d.html +2 -2
- package/examples/widgets_minimap.html +1 -1
- package/examples/widgets_searchbar.html +2 -2
- package/lib/Controls/FirstPersonControls.js +5 -12
- package/lib/Controls/FlyControls.js +4 -13
- package/lib/Controls/GlobeControls.js +33 -43
- package/lib/Controls/PlanarControls.js +9 -20
- package/lib/Controls/StateControl.js +2 -11
- package/lib/Controls/StreetControls.js +14 -24
- package/lib/Converter/Feature2Mesh.js +77 -70
- package/lib/Converter/Feature2Texture.js +15 -25
- package/lib/Converter/convertToTile.js +16 -26
- package/lib/Converter/textureConverter.js +9 -19
- package/lib/Core/3DTiles/C3DTBatchTable.js +5 -13
- package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +1 -8
- package/lib/Core/3DTiles/C3DTBoundingVolume.js +17 -27
- package/lib/Core/3DTiles/C3DTExtensions.js +1 -8
- package/lib/Core/3DTiles/C3DTFeature.js +3 -10
- package/lib/Core/3DTiles/C3DTilesEnums.js +3 -11
- package/lib/Core/3DTiles/C3DTileset.js +7 -16
- package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +5 -11
- package/lib/Core/AnimationPlayer.js +2 -11
- package/lib/Core/Deprecated/Undeprecator.js +9 -20
- package/lib/Core/EntwinePointTileNode.js +6 -16
- package/lib/Core/Feature.js +16 -30
- package/lib/Core/Geographic/CoordStars.js +3 -12
- package/lib/Core/Geographic/Coordinates.js +12 -22
- package/lib/Core/Geographic/Crs.js +7 -15
- package/lib/Core/Geographic/Extent.js +36 -47
- package/lib/Core/Geographic/GeoidGrid.js +6 -16
- package/lib/Core/Label.js +7 -17
- package/lib/Core/MainLoop.js +7 -16
- package/lib/Core/Math/Ellipsoid.js +6 -17
- package/lib/Core/Picking.js +10 -20
- package/lib/Core/PointCloudNode.js +2 -11
- package/lib/Core/PotreeNode.js +4 -13
- package/lib/Core/Prefab/Globe/Atmosphere.js +17 -26
- package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +6 -16
- package/lib/Core/Prefab/Globe/GlobeLayer.js +19 -28
- package/lib/Core/Prefab/Globe/SkyShader.js +2 -11
- package/lib/Core/Prefab/GlobeView.js +27 -45
- package/lib/Core/Prefab/Planar/PlanarLayer.js +11 -20
- package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +6 -16
- package/lib/Core/Prefab/PlanarView.js +10 -25
- package/lib/Core/Prefab/TileBuilder.js +13 -22
- package/lib/Core/Prefab/computeBufferTileGeometry.js +12 -16
- package/lib/Core/Scheduler/Cache.js +2 -10
- package/lib/Core/Scheduler/CancelledCommandException.js +1 -8
- package/lib/Core/Scheduler/Scheduler.js +15 -23
- package/lib/Core/Style.js +26 -40
- package/lib/Core/System/Capabilities.js +2 -13
- package/lib/Core/TileGeometry.js +13 -15
- package/lib/Core/TileMesh.js +6 -15
- package/lib/Core/View.js +43 -58
- package/lib/Layer/C3DTilesLayer.js +29 -41
- package/lib/Layer/ColorLayer.js +10 -16
- package/lib/Layer/ElevationLayer.js +7 -14
- package/lib/Layer/EntwinePointTileLayer.js +11 -18
- package/lib/Layer/FeatureGeometryLayer.js +9 -16
- package/lib/Layer/GeoidLayer.js +6 -15
- package/lib/Layer/GeometryLayer.js +11 -17
- package/lib/Layer/InfoLayer.js +5 -14
- package/lib/Layer/LabelLayer.js +22 -32
- package/lib/Layer/Layer.js +16 -26
- package/lib/Layer/LayerUpdateState.js +1 -8
- package/lib/Layer/LayerUpdateStrategy.js +7 -18
- package/lib/Layer/OrientedImageLayer.js +15 -25
- package/lib/Layer/PointCloudLayer.js +27 -24
- package/lib/Layer/PotreeLayer.js +8 -18
- package/lib/Layer/RasterLayer.js +9 -17
- package/lib/Layer/ReferencingLayerProperties.js +1 -8
- package/lib/Layer/TiledGeometryLayer.js +37 -33
- package/lib/Main.js +86 -707
- package/lib/MainBundle.js +4 -34
- package/lib/Parser/B3dmParser.js +80 -131
- package/lib/Parser/CameraCalibrationParser.js +5 -14
- package/lib/Parser/GDFParser.js +11 -22
- package/lib/Parser/GLTFParser.js +88 -0
- package/lib/Parser/GTXParser.js +9 -21
- package/lib/Parser/GeoJsonParser.js +14 -22
- package/lib/Parser/GpxParser.js +7 -14
- package/lib/Parser/ISGParser.js +19 -28
- package/lib/Parser/KMLParser.js +7 -14
- package/lib/Parser/LASLoader.js +31 -21
- package/lib/Parser/LASParser.js +10 -17
- package/lib/Parser/MapBoxUrlParser.js +2 -9
- package/lib/Parser/PntsParser.js +4 -14
- package/lib/Parser/PotreeBinParser.js +8 -16
- package/lib/Parser/PotreeCinParser.js +3 -12
- package/lib/Parser/ShapefileParser.js +11 -18
- package/lib/Parser/VectorTileParser.js +23 -31
- package/lib/Parser/XbilParser.js +5 -13
- package/lib/Parser/deprecated/LegacyGLTFLoader.js +2 -12
- package/lib/Process/3dTilesProcessing.js +14 -27
- package/lib/Process/FeatureProcessing.js +14 -22
- package/lib/Process/LayeredMaterialNodeProcessing.js +19 -28
- package/lib/Process/ObjectRemovalHelper.js +2 -9
- package/lib/Process/handlerNodeError.js +1 -7
- package/lib/Provider/3dTilesProvider.js +32 -29
- package/lib/Provider/DataSourceProvider.js +2 -9
- package/lib/Provider/Fetcher.js +40 -22
- package/lib/Provider/PointCloudProvider.js +7 -19
- package/lib/Provider/TileProvider.js +4 -12
- package/lib/Provider/URLBuilder.js +4 -12
- package/lib/Renderer/Camera.js +7 -17
- package/lib/Renderer/Color.js +3 -11
- package/lib/Renderer/ColorLayersOrdering.js +14 -22
- package/lib/Renderer/CommonMaterial.js +3 -12
- package/lib/Renderer/Label2DRenderer.js +5 -16
- package/lib/Renderer/LayeredMaterial.js +33 -53
- package/lib/Renderer/OBB.js +12 -21
- package/lib/Renderer/OrientedImageCamera.js +2 -11
- package/lib/Renderer/OrientedImageMaterial.js +17 -35
- package/lib/Renderer/PointsMaterial.js +224 -94
- package/lib/Renderer/RasterTile.js +18 -30
- package/lib/Renderer/RenderMode.js +2 -9
- package/lib/Renderer/Shader/ShaderChunk.js +5 -23
- package/lib/Renderer/Shader/ShaderUtils.js +2 -9
- package/lib/Renderer/SphereHelper.js +2 -11
- package/lib/Renderer/WebXR.js +2 -11
- package/lib/Renderer/c3DEngine.js +20 -53
- package/lib/Source/C3DTilesGoogleSource.js +76 -0
- package/lib/Source/C3DTilesIonSource.js +6 -13
- package/lib/Source/C3DTilesSource.js +5 -12
- package/lib/Source/EntwinePointTileSource.js +12 -19
- package/lib/Source/FileSource.js +7 -14
- package/lib/Source/OrientedImageSource.js +6 -14
- package/lib/Source/PotreeSource.js +9 -16
- package/lib/Source/Source.js +26 -39
- package/lib/Source/TMSSource.js +11 -22
- package/lib/Source/VectorTilesSource.js +75 -34
- package/lib/Source/WFSSource.js +7 -14
- package/lib/Source/WMSSource.js +5 -12
- package/lib/Source/WMTSSource.js +3 -10
- package/lib/ThreeExtended/capabilities/WebGL.js +1 -8
- package/lib/ThreeExtended/libs/ktx-parse.module.js +2 -256
- package/lib/ThreeExtended/libs/zstddec.module.js +2 -8
- package/lib/ThreeExtended/loaders/DDSLoader.js +10 -16
- package/lib/ThreeExtended/loaders/DRACOLoader.js +14 -19
- package/lib/ThreeExtended/loaders/GLTFLoader.js +124 -129
- package/lib/ThreeExtended/loaders/KTX2Loader.js +73 -78
- package/lib/ThreeExtended/utils/BufferGeometryUtils.js +40 -59
- package/lib/ThreeExtended/utils/WorkerPool.js +2 -9
- package/lib/Utils/CameraUtils.js +32 -44
- package/lib/Utils/DEMUtils.js +8 -19
- package/lib/Utils/FeaturesUtils.js +8 -16
- package/lib/Utils/Gradients.js +16 -0
- package/lib/Utils/OrientationUtils.js +8 -18
- package/lib/Utils/ThreeUtils.js +2 -9
- package/lib/Utils/gui/C3DTilesStyle.js +7 -15
- package/lib/Utils/gui/Main.js +7 -48
- package/lib/Utils/gui/Minimap.js +12 -20
- package/lib/Utils/gui/Navigation.js +6 -14
- package/lib/Utils/gui/Scale.js +11 -19
- package/lib/Utils/gui/Searchbar.js +5 -13
- package/lib/Utils/gui/Widget.js +1 -8
- package/lib/Utils/placeObjectOnGround.js +13 -23
- package/package.json +13 -8
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.KTX2Loader = void 0;
|
|
7
|
-
var _three = require("three");
|
|
8
|
-
var _WorkerPool = require("../utils/WorkerPool.js");
|
|
9
|
-
var _ktxParseModule = require("../libs/ktx-parse.module.js");
|
|
10
|
-
var _zstddecModule = require("../libs/zstddec.module.js");
|
|
11
1
|
/**
|
|
12
2
|
* Loader for KTX 2.0 GPU Texture containers.
|
|
13
3
|
*
|
|
@@ -21,16 +11,20 @@ var _zstddecModule = require("../libs/zstddec.module.js");
|
|
|
21
11
|
* - DFD: https://www.khronos.org/registry/DataFormat/specs/1.3/dataformat.1.3.html#basicdescriptor
|
|
22
12
|
*/
|
|
23
13
|
|
|
14
|
+
import { CompressedTexture, CompressedArrayTexture, CompressedCubeTexture, Data3DTexture, DataTexture, DisplayP3ColorSpace, FileLoader, FloatType, HalfFloatType, NoColorSpace, LinearFilter, LinearMipmapLinearFilter, LinearDisplayP3ColorSpace, LinearSRGBColorSpace, Loader, RedFormat, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_6x6_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBAFormat, RGFormat, SRGBColorSpace, UnsignedByteType } from 'three';
|
|
15
|
+
import { WorkerPool } from "../utils/WorkerPool.js";
|
|
16
|
+
import { read, KHR_DF_FLAG_ALPHA_PREMULTIPLIED, KHR_DF_TRANSFER_SRGB, KHR_SUPERCOMPRESSION_NONE, KHR_SUPERCOMPRESSION_ZSTD, VK_FORMAT_UNDEFINED, VK_FORMAT_R16_SFLOAT, VK_FORMAT_R16G16_SFLOAT, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_R8_SRGB, VK_FORMAT_R8_UNORM, VK_FORMAT_R8G8_SRGB, VK_FORMAT_R8G8_UNORM, VK_FORMAT_R8G8B8A8_SRGB, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_ASTC_6x6_SRGB_BLOCK, VK_FORMAT_ASTC_6x6_UNORM_BLOCK, KHR_DF_PRIMARIES_UNSPECIFIED, KHR_DF_PRIMARIES_BT709, KHR_DF_PRIMARIES_DISPLAYP3 } from "../libs/ktx-parse.module.js";
|
|
17
|
+
import { ZSTDDecoder } from "../libs/zstddec.module.js";
|
|
24
18
|
const _taskCache = new WeakMap();
|
|
25
19
|
let _activeLoaders = 0;
|
|
26
20
|
let _zstd;
|
|
27
|
-
class KTX2Loader extends
|
|
21
|
+
class KTX2Loader extends Loader {
|
|
28
22
|
constructor(manager) {
|
|
29
23
|
super(manager);
|
|
30
24
|
this.transcoderPath = '';
|
|
31
25
|
this.transcoderBinary = null;
|
|
32
26
|
this.transcoderPending = null;
|
|
33
|
-
this.workerPool = new
|
|
27
|
+
this.workerPool = new WorkerPool();
|
|
34
28
|
this.workerSourceURL = '';
|
|
35
29
|
this.workerConfig = null;
|
|
36
30
|
if (typeof MSC_TRANSCODER !== 'undefined') {
|
|
@@ -74,13 +68,13 @@ class KTX2Loader extends _three.Loader {
|
|
|
74
68
|
init() {
|
|
75
69
|
if (!this.transcoderPending) {
|
|
76
70
|
// Load transcoder wrapper.
|
|
77
|
-
const jsLoader = new
|
|
71
|
+
const jsLoader = new FileLoader(this.manager);
|
|
78
72
|
jsLoader.setPath(this.transcoderPath);
|
|
79
73
|
jsLoader.setWithCredentials(this.withCredentials);
|
|
80
74
|
const jsContent = jsLoader.loadAsync('basis_transcoder.js');
|
|
81
75
|
|
|
82
76
|
// Load transcoder WASM binary.
|
|
83
|
-
const binaryLoader = new
|
|
77
|
+
const binaryLoader = new FileLoader(this.manager);
|
|
84
78
|
binaryLoader.setPath(this.transcoderPath);
|
|
85
79
|
binaryLoader.setResponseType('arraybuffer');
|
|
86
80
|
binaryLoader.setWithCredentials(this.withCredentials);
|
|
@@ -115,7 +109,7 @@ class KTX2Loader extends _three.Loader {
|
|
|
115
109
|
if (this.workerConfig === null) {
|
|
116
110
|
throw new Error('THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.');
|
|
117
111
|
}
|
|
118
|
-
const loader = new
|
|
112
|
+
const loader = new FileLoader(this.manager);
|
|
119
113
|
loader.setResponseType('arraybuffer');
|
|
120
114
|
loader.setWithCredentials(this.withCredentials);
|
|
121
115
|
loader.load(url, buffer => {
|
|
@@ -141,17 +135,17 @@ class KTX2Loader extends _three.Loader {
|
|
|
141
135
|
if (type === 'error') return Promise.reject(error);
|
|
142
136
|
let texture;
|
|
143
137
|
if (container.faceCount === 6) {
|
|
144
|
-
texture = new
|
|
138
|
+
texture = new CompressedCubeTexture(faces, format, UnsignedByteType);
|
|
145
139
|
} else {
|
|
146
140
|
const mipmaps = faces[0].mipmaps;
|
|
147
|
-
texture = container.layerCount > 1 ? new
|
|
141
|
+
texture = container.layerCount > 1 ? new CompressedArrayTexture(mipmaps, width, height, container.layerCount, format, UnsignedByteType) : new CompressedTexture(mipmaps, width, height, format, UnsignedByteType);
|
|
148
142
|
}
|
|
149
|
-
texture.minFilter = faces[0].mipmaps.length === 1 ?
|
|
150
|
-
texture.magFilter =
|
|
143
|
+
texture.minFilter = faces[0].mipmaps.length === 1 ? LinearFilter : LinearMipmapLinearFilter;
|
|
144
|
+
texture.magFilter = LinearFilter;
|
|
151
145
|
texture.generateMipmaps = false;
|
|
152
146
|
texture.needsUpdate = true;
|
|
153
147
|
texture.colorSpace = parseColorSpace(container);
|
|
154
|
-
texture.premultiplyAlpha = !!(dfdFlags &
|
|
148
|
+
texture.premultiplyAlpha = !!(dfdFlags & KHR_DF_FLAG_ALPHA_PREMULTIPLIED);
|
|
155
149
|
return texture;
|
|
156
150
|
}
|
|
157
151
|
|
|
@@ -162,8 +156,8 @@ class KTX2Loader extends _three.Loader {
|
|
|
162
156
|
*/
|
|
163
157
|
async _createTexture(buffer) {
|
|
164
158
|
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
165
|
-
const container =
|
|
166
|
-
if (container.vkFormat !==
|
|
159
|
+
const container = read(new Uint8Array(buffer));
|
|
160
|
+
if (container.vkFormat !== VK_FORMAT_UNDEFINED) {
|
|
167
161
|
return createRawTexture(container);
|
|
168
162
|
}
|
|
169
163
|
|
|
@@ -192,7 +186,7 @@ class KTX2Loader extends _three.Loader {
|
|
|
192
186
|
}
|
|
193
187
|
|
|
194
188
|
/* CONSTANTS */
|
|
195
|
-
|
|
189
|
+
|
|
196
190
|
KTX2Loader.BasisFormat = {
|
|
197
191
|
ETC1S: 0,
|
|
198
192
|
UASTC_4x4: 1
|
|
@@ -217,16 +211,16 @@ KTX2Loader.TranscoderFormat = {
|
|
|
217
211
|
RGBA4444: 16
|
|
218
212
|
};
|
|
219
213
|
KTX2Loader.EngineFormat = {
|
|
220
|
-
RGBAFormat:
|
|
221
|
-
RGBA_ASTC_4x4_Format:
|
|
222
|
-
RGBA_BPTC_Format:
|
|
223
|
-
RGBA_ETC2_EAC_Format:
|
|
224
|
-
RGBA_PVRTC_4BPPV1_Format:
|
|
225
|
-
RGBA_S3TC_DXT5_Format:
|
|
226
|
-
RGB_ETC1_Format:
|
|
227
|
-
RGB_ETC2_Format:
|
|
228
|
-
RGB_PVRTC_4BPPV1_Format:
|
|
229
|
-
RGB_S3TC_DXT1_Format:
|
|
214
|
+
RGBAFormat: RGBAFormat,
|
|
215
|
+
RGBA_ASTC_4x4_Format: RGBA_ASTC_4x4_Format,
|
|
216
|
+
RGBA_BPTC_Format: RGBA_BPTC_Format,
|
|
217
|
+
RGBA_ETC2_EAC_Format: RGBA_ETC2_EAC_Format,
|
|
218
|
+
RGBA_PVRTC_4BPPV1_Format: RGBA_PVRTC_4BPPV1_Format,
|
|
219
|
+
RGBA_S3TC_DXT5_Format: RGBA_S3TC_DXT5_Format,
|
|
220
|
+
RGB_ETC1_Format: RGB_ETC1_Format,
|
|
221
|
+
RGB_ETC2_Format: RGB_ETC2_Format,
|
|
222
|
+
RGB_PVRTC_4BPPV1_Format: RGB_PVRTC_4BPPV1_Format,
|
|
223
|
+
RGB_S3TC_DXT1_Format: RGB_S3TC_DXT1_Format
|
|
230
224
|
};
|
|
231
225
|
|
|
232
226
|
/* WEB WORKER */
|
|
@@ -498,38 +492,38 @@ KTX2Loader.BasisWorker = function () {
|
|
|
498
492
|
// Parsing for non-Basis textures. These textures are may have supercompression
|
|
499
493
|
// like Zstd, but they do not require transcoding.
|
|
500
494
|
|
|
501
|
-
const UNCOMPRESSED_FORMATS = new Set([
|
|
495
|
+
const UNCOMPRESSED_FORMATS = new Set([RGBAFormat, RGFormat, RedFormat]);
|
|
502
496
|
const FORMAT_MAP = {
|
|
503
|
-
[
|
|
504
|
-
[
|
|
505
|
-
[
|
|
506
|
-
[
|
|
507
|
-
[
|
|
508
|
-
[
|
|
509
|
-
[
|
|
510
|
-
[
|
|
511
|
-
[
|
|
512
|
-
[
|
|
513
|
-
[
|
|
514
|
-
[
|
|
515
|
-
[
|
|
516
|
-
[
|
|
497
|
+
[VK_FORMAT_R32G32B32A32_SFLOAT]: RGBAFormat,
|
|
498
|
+
[VK_FORMAT_R16G16B16A16_SFLOAT]: RGBAFormat,
|
|
499
|
+
[VK_FORMAT_R8G8B8A8_UNORM]: RGBAFormat,
|
|
500
|
+
[VK_FORMAT_R8G8B8A8_SRGB]: RGBAFormat,
|
|
501
|
+
[VK_FORMAT_R32G32_SFLOAT]: RGFormat,
|
|
502
|
+
[VK_FORMAT_R16G16_SFLOAT]: RGFormat,
|
|
503
|
+
[VK_FORMAT_R8G8_UNORM]: RGFormat,
|
|
504
|
+
[VK_FORMAT_R8G8_SRGB]: RGFormat,
|
|
505
|
+
[VK_FORMAT_R32_SFLOAT]: RedFormat,
|
|
506
|
+
[VK_FORMAT_R16_SFLOAT]: RedFormat,
|
|
507
|
+
[VK_FORMAT_R8_SRGB]: RedFormat,
|
|
508
|
+
[VK_FORMAT_R8_UNORM]: RedFormat,
|
|
509
|
+
[VK_FORMAT_ASTC_6x6_SRGB_BLOCK]: RGBA_ASTC_6x6_Format,
|
|
510
|
+
[VK_FORMAT_ASTC_6x6_UNORM_BLOCK]: RGBA_ASTC_6x6_Format
|
|
517
511
|
};
|
|
518
512
|
const TYPE_MAP = {
|
|
519
|
-
[
|
|
520
|
-
[
|
|
521
|
-
[
|
|
522
|
-
[
|
|
523
|
-
[
|
|
524
|
-
[
|
|
525
|
-
[
|
|
526
|
-
[
|
|
527
|
-
[
|
|
528
|
-
[
|
|
529
|
-
[
|
|
530
|
-
[
|
|
531
|
-
[
|
|
532
|
-
[
|
|
513
|
+
[VK_FORMAT_R32G32B32A32_SFLOAT]: FloatType,
|
|
514
|
+
[VK_FORMAT_R16G16B16A16_SFLOAT]: HalfFloatType,
|
|
515
|
+
[VK_FORMAT_R8G8B8A8_UNORM]: UnsignedByteType,
|
|
516
|
+
[VK_FORMAT_R8G8B8A8_SRGB]: UnsignedByteType,
|
|
517
|
+
[VK_FORMAT_R32G32_SFLOAT]: FloatType,
|
|
518
|
+
[VK_FORMAT_R16G16_SFLOAT]: HalfFloatType,
|
|
519
|
+
[VK_FORMAT_R8G8_UNORM]: UnsignedByteType,
|
|
520
|
+
[VK_FORMAT_R8G8_SRGB]: UnsignedByteType,
|
|
521
|
+
[VK_FORMAT_R32_SFLOAT]: FloatType,
|
|
522
|
+
[VK_FORMAT_R16_SFLOAT]: HalfFloatType,
|
|
523
|
+
[VK_FORMAT_R8_SRGB]: UnsignedByteType,
|
|
524
|
+
[VK_FORMAT_R8_UNORM]: UnsignedByteType,
|
|
525
|
+
[VK_FORMAT_ASTC_6x6_SRGB_BLOCK]: UnsignedByteType,
|
|
526
|
+
[VK_FORMAT_ASTC_6x6_UNORM_BLOCK]: UnsignedByteType
|
|
533
527
|
};
|
|
534
528
|
async function createRawTexture(container) {
|
|
535
529
|
const {
|
|
@@ -542,10 +536,10 @@ async function createRawTexture(container) {
|
|
|
542
536
|
//
|
|
543
537
|
|
|
544
538
|
let zstd;
|
|
545
|
-
if (container.supercompressionScheme ===
|
|
539
|
+
if (container.supercompressionScheme === KHR_SUPERCOMPRESSION_ZSTD) {
|
|
546
540
|
if (!_zstd) {
|
|
547
541
|
_zstd = new Promise(async resolve => {
|
|
548
|
-
const zstd = new
|
|
542
|
+
const zstd = new ZSTDDecoder();
|
|
549
543
|
await zstd.init();
|
|
550
544
|
resolve(zstd);
|
|
551
545
|
});
|
|
@@ -562,17 +556,17 @@ async function createRawTexture(container) {
|
|
|
562
556
|
const levelDepth = container.pixelDepth ? Math.max(1, container.pixelDepth >> levelIndex) : 0;
|
|
563
557
|
const level = container.levels[levelIndex];
|
|
564
558
|
let levelData;
|
|
565
|
-
if (container.supercompressionScheme ===
|
|
559
|
+
if (container.supercompressionScheme === KHR_SUPERCOMPRESSION_NONE) {
|
|
566
560
|
levelData = level.levelData;
|
|
567
|
-
} else if (container.supercompressionScheme ===
|
|
561
|
+
} else if (container.supercompressionScheme === KHR_SUPERCOMPRESSION_ZSTD) {
|
|
568
562
|
levelData = zstd.decode(level.levelData, level.uncompressedByteLength);
|
|
569
563
|
} else {
|
|
570
564
|
throw new Error('THREE.KTX2Loader: Unsupported supercompressionScheme.');
|
|
571
565
|
}
|
|
572
566
|
let data;
|
|
573
|
-
if (TYPE_MAP[vkFormat] ===
|
|
567
|
+
if (TYPE_MAP[vkFormat] === FloatType) {
|
|
574
568
|
data = new Float32Array(levelData.buffer, levelData.byteOffset, levelData.byteLength / Float32Array.BYTES_PER_ELEMENT);
|
|
575
|
-
} else if (TYPE_MAP[vkFormat] ===
|
|
569
|
+
} else if (TYPE_MAP[vkFormat] === HalfFloatType) {
|
|
576
570
|
data = new Uint16Array(levelData.buffer, levelData.byteOffset, levelData.byteLength / Uint16Array.BYTES_PER_ELEMENT);
|
|
577
571
|
} else {
|
|
578
572
|
data = levelData;
|
|
@@ -586,10 +580,10 @@ async function createRawTexture(container) {
|
|
|
586
580
|
}
|
|
587
581
|
let texture;
|
|
588
582
|
if (UNCOMPRESSED_FORMATS.has(FORMAT_MAP[vkFormat])) {
|
|
589
|
-
texture = container.pixelDepth === 0 ? new
|
|
583
|
+
texture = container.pixelDepth === 0 ? new DataTexture(mipmaps[0].data, container.pixelWidth, container.pixelHeight) : new Data3DTexture(mipmaps[0].data, container.pixelWidth, container.pixelHeight, container.pixelDepth);
|
|
590
584
|
} else {
|
|
591
585
|
if (container.pixelDepth > 0) throw new Error('THREE.KTX2Loader: Unsupported pixelDepth.');
|
|
592
|
-
texture = new
|
|
586
|
+
texture = new CompressedTexture(mipmaps, container.pixelWidth, container.pixelHeight);
|
|
593
587
|
}
|
|
594
588
|
texture.mipmaps = mipmaps;
|
|
595
589
|
texture.type = TYPE_MAP[vkFormat];
|
|
@@ -603,14 +597,15 @@ async function createRawTexture(container) {
|
|
|
603
597
|
}
|
|
604
598
|
function parseColorSpace(container) {
|
|
605
599
|
const dfd = container.dataFormatDescriptor[0];
|
|
606
|
-
if (dfd.colorPrimaries ===
|
|
607
|
-
return dfd.transferFunction ===
|
|
608
|
-
} else if (dfd.colorPrimaries ===
|
|
609
|
-
return dfd.transferFunction ===
|
|
610
|
-
} else if (dfd.colorPrimaries ===
|
|
611
|
-
return
|
|
600
|
+
if (dfd.colorPrimaries === KHR_DF_PRIMARIES_BT709) {
|
|
601
|
+
return dfd.transferFunction === KHR_DF_TRANSFER_SRGB ? SRGBColorSpace : LinearSRGBColorSpace;
|
|
602
|
+
} else if (dfd.colorPrimaries === KHR_DF_PRIMARIES_DISPLAYP3) {
|
|
603
|
+
return dfd.transferFunction === KHR_DF_TRANSFER_SRGB ? DisplayP3ColorSpace : LinearDisplayP3ColorSpace;
|
|
604
|
+
} else if (dfd.colorPrimaries === KHR_DF_PRIMARIES_UNSPECIFIED) {
|
|
605
|
+
return NoColorSpace;
|
|
612
606
|
} else {
|
|
613
607
|
console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${dfd.colorPrimaries}"`);
|
|
614
|
-
return
|
|
608
|
+
return NoColorSpace;
|
|
615
609
|
}
|
|
616
|
-
}
|
|
610
|
+
}
|
|
611
|
+
export { KTX2Loader };
|
|
@@ -1,24 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.computeMikkTSpaceTangents = computeMikkTSpaceTangents;
|
|
7
|
-
exports.computeMorphedAttributes = computeMorphedAttributes;
|
|
8
|
-
exports.deepCloneAttribute = deepCloneAttribute;
|
|
9
|
-
exports.deinterleaveAttribute = deinterleaveAttribute;
|
|
10
|
-
exports.deinterleaveGeometry = deinterleaveGeometry;
|
|
11
|
-
exports.estimateBytesUsed = estimateBytesUsed;
|
|
12
|
-
exports.interleaveAttributes = interleaveAttributes;
|
|
13
|
-
exports.mergeAttributes = mergeAttributes;
|
|
14
|
-
exports.mergeBufferAttributes = mergeBufferAttributes;
|
|
15
|
-
exports.mergeBufferGeometries = mergeBufferGeometries;
|
|
16
|
-
exports.mergeGeometries = mergeGeometries;
|
|
17
|
-
exports.mergeGroups = mergeGroups;
|
|
18
|
-
exports.mergeVertices = mergeVertices;
|
|
19
|
-
exports.toCreasedNormals = toCreasedNormals;
|
|
20
|
-
exports.toTrianglesDrawMode = toTrianglesDrawMode;
|
|
21
|
-
var _three = require("three");
|
|
1
|
+
import { BufferAttribute, BufferGeometry, Float32BufferAttribute, InstancedBufferAttribute, InterleavedBuffer, InterleavedBufferAttribute, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, Vector3 } from 'three';
|
|
22
2
|
function computeMikkTSpaceTangents(geometry, MikkTSpace) {
|
|
23
3
|
let negateSign = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
24
4
|
if (!MikkTSpace || !MikkTSpace.isReady) {
|
|
@@ -64,7 +44,7 @@ function computeMikkTSpaceTangents(geometry, MikkTSpace) {
|
|
|
64
44
|
|
|
65
45
|
//
|
|
66
46
|
|
|
67
|
-
_geometry.setAttribute('tangent', new
|
|
47
|
+
_geometry.setAttribute('tangent', new BufferAttribute(tangents, 4));
|
|
68
48
|
if (geometry !== _geometry) {
|
|
69
49
|
geometry.copy(_geometry);
|
|
70
50
|
}
|
|
@@ -84,7 +64,7 @@ function mergeGeometries(geometries) {
|
|
|
84
64
|
const attributes = {};
|
|
85
65
|
const morphAttributes = {};
|
|
86
66
|
const morphTargetsRelative = geometries[0].morphTargetsRelative;
|
|
87
|
-
const mergedGeometry = new
|
|
67
|
+
const mergedGeometry = new BufferGeometry();
|
|
88
68
|
let offset = 0;
|
|
89
69
|
for (let i = 0; i < geometries.length; ++i) {
|
|
90
70
|
const geometry = geometries[i];
|
|
@@ -238,7 +218,7 @@ function mergeAttributes(attributes) {
|
|
|
238
218
|
array.set(attributes[i].array, offset);
|
|
239
219
|
offset += attributes[i].array.length;
|
|
240
220
|
}
|
|
241
|
-
const result = new
|
|
221
|
+
const result = new BufferAttribute(array, itemSize, normalized);
|
|
242
222
|
if (gpuType !== undefined) {
|
|
243
223
|
result.gpuType = gpuType;
|
|
244
224
|
}
|
|
@@ -249,14 +229,14 @@ function mergeAttributes(attributes) {
|
|
|
249
229
|
* @param {BufferAttribute}
|
|
250
230
|
* @return {BufferAttribute}
|
|
251
231
|
*/
|
|
252
|
-
function deepCloneAttribute(attribute) {
|
|
232
|
+
export function deepCloneAttribute(attribute) {
|
|
253
233
|
if (attribute.isInstancedInterleavedBufferAttribute || attribute.isInterleavedBufferAttribute) {
|
|
254
234
|
return deinterleaveAttribute(attribute);
|
|
255
235
|
}
|
|
256
236
|
if (attribute.isInstancedBufferAttribute) {
|
|
257
|
-
return new
|
|
237
|
+
return new InstancedBufferAttribute().copy(attribute);
|
|
258
238
|
}
|
|
259
|
-
return new
|
|
239
|
+
return new BufferAttribute().copy(attribute);
|
|
260
240
|
}
|
|
261
241
|
|
|
262
242
|
/**
|
|
@@ -283,7 +263,7 @@ function interleaveAttributes(attributes) {
|
|
|
283
263
|
}
|
|
284
264
|
|
|
285
265
|
// Create the set of buffer attributes
|
|
286
|
-
const interleavedBuffer = new
|
|
266
|
+
const interleavedBuffer = new InterleavedBuffer(new TypedArray(arrayLength), stride);
|
|
287
267
|
let offset = 0;
|
|
288
268
|
const res = [];
|
|
289
269
|
const getters = ['getX', 'getY', 'getZ', 'getW'];
|
|
@@ -292,7 +272,7 @@ function interleaveAttributes(attributes) {
|
|
|
292
272
|
const attribute = attributes[j];
|
|
293
273
|
const itemSize = attribute.itemSize;
|
|
294
274
|
const count = attribute.count;
|
|
295
|
-
const iba = new
|
|
275
|
+
const iba = new InterleavedBufferAttribute(interleavedBuffer, itemSize, offset, attribute.normalized);
|
|
296
276
|
res.push(iba);
|
|
297
277
|
offset += itemSize;
|
|
298
278
|
|
|
@@ -308,7 +288,7 @@ function interleaveAttributes(attributes) {
|
|
|
308
288
|
}
|
|
309
289
|
|
|
310
290
|
// returns a new, non-interleaved version of the provided attribute
|
|
311
|
-
function deinterleaveAttribute(attribute) {
|
|
291
|
+
export function deinterleaveAttribute(attribute) {
|
|
312
292
|
const cons = attribute.data.array.constructor;
|
|
313
293
|
const count = attribute.count;
|
|
314
294
|
const itemSize = attribute.itemSize;
|
|
@@ -316,9 +296,9 @@ function deinterleaveAttribute(attribute) {
|
|
|
316
296
|
const array = new cons(count * itemSize);
|
|
317
297
|
let newAttribute;
|
|
318
298
|
if (attribute.isInstancedInterleavedBufferAttribute) {
|
|
319
|
-
newAttribute = new
|
|
299
|
+
newAttribute = new InstancedBufferAttribute(array, itemSize, normalized, attribute.meshPerAttribute);
|
|
320
300
|
} else {
|
|
321
|
-
newAttribute = new
|
|
301
|
+
newAttribute = new BufferAttribute(array, itemSize, normalized);
|
|
322
302
|
}
|
|
323
303
|
for (let i = 0; i < count; i++) {
|
|
324
304
|
newAttribute.setX(i, attribute.getX(i));
|
|
@@ -336,7 +316,7 @@ function deinterleaveAttribute(attribute) {
|
|
|
336
316
|
}
|
|
337
317
|
|
|
338
318
|
// deinterleaves all attributes on the geometry
|
|
339
|
-
function deinterleaveGeometry(geometry) {
|
|
319
|
+
export function deinterleaveGeometry(geometry) {
|
|
340
320
|
const attributes = geometry.attributes;
|
|
341
321
|
const morphTargets = geometry.morphTargets;
|
|
342
322
|
const attrMap = new Map();
|
|
@@ -410,10 +390,10 @@ function mergeVertices(geometry) {
|
|
|
410
390
|
for (let i = 0, l = attributeNames.length; i < l; i++) {
|
|
411
391
|
const name = attributeNames[i];
|
|
412
392
|
const attr = geometry.attributes[name];
|
|
413
|
-
tmpAttributes[name] = new
|
|
393
|
+
tmpAttributes[name] = new BufferAttribute(new attr.array.constructor(attr.count * attr.itemSize), attr.itemSize, attr.normalized);
|
|
414
394
|
const morphAttr = geometry.morphAttributes[name];
|
|
415
395
|
if (morphAttr) {
|
|
416
|
-
tmpMorphAttributes[name] = new
|
|
396
|
+
tmpMorphAttributes[name] = new BufferAttribute(new morphAttr.array.constructor(morphAttr.count * morphAttr.itemSize), morphAttr.itemSize, morphAttr.normalized);
|
|
417
397
|
}
|
|
418
398
|
}
|
|
419
399
|
|
|
@@ -470,11 +450,11 @@ function mergeVertices(geometry) {
|
|
|
470
450
|
const result = geometry.clone();
|
|
471
451
|
for (const name in geometry.attributes) {
|
|
472
452
|
const tmpAttribute = tmpAttributes[name];
|
|
473
|
-
result.setAttribute(name, new
|
|
453
|
+
result.setAttribute(name, new BufferAttribute(tmpAttribute.array.slice(0, nextIndex * tmpAttribute.itemSize), tmpAttribute.itemSize, tmpAttribute.normalized));
|
|
474
454
|
if (!(name in tmpMorphAttributes)) continue;
|
|
475
455
|
for (let j = 0; j < tmpMorphAttributes[name].length; j++) {
|
|
476
456
|
const tmpMorphAttribute = tmpMorphAttributes[name][j];
|
|
477
|
-
result.morphAttributes[name][j] = new
|
|
457
|
+
result.morphAttributes[name][j] = new BufferAttribute(tmpMorphAttribute.array.slice(0, nextIndex * tmpMorphAttribute.itemSize), tmpMorphAttribute.itemSize, tmpMorphAttribute.normalized);
|
|
478
458
|
}
|
|
479
459
|
}
|
|
480
460
|
|
|
@@ -490,11 +470,11 @@ function mergeVertices(geometry) {
|
|
|
490
470
|
* @return {BufferGeometry}
|
|
491
471
|
*/
|
|
492
472
|
function toTrianglesDrawMode(geometry, drawMode) {
|
|
493
|
-
if (drawMode ===
|
|
473
|
+
if (drawMode === TrianglesDrawMode) {
|
|
494
474
|
console.warn('THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.');
|
|
495
475
|
return geometry;
|
|
496
476
|
}
|
|
497
|
-
if (drawMode ===
|
|
477
|
+
if (drawMode === TriangleFanDrawMode || drawMode === TriangleStripDrawMode) {
|
|
498
478
|
let index = geometry.getIndex();
|
|
499
479
|
|
|
500
480
|
// generate index if not present
|
|
@@ -518,7 +498,7 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
518
498
|
|
|
519
499
|
const numberOfTriangles = index.count - 2;
|
|
520
500
|
const newIndices = [];
|
|
521
|
-
if (drawMode ===
|
|
501
|
+
if (drawMode === TriangleFanDrawMode) {
|
|
522
502
|
// gl.TRIANGLE_FAN
|
|
523
503
|
|
|
524
504
|
for (let i = 1; i <= numberOfTriangles; i++) {
|
|
@@ -564,15 +544,15 @@ function toTrianglesDrawMode(geometry, drawMode) {
|
|
|
564
544
|
* @return {Object} An Object with original position/normal attributes and morphed ones.
|
|
565
545
|
*/
|
|
566
546
|
function computeMorphedAttributes(object) {
|
|
567
|
-
const _vA = new
|
|
568
|
-
const _vB = new
|
|
569
|
-
const _vC = new
|
|
570
|
-
const _tempA = new
|
|
571
|
-
const _tempB = new
|
|
572
|
-
const _tempC = new
|
|
573
|
-
const _morphA = new
|
|
574
|
-
const _morphB = new
|
|
575
|
-
const _morphC = new
|
|
547
|
+
const _vA = new Vector3();
|
|
548
|
+
const _vB = new Vector3();
|
|
549
|
+
const _vC = new Vector3();
|
|
550
|
+
const _tempA = new Vector3();
|
|
551
|
+
const _tempB = new Vector3();
|
|
552
|
+
const _tempC = new Vector3();
|
|
553
|
+
const _morphA = new Vector3();
|
|
554
|
+
const _morphB = new Vector3();
|
|
555
|
+
const _morphC = new Vector3();
|
|
576
556
|
function _calculateMorphedAttributeData(object, attribute, morphAttribute, morphTargetsRelative, a, b, c, modifiedAttributeArray) {
|
|
577
557
|
_vA.fromBufferAttribute(attribute, a);
|
|
578
558
|
_vB.fromBufferAttribute(attribute, b);
|
|
@@ -689,8 +669,8 @@ function computeMorphedAttributes(object) {
|
|
|
689
669
|
}
|
|
690
670
|
}
|
|
691
671
|
}
|
|
692
|
-
const morphedPositionAttribute = new
|
|
693
|
-
const morphedNormalAttribute = new
|
|
672
|
+
const morphedPositionAttribute = new Float32BufferAttribute(modifiedPosition, 3);
|
|
673
|
+
const morphedNormalAttribute = new Float32BufferAttribute(modifiedNormal, 3);
|
|
694
674
|
return {
|
|
695
675
|
positionAttribute: positionAttribute,
|
|
696
676
|
normalAttribute: normalAttribute,
|
|
@@ -778,11 +758,11 @@ function toCreasedNormals(geometry) {
|
|
|
778
758
|
const hashMultiplier = (1 + 1e-10) * 1e2;
|
|
779
759
|
|
|
780
760
|
// reusable vectors
|
|
781
|
-
const verts = [new
|
|
782
|
-
const tempVec1 = new
|
|
783
|
-
const tempVec2 = new
|
|
784
|
-
const tempNorm = new
|
|
785
|
-
const tempNorm2 = new
|
|
761
|
+
const verts = [new Vector3(), new Vector3(), new Vector3()];
|
|
762
|
+
const tempVec1 = new Vector3();
|
|
763
|
+
const tempVec2 = new Vector3();
|
|
764
|
+
const tempNorm = new Vector3();
|
|
765
|
+
const tempNorm2 = new Vector3();
|
|
786
766
|
|
|
787
767
|
// hashes a vector
|
|
788
768
|
function hashVertex(v) {
|
|
@@ -808,7 +788,7 @@ function toCreasedNormals(geometry) {
|
|
|
808
788
|
tempVec2.subVectors(a, b);
|
|
809
789
|
|
|
810
790
|
// add the normal to the map for all vertices
|
|
811
|
-
const normal = new
|
|
791
|
+
const normal = new Vector3().crossVectors(tempVec1, tempVec2).normalize();
|
|
812
792
|
for (let n = 0; n < 3; n++) {
|
|
813
793
|
const vert = verts[n];
|
|
814
794
|
const hash = hashVertex(vert);
|
|
@@ -822,7 +802,7 @@ function toCreasedNormals(geometry) {
|
|
|
822
802
|
// average normals from all vertices that share a common location if they are within the
|
|
823
803
|
// provided crease threshold
|
|
824
804
|
const normalArray = new Float32Array(posAttr.count * 3);
|
|
825
|
-
const normAttr = new
|
|
805
|
+
const normAttr = new BufferAttribute(normalArray, 3, false);
|
|
826
806
|
for (let i = 0, l = posAttr.count / 3; i < l; i++) {
|
|
827
807
|
// get the face normal for this vertex
|
|
828
808
|
const i3 = 3 * i;
|
|
@@ -860,4 +840,5 @@ function mergeBufferGeometries(geometries) {
|
|
|
860
840
|
function mergeBufferAttributes(attributes) {
|
|
861
841
|
console.warn('THREE.BufferGeometryUtils: mergeBufferAttributes() has been renamed to mergeAttributes().'); // @deprecated, r151
|
|
862
842
|
return mergeAttributes(attributes);
|
|
863
|
-
}
|
|
843
|
+
}
|
|
844
|
+
export { computeMikkTSpaceTangents, mergeGeometries, mergeBufferGeometries, mergeAttributes, mergeBufferAttributes, interleaveAttributes, estimateBytesUsed, mergeVertices, toTrianglesDrawMode, computeMorphedAttributes, mergeGroups, toCreasedNormals };
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.WorkerPool = void 0;
|
|
7
1
|
/**
|
|
8
2
|
* @author Deepkolos / https://github.com/deepkolos
|
|
9
3
|
*/
|
|
10
4
|
|
|
11
|
-
class WorkerPool {
|
|
5
|
+
export class WorkerPool {
|
|
12
6
|
constructor() {
|
|
13
7
|
let pool = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4;
|
|
14
8
|
this.pool = pool;
|
|
@@ -73,5 +67,4 @@ class WorkerPool {
|
|
|
73
67
|
this.queue.length = 0;
|
|
74
68
|
this.workerStatus = 0;
|
|
75
69
|
}
|
|
76
|
-
}
|
|
77
|
-
exports.WorkerPool = WorkerPool;
|
|
70
|
+
}
|