Skip to content

Commit e0b32b4

Browse files
committed
refactor(parsers): move and rename parsers to a new parser directory
Multiple classes are in charge of decoding file chunks. They were scattered into multiple directories and had different names : Loaders, Parsers, IoDrivers... They are now all moved to a new src/Parser directory This commit addresses first item of #695
1 parent beb2f53 commit e0b32b4

20 files changed

Lines changed: 51 additions & 51 deletions

src/Core/Scheduler/Providers/3dTiles_Provider.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as THREE from 'three';
2-
import B3dmLoader from '../../../Renderer/ThreeExtended/B3dmLoader';
3-
import PntsLoader from '../../../Renderer/ThreeExtended/PntsLoader';
2+
import B3dmParser from '../../../Parser/B3dmParser';
3+
import PntsParser from '../../../Parser/PntsParser';
44
import Fetcher from './Fetcher';
55
import OBB from '../../../Renderer/ThreeExtended/OBB';
66
import Extent from '../../Geographic/Extent';
@@ -142,11 +142,11 @@ export function patchMaterialForLogDepthSupport(material) {
142142
};
143143
}
144144

145-
let b3dmLoader;
145+
let b3dmParser;
146146
let textDecoder;
147147
function b3dmToMesh(data, layer, url) {
148-
b3dmLoader = b3dmLoader || new B3dmLoader();
149-
return b3dmLoader.parse(data, layer.asset.gltfUpAxis, url, textDecoder).then((result) => {
148+
b3dmParser = b3dmParser || new B3dmParser();
149+
return b3dmParser.parse(data, layer.asset.gltfUpAxis, url, textDecoder).then((result) => {
150150
const init = function f_init(mesh) {
151151
mesh.frustumCulled = false;
152152
if (mesh.material) {
@@ -177,7 +177,7 @@ function b3dmToMesh(data, layer, url) {
177177

178178
function pntsParse(data) {
179179
return new Promise((resolve) => {
180-
resolve({ object3d: PntsLoader.parse(data, textDecoder).point });
180+
resolve({ object3d: PntsParser.parse(data, textDecoder).point });
181181
});
182182
}
183183

src/Core/Scheduler/Providers/OGCWebServiceHelper.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as THREE from 'three';
22
import Fetcher from './Fetcher';
3-
import IoDriver_XBIL from './IoDriver_XBIL';
3+
import XbilParser from '../../../Parser/XbilParser';
44
import Projection from '../../Geographic/Projection';
55
import Extent from '../../Geographic/Extent';
66

@@ -12,7 +12,7 @@ export const SIZE_TEXTURE_TILE = 256;
1212
// Info : THREE.js have cache image https://github.com/mrdoob/three.js/blob/master/src/loaders/ImageLoader.js#L25
1313
const cache = new Map();
1414
const pending = new Map();
15-
const ioDXBIL = new IoDriver_XBIL();
15+
const XBIL = new XbilParser();
1616
const projection = new Projection();
1717

1818
const getTextureFloat = function getTextureFloat(buffer) {
@@ -24,7 +24,7 @@ const getTextureFloat = function getTextureFloat(buffer) {
2424
const tileCoord = new Extent('WMTS:WGS84G', 0, 0, 0);
2525

2626
export default {
27-
ioDXBIL,
27+
XBIL,
2828
getColorTextureByUrl(url, networkOptions) {
2929
if (cache.has(url)) {
3030
return Promise.resolve(cache.get(url));
@@ -59,7 +59,7 @@ export default {
5959
return pending.get(url);
6060
}
6161

62-
const promiseXBil = ioDXBIL.read(url, networkOptions).then((result) => {
62+
const promiseXBil = XBIL.read(url, networkOptions).then((result) => {
6363
// TODO RGBA is needed for navigator with no support in texture float
6464
// In RGBA elevation texture LinearFilter give some errors with nodata value.
6565
// need to rewrite sample function in shader

src/Core/Scheduler/Providers/PointCloudProvider.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import * as THREE from 'three';
22
import Fetcher from './Fetcher';
33
import PointCloudProcessing from '../../../Process/PointCloudProcessing';
4-
import PotreeBinLoader from './PotreeBinLoader';
5-
import PotreeCinLoader from './PotreeCinLoader';
4+
import PotreeBinParser from '../../../Parser/PotreeBinParser';
5+
import PotreeCinParser from '../../../Parser/PotreeCinParser';
66
import Picking from '../../Picking';
77

88
// Create an A(xis)A(ligned)B(ounding)B(ox) for the child `childIndex` of one aabb.
@@ -123,9 +123,9 @@ function addPickingAttribute(points) {
123123
function loadPointFile(layer, url) {
124124
return fetch(url, layer.fetchOptions).then(foo => foo.arrayBuffer()).then((ab) => {
125125
if (layer.metadata.customBinFormat) {
126-
return addPickingAttribute(PotreeCinLoader.parse(ab));
126+
return addPickingAttribute(PotreeCinParser.parse(ab));
127127
} else {
128-
return addPickingAttribute(PotreeBinLoader.parse(ab));
128+
return addPickingAttribute(PotreeBinParser.parse(ab));
129129
}
130130
});
131131
}

src/Core/Scheduler/Providers/Raster_Provider.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import * as THREE from 'three';
88
import togeojson from 'togeojson';
99
import Extent from '../../Geographic/Extent';
1010
import Feature2Texture from '../../../Renderer/ThreeExtended/Feature2Texture';
11-
import GeoJSON2Features from '../../../Renderer/ThreeExtended/GeoJSON2Features';
11+
import GeoJsonParser from '../../../Parser/GeoJsonParser';
1212
import Fetcher from './Fetcher';
1313

1414
function getExtentFromGpxFile(file) {
@@ -104,7 +104,7 @@ export default {
104104
}
105105

106106
if (geojson) {
107-
layer.feature = GeoJSON2Features.parse(parentCrs, geojson, layer.extent, options);
107+
layer.feature = GeoJsonParser.parse(parentCrs, geojson, layer.extent, options);
108108
layer.extent = layer.feature.extent || layer.feature.geometry.extent;
109109
}
110110
});

src/Core/Scheduler/Providers/WFS_Provider.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import Extent from '../../Geographic/Extent';
88
import URLBuilder from './URLBuilder';
99
import Fetcher from './Fetcher';
10-
import GeoJSON2Features from '../../../Renderer/ThreeExtended/GeoJSON2Features';
10+
import GeoJsonParser from '../../../Parser/GeoJsonParser';
1111
import Feature2Mesh from '../../../Renderer/ThreeExtended/Feature2Mesh';
1212

1313
const cache = new Map();
@@ -70,7 +70,7 @@ function getFeatures(crs, tile, layer) {
7070
layer.convert = layer.convert ? layer.convert : Feature2Mesh.convert({});
7171

7272
return Fetcher.json(urld, layer.networkOptions).then(
73-
geojson => assignLayer(layer.convert(GeoJSON2Features.parse(crs, geojson, tile.extent, { filter: layer.filter })), layer),
73+
geojson => assignLayer(layer.convert(GeoJsonParser.parse(crs, geojson, tile.extent, { filter: layer.filter })), layer),
7474
(err) => {
7575
// special handling for 400 errors, as it probably means the config is wrong
7676
if (err.response.status == 400) {

src/Core/View.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const VIEW_EVENTS = {
3737
* @constructor
3838
* @example
3939
* // How add gpx object
40-
* itowns.GpxUtils.load(url, viewer.referenceCrs).then((gpx) => {
40+
* itowns.GpxParser.load(url, viewer.referenceCrs).then((gpx) => {
4141
* if (gpx) {
4242
* viewer.scene.add(gpx);
4343
* }

src/Main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ export { default as Extent } from './Core/Geographic/Extent';
33
export { GeometryLayer, ImageryLayers } from './Core/Layer/Layer';
44
export { STRATEGY_MIN_NETWORK_TRAFFIC, STRATEGY_GROUP, STRATEGY_PROGRESSIVE, STRATEGY_DICHOTOMY } from './Core/Layer/LayerUpdateStrategy';
55
export { default as GlobeView, GLOBE_VIEW_EVENTS, createGlobeLayer } from './Core/Prefab/GlobeView';
6-
export { default as GpxUtils } from './Core/Scheduler/Providers/GpxUtils';
76
export { default as PlanarView, createPlanarLayer } from './Core/Prefab/PlanarView';
87
export { default as PanoramaView, createPanoramaLayer } from './Core/Prefab/PanoramaView';
98
export { default as Panorama } from './Core/Prefab/Panorama/Constants';
109
export { default as Fetcher } from './Core/Scheduler/Providers/Fetcher';
1110
export { MAIN_LOOP_EVENTS } from './Core/MainLoop';
1211
export { default as View } from './Core/View';
1312
export { VIEW_EVENTS } from './Core/View';
13+
export { default as GpxParser } from './Parser/GpxParser';
14+
export { default as GeoJsonParser } from './Parser/GeoJsonParser';
1415
export { process3dTilesNode, init3dTilesLayer, $3dTilesCulling, $3dTilesSubdivisionControl, pre3dTilesUpdate } from './Process/3dTilesProcessing';
1516
export { default as FeatureProcessing } from './Process/FeatureProcessing';
1617
export { updateLayeredMaterialNodeImagery, updateLayeredMaterialNodeElevation } from './Process/LayeredMaterialNodeProcessing';
@@ -22,7 +23,6 @@ export { default as Feature2Mesh } from './Renderer/ThreeExtended/Feature2Mesh';
2223
export { default as FlyControls } from './Renderer/ThreeExtended/FlyControls';
2324
export { default as FirstPersonControls } from './Renderer/ThreeExtended/FirstPersonControls';
2425
export { default as PlanarControls } from './Renderer/ThreeExtended/PlanarControls';
25-
export { default as GeoJSON2Features } from './Renderer/ThreeExtended/GeoJSON2Features';
2626
export { default as FeaturesUtils } from './Renderer/ThreeExtended/FeaturesUtils';
2727
export { CONTROL_EVENTS } from './Renderer/ThreeExtended/GlobeControls';
2828
export { default as DEMUtils } from './utils/DEMUtils';
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import * as THREE from 'three';
22
import GLTFLoader from './GLTFLoader';
3-
import LegacyGLTFLoader from './deprecated/LegacyGLTFLoader';
3+
import LegacyGLTFLoader from './LegacyGLTFLoader';
44
import BatchTable from './BatchTable';
55

66
const matrixChangeUpVectorZtoY = (new THREE.Matrix4()).makeRotationX(Math.PI / 2);
77
// For gltf rotation
88
const matrixChangeUpVectorZtoX = (new THREE.Matrix4()).makeRotationZ(-Math.PI / 2);
99

10-
function B3dmLoader() {
10+
function B3dmParser() {
1111
this.glTFLoader = new GLTFLoader();
1212
this.LegacyGLTFLoader = new LegacyGLTFLoader();
1313
}
@@ -46,7 +46,7 @@ function applyOptionalCesiumRTC(data, gltf, textDecoder) {
4646
}
4747
}
4848

49-
B3dmLoader.prototype.parse = function parse(buffer, gltfUpAxis, url, textDecoder) {
49+
B3dmParser.prototype.parse = function parse(buffer, gltfUpAxis, url, textDecoder) {
5050
if (!buffer) {
5151
throw new Error('No array buffer provided.');
5252
}
@@ -124,4 +124,4 @@ B3dmLoader.prototype.parse = function parse(buffer, gltfUpAxis, url, textDecoder
124124
}
125125
};
126126

127-
export default B3dmLoader;
127+
export default B3dmParser;

0 commit comments

Comments
 (0)