|
|
|
@ -19,6 +19,9 @@ export class CursorViewer
|
|
|
|
|
m_LastEntity: THREE.Object3D;
|
|
|
|
|
m_LastIndex: number;
|
|
|
|
|
|
|
|
|
|
private m_Width:number;
|
|
|
|
|
private m_Height:number;
|
|
|
|
|
|
|
|
|
|
//容器节点
|
|
|
|
|
private m_DomEl: HTMLElement;
|
|
|
|
|
constructor(container: HTMLElement)
|
|
|
|
@ -28,7 +31,7 @@ export class CursorViewer
|
|
|
|
|
this.InitCamera();
|
|
|
|
|
this.InitRender();
|
|
|
|
|
this.InitCursor();
|
|
|
|
|
this.SetSize(container.scrollWidth, container.scrollHeight);
|
|
|
|
|
this.onSize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get Scene() { return this.m_Scene; }
|
|
|
|
@ -37,14 +40,10 @@ export class CursorViewer
|
|
|
|
|
private InitCamera()
|
|
|
|
|
{
|
|
|
|
|
this.m_Camera = new CameraControl();
|
|
|
|
|
this.m_Camera.ViewHeight = this.m_DomEl.scrollHeight;
|
|
|
|
|
this.m_Camera.SetSize(this.m_DomEl.scrollWidth, this.m_DomEl.scrollHeight);
|
|
|
|
|
this.m_Camera.ViewHeight = 1;
|
|
|
|
|
this.m_Camera.SetSize(1, 1);
|
|
|
|
|
this.m_Camera.Update();
|
|
|
|
|
}
|
|
|
|
|
onSize()
|
|
|
|
|
{
|
|
|
|
|
this.SetSize(this.m_DomEl.scrollWidth, this.m_DomEl.scrollHeight);
|
|
|
|
|
}
|
|
|
|
|
private InitRender()
|
|
|
|
|
{
|
|
|
|
|
let canvas = document.createElement("canvas");
|
|
|
|
@ -112,34 +111,28 @@ export class CursorViewer
|
|
|
|
|
*/
|
|
|
|
|
ScreenPointToViewerPoint(p: THREE.Vector3)
|
|
|
|
|
{
|
|
|
|
|
let width = this.m_DomEl.scrollWidth;
|
|
|
|
|
if (width % 2 == 1)
|
|
|
|
|
{
|
|
|
|
|
width -= 1;
|
|
|
|
|
}
|
|
|
|
|
let height = this.m_DomEl.scrollHeight;
|
|
|
|
|
if (height % 2 == 1)
|
|
|
|
|
{
|
|
|
|
|
height -= 1;
|
|
|
|
|
}
|
|
|
|
|
p.x = p.x - this.m_DomEl.scrollWidth * 0.5;
|
|
|
|
|
p.y = this.m_DomEl.scrollHeight * 0.5 - p.y;
|
|
|
|
|
p.x = p.x - this.m_Width * 0.5;
|
|
|
|
|
p.y = this.m_Height * 0.5 - p.y;
|
|
|
|
|
}
|
|
|
|
|
SetSize(width, height)
|
|
|
|
|
|
|
|
|
|
onSize()
|
|
|
|
|
{
|
|
|
|
|
if (width % 2 == 1)
|
|
|
|
|
this.m_Width = this.m_DomEl.scrollWidth;
|
|
|
|
|
this.m_Height = this.m_DomEl.scrollHeight;
|
|
|
|
|
if (this.m_Width % 2 == 1)
|
|
|
|
|
{
|
|
|
|
|
width -= 1;
|
|
|
|
|
this.m_Width -= 1;
|
|
|
|
|
}
|
|
|
|
|
if (height % 2 == 1)
|
|
|
|
|
if (this.m_Height % 2 == 1)
|
|
|
|
|
{
|
|
|
|
|
height -= 1;
|
|
|
|
|
this.m_Height -= 1;
|
|
|
|
|
}
|
|
|
|
|
this.m_Camera.SetSize(width, height);
|
|
|
|
|
this.m_Camera.ViewHeight = height;
|
|
|
|
|
|
|
|
|
|
this.m_Camera.SetSize(this.m_Width, this.m_Height);
|
|
|
|
|
this.m_Camera.ViewHeight = this.m_Height;
|
|
|
|
|
this.m_Camera.Update();
|
|
|
|
|
|
|
|
|
|
this.m_Render.setSize(width, height);
|
|
|
|
|
this.m_Render.setSize(this.m_Width, this.m_Height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HideCursor()
|
|
|
|
|