Back to the Shapespark home page

Lock Orbit Camera

Hi, Is there a way to lock the orbit camera? so that the viewer wont be able to zoom or pan and rotate?
We would like to put this as our lock view option.

Thanks

Hi @jamescastillo

You can lock rotation by limiting the view angles in the editor, please try setting both min and max to the same value for each row. For example:

image

We are currently working on limiting camera zoom distance, it is not available in the editor yet, but you can access distance values by manually modifying scene.json file.

  1. Backup the original scene.json.

  2. Get scene.json in the readable format: http://localhost:5000/scenes/YOUR-SCENE-NAME/scene.json?pretty by saving the content of the page, overwriting scene.json.

  3. Look for the “views” list in scene.json, and for your orbit view add “minDistance” and “maxDistance”, as in the below example:

   {
      "distance": 10,
      "hideFromMenu": false,
      "id": 10,
      "minDistance": 10,
      "maxDistance": 10,
      "maxSideAngle": -1.1344640137963142,
      "maxUpAngle": 0.7853981633974483,
      "minSideAngle": -1.1344640137963142,
      "minUpAngle": 0.7853981633974483,
      "mode": "orbit",
      "name": "Orbit",
      "noPitchRotate": false,
      "panPrimary": false,
      "rotation": [
        -65,
        -45
      ],
      "sky": "default",
      "target": [
        3.06353223323822,
        -7.526589870452881,
        1.2500000596046448
      ]
    },

hi Kamil, Thank you for your response. I managed to lock the view and pan but the zoom and drag is still there. Is there a way to limit the zoom and drag too?

Right, sorry, forgot about pan.
You can disable pan only by modifying scene.json file. If you wish to disable pan you should add: “noPan”: true.
Example view setting with ‘noPan’ option:

{
      "distance": 10,
      "hideFromMenu": false,
      "id": 10,
      "minDistance": 10,
      "maxDistance": 10,
      "maxSideAngle": -1.1344640137963142,
      "maxUpAngle": 0.7853981633974483,
      "minSideAngle": -1.1344640137963142,
      "minUpAngle": 0.7853981633974483,
      "mode": "orbit",
      "name": "Orbit",
      "noPan": true,
      "noPitchRotate": false,
      "panPrimary": false,
      "rotation": [
        -65,
        -45
      ],
      "sky": "default",
      "target": [
        3.06353223323822,
        -7.526589870452881,
        1.2500000596046448
      ]

As for the zoom. Did you set “minDistance” and “maxDistance” in the scene.json file for the view that should be locked? If you are able to lock panning by modifying scene.json file but have not been able to lock the zoom, please let me know - I can take a closer look at your scene.

Best

Hi Kamil, thank you for your response. Please see the my scene below.

“views”: [
{
“distance”: 4.073865699990559,
“hideFromMenu”: true,
“id”: 2,
“maxSideAngle”: 0.7853981633974483,
“maxUpAngle”: 0,
“minSideAngle”: 0.7853981633974483,
“minUpAngle”: 0,
“mode”: “orbit”,
“name”: “Lock Mode”,
“noPitchRotate”: false,
“panPrimary”: false,
“rotation”: [
45,
0
],
“sky”: “sky0”,
“target”: [
2.6900686699767395,
6.064482758131637,
0.9792222793940992

We just want the freeze the view. No Zoom, Pan, Rotate or Drag. Appreciate your help :slight_smile:

I don’t see attributes “noPan”, “minDistance” and “maxDistance” in your scene.json, and in the snippet you have pasted. Did you put them in your view configuration and saved the scene.json?

For the record, your view configuration should be modified, and look like this:

  "views": [
    {
      "distance": 4.073865699990559,
      "hideFromMenu": true,
      "id": 2,
      "maxSideAngle": 0.7853981633974483,
      "maxUpAngle": 0,
      "minSideAngle": 0.7853981633974483,
      "minUpAngle": 0,
      "minDistance": 4,
      "maxDistance": 4,
      "noPan": true,
      "mode": "orbit",
      "name": "Lock Mode",
      "noPitchRotate": false,
      "panPrimary": false,
      "rotation": [
        45,
        0
      ],
      "sky": "sky0",
      "target": [
        2.6900686699767395,
        6.064482758131637,
        0.9792222793940992
      ]
    }

Thank you Kamil. I’ll try this first :slight_smile:

hi Kamil,

After saving this settings, my scene doesnt load properly. please see the screenshot below.

It’s hard to tell without seeing whole while. If you copied text from forum your text editor/system might have replaced double quotes with similar non-ASCII character (however, unlikely as far as I can tell from looking at the picture).
For reference I’m sending you modified scene.json file by me, with the same changes. Please let me know if this would work

scene.json (842.5 KB)

It worked! Thanks so much!

1 Like