mirror of https://gitee.com/cf-fz/WebCAD.git
!2925 优化:点选复合实体时,右侧栏材质单独显示子实体的材质
parent
4bbc3e9067
commit
f4b6cce59b
@ -0,0 +1,44 @@
|
||||
import { Vector3 } from "three";
|
||||
import { app } from "../ApplicationServices/Application";
|
||||
import { ApplyMtlToSelectedObjs, ApplyPartMtlToInterFace } from "../Common/ApplyMaterial";
|
||||
import { GetEntity } from "../Common/Utils";
|
||||
import { PhysicalMaterialRecord } from "../DatabaseServices/PhysicalMaterialRecord";
|
||||
import { CommandWrap } from "../Editor/CommandMachine";
|
||||
import { GenerateRaycaster, PointPick, Raycast } from "../Editor/PointPick";
|
||||
import { userConfig } from "../Editor/UserConfig";
|
||||
|
||||
export async function DropMaterialApply(pt: Vector3, getMtlFunction: () => Promise<PhysicalMaterialRecord>)
|
||||
{
|
||||
let raycaster = GenerateRaycaster(pt, app.Viewer);
|
||||
let intersection = Raycast(raycaster, app.Viewer.VisibleObjects, { filterErase: true });
|
||||
if (intersection && intersection.object)
|
||||
{
|
||||
if (intersection.face?.materialIndex !== undefined)
|
||||
{
|
||||
let obj = intersection.object;
|
||||
let en = GetEntity(obj);
|
||||
|
||||
await CommandWrap(async () =>
|
||||
{
|
||||
let mtl = await getMtlFunction();
|
||||
if (!mtl) return;
|
||||
|
||||
ApplyPartMtlToInterFace(mtl, en, intersection, raycaster);
|
||||
}, "拽拖材质应用");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let selectObj = PointPick(pt, app.Viewer, { filterErase: true }, app.Viewer.VisibleObjects, userConfig.cursorSize.SquareSize);
|
||||
if (selectObj.length > 0)
|
||||
{
|
||||
CommandWrap(async () =>
|
||||
{
|
||||
let mtl = await getMtlFunction();
|
||||
if (!mtl) return;
|
||||
|
||||
ApplyMtlToSelectedObjs(mtl, selectObj, raycaster);
|
||||
}, "拽拖材质应用");
|
||||
}
|
||||
}
|
Loading…
Reference in new issue