Viewer api and javascript development


(Alex) #42

It was my first model in Blender. So it is created from deformed boxes, spheres ... every further attempts to correct that only make all worst and so I save that for historical reasons and only inserted skeleton for animation :smiley:
UPDATE: Today I have seen some strange effect with "oil cat" rendering under some Linux distribution, but it was fixed after upgrade. May be you talked about something like that? I realized that the model I used can be not very appropriate for sketchfab because, it has textures without UV mapping. I fixed the issue and upload new model without textures - it also may be used for experiments with API if some problems appear https://ayvlasov.neocities.org/sketchfab/test2/cat_walk2.html


(Jonnyqb) #43

Hi. I need a bit of help.
I tried following this example
http://www.shaderbytes.co.za/sketchfab/development/api/examples/example_1.html
but changing my own model. I removed the buttons from the code and have tried to just use the
sketchfabAPIUtility.setColor(prop, sketchfabAPIUtility.DiffusePBR, whiteBoneColor); method to change all materials in my model.
it does not work. the code is so simple and i can't figure out what's wrong.

I used the same for-in loop in the example code to print to the console my material names and they match the console output from the SketchFabUtility's output.
I've tried all the other setColor options: DiffuseColor, DiffuseIntesity, Specular, Emit, etc.
the only thing that works is changing Alpha settings.

I get the feeling that my model is the culprit, but i don't know how.
my model has the id f137fea505b14aaa9e4fe9efd6feb4f8
my model was uploaded as 3 different OBJs, their materials, and an empty sketchfab.zbrush file.
I have access to Blender, but uploading from Blender causes my skinny skeleton line to disappear. Using OBJ i can hand code the OBJ file using lines, but I can't get Blender to handle them the good way SketchFab does.
I have a workaround using alpha to hide materials, but my next phase will need the material color change option.

Thank you all for your time and help.


#44

Maybe the scene graph is funky due to the zbrush concatenation, but I'm not sure why Alpha would still work then.

Regardless, @shaderbytes is your man.


(Jonnyqb) #45

thanks @james
i tried a direct upload from Blender of an object with the same material names and i get the same problem. Alpha works, setColor does not.
i don't understand scene graphs enough, but that could an issue. i build an OBJ file in custom software that builds a voxel model by placing little OBJ cubes at the appropriate (x,y,z) locations. i suppose it could be something in the format of the OBJ file. then Blender imports it but doesn't "correct" it.
I have tried exporting the file from Blender to a new OBJ hoping that corrects anything I did wrong in my code. that doesn't change things.

i build a simple model in blender and uploaded to SketchFab using the Upload add-on. 359045bede9e43afaa5fe01fc809da73
this one also has the same problems.

thanks

hopefully @shaderbytes will be able to give more insight.

thanks.


(Shaderbytes) #46

Hi there

I had a look at some models and it seems for some reason that sometimes there is no color object on the skechfab channel itself. @james @mauricesvay ??

I added in a check to see if the color object on the channel is null now and if so it will log to the consol and also abort the function as it produces an error otherwise. The code on Github has been updated.

Here is an example of it breaking :

http://www.shaderbytes.co.za/sketchfab/development/api/examples/example_1b.html

I included logging the materials array , if you drill into it and look at DiffusePBR channel you will see there is no color object on it. Perhaps because it has a texture? I'm not sure..

EDIT :

Ok I just changed the code again , It will create a color object if none is found, :smile:


(Shaderbytes) #47

Here is your model as example now , I added a dropdown to choose channels and found changing the AlbedoPBR give visual results.

http://www.shaderbytes.co.za/sketchfab/development/api/examples/example_1c.html

I also checked the initial color object for the channel and they are there , so actually your model soes not even fall into the problem area I solved above?? So you must be doing something incorrectly .. do you have a sample page we can check?


(Jonnyqb) #48

thanks @shaderbytes.
i'll see about getting a stripped down version of my page somewhere for you to see.
i wonder why my model doesn't use DiffusePBR like what "normal" models seem to use.
i don't even know what AlbedoPBR is, but i'm certainly glad you found that works.
thanks for your code.

I was thinking earlier that maybe there's some strange method we're using to generate our own colors in our own .mtl file in the code where we build said models. in the past, Blender would change those mtl files when i'd export OBJ.


(Nirmal007) #49

Hi all, I need little bit help.
I tried this example with my Model "536959675c6244ffaa4d9b684bbd693c" . In my model there is one material name "16 - default". I tried to change texture with my .jpg texture file and call function sketchfabAPIUtility.setTexture("16 - Default", sketchfabAPIUtility.MetalnessPBR, 'https://s3.ap-south-1.amazonaws.com/sketchfab-labs01/materials/Barricatos-D.jpg'); . Everything's looks ok but callback of setTexture() not received and nothing happens.


(Shaderbytes) #50

hi there , is the server your embed is hosted on CORS enabled? This is a requirement for texture injection to work?

Do you have a link I can look at?


(Nirmal007) #51

Hi shaderbytes Thanks for reply ,
My texture image source is
"https://s3.ap-south-1.amazonaws.com/sketchfab-labs01/materials/Barricatos-D.jpg"
This is image source url from AWS S3 bucket.
I have no idea about CORS embled.


(Shaderbytes) #52

CORS is a security system implemented by servers and browsers. In essence a server has to be configured to enable CORS. This would require editing some files on the server. I tested your image and it fails due to this restriction :

"Image from origin 'https://s3.ap-south-1.amazonaws.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://sketchfab.com' is therefore not allowed access."


(Nirmal007) #53

Hi I got it . I try a different image url (copied from example) is working properly. Please tell me about how I host my texture file with CORS enabled and how can I test my images urls is CORS enabled.


(Shaderbytes) #54

to test use chrome browser and open the developer tools (press F12 key or use menu) then click the "Console" tab. This is where an error will be displayed , like the error I posted above.

Do you rent any server space for your domain? like where your site or clients site is hosted? You would need access to the config files on the server to make edits to enable CORS. You will just have to use google and get this sorted by yourself as it is not something anyone can do for you. Some file sharing services might be cors enabled , like dropbox etc.. but Im not sure , see what the internet says about it..

On the server space I rent I had to google and find out which files to edit by myself as well :slight_smile:


(Hakkun) #55

What are the plans for next api update? Are there any new features?


(Mauricesvay) #56

Is there anything you would like to have in the API?


(Sabry M) #57

Hi everyone, if you'd asked me...I'm certainly looking forward to endpoints for private models ...which had been indicated to be close to deployment end of last year. Any news on that.?


(Mauricesvay) #58

You must be talking about the Data API, not the Viewer API. As far as I know, access to private models with the Data API is coming soon, but I don't have any ETA.


(Hakkun) #59

My wishlist would be:

  • assign multiple materials per mesh together with texture maps (from a material catalogue)
  • limit pan&drag movement of camera (only zoom etc.)
  • dynamically print text on texture
  • create a custom preloader

Greetings


(Klaasnienhuis) #60

Especially those last three points would be great!
Apart from having more control over the navigation, please also consider modifying the autospin behavior. Autospin currently spins the model which makes it hard to implement preset camera angles. For instance, when I have buttons for a front and rear view, the autospin makes it impossible to use these. If autospin actually spins the camera, this issue would be resolved.
Being able to combine multiple scenes together would be a great addition as well. Consider a system where users can preview helmets on a few demo heads. It would be great if the helmets could be imported from separate Sketchfab scenes. This makes it easy to add new helmets, and having a large collection of helmets wouldn't be an issue anymore since they don't have to be uploaded in one single scene.
Adding more control over UV placement is also a feature my clients talk about. For instance moving, scaling and rotating a logo on a tshirt. It's currently possible to have a separate UV channel for the logo, but I can't transform the logo, unless I generate a new image on the fly and upload it. Which is a lot less responsive and more complex.
@mauricesvay get in touch for some real world scenarios if these features make sense to you.


(Mauricesvay) #61
  • "multiple materials per mesh" do you mean materials where you could have multiple layers of textures? Right now the viewer doesn't support that, so we can't offer an API for that.
  • "limit pan&drag movement of camera": it's on our roadmap
  • "dynamically print text on texture": I believe you can generate a texture from an HTML5 canvas, but I haven't tested it. This should allow dynamic text on texture.
  • "dynamically print text on texture": not sure what it means. The possibility to create you own "Loading" UI?