ris-framework 0.2.0-dev.14 → 0.2.0-dev.16

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.
Files changed (160) hide show
  1. package/CHANGELOG.md +39 -2
  2. package/README.md +8 -6
  3. package/dist/api/IFramework.d.ts +1 -1
  4. package/dist/api/IFramework.d.ts.map +1 -1
  5. package/dist/api/_export.d.ts +3 -0
  6. package/dist/api/_export.d.ts.map +1 -1
  7. package/dist/api/camera/CameraTransformUtilities.d.ts +65 -0
  8. package/dist/api/camera/CameraTransformUtilities.d.ts.map +1 -0
  9. package/dist/api/camera/ICamera.d.ts +36 -2
  10. package/dist/api/camera/ICamera.d.ts.map +1 -1
  11. package/dist/api/camera/OrbitCamera.d.ts +22 -14
  12. package/dist/api/camera/OrbitCamera.d.ts.map +1 -1
  13. package/dist/api/camera/OrthographicCamera.d.ts +33 -11
  14. package/dist/api/camera/OrthographicCamera.d.ts.map +1 -1
  15. package/dist/api/camera/PerspectiveCamera.d.ts +32 -18
  16. package/dist/api/camera/PerspectiveCamera.d.ts.map +1 -1
  17. package/dist/api/content/ContentManager.d.ts.map +1 -1
  18. package/dist/api/lights/AmbientLight.d.ts +7 -2
  19. package/dist/api/lights/AmbientLight.d.ts.map +1 -1
  20. package/dist/api/lights/DirectionalLight.d.ts +18 -4
  21. package/dist/api/lights/DirectionalLight.d.ts.map +1 -1
  22. package/dist/api/lights/ILight.d.ts +18 -0
  23. package/dist/api/lights/ILight.d.ts.map +1 -0
  24. package/dist/api/lights/PointLight.d.ts +17 -4
  25. package/dist/api/lights/PointLight.d.ts.map +1 -1
  26. package/dist/api/lights/_export.d.ts +1 -0
  27. package/dist/api/lights/_export.d.ts.map +1 -1
  28. package/dist/api/material/ForwardBlinnPhongMaterial.d.ts +2 -2
  29. package/dist/api/material/ForwardBlinnPhongMaterial.d.ts.map +1 -1
  30. package/dist/api/material/IMaterial.d.ts +7 -0
  31. package/dist/api/material/IMaterial.d.ts.map +1 -1
  32. package/dist/api/material/IMaterialFactory.d.ts +3 -2
  33. package/dist/api/material/IMaterialFactory.d.ts.map +1 -1
  34. package/dist/api/material/IUnlitMaterialDescriptor.d.ts +16 -0
  35. package/dist/api/material/IUnlitMaterialDescriptor.d.ts.map +1 -0
  36. package/dist/api/material/MaterialFactory.d.ts +3 -2
  37. package/dist/api/material/MaterialFactory.d.ts.map +1 -1
  38. package/dist/api/material/SpriteMaterial.d.ts +3 -0
  39. package/dist/api/material/SpriteMaterial.d.ts.map +1 -1
  40. package/dist/api/material/UnlitMaterial.d.ts +5 -12
  41. package/dist/api/material/UnlitMaterial.d.ts.map +1 -1
  42. package/dist/api/material/_export.d.ts +1 -1
  43. package/dist/api/material/_export.d.ts.map +1 -1
  44. package/dist/api/meshes/IRenderableMesh.d.ts +3 -14
  45. package/dist/api/meshes/IRenderableMesh.d.ts.map +1 -1
  46. package/dist/api/meshes/RenderableMesh.d.ts +5 -20
  47. package/dist/api/meshes/RenderableMesh.d.ts.map +1 -1
  48. package/dist/api/rendering/IGraphicsDevice.d.ts +2 -2
  49. package/dist/api/rendering/IGraphicsDevice.d.ts.map +1 -1
  50. package/dist/api/rendering/IRenderer.d.ts +6 -4
  51. package/dist/api/rendering/IRenderer.d.ts.map +1 -1
  52. package/dist/api/rendering/_export-rendering.d.ts +1 -0
  53. package/dist/api/rendering/_export-rendering.d.ts.map +1 -1
  54. package/dist/api/rendering/primitive/IPrimitiveStateDescriptor.d.ts +24 -0
  55. package/dist/api/rendering/primitive/IPrimitiveStateDescriptor.d.ts.map +1 -0
  56. package/dist/api/rendering/primitive/_export.d.ts +1 -1
  57. package/dist/api/rendering/primitive/_export.d.ts.map +1 -1
  58. package/dist/api/rendering/render-pipelines/IMainRenderTargetRenderPipeline.d.ts +5 -0
  59. package/dist/api/rendering/render-pipelines/IMainRenderTargetRenderPipeline.d.ts.map +1 -1
  60. package/dist/api/rendering/texture/ITextureDescriptor.d.ts +5 -1
  61. package/dist/api/rendering/texture/ITextureDescriptor.d.ts.map +1 -1
  62. package/dist/api/rendering/texture/ITextureFactory.d.ts +3 -1
  63. package/dist/api/rendering/texture/ITextureFactory.d.ts.map +1 -1
  64. package/dist/api/rendering/texture/TextureUtilities.d.ts +7 -0
  65. package/dist/api/rendering/texture/TextureUtilities.d.ts.map +1 -1
  66. package/dist/api/scene/ISceneObject.d.ts +12 -0
  67. package/dist/api/scene/ISceneObject.d.ts.map +1 -0
  68. package/dist/api/scene/Scene.d.ts +17 -6
  69. package/dist/api/scene/Scene.d.ts.map +1 -1
  70. package/dist/api/scene/node/Node.d.ts +26 -0
  71. package/dist/api/scene/node/Node.d.ts.map +1 -0
  72. package/dist/api/scene/node/TransformNode.d.ts +46 -0
  73. package/dist/api/scene/node/TransformNode.d.ts.map +1 -0
  74. package/dist/core/material/UnlitMaterialDescriptorUtilities.d.ts +17 -0
  75. package/dist/core/material/UnlitMaterialDescriptorUtilities.d.ts.map +1 -0
  76. package/dist/core/rendering/AGraphicsDevice.d.ts +2 -2
  77. package/dist/core/rendering/AGraphicsDevice.d.ts.map +1 -1
  78. package/dist/core/rendering/ARenderer.d.ts +5 -2
  79. package/dist/core/rendering/ARenderer.d.ts.map +1 -1
  80. package/dist/core/rendering/primitive/PrimitiveStateDescriptorUtilities.d.ts +15 -0
  81. package/dist/core/rendering/primitive/PrimitiveStateDescriptorUtilities.d.ts.map +1 -0
  82. package/dist/core/rendering/texture/TextureDescriptorUtilities.d.ts +2 -2
  83. package/dist/core/rendering/texture/TextureDescriptorUtilities.d.ts.map +1 -1
  84. package/dist/index.js +704 -272
  85. package/dist/webgl/WebGlGraphicsDevice.d.ts +2 -2
  86. package/dist/webgl/WebGlGraphicsDevice.d.ts.map +1 -1
  87. package/dist/webgl/lights/WebGlLightsBuffer.d.ts.map +1 -1
  88. package/dist/webgl/primitive/WebGlPrimitiveState.d.ts +3 -3
  89. package/dist/webgl/primitive/WebGlPrimitiveState.d.ts.map +1 -1
  90. package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts +8 -0
  91. package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts.map +1 -1
  92. package/dist/webgl/texture/WebGlTextureFactory.d.ts +1 -1
  93. package/dist/webgl/texture/WebGlTextureFactory.d.ts.map +1 -1
  94. package/dist/webgl/utilities/WebGlTextureUtilities.d.ts.map +1 -1
  95. package/dist/webgpu/WebGpuGraphicsDevice.d.ts +2 -2
  96. package/dist/webgpu/WebGpuGraphicsDevice.d.ts.map +1 -1
  97. package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts +2 -2
  98. package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts.map +1 -1
  99. package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts +5 -0
  100. package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts.map +1 -1
  101. package/dist/webgpu/texture/WebGpuTextureFactory.d.ts.map +1 -1
  102. package/package.json +2 -2
  103. package/src/Framework.ts +1 -1
  104. package/src/api/IFramework.ts +1 -1
  105. package/src/api/_export.ts +3 -0
  106. package/src/api/camera/CameraTransformUtilities.ts +182 -0
  107. package/src/api/camera/ICamera.ts +42 -2
  108. package/src/api/camera/OrbitCamera.ts +71 -38
  109. package/src/api/camera/OrthographicCamera.ts +71 -28
  110. package/src/api/camera/PerspectiveCamera.ts +69 -33
  111. package/src/api/content/ContentManager.ts +9 -5
  112. package/src/api/lights/AmbientLight.ts +8 -2
  113. package/src/api/lights/DirectionalLight.ts +30 -5
  114. package/src/api/lights/ILight.ts +22 -0
  115. package/src/api/lights/PointLight.ts +26 -5
  116. package/src/api/lights/_export.ts +1 -0
  117. package/src/api/material/ForwardBlinnPhongMaterial.ts +2 -2
  118. package/src/api/material/IMaterial.ts +8 -0
  119. package/src/api/material/IMaterialFactory.ts +3 -2
  120. package/src/api/material/IUnlitMaterialDescriptor.ts +18 -0
  121. package/src/api/material/MaterialFactory.ts +4 -3
  122. package/src/api/material/SpriteMaterial.ts +4 -0
  123. package/src/api/material/UnlitMaterial.ts +11 -18
  124. package/src/api/material/_export.ts +1 -1
  125. package/src/api/meshes/IRenderableMesh.ts +3 -18
  126. package/src/api/meshes/RenderableMesh.ts +15 -45
  127. package/src/api/rendering/IGraphicsDevice.ts +2 -2
  128. package/src/api/rendering/IRenderer.ts +6 -4
  129. package/src/api/rendering/_export-rendering.ts +2 -1
  130. package/src/api/rendering/primitive/IPrimitiveStateDescriptor.ts +27 -0
  131. package/src/api/rendering/primitive/_export.ts +1 -1
  132. package/src/api/rendering/render-pipelines/IMainRenderTargetRenderPipeline.ts +6 -0
  133. package/src/api/rendering/texture/ITextureDescriptor.ts +6 -1
  134. package/src/api/rendering/texture/ITextureFactory.ts +3 -1
  135. package/src/api/rendering/texture/TextureUtilities.ts +16 -0
  136. package/src/api/scene/ISceneObject.ts +13 -0
  137. package/src/api/scene/Scene.ts +52 -11
  138. package/src/api/scene/node/Node.ts +54 -0
  139. package/src/api/scene/node/TransformNode.ts +88 -0
  140. package/src/core/material/UnlitMaterialDescriptorUtilities.ts +21 -0
  141. package/src/core/rendering/AGraphicsDevice.ts +2 -2
  142. package/src/core/rendering/ARenderer.ts +23 -5
  143. package/src/core/rendering/primitive/PrimitiveStateDescriptorUtilities.ts +22 -0
  144. package/src/core/rendering/texture/TextureDescriptorUtilities.ts +3 -2
  145. package/src/webgl/WebGlGraphicsDevice.ts +2 -3
  146. package/src/webgl/lights/WebGlLightsBuffer.ts +21 -8
  147. package/src/webgl/primitive/WebGlPrimitiveState.ts +8 -6
  148. package/src/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.ts +14 -0
  149. package/src/webgl/texture/WebGlTextureFactory.ts +27 -16
  150. package/src/webgl/utilities/WebGlTextureUtilities.ts +10 -4
  151. package/src/webgpu/WebGpuGraphicsDevice.ts +3 -3
  152. package/src/webgpu/primitive/WebGpuPrimitiveState.ts +7 -5
  153. package/src/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.ts +6 -0
  154. package/src/webgpu/texture/WebGpuTextureFactory.ts +1 -1
  155. package/dist/api/material/ICameraMaterial.d.ts +0 -18
  156. package/dist/api/material/ICameraMaterial.d.ts.map +0 -1
  157. package/dist/api/rendering/primitive/PrimitiveStateDescriptor.d.ts +0 -24
  158. package/dist/api/rendering/primitive/PrimitiveStateDescriptor.d.ts.map +0 -1
  159. package/src/api/material/ICameraMaterial.ts +0 -22
  160. package/src/api/rendering/primitive/PrimitiveStateDescriptor.ts +0 -27
@@ -2,14 +2,14 @@ import {
2
2
  Color,
3
3
  type IFramework,
4
4
  type ITexture2D,
5
- type ITextureFactory,
6
5
  type ITextureDescriptor,
6
+ type ITextureFactory,
7
7
  TextureFormat,
8
8
  TextureUsage,
9
9
  TextureUtilities
10
10
  } from "../../api/index.ts"
11
11
  import {WebGlTexture2D} from "./WebGlTexture2D.ts";
12
- import {type IKtx2Texture, KtxDFTransfer, KtxTranscodeFlags, KtxTranscodeFormat, VkFormat} from "ris-ktx2";
12
+ import {type IKtx2Texture, KtxTranscodeFlags, KtxTranscodeFormat, VkFormat} from "ris-ktx2";
13
13
  import {vec2} from "gl-matrix";
14
14
  import {ColorSpace} from "../../api/rendering/enums.ts";
15
15
  import {resolveTextureDescriptor} from "../../core/rendering/texture/TextureDescriptorUtilities.ts";
@@ -34,8 +34,10 @@ export class WebGlTextureFactory implements ITextureFactory {
34
34
  let textureFormat = desc.textureFormat;
35
35
  const gpuFeatures = this._framework.graphicsDevice.features;
36
36
 
37
- const srgb = ktxTexture.oetf == KtxDFTransfer.SRGB;
38
- const preferSrgb = this._framework.renderer.preferredColorSpace == ColorSpace.SRGB;
37
+ // Textures always adapt to the framework's preferred color space, unless user defined it's preferred.
38
+ const preferSrgb = (descriptor?.preferredColorSpace ?? this._framework.renderer.colorSpace) == ColorSpace.SRGB;
39
+ // An explicit texture format overrides both color space preferences.
40
+ const userSpecifiedTextureFormat = desc.textureFormat != TextureFormat.UNDEFINED;
39
41
 
40
42
  if (ktxTexture.needsTranscoding && vkFormat == VkFormat.UNDEFINED)
41
43
  {
@@ -46,22 +48,22 @@ export class WebGlTextureFactory implements ITextureFactory {
46
48
  if(gpuFeatures.supportsTextureCompressionBC)
47
49
  {
48
50
  transcodeFormat = KtxTranscodeFormat.BC7_RGBA;
49
- textureFormat = srgb ? TextureFormat.BC7_RGBA_SRGB : TextureFormat.BC7_RGBA_UNORM;
51
+ textureFormat = preferSrgb ? TextureFormat.BC7_RGBA_SRGB : TextureFormat.BC7_RGBA_UNORM;
50
52
  }
51
53
  else if(gpuFeatures.supportsTextureCompressionASTC)
52
54
  {
53
55
  transcodeFormat = KtxTranscodeFormat.ASTC_4X4_RGBA;
54
- textureFormat = srgb ? TextureFormat.ASTC_4X4_RGBA_SRGB : TextureFormat.ASTC_4X4_RGBA_UNORM;
56
+ textureFormat = preferSrgb ? TextureFormat.ASTC_4X4_RGBA_SRGB : TextureFormat.ASTC_4X4_RGBA_UNORM;
55
57
  }
56
58
  else if(gpuFeatures.supportsTextureCompressionS3TC)
57
59
  {
58
60
  transcodeFormat = KtxTranscodeFormat.BC3_RGBA;
59
- textureFormat = srgb ? TextureFormat.BC3_RGBA_SRGB : TextureFormat.BC3_RGBA_UNORM;
61
+ textureFormat = preferSrgb ? TextureFormat.BC3_RGBA_SRGB : TextureFormat.BC3_RGBA_UNORM;
60
62
  }
61
63
  else if(gpuFeatures.supportsTextureCompressionETC2)
62
64
  {
63
65
  transcodeFormat = KtxTranscodeFormat.ETC2_RGBA;
64
- textureFormat = srgb ? TextureFormat.ETC2_RGBA8_SRGB : TextureFormat.ETC2_RGBA8_UNORM;
66
+ textureFormat = preferSrgb ? TextureFormat.ETC2_RGBA8_SRGB : TextureFormat.ETC2_RGBA8_UNORM;
65
67
  }
66
68
  else if(gpuFeatures.supportsTextureCompressionPVRTC)
67
69
  {
@@ -72,7 +74,7 @@ export class WebGlTextureFactory implements ITextureFactory {
72
74
  else
73
75
  {
74
76
  transcodeFormat = KtxTranscodeFormat.RGBA32;
75
- textureFormat = srgb ? TextureFormat.RGBA_8_UNORM_SRGB : TextureFormat.RGBA_8_UNORM;
77
+ textureFormat = preferSrgb ? TextureFormat.RGBA_8_UNORM_SRGB : TextureFormat.RGBA_8_UNORM;
76
78
  }
77
79
  }
78
80
  else
@@ -83,13 +85,18 @@ export class WebGlTextureFactory implements ITextureFactory {
83
85
  ktxTexture.transcodeBasis(transcodeFormat, KtxTranscodeFlags.HIGH_QUALITY);
84
86
  }
85
87
  else {
86
- // No transcoding path, the vkFormat already says linear or sRGB.
88
+ // No transcoding path: map the vkFormat, then switch to the preferred color space variant.
87
89
  textureFormat = TextureUtilities.convertVkFormatToTextureFormat(vkFormat);
88
- if(!srgb && preferSrgb && !TextureUtilities.isSrgbFormat(textureFormat)){
89
- textureFormat = TextureUtilities.convertToSrgbVariant(textureFormat);
90
- }
91
- else if(srgb && !preferSrgb && TextureUtilities.isSrgbFormat(textureFormat)){
92
- textureFormat = TextureUtilities.convertToLinearVariant(textureFormat);
90
+
91
+ if (userSpecifiedTextureFormat) {
92
+ // The data can only be reinterpreted as the file's format or its sRGB/linear variant.
93
+ textureFormat = TextureUtilities.resolveExplicitFormat(textureFormat, desc.textureFormat);
94
+ } else {
95
+ if (preferSrgb && !TextureUtilities.isSrgbFormat(textureFormat)) {
96
+ textureFormat = TextureUtilities.convertToSrgbVariant(textureFormat);
97
+ } else if (!preferSrgb && TextureUtilities.isSrgbFormat(textureFormat)) {
98
+ textureFormat = TextureUtilities.convertToLinearVariant(textureFormat);
99
+ }
93
100
  }
94
101
  }
95
102
 
@@ -125,8 +132,12 @@ export class WebGlTextureFactory implements ITextureFactory {
125
132
  channels: number = 4,
126
133
  label: string | null | undefined = null,
127
134
  textureUsage = TextureUsage.COPY_DST | TextureUsage.TEXTURE_BINDING,
128
- textureFormat= TextureFormat.RGBA_8_UNORM,
135
+ textureFormat = TextureFormat.UNDEFINED,
129
136
  useMipMaps = false): ITexture2D {
137
+ if (textureFormat == TextureFormat.UNDEFINED) {
138
+ textureFormat = this._framework.renderer.preferredTextureFormat;
139
+ }
140
+
130
141
 
131
142
  if (!data) {
132
143
  throw new Error("Data must not be null.");
@@ -1,5 +1,5 @@
1
1
  import {WebGlConverter} from "./WebGlConverter.ts";
2
- import {AlignUtilities, TextureFormat} from "../../api/index.ts";
2
+ import { TextureFormat} from "../../api/index.ts";
3
3
  import {vec2} from "gl-matrix";
4
4
  import {WebGlUtilities} from "./WebGlUtilities.ts";
5
5
 
@@ -127,6 +127,9 @@ export class WebGlTextureUtilities {
127
127
  gl.texStorage2D(gl.TEXTURE_2D, mipLevels, internalFormat, baseWidth, baseHeight);
128
128
  }
129
129
 
130
+ // Texture data might not be aligned to 4. So disable it.
131
+ gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
132
+
130
133
  if (data && data.length > 0) {
131
134
 
132
135
  let width = baseWidth;
@@ -140,9 +143,9 @@ export class WebGlTextureUtilities {
140
143
  if (useTexStorage) {
141
144
  gl.compressedTexSubImage2D(gl.TEXTURE_2D, i, 0, 0, width, height, internalFormat, mipLevelData, 0);
142
145
  } else {
143
- const alignedWidth = AlignUtilities.align(width, blockSize[0]);
144
- const alignedHeight = AlignUtilities.align(height, blockSize[1]);
145
- gl.compressedTexImage2D(gl.TEXTURE_2D, i, internalFormat, alignedWidth, alignedHeight, 0, mipLevelData, 0);
146
+ // const alignedWidth = AlignUtilities.align(width, blockSize[0]);
147
+ // const alignedHeight = AlignUtilities.align(height, blockSize[1]);
148
+ gl.compressedTexImage2D(gl.TEXTURE_2D, i, internalFormat, width, height, 0, mipLevelData, 0);
146
149
  }
147
150
  } else {
148
151
  throw new Error("unsupported data type");
@@ -153,6 +156,9 @@ export class WebGlTextureUtilities {
153
156
  }
154
157
  }
155
158
 
159
+ // Restore to default.
160
+ gl.pixelStorei(gl.UNPACK_ALIGNMENT, 4);
161
+
156
162
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
157
163
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
158
164
 
@@ -9,7 +9,7 @@ import {
9
9
  type ISampler,
10
10
  type ISwapChain,
11
11
  type IWindowManager,
12
- PrimitiveStateDescriptor,
12
+ type IPrimitiveStateDescriptor,
13
13
  RenderPassDescriptor,
14
14
  SwapChainDescriptor,
15
15
  } from "../api/index.ts";
@@ -158,8 +158,8 @@ export class WebGpuGraphicsDevice extends AGraphicsDevice {
158
158
  }
159
159
 
160
160
  /** @inheritDoc */
161
- public createPrimitiveState(descriptor?: PrimitiveStateDescriptor): IPrimitiveState {
162
- return new WebGpuPrimitiveState(descriptor ?? new PrimitiveStateDescriptor());
161
+ public createPrimitiveState(descriptor?: IPrimitiveStateDescriptor): IPrimitiveState {
162
+ return new WebGpuPrimitiveState(descriptor);
163
163
  }
164
164
 
165
165
  /** @inheritDoc */
@@ -2,10 +2,11 @@ import {
2
2
  type CullMode,
3
3
  type FrontFace,
4
4
  type IPrimitiveState,
5
- type PrimitiveStateDescriptor,
5
+ type IPrimitiveStateDescriptor,
6
6
  type PrimitiveTopology,
7
7
  } from "../../api/index.ts";
8
8
  import type {GpuCullMode, GpuFrontFace, GpuPrimitiveTopology} from "../WebGpuTypes.ts";
9
+ import {resolvePrimitiveStateDescriptor} from "../../core/rendering/primitive/PrimitiveStateDescriptorUtilities.ts";
9
10
  import {WebGpuConverter} from "../utilities/WebGpuConverter.ts";
10
11
 
11
12
  /**
@@ -18,10 +19,11 @@ export class WebGpuPrimitiveState implements IPrimitiveState {
18
19
  * The constructor.
19
20
  * @param descriptor The primitive state descriptor.
20
21
  */
21
- public constructor(descriptor: PrimitiveStateDescriptor) {
22
- this.topology = descriptor.topology;
23
- this.cullFace = descriptor.cullFace;
24
- this.frontFace = descriptor.frontFace;
22
+ public constructor(descriptor?: IPrimitiveStateDescriptor) {
23
+ const resolved = resolvePrimitiveStateDescriptor(descriptor);
24
+ this.topology = resolved.topology;
25
+ this.cullFace = resolved.cullFace;
26
+ this.frontFace = resolved.frontFace;
25
27
  this.gpuTopology = WebGpuConverter.convertTopology(this.topology);
26
28
  this.gpuCullMode = WebGpuConverter.convertCullMode(this.cullFace);
27
29
  this.gpuFrontFace = WebGpuConverter.convertFrontFace(this.frontFace);
@@ -1,3 +1,4 @@
1
+ import {ColorSpace} from "../../api/rendering/enums.ts";
1
2
  import {vec2} from "gl-matrix";
2
3
  import {
3
4
  BufferUsage,
@@ -81,6 +82,11 @@ export class WebGpuMainRenderTargetRenderPipeline extends AWebGpuRenderPipeline
81
82
  this._graphicsDevice.swapChain?.textureFormat ?? this._framework.renderer.preferredTextureFormat);
82
83
  }
83
84
 
85
+ /**
86
+ * The color space. Stored only; it has no effect on WebGPU yet.
87
+ */
88
+ public colorSpace: ColorSpace = ColorSpace.LINEAR;
89
+
84
90
  private _getBindGroup(): GpuBindGroup {
85
91
  if (!this._bindGroup) {
86
92
  this._bindGroup = this._graphicsDevice.device.createBindGroup({
@@ -36,7 +36,7 @@ export class WebGpuTextureFactory implements ITextureFactory {
36
36
  channels: number = 4,
37
37
  label: string | null | undefined = null,
38
38
  textureUsage = TextureUsage.COPY_DST | TextureUsage.TEXTURE_BINDING,
39
- textureFormat = TextureFormat.RGBA_8_UNORM,
39
+ textureFormat = TextureFormat.UNDEFINED,
40
40
  useMipMaps = false): ITexture2D {
41
41
 
42
42
  if (!data) {
@@ -1,18 +0,0 @@
1
- import type { IMaterial } from "./IMaterial.js";
2
- import type { ICamera } from "../camera/ICamera.js";
3
- /**
4
- * A material that renders with a camera (unlit, Blinn-Phong, inspect mips).
5
- * A `Scene` assigns its camera to these materials in `scene.update()`.
6
- * @public
7
- */
8
- export interface ICameraMaterial extends IMaterial {
9
- /** The camera. Setting it binds the camera's buffers. */
10
- camera?: ICamera;
11
- }
12
- /**
13
- * Whether a material is an {@link ICameraMaterial}.
14
- * @param material The material.
15
- * @public
16
- */
17
- export declare function isCameraMaterial(material: IMaterial | undefined): material is ICameraMaterial;
18
- //# sourceMappingURL=ICameraMaterial.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ICameraMaterial.d.ts","sourceRoot":"","sources":["../../../src/api/material/ICameraMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAE9C,yDAAyD;IACzD,MAAM,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,IAAI,eAAe,CAE7F"}
@@ -1,24 +0,0 @@
1
- import { PrimitiveTopology } from "./PrimitiveTopology.js";
2
- import { CullMode } from "./CullMode.js";
3
- import { FrontFace } from "./FrontFace.js";
4
- /**
5
- * Describes the state of a primitive.
6
- */
7
- export declare class PrimitiveStateDescriptor {
8
- /**
9
- * The topology of the primitive.
10
- * By default, it is set to TRIANGLE_LIST.
11
- */
12
- topology: PrimitiveTopology;
13
- /**
14
- * The culling mode.
15
- * By default, it is set to BACK.
16
- */
17
- cullFace: CullMode;
18
- /**
19
- * The front face.
20
- * By default, it is set to CCW(counter clock-wise).
21
- */
22
- frontFace: FrontFace;
23
- }
24
- //# sourceMappingURL=PrimitiveStateDescriptor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrimitiveStateDescriptor.d.ts","sourceRoot":"","sources":["../../../../src/api/rendering/primitive/PrimitiveStateDescriptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC;;GAEG;AACH,qBAAa,wBAAwB;IAEjC;;;OAGG;IACI,QAAQ,EAAE,iBAAiB,CAAmC;IAErE;;;OAGG;IACI,QAAQ,EAAE,QAAQ,CAAiB;IAE1C;;;OAGG;IACI,SAAS,EAAE,SAAS,CAAiB;CAC/C"}
@@ -1,22 +0,0 @@
1
- import type { IMaterial } from "./IMaterial.ts";
2
- import type { ICamera } from "../camera/ICamera.ts";
3
-
4
- /**
5
- * A material that renders with a camera (unlit, Blinn-Phong, inspect mips).
6
- * A `Scene` assigns its camera to these materials in `scene.update()`.
7
- * @public
8
- */
9
- export interface ICameraMaterial extends IMaterial {
10
-
11
- /** The camera. Setting it binds the camera's buffers. */
12
- camera?: ICamera;
13
- }
14
-
15
- /**
16
- * Whether a material is an {@link ICameraMaterial}.
17
- * @param material The material.
18
- * @public
19
- */
20
- export function isCameraMaterial(material: IMaterial | undefined): material is ICameraMaterial {
21
- return !!material && "camera" in material;
22
- }
@@ -1,27 +0,0 @@
1
- import {PrimitiveTopology} from "./PrimitiveTopology.ts";
2
- import {CullMode} from "./CullMode.ts";
3
- import {FrontFace} from "./FrontFace.ts";
4
-
5
- /**
6
- * Describes the state of a primitive.
7
- */
8
- export class PrimitiveStateDescriptor {
9
-
10
- /**
11
- * The topology of the primitive.
12
- * By default, it is set to TRIANGLE_LIST.
13
- */
14
- public topology: PrimitiveTopology = PrimitiveTopology.TRIANGLE_LIST;
15
-
16
- /**
17
- * The culling mode.
18
- * By default, it is set to BACK.
19
- */
20
- public cullFace: CullMode = CullMode.BACK;
21
-
22
- /**
23
- * The front face.
24
- * By default, it is set to CCW(counter clock-wise).
25
- */
26
- public frontFace: FrontFace = FrontFace.CCW;
27
- }