diff --git a/.eslintrc.json b/.eslintrc.json
index 254a952a202ea94ab12564caf3fafbdea82bdb1c..dd393e6507d09459c9a1da98d5e02e766622e98b 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -131,7 +131,7 @@
"no-redeclare": 1,
"no-return-assign": 0,
"no-script-url": 1,
- "no-self-assign": 1,
+ "no-self-assign": 0,
"no-self-compare": 1,
"no-sequences": 1,
"no-unmodified-loop-condition": 1,
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 4745c7f8956218166cc34488bec1aef0a19a4edd..1e6c6e60fa40565251b7eb86cddf303e7434b91a 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -6,4 +6,5 @@
"typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
"javascript.format.placeOpenBraceOnNewLineForFunctions": true,
"javascript.format.placeOpenBraceOnNewLineForControlBlocks": true,
+ "liveServer.settings.port": 5502,
}
\ No newline at end of file
diff --git a/README.md b/README.md
index 483667113df58e76b15628a1e560babd3d6e89a1..c03993a6f11fd4adafcba399ff880f8c7ab83ca2 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,89 @@
-# @feng3d/renderer
+# @feng3d/webgl
+feng3d引擎的WebGL渲染器,可以让用户无需直接接触WebGL的API,只需提供渲染所需数据,组织好渲染数据结构便可渲染,并且支持动态修改数据从而实现动态渲染。
+
+## 示例
+
+[@feng3d/webgl示例](https://feng3d.com/webgl/)
+
+这里实现完整的 [webgl1](https://mdn.github.io/dom-examples/webgl-examples/tutorial/sample1/) [webgl2](https://github.com/WebGLSamples/WebGL2Samples.git) 官方示例(https://github.com/webgpu/webgpu-samples)。
+
+## 安装
+```
+npm i @feng3d/webgl@0.0.3
+```
+
+## 如何使用
+
+```typescript
+import { ISubmit } from "@feng3d/render-api";
+import { WebGL } from "@feng3d/webgl";
+
+const init = async (canvas: HTMLCanvasElement) =>
+{
+ const devicePixelRatio = window.devicePixelRatio || 1;
+ canvas.width = canvas.clientWidth * devicePixelRatio;
+ canvas.height = canvas.clientHeight * devicePixelRatio;
+
+ const webgl = new WebGL({ canvasId: "glcanvas", contextId: "webgl" }); // 初始化WebGL
+
+ const submit: ISubmit = { // 一次GPU提交
+ commandEncoders: [ // 命令编码列表
+ {
+ passEncoders: [ // 通道编码列表
+ { // 渲染通道
+ descriptor: { // 渲染通道描述
+ colorAttachments: [{ // 颜色附件
+ clearValue: [0.0, 0.0, 0.0, 1.0], // 渲染前填充颜色
+ }],
+ },
+ renderObjects: [{ // 渲染对象
+ pipeline: { // 渲染管线
+ vertex: { // 顶点着色器
+ code: `
+ attribute vec4 position;
+
+ void main() {
+ gl_Position = position;
+ }
+ ` },
+ fragment: { // 片段着色器
+ code: `
+ precision highp float;
+ uniform vec4 color;
+ void main() {
+ gl_FragColor = color;
+ // gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+ }
+ ` },
+ },
+ vertices: {
+ position: { data: new Float32Array([0.0, 0.5, -0.5, -0.5, 0.5, -0.5]), format: "float32x2" }, // 顶点坐标数据
+ },
+ indices: new Uint16Array([0, 1, 2]), // 顶点索引数据
+ uniforms: { color: [1, 0, 0, 1] }, // Uniform 颜色值。
+ drawIndexed: { indexCount: 3 }, // 绘制命令
+ }]
+ },
+ ]
+ }
+ ],
+ };
+
+ webgl.submit(submit); // 提交GPU执行
+};
+
+let webglCanvas = document.querySelector("#glcanvas") as HTMLCanvasElement;
+if (!webglCanvas)
+{
+ webglCanvas = document.createElement("canvas");
+ webglCanvas.id = "webgpu";
+ webglCanvas.style.width = "400px";
+ webglCanvas.style.height = "300px";
+ document.body.appendChild(webglCanvas);
+}
+init(webglCanvas);
+```
## 不再支持内容
1. 为了兼容WebGPU,GLSL着色器中数据结构不再支持纹理。
diff --git a/examples/index.html b/examples/index.html
index 04c3fdcd666b7fc5c2314745c74fe2575fdb6bae..c83f129c9375a11eb7d773bb393e5539138fee93 100644
--- a/examples/index.html
+++ b/examples/index.html
@@ -228,7 +228,7 @@
-
+
diff --git a/examples/index.ts b/examples/index.ts
index 541c5562afabdfc62777e1f2e93f41901e9655fc..1a4d9d4454609a1f6ec1f06496656cc81d6a0f97 100644
--- a/examples/index.ts
+++ b/examples/index.ts
@@ -105,7 +105,7 @@ button.id = "button";
button.textContent = "View source";
button.addEventListener("click", function (event)
{
- window.open(`https://gitlab.com/feng3d/renderer/tree/master/examples/src/${selected}.ts`);
+ window.open(`https://gitee.com/feng3d/webgl/tree/master/examples/src/${selected}.ts`);
}, false);
button.style.display = "none";
document.body.appendChild(button);
diff --git a/examples/package.json b/examples/package.json
index 97ac9167df7ec7c190b859b2da0759c4b040f450..bd16a78e221323f02a8ef95cbca4e193bd7eefde 100644
--- a/examples/package.json
+++ b/examples/package.json
@@ -13,6 +13,6 @@
},
"dependencies": {
"gl-matrix": "^3.4.3",
- "@feng3d/webgl": "0.0.2"
+ "@feng3d/webgl": "0.0.3"
}
}
\ No newline at end of file
diff --git a/examples/src/WebGL2Samples/buffer_uniform.ts b/examples/src/WebGL2Samples/buffer_uniform.ts
index 6e110e74c943605105401481b6eca335ffad88ff..4928f9c1ba054ec0063ef7afe2a47918d7e627cb 100644
--- a/examples/src/WebGL2Samples/buffer_uniform.ts
+++ b/examples/src/WebGL2Samples/buffer_uniform.ts
@@ -107,11 +107,11 @@ import { getShaderSource } from "./utility";
// -- update uniform buffer
transforms.transform.MV[0] = 0.1 * Math.cos(uTime) + 0.4;
- transforms.transform.MV = transforms.transform.MV;
+ transforms.transform.MV = transforms.transform.MV; // 强制更新
lightPos.light.position[0] = Math.cos(3 * uTime);
lightPos.light.position[1] = Math.sin(6 * uTime);
- lightPos.light.position = lightPos.light.position;
+ lightPos.light.position = lightPos.light.position; // 强制更新
webgl.submit(submit);
diff --git a/examples/src/WebGL2Samples/draw_instanced_ubo.ts b/examples/src/WebGL2Samples/draw_instanced_ubo.ts
index 339fe6554b329c2a5420b53809b283f937602981..0f730efdbda6b5f8dbbf100cd81ffe3c224d7f24 100644
--- a/examples/src/WebGL2Samples/draw_instanced_ubo.ts
+++ b/examples/src/WebGL2Samples/draw_instanced_ubo.ts
@@ -40,7 +40,7 @@ const transforms = {
const materials = {
Diffuse: [
- [1.0, 0.5, 0.0, 1.0,],
+ [1.0, 0.5, 0.0, 1.0],
[0.0, 0.5, 1.0, 1.0],
]
};
diff --git a/examples/src/WebGL2Samples/draw_primitive_restart.ts b/examples/src/WebGL2Samples/draw_primitive_restart.ts
index 85def9dc9d65583a3fac6188590d3d72d10fe4d8..7a2e4e52ce3915b94d1b909b1c12158673dd9eb8 100644
--- a/examples/src/WebGL2Samples/draw_primitive_restart.ts
+++ b/examples/src/WebGL2Samples/draw_primitive_restart.ts
@@ -45,7 +45,7 @@ const vertexArray: { vertices?: IVertexAttributes } = {
const renderObject: IRenderObject = {
vertices: vertexArray.vertices,
- indices: indices,
+ indices,
uniforms: {},
drawIndexed: { indexCount: 7, instanceCount: 2 },
pipeline: program,
@@ -63,7 +63,7 @@ webgl.submit({
renderObjects: [renderObject]
}]
}]
-})
+});
// -- Delete WebGL resources
webgl.deleteProgram(program);
diff --git a/examples/src/WebGL2Samples/fbo_blit.ts b/examples/src/WebGL2Samples/fbo_blit.ts
index 127c5e12c069a428bd5723c102154e9b111c1e8f..394d776a7f7687122037b40f1b6234451bcf585c 100644
--- a/examples/src/WebGL2Samples/fbo_blit.ts
+++ b/examples/src/WebGL2Samples/fbo_blit.ts
@@ -55,7 +55,7 @@ loadImage("../../assets/img/Di-3d.png", (image) =>
size: [image.width, image.height],
format: "rgba8unorm",
sources: [{
- image: image, flipY: true
+ image, flipY: true
}],
};
const samplerDiffuse: ISampler = {
diff --git a/examples/src/WebGL2Samples/fbo_multisample.ts b/examples/src/WebGL2Samples/fbo_multisample.ts
index 8b4b9724d9397fbec4d1723e41d848e0cf76326d..00a8f2ff43edd9f4d64ff3133e0991e8735476cc 100644
--- a/examples/src/WebGL2Samples/fbo_multisample.ts
+++ b/examples/src/WebGL2Samples/fbo_multisample.ts
@@ -85,7 +85,7 @@ const framebuffer: IRenderPassDescriptor = {
// -- Init VertexArray
const vertexArrays: { vertices?: IVertexAttributes }[] = [
{
- vertices: { position: { data: data, format: "float32x2" } }
+ vertices: { position: { data, format: "float32x2" } }
},
{
vertices: {
diff --git a/examples/src/WebGL2Samples/fbo_new_blend_equation.ts b/examples/src/WebGL2Samples/fbo_new_blend_equation.ts
index 211e3409d7172f33cf3995f2da80b0e5202241d7..1180ada0cac52210dcf02727493b954bed986172 100644
--- a/examples/src/WebGL2Samples/fbo_new_blend_equation.ts
+++ b/examples/src/WebGL2Samples/fbo_new_blend_equation.ts
@@ -102,7 +102,7 @@ loadImage(imageUrl, function (image)
{
texture = {
size: [image.width, image.height],
- sources: [{ image: image, mipLevel: 0 }],
+ sources: [{ image, mipLevel: 0 }],
format: "rgba8unorm",
generateMipmap: true,
};
@@ -129,7 +129,7 @@ function render()
const renderObjects: IRenderPassObject[] = [];
const renderPass: IRenderPass = {
descriptor: { colorAttachments: [{ clearValue: [0.5, 0.0, 0.0, 1.0], loadOp: "clear" }] },
- renderObjects: renderObjects,
+ renderObjects,
};
for (let i = 0; i < Corners.MAX; ++i)
@@ -194,7 +194,6 @@ function render()
webgl.submit({ commandEncoders: [{ passEncoders: [renderPass] }] });
-
// -- Clean up
webgl.deleteTexture(texture);
webgl.deleteProgram(program);
diff --git a/examples/src/WebGL2Samples/fbo_read_pixels.ts b/examples/src/WebGL2Samples/fbo_read_pixels.ts
index beb7eb6d57aae3e97988207f9df92efffffc1a44..21e86a53211cb3ba90d1d35863202f173089d10d 100644
--- a/examples/src/WebGL2Samples/fbo_read_pixels.ts
+++ b/examples/src/WebGL2Samples/fbo_read_pixels.ts
@@ -144,7 +144,7 @@ const renderObjects: IRenderPassObject[] = [];
// Pass 2
const rp: IRenderPass = {
descriptor: { colorAttachments: [{ clearValue: [0.0, 0.0, 0.0, 1.0], loadOp: "clear" }] },
- renderObjects: renderObjects
+ renderObjects
};
const ro: IRenderObject = {
diff --git a/examples/src/WebGL2Samples/fbo_rtt_texture_array.ts b/examples/src/WebGL2Samples/fbo_rtt_texture_array.ts
index 1380527172eb7b17dfd36cb693b1d3ebe816a7ae..d18b0806c1d27a8af146ba359eb94edc81bbf3f5 100644
--- a/examples/src/WebGL2Samples/fbo_rtt_texture_array.ts
+++ b/examples/src/WebGL2Samples/fbo_rtt_texture_array.ts
@@ -148,7 +148,7 @@ const renderPass: IRenderPass = {
descriptor: {
colorAttachments: [{ clearValue: [0.0, 0.0, 0.0, 1.0], loadOp: "clear" }],
},
- renderObjects: renderObjects,
+ renderObjects,
};
const renderObject: IRenderObject = {
diff --git a/examples/src/WebGL2Samples/geo_vertex_format.ts b/examples/src/WebGL2Samples/geo_vertex_format.ts
index 3314559280ce6b2e142f7578dca644f111468a73..8b590d7e3d2d680edc833628ad677de1652e2dc4 100644
--- a/examples/src/WebGL2Samples/geo_vertex_format.ts
+++ b/examples/src/WebGL2Samples/geo_vertex_format.ts
@@ -148,7 +148,6 @@ import { getShaderSource, loadImage } from "./utility";
20, 21, 22, 20, 22, 23 // left
];
-
// -- Init VertexArray
const vertexArray: { vertices?: IVertexAttributes } = {
@@ -171,7 +170,7 @@ import { getShaderSource, loadImage } from "./utility";
format: "rgba8unorm",
mipLevelCount: 1,
size: [512, 512],
- sources: [{ image: image, flipY: false }],
+ sources: [{ image, flipY: false }],
};
sampler = {
minFilter: "nearest",
diff --git a/examples/src/WebGL2Samples/glsl_centroid.ts b/examples/src/WebGL2Samples/glsl_centroid.ts
index 84c2610edd03d9269d49745887e2b31c1b7a7299..de9255040b3d0cd58ee08f886200960ecf0ba018 100644
--- a/examples/src/WebGL2Samples/glsl_centroid.ts
+++ b/examples/src/WebGL2Samples/glsl_centroid.ts
@@ -135,13 +135,13 @@ const vertexArrays: { vertices?: IVertexAttributes }[] = [
{
vertices: {
position: { data: positions, format: "float32x2" },
- data: { data: data, format: "float32" },
+ data: { data, format: "float32" },
}
},
{
vertices: {
position: { data: positions, format: "float32x2" },
- data: { data: data, format: "float32" },
+ data: { data, format: "float32" },
}
},
{
@@ -175,7 +175,7 @@ for (let i = 0; i < VIEWPORTS.MAX; ++i)
const renderObjects: IRenderPassObject[] = [];
// Pass 2
const rp2: IRenderPass = {
- renderObjects: renderObjects,
+ renderObjects,
};
const ro: IRenderObject = {
pipeline: programs[PROGRAM.SPLASH],
diff --git a/examples/src/WebGL2Samples/glsl_flat_smooth_interpolators.ts b/examples/src/WebGL2Samples/glsl_flat_smooth_interpolators.ts
index c345e4774578741792ecf2acbaae96705410d645..769e1354748f264a0d60d08ec8331059828d764a 100644
--- a/examples/src/WebGL2Samples/glsl_flat_smooth_interpolators.ts
+++ b/examples/src/WebGL2Samples/glsl_flat_smooth_interpolators.ts
@@ -111,7 +111,7 @@ glTFLoader.loadGLTF(gltfUrl, function (glTF)
},
},
};
- vertexArrayMaps[mid].push({ vertexArray, indices: indices });
+ vertexArrayMaps[mid].push({ vertexArray, indices });
}
}
@@ -143,7 +143,7 @@ glTFLoader.loadGLTF(gltfUrl, function (glTF)
colorAttachments: [{ clearValue: [0.0, 0.0, 0.0, 1.0], loadOp: "clear" }],
depthStencilAttachment: { depthLoadOp: "clear" }
},
- renderObjects: renderObjects,
+ renderObjects,
};
mat4.rotateY(modelView, modelView, rotatationSpeedY);
diff --git a/examples/src/WebGL2Samples/glsl_non_square_matrix.ts b/examples/src/WebGL2Samples/glsl_non_square_matrix.ts
index b0971f89085c6b8ef4023b869e3a1b2d363d6ae2..87f68bd9e9945d9115ecf1718163a0514b9fce08 100644
--- a/examples/src/WebGL2Samples/glsl_non_square_matrix.ts
+++ b/examples/src/WebGL2Samples/glsl_non_square_matrix.ts
@@ -51,7 +51,7 @@ loadImage("../../assets/img/Di-3d.png", function (image)
size: [image.width, image.height],
format: "rgba8unorm",
sources: [{
- image: image, flipY: false,
+ image, flipY: false,
}]
};
const sampler: ISampler = { minFilter: "nearest", magFilter: "nearest" };
diff --git a/examples/src/WebGL2Samples/query_occlusion.ts b/examples/src/WebGL2Samples/query_occlusion.ts
index f76b58fbb6422392f963774411fb645af084f6f9..d15d4446f200cdbb4c13f76bed982be90a22b6dc 100644
--- a/examples/src/WebGL2Samples/query_occlusion.ts
+++ b/examples/src/WebGL2Samples/query_occlusion.ts
@@ -48,7 +48,7 @@ const rp: IRenderPass = {
colorAttachments: [{ clearValue: [0.0, 0.0, 0.0, 1.0], loadOp: "clear" }],
depthStencilAttachment: { depthLoadOp: "clear" },
},
- renderObjects: renderObjects,
+ renderObjects,
};
const ro: IRenderObject = {
diff --git a/examples/src/WebGL2Samples/sampler_filter.ts b/examples/src/WebGL2Samples/sampler_filter.ts
index b34d8bd30672cb9b41eaa70c9f0abbfc69ca5bcc..482de0fb757af4bcf0ed2cc14a82fc94310534b2 100644
--- a/examples/src/WebGL2Samples/sampler_filter.ts
+++ b/examples/src/WebGL2Samples/sampler_filter.ts
@@ -106,7 +106,6 @@ samplers[Corners.TOP_RIGHT].minFilter = "linear";
samplers[Corners.BOTTOM_RIGHT].minFilter = "linear";
samplers[Corners.BOTTOM_LEFT].minFilter = "linear";
-
// Mag filter
samplers[Corners.TOP_LEFT].magFilter = "nearest";
samplers[Corners.TOP_RIGHT].magFilter = "linear";
@@ -126,7 +125,7 @@ loadImage(imageUrl, function (image)
texture = {
size: [image.width, image.height],
format: "rgba8unorm",
- sources: [{ image: image, mipLevel: 0 }],
+ sources: [{ image, mipLevel: 0 }],
generateMipmap: true,
};
@@ -146,7 +145,7 @@ function render()
const renderObjects: IRenderPassObject[] = [];
const rp: IRenderPass = {
descriptor: { colorAttachments: [{ clearValue: [0.0, 0.0, 0.0, 1.0], loadOp: "clear" }] },
- renderObjects: renderObjects
+ renderObjects
};
const ro: IRenderObject = {
diff --git a/examples/src/WebGL2Samples/sampler_object.ts b/examples/src/WebGL2Samples/sampler_object.ts
index 05bf4ea150abf053f600437742565f8c691bbd24..79f995ff57fd62d55145a486d824a891b26cc91a 100644
--- a/examples/src/WebGL2Samples/sampler_object.ts
+++ b/examples/src/WebGL2Samples/sampler_object.ts
@@ -69,7 +69,7 @@ loadImage(imageUrl, function (image)
{
texture = {
size: [image.width, image.height],
- sources: [{ image: image, mipLevel: 0 }],
+ sources: [{ image, mipLevel: 0 }],
format: "rgba8unorm",
generateMipmap: true,
};
diff --git a/examples/src/WebGL2Samples/sampler_wrap.ts b/examples/src/WebGL2Samples/sampler_wrap.ts
index df7eacc8b44688c31461ff940ddcbdb56f0c7933..91fbd8f348fb060ed92e9c62ffd2c6c33595a9ef 100644
--- a/examples/src/WebGL2Samples/sampler_wrap.ts
+++ b/examples/src/WebGL2Samples/sampler_wrap.ts
@@ -101,7 +101,7 @@ for (let i = 0; i < Corners.MAX; ++i)
samplers[i] = {
minFilter: "linear",
magFilter: "linear",
- mipmapFilter:"linear",
+ mipmapFilter: "linear",
};
}
@@ -123,7 +123,7 @@ loadImage(imageUrl, function (image)
{
texture = {
size: [image.width, image.height],
- sources: [{ image: image, mipLevel: 0 }],
+ sources: [{ image, mipLevel: 0 }],
format: "rgba8unorm",
generateMipmap: true,
};
@@ -136,7 +136,7 @@ function render()
// Clear color buffer
const rp: IRenderPass = {
descriptor: { colorAttachments: [{ clearValue: [0.0, 0.0, 0.0, 1.0], loadOp: "clear" }] },
- renderObjects: renderObjects,
+ renderObjects,
};
const matrix = new Float32Array([
diff --git a/examples/src/WebGL2Samples/texture_3d.ts b/examples/src/WebGL2Samples/texture_3d.ts
index 3bf11f3f11eff0a19158df083444403652984eb4..48b1e93845a3138a86f79ad99638c82e0cf753b3 100644
--- a/examples/src/WebGL2Samples/texture_3d.ts
+++ b/examples/src/WebGL2Samples/texture_3d.ts
@@ -84,7 +84,7 @@ import { getShaderSource } from "./utility";
dimension: "3d",
format: "r8unorm",
generateMipmap: true,
- sources: [{ __type: "TextureDataSource", mipLevel: 0, size: [SIZE, SIZE, SIZE], data: data }],
+ sources: [{ __type: "TextureDataSource", mipLevel: 0, size: [SIZE, SIZE, SIZE], data }],
};
const sampler: ISampler = {
lodMinClamp: 0,
diff --git a/examples/src/WebGL2Samples/texture_derivative.ts b/examples/src/WebGL2Samples/texture_derivative.ts
index 26fcca613c91c0ac9129ab5ec0c7cb5341bc5fba..5e5762d981222e435db3f233ad94c091ff487cf3 100644
--- a/examples/src/WebGL2Samples/texture_derivative.ts
+++ b/examples/src/WebGL2Samples/texture_derivative.ts
@@ -115,7 +115,6 @@ import { getShaderSource, loadImage } from "./utility";
20, 21, 22, 20, 22, 23 // left
];
-
// -- Init VertexArray
const vertexArray: { vertices?: IVertexAttributes } = {
vertices: {
@@ -137,7 +136,7 @@ import { getShaderSource, loadImage } from "./utility";
mipLevelCount: 1,
size: [512, 512],
sources: [{
- image: image, flipY: false,
+ image, flipY: false,
}]
};
sampler = {
diff --git a/examples/src/WebGL2Samples/texture_fetch.ts b/examples/src/WebGL2Samples/texture_fetch.ts
index 03762c81dee291617f56b774c1c30c1736225fcf..4283d049198d71ec71ebb6f81ab71ee4e8055b2e 100644
--- a/examples/src/WebGL2Samples/texture_fetch.ts
+++ b/examples/src/WebGL2Samples/texture_fetch.ts
@@ -51,7 +51,7 @@ import { getShaderSource, loadImage } from "./utility";
size: [image.width, image.height],
format: "rgba8unorm",
sources: [{
- mipLevel: 0, image: image, flipY: false,
+ mipLevel: 0, image, flipY: false,
}],
};
const sampler: ISampler = {
diff --git a/examples/src/WebGL2Samples/texture_format.ts b/examples/src/WebGL2Samples/texture_format.ts
index 0630d44a098f1c5d9c684f24460a2cfb1662a0ec..30b0bade2ee06f33d4031ec039c4ff3c6d104aaa 100644
--- a/examples/src/WebGL2Samples/texture_format.ts
+++ b/examples/src/WebGL2Samples/texture_format.ts
@@ -144,7 +144,7 @@ import { getShaderSource, loadImage } from "./utility";
size: [image.width, image.height],
format: textureFormats[i].format,
sources: [{
- mipLevel: 0, image: image, flipY: false,
+ mipLevel: 0, image, flipY: false,
}],
};
samplers[i] = {
@@ -166,7 +166,7 @@ import { getShaderSource, loadImage } from "./utility";
const renderObjects: IRenderPassObject[] = [];
const rp: IRenderPass = {
descriptor: { colorAttachments: [{ clearValue: [0.0, 0.0, 0.0, 1.0], loadOp: "clear" }] },
- renderObjects: renderObjects
+ renderObjects
};
for (i = 0; i < TextureTypes.RGB8UI; ++i)
diff --git a/examples/src/WebGL2Samples/texture_grad.ts b/examples/src/WebGL2Samples/texture_grad.ts
index f2bf9a68b75490ea0d6f30bfa59191b5ca11a522..7f38b7dc71792f94c2259fdea25a210b38a8c44e 100644
--- a/examples/src/WebGL2Samples/texture_grad.ts
+++ b/examples/src/WebGL2Samples/texture_grad.ts
@@ -131,7 +131,7 @@ import { getShaderSource, loadImage } from "./utility";
mipLevelCount: 1,
size: [512, 512],
sources: [{
- image: image, flipY: false,
+ image, flipY: false,
}]
};
sampler = {
diff --git a/examples/src/WebGL2Samples/texture_immutable.ts b/examples/src/WebGL2Samples/texture_immutable.ts
index e8a9981f3cc502f09e9d4e6c3d418cbab8672798..9ad3d4db2bcca073e299fdd28dc91bbe5a4b570e 100644
--- a/examples/src/WebGL2Samples/texture_immutable.ts
+++ b/examples/src/WebGL2Samples/texture_immutable.ts
@@ -88,7 +88,7 @@ import { getShaderSource, loadImage } from "./utility";
mipLevelCount: 1,
size: [512, 512],
sources: [{
- image: image, flipY: false,
+ image, flipY: false,
}],
};
const sampler2D: ISampler = {
@@ -111,7 +111,7 @@ import { getShaderSource, loadImage } from "./utility";
const renderObjects: IRenderPassObject[] = [];
const rp: IRenderPass = {
descriptor: { colorAttachments: [{ clearValue: [0.0, 0.0, 0.0, 1.0], loadOp: "clear" }] },
- renderObjects: renderObjects
+ renderObjects
};
renderObjects.push(
@@ -172,7 +172,7 @@ import { getShaderSource, loadImage } from "./utility";
generateMipmap: true,
mipLevelCount: Math.log2(SIZE),
size: [SIZE, SIZE, SIZE],
- sources: [{ __type: "TextureDataSource", size: [SIZE, SIZE, SIZE], data: data }],
+ sources: [{ __type: "TextureDataSource", size: [SIZE, SIZE, SIZE], data }],
};
const sampler3D: ISampler = {
lodMinClamp: 0,
diff --git a/examples/src/WebGL2Samples/texture_integer.ts b/examples/src/WebGL2Samples/texture_integer.ts
index c3c4e4aaf3e771037ce19c096f9c6bc0796a5934..5fe9048bf2fde6139ae9fe3370be46d7728345bb 100644
--- a/examples/src/WebGL2Samples/texture_integer.ts
+++ b/examples/src/WebGL2Samples/texture_integer.ts
@@ -53,7 +53,7 @@ import { getShaderSource, loadImage } from "./utility";
size: [image.width, image.height],
format: "rgba8uint",
sources: [{
- mipLevel: 0, image: image, flipY: false,
+ mipLevel: 0, image, flipY: false,
}],
};
const sampler: ISampler = {
diff --git a/examples/src/WebGL2Samples/texture_lod.ts b/examples/src/WebGL2Samples/texture_lod.ts
index 2720e97cda60a146b751859a9ba0c3b5da5720bc..a2c740a4988aed9d54f32b8c199eebec86d5cd6e 100644
--- a/examples/src/WebGL2Samples/texture_lod.ts
+++ b/examples/src/WebGL2Samples/texture_lod.ts
@@ -128,7 +128,7 @@ import { getShaderSource, loadImage } from "./utility";
size: [image.width, image.height],
format: "rgba8unorm",
generateMipmap: true,
- sources: [{ mipLevel: 0, image: image }],
+ sources: [{ mipLevel: 0, image }],
};
samplers[Corners.TOP_LEFT] = {
minFilter: "linear",
@@ -140,7 +140,7 @@ import { getShaderSource, loadImage } from "./utility";
size: [image.width, image.height],
format: "rgba8unorm",
generateMipmap: true,
- sources: [{ mipLevel: 0, image: image }],
+ sources: [{ mipLevel: 0, image }],
};
samplers[Corners.TOP_RIGHT] = {
minFilter: "linear",
@@ -154,7 +154,7 @@ import { getShaderSource, loadImage } from "./utility";
size: [image.width, image.height],
format: "rgba8unorm",
generateMipmap: true,
- sources: [{ mipLevel: 0, image: image }],
+ sources: [{ mipLevel: 0, image }],
};
samplers[Corners.BOTTOM_LEFT] = {
minFilter: "linear",
@@ -168,7 +168,7 @@ import { getShaderSource, loadImage } from "./utility";
size: [image.width, image.height],
format: "rgba8unorm",
generateMipmap: true,
- sources: [{ mipLevel: 0, image: image }],
+ sources: [{ mipLevel: 0, image }],
};
samplers[Corners.BOTTOM_RIGHT] = {
minFilter: "linear",
@@ -187,7 +187,7 @@ import { getShaderSource, loadImage } from "./utility";
// Clear color buffer
const rp: IRenderPass = {
descriptor: { colorAttachments: [{ clearValue: [0.0, 0.0, 0.0, 1.0], loadOp: "clear" }] },
- renderObjects: renderObjects,
+ renderObjects,
};
const matrix = new Float32Array([
diff --git a/examples/src/WebGL2Samples/texture_offset.ts b/examples/src/WebGL2Samples/texture_offset.ts
index dd59350df470a175ed99c9d12a8e14c1d9bf17f3..b423614a07d28cf66cb5a6bedcef608ad37f266b 100644
--- a/examples/src/WebGL2Samples/texture_offset.ts
+++ b/examples/src/WebGL2Samples/texture_offset.ts
@@ -75,7 +75,7 @@ import { getShaderSource, loadImage } from "./utility";
const texture: ITexture = {
size: [image.width, image.height],
format: "rgba8unorm",
- sources: [{ mipLevel: 0, image: image, flipY: false, }],
+ sources: [{ mipLevel: 0, image, flipY: false }],
};
const sampler: ISampler = {
minFilter: "nearest",
@@ -88,7 +88,7 @@ import { getShaderSource, loadImage } from "./utility";
// -- Render
const rp: IRenderPass = {
descriptor: { colorAttachments: [{ clearValue: [0.0, 0.0, 0.0, 1.0], loadOp: "clear" }] },
- renderObjects: renderObjects
+ renderObjects
};
const matrix = new Float32Array([
diff --git a/examples/src/WebGL2Samples/texture_pixel_store.ts b/examples/src/WebGL2Samples/texture_pixel_store.ts
index cfe63ca0dc8a1bc9efbe4914aa82198b1c342f80..89d05f524a67c3f59c16fa0d073a7b919d702871 100644
--- a/examples/src/WebGL2Samples/texture_pixel_store.ts
+++ b/examples/src/WebGL2Samples/texture_pixel_store.ts
@@ -80,7 +80,7 @@ import { getShaderSource, loadImage } from "./utility";
// -- Render
const rp: IRenderPass = {
descriptor: { colorAttachments: [{ clearValue: [0.0, 0.0, 0.0, 1.0], loadOp: "clear" }] },
- renderObjects: renderObjects,
+ renderObjects,
};
const matrix = new Float32Array([
diff --git a/examples/src/WebGL2Samples/texture_srgb.ts b/examples/src/WebGL2Samples/texture_srgb.ts
index 4aca4048b87c045c3ea8ca79e1bd12fd82ea9abd..f5a947ec462371ea13b3f7482babc77afe399883 100644
--- a/examples/src/WebGL2Samples/texture_srgb.ts
+++ b/examples/src/WebGL2Samples/texture_srgb.ts
@@ -47,7 +47,7 @@ import { getShaderSource, loadImage } from "./utility";
const vertices: IVertexAttributes = {
position: { data: vertexPosBuffer, format: "float32x2" },
textureCoordinates: { data: vertexTexBuffer, format: "float32x2" },
- }
+ };
// -- Load texture then render
@@ -59,7 +59,7 @@ import { getShaderSource, loadImage } from "./utility";
texture = {
size: [image.width, image.height],
format: "rgba8unorm-srgb",
- sources: [{ mipLevel: 0, image: image }],
+ sources: [{ mipLevel: 0, image }],
};
sampler = { minFilter: "nearest", magFilter: "nearest" };
@@ -72,7 +72,7 @@ import { getShaderSource, loadImage } from "./utility";
// Clear color buffer
const rp: IRenderPass = {
descriptor: { colorAttachments: [{ clearValue: [0.0, 0.0, 0.0, 1.0], loadOp: "clear" }] },
- renderObjects: renderObjects,
+ renderObjects,
};
const matrix = new Float32Array([
diff --git a/examples/src/WebGL2Samples/texture_vertex.ts b/examples/src/WebGL2Samples/texture_vertex.ts
index 152a8cafbf310bb22505ca568bf5fabc6016a6e4..79edd93e89a2873300f94e80799655f3f6516cbb 100644
--- a/examples/src/WebGL2Samples/texture_vertex.ts
+++ b/examples/src/WebGL2Samples/texture_vertex.ts
@@ -111,7 +111,7 @@ import { getShaderSource, loadImage } from "./utility";
format: "rgba8unorm",
mipLevelCount: 1,
size: [256, 256],
- sources: [{ image: image, flipY: false, }],
+ sources: [{ image, flipY: false }],
};
sampler = {
minFilter: "nearest",
@@ -192,7 +192,7 @@ import { getShaderSource, loadImage } from "./utility";
colorAttachments: [{ clearValue: [0.0, 0.0, 0.0, 1.0], loadOp: "clear" }],
depthStencilAttachment: { depthLoadOp: "clear" }
},
- renderObjects: renderObjects,
+ renderObjects,
};
orientation[0] = 0.00020; // yaw
diff --git a/examples/src/WebGL2Samples/transform_feedback_instanced.ts b/examples/src/WebGL2Samples/transform_feedback_instanced.ts
index 28907b76e4d2cadaf8d0172d5b8c1fa41c128361..0fd0b220367e8204721eb6fbbfe3fda6994bc190 100644
--- a/examples/src/WebGL2Samples/transform_feedback_instanced.ts
+++ b/examples/src/WebGL2Samples/transform_feedback_instanced.ts
@@ -159,7 +159,7 @@ import { getShaderSource } from "./utility";
}
]
}]
- }
+ };
function transform()
{
diff --git a/examples/src/WebGL2Samples/transform_feedback_separated_2.ts b/examples/src/WebGL2Samples/transform_feedback_separated_2.ts
index 6dae6274d44a75a96dd78a2103943cf5abfcd4f1..055ade8dc2882ab523b1d720b6b64deb6dc0c27d 100644
--- a/examples/src/WebGL2Samples/transform_feedback_separated_2.ts
+++ b/examples/src/WebGL2Samples/transform_feedback_separated_2.ts
@@ -164,7 +164,7 @@ import { getShaderSource } from "./utility";
}
]
}]
- }
+ };
function transform()
{
diff --git a/examples/src/regl-examples/bunny.ts b/examples/src/regl-examples/bunny.ts
index 2fb76c82a77c9bc660c67b6a044b2074cf6037f0..388a1960add266a3624b8221e383d8c65198caa7 100644
--- a/examples/src/regl-examples/bunny.ts
+++ b/examples/src/regl-examples/bunny.ts
@@ -82,8 +82,8 @@ function draw()
[0, 2.5, 0],
[0, 1, 0]);
- renderObject.uniforms.projection =
- mat4.perspective([],
+ renderObject.uniforms.projection
+ = mat4.perspective([],
Math.PI / 4,
viewportWidth / viewportHeight,
0.01,
diff --git a/examples/src/regl-examples/cloth.ts b/examples/src/regl-examples/cloth.ts
index e4cf4d71c99f63ef8d5afe31a641ce2af8acb000..b67600e519e0fe23a8847c9abc61a1f338a90d10 100644
--- a/examples/src/regl-examples/cloth.ts
+++ b/examples/src/regl-examples/cloth.ts
@@ -370,8 +370,8 @@ import * as vec3 from "./stackgl/gl-vec3";
camera.tick();
renderObject.uniforms.view = camera.view();
- renderObject.uniforms.projection =
- mat4.perspective([],
+ renderObject.uniforms.projection
+ = mat4.perspective([],
Math.PI / 4,
viewportWidth / viewportHeight,
0.01,
diff --git a/examples/src/regl-examples/cube.ts b/examples/src/regl-examples/cube.ts
index 7c53d43e8d2a86671c808b7d177a488570c696f1..f1dfad842bb3d02f8dfd370a4ec7ed48466f6910 100644
--- a/examples/src/regl-examples/cube.ts
+++ b/examples/src/regl-examples/cube.ts
@@ -118,8 +118,8 @@ import * as mat4 from "./stackgl/gl-mat4";
[5 * Math.cos(t), 2.5 * Math.sin(t), 5 * Math.sin(t)],
[0, 0.0, 0],
[0, 1, 0]);
- renderObject.uniforms.projection =
- mat4.perspective([],
+ renderObject.uniforms.projection
+ = mat4.perspective([],
Math.PI / 4,
viewportWidth / viewportHeight,
0.01,
diff --git a/examples/src/test/fractalCube.ts b/examples/src/test/fractalCube.ts
index c9841d974f908494e907bcd271aa92865bd24333..35e98edbdc6fb244b64830bca35876f532b0c5a9 100644
--- a/examples/src/test/fractalCube.ts
+++ b/examples/src/test/fractalCube.ts
@@ -97,7 +97,7 @@ async function main()
},
]
}]
- }
+ };
let then = 0;
diff --git a/examples/src/webgl-examples/sample1.ts b/examples/src/webgl-examples/sample1.ts
index e42a861f509943fe6a85dcd75571196d8c8b4bab..9f334e70c24128ea28840ceffd10087c4f2db113 100644
--- a/examples/src/webgl-examples/sample1.ts
+++ b/examples/src/webgl-examples/sample1.ts
@@ -1,32 +1,67 @@
-// see https://github.com/mdn/dom-examples/blob/main/webgl-examples/tutorial/sample1/webgl-demo.js
-// https://mdn.github.io/dom-examples/webgl-examples/tutorial/sample1/
-
import { ISubmit } from "@feng3d/render-api";
-import { IGLCanvasContext, WebGL } from "@feng3d/webgl";
+import { WebGL } from "@feng3d/webgl";
-async function main()
+const init = async (canvas: HTMLCanvasElement) =>
{
- const renderingContext: IGLCanvasContext = { canvasId: "glcanvas", contextId: "webgl" };
+ const devicePixelRatio = window.devicePixelRatio || 1;
+ canvas.width = canvas.clientWidth * devicePixelRatio;
+ canvas.height = canvas.clientHeight * devicePixelRatio;
+
+ const webgl = new WebGL({ canvasId: "glcanvas", contextId: "webgl" }); // 初始化WebGL
- const webgl = new WebGL(renderingContext);
+ const submit: ISubmit = { // 一次GPU提交
+ commandEncoders: [ // 命令编码列表
+ {
+ passEncoders: [ // 通道编码列表
+ { // 渲染通道
+ descriptor: { // 渲染通道描述
+ colorAttachments: [{ // 颜色附件
+ clearValue: [0.0, 0.0, 0.0, 1.0], // 渲染前填充颜色
+ }],
+ },
+ renderObjects: [{ // 渲染对象
+ pipeline: { // 渲染管线
+ vertex: { // 顶点着色器
+ code: `
+ attribute vec4 position;
- const submit: ISubmit = {
- commandEncoders: [{
- passEncoders: [
- {
- descriptor: {
- colorAttachments: [{
- // view: { texture: {} },
- clearValue: [1, 0, 0, 0.5],
- loadOp: "clear",
- }],
+ void main() {
+ gl_Position = position;
+ }
+ ` },
+ fragment: { // 片段着色器
+ code: `
+ precision highp float;
+ uniform vec4 color;
+ void main() {
+ gl_FragColor = color;
+ // gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
+ }
+ ` },
+ },
+ vertices: {
+ position: { data: new Float32Array([0.0, 0.5, -0.5, -0.5, 0.5, -0.5]), format: "float32x2" }, // 顶点坐标数据
+ },
+ indices: new Uint16Array([0, 1, 2]), // 顶点索引数据
+ uniforms: { color: [1, 0, 0, 1] }, // Uniform 颜色值。
+ drawIndexed: { indexCount: 3 }, // 绘制命令
+ }]
},
- }
- ]
- }]
+ ]
+ }
+ ],
};
- webgl.submit(submit);
-}
+ webgl.submit(submit); // 提交GPU执行
+};
-window.onload = main;
+let webglCanvas = document.querySelector("#glcanvas") as HTMLCanvasElement;
+if (!webglCanvas)
+{
+ webglCanvas = document.createElement("canvas");
+ webglCanvas.id = "webgpu";
+ webglCanvas.style.width = "400px";
+ webglCanvas.style.height = "300px";
+ document.body.appendChild(webglCanvas);
+}
+init(webglCanvas);
\ No newline at end of file
diff --git a/examples/src/webgl-examples/sample2.ts b/examples/src/webgl-examples/sample2.ts
index d24120bceb3709fb6ede2cd80d2324c026f27016..be3e0e323351f21993b212042f8907b2d732cca8 100644
--- a/examples/src/webgl-examples/sample2.ts
+++ b/examples/src/webgl-examples/sample2.ts
@@ -44,7 +44,7 @@ function main()
},
vertices: {
aVertexPosition: {
- format:"float32x2",
+ format: "float32x2",
data: new Float32Array([
1.0, 1.0,
-1.0, 1.0,
diff --git a/package-lock.json b/package-lock.json
index dbb265ec6daa12e2c37da2f35f6a6d946cf0bd79..c6c54a2ecbc0a0fc394a14bd36129dba5c8a3112 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,20 +1,20 @@
{
"name": "@feng3d/webgl",
- "version": "0.0.2",
+ "version": "0.0.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@feng3d/webgl",
- "version": "0.0.2",
- "license": "MIT",
+ "version": "0.0.3",
"workspaces": [
".",
"./examples"
],
"dependencies": {
+ "@feng3d/render-api": "0.0.2",
"@feng3d/serialization": "^0.8.1",
- "@feng3d/watcher": "^0.8.3"
+ "@feng3d/watcher": "^0.8.7"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "5.17.0",
@@ -33,7 +33,7 @@
"examples": {
"name": "webgl-renderer-examples",
"dependencies": {
- "@feng3d/webgl": "0.0.2",
+ "@feng3d/webgl": "0.0.3",
"gl-matrix": "^3.4.3"
},
"devDependencies": {
@@ -510,6 +510,12 @@
"integrity": "sha512-fenG1YSlgmB0s6qm+vuj+V6n2luCr/PZbmnS2CNPJFB3+Vmq3QZKZP9iyryYN2T52W4PhgqblOcMyq1pIAPwMw==",
"license": "MIT"
},
+ "node_modules/@feng3d/render-api": {
+ "version": "0.0.2",
+ "resolved": "https://registry.npmjs.org/@feng3d/render-api/-/render-api-0.0.2.tgz",
+ "integrity": "sha512-FcNiDTJ2lZgGBe3/x/xfu2thrNbqt4TxPr7D4FVqZdJ5VvZ6GroQYTiHLScgpAqpW+6Q7wAIzuyZ4DTlguyXbw==",
+ "license": "MIT"
+ },
"node_modules/@feng3d/serialization": {
"version": "0.8.3",
"resolved": "http://101.32.206.6:4873/@feng3d/serialization/-/serialization-0.8.3.tgz",
@@ -520,9 +526,9 @@
}
},
"node_modules/@feng3d/watcher": {
- "version": "0.8.6",
- "resolved": "http://101.32.206.6:4873/@feng3d/watcher/-/watcher-0.8.6.tgz",
- "integrity": "sha512-FETJWDTQ2b01MOx2sFryiKiqyjNgEiKE7rjXXclzNxt/6ZpiktFXW7q9zhb1i/jOOkMUc42le6fCHV9dzsUmdg==",
+ "version": "0.8.7",
+ "resolved": "https://registry.npmjs.org/@feng3d/watcher/-/watcher-0.8.7.tgz",
+ "integrity": "sha512-O7H+mUjX/EUYJ9w+4AU3O0rAUX/betozEGePiMpnlmwFthoCFqHPSAufECuHlSfxo/QNE4U08yX+zjF+qvJ97A==",
"license": "MIT"
},
"node_modules/@feng3d/webgl": {
diff --git a/package.json b/package.json
index 8e7a92214036ea657c47c6ec60143a4b4b0caef5..040ea5e195e685a92a262dc697a88f17c5b28ea2 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,8 @@
{
"name": "@feng3d/webgl",
- "version": "0.0.2",
+ "version": "0.0.3",
"description": "渲染库",
+ "homepage": "https://feng3d.com/webgl/",
"author": "feng",
"type": "module",
"main": "./src/index.ts",
@@ -30,7 +31,7 @@
},
"repository": {
"type": "git",
- "url": "https://gitee.com/feng3d/webgl-renderer.git"
+ "url": "https://gitee.com/feng3d/webgl.git"
},
"publishConfig": {
"access": "public"
@@ -60,7 +61,7 @@
"vitest": "^0.32.2"
},
"dependencies": {
- "@feng3d/render-api": "0.0.1",
+ "@feng3d/render-api": "0.0.2",
"@feng3d/serialization": "^0.8.1",
"@feng3d/watcher": "^0.8.7"
}
diff --git a/src/RunWebGL.ts b/src/RunWebGL.ts
index 051166be24c979849d944d6283fc7f1be2f9d5e9..fa75989995d4f285878ad5bb3c5dddb9c90801c7 100644
--- a/src/RunWebGL.ts
+++ b/src/RunWebGL.ts
@@ -458,7 +458,7 @@ export class RunWebGL
*/
private runUniform(gl: WebGLRenderingContext, type: IGLUniformBufferType, uniformInfo: IUniformItemInfo, data: any)
{
- if (typeof data === 'number')
+ if (typeof data === "number")
{
data = [data];
}
@@ -718,7 +718,7 @@ export class RunWebGL
{
if (depthStencil && (depthStencil.depthWriteEnabled || depthStencil.depthCompare !== "always"))
{
- const depthCompare: IGLCompareFunction = getIGLCompareFunction(depthStencil.depthCompare ?? 'less');
+ const depthCompare: IGLCompareFunction = getIGLCompareFunction(depthStencil.depthCompare ?? "less");
const depthWriteEnabled = depthStencil.depthWriteEnabled ?? true;
//
gl.enable(gl.DEPTH_TEST);
@@ -783,7 +783,7 @@ export class RunWebGL
gl.colorMask(colorMask[0], colorMask[1], colorMask[2], colorMask[3]);
//
- let blend = targets?.[0]?.blend;
+ const blend = targets?.[0]?.blend;
if (blend)
{
const color: IBlendComponent = blend.color;
diff --git a/src/caches/getGLFramebuffer.ts b/src/caches/getGLFramebuffer.ts
index 7c31e009cb27ba337321e1066e8ace773d463115..57983ea101cda4416d0373773b710154bea6ba4c 100644
--- a/src/caches/getGLFramebuffer.ts
+++ b/src/caches/getGLFramebuffer.ts
@@ -111,18 +111,19 @@ export function getGLFramebuffer(gl: WebGLRenderingContext, passDescriptor: IRen
}
/**
- *
- * @param gl
- * @param passDescriptor
+ *
+ * @param gl
+ * @param passDescriptor
* @param handleMultisample 处理存在多重采样的渲染通道描述。
- * @returns
+ * @returns
*/
export function deleteFramebuffer(gl: WebGLRenderingContext, passDescriptor: IRenderPassDescriptor, handleMultisample = true)
{
if (handleMultisample && passDescriptor?.[_IGLRenderPassDescriptorWithMultisample])
{
deleteRenderPassDescriptorWithMultisample(gl, passDescriptor[_IGLRenderPassDescriptorWithMultisample]);
- return;
+
+return;
}
const webGLFramebuffer = gl._framebuffers.get(passDescriptor);
@@ -139,5 +140,5 @@ function deleteRenderPassDescriptorWithMultisample(gl: WebGLRenderingContext, re
renderPassDescriptorWithMultisample.renderbuffers.forEach((v) =>
{
deleteRenderbuffer(gl, v);
- })
+ });
}
\ No newline at end of file
diff --git a/src/caches/getGLProgram.ts b/src/caches/getGLProgram.ts
index d15247b08e27e2212419a2fd561aa0fac02ac0aa..5c38125adca3ee76197c32e8808258116fc1ec1f 100644
--- a/src/caches/getGLProgram.ts
+++ b/src/caches/getGLProgram.ts
@@ -349,7 +349,7 @@ function getBufferBindingInfo(uniformBlock: IUniformBlockInfo): IBufferBindingIn
//
const paths = itemInfo.paths.slice(1);
//
- items.push({ paths, offset: itemInfoOffset, size: itemInfoSize, Cls: Cls });
+ items.push({ paths, offset: itemInfoOffset, size: itemInfoSize, Cls });
});
});
currentSize = roundUp(16, currentSize); // 整个统一块数据对齐
@@ -370,7 +370,7 @@ function roundUp(k: number, n: number): number
}
/**
- *
+ *
* @see https://github.com/brendan-duncan/wgsl_reflect/blob/main/src/wgsl_reflect.ts#L1206
* @see https://www.orillusion.com/zh/wgsl.html#memory-layouts
*/
@@ -381,29 +381,29 @@ const uniformBufferTypeAlignSizeMap: {
clsType: Float32ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor,
}
} = {
- "FLOAT": { align: 4, size: 4, clsType: Float32Array },
- "FLOAT_VEC2": { align: 8, size: 8, clsType: Float32Array },
- "FLOAT_VEC3": { align: 16, size: 12, clsType: Float32Array },
- "FLOAT_VEC4": { align: 16, size: 16, clsType: Float32Array },
- "INT": { align: 4, size: 4, clsType: Int32Array },
- "INT_VEC2": { align: 8, size: 8, clsType: Int32Array },
- "INT_VEC3": { align: 16, size: 12, clsType: Int32Array },
- "INT_VEC4": { align: 16, size: 16, clsType: Int32Array },
- "BOOL": { align: 4, size: 4, clsType: Int32Array },
- "BOOL_VEC2": { align: 8, size: 8, clsType: Int32Array },
- "BOOL_VEC3": { align: 16, size: 12, clsType: Int32Array },
- "BOOL_VEC4": { align: 16, size: 16, clsType: Int32Array },
- "FLOAT_MAT2": { align: 8, size: 16, clsType: Float32Array },
- "FLOAT_MAT3": { align: 16, size: 48, clsType: Float32Array },
- "FLOAT_MAT4": { align: 16, size: 64, clsType: Float32Array },
- "UNSIGNED_INT": { align: 4, size: 4, clsType: Uint32Array },
- "UNSIGNED_INT_VEC2": { align: 8, size: 8, clsType: Uint32Array },
- "UNSIGNED_INT_VEC3": { align: 16, size: 12, clsType: Uint32Array },
- "UNSIGNED_INT_VEC4": { align: 16, size: 16, clsType: Uint32Array },
- "FLOAT_MAT2x3": { align: 16, size: 32, clsType: Float32Array },
- "FLOAT_MAT2x4": { align: 16, size: 32, clsType: Float32Array },
- "FLOAT_MAT3x2": { align: 8, size: 24, clsType: Float32Array },
- "FLOAT_MAT3x4": { align: 16, size: 48, clsType: Float32Array },
- "FLOAT_MAT4x2": { align: 8, size: 32, clsType: Float32Array },
- "FLOAT_MAT4x3": { align: 16, size: 64, clsType: Float32Array },
+ FLOAT: { align: 4, size: 4, clsType: Float32Array },
+ FLOAT_VEC2: { align: 8, size: 8, clsType: Float32Array },
+ FLOAT_VEC3: { align: 16, size: 12, clsType: Float32Array },
+ FLOAT_VEC4: { align: 16, size: 16, clsType: Float32Array },
+ INT: { align: 4, size: 4, clsType: Int32Array },
+ INT_VEC2: { align: 8, size: 8, clsType: Int32Array },
+ INT_VEC3: { align: 16, size: 12, clsType: Int32Array },
+ INT_VEC4: { align: 16, size: 16, clsType: Int32Array },
+ BOOL: { align: 4, size: 4, clsType: Int32Array },
+ BOOL_VEC2: { align: 8, size: 8, clsType: Int32Array },
+ BOOL_VEC3: { align: 16, size: 12, clsType: Int32Array },
+ BOOL_VEC4: { align: 16, size: 16, clsType: Int32Array },
+ FLOAT_MAT2: { align: 8, size: 16, clsType: Float32Array },
+ FLOAT_MAT3: { align: 16, size: 48, clsType: Float32Array },
+ FLOAT_MAT4: { align: 16, size: 64, clsType: Float32Array },
+ UNSIGNED_INT: { align: 4, size: 4, clsType: Uint32Array },
+ UNSIGNED_INT_VEC2: { align: 8, size: 8, clsType: Uint32Array },
+ UNSIGNED_INT_VEC3: { align: 16, size: 12, clsType: Uint32Array },
+ UNSIGNED_INT_VEC4: { align: 16, size: 16, clsType: Uint32Array },
+ FLOAT_MAT2x3: { align: 16, size: 32, clsType: Float32Array },
+ FLOAT_MAT2x4: { align: 16, size: 32, clsType: Float32Array },
+ FLOAT_MAT3x2: { align: 8, size: 24, clsType: Float32Array },
+ FLOAT_MAT3x4: { align: 16, size: 48, clsType: Float32Array },
+ FLOAT_MAT4x2: { align: 8, size: 32, clsType: Float32Array },
+ FLOAT_MAT4x3: { align: 16, size: 64, clsType: Float32Array },
};
\ No newline at end of file
diff --git a/src/caches/getGLRenderOcclusionQuery.ts b/src/caches/getGLRenderOcclusionQuery.ts
index cc8c974ac81d3de68b77514e637ebd594056ddc8..36fba8b710f46446b09c791f96c2d02ea3d0b6e1 100644
--- a/src/caches/getGLRenderOcclusionQuery.ts
+++ b/src/caches/getGLRenderOcclusionQuery.ts
@@ -108,7 +108,7 @@ export function getGLOcclusionQueryStep(gl: WebGL2RenderingContext, occlusionQue
}
return undefined;
- }
+ };
return { begin, end, resolve } as IGLOcclusionQueryStep;
}
diff --git a/src/caches/getGLSampler.ts b/src/caches/getGLSampler.ts
index dca0041a2e2eb2de8bba3d289113eb57af65ce7b..9fe3d6bcbaab3d0d0b0e692a528c249261076e09 100644
--- a/src/caches/getGLSampler.ts
+++ b/src/caches/getGLSampler.ts
@@ -67,7 +67,7 @@ export function getIGLTextureWrap(addressMode: IAddressMode = "repeat")
const addressModeMap: { [key: string]: IGLTextureWrap } = {
"clamp-to-edge": "CLAMP_TO_EDGE",
- "repeat": "REPEAT",
+ repeat: "REPEAT",
"mirror-repeat": "MIRRORED_REPEAT",
};
@@ -118,6 +118,6 @@ export function getIGLTextureMagFilter(magFilter: IFilterMode = "nearest")
}
const magFilterMap: { [key: string]: IGLTextureMagFilter } = {
- "nearest": "NEAREST",
- "linear": "LINEAR",
+ nearest: "NEAREST",
+ linear: "LINEAR",
};
\ No newline at end of file
diff --git a/src/caches/getGLTexture.ts b/src/caches/getGLTexture.ts
index 126b568ff95e27919a00d53ccc6bc7e1492078e5..c8cce70d9c975fb36e1920e0a579f6c3cb0a5a99 100644
--- a/src/caches/getGLTexture.ts
+++ b/src/caches/getGLTexture.ts
@@ -230,7 +230,7 @@ export function getGLTexture(gl: WebGLRenderingContext, texture: ITexture)
{
for (let i = 0; i < mipLevelCount; i++)
{
- gl.texImage2D(gl[target], i, gl[format], width, height, 0, gl[format], gl[type], null)
+ gl.texImage2D(gl[target], i, gl[format], width, height, 0, gl[format], gl[type], null);
}
}
else
@@ -239,7 +239,7 @@ export function getGLTexture(gl: WebGLRenderingContext, texture: ITexture)
}
}
}
- }
+ };
createTexture();
const updateSources = () =>
@@ -325,7 +325,8 @@ export function getGLTexture(gl: WebGLRenderingContext, texture: ITexture)
console.error(`WebGL1 中 不支持 ${target} 纹理类型!`);
}
}
- return;
+
+return;
}
// 处理数据资源
@@ -373,7 +374,7 @@ export function getGLTexture(gl: WebGLRenderingContext, texture: ITexture)
gl.texSubImage2D(gl[bindTarget], mipLevel, xoffset, yoffset, width, height, gl[format], gl[type], data);
- console.assert(!offset, `WebGL1 不支持 IGLTextureDataSource.dataLayout.offset !`)
+ console.assert(!offset, `WebGL1 不支持 IGLTextureDataSource.dataLayout.offset !`);
}
else
{
diff --git a/src/caches/getIGLDrawMode.ts b/src/caches/getIGLDrawMode.ts
index 529e35b6eb06f4685c0416e34af0a5f04fbcacda..77980f0d323d1d75aa5ecfb6ea389ac4223c6cbe 100644
--- a/src/caches/getIGLDrawMode.ts
+++ b/src/caches/getIGLDrawMode.ts
@@ -17,8 +17,8 @@ const drawModeMap: { [key: string]: IGLDrawMode } = {
"line-strip": "LINE_STRIP",
"triangle-list": "TRIANGLES",
"triangle-strip": "TRIANGLE_STRIP",
- "LINE_LOOP": "LINE_LOOP",
- "TRIANGLE_FAN": "TRIANGLE_FAN",
+ LINE_LOOP: "LINE_LOOP",
+ TRIANGLE_FAN: "TRIANGLE_FAN",
};
/**
diff --git a/src/caches/getIGLRenderPassDescriptorWithMultisample.ts b/src/caches/getIGLRenderPassDescriptorWithMultisample.ts
index 326c3430bdc1396b4f19f02a7a347a961473cfc4..d5022c55944db8a4a6d1b3e9a3819b6c20b66bc2 100644
--- a/src/caches/getIGLRenderPassDescriptorWithMultisample.ts
+++ b/src/caches/getIGLRenderPassDescriptorWithMultisample.ts
@@ -4,11 +4,11 @@ import { GLRenderbufferInternalformat, IGLRenderbuffer } from "../data/IGLRender
import { getIGLTextureFormats } from "./getIGLTextureFormats";
/**
- *
+ *
* 当需要渲染到纹理并且开启多重采样时,就必须使用支持多重采样的渲染缓冲区来进行接受中间结果再拷贝到模板纹理上。
- *
+ *
* 当`passDescriptor.multisample`值存在时,引擎将会自动创建支持`multisample`的`IGLRenderbuffer`用于接收颜色附件的结果。在渲染通道执行结束后在由`IGLRenderbuffer`拷贝到对应纹理上。
- *
+ *
* @param sourcePassDescriptor 需要渲染到纹理并且开启多重采样的渲染通道描述。
*/
export function getIGLRenderPassDescriptorWithMultisample(sourcePassDescriptor: IRenderPassDescriptor): IGLRenderPassDescriptorWithMultisample
@@ -38,7 +38,8 @@ export function getIGLRenderPassDescriptorWithMultisample(sourcePassDescriptor:
...v,
view: renderbuffer as any,
};
- return colorAttachment;
+
+return colorAttachment;
}),
depthStencilAttachment: sourcePassDescriptor.depthStencilAttachment,
sampleCount: sourcePassDescriptor.sampleCount,
diff --git a/src/caches/getIGLTextureFormats.ts b/src/caches/getIGLTextureFormats.ts
index 995dfaea4b9f09541bfe33be6f30831c71e7be94..f688e6c98eacc5184b718efc2a44b3b223c052f4 100644
--- a/src/caches/getIGLTextureFormats.ts
+++ b/src/caches/getIGLTextureFormats.ts
@@ -11,48 +11,48 @@ export function getIGLTextureFormats(format: ITextureFormat = "rgba8unorm")
}
const formatMap: { [key: string]: IGLTextureFormats } = {
- "r8unorm": { internalformat: "R8", format: "RED", type: "UNSIGNED_BYTE", },
- "r8snorm": undefined,
- "r8uint": { internalformat: "R8", format: "RED", type: "UNSIGNED_BYTE", },
- "r8sint": undefined,
- "r16uint": undefined,
- "r16sint": undefined,
- "r16float": { internalformat: "R16F", format: "RED", type: "HALF_FLOAT" },
- "rg8unorm": undefined,
- "rg8snorm": undefined,
- "rg8uint": undefined,
- "rg8sint": undefined,
- "r32uint": undefined,
- "r32sint": undefined,
- "r32float": undefined,
- "rg16uint": undefined,
- "rg16sint": undefined,
- "rg16float": { internalformat: "RG16F", format: "RG", type: "HALF_FLOAT" },
- "rgba8unorm": { internalformat: "RGBA8", format: "RGBA", type: "UNSIGNED_BYTE" },
- "rgba8unorm-srgb": { internalformat: "SRGB8", format: "RGB", type: "UNSIGNED_BYTE", },
- "rgba8snorm": undefined,
- "rgba8uint": { internalformat: "RGBA8UI", format: "RGBA_INTEGER", type: "UNSIGNED_BYTE", },
- "rgba8sint": undefined,
- "bgra8unorm": undefined,
+ r8unorm: { internalformat: "R8", format: "RED", type: "UNSIGNED_BYTE" },
+ r8snorm: undefined,
+ r8uint: { internalformat: "R8", format: "RED", type: "UNSIGNED_BYTE" },
+ r8sint: undefined,
+ r16uint: undefined,
+ r16sint: undefined,
+ r16float: { internalformat: "R16F", format: "RED", type: "HALF_FLOAT" },
+ rg8unorm: undefined,
+ rg8snorm: undefined,
+ rg8uint: undefined,
+ rg8sint: undefined,
+ r32uint: undefined,
+ r32sint: undefined,
+ r32float: undefined,
+ rg16uint: undefined,
+ rg16sint: undefined,
+ rg16float: { internalformat: "RG16F", format: "RG", type: "HALF_FLOAT" },
+ rgba8unorm: { internalformat: "RGBA8", format: "RGBA", type: "UNSIGNED_BYTE" },
+ "rgba8unorm-srgb": { internalformat: "SRGB8", format: "RGB", type: "UNSIGNED_BYTE" },
+ rgba8snorm: undefined,
+ rgba8uint: { internalformat: "RGBA8UI", format: "RGBA_INTEGER", type: "UNSIGNED_BYTE" },
+ rgba8sint: undefined,
+ bgra8unorm: undefined,
"bgra8unorm-srgb": undefined,
- "rgb9e5ufloat": undefined,
- "rgb10a2uint": undefined,
- "rgb10a2unorm": undefined,
- "rg11b10ufloat": undefined,
- "rg32uint": undefined,
- "rg32sint": undefined,
- "rg32float": undefined,
- "rgba16uint": undefined,
- "rgba16sint": undefined,
- "rgba16float": { internalformat: "RGB16F", format: "RGB", type: "HALF_FLOAT" },
- "rgba32uint": undefined,
- "rgba32sint": undefined,
- "rgba32float": { internalformat: "RGBA32F", format: "RGBA", type: "FLOAT" },
- "stencil8": undefined,
- "depth16unorm": { internalformat: "DEPTH_COMPONENT16", format: "DEPTH_COMPONENT", type: "UNSIGNED_SHORT", },
- "depth24plus": undefined,
+ rgb9e5ufloat: undefined,
+ rgb10a2uint: undefined,
+ rgb10a2unorm: undefined,
+ rg11b10ufloat: undefined,
+ rg32uint: undefined,
+ rg32sint: undefined,
+ rg32float: undefined,
+ rgba16uint: undefined,
+ rgba16sint: undefined,
+ rgba16float: { internalformat: "RGB16F", format: "RGB", type: "HALF_FLOAT" },
+ rgba32uint: undefined,
+ rgba32sint: undefined,
+ rgba32float: { internalformat: "RGBA32F", format: "RGBA", type: "FLOAT" },
+ stencil8: undefined,
+ depth16unorm: { internalformat: "DEPTH_COMPONENT16", format: "DEPTH_COMPONENT", type: "UNSIGNED_SHORT" },
+ depth24plus: undefined,
"depth24plus-stencil8": undefined,
- "depth32float": undefined,
+ depth32float: undefined,
"depth32float-stencil8": undefined,
"bc1-rgba-unorm": undefined,
"bc1-rgba-unorm-srgb": undefined,
diff --git a/src/caches/getIGLTextureTarget.ts b/src/caches/getIGLTextureTarget.ts
index 284df9a46865e38c44bf59145380d48c8708472d..77e7f47f7580ca61bda6f4042be478d3673aba98 100644
--- a/src/caches/getIGLTextureTarget.ts
+++ b/src/caches/getIGLTextureTarget.ts
@@ -13,7 +13,7 @@ const dimensionMap: { [key: string]: IGLTextureTarget } = {
"1d": undefined,
"2d": "TEXTURE_2D",
"2d-array": "TEXTURE_2D_ARRAY",
- "cube": "TEXTURE_CUBE_MAP",
+ cube: "TEXTURE_CUBE_MAP",
"cube-array": undefined,
"3d": "TEXTURE_3D",
};
\ No newline at end of file
diff --git a/src/data/IGLCommandEncoder.ts b/src/data/IGLCommandEncoder.ts
index bbcfa7bc63e365e16e2e28a5a25d538e0f194f06..32bff98d0943e19c48fdcbb6d8f558e0103bf355 100644
--- a/src/data/IGLCommandEncoder.ts
+++ b/src/data/IGLCommandEncoder.ts
@@ -17,7 +17,7 @@ declare module "@feng3d/render-api"
export interface IImageCopyTexture
{
/**
- *
+ *
* 注:当值设置为 null或者undefined时表示当前画布。
*/
texture: ITextureLike;
diff --git a/src/data/IGLDepthStencilState.ts b/src/data/IGLDepthStencilState.ts
index dc5f10134a8032659353a224524db13f63afa378..6e4f1dbbac6accee1f7930a61c1951eb4ca88cf5 100644
--- a/src/data/IGLDepthStencilState.ts
+++ b/src/data/IGLDepthStencilState.ts
@@ -1,4 +1,3 @@
-
/**
* 深度状态。
*/
diff --git a/src/data/IGLOcclusionQuery.ts b/src/data/IGLOcclusionQuery.ts
index 416155e40aea26f61c302fea5a345942ec95da46..778c7770603ede9280ea0cae030e5e6573c4978f 100644
--- a/src/data/IGLOcclusionQuery.ts
+++ b/src/data/IGLOcclusionQuery.ts
@@ -14,7 +14,7 @@ export interface IGLOcclusionQuery
/**
* 临时变量, 执行过程中由引擎自动填充。
- *
+ *
* @internal
*/
_step?: IGLOcclusionQueryStep;
diff --git a/src/data/IGLPrimitiveState.ts b/src/data/IGLPrimitiveState.ts
index e1e876ef41759b64c71da742cfce4205c37be179..2b408972f2d288017d436e78d907b637c593cd6e 100644
--- a/src/data/IGLPrimitiveState.ts
+++ b/src/data/IGLPrimitiveState.ts
@@ -33,7 +33,7 @@ declare module "@feng3d/render-api"
/**
* * `FRONT_AND_BACK` 剔除正面与背面,仅在WebGL中生效!
- *
+ *
* @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/cullFace
*/
readonly cullFace?: ICullFace;
diff --git a/src/data/IGLTexturePixelStore.ts b/src/data/IGLTexturePixelStore.ts
index 346ffc349252159c28503e9b3630cea6ac1ce419..381a7bb04d7cfbcd0e8418555446daa832617630 100644
--- a/src/data/IGLTexturePixelStore.ts
+++ b/src/data/IGLTexturePixelStore.ts
@@ -1,4 +1,3 @@
-
/**
* 像素解包打包时参数。
*
diff --git a/src/data/IGLTransformFeedbackPass.ts b/src/data/IGLTransformFeedbackPass.ts
index 413eb17296f65561876166521cf26fc531913f94..2e9228e39c62f2a760ac59c5b1bfba99e16261ad 100644
--- a/src/data/IGLTransformFeedbackPass.ts
+++ b/src/data/IGLTransformFeedbackPass.ts
@@ -36,7 +36,7 @@ export interface IGLTransformFeedbackObject
/**
* 根据顶点数据绘制图元。
- *
+ *
* @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawVertex
*/
readonly drawVertex: IDrawVertex;
diff --git a/src/runs/getIGLBuffer.ts b/src/runs/getIGLBuffer.ts
index 646fc3243171ba891b9830df70d63953b9e2b080..8ac96942781ac53a47cc17c73d930f25f79e0037 100644
--- a/src/runs/getIGLBuffer.ts
+++ b/src/runs/getIGLBuffer.ts
@@ -7,9 +7,9 @@ export function getIGLBuffer(data: TypedArray, target?: IGLBufferTarget, usage:
const buffer: IBuffer = {
size: Math.ceil(data.byteLength / 4) * 4,
- target: target,
- usage: usage,
- data: data,
+ target,
+ usage,
+ data,
};
data[_IGLBuffer] = buffer;
diff --git a/src/runs/runColorTargetStates.ts b/src/runs/runColorTargetStates.ts
index e46060acba73cecff21a75aa6294d8f3edde8fe3..ad9f59ca40c13bd2b0b1a3ae03cf3b42206346c4 100644
--- a/src/runs/runColorTargetStates.ts
+++ b/src/runs/runColorTargetStates.ts
@@ -12,11 +12,11 @@ export function getIGLBlendEquation(operation?: IBlendOperation)
}
const operationMap: { [key: string]: IGLBlendEquation } = {
- "add": "FUNC_ADD",
- "subtract": "FUNC_SUBTRACT",
+ add: "FUNC_ADD",
+ subtract: "FUNC_SUBTRACT",
"reverse-subtract": "FUNC_REVERSE_SUBTRACT",
- "min": "MIN",
- "max": "MAX",
+ min: "MIN",
+ max: "MAX",
};
export function getIGLBlendFactor(blendFactor: IBlendFactor, operation: IBlendOperation)
@@ -33,18 +33,18 @@ export function getIGLBlendFactor(blendFactor: IBlendFactor, operation: IBlendOp
}
const blendFactorMap: { [key: string]: IGLBlendFactor } = {
- "zero": "ZERO",
- "one": "ONE",
- "src": "SRC_COLOR",
+ zero: "ZERO",
+ one: "ONE",
+ src: "SRC_COLOR",
"one-minus-src": "ONE_MINUS_SRC_COLOR",
"src-alpha": "SRC_ALPHA",
"one-minus-src-alpha": "ONE_MINUS_SRC_ALPHA",
- "dst": "DST_COLOR",
+ dst: "DST_COLOR",
"one-minus-dst": "ONE_MINUS_DST_COLOR",
"dst-alpha": "DST_ALPHA",
"one-minus-dst-alpha": "ONE_MINUS_DST_ALPHA",
"src-alpha-saturated": "SRC_ALPHA_SATURATE",
- "constant": "CONSTANT_COLOR",
+ constant: "CONSTANT_COLOR",
"one-minus-constant": "ONE_MINUS_CONSTANT_COLOR",
};
diff --git a/src/runs/runDepthState.ts b/src/runs/runDepthState.ts
index 9d99e8bdfbcc43c438caa7a98325805b5dd77933..b4d5ca0d362069a65fe2ccfb3905cc576d052114 100644
--- a/src/runs/runDepthState.ts
+++ b/src/runs/runDepthState.ts
@@ -6,17 +6,17 @@ export function getIGLCompareFunction(depthCompare: ICompareFunction)
const glDepthCompare: IGLCompareFunction = depthCompareMap[depthCompare];
console.assert(!!glDepthCompare, `接收到错误值,请从 ${Object.keys(depthCompareMap).toString()} 中取值!`);
-
+
return glDepthCompare;
}
const depthCompareMap: { [key: string]: IGLCompareFunction } = {
- "never": "NEVER",
- "less": "LESS",
- "equal": "EQUAL",
+ never: "NEVER",
+ less: "LESS",
+ equal: "EQUAL",
"less-equal": "LEQUAL",
- "greater": "GREATER",
+ greater: "GREATER",
"not-equal": "NOTEQUAL",
"greater-equal": "GEQUAL",
- "always": "ALWAYS",
+ always: "ALWAYS",
};
\ No newline at end of file
diff --git a/src/runs/runStencilState.ts b/src/runs/runStencilState.ts
index 39ab87965cb566b6e260477ca24593c41e97b17d..d4a114b52627ae357aa0c0d57d5e5dc55ed7c41f 100644
--- a/src/runs/runStencilState.ts
+++ b/src/runs/runStencilState.ts
@@ -8,14 +8,14 @@ export function getIGLStencilFunc(compare: ICompareFunction)
return stencilFunc;
}
const compareMap: { [key: string]: IGLStencilFunc } = {
- "never": "NEVER",
- "less": "LESS",
- "equal": "EQUAL",
+ never: "NEVER",
+ less: "LESS",
+ equal: "EQUAL",
"less-equal": "LEQUAL",
- "greater": "GREATER",
+ greater: "GREATER",
"not-equal": "NOTEQUAL",
"greater-equal": "GEQUAL",
- "always": "ALWAYS",
+ always: "ALWAYS",
};
export function getIGLStencilOp(stencilOperation?: IStencilOperation)
@@ -25,10 +25,10 @@ export function getIGLStencilOp(stencilOperation?: IStencilOperation)
return glStencilOp;
}
const stencilOperationMap: { [key: string]: IGLStencilOp } = {
- "keep": "KEEP",
- "zero": "ZERO",
- "replace": "REPLACE",
- "invert": "INVERT",
+ keep: "KEEP",
+ zero: "ZERO",
+ replace: "REPLACE",
+ invert: "INVERT",
"increment-clamp": "INCR",
"decrement-clamp": "DECR",
"increment-wrap": "INCR_WRAP",
diff --git a/src/utils/getGLRenderPassAttachmentSize.ts b/src/utils/getGLRenderPassAttachmentSize.ts
index 94e52b1455115af9f933ce255568a0b5022f39eb..3cb7a0bfb253f561c427b468caae144bd1c266f4 100644
--- a/src/utils/getGLRenderPassAttachmentSize.ts
+++ b/src/utils/getGLRenderPassAttachmentSize.ts
@@ -2,9 +2,9 @@ import { IRenderPassDescriptor } from "@feng3d/render-api";
/**
* 获取渲染通道附件尺寸。
- *
- * @param gl
- * @param descriptor
+ *
+ * @param gl
+ * @param descriptor
*/
export function getGLRenderPassAttachmentSize(gl: WebGLRenderingContext, descriptor: IRenderPassDescriptor): { readonly width: number; readonly height: number; }
{
@@ -20,10 +20,8 @@ export function getGLRenderPassAttachmentSize(gl: WebGLRenderingContext, descrip
{
return { width: view.texture.size[0], height: view.texture.size[1] };
}
- else
- {
+
return { width: gl.drawingBufferWidth, height: gl.drawingBufferHeight };
- }
}
}
@@ -35,10 +33,8 @@ export function getGLRenderPassAttachmentSize(gl: WebGLRenderingContext, descrip
{
return { width: view.texture.size[0], height: view.texture.size[1] };
}
- else
- {
+
return { width: gl.drawingBufferWidth, height: gl.drawingBufferHeight };
- }
}
return { width: gl.drawingBufferWidth, height: gl.drawingBufferHeight };
diff --git a/src/utils/getIGLCullFace.ts b/src/utils/getIGLCullFace.ts
index eaff6985d8d3a03f6ac4baaa77f0b8498b0aa0c3..fb670de43ea3d9dc7a92b842aa02ccfc1277db83 100644
--- a/src/utils/getIGLCullFace.ts
+++ b/src/utils/getIGLCullFace.ts
@@ -10,10 +10,10 @@ export function getIGLCullFace(cullFace: ICullFace)
}
const cullFaceMap: { [key: string]: IGLCullFace } = {
- "FRONT_AND_BACK": "FRONT_AND_BACK",
- "none": "BACK", // 不会开启剔除面功能,什么值无所谓。
- "front": "FRONT",
- "back": "BACK",
+ FRONT_AND_BACK: "FRONT_AND_BACK",
+ none: "BACK", // 不会开启剔除面功能,什么值无所谓。
+ front: "FRONT",
+ back: "BACK",
};
/**
diff --git a/src/utils/getIGLFrontFace.ts b/src/utils/getIGLFrontFace.ts
index 144f380449fb05df44ad05e4cdfb49a4cad4c2ea..de4c9262e6f9db382b4d820cf890d67de7c93aef 100644
--- a/src/utils/getIGLFrontFace.ts
+++ b/src/utils/getIGLFrontFace.ts
@@ -9,8 +9,8 @@ export function getIGLFrontFace(frontFace: IFrontFace)
return glFrontFace;
}
const frontFaceMap: { [key: string]: IGLFrontFace } = {
- "ccw": "CCW",
- "cw": "CW",
+ ccw: "CCW",
+ cw: "CW",
};
/**
diff --git a/src/utils/getIVertexFormat.ts b/src/utils/getIVertexFormat.ts
index 1474fa158e9296e92b6fe58d1c5c52e0b5273ce2..b0161e7db246b96079126247ad5e76df15bd06c2 100644
--- a/src/utils/getIVertexFormat.ts
+++ b/src/utils/getIVertexFormat.ts
@@ -6,9 +6,9 @@ export function getIVertexFormat(numComponents: 1 | 2 | 3 | 4, type: IGLVertexAt
{
const element = formatMap[key];
if (
- element.numComponents === numComponents &&
- element.type === type &&
- !element.normalized === !normalized
+ element.numComponents === numComponents
+ && element.type === type
+ && !element.normalized === !normalized
)
{
return key as IVertexFormat;
@@ -31,40 +31,39 @@ export function getIGLVertexFormat(format: IVertexFormat): IGLVertexFormat
export const formatMap: { [key: string]: IGLVertexFormat } = {
- "uint8x2": { numComponents: 2, type: "UNSIGNED_BYTE", normalized: false },
- "uint8x4": { numComponents: 4, type: "UNSIGNED_BYTE", normalized: false },
- "sint8x2": { numComponents: 2, type: "BYTE", normalized: false },
- "sint8x4": { numComponents: 4, type: "BYTE", normalized: false },
- "unorm8x2": { numComponents: 2, type: "UNSIGNED_BYTE", normalized: true },
- "unorm8x4": { numComponents: 4, type: "UNSIGNED_BYTE", normalized: true },
- "snorm8x2": { numComponents: 2, type: "BYTE", normalized: true },
- "snorm8x4": { numComponents: 4, type: "BYTE", normalized: true },
- "uint16x2": { numComponents: 2, type: "UNSIGNED_SHORT", normalized: false },
- "uint16x4": { numComponents: 4, type: "UNSIGNED_SHORT", normalized: false },
- "sint16x2": { numComponents: 2, type: "SHORT", normalized: false },
- "sint16x4": { numComponents: 4, type: "SHORT", normalized: false },
- "unorm16x2": { numComponents: 2, type: "UNSIGNED_SHORT", normalized: true },
- "unorm16x4": { numComponents: 4, type: "UNSIGNED_SHORT", normalized: true },
- "snorm16x2": { numComponents: 2, type: "SHORT", normalized: true },
- "snorm16x4": { numComponents: 4, type: "SHORT", normalized: true },
- "float16x2": { numComponents: 2, type: "HALF_FLOAT", normalized: false },
- "float16x4": { numComponents: 4, type: "HALF_FLOAT", normalized: false },
- "float32": { numComponents: 1, type: "FLOAT", normalized: false },
- "float32x2": { numComponents: 2, type: "FLOAT", normalized: false },
- "float32x3": { numComponents: 3, type: "FLOAT", normalized: false },
- "float32x4": { numComponents: 4, type: "FLOAT", normalized: false },
- "uint32": { numComponents: 1, type: "UNSIGNED_INT", normalized: false },
- "uint32x2": { numComponents: 2, type: "UNSIGNED_INT", normalized: false },
- "uint32x3": { numComponents: 3, type: "UNSIGNED_INT", normalized: false },
- "uint32x4": { numComponents: 4, type: "UNSIGNED_INT", normalized: false },
- "sint32": { numComponents: 1, type: "INT", normalized: false },
- "sint32x2": { numComponents: 2, type: "INT", normalized: false },
- "sint32x3": { numComponents: 3, type: "INT", normalized: false },
- "sint32x4": { numComponents: 4, type: "INT", normalized: false },
+ uint8x2: { numComponents: 2, type: "UNSIGNED_BYTE", normalized: false },
+ uint8x4: { numComponents: 4, type: "UNSIGNED_BYTE", normalized: false },
+ sint8x2: { numComponents: 2, type: "BYTE", normalized: false },
+ sint8x4: { numComponents: 4, type: "BYTE", normalized: false },
+ unorm8x2: { numComponents: 2, type: "UNSIGNED_BYTE", normalized: true },
+ unorm8x4: { numComponents: 4, type: "UNSIGNED_BYTE", normalized: true },
+ snorm8x2: { numComponents: 2, type: "BYTE", normalized: true },
+ snorm8x4: { numComponents: 4, type: "BYTE", normalized: true },
+ uint16x2: { numComponents: 2, type: "UNSIGNED_SHORT", normalized: false },
+ uint16x4: { numComponents: 4, type: "UNSIGNED_SHORT", normalized: false },
+ sint16x2: { numComponents: 2, type: "SHORT", normalized: false },
+ sint16x4: { numComponents: 4, type: "SHORT", normalized: false },
+ unorm16x2: { numComponents: 2, type: "UNSIGNED_SHORT", normalized: true },
+ unorm16x4: { numComponents: 4, type: "UNSIGNED_SHORT", normalized: true },
+ snorm16x2: { numComponents: 2, type: "SHORT", normalized: true },
+ snorm16x4: { numComponents: 4, type: "SHORT", normalized: true },
+ float16x2: { numComponents: 2, type: "HALF_FLOAT", normalized: false },
+ float16x4: { numComponents: 4, type: "HALF_FLOAT", normalized: false },
+ float32: { numComponents: 1, type: "FLOAT", normalized: false },
+ float32x2: { numComponents: 2, type: "FLOAT", normalized: false },
+ float32x3: { numComponents: 3, type: "FLOAT", normalized: false },
+ float32x4: { numComponents: 4, type: "FLOAT", normalized: false },
+ uint32: { numComponents: 1, type: "UNSIGNED_INT", normalized: false },
+ uint32x2: { numComponents: 2, type: "UNSIGNED_INT", normalized: false },
+ uint32x3: { numComponents: 3, type: "UNSIGNED_INT", normalized: false },
+ uint32x4: { numComponents: 4, type: "UNSIGNED_INT", normalized: false },
+ sint32: { numComponents: 1, type: "INT", normalized: false },
+ sint32x2: { numComponents: 2, type: "INT", normalized: false },
+ sint32x3: { numComponents: 3, type: "INT", normalized: false },
+ sint32x4: { numComponents: 4, type: "INT", normalized: false },
"unorm10-10-10-2": { numComponents: 4, type: "UNSIGNED_INT_2_10_10_10_REV", normalized: true },
};
-
interface IGLVertexFormat
{
/**
diff --git a/src/utils/updateBufferBinding.ts b/src/utils/updateBufferBinding.ts
index f7cb79abdd933d38e56b14e1d98fbde0696aebc3..032e6c6b9d129377f4044393c5a7a824ea8b7651 100644
--- a/src/utils/updateBufferBinding.ts
+++ b/src/utils/updateBufferBinding.ts
@@ -4,10 +4,10 @@ import { IBufferBindingInfo } from "../caches/getGLProgram";
import { getIGLBuffer } from "../runs/getIGLBuffer";
/**
- *
- * @param uniformBlock
- * @param uniformData
- *
+ *
+ * @param uniformBlock
+ * @param uniformData
+ *
* @see https://learnopengl-cn.readthedocs.io/zh/latest/04%20Advanced%20OpenGL/08%20Advanced%20GLSL/#uniform_1
*/
export function updateBufferBinding(bufferBindingInfo: IBufferBindingInfo, uniformData: IBufferBinding)
@@ -57,6 +57,7 @@ export function updateBufferBinding(bufferBindingInfo: IBufferBindingInfo, unifo
{
console.warn(`没有找到 统一块变量属性 ${paths.join(".")} 的值!`);
}
+
return;
}
}
@@ -78,7 +79,7 @@ export function updateBufferBinding(bufferBindingInfo: IBufferBindingInfo, unifo
const writeBuffers = buffer.writeBuffers ?? [];
writeBuffers.push({ data: data.buffer, bufferOffset: offset + itemInfoOffset, size: Math.min(itemInfoSize, data.byteLength) });
buffer.writeBuffers = writeBuffers;
- }
+ };
update();
watcher.watchchain(uniformData, paths.join("."), update, undefined, false);
diff --git a/typedoc.json b/typedoc.json
index 1b7c73d078c711d369752174a3eb203fee7fe662..7d96556e48352d3cfa0f155205899059eb2fbd7a 100644
--- a/typedoc.json
+++ b/typedoc.json
@@ -4,6 +4,6 @@
"entryPoints": [
"src/index.ts"
],
- "sourceLinkTemplate": "https://gitee.com/feng3d/webgl-renderer/tree/master/{path}#L{line}",
+ "sourceLinkTemplate": "https://gitee.com/feng3d/webgl/tree/master/{path}#L{line}",
"out": "public/docs"
}
\ No newline at end of file