Editable Mesh
*Ta zawartość została przetłumaczona przy użyciu narzędzi AI (w wersji beta) i może zawierać błędy. Aby wyświetlić tę stronę w języku angielskim, kliknij tutaj.
Podsumowanie
Metody
Członkowie odziedziczeni
6 odziedziczonych od: Object
Materiały referencyjne dotyczące interfejsów API
Właściwości
Metody
Add Bone
Parametry
Zwroty
Add Color
Add Triangle
Batch Add
Parametry
Zwroty
Batch Get Face Attributes
Parametry
Zwroty
Batch Get Vertex Attributes
Parametry
Zwroty
Batch Get Vertex Face Attributes
Editable Mesh: Batch Get Vertex Face Attributes(
Parametry
Zwroty
Batch Set Face Attributes
Batch Set Values
Batch Set Vertex Face Attributes
Clear
Editable Mesh: Clear():()
Zwroty
()
Destroy
Editable Mesh: Destroy():()
Zwroty
()
Find Closest Point On Surface
Find Closest Vertex
Find Vertices Within Sphere
Get Adjacent Vertices
Get Bone Is Virtual
Get Faces With Attribute
Get Faces With Color
Get Faces With Normal
Get Facs Corrective Pose
Get Facs Pose
Parametry
Zwroty
Get Vertex Bone Weights
Get Vertex Colors
Get Vertex Face Color
Get Vertex Face Normal
Get Vertex Face UV
Get Vertex Normals
Get Vertices With Attribute
Get Vertices With Color
Get Vertices With Normal
Merge Vertices
Raycast Local
Zwroty
Przykłady kodu
EditableMesh:RaycastLocal()
local AssetService = game:GetService("AssetService")
local Workspace = game:GetService("Workspace")
-- Inicjalizuj EditableMesh w przestrzeni
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
-- Funkcja, która rzuci promień z danego punktu, zwracając punkt trafienia w świecie i współrzędną UV
local function castRayFromCamera(meshPart: MeshPart, editableMesh: EditableMesh, viewportPoint: Vector3)
if not meshPart then
return
end
-- Oblicz, jak bardzo obiekt jest skalowany w każdym wymiarze
local renderScale = meshPart.Size / meshPart.MeshSize
-- Utwórz promień z kamery w kierunku klikniętego punktu
local ray = Workspace.CurrentCamera:ViewportPointToRay(viewportPoint.X, viewportPoint.Y)
-- Przekształć do przestrzeni obiektu, aby użyć z 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
-- Nie trafił w żadne powierzchnie
return
end
-- Oblicz punkt trafienia w przestrzeni świata
local worldHitPoint = meshPart.CFrame:PointToWorldSpace(point * renderScale)
-- Pobierz UV na powierzchni
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)
-- Interpoluj UV w obrębie powierzchni na podstawie współrzędnej barycentrycznej
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 Name
Set Bone Parent
Set Color
Set Color Alpha
Set Face Colors
Set Face Normals
Set Face U Vs
Set Face Vertices
Set Facs Bone Pose
Parametry
Zwroty
()
Set Facs Corrective Pose
Set Facs Pose
Parametry
Zwroty
()
Set Normal
Set Position
Set Vertex Bones
Set Vertex Bone Weights
Set Vertex Face Color
Set Vertex Face Normal
Set Vertex Face UV
Triangulate
Editable Mesh: Triangulate():()
Zwroty
()