|
1 | 1 | import * as THREE from 'three';
|
2 | 2 |
|
3 | 3 | import TiledGeometryLayer from 'Layer/TiledGeometryLayer';
|
4 |
| -import { globalExtentTMS } from 'Core/Geographic/Extent'; |
| 4 | +import { globalExtentTMS, schemeTiles } from 'Core/Geographic/Extent'; |
5 | 5 | import CRS from 'Core/Geographic/Crs';
|
6 | 6 | import PlanarTileBuilder from './PlanarTileBuilder';
|
7 | 7 |
|
@@ -39,19 +39,47 @@ class PlanarLayer extends TiledGeometryLayer {
|
39 | 39 | */
|
40 | 40 | constructor(id, extent, object3d, config = {}) {
|
41 | 41 | const tms = CRS.formatToTms(extent.crs);
|
42 |
| - const tileMatrixSets = [tms]; |
| 42 | + |
| 43 | + const scheme = schemeTiles.get(tms); |
| 44 | + let schemeTile; |
| 45 | + let clipPlanes = []; |
| 46 | + if (scheme) { |
| 47 | + schemeTile = globalExtentTMS.get(extent.crs).subdivisionByScheme(scheme); |
| 48 | + clipPlanes = [ |
| 49 | + new THREE.Plane(new THREE.Vector3(1, 0, 0), -extent.west), |
| 50 | + new THREE.Plane(new THREE.Vector3(-1, 0, 0), extent.east), |
| 51 | + new THREE.Plane(new THREE.Vector3(0, -1, 0), extent.north), |
| 52 | + new THREE.Plane(new THREE.Vector3(0, 1, 0), -extent.south), |
| 53 | + ]; |
| 54 | + config.materialOptions = { clippingPlanes: clipPlanes }; |
| 55 | + } else { |
| 56 | + schemeTile = [extent]; |
| 57 | + } |
| 58 | + |
43 | 59 | if (!globalExtentTMS.get(extent.crs)) {
|
44 | 60 | // Add new global extent for this new crs projection.
|
45 | 61 | globalExtentTMS.set(extent.crs, extent);
|
46 | 62 | }
|
47 |
| - config.tileMatrixSets = tileMatrixSets; |
48 |
| - super(id, object3d || new THREE.Group(), [extent], new PlanarTileBuilder({ crs: extent.crs }), config); |
| 63 | + |
| 64 | + config.tileMatrixSets = [tms]; |
| 65 | + |
| 66 | + const builder = new PlanarTileBuilder({ crs: extent.crs }); |
| 67 | + |
| 68 | + super(id, object3d || new THREE.Group(), schemeTile, builder, config); |
| 69 | + |
49 | 70 | this.isPlanarLayer = true;
|
50 | 71 | this.extent = extent;
|
51 | 72 | this.minSubdivisionLevel = this.minSubdivisionLevel == undefined ? 0 : this.minSubdivisionLevel;
|
52 |
| - this.maxSubdivisionLevel = this.maxSubdivisionLevel == undefined ? 5 : this.maxSubdivisionLevel; |
| 73 | + this.maxSubdivisionLevel = this.maxSubdivisionLevel == undefined ? 19 : this.maxSubdivisionLevel; |
53 | 74 | this.maxDeltaElevationLevel = this.maxDeltaElevationLevel || 4.0;
|
54 | 75 | }
|
| 76 | + |
| 77 | + culling(node, camera) { |
| 78 | + if (super.culling(node, camera)) { |
| 79 | + return true; |
| 80 | + } |
| 81 | + return !node.extent.intersectsExtent(this.extent); |
| 82 | + } |
55 | 83 | }
|
56 | 84 |
|
57 | 85 | export default PlanarLayer;
|
0 commit comments