You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let{ Asset, EntityMgr, Camera, vec3, quat, Screen, OrbitControl, MeshRenderer, Filter, Shader, Material, QuadMesh }=Ashes;letCDN='https://but0n.github.io/Ashes/'Material.SHADER_PATH=CDN+Material.SHADER_PATH;// DamagedHelmetletgltf=CDN+'gltfsamples/DamagedHelmet.glb';asyncfunctionmain(){letscreen=newScreen('#screen');screen.bgColor=[0.2,0.2,0.2,1];letskybox=awaitAsset.loadCubemap(CDN+'res/envmap/GoldenGateBridge2/');letscene=EntityMgr.create('root - (Click each bar which has yellow border to toggle visible)');// CameraletmainCamera=EntityMgr.create('camera');letcam=mainCamera.addComponent(newCamera(screen.width/screen.height));// Set default positionletcameraTrans=mainCamera.components.Transform;vec3.set(cameraTrans.translate,0,10,10);// Add it to scenescene.appendChild(mainCamera);// Attach controlermainCamera.addComponent(newOrbitControl(screen,mainCamera));document.querySelector('body').appendChild(scene);// Load a gltf modelletgltfroot=awaitAsset.loadGLTF(gltf,screen,skybox);scene.appendChild(gltfroot);}main();
Create a quad with texture
// Create an entityletquad=scene.appendChild(EntityMgr.create('quad'));// Load a materialletquadMat=awaitAsset.LoadMaterial('stylize');// PBR material// Load a textureletfloor=awaitAsset.loadTexture(CDN+'res/textures/floor.png',{minFilter: screen.gl.NEAREST_MIPMAP_NEAREST});floor.flipY=true;// Attach texture to material we createdMaterial.setTexture(quadMat,'baseColorTexture',floor);quadMat.shader.macros['HAS_BASECOLOR_MAP']='';// Create a renderer componentletquadMR=newMeshRenderer(screen,newQuadMesh(),quadMat);// Attach renderer to entityquad.addComponent(quadMR);// Set local translate [x, y, z]quad.components.Transform.translate[1]=-1;// Set euler angle x, y, zquat.fromEuler(quad.components.Transform.quaternion,-90,0,0);// The original size of quad is 2x2vec3.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