Josh Posted May 26 Share Posted May 26 Just making some examples here for later: https://ambientcg.com/api/v2/full_json?type=HDRI&sort=Popular&limit=10&include=downloadData&offset=0 Docs: https://docs.ambientcg.com/api/v2/full_json/ Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted May 28 Author Share Posted May 28 And here is how to retrieve the contents of a Github repository: https://api.github.com/repos/ultraengine/documentation/contents/CPP Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted May 28 Author Share Posted May 28 This gets the categories: https://ambientcg.com/api/v2/categories_json Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted May 28 Author Share Posted May 28 Get all files in a category, with downloads and preview images: https://ambientcg.com/api/v2/full_json?type=Material&sort=Popular&limit=10&include=downloadData%2CpreviewData&offset=0&category=Bricks Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted May 28 Author Share Posted May 28 Get download links and preview images for a single item: https://ambientcg.com/api/v2/full_json?type=Material&sort=Popular&limit=10&include=downloadData%2CpreviewData&offset=0&id=Bricks092 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted May 28 Author Share Posted May 28 Here is a basic skeleton for a downloader. The idea is to have one system with multiple content providers that can be plugged in to download assets from other sources. local extension = {} extension.providers = {} function extension:Initialize() local sidepanelwidth = 280 local x = 4 local y = 4 extension.window = CreateWindow("Asset Library", 0, 0, 1024, 768, program.window, WINDOW_HIDDEN | WINDOW_TITLEBAR | WINDOW_CENTER | WINDOW_RESIZABLE) extension.ui = CreateInterface(extension.window) extension.treeview = CreateTreeView(x, y, sidepanelwidth, extension.ui.background.size.y - y * 2, extension.ui.background) extension.treeview:SetLayout(1,0,1,1) extension.panel = CreatePanel(x + sidepanelwidth + 4, y, extension.ui.background.size.x - sidepanelwidth - 4 - 2 * x, extension.ui.background.size.y - 2 * y, extension.ui.background, PANEL_BORDER) extension.panel:SetLayout(1,1,1,1) --extension.panel:SetColor(extension.panel:GetColor(WIDGETCOLOR_SUNKEN)) extension.panel:SetColor(0,0,0,1) --Set DPI scale if needed if program.window.display.scale ~= 1 then local scale = program.window.display.scale local pos = extension.window.position local size = extension.window.size extension.window:SetShape(pos.x, pos.y, size.x * scale, size.y * scale) extension.ui:SetScale(scale) end ListenEvent(EVENT_WINDOWCLOSE, extension.window, extension.ProcessEvent, extension) ListenEvent(EVENT_WINDOWSIZE, extension.window, extension.ProcessEvent, extension) local s = FetchUrl("https://ambientcg.com/api/v2/categories_json") local t = LoadTable(s) local n local groups = {} for n = 1, #t do local name = t[n].categoryName local group = t[n].defaultDataTypeId if groups[group] == nil then groups[group] = {} end groups[group][name] = t --extension.treeview.root:AddNode(name) end local k,v local base = extension.treeview.root:AddNode("AmbientCG") for k,v in pairs(groups) do local node = base:AddNode(k) local k2, v2 for k2, v2 in pairs(v) do node:AddNode(k2) end end base:Expand() end function extension.ProcessEvent(event, extension) if event.id == EVENT_WIDGETACTION then if event.source == extension.menuitem then if extension.window == nil then extension:Initialize() end extension.window:SetHidden(false) extension.window:Activate() return false end elseif event.id == EVENT_WINDOWCLOSE then if event.source == extension.window then program.window:Activate() extension.window:SetHidden(true) return false end end end local submenu = program.menu:FindChild("Scripting") if submenu == nil then Print("Error: Could not find script menu") return end extension.menuitem = CreateMenu("Asset Library", submenu) ListenEvent(EVENT_WIDGETACTION, extension.menuitem, extension.ProcessEvent, extension) --Add a content provider local t = {} function t:GetCategories() end table.insert(extension.providers, t) Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted May 28 Author Share Posted May 28 3dassetsone API: https://3dassets.one/about-site Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted May 29 Author Share Posted May 29 I think I am going to make the interface in C++, built into the program, and then use Lua for the various integrations with different websites. Here is the final version of the pure Lua approach. It doesn't download assets but it's a nice example of asynchronous behavior with Lua. AssetLibrary.lua 3 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted June 8 Author Share Posted June 8 There is also a REST API for invision power board, the system this site uses: https://invisioncommunity.com/developers/rest-api/index/ I unlocked the downloads system and we can test with it: https://www.ultraengine.com/community/files Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted October 4 Author Share Posted October 4 I tried uploading an ambientcg.com material here to test with. There are two versions you can download, (although they are actually the same file with a different name). There is a lot of good CC0 content out there that does not have any type of web API to access it. It might make more sense to take all this stuff and upload it into our website's system. Of course that process would need to be automated because there would be too much content to manage otherwise. This would give us a single point of access for all this stuff. The PBR texture providers are usually not very motivated to create a web API because they make money through advertisements, but they still are releasing their stuff under CC0 license. I'm not sure why, but that license allows us to redistribute files any way we want, and it doesn't look like this is going to happen otherwise. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted October 4 Author Share Posted October 4 Another test: Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted October 4 Author Share Posted October 4 texturecan.com has assets from 001 to 641 here: https://www.texturecan.com/details/641/ Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.