HunterLarco / voxel.css

A lightweight 3D CSS voxel library.
http://voxelcss.com
MIT License
3.35k stars 128 forks source link

Crash label:bug #32

Open ghost opened 8 years ago

ghost commented 8 years ago
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>3D ROOM</title>
  <link rel="stylesheet" href="style.css">
<!--</head>-->
  </head>
<body>
<script src="script.js"></script>
<script>
var scene;
var world;
var color = "#ffeb3b";
function graph(x,y,z) {
    var voxel = new voxelcss.Voxel(x*50, y*50, z*50, 50, {
      mesh: new voxelcss.Mesh(new voxelcss.ColorFace(color))
    });
    world.add(voxel);
    voxel.addEventListener("VoxelClick",function() {alert();});
}
function init(element) {
  var PI          = Math.PI;
  scene       = new voxelcss.Scene();
  var lightSource = new voxelcss.LightSource(300, 300, 300, 750, 0.3, 1);
  world       = new voxelcss.World(scene);
  scene.rotate(-PI / 8, PI / 4, 0);
  scene.attach(element);
  scene.addLightSource(lightSource);
    for(x=0;x<=100;x++) {
        for(z=0;z<=100;z++) {graph(x,0,z);}
        graph(x,100,100);
        graph(x,100,0);
    }
    for(y=0;y<=100;y++) {
        graph(0,y,0);
        graph(100,y,0);
        graph(0,y,100);
        graph(100,y,100);
    }
    for (z=0; z<=100; z++) {
        graph(0,100,z);
        graph(100,100,z);
    }
}
init(document.body); </script>
</body>
</html>

Try this. It crashes the browser.

ghost commented 8 years ago

So, it's not good for games.