Allow `DrawGizmo` to be used outside of FxDK

More likely then not this is one they made themselves in NUI (see [FREE][tool] object controller gizmo and GitHub - dolutattoo/dolu_tool: This is a dev tool for FiveM. Includes interior debuggin tools and many other features)

The FxDK Gizmo doesn’t look like its usable in base game because you cannot set m_gizmoMode and im3d wont work without the m_gizmoMode set.

I’ve already tried getting it to work, but as said in the reasons above the Gizmo isn’t able to be used at all in base game.

// Taken from FxDK
function makeEntityMatrix(entity: Entity): Float32Array {
    const [f, r, u, a] = GetEntityMatrix(entity.Handle);

    return new Float32Array([
        r[0], r[1], r[2], 0,
        f[0], f[1], f[2], 0,
        u[0], u[1], u[2], 0,
        a[0], a[1], a[2], 1,
    ]);
}

// Taken from FxDK
function applyEntityMatrix(entity: Entity, mat: Float32Array | number[]) {
    const ent = entity.Handle;
    SetEntityMatrix(
        ent,
        mat[4], mat[5], mat[6], // right
        mat[0], mat[1], mat[2], // forward
        mat[8], mat[9], mat[10], // up
        mat[12], mat[13], mat[14], // at
    );
}

if (editorMode) {
    const matrixBuff = makeEntityMatrix(hitEnt as Entity) as any
    // Always false because m_gizmoMode isn't set
    const changed = DrawGizmo(matrixBuff, 'Editor1')
    if (changed) {
        applyEntityMatrix(hitEnt, matrixBuff);
    }
}
1 Like