ashes3d
An 3D engine for indie games
Last updated a month ago by but0n .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ashes3d 
SYNC missed versions from official npm registry.

Build Status

Examples

Features

ezgif-4-e4c6f3cb3183

  • Entity–component–system (ECS) architectural
  • glTF support
  • Physically based rendering (PBR)
  • Post effects (WIP)
  • Skeleton animation
  • Keyframe animation
  • HDR

Getting Started

  • via CDN
<script src="https://cdn.jsdelivr.net/npm/ashes3d/build/ashes.main.js"></script>
  • via npm
npm i ashes3d

Usage

Try it


let { Asset, EntityMgr, Camera, vec3, quat, Screen, OrbitControl, MeshRenderer, Filter, Shader, Material, QuadMesh } = Ashes;

let CDN = 'https://but0n.github.io/Ashes/'
Material.SHADER_PATH = CDN + Material.SHADER_PATH;


// DamagedHelmet
let gltf = CDN + 'gltfsamples/DamagedHelmet.glb';


async function main() {

    let screen = new Screen('#screen');

    screen.bgColor = [0.2,0.2,0.2,1];


    let skybox = await Asset.loadCubemap(CDN + 'res/envmap/GoldenGateBridge2/');

    let scene = EntityMgr.create('root - (Click each bar which has yellow border to toggle visible)');

    // Camera
    let mainCamera = EntityMgr.create('camera');
    let cam = mainCamera.addComponent(new Camera(screen.width / screen.height));

    // Set default position
    let cameraTrans = mainCamera.components.Transform;
    vec3.set(cameraTrans.translate, 0, 10, 10);

    // Add it to scene
    scene.appendChild(mainCamera);

    // Attach controler
    mainCamera.addComponent(new OrbitControl(screen, mainCamera));

    document.querySelector('body').appendChild(scene);

    // Load a gltf model
    let gltfroot = await Asset.loadGLTF(gltf, screen, skybox);
    scene.appendChild(gltfroot);

}

main();

Create a quad with texture

    // Create an entity
    let quad = scene.appendChild(EntityMgr.create('quad'));

    // Load a material
    let quadMat = await Asset.LoadMaterial('stylize'); // PBR material

    // Load a texture
    let floor = await Asset.loadTexture(CDN + 'res/textures/floor.png', { minFilter: screen.gl.NEAREST_MIPMAP_NEAREST });
    floor.flipY = true;

    // Attach texture to material we created
    Material.setTexture(quadMat, 'baseColorTexture', floor);
    quadMat.shader.macros['HAS_BASECOLOR_MAP'] = '';

    // Create a renderer component
    let quadMR = new MeshRenderer(screen, new QuadMesh(), quadMat);

    // Attach renderer to entity
    quad.addComponent(quadMR);

    // Set local translate [x, y, z]
    quad.components.Transform.translate[1] = -1;

    // Set euler angle x, y, z
    quat.fromEuler(quad.components.Transform.quaternion, -90, 0, 0);

    // The original size of quad is 2x2
    vec3.scale(quad.components.Transform.scale, quad.components.Transform.scale, 9);

Deployment

git clone https://github.com/but0n/Ashes.git
cd Ashes

# if you don't have yarn installed
npm install -g yarn

yarn

yarn dev

Current Tags

  • 0.2.5                                ...           latest (a month ago)

60 Versions

  • 0.2.5                                ...           a month ago
  • 0.2.4                                ...           5 months ago
  • 0.2.3                                ...           5 months ago
  • 0.2.2                                ...           6 months ago
  • 0.2.1                                ...           6 months ago
  • 0.2.0                                ...           8 months ago
  • 0.1.2                                ...           8 months ago
  • 0.1.1                                ...           8 months ago
  • 0.1.0                                ...           8 months ago
  • 0.0.51                                ...           8 months ago
  • 0.0.50                                ...           9 months ago
  • 0.0.49                                ...           9 months ago
  • 0.0.48                                ...           9 months ago
  • 0.0.47                                ...           9 months ago
  • 0.0.46                                ...           9 months ago
  • 0.0.45                                ...           9 months ago
  • 0.0.44                                ...           9 months ago
  • 0.0.43                                ...           9 months ago
  • 0.0.42                                ...           9 months ago
  • 0.0.41                                ...           9 months ago
  • 0.0.40                                ...           9 months ago
  • 0.0.39                                ...           9 months ago
  • 0.0.38                                ...           9 months ago
  • 0.0.37                                ...           9 months ago
  • 0.0.36                                ...           9 months ago
  • 0.0.35                                ...           9 months ago
  • 0.0.34                                ...           9 months ago
  • 0.0.33                                ...           9 months ago
  • 0.0.32                                ...           9 months ago
  • 0.0.31                                ...           9 months ago
  • 0.0.30                                ...           9 months ago
  • 0.0.29                                ...           9 months ago
  • 0.0.28                                ...           9 months ago
  • 0.0.27                                ...           9 months ago
  • 0.0.26                                ...           9 months ago
  • 0.0.25                                ...           9 months ago
  • 0.0.24                                ...           9 months ago
  • 0.0.23                                ...           9 months ago
  • 0.0.22                                ...           9 months ago
  • 0.0.21                                ...           9 months ago
  • 0.0.20                                ...           9 months ago
  • 0.0.19                                ...           10 months ago
  • 0.0.18                                ...           10 months ago
  • 0.0.17                                ...           10 months ago
  • 0.0.16                                ...           10 months ago
  • 0.0.15                                ...           10 months ago
  • 0.0.14                                ...           10 months ago
  • 0.0.13                                ...           10 months ago
  • 0.0.12                                ...           10 months ago
  • 0.0.11                                ...           10 months ago
  • 0.0.10                                ...           10 months ago
  • 0.0.9                                ...           10 months ago
  • 0.0.8                                ...           10 months ago
  • 0.0.7                                ...           10 months ago
  • 0.0.6                                ...           10 months ago
  • 0.0.5                                ...           a year ago
  • 0.0.4                                ...           a year ago
  • 0.0.3                                ...           a year ago
  • 0.0.2                                ...           a year ago
  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 83
Dependencies (0)
None
Dev Dependencies (10)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |