JavaScript
var WALL_SIZE = 50,
map = [
[1,1,1,1,1,1,1,1,1,1],
[1,0,0,1,0,0,0,0,0,1],
[1,0,0,1,0,0,0,0,0,1],
[1,0,0,1,1,1,0,0,0,1],
[1,0,0,0,0,1,0,0,0,1],
[1,1,1,1,0,1,0,0,0,1],
[1,0,0,1,0,1,1,0,1,1],
[1,0,0,1,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,1],
[1,1,1,1,1,1,1,1,1,1]
];
var engine = new BABYLON.Engine(document.getElementById('canvas'), true);
var scene = new BABYLON.Scene(engine);
var camera = new BABYLON.ArcRotateCamera('camera', 150, 0.8, 150, new BABYLON.Vector3(0, 0, 0), scene);
camera.mode = BABYLON.Camera.PERSPECTIVE_CAMERA;
camera.setPosition(new BABYLON.Vector3(0, 700, 200));
var material = new BABYLON.StandardMaterial("sm", scene);
var light = new BABYLON.SpotLight("light", new BABYLON.Vector3(-100, 0, 100), new BABYLON.Vector3(1, -0.7, -0.6), 3, 3, scene);
// var light = new BABYLON.DirectionalLight("light", new BABYLON.Vector3(-1, 0, 0), scene);
light.diffuse = new BABYLON.Color3(1, 1, 1);
light.specular = new BABYLON.Color3(1, 1, 1);
light.range = 300;
var ground = BABYLON.Mesh.CreateGround('ground', 1000, 1000, 1, scene);
var wall,
wMap = map[0].length,
hMap = map.length,
dx = Math.floor(hMap * WALL_SIZE / 2),
dz = Math.floor(wMap * WALL_SIZE / 2);
for (var i = 0; i < hMap; i++) {
for (var j = 0; j < wMap; j++) {
if (map[i][j]) {
if (wall) wall = wall.clone();
else {
wall = BABYLON.Mesh.CreateBox("wall", WALL_SIZE, scene);
wall.material = material;
wall.material.specularColor = new BABYLON.Color3(0, 0, 0);
}
wall.position = new BABYLON.Vector3(
...