mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-24 07:30:38 +00:00
webgl codecheck告警
Signed-off-by: zhoubin <zhoubin113@huawei.com>
This commit is contained in:
parent
8d21a57cf7
commit
fd34bf8166
@ -36,7 +36,7 @@ export class Demo {
|
||||
}
|
||||
|
||||
export async function main(gl, type) {
|
||||
if(!type) {
|
||||
if (!type) {
|
||||
type = Demo.WEBGL1_CUBE_DEMO;
|
||||
}
|
||||
switch (type) {
|
||||
|
@ -124,7 +124,7 @@ export async function shadowDemo(gl) {
|
||||
|
||||
function draw(gl, program, o, viewProjMatrix) {
|
||||
initAttributeVariable(gl, program.a_Position, o.vertexBuffer);
|
||||
if (program.a_Color != undefined) { // 如果a_Color定义为属性
|
||||
if (program.a_Color !== undefined) { // 如果a_Color定义为属性
|
||||
initAttributeVariable(gl, program.a_Color, o.colorBuffer);
|
||||
}
|
||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, o.indexBuffer);
|
||||
@ -143,7 +143,7 @@ function draw2(gl, program, o, viewProjMatrix, image) {
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
||||
gl.uniform1i(program.u_Sampler, 1);
|
||||
if (program.a_Color != undefined) { // 如果a_Color定义为属性
|
||||
if (program.a_Color !== undefined) { // 如果a_Color定义为属性
|
||||
initAttributeVariable(gl, program.a_Color, o.colorBuffer);
|
||||
}
|
||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, o.indexBuffer);
|
||||
|
@ -126,7 +126,7 @@ export async function shadow2Demo(gl) {
|
||||
|
||||
function draw(gl, program, o, viewProjMatrix) {
|
||||
initAttributeVariable(gl, program.a_Position, o.vertexBuffer);
|
||||
if (program.a_Color != undefined) { // 如果a_Color定义为属性
|
||||
if (program.a_Color !== undefined) { // 如果a_Color定义为属性
|
||||
initAttributeVariable(gl, program.a_Color, o.colorBuffer);
|
||||
}
|
||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, o.indexBuffer);
|
||||
@ -145,7 +145,7 @@ function draw2(gl, program, o, viewProjMatrix, image) {
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
||||
gl.uniform1i(program.u_Sampler, 1);
|
||||
if (program.a_Color != undefined) { // 如果a_Color定义为属性
|
||||
if (program.a_Color !== undefined) { // 如果a_Color定义为属性
|
||||
initAttributeVariable(gl, program.a_Color, o.colorBuffer);
|
||||
}
|
||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, o.indexBuffer);
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export class Images{
|
||||
export class Images {
|
||||
static MF_IMG = '/data/storage/el1/bundle/com.example.webgl/assets/entry/resources/rawfile/mf.jpg';
|
||||
static VR_IMG = '/data/storage/el1/bundle/com.example.webgl/assets/entry/resources/rawfile/vr.jpg';
|
||||
static FLOOR = '/data/storage/el1/bundle/com.example.webgl/assets/entry/resources/rawfile/floor.jpg';
|
||||
|
@ -118,17 +118,17 @@ export class Matrix4 {
|
||||
if (x < 0) {
|
||||
s = -s;
|
||||
}
|
||||
this.rotateX(e, s, c)
|
||||
this.rotateX(e, s, c);
|
||||
} else if (0 === x && 0 !== y && 0 === z) {
|
||||
if (y < 0) {
|
||||
s = -s;
|
||||
}
|
||||
this.rotateY(e, s, c)
|
||||
this.rotateY(e, s, c);
|
||||
} else if (0 === x && 0 === y && 0 !== z) {
|
||||
if (z < 0) {
|
||||
s = -s;
|
||||
}
|
||||
this.rotateZ(e, s, c)
|
||||
this.rotateZ(e, s, c);
|
||||
} else {
|
||||
len = Math.sqrt(x * x + y * y + z * z);
|
||||
if (len !== 1) {
|
||||
@ -205,7 +205,7 @@ export class Matrix4 {
|
||||
let B4 = a[9] * a[15] - a[11] * a[13];
|
||||
let B5 = a[10] * a[15] - a[11] * a[14];
|
||||
let det = A0 * B5 - A1 * B4 + A2 * B3 + A3 * B2 - A4 * B1 + A5 * B0;
|
||||
if (det == 0) {
|
||||
if (det === 0) {
|
||||
return null;
|
||||
}
|
||||
let invDet = 1 / det;
|
||||
@ -364,7 +364,7 @@ export class Matrix4 {
|
||||
let cosB = Math.cos(radian);
|
||||
let sinB = Math.sin(radian);
|
||||
let len = Math.sqrt(x * x + y * y + z * z);
|
||||
if (len != 1) {
|
||||
if (len !== 1) {
|
||||
let rlen = 1 / len;
|
||||
x *= rlen;
|
||||
y *= rlen;
|
||||
@ -430,7 +430,7 @@ export class Matrix4 {
|
||||
arr[11] = -s[0] * s[5] * s[11] + s[0] * s[7] * s[9] + s[4] * s[1] * s[11] - s[4] * s[3] * s[9] - s[8] * s[1] * s[7] + s[8] * s[3] * s[5];
|
||||
arr[15] = s[0] * s[5] * s[10] - s[0] * s[6] * s[9] - s[4] * s[1] * s[10] + s[4] * s[2] * s[9] + s[8] * s[1] * s[6] - s[8] * s[2] * s[5];
|
||||
det = s[0] * arr[0] + s[1] * arr[4] + s[2] * arr[8] + s[3] * arr[12];
|
||||
if (det == 0) {
|
||||
if (det === 0) {
|
||||
return false;
|
||||
}
|
||||
det = 1 / det;
|
||||
@ -449,11 +449,11 @@ export class Matrix4 {
|
||||
let cosB = Math.cos(radian);
|
||||
let sinB = Math.sin(radian);
|
||||
let cosA = 1, sinA = 0;
|
||||
if (ry != 0) {
|
||||
if (ry !== 0) {
|
||||
cosA = this.elements[5];
|
||||
sinA = this.elements[6];
|
||||
}
|
||||
if (rz != 0) {
|
||||
if (rz !== 0) {
|
||||
cosA = this.elements[0];
|
||||
sinA = this.elements[1];
|
||||
}
|
||||
@ -481,11 +481,11 @@ export class Matrix4 {
|
||||
let cosB = Math.cos(radian);
|
||||
let sinB = Math.sin(radian);
|
||||
let cosA = 1, sinA = 0;
|
||||
if (ry != 0) {
|
||||
if (ry !== 0) {
|
||||
cosA = this.elements[5];
|
||||
sinA = this.elements[6];
|
||||
}
|
||||
if (rz != 0) {
|
||||
if (rz !== 0) {
|
||||
cosA = this.elements[0];
|
||||
sinA = this.elements[1];
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ export class Scene {
|
||||
let fun = () => {
|
||||
render();
|
||||
this.render();
|
||||
if(!this.gl.closed) {
|
||||
if (!this.gl.closed) {
|
||||
requestAnimationFrame(fun);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user