zoukankan      html  css  js  c++  java
  • 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,
    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

  • 相关阅读:
    python开发环境安装
    python文件I/O
    python字符串方法以及注释
    python列表
    php: Can't use function return value in write context
    Notice : brew install php70
    对web开发从业者的发展方向的思考
    关于微信跨号支付
    MySQL触发器写法
    MySQL慢查询日志
  • 原文地址:https://www.cnblogs.com/haibalai/p/15829001.html
Copyright © 2011-2022 走看看