3D ViewportFrame Script

I’ve scripted a way to enable Viewport 3D support automatically, easily and quickly. Programming/scripting knowledge isn’t required in order to do so.

The way I achieved this is pretty simple: Assign the SurfaceGui adornee to the part I want it to render on and move it to StarterGui.

But then there is an issue. You have to create a script to in a loop (or at RenderStepped) to be able to assign the instance properties to the latest values, add or remove parts from the Viewport. Then there’s also the issue of the clutter it becomes with too many ViewportFrames.

The solution. The script I made does all of this automatically for anyone. It’s a quick, easy and efficient way to update data in real-time. It supports BaseParts, Players, and Attachments right now. I plan on adding more things into it later (such as lights).

It is free and open-source, so feel free to use it in your places, but don’t forget to check the READ ME local script!

Click here to go to the model.

I’ve also made a small demo place for this, so you may test it out before taking anything.

Notes:
The template part has a bool value inside named “Enable 3D Viewport”. This is the BoolValue the local script looks for while scanning for the GUIs. If set to true, it will enable the viewport, and if not, it won’t.
There are three ways of defining the location to render at:
Focus: An ObjectValue with the value of a part. Position and Orientation are of the part.
CFrame: A CFrameValue. Gets the data straight away.
Position and Orientation: Two Vector3Values that represent respectively the Position and Orientation of the camera.

You can modify the SurfaceGui and the ViewportFrame as you wish (and you can even use a BillboardGui instead!); make sure the ViewportFrame is inside the Surface/BillboardGui.

Maximum Render Distance: This magnitude maximum was made to prevent frame drops and too much CPU usage coming from many parts being rendered and calculated at once. Default is 50.
Immersive: Sets wether or not the ViewportFrame Camera should be influenced by the local camera’s orientation.

image

9 Likes