Editable Mesh
Summary
Methods
Inherited Members
6 inherited from Object
API Reference
Properties
Methods
Add Bone
Parameters
Returns
Add Color
Add Triangle
Batch Add
Parameters
Returns
Batch Get Face Attributes
Parameters
Returns
Batch Get Vertex Attributes
Parameters
Returns
Batch Get Vertex Face Attributes
Editable Mesh: Batch Get Vertex Face Attributes(
Parameters
Returns
Batch Set Face Attributes
Batch Set Values
Batch Set Vertex Face Attributes
Clear
Editable Mesh: Clear():()
Returns
()
Destroy
Editable Mesh: Destroy():()
Returns
()
Find Closest Point On Surface
Find Closest Vertex
Find Vertices Within Sphere
Get Adjacent Faces
Get Adjacent Vertices
Get Bone By Name
Get Bone Is Virtual
Get Color Alpha
Get Faces With Attribute
Get Faces With Color
Get Faces With Normal
Get Facs Corrective Pose
Get Facs Pose
Parameters
Returns
Get Vertex Bones
Get Vertex Bone Weights
Get Vertex Colors
Get Vertex Face Color
Get Vertex Face Normal
Get Vertex Faces
Get Vertex Face UV
Get Vertex Normals
Get Vertices With Attribute
Get Vertices With Color
Get Vertices With Normal
Merge Vertices
Raycast Local
Returns
Code Samples
EditableMesh:RaycastLocal()
local AssetService = game:GetService("AssetService")
local Workspace = game:GetService("Workspace")
-- Initialize EditableMesh in space
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
-- Function that will cast a ray from the given point, returning the world point of the hit and the UV coordinate
local function castRayFromCamera(meshPart: MeshPart, editableMesh: EditableMesh, viewportPoint: Vector3)
if not meshPart then
return
end
-- Calculate how much the object is being scaled in each dimension
local renderScale = meshPart.Size / meshPart.MeshSize
-- Create ray from camera along the direction of a clicked point
local ray = Workspace.CurrentCamera:ViewportPointToRay(viewportPoint.X, viewportPoint.Y)
-- Convert to object space to use with 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
-- Didn't hit any faces
return
end
-- Compute the hit point in world space
local worldHitPoint = meshPart.CFrame:PointToWorldSpace(point * renderScale)
-- Get the UVs on the face
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)
-- Interpolate UVs within the face based on the barycentric coordinate
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
Parameters
Returns
()
Set Facs Corrective Pose
Set Facs Pose
Parameters
Returns
()
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():()
Returns
()