[
  {
    "name": "ar_world",
    "arguments": {
      "command": "capabilities",
      "payload": {}
    }
  },
  {
    "name": "ar_world",
    "arguments": {
      "command": "apply",
      "payload": {
        "requestId": "create-turntable-v1",
        "operations": [
          {
            "op": "entity.create",
            "entity": {
              "id": "turntable.model",
              "name": "Turntable model",
              "geometry": {
                "shape": "box",
                "size": [
                  0.25,
                  0.4,
                  0.25
                ]
              },
              "material": {
                "color": "#6E7DFF"
              },
              "transform": {
                "position": [
                  0,
                  1,
                  -1.5
                ]
              },
              "grabbable": true
            }
          },
          {
            "op": "entity.create",
            "entity": {
              "id": "turntable.toggle",
              "name": "Turn",
              "kind": "control",
              "grabbable": false,
              "geometry": {
                "size": [
                  0.5,
                  0.16,
                  0.035
                ]
              },
              "transform": {
                "position": [
                  0.55,
                  1.1,
                  -1.5
                ]
              },
              "control": {
                "type": "toggle",
                "label": "Turn",
                "value": 0,
                "min": 0,
                "max": 1,
                "step": 1
              }
            }
          },
          {
            "op": "entity.create",
            "entity": {
              "id": "turntable.speed",
              "name": "Speed",
              "kind": "control",
              "grabbable": false,
              "geometry": {
                "size": [
                  0.5,
                  0.16,
                  0.035
                ]
              },
              "transform": {
                "position": [
                  0.55,
                  0.85,
                  -1.5
                ]
              },
              "control": {
                "type": "slider",
                "label": "Speed (rad/s)",
                "value": 0.2,
                "min": 0,
                "max": 1,
                "step": 0.05
              }
            }
          }
        ]
      }
    }
  },
  {
    "name": "ar_world",
    "arguments": {
      "command": "program",
      "payload": {
        "command": "install",
        "program": {
          "id": "turntable.rotation",
          "name": "Turntable rotation",
          "source": "return {\n  tick() {\n    const model = api.get('turntable.model');\n    const toggle = api.get('turntable.toggle');\n    const slider = api.get('turntable.speed');\n    if (!model || model.heldBy || !toggle || !slider) return;\n    if (toggle.control.value === 0) return;\n    const rotation = model.transform.rotation.slice();\n    rotation[1] += slider.control.value * api.dt;\n    api.emit([{\n      op: 'entity.patch',\n      id: model.id,\n      patch: { transform: { rotation } }\n    }]);\n  }\n};",
          "entityIds": [
            "turntable.model",
            "turntable.toggle",
            "turntable.speed"
          ],
          "params": {},
          "state": {},
          "hz": 20
        }
      }
    }
  },
  {
    "name": "ar_world",
    "arguments": {
      "command": "resume",
      "payload": {}
    }
  },
  {
    "name": "ar_world",
    "arguments": {
      "command": "observe",
      "payload": {
        "ids": [
          "turntable.model",
          "turntable.toggle",
          "turntable.speed"
        ]
      }
    }
  }
]
