const { CANNON } = require('/uploads/alexandru/cannon.js');
AB.clockTick = 100;
AB.maxSteps = 5000;
AB.drawRunControls = false;
ABWorld.drawCameraControls = true;
ABHandler.GROUNDZERO = true;
const skycolour = "lightblue";
const cubeGeometry = new THREE.BoxGeometry(2, 2, 2);
// colour is Green
let markerX = new THREE.Mesh(cubeGeometry);
markerX.material = new THREE.MeshBasicMaterial({ color: 0x00FF00 });
markerX.position.set(100, 0, 0);
// colour is Blue
let markerZ = new THREE.Mesh(cubeGeometry);
markerZ.material = new THREE.MeshBasicMaterial({ color: 0x0000FF });
markerZ.position.set(0, 0, 100);
// colour is Yellow
let markerY = new THREE.Mesh(cubeGeometry);
markerY.material = new THREE.MeshBasicMaterial({ color: 0xFFFF00 });
markerY.position.set(0, 100, 0);
const MODELLENGTH = 600;
const MODELWIDTH = 300;
const SCALE_CASTLE = 0.8; // scale it by this
const SCALEDMODELLENGTH = MODELLENGTH * SCALE_CASTLE;
const SCALEDMODELWIDTH = MODELWIDTH * SCALE_CASTLE;
const startRadiusConst = SCALEDMODELLENGTH * 0.5;
const maxRadiusConst = SCALEDMODELLENGTH * 10;
AB.world.newRun = function () {
ABWorld.init3d(startRadiusConst, maxRadiusConst, skycolour);
ABWorld.render();
init();
};
AB.runReady = true; // start run loop
function generateBox(x, y, z, width, depth, falls) {
// ThreeJS
const geometry = new THREE.BoxGeometry(width, boxHeight, depth);
const color = new THREE.Color(`hsl(${30 + stack.length * 4}, 100%, 50%)`);
const material = new THREE.MeshLambertMaterial({ color });
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(x, y, z);
scene.add(mesh);
return {
threejs: mesh,
width,
depth
};
}
const originalBoxSize = 3;
let stack=[];
const boxHeight = 1; //Height of each layerfunction addLayer(x, z, width, depth, direction) {
const y = boxHeight * stack.length; // Add the new box one layer higher
const layer = generateBox(x, y, z, width, depth, false);
layer.direction = direction;
stack.push(layer);
function loadXYZAxes(scene) {
scene.add(markerX);
scene.add(markerY);
scene.add(markerZ);
}
function init() {
scene = ABWorld.scene;
loadXYZAxes(scene);
addLayer(0, 0, originalBoxSize, originalBoxSize);
addLayer(-10, 0, originalBoxSize, originalBoxSize);
const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
scene.add(ambientLight);
const dirLight = new THREE.DirectionalLight(0xffffff, 0.6);
dirLight.position.set(10, 20, 0);
scene.add(dirLight);
const aspect = window.innerWidth / window.innerHeight;
const width = 10;
const height = width / aspect;
camera = new THREE.OrthographicCamera(
width / -2, // left
width / 2, // right
height / 2, // top
height / -2, // bottom
0, // near plane
100 // far plane
);
camera.position.set(4, 4, 4);
camera.lookAt(0, 0, 0);
}