代码拉取完成,页面将自动刷新
var Rotation = 0.0;
main();
function main() {
const canvas = document.querySelector('#canvas9');
const gl = canvas.getContext('webgl');
if (!gl) {
alert('加载失败,请更换浏览器');
return;
}
const tshaderProgramInfo = createTexShaderProgramInfo(gl);
const nshaderProgramInfo = createNormalShaderProgramInfo(gl);
const cube_buffer = Cube_bufferInit(gl, 1.2);
const ball_buffer = Ball_bufferInit(gl, 1, 5);
var then = 0;
function render(now) {
var packedInfos = [];
const cubeLocation = [1.0, 1.0, -11.0];
const ballLocation = [-1.0, 1.0, -8.0];
//创建正方体
cube_modelmatrixInfo = {
translateAttri: cubeLocation,
rotateSpeed: [1.0, 0.7, 0.8],
};
const cube_matrix = createModelViewMatrix(cube_modelmatrixInfo);
const cube_packedInfo = packInfo(cube_buffer, cube_matrix, tshaderProgramInfo);
packedInfos.push(cube_packedInfo);
//////////
//创建球体
ball_modelmatrixInfo = {
translateAttri: ballLocation,
rotateSpeed: [0.7, 0.8, 1.0],
transAfterRot: [0.0, 0.3, 0.0],
};
const ball_matrix = createModelViewMatrix(ball_modelmatrixInfo);
const ball_packedInfo = packInfo(ball_buffer, ball_matrix, nshaderProgramInfo);
packedInfos.push(ball_packedInfo);
//////////
now *= 0.001;
const deltaTime = now - then;
then = now;
drawScene(gl, packedInfos, deltaTime);
requestAnimationFrame(render);
}
requestAnimationFrame(render);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。