Triggering Camera position change with JQuery?

Hi All,

I’m a novice with JS, but have taken some basic courses. I’m trying to get the camera to zoom on an object, after turning off some other nodes in the scene. I’ve been using JQuery with good luck for other buttons. No joy here.

$(’#buttonID’).on(‘click’, function (event) {
[26.12416730993728, 8.155939800886562, 18.378355282040154],
[14.58507262912475, 6.412266103856627, 16.052308955896603],

I’m getting this in the console:

“filename.html:239 Uncaught TypeError: Cannot read property ‘setCameraLookAt’ of undefined
at HTMLButtonElement. (filename.html:239)
at HTMLButtonElement.dispatch (jquery-3.4.1.slim.min.js:2)
at HTMLButtonElement.v.handle (jquery-3.4.1.slim.min.js:2)”



it says “api” variable is not initialized.
That variable must be set from when you initialize sketchfab viewer api, it gives you back the value to put in that variable.

I would recommend to read the samples code (and particularly the first one) to check how you can get it. Viewer API - Examples - Sketchfab

1 Like

Thanks! I was able to get it to work with a fresh API instance. I’ve been using ShaderBytes API utility for some other features, since it’s quick to rough out an idea for my colleagues (my strengths are in anatomy not coding!). The API commands tend not to function with the API utility running.



1 Like