Jump to content

camerasManager 0.0.2

   (1 review)

About This File

This is a tool for using cameras.

ONLY CLIENTSIDE;

Using: 

const camerasManager = require('./camerasManager.js');

//creating camera

/**
@param {String} - camera name
@param {String} - type camera
@param {Vector3} - position
@param {Vector3} - rotation
@param {Number} - fov 
*/
const kemperrr_camera = camerasManager.createCamera('kemperrr_the_best?', 'default', new mp.Vector3(0, 0, 100), new mp.Vector3(), 50);

//destroy camera
/**
@param {Camera} - destroyed camera
*/
camerasManager.destroyCamera(kemperrr_camera);

//get camera by name
/**
@param {String} camera name
*/
const kemperrr_camera = camerasManager.getCamera('kemperrr_the_best?');

//activate camera
/**
@param {Camera} - camera to activate
@param {Boolean} - toggle
*/
camerasManager.setActiveCamera(kemperrr_camera, true);

//deactivate camera
/**
@param {Camera} - camera to activate
@param {Boolean} - toggle
*/
camerasManager.setActiveCamera(kemperrr_camera, false);

//activate with interpolation
/**
@param {Camera} - camera to activate
@param {Vector3} - where the camera will fly
@param {Vector3} - New camera rotation
@param {Number} - The time for which the camera will fly by
@param {Number} - hz
@param {Number} - hz
*/
camerasManager.setActiveCameraWithInterp(kemperrr_camera, new mp.Vector3(100, 200, 100), new mp.Vector3(0, 0, 90), 5000, 0, 0);

//get gameplay camera
const gameplayCamera = camerasManager.gameplayCam;
mp.game.notify(JSON.stringify(gameplayCamera.getDirection()));

//get current active camera
const activeCamera = camerasManager.activeCamera;
mp.game.notify(JSON.stringify(activeCamera.getCoord()));

//events

//an event is triggered when any camera starts interpolating
camerasManager.on('startInterp', (camera) => {
  mp.game.notify(JSON.stringify(camera.getCoord()));
});

//the event is triggered when any camera has completed interpolation
camerasManager.on('stopInterp', (camera) => {
  mp.game.notify(JSON.stringify(camera.getCoord()));
});

:(


What's New in Version 0.0.2   See changelog

Released

Thank George for feature;

 

1) Add functions directly instead of working with the manager, e.g.:

const kemperrr_camera = camerasManager.createCamera('kemperrr_the_best?', 'default', new mp.Vector3(0, 0, 100), new mp.Vector3(), 50);
kemperrr_camera.setActiveCamera(false);

2) Add a proxy or expose an object with cameras so:

camerasManager.getCamera('kemperrr_the_best?'); // =>
camerasManager["kemperrr_the_best?"];

 

3) fix doesExist function

  • Like 5

User Feedback

Create an account or sign in to leave a review

You need to be a member in order to leave a review

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

ragempdev

   6 of 6 members found this review helpful 6 / 6 members

tips:

1) Add functions directly instead of working with the manager, e.g.:

kemperrr_camera.setActiveCamera(false);

2) Add a proxy or expose an object with cameras so:

camerasManager.getCamera('camera?'); // =>
camerasManager["camera"];

3)

    static doesExist(camera) {
        try {
            return camera.doesExist();
        } catch(err) {
            return false;
        }
        return true;
    }

// =>
    static doesExist(camera) {
        return mp.cameras.exists(camera)&& camera.doesExist();
    }

 

  • Like 1
Link to review
×
×
  • Create New...