Editable Mesh
概要
方法
継承されたメンバー
Objectから継承された6
APIリファレンス
プロパティ
方法
Add Bone
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 Values
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 Faces With Normal
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 Name
Set Bone Parent
Set Color Alpha
Set Face Colors
Set Face Normals
Set Face Vertices
Set Facs Bone Pose
パラメータ
戻り値
()
Set Facs Corrective Pose
Set Facs Pose
パラメータ
戻り値
()
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():()
戻り値
()