区块链技术博客
www.b2bchain.cn

Babylon.js 构建 地球,支持切片地图 (六)求职学习资料

本文介绍了Babylon.js 构建 地球,支持切片地图 (六)求职学习资料,有助于帮助完成毕业设计以及求职,是一篇很好的资料。

对技术面试,学习经验等有一些体会,在此分享。

针对切片管理

Babylon.js 构建 地球,支持切片地图 (六)

针对EarthControl类 主要是管理主类 负责事件监听后重新刷新切片
“`javascript

const BABYLON = require(‘babylonjs’);
import {EarthTool} from ‘./EarthTool’;
import {BuildTileTool} from ‘./BuildTileTool’;

export class EarthControl {
constructor(scene) {
this.scene = scene,
this.rangeAera = 6,
this.maxTilesCount = 512,
this.tilesCount = 0,
this.tilesRemoveCount = 0,
this.level = 0,
this.tiles = [],
this.checkForTile = true,
this.stoprendering = false,
this.nVisible = 0,
this.nHidden = 0,
EarthTool.SetLevel(),
this.addObserver(),
this.camera = this.scene.getCameraByName(“EarthCamera”),
this.drawMinimalEarth(),
this._tick = ()=>this.tick(),
this.scene.registerBeforeRender(this._tick),
this.keyHelper()
}

drawMinimalEarth() {
this.pixelXY = EarthTool.LatLongToPixelXY(90, -180, 3),
this.tileXY = EarthTool.PixelXYToTileXY(this.pixelXY.x, this.pixelXY.y),
this.tileInfo = EarthTool.ComputeVisibleTiles(this.tileXY.x, this.tileXY.y, 3, 8, false);
for (let t = 0; t < this.tileInfo.length; t++) { if (void 0 !== EarthControl.TilesbyQuadKey[this.tileInfo[t].quadKey]) continue; this._tileTexturCB = ()=>this.updateGeoInfo();
const i = new BuildTileTool(this.scene,this.tileInfo[t].quadKey,360 / this.tileInfo[t].nFaces,this.tileInfo[t].offsetX,this.tileInfo[t].offsetY,16,this.tileInfo[t].level,this.tileInfo[t].k,this.tileInfo[t].j,this._tileTexturCB);
console.log(360 / this.tileInfo[t].nFaces),
this.tiles.push(i),
EarthControl.TilesbyQuadKey[this.tileInfo[t].quadKey] = i,
this.tilesCount++
}
}
tick() {
this.camera.isDirty ? (this.level = this.getBestLevelResolution(),
this.checkForTile = true) : true === this.checkForTile && (this.level = this.getBestLevelResolution(),
this.getGeoInfo(this.level),
this.checkForTile = false)
}
getBestLevelResolution() {
const e = EarthTool.MapNumberToInterval(this.camera.radius, 50, 150, 0, 50);
return EarthTool.GetBestLevelResolution(e, this.scene.getEngine().getRenderHeight())
}
pointerup(e) {
const t = e.pickInfo.pickedPoint;
t && “earth” === e.pickInfo.pickedMesh.name && EarthTool.Vec3ToLatLong(t, false)
}
getGeoInfo(t) {
const i = EarthTool.CameraToLatlong(this.camera.beta, this.camera.alpha);
this.pixelXY = EarthTool.LatLongToPixelXY(i.x, i.y, t),
this.tileXY = EarthTool.PixelXYToTileXY(this.pixelXY.x, this.pixelXY.y),
this.tileInfo = EarthTool.ComputeVisibleTiles(this.tileXY.x, this.tileXY.y, t, this.rangeAera, true);
for (let n = 0; n < this.tileInfo.length; n++) { if (void 0 !== EarthControl.TilesbyQuadKey[this.tileInfo[n].quadKey]) continue; const t = new BuildTileTool(this.scene,this.tileInfo[n].quadKey,360 / this.tileInfo[n].nFaces,this.tileInfo[n].offsetX,this.tileInfo[n].offsetY,8,this.tileInfo[n].level,this.tileInfo[n].k,this.tileInfo[n].j,this._tileTexturCB); this.tiles.push(t), EarthControl.TilesbyQuadKey[this.tileInfo[n].quadKey] = t, this.tilesCount++ } this.topleftLatLon = void 0, this.showHide(this.level), this.removeTile() } updateGeoInfo() { this.time = Date.now(), this.checkInterval || (this.checkInterval = setInterval(()=>{
Date.now() – this.time >= 150 && (this.level = this.getBestLevelResolution(),
this.getGeoInfo(this.level),
clearInterval(this.checkInterval),
this.checkInterval = null)
}
, 150))

针对切片管理

Babylon.js 构建 地球,支持切片地图 (六)

针对EarthControl类 主要是管理主类 负责事件监听后重新刷新切片
“`javascript

const BABYLON = require(‘babylonjs’);
import {EarthTool} from ‘./EarthTool’;
import {BuildTileTool} from ‘./BuildTileTool’;

export class EarthControl {
constructor(scene) {
this.scene = scene,
this.rangeAera = 6,
this.maxTilesCount = 512,
this.tilesCount = 0,
this.tilesRemoveCount = 0,
this.level = 0,
this.tiles = [],
this.checkForTile = true,
this.stoprendering = false,
this.nVisible = 0,
this.nHidden = 0,
EarthTool.SetLevel(),
this.addObserver(),
this.camera = this.scene.getCameraByName(“EarthCamera”),
this.drawMinimalEarth(),
this._tick = ()=>this.tick(),
this.scene.registerBeforeRender(this._tick),
this.keyHelper()
}

drawMinimalEarth() {
this.pixelXY = EarthTool.LatLongToPixelXY(90, -180, 3),
this.tileXY = EarthTool.PixelXYToTileXY(this.pixelXY.x, this.pixelXY.y),
this.tileInfo = EarthTool.ComputeVisibleTiles(this.tileXY.x, this.tileXY.y, 3, 8, false);
for (let t = 0; t < this.tileInfo.length; t++) { if (void 0 !== EarthControl.TilesbyQuadKey[this.tileInfo[t].quadKey]) continue; this._tileTexturCB = ()=>this.updateGeoInfo();
const i = new BuildTileTool(this.scene,this.tileInfo[t].quadKey,360 / this.tileInfo[t].nFaces,this.tileInfo[t].offsetX,this.tileInfo[t].offsetY,16,this.tileInfo[t].level,this.tileInfo[t].k,this.tileInfo[t].j,this._tileTexturCB);
console.log(360 / this.tileInfo[t].nFaces),
this.tiles.push(i),
EarthControl.TilesbyQuadKey[this.tileInfo[t].quadKey] = i,
this.tilesCount++
}
}
tick() {
this.camera.isDirty ? (this.level = this.getBestLevelResolution(),
this.checkForTile = true) : true === this.checkForTile && (this.level = this.getBestLevelResolution(),
this.getGeoInfo(this.level),
this.checkForTile = false)
}
getBestLevelResolution() {
const e = EarthTool.MapNumberToInterval(this.camera.radius, 50, 150, 0, 50);
return EarthTool.GetBestLevelResolution(e, this.scene.getEngine().getRenderHeight())
}
pointerup(e) {
const t = e.pickInfo.pickedPoint;
t && “earth” === e.pickInfo.pickedMesh.name && EarthTool.Vec3ToLatLong(t, false)
}
getGeoInfo(t) {
const i = EarthTool.CameraToLatlong(this.camera.beta, this.camera.alpha);
this.pixelXY = EarthTool.LatLongToPixelXY(i.x, i.y, t),
this.tileXY = EarthTool.PixelXYToTileXY(this.pixelXY.x, this.pixelXY.y),
this.tileInfo = EarthTool.ComputeVisibleTiles(this.tileXY.x, this.tileXY.y, t, this.rangeAera, true);
for (let n = 0; n < this.tileInfo.length; n++) { if (void 0 !== EarthControl.TilesbyQuadKey[this.tileInfo[n].quadKey]) continue; const t = new BuildTileTool(this.scene,this.tileInfo[n].quadKey,360 / this.tileInfo[n].nFaces,this.tileInfo[n].offsetX,this.tileInfo[n].offsetY,8,this.tileInfo[n].level,this.tileInfo[n].k,this.tileInfo[n].j,this._tileTexturCB); this.tiles.push(t), EarthControl.TilesbyQuadKey[this.tileInfo[n].quadKey] = t, this.tilesCount++ } this.topleftLatLon = void 0, this.showHide(this.level), this.removeTile() } updateGeoInfo() { this.time = Date.now(), this.checkInterval || (this.checkInterval = setInterval(()=>{
Date.now() – this.time >= 150 && (this.level = this.getBestLevelResolution(),
this.getGeoInfo(this.level),
clearInterval(this.checkInterval),
this.checkInterval = null)
}
, 150))

针对切片管理

Babylon.js 构建 地球,支持切片地图 (六)

针对EarthControl类 主要是管理主类 负责事件监听后重新刷新切片
“`javascript

const BABYLON = require(‘babylonjs’);
import {EarthTool} from ‘./EarthTool’;
import {BuildTileTool} from ‘./BuildTileTool’;

export class EarthControl {
constructor(scene) {
this.scene = scene,
this.rangeAera = 6,
this.maxTilesCount = 512,
this.tilesCount = 0,
this.tilesRemoveCount = 0,
this.level = 0,
this.tiles = [],
this.checkForTile = true,
this.stoprendering = false,
this.nVisible = 0,
this.nHidden = 0,
EarthTool.SetLevel(),
this.addObserver(),
this.camera = this.scene.getCameraByName(“EarthCamera”),
this.drawMinimalEarth(),
this._tick = ()=>this.tick(),
this.scene.registerBeforeRender(this._tick),
this.keyHelper()
}

drawMinimalEarth() {
this.pixelXY = EarthTool.LatLongToPixelXY(90, -180, 3),
this.tileXY = EarthTool.PixelXYToTileXY(this.pixelXY.x, this.pixelXY.y),
this.tileInfo = EarthTool.ComputeVisibleTiles(this.tileXY.x, this.tileXY.y, 3, 8, false);
for (let t = 0; t < this.tileInfo.length; t++) { if (void 0 !== EarthControl.TilesbyQuadKey[this.tileInfo[t].quadKey]) continue; this._tileTexturCB = ()=>this.updateGeoInfo();
const i = new BuildTileTool(this.scene,this.tileInfo[t].quadKey,360 / this.tileInfo[t].nFaces,this.tileInfo[t].offsetX,this.tileInfo[t].offsetY,16,this.tileInfo[t].level,this.tileInfo[t].k,this.tileInfo[t].j,this._tileTexturCB);
console.log(360 / this.tileInfo[t].nFaces),
this.tiles.push(i),
EarthControl.TilesbyQuadKey[this.tileInfo[t].quadKey] = i,
this.tilesCount++
}
}
tick() {
this.camera.isDirty ? (this.level = this.getBestLevelResolution(),
this.checkForTile = true) : true === this.checkForTile && (this.level = this.getBestLevelResolution(),
this.getGeoInfo(this.level),
this.checkForTile = false)
}
getBestLevelResolution() {
const e = EarthTool.MapNumberToInterval(this.camera.radius, 50, 150, 0, 50);
return EarthTool.GetBestLevelResolution(e, this.scene.getEngine().getRenderHeight())
}
pointerup(e) {
const t = e.pickInfo.pickedPoint;
t && “earth” === e.pickInfo.pickedMesh.name && EarthTool.Vec3ToLatLong(t, false)
}
getGeoInfo(t) {
const i = EarthTool.CameraToLatlong(this.camera.beta, this.camera.alpha);
this.pixelXY = EarthTool.LatLongToPixelXY(i.x, i.y, t),
this.tileXY = EarthTool.PixelXYToTileXY(this.pixelXY.x, this.pixelXY.y),
this.tileInfo = EarthTool.ComputeVisibleTiles(this.tileXY.x, this.tileXY.y, t, this.rangeAera, true);
for (let n = 0; n < this.tileInfo.length; n++) { if (void 0 !== EarthControl.TilesbyQuadKey[this.tileInfo[n].quadKey]) continue; const t = new BuildTileTool(this.scene,this.tileInfo[n].quadKey,360 / this.tileInfo[n].nFaces,this.tileInfo[n].offsetX,this.tileInfo[n].offsetY,8,this.tileInfo[n].level,this.tileInfo[n].k,this.tileInfo[n].j,this._tileTexturCB); this.tiles.push(t), EarthControl.TilesbyQuadKey[this.tileInfo[n].quadKey] = t, this.tilesCount++ } this.topleftLatLon = void 0, this.showHide(this.level), this.removeTile() } updateGeoInfo() { this.time = Date.now(), this.checkInterval || (this.checkInterval = setInterval(()=>{
Date.now() – this.time >= 150 && (this.level = this.getBestLevelResolution(),
this.getGeoInfo(this.level),
clearInterval(this.checkInterval),
this.checkInterval = null)
}
, 150))

部分转自互联网,侵权删除联系

赞(0) 打赏
部分文章转自网络,侵权联系删除b2bchain区块链学习技术社区 » Babylon.js 构建 地球,支持切片地图 (六)求职学习资料
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

b2b链

联系我们联系我们