отключил управление колесиком мыши через управление землей
This commit is contained in:
parent
c2b9bf78aa
commit
af1470db50
@ -61,6 +61,7 @@ const NavigationPanel: React.FC<NavigationPanelProps> = ({
|
||||
tooltip: 'Управление как в Google Earth: ЛКМ по модели для установки центра вращения, затем вращение и масштабирование колесом мыши',
|
||||
action: () => {
|
||||
viewer?.setControls?.(viewer.earthControls);
|
||||
if (viewer?.earthControls) viewer.earthControls.enableWheelZoom = false;
|
||||
setActiveMode('earth');
|
||||
}
|
||||
},
|
||||
@ -71,9 +72,8 @@ const NavigationPanel: React.FC<NavigationPanelProps> = ({
|
||||
tooltip: 'Свободный полёт в 3D пространстве: WASD для перемещения, мышь для поворота камеры',
|
||||
action: () => {
|
||||
viewer?.setControls?.(viewer.fpControls);
|
||||
if (viewer?.fpControls) {
|
||||
viewer.fpControls.lockElevation = false;
|
||||
}
|
||||
if (viewer?.fpControls) viewer.fpControls.lockElevation = false;
|
||||
if (viewer?.earthControls) viewer.earthControls.enableWheelZoom = true;
|
||||
setActiveMode('flight');
|
||||
}
|
||||
},
|
||||
@ -84,9 +84,8 @@ const NavigationPanel: React.FC<NavigationPanelProps> = ({
|
||||
tooltip: 'Движение только в горизонтальной плоскости: WASD для перемещения по осям X и Y, высота камеры зафиксирована',
|
||||
action: () => {
|
||||
viewer?.setControls?.(viewer.fpControls);
|
||||
if (viewer?.fpControls) {
|
||||
viewer.fpControls.lockElevation = true;
|
||||
}
|
||||
if (viewer?.fpControls) viewer.fpControls.lockElevation = true;
|
||||
if (viewer?.earthControls) viewer.earthControls.enableWheelZoom = true;
|
||||
setActiveMode('helicopter');
|
||||
}
|
||||
},
|
||||
@ -97,6 +96,7 @@ const NavigationPanel: React.FC<NavigationPanelProps> = ({
|
||||
tooltip: 'Орбитальное вращение вокруг центра сцены: ЛКМ - поворот, ПКМ - панорама, колесо - масштаб',
|
||||
action: () => {
|
||||
viewer?.setControls?.(viewer.orbitControls);
|
||||
if (viewer?.earthControls) viewer.earthControls.enableWheelZoom = true;
|
||||
setActiveMode('orbit');
|
||||
}
|
||||
},
|
||||
|
||||
@ -23,6 +23,8 @@ export class EarthControls extends EventDispatcher {
|
||||
|
||||
this.tweens = [];
|
||||
|
||||
this.enableWheelZoom = true; // <--- добавляем флаг
|
||||
|
||||
{
|
||||
let sg = new THREE.SphereGeometry(1, 16, 16);
|
||||
let sm = new THREE.MeshNormalMaterial();
|
||||
@ -142,6 +144,7 @@ export class EarthControls extends EventDispatcher {
|
||||
};
|
||||
|
||||
let scroll = (e) => {
|
||||
if (!this.enableWheelZoom) return; // <--- блокируем zoom если флаг выключен
|
||||
this.wheelDelta += e.delta;
|
||||
};
|
||||
|
||||
|
||||
@ -1,804 +0,0 @@
|
||||
import * as THREE from 'three';
|
||||
|
||||
// Импорты констант и енумов
|
||||
import { ClipTask, ClipMethod, CameraMode, LengthUnits, ElevationGradientRepeat } from "../defines";
|
||||
|
||||
// Импорты рендереров
|
||||
import { Renderer } from "../PotreeRenderer";
|
||||
import { PotreeRenderer } from "./PotreeRenderer";
|
||||
import { EDLRenderer } from "./EDLRenderer";
|
||||
import { HQSplatRenderer } from "./HQSplatRenderer";
|
||||
|
||||
// Импорты основных компонентов
|
||||
import { Scene } from "./Scene";
|
||||
|
||||
// Импорты инструментов
|
||||
import { ClippingTool } from "../utils/ClippingTool";
|
||||
import { TransformationTool } from "../utils/TransformationTool";
|
||||
import { AnnotationTool } from "../utils/AnnotationTool";
|
||||
import { MeasuringTool } from "../utils/MeasuringTool";
|
||||
import { ProfileTool } from "../utils/ProfileTool";
|
||||
import { VolumeTool } from "../utils/VolumeTool";
|
||||
|
||||
// Импорты утилит
|
||||
import { Utils } from "../utils";
|
||||
import { BoxVolume } from "../utils/Volume";
|
||||
import { Features } from "../Features";
|
||||
import { Message } from "../utils/Message";
|
||||
import { Compass } from "../utils/Compass";
|
||||
|
||||
// Импорты навигации
|
||||
import { InputHandler } from "../navigation/InputHandler";
|
||||
import { OrbitControls } from "../navigation/OrbitControls";
|
||||
import { FirstPersonControls } from "../navigation/FirstPersonControls";
|
||||
import { EarthControls } from "../navigation/EarthControls";
|
||||
import { DeviceOrientationControls } from "../navigation/DeviceOrientationControls";
|
||||
import { VRControls } from "../navigation/VRControls";
|
||||
|
||||
// Импорты дополнительных компонентов
|
||||
import { NavigationCube } from "./NavigationCube";
|
||||
import { MapView } from "./map";
|
||||
import { ProfileWindow, ProfileWindowController } from "./profile";
|
||||
import { Sidebar } from "./sidebar";
|
||||
|
||||
// Импорты событий и схем
|
||||
import { EventDispatcher } from "../EventDispatcher";
|
||||
import { ClassificationScheme } from "../materials/ClassificationScheme";
|
||||
|
||||
// Импорты VR и дополнительных библиотек
|
||||
import { VRButton } from '../../libs/three.js/extra/VRButton';
|
||||
|
||||
// Импорты функций и констант
|
||||
import { updatePointClouds } from "../Potree_update_visibility";
|
||||
import { pointBudget, setPointBudget, framenumber, setFrameNumber } from "../constants";
|
||||
import { TWEEN } from "../libs/tween/Tween";
|
||||
|
||||
// Импорты внешних библиотек
|
||||
import JSON5 from "json5";
|
||||
import proj4 from "proj4";
|
||||
|
||||
// Интерфейсы для опций
|
||||
export interface ViewerOptions {
|
||||
width?: number;
|
||||
height?: number;
|
||||
enableEDL?: boolean;
|
||||
pointBudget?: number;
|
||||
background?: string;
|
||||
noDragAndDrop?: boolean;
|
||||
onPointCloudLoaded?: Function;
|
||||
}
|
||||
|
||||
// Основной класс Viewer - полная TypeScript версия
|
||||
export class Viewer extends EventDispatcher {
|
||||
// Основные свойства viewer
|
||||
public renderArea: HTMLElement;
|
||||
public guiLoaded: boolean = false;
|
||||
public guiLoadTasks: Function[] = [];
|
||||
public onVrListeners: Function[] = [];
|
||||
public messages: any[] = [];
|
||||
|
||||
// Сервер и настройки
|
||||
public server: any = null;
|
||||
public fov: number = 60;
|
||||
public isFlipYZ: boolean = false;
|
||||
public useDEMCollisions: boolean = false;
|
||||
public generateDEM: boolean = false;
|
||||
public minNodeSize: number = 30;
|
||||
public edlStrength: number = 1.0;
|
||||
public edlRadius: number = 1.4;
|
||||
public edlOpacity: number = 1.0;
|
||||
public useEDL: boolean = false;
|
||||
public description: string = "";
|
||||
|
||||
// Классификации
|
||||
public classifications: any = ClassificationScheme.DEFAULT;
|
||||
|
||||
// Настройки движения и отображения
|
||||
public moveSpeed: number = 10;
|
||||
public lengthUnit: any = LengthUnits.METER;
|
||||
public lengthUnitDisplay: any = LengthUnits.METER;
|
||||
public showBoundingBox: boolean = false;
|
||||
public showAnnotations: boolean = true;
|
||||
public freeze: boolean = false;
|
||||
public clipTask: number = ClipTask.HIGHLIGHT;
|
||||
public clipMethod: number = ClipMethod.INSIDE_ANY;
|
||||
public elevationGradientRepeat: number = ElevationGradientRepeat.CLAMP;
|
||||
|
||||
// Фильтры
|
||||
public filterReturnNumberRange: [number, number] = [0, 7];
|
||||
public filterNumberOfReturnsRange: [number, number] = [0, 7];
|
||||
public filterGPSTimeRange: [number, number] = [-Infinity, Infinity];
|
||||
public filterPointSourceIDRange: [number, number] = [0, 65535];
|
||||
|
||||
// Рендереры
|
||||
public potreeRenderer: any = null;
|
||||
public edlRenderer: any = null;
|
||||
public renderer: THREE.WebGLRenderer | null = null;
|
||||
public pRenderer: any = null;
|
||||
|
||||
// Сцены и камеры
|
||||
public scene!: Scene; // Инициализируется в конструкторе
|
||||
public sceneVR: any = null;
|
||||
public overlay: any = null;
|
||||
public overlayCamera: any = null;
|
||||
|
||||
// Контролы и инструменты
|
||||
public inputHandler: InputHandler | null = null;
|
||||
public controls: any = null;
|
||||
public orbitControls: OrbitControls | null = null;
|
||||
public fpControls: FirstPersonControls | null = null;
|
||||
public earthControls: EarthControls | null = null;
|
||||
public deviceOrientationControls: DeviceOrientationControls | null = null;
|
||||
public vrControls: VRControls | null = null;
|
||||
|
||||
// Инструменты (инициализируются в конструкторе)
|
||||
public clippingTool!: ClippingTool;
|
||||
public transformationTool!: TransformationTool;
|
||||
public measuringTool!: MeasuringTool;
|
||||
public profileTool!: ProfileTool;
|
||||
public volumeTool!: VolumeTool;
|
||||
public annotationTool!: AnnotationTool;
|
||||
|
||||
// Дополнительные компоненты
|
||||
public navigationCube: NavigationCube | null = null;
|
||||
public compass: Compass | null = null;
|
||||
public mapView: MapView | null = null;
|
||||
public sidebar: Sidebar | null = null;
|
||||
|
||||
// Вспомогательные объекты
|
||||
public skybox: any = null;
|
||||
public clock: THREE.Clock = new THREE.Clock();
|
||||
public background: any = null;
|
||||
public stats: any = null;
|
||||
|
||||
// Callback для загрузки облаков точек
|
||||
public pointCloudLoadedCallback: Function;
|
||||
|
||||
constructor(domElement: HTMLElement, args: ViewerOptions = {}) {
|
||||
super();
|
||||
|
||||
this.renderArea = domElement;
|
||||
this.pointCloudLoadedCallback = args.onPointCloudLoaded || function () {};
|
||||
|
||||
try {
|
||||
// Инициализация Three.js
|
||||
this.initThree();
|
||||
|
||||
// Инициализация drag and drop (если не отключено)
|
||||
if (!args.noDragAndDrop) {
|
||||
this.initDragAndDrop();
|
||||
}
|
||||
|
||||
// Инициализация статистики (если доступно)
|
||||
if (typeof (window as any).Stats !== "undefined") {
|
||||
this.stats = new (window as any).Stats();
|
||||
this.stats.showPanel(0); // 0: fps, 1: ms, 2: mb, 3+: custom
|
||||
document.body.appendChild(this.stats.dom);
|
||||
}
|
||||
|
||||
// Создание контролов
|
||||
this.createControls();
|
||||
|
||||
// Создание инструментов
|
||||
this.createTools();
|
||||
|
||||
// Создание сцены
|
||||
this.scene = new Scene();
|
||||
|
||||
// Настройка обработчиков событий
|
||||
this.setupEventHandlers();
|
||||
|
||||
// Запуск основного цикла рендеринга
|
||||
this.startRenderLoop();
|
||||
|
||||
} catch (error) {
|
||||
console.error('Ошибка инициализации Viewer:', error);
|
||||
this.onCrash(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Инициализация Three.js компонентов
|
||||
private initThree(): void {
|
||||
// Создание рендерера
|
||||
this.renderer = new THREE.WebGLRenderer({
|
||||
alpha: true,
|
||||
antialias: true,
|
||||
preserveDrawingBuffer: true
|
||||
});
|
||||
this.renderer.setSize(this.renderArea.clientWidth, this.renderArea.clientHeight);
|
||||
this.renderer.setClearColor(0x000000, 0);
|
||||
this.renderer.setPixelRatio(window.devicePixelRatio);
|
||||
this.renderArea.appendChild(this.renderer.domElement);
|
||||
|
||||
// Дополнительные настройки рендерера
|
||||
this.renderer.shadowMap.enabled = true;
|
||||
this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
||||
this.renderer.outputColorSpace = THREE.SRGBColorSpace;
|
||||
|
||||
console.log('Three.js инициализирован');
|
||||
}
|
||||
|
||||
// Создание контролов навигации
|
||||
private createControls(): void {
|
||||
if (!this.renderer || !this.renderArea) return;
|
||||
|
||||
// Создание камеры
|
||||
const camera = new THREE.PerspectiveCamera(
|
||||
this.fov,
|
||||
this.renderArea.clientWidth / this.renderArea.clientHeight,
|
||||
0.1,
|
||||
1000
|
||||
);
|
||||
camera.position.set(10, 10, 10);
|
||||
camera.lookAt(0, 0, 0);
|
||||
|
||||
// Создание различных типов контролов
|
||||
this.orbitControls = new OrbitControls(camera, this.renderer.domElement);
|
||||
this.fpControls = new FirstPersonControls(camera, this.renderer.domElement);
|
||||
this.earthControls = new EarthControls(camera, this.renderer.domElement);
|
||||
|
||||
// Установка активных контролов по умолчанию
|
||||
this.controls = this.orbitControls;
|
||||
|
||||
// Создание input handler
|
||||
this.inputHandler = new InputHandler(this.renderArea, camera, this.renderer);
|
||||
|
||||
console.log('Контролы навигации созданы');
|
||||
}
|
||||
|
||||
// Создание инструментов
|
||||
private createTools(): void {
|
||||
// Создание инструментов измерения и редактирования
|
||||
this.measuringTool = new MeasuringTool(this);
|
||||
this.clippingTool = new ClippingTool(this);
|
||||
this.volumeTool = new VolumeTool(this);
|
||||
this.annotationTool = new AnnotationTool(this);
|
||||
this.profileTool = new ProfileTool(this);
|
||||
this.transformationTool = new TransformationTool(this);
|
||||
|
||||
// Создание навигационных компонентов
|
||||
this.navigationCube = new NavigationCube(this);
|
||||
this.compass = new Compass(this);
|
||||
|
||||
console.log('Инструменты созданы');
|
||||
}
|
||||
|
||||
// Настройка обработчиков событий
|
||||
private setupEventHandlers(): void {
|
||||
// Обработка изменения размера окна
|
||||
const handleResize = () => {
|
||||
if (this.renderer && this.scene) {
|
||||
const camera = this.scene.getActiveCamera();
|
||||
if (camera) {
|
||||
camera.aspect = this.renderArea.clientWidth / this.renderArea.clientHeight;
|
||||
camera.updateProjectionMatrix();
|
||||
}
|
||||
this.renderer.setSize(this.renderArea.clientWidth, this.renderArea.clientHeight);
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('resize', handleResize);
|
||||
|
||||
// TODO: Добавить остальные обработчики событий
|
||||
}
|
||||
|
||||
// Инициализация drag and drop
|
||||
private initDragAndDrop(): void {
|
||||
const allowDrag = (e: DragEvent) => {
|
||||
e.dataTransfer!.dropEffect = 'copy';
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
const dropHandler = async (event: DragEvent) => {
|
||||
event.preventDefault();
|
||||
|
||||
const files = Array.from(event.dataTransfer?.files || []);
|
||||
|
||||
for (const file of files) {
|
||||
console.log('Dropped file:', file.name);
|
||||
// TODO: Реализовать загрузку файлов
|
||||
}
|
||||
};
|
||||
|
||||
this.renderArea.addEventListener('dragover', allowDrag);
|
||||
this.renderArea.addEventListener('drop', dropHandler);
|
||||
}
|
||||
|
||||
// Запуск основного цикла рендеринга
|
||||
private startRenderLoop(): void {
|
||||
const animate = (timestamp: number) => {
|
||||
if (this.stats) this.stats.begin();
|
||||
|
||||
// Обновление логики
|
||||
this.update(this.clock.getDelta(), timestamp);
|
||||
|
||||
// Рендеринг
|
||||
this.render();
|
||||
|
||||
if (this.stats) this.stats.end();
|
||||
|
||||
// Следующий кадр
|
||||
requestAnimationFrame(animate);
|
||||
};
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
// Основной метод обновления
|
||||
public update(delta: number, timestamp: number): void {
|
||||
// Обновление контролов
|
||||
if (this.controls && this.controls.update) {
|
||||
this.controls.update(delta);
|
||||
}
|
||||
|
||||
// Обновление сцены
|
||||
if (this.scene) {
|
||||
this.scene.update?.(delta, timestamp);
|
||||
}
|
||||
|
||||
// Обновление инструментов
|
||||
this.measuringTool?.update?.(delta);
|
||||
this.clippingTool?.update?.(delta);
|
||||
this.volumeTool?.update?.(delta);
|
||||
this.navigationCube?.update?.(delta);
|
||||
}
|
||||
|
||||
// Основной метод рендеринга
|
||||
public render(): void {
|
||||
if (!this.renderer || !this.scene) return;
|
||||
|
||||
const camera = this.scene.getActiveCamera();
|
||||
if (!camera) return;
|
||||
|
||||
this.renderer.render(this.scene.scene, camera);
|
||||
}
|
||||
|
||||
// Обработка критических ошибок
|
||||
public onCrash(error: any): void {
|
||||
console.error('Критическая ошибка Viewer:', error);
|
||||
|
||||
const errorElement = document.createElement('div');
|
||||
errorElement.style.cssText = `
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
background: rgba(255, 0, 0, 0.8);
|
||||
color: white;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
z-index: 100000;
|
||||
font-family: monospace;
|
||||
`;
|
||||
errorElement.innerHTML = `
|
||||
<h3>Критическая ошибка Potree Viewer</h3>
|
||||
<pre>${error.toString()}</pre>
|
||||
<button onclick="location.reload()">Перезагрузить</button>
|
||||
`;
|
||||
|
||||
this.renderArea.appendChild(errorElement);
|
||||
}
|
||||
|
||||
// Методы управления точками
|
||||
public setPointBudget(value: number): void {
|
||||
setPointBudget(value);
|
||||
console.log('Point budget set to:', value);
|
||||
}
|
||||
|
||||
public getPointBudget(): number {
|
||||
return pointBudget;
|
||||
}
|
||||
|
||||
public setFOV(value: number): void {
|
||||
this.fov = value;
|
||||
if (this.scene) {
|
||||
const camera = this.scene.getActiveCamera();
|
||||
if (camera && camera.fov !== undefined) {
|
||||
camera.fov = value;
|
||||
camera.updateProjectionMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public getFOV(): number {
|
||||
return this.fov;
|
||||
}
|
||||
|
||||
// Методы EDL (Eye Dome Lighting)
|
||||
public setEDLEnabled(enabled: boolean): void {
|
||||
this.useEDL = enabled;
|
||||
// TODO: Применить к рендереру
|
||||
}
|
||||
|
||||
public getEDLEnabled(): boolean {
|
||||
return this.useEDL;
|
||||
}
|
||||
|
||||
public setEDLRadius(value: number): void {
|
||||
this.edlRadius = value;
|
||||
// TODO: Применить к EDL рендереру
|
||||
}
|
||||
|
||||
public getEDLRadius(): number {
|
||||
return this.edlRadius;
|
||||
}
|
||||
|
||||
public setEDLStrength(value: number): void {
|
||||
this.edlStrength = value;
|
||||
// TODO: Применить к EDL рендереру
|
||||
}
|
||||
|
||||
public getEDLStrength(): number {
|
||||
return this.edlStrength;
|
||||
}
|
||||
|
||||
public setEDLOpacity(value: number): void {
|
||||
this.edlOpacity = value;
|
||||
// TODO: Применить к EDL рендереру
|
||||
}
|
||||
|
||||
public getEDLOpacity(): number {
|
||||
return this.edlOpacity;
|
||||
}
|
||||
|
||||
// Методы управления фоном
|
||||
public setBackground(bg: string): void {
|
||||
this.background = bg;
|
||||
|
||||
if (bg === "skybox") {
|
||||
// TODO: Загрузить skybox
|
||||
this.renderer?.setClearColor(0x87CEEB, 1);
|
||||
} else if (bg === "gradient") {
|
||||
// TODO: Установить градиент
|
||||
this.renderer?.setClearColor(0x87CEEB, 1);
|
||||
} else if (bg === "black") {
|
||||
this.renderer?.setClearColor(0x000000, 1);
|
||||
} else if (bg === "white") {
|
||||
this.renderer?.setClearColor(0xFFFFFF, 1);
|
||||
} else {
|
||||
// Попробовать разобрать как цвет
|
||||
try {
|
||||
const color = new THREE.Color(bg);
|
||||
this.renderer?.setClearColor(color, 1);
|
||||
} catch (e) {
|
||||
console.warn('Неизвестный тип фона:', bg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public getBackground(): string {
|
||||
return this.background;
|
||||
}
|
||||
|
||||
// Методы управления описанием
|
||||
public setDescription(value: string): void {
|
||||
this.description = value;
|
||||
const descElement = this.renderArea.querySelector('#potree_description');
|
||||
if (descElement) {
|
||||
descElement.textContent = value;
|
||||
}
|
||||
}
|
||||
|
||||
public getDescription(): string {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
// Методы управления отображением
|
||||
public setShowBoundingBox(value: boolean): void {
|
||||
this.showBoundingBox = value;
|
||||
// TODO: Применить к pointclouds
|
||||
}
|
||||
|
||||
public getShowBoundingBox(): boolean {
|
||||
return this.showBoundingBox;
|
||||
}
|
||||
|
||||
public setMoveSpeed(value: number): void {
|
||||
this.moveSpeed = value;
|
||||
// TODO: Применить к контролам
|
||||
}
|
||||
|
||||
public getMoveSpeed(): number {
|
||||
return this.moveSpeed;
|
||||
}
|
||||
|
||||
public setMinNodeSize(value: number): void {
|
||||
this.minNodeSize = value;
|
||||
// TODO: Применить к pointclouds
|
||||
}
|
||||
|
||||
public getMinNodeSize(): number {
|
||||
return this.minNodeSize;
|
||||
}
|
||||
|
||||
public setFreeze(value: boolean): void {
|
||||
this.freeze = value;
|
||||
// TODO: Заморозить/разморозить обновления
|
||||
}
|
||||
|
||||
public getFreeze(): boolean {
|
||||
return this.freeze;
|
||||
}
|
||||
|
||||
public setShowAnnotations(value: boolean): void {
|
||||
this.showAnnotations = value;
|
||||
// TODO: Показать/скрыть аннотации
|
||||
}
|
||||
|
||||
public getShowAnnotations(): boolean {
|
||||
return this.showAnnotations;
|
||||
}
|
||||
|
||||
// Методы управления классификациями
|
||||
public setClassifications(classifications: { [key: string]: any }): void {
|
||||
this.classifications = classifications;
|
||||
this.dispatchEvent({ type: 'classifications_changed', classifications });
|
||||
}
|
||||
|
||||
public setClassificationVisibility(key: string, value: boolean): void {
|
||||
if (this.classifications[key]) {
|
||||
this.classifications[key].visible = value;
|
||||
this.dispatchEvent({ type: 'classification_visibility_changed', key, value });
|
||||
}
|
||||
}
|
||||
|
||||
public toggleAllClassificationsVisibility(): void {
|
||||
// Определяем состояние: если все видимы, скрываем все, иначе показываем все
|
||||
const allVisible = Object.values(this.classifications).every((cls: any) => cls.visible);
|
||||
const newVisibility = !allVisible;
|
||||
|
||||
Object.keys(this.classifications).forEach(key => {
|
||||
this.setClassificationVisibility(key, newVisibility);
|
||||
});
|
||||
}
|
||||
|
||||
// Методы управления фильтрами
|
||||
public setFilterReturnNumberRange(from: number, to: number): void {
|
||||
this.filterReturnNumberRange = [from, to];
|
||||
this.dispatchEvent({ type: 'filter_return_number_changed', range: [from, to] });
|
||||
}
|
||||
|
||||
public setFilterNumberOfReturnsRange(from: number, to: number): void {
|
||||
this.filterNumberOfReturnsRange = [from, to];
|
||||
this.dispatchEvent({ type: 'filter_number_of_returns_changed', range: [from, to] });
|
||||
}
|
||||
|
||||
public setFilterGPSTimeRange(from: number, to: number): void {
|
||||
this.filterGPSTimeRange = [from, to];
|
||||
this.dispatchEvent({ type: 'filter_gps_time_changed', range: [from, to] });
|
||||
}
|
||||
|
||||
public setFilterPointSourceIDRange(from: number, to: number): void {
|
||||
this.filterPointSourceIDRange = [from, to];
|
||||
this.dispatchEvent({ type: 'filter_point_source_id_changed', range: [from, to] });
|
||||
}
|
||||
|
||||
public getGpsTimeExtent(): [number, number] {
|
||||
// TODO: Получить актуальный диапазон времени GPS из pointclouds
|
||||
let min = Infinity;
|
||||
let max = -Infinity;
|
||||
|
||||
if (this.scene) {
|
||||
this.scene.pointclouds.forEach((pointcloud: any) => {
|
||||
if (pointcloud.gpsTimeExtent) {
|
||||
min = Math.min(min, pointcloud.gpsTimeExtent[0]);
|
||||
max = Math.max(max, pointcloud.gpsTimeExtent[1]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return min !== Infinity ? [min, max] : [0, 0];
|
||||
}
|
||||
|
||||
// Методы управления обрезкой
|
||||
public getClipTask(): number {
|
||||
return this.clipTask;
|
||||
}
|
||||
|
||||
public getClipMethod(): number {
|
||||
return this.clipMethod;
|
||||
}
|
||||
|
||||
public setClipTask(value: number): void {
|
||||
this.clipTask = value;
|
||||
this.dispatchEvent({ type: 'clip_task_changed', clipTask: value });
|
||||
}
|
||||
|
||||
public setClipMethod(value: number): void {
|
||||
this.clipMethod = value;
|
||||
this.dispatchEvent({ type: 'clip_method_changed', clipMethod: value });
|
||||
}
|
||||
|
||||
// Методы управления единицами измерения
|
||||
public setLengthUnit(value: string): void {
|
||||
this.lengthUnit = value;
|
||||
this.lengthUnitDisplay = value;
|
||||
this.dispatchEvent({ type: 'length_unit_changed', lengthUnit: value });
|
||||
}
|
||||
|
||||
// Методы управления камерой и видами
|
||||
public fitToScreen(factor: number = 1, animationDuration: number = 0): void {
|
||||
if (!this.scene) return;
|
||||
|
||||
const boundingBox = this.scene.getBoundingBox();
|
||||
const size = boundingBox.getSize(new THREE.Vector3());
|
||||
const center = boundingBox.getCenter(new THREE.Vector3());
|
||||
|
||||
const camera = this.scene.getActiveCamera();
|
||||
if (!camera) return;
|
||||
|
||||
const distance = Math.max(size.x, size.y, size.z) * factor * 1.5;
|
||||
camera.position.copy(center);
|
||||
camera.position.z += distance;
|
||||
camera.lookAt(center);
|
||||
|
||||
console.log('Fit to screen:', { center, distance, size });
|
||||
}
|
||||
|
||||
public zoomTo(node: any, factor: number = 1, animationDuration: number = 0): void {
|
||||
// TODO: Реализовать зум к конкретному узлу
|
||||
console.log('Zoom to node:', node, factor, animationDuration);
|
||||
}
|
||||
|
||||
public getBoundingBox(pointclouds?: any[]): THREE.Box3 {
|
||||
if (this.scene) {
|
||||
return this.scene.getBoundingBox(pointclouds);
|
||||
}
|
||||
return new THREE.Box3();
|
||||
}
|
||||
|
||||
// Методы установки предустановленных видов
|
||||
public setTopView(): void {
|
||||
if (!this.scene) return;
|
||||
const camera = this.scene.getActiveCamera();
|
||||
if (!camera) return;
|
||||
|
||||
const boundingBox = this.getBoundingBox();
|
||||
const center = boundingBox.getCenter(new THREE.Vector3());
|
||||
const size = boundingBox.getSize(new THREE.Vector3());
|
||||
|
||||
camera.position.set(center.x, center.y, center.z + Math.max(size.x, size.y) * 1.5);
|
||||
camera.lookAt(center);
|
||||
camera.up.set(0, 1, 0);
|
||||
}
|
||||
|
||||
public setBottomView(): void {
|
||||
if (!this.scene) return;
|
||||
const camera = this.scene.getActiveCamera();
|
||||
if (!camera) return;
|
||||
|
||||
const boundingBox = this.getBoundingBox();
|
||||
const center = boundingBox.getCenter(new THREE.Vector3());
|
||||
const size = boundingBox.getSize(new THREE.Vector3());
|
||||
|
||||
camera.position.set(center.x, center.y, center.z - Math.max(size.x, size.y) * 1.5);
|
||||
camera.lookAt(center);
|
||||
camera.up.set(0, 1, 0);
|
||||
}
|
||||
|
||||
public setFrontView(): void {
|
||||
if (!this.scene) return;
|
||||
const camera = this.scene.getActiveCamera();
|
||||
if (!camera) return;
|
||||
|
||||
const boundingBox = this.getBoundingBox();
|
||||
const center = boundingBox.getCenter(new THREE.Vector3());
|
||||
const size = boundingBox.getSize(new THREE.Vector3());
|
||||
|
||||
camera.position.set(center.x, center.y + Math.max(size.x, size.z) * 1.5, center.z);
|
||||
camera.lookAt(center);
|
||||
camera.up.set(0, 0, 1);
|
||||
}
|
||||
|
||||
public setBackView(): void {
|
||||
if (!this.scene) return;
|
||||
const camera = this.scene.getActiveCamera();
|
||||
if (!camera) return;
|
||||
|
||||
const boundingBox = this.getBoundingBox();
|
||||
const center = boundingBox.getCenter(new THREE.Vector3());
|
||||
const size = boundingBox.getSize(new THREE.Vector3());
|
||||
|
||||
camera.position.set(center.x, center.y - Math.max(size.x, size.z) * 1.5, center.z);
|
||||
camera.lookAt(center);
|
||||
camera.up.set(0, 0, 1);
|
||||
}
|
||||
|
||||
public setLeftView(): void {
|
||||
if (!this.scene) return;
|
||||
const camera = this.scene.getActiveCamera();
|
||||
if (!camera) return;
|
||||
|
||||
const boundingBox = this.getBoundingBox();
|
||||
const center = boundingBox.getCenter(new THREE.Vector3());
|
||||
const size = boundingBox.getSize(new THREE.Vector3());
|
||||
|
||||
camera.position.set(center.x - Math.max(size.y, size.z) * 1.5, center.y, center.z);
|
||||
camera.lookAt(center);
|
||||
camera.up.set(0, 0, 1);
|
||||
}
|
||||
|
||||
public setRightView(): void {
|
||||
if (!this.scene) return;
|
||||
const camera = this.scene.getActiveCamera();
|
||||
if (!camera) return;
|
||||
|
||||
const boundingBox = this.getBoundingBox();
|
||||
const center = boundingBox.getCenter(new THREE.Vector3());
|
||||
const size = boundingBox.getSize(new THREE.Vector3());
|
||||
|
||||
camera.position.set(center.x + Math.max(size.y, size.z) * 1.5, center.y, center.z);
|
||||
camera.lookAt(center);
|
||||
camera.up.set(0, 0, 1);
|
||||
}
|
||||
|
||||
// Методы управления контролами
|
||||
public setControls(controls: any): void {
|
||||
this.controls = controls;
|
||||
console.log('Controls set to:', controls);
|
||||
}
|
||||
|
||||
public getControls(): any {
|
||||
return this.controls;
|
||||
}
|
||||
|
||||
// Методы загрузки GUI
|
||||
public loadGUI(callback?: () => void): void {
|
||||
console.log('loadGUI: Используем React компонент PotreeSidebar.tsx');
|
||||
this.guiLoaded = true;
|
||||
|
||||
// Выполняем все отложенные задачи
|
||||
this.guiLoadTasks.forEach(task => task());
|
||||
this.guiLoadTasks = [];
|
||||
|
||||
// Вызываем callback если есть
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
public setLanguage(lang: string): void {
|
||||
console.log('Setting language:', lang);
|
||||
// TODO: Реализовать смену языка
|
||||
}
|
||||
|
||||
// Метод очистки ресурсов
|
||||
public destroy(): void {
|
||||
// Остановка анимации
|
||||
if (this.animationId) {
|
||||
cancelAnimationFrame(this.animationId);
|
||||
}
|
||||
|
||||
// Очистка рендерера
|
||||
if (this.renderer) {
|
||||
this.renderer.dispose();
|
||||
if (this.renderer.domElement.parentElement) {
|
||||
this.renderer.domElement.parentElement.removeChild(this.renderer.domElement);
|
||||
}
|
||||
}
|
||||
|
||||
// Очистка инструментов
|
||||
this.measuringTool = null;
|
||||
this.clippingTool = null;
|
||||
this.volumeTool = null;
|
||||
this.annotationTool = null;
|
||||
this.profileTool = null;
|
||||
this.transformationTool = null;
|
||||
|
||||
// Очистка контролов
|
||||
this.orbitControls = null;
|
||||
this.fpControls = null;
|
||||
this.earthControls = null;
|
||||
this.controls = null;
|
||||
|
||||
// Очистка сцены
|
||||
this.scene = null;
|
||||
|
||||
console.log('Viewer destroyed');
|
||||
}
|
||||
|
||||
// Методы событий (наследуются от EventDispatcher)
|
||||
// addEventListener, removeEventListener, dispatchEvent - уже есть в EventDispatcher
|
||||
}
|
||||
2
src/vite-env.d.ts
vendored
2
src/vite-env.d.ts
vendored
@ -1 +1 @@
|
||||
/// <reference types="vite/client" />
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user