MeshPart

顯示已棄用項目

*此內容很快就會推出您所選的語言版本。

MeshPart is a form of BasePart that includes a physically simulated custom mesh. Unlike with other mesh classes, such as SpecialMesh and BlockMesh, they are not parented to a BasePart but rather behave as a BasePart in their own right.

The mesh and texture of a MeshPart are determined by the MeshId and TextureID properties. For more information, see Meshes.

概要

屬性

屬性 繼承自 TriangleMeshPart屬性 繼承自 BasePart屬性 繼承自 PVInstance

方法

方法 繼承自 BasePart方法 繼承自 PVInstance

活動

活動 繼承自 BasePart

屬性

DoubleSided

平行讀取
外掛程式安全性

This property determines whether to render both faces of polygons in the mesh. It is only changeable in Studio. This is useful for meshes that are typically modeled as "cards" such as a leaf, hair, or cloth.

HasJointOffset

隱藏
平行讀取
無法存取安全性

HasSkinnedMesh

隱藏
平行讀取
無法存取安全性

JointOffset

隱藏
平行讀取
無法存取安全性

MeshContent

隱藏
平行讀取
無法存取安全性

The mesh that is displayed on the MeshPart. Supports asset URIs and EditableMesh objects.

Note that this property cannot be changed directly by scripts, as the collision geometry of the mesh cannot be recomputed in realtime. See AssetService:CreateMeshPartAsync() as a method to create a new MeshPart from a given Content with a specified CollisionFidelity. MeshPart:ApplyMesh() can be used to overwrite the MeshContent, TextureContent, and collision geometry of an existing MeshPart.

MeshId

ContentId
平行讀取
無法存取安全性

The asset URIs of the mesh that is displayed on the MeshPart. Reads and writes to MeshContent.

Note that this property cannot be changed directly by scripts, as the collision geometry of the mesh cannot be recomputed in realtime. See AssetService:CreateMeshPartAsync() as a method to create a new MeshPart from a given Content with a specified CollisionFidelity. MeshPart:ApplyMesh() can be used to overwrite the MeshContent, TextureContent, and collision geometry of an existing MeshPart.

RenderFidelity

未複製
平行讀取
外掛程式安全性

This property determines the level of detail that the MeshPart will be shown in. It can be set to the possible values of the Enum.RenderFidelity enum.

The default value is Automatic, meaning the mesh's detail is based on its distance from the camera as outlined in the following table.

Distance From CameraRender FidelityExample
Less than 250 studsHighest
250-500 studsMedium
500 or more studsLowest

TextureContent

隱藏
平行讀取

The texture applied to the MeshPart. Supports asset URIs and EditableImage objects.

When this property is set to Content.none, no texture will be applied to the mesh.


local Workspace = game:GetService("Workspace")
local meshPart = Workspace.MeshPart
meshPart.TextureContent = Content.none -- No texture

Note that the MeshContent property cannot be directly changed during runtime but the texture can.

Changing a Mesh Texture

Using the TextureContent property, the texture of a mesh can be changed without having to re-upload the mesh. To do this, a new image can be uploaded to Roblox with the desired texture. The original texture image file can be obtained by exporting the mesh using the Export Selection option in Studio. The image file will be saved alongside the exported .obj file.

The new texture can then be uploaded to Roblox as a decal and its asset URI can be applied to the mesh using the TextureContent or TextureID property.

TextureContent can also be set to reference an EditableImage that has not been published yet.


local AssetService = game:GetService("AssetService")
local Workspace = game:GetService("Workspace")
local meshPart = Workspace.MeshPart
local editableImage = AssetService:CreateEditableImageAsync(meshPart.TextureContent)
meshPart.TextureContent = Content.fromObject(editableImage) -- Live updates

When TextureContent references an EditableImage, the texture will live update with any edits to the EditableImage object.

Making a Textured Mesh

A mesh can only be textured if the mesh has been UV mapped, referring to the practice of projecting a texture map onto a mesh. This cannot be done using Roblox Studio and must be done using an external 3D modeling application such as Blender.

TextureID

ContentId
平行讀取

The texture applied to the MeshPart. Reads and writes to TextureContent.

When this property is set to an empty string, no texture will be applied to the mesh.


local Workspace = game:GetService("Workspace")
local meshPart = Workspace.MeshPart
meshPart.TextureID = "" -- No texture

Note that the MeshPart.MeshId property cannot be changed during runtime but the texture can. See TextureContent for details.

方法

ApplyMesh

void

Overwrites the MeshContent, TextureContent, and collision geometry properties of this MeshPart from the given source meshPart.

Most of these properties are read-only and cannot be changed during runtime on their own directly. To keep MeshContent and physics data in sync, they must be updated together.

Copies the following properties:

參數

meshPart: Instance

返回

void

活動