一个轻量级的3D CSS 库

时间:2025-02-26 09:05:26

JavaScript 3D library

该项目的目的是为了打造轻量级的、实用简单的3D CSS库。

Usage使用方法

下载 minified库文件 和 css文件,并将其包含于你的HTML中,就如此简单。

<script src="js/voxelcss.js"></script>
<link rel='stylesheet' href="css/voxel.css"></link>

下面这段代码既是对其应用:

<script>

    var scene, world, editor;

    init();

    function init() {
   scene = new voxelcss.Scene();
   scene.rotate(-Math.PI / 8, Math.PI / 4, 0);
   scene.attach(document.body);    var lightSource = new voxelcss.LightSource(300, 300, 300, 750, 0.3, 1);
   scene.addLightSource(lightSource);    world = new voxelcss.World(scene);
   editor = new voxelcss.Editor(world);
   editor.enableAutoSave();    editor.load();
   if(world.getVoxels().length === 0)
     editor.add(new voxelcss.Voxel(0, 0, 0, 100, {
       mesh: voxelcss.Meshes.grass
     }));
   } </script>