ris-framework 0.1.0-dev.9 → 0.2.0-dev.11
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 +49 -1
- package/README.md +15 -4
- package/dist/Framework.d.ts +9 -3
- package/dist/Framework.d.ts.map +1 -1
- package/dist/api/IFramework.d.ts +7 -6
- package/dist/api/IFramework.d.ts.map +1 -1
- package/dist/api/_export.d.ts +2 -0
- package/dist/api/_export.d.ts.map +1 -1
- package/dist/api/camera/CameraFactory.d.ts +3 -2
- package/dist/api/camera/CameraFactory.d.ts.map +1 -1
- package/dist/api/camera/ICamera.d.ts +5 -0
- package/dist/api/camera/ICamera.d.ts.map +1 -1
- package/dist/api/camera/ICameraFactory.d.ts +5 -6
- package/dist/api/camera/ICameraFactory.d.ts.map +1 -1
- package/dist/api/camera/OrthographicCamera.d.ts +7 -0
- package/dist/api/camera/OrthographicCamera.d.ts.map +1 -1
- package/dist/api/camera/PerspectiveCamera.d.ts +30 -6
- package/dist/api/camera/PerspectiveCamera.d.ts.map +1 -1
- package/dist/api/content/ContentManager.d.ts +67 -2
- package/dist/api/content/ContentManager.d.ts.map +1 -1
- package/dist/api/content/IContentManager.d.ts +32 -1
- package/dist/api/content/IContentManager.d.ts.map +1 -1
- package/dist/api/content/ShaderModuleContent.d.ts.map +1 -1
- package/dist/api/data/Color.d.ts +5 -0
- package/dist/api/data/Color.d.ts.map +1 -1
- package/dist/api/geometry/BaseGeometry.d.ts +9 -0
- package/dist/api/geometry/BaseGeometry.d.ts.map +1 -1
- package/dist/api/geometry/GeometryBuilder.d.ts +3 -1
- package/dist/api/geometry/GeometryBuilder.d.ts.map +1 -1
- package/dist/api/geometry/IGeometryBuilder.d.ts +24 -0
- package/dist/api/geometry/IGeometryBuilder.d.ts.map +1 -1
- package/dist/api/geometry/_export-geometry.d.ts +1 -0
- package/dist/api/geometry/_export-geometry.d.ts.map +1 -1
- package/dist/api/input/InputManager.d.ts +4 -0
- package/dist/api/input/InputManager.d.ts.map +1 -1
- package/dist/api/lights/AmbientLight.d.ts +35 -0
- package/dist/api/lights/AmbientLight.d.ts.map +1 -0
- package/dist/api/lights/DirectionalLight.d.ts +40 -0
- package/dist/api/lights/DirectionalLight.d.ts.map +1 -0
- package/dist/api/lights/LightFactory.d.ts +18 -0
- package/dist/api/lights/LightFactory.d.ts.map +1 -0
- package/dist/api/lights/LightId.d.ts +6 -0
- package/dist/api/lights/LightId.d.ts.map +1 -0
- package/dist/api/lights/LightsBuffer.d.ts +70 -0
- package/dist/api/lights/LightsBuffer.d.ts.map +1 -0
- package/dist/api/lights/PointLight.d.ts +59 -0
- package/dist/api/lights/PointLight.d.ts.map +1 -0
- package/dist/api/lights/_export.d.ts +6 -0
- package/dist/api/lights/_export.d.ts.map +1 -0
- package/dist/api/loaders/ObjGeometryMapper.d.ts +19 -0
- package/dist/api/loaders/ObjGeometryMapper.d.ts.map +1 -0
- package/dist/api/loaders/_export.d.ts +1 -0
- package/dist/api/loaders/_export.d.ts.map +1 -1
- package/dist/api/loaders/obj/ObjLoader.d.ts +29 -0
- package/dist/api/loaders/obj/ObjLoader.d.ts.map +1 -0
- package/dist/api/loaders/obj/ObjTypes.d.ts +103 -0
- package/dist/api/loaders/obj/ObjTypes.d.ts.map +1 -0
- package/dist/api/loaders/obj/index.d.ts +3 -0
- package/dist/api/loaders/obj/index.d.ts.map +1 -0
- package/dist/api/material/ForwardBlinnPhongMaterial.d.ts +127 -0
- package/dist/api/material/ForwardBlinnPhongMaterial.d.ts.map +1 -0
- package/dist/api/material/IMaterial.d.ts +15 -6
- package/dist/api/material/IMaterial.d.ts.map +1 -1
- package/dist/api/material/IMaterialFactory.d.ts +17 -2
- package/dist/api/material/IMaterialFactory.d.ts.map +1 -1
- package/dist/api/material/InspectTextureMipsMaterial.d.ts +16 -7
- package/dist/api/material/InspectTextureMipsMaterial.d.ts.map +1 -1
- package/dist/api/material/MaterialFactory.d.ts +6 -0
- package/dist/api/material/MaterialFactory.d.ts.map +1 -1
- package/dist/api/material/SpriteMaterial.d.ts +51 -0
- package/dist/api/material/SpriteMaterial.d.ts.map +1 -0
- package/dist/api/material/UnlitMaterial.d.ts +28 -10
- package/dist/api/material/UnlitMaterial.d.ts.map +1 -1
- package/dist/api/material/_export.d.ts +2 -0
- package/dist/api/material/_export.d.ts.map +1 -1
- package/dist/api/meshes/IMesh.d.ts +35 -5
- package/dist/api/meshes/IMesh.d.ts.map +1 -1
- package/dist/api/meshes/IMeshFactory.d.ts +25 -4
- package/dist/api/meshes/IMeshFactory.d.ts.map +1 -1
- package/dist/api/meshes/Mesh.d.ts +58 -6
- package/dist/api/meshes/Mesh.d.ts.map +1 -1
- package/dist/api/meshes/MeshFactory.d.ts +7 -3
- package/dist/api/meshes/MeshFactory.d.ts.map +1 -1
- package/dist/api/meshes/QuadMesh.d.ts +5 -1
- package/dist/api/meshes/QuadMesh.d.ts.map +1 -1
- package/dist/api/meshes/SubMesh.d.ts +47 -0
- package/dist/api/meshes/SubMesh.d.ts.map +1 -0
- package/dist/api/meshes/_export.d.ts +1 -0
- package/dist/api/meshes/_export.d.ts.map +1 -1
- package/dist/api/rendering/render-pipelines/IForwardBlinnPhongRenderPipeline.d.ts +56 -0
- package/dist/api/rendering/render-pipelines/IForwardBlinnPhongRenderPipeline.d.ts.map +1 -0
- package/dist/api/rendering/render-pipelines/IRenderPipeline.d.ts +3 -0
- package/dist/api/rendering/render-pipelines/IRenderPipeline.d.ts.map +1 -1
- package/dist/api/rendering/render-pipelines/IRenderPipelineFactory.d.ts +29 -0
- package/dist/api/rendering/render-pipelines/IRenderPipelineFactory.d.ts.map +1 -1
- package/dist/api/rendering/render-pipelines/_export-render-pipelines.d.ts +1 -0
- package/dist/api/rendering/render-pipelines/_export-render-pipelines.d.ts.map +1 -1
- package/dist/api/scene/Scene.d.ts +104 -0
- package/dist/api/scene/Scene.d.ts.map +1 -0
- package/dist/api/shader/IShaderModuleLoader.d.ts +4 -1
- package/dist/api/shader/IShaderModuleLoader.d.ts.map +1 -1
- package/dist/api/shader/{shader-loader.d.ts → ShaderLoader.d.ts} +1 -1
- package/dist/api/shader/ShaderLoader.d.ts.map +1 -0
- package/dist/api/sprites/SpriteBatchDrawable.d.ts +1 -1
- package/dist/api/sprites/SpriteBatchDrawable.d.ts.map +1 -1
- package/dist/api/sprites/SpriteBatchMesh.d.ts +14 -1
- package/dist/api/sprites/SpriteBatchMesh.d.ts.map +1 -1
- package/dist/api/utilities/GeometryUtilities.d.ts.map +1 -1
- package/dist/api/window/WindowManager.d.ts +4 -0
- package/dist/api/window/WindowManager.d.ts.map +1 -1
- package/dist/core/rendering/vertex-buffer-layout.d.ts +1 -0
- package/dist/core/rendering/vertex-buffer-layout.d.ts.map +1 -1
- package/dist/index.js +2252 -260
- package/dist/webgl/WebGlGraphicsDevice.d.ts.map +1 -1
- package/dist/webgl/lights/WebGlAmbientLightFactory.d.ts +17 -0
- package/dist/webgl/lights/WebGlAmbientLightFactory.d.ts.map +1 -0
- package/dist/webgl/lights/WebGlLightsBuffer.d.ts +55 -0
- package/dist/webgl/lights/WebGlLightsBuffer.d.ts.map +1 -0
- package/dist/webgl/render-pipelines/AWebGlRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/AWebGlRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts +3 -0
- package/dist/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/WebGlRenderPipelineFactory.d.ts +3 -1
- package/dist/webgl/render-pipelines/WebGlRenderPipelineFactory.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/inspect/WebGlInspectTextureMipsRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/inspect/WebGlInspectTextureMipsRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/material/WebGlBlinnPhongRenderPipeline.d.ts +88 -0
- package/dist/webgl/render-pipelines/material/WebGlBlinnPhongRenderPipeline.d.ts.map +1 -0
- package/dist/webgl/render-pipelines/material/WebGlUnlitRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/material/WebGlUnlitRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/render-pipelines/sprite/WebGlSpriteRenderPipeline.d.ts +3 -1
- package/dist/webgl/render-pipelines/sprite/WebGlSpriteRenderPipeline.d.ts.map +1 -1
- package/dist/webgl/shader/WebGlShaderModule.d.ts +4 -1
- package/dist/webgl/shader/WebGlShaderModule.d.ts.map +1 -1
- package/dist/webgl/shader/WebGlShaderModuleLoader.d.ts +16 -5
- package/dist/webgl/shader/WebGlShaderModuleLoader.d.ts.map +1 -1
- package/dist/webgl/texture/WebGlTexture2D.d.ts +8 -1
- package/dist/webgl/texture/WebGlTexture2D.d.ts.map +1 -1
- package/dist/webgl/utilities/webgl-filter-anisotropic-utilities.d.ts +0 -1
- package/dist/webgl/utilities/webgl-filter-anisotropic-utilities.d.ts.map +1 -1
- package/package.json +4 -4
- package/shaders/glsl/forward_blinn_phong_material_fs.glsl +110 -0
- package/shaders/glsl/forward_blinn_phong_material_vs.glsl +32 -0
- package/shaders/glsl/sprite_fs.glsl +1 -1
- package/shaders/glsl/unlit_material_fs.glsl +1 -1
- package/src/Framework.ts +37 -13
- package/src/api/IFramework.ts +8 -6
- package/src/api/_export.ts +2 -0
- package/src/api/camera/CameraFactory.ts +6 -6
- package/src/api/camera/ICamera.ts +6 -0
- package/src/api/camera/ICameraFactory.ts +5 -10
- package/src/api/camera/OrthographicCamera.ts +23 -1
- package/src/api/camera/PerspectiveCamera.ts +60 -15
- package/src/api/content/ContentManager.ts +201 -5
- package/src/api/content/IContentManager.ts +33 -1
- package/src/api/content/ShaderModuleContent.ts +9 -0
- package/src/api/data/Color.ts +7 -1
- package/src/api/geometry/BaseGeometry.ts +23 -0
- package/src/api/geometry/GeometryBuilder.ts +14 -2
- package/src/api/geometry/IGeometryBuilder.ts +31 -1
- package/src/api/geometry/_export-geometry.ts +2 -1
- package/src/api/input/InputManager.ts +14 -5
- package/src/api/lights/AmbientLight.ts +53 -0
- package/src/api/lights/DirectionalLight.ts +60 -0
- package/src/api/lights/LightFactory.ts +21 -0
- package/src/api/lights/LightId.ts +9 -0
- package/src/api/lights/LightsBuffer.ts +87 -0
- package/src/api/lights/PointLight.ts +91 -0
- package/src/api/lights/_export.ts +5 -0
- package/src/api/loaders/ObjGeometryMapper.ts +28 -0
- package/src/api/loaders/_export.ts +2 -1
- package/src/api/loaders/obj/ObjLoader.ts +270 -0
- package/src/api/loaders/obj/ObjTypes.ts +124 -0
- package/src/api/loaders/obj/index.ts +5 -0
- package/src/api/material/ForwardBlinnPhongMaterial.ts +302 -0
- package/src/api/material/IMaterial.ts +16 -6
- package/src/api/material/IMaterialFactory.ts +19 -2
- package/src/api/material/InspectTextureMipsMaterial.ts +63 -24
- package/src/api/material/MaterialFactory.ts +12 -0
- package/src/api/material/SpriteMaterial.ts +83 -0
- package/src/api/material/UnlitMaterial.ts +101 -29
- package/src/api/material/_export.ts +3 -1
- package/src/api/meshes/IMesh.ts +45 -6
- package/src/api/meshes/IMeshFactory.ts +27 -4
- package/src/api/meshes/Mesh.ts +163 -41
- package/src/api/meshes/MeshFactory.ts +30 -6
- package/src/api/meshes/QuadMesh.ts +6 -2
- package/src/api/meshes/SubMesh.ts +71 -0
- package/src/api/meshes/_export.ts +1 -0
- package/src/api/rendering/render-pipelines/IForwardBlinnPhongRenderPipeline.ts +66 -0
- package/src/api/rendering/render-pipelines/IRenderPipeline.ts +4 -0
- package/src/api/rendering/render-pipelines/IRenderPipelineFactory.ts +39 -0
- package/src/api/rendering/render-pipelines/_export-render-pipelines.ts +2 -1
- package/src/api/scene/Scene.ts +264 -0
- package/src/api/shader/IShaderModuleLoader.ts +2 -1
- package/src/api/sprites/SpriteBatchDrawable.ts +12 -16
- package/src/api/sprites/SpriteBatchMesh.ts +23 -4
- package/src/api/utilities/GeometryUtilities.ts +2 -0
- package/src/api/window/WindowManager.ts +22 -2
- package/src/core/rendering/vertex-buffer-layout.ts +32 -1
- package/src/main.ts +0 -1
- package/src/webgl/WebGlGraphicsDevice.ts +0 -1
- package/src/webgl/lights/WebGlAmbientLightFactory.ts +35 -0
- package/src/webgl/lights/WebGlLightsBuffer.ts +215 -0
- package/src/webgl/render-pipelines/AWebGlRenderPipeline.ts +7 -1
- package/src/webgl/render-pipelines/WebGlMainRenderTargetRenderPipeline.ts +3 -0
- package/src/webgl/render-pipelines/WebGlRenderPipelineFactory.ts +24 -2
- package/src/webgl/render-pipelines/inspect/WebGlInspectTextureMipsRenderPipeline.ts +16 -6
- package/src/webgl/render-pipelines/material/WebGlBlinnPhongRenderPipeline.ts +300 -0
- package/src/webgl/render-pipelines/material/WebGlUnlitRenderPipeline.ts +16 -6
- package/src/webgl/render-pipelines/sprite/WebGlSpriteRenderPipeline.ts +11 -7
- package/src/webgl/shader/WebGlShaderModule.ts +11 -4
- package/src/webgl/shader/WebGlShaderModuleLoader.ts +29 -10
- package/src/webgl/texture/WebGlTexture2D.ts +19 -5
- package/src/webgl/utilities/webgl-filter-anisotropic-utilities.ts +9 -6
- package/dist/api/shader/shader-loader.d.ts.map +0 -1
- /package/src/api/shader/{shader-loader.ts → ShaderLoader.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
|
+
|
|
6
|
+
## [0.2.0] - Unreleased
|
|
7
|
+
|
|
8
|
+
Compared with `main` (0.1.0).
|
|
9
|
+
|
|
10
|
+
### Breaking changes
|
|
11
|
+
|
|
12
|
+
- **tsyringe and reflect-metadata removed.** Services are created by `Framework` and get their dependencies through constructors. Consumers no longer need `reflect-metadata` or decorator settings.
|
|
13
|
+
- **Perspective camera.** `cameraFactory.createPerspectiveCamera(descriptor?, scene?)` takes a `PerspectiveCameraDescriptor` (`fov` in degrees, `aspectRatio`, `near`, `far`, `eye`, `target`, `up`) instead of `(fov, aspectRatio, near, far)`. The `PerspectiveCamera` constructor is `(framework, descriptor?, scene?)` instead of `(framework, fov, aspectRatio, nearPlane, farPlane)`.
|
|
14
|
+
- **`ICamera.positionBuffer`.** This new member is required (std140 world-space eye). Custom `ICamera` implementations must provide it. `PerspectiveCamera`, `OrthographicCamera` and `OrbitCamera` implement it.
|
|
15
|
+
- **Meshes.** `meshFactory.create(scene, geometry, material)` replaces `create(geometry, geometryFormat)`. The `Mesh` constructor is `(framework, scene, material?)` instead of `(framework)`. The `QuadMesh` constructor is `(framework, scene, material, isUpdatable, scale?)`.
|
|
16
|
+
- **Materials.** `IMaterial.modelMatrix` is replaced by `IMaterial.modelBuffer`. The mesh owns the model buffer and assigns it before drawing. `UnlitMaterial` and `InspectTextureMipsMaterial` no longer create their own model buffer. They create their render pipeline once a model buffer is assigned, and rendering without one throws.
|
|
17
|
+
- **Render pipelines.** `createUnlitRenderPipeline` and `createInspectTextureMipsRenderPipeline` throw when no model buffer is passed.
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- `Scene` holds meshes, lights and the active camera. `scene.add(item)` and `scene.remove(item)` accept a mesh, `AmbientLight`, `DirectionalLight`, `PointLight` or camera. Adding the same item twice does nothing. Meshes, lights and the perspective camera given a scene in their constructor add themselves, and a disposed mesh removes itself. Removing the active camera clears `scene.camera`. `scene.update(time)` assigns the camera to materials and uploads changed lights. `scene.render()` draws every mesh.
|
|
22
|
+
- Lights: `AmbientLight`, `DirectionalLight` and `PointLight` (constant, linear and quadratic attenuation) are plain data classes with descriptors, `intensity`, auto-assigned ids and an optional `scene` constructor argument. `LightsBuffer` is a std140 lights buffer with configurable directional and point light slots, and it uploads only when light data changed. `framework.lightsFactory` creates them.
|
|
23
|
+
- `ForwardBlinnPhongMaterial` with ambient, diffuse and Blinn-Phong specular lighting from directional and point lights. Normals use the normal matrix, so non-uniform scale is handled. Specular colour and shininess come from MTL `Ks` and `Ns`, and shader variants are cached per light count. Its descriptor requires `projectionViewBuffer` and `cameraPositionBuffer`, and `materialFactory.createForwardBlinnPhongMaterial(descriptor)` creates it.
|
|
24
|
+
- Mesh transforms: `mesh.position`, `mesh.rotation` (Euler radians, applied Y, then X, then Z), `mesh.scale` and a lazily computed `mesh.modelMatrix` / `mesh.modelBuffer`. Submeshes use their parent's transform.
|
|
25
|
+
- Submeshes: one mesh can draw several index ranges, each with its own material (`mesh.addSubMesh`, `meshFactory.createWithSubMeshes`).
|
|
26
|
+
- OBJ/MTL loading:
|
|
27
|
+
- `ObjLoader` is framework-independent and produces plain definitions. `ObjLoader.loadAsync(path, options)` supports `resolveMaterialUrl` and `ignoreMaterials`.
|
|
28
|
+
- `content.loadMeshAsync(path, scene)` loads a mesh with unlit materials, and `content.loadBlinnPhongMeshAsync(path, scene)` loads one with Blinn-Phong materials.
|
|
29
|
+
- `geometryBuilder.create(descriptor)` with `GeometryDescriptor`. `BaseGeometry` is exported.
|
|
30
|
+
- `SpriteMaterial` and `materialFactory.createSpriteMaterial`; sprite batches draw through it.
|
|
31
|
+
- `UnlitMaterialDescriptor.camera` and a `camera` property on the unlit and Blinn-Phong materials. A scene assigns its camera through this property.
|
|
32
|
+
- Examples: `unlit_mesh`, `blinn_phong_mesh` and `sprite_batch`, with `npm run dev:examples` and `npm run build:examples`.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- `content.loadShaderModule(id, replacements?)` takes optional `##KEY##` replacement values, and they are part of the shader cache key.
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
|
|
40
|
+
- The sprite fragment shader added `vec4(1.0)` to every pixel, so sprites rendered white.
|
|
41
|
+
- The orthographic camera's default eye was at z = -1 instead of z = 1.
|
|
42
|
+
- The default texture was a static shared by every `Framework` instance, so a second framework (a new GL context) reused a texture from the old one. It is now per framework.
|
|
43
|
+
- The anisotropic filtering helper cached the extension object from the first GL context on a shared static. It is now looked up per context.
|
|
44
|
+
- A leftover `debugger` statement in `WebGlGraphicsDevice` initialization is removed.
|
|
45
|
+
|
|
46
|
+
### Removed
|
|
47
|
+
|
|
48
|
+
- The `tsyringe` and `reflect-metadata` dependencies.
|
|
49
|
+
- `IMaterial.modelMatrix`, replaced by `modelBuffer` (see Breaking changes).
|
|
50
|
+
|
|
51
|
+
## [0.1.0]
|
|
4
52
|
|
|
5
53
|
- Initial release setup. `development` publishes a prerelease on the npm `next` tag. `main` publishes this version on `latest`.
|
|
6
54
|
- 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
|
@@ -18,7 +18,7 @@ Open `index.html`. The module script is `src/main.ts`. That file builds the page
|
|
|
18
18
|
| `shaders/glsl` | Vertex and fragment shaders used by the built-in shader modules. |
|
|
19
19
|
| `tests` | Vitest tests for the types under `src/api`. |
|
|
20
20
|
|
|
21
|
-
Runtime dependencies are `ris-ktx2
|
|
21
|
+
Runtime dependencies are `ris-ktx2` and `gl-matrix`. The KTX2 types (`IKtx2Texture`, `VkFormat`, `KtxTranscodeFormat`, and the rest) are imported from `ris-ktx2`. The library build includes the browser portion of `ris-ktx2`, with its Node loader replaced by a stub, so the published entry does not import Node built-ins. TypeScript, Vite, and Vitest are dev dependencies. Notices for the bundled KTX loader are in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). The package license is Apache License 2.0. Copyright 2026 Luka Erkapic. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
|
|
22
22
|
|
|
23
23
|
## Prerequisites
|
|
24
24
|
|
|
@@ -54,7 +54,7 @@ To work in this repository:
|
|
|
54
54
|
npm ci
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
`Framework` creates its services itself and passes dependencies through their constructors; no dependency-injection container or `reflect-metadata` import is needed.
|
|
58
58
|
|
|
59
59
|
## Create a framework instance
|
|
60
60
|
|
|
@@ -76,8 +76,6 @@ No config field is required. Each field has a default.
|
|
|
76
76
|
Every field is optional on `IFrameworkConfiguration`. A new `FrameworkConfiguration` sets `useKtx2`, `textureFiltering`, `alpha`, and `powerPreference`. `canvas` and `backBufferSize` start unset.
|
|
77
77
|
|
|
78
78
|
```ts
|
|
79
|
-
import "reflect-metadata";
|
|
80
|
-
|
|
81
79
|
import { Framework, FrameworkConfiguration, TextureSamplerFilteringPreset } from "ris-framework";
|
|
82
80
|
|
|
83
81
|
const config = new FrameworkConfiguration();
|
|
@@ -168,6 +166,19 @@ The first `begin` / `drawRect` / `end` runs inside `initialize()`, before the te
|
|
|
168
166
|
|
|
169
167
|
Setting `framework.renderer.clearColor` after `initialize()` updates later frames. The first frame has already cleared with the default light pink.
|
|
170
168
|
|
|
169
|
+
## Scene
|
|
170
|
+
|
|
171
|
+
`new Scene(framework)` holds meshes, lights and the camera. `scene.add(item)` and `scene.remove(item)` accept a mesh, an `AmbientLight`, `DirectionalLight`, `PointLight` or a camera; adding twice does nothing. Meshes, lights and the perspective camera given a scene in their constructor add themselves, and a disposed mesh removes itself. Adding a camera makes it `scene.camera`; removing the active camera clears it. `addLight`/`removeLight` remain as deprecated aliases.
|
|
172
|
+
|
|
173
|
+
## Examples
|
|
174
|
+
|
|
175
|
+
Browser examples live in [`examples/`](examples/), one folder per example. See [`examples/README.md`](examples/README.md).
|
|
176
|
+
|
|
177
|
+
```sh
|
|
178
|
+
npm run dev:examples # serve the examples index, e.g. /sprite_batch/
|
|
179
|
+
npm run build:examples # build every example into examples/dist/
|
|
180
|
+
```
|
|
181
|
+
|
|
171
182
|
## What is still unfinished
|
|
172
183
|
|
|
173
184
|
These throw, or they accept a call and do not do the work the name suggests:
|
package/dist/Framework.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { type ICameraFactory, type IContentManager, type IFramework, IFrameworkConfiguration, type IImageLoader, type IRenderer, type IRenderPipelineFactory, type IWindowManager } from "./api/index.js";
|
|
2
|
-
import { GameTime, type IBufferFactory, type IGeometryBuilder, type IGraphicsDevice, type IImageProcessor, type IInputManager, type IMaterialFactory, type IMeshFactory, type ISpriteBatch, type ITextureFactory, type ITimeManager, RenderingBackend } from "./api/index.js";
|
|
2
|
+
import { GameTime, type IBufferFactory, type IGeometryBuilder, type IGraphicsDevice, type IImageProcessor, type IInputManager, type IMaterialFactory, type AmbientLightFactory, type IMeshFactory, type ISpriteBatch, type ITextureFactory, type ITimeManager, RenderingBackend } from "./api/index.js";
|
|
3
3
|
import type { IKtx2Factory } from "ris-ktx2";
|
|
4
4
|
export declare class Framework implements IFramework {
|
|
5
5
|
private readonly _onLoadContentListeners;
|
|
6
6
|
private readonly _onInitializeListeners;
|
|
7
7
|
private readonly _onUpdateListeners;
|
|
8
8
|
private readonly _onRenderListeners;
|
|
9
|
-
private readonly _container;
|
|
10
9
|
private readonly _textureFactory;
|
|
11
10
|
private readonly _buffersFactory;
|
|
12
11
|
private readonly _contentManager;
|
|
13
12
|
private readonly _geometryBuilder;
|
|
14
13
|
private readonly _meshFactory;
|
|
14
|
+
private _disposed;
|
|
15
15
|
/**
|
|
16
16
|
* The constructor for the Framework class.
|
|
17
17
|
* @param options The optional framework configuration. When omitted, a default `FrameworkConfiguration` is used.
|
|
@@ -70,12 +70,18 @@ export declare class Framework implements IFramework {
|
|
|
70
70
|
/** @inheritDoc */
|
|
71
71
|
readonly materialFactory: IMaterialFactory;
|
|
72
72
|
/** @inheritDoc */
|
|
73
|
+
readonly lightsFactory: AmbientLightFactory;
|
|
74
|
+
/** @inheritDoc */
|
|
73
75
|
readonly timeManager: ITimeManager;
|
|
74
76
|
/** @inheritDoc */
|
|
75
77
|
readonly input: IInputManager;
|
|
76
78
|
/** @inheritdoc */
|
|
77
79
|
initialize(): void;
|
|
78
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Stops the event loop and disposes the framework's services and GL resources,
|
|
82
|
+
* including per-framework caches such as the default texture and the shader modules.
|
|
83
|
+
* A new `Framework` afterwards creates fresh resources on its own context. Calling it twice does nothing.
|
|
84
|
+
*/
|
|
79
85
|
dispose(): void;
|
|
80
86
|
}
|
|
81
87
|
//# sourceMappingURL=Framework.d.ts.map
|
package/dist/Framework.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Framework.d.ts","sourceRoot":"","sources":["../src/Framework.ts"],"names":[],"mappings":"AAQA,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,UAAU,EAAE,uBAAuB,EACxC,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAGH,QAAQ,EACR,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,aAAa,EAElB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,YAAY,EAGjB,gBAAgB,EAEnB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Framework.d.ts","sourceRoot":"","sources":["../src/Framework.ts"],"names":[],"mappings":"AAQA,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,UAAU,EAAE,uBAAuB,EACxC,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAGH,QAAQ,EACR,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,aAAa,EAElB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAC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content/IContentManager.js";
|
|
|
11
11
|
import type { IImageLoader } from "./loaders/IImageLoader.js";
|
|
12
12
|
import type { IMeshFactory } from "./meshes/IMeshFactory.js";
|
|
13
13
|
import type { IMaterialFactory } from "./material/IMaterialFactory.js";
|
|
14
|
+
import type { AmbientLightFactory } from "./lights/LightFactory.js";
|
|
14
15
|
import type { ITimeManager } from "./time/ITimeManager.js";
|
|
15
16
|
import type { IInputManager } from "./input/IInputManager.js";
|
|
16
17
|
import type { IWindowManager } from "./window/IWindowManager.js";
|
|
@@ -75,6 +76,10 @@ export interface IFramework extends IDisposable {
|
|
|
75
76
|
* The material factory.
|
|
76
77
|
*/
|
|
77
78
|
readonly materialFactory: IMaterialFactory;
|
|
79
|
+
/**
|
|
80
|
+
* The ambient light factory.
|
|
81
|
+
*/
|
|
82
|
+
readonly lightsFactory: AmbientLightFactory;
|
|
78
83
|
/**
|
|
79
84
|
* The time manager.
|
|
80
85
|
*/
|
|
@@ -95,13 +100,9 @@ export interface IFramework extends IDisposable {
|
|
|
95
100
|
* Content can be loaded here.
|
|
96
101
|
*/
|
|
97
102
|
removeOnLoadContentListener(event: () => void): void;
|
|
98
|
-
/**
|
|
99
|
-
* Called when the framework is initialized.
|
|
100
|
-
*/
|
|
103
|
+
/** Called when the framework is initialized.*/
|
|
101
104
|
addOnInitializedListener(event: () => void): void;
|
|
102
|
-
/**
|
|
103
|
-
* Called when the framework is initialized.
|
|
104
|
-
*/
|
|
105
|
+
/** Called when the framework is initialized.*/
|
|
105
106
|
removeOnInitializedListener(event: () => void): void;
|
|
106
107
|
/**
|
|
107
108
|
* Called when framework is updated.
|
|
@@ -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,KAA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K,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;CAEtB"}
|
package/dist/api/_export.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export * from "./rendering/sampler/_export.js";
|
|
|
22
22
|
export * from "./utilities/_export.js";
|
|
23
23
|
export * from "./meshes/_export.js";
|
|
24
24
|
export * from "./material/_export.js";
|
|
25
|
+
export * from "./lights/_export.js";
|
|
26
|
+
export * from "./scene/Scene.js";
|
|
25
27
|
export * from "./input/_export.js";
|
|
26
28
|
export * from "./image/_export.js";
|
|
27
29
|
//# 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,8BAA8B,CAAC;AAC7C,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC;AACvD,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,0DAA0D,CAAC;AACzE,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAA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}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { vec2 } from "gl-matrix";
|
|
2
2
|
import type { ICameraFactory } from "./ICameraFactory.js";
|
|
3
|
+
import type { Scene } from "../scene/Scene.js";
|
|
3
4
|
import type { IFramework } from "../IFramework.js";
|
|
4
5
|
import type { IOrthographicCamera } from "./IOrthographicCamera.js";
|
|
5
6
|
import { OrbitCamera } from "./OrbitCamera.js";
|
|
6
|
-
import { PerspectiveCamera } from "./PerspectiveCamera.js";
|
|
7
|
+
import { PerspectiveCamera, type PerspectiveCameraDescriptor } from "./PerspectiveCamera.js";
|
|
7
8
|
/** The Camera Factory */
|
|
8
9
|
export declare class CameraFactory implements ICameraFactory {
|
|
9
10
|
private readonly _framework;
|
|
@@ -20,6 +21,6 @@ export declare class CameraFactory implements ICameraFactory {
|
|
|
20
21
|
/** @inheritDoc */
|
|
21
22
|
createOrbitCamera(fov?: number, aspectRatio?: number, near?: number, far?: number): OrbitCamera;
|
|
22
23
|
/** @inheritDoc */
|
|
23
|
-
createPerspectiveCamera(
|
|
24
|
+
createPerspectiveCamera(descriptor?: PerspectiveCameraDescriptor, scene?: Scene): PerspectiveCamera;
|
|
24
25
|
}
|
|
25
26
|
//# sourceMappingURL=CameraFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CameraFactory.d.ts","sourceRoot":"","sources":["../../../src/api/camera/CameraFactory.ts"],"names":[],"mappings":"AAAA,OAAQ,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"CameraFactory.d.ts","sourceRoot":"","sources":["../../../src/api/camera/CameraFactory.ts"],"names":[],"mappings":"AAAA,OAAQ,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAC,iBAAiB,EAAE,KAAK,2BAA2B,EAAC,MAAM,wBAAwB,CAAC;AAE3F,yBAAyB;AACzB,qBAAa,aAAc,YAAW,cAAc;IAQ7B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAN9C,MAAM,CAAC,cAAc,OAAwB;IAE7C;;;OAGG;gBACiC,UAAU,EAAE,UAAU;IAE1D,kBAAkB;IACX,+BAA+B,CAAC,MAAM,CAAC,EAAE,IAAI,GAAG,mBAAmB;IAa1E,kBAAkB;IACX,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,mBAAmB;IAMzI,kBAAkB;IACX,iBAAiB,CAAC,GAAG,SAAK,EAAE,WAAW,SAAI,EAAE,IAAI,SAAO,EAAE,GAAG,SAAM,GAAG,WAAW;IAKxF,kBAAkB;IACX,uBAAuB,CAAC,UAAU,CAAC,EAAE,2BAA2B,EAAE,KAAK,CAAC,EAAG,KAAK,GAAG,iBAAiB;CAO9G"}
|
|
@@ -28,6 +28,11 @@ export interface ICamera extends IDisposable {
|
|
|
28
28
|
* The view buffer.
|
|
29
29
|
*/
|
|
30
30
|
readonly viewBuffer: IUniformBuffer;
|
|
31
|
+
/**
|
|
32
|
+
* The world-space eye position buffer, std140 `vec3` (`[x, y, z, 0]`).
|
|
33
|
+
* Used by lit materials for specular highlights.
|
|
34
|
+
*/
|
|
35
|
+
readonly positionBuffer: IUniformBuffer;
|
|
31
36
|
/**
|
|
32
37
|
* Update the GPU buffers.
|
|
33
38
|
* This needs to be called when camera properties are changed.
|
|
@@ -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;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAE7C,4BAA4B;AAC5B,MAAM,WAAW,OAAQ,SAAQ,WAAW;IAExC;;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,aAAa,IAAI,IAAI,CAAC;IAEtB;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;CAEhC"}
|
|
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;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAC,QAAQ,EAAC,MAAM,qBAAqB,CAAC;AAE7C,4BAA4B;AAC5B,MAAM,WAAW,OAAQ,SAAQ,WAAW;IAExC;;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;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;CAEhC"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import type { IOrthographicCamera } from "./IOrthographicCamera.js";
|
|
2
2
|
import { vec2 } from "gl-matrix";
|
|
3
3
|
import { OrbitCamera } from "./OrbitCamera.js";
|
|
4
|
-
import { PerspectiveCamera } from "./PerspectiveCamera.js";
|
|
4
|
+
import { PerspectiveCamera, type PerspectiveCameraDescriptor } from "./PerspectiveCamera.js";
|
|
5
|
+
import type { Scene } from "../scene/Scene.js";
|
|
5
6
|
/**
|
|
6
7
|
* The camera factory.
|
|
7
8
|
*/
|
|
8
9
|
export interface ICameraFactory {
|
|
9
10
|
/**
|
|
10
11
|
* Creates a new perspective camera.
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
13
|
-
* @param near The near plane. By default, 0.01.
|
|
14
|
-
* @param far The far plane. By default, 100.
|
|
12
|
+
* @param descriptor The optional descriptor; omitted fields use the defaults documented on {@link PerspectiveCameraDescriptor}.
|
|
13
|
+
* @param scene The optional scene; the camera becomes its `scene.camera`.
|
|
15
14
|
* @return The perspective camera.
|
|
16
15
|
*/
|
|
17
|
-
createPerspectiveCamera(
|
|
16
|
+
createPerspectiveCamera(descriptor?: PerspectiveCameraDescriptor, scene?: Scene): PerspectiveCamera;
|
|
18
17
|
/**
|
|
19
18
|
* Creates a new orthographic camera which is suitable for 2D games, or for UI rendering.
|
|
20
19
|
* Also, suitable when orthographic projection is required, such as shadow mapping.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ICameraFactory.d.ts","sourceRoot":"","sources":["../../../src/api/camera/ICameraFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAC,iBAAiB,EAAC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"ICameraFactory.d.ts","sourceRoot":"","sources":["../../../src/api/camera/ICameraFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAC/B,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAC,iBAAiB,EAAE,KAAK,2BAA2B,EAAC,MAAM,wBAAwB,CAAC;AAC3F,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,cAAc;IAE3B;;;;;OAKG;IACH,uBAAuB,CAAC,UAAU,CAAC,EAAE,2BAA2B,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,iBAAiB,CAAC;IAEpG;;;;;;;;;;OAUG;IACH,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,mBAAmB,CAAC;IAEnI;;;;OAIG;IACH,+BAA+B,CAAC,MAAM,CAAC,EAAE,IAAI,GAAG,mBAAmB,CAAC;IAEpE;;;;;;;OAOG;IACH,iBAAiB,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;CAgBnG"}
|
|
@@ -29,6 +29,9 @@ export declare class OrthographicCamera implements IOrthographicCamera {
|
|
|
29
29
|
private _projectionBuffer;
|
|
30
30
|
private _viewBuffer;
|
|
31
31
|
private _projectionViewBuffer;
|
|
32
|
+
private _positionBuffer;
|
|
33
|
+
/** std140 vec3 world-space eye, padded to 4 floats. */
|
|
34
|
+
private readonly _positionData;
|
|
32
35
|
/**
|
|
33
36
|
*
|
|
34
37
|
* @param framework
|
|
@@ -80,6 +83,10 @@ export declare class OrthographicCamera implements IOrthographicCamera {
|
|
|
80
83
|
get projectionViewBuffer(): IUniformBuffer;
|
|
81
84
|
/** @inheritDoc */
|
|
82
85
|
get viewBuffer(): IUniformBuffer;
|
|
86
|
+
/** @inheritDoc */
|
|
87
|
+
get positionBuffer(): IUniformBuffer;
|
|
88
|
+
/** Writes the world-space eye into the std140 position data (no z flip: the look-at uses the eye as is). */
|
|
89
|
+
private _updatePositionData;
|
|
83
90
|
/**
|
|
84
91
|
* Updates the camera matrices.
|
|
85
92
|
*/
|
|
@@ -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;AAE7C;;GAEG;AACH,qBAAa,kBAAmB,YAAW,mBAAmB;IAE1D,MAAM,CAAC,SAAS,OAA4B;IAE5C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IAExC,iBAAiB;IACjB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IAEvC,OAAO,CAAC,IAAI,CAAO;IACnB,OAAO,CAAC,OAAO,CAAO;IAEtB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,IAAI,CAAS;IAErB,SAAS,CAAC,QAAQ,UAAQ;IAE1B,SAAS,CAAC,iBAAiB,OAAiB;IAC5C,SAAS,CAAC,WAAW,OAAiB;IACtC,SAAS,CAAC,qBAAqB,OAAiB;IAEhD,SAAgB,QAAQ,OAAiB;IACzC,SAAgB,MAAM,OAAiB;IACvC,SAAgB,SAAS,OAAiB;IAE1C,OAAO,CAAC,iBAAiB,CAAyB;IAClD,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,qBAAqB,CAAyB;
|
|
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,OAA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C,eAAe;IAMzB,kBAAkB;IACX,UAAU,IAAI,IAAI;IAmBzB,kBAAkB;IACX,aAAa,IAAI,IAAI;IAQ5B,kBAAkB;IACX,MAAM,CAAC,CAAC,EAAE,QAAQ,GAAG,IAAI;IAShC,kBAAkB;IACX,OAAO,IAAI,IAAI;CAOzB"}
|
|
@@ -3,6 +3,26 @@ import { mat4, vec3 } from "gl-matrix";
|
|
|
3
3
|
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
|
+
import type { Scene } from "../scene/Scene.js";
|
|
7
|
+
/**
|
|
8
|
+
* The descriptor for a perspective camera. Every field is optional.
|
|
9
|
+
*/
|
|
10
|
+
export interface PerspectiveCameraDescriptor {
|
|
11
|
+
/** The vertical field of view in degrees. By default, 60. */
|
|
12
|
+
fov?: number;
|
|
13
|
+
/** The aspect ratio (width / height). By default, 1. */
|
|
14
|
+
aspectRatio?: number;
|
|
15
|
+
/** The near plane. By default, 0.01. */
|
|
16
|
+
near?: number;
|
|
17
|
+
/** The far plane. By default, 100. */
|
|
18
|
+
far?: number;
|
|
19
|
+
/** The eye position. Copied. By default, (0, 0, 3). */
|
|
20
|
+
eye?: vec3;
|
|
21
|
+
/** The point the camera looks at. Copied. By default, the origin. */
|
|
22
|
+
target?: vec3;
|
|
23
|
+
/** The up vector. Copied. By default, (0, 1, 0). */
|
|
24
|
+
up?: vec3;
|
|
25
|
+
}
|
|
6
26
|
/**
|
|
7
27
|
* The perspective camera.
|
|
8
28
|
*/
|
|
@@ -18,14 +38,13 @@ export declare class PerspectiveCamera implements ICamera {
|
|
|
18
38
|
private _viewBuffer;
|
|
19
39
|
private _projectionBuffer;
|
|
20
40
|
/**
|
|
21
|
-
* The constructor.
|
|
41
|
+
* The constructor. Call `initialize()` before use (the camera factory does).
|
|
22
42
|
* @param framework The framework.
|
|
23
|
-
* @param
|
|
24
|
-
* @
|
|
25
|
-
* @param
|
|
26
|
-
* @param farPlane The far plane.
|
|
43
|
+
* @param descriptor The optional descriptor; omitted fields use the defaults documented on {@link PerspectiveCameraDescriptor}.
|
|
44
|
+
* `fov` is in degrees; {@link fieldOfView} holds it in radians. Vectors are copied.
|
|
45
|
+
* @param scene The optional scene; the camera assigns itself as `scene.camera`.
|
|
27
46
|
*/
|
|
28
|
-
constructor(framework: IFramework,
|
|
47
|
+
constructor(framework: IFramework, descriptor?: PerspectiveCameraDescriptor, scene?: Scene);
|
|
29
48
|
/**
|
|
30
49
|
* The projection matrix.
|
|
31
50
|
*/
|
|
@@ -94,6 +113,11 @@ export declare class PerspectiveCamera implements ICamera {
|
|
|
94
113
|
* Initialize the camera.
|
|
95
114
|
*/
|
|
96
115
|
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
|
+
*/
|
|
120
|
+
private _worldEye;
|
|
97
121
|
/**
|
|
98
122
|
* Updates the camera matrices.
|
|
99
123
|
*/
|
|
@@ -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;AAE7C;;GAEG;AACH,qBAAa,iBAAkB,YAAW,OAAO;IAE7C,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAC1C,OAA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IACI,QAAQ,SAAQ;IAEvB,kBAAkB;IAClB,SAAgB,UAAU,EAAE,OAAO,GAAG,SAAS,CAAa;IAE5D;;OAEG;IACI,UAAU,IAAI,IAAI;IAQzB;;;OAGG;IACH,OAAO,CAAC,SAAS;IAIjB;;OAEG;IACH,SAAS,CAAC,eAAe,IAAI,IAAI;IAajC,kBAAkB;IACX,MAAM,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, TextureDescriptor, ContentConfig } from "../index.js";
|
|
1
|
+
import { type IShaderModule, type IContentManager, type IShaderModuleLoader, type ITexture2D, type IFramework, TextureDescriptor, ContentConfig, type IMesh, type Scene } from "../index.js";
|
|
2
2
|
import type { IKtx2Texture } from "ris-ktx2";
|
|
3
3
|
/**
|
|
4
4
|
* The content manager.
|
|
@@ -9,6 +9,7 @@ export declare class ContentManager implements IContentManager {
|
|
|
9
9
|
readonly shaderModuleLoader: IShaderModuleLoader;
|
|
10
10
|
private readonly _ktx2Factory;
|
|
11
11
|
private readonly _ktx2TextureCache;
|
|
12
|
+
private readonly _objLoader;
|
|
12
13
|
/**
|
|
13
14
|
* The constructor.
|
|
14
15
|
* @param _framework The framework.
|
|
@@ -17,11 +18,75 @@ export declare class ContentManager implements IContentManager {
|
|
|
17
18
|
constructor(_framework: IFramework, shaderModuleLoader: IShaderModuleLoader);
|
|
18
19
|
/** @inheritDoc */
|
|
19
20
|
loadKtx2Async(path: string, contentConfig?: ContentConfig): Promise<IKtx2Texture>;
|
|
21
|
+
/**
|
|
22
|
+
* Disposes the cached shader modules (their GL programs) and forgets cached KTX2 data.
|
|
23
|
+
* Called from `Framework.dispose()`.
|
|
24
|
+
*/
|
|
25
|
+
dispose(): void;
|
|
20
26
|
/** @inheritDoc */
|
|
21
|
-
loadShaderModule(shaderModuleId: string
|
|
27
|
+
loadShaderModule(shaderModuleId: string, keyValueDictionary?: {
|
|
28
|
+
[id: string]: number;
|
|
29
|
+
}): IShaderModule;
|
|
22
30
|
/** @inheritDoc */
|
|
23
31
|
loadTexture2DAsync(path: string, textureDescriptor?: TextureDescriptor, contentConfig?: ContentConfig): Promise<ITexture2D>;
|
|
24
32
|
/** @inheritDoc */
|
|
25
33
|
loadTexture2DFromPixels(width: number, height: number, pixels: ArrayBuffer): ITexture2D;
|
|
34
|
+
/** @inheritDoc */
|
|
35
|
+
loadMeshAsync(path: string, scene: Scene): Promise<IMesh>;
|
|
36
|
+
/** @inheritDoc */
|
|
37
|
+
loadBlinnPhongMeshAsync(path: string, scene: Scene): Promise<IMesh>;
|
|
38
|
+
/**
|
|
39
|
+
* Loads the OBJ file and its .mtl material libraries.
|
|
40
|
+
* @param path The path or url to the .obj file.
|
|
41
|
+
* @returns The plain OBJ data.
|
|
42
|
+
*/
|
|
43
|
+
private _loadObj;
|
|
44
|
+
/**
|
|
45
|
+
* Creates framework geometry from the OBJ geometry.
|
|
46
|
+
* Vertex colours stay white, because each submesh's material carries the colour.
|
|
47
|
+
* @param definition The OBJ geometry definition.
|
|
48
|
+
* @returns The geometry.
|
|
49
|
+
*/
|
|
50
|
+
private _createGeometry;
|
|
51
|
+
/**
|
|
52
|
+
* Creates one submesh descriptor per material range.
|
|
53
|
+
* Ranges that use the same material name share one material instance.
|
|
54
|
+
* @param objResult The loaded OBJ data.
|
|
55
|
+
* @param createMaterial Creates the material for a definition (undefined without `usemtl` or .mtl entry).
|
|
56
|
+
* @returns The submesh descriptors, in file order.
|
|
57
|
+
*/
|
|
58
|
+
private _createSubMeshDescriptors;
|
|
59
|
+
/**
|
|
60
|
+
* Indexes material definitions by name.
|
|
61
|
+
* @param definitions The material definitions from the .mtl files.
|
|
62
|
+
* @returns A map from material name to definition.
|
|
63
|
+
*/
|
|
64
|
+
private _indexMaterialDefinitions;
|
|
65
|
+
/**
|
|
66
|
+
* Finds the definition for a `usemtl` name.
|
|
67
|
+
* @param definitionsByName The definitions by name.
|
|
68
|
+
* @param materialName The material name, or undefined for faces without `usemtl`.
|
|
69
|
+
* @returns The definition, or undefined when there is none.
|
|
70
|
+
*/
|
|
71
|
+
private _findMaterialDefinition;
|
|
72
|
+
/**
|
|
73
|
+
* Creates the default unlit material for an OBJ material definition.
|
|
74
|
+
* The diffuse colour is the definition's `Kd` with `d` as alpha; white when there is no definition.
|
|
75
|
+
* @param definition The material definition, or undefined.
|
|
76
|
+
* @param camera The scene's current camera, or undefined; the scene assigns it on update.
|
|
77
|
+
* @returns The unlit material.
|
|
78
|
+
*/
|
|
79
|
+
private _createUnlitMaterial;
|
|
80
|
+
/**
|
|
81
|
+
* Creates a Blinn-Phong material for an OBJ material definition.
|
|
82
|
+
* `Kd` (with `d` as alpha) becomes the diffuse colour, white when missing.
|
|
83
|
+
* `Ka` becomes the ambient colour; when missing the diffuse colour is used, so ambient light tints by the surface colour.
|
|
84
|
+
* `Ks` and `Ns` become specular colour and shininess; when missing the material defaults stay (0.5 grey, 32).
|
|
85
|
+
* @param definition The material definition, or undefined.
|
|
86
|
+
* @param camera The scene's camera; its projection view and position buffers are bound.
|
|
87
|
+
* @param lightsBuffer The optional lights buffer; the shader is compiled for its light counts.
|
|
88
|
+
* @returns The Blinn-Phong material.
|
|
89
|
+
*/
|
|
90
|
+
private _createBlinnPhongMaterial;
|
|
26
91
|
}
|
|
27
92
|
//# sourceMappingURL=ContentManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentManager.d.ts","sourceRoot":"","sources":["../../../src/api/content/ContentManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"ContentManager.d.ts","sourceRoot":"","s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,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAUtE,kBAAkB;IACL,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAmBhF;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IAIhB;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAMvB;;;;;;OAMG;IACH,OAAO,CAAC,yBAAyB;IA0BjC;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IAQjC;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;IAS/B;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;IAW5B;;;;;;;;;OASG;IACH,OAAO,CAAC,yBAAyB;CA0BpC"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { Scene } from "../scene/Scene.js";
|
|
1
2
|
import type { IShaderModuleLoader } from "../shader/IShaderModuleLoader.js";
|
|
2
3
|
import type { IShaderModule } from "../shader/IShaderModule.js";
|
|
3
4
|
import type { ITexture2D } from "../rendering/texture/ITexture2D.js";
|
|
4
5
|
import { TextureDescriptor } from "../rendering/texture/TextureDescriptor.js";
|
|
5
6
|
import { ContentConfig } from "./ContentConfig.js";
|
|
6
7
|
import type { IKtx2Texture } from "ris-ktx2";
|
|
8
|
+
import type { IMesh } from "../meshes/IMesh.js";
|
|
7
9
|
/**
|
|
8
10
|
* The content manager.
|
|
9
11
|
*/
|
|
@@ -22,9 +24,12 @@ export interface IContentManager {
|
|
|
22
24
|
/**
|
|
23
25
|
* Loads a shader module.
|
|
24
26
|
* @param shaderAssetId - The id of a shader asset.
|
|
27
|
+
* @param keyValueDictionary - If present, tries to find key in shader such that it replaced ##DIRECTIONAL_LIGHT_COUNT## by given value for key DIRECTIONAL_LIGHST_COUNT.
|
|
25
28
|
* @returns The shader module.
|
|
26
29
|
*/
|
|
27
|
-
loadShaderModule(shaderAssetId: string
|
|
30
|
+
loadShaderModule(shaderAssetId: string, keyValueDictionary?: {
|
|
31
|
+
[id: string]: number;
|
|
32
|
+
}): IShaderModule;
|
|
28
33
|
/**
|
|
29
34
|
* Loads a texture2D.
|
|
30
35
|
* @param path - The file path to the texture.
|
|
@@ -33,5 +38,31 @@ export interface IContentManager {
|
|
|
33
38
|
* @returns The Texture2D.
|
|
34
39
|
*/
|
|
35
40
|
loadTexture2DAsync(path: string, desc?: TextureDescriptor, contentConfig?: ContentConfig): Promise<ITexture2D>;
|
|
41
|
+
/**
|
|
42
|
+
* Loads a mesh from a model, typically.
|
|
43
|
+
* Currently, OBJ(WAVEFRONT) is supported.
|
|
44
|
+
* The mesh has one submesh per `usemtl` range, all sharing one vertex and index buffer.
|
|
45
|
+
* By default, each submesh gets an unlit material with the .mtl `Kd` as diffuse colour and `d` as alpha.
|
|
46
|
+
* @param path The path or url to the model.
|
|
47
|
+
* @param scene The scene the mesh adds itself to; `scene.render()` draws it. The materials use `scene.camera`
|
|
48
|
+
* (assigned on `scene.update()` when it is set later).
|
|
49
|
+
* @return The mesh.
|
|
50
|
+
*/
|
|
51
|
+
loadMeshAsync(path: string, scene: Scene): Promise<IMesh>;
|
|
52
|
+
/**
|
|
53
|
+
* Loads an OBJ (Wavefront) mesh with lit Blinn-Phong materials.
|
|
54
|
+
* Like {@link loadMeshAsync}, the mesh has one submesh per `usemtl` range sharing one vertex and index buffer,
|
|
55
|
+
* and ranges with the same material name share one material. `scene.render()` draws it.
|
|
56
|
+
* The .mtl values map onto `ForwardBlinnPhongMaterial`:
|
|
57
|
+
* - `Kd` → `diffuseColor` (with `d` as alpha), white when missing.
|
|
58
|
+
* - `Ka` → `ambientColor`, the diffuse colour when missing.
|
|
59
|
+
* - `Ks` → `specularColor` and `Ns` → `shininess`, the material defaults (0.5 grey, 32) when missing.
|
|
60
|
+
* Without an .mtl file every submesh gets a white material with those defaults.
|
|
61
|
+
* @param path The path or url to the .obj file. A relative `mtllib` is resolved against it.
|
|
62
|
+
* @param scene The scene the mesh adds itself to. Every material uses the scene's lights and `scene.camera`
|
|
63
|
+
* (assigned on `scene.update()` when it is set later).
|
|
64
|
+
* @return The mesh.
|
|
65
|
+
*/
|
|
66
|
+
loadBlinnPhongMeshAsync(path: string, scene: Scene): Promise<IMesh>;
|
|
36
67
|
}
|
|
37
68
|
//# sourceMappingURL=IContentManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IContentManager.d.ts","sourceRoot":"","sources":["../../../src/api/content/IContentManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAC,iBAAiB,EAAC,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"IContentManager.d.ts","sourceRoot":"","sources":["../../../src/api/content/IContentManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAC,iBAAiB,EAAC,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,eAAe;IAE5B;;OAEG;IACH,QAAQ,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;IAEjD;;;;;OAKG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAE3E;;;;;OAKG;IACH,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,kBAAkB,CAAC,EAAE;QAAE,CAAC,EAAE,EAAC,MAAM,GAAG,MAAM,CAAA;KAAC,GAAG,aAAa,CAAC;IAEpG;;;;;;OAMG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,iBAAiB,EAAE,aAAa,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAE/G;;;;;;;;;OASG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAE1D;;;;;;;;;;;;;OAaG;IACH,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CAEvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShaderModuleContent.d.ts","sourceRoot":"","sources":["../../../src/api/content/ShaderModuleContent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ShaderModuleContent.d.ts","sourceRoot":"","sources":["../../../src/api/content/ShaderModuleContent.ts"],"names":[],"mappings":"AAYA;;;;;;;;;GASG;AAGH,eAAO,MAAM,mBAAmB,EAAG;IAAC,CAAC,EAAE,EAAE,MAAM,GAAG,GAAG,CAAA;CA+BpD,CAAA"}
|
package/dist/api/data/Color.d.ts
CHANGED
|
@@ -115,5 +115,10 @@ export declare class Color implements Iterable<number> {
|
|
|
115
115
|
* @param o - The color that receives value.
|
|
116
116
|
*/
|
|
117
117
|
lerp(a: Color, b: Color, t: number, o: Color): void;
|
|
118
|
+
/**
|
|
119
|
+
* Copy self and return new instance with same values.
|
|
120
|
+
* @return Color
|
|
121
|
+
* */
|
|
122
|
+
copy(): Color;
|
|
118
123
|
}
|
|
119
124
|
//# sourceMappingURL=Color.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Color.d.ts","sourceRoot":"","sources":["../../../src/api/data/Color.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEvC;;GAEG;AACH,qBAAa,KAAM,YAAW,QAAQ,CAAC,MAAM,CAAC;IAE1C,OAAO,CAAC,OAAO,CAAa;IAE5B;;;;;;OAMG;gBAEE,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,SAAI;IAQV,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;IAI/C;;OAEG;IACH,IAAW,CAAC,IAAK,MAAM,CAEtB;IAED,IAAW,CAAC,CAAC,KAAK,EAAE,MAAM,EAEzB;IAED;;OAEG;IACH,IAAW,CAAC,IAAK,MAAM,CAEtB;IAED,IAAW,CAAC,CAAC,KAAK,EAAE,MAAM,EAEzB;IAED;;OAEG;IACH,IAAW,CAAC,IAAK,MAAM,CAEtB;IAED,IAAW,CAAC,CAAC,KAAK,EAAE,MAAM,EAEzB;IAED;;OAEG;IACH,IAAW,CAAC,IAAK,MAAM,CAEtB;IAED,IAAW,CAAC,CAAC,KAAK,EAAE,MAAM,EAEzB;IAED;;OAEG;WACW,KAAK,IAAI,KAAK;IAI5B;;OAEG;WACW,KAAK,IAAI,KAAK;IAI5B,6BAA6B;WACf,WAAW;IAIzB;;OAEG;WACW,SAAS,IAAI,KAAK;IAIhC;;OAEG;WACW,GAAG,IAAI,KAAK;IAI1B;;OAEG;WACW,KAAK,IAAI,KAAK;IAI5B;;OAEG;WACW,IAAI,IAAI,KA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