ris-framework 0.2.0-dev.11 → 0.2.0-dev.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -29
- package/README.md +99 -150
- package/dist/Framework.d.ts +26 -8
- package/dist/Framework.d.ts.map +1 -1
- package/dist/api/IFramework.d.ts +43 -0
- package/dist/api/IFramework.d.ts.map +1 -1
- package/dist/api/_export.d.ts +1 -1
- package/dist/api/_export.d.ts.map +1 -1
- package/dist/api/content/ContentManager.d.ts +5 -57
- package/dist/api/content/ContentManager.d.ts.map +1 -1
- package/dist/api/content/IContentManager.d.ts +24 -21
- package/dist/api/content/IContentManager.d.ts.map +1 -1
- package/dist/api/lights/LightsBuffer.d.ts +13 -6
- package/dist/api/lights/LightsBuffer.d.ts.map +1 -1
- package/dist/api/loaders/ObjGeometryMapper.d.ts +2 -2
- package/dist/api/loaders/ObjLoader.d.ts +61 -0
- package/dist/api/loaders/ObjLoader.d.ts.map +1 -0
- package/dist/api/loaders/_export.d.ts +1 -0
- package/dist/api/loaders/_export.d.ts.map +1 -1
- package/dist/api/loaders/obj/{ObjLoader.d.ts → ObjParser.d.ts} +20 -5
- package/dist/api/loaders/obj/ObjParser.d.ts.map +1 -0
- package/dist/api/loaders/obj/ObjTypes.d.ts +17 -1
- package/dist/api/loaders/obj/ObjTypes.d.ts.map +1 -1
- package/dist/api/loaders/obj/index.d.ts +1 -1
- package/dist/api/material/ForwardBlinnPhongMaterial.d.ts +22 -11
- package/dist/api/material/ForwardBlinnPhongMaterial.d.ts.map +1 -1
- package/dist/api/material/ICameraMaterial.d.ts +18 -0
- package/dist/api/material/ICameraMaterial.d.ts.map +1 -0
- package/dist/api/material/ILightsMaterial.d.ts +26 -0
- package/dist/api/material/ILightsMaterial.d.ts.map +1 -0
- package/dist/api/material/IMaterial.d.ts +2 -8
- package/dist/api/material/IMaterial.d.ts.map +1 -1
- package/dist/api/material/InspectTextureMipsMaterial.d.ts +2 -2
- package/dist/api/material/InspectTextureMipsMaterial.d.ts.map +1 -1
- package/dist/api/material/SpriteMaterial.d.ts +2 -2
- package/dist/api/material/SpriteMaterial.d.ts.map +1 -1
- package/dist/api/material/UnlitMaterial.d.ts +4 -3
- package/dist/api/material/UnlitMaterial.d.ts.map +1 -1
- package/dist/api/material/_export.d.ts +2 -0
- package/dist/api/material/_export.d.ts.map +1 -1
- package/dist/api/meshes/IMesh.d.ts +29 -34
- package/dist/api/meshes/IMesh.d.ts.map +1 -1
- package/dist/api/meshes/IMeshFactory.d.ts +13 -8
- package/dist/api/meshes/IMeshFactory.d.ts.map +1 -1
- package/dist/api/meshes/IRenderableMesh.d.ts +47 -0
- package/dist/api/meshes/IRenderableMesh.d.ts.map +1 -0
- package/dist/api/meshes/Mesh.d.ts +11 -57
- package/dist/api/meshes/Mesh.d.ts.map +1 -1
- package/dist/api/meshes/MeshFactory.d.ts +6 -3
- package/dist/api/meshes/MeshFactory.d.ts.map +1 -1
- package/dist/api/meshes/QuadMesh.d.ts +3 -5
- package/dist/api/meshes/QuadMesh.d.ts.map +1 -1
- package/dist/api/meshes/RenderableMesh.d.ts +95 -0
- package/dist/api/meshes/RenderableMesh.d.ts.map +1 -0
- package/dist/api/meshes/_export.d.ts +2 -1
- package/dist/api/meshes/_export.d.ts.map +1 -1
- package/dist/api/rendering/IGraphicsDeviceFeatures.d.ts +8 -2
- package/dist/api/rendering/IGraphicsDeviceFeatures.d.ts.map +1 -1
- package/dist/api/rendering/IRenderer.d.ts +28 -1
- package/dist/api/rendering/IRenderer.d.ts.map +1 -1
- package/dist/api/rendering/enums.d.ts +7 -0
- package/dist/api/rendering/enums.d.ts.map +1 -1
- package/dist/api/rendering/renderer-interface.d.ts +1 -31
- package/dist/api/rendering/renderer-interface.d.ts.map +1 -1
- package/dist/api/rendering/renderpass/RenderPassDescriptor.d.ts +2 -6
- package/dist/api/rendering/renderpass/RenderPassDescriptor.d.ts.map +1 -1
- package/dist/api/rendering/swapchain/ISwapChain.d.ts +1 -3
- package/dist/api/rendering/swapchain/ISwapChain.d.ts.map +1 -1
- package/dist/api/rendering/texture/TextureFormat.d.ts +88 -14
- package/dist/api/rendering/texture/TextureFormat.d.ts.map +1 -1
- package/dist/api/rendering/texture/TextureUtilities.d.ts +23 -0
- package/dist/api/rendering/texture/TextureUtilities.d.ts.map +1 -1
- package/dist/api/scene/Scene.d.ts +30 -21
- package/dist/api/scene/Scene.d.ts.map +1 -1
- package/dist/api/scene/SceneMesh.d.ts +27 -0
- package/dist/api/scene/SceneMesh.d.ts.map +1 -0
- package/dist/api/utilities/AlignUtilities.d.ts.map +1 -1
- package/dist/api/window/WindowManager.d.ts.map +1 -1
- package/dist/core/rendering/ARenderer.d.ts +5 -5
- package/dist/core/rendering/ARenderer.d.ts.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4006 -1355
- package/dist/webgl/WebGLGraphicsDeviceFeatures.d.ts +4 -0
- package/dist/webgl/WebGLGraphicsDeviceFeatures.d.ts.map +1 -1
- package/dist/webgl/WebGlRenderer.d.ts +1 -3
- package/dist/webgl/WebGlRenderer.d.ts.map +1 -1
- package/dist/webgl/lights/WebGlLightsBuffer.d.ts +8 -4
- package/dist/webgl/lights/WebGlLightsBuffer.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts +2 -0
- package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/swap-chain/WebGlSwapChain.d.ts +3 -2
- package/dist/webgl/swap-chain/WebGlSwapChain.d.ts.map +1 -1
- package/dist/webgl/texture/WebGlTextureFactory.d.ts +7 -0
- package/dist/webgl/texture/WebGlTextureFactory.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlConstants.d.ts +91 -0
- package/dist/webgl/utilities/WebGlConstants.d.ts.map +1 -0
- package/dist/webgl/utilities/WebGlConverter.d.ts +0 -7
- package/dist/webgl/utilities/WebGlConverter.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlErrorUtilities.d.ts +10 -0
- package/dist/webgl/utilities/WebGlErrorUtilities.d.ts.map +1 -0
- package/dist/webgl/utilities/WebGlTextureUtilities.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlUtilities.d.ts +3 -0
- package/dist/webgl/utilities/WebGlUtilities.d.ts.map +1 -1
- package/dist/webgpu/WebGpuGpuInfo.d.ts +28 -0
- package/dist/webgpu/WebGpuGpuInfo.d.ts.map +1 -0
- package/dist/webgpu/WebGpuGraphicsDevice.d.ts +80 -0
- package/dist/webgpu/WebGpuGraphicsDevice.d.ts.map +1 -0
- package/dist/webgpu/WebGpuGraphicsDeviceFeatures.d.ts +26 -0
- package/dist/webgpu/WebGpuGraphicsDeviceFeatures.d.ts.map +1 -0
- package/dist/webgpu/WebGpuRenderer.d.ts +26 -0
- package/dist/webgpu/WebGpuRenderer.d.ts.map +1 -0
- package/dist/webgpu/WebGpuTypes.d.ts +355 -0
- package/dist/webgpu/WebGpuTypes.d.ts.map +1 -0
- package/dist/webgpu/blending/WebGpuBlendState.d.ts +30 -0
- package/dist/webgpu/blending/WebGpuBlendState.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuBuffersFactory.d.ts +20 -0
- package/dist/webgpu/buffers/WebGpuBuffersFactory.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuIndexBuffer.d.ts +46 -0
- package/dist/webgpu/buffers/WebGpuIndexBuffer.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuUniformBuffer.d.ts +43 -0
- package/dist/webgpu/buffers/WebGpuUniformBuffer.d.ts.map +1 -0
- package/dist/webgpu/buffers/WebGpuVertexBuffer.d.ts +49 -0
- package/dist/webgpu/buffers/WebGpuVertexBuffer.d.ts.map +1 -0
- package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts +32 -0
- package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts.map +1 -0
- package/dist/webgpu/render-pass/WebGpuRenderPass.d.ts +28 -0
- package/dist/webgpu/render-pass/WebGpuRenderPass.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/AWebGpuRenderPipeline.d.ts +50 -0
- package/dist/webgpu/render-pipelines/AWebGpuRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts +34 -0
- package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/WebGpuRenderPipelineFactory.d.ts +26 -0
- package/dist/webgpu/render-pipelines/WebGpuRenderPipelineFactory.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/material/AWebGpuMeshRenderPipeline.d.ts +72 -0
- package/dist/webgpu/render-pipelines/material/AWebGpuMeshRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/render-pipelines/material/WebGpuUnlitRenderPipeline.d.ts +40 -0
- package/dist/webgpu/render-pipelines/material/WebGpuUnlitRenderPipeline.d.ts.map +1 -0
- package/dist/webgpu/sampler/WebGpuSampler.d.ts +39 -0
- package/dist/webgpu/sampler/WebGpuSampler.d.ts.map +1 -0
- package/dist/webgpu/shader/WebGpuShaderModule.d.ts +29 -0
- package/dist/webgpu/shader/WebGpuShaderModule.d.ts.map +1 -0
- package/dist/webgpu/shader/WebGpuShaderModuleLoader.d.ts +21 -0
- package/dist/webgpu/shader/WebGpuShaderModuleLoader.d.ts.map +1 -0
- package/dist/webgpu/shader/WgslShaderContent.d.ts +9 -0
- package/dist/webgpu/shader/WgslShaderContent.d.ts.map +1 -0
- package/dist/webgpu/swap-chain/WebGpuSwapChain.d.ts +41 -0
- package/dist/webgpu/swap-chain/WebGpuSwapChain.d.ts.map +1 -0
- package/dist/webgpu/texture/WebGpuTexture2D.d.ts +47 -0
- package/dist/webgpu/texture/WebGpuTexture2D.d.ts.map +1 -0
- package/dist/webgpu/texture/WebGpuTextureFactory.d.ts +21 -0
- package/dist/webgpu/texture/WebGpuTextureFactory.d.ts.map +1 -0
- package/dist/webgpu/texture/WebGpuTextureView.d.ts +25 -0
- package/dist/webgpu/texture/WebGpuTextureView.d.ts.map +1 -0
- package/dist/webgpu/utilities/WebGpuConverter.d.ts +45 -0
- package/dist/webgpu/utilities/WebGpuConverter.d.ts.map +1 -0
- package/package.json +2 -2
- package/shaders/glsl/main_render_target_flip_y_fs.glsl +35 -1
- package/shaders/wgsl/forward_blinn_phong_material.wgsl +150 -0
- package/shaders/wgsl/inspect_texture_mips.wgsl +51 -0
- package/shaders/wgsl/main_frame_buffer.wgsl +35 -0
- package/shaders/wgsl/main_render_target_flip_y.wgsl +35 -0
- package/shaders/wgsl/sprite.wgsl +40 -0
- package/shaders/wgsl/unlit_material.wgsl +49 -0
- package/src/Framework.ts +121 -37
- package/src/api/IFramework.ts +55 -0
- package/src/api/_export.ts +1 -1
- package/src/api/content/ContentManager.ts +46 -180
- package/src/api/content/IContentManager.ts +25 -21
- package/src/api/lights/LightsBuffer.ts +13 -6
- package/src/api/loaders/ObjGeometryMapper.ts +2 -2
- package/src/api/loaders/ObjLoader.ts +126 -0
- package/src/api/loaders/_export.ts +1 -0
- package/src/api/loaders/obj/{ObjLoader.ts → ObjParser.ts} +35 -4
- package/src/api/loaders/obj/ObjTypes.ts +19 -1
- package/src/api/loaders/obj/index.ts +1 -1
- package/src/api/material/ForwardBlinnPhongMaterial.ts +48 -22
- package/src/api/material/ICameraMaterial.ts +22 -0
- package/src/api/material/ILightsMaterial.ts +32 -0
- package/src/api/material/IMaterial.ts +2 -9
- package/src/api/material/InspectTextureMipsMaterial.ts +2 -2
- package/src/api/material/SpriteMaterial.ts +2 -2
- package/src/api/material/UnlitMaterial.ts +4 -3
- package/src/api/material/_export.ts +2 -0
- package/src/api/meshes/IMesh.ts +32 -37
- package/src/api/meshes/IMeshFactory.ts +14 -8
- package/src/api/meshes/IRenderableMesh.ts +58 -0
- package/src/api/meshes/Mesh.ts +17 -132
- package/src/api/meshes/MeshFactory.ts +14 -5
- package/src/api/meshes/QuadMesh.ts +4 -6
- package/src/api/meshes/RenderableMesh.ts +207 -0
- package/src/api/meshes/_export.ts +6 -5
- package/src/api/rendering/IGraphicsDeviceFeatures.ts +28 -21
- package/src/api/rendering/IRenderer.ts +34 -1
- package/src/api/rendering/enums.ts +10 -0
- package/src/api/rendering/renderer-interface.ts +1 -36
- package/src/api/rendering/renderpass/RenderPassDescriptor.ts +10 -14
- package/src/api/rendering/swapchain/ISwapChain.ts +1 -3
- package/src/api/rendering/texture/TextureFormat.ts +128 -14
- package/src/api/rendering/texture/TextureUtilities.ts +225 -10
- package/src/api/scene/Scene.ts +102 -69
- package/src/api/scene/SceneMesh.ts +61 -0
- package/src/api/sprites/SpriteBatchMesh.ts +1 -1
- package/src/api/utilities/AlignUtilities.ts +2 -1
- package/src/api/window/WindowManager.ts +1 -1
- package/src/core/rendering/ARenderer.ts +24 -15
- package/src/index.ts +0 -1
- package/src/main.ts +2 -3
- package/src/webgl/WebGLGraphicsDeviceFeatures.ts +12 -2
- package/src/webgl/WebGlGpuInfo.ts +1 -1
- package/src/webgl/WebGlRenderer.ts +2 -5
- package/src/webgl/lights/WebGlLightsBuffer.ts +14 -4
- package/src/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.ts +18 -1
- package/src/webgl/swap-chain/WebGlSwapChain.ts +7 -6
- package/src/webgl/texture/WebGlTextureFactory.ts +49 -7
- package/src/webgl/utilities/WebGlConstants.ts +136 -0
- package/src/webgl/utilities/WebGlConverter.ts +91 -22
- package/src/webgl/utilities/WebGlErrorUtilities.ts +15 -0
- package/src/webgl/utilities/WebGlTextureUtilities.ts +5 -2
- package/src/webgl/utilities/WebGlUtilities.ts +4 -0
- package/src/webgpu/WebGpuGpuInfo.ts +61 -0
- package/src/webgpu/WebGpuGraphicsDevice.ts +199 -0
- package/src/webgpu/WebGpuGraphicsDeviceFeatures.ts +41 -0
- package/src/webgpu/WebGpuRenderer.ts +49 -0
- package/src/webgpu/WebGpuTypes.ts +288 -0
- package/src/webgpu/blending/WebGpuBlendState.ts +53 -0
- package/src/webgpu/buffers/WebGpuBuffersFactory.ts +46 -0
- package/src/webgpu/buffers/WebGpuIndexBuffer.ts +118 -0
- package/src/webgpu/buffers/WebGpuUniformBuffer.ts +102 -0
- package/src/webgpu/buffers/WebGpuVertexBuffer.ts +119 -0
- package/src/webgpu/primitive/WebGpuPrimitiveState.ts +52 -0
- package/src/webgpu/render-pass/WebGpuRenderPass.ts +131 -0
- package/src/webgpu/render-pipelines/AWebGpuRenderPipeline.ts +123 -0
- package/src/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.ts +119 -0
- package/src/webgpu/render-pipelines/WebGpuRenderPipelineFactory.ts +66 -0
- package/src/webgpu/render-pipelines/material/AWebGpuMeshRenderPipeline.ts +249 -0
- package/src/webgpu/render-pipelines/material/WebGpuUnlitRenderPipeline.ts +101 -0
- package/src/webgpu/sampler/WebGpuSampler.ts +84 -0
- package/src/webgpu/shader/WebGpuShaderModule.ts +65 -0
- package/src/webgpu/shader/WebGpuShaderModuleLoader.ts +38 -0
- package/src/webgpu/shader/WgslShaderContent.ts +20 -0
- package/src/webgpu/swap-chain/WebGpuSwapChain.ts +93 -0
- package/src/webgpu/texture/WebGpuTexture2D.ts +197 -0
- package/src/webgpu/texture/WebGpuTextureFactory.ts +118 -0
- package/src/webgpu/texture/WebGpuTextureView.ts +43 -0
- package/src/webgpu/utilities/WebGpuConverter.ts +299 -0
- package/src/wgsl-raw.d.ts +4 -0
- package/dist/api/FrameworkConfiguration.d.ts +0 -23
- package/dist/api/FrameworkConfiguration.d.ts.map +0 -1
- package/dist/api/IFrameworkConfiguration.d.ts +0 -25
- package/dist/api/IFrameworkConfiguration.d.ts.map +0 -1
- package/dist/api/loaders/obj/ObjLoader.d.ts.map +0 -1
- package/dist/api/meshes/SubMesh.d.ts +0 -47
- package/dist/api/meshes/SubMesh.d.ts.map +0 -1
- package/src/api/FrameworkConfiguration.ts +0 -29
- package/src/api/IFrameworkConfiguration.ts +0 -30
- package/src/api/meshes/SubMesh.ts +0 -71
package/src/api/meshes/Mesh.ts
CHANGED
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The mesh is a building class for a world shape.
|
|
3
3
|
*/
|
|
4
|
-
import {mat4, quat, vec3} from "gl-matrix";
|
|
5
4
|
import {State} from "../data/State.ts";
|
|
6
5
|
import type {IVertexBuffer} from "../rendering/buffers/IVertexBuffer.ts";
|
|
7
6
|
import type {IIndexBuffer} from "../rendering/buffers/IIndexBuffer.ts";
|
|
8
|
-
import type {IUniformBuffer} from "../rendering/buffers/IUniformBuffer.ts";
|
|
9
7
|
import type {IFramework} from "../IFramework.ts";
|
|
10
8
|
import type {IMesh} from "./IMesh.ts";
|
|
11
9
|
import {BufferUsage} from "../rendering/buffers/BufferUsage.ts";
|
|
12
10
|
import type {IGeometry} from "../geometry/IGeometry.ts";
|
|
13
11
|
import {MeshParameters} from "./MeshParameters.ts";
|
|
14
12
|
import {GeometryUtilities} from "../utilities/GeometryUtilities.ts";
|
|
15
|
-
import type {IMaterial} from "../material/IMaterial.ts";
|
|
16
13
|
import type {GeometryFormat} from "../geometry/GeometryFormat.ts";
|
|
17
|
-
import {SubMesh} from "./SubMesh.ts";
|
|
18
|
-
import type {Scene} from "../scene/Scene.ts";
|
|
19
14
|
|
|
20
15
|
/**
|
|
21
|
-
* The mesh.
|
|
16
|
+
* The base mesh: geometry and the vertex and index buffers created from it (C# `BaseMesh`).
|
|
17
|
+
* No material and no transform; {@link RenderableMesh} adds those.
|
|
18
|
+
* @public
|
|
22
19
|
*/
|
|
23
20
|
export class Mesh implements IMesh {
|
|
24
21
|
|
|
@@ -32,116 +29,23 @@ export class Mesh implements IMesh {
|
|
|
32
29
|
protected _normals?: number[];
|
|
33
30
|
protected _vertexBuffer?: IVertexBuffer;
|
|
34
31
|
protected _indexBuffer?: IIndexBuffer;
|
|
35
|
-
protected
|
|
36
|
-
private readonly _modelMatrix = mat4.create();
|
|
37
|
-
private readonly _rotationQuat = quat.create();
|
|
38
|
-
// Cached copies to detect in-place edits; NaN forces the first computation.
|
|
39
|
-
private readonly _lastPosition = vec3.fromValues(NaN, NaN, NaN);
|
|
40
|
-
private readonly _lastRotation = vec3.create();
|
|
41
|
-
private readonly _lastScale = vec3.create();
|
|
42
|
-
private _modelBuffer?: IUniformBuffer;
|
|
43
|
-
/** The matrix last uploaded to the model buffer. */
|
|
44
|
-
private readonly _uploadedMatrix = mat4.create();
|
|
45
|
-
|
|
46
|
-
/** @inheritDoc */
|
|
47
|
-
public position: vec3 = vec3.create();
|
|
48
|
-
|
|
49
|
-
/** @inheritDoc */
|
|
50
|
-
public rotation: vec3 = vec3.create();
|
|
51
|
-
|
|
52
|
-
/** @inheritDoc */
|
|
53
|
-
public scale: vec3 = vec3.fromValues(1, 1, 1);
|
|
54
|
-
|
|
55
|
-
/** @inheritDoc */
|
|
56
|
-
public get modelMatrix(): mat4 {
|
|
57
|
-
if (!vec3.exactEquals(this._lastPosition, this.position)
|
|
58
|
-
|| !vec3.exactEquals(this._lastRotation, this.rotation)
|
|
59
|
-
|| !vec3.exactEquals(this._lastScale, this.scale)) {
|
|
60
|
-
vec3.copy(this._lastPosition, this.position);
|
|
61
|
-
vec3.copy(this._lastRotation, this.rotation);
|
|
62
|
-
vec3.copy(this._lastScale, this.scale);
|
|
63
|
-
const q = quat.identity(this._rotationQuat);
|
|
64
|
-
quat.rotateY(q, q, this.rotation[1]);
|
|
65
|
-
quat.rotateX(q, q, this.rotation[0]);
|
|
66
|
-
quat.rotateZ(q, q, this.rotation[2]);
|
|
67
|
-
mat4.fromRotationTranslationScale(this._modelMatrix, q, this.position, this.scale);
|
|
68
|
-
}
|
|
69
|
-
return this._modelMatrix;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/** @inheritDoc Created on first access and disposed with the mesh. */
|
|
73
|
-
public get modelBuffer(): IUniformBuffer {
|
|
74
|
-
if (!this._modelBuffer) {
|
|
75
|
-
mat4.copy(this._uploadedMatrix, this.modelMatrix);
|
|
76
|
-
this._modelBuffer = this._framework.bufferFactory.createUniformBuffer(
|
|
77
|
-
this._uploadedMatrix, BufferUsage.UNIFORM | BufferUsage.COPY_DST, "Mesh.modelBuffer");
|
|
78
|
-
}
|
|
79
|
-
return this._modelBuffer;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/** Uploads the model matrix when the transform changed since the last upload. */
|
|
83
|
-
private _updateModelBuffer(): IUniformBuffer {
|
|
84
|
-
const buffer = this.modelBuffer;
|
|
85
|
-
const matrix = this.modelMatrix;
|
|
86
|
-
if (!mat4.exactEquals(this._uploadedMatrix, matrix)) {
|
|
87
|
-
mat4.copy(this._uploadedMatrix, matrix);
|
|
88
|
-
buffer.update(this._uploadedMatrix);
|
|
89
|
-
}
|
|
90
|
-
return buffer;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Assigns this mesh's model buffer to a material that uses one (has a `modelBuffer` property),
|
|
95
|
-
* only when it differs. Materials without one (e.g. sprites) are skipped and no buffer is created for them.
|
|
96
|
-
* @internal
|
|
97
|
-
*/
|
|
98
|
-
__assignModelBuffer(material: IMaterial): void {
|
|
99
|
-
if (!("modelBuffer" in material)) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const buffer = this._updateModelBuffer();
|
|
103
|
-
if (material.modelBuffer !== buffer) {
|
|
104
|
-
material.modelBuffer = buffer;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
32
|
+
protected _geometry?: IGeometry;
|
|
107
33
|
|
|
108
34
|
/**
|
|
109
35
|
* The constructor.
|
|
110
36
|
* @param _framework The framework.
|
|
111
|
-
* @param scene The scene. The mesh adds itself to it and removes itself on dispose.
|
|
112
|
-
* `null` only for internal meshes drawn outside a scene (e.g. the sprite batch).
|
|
113
|
-
* @param _material The material. Optional for a mesh that only holds submeshes.
|
|
114
37
|
*/
|
|
115
|
-
public constructor(protected readonly _framework: IFramework
|
|
116
|
-
scene?.add(this);
|
|
38
|
+
public constructor(protected readonly _framework: IFramework) {
|
|
117
39
|
}
|
|
118
40
|
|
|
119
|
-
/** The
|
|
120
|
-
public get
|
|
121
|
-
return this.
|
|
41
|
+
/** The geometry the buffers were created from with {@link setGeometry}, if any. */
|
|
42
|
+
public get geometry(): IGeometry | undefined {
|
|
43
|
+
return this._geometry;
|
|
122
44
|
}
|
|
123
45
|
|
|
124
|
-
/**
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/** The submeshes. They share this mesh's vertex and index buffers. */
|
|
130
|
-
public get subMeshes(): SubMesh[] {
|
|
131
|
-
return this._subMeshes;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Adds a submesh that draws a range of this mesh's index buffer with its own material.
|
|
136
|
-
* @param material The material of the submesh.
|
|
137
|
-
* @param indexStart The first index of the range.
|
|
138
|
-
* @param indexCount The number of indices in the range.
|
|
139
|
-
* @returns The submesh.
|
|
140
|
-
*/
|
|
141
|
-
public addSubMesh(material: IMaterial, indexStart: number, indexCount: number): SubMesh {
|
|
142
|
-
const subMesh = new SubMesh(this, material, indexStart, indexCount);
|
|
143
|
-
this._subMeshes.push(subMesh);
|
|
144
|
-
return subMesh;
|
|
46
|
+
/** The geometry format used when {@link setGeometry} is called without one. Undefined for a plain mesh. */
|
|
47
|
+
protected get _defaultGeometryFormat(): GeometryFormat | undefined {
|
|
48
|
+
return undefined;
|
|
145
49
|
}
|
|
146
50
|
|
|
147
51
|
/**
|
|
@@ -301,13 +205,13 @@ export class Mesh implements IMesh {
|
|
|
301
205
|
*
|
|
302
206
|
* This will create vertex buffer and index buffer from geometry.
|
|
303
207
|
* @param geometry - The geometry.
|
|
304
|
-
* @param geometryFormat - The vertex layout.
|
|
208
|
+
* @param geometryFormat - The vertex layout. A `RenderableMesh` defaults to its material's geometry format.
|
|
305
209
|
*/
|
|
306
210
|
public setGeometry(geometry: IGeometry, geometryFormat?: GeometryFormat): void {
|
|
307
211
|
|
|
308
|
-
const format = geometryFormat ?? this.
|
|
212
|
+
const format = geometryFormat ?? this._defaultGeometryFormat;
|
|
309
213
|
if (format === undefined) {
|
|
310
|
-
throw new Error("Cannot create buffers for a Mesh without a
|
|
214
|
+
throw new Error("Cannot create buffers for a Mesh without a geometry format (pass one, or give a RenderableMesh a material).");
|
|
311
215
|
}
|
|
312
216
|
if (geometry.vertexCount == 0) {
|
|
313
217
|
const message =
|
|
@@ -316,6 +220,7 @@ export class Mesh implements IMesh {
|
|
|
316
220
|
throw new Error(message);
|
|
317
221
|
}
|
|
318
222
|
|
|
223
|
+
this._geometry = geometry;
|
|
319
224
|
const interleavedData = geometry.toInterleaved(format);
|
|
320
225
|
const stride = GeometryUtilities.stride(format);
|
|
321
226
|
|
|
@@ -345,34 +250,14 @@ export class Mesh implements IMesh {
|
|
|
345
250
|
this.applyChanges();
|
|
346
251
|
}
|
|
347
252
|
|
|
348
|
-
/** @inheritDoc */
|
|
349
|
-
public render(): void {
|
|
350
|
-
|
|
351
|
-
// Render submeshes.
|
|
352
|
-
if (this.subMeshes?.length > 0) {
|
|
353
|
-
for (let i = 0; i < this.subMeshes.length; ++i) {
|
|
354
|
-
this.subMeshes[i].render();
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (this.material) {
|
|
359
|
-
this.__assignModelBuffer(this.material);
|
|
360
|
-
this.material.beforeRender();
|
|
361
|
-
this.material.renderMesh(this);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
253
|
/**
|
|
366
|
-
*
|
|
254
|
+
* Disposes the vertex and index buffers.
|
|
367
255
|
*/
|
|
368
256
|
public dispose(): void {
|
|
369
|
-
this.scene?.remove(this);
|
|
370
|
-
this._subMeshes.length = 0;
|
|
371
257
|
this._vertexBuffer?.dispose();
|
|
372
258
|
this._vertexBuffer = undefined;
|
|
373
259
|
this._indexBuffer?.dispose();
|
|
374
260
|
this._indexBuffer = undefined;
|
|
375
|
-
this.
|
|
376
|
-
this._modelBuffer = undefined;
|
|
261
|
+
this._state = State.DISPOSED;
|
|
377
262
|
}
|
|
378
263
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {RenderableMesh} from "./RenderableMesh.ts";
|
|
2
|
+
import type { IRenderableMesh } from "./IRenderableMesh.ts";
|
|
3
|
+
import type { GeometryFormat } from "../geometry/GeometryFormat.ts";
|
|
2
4
|
import type { IMeshFactory } from "./IMeshFactory.ts";
|
|
3
5
|
import type { IGeometry } from "../geometry/IGeometry.ts";
|
|
4
6
|
import type { IMesh } from "./IMesh.ts";
|
|
@@ -22,14 +24,21 @@ export class MeshFactory implements IMeshFactory {
|
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
/** @inheritDoc */
|
|
25
|
-
public
|
|
26
|
-
const mesh = new Mesh(this._framework
|
|
27
|
+
public createMesh(geometry: IGeometry, geometryFormat: GeometryFormat): IMesh {
|
|
28
|
+
const mesh = new Mesh(this._framework);
|
|
29
|
+
mesh.setGeometry(geometry, geometryFormat);
|
|
30
|
+
return mesh;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** @inheritDoc */
|
|
34
|
+
public create(geometry: IGeometry, material: IMaterial): IRenderableMesh {
|
|
35
|
+
const mesh = new RenderableMesh(this._framework, material);
|
|
27
36
|
mesh.setGeometry(geometry);
|
|
28
37
|
return mesh;
|
|
29
38
|
}
|
|
30
39
|
|
|
31
40
|
/** @inheritDoc */
|
|
32
|
-
public createWithSubMeshes(
|
|
41
|
+
public createWithSubMeshes(geometry: IGeometry, subMeshes: SubMeshDescriptor[]): IRenderableMesh {
|
|
33
42
|
if (subMeshes.length == 0) {
|
|
34
43
|
throw new Error("createWithSubMeshes needs at least one submesh.");
|
|
35
44
|
}
|
|
@@ -38,7 +47,7 @@ export class MeshFactory implements IMeshFactory {
|
|
|
38
47
|
throw new Error("All submesh materials must use the same geometry format, as they share one vertex buffer.");
|
|
39
48
|
}
|
|
40
49
|
|
|
41
|
-
const mesh = new
|
|
50
|
+
const mesh = new RenderableMesh(this._framework);
|
|
42
51
|
mesh.setGeometry(geometry, format);
|
|
43
52
|
for (const subMesh of subMeshes) {
|
|
44
53
|
mesh.addSubMesh(subMesh.material, subMesh.indexStart, subMesh.indexCount);
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {RenderableMesh} from "./RenderableMesh.ts";
|
|
2
2
|
import {Rect} from "../data/Rect.ts";
|
|
3
3
|
import type { IFramework } from "../IFramework.ts";
|
|
4
4
|
import {vec2} from "gl-matrix";
|
|
5
5
|
import {BufferUsage} from "../rendering/buffers/BufferUsage.ts";
|
|
6
6
|
import type {IMaterial} from "../material/IMaterial.ts";
|
|
7
|
-
import type {Scene} from "../scene/Scene.ts";
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* The mesh of a quad.
|
|
11
10
|
*/
|
|
12
|
-
export class QuadMesh extends
|
|
11
|
+
export class QuadMesh extends RenderableMesh {
|
|
13
12
|
|
|
14
13
|
private readonly ELEMENTS_IN_VERTEX = 9;
|
|
15
14
|
private readonly TEX_COORD_POS_S = 7;
|
|
@@ -18,13 +17,12 @@ export class QuadMesh extends Mesh {
|
|
|
18
17
|
/**
|
|
19
18
|
* The constructor.
|
|
20
19
|
* @param framework The framework.
|
|
21
|
-
* @param scene The scene the quad adds itself to.
|
|
22
20
|
* @param material The material.
|
|
23
21
|
* @param _isUpdatable Makes mesh updatable.
|
|
24
22
|
* @param scale The scale factor for geometry. If not set, it is set to (1,1).
|
|
25
23
|
*/
|
|
26
|
-
public constructor(framework: IFramework,
|
|
27
|
-
|
|
24
|
+
public constructor(framework: IFramework, material: IMaterial, private _isUpdatable: boolean, scale?: vec2) {
|
|
25
|
+
super(framework, material);
|
|
28
26
|
if(_isUpdatable) {
|
|
29
27
|
this._bufferUsage = BufferUsage.VERTEX | BufferUsage.COPY_DST;
|
|
30
28
|
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import {mat4, quat, vec3} from "gl-matrix";
|
|
2
|
+
import {Mesh} from "./Mesh.ts";
|
|
3
|
+
import type {IRenderableMesh} from "./IRenderableMesh.ts";
|
|
4
|
+
import type {IFramework} from "../IFramework.ts";
|
|
5
|
+
import type {IMaterial} from "../material/IMaterial.ts";
|
|
6
|
+
import type {IUniformBuffer} from "../rendering/buffers/IUniformBuffer.ts";
|
|
7
|
+
import type {IVertexBuffer} from "../rendering/buffers/IVertexBuffer.ts";
|
|
8
|
+
import type {IIndexBuffer} from "../rendering/buffers/IIndexBuffer.ts";
|
|
9
|
+
import type {GeometryFormat} from "../geometry/GeometryFormat.ts";
|
|
10
|
+
import {BufferUsage} from "../rendering/buffers/BufferUsage.ts";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A mesh that can be drawn (C# `RenderableMesh`). See {@link IRenderableMesh}.
|
|
14
|
+
*
|
|
15
|
+
* - Root: `new RenderableMesh(framework, material?)` owns the vertex and index buffers, the transform and the model buffer.
|
|
16
|
+
* - Sub mesh: `new RenderableMesh(framework, material, parent, indexStart, indexCount)` (or `parent.addSubMesh(...)`)
|
|
17
|
+
* shares the parent's buffers, transform and model buffer, and only stores its index range.
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export class RenderableMesh extends Mesh implements IRenderableMesh {
|
|
21
|
+
|
|
22
|
+
private readonly _subMeshes: RenderableMesh[] = [];
|
|
23
|
+
private readonly _parent?: RenderableMesh;
|
|
24
|
+
|
|
25
|
+
// Transform; only used on the root.
|
|
26
|
+
private _position: vec3 = vec3.create();
|
|
27
|
+
private _rotation: vec3 = vec3.create();
|
|
28
|
+
private _scale: vec3 = vec3.fromValues(1, 1, 1);
|
|
29
|
+
private readonly _modelMatrix = mat4.create();
|
|
30
|
+
private readonly _rotationQuat = quat.create();
|
|
31
|
+
// Cached copies to detect in-place edits; NaN forces the first computation.
|
|
32
|
+
private readonly _lastPosition = vec3.fromValues(NaN, NaN, NaN);
|
|
33
|
+
private readonly _lastRotation = vec3.create();
|
|
34
|
+
private readonly _lastScale = vec3.create();
|
|
35
|
+
private _modelBuffer?: IUniformBuffer;
|
|
36
|
+
/** The matrix last uploaded to the model buffer. */
|
|
37
|
+
private readonly _uploadedMatrix = mat4.create();
|
|
38
|
+
|
|
39
|
+
/** @inheritDoc */
|
|
40
|
+
public material?: IMaterial;
|
|
41
|
+
|
|
42
|
+
/** @inheritDoc */
|
|
43
|
+
public readonly indexStart: number;
|
|
44
|
+
|
|
45
|
+
/** @inheritDoc */
|
|
46
|
+
public readonly indexCount: number;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The constructor.
|
|
50
|
+
* @param framework The framework.
|
|
51
|
+
* @param material The material. Optional for a root mesh drawn only through its sub meshes.
|
|
52
|
+
* @param parent The parent, for a sub mesh. A sub mesh shares the parent's buffers and transform and is added to `parent.subMeshes`.
|
|
53
|
+
* @param indexStart The first index of the range. Defaults to 0.
|
|
54
|
+
* @param indexCount The number of indices of the range. -1 (default) draws all indices.
|
|
55
|
+
*/
|
|
56
|
+
public constructor(framework: IFramework, material?: IMaterial, parent?: RenderableMesh, indexStart = 0, indexCount = -1) {
|
|
57
|
+
super(framework);
|
|
58
|
+
this.material = material;
|
|
59
|
+
this._parent = parent;
|
|
60
|
+
this.indexStart = indexStart;
|
|
61
|
+
this.indexCount = indexCount;
|
|
62
|
+
parent?._subMeshes.push(this);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** The root mesh: the one owning the buffers and the transform. */
|
|
66
|
+
private get _root(): RenderableMesh {
|
|
67
|
+
return this._parent ? this._parent._root : this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** @inheritDoc */
|
|
71
|
+
public get parent(): RenderableMesh | undefined {
|
|
72
|
+
return this._parent;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** @inheritDoc */
|
|
76
|
+
public get subMeshes(): readonly RenderableMesh[] {
|
|
77
|
+
return this._subMeshes;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Adds a sub mesh that draws a range of this mesh's index buffer with its own material.
|
|
82
|
+
* @param material The material of the sub mesh.
|
|
83
|
+
* @param indexStart The first index of the range.
|
|
84
|
+
* @param indexCount The number of indices in the range; -1 draws all.
|
|
85
|
+
* @returns The sub mesh.
|
|
86
|
+
*/
|
|
87
|
+
public addSubMesh(material: IMaterial | undefined, indexStart: number, indexCount: number): RenderableMesh {
|
|
88
|
+
return new RenderableMesh(this._framework, material, this, indexStart, indexCount);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The parent's vertex buffer for a sub mesh, else its own. */
|
|
92
|
+
public override get vertexBuffer(): IVertexBuffer | undefined {
|
|
93
|
+
return this._parent ? this._parent.vertexBuffer : this._vertexBuffer;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The parent's index buffer for a sub mesh, else its own. */
|
|
97
|
+
public override get indexBuffer(): IIndexBuffer | undefined {
|
|
98
|
+
return this._parent ? this._parent.indexBuffer : this._indexBuffer;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** The material's geometry format. */
|
|
102
|
+
protected override get _defaultGeometryFormat(): GeometryFormat | undefined {
|
|
103
|
+
return this.material?.geometryFormat;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** @inheritDoc */
|
|
107
|
+
public get position(): vec3 { return this._root._position; }
|
|
108
|
+
public set position(value: vec3) { this._root._position = value; }
|
|
109
|
+
|
|
110
|
+
/** @inheritDoc */
|
|
111
|
+
public get rotation(): vec3 { return this._root._rotation; }
|
|
112
|
+
public set rotation(value: vec3) { this._root._rotation = value; }
|
|
113
|
+
|
|
114
|
+
/** @inheritDoc */
|
|
115
|
+
public get scale(): vec3 { return this._root._scale; }
|
|
116
|
+
public set scale(value: vec3) { this._root._scale = value; }
|
|
117
|
+
|
|
118
|
+
/** @inheritDoc */
|
|
119
|
+
public get modelMatrix(): mat4 {
|
|
120
|
+
const root = this._root;
|
|
121
|
+
if (root !== this) {
|
|
122
|
+
return root.modelMatrix;
|
|
123
|
+
}
|
|
124
|
+
if (!vec3.exactEquals(this._lastPosition, this._position)
|
|
125
|
+
|| !vec3.exactEquals(this._lastRotation, this._rotation)
|
|
126
|
+
|| !vec3.exactEquals(this._lastScale, this._scale)) {
|
|
127
|
+
vec3.copy(this._lastPosition, this._position);
|
|
128
|
+
vec3.copy(this._lastRotation, this._rotation);
|
|
129
|
+
vec3.copy(this._lastScale, this._scale);
|
|
130
|
+
const q = quat.identity(this._rotationQuat);
|
|
131
|
+
quat.rotateY(q, q, this._rotation[1]);
|
|
132
|
+
quat.rotateX(q, q, this._rotation[0]);
|
|
133
|
+
quat.rotateZ(q, q, this._rotation[2]);
|
|
134
|
+
mat4.fromRotationTranslationScale(this._modelMatrix, q, this._position, this._scale);
|
|
135
|
+
}
|
|
136
|
+
return this._modelMatrix;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** @inheritDoc Created on first access and disposed with the root mesh. */
|
|
140
|
+
public get modelBuffer(): IUniformBuffer {
|
|
141
|
+
const root = this._root;
|
|
142
|
+
if (root !== this) {
|
|
143
|
+
return root.modelBuffer;
|
|
144
|
+
}
|
|
145
|
+
if (!this._modelBuffer) {
|
|
146
|
+
mat4.copy(this._uploadedMatrix, this.modelMatrix);
|
|
147
|
+
this._modelBuffer = this._framework.bufferFactory.createUniformBuffer(
|
|
148
|
+
this._uploadedMatrix, BufferUsage.UNIFORM | BufferUsage.COPY_DST, "RenderableMesh.modelBuffer");
|
|
149
|
+
}
|
|
150
|
+
return this._modelBuffer;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Uploads the root's model matrix when the transform changed since the last upload. */
|
|
154
|
+
private _updateModelBuffer(): IUniformBuffer {
|
|
155
|
+
const root = this._root;
|
|
156
|
+
const buffer = root.modelBuffer;
|
|
157
|
+
const matrix = root.modelMatrix;
|
|
158
|
+
if (!mat4.exactEquals(root._uploadedMatrix, matrix)) {
|
|
159
|
+
mat4.copy(root._uploadedMatrix, matrix);
|
|
160
|
+
buffer.update(root._uploadedMatrix);
|
|
161
|
+
}
|
|
162
|
+
return buffer;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Assigns the model buffer to a material that uses one (has a `modelBuffer` property), only when it differs.
|
|
167
|
+
* Materials without one (e.g. sprites) are skipped and no buffer is created for them.
|
|
168
|
+
*/
|
|
169
|
+
private _assignModelBuffer(material: IMaterial): void {
|
|
170
|
+
if (!("modelBuffer" in material)) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const buffer = this._updateModelBuffer();
|
|
174
|
+
if (material.modelBuffer !== buffer) {
|
|
175
|
+
material.modelBuffer = buffer;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** @inheritDoc */
|
|
180
|
+
public render(): void {
|
|
181
|
+
if (this.material) {
|
|
182
|
+
this._assignModelBuffer(this.material);
|
|
183
|
+
this.material.beforeRender();
|
|
184
|
+
this.material.renderMesh(this);
|
|
185
|
+
}
|
|
186
|
+
for (const subMesh of this._subMeshes) {
|
|
187
|
+
subMesh.render();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Disposes the sub meshes, then (for a root) the vertex, index and model buffers, once.
|
|
193
|
+
* A sub mesh never disposes the shared buffers. Materials are not disposed.
|
|
194
|
+
*/
|
|
195
|
+
public override dispose(): void {
|
|
196
|
+
for (const subMesh of this._subMeshes) {
|
|
197
|
+
subMesh.dispose();
|
|
198
|
+
}
|
|
199
|
+
this._subMeshes.length = 0;
|
|
200
|
+
if (this._parent) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
super.dispose();
|
|
204
|
+
this._modelBuffer?.dispose();
|
|
205
|
+
this._modelBuffer = undefined;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * from "./IMeshFactory.ts";
|
|
2
|
-
export * from "./IMesh.ts"
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
2
|
+
export * from "./IMesh.ts";
|
|
3
|
+
export * from "./IRenderableMesh.ts";
|
|
4
|
+
export * from "./Mesh.ts";
|
|
5
|
+
export * from "./RenderableMesh.ts";
|
|
5
6
|
export * from "./QuadMesh.ts";
|
|
6
|
-
export * from "./MeshParameters.ts"
|
|
7
|
-
export * from "./MeshFactory.ts";
|
|
7
|
+
export * from "./MeshParameters.ts";
|
|
8
|
+
export * from "./MeshFactory.ts";
|
|
@@ -3,30 +3,37 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface IGraphicsDeviceFeatures {
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Supports S3TC / DXT (BC1–BC3) texture compression.
|
|
8
|
+
*/
|
|
9
|
+
readonly supportsTextureCompressionS3TC: boolean;
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Supports the sRGB variants of S3TC / DXT (BC1–BC3).
|
|
13
|
+
* In WebGL2 this needs WEBGL_compressed_texture_s3tc_srgb; in WebGPU it is part of texture-compression-bc.
|
|
14
|
+
*/
|
|
15
|
+
readonly supportsTextureCompressionS3TCSrgb: boolean;
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Supports full Block Compression (BC1–BC7) textures.
|
|
19
|
+
Includes S3TC (BC1–BC3) plus BC4–BC7.
|
|
20
|
+
*/
|
|
21
|
+
readonly supportsTextureCompressionBC: boolean;
|
|
21
22
|
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Supports ETC2 / EAC texture compression (OpenGL/ES and Vulkan standard).
|
|
25
|
+
*/
|
|
26
|
+
readonly supportsTextureCompressionETC2: boolean;
|
|
26
27
|
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Supports ASTC (Adaptive Scalable Texture Compression) — LDR and HDR profiles.
|
|
30
|
+
*/
|
|
31
|
+
readonly supportsTextureCompressionASTC: boolean;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Supports PVRTC (PowerVR Texture Compression) 1.
|
|
35
|
+
* PVRTC 2 is not supported by either WebGL2 or WebGPU context.
|
|
36
|
+
*/
|
|
37
|
+
readonly supportsTextureCompressionPVRTC: boolean;
|
|
31
38
|
|
|
32
39
|
}
|
|
@@ -3,10 +3,40 @@ import {TextureFormat} from "./texture/TextureFormat.ts";
|
|
|
3
3
|
import {Color} from "../data/Color.ts";
|
|
4
4
|
import {RenderingBackend} from "./RenderingBackend.ts";
|
|
5
5
|
import {vec2} from "gl-matrix";
|
|
6
|
+
import type {PowerPreferenceType} from "./PowerPreference.ts";
|
|
7
|
+
import type {TextureSamplerFilteringPreset} from "../../core/rendering/enums.ts";
|
|
8
|
+
import type {TextureColorSpace} from "./enums.ts";
|
|
6
9
|
|
|
7
10
|
|
|
11
|
+
/**
|
|
12
|
+
* The configuration for the renderer. This is used to initialize the renderer.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export interface IRendererConfiguration {
|
|
16
|
+
|
|
17
|
+
/**The size of the main frame buffer. */
|
|
18
|
+
backBufferSize: vec2;
|
|
19
|
+
|
|
20
|
+
/** Should back buffer use alpha. */
|
|
21
|
+
alpha: boolean;
|
|
22
|
+
|
|
23
|
+
/** The preference when it comes to selecting GPU device. Only makes sense to set on multi-GPU devices. */
|
|
24
|
+
powerPreference: PowerPreferenceType;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The preset for texture sampler filtering.
|
|
28
|
+
* This is used to configure the default texture sampler in the graphics device.
|
|
29
|
+
* The default texture sampler is used when a texture is sampled without a specific sampler being bound.
|
|
30
|
+
*/
|
|
31
|
+
textureFiltering: TextureSamplerFilteringPreset;
|
|
32
|
+
|
|
33
|
+
/** The desired texture color space. */
|
|
34
|
+
textureColorSpace: TextureColorSpace;
|
|
35
|
+
}
|
|
36
|
+
|
|
8
37
|
/**
|
|
9
38
|
* The interface for a renderer.
|
|
39
|
+
* @public
|
|
10
40
|
*/
|
|
11
41
|
export interface IRenderer {
|
|
12
42
|
|
|
@@ -16,7 +46,10 @@ export interface IRenderer {
|
|
|
16
46
|
readonly graphicsDevice: IGraphicsDevice;
|
|
17
47
|
|
|
18
48
|
/**
|
|
19
|
-
* The
|
|
49
|
+
* The preferred texture format.
|
|
50
|
+
* This will encode texture which do not specify texture format to:
|
|
51
|
+
* - {@link TextureFormat.} // TODO: describe SRGB depending on TextureSurfaceFormat requested
|
|
52
|
+
* - {@link TextureFormat.} // TODO: describe RGBA depending on TextureSurfaceFormat requested
|
|
20
53
|
*/
|
|
21
54
|
readonly preferredTextureFormat: TextureFormat;
|
|
22
55
|
|
|
@@ -17,4 +17,14 @@ export enum Culling {
|
|
|
17
17
|
* The front faces will be culled. Only back faces will be rendered.
|
|
18
18
|
*/
|
|
19
19
|
Front
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** TODO: */
|
|
23
|
+
export enum TextureColorSpace
|
|
24
|
+
{
|
|
25
|
+
/** TODO */
|
|
26
|
+
LINEAR = "LINEAR",
|
|
27
|
+
|
|
28
|
+
/** TODO */
|
|
29
|
+
SRGB = "S_RGBA",
|
|
20
30
|
}
|