エンジンクラス
EditableMesh
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
概要
方法
継承されたメンバー
Objectから継承された6
APIリファレンス
プロパティ
方法
AddBone
AddColor
AddTriangle
Destroy
EditableMesh:Destroy():()
戻り値
()
FindClosestPointOnSurface
FindClosestVertex
FindVerticesWithinSphere
GetAdjacentVertices
GetFacesWithAttribute
GetFacesWithNormal
GetFacsCorrectivePose
GetFacsPose
GetVertexBoneWeights
GetVertexFaceColor
GetVertexFaceNormal
GetVertexFaceUV
GetVerticesWithAttribute
GetVerticesWithColor
GetVerticesWithNormal
RaycastLocal
戻り値
コードサンプル
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)
endSetBoneCFrame
SetBoneIsVirtual
SetBoneName
SetBoneParent
SetColorAlpha
SetFaceColors
SetFaceNormals
SetFaceVertices
SetFacsBonePose
パラメータ
戻り値
()
SetFacsCorrectivePose
SetFacsPose
パラメータ
戻り値
()
SetNormal
SetPosition
SetVertexBones
SetVertexBoneWeights
SetVertexFaceColor
SetVertexFaceNormal
SetVertexFaceUV
Triangulate
EditableMesh:Triangulate():()
戻り値
()