figureone
    Preparing search index...

    Camera control definition object that extends and OBJ_FigurePrimitive

    A camera control is a transparent rectangle that uses touch and drag gestures to rotate the position of the camera in a 3D scene around a vertical axis.

    The vertical axis will always remain vertical. Left/right movements will rotate the scene around the vertical axis (in the azimuth of the vertical axis), while up/down movements will change the elevation relative to the vertical axis.

    The transparent rectangle will be positioned relative to the 2D HTML canvas the figure is drawn in on the screen. The left, bottom, width and height properties are numbers from 0 to 1 which represent percentage of the screen width and height.

    Thus for the rectangle to cover the entire screen, values of left: 0, bottom: 0, width: 1 and height: 1 would be used (these are the default values as well).

    By default, the figure's Scene camera position is modified. If an element's custom scene is to be controlled, use the scene property to link to it.

    How fast the camera is rotated in the aziumuth and elevation is controlled by the sensitivity, xSensitivity and ySensitivity properties. A higher sensitivity value will result in more rotation for the same user movement. If only azimuthal or elevation rotation is desired set ySensitivity or xSensitivity to 0 respectively.

    // Add a camera control that will cover the whole screen

    figure.add([
    {
    make: 'cylinder',
    radius: 0.01,
    color: [1, 0, 0, 1],
    line: [[-1, 0, 0], [1, 0, 0]],
    },
    {
    make: 'cylinder',
    radius: 0.01,
    color: [0, 1, 0, 1],
    line: [[0, -1, 0], [0, 1, 0]],
    },
    {
    make: 'cylinder',
    radius: 0.01,
    color: [0, 0, 1, 1],
    line: [[0, 0, -1], [0, 0, 1]],
    },
    {
    make: 'grid',
    bounds: [-0.8, -0.8, 1.6, 1.6],
    xStep: 0.05,
    yStep: 0.05,
    line: { width: 0.002 },
    color: [0.7, 0.7, 0.7, 1],
    transform: ['r', Math.PI / 2, 1, 0, 0],
    },
    ]);

    // Add camera control
    figure.add({
    make: 'cameraControl',
    });
    // Add a thin bar at the bottom of the figure that rotates the scene in the
    // azimuth only

    figure.add([
    {
    make: 'cylinder',
    radius: 0.01,
    color: [1, 0, 0, 1],
    line: [[-1, 0, 0], [1, 0, 0]],
    },
    {
    make: 'cylinder',
    radius: 0.01,
    color: [0, 1, 0, 1],
    line: [[0, -1, 0], [0, 1, 0]],
    },
    {
    make: 'cylinder',
    radius: 0.01,
    color: [0, 0, 1, 1],
    line: [[0, 0, -1], [0, 0, 1]],
    },
    {
    make: 'grid',
    bounds: [-0.8, -0.8, 1.6, 1.6],
    xStep: 0.05,
    yStep: 0.05,
    line: { width: 0.002 },
    color: [0.7, 0.7, 0.7, 1],
    transform: ['r', Math.PI / 2, 1, 0, 0],
    },
    ]);

    // Add a moveable cube
    figure.add({
    make: 'cube',
    side: 0.3,
    color: [1, 0, 0, 1],
    center: [0.3, 0, 0],
    move: {
    plane: [[0, 0, 0], [0, 1, 0]],
    },
    });

    // Add camera control bar at the bottom of the screen that only allows
    // rotation in the azimuth. As the camera control bar does not overlap the
    // cube, then both the cube can moved, and the scene rotated with the bar.
    figure.add({
    make: 'cameraControl',
    color: [0, 0, 0, 0.2],
    ySensitivity: 0,
    height: 0.1,
    });

    @interface