|
|
@ -7,7 +7,7 @@ import { MouseKey, KeyBoard } from '../Common/KeyEnum';
|
|
|
|
import { app } from '../ApplicationServices/Application';
|
|
|
|
import { app } from '../ApplicationServices/Application';
|
|
|
|
import * as THREE from 'three';
|
|
|
|
import * as THREE from 'three';
|
|
|
|
import { number } from 'mobx-state-tree/dist/types/primitives';
|
|
|
|
import { number } from 'mobx-state-tree/dist/types/primitives';
|
|
|
|
import { Box2, Vector2 } from '../../@types/three/three-core';
|
|
|
|
import { Box2, Vector2, Raycaster } from '../../@types/three/three-core';
|
|
|
|
import * as _ from 'lodash';
|
|
|
|
import * as _ from 'lodash';
|
|
|
|
import { SelectType, SelectSet, SelectSetBase } from './SelectSet';
|
|
|
|
import { SelectType, SelectSet, SelectSetBase } from './SelectSet';
|
|
|
|
import { SelectBox } from './SelectBox';
|
|
|
|
import { SelectBox } from './SelectBox';
|
|
|
@ -54,26 +54,27 @@ export class SelectControls
|
|
|
|
//如果还没选择 那么
|
|
|
|
//如果还没选择 那么
|
|
|
|
if (!this.m_SelectIng)
|
|
|
|
if (!this.m_SelectIng)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
let raycaster = new THREE.Raycaster();
|
|
|
|
|
|
|
|
raycaster.setFromCamera({
|
|
|
|
|
|
|
|
x: (pt.x / this.m_Viewer.m_HtmlElement.scrollWidth) * 2 - 1,
|
|
|
|
|
|
|
|
y: - (pt.y / this.m_Viewer.m_HtmlElement.scrollHeight) * 2 + 1
|
|
|
|
|
|
|
|
}, this.m_Viewer.m_Camera.m_CurCamera);
|
|
|
|
|
|
|
|
raycaster.ray.origin.sub(raycaster.ray.direction.clone().multiplyScalar(1e3));
|
|
|
|
|
|
|
|
let intersectObjects = raycaster.intersectObjects(this.m_Viewer.m_Scene.children);
|
|
|
|
|
|
|
|
|
|
|
|
let selectID = this.gpuPick.pick(pt.x, pt.y);
|
|
|
|
if (intersectObjects.length > 0)
|
|
|
|
if (selectID > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let selectObject = this.m_Viewer.m_Scene.getObjectById(selectID);
|
|
|
|
|
|
|
|
if (selectObject)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
let selectData = new SelectPick(this.m_Viewer, pt.clone());
|
|
|
|
let selectData = new SelectPick(this.m_Viewer, pt.clone());
|
|
|
|
selectData.m_SelectList.push(selectObject);
|
|
|
|
selectData.m_SelectList.push(intersectObjects[0].object);
|
|
|
|
|
|
|
|
|
|
|
|
if (isRemove)
|
|
|
|
if (isRemove)
|
|
|
|
this.m_SelectSet.RemoveSelect(selectData);
|
|
|
|
this.m_SelectSet.RemoveSelect(selectData);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
this.m_SelectSet.AddSelect(selectData);
|
|
|
|
this.m_SelectSet.AddSelect(selectData);
|
|
|
|
|
|
|
|
|
|
|
|
this.UpdateView();
|
|
|
|
this.UpdateView();
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.m_SelectIng = !this.m_SelectIng;
|
|
|
|
this.m_SelectIng = !this.m_SelectIng;
|
|
|
|
if (this.m_SelectIng)
|
|
|
|
if (this.m_SelectIng)
|
|
|
|