Skip to content

Commit

Permalink
DefaultMap
Browse files Browse the repository at this point in the history
  • Loading branch information
solcloud committed Sep 25, 2022
1 parent 65b2521 commit 021bbac
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1,942 deletions.
36 changes: 22 additions & 14 deletions src/Map/DefaultMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,29 @@ public function __construct()
$radiusHalf = Player::playerBoundingRadius / 2;
$boxHeight = Player::boxHeightCrouchCover;

$this->addBox(new Box(new Point(), 31 * $scale, 5 * Player::headHeightStand, 31 * $scale));
foreach ([3, 9, 15, 21, 27] as $x) {
$attackers[] = new Point($x * $scale + $radiusHalf, 0, 6 * $scale);
$this->addBox(new Box(new Point(($x - 1) * $scale, 0, 7 * $scale), 3 * $scale, $boxHeight, $scale));
$this->addBox(new Box(new Point(($x) * $scale, $boxHeight, 7 * $scale), 1 * $scale, $boxHeight, $scale));

$defenders[] = new Point($x * $scale + $radiusHalf, 0, 28 * $scale + $scaleHalf);
$this->addBox(new Box(new Point(($x - 1) * $scale, 0, 27 * $scale), 3 * $scale, $boxHeight, $scale));
$this->addBox(new Box(new Point(($x) * $scale, $boxHeight, 27 * $scale), 1 * $scale, $boxHeight, $scale));
$this->addBox(new Box(new Point(), 43 * $scale, 5 * Player::headHeightStand, 32 * $scale));
foreach ([5, 13, 21, 29, 37] as $x) {
$attackers[] = new Point($x * $scale + $radiusHalf, 0, 4 * $scale);
$this->addBox(new Box(new Point(($x - 1) * $scale, 0, 5 * $scale), 3 * $scale, $boxHeight, $scale));
$this->addBox(new Box(new Point(($x) * $scale, $boxHeight, 5 * $scale), 1 * $scale, $boxHeight, $scale));

$defenders[] = new Point($x * $scale + $radiusHalf, 0, 27 * $scale + $scaleHalf);
$this->addBox(new Box(new Point(($x - 1) * $scale, 0, 26 * $scale), 3 * $scale, $boxHeight, $scale));
$this->addBox(new Box(new Point(($x) * $scale, $boxHeight, 26 * $scale), 1 * $scale, $boxHeight, $scale));
}
$this->addBox(new Box(new Point(15 * $scale, 0, 0 * $scale), $scale, Player::headHeightCrouch, $scale));
$this->addBox(new Box(new Point(15 * $scale, 0, 30 * $scale), $scale, Player::headHeightCrouch, $scale));
$ramp = new Ramp(new Point(5 * $scale, 0, 0 * $scale), new Point2D(1, 0), 20, $scale);
foreach ($ramp->getBoxes() as $box) {
$this->addBox($box);

$stepHeight = 10;
$stepCount = Player::headHeightCrouch / $stepHeight;
foreach ([0, 31] as $z) {
$ramp1 = new Ramp(new Point(19 * $scale, 0, $z * $scale), new Point2D(1, 0), $stepCount, $scale, true, 12, $stepHeight);
foreach ($ramp1->getBoxes() as $box) {
$this->addBox($box);
}
$this->addBox(new Box(new Point(21 * $scale, 0, $z * $scale), $scale, Player::headHeightCrouch, $scale));
$ramp2 = new Ramp(new Point(24 * $scale - 20, 0, $z * $scale), new Point2D(-1, 0), $stepCount, $scale, true, 12, $stepHeight);
foreach ($ramp2->getBoxes() as $box) {
$this->addBox($box);
}
}

$this->setAttackersSpawnPositions($attackers);
Expand Down
17 changes: 15 additions & 2 deletions www/mapGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
</div>
<script>
let camera, scene, renderer, controls;
const worldMaterial = new THREE.MeshPhongMaterial({color: 0x9f998e})
const material = new THREE.MeshPhongMaterial({color: 0x664b17})

function init() {
scene = new THREE.Scene();
Expand All @@ -60,15 +62,23 @@ function init() {
scene.add(new THREE.Mesh(new THREE.SphereGeometry(10), new THREE.MeshBasicMaterial({color: 0x000000, transparent: true, opacity: 0.8})))
}

function createRamp(startX = 1507.1, startY = 0, endX = 1676, endY = 140.1, depth = 80) {
const shape = new THREE.Shape();
shape.moveTo(startX, startY);
shape.lineTo(endX, startY);
shape.lineTo(endX, endY);
shape.lineTo(startX, startY);

return new THREE.Mesh(new THREE.ExtrudeGeometry(shape, {steps: 2, depth: depth,}), material);
}

function object() {
const json = '<?= json_encode($boxes, JSON_THROW_ON_ERROR) ?>';
const data = JSON.parse(json);
const extra = new THREE.Group()
extra.name = 'extra'
const map = new THREE.Group()
map.name = 'map'
const worldMaterial = new THREE.MeshPhongMaterial({color: 0x9f998e})
const material = new THREE.MeshPhongMaterial({color: 0x664b17})

let first = true, center, maxHeight
data.forEach(function (box) {
Expand Down Expand Up @@ -119,6 +129,9 @@ function object() {
const d1 = new THREE.DirectionalLight(0xffeac2, 0.6);
const a1 = new THREE.AmbientLight(0xDADADA, .8)
extra.add(s1, d1, a1, lightTarget, bulb);
const ramp1 = createRamp()
ramp1.position.z = -80.1
extra.add(ramp1)

scene.add(map, extra)
renderer.render(scene, camera);
Expand Down
230 changes: 1 addition & 229 deletions www/resources/map/default-extra.json
Original file line number Diff line number Diff line change
@@ -1,229 +1 @@
{
"metadata": {
"version": 4.5,
"type": "Object",
"generator": "Object3D.toJSON"
},
"geometries": [
{
"uuid": "b15e823f-b549-43b8-8686-98b1ef78bbda",
"type": "SphereGeometry",
"radius": 90,
"widthSegments": 32,
"heightSegments": 16,
"phiStart": 0,
"phiLength": 6.283185307179586,
"thetaStart": 0,
"thetaLength": 3.141592653589793
}
],
"materials": [
{
"uuid": "24c4e72f-25b5-42dc-9018-46e0d18354b0",
"type": "MeshBasicMaterial",
"color": 16777215,
"reflectivity": 1,
"refractionRatio": 0.98,
"depthFunc": 3,
"depthTest": true,
"depthWrite": true,
"colorWrite": true,
"stencilWrite": false,
"stencilWriteMask": 255,
"stencilFunc": 519,
"stencilRef": 0,
"stencilFuncMask": 255,
"stencilFail": 7680,
"stencilZFail": 7680,
"stencilZPass": 7680
}
],
"object": {
"uuid": "130ebea7-dd2a-4835-bf5c-4899745d41b6",
"type": "Group",
"name": "extra",
"layers": 1,
"matrix": [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1
],
"children": [
{
"uuid": "2804ae7c-9806-4a8b-a31a-74e2990d1d12",
"type": "SpotLight",
"castShadow": true,
"layers": 1,
"matrix": [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
1395,
2372.5,
-1395,
1
],
"color": 16777215,
"intensity": 0.6,
"distance": 0,
"angle": 1.0471975511965976,
"decay": 1,
"penumbra": 0,
"shadow": {
"mapSize": [
2048,
2048
],
"camera": {
"uuid": "511945e1-ecaf-46e1-8e1b-92175647c842",
"type": "PerspectiveCamera",
"layers": 1,
"fov": 119.99999999999999,
"zoom": 1,
"near": 1,
"far": 900601,
"focus": 10,
"aspect": 1,
"filmGauge": 35,
"filmOffset": 0
}
}
},
{
"uuid": "aa2d9faf-8021-4e7d-ae9f-6df70c13f7b8",
"type": "DirectionalLight",
"layers": 1,
"matrix": [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
1,
0,
1
],
"color": 16771778,
"intensity": 0.6,
"shadow": {
"camera": {
"uuid": "0d568d2d-d917-4542-8339-6f0f7bdbe2e8",
"type": "OrthographicCamera",
"layers": 1,
"zoom": 1,
"left": -5,
"right": 5,
"top": 5,
"bottom": -5,
"near": 0.5,
"far": 500
}
}
},
{
"uuid": "f3b5731b-2cb4-49ee-bdfd-a3fbfb1b33f4",
"type": "AmbientLight",
"layers": 1,
"matrix": [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1
],
"color": 14342874,
"intensity": 0.8
},
{
"uuid": "02c4459e-e63d-4cae-9037-b0093ae1c54f",
"type": "Object3D",
"name": "light-target",
"layers": 1,
"matrix": [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
1395,
0,
-1395,
1
]
},
{
"uuid": "942dd746-7d9b-41a0-bac8-ac51fcecd36f",
"type": "Mesh",
"layers": 1,
"matrix": [
1,
0,
0,
0,
0,
1,
0,
0,
0,
0,
1,
0,
1395,
979,
-1395,
1
],
"geometry": "b15e823f-b549-43b8-8686-98b1ef78bbda",
"material": "24c4e72f-25b5-42dc-9018-46e0d18354b0"
}
]
}
}
{"metadata":{"version":4.5,"type":"Object","generator":"Object3D.toJSON"},"geometries":[{"uuid":"24b42735-ded5-4972-b517-603003ba71ab","type":"SphereGeometry","radius":90,"widthSegments":32,"heightSegments":16,"phiStart":0,"phiLength":6.283185307179586,"thetaStart":0,"thetaLength":3.141592653589793},{"uuid":"d44eb102-5e42-46ef-8272-df5f65ed8f3f","type":"ExtrudeGeometry","shapes":["a6ec2807-1eae-4e28-bbb7-72af7d9cbdd4"],"options":{"steps":2,"depth":80}}],"materials":[{"uuid":"71ec1255-a38a-43b5-b568-fa953d60272d","type":"MeshBasicMaterial","color":16777215,"reflectivity":1,"refractionRatio":0.98,"depthFunc":3,"depthTest":true,"depthWrite":true,"colorWrite":true,"stencilWrite":false,"stencilWriteMask":255,"stencilFunc":519,"stencilRef":0,"stencilFuncMask":255,"stencilFail":7680,"stencilZFail":7680,"stencilZPass":7680},{"uuid":"cd8c2fa0-51da-4a4b-98a8-46323e9ba89e","type":"MeshPhongMaterial","color":6703895,"emissive":0,"specular":1118481,"shininess":30,"reflectivity":1,"refractionRatio":0.98,"depthFunc":3,"depthTest":true,"depthWrite":true,"colorWrite":true,"stencilWrite":false,"stencilWriteMask":255,"stencilFunc":519,"stencilRef":0,"stencilFuncMask":255,"stencilFail":7680,"stencilZFail":7680,"stencilZPass":7680}],"shapes":[{"arcLengthDivisions":200,"type":"Shape","autoClose":false,"curves":[{"metadata":{"version":4.5,"type":"Curve","generator":"Curve.toJSON"},"arcLengthDivisions":200,"type":"LineCurve","v1":[1507.1,0],"v2":[1676,0]},{"metadata":{"version":4.5,"type":"Curve","generator":"Curve.toJSON"},"arcLengthDivisions":200,"type":"LineCurve","v1":[1676,0],"v2":[1676,140.1]},{"metadata":{"version":4.5,"type":"Curve","generator":"Curve.toJSON"},"arcLengthDivisions":200,"type":"LineCurve","v1":[1676,140.1],"v2":[1507.1,0]}],"currentPoint":[1507.1,0],"uuid":"a6ec2807-1eae-4e28-bbb7-72af7d9cbdd4","holes":[]}],"object":{"uuid":"d7561479-2518-4c53-80e1-20679bd448a6","type":"Group","name":"extra","layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"children":[{"uuid":"0d316a9d-b662-4f81-acd8-5b606b59fdc4","type":"SpotLight","castShadow":true,"layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,1720,2372.5,-1280,1],"color":16777215,"intensity":0.6,"distance":0,"angle":1.0471975511965976,"decay":1,"penumbra":0,"shadow":{"mapSize":[2048,2048],"camera":{"uuid":"a97b3e33-f827-42a6-bc34-053fc725f39b","type":"PerspectiveCamera","layers":1,"fov":119.99999999999999,"zoom":1,"near":1,"far":9490,"focus":10,"aspect":1,"filmGauge":35,"filmOffset":0}}},{"uuid":"442ee6c8-5600-4f4a-b39c-0ede48593cb1","type":"DirectionalLight","layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,1,0,1],"color":16771778,"intensity":0.6,"shadow":{"camera":{"uuid":"65bddd35-5c5f-4fa2-b662-58b8ca6829e5","type":"OrthographicCamera","layers":1,"zoom":1,"left":-5,"right":5,"top":5,"bottom":-5,"near":0.5,"far":500}}},{"uuid":"7b447ba4-e29e-4c20-96c6-11bc620f8712","type":"AmbientLight","layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],"color":14342874,"intensity":0.8},{"uuid":"0fe38749-ef59-4143-b509-b9725b43d33a","type":"Object3D","name":"light-target","layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,1720,0,-1280,1]},{"uuid":"2ff705dc-fea5-40ce-a64b-9248f584da7a","type":"Mesh","layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,1720,979,-1280,1],"geometry":"24b42735-ded5-4972-b517-603003ba71ab","material":"71ec1255-a38a-43b5-b568-fa953d60272d"},{"uuid":"02e2d9dd-e202-4b2e-9e35-c24e9c0cc88d","type":"Mesh","layers":1,"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,-80.1,1],"geometry":"d44eb102-5e42-46ef-8272-df5f65ed8f3f","material":"cd8c2fa0-51da-4a4b-98a8-46323e9ba89e"}]}}
Loading

0 comments on commit 021bbac

Please sign in to comment.