MCPcopy Index your code
hub / github.com/but0n/Ashes

github.com/but0n/Ashes @v0.5.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.5.0 ↗ · + Follow
256 symbols 439 edges 33 files 0 documented · 0% updated 3y ago★ 3476 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

image

Build Status

Ray Tracing demo

  • Press k to toggle render mode
  • Press q and e to adjust aperture (depth of field)
  • Press a and d to focal length
  • Press [ andd ] to adjust exposure

glTF Example

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 --recursive https://github.com/but0n/Ashes.git
cd Ashes

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

yarn

yarn dev

Extension points exported contracts — how you extend this code

Entity (Interface)
(no doc)
src/ECS/entityMgr.ts

Core symbols most depended-on inside this repo

create
called by 21
src/ECS/entityMgr.ts
create
called by 15
src/math.ts
addComponent
called by 14
src/ECS/entityMgr.ts
setUniform
called by 12
src/material/material.ts
getSubChunks
called by 7
src/mesh/mesh.ts
setTexture
called by 7
src/material/material.ts
bind
called by 6
src/filter.ts
registSystem
called by 6
src/ECS/system.ts

Shape

Method 160
Class 93
Enum 1
Function 1
Interface 1

Languages

TypeScript100%

Modules by API surface

src/tree/bvh.ts27 symbols
src/mesh/mesh.ts24 symbols
src/asset.ts16 symbols
src/shader.ts14 symbols
src/bounds/aabb.ts14 symbols
src/meshRenderer.ts13 symbols
src/material/material.ts13 symbols
src/animation.ts12 symbols
src/texture.ts10 symbols
src/filter.ts10 symbols
src/webgl2/screen.ts9 symbols
src/transform.ts9 symbols

For agents

$ claude mcp add Ashes \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact