{
let canvas = html`<canvas width="${width}" height="400"/>`
let projection = glm.mat4.create();
let model = glm.mat4.create();
let view = glm.mat4.create();
let ident = glm.mat4.create();
let sphere = null;
let a = 0;
let b = 0;
async function setup(gl) {
gl.enable(gl.DEPTH_TEST);
gl.clearColor(0.3,0.3,0.3,1.0);
glm.mat4.perspective(projection,(45*Math.PI)/180,width/400,0.1,20);
gl.activeTexture(gl.TEXTURE0);
await gl_utils.textures.world(gl);
gl.activeTexture(gl.TEXTURE1);
await gl_utils.textures.load(gl,lua);
gl.activeTexture(gl.TEXTURE2);
await gl_utils.textures.load(gl,sol);
sphere = sphereGeometry(gl);
gl_utils.viewHandler(canvas,(x,y,z)=>{
glm.mat4.lookAt(view,[2*x,2*y,2*z],[0,0,0],[0,1,0]);
});
}
function draw(gl) {
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
glm.mat4.rotate(model,ident,a,[0,0.5,0]);
sphere.draw({model, view, projection, textura: 2});
glm.mat4.rotate(model,ident,-a,[0,1,0]);
glm.mat4.translate(model,model,[-5,0,0]);
glm.mat4.scale(model,model,[0.25,0.25,0.25]);
sphere.draw({model, view, projection, textura: 0});
glm.mat4.rotate(model,model,b,[0,2,0]);
glm.mat4.translate(model,model,[-6,0,0]);
glm.mat4.scale(model,model,[0.15,0.15,0.15]);
sphere.draw({model, view, projection, textura: 1});
a += 0.01;
b+=0.015;
}
return gl_utils.appLoop(canvas,{setup,draw});
}