Screenshot API function not working on my 3D configurator


(Pierreyvesjacques) #1

Hello!

I would like to add a simple screenshot button to my 3D configurator.

Visitors will be able to download and share the view to their social networks =)

I use to code in the API reference: https://sketchfab.com/developers/viewer/screenshot

							 $( '#screenshot' ).click( function () {
								api.getScreenShot( 'image/png', function ( err, result ) {
									var height = $( '#sketchfab-iframe' ).height();
									var width = $( '#sketchfab-iframe' ).width()
									if ( height < 100 ) {
										height = 100;
									}
									if ( width > 100 ) {
										width = 100;
									}

									$( '#screenshot' ).parent().append('Téléchargez puis partagez =)');
									console.log(err);
								}); 
							 }); 

But noting appends, not log error… Anyone could help me on this ?

The configurator is here : https://pierreyves3d.com/kkbb/di-lamp/ :grinning:

Pierre-Yves


(Paul Sketch) #2

can you try with explicetely specifying height and width ?
like api.getScreenShot(800, 800, ‘image/png’, function …


(Pierreyvesjacques) #3

Merci @paul_sketch !

It’s now working, this is the code:

                                                    //for sreenshots
						$( '#screenshot' ).click( function () {
							theApi.getScreenShot(1280,1280, 'image/png', function ( err, result ) {
								
								var img = document.createElement("img");
								img.src = result;
								img.width = 128;
								img.height = 128;
								$( '#screenshot_result' ).append(img);
							}); 
						});  

And the result: