Editable Mesh
요약
메서드
상속된 멤버
API 참조
속성
메서드
Add Color
Add Triangle
Batch Add
매개 변수
반환
Batch Get Face Attributes
매개 변수
반환
Batch Get Vertex Attributes
매개 변수
반환
Batch Get Vertex Face Attributes
Editable Mesh: Batch Get Vertex Face Attributes(
매개 변수
반환
Batch Set Face Attributes
Batch Set Vertex Face Attributes
Clear
Editable Mesh: Clear():()
반환
()
Destroy
Editable Mesh: Destroy():()
반환
()
Find Closest Point On Surface
Find Closest Vertex
Find Vertices Within Sphere
Get Adjacent Vertices
Get Faces With Attribute
Get Facs Corrective Pose
Get Facs Pose
Get Vertex Bone Weights
Get Vertex Face Color
Get Vertex Face Normal
Get Vertex Face UV
Get Vertices With Attribute
Get Vertices With Color
Get Vertices With Normal
Raycast Local
반환
코드 샘플
EditableMesh:RaycastLocal()
local AssetService = game:GetService("AssetService")
local Workspace = game:GetService("Workspace")
-- 공간에서 EditableMesh 초기화
local editableMesh = nil
local success, errorMsg = pcall(function()
editableMesh = AssetService:CreateEditableMeshAsync(Content.fromUri("rbxassetid://ASSET_ID"))
end)
local meshPart = nil
if success and editableMesh then
meshPart = AssetService:CreateMeshPartAsync(
Content.fromObject(editableMesh),
{ CollisionFidelity = Enum.CollisionFidelity.Hull }
)
meshPart.Parent = Workspace
else
warn(errorMsg)
end
-- 주어진 지점에서 레이를 쏘고, 충돌한 세계 지점과 UV 좌표를 반환하는 함수
local function castRayFromCamera(meshPart: MeshPart, editableMesh: EditableMesh, viewportPoint: Vector3)
if not meshPart then
return
end
-- 각 차원에서 객체가 얼마나 스케일되고 있는지 계산
local renderScale = meshPart.Size / meshPart.MeshSize
-- 클릭한 지점의 방향으로 카메라에서 레이 생성
local ray = Workspace.CurrentCamera:ViewportPointToRay(viewportPoint.X, viewportPoint.Y)
-- RaycastLocal()에 사용하기 위해 객체 공간으로 변환
local relativeOrigin = meshPart.CFrame:PointToObjectSpace(ray.Origin) / renderScale
local relativeTarget = meshPart.CFrame:PointToObjectSpace(ray.Origin + ray.Direction * 100) / renderScale
local relativeDirection = relativeTarget - relativeOrigin
local faceId, point, barycentricCoordinate, vertId1, vertId2, vertId3 =
editableMesh:RaycastLocal(relativeOrigin, relativeDirection)
if not faceId then
-- 어떤 면에도 충돌하지 않음
return
end
-- 세계 공간에서의 충돌 지점 계산
local worldHitPoint = meshPart.CFrame:PointToWorldSpace(point * renderScale)
-- 면의 UV 가져오기
local uvId1 = editableMesh:GetVertexFaceUV(vertId1, faceId)
local uvId2 = editableMesh:GetVertexFaceUV(vertId2, faceId)
local uvId3 = editableMesh:GetVertexFaceUV(vertId3, faceId)
local uv1 = editableMesh:GetUV(uvId1)
local uv2 = editableMesh:GetUV(uvId2)
local uv3 = editableMesh:GetUV(uvId3)
-- 바리센트릭 좌표에 따라 면 내에서 UV 보간
local u = (barycentricCoordinate.x * uv1.x) + (barycentricCoordinate.y * uv2.x) + (barycentricCoordinate.z * uv3.x)
local v = (barycentricCoordinate.x * uv1.y) + (barycentricCoordinate.y * uv2.y) + (barycentricCoordinate.z * uv3.y)
return worldHitPoint, Vector2.new(u, v)
end
if meshPart and editableMesh then
local worldHitPoint, uv = castRayFromCamera(meshPart, editableMesh, Vector3.new(400, 300, 0))
print(worldHitPoint, uv)
endSet Bone C Frame
Set Bone Is Virtual
Set Bone Parent
Set Color Alpha
Set Face Normals
Set Face Vertices
Set Facs Bone Pose
매개 변수
반환
()
Set Facs Corrective Pose
Set Facs Pose
매개 변수
반환
()
Set Normal
Set Vertex Bones
Set Vertex Bone Weights
Set Vertex Face Color
Set Vertex Face Normal
Set Vertex Face UV
Triangulate
Editable Mesh: Triangulate():()
반환
()