CreateFrustum.js 封装创建视锥体的类

class CreateFrustum{
    constructor(options){
        this.position = options.position;
        this.orientation = options.orientation;
        this.fov = options.fov || 30;
        this.near = options.near || 10;
        this.far = options.far || 100;
        this.aspectRatio = options.aspectRatio;
        this.add();
    }

// 更新视锥体的姿态
update(position, orientation){
    this.position = position;
    this.orientation = orientation;
    this.add();
}

// 创建视锥体和轮廓线
add(){
    this.clear();
    this.addFrustum();
    this.addOutline();
}

// 清除视锥体和轮廓线
clear(){
    this.clearFrustum();
    this.clearOutline();
}

// 清除视锥体
clearFrustum(){
    if(this.frustumPrimitive){
        viewer.scene.primitives.remove(this.frustumPrimitive);
        this.frustumPrimitive = null;
    }
}

// 清除轮廓线
clearOutline(){
    if(this.outlinePrimitive){
        viewer.scene
此内容 登录注册 后可见
说点什么吧...