Issue:
After creating a new EditableMesh based off of an existing mesh, attempting to use :ApplyMesh(EditableMesh) on a 2nd already existing mesh yields an “Unable to cast value to Object” error.
Context:
For one of my games, I have a surfing system with customizable surfboards. I wanted to add placeable decals to them, which means using editable meshes. According to the documentation, we should be able to use :ApplyMesh() to update existing meshes. Seeing as surfboards are things that players have to interact with, those meshes will be pre-existing in the workspace and, as such, need the use of :ApplyMesh().
To test the feasibility of this, I decided to have one such preexisting mesh loop through several others (simulating the player scrolling through different surfboards) by first creating a new EditableMesh based off of the other surfboard models hidden in ReplicatedStorage, then applying it to the workspace Mesh using Mesh:ApplyMesh(EditableMesh), and then projecting an image onto that. It was during this that I ran into the error described above.
EditableMesh_Error.rbxl (100.8 KB)
11-3D-Longboard.obj (60.7 KB)
5-9P-Shortboard.obj (60.7 KB)
6-2A-Fishboard.obj (60.5 KB)
Attached is an isolated case of the described error with the scenario described above. Additionally, I’ve attached the .obj mesh files referenced by the MeshParts in ReplicatedStorage.
Expected behavior
In theory, EditableMesh made from AssetService:CreateEditableMeshAsync(newMesh.MeshContent)
should be a valid input to :ApplyMesh()
and have the MeshPart in question update to look like the new mesh.