1. Go to this page and download the library: Download wolvesfortress/libcamera library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wolvesfortress / libcamera example snippets
use muqsit\libcamera\libcamera;
use pocketmine\plugin\PluginBase;
class MyPlugin extends PluginBase{
public function onEnable() : void{
if(!libcamera::isRegistered()){
libcamera::register($this);
}
}
// ...
}
use muqsit\libcamera\libcamera;
use muqsit\libcamera\CameraInstruction;
use pocketmine\network\mcpe\protocol\types\camera\CameraPreset;
use pocketmine\network\mcpe\protocol\types\camera\CameraSetInstructionEase;
use pocketmine\network\mcpe\protocol\types\camera\CameraSetInstructionEaseType;
use pocketmine\network\mcpe\protocol\types\camera\CameraSetInstructionRotation;
use pocketmine\network\mcpe\protocol\types\camera\Vector3;
use pocketmine\player\Player;
// ...
if($player instanceof Player && $player->isOnline()){
/**
* @phpstan-param CameraPreset $preset
* @phpstan-param CameraSetInstructionEase|null $ease
* @phpstan-param Vector3|null $camera_pos
* @phpstan-param CameraSetInstructionRotation|null $rot
* @phpstan-param Vector3|null $facing_pos
*/
CameraInstruction::set(
preset: libcamera::getPresetRegistry()->registered["target"],
ease: new CameraSetInstructionEase(
CameraSetInstructionEaseType::IN_OUT_CUBIC,
(float) 5.0 // duration (sec)
),
camera_pos: null,
rot: new CameraSetInstructionRotation(
(float)20.0, //pitch
(float)180.0 //yaw
),
facing_pos: null
)->send($player);
}
use muqsit\libcamera\libcamera;
use muqsit\libcamera\CameraInstruction;
use pocketmine\network\mcpe\protocol\types\camera\CameraFadeInstructionColor;
use pocketmine\network\mcpe\protocol\types\camera\CameraFadeInstructionTime;
use pocketmine\player\Player;
// ...
if($player instanceof Player && $player->isOnline()){
/**
* @phpstan-param CameraFadeInstructionColor|null $color
* @phpstan-param CameraFadeInstructionTime|null $time
*/
CameraInstruction::fade(
color: new CameraFadeInstructionColor((float)$r,(float)$g,(float)$b),
time: new CameraFadeInstructionTime((float)$fadeInTime,(float)$stayTime,(float)$fadeOutTime)
)->send($player);
}
use muqsit\libcamera\libcamera;
use muqsit\libcamera\CameraInstruction;
use pocketmine\network\mcpe\protocol\types\camera\CameraTargetInstruction;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
// ...
if($player instanceof Player && $player->isOnline()){
/**
* @phpstan-param Vector3|null $targetCenterOffset
* @phpstan-param int $actorUniqueId
*/
CameraInstruction::target(
targetCenterOffset: Vector3::zero(), // no offset
actorUniqueId: $player->getId() // for example target the player
)->send($player);
}
use muqsit\libcamera\libcamera;
use muqsit\libcamera\CameraInstruction;
use pocketmine\player\Player;
// ...
if($player instanceof Player && $player->isOnline()){
CameraInstruction::removeTarget()->send($player);
}
use muqsit\libcamera\libcamera;
use muqsit\libcamera\CameraInstruction;
use pocketmine\player\Player;
// ...
if($player instanceof Player && $player->isOnline()){
CameraInstruction::clear()->send($player);
}
use muqsit\libcamera\libcamera;
use muqsit\libcamera\CameraInstruction;
use pocketmine\network\mcpe\protocol\types\camera\CameraFadeInstructionColor;
use pocketmine\network\mcpe\protocol\types\camera\CameraFadeInstructionTime;
use pocketmine\math\Vector3;
use pocketmine\player\Player;
// ...
if($player instanceof Player && $player->isOnline()){
CameraInstruction::multi(
CameraInstruction::target(
targetCenterOffset: Vector3::zero(),
actorUniqueId: $player->getId()
),
CameraInstruction::fade(
color: new CameraFadeInstructionColor((float)$r,(float)$g,(float)$b),
time: new CameraFadeInstructionTime((float)$fadeInTime,(float)$stayTime,(float)$fadeOutTime)
)
)->send($player);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.