How to edit more complex 3D options through API?

(Solsnare) #1

Hello everyone.

I am currently using Sketchfab data API to upload some 3D models made in an app i'm working on.

Everything has been working great thus far, models uploading and the Uid being placed into some iframes that im adding dynamically to the website (Without the viewer API).

The problem i'm having is, the voxel models have textures that are point filtered or "Nearest". Therefore i need to go into the PBR Channel settings in the 3D options, and set the base RGB to have nearest filtering rather than Trilinear.

I would love to be able to edit this setting on Sketchfab directly, but i am at a loss at how to do it as the API for editing the 3D options is very minimal...

It looks like it's possible to do this within my embedded iframes using the viewer API, but it doesnt seem super well documented as to how exactly i would access this info. Would i be using the viewer API utility?

Would love to get some light shed on this as i'm at a loss at this point, the models look AWFUL without this change.

If there's anyway to tell sketchfab to make this default changes through the model file somehow, i would be totally fine with putting some extra piece of text into it, maybe some sketchfab specific note.

Awaiting responses, thanks a lot in advance to anyone taking the time to help me here.

  • Sol.

Above is the really big question, but additionally, I'm noticing that the "nearest" setting requires the texture to be power of 2 in order to be accurately assigned. My textures are an arbitrarily sized atlas, so this isn't working properly and the textures are getting messed up.
I can just ignore this issue and make sure that it makes the texture im using go up to the nearest power of 2.. but if it's possible not to, i would love to avoid this.

(Shaderbytes) #2

to answer some questions :

The viewer api utility is just an abstraction on the sketchfab viewer api. It cant do anything more than what the viewer api offers itself. Secondly edits made using the viewer api do not persist, they are runtime only.

My textures are an arbitrarily sized atlas, so this isn't working properly and the textures are getting messed up.
I can just ignore this issue and make sure that it makes the texture im using go up to the nearest power of 2.. but if it's possible not to, i would love to avoid this.

Power 2 textures is something cg has always preferred. Atlased textures should be no different. Do yourself a favour and adjust your workflow to meet these standards or you will be swimming upstream where ever you go with 3d rendering. Keep in mind power 2 does not mean it has to be equal in width and height eg 4096x256 is a valid power 2 texture.

(Solsnare) #3

Thanks for the clarification on the functionality.
I was just about to make the textures square but that would be totally unnecessary.

You confirmed my suspicions for the viewer API being just for the websites so that i can edit the functionality of whats being rendered in the eyeframe, and to what extent.

Is it possible to use this viewer api to edit the material in the way im specifying above?

I'd MUCH rather just edit the 3D settings permanently in sketchfab, but i dont see any of the API commands that i need in order to edit the texture settings. I want users to go from sketchfab to the app as well, and they definitely wont be impressed by the lack of proper visuals provided. But if this is just not possible, i will settle with the Viewer API, though this is really an unfortunate circumstance with a system so powerful.

(Shaderbytes) #4

I dont think it is possible , these are the only properties I've ever seen returned for a texture :

internalFormat: "RGB"
magFilter: "LINEAR"
texCoordUnit: 0
textureTarget: "TEXTURE_2D"
uid: "0a27ec52a85b4c9cbaea916a15972628"
wrapS: "REPEAT"
wrapT: "REPEAT"

uid is unique to each texture , texCoordUnit does sometimes have other values than 0. The rest are always the same. Also there is zero documentation for this.

(Solsnare) #5

What API are you referencing to get this information?

Is this from Data or Viewer API?

The mag, and min filter i dont even see in the 3d options on sketchfabs website. But filltering is the appropriate parameter to be editing.

(Solsnare) #6

Really wish someone from staff would address this question as well.. Do they ever look in this forum?

(Solsnare) #7

Actually i think i made some progress..

I figured out how to see what requests the /edit was making on sketchfab, it looks as though the payload shows the texture material data to be present:

the only problem now is that, i don't know what that ID from the materials is???

It's got some unique ID and i'm not sure where i can "Get" the options from this.

I looked at the!/models/get_v3_models_uid

And it seems as though options are supposed to be returned (as indicated by the "model" tab in the example value at the top)

But any tests within the test tool there, or the API on my end shows that options are non-existant.

I am at a loss as to how to indicate that i want either the first, or all material options to be changed for the AlbedoPBR -> Texture settings.

Im so close!!! Please help!

(Shaderbytes) #8

not sure if I understand your question , using the viewer api :

So get all the materials first , make changes to whichever channels textures you require , then update those materials.

(Solsnare) #9

Ok the viewer API i see can totally edit these options and i'm definitely going to use it if i can't use the Data API and have it edit on the Sketchfab website.

However, what i'm noticing is that you can actually edit these settings permanently in sketchfab, rather than the viewer, using the data API (as indicated by the picture i posted last, this is from inspecting the network traffic and looking at the payload the 3D options sends when clicking "Publish".)

The FINAL thing that i need here to continue this, is figuring out where to get that Material unique ID so that i can do a "Patch request" to the options (!/models/patch_v3_models_uid_options)
to update the

(Solsnare) #10

@james @stephomi Could either of you please provide your wisdom on this :slight_smile:

(Shaderbytes) #11

This seems to only show parameters for a few specific properties. There might be no do what you want via data api. Anyway let a sketchfab dev come share some info.


(Solsnare) #12

I thought you couldn't as well but you can clearly see in the 3d options utility on the website that it's making a rest data api patch call for the model:

with the additional options in the request payload:

i believe there is just a bunch of stuff in the data API that you can do, but is undocumented :frowning:


You can edit those things via the API V2, but it's undocumented and not officially supported. It may be subject to change without warning.

(Solsnare) #14

Ok thats great, so the api link would be:{UID}?

However, one point needing clarification:

In order to do this i need to either:

Do a Get model request to get the material ID.

Somehow state to the API that i need ALL the materials to have the proceeding changes (i tried doing a v3/models/{UID} get call for this and it doesnt return the "options", even though it says it should in the API)

As an example, i need to do this:

{materials["Unique Material ID (How do i get this?)"].Channels.AlbedoPBR.texture.magfilter: "NEAREST"}


Yes that endpoint should work. To find your material IDs, you probably need to use the internal endpoint GET{UID} but again, it's undocumented and subject to change.

For your JSON payloads to be valid, you have to include the full objects with all key/value pairs, even if you're not editing them.

Uploading, setting camera position, creating a preview/thumbnail
(Solsnare) #16

Ok i just tried that endpoint and it gave me all the material data indexes i wanted.

YES!!!!! :smiley:

For this part, what you mean is:
1. Use that API to get the entire contents of the model you're attempting to edit the options of. :+1:
2. Edit that result you've attained in whatever way you like :+1:
3. use this endpoint:{UID} with a PATCH request, with the entire objects data i've edited in step 2?

(Solsnare) #17

Ok i just tried all what i stated above.

What happens in the last step:

is that it doesnt seem to update the data i edited.

It also returns what seems to be the output of a v3/models/{uid} get request?

{ uid: 'b664fc7cae49475185ce42b9bb5371e8',
publishedAt: '2017-07-10T03:11:28.369898',
likeCount: 0,
commentCount: 0,
isDownloadAllowed: true,
isDownloadable: false,
processingStatus: 2,
staffpickedAt: null,
isPrivate: false,
embedUrl: '',
description: 'Created by: WordHomie in JuicyVoxels',
tags: [],
viewerUrl: '',
isProtected: false,
vertexCount: 898,
{ username: 'solsnare',
account: 'free',
displayName: 'solsnare',
uid: '6689b156e06544309227656862eaf7ae',
avatars: { images: [Object], uid: '3ef1bd11d3eb4b57a0b353e8f2e5fc3e' },
profileUrl: '' },
date: '2017-07-10T03:11:20.578235',
urlid: 'b664fc7cae49475185ce42b9bb5371e8',
categories: [],
{ images: [ [Object], [Object], [Object], [Object] ],
uid: '63bcc77387744a119467630144588eed' },
viewCount: 1,
name: 'Wordsicles',
license: null,
editorUrl: '',
faceCount: 1422,
downloadCount: 0 }

I tried using{UID} as a patch request
this didnt work as well, but seems most promising because this what the web utility uses to send the PATCH request.
However it gives me an "authentication credentials not provided" error, even though i did supply the header with the credentials, and it works for everything else. I'm assuming because this is a development account specific end point?

I tried doing{UID} patch request, it returns null and doesnt do anything.

finally tried doing{UID}/options request, with all the option data i got and edited.
returns a null and doesnt do anything once again..

Arggggggggggggg :frowning:

(Solsnare) #18

Please anyone, don't mean to keep trying to get a reply but i'm on a tight schedule to get this apps configuration out the door.


try adding ?token=API_TOKEN to the URL?

(Solsnare) #20

Like this?

Sending patch request to this url:
Finished patching the data: { detail: 'Authentication credentials were not provided.' }

It failed this way

Btw if it isnt clear, i didnt actually just put the text API_TOKEN, it was my actual token there.