Segment
Source: Segment.js:67
Planet segment Web Mercator tile class that stored and rendered with quad tree.
Constructor
new Segment(
node: quadTree.Node,
planet: Planet,
tileZoom: Number,
extent: Extent,
): SegmentParameters
node(quadTree.Node) — Segment node.planet(Planet) — Current planet scene.tileZoom(Number) — Zoom index.extent(Extent) — Segment extent.
Instance Methods
acceptForRendering(camera: Camera): boolean
Returns that segment good for rendering with camera by current lod ratio.
Parameters
camera(Camera) — Camera object.
Returns
boolean
getEntityTerrainPoint(
entity: Entity,
res: Vec3,
normal?: Vec3,
): Vec3
Returns entity terrain point.
Parameters
entity(Entity) — Entity.res(Vec3) — Point coordinates.normal(Vec3, optional) — Terrain point normal.
Returns
getTerrainPoint(
xyz: Vec3,
insideSegmentPosition: LonLat,
res?: Vec3,
normal?: Vec3,
): number
Returns distance from object to terrain coordinates and terrain point that calculates out in the res parameter.
Parameters
xyz(Vec3) — Cartesian object position.insideSegmentPosition(LonLat) — Geodetic object position.res(Vec3, optional) — Result cartesian coordinates on the terrain.normal(Vec3, optional) — Terrain point normal.
Returns
number
projectNative(lonlat: LonLat): LonLat
Project wgs86 to segment native projection.
Parameters
lonlat(LonLat) — Coordinates to project.
Returns
loadTerrain(forceLoading: boolean)
Parameters
forceLoading(boolean)
elevationsExists(elevations: Float32Array)
Terrain obtained from server.
Parameters
elevations(Float32Array) — Elevation data.
elevationsNotExists()
Terrain is not obtained or not exists on the server.
deleteBuffers()
Delete segment gl buffers.
deleteMaterials()
Delete materials.
deleteElevations()
Delete elevation data.
clearSegment()
Clear but not destroy segment data.
_freeCache()
Removes cache records.
destroySegment()
Clear and destroy all segment data.
createBoundsByExtent()
Creates bound volumes by segment geographical extent.
getMaterialByLayer(layer: Layer): planetSegment.Material
Gets specific layer material.
Parameters
layer(Layer) — Layer object.
Returns
planetSegment.Material
getEntityTerrainPoint(entity: Entity, res: Vec3): Vec3
Returns entity terrain point.
Parameters
Returns
isLonLatInside(lonLat: LonLat): boolean
Returns true when the segment covers the point.
Parameters
lonLat(LonLat) — Geodetic coordinates.
Returns
boolean
getTerrainPoint(
xyz: Vec3,
insideSegmentPosition: LonLat,
res?: Vec3,
): number
Returns distance from object to terrain coordinates and terrain point that calculates out in the res parameter.
Parameters
xyz(Vec3) — Cartesian object position.insideSegmentPosition(LonLat) — Geodetic object position.res(Vec3, optional) — Result cartesian coordinates on the terrain, on the ellipsoid when the segment has no vertices yet.
Returns
number
_hitCellTriangle()
Ray test of the cell triangle at tri[i]: 1 when the point is above it, -1 when below it, 0 when missed.
projectNative(lonlat: LonLat): LonLat
Project wgs86 to segment native projection.
Parameters
lonlat(LonLat) — Coordinates to project.
Returns
elevationsExists(elevations: Float32Array)
Terrain obtained from server.
Parameters
elevations(Float32Array) — Elevation data.
elevationsNotExists()
Keep plain elevation segment for rendering
'this.tileZoom <= this.planet.terrain.maxZoom' it means, that the segment is plain
_equalizeCorner(corner: number)
Takes the corner vertex from the owner of the point: the segment of the lowest zoom among the ones that have a corner there. The owner keeps its vertex, so the result doesn't depend on the order the segments go, and the comparison makes the vertex follow the owner without any labels.
Parameters
corner(number) — Corner index, NW, NE, SW or SE.
_equalizeCornerOnSide()
Puts the corner on the side of a neighbor of a lower zoom, when the point lies inside that side.
_getNormalMapSource()
The segment the normal map of this one comes from: itself, or the parent whose normal map.
_normalMapDrawn()
Called when the normal map is drawn. New normals change all the sides for the finer normal maps that took them.
_setExtentLonLat()
_getExtentCorners()
Returns the SW, NW, NE and SE corners of the segment on the ellipsoid.
setTerrainBoundingVolume(bounds: NumberArray6)
Sets the bounding volume of the terrain vertices, the plain segment volume when there are no finite vertices.
Parameters
bounds(NumberArray6) — [xmin, ymin, zmin, xmax, ymax, zmax].
_createPlainBounds()
Creates the plain segment box center and half diagonal, the LOD volume without terrain.
setLodRadius(radius: number)
Raises the LOD center over the plain segment center by the height of the median vertex radius over the surface.
Parameters
radius(number) — Median geocentric radius of the segment vertices.
getLonLat(lon: number, lat: number): LonLat
Returns the geodetic coordinates of the native point.
Parameters
lon(number) — Native longitude.lat(number) — Native latitude.
Returns
getMaterialByLayer(layer: Layer): Material | undefined
Gets specific layer material.
Parameters
layer(Layer) — Layer object.
Returns
Material| undefined
_getCyclicLonShift(
sourceExtent: Extent,
targetExtent: Extent,
worldWidth: number,
): number
Computes cyclic longitude shift for sourceExtent to align it with targetExtent in wrapped horizontal coordinate space (for example, Web Mercator world copies).
Parameters
sourceExtent(Extent) — Source extent to shift along longitude.targetExtent(Extent) — Target extent used as alignment reference.worldWidth(number) — Full world width in projection units.
Returns
number— Longitude shift to apply tosourceExtent.
Instance Fields
node: quadTree.Node
Quad tree node of the segment.
planet: Planet
Planet pointer.
handler: Handler
WebGl handler pointer.
bsphere: Sphere
Segment bounding sphere
bbox: Box
Segment bounding box.
_extent: Extent
Geographical extent.
gridSize: number
Vertices grid size.
tileZoom: number
Tile zoom index.
tileX: number
Horizontal tile index.
tileY: number
Vertical tile index.
materials: Array.<planetSegment.Material>
Texture materials array.
plainReady: boolean
Plain segment vertices was created.
initialized: boolean
Segment is ready to create plain vertices.
normalMapReady: boolean
Normal map is allready made.
parentNormalMapReady: boolean
Parent normal map is made allready(optimization parameter).
terrainReady: boolean
Terrain is allready applied flag.
terrainIsLoading: boolean
Terrain is loading now flag.
terrainExists: boolean
Terrain existing flag.