3D Texts lets staff put texts and pictures on the surfaces of the map.
They are placed and removed with the Text Tool and the Picture Placer of the tool gun, or
from code with SurfaceText:add_text and SurfaceText:add_picture. The server keeps
them in SurfaceText.texts and SurfaceText.pictures, saves them with the plugin data
and sends them to every client, which draws them in the world and fades them out with
distance.
Summary
Hooks
Methods
Hooks
Implements hook LoadData
Loads the stored 3D texts and pictures when the framework loads its data.
Implements hook PlayerInitialized
Sends all stored 3D texts and pictures to the player who has just initialized.
Parameters
- actor Player
Draws every placed 3D text and picture within fade range of the local player, plus a placement preview while the texts or pictures tool is equipped.
Parameters
- depth Boolean whether the depth pass is being drawn
- skybox Boolean whether the skybox is being drawn
Implements hook RegisterPermissions
Registers the 'texts' and 'pictures' level design permissions.
Implements hook SaveData
Saves the 3D texts and pictures when the framework saves its data.
Methods
Adds a 3D picture, saves it and broadcasts it to all clients. Serverside only. Does nothing unless url, width and height are all present.
SurfaceText:add_picture({
url = 'https://example.com/poster.png',
width = 512,
height = 512,
fade_offset = 0,
pos = trace.HitPos,
normal = trace.HitNormal,
angle = angle -- built the same way as for SurfaceText:add_text
})
Parameters
- data Map picture data: url, width, height, pos, normal, angle and optional fade_offset
Adds a 3D text, saves it and broadcasts it to all clients. Serverside only. Does nothing unless text, pos, angle, style and scale are all present.
local trace = actor:GetEyeTrace()
local angle = trace.HitNormal:Angle()
angle:RotateAroundAxis(angle:Forward(), 90)
angle:RotateAroundAxis(angle:Right(), 270)
SurfaceText:add_text({
text = 'Sample Text',
style = 5, -- 1 to 10, see the texts tool
scale = 1,
color = Color(255, 255, 255),
extra_color = Color(255, 0, 0, 100), -- background / shadow color
fade_offset = 0,
pos = trace.HitPos,
normal = trace.HitNormal,
angle = angle
})
Parameters
- data Map text data: text, style, scale, color, extra_color, pos, normal, angle and optional fade_offset
Draws a preview of the picture configured in the pictures tool at the spot the local player is looking at. A red box is drawn instead if the URL is not a png or jpg image.
Draws a translucent preview of the text configured in the texts tool at the spot the local player is looking at.
Reads the 3D texts and pictures from the plugin data storage, replacing the currently stored ones. Serverside only.
Asks the player's client to find the 3D picture they are looking at and request its removal. Serverside only; does nothing if the player lacks the 'pictures' permission.
Parameters
- actor Player
Asks the player's client to find the 3D text they are looking at and request its removal. Serverside only; does nothing if the player lacks the 'texts' permission.
Parameters
- actor Player
Writes all 3D texts and pictures to the plugin data storage. Serverside only.
Finds the 3D picture hit by the trace and asks the server to remove it. Clientside only.
Parameters
- trace Map trace result, e.g. from Player:GetEyeTraceNoCursor
Returns
- Boolean true if a picture was hit and its removal was requested
Finds the 3D text hit by the trace and asks the server to remove it. Clientside only.
Parameters
- trace Map trace result, e.g. from Player:GetEyeTraceNoCursor
Returns
- Boolean true if a text was hit and its removal was requested