|
|
@ -6,6 +6,7 @@ import { RenderType } from './Enum';
|
|
|
|
import * as xaop from 'xaop';
|
|
|
|
import * as xaop from 'xaop';
|
|
|
|
import { GeUtils } from "../Geometry/GeUtils";
|
|
|
|
import { GeUtils } from "../Geometry/GeUtils";
|
|
|
|
import { Entity } from '../DatabaseServices/Entity';
|
|
|
|
import { Entity } from '../DatabaseServices/Entity';
|
|
|
|
|
|
|
|
import { PlaneExt } from '../Geometry/Plane';
|
|
|
|
|
|
|
|
|
|
|
|
//导入其他js模块
|
|
|
|
//导入其他js模块
|
|
|
|
require("three-CopyShader");
|
|
|
|
require("three-CopyShader");
|
|
|
@ -162,23 +163,27 @@ export class Viewer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ScreenToWorld(pt: THREE.Vector3)
|
|
|
|
ScreenToWorld(pt: THREE.Vector3)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pt.x -= this.m_HtmlElement.scrollWidth * 0.5;
|
|
|
|
//变换和求交点
|
|
|
|
pt.y -= this.m_HtmlElement.scrollHeight * 0.5;
|
|
|
|
let plan = new PlaneExt(new THREE.Vector3(0, 0, 1));
|
|
|
|
pt.y *= -1;
|
|
|
|
let raycaster = new THREE.Raycaster();
|
|
|
|
pt.multiplyScalar(this.m_ViewHeight / this.m_HtmlElement.scrollHeight);
|
|
|
|
raycaster.setFromCamera(
|
|
|
|
|
|
|
|
{
|
|
|
|
this.m_Camera.m_CurCamera.updateMatrix();
|
|
|
|
x: (pt.x / this.m_HtmlElement.scrollWidth) * 2 - 1,
|
|
|
|
pt.applyMatrix4(this.m_Camera.m_CurCamera.matrix);
|
|
|
|
y: - (pt.y / this.m_HtmlElement.scrollHeight) * 2 + 1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
, this.m_Camera.m_CurCamera
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
plan.intersectRay(raycaster.ray, pt, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WorldToScreen(pt: THREE.Vector3)
|
|
|
|
WorldToScreen(pt: THREE.Vector3)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.m_Camera.m_CurCamera.updateMatrix();
|
|
|
|
let widthHalf = this.m_HtmlElement.scrollWidth * 0.5;
|
|
|
|
pt.applyMatrix4(this.m_Camera.m_CurCamera.matrixWorldInverse);
|
|
|
|
let heightHalf = this.m_HtmlElement.scrollHeight * 0.5;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pt.project(this.m_Camera.m_CurCamera);
|
|
|
|
|
|
|
|
|
|
|
|
pt.multiplyScalar(this.m_HtmlElement.scrollHeight / this.m_ViewHeight)
|
|
|
|
pt.x = (pt.x * widthHalf) + widthHalf;
|
|
|
|
pt.y *= -1
|
|
|
|
pt.y = - (pt.y * heightHalf) + heightHalf;
|
|
|
|
pt.x += this.m_HtmlElement.scrollWidth * 0.5;
|
|
|
|
|
|
|
|
pt.y += this.m_HtmlElement.scrollHeight * 0.5;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onSize = (width?, height?) =>
|
|
|
|
onSize = (width?, height?) =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|