-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
137 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { requestNewTile } from '../../Process/TiledNodeProcessing'; | ||
|
||
// TODO: move to tiledMeshLayer class constructor, | ||
// when it will be created | ||
export default { | ||
buildRootTile(tiledMeshLayer, view, scheduler) { | ||
if (!tiledMeshLayer.schemeTile) { | ||
throw new Error(`Cannot init tiled layer without schemeTile for layer ${tiledMeshLayer.id}`); | ||
} | ||
|
||
tiledMeshLayer.level0Nodes = []; | ||
tiledMeshLayer.onTileCreated = tiledMeshLayer.onTileCreated || (() => {}); | ||
|
||
const promises = []; | ||
|
||
for (const root of tiledMeshLayer.schemeTile) { | ||
promises.push(requestNewTile(view, scheduler, tiledMeshLayer, root)); | ||
} | ||
tiledMeshLayer.whenReady = Promise.all(promises).then((level0s) => { | ||
tiledMeshLayer.level0Nodes = level0s; | ||
for (const level0 of level0s) { | ||
tiledMeshLayer.object3d.add(level0); | ||
level0.updateMatrixWorld(); | ||
} | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* To change this license header, choose License Headers in Project Properties. | ||
* To change this template file, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
import * as THREE from 'three'; | ||
import TileGeometry from '../Core/TileGeometry'; | ||
import TileMesh from '../Core/TileMesh'; | ||
import LayeredMaterial from '../Renderer/LayeredMaterial'; | ||
import Cache from '../Core/Scheduler/Cache'; | ||
|
||
export default { | ||
convert(data, extent, layer, requester) { | ||
const builder = layer.builder; | ||
const parent = requester; | ||
const level = (parent !== undefined) ? (parent.level + 1) : 0; | ||
|
||
const { sharableExtent, quaternion, position } = builder.computeSharableExtent(extent); | ||
const south = sharableExtent.south().toFixed(6); | ||
const segment = layer.segments || 16; | ||
const key = `${builder.type}_${layer.disableSkirt ? 0 : 1}_${segment}_${level}_${south}`; | ||
|
||
let geometry = Cache.get(key); | ||
// build geometry if doesn't exist | ||
if (!geometry) { | ||
const paramsGeometry = { | ||
extent: sharableExtent, | ||
level, | ||
segment, | ||
disableSkirt: layer.disableSkirt, | ||
}; | ||
|
||
geometry = new TileGeometry(paramsGeometry, builder); | ||
Cache.set(key, geometry); | ||
|
||
geometry._count = 0; | ||
geometry.dispose = () => { | ||
geometry._count--; | ||
if (geometry._count == 0) { | ||
THREE.BufferGeometry.prototype.dispose.call(geometry); | ||
Cache.delete(key); | ||
} | ||
}; | ||
} | ||
|
||
// build tile | ||
geometry._count++; | ||
const material = new LayeredMaterial(layer.materialOptions); | ||
const tile = new TileMesh(layer, geometry, material, extent, level); | ||
// TODO semble ne pas etre necessaire | ||
tile.layers.set(layer.threejsLayer); | ||
|
||
if (parent && parent instanceof TileMesh) { | ||
// get parent extent transformation | ||
const pTrans = builder.computeSharableExtent(parent.extent); | ||
// place relative to his parent | ||
position.sub(pTrans.position).applyQuaternion(pTrans.quaternion.inverse()); | ||
quaternion.premultiply(pTrans.quaternion); | ||
} | ||
|
||
tile.position.copy(position); | ||
tile.quaternion.copy(quaternion); | ||
|
||
tile.material.transparent = layer.opacity < 1.0; | ||
tile.material.uniforms.opacity.value = layer.opacity; | ||
tile.setVisibility(false); | ||
tile.updateMatrix(); | ||
|
||
if (parent) { | ||
tile.setBBoxZ(parent.OBB().z.min, parent.OBB().z.max); | ||
} else if (layer.materialOptions && layer.materialOptions.useColorTextureElevation) { | ||
tile.setBBoxZ(layer.materialOptions.colorTextureElevationMinZ, layer.materialOptions.colorTextureElevationMaxZ); | ||
} | ||
|
||
return Promise.resolve(tile); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters