zoukankan      html  css  js  c++  java
  • Babylon.js 构建 地球,支持切片地图 (三)

    继续上一篇camera 的类

    针对CameraEarthWheelControl
    ```javascript
    const BABYLON = require('babylonjs');
    import {EarthTool} from './EarthTool';

    export class CameraEarthWheelControl {
    constructor(camera) {
    this.camera = camera;
    this.wheelPrecision = 3,
    this.wheelDeltaPercentage = 0,
    this._maxRadius = 150,
    this._minRadius = 50
    }
    getTypeName() {
    return null
    }
    getClassName() {
    return "CameraEarthWheelControl"
    }
    getSimpleName() {
    return "earthmousewheel"
    }
    computeDeltaFromMouseWheelLegacyEvent(e, t) {
    let i = 0;
    const n = .01 * e * this.wheelDeltaPercentage * t;
    return i = e > 0 ? n / (1 + this.wheelDeltaPercentage) : n * (1 + this.wheelDeltaPercentage),
    i
    }
    attachControl(e, t) {
    const i = BABYLON.Vector2.Zero();
    this._wheel = (e,i)=>{
    if (e.type !== BABYLON.PointerEventTypes.POINTERWHEEL)
    return;
    const n = e.event;
    let r = 0
    , o = 0;
    if (o = n.wheelDelta ? n.wheelDelta : 60 * -(n.deltaY || n.detail),
    this.wheelDeltaPercentage) {
    if (r = this.computeDeltaFromMouseWheelLegacyEvent(o, this.camera.radius),
    r > 0) {
    let e = this.camera.radius
    , t = this.camera.inertialRadiusOffset + r;
    for (let i = 0; i < 20 && Math.abs(t) > .001; i++)
    e -= t,
    t *= this.camera.inertia;
    e = BABYLON.Scalar.Clamp(e, 0, Number.MAX_VALUE),
    r = this.computeDeltaFromMouseWheelLegacyEvent(o, e)
    }
    } else {
    r = o > 0 ? EarthTool.MapNumberToInterval(this.camera.radius, 220, 50, 10, 1e-4) : -EarthTool.MapNumberToInterval(this.camera.radius, 220, 50, 10, 1e-4);
    let e = EarthTool.MapNumberToInterval(this.camera.radius, 220, 50, .9, .2);
    e > .9 ? e = .9 : e < 0 && (e = 0), this.camera.inertia = e } r && (this.camera.inertialRadiusOffset += r), n.preventDefault && (t || n.preventDefault()) } , this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, BABYLON.PointerEventTypes.POINTERWHEEL), this.camera.getScene(), this._pointer = ()=>{
    const e = (this.camera.latLonAtmouse.x - i.x) * Math.PI / 180
    , t = (this.camera.latLonAtmouse.y - i.y) * Math.PI / 180;
    this.camera.distance && (this.camera.inertialAlphaOffset += t / 5,

  • 相关阅读:
    java实现第三届蓝桥杯填算式
    java实现第三届蓝桥杯填算式
    微信--高效解决token及授权用户openid的持久化处理办法
    微信开发学习总结——微信开发入门(转)
    Java 微信公众号开发--- 接入微信
    微信开发工具类
    手把手教你反编译别人的app
    马士兵hadoop第五课:java开发Map/Reduce(转)
    马士兵hadoop第四课:Yarn和Map/Reduce配置启动和原理讲解(转)
    马士兵hadoop第三课:java开发hdfs(转)
  • 原文地址:https://www.cnblogs.com/haibalai/p/15828994.html
Copyright © 2011-2022 走看看