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

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

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

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

针对切片管理
Babylon.js 构建 地球,支持切片地图 (五)

BuildTileTool类
“`javascript
const BABYLON = require(‘babylonjs’);
import {TileTexture} from ‘./TileTexture’;
import {EarthTool} from ‘./EarthTool’;
import {EarthControl} from ‘./EarthControl’;
export class BuildTileTool {
constructor(scene, quadKey, size, offsetX, offsetY, subd, level, a, c, l) {
if (this.scene = scene,
this.quadKey = quadKey,
this.size = size,
this.offsetX = offsetX,
this.offsetY = offsetY,
this.subd = subd,
this.level = level,
this.k = a,
this.j = c,
this.cb = l,
this.tileMapLoaded = false,
this.isReady = false,
this.lock = false,
this.useShader = true,
3 === this.level && (this.lock = true),
this.builTile(),
this.useShader) {
const i = new TileTexture(scene,()=>this.tileTexturCB(),level,a,c,quadKey);
this.tile.material = i.shaderMaterial
}
}
tileTexturCB() {
this.tileMapLoaded = true,
this.cb()
}
builTile() {
this.tile = BABYLON.MeshBuilder.CreateGround(“tile”, {
height: this.size,
width: this.size,
subdivisions: this.subd,
updatable: true
}, this.scene),
this.tile.renderingGroupId = this.level – 3;
let e = this.tile.getVerticesData(BABYLON.VertexBuffer.PositionKind);
const t = e.length / 3;
for (let i = 0; i < t; i++)
if (this.useShader) {
let t = e[3 * i] + this.offsetX;
const n = e[3 * i + 1];
let r = e[3 * i + 2] + this.offsetY;
t = EarthTool.MapNumberToInterval(t, -180, 180, -EarthTool.EPSG3857_MAX_BOUND, EarthTool.EPSG3857_MAX_BOUND),
r = EarthTool.MapNumberToInterval(r, -180, 180, -EarthTool.EPSG3857_MAX_BOUND, EarthTool.EPSG3857_MAX_BOUND);
const o = EarthTool.InverseWebMercator(t, r, n);
e[3 * i] = o.x,
e[3 * i + 1] = o.y,
e[3 * i + 2] = o.z

针对切片管理
Babylon.js 构建 地球,支持切片地图 (五)

BuildTileTool类
“`javascript
const BABYLON = require(‘babylonjs’);
import {TileTexture} from ‘./TileTexture’;
import {EarthTool} from ‘./EarthTool’;
import {EarthControl} from ‘./EarthControl’;
export class BuildTileTool {
constructor(scene, quadKey, size, offsetX, offsetY, subd, level, a, c, l) {
if (this.scene = scene,
this.quadKey = quadKey,
this.size = size,
this.offsetX = offsetX,
this.offsetY = offsetY,
this.subd = subd,
this.level = level,
this.k = a,
this.j = c,
this.cb = l,
this.tileMapLoaded = false,
this.isReady = false,
this.lock = false,
this.useShader = true,
3 === this.level && (this.lock = true),
this.builTile(),
this.useShader) {
const i = new TileTexture(scene,()=>this.tileTexturCB(),level,a,c,quadKey);
this.tile.material = i.shaderMaterial
}
}
tileTexturCB() {
this.tileMapLoaded = true,
this.cb()
}
builTile() {
this.tile = BABYLON.MeshBuilder.CreateGround(“tile”, {
height: this.size,
width: this.size,
subdivisions: this.subd,
updatable: true
}, this.scene),
this.tile.renderingGroupId = this.level – 3;
let e = this.tile.getVerticesData(BABYLON.VertexBuffer.PositionKind);
const t = e.length / 3;
for (let i = 0; i < t; i++)
if (this.useShader) {
let t = e[3 * i] + this.offsetX;
const n = e[3 * i + 1];
let r = e[3 * i + 2] + this.offsetY;
t = EarthTool.MapNumberToInterval(t, -180, 180, -EarthTool.EPSG3857_MAX_BOUND, EarthTool.EPSG3857_MAX_BOUND),
r = EarthTool.MapNumberToInterval(r, -180, 180, -EarthTool.EPSG3857_MAX_BOUND, EarthTool.EPSG3857_MAX_BOUND);
const o = EarthTool.InverseWebMercator(t, r, n);
e[3 * i] = o.x,
e[3 * i + 1] = o.y,
e[3 * i + 2] = o.z

针对切片管理
Babylon.js 构建 地球,支持切片地图 (五)

BuildTileTool类
“`javascript
const BABYLON = require(‘babylonjs’);
import {TileTexture} from ‘./TileTexture’;
import {EarthTool} from ‘./EarthTool’;
import {EarthControl} from ‘./EarthControl’;
export class BuildTileTool {
constructor(scene, quadKey, size, offsetX, offsetY, subd, level, a, c, l) {
if (this.scene = scene,
this.quadKey = quadKey,
this.size = size,
this.offsetX = offsetX,
this.offsetY = offsetY,
this.subd = subd,
this.level = level,
this.k = a,
this.j = c,
this.cb = l,
this.tileMapLoaded = false,
this.isReady = false,
this.lock = false,
this.useShader = true,
3 === this.level && (this.lock = true),
this.builTile(),
this.useShader) {
const i = new TileTexture(scene,()=>this.tileTexturCB(),level,a,c,quadKey);
this.tile.material = i.shaderMaterial
}
}
tileTexturCB() {
this.tileMapLoaded = true,
this.cb()
}
builTile() {
this.tile = BABYLON.MeshBuilder.CreateGround(“tile”, {
height: this.size,
width: this.size,
subdivisions: this.subd,
updatable: true
}, this.scene),
this.tile.renderingGroupId = this.level – 3;
let e = this.tile.getVerticesData(BABYLON.VertexBuffer.PositionKind);
const t = e.length / 3;
for (let i = 0; i < t; i++)
if (this.useShader) {
let t = e[3 * i] + this.offsetX;
const n = e[3 * i + 1];
let r = e[3 * i + 2] + this.offsetY;
t = EarthTool.MapNumberToInterval(t, -180, 180, -EarthTool.EPSG3857_MAX_BOUND, EarthTool.EPSG3857_MAX_BOUND),
r = EarthTool.MapNumberToInterval(r, -180, 180, -EarthTool.EPSG3857_MAX_BOUND, EarthTool.EPSG3857_MAX_BOUND);
const o = EarthTool.InverseWebMercator(t, r, n);
e[3 * i] = o.x,
e[3 * i + 1] = o.y,
e[3 * i + 2] = o.z

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

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

评论 抢沙发

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

b2b链

联系我们联系我们