1 Star 2 Fork 0

Arthas/BUAA_计算机图形学

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
demo9.js 1.62 KB
一键复制 编辑 原始数据 按行查看 历史
Arthas 提交于 2021-12-29 16:04 . add texture and homework9
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);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xu-wenchong/buaa-computer-graphics.git
git@gitee.com:xu-wenchong/buaa-computer-graphics.git
xu-wenchong
buaa-computer-graphics
BUAA_计算机图形学
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385