I’ve seen a lot of people looking for ways to performantly render the workspace to a ViewportFrame. So I made ViewportRender!
Concepts
ViewportRender has a few classes built in.
Camera
- The most important class. It contains a camera tracker which can track existing cameras (the default camera which it tracks is workspace.CurrentCamera)
Plugin
- A basic plugin. It contains an OnCamera BindableEvent which is fired when a camera is created.
Tracking
Let’s say you want to make a copy of the player’s default camera. Well you can use the Track
function of a ViewportRender Camera! Track accepts two arguments: targetCamera
and offset
.
targetCamera
- The target camera to track (default will be workspace.CurrentCamera)
offset
- A cframe which represents the offset from the target camera that the tracker should render.
To make a camera start rendering the workspace you can call Camera:Run()
. The workspace should be copied into Camera.Frame
.
Plugins
ViewportRender has a simple Plugin API allowing for render modules.
Install
will require a module and call Inject
with the return value
Inject
will inject a table which should contain any plugin info such as the OnCamera event.
I’m open to any feedback on this project! It’s in a bit of an early state right now.