Can we get a simple, toned down script examples in the hub for each of the API. Just trying to create a simple mesh is super confused? The way it’s worded, this
local AssetService = game:GetService("AssetService")
local EditableMesh = AssetService:CreateEditableMesh()
local MeshPart = AssetService:CreateMeshPartAsync(EditableMesh) -- ?
CreateMeshPartAsync sounds like it creates a MeshPart, but I get unable to cast Object to Content? First sentence
To me implies that the EditableMesh is what I put inside the CreateMeshPartAsync?
And even example code provided is confusing
To me, I’d imagine I should be able to just copy/paste from the hub and press play and it’d work, but the function never gets called and I have no clue how to actually attribute the EditableMesh to a mesh part
See, I read the hub as this? Like what is MeshContent?
AssetService:CreateMeshPartAsync(makeSharpCube())
Like can anyone just provide simple code for creating a flat plane, or a cube. That I can copy/paste into studio and play and have it work right there? Cause nothing here is working in studio for me and I can’t figure it out myself
local AssetService = game:GetService("AssetService")
local myMeshPart = workspace:FindFirstChildWhichIsA("MeshPart")
local myEditableMesh = AssetService:CreateEditableMesh()
local v1 = myEditableMesh:AddVertex(Vector3.new(0, 0, 0))
local v2 = myEditableMesh:AddVertex(Vector3.new(1, 0, 0))
local v3 = myEditableMesh:AddVertex(Vector3.new(0, 1, 0))
local v4 = myEditableMesh:AddVertex(Vector3.new(1, 1, 0))
local v5 = myEditableMesh:AddVertex(Vector3.new(0, 0, 1))
local v6 = myEditableMesh:AddVertex(Vector3.new(1, 0, 1))
local v7 = myEditableMesh:AddVertex(Vector3.new(0, 1, 1))
local v8 = myEditableMesh:AddVertex(Vector3.new(1, 1, 1))
-- Helper method to compute extents of a Mesh. This will eventually
-- be replaced with a direct getter method on EditableMesh
local function computeExtents(em: EditableMesh)
local verts = em:GetVertices()
if #verts == 0 then
return Vector3.zero
end
local inf = math.huge
local min = Vector3.new(inf, inf, inf)
local max = Vector3.new(-inf, -inf, -inf)
for _, id in verts do
local v = em:GetPosition(id)
min = min:Min(v)
max = max:Max(v)
end
return max - min
end
-- Create a new MeshPart instance linked to this EditableMesh Content
-- Note: EditableMesh:CreateMeshPartAsync will be replaced with
-- AssetService:CreateMeshPartAsync(Content, …) before public release
local newMeshPart = myEditableMesh:CreateMeshPartAsync(computeExtents(myEditableMesh))
-- Apply newMeshPart which is linked to the EditableMesh onto myMeshPart
myMeshPart:ApplyMesh(newMeshPart)
-- Any changes to myEditableMesh will now live update on myMeshPart
local vertexId = myEditableMesh:GetVertices()[1]
myEditableMesh:SetPosition(vertexId, Vector3.one)
-- You can create more MeshPart instances that reference the same
-- EditableMesh content
local newMeshPart2 = myEditableMesh:CreateMeshPartAsync(computeExtents(myEditableMesh))
-- Drop newMeshPart2 under workspace to render it
newMeshPart2.parent = workspace
-- Any changes to myEditableMesh will now live update on both
-- myMeshPart and newMeshPart2
myEditableMesh:SetPosition(vertexId, Vector3.one*2)
-- Calling these two lines again will recalculate collision and fluid geometry
-- with a snapshot of the current edits and update myMeshPart.
-- It is generally recommended to do this at the end of a conceptual edit operation.
-- Note: EditableMesh:CreateMeshPartAsync will be replaced with
-- AssetService:CreateMeshPartAsync(Content, …) before public release
local newMeshPart = myEditableMesh:CreateMeshPartAsync(computeExtents(myEditableMesh))
myMeshPart:ApplyMesh(newMeshPart)
Invalid mesh. Cannot create a MeshPart from an empty mesh. Mesh has no faces. - Server - Script:35
like what am I doing wrong… it has faces, I create vertices, thus it should have faces??