• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

iTowns / itowns / 15994794586

01 Jul 2025 09:02AM UTC coverage: 87.031%. First build
15994794586

Pull #2557

github

web-flow
Merge ddf98ecce into 651c88ad2
Pull Request #2557: Migrate TileMesh-related modules to typescript

2783 of 3726 branches covered (74.69%)

Branch coverage included in aggregate %.

426 of 433 new or added lines in 15 files covered. (98.38%)

26086 of 29445 relevant lines covered (88.59%)

1099.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.3
/packages/Main/src/Converter/convertToTile.ts
1
import * as THREE from 'three';
1✔
2
import TileMesh from 'Core/TileMesh';
1✔
3
import { LayeredMaterial } from 'Renderer/LayeredMaterial';
1✔
4
import { newTileGeometry, TileBuilder, TileBuilderParams } from 'Core/Prefab/TileBuilder';
1✔
5
import ReferLayerProperties from 'Layer/ReferencingLayerProperties';
1✔
6
import { geoidLayerIsVisible } from 'Layer/GeoidLayer';
1✔
7

1✔
8
import type { Extent } from '@itowns/geographic';
1✔
9
import type { LayeredMaterialParameters } from 'Renderer/LayeredMaterial';
1✔
10

1✔
11
const dimensions = new THREE.Vector2();
1✔
12

1✔
13
interface TileLayerLike {
1✔
14
    diffuse: THREE.Color;
1✔
15
    showOutline: boolean;
1✔
16
    isGlobeLayer: boolean;
1✔
17
    segments: number;
1✔
18
    disableSkirt: boolean;
1✔
19
    hideSkirt: boolean;
1✔
20
    tileMatrixSets: string[];
1✔
21
    materialOptions: LayeredMaterialParameters;
1✔
22
    builder: TileBuilder<TileBuilderParams>;
1✔
23
}
1✔
24

1✔
25
function setTileFromTiledLayer(tile: TileMesh, tileLayer: TileLayerLike) {
65✔
26
    if (tileLayer.diffuse) {
65!
NEW
27
        tile.material.setUniform('diffuse', tileLayer.diffuse);
×
28
    }
×
29

65✔
30
    if (__DEBUG__) {
65✔
31
        tile.material.setUniform('showOutline', tileLayer.showOutline || false);
65✔
32
    }
65✔
33

65✔
34
    if (tileLayer.isGlobeLayer) {
65✔
35
        // Computes a point used for horizon culling.
48✔
36
        // If the point is below the horizon,
48✔
37
        // the tile is guaranteed to be below the horizon as well.
48✔
38
        tile.horizonCullingPoint = tile.extent.center().as('EPSG:4978').toVector3();
48✔
39
        tile.extent.planarDimensions(dimensions).multiplyScalar(THREE.MathUtils.DEG2RAD);
48✔
40

48✔
41
        // alpha is maximum angle between two points of tile
48✔
42
        const alpha = dimensions.length();
48✔
43
        const h = Math.abs(1.0 / Math.cos(alpha * 0.5));
48✔
44
        tile.horizonCullingPoint.setLength(h * tile.horizonCullingPoint.length());
48✔
45
        tile.horizonCullingPointElevationScaled = tile.horizonCullingPoint.clone();
48✔
46
    }
48✔
47
}
65✔
48

1✔
49
export default {
1✔
50
    convert(requester: TileMesh, extent: Extent, layer: TileLayerLike) {
1✔
51
        const builder = layer.builder;
65✔
52
        const parent = requester;
65✔
53
        const level = (parent !== undefined) ? (parent.level + 1) : 0;
65✔
54

65✔
55
        const paramsGeometry = {
65✔
56
            extent,
65✔
57
            level,
65✔
58
            segments: layer.segments || 16,
65✔
59
            disableSkirt: layer.disableSkirt,
65✔
60
            hideSkirt: layer.hideSkirt,
65✔
61
        };
65✔
62

65✔
63
        return newTileGeometry(builder, paramsGeometry).then((result) => {
65✔
64
            // build tile mesh
65✔
65
            result.geometry.increaseRefCount();
65✔
66
            const crsCount = layer.tileMatrixSets.length;
65✔
67
            const material = new LayeredMaterial(layer.materialOptions, crsCount);
65✔
68
            ReferLayerProperties(material, layer);
65✔
69

65✔
70
            const tile = new TileMesh(result.geometry, material, layer, extent, level);
65✔
71

65✔
72
            if (parent && parent.isTileMesh) {
65✔
73
                // get parent extent transformation
12✔
74
                const pTrans = builder.computeShareableExtent(parent.extent);
12✔
75
                // place relative to his parent
12✔
76
                result.position.sub(pTrans.position).applyQuaternion(pTrans.quaternion.invert());
12✔
77
                result.quaternion.premultiply(pTrans.quaternion);
12✔
78
            }
12✔
79

65✔
80
            tile.position.copy(result.position);
65✔
81
            tile.quaternion.copy(result.quaternion);
65✔
82
            tile.visible = false;
65✔
83
            tile.updateMatrix();
65✔
84

65✔
85
            setTileFromTiledLayer(tile, layer);
65✔
86

65✔
87
            if (parent) {
65✔
88
                tile.geoidHeight = parent.geoidHeight;
12✔
89
                const geoidHeight = geoidLayerIsVisible(layer) ? tile.geoidHeight : 0;
12!
90
                tile.setBBoxZ({ min: parent.obb.z.min, max: parent.obb.z.max, geoidHeight });
12✔
91
                tile.material.setUniform('geoidHeight', geoidHeight);
12✔
92
            }
12✔
93

65✔
94
            return tile;
65✔
95
        });
65✔
96
    },
65✔
97
};
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc