-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodels_billboard.php
82 lines (63 loc) · 2.4 KB
/
models_billboard.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
declare(strict_types=1);
use Nawarian\Raylib\Types\{Camera3D, Color, Vector3};
use function Nawarian\Raylib\{
BeginDrawing,
BeginMode3D,
ClearBackground,
CloseWindow,
DrawBillboard,
DrawFPS,
DrawGrid,
EndDrawing,
EndMode3D,
InitWindow,
LoadTexture,
SetCameraMode,
SetTargetFPS,
UnloadTexture,
UpdateCamera,
WindowShouldClose
};
require_once __DIR__ . '/../../vendor/autoload.php';
// Initialization
//--------------------------------------------------------------------------------------
$screenWidth = 800;
$screenHeight = 450;
InitWindow($screenWidth, $screenHeight, 'raylib [models] example - drawing billboards');
// Define the camera to look into our 3d world
$camera = new Camera3D(
new Vector3(5, 4, 5),
new Vector3(0, 2, 0),
new Vector3(0, 1, 0),
45,
Camera3D::PROJECTION_PERSPECTIVE,
);
$bill = LoadTexture(__DIR__ . '/resources/billboard.png'); // Our texture billboard
$billPosition = new Vector3(0, 2, 0); // Position where draw billboard
SetCameraMode($camera, Camera3D::MODE_ORBITAL); // Set an orbital camera mode
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) { // Detect window close button or ESC key
// Update
//----------------------------------------------------------------------------------
UpdateCamera($camera); // Update camera
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(Color::rayWhite());
BeginMode3D($camera);
DrawGrid(10, 1); // Draw a grid
DrawBillboard($camera, $bill, $billPosition, 2.0, Color::white());
EndMode3D();
DrawFPS(10, 10);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture($bill); // Unload texture
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------