Skip to content

SurfaceView

Class ยท server and client scripts

SurfaceView shows what a camera sees, a portal or a mirror on one face of a part. Add SurfaceView to a part with ViewMode = "Portal" or ViewMode = "Mirror" to configure its ViewMode.

Example

-- Server script in a part: link it with a new part as a two-way portal.
local exit = World.Spawn({ Shape = "Box", Body = { Motion = "Static" } })
exit.Position = (self.Position or Vector3.Zero) + Vector3.new(0, 0, 40)
exit.Parent = World
local here = World.Spawn({
    Shape = "Box",
    SurfaceView = { ViewMode = "Portal", ViewTarget = exit },
})
here.Parent = self
local back = World.Spawn({
    Shape = "Box",
    SurfaceView = { ViewMode = "Portal", ViewTarget = self },
})
back.Parent = exit

ViewMode

Property
ViewMode: SurfaceViewMode

ViewMode is what the face shows: "Camera" shows what the ViewTarget camera sees, "Portal" shows the world as seen out of a face of the ViewTarget part, and "Mirror" shows the world reflected in the face.

Default "Camera"

ViewTarget

Property
ViewTarget: Entity?

ViewTarget is the camera a "Camera" view shows, or what a "Portal" view looks out of: a part, which uses this view's ViewFace, or a SurfaceView on a part, which uses its own ViewFace. With ViewTarget nil, a "Camera" or "Portal" view shows nothing; a "Mirror" view ignores ViewTarget.

Default nil

ViewFace

Property
ViewFace: Face

ViewFace is the face of the part that shows the view: "Right" (+X), "Top" (+Y), "Back" (+Z), "Left" (-X), "Bottom" (-Y) or "Front" (-Z).

Default "Front"

ViewWidth

Property
ViewWidth: number

ViewWidth is the width in pixels of a "Portal" or "Mirror" image, up to 2048; 0 sizes it to the screen.

Default 0

ViewHeight

Property
ViewHeight: number

ViewHeight is the height in pixels of a "Portal" or "Mirror" image, up to 2048; 0 sizes it to the screen.

Default 0

ViewDistance

Property
ViewDistance: number

ViewDistance is how far from the viewer, in world units, the surface view draws; past it the face shows nothing and costs no rendering. 0 draws it at any distance.

Default 200