What is the parameter's format for an orientation update?


(3diclone) #1

Hello,
I'm trying to update a model's orientation with a PATCH call to /v3/models/{uid}/options. The documentation says the parameter should be 'Either a 4x4 matrix or an angle with an axis.'
But I couldn't find any information how this parameter should be formatted. I was trying to set x axis to 90 degrees with:
{"x": "90"}
but the error response was: 'Options keys orientation must contains axis and angle or matrix'
Could you please help me what the correct format for axis/angle parameters is?

[I've checked if I'm using the PATCH call right, I could change the background colour, so the call is working.]

Many thanks in advance.
Denes


#2

I think it's
{"axis": "x","angle": 90}

@stephomi ?


#3

Ah sorry, it needs to be a vector, like:

{
    "axis": [1,0,0],
    "angle": 90
}

(3diclone) #4

Hello James,
Thanks for the really fast reply - it solved my problem, thank you!
Denes


(3diclone) #5

And I have another question (I don't know what's better: creating a new topic or changing the current's title):
I managed to set an environment for a model, but I couldn't find in the documentation how to change the background's blur and brightness parameter via the API? Is there any way to update that parameter?
Denes


#6

Not yet, the options are pretty limited right now :confused:

We're working to add more!


(3diclone) #7

Thank you for the information. I hope these options will get their way into the API soon :slight_smile:
Denes


(Avinash Srivastava) #8

Hi,

I am facing the same issue but my problem is that when i am testing this api using postman, i am getting error as "Option key Orientation is not json". Can you please share your piece of code like how you are calling this from your code. This will help me a lot.

Thanks in advance.


(3diclone) #9

Hello,
I used this PHP code:

$url='https://api.sketchfab.com/v3/models/'.$MODEL.'/options';
$query=array(
'orientation'=>'{"axis": [1,0,0], "angle": 90}'
'background'=>'{"color": "#ff00ff"}'
);
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Token '.$TOKEN));
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');


(Minimoich) #10

Hi,

We are doing bodyscan. But after uploading my models, instead of standing, the models are lying on the ground. :frowning:

I can use the "3D Settings" (1 time X, then 2 times Z), but I want to correct the orientation by script. So I try the API Swagger UI to give one orientation to a model, but I can't find the way to give the right orientation.

It seems that it's not possible to apply more than one time the same request "patch". I can apply one rotation, but I didn't find the way to make them stand.

Thanks


#11

You can pass a 4x4 matrix instead of an axis and angle. See: http://glmatrix.net/

"options": {
  "orientation": {
    "matrix": [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
  }
}

#12

You should also pass this options object with your initial upload POST instead of making an additional PATCH request.


(Minimoich) #13

Thanks James for your fast answer.
I'm not able to use the matrix, I cannot apply a rotation. Maybe I didn't explain my problem correctly.
I don't want to set an "orientation" to my model, but a "rotation". When I upload my models, they are not standing correctly, nor face.


#14

The orientation is used to apply a rotation. I think [-1, 0, 0, 0, 0, 0, -1, 0, 0, -1, 0, 0, 0 ,0, 0, 1] is what you want in this case.

Maybe @stephomi can give you a clearer description?