This commit is contained in:
Daniel Maixner 2022-10-25 15:57:23 +02:00
parent e7740f6772
commit 1190a74faf
4 changed files with 7 additions and 80 deletions

View File

@ -64,7 +64,7 @@ export class Radar {
ctx.lineWidth = 10;
ctx.strokeStyle = "#70a670"
}
ctx.fillStyle = "#" + Color[player.getId()].toString(16).padStart(6, '0');
ctx.fillStyle = "#" + Color[player.data.color].toString(16).padStart(6, '0');
ctx.beginPath()
ctx.arc(player.data.position.x, -player.data.position.z, 50, 0, 2 * Math.PI)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -41,6 +41,7 @@ foreach ($map->getBoxes() as $box) {
<textarea class="extra">Generating...</textarea>
</div>
<script>
const forRadar = <?= ($radarMapGenerator ? 'true' : 'false') ?>;
let camera, scene, renderer, controls, extra;
const worldMaterial = new THREE.MeshLambertMaterial({color: 0x9f998e})
const material = new THREE.MeshLambertMaterial({color: 0x664b17})
@ -49,18 +50,18 @@ foreach ($map->getBoxes() as $box) {
scene = new THREE.Scene();
renderer = new THREE.WebGLRenderer({antialias: true});
if (<?= (int)$radarMapGenerator ?>) {
if (forRadar) {
renderer.setSize(800, 800);
} else {
renderer.setSize(window.innerWidth, window.innerHeight);
}
if (<?= (int)!$radarMapGenerator ?>) {
if (!forRadar) {
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
}
document.body.appendChild(renderer.domElement);
if (<?= (int)$radarMapGenerator ?>) {
if (forRadar) {
camera = new THREE.OrthographicCamera(-400, 400, 400, -400, 1, 9000)
} else {
camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.01, 99999);
@ -109,7 +110,7 @@ foreach ($map->getBoxes() as $box) {
center.position.set(box.width / 2, box.height / 2, box.depth / -2)
center.visible = false
map.add(center)
if (<?= (int)!$radarMapGenerator ?>) {
if (!forRadar) {
camera.position.x = center.position.x;
camera.position.z = center.position.z;
camera.lookAt(camera.position.x, 0, camera.position.z)
@ -216,7 +217,7 @@ foreach ($map->getBoxes() as $box) {
init()
object()
extraGeometry()
if (<?= (int)!$radarMapGenerator ?>) {
if (!forRadar) {
spawns()
buyAreas()
}

View File

@ -1,74 +0,0 @@
<!Doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
<script src="./assets/threejs/three.js"></script>
<script src="./assets/js/utils.js"></script>
<style>
body {
margin: 0;
}
</style>
</head>
<body>
<script>
let camera, scene, renderer;
function init() {
scene = new THREE.Scene();
scene.background = new THREE.Color(0xdadada)
camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.01, 99);
camera.position.z = 9;
camera.position.y = 7;
camera.lookAt(0, 3, 0)
const gridHelper = new THREE.GridHelper(9, 9);
scene.add(gridHelper);
renderer = new THREE.WebGLRenderer({antialias: true});
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
renderer.setAnimationLoop(animation);
}
let body, player
function object() {
const head = new THREE.Mesh(
new THREE.SphereGeometry(1),
new THREE.MeshBasicMaterial({
map: new THREE.TextureLoader().load(
'./resources/face.png'
)
})
);
head.name = "head"
head.position.y = 5 + 1
body = new THREE.Mesh(
new THREE.CylinderGeometry(1, 1, 5, 32),
new THREE.MeshBasicMaterial({color: 0x0000FF})
);
body.translateY(body.geometry.parameters.height / 2)
body.name = "body"
player = new THREE.Object3D();
head.rotation.reorder("YXZ")
head.rotateY(degreeToRadian(90))
player.add(head, body)
scene.add(player)
}
function animation(time) {
player.rotation.y -= 0.004
renderer.render(scene, camera);
}
init()
object()
</script>
</body>
</html>