Unity.ts - Interfaces

For the web page, we start by creating a namespace called unitySample. This namespace contains several interfaces and classes. This section covers the interfaces in unitySample.

IGameDataCube

The IGameDataCube interface sorts the information from the game data-stream. We normally catch the data as an array then convert it to this interface to have the information related to the object easily accessible.

name
Name of the object.
leader
Boolean that indicates if the object is the leader.
popularity
Current popularity value of the object.
mat
Current matrix of the object.
selected
Boolean that indicates if the object is selected.
popText
Popularity value converted into a string.
color
Current color of the object.
    // Conversion from Json data into structure for a specific cube
    export interface IGameDataCube {
        name: string;
        popularity: number;
        mat: IUnityMatrix4x4;
        selected?: boolean;
        popText?: string;
        color: IUnityColor;
    }

ICubePopularity

The ICubePopularity interface sorts the information related to the popularity.

name
Name of the object.
popularity
Popularity value of the object.
    // Conversion from Json data into structure for the popularity
    export interface ICubePopularity {
        name: string;
        popularity: number;
    }

ICubePopularities

The ICubePopularities interface sorts the information related to the popularity and places it into an array. We use it when multiple popularity values are available at the same time.

cubes
List of ICubePopularity values.
    // Conversion from Json data into array of structure for the popularity
    export interface ICubePopularities {
        cubes: ICubePopularity[];
    }

IGameData

The IGameData interface sorts the information from the game data. We do this because we send information from the objects and the projection-view matrix at the same time.

cubes
Information about each object that is using the IGameDataCube interface.
MatProjView
The projection view matrix (useful for the WebGL portion).
    // Conversion from Json data into structure for the entire data
    export interface IGameData {
        cubes: IGameDataCube[];
        MatProjView: IUnityMatrix4x4;
        camera: number;
        scene: number;
    }

IGameChangeColorAnnotation

The IGameChangeColorAnnotation interface sorts the information from the annotation sent when a cube color changes.

name
Name of the cube that changed color.
color
New color that was applied to the cube.
    // Conversion from Json data into structure for the entire annotation
    export interface IGameChangeColorAnnotation {
        name: string;
        color: any;
    }

IGameChangeColorAnnotationList

The IGameChangeColorAnnotationList interface sorts the information from the annotation sent when a cube changes color and places it into an array. We use it when multiple color-change values are available at the same time.

colorList
List of IGameChangeColorAnnotation values.
    // Annotation list
    export interface IGameChangeColorAnnotationList {
        colorList: IGameChangeColorAnnotation[];
    }