You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en-us/reference/engine/classes/EditableMesh.yaml
+41-27Lines changed: 41 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -5,38 +5,42 @@ memory_category: Instances
5
5
summary: |
6
6
Instance which allows for the runtime creation and manipulation of meshes.
7
7
description: |
8
-
`EditableMesh` changes the applied visual mesh when linked to a
8
+
`Class.EditableMesh` changes the applied visual mesh when linked to a
9
9
`Class.MeshPart`, allowing for querying and modification of the mesh both in
10
10
Studio and in experience.
11
11
12
-
An `EditableMesh` can be created from an existing `Datatype.Content` of a
12
+
An `Class.EditableMesh` can be created from an existing `Datatype.Content` of a
13
13
`Class.MeshPart` or a mesh ID using
14
-
`Class.AssetService:CreateEditableMeshAsync()`, or a blank `EditableMesh` can
14
+
`Class.AssetService:CreateEditableMeshAsync()`, or a blank `Class.EditableMesh` can
15
15
be created with `Class.AssetService:CreateEditableMesh()`. It can then be
16
16
displayed, modified, and its collision model updated. Not all of the steps are
17
-
necessary; for example, you might want to create an `EditableMesh` just to
17
+
necessary; for example, you might want to create an `Class.EditableMesh` just to
18
18
raycast without ever displaying it.
19
19
20
-
An `EditableMesh` is displayed when it's linked to a new `Class.MeshPart`,
20
+
An `Class.EditableMesh` is displayed when it's linked to a new `Class.MeshPart`,
21
21
through `Class.AssetService:CreateMeshPartAsync()`. You can create more
22
-
`Class.MeshPart` instances that reference the same `EditableMesh` content, or
22
+
`Class.MeshPart` instances that reference the same `Class.EditableMesh` content, or
23
23
link to an existing `Class.MeshPart` through `Class.MeshPart:ApplyMesh()`.
24
24
25
-
Calling `Class.AssetService:CreateMeshPartAsync()` will recalculate collision
26
-
and fluid geometry with any edits and update the existing `Class.MeshPart`. It
27
-
is generally recommended to do this at the end of a conceptual edit operation.
28
-
`Class.MeshPart:ApplyMesh()` will update the colission and fluid geometry of
29
-
the target `Class.MeshPart`.
25
+
To recalculate collision and fluid geometry after editing, you can again call
26
+
`Class.AssetService:CreateMeshPartAsync()` and `Class.MeshPart:ApplyMesh()`
27
+
to update an existing `Class.MeshPart`. It's generally recommended to do this
28
+
at the end of a conceptual edit, not after individual calls to methods that
29
+
manipulate geometry. Visual changes to the mesh will always be immediately
30
+
reflected by the engine, without the need to call
31
+
`Class.AssetService:CreateMeshPartAsync()`.
30
32
31
-
#### Enabling EditableMesh for Published Experiences
33
+
##### Enabling EditableMesh for Published Experiences
34
+
32
35
For security purposes, using `Class.EditableMesh` fails by default for published
33
-
experiences. To enable the use
34
-
of `Class.EditableMesh`, you must be 13+ age verified and ID verified. After you are
35
-
verified, open Studio. Select **File > Game Settings > Security** and enable the
36
-
**AllowMesh & ImageAPIs** toggle. Remember to review the Terms of Use before
37
-
enabling the toggle.
36
+
experiences. To enable usage, `Class.EditableMesh`, you must be 13+ age verified
37
+
and ID verified. After you are verified, open Studio's
38
+
[Game Settings](../../../studio/game-settings.md), select **Security**, and
39
+
enable the **Allow Mesh & Image APIs** toggle. Remember to
40
+
review the [Terms of Use](https://en.help.roblox.com/hc/en-us/articles/115004647846-Roblox-Terms-of-Use#creators-restrictions-on-use) before enabling the toggle.
38
41
39
-
#### Permissions
42
+
##### Permissions
43
+
40
44
To prevent misuse, `Class.AssetService:CreateEditableMeshAsync()` will only
41
45
allow you to load and edit mesh assets:
42
46
@@ -48,22 +52,30 @@ description: |
48
52
49
53
The APIs throw an error if they are used to load an asset that does
50
54
not meet the criteria above.
55
+
56
+
##### Fixed-Size Meshes
51
57
52
-
#### Stable Vertex/Face IDs
58
+
When creating an `Class.EditableMesh` from an existing mesh asset (via
59
+
`Class.AssetService:CreateEditableMeshAsync()`), the resulting editable mesh
60
+
is fixed-size by default. Fixed-size meshes are more efficient in terms of memory
61
+
but you cannot change the number of vertices, faces, or attributes. Only the values
62
+
of vertex attributes and positions can be edited.
53
63
54
-
Many `EditableMesh` methods take **vertex**, **normal**, **UV**, **color** and
64
+
##### Stable Vertex/Face IDs
65
+
66
+
Many `Class.EditableMesh` methods take **vertex**, **normal**, **UV**, **color** and
55
67
**face** IDs. These are represented as integers in Luau but they require some
56
68
special handling. The main difference is that IDs are stable and they remain
57
69
the same even if other parts of the mesh change. For example, if an
58
-
`EditableMesh` has five vertices `{1, 2, 3, 4, 5}` and you remove vertex `4`,
70
+
`Class.EditableMesh` has five vertices `{1, 2, 3, 4, 5}` and you remove vertex `4`,
59
71
the new vertices will be `{1, 2, 3, 5}`.
60
72
61
73
Note that the IDs are not guaranteed to be in order and there may be holes in
62
74
the numbering, so when iterating through vertices or faces, you should iterate
63
75
through the table returned by `Class.EditableMesh:GetVertices()|GetVertices()`
64
76
or `Class.EditableMesh:GetFaces()|GetFaces()`.
65
77
66
-
#### Split Vertex Attributes
78
+
##### Split Vertex Attributes
67
79
68
80
A **vertex** is a corner of a face, and topologically connects faces together.
69
81
Vertices can have several attributes: position, normal, UV coordinate, color,
@@ -120,7 +132,7 @@ description: |
120
132
end
121
133
```
122
134
123
-
#### Winding
135
+
##### Winding
124
136
125
137
Mesh faces have a front side and a back side. When drawing meshes, only the
126
138
front of the faces are drawn by default, although you can change this by
@@ -132,9 +144,9 @@ description: |
132
144
133
145
<img src="../../../assets/engine-api/classes/EditableMesh/Winding.png" alt="Order of the vertices around the face" width="550" />
134
146
135
-
#### Limitations
147
+
##### Limitations
136
148
137
-
`EditableMesh` currently has a limit of 60,000 vertices and 20,000 triangles.
149
+
`Class.EditableMesh` currently has a limit of 60,000 vertices and 20,000 triangles.
138
150
Attempting to add too many vertices or triangles will cause an error.
139
151
code_samples: []
140
152
inherits:
@@ -308,8 +320,10 @@ methods:
308
320
capabilities: []
309
321
writeCapabilities: []
310
322
- name: EditableMesh:Destroy
311
-
summary: ''
312
-
description: ''
323
+
summary: |
324
+
Destroys the mesh.
325
+
description: |
326
+
Destroys the contents of the mesh, immediately reclaiming used memory.
0 commit comments