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,7 +2,7 @@ import { AGraphicsDevice, type IGraphicsDeviceDescriptor } from "../core/renderi
2
2
  import { type BlendStateDescriptor } from "../core/rendering/blending/blend-state-descriptor";
3
3
  import { WebGLGraphicsDeviceFeatures } from "./WebGLGraphicsDeviceFeatures.js";
4
4
  import type { SamplerDescriptor } from "../core/rendering/sampler/sampler-descriptor.js";
5
- import { type IBlendState, type IGPUInfo, type IPrimitiveState, type IRenderPass, type ISampler, type ISwapChain, type IWindowManager, PrimitiveStateDescriptor, RenderPassDescriptor, SwapChainDescriptor } from "../api/index.js";
5
+ import { type IBlendState, type IGPUInfo, type IPrimitiveState, type IRenderPass, type ISampler, type ISwapChain, type IWindowManager, type IPrimitiveStateDescriptor, RenderPassDescriptor, SwapChainDescriptor } from "../api/index.js";
6
6
  /**
7
7
  * Creates WebGL2 enabled graphics device.
8
8
  * @internal
@@ -42,6 +42,6 @@ export declare class WebGlGraphicsDevice extends AGraphicsDevice {
42
42
  /** @inheritdoc */
43
43
  createBlendState(descriptor: BlendStateDescriptor): IBlendState;
44
44
  /** @inheritdoc */
45
- createPrimitiveState(descriptor?: PrimitiveStateDescriptor): IPrimitiveState;
45
+ createPrimitiveState(descriptor?: IPrimitiveStateDescriptor): IPrimitiveState;
46
46
  }
47
47
  //# sourceMappingURL=WebGlGraphicsDevice.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebGlGraphicsDevice.d.ts","sourceRoot":"","sources":["../../src/webgl/WebGlGraphicsDev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MAAM,IAAI,IAAI;IAcrB,kBAAkB;IACX,OAAO,IAAI,IAAI;IAQtB,OAAO,CAAC,kBAAkB;IAK1B,OAAO,CAAC,QAAQ;IAUhB,2FAA2F;IAC3F,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,UAAU;CAqDrB"}
@@ -1,4 +1,4 @@
1
- import { CullMode, type FrontFace, type IPrimitiveState, type PrimitiveStateDescriptor, type PrimitiveTopology } from "../../api/index.js";
1
+ import { CullMode, type FrontFace, type IPrimitiveState, type IPrimitiveStateDescriptor, type PrimitiveTopology } from "../../api/index.js";
2
2
  /**
3
3
  * The WebGL implementation of a primitive state.
4
4
  */
@@ -10,9 +10,9 @@ export declare class WebGlPrimitiveState implements IPrimitiveState {
10
10
  /**
11
11
  * The constructor.
12
12
  * @param _gl The WebGL2 Rendering Context.
13
- * @param descriptor The descriptor of the primitive state.
13
+ * @param descriptor The descriptor of the primitive state; missing fields use the defaults.
14
14
  */
15
- constructor(_gl: WebGL2RenderingContext, descriptor: PrimitiveStateDescriptor);
15
+ constructor(_gl: WebGL2RenderingContext, descriptor?: IPrimitiveStateDescriptor);
16
16
  /** @inheritdoc */
17
17
  readonly topology: PrimitiveTopology;
18
18
  /** @inheritdoc */
@@ -1 +1 @@
1
- {"version":3,"file":"WebGlPrimitiveState.d.ts","sourceRoot":"","sources":["../../../src/webgl/primitive/WebGlPrimitiveState.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACzB,MAAM,oBAAoB,CAAC;AAG5B;;EAEE;AACF,qBAAa,mBAAoB,YAAW,eAAe;IACvD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAU;IAC1C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IAEtC;;;;OAIG;gBACgB,GAAG,EAAE,sBAAsB,EAAE,UAAU,EAAE,wBAAwB;IAYpF,kBAAkB;IAClB,SAAgB,QAAQ,EAAE,iBAAiB,CAAC;IAE5C,kBAAkB;IAClB,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IAEnC,kBAAkB;IAClB,SAAgB,SAAS,EAAE,SAAS,CAAC;IAErC;;MAEE;IACF,IAAW,eAAe,WAEzB;IAED,kBAAkB;IACX,KAAK,CAAC,EAAE,EAAE,sBAAsB;CAW1C"}
1
+ {"version":3,"file":"WebGlPrimitiveState.d.ts","sourceRoot":"","sources":["../../../src/webgl/primitive/WebGlPrimitiveState.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,QAAQ,EACR,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACzB,MAAM,oBAAoB,CAAC;AAI5B;;EAEE;AACF,qBAAa,mBAAoB,YAAW,eAAe;IACvD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAU;IAC1C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IAEtC;;;;OAIG;gBACgB,GAAG,EAAE,sBAAsB,EAAE,UAAU,CAAC,EAAE,yBAAyB;IAatF,kBAAkB;IAClB,SAAgB,QAAQ,EAAE,iBAAiB,CAAC;IAE5C,kBAAkB;IAClB,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IAEnC,kBAAkB;IAClB,SAAgB,SAAS,EAAE,SAAS,CAAC;IAErC;;MAEE;IACF,IAAW,eAAe,WAEzB;IAED,kBAAkB;IACX,KAAK,CAAC,EAAE,EAAE,sBAAsB;CAW1C"}
@@ -1,6 +1,7 @@
1
1
  import { GeometryFormat } from "../../api/geometry/GeometryFormat.js";
2
2
  import { AWebGlRenderPipeline } from "./AWebGlRenderPipeline.js";
3
3
  import { type IFramework, type IMainRenderTargetRenderPipeline, type ITexture2D } from "../../api/index.js";
4
+ import { ColorSpace } from "../../api/rendering/enums.js";
4
5
  /**
5
6
  * The WebGL implementation of the main render target render pipeline.
6
7
  */
@@ -9,6 +10,7 @@ export declare class WebGlMainRenderTargetRenderPipeline extends AWebGlRenderPip
9
10
  private _indexBuffer;
10
11
  private _mainRenderTarget;
11
12
  private _colorConversionUniformLocation;
13
+ /** The shader's `u_colorConversion`: 1 encodes linear to sRGB on output, 0 passes through. */
12
14
  private _colorSpaceValue;
13
15
  /**
14
16
  * The constructor.
@@ -16,6 +18,12 @@ export declare class WebGlMainRenderTargetRenderPipeline extends AWebGlRenderPip
16
18
  * @param mainRenderTarget The main render target texture. This is the texture that will be rendered to by this render pipeline. It should be the same texture as the one used in the swap chain's render pass descriptor for the main render target.
17
19
  */
18
20
  constructor(framework: IFramework, mainRenderTarget: ITexture2D);
21
+ /**
22
+ * The color space. With SRGB the main render target is sRGB (sampled back as linear) and the shader
23
+ * encodes to sRGB for the screen; with LINEAR the values are passed through. Takes effect on the next frame.
24
+ */
25
+ get colorSpace(): ColorSpace;
26
+ set colorSpace(value: ColorSpace);
19
27
  /** @inheritDoc */
20
28
  readonly geometryFormat = GeometryFormat.POS3_COLOR4_TEXTURECOORDS2;
21
29
  /** @inheritdoc */
@@ -1 +1 @@
1
- {"version":3,"file":"WebGlMainRenderTargetRenderPipeline.d.ts","sourceRoot":"","sources":["../../../src/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAC,MAAM,sCAAsC,CAAC;AAKpE,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAEH,KAAK,UAAU,EACf,KAAK,+BAA+B,EACpC,KAAK,UAAU,EAElB,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,qBAAa,mCAAoC,SAAQ,oBAAqB,YAAW,+BAA+B;IAEpH,OAAO,CAAC,aAAa,CAA4B;IACjD,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,iBAAiB,CAAyB;IAElD,OAAO,CAAC,+BAA+B,CAA+B;IACtE,OAAO,CAAC,gBAAgB,CAAK;IAE7B;;;;OAIG;gBACgB,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,UAAU;IAStE,kBAAkB;IAClB,SAAgB,cAAc,6CAA6C;IAE3E,kBAAkB;IAClB,SAAS,CAAC,eAAe,IAAI,WAAW,EAAE;IAI1C,kBAAkB;IAClB,IAAW,gBAAgB,IAAI,UAAU,CAKxC;IAED,kBAAkB;IAClB,IAAW,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAE5C;IAED,kBAAkB;IACX,UAAU,IAAI,IAAI;IAUzB,OAAO,CAAC,gBAAgB;IAmBxB,kBAAkB;IACX,MAAM,IAAI,IAAI;IAqBrB,kBAAkB;IACF,OAAO,IAAI,IAAI;CAMlC"}
1
+ {"version":3,"file":"WebGlMainRenderTargetRenderPipeline.d.ts","sourceRoot":"","sources":["../../../src/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAC,MAAM,sCAAsC,CAAC;AAKpE,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAEH,KAAK,UAAU,EACf,KAAK,+BAA+B,EACpC,KAAK,UAAU,EAElB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAC;AAExD;;GAEG;AACH,qBAAa,mCAAoC,SAAQ,oBAAqB,YAAW,+BAA+B;IAEpH,OAAO,CAAC,aAAa,CAA4B;IACjD,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,iBAAiB,CAAyB;IAElD,OAAO,CAAC,+BAA+B,CAA+B;IACtE,8FAA8F;IAC9F,OAAO,CAAC,gBAAgB,CAAK;IAE7B;;;;OAIG;gBACgB,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,UAAU;IAStE;;;OAGG;IACH,IAAW,UAAU,IAAI,UAAU,CAElC;IAED,IAAW,UAAU,CAAC,KAAK,EAAE,UAAU,EAEtC;IAED,kBAAkB;IAClB,SAAgB,cAAc,6CAA6C;IAE3E,kBAAkB;IAClB,SAAS,CAAC,eAAe,IAAI,WAAW,EAAE;IAI1C,kBAAkB;IAClB,IAAW,gBAAgB,IAAI,UAAU,CAKxC;IAED,kBAAkB;IAClB,IAAW,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAE5C;IAED,kBAAkB;IACX,UAAU,IAAI,IAAI;IAUzB,OAAO,CAAC,gBAAgB;IAmBxB,kBAAkB;IACX,MAAM,IAAI,IAAI;IAqBrB,kBAAkB;IACF,OAAO,IAAI,IAAI;CAMlC"}
@@ -1,4 +1,4 @@
1
- import { Color, type IFramework, type ITexture2D, type ITextureFactory, type ITextureDescriptor, TextureFormat } from "../../api/index.js";
1
+ import { Color, type IFramework, type ITexture2D, type ITextureDescriptor, type ITextureFactory, TextureFormat } from "../../api/index.js";
2
2
  import { type IKtx2Texture } from "ris-ktx2";
3
3
  export declare class WebGlTextureFactory implements ITextureFactory {
4
4
  private readonly _framework;
@@ -1 +1 @@
1
- {"version":3,"file":"WebGlTextureFactory.d.ts","sourceRoot":"","sources":["../../../src/webgl/texture/WebGlTextureFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,aAAa,EAGhB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAC,KAAK,YAAY,EAAiE,MAAM,UAAU,CAAC;AAK3G,qBAAa,mBAAoB,YAAW,eAAe;IAM3C,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJvC;;;OAGG;gBAC0B,UAAU,EAAE,UAAU;IAGnD,kBAAkB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K,GAAE,MAAM,GAAG,IAAI,GAAG,SAAgB,EACvC,YAAY,SAAuD,EACnE,aAAa,gBAA0B,EACvC,UAAU,UAAQ,GAAG,UAAU;IAqCnC,kBAAkB;IACX,WAAW,CACd,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAC7B,KAAK,GAAE,KAAK,GAAG,IAAW,EAC1B,YAAY,SAAuD,EACnE,aAAa,gBAA0B,EACvC,KAAK,GAAE,MAAM,GAAG,IAAW,EAC3B,SAAS,UAAQ,GAAG,UAAU;CA2CrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"WebGlTextureUtilities.d.ts","sourceRoot":"","sources":["../../../src/webgl/utilities/WebGlTextureUtilities.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,aAAa,EAAC,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAG/B;;GAEG;AACH,qBAAa,qBAAqB;IAE9B;;;;;;;;;;;OAWG;IACI,eAAe,CAClB,EAAE,EAAE,sBAAsB,EAC1B,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAC7B,IAAI,GAAE,UAAU,EAAE,GAAG,gBAAgB,EAAE,GAAG,IAAW,EACrD,aAAa,gBAA6B,EAC1C,UAAU,UAAQ,EAClB,UAAU,SAAM,EAChB,KAAK,GAAE,MAAM,GAAG,IAAW,GAC5B,YAAY;IA2Df;;;;;;;;;;OAUG;IACI,yBAAyB,CAC5B,EAAE,EAAE,sBAAsB,EAC1B,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAChC,IAAI,GAAE,UAAU,EAAE,GAAG,IAAW,EAChC,KAAK,GAAE,MAAM,GAAG,IAAW,EAC3B,aAAa,gBAA6B,EAC1C,UAAU,SAAM,GACjB,YAAY;CAkElB"}
1
+ {"version":3,"file":"WebGlTextureUtilities.d.ts","sourceRoot":"","sources":["../../../src/webgl/utilities/WebGlTextureUtilities.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAG/B;;GAEG;AACH,qBAAa,qBAAqB;IAE9B;;;;;;;;;;;OAWG;IACI,eAAe,CAClB,EAAE,EAAE,sBAAsB,EAC1B,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAC7B,IAAI,GAAE,UAAU,EAAE,GAAG,gBAAgB,EAAE,GAAG,IAAW,EACrD,aAAa,gBAA6B,EAC1C,UAAU,UAAQ,EAClB,UAAU,SAAM,EAChB,KAAK,GAAE,MAAM,GAAG,IAAW,GAC5B,YAAY;IA2Df;;;;;;;;;;OAUG;IACI,yBAAyB,CAC5B,EAAE,EAAE,sBAAsB,EAC1B,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAChC,IAAI,GAAE,UAAU,EAAE,GAAG,IAAW,EAChC,KAAK,GAAE,MAAM,GAAG,IAAW,EAC3B,aAAa,gBAA6B,EAC1C,UAAU,SAAM,GACjB,YAAY;CAwElB"}
@@ -1,7 +1,7 @@
1
1
  import { AGraphicsDevice, type IGraphicsDeviceDescriptor } from "../core/rendering/AGraphicsDevice.js";
2
2
  import type { BlendStateDescriptor } from "../core/rendering/blending/blend-state-descriptor.js";
3
3
  import type { SamplerDescriptor } from "../core/rendering/sampler/sampler-descriptor.js";
4
- import { type IBlendState, type IGPUInfo, type IPrimitiveState, type IRenderPass, type ISampler, type ISwapChain, type IWindowManager, PrimitiveStateDescriptor, RenderPassDescriptor, SwapChainDescriptor } from "../api/index.js";
4
+ import { type IBlendState, type IGPUInfo, type IPrimitiveState, type IRenderPass, type ISampler, type ISwapChain, type IWindowManager, type IPrimitiveStateDescriptor, RenderPassDescriptor, SwapChainDescriptor } from "../api/index.js";
5
5
  import { type GpuAdapter, type GpuDevice, type GpuRenderPassEncoder } from "./WebGpuTypes.js";
6
6
  import { WebGpuGraphicsDeviceFeatures } from "./WebGpuGraphicsDeviceFeatures.js";
7
7
  import { WebGpuSwapChain } from "./swap-chain/WebGpuSwapChain.js";
@@ -65,7 +65,7 @@ export declare class WebGpuGraphicsDevice extends AGraphicsDevice {
65
65
  /** @inheritDoc */
66
66
  createBlendState(descriptor: BlendStateDescriptor): IBlendState;
67
67
  /** @inheritDoc */
68
- createPrimitiveState(descriptor?: PrimitiveStateDescriptor): IPrimitiveState;
68
+ createPrimitiveState(descriptor?: IPrimitiveStateDescriptor): IPrimitiveState;
69
69
  /** @inheritDoc */
70
70
  setupDebugCallback(): void;
71
71
  /** @inheritDoc */
@@ -1 +1 @@
1
- {"version":3,"file":"WebGpuGraphicsDevice.d.ts","sourceRoot":"","sources":["../../src/webgpu/WebGpuGraphicsDevice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,KAAK,yBAAyB,EAAC,MAAM,sCAAsC,CAAC;AACrG,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,sDAAsD,CAAC;AAC/F,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,iDAAiD,CAAC;AACvF,OAAO,EACH,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,EACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAkB,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAE7G,OAAO,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AAE/E,OAAO,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAMhE;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,eAAe;IAErD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;IACtC,OAAO,CAAC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State, type PrimitiveStateDescriptor, type PrimitiveTopology } from "../../api/index.js";
1
+ import { type CullMode, type FrontFace, type IPrimitiveState, type IPrimitiveStateDescriptor, type PrimitiveTopology } from "../../api/index.js";
2
2
  import type { GpuCullMode, GpuFrontFace, GpuPrimitiveTopology } from "../WebGpuTypes.js";
3
3
  /**
4
4
  * The WebGPU primitive state. WebGPU bakes it into the render pipeline, so this only holds the converted values.
@@ -9,7 +9,7 @@ export declare class WebGpuPrimitiveState implements IPrimitiveState {
9
9
  * The constructor.
10
10
  * @param descriptor The primitive state descriptor.
11
11
  */
12
- constructor(descriptor: PrimitiveStateDescriptor);
12
+ constructor(descriptor?: IPrimitiveStateDescriptor);
13
13
  /** @inheritDoc */
14
14
  readonly topology: PrimitiveTopology;
15
15
  /** @inheritDoc */
@@ -1 +1 @@
1
- {"version":3,"file":"WebGpuPrimitiveState.d.ts","sourceRoot":"","sources":["../../../src/webgpu/primitive/WebGpuPrimitiveState.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,WAAW,EAAE,YAAY,EAAE,oBAAoB,EAAC,MAAM,mBAAmB,CAAC;AAGvF;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,eAAe;IAExD;;;OAGG;gBACgB,UAAU,EAAE,wBAAwB;IASvD,kBAAkB;IAClB,SAAgB,QAAQ,EAAE,iBAAiB,CAAC;IAE5C,kBAAkB;IAClB,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IAEnC,kBAAkB;IAClB,SAAgB,SAAS,EAAE,SAAS,CAAC;IAErC,2BAA2B;IAC3B,SAAgB,WAAW,EAAE,oBAAoB,CAAC;IAElD,4BAA4B;IAC5B,SAAgB,WAAW,EAAE,WAAW,CAAC;IAEzC,6BAA6B;IAC7B,SAAgB,YAAY,EAAE,YAAY,CAAC;IAE3C,qDAAqD;IACrD,IAAW,iBAAiB,IAAI;QAAE,QAAQ,EAAE,oBAAoB,CAAC;QAAC,QAAQ,EAAE,WAAW,CAAC;QAAC,SAAS,EAAE,YAAY,CAAA;KAAE,CAEjH;CACJ"}
1
+ {"version":3,"file":"WebGpuPrimitiveState.d.ts","sourceRoot":"","sources":["../../../src/webgpu/primitive/WebGpuPrimitiveState.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,WAAW,EAAE,YAAY,EAAE,oBAAoB,EAAC,MAAM,mBAAmB,CAAC;AAIvF;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,eAAe;IAExD;;;OAGG;gBACgB,UAAU,CAAC,EAAE,yBAAyB;IAUzD,kBAAkB;IAClB,SAAgB,QAAQ,EAAE,iBAAiB,CAAC;IAE5C,kBAAkB;IAClB,SAAgB,QAAQ,EAAE,QAAQ,CAAC;IAEnC,kBAAkB;IAClB,SAAgB,SAAS,EAAE,SAAS,CAAC;IAErC,2BAA2B;IAC3B,SAAgB,WAAW,EAAE,oBAAoB,CAAC;IAElD,4BAA4B;IAC5B,SAAgB,WAAW,EAAE,WAAW,CAAC;IAEzC,6BAA6B;IAC7B,SAAgB,YAAY,EAAE,YAAY,CAAC;IAE3C,qDAAqD;IACrD,IAAW,iBAAiB,IAAI;QAAE,QAAQ,EAAE,oBAAoB,CAAC;QAAC,QAAQ,EAAE,WAAW,CAAC;QAAC,SAAS,EAAE,YAAY,CAAA;KAAE,CAEjH;CACJ"}
@@ -1,3 +1,4 @@
1
+ import { ColorSpace } from "../../api/rendering/enums.js";
1
2
  import { GeometryFormat, type IFramework, type IMainRenderTargetRenderPipeline, type ITexture2D } from "../../api/index.js";
2
3
  import { AWebGpuRenderPipeline } from "./AWebGpuRenderPipeline.js";
3
4
  /**
@@ -25,6 +26,10 @@ export declare class WebGpuMainRenderTargetRenderPipeline extends AWebGpuRenderP
25
26
  set mainRenderTarget(value: ITexture2D);
26
27
  /** @inheritDoc */
27
28
  initialize(): void;
29
+ /**
30
+ * The color space. Stored only; it has no effect on WebGPU yet.
31
+ */
32
+ colorSpace: ColorSpace;
28
33
  private _getBindGroup;
29
34
  /** @inheritDoc */
30
35
  render(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"WebGpuMainRenderTargetRenderPipeline.d.ts","sourceRoot":"","sources":["../../../src/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,cAAc,EACd,KAAK,UAAU,EACf,KAAK,+BAA+B,EACpC,KAAK,UAAU,EAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAC,qBAAqB,EAAC,MAAM,4BAA4B,CAAC;AAOjE;;;;GAIG;AACH,qBAAa,oCAAqC,SAAQ,qBAAsB,YAAW,+BAA+B;IAEtH,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,iBAAiB,CAAkB;IAC3C,OAAO,CAAC,gBAAgB,CAA6B;IACrD,OAAO,CAAC,UAAU,CAA6B;IAE/C;;;;OAIG;gBACgB,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,UAAU;IAKtE,kBAAkB;IAClB,SAAgB,cAAc,sCAAsC;IAEpE,kBAAkB;IAClB,IAAW,gBAAgB,IAAI,UAAU,CAExC;IAED,+DAA+D;IAC/D,IAAW,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAG5C;IAED,kBAAkB;IACX,UAAU,IAAI,IAAI;IA6BzB,OAAO,CAAC,aAAa;IAcrB,kBAAkB;IACX,MAAM,IAAI,IAAI;IAYrB,kBAAkB;IACF,OAAO,IAAI,IAAI;CAOlC"}
1
+ {"version":3,"file":"WebGpuMainRenderTargetRenderPipeline.d.ts","sourceRoot":"","sources":["../../../src/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAC;AAExD,OAAO,EAEH,cAAc,EACd,KAAK,UAAU,EACf,KAAK,+BAA+B,EACpC,KAAK,UAAU,EAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAC,qBAAqB,EAAC,MAAM,4BAA4B,CAAC;AAOjE;;;;GAIG;AACH,qBAAa,oCAAqC,SAAQ,qBAAsB,YAAW,+BAA+B;IAEtH,OAAO,CAAC,aAAa,CAA6B;IAClD,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,iBAAiB,CAAkB;IAC3C,OAAO,CAAC,gBAAgB,CAA6B;IACrD,OAAO,CAAC,UAAU,CAA6B;IAE/C;;;;OAIG;gBACgB,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAE,UAAU;IAKtE,kBAAkB;IAClB,SAAgB,cAAc,sCAAsC;IAEpE,kBAAkB;IAClB,IAAW,gBAAgB,IAAI,UAAU,CAExC;IAED,+DAA+D;IAC/D,IAAW,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAG5C;IAED,kBAAkB;IACX,UAAU,IAAI,IAAI;IA6BzB;;OAEG;IACI,UAAU,EAAE,UAAU,CAAqB;IAElD,OAAO,CAAC,aAAa;IAcrB,kBAAkB;IACX,MAAM,IAAI,IAAI;IAYrB,kBAAkB;IACF,OAAO,IAAI,IAAI;CAOlC"}
@@ -1 +1 @@
1
- {"version":3,"file":"WebGpuTextureFactory.d.ts","sourceRoot":"","sources":["../../../src/webgpu/texture/WebGpuTextureFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,aAAa,EAEhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,YAAY,EAAC,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,WAAW,CAAC,EAAE,kBAAkB,GAAG,UAAU;IAI9F,kBAAkB;IACX,MAAM,CACT,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAC7B,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,gBAAgB,GAAG,eAAe,EACpD,QAAQ,GAAE,MAAU,EACpB,KAAK,GAAE,MAAM,GAAG,IAAI,GAAG,SAAgB,EACvC,YAAY,SAAuD,EACnE,aAAa,gBAA0B,EACvC,UAAU,UAAQ,GAAG,UAAU;IAuCnC,kBAAkB;IACX,WAAW,CACd,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAC7B,KAAK,GAAE,KAAK,GAAG,IAAW,EAC1B,YAAY,SAAuD,EACnE,aAAa,gBAA0B,EACvC,KAAK,GAAE,MAAM,GAAG,IAAW,EAC3B,SAAS,UAAQ,GAAG,UAAU;CAmCrC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ris-framework",
3
- "version": "0.2.0-dev.14",
3
+ "version": "0.2.0-dev.16",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "gl-matrix": "^3.4.4",
37
- "ris-ktx2": "^0.2.0-dev.13"
37
+ "ris-ktx2": "^0.2.0"
38
38
  },
39
39
  "files": [
40
40
  "dist",
package/src/Framework.ts CHANGED
@@ -100,7 +100,7 @@ export class Framework implements IFramework {
100
100
  textureFiltering: this._configuration.textureFiltering ?? TextureSamplerFilteringPreset.BILINEAR,
101
101
  alpha: this._configuration.alpha ?? false,
102
102
  powerPreference: this._configuration.powerPreference ?? PowerPreferenceType.DEFAULT,
103
- textureColorSpace: this._configuration.textureColorSpace ?? ColorSpace.SRGB
103
+ textureColorSpace: this._configuration.textureColorSpace ?? ColorSpace.LINEAR
104
104
  };
105
105
 
106
106
 
@@ -41,7 +41,7 @@ export class IFrameworkConfiguration {
41
41
  /** The texture filtering to configure */
42
42
  textureFiltering?: TextureSamplerFilteringPreset;
43
43
 
44
- /** The texture color space to use by default. By default, it is {@link ColorSpace.SRGB}. */
44
+ /** The texture color space to use by default. By default, it is {@link ColorSpace.LINEAR}. */
45
45
  textureColorSpace?: ColorSpace;
46
46
 
47
47
  /**
@@ -24,5 +24,8 @@ export * from "./material/_export.ts";
24
24
  export * from "./lights/_export.ts";
25
25
  export * from "./scene/Scene.ts";
26
26
  export * from "./scene/SceneMesh.ts";
27
+ export * from "./scene/ISceneObject.ts";
28
+ export * from "./scene/node/Node.ts";
29
+ export * from "./scene/node/TransformNode.ts";
27
30
  export * from "./input/_export.ts";
28
31
  export * from "./image/_export.ts";
@@ -0,0 +1,182 @@
1
+ import {mat3, mat4, vec3} from "gl-matrix";
2
+ import {TransformNode} from "../scene/node/TransformNode.ts";
3
+
4
+ const _f = vec3.create();
5
+ const _x = vec3.create();
6
+ const _y = vec3.create();
7
+ const _z = vec3.create();
8
+ const _u = vec3.create();
9
+ const _m = mat4.create();
10
+ const _n = mat3.create();
11
+ const _p = vec3.create();
12
+ const _t = vec3.create();
13
+
14
+ /**
15
+ * Helpers shared by the cameras for deriving the view from a transform.
16
+ * Cameras look down their local -Z axis with +Y up.
17
+ * @internal
18
+ */
19
+ export class CameraTransformUtilities {
20
+
21
+ /**
22
+ * Writes the view matrix `inverse(T * R)` from a world matrix, ignoring scale.
23
+ * @param out The view matrix.
24
+ * @param world The camera's world matrix (`transform.modelMatrix`).
25
+ */
26
+ public static viewFromWorld(out: mat4, world: mat4): mat4 {
27
+ // Normalize the basis columns to drop scale, keeping rotation and translation (T * R).
28
+ mat4.copy(out, world);
29
+ for (let c = 0; c < 3; c++) {
30
+ const i = c * 4;
31
+ const length = Math.hypot(out[i], out[i + 1], out[i + 2]) || 1;
32
+ out[i] /= length;
33
+ out[i + 1] /= length;
34
+ out[i + 2] /= length;
35
+ }
36
+ return mat4.invert(out, out) ?? mat4.identity(out);
37
+ }
38
+
39
+ /**
40
+ * Writes the Euler rotation (the transform's Y-X-Z order) that makes a camera at `position` look at `target`
41
+ * with `up` as the up hint (a non-vertical up rolls the camera). When `up` is parallel to the view direction,
42
+ * the world axis least aligned with the view direction is used instead. Leaves `out` unchanged when the points are equal.
43
+ * @param out The rotation.
44
+ * @param position The camera position.
45
+ * @param target The point to look at.
46
+ * @param up The up hint. By default, world +Y.
47
+ */
48
+ public static lookAtRotation(out: vec3, position: vec3, target: vec3, up: vec3 = [0, 1, 0]): vec3 {
49
+ vec3.sub(_f, target, position);
50
+ if (vec3.sqrLen(_f) === 0) {
51
+ return out;
52
+ }
53
+ vec3.normalize(_f, _f);
54
+ vec3.negate(_z, _f);
55
+ vec3.cross(_x, up, _z);
56
+ if (vec3.sqrLen(_x) < 1e-12) {
57
+ // Up is parallel to the view direction (or zero): pick the world axis least aligned with it.
58
+ const ax = Math.abs(_f[0]), ay = Math.abs(_f[1]), az = Math.abs(_f[2]);
59
+ vec3.set(_u, 0, 0, 0);
60
+ _u[ay <= ax && ay <= az ? 1 : az <= ax ? 2 : 0] = 1;
61
+ vec3.cross(_x, _u, _z);
62
+ }
63
+ vec3.normalize(_x, _x);
64
+ vec3.cross(_y, _z, _x);
65
+ // R = Ry * Rx * Rz with columns x, y, z: m23 = -sin(pitch).
66
+ const m23 = _z[1];
67
+ out[0] = Math.asin(Math.max(-1, Math.min(1, -m23)));
68
+ if (Math.abs(m23) < 0.9999999) {
69
+ out[1] = Math.atan2(_z[0], _z[2]);
70
+ out[2] = Math.atan2(_x[1], _y[1]);
71
+ } else {
72
+ out[1] = Math.atan2(-_x[2], _x[0]);
73
+ out[2] = 0;
74
+ }
75
+ return out;
76
+ }
77
+
78
+ /**
79
+ * Writes the camera's forward direction (unit length) from a world matrix.
80
+ * @param out The direction.
81
+ * @param world The camera's world matrix.
82
+ */
83
+ public static forwardFromWorld(out: vec3, world: mat4): vec3 {
84
+ vec3.set(out, -world[8], -world[9], -world[10]);
85
+ return vec3.normalize(out, out);
86
+ }
87
+
88
+ /**
89
+ * Rotates a camera transform to look at a world-space point with a world-space up hint.
90
+ * When the transform has a `TransformNode` parent, the target and up are converted into the parent's space.
91
+ * @param transform The camera transform.
92
+ * @param target The world point.
93
+ * @param up The world up hint.
94
+ */
95
+ public static aimTransform(transform: TransformNode, target: vec3, up: vec3): void {
96
+ const parent = transform.parent;
97
+ if (parent instanceof TransformNode) {
98
+ mat4.invert(_m, parent.modelMatrix);
99
+ vec3.transformMat4(_t, target, _m);
100
+ mat3.fromMat4(_n, _m);
101
+ vec3.transformMat3(_p, up, _n);
102
+ CameraTransformUtilities.lookAtRotation(transform.rotation, transform.position, _t, _p);
103
+ } else {
104
+ CameraTransformUtilities.lookAtRotation(transform.rotation, transform.position, target, up);
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Writes a world position into `transform.position`, converting into the parent's space when it has a `TransformNode` parent.
110
+ */
111
+ public static setWorldPosition(transform: TransformNode, world: vec3): void {
112
+ const parent = transform.parent;
113
+ if (parent instanceof TransformNode) {
114
+ mat4.invert(_m, parent.modelMatrix);
115
+ vec3.transformMat4(transform.position, world, _m);
116
+ } else {
117
+ vec3.copy(transform.position, world);
118
+ }
119
+ }
120
+ }
121
+
122
+ /**
123
+ * The eye / target / up state of a camera, wrapping its transform (the single source of truth).
124
+ * @internal
125
+ */
126
+ export class CameraAim {
127
+ private readonly _target = vec3.create();
128
+ private _hasTarget = false;
129
+ private readonly _up = vec3.fromValues(0, 1, 0);
130
+
131
+ public constructor(private readonly _transform: () => TransformNode) {
132
+ }
133
+
134
+ public setEye(eye: vec3): void {
135
+ CameraTransformUtilities.setWorldPosition(this._transform(), eye);
136
+ if (this._hasTarget) {
137
+ this.aim();
138
+ }
139
+ }
140
+
141
+ public getEye(out: vec3 = vec3.create()): vec3 {
142
+ const m = this._transform().modelMatrix;
143
+ return vec3.set(out, m[12], m[13], m[14]);
144
+ }
145
+
146
+ public setTarget(target: vec3): void {
147
+ vec3.copy(this._target, target);
148
+ this._hasTarget = true;
149
+ this.aim();
150
+ }
151
+
152
+ public getTarget(out: vec3 = vec3.create()): vec3 {
153
+ if (this._hasTarget) {
154
+ return vec3.copy(out, this._target);
155
+ }
156
+ const m = this._transform().modelMatrix;
157
+ CameraTransformUtilities.forwardFromWorld(_f, m);
158
+ return vec3.set(out, m[12] + _f[0], m[13] + _f[1], m[14] + _f[2]);
159
+ }
160
+
161
+ public setUp(up: vec3): void {
162
+ vec3.copy(this._up, up);
163
+ if (this._hasTarget) {
164
+ this.aim();
165
+ }
166
+ }
167
+
168
+ public getUp(out: vec3 = vec3.create()): vec3 {
169
+ return vec3.copy(out, this._up);
170
+ }
171
+
172
+ /** One-shot look-at with the current up; forgets the stored target. */
173
+ public lookAt(target: vec3): void {
174
+ this._hasTarget = false;
175
+ CameraTransformUtilities.aimTransform(this._transform(), target, this._up);
176
+ }
177
+
178
+ /** Re-aims at the stored target. */
179
+ public aim(): void {
180
+ CameraTransformUtilities.aimTransform(this._transform(), this._target, this._up);
181
+ }
182
+ }
@@ -1,10 +1,11 @@
1
1
  import type { IDisposable } from "../core/IDisposable.ts";
2
- import {mat4} from "gl-matrix"
2
+ import {mat4, vec3} from "gl-matrix"
3
3
  import type { IUniformBuffer } from "../rendering/buffers/IUniformBuffer.ts";
4
4
  import {GameTime} from "../time/GameTime.ts";
5
+ import type {ISceneObject} from "../scene/ISceneObject.ts";
5
6
 
6
7
  /** The camera interface. */
7
- export interface ICamera extends IDisposable {
8
+ export interface ICamera extends ISceneObject, IDisposable {
8
9
 
9
10
  /**
10
11
  * The projection matrix.
@@ -48,6 +49,45 @@ export interface ICamera extends IDisposable {
48
49
  */
49
50
  updateBuffers(): void;
50
51
 
52
+ /**
53
+ * Moves the camera: writes `transform.position` from a world position (converted into the parent's space
54
+ * when the transform has a `TransformNode` parent). Re-aims at the target when one was set with {@link setTarget},
55
+ * keeping the old eye/target behaviour; otherwise the rotation is kept.
56
+ * @param eye The world position.
57
+ */
58
+ setEye(eye: vec3): void;
59
+
60
+ /**
61
+ * The world position of the camera (the transform's world translation).
62
+ * @param out Optional vector to write into.
63
+ */
64
+ getEye(out?: vec3): vec3;
65
+
66
+ /**
67
+ * Stores the target and rotates the transform to look at it with the current up ({@link getUp}).
68
+ * @param target The world point to look at.
69
+ */
70
+ setTarget(target: vec3): void;
71
+
72
+ /**
73
+ * The last target set with {@link setTarget}, or the eye plus the view direction when none is set.
74
+ * @param out Optional vector to write into.
75
+ */
76
+ getTarget(out?: vec3): vec3;
77
+
78
+ /**
79
+ * Sets the up vector used when aiming (world space, by default (0, 1, 0)); a non-vertical up rolls the camera.
80
+ * Re-aims when a target is set. An up parallel to the view direction falls back to the world axis least aligned with it.
81
+ * @param up The up vector.
82
+ */
83
+ setUp(up: vec3): void;
84
+
85
+ /**
86
+ * The up vector used when aiming.
87
+ * @param out Optional vector to write into.
88
+ */
89
+ getUp(out?: vec3): vec3;
90
+
51
91
  /**
52
92
  * Update the camera.
53
93
  * @param time - The game time object.