canvas实现三维空间点线旋转动画效果代码
代码语言:html
所属分类:动画
代码描述:canvas实现三维空间点线旋转动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
body {
margin: 0;
overflow: hidden;
background: #111;
}
canvas {
display: block;
filter: brightness(1.1) contrast(1.1);
}
</style>
</head>
<body translate="no">
<canvas id="canvas"></canvas>
<script>
// Enhanced Point Class
function Point(pos) {
this.x = pos.x - canvas.width / 2 || 0;
this.y = pos.y - canvas.height / 2 || 0;
this.z = pos.z || 0;
this.cX = 0;
this.cY = 0;
this.cZ = 0;
this.xPos = 0;
this.yPos = 0;
this.map2D();
}
Point.prototype.rotateX = function (angleX) {
var cosX = Math.cos(angleX),
sinX = Math.sin(angleX),
y1 = this.y * cosX - this.z * sinX,
z1 = this.z * cosX + this.y * sinX;
this.y = y1;
.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0