Skip to content

Player

Description of the player field

interface PlayerState {
    selectedTool: string
    selectedArea: SelectedArea | undefined
    playerErrors: {
        id: string
        values: object
    }[]
    camera: {
        position: number[]
        target: number[]
        distance: number
        type: string | null
        availableCameraTypes: string[]
        focusDuration: number
    }
    selectedToolOptions: {
        focusEnabled: boolean
        doubleClickEnabled: boolean
        multiSelectionEnabled: boolean
        selectionEnabled: boolean
    }
    selectedNodes: SelectedNodeMap
    networkState: 'DISCONNECTED' | 'CONNECTED' | 'CONNECTED_WIFI' | 'UNKNOWN'
    refreshLayers: boolean
    orientationCube: {
        side: 'left' | 'right'
    }

}

selectedTool

Updated by: UI

Tells which selected tool mode is enabled. The possible values are the following:

  • annotate
  • quotation
  • select
  • multiselect
  • multiselect_add
  • multiselect_remove
  • focus
  • color

Data model

selectedTool: string

Examples

Changing the selected tool

{
    ...
    "player": {
        ...
        "selectedTool": "focus",
        ...
    },
    ...
}

selectedArea

Updated by: UI/Player

Set the boundaries of a 2D box in the view space, used to select multiple nodes.

Data model

interface SelectedArea {
    bottomLeft: {
        x: number
        y: number
    }
    topRight: {
        x: number
        y: number
    }
}

Examples

Set the boundaries of a selected area

{
    ...
    "player": {
        ...
        "selectedArea": {
            "bottomLeft": {
                "x": 90,
                "y": 1198
            },
            "topRight": {
                "x": 756,
                "y": 883
            }
        }
        ...
    },
    ...
}

Operations done by the Player

When the operation has been acknowledged by the Player, it removes the field entirely.

playerErrors

Updated by: UI/Player

Stores information about an error that occurred in the Player, so that the UI can create a dialog window to show the information to the user.

  • id can either be an error code or a description of the error.
  • values is an object containing additional information.

Data model

playerErrors: {
        id: string
        values: object
    }[]

Examples

Remove all errors

Once the UI has processed an error, it can remove it from the state:

{
    ...
    "player": {
        ...
        "playerErrors": []
        ...
    }
    ...
}

Operations done by the Player

When an error occurs, the Player adds an element to the array.

{
    ...
    "player": {
        ...
        "playerErrors": [
            {
                "id": "scene parsing error",
                "values": {}
            }
        ]
        ...
    }
    ...
}

camera

Updated by: UI/Player

Information of the camera through which the user observes the scene.

Data model

camera: {
        position: number[]
        target: number[]
        distance: number
        type: string | null
        availableCameraTypes: string[]
        focusDuration: number
    }

Examples

Change the camera position and/or target

{
    ...
    "player": {
        ...
        "camera": {
            "availableCameraTypes": [
                "third person",
                "first person",
                "blueprint"
            ],
            "type": "third person",
            "position": [
                2.2613277435302734,
                0.7330776453018188,
                -6.118821620941162
            ],
            "target": [
                2.2613277435302734,
                0.7330776453018188,
                3.966489315032959
            ],
            "distance": 10.085310935974121,
            "focusDuration": 0
        }
        ...
    },
    ...
}

Changing the camera type

{
    ...
    "player": {
        ...
        "camera": {
            "availableCameraTypes": [
                "third person",
                "first person",
                "blueprint"
            ],
            "type": "first person",
            "position": [
                28.779422760009766,
                18.87126350402832,
                29.975875854492188
            ],
            "target": [
                28.779422760009766,
                17.87126350402832,
                29.97500228881836
            ],
            "distance": 1,
            "focusDuration": 0
        }
        ...
    },
    ...
}

Adding available camera types

{
    ...
    "player": {
        ...
        "camera": {
            "availableCameraTypes": [
                "third person",
                "first person",
                "blueprint"
            ],
            "distance":10,
            "focusDuration":0,
            "position":[],
            "target":[],
            "type":null
        }
        ...
    },
    ...
}

selectedToolOptions

Updated by: UI

Enables different features of the Player.

  • focusEnabled: If true, clicking on a node will focus on it.
  • doubleClickEnabled: If true, double clicking on a node will focus on it and make the other nodes transparent.
  • multiSelectionEnabled: Enable multiselection.
  • selectionEnabled: Enable selection.

Data model

selectedToolOptions: {
    focusEnabled: boolean
    doubleClickEnabled: boolean
    multiSelectionEnabled: boolean
    selectionEnabled: boolean
}

Examples

Changing the selected tool options

{
    ...
    "player": {
        ...
        "selectedToolOptions": {
            "focusEnabled": true,
            "doubleClickEnabled": false,
            "multiSelectionEnabled": false,
            "selectionEnabled": true
        }
        ...
    },
    ...
}

selectedNodes

Updated by: UI/Player

Define the selected nodes.

Data model

interface SelectedNodeMap {
    [id: string]: {
        colorId: number
        node: SceneTreeNode | null
    }
}

Examples

Select multiple nodes

{
    ...
    "player": {
        ...
        "selectedNodes": {
            "61f9208694fae90010ed3768": {
                "colorId": 0,
                "node": {
                    "type": "node",
                    "id": "61f9208694fae90010ed3768",
                    "uuid": "62c2336f-5ceb-4c66-e5f1-428b1b7b7495",
                    "attributes": {
                        "name": "middlewareTestFile.fbx",
                        "file": "61f9208519bc49000dec2885",
                        "numChildren": 6,
                        "numAttributes": 16,
                        "layerColors": [],
                        "children": [
                            "61f9208694fae90010ed375c",
                            "61f9208694fae90010ed375f",
                            "61f9208694fae90010ed3761",
                            "61f9208694fae90010ed3763",
                            "61f9208694fae90010ed3765",
                            "61f9208694fae90010ed3767"
                        ]
                    }
                }
            },
            "61f9208694fae90010ed3767": {
                "colorId": 0,
                "node": {
                    "type": "node",
                    "id": "61f9208694fae90010ed3767",
                    "uuid": "4b841af5-5e1d-5b56-3474-2562600a764b",
                    "attributes": {
                        "name": "Cone",
                        "file": "61f9208519bc49000dec2885",
                        "numChildren": 1,
                        "numAttributes": 16,
                        "layerColors": []
                    }
                }
            }
        }
        ...
    },
    ...
}

Remove a selected node

{
    ...
    "player": {
        ...
        "selectedNodes": {
            "61f9208694fae90010ed3767": {
                "colorId": 0,
                "node": {
                    "type": "node",
                    "id": "61f9208694fae90010ed3767",
                    "uuid": "4b841af5-5e1d-5b56-3474-2562600a764b",
                    "attributes": {
                        "name": "Cone",
                        "file": "61f9208519bc49000dec2885",
                        "numChildren": 1,
                        "numAttributes": 16,
                        "layerColors": []
                    }
                }
            }
        }
        ...
    },
    ...
}

Replacing a field of a selected node

{
    ...
    "player": {
        ...
        "selectedNodes": {
            "61f9208694fae90010ed3767": {
                "colorId": 0,
                "node": {
                    "type": "node",
                    "id": "61f9208694fae90010ed3767",
                    "uuid": "4b841af5-5e1d-5b56-3474-2562600a764b",
                    "attributes": {
                        "name": "RedCone",
                        "file": "61f9208519bc49000dec2885",
                        "numChildren": 1,
                        "numAttributes": 16,
                        "layerColors": []
                    }
                }
            }
        }
        ...
    },
    ...
}

networkState

Updated by: Player

Informs the state of the connection to the network. Mainly used for the offline mode.

Data model

networkState: 'DISCONNECTED' | 'CONNECTED' | 'CONNECTED_WIFI' | 'UNKNOWN'

Operations done by the Player

The Player sets the field depending on network connectivity:

{
    ...
    "player": {
        ...
        "networkState": "CONNECTED"
        ...
    },
    ...
}

refreshLayers

Updated by: UI/Player

Notify the Player that it needs to refresh its internal list of the Layers of the file.

Data model

refreshLayers: boolean

Examples

Refresh layers

{
    ...
    "player": {
        ...
        "refreshLayers": true,
        ...
    },
    ...
}

Operations done by the Player

When the operation has been acknowledge by the Player, it resets the field to false:

{
    ...
    "player": {
        ...
        "refreshLayers": false,
        ...
    },
    ...
}

orientationCube

Updated by: UI

Stores the side where the orientation cube should be displayed.

Data model

orientationCube: {
    side: 'left' | 'right'
}

Examples

Change cube location to the right

{
  "player":{
    ...
    "orientationCube":{
        "side":"right"
    }
    ...
}

November 24, 2022 March 8, 2022