ris-framework 0.2.0-dev.13 → 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.
- package/CHANGELOG.md +43 -2
- package/README.md +13 -5
- package/dist/api/IFramework.d.ts +3 -3
- package/dist/api/IFramework.d.ts.map +1 -1
- package/dist/api/_export.d.ts +3 -0
- package/dist/api/_export.d.ts.map +1 -1
- package/dist/api/camera/CameraTransformUtilities.d.ts +65 -0
- package/dist/api/camera/CameraTransformUtilities.d.ts.map +1 -0
- package/dist/api/camera/ICamera.d.ts +36 -2
- package/dist/api/camera/ICamera.d.ts.map +1 -1
- package/dist/api/camera/OrbitCamera.d.ts +22 -14
- package/dist/api/camera/OrbitCamera.d.ts.map +1 -1
- package/dist/api/camera/OrthographicCamera.d.ts +33 -11
- package/dist/api/camera/OrthographicCamera.d.ts.map +1 -1
- package/dist/api/camera/PerspectiveCamera.d.ts +32 -18
- package/dist/api/camera/PerspectiveCamera.d.ts.map +1 -1
- package/dist/api/content/ContentManager.d.ts +2 -2
- package/dist/api/content/ContentManager.d.ts.map +1 -1
- package/dist/api/content/IContentManager.d.ts +2 -2
- package/dist/api/content/IContentManager.d.ts.map +1 -1
- package/dist/api/lights/AmbientLight.d.ts +7 -2
- package/dist/api/lights/AmbientLight.d.ts.map +1 -1
- package/dist/api/lights/DirectionalLight.d.ts +18 -4
- package/dist/api/lights/DirectionalLight.d.ts.map +1 -1
- package/dist/api/lights/ILight.d.ts +18 -0
- package/dist/api/lights/ILight.d.ts.map +1 -0
- package/dist/api/lights/PointLight.d.ts +17 -4
- package/dist/api/lights/PointLight.d.ts.map +1 -1
- package/dist/api/lights/_export.d.ts +1 -0
- package/dist/api/lights/_export.d.ts.map +1 -1
- package/dist/api/material/ForwardBlinnPhongMaterial.d.ts +2 -2
- package/dist/api/material/ForwardBlinnPhongMaterial.d.ts.map +1 -1
- package/dist/api/material/IMaterial.d.ts +7 -0
- package/dist/api/material/IMaterial.d.ts.map +1 -1
- package/dist/api/material/IMaterialFactory.d.ts +3 -2
- package/dist/api/material/IMaterialFactory.d.ts.map +1 -1
- package/dist/api/material/IUnlitMaterialDescriptor.d.ts +16 -0
- package/dist/api/material/IUnlitMaterialDescriptor.d.ts.map +1 -0
- package/dist/api/material/MaterialFactory.d.ts +3 -2
- package/dist/api/material/MaterialFactory.d.ts.map +1 -1
- package/dist/api/material/SpriteMaterial.d.ts +3 -0
- package/dist/api/material/SpriteMaterial.d.ts.map +1 -1
- package/dist/api/material/UnlitMaterial.d.ts +5 -12
- package/dist/api/material/UnlitMaterial.d.ts.map +1 -1
- package/dist/api/material/_export.d.ts +1 -1
- package/dist/api/material/_export.d.ts.map +1 -1
- package/dist/api/meshes/IRenderableMesh.d.ts +3 -14
- package/dist/api/meshes/IRenderableMesh.d.ts.map +1 -1
- package/dist/api/meshes/RenderableMesh.d.ts +5 -20
- package/dist/api/meshes/RenderableMesh.d.ts.map +1 -1
- package/dist/api/rendering/IGraphicsDevice.d.ts +2 -2
- package/dist/api/rendering/IGraphicsDevice.d.ts.map +1 -1
- package/dist/api/rendering/IRenderer.d.ts +13 -6
- package/dist/api/rendering/IRenderer.d.ts.map +1 -1
- package/dist/api/rendering/_export-rendering.d.ts +1 -0
- package/dist/api/rendering/_export-rendering.d.ts.map +1 -1
- package/dist/api/rendering/enums.d.ts +5 -5
- package/dist/api/rendering/enums.d.ts.map +1 -1
- package/dist/api/rendering/primitive/IPrimitiveStateDescriptor.d.ts +24 -0
- package/dist/api/rendering/primitive/IPrimitiveStateDescriptor.d.ts.map +1 -0
- package/dist/api/rendering/primitive/_export.d.ts +1 -1
- package/dist/api/rendering/primitive/_export.d.ts.map +1 -1
- package/dist/api/rendering/render-pipelines/IMainRenderTargetRenderPipeline.d.ts +5 -0
- package/dist/api/rendering/render-pipelines/IMainRenderTargetRenderPipeline.d.ts.map +1 -1
- package/dist/api/rendering/texture/ITextureDescriptor.d.ts +53 -0
- package/dist/api/rendering/texture/ITextureDescriptor.d.ts.map +1 -0
- package/dist/api/rendering/texture/ITextureFactory.d.ts +5 -3
- package/dist/api/rendering/texture/ITextureFactory.d.ts.map +1 -1
- package/dist/api/rendering/texture/TextureUtilities.d.ts +29 -21
- package/dist/api/rendering/texture/TextureUtilities.d.ts.map +1 -1
- package/dist/api/rendering/texture/_export-texture.d.ts +1 -1
- package/dist/api/rendering/texture/_export-texture.d.ts.map +1 -1
- package/dist/api/scene/ISceneObject.d.ts +12 -0
- package/dist/api/scene/ISceneObject.d.ts.map +1 -0
- package/dist/api/scene/Scene.d.ts +17 -6
- package/dist/api/scene/Scene.d.ts.map +1 -1
- package/dist/api/scene/node/Node.d.ts +26 -0
- package/dist/api/scene/node/Node.d.ts.map +1 -0
- package/dist/api/scene/node/TransformNode.d.ts +46 -0
- package/dist/api/scene/node/TransformNode.d.ts.map +1 -0
- package/dist/core/material/UnlitMaterialDescriptorUtilities.d.ts +17 -0
- package/dist/core/material/UnlitMaterialDescriptorUtilities.d.ts.map +1 -0
- package/dist/core/rendering/AGraphicsDevice.d.ts +2 -2
- package/dist/core/rendering/AGraphicsDevice.d.ts.map +1 -1
- package/dist/core/rendering/ARenderer.d.ts +7 -1
- package/dist/core/rendering/ARenderer.d.ts.map +1 -1
- package/dist/core/rendering/primitive/PrimitiveStateDescriptorUtilities.d.ts +15 -0
- package/dist/core/rendering/primitive/PrimitiveStateDescriptorUtilities.d.ts.map +1 -0
- package/dist/core/rendering/texture/TextureDescriptorUtilities.d.ts +14 -0
- package/dist/core/rendering/texture/TextureDescriptorUtilities.d.ts.map +1 -0
- package/dist/core/rendering/texture/texture.d.ts +3 -2
- package/dist/core/rendering/texture/texture.d.ts.map +1 -1
- package/dist/index.js +959 -540
- package/dist/webgl/WebGlGraphicsDevice.d.ts +2 -2
- package/dist/webgl/WebGlGraphicsDevice.d.ts.map +1 -1
- package/dist/webgl/lights/WebGlLightsBuffer.d.ts.map +1 -1
- package/dist/webgl/primitive/WebGlPrimitiveState.d.ts +3 -3
- package/dist/webgl/primitive/WebGlPrimitiveState.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts +8 -0
- package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/texture/WebGlTexture2D.d.ts +3 -2
- package/dist/webgl/texture/WebGlTexture2D.d.ts.map +1 -1
- package/dist/webgl/texture/WebGlTextureFactory.d.ts +2 -9
- package/dist/webgl/texture/WebGlTextureFactory.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlErrorUtilities.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlTextureUtilities.d.ts.map +1 -1
- package/dist/webgpu/WebGpuGraphicsDevice.d.ts +2 -2
- package/dist/webgpu/WebGpuGraphicsDevice.d.ts.map +1 -1
- package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts +2 -2
- package/dist/webgpu/primitive/WebGpuPrimitiveState.d.ts.map +1 -1
- package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts +5 -0
- package/dist/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.d.ts.map +1 -1
- package/dist/webgpu/texture/WebGpuTexture2D.d.ts +3 -2
- package/dist/webgpu/texture/WebGpuTexture2D.d.ts.map +1 -1
- package/dist/webgpu/texture/WebGpuTextureFactory.d.ts +2 -2
- package/dist/webgpu/texture/WebGpuTextureFactory.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/Framework.ts +2 -2
- package/src/api/IFramework.ts +3 -3
- package/src/api/_export.ts +3 -0
- package/src/api/camera/CameraTransformUtilities.ts +182 -0
- package/src/api/camera/ICamera.ts +42 -2
- package/src/api/camera/OrbitCamera.ts +71 -38
- package/src/api/camera/OrthographicCamera.ts +71 -28
- package/src/api/camera/PerspectiveCamera.ts +69 -33
- package/src/api/content/ContentManager.ts +18 -12
- package/src/api/content/IContentManager.ts +2 -2
- package/src/api/lights/AmbientLight.ts +8 -2
- package/src/api/lights/DirectionalLight.ts +30 -5
- package/src/api/lights/ILight.ts +22 -0
- package/src/api/lights/PointLight.ts +26 -5
- package/src/api/lights/_export.ts +1 -0
- package/src/api/material/ForwardBlinnPhongMaterial.ts +2 -2
- package/src/api/material/IMaterial.ts +8 -0
- package/src/api/material/IMaterialFactory.ts +3 -2
- package/src/api/material/IUnlitMaterialDescriptor.ts +18 -0
- package/src/api/material/MaterialFactory.ts +4 -3
- package/src/api/material/SpriteMaterial.ts +4 -0
- package/src/api/material/UnlitMaterial.ts +11 -18
- package/src/api/material/_export.ts +1 -1
- package/src/api/meshes/IRenderableMesh.ts +3 -18
- package/src/api/meshes/RenderableMesh.ts +15 -45
- package/src/api/rendering/IGraphicsDevice.ts +2 -2
- package/src/api/rendering/IRenderer.ts +14 -6
- package/src/api/rendering/_export-rendering.ts +2 -1
- package/src/api/rendering/enums.ts +5 -5
- package/src/api/rendering/primitive/IPrimitiveStateDescriptor.ts +27 -0
- package/src/api/rendering/primitive/_export.ts +1 -1
- package/src/api/rendering/render-pipelines/IMainRenderTargetRenderPipeline.ts +6 -0
- package/src/api/rendering/texture/ITextureDescriptor.ts +62 -0
- package/src/api/rendering/texture/ITextureFactory.ts +5 -3
- package/src/api/rendering/texture/TextureUtilities.ts +59 -61
- package/src/api/rendering/texture/_export-texture.ts +1 -1
- package/src/api/scene/ISceneObject.ts +13 -0
- package/src/api/scene/Scene.ts +52 -11
- package/src/api/scene/node/Node.ts +54 -0
- package/src/api/scene/node/TransformNode.ts +88 -0
- package/src/core/material/UnlitMaterialDescriptorUtilities.ts +21 -0
- package/src/core/rendering/AGraphicsDevice.ts +2 -2
- package/src/core/rendering/ARenderer.ts +26 -4
- package/src/core/rendering/primitive/PrimitiveStateDescriptorUtilities.ts +22 -0
- package/src/core/rendering/texture/TextureDescriptorUtilities.ts +28 -0
- package/src/core/rendering/texture/texture.ts +2 -2
- package/src/main.ts +5 -4
- package/src/webgl/WebGlGraphicsDevice.ts +2 -3
- package/src/webgl/lights/WebGlLightsBuffer.ts +21 -8
- package/src/webgl/primitive/WebGlPrimitiveState.ts +8 -6
- package/src/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.ts +14 -0
- package/src/webgl/texture/WebGlTexture2D.ts +9 -8
- package/src/webgl/texture/WebGlTextureFactory.ts +62 -65
- package/src/webgl/utilities/WebGlErrorUtilities.ts +3 -2
- package/src/webgl/utilities/WebGlTextureUtilities.ts +10 -4
- package/src/webgpu/WebGpuGraphicsDevice.ts +3 -3
- package/src/webgpu/primitive/WebGpuPrimitiveState.ts +7 -5
- package/src/webgpu/render-pipelines/WebGpuMainRenderTargetRenderPipeline.ts +6 -0
- package/src/webgpu/texture/WebGpuTexture2D.ts +10 -9
- package/src/webgpu/texture/WebGpuTextureFactory.ts +20 -17
- package/dist/api/material/ICameraMaterial.d.ts +0 -18
- package/dist/api/material/ICameraMaterial.d.ts.map +0 -1
- package/dist/api/rendering/primitive/PrimitiveStateDescriptor.d.ts +0 -24
- package/dist/api/rendering/primitive/PrimitiveStateDescriptor.d.ts.map +0 -1
- package/dist/api/rendering/texture/TextureDescriptor.d.ts +0 -42
- package/dist/api/rendering/texture/TextureDescriptor.d.ts.map +0 -1
- package/src/api/material/ICameraMaterial.ts +0 -22
- package/src/api/rendering/primitive/PrimitiveStateDescriptor.ts +0 -27
- package/src/api/rendering/texture/TextureDescriptor.ts +0 -52
package/CHANGELOG.md
CHANGED
|
@@ -2,8 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
|
+
An unreleased version is dated `{{YYYY-MM-DD}}`; the publish pipeline fills in the date when it is merged to `main`.
|
|
5
6
|
|
|
6
|
-
## [0.
|
|
7
|
+
## [0.3.0] - {{YYYY-MM-DD}}
|
|
8
|
+
|
|
9
|
+
Compared with 0.2.0.
|
|
10
|
+
|
|
11
|
+
### Breaking changes
|
|
12
|
+
|
|
13
|
+
- Renderable meshes take their transform from `mesh.transform` (a `TransformNode`); `mesh.position`, `rotation`, `scale` and `modelMatrix` are removed.
|
|
14
|
+
- Cameras have a `transform`; the `eye`, `target` and `up` properties are replaced by `setEye`/`setTarget`/`setUp` and their getters.
|
|
15
|
+
- `PointLight.position` is replaced by `setPosition`/`getPosition`, and `DirectionalLight.direction` by `setDirection`/`getDirection`.
|
|
16
|
+
- `ICameraMaterial` is removed; use `IMaterial.camera`.
|
|
17
|
+
- `IRenderer.preferredColorSpace` is renamed to `IRenderer.colorSpace`, and the `textureColorSpace` default is now `LINEAR`.
|
|
18
|
+
- `PrimitiveStateDescriptor` class is replaced by the `IPrimitiveStateDescriptor` interface; all fields are optional and default to back-face culled, counter-clockwise triangles.
|
|
19
|
+
- `UnlitMaterialDescriptor` class is replaced by the `IUnlitMaterialDescriptor` interface (all fields optional).
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- `TransformNode` (with a `Node` parent/child hierarchy), `ISceneObject` and `scene.nodes`; meshes, cameras and lights are scene objects, and parented ones work in world space.
|
|
24
|
+
- The `ILight` interface shared by all lights.
|
|
25
|
+
- `IMaterial.camera`: materials bind the camera buffers they use.
|
|
26
|
+
- `IRenderer.colorSpace` can be switched at runtime.
|
|
27
|
+
- `ITextureDescriptor.preferredColorSpace` to choose the color space per texture.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- `textureFactory.create` without a format follows the renderer's color space.
|
|
32
|
+
- Basis KTX2 textures can be transcoded to PVRTC1 RGB.
|
|
33
|
+
- Requires `ris-ktx2` ^0.2.0 (stable).
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- `ColorSpace` was not exported from the package entry.
|
|
38
|
+
- An explicit `textureFormat` was ignored when loading KTX2 textures.
|
|
39
|
+
- `content.loadTexture2DAsync` ignored the descriptor's label and usage.
|
|
40
|
+
- ASTC textures were uploaded with the wrong size.
|
|
41
|
+
- `OrbitCamera` zoom now checks the real eye-to-target distance against the near and far planes.
|
|
42
|
+
|
|
43
|
+
## [0.2.0] - 2026-11-01
|
|
7
44
|
|
|
8
45
|
Compared with `main` (0.1.0).
|
|
9
46
|
|
|
@@ -16,6 +53,7 @@ Compared with `main` (0.1.0).
|
|
|
16
53
|
- Materials take a `modelBuffer` owned by the mesh instead of `modelMatrix`, and `renderMesh` takes an `IRenderableMesh`.
|
|
17
54
|
- Render pipelines throw when no model buffer is passed.
|
|
18
55
|
- Requires `ris-ktx2` 0.2.
|
|
56
|
+
- `TextureDescriptor` class is replaced by the `ITextureDescriptor` interface; all fields are optional and factories fill in defaults.
|
|
19
57
|
|
|
20
58
|
### Added
|
|
21
59
|
|
|
@@ -26,11 +64,14 @@ Compared with `main` (0.1.0).
|
|
|
26
64
|
- OBJ/MTL loading through `framework.objLoader`, `ObjParser`, and `content.loadMeshAsync`, `loadUnlitMeshAsync` and `loadBlinnPhongMeshAsync`.
|
|
27
65
|
- `geometryBuilder.create(descriptor)` and the exported `BaseGeometry`.
|
|
28
66
|
- sRGB compressed texture formats (BC1, BC3, BC7, ETC2), with KTX2 loading choosing sRGB automatically.
|
|
67
|
+
- `ColorSpace` enum, the `textureColorSpace` configuration option (default `SRGB`) and `IRenderer.preferredColorSpace`.
|
|
68
|
+
- `TextureUtilities.convertToSrgbVariant`, `convertToLinearVariant` and `isSrgbFormat`.
|
|
29
69
|
- Examples: `unlit_mesh`, `blinn_phong_mesh` and `sprite_batch`.
|
|
30
70
|
|
|
31
71
|
### Changed
|
|
32
72
|
|
|
33
73
|
- `content.loadShaderModule` accepts optional replacement values.
|
|
74
|
+
- Textures without a format, and KTX2 textures, follow the configured color space.
|
|
34
75
|
|
|
35
76
|
### Fixed
|
|
36
77
|
|
|
@@ -40,7 +81,7 @@ Compared with `main` (0.1.0).
|
|
|
40
81
|
- A leftover `debugger` statement in WebGL device initialization.
|
|
41
82
|
- Swapped BC/S3TC compression flags could select BC7 on GPUs without BPTC support.
|
|
42
83
|
|
|
43
|
-
## [0.1.0]
|
|
84
|
+
## [0.1.0] - 2026-10-08
|
|
44
85
|
|
|
45
86
|
- Initial release setup. `development` publishes a prerelease on the npm `next` tag. `main` publishes this version on `latest`.
|
|
46
87
|
- The package entry is compiled JavaScript and declarations in `dist`. Consumers import `Framework`, `FrameworkConfiguration`, `TextureSamplerFilteringPreset`, and the types formerly published as `ris-framework-api` from `ris-framework` without compiling this repository. Built-in shaders and the browser KTX2 loader are included in that JavaScript.
|
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ framework.renderer.clearColor = Color.cornerFlowerBlue();
|
|
|
36
36
|
| `canvas` | created and appended | The canvas to render into. |
|
|
37
37
|
| `backBufferSize` | `800 × 600` | Back buffer size. |
|
|
38
38
|
| `textureFiltering` | `BILINEAR` | Default sampler preset. |
|
|
39
|
-
| `textureColorSpace` | `
|
|
39
|
+
| `textureColorSpace` | `LINEAR` | Default texture colour space; switch at runtime with `framework.renderer.colorSpace`. |
|
|
40
40
|
| `useKtx2` | `false` | Creates `framework.ktx2Factory`. |
|
|
41
41
|
| `alpha` | `false` | Whether the back buffer has an alpha channel. |
|
|
42
42
|
| `powerPreference` | `DEFAULT` | GPU preference on multi-GPU systems. |
|
|
@@ -53,13 +53,15 @@ const scene = new Scene(framework);
|
|
|
53
53
|
// Passing the scene makes this the scene's camera.
|
|
54
54
|
const camera = framework.cameraFactory.createPerspectiveCamera({
|
|
55
55
|
aspectRatio: canvas.width / canvas.height,
|
|
56
|
-
|
|
56
|
+
position: [0, 0, 3], // world position; aims at `target` (default origin). Later: camera.setEye(...), setTarget(...), setUp(...)
|
|
57
57
|
}, scene);
|
|
58
58
|
|
|
59
59
|
scene.activeAmbientLight.color = new Color(0.4, 0.4, 0.4);
|
|
60
60
|
// Lights take an optional scene; passing it adds them.
|
|
61
61
|
new DirectionalLight({ color: new Color(1, 1, 1), intensity: 0.8, direction: [-0.4, -0.6, 1] }, scene);
|
|
62
|
-
new PointLight({ color: new Color(1, 0.5, 0.2), intensity: 1.2, linear: 0.35, quadratic: 0.44 }, scene);
|
|
62
|
+
const lamp = new PointLight({ color: new Color(1, 0.5, 0.2), intensity: 1.2, linear: 0.35, quadratic: 0.44 }, scene);
|
|
63
|
+
// Lights implement ILight and are scene objects: position and direction live in light.transform.
|
|
64
|
+
lamp.setPosition([0, 2, 0]);
|
|
63
65
|
|
|
64
66
|
framework.addOnUpdateListener(time => {
|
|
65
67
|
camera.update(time);
|
|
@@ -74,9 +76,9 @@ framework.addOnRenderListener(() => scene.render());
|
|
|
74
76
|
|
|
75
77
|
- `IMesh` / `Mesh` hold geometry and the vertex and index buffers.
|
|
76
78
|
- `IRenderableMesh` / `RenderableMesh` add a material, an index range and sub meshes (`mesh.addSubMesh(material, start, count)` or `meshFactory.createWithSubMeshes`). The root mesh owns the transform and one model buffer, which all its sub meshes share.
|
|
77
|
-
- Transforms: `mesh.position`, `
|
|
79
|
+
- Transforms: `mesh.transform` is a `TransformNode` with `position`, `rotation` (Euler radians, applied Y, then X, then Z) and `scale`. `transform.modelMatrix` is recomputed only when one of them changes, and parenting one transform to another (`parent.addChild(child)`) makes it relative to the parent. Meshes, cameras and lights are all scene objects (`ISceneObject`) with a `transform`.
|
|
78
80
|
- `SceneMesh`: `scene.add(mesh)` wraps a renderable mesh in a `SceneMesh`, which owns its materials. `sceneMesh.dispose()` and `scene.dispose()` dispose the mesh and each material once.
|
|
79
|
-
- Materials come from `framework.materialFactory`. They include unlit, `ForwardBlinnPhongMaterial` and `SpriteMaterial`.
|
|
81
|
+
- Materials come from `framework.materialFactory`. They include unlit (`createUnlitMaterial(descriptor?: IUnlitMaterialDescriptor)`), `ForwardBlinnPhongMaterial` and `SpriteMaterial`.
|
|
80
82
|
|
|
81
83
|
## Loading OBJ/MTL
|
|
82
84
|
|
|
@@ -103,8 +105,14 @@ const geometry = await framework.content.loadMeshAsync("/assets/cube.obj", Geome
|
|
|
103
105
|
```ts
|
|
104
106
|
const png = await framework.content.loadTexture2DAsync("/assets/test.png");
|
|
105
107
|
const ktx = await framework.content.loadTexture2DAsync("/assets/kodim23.ktx2");
|
|
108
|
+
|
|
109
|
+
// Optional descriptor: every field is optional, missing ones get defaults.
|
|
110
|
+
const desc: ITextureDescriptor = { generateMipmaps: true, textureFormat: TextureFormat.RGBA_8_UNORM };
|
|
111
|
+
const cat = await framework.content.loadTexture2DAsync("/assets/cat.jpg", desc);
|
|
106
112
|
```
|
|
107
113
|
|
|
114
|
+
Textures without a format use `RGBA_8_UNORM` when the colour space is `LINEAR` (the default) and `RGBA_8_UNORM_SRGB` when it is `SRGB`.
|
|
115
|
+
|
|
108
116
|
Paths ending in `.ktx2` are loaded through `ris-ktx2`.
|
|
109
117
|
|
|
110
118
|
- **Basis Universal files** are transcoded to the best format the GPU supports, in this order: BC7, ASTC 4×4, BC3, ETC2, PVRTC, and RGBA8 as a last resort.
|
package/dist/api/IFramework.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ import type { IDisposable } from "./core/IDisposable.js";
|
|
|
23
23
|
import type { vec2 } from "gl-matrix";
|
|
24
24
|
import type { TextureSamplerFilteringPreset } from "../core/rendering/enums.js";
|
|
25
25
|
import type { PowerPreferenceType } from "./rendering/PowerPreference.js";
|
|
26
|
-
import type {
|
|
26
|
+
import type { ColorSpace } from "./rendering/enums.js";
|
|
27
27
|
/**
|
|
28
28
|
* The configuration for the framework.
|
|
29
29
|
* @public
|
|
@@ -35,8 +35,8 @@ export declare class IFrameworkConfiguration {
|
|
|
35
35
|
backBufferSize?: vec2;
|
|
36
36
|
/** The texture filtering to configure */
|
|
37
37
|
textureFiltering?: TextureSamplerFilteringPreset;
|
|
38
|
-
/** The texture color space to use by default. By default, it is {@link
|
|
39
|
-
textureColorSpace?:
|
|
38
|
+
/** The texture color space to use by default. By default, it is {@link ColorSpace.LINEAR}. */
|
|
39
|
+
textureColorSpace?: ColorSpace;
|
|
40
40
|
/**
|
|
41
41
|
* The HTMLCanvasElement to use for rendering.
|
|
42
42
|
* If null, a new canvas will be created and added to the document body.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IFramework.d.ts","sourceRoot":"","sources":["../../src/api/IFramework.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wDAAwD,CAAC;AACrG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,EAA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;;;OAGG;IACH,2BAA2B,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAErD,+CAA+C;IAC/C,wBAAwB,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAElD,+CAA+C;IAC/C,2BAA2B,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAErD;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,IAAI,CAAC;IAE/D;;OAEG;IACH,sBAAsB,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,IAAI,CAAC;IAElE;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAE7C;;OAEG;IACH,sBAAsB,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAEhD,iCAAiC;IACjC,UAAU,IAAI,IAAI,CAAC;IAEnB;;;OAGG;IACH,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAEpC"}
|
package/dist/api/_export.d.ts
CHANGED
|
@@ -24,6 +24,9 @@ export * from "./material/_export.js";
|
|
|
24
24
|
export * from "./lights/_export.js";
|
|
25
25
|
export * from "./scene/Scene.js";
|
|
26
26
|
export * from "./scene/SceneMesh.js";
|
|
27
|
+
export * from "./scene/ISceneObject.js";
|
|
28
|
+
export * from "./scene/node/Node.js";
|
|
29
|
+
export * from "./scene/node/TransformNode.js";
|
|
27
30
|
export * from "./input/_export.js";
|
|
28
31
|
export * from "./image/_export.js";
|
|
29
32
|
//# sourceMappingURL=_export.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_export.d.ts","sourceRoot":"","sources":["../../src/api/_export.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC;A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C,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { mat4, vec3 } from "gl-matrix";
|
|
2
|
+
import { TransformNode } from "../scene/node/TransformNode.js";
|
|
3
|
+
/**
|
|
4
|
+
* Helpers shared by the cameras for deriving the view from a transform.
|
|
5
|
+
* Cameras look down their local -Z axis with +Y up.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class CameraTransformUtilities {
|
|
9
|
+
/**
|
|
10
|
+
* Writes the view matrix `inverse(T * R)` from a world matrix, ignoring scale.
|
|
11
|
+
* @param out The view matrix.
|
|
12
|
+
* @param world The camera's world matrix (`transform.modelMatrix`).
|
|
13
|
+
*/
|
|
14
|
+
static viewFromWorld(out: mat4, world: mat4): mat4;
|
|
15
|
+
/**
|
|
16
|
+
* Writes the Euler rotation (the transform's Y-X-Z order) that makes a camera at `position` look at `target`
|
|
17
|
+
* with `up` as the up hint (a non-vertical up rolls the camera). When `up` is parallel to the view direction,
|
|
18
|
+
* the world axis least aligned with the view direction is used instead. Leaves `out` unchanged when the points are equal.
|
|
19
|
+
* @param out The rotation.
|
|
20
|
+
* @param position The camera position.
|
|
21
|
+
* @param target The point to look at.
|
|
22
|
+
* @param up The up hint. By default, world +Y.
|
|
23
|
+
*/
|
|
24
|
+
static lookAtRotation(out: vec3, position: vec3, target: vec3, up?: vec3): vec3;
|
|
25
|
+
/**
|
|
26
|
+
* Writes the camera's forward direction (unit length) from a world matrix.
|
|
27
|
+
* @param out The direction.
|
|
28
|
+
* @param world The camera's world matrix.
|
|
29
|
+
*/
|
|
30
|
+
static forwardFromWorld(out: vec3, world: mat4): vec3;
|
|
31
|
+
/**
|
|
32
|
+
* Rotates a camera transform to look at a world-space point with a world-space up hint.
|
|
33
|
+
* When the transform has a `TransformNode` parent, the target and up are converted into the parent's space.
|
|
34
|
+
* @param transform The camera transform.
|
|
35
|
+
* @param target The world point.
|
|
36
|
+
* @param up The world up hint.
|
|
37
|
+
*/
|
|
38
|
+
static aimTransform(transform: TransformNode, target: vec3, up: vec3): void;
|
|
39
|
+
/**
|
|
40
|
+
* Writes a world position into `transform.position`, converting into the parent's space when it has a `TransformNode` parent.
|
|
41
|
+
*/
|
|
42
|
+
static setWorldPosition(transform: TransformNode, world: vec3): void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The eye / target / up state of a camera, wrapping its transform (the single source of truth).
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export declare class CameraAim {
|
|
49
|
+
private readonly _transform;
|
|
50
|
+
private readonly _target;
|
|
51
|
+
private _hasTarget;
|
|
52
|
+
private readonly _up;
|
|
53
|
+
constructor(_transform: () => TransformNode);
|
|
54
|
+
setEye(eye: vec3): void;
|
|
55
|
+
getEye(out?: vec3): vec3;
|
|
56
|
+
setTarget(target: vec3): void;
|
|
57
|
+
getTarget(out?: vec3): vec3;
|
|
58
|
+
setUp(up: vec3): void;
|
|
59
|
+
getUp(out?: vec3): vec3;
|
|
60
|
+
/** One-shot look-at with the current up; forgets the stored target. */
|
|
61
|
+
lookAt(target: vec3): void;
|
|
62
|
+
/** Re-aims at the stored target. */
|
|
63
|
+
aim(): void;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=CameraTransformUtilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CameraTransformUtilities.d.ts","sourceRoot":"","sources":["../../../src/api/camera/CameraTransformUtil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AAuE;IAChE,MAAM,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI;IAKjC,oCAAoC;IAC7B,GAAG,IAAI,IAAI;CAGrB"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { IDisposable } from "../core/IDisposable.js";
|
|
2
|
-
import { mat4 } from "gl-matrix";
|
|
2
|
+
import { mat4, vec3 } from "gl-matrix";
|
|
3
3
|
import type { IUniformBuffer } from "../rendering/buffers/IUniformBuffer.js";
|
|
4
4
|
import { GameTime } from "../time/GameTime.js";
|
|
5
|
+
import type { ISceneObject } from "../scene/ISceneObject.js";
|
|
5
6
|
/** The camera interface. */
|
|
6
|
-
export interface ICamera extends IDisposable {
|
|
7
|
+
export interface ICamera extends ISceneObject, IDisposable {
|
|
7
8
|
/**
|
|
8
9
|
* The projection matrix.
|
|
9
10
|
*/
|
|
@@ -38,6 +39,39 @@ export interface ICamera extends IDisposable {
|
|
|
38
39
|
* This needs to be called when camera properties are changed.
|
|
39
40
|
*/
|
|
40
41
|
updateBuffers(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Moves the camera: writes `transform.position` from a world position (converted into the parent's space
|
|
44
|
+
* when the transform has a `TransformNode` parent). Re-aims at the target when one was set with {@link setTarget},
|
|
45
|
+
* keeping the old eye/target behaviour; otherwise the rotation is kept.
|
|
46
|
+
* @param eye The world position.
|
|
47
|
+
*/
|
|
48
|
+
setEye(eye: vec3): void;
|
|
49
|
+
/**
|
|
50
|
+
* The world position of the camera (the transform's world translation).
|
|
51
|
+
* @param out Optional vector to write into.
|
|
52
|
+
*/
|
|
53
|
+
getEye(out?: vec3): vec3;
|
|
54
|
+
/**
|
|
55
|
+
* Stores the target and rotates the transform to look at it with the current up ({@link getUp}).
|
|
56
|
+
* @param target The world point to look at.
|
|
57
|
+
*/
|
|
58
|
+
setTarget(target: vec3): void;
|
|
59
|
+
/**
|
|
60
|
+
* The last target set with {@link setTarget}, or the eye plus the view direction when none is set.
|
|
61
|
+
* @param out Optional vector to write into.
|
|
62
|
+
*/
|
|
63
|
+
getTarget(out?: vec3): vec3;
|
|
64
|
+
/**
|
|
65
|
+
* Sets the up vector used when aiming (world space, by default (0, 1, 0)); a non-vertical up rolls the camera.
|
|
66
|
+
* Re-aims when a target is set. An up parallel to the view direction falls back to the world axis least aligned with it.
|
|
67
|
+
* @param up The up vector.
|
|
68
|
+
*/
|
|
69
|
+
setUp(up: vec3): void;
|
|
70
|
+
/**
|
|
71
|
+
* The up vector used when aiming.
|
|
72
|
+
* @param out Optional vector to write into.
|
|
73
|
+
*/
|
|
74
|
+
getUp(out?: vec3): vec3;
|
|
41
75
|
/**
|
|
42
76
|
* Update the camera.
|
|
43
77
|
* @param time - The game time object.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ICamera.d.ts","sourceRoot":"","sources":["../../../src/api/camera/ICamera.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"ICamera.d.ts","sourceRoot":"","sources":["../../../src/api/camera/ICamera.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,WAAW,CAAA;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAE3D,4BAA4B;AAC5B,MAAM,WAAW,OAAQ,SAAQ,YAAY,EAAE,WAAW;IAEtD;;OAEG;IACH,QAAQ,CAAC,gBAAgB,EAAE,IAAI,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,IAAI,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,oBAAoB,EAAE,IAAI,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,oBAAoB,EAAE,cAAc,CAAC;IAE9C;;OAEG;IACH,QAAQ,CAAC,gBAAgB,EAAE,cAAc,CAAC;IAE1C;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IAEpC;;;OAGG;IACH,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAExC;;;OAGG;IACH,aAAa,IAAI,IAAI,CAAC;IAEtB;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;IAExB;;;OAGG;IACH,MAAM,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAEzB;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;IAE9B;;;OAGG;IACH,SAAS,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAE5B;;;;OAIG;IACH,KAAK,CAAC,EAAE,EAAE,IAAI,GAAG,IAAI,CAAC;IAEtB;;;OAGG;IACH,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAExB;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;CAEhC"}
|
|
@@ -6,6 +6,7 @@ import type { ICamera } from "./ICamera.js";
|
|
|
6
6
|
import { GameTime } from "../time/GameTime.js";
|
|
7
7
|
import { MouseButton } from "../input/mouse/MouseButton.js";
|
|
8
8
|
import { InputDeviceType } from "../input/InputDeviceType.js";
|
|
9
|
+
import type { TransformNode } from "../scene/node/TransformNode.js";
|
|
9
10
|
/**
|
|
10
11
|
* Camerae that support orbit movement.
|
|
11
12
|
*/
|
|
@@ -22,6 +23,7 @@ export declare class OrbitCamera implements ICamera {
|
|
|
22
23
|
private readonly _coreCamera;
|
|
23
24
|
private readonly _inputManager;
|
|
24
25
|
/** The rotation around the vertical axis. */
|
|
26
|
+
private readonly _target;
|
|
25
27
|
private _yaw;
|
|
26
28
|
/** The tilt of the camera.*/
|
|
27
29
|
private _pitch;
|
|
@@ -41,7 +43,6 @@ export declare class OrbitCamera implements ICamera {
|
|
|
41
43
|
/** The speed of pinch.*/
|
|
42
44
|
pinchSpeed: number;
|
|
43
45
|
/** The up vector. */
|
|
44
|
-
up: vec3;
|
|
45
46
|
/** The clamp values of pitch axis */
|
|
46
47
|
pitchClamp: vec2;
|
|
47
48
|
/** @inheritDoc */
|
|
@@ -64,23 +65,30 @@ export declare class OrbitCamera implements ICamera {
|
|
|
64
65
|
get direction(): vec3;
|
|
65
66
|
/** Orbit controls can be used if this button is pressed. */
|
|
66
67
|
orbitButton: MouseButton;
|
|
68
|
+
/** The orbit camera's transform: the core camera's transform. Its position is the eye; the rotation is set each update to look at {@link target}. */
|
|
69
|
+
get transform(): TransformNode;
|
|
67
70
|
/**
|
|
68
|
-
*
|
|
71
|
+
* Sets the point the camera orbits around and looks at (the core camera's target). By default, the origin.
|
|
72
|
+
* @param target The world point.
|
|
69
73
|
*/
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
*/
|
|
74
|
-
set eye(value: vec3);
|
|
75
|
-
/**
|
|
76
|
-
* The eye position of the camera.
|
|
77
|
-
*/
|
|
78
|
-
get target(): vec3;
|
|
74
|
+
setTarget(target: vec3): void;
|
|
75
|
+
/** @inheritDoc */
|
|
76
|
+
getTarget(out?: vec3): vec3;
|
|
79
77
|
/**
|
|
80
|
-
*
|
|
78
|
+
* Moves the camera to a world position and re-derives the orbit (pitch, yaw, distance) around the target.
|
|
79
|
+
* @param eye The world position.
|
|
81
80
|
*/
|
|
82
|
-
|
|
83
|
-
/**
|
|
81
|
+
setEye(eye: vec3): void;
|
|
82
|
+
/** @inheritDoc */
|
|
83
|
+
getEye(out?: vec3): vec3;
|
|
84
|
+
/** Sets the up vector the core camera aims with (the orbit angles stay around world +Y, so this rolls the view). */
|
|
85
|
+
setUp(up: vec3): void;
|
|
86
|
+
/** @inheritDoc */
|
|
87
|
+
getUp(out?: vec3): vec3;
|
|
88
|
+
/** The eye: `transform.position` (world space). */
|
|
89
|
+
private get _eye();
|
|
90
|
+
/** Re-derives pitch and yaw from the eye and target, and aims the core camera at the target. */
|
|
91
|
+
private _syncFromTransform;
|
|
84
92
|
get coreCamera(): ICamera | undefined;
|
|
85
93
|
/**
|
|
86
94
|
* Find a target from yaw and pitch.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrbitCamera.d.ts","sourceRoot":"","sources":["../../../src/api/camera/OrbitCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAC,WAAW,EAAC,MAAM,+BAA+B,CAAC;AAG1D,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAE5D;;GAEG;AACH,qBAAa,WAAY,YAAW,OAAO;
|
|
1
|
+
{"version":3,"file":"OrbitCamera.d.ts","sourceRoot":"","sources":["../../../src/api/camera/OrbitCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAC,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC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,OAAO,CAAC,uBAAuB;IAsB/B;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IAOjC;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IA4EzB,wCAAwC;IACxC,OAAO,CAAC,mCAAmC;IA2D3C,kBAAkB;IACX,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAiCnC,kBAAkB;IACX,OAAO,IAAI,IAAI;CAGzB"}
|
|
@@ -3,16 +3,16 @@ import type { IFramework } from "../IFramework.js";
|
|
|
3
3
|
import { vec3, mat4 } from "gl-matrix";
|
|
4
4
|
import type { IUniformBuffer } from "../rendering/buffers/IUniformBuffer.js";
|
|
5
5
|
import { GameTime } from "../time/GameTime.js";
|
|
6
|
+
import { TransformNode } from "../scene/node/TransformNode.js";
|
|
6
7
|
/**
|
|
7
8
|
* The Orthographic Camera.
|
|
8
9
|
*/
|
|
9
10
|
export declare class OrthographicCamera implements IOrthographicCamera {
|
|
10
|
-
static UP_VECTOR: vec3;
|
|
11
11
|
private readonly _framework;
|
|
12
12
|
/** @ts-ignore */
|
|
13
13
|
private readonly _zSpaceLength;
|
|
14
|
-
private
|
|
15
|
-
private
|
|
14
|
+
private readonly _lastWorld;
|
|
15
|
+
private readonly _direction;
|
|
16
16
|
private _left;
|
|
17
17
|
private _right;
|
|
18
18
|
private _top;
|
|
@@ -23,9 +23,33 @@ export declare class OrthographicCamera implements IOrthographicCamera {
|
|
|
23
23
|
protected _projectionMatrix: mat4;
|
|
24
24
|
protected _viewMatrix: mat4;
|
|
25
25
|
protected _projectionViewMatrix: mat4;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The camera transform: the single source of the view. The camera looks down its local -Z axis;
|
|
28
|
+
* the view matrix is `inverse(T * R)` of `transform.modelMatrix` (scale is ignored).
|
|
29
|
+
* By default, at (0, 0, 1) looking down -Z at the origin.
|
|
30
|
+
*/
|
|
31
|
+
transform: TransformNode;
|
|
32
|
+
/** The unit direction the camera looks in, from the transform. */
|
|
33
|
+
get direction(): vec3;
|
|
34
|
+
private readonly _aim;
|
|
35
|
+
/**
|
|
36
|
+
* Rotates the transform once so the camera looks at a world point, using the current up ({@link getUp}).
|
|
37
|
+
* Forgets the target stored by {@link setTarget}, so a later {@link setEye} does not re-aim.
|
|
38
|
+
* @param target The point to look at.
|
|
39
|
+
*/
|
|
40
|
+
lookAt(target: vec3): void;
|
|
41
|
+
/** @inheritDoc */
|
|
42
|
+
setEye(eye: vec3): void;
|
|
43
|
+
/** @inheritDoc */
|
|
44
|
+
getEye(out?: vec3): vec3;
|
|
45
|
+
/** @inheritDoc */
|
|
46
|
+
setTarget(target: vec3): void;
|
|
47
|
+
/** @inheritDoc */
|
|
48
|
+
getTarget(out?: vec3): vec3;
|
|
49
|
+
/** @inheritDoc */
|
|
50
|
+
setUp(up: vec3): void;
|
|
51
|
+
/** @inheritDoc */
|
|
52
|
+
getUp(out?: vec3): vec3;
|
|
29
53
|
private _projectionBuffer;
|
|
30
54
|
private _viewBuffer;
|
|
31
55
|
private _projectionViewBuffer;
|
|
@@ -68,10 +92,6 @@ export declare class OrthographicCamera implements IOrthographicCamera {
|
|
|
68
92
|
/** @inheritDoc */
|
|
69
93
|
set farPlane(value: number);
|
|
70
94
|
/** @inheritDoc */
|
|
71
|
-
get eye(): vec3;
|
|
72
|
-
/** @inheritDoc */
|
|
73
|
-
set eye(value: vec3);
|
|
74
|
-
/** @inheritDoc */
|
|
75
95
|
get projectionMatrix(): mat4;
|
|
76
96
|
/** @inheritDoc */
|
|
77
97
|
get projectionViewMatrix(): mat4;
|
|
@@ -85,8 +105,10 @@ export declare class OrthographicCamera implements IOrthographicCamera {
|
|
|
85
105
|
get viewBuffer(): IUniformBuffer;
|
|
86
106
|
/** @inheritDoc */
|
|
87
107
|
get positionBuffer(): IUniformBuffer;
|
|
88
|
-
/** Writes the world
|
|
108
|
+
/** Writes the transform's world position into the std140 position data. */
|
|
89
109
|
private _updatePositionData;
|
|
110
|
+
/** True when the transform's world matrix changed since the view was last built. */
|
|
111
|
+
private _transformChanged;
|
|
90
112
|
/**
|
|
91
113
|
* Updates the camera matrices.
|
|
92
114
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrthographicCamera.d.ts","sourceRoot":"","sources":["../../../src/api/camera/OrthographicCamera.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAE7E,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"OrthographicCamera.d.ts","sourceRoot":"","sources":["../../../src/api/camera/OrthographicCamera.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAE7E,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAC,aAAa,EAAC,MAAM,gCAAgC,CAAC;AAG7D;;GAEG;AACH,qBAAa,kBAAmB,YAAW,mBAAmB;IAE1D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IAExC,iBAAiB;IACjB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAEvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqE;IAChG,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiB;IAE5C,OAAO,CAAC,KAAK,CAAS;IACtB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AkB;IACX,aAAa,IAAI,IAAI;IAQ5B,kBAAkB;IACX,MAAM,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI;IAShC,kBAAkB;IACX,OAAO,IAAI,IAAI;CAOzB"}
|
|
@@ -4,6 +4,7 @@ import type { IFramework } from "../IFramework.js";
|
|
|
4
4
|
import type { IUniformBuffer } from "../rendering/buffers/IUniformBuffer.js";
|
|
5
5
|
import { GameTime } from "../time/GameTime.js";
|
|
6
6
|
import type { Scene } from "../scene/Scene.js";
|
|
7
|
+
import { TransformNode } from "../scene/node/TransformNode.js";
|
|
7
8
|
/**
|
|
8
9
|
* The descriptor for a perspective camera. Every field is optional.
|
|
9
10
|
*/
|
|
@@ -16,11 +17,13 @@ export interface PerspectiveCameraDescriptor {
|
|
|
16
17
|
near?: number;
|
|
17
18
|
/** The far plane. By default, 100. */
|
|
18
19
|
far?: number;
|
|
19
|
-
/** The
|
|
20
|
+
/** The world position (see {@link ICamera.setEye}). By default, (0, 0, -3). */
|
|
21
|
+
position?: vec3;
|
|
22
|
+
/** Alias of {@link position}; `position` wins when both are given. */
|
|
20
23
|
eye?: vec3;
|
|
21
|
-
/** The point the camera looks at
|
|
24
|
+
/** The point the camera looks at (see {@link ICamera.setTarget}). By default, the origin. */
|
|
22
25
|
target?: vec3;
|
|
23
|
-
/** The up vector
|
|
26
|
+
/** The up vector used to aim (see {@link ICamera.setUp}). By default, (0, 1, 0). */
|
|
24
27
|
up?: vec3;
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
@@ -28,7 +31,8 @@ export interface PerspectiveCameraDescriptor {
|
|
|
28
31
|
*/
|
|
29
32
|
export declare class PerspectiveCamera implements ICamera {
|
|
30
33
|
protected readonly _framework: IFramework;
|
|
31
|
-
private readonly
|
|
34
|
+
private readonly _lastWorld;
|
|
35
|
+
private readonly _positionData;
|
|
32
36
|
private _projectionMatrix;
|
|
33
37
|
private _viewMatrix;
|
|
34
38
|
private _projectionViewMatrix;
|
|
@@ -78,19 +82,32 @@ export declare class PerspectiveCamera implements ICamera {
|
|
|
78
82
|
/** @inheritDoc */
|
|
79
83
|
get positionBuffer(): IUniformBuffer;
|
|
80
84
|
/**
|
|
81
|
-
* The
|
|
85
|
+
* The camera transform: the single source of the view. The camera looks down its local -Z axis;
|
|
86
|
+
* the view matrix is `inverse(T * R)` of `transform.modelMatrix` (scale is ignored).
|
|
87
|
+
* By default, at (0, 0, -3) looking at the origin.
|
|
82
88
|
*/
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
target: vec3;
|
|
89
|
+
transform: TransformNode;
|
|
90
|
+
/** The unit direction the camera looks in, from the transform. */
|
|
91
|
+
get direction(): vec3;
|
|
92
|
+
private readonly _aim;
|
|
88
93
|
/**
|
|
89
|
-
*
|
|
94
|
+
* Rotates the transform once so the camera looks at a world point, using the current up ({@link getUp}).
|
|
95
|
+
* Forgets the target stored by {@link setTarget}, so a later {@link setEye} does not re-aim.
|
|
96
|
+
* @param target The point to look at.
|
|
90
97
|
*/
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
|
|
98
|
+
lookAt(target: vec3): void;
|
|
99
|
+
/** @inheritDoc */
|
|
100
|
+
setEye(eye: vec3): void;
|
|
101
|
+
/** @inheritDoc */
|
|
102
|
+
getEye(out?: vec3): vec3;
|
|
103
|
+
/** @inheritDoc */
|
|
104
|
+
setTarget(target: vec3): void;
|
|
105
|
+
/** @inheritDoc */
|
|
106
|
+
getTarget(out?: vec3): vec3;
|
|
107
|
+
/** @inheritDoc */
|
|
108
|
+
setUp(up: vec3): void;
|
|
109
|
+
/** @inheritDoc */
|
|
110
|
+
getUp(out?: vec3): vec3;
|
|
94
111
|
/**
|
|
95
112
|
* The field of view of the camera.
|
|
96
113
|
*/
|
|
@@ -113,10 +130,7 @@ export declare class PerspectiveCamera implements ICamera {
|
|
|
113
130
|
* Initialize the camera.
|
|
114
131
|
*/
|
|
115
132
|
initialize(): void;
|
|
116
|
-
/**
|
|
117
|
-
* The eye in world space, as used by the view matrix: z is flipped for the right-handed look-at.
|
|
118
|
-
* This is what {@link positionBuffer} holds, std140 `vec3` (padded to 16 bytes).
|
|
119
|
-
*/
|
|
133
|
+
/** The world position, std140 `vec3` (padded to 16 bytes). This is what {@link positionBuffer} holds. */
|
|
120
134
|
private _worldEye;
|
|
121
135
|
/**
|
|
122
136
|
* Updates the camera matrices.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PerspectiveCamera.d.ts","sourceRoot":"","sources":["../../../src/api/camera/PerspectiveCamera.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"PerspectiveCamera.d.ts","sourceRoot":"","sources":["../../../src/api/camera/PerspectiveCamera.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAC7C,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAC,aAAa,EAAC,MAAM,gCAAgC,CAAC;AAG7D;;GAEG;AACH,MAAM,WAAW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,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAMnC,kBAAkB;IACX,aAAa,IAAI,IAAI;IAO5B,kBAAkB;IACX,OAAO,IAAI,IAAI;CAMzB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type IShaderModule, type IContentManager, type IShaderModuleLoader, type ITexture2D, type IFramework,
|
|
1
|
+
import { type IShaderModule, type IContentManager, type IShaderModuleLoader, type ITexture2D, type IFramework, type ITextureDescriptor, ContentConfig, type IMesh, type IRenderableMesh, type GeometryFormat, type ICamera } from "../index.js";
|
|
2
2
|
import type { IKtx2Texture } from "ris-ktx2";
|
|
3
3
|
/**
|
|
4
4
|
* The content manager.
|
|
@@ -27,7 +27,7 @@ export declare class ContentManager implements IContentManager {
|
|
|
27
27
|
[id: string]: number;
|
|
28
28
|
}): IShaderModule;
|
|
29
29
|
/** @inheritDoc */
|
|
30
|
-
loadTexture2DAsync(path: string, textureDescriptor?:
|
|
30
|
+
loadTexture2DAsync(path: string, textureDescriptor?: ITextureDescriptor, contentConfig?: ContentConfig): Promise<ITexture2D>;
|
|
31
31
|
/** @inheritDoc */
|
|
32
32
|
loadTexture2DFromPixels(width: number, height: number, pixels: ArrayBuffer): ITexture2D;
|
|
33
33
|
/** @inheritDoc */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentManager.d.ts","sourceRoot":"","sources":["../../../src/api/content/ContentManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContentManager.d.ts","sourceRoot":"","sources":["../../../src/api/content/ContentManager.ts"],"names":[],"mappings":"AACA,OAAO,EACH,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,kBAAkB,EAEvB,aAAa,EAEb,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,cAAc,EAEnB,KAAK,OAAO,EAEf,MAAM,aAAa,CAAC;AAKrB,OAAO,KA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