调整选择板代码
This commit is contained in:
parent
35347e004e
commit
caa39923dd
20
src/Utils.ts
20
src/Utils.ts
@ -36,23 +36,3 @@ export function LoadBoard(view: Viewer, data: any[], clear: boolean = true)
|
||||
|
||||
return relations;
|
||||
}
|
||||
|
||||
export function SelectBlock(view: Viewer, blockMeshMap: Map<number, number>, dataID: number)
|
||||
{
|
||||
if (blockMeshMap.has(dataID))
|
||||
{
|
||||
let meshId = blockMeshMap.get(dataID);
|
||||
view.m_Scene.children.forEach(obj =>
|
||||
{
|
||||
if (obj instanceof Mesh)
|
||||
{
|
||||
if (obj.id == meshId)
|
||||
{
|
||||
obj.material = selectMaterial;
|
||||
view.m_bNeedUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -37,18 +37,9 @@ export class Viewer
|
||||
this.OnSize();
|
||||
});
|
||||
|
||||
let oldMesh: Mesh;
|
||||
this.m_Render.domElement.addEventListener("mousemove", (e: MouseEvent) =>
|
||||
{
|
||||
let mesh = PointPick(this, e.offsetX, e.offsetY);
|
||||
if (oldMesh)
|
||||
oldMesh.material = boardMaterial;
|
||||
if (mesh && mesh.material !== ColorMaterial.GetBasicMaterial(1))
|
||||
{
|
||||
oldMesh = mesh;
|
||||
mesh.material = selectMaterial;
|
||||
}
|
||||
this.m_bNeedUpdate = true;
|
||||
this.SelectByPoint(e.offsetX, e.offsetY);
|
||||
})
|
||||
}
|
||||
|
||||
@ -196,4 +187,39 @@ export class Viewer
|
||||
this.m_Camera.LookAt(new Vector3(1, 1, -1));
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
|
||||
oldMesh: Mesh;
|
||||
SelectByPoint(x: number, y: number)
|
||||
{
|
||||
let mesh = PointPick(this, x, y);
|
||||
if (this.oldMesh)
|
||||
this.oldMesh.material = boardMaterial;
|
||||
if (mesh && mesh.material !== ColorMaterial.GetBasicMaterial(1))
|
||||
{
|
||||
this.oldMesh = mesh;
|
||||
mesh.material = selectMaterial;
|
||||
}
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
SelectBlock(blockMeshMap: Map<number, number>, dataID: number)
|
||||
{
|
||||
if (blockMeshMap.has(dataID))
|
||||
{
|
||||
let meshId = blockMeshMap.get(dataID);
|
||||
if (this.oldMesh)
|
||||
this.oldMesh.material = boardMaterial;
|
||||
this.m_Scene.children.forEach(obj =>
|
||||
{
|
||||
if (obj instanceof Mesh)
|
||||
{
|
||||
if (obj.id == meshId)
|
||||
{
|
||||
obj.material = selectMaterial;
|
||||
this.m_bNeedUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user