Size of model for viewport frame

Hello! I am trying to display all of a user’s limited items, but I am having trouble adjusting the viewport frame to get a good view of the limited. Also, I am using Module3D V6.

image

That was a result of trying to use :GetExtentsSize(). Doesn’t really work :frowning:

Anyone ever done this before, or have any idea what I should do? I tried searching but no luck.

Edit: Realized that GetExtentsSize doesn’t really work because some accessories have a really weird model size for no apparent reason.

Hopefully this can help you figure out what you need to do to your viewport frame’s camera.

You first need to get the model size, get the axis with the highest number so it will all fit, then multiply that number (which basically changes the distance that should stay consistent) until it all fits nicely, and then set your CFrame of your camera to what I did.

local Model = workspace.Model
local PrimaryPart = Model.PrimaryPart
local Camera = workspace.Camera -- Path to your camera

local Size = Model:GetExtentsSize() -- Get the extents size of the model

local LongestAxisSize = math.max(Size.X, Size.Y, Size.Z) -- Get the largest number whether it be the X, Y, or Z number.

local Distance = LongestAxisSize * 2 -- The higher the second number, the farther away the camera will be from the part.

-- Set the CFrame of the camera (Position, lookAt).
-- Position is a Vector3 value that decides where your camera will be at. I first set the base position then add the offset in the front direction of the primary part, then I multiply it by however much is needed.
-- lookAt is a Vector3 value that has your camera look at the Vector3 position.
Camera.CFrame = CFrame.new(PrimaryPart.Position + (PrimaryPart.CFrame.LookVector * LongestAxisSize * 2), PrimaryPart.Position)
1 Like

This will only work if Roblox would size their items appropriately though :frowning:

The dominus vesp model properly outlines the size of the hat, yet the Dominus formidulosus doesn’t.

You could create an exact copy of the hat using a MeshPart which will set the part’s size to what you need.

Left: Part with a SpecialMesh inside of it.
Right: MeshPart with the MeshId and TextureID properties set the same.

Wow, that actually does work. Going to try it out now :slight_smile:

1 Like

Ugh, apparently scripts cannot write to MeshId

I ran into this issue awhile back too but I’m not really sure what you could do unless if anyone else can come up with something better.

Perhaps you could create some kind of script to automate the process and run it in studio to collect all of the limiteds published by Roblox and then save it in ServerStorage and then change the size of every part to what you want it to be (or output if it works to replace them to MeshParts) then copy them to the client as needed?

This api page should work fine:
https://catalog.roblox.com/v1/search/items/details?Category=2&CreatorName=Roblox

It is limited to pages meaning you cannot view all the data at once. After getting the data from each page you can iterate to the next page from the ‘nextPageCursor’ at the beginning of the table.

Example: This would give you page two:
https://catalog.roblox.com/v1/search/items/details?Category=2&CreatorName=Roblox&Cursor=2_1_ef67c9fe430910dac158519e724efcd7

You would also need to use a proxy to access Roblox’s API from studio, rprxy.xyz is a good one.
You can just replace ---.roblox.com to ---.rprxy.xyz

Example:

local HttpService = game:GetService("HttpService")
local Total = {} -- Fill this table in with the page information (should be under Page.data)
local NextCursor

while true do
    local Page = HttpService:JSONEncode(HttpService:GetAsync("http://catalog.rprxy.xyz/v1/search/items/details?Category=2&CreatorName=Roblox&Cursor=" .. NextCursor))
    
    -- Break the loop if there's no more pages to go through. If there is more pages, set NextCursor so we can read through that page next iteration.
    if not Page.nextPageCursor then
        break
    else
        NextCursor = Page.nextPageCursor
    end
    
    wait(0.25) -- Can't spam too many web requests at once.
end

Seems like quite the task, but why not. Will reply how it goes.

How would I change the cursor? Changing Cursor=2… to Cursor=1… or any other number gives an error
Edit: Nevermind, the next page link is contained within the info you get from the table it returns.

Edit 2: began writing a script in studio to try and automate this process, I don’t know why. Doesn’t change the fact that scripts can’t access MeshId for some reason. Not sure how else to do this. Going through and changing every mesh in the properties window just won’t work.

Just found an API to get the image of an item, so will use that. Thanks for the help though.

1 Like

Which API are you mentioning? rbxthumbid? I would like to know too.

https://www.roblox.com/asset-thumbnail/image?assetId=%s&width=420&height=420&format=png
1 Like

How did you end up using this API? I wrote this code:

and the result is this: "�PNG " just that string.

You don’t need to use a proxy or HttpService for grabbing asset thumbnails.

The reason it is returning that symbol is because you’re attempting to grab an image but you can’t display images that are outside of Roblox’s domain in-game so the function below should work better.

I’m not seeing a way to get an icon from there. You can only get IconImageAssetId from a GamePass.

Did it like this

newFrame.VPF.Image = string.format("https://www.roblox.com/asset-thumbnail/image?assetId=%s&width=420&height=420&format=png", assetIdString)

I think I was overcomplicating it haha.

1 Like

Oops sorry, forgot that doesn’t work with assets!

Try this for any assets from on: https://www.roblox.com/asset-thumbnail/image?assetId=".. id .."&width=420&height=420&format=png

2 Likes

By the way, a ContentId was made to shorthand writing this, it’s called rbxthumb. This link here is equivalent to writing the shorthand:

rbxthumb://type=Asset&id=" .. id .. "&w=420&h=420"
3 Likes