@bloopjs/toodle 0.0.100
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/LICENSE +21 -0
- package/README.md +44 -0
- package/dist/Toodle.d.ts +304 -0
- package/dist/Toodle.d.ts.map +1 -0
- package/dist/colors/mod.d.ts +872 -0
- package/dist/colors/mod.d.ts.map +1 -0
- package/dist/coreTypes/Color.d.ts +7 -0
- package/dist/coreTypes/Color.d.ts.map +1 -0
- package/dist/coreTypes/Point.d.ts +8 -0
- package/dist/coreTypes/Point.d.ts.map +1 -0
- package/dist/coreTypes/Size.d.ts +5 -0
- package/dist/coreTypes/Size.d.ts.map +1 -0
- package/dist/coreTypes/Transform.d.ts +16 -0
- package/dist/coreTypes/Transform.d.ts.map +1 -0
- package/dist/coreTypes/Vec2.d.ts +8 -0
- package/dist/coreTypes/Vec2.d.ts.map +1 -0
- package/dist/coreTypes/mod.d.ts +6 -0
- package/dist/coreTypes/mod.d.ts.map +1 -0
- package/dist/docs/snippets/add-remove-children.d.ts +1 -0
- package/dist/docs/snippets/basic-quad.d.ts +1 -0
- package/dist/docs/snippets/filter-linear.d.ts +1 -0
- package/dist/docs/snippets/filter-nearest.d.ts +1 -0
- package/dist/docs/snippets/flipxy.d.ts +1 -0
- package/dist/docs/snippets/hello-text.d.ts +1 -0
- package/dist/docs/snippets/jumbo-textures.d.ts +1 -0
- package/dist/docs/snippets/layer.d.ts +1 -0
- package/dist/docs/snippets/layout-edges.d.ts +1 -0
- package/dist/docs/snippets/layout-screen-and-world-space.d.ts +1 -0
- package/dist/docs/snippets/postprocess.d.ts +1 -0
- package/dist/docs/snippets/quad-size-scale.d.ts +1 -0
- package/dist/docs/snippets/quickstart.d.ts +1 -0
- package/dist/docs/snippets/repeat-texture-loading.d.ts +1 -0
- package/dist/docs/snippets/screen-shaders.d.ts +1 -0
- package/dist/docs/snippets/shader-color-flash.d.ts +1 -0
- package/dist/docs/snippets/shader-default.d.ts +1 -0
- package/dist/docs/snippets/shader-fill.d.ts +1 -0
- package/dist/docs/snippets/shapes-line.d.ts +1 -0
- package/dist/docs/snippets/sprite-region.d.ts +1 -0
- package/dist/docs/snippets/text-alignment.d.ts +1 -0
- package/dist/docs/snippets/text-shrink-to-fit.d.ts +1 -0
- package/dist/docs/snippets/text-word-wrap.d.ts +1 -0
- package/dist/docs/snippets/texture-bundles-prebaked.d.ts +1 -0
- package/dist/docs/snippets/texture-bundles.d.ts +1 -0
- package/dist/docs/snippets/transforms.d.ts +1 -0
- package/dist/docs/snippets/transparent-cropping.d.ts +1 -0
- package/dist/examples/0-hello.d.ts +1 -0
- package/dist/examples/1-hello.d.ts +1 -0
- package/dist/examples/1-hello.d.ts.map +1 -0
- package/dist/examples/1-quad.d.ts +1 -0
- package/dist/examples/10-resize.d.ts +1 -0
- package/dist/examples/10-resize.d.ts.map +1 -0
- package/dist/examples/11-bundle-test.d.ts +1 -0
- package/dist/examples/11-bundle-test.d.ts.map +1 -0
- package/dist/examples/12-transparent-pixel-cropping.d.ts +1 -0
- package/dist/examples/12-transparent-pixel-cropping.d.ts.map +1 -0
- package/dist/examples/13-crop.d.ts +1 -0
- package/dist/examples/13-crop.d.ts.map +1 -0
- package/dist/examples/14-bundle-bench.d.ts +1 -0
- package/dist/examples/14-bundle-bench.d.ts.map +1 -0
- package/dist/examples/15-text-layer.d.ts +1 -0
- package/dist/examples/15-text-layer.d.ts.map +1 -0
- package/dist/examples/16-jumbo-texture.d.ts +1 -0
- package/dist/examples/16-jumbo-textures.d.ts +1 -0
- package/dist/examples/16-screen-shader.d.ts +1 -0
- package/dist/examples/16-screen-shader.d.ts.map +1 -0
- package/dist/examples/17-lighting.d.ts +1 -0
- package/dist/examples/17-lighting.d.ts.map +1 -0
- package/dist/examples/17-translations.d.ts +1 -0
- package/dist/examples/18-blur.d.ts +1 -0
- package/dist/examples/19-postprocess.d.ts +1 -0
- package/dist/examples/19-screenshader.d.ts +1 -0
- package/dist/examples/2-shapes.d.ts +1 -0
- package/dist/examples/2-shapes.d.ts.map +1 -0
- package/dist/examples/3-shader.d.ts +1 -0
- package/dist/examples/3-shader.d.ts.map +1 -0
- package/dist/examples/4-shader-bench.d.ts +1 -0
- package/dist/examples/4-shader-bench.d.ts.map +1 -0
- package/dist/examples/5-z.d.ts +1 -0
- package/dist/examples/5-z.d.ts.map +1 -0
- package/dist/examples/6-atlas.d.ts +1 -0
- package/dist/examples/6-atlas.d.ts.map +1 -0
- package/dist/examples/7-text.d.ts +1 -0
- package/dist/examples/7-text.d.ts.map +1 -0
- package/dist/examples/8-text-bench.d.ts +1 -0
- package/dist/examples/8-text-bench.d.ts.map +1 -0
- package/dist/examples/9-alignment.d.ts +1 -0
- package/dist/examples/9-alignment.d.ts.map +1 -0
- package/dist/examples/main.d.ts +1 -0
- package/dist/examples/main.d.ts.map +1 -0
- package/dist/examples/util.d.ts +82 -0
- package/dist/examples/util.d.ts.map +1 -0
- package/dist/limits.d.ts +23 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/math/angle.d.ts +13 -0
- package/dist/math/angle.d.ts.map +1 -0
- package/dist/math/matrix.d.ts +26 -0
- package/dist/math/matrix.d.ts.map +1 -0
- package/dist/math/mod.d.ts +3 -0
- package/dist/math/mod.d.ts.map +1 -0
- package/dist/mod.d.ts +17 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +19665 -0
- package/dist/mod.js.map +41 -0
- package/dist/postprocess.d.ts +10 -0
- package/dist/postprocess.d.ts.map +1 -0
- package/dist/scene/Batcher.d.ts +20 -0
- package/dist/scene/Batcher.d.ts.map +1 -0
- package/dist/scene/Camera.d.ts +16 -0
- package/dist/scene/Camera.d.ts.map +1 -0
- package/dist/scene/JumboQuadNode.d.ts +29 -0
- package/dist/scene/JumboQuadNode.d.ts.map +1 -0
- package/dist/scene/QuadNode.d.ts +159 -0
- package/dist/scene/QuadNode.d.ts.map +1 -0
- package/dist/scene/RenderComponent.d.ts +11 -0
- package/dist/scene/RenderComponent.d.ts.map +1 -0
- package/dist/scene/SceneNode.d.ts +300 -0
- package/dist/scene/SceneNode.d.ts.map +1 -0
- package/dist/scene/mod.d.ts +5 -0
- package/dist/scene/mod.d.ts.map +1 -0
- package/dist/screen/mod.d.ts +2 -0
- package/dist/screen/mod.d.ts.map +1 -0
- package/dist/screen/resolution.d.ts +5 -0
- package/dist/screen/resolution.d.ts.map +1 -0
- package/dist/shaders/EngineUniform.d.ts +9 -0
- package/dist/shaders/EngineUniform.d.ts.map +1 -0
- package/dist/shaders/IShader.d.ts +15 -0
- package/dist/shaders/IShader.d.ts.map +1 -0
- package/dist/shaders/QuadShader.d.ts +18 -0
- package/dist/shaders/QuadShader.d.ts.map +1 -0
- package/dist/shaders/ShaderDescriptor.d.ts +7 -0
- package/dist/shaders/ShaderDescriptor.d.ts.map +1 -0
- package/dist/shaders/mod.d.ts +6 -0
- package/dist/shaders/mod.d.ts.map +1 -0
- package/dist/shaders/parser.d.ts +8 -0
- package/dist/shaders/parser.d.ts.map +1 -0
- package/dist/shaders/postprocess/blur.d.ts +3 -0
- package/dist/shaders/postprocess/blur.d.ts.map +1 -0
- package/dist/shaders/postprocess/mod.d.ts +17 -0
- package/dist/shaders/postprocess/mod.d.ts.map +1 -0
- package/dist/shaders/samplers.d.ts +3 -0
- package/dist/shaders/samplers.d.ts.map +1 -0
- package/dist/shaders/wgsl/example.wgsl.d.ts +3 -0
- package/dist/shaders/wgsl/example.wgsl.d.ts.map +1 -0
- package/dist/shaders/wgsl/hello.wgsl.d.ts +3 -0
- package/dist/shaders/wgsl/hello.wgsl.d.ts.map +1 -0
- package/dist/shaders/wgsl/helloInstanced.wgsl.d.ts +3 -0
- package/dist/shaders/wgsl/helloInstanced.wgsl.d.ts.map +1 -0
- package/dist/shaders/wgsl/quad.wgsl.d.ts +3 -0
- package/dist/shaders/wgsl/quad.wgsl.d.ts.map +1 -0
- package/dist/src/Toodle.d.ts +303 -0
- package/dist/src/Toodle.d.ts.map +1 -0
- package/dist/src/colors/mod.d.ts +871 -0
- package/dist/src/coreTypes/Color.d.ts +6 -0
- package/dist/src/coreTypes/Color.d.ts.map +1 -0
- package/dist/src/coreTypes/Point.d.ts +7 -0
- package/dist/src/coreTypes/Point.d.ts.map +1 -0
- package/dist/src/coreTypes/Size.d.ts +4 -0
- package/dist/src/coreTypes/Size.d.ts.map +1 -0
- package/dist/src/coreTypes/Transform.d.ts +15 -0
- package/dist/src/coreTypes/Transform.d.ts.map +1 -0
- package/dist/src/coreTypes/Vec2.d.ts +7 -0
- package/dist/src/coreTypes/Vec2.d.ts.map +1 -0
- package/dist/src/coreTypes/mod.d.ts +5 -0
- package/dist/src/coreTypes/mod.d.ts.map +1 -0
- package/dist/src/limits.d.ts +22 -0
- package/dist/src/limits.d.ts.map +1 -0
- package/dist/src/math/angle.d.ts +12 -0
- package/dist/src/math/angle.d.ts.map +1 -0
- package/dist/src/math/matrix.d.ts +25 -0
- package/dist/src/math/matrix.d.ts.map +1 -0
- package/dist/src/math/mod.d.ts +2 -0
- package/dist/src/math/mod.d.ts.map +1 -0
- package/dist/src/mod.d.ts +16 -0
- package/dist/src/mod.d.ts.map +1 -0
- package/dist/src/postprocess.d.ts +10 -0
- package/dist/src/postprocess.d.ts.map +1 -0
- package/dist/src/scene/Batcher.d.ts +19 -0
- package/dist/src/scene/Batcher.d.ts.map +1 -0
- package/dist/src/scene/Camera.d.ts +15 -0
- package/dist/src/scene/Camera.d.ts.map +1 -0
- package/dist/src/scene/JumboQuadNode.d.ts +28 -0
- package/dist/src/scene/QuadNode.d.ts +158 -0
- package/dist/src/scene/QuadNode.d.ts.map +1 -0
- package/dist/src/scene/RenderComponent.d.ts +10 -0
- package/dist/src/scene/RenderComponent.d.ts.map +1 -0
- package/dist/src/scene/SceneNode.d.ts +299 -0
- package/dist/src/scene/SceneNode.d.ts.map +1 -0
- package/dist/src/scene/mod.d.ts +4 -0
- package/dist/src/scene/mod.d.ts.map +1 -0
- package/dist/src/screen/mod.d.ts +1 -0
- package/dist/src/screen/mod.d.ts.map +1 -0
- package/dist/src/screen/resolution.d.ts +4 -0
- package/dist/src/screen/resolution.d.ts.map +1 -0
- package/dist/src/shaders/EngineUniform.d.ts +8 -0
- package/dist/src/shaders/EngineUniform.d.ts.map +1 -0
- package/dist/src/shaders/IShader.d.ts +14 -0
- package/dist/src/shaders/IShader.d.ts.map +1 -0
- package/dist/src/shaders/QuadShader.d.ts +17 -0
- package/dist/src/shaders/QuadShader.d.ts.map +1 -0
- package/dist/src/shaders/ShaderDescriptor.d.ts +6 -0
- package/dist/src/shaders/ShaderDescriptor.d.ts.map +1 -0
- package/dist/src/shaders/mod.d.ts +5 -0
- package/dist/src/shaders/mod.d.ts.map +1 -0
- package/dist/src/shaders/parser.d.ts +7 -0
- package/dist/src/shaders/parser.d.ts.map +1 -0
- package/dist/src/shaders/postprocess/blur.d.ts +2 -0
- package/dist/src/shaders/postprocess/mod.d.ts +16 -0
- package/dist/src/shaders/postprocess/postprocess.d.ts +8 -0
- package/dist/src/shaders/postprocess/util.d.ts +2 -0
- package/dist/src/shaders/samplers.d.ts +2 -0
- package/dist/src/shaders/samplers.d.ts.map +1 -0
- package/dist/src/shaders/wgsl/example.wgsl.d.ts +2 -0
- package/dist/src/shaders/wgsl/example.wgsl.d.ts.map +1 -0
- package/dist/src/shaders/wgsl/hello.wgsl.d.ts +2 -0
- package/dist/src/shaders/wgsl/hello.wgsl.d.ts.map +1 -0
- package/dist/src/shaders/wgsl/helloInstanced.wgsl.d.ts +2 -0
- package/dist/src/shaders/wgsl/helloInstanced.wgsl.d.ts.map +1 -0
- package/dist/src/shaders/wgsl/quad.wgsl.d.ts +2 -0
- package/dist/src/shaders/wgsl/quad.wgsl.d.ts.map +1 -0
- package/dist/src/text/FontPipeline.d.ts +13 -0
- package/dist/src/text/FontPipeline.d.ts.map +1 -0
- package/dist/src/text/MsdfFont.d.ts +81 -0
- package/dist/src/text/MsdfFont.d.ts.map +1 -0
- package/dist/src/text/TextFormatting.d.ts +18 -0
- package/dist/src/text/TextFormatting.d.ts.map +1 -0
- package/dist/src/text/TextNode.d.ts +18 -0
- package/dist/src/text/TextNode.d.ts.map +1 -0
- package/dist/src/text/TextShader.d.ts +14 -0
- package/dist/src/text/TextShader.d.ts.map +1 -0
- package/dist/src/text/mod.d.ts +3 -0
- package/dist/src/text/mod.d.ts.map +1 -0
- package/dist/src/text/shaping.d.ts +38 -0
- package/dist/src/text/shaping.d.ts.map +1 -0
- package/dist/src/text/text.wgsl.d.ts +2 -0
- package/dist/src/text/text.wgsl.d.ts.map +1 -0
- package/dist/src/textures/AssetManager.d.ts +181 -0
- package/dist/src/textures/AssetManager.d.ts.map +1 -0
- package/dist/src/textures/NewTextureComputeShader.d.ts +28 -0
- package/dist/src/textures/TextureComputeShader.d.ts +20 -0
- package/dist/src/textures/TextureComputeShader.d.ts.map +1 -0
- package/dist/src/textures/crop.wgsl.d.ts +2 -0
- package/dist/src/textures/mod.d.ts +1 -0
- package/dist/src/textures/mod.d.ts.map +1 -0
- package/dist/src/textures/pixel-scraping.wgsl.d.ts +2 -0
- package/dist/src/textures/pixel-scraping.wgsl.d.ts.map +1 -0
- package/dist/src/textures/texture-processing.wgsl.d.ts +2 -0
- package/dist/src/textures/types.d.ts +176 -0
- package/dist/src/textures/types.d.ts.map +1 -0
- package/dist/src/textures/util.d.ts +7 -0
- package/dist/src/textures/util.d.ts.map +1 -0
- package/dist/src/utils/assert.d.ts +1 -0
- package/dist/src/utils/assert.d.ts.map +1 -0
- package/dist/src/utils/boilerplate.d.ts +10 -0
- package/dist/src/utils/boilerplate.d.ts.map +1 -0
- package/dist/src/utils/error.d.ts +7 -0
- package/dist/src/utils/error.d.ts.map +1 -0
- package/dist/src/utils/mod.d.ts +2 -0
- package/dist/src/utils/mod.d.ts.map +1 -0
- package/dist/src/utils/pool.d.ts +22 -0
- package/dist/src/utils/pool.d.ts.map +1 -0
- package/dist/test/math/matrix.test.d.ts +1 -0
- package/dist/test/scene/Batcher.test.d.ts +1 -0
- package/dist/test/scene/SceneNode.test.d.ts +1 -0
- package/dist/test/shader/parser.test.d.ts +1 -0
- package/dist/text/FontPipeline.d.ts +14 -0
- package/dist/text/FontPipeline.d.ts.map +1 -0
- package/dist/text/MsdfFont.d.ts +82 -0
- package/dist/text/MsdfFont.d.ts.map +1 -0
- package/dist/text/TextFormatting.d.ts +19 -0
- package/dist/text/TextFormatting.d.ts.map +1 -0
- package/dist/text/TextNode.d.ts +19 -0
- package/dist/text/TextNode.d.ts.map +1 -0
- package/dist/text/TextShader.d.ts +15 -0
- package/dist/text/TextShader.d.ts.map +1 -0
- package/dist/text/mod.d.ts +4 -0
- package/dist/text/mod.d.ts.map +1 -0
- package/dist/text/shaping.d.ts +39 -0
- package/dist/text/shaping.d.ts.map +1 -0
- package/dist/text/text.wgsl.d.ts +3 -0
- package/dist/text/text.wgsl.d.ts.map +1 -0
- package/dist/textures/AssetManager.d.ts +182 -0
- package/dist/textures/AssetManager.d.ts.map +1 -0
- package/dist/textures/TextureComputeShader.d.ts +21 -0
- package/dist/textures/TextureComputeShader.d.ts.map +1 -0
- package/dist/textures/mod.d.ts +2 -0
- package/dist/textures/mod.d.ts.map +1 -0
- package/dist/textures/pixel-scraping.wgsl.d.ts +3 -0
- package/dist/textures/pixel-scraping.wgsl.d.ts.map +1 -0
- package/dist/textures/types.d.ts +177 -0
- package/dist/textures/types.d.ts.map +1 -0
- package/dist/textures/util.d.ts +8 -0
- package/dist/textures/util.d.ts.map +1 -0
- package/dist/utils/assert.d.ts +2 -0
- package/dist/utils/assert.d.ts.map +1 -0
- package/dist/utils/boilerplate.d.ts +11 -0
- package/dist/utils/boilerplate.d.ts.map +1 -0
- package/dist/utils/error.d.ts +8 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/mod.d.ts +3 -0
- package/dist/utils/mod.d.ts.map +1 -0
- package/dist/utils/pool.d.ts +23 -0
- package/dist/utils/pool.d.ts.map +1 -0
- package/package.json +47 -0
- package/src/Toodle.ts +853 -0
- package/src/colors/mod.ts +151 -0
- package/src/coreTypes/Color.ts +1 -0
- package/src/coreTypes/Point.ts +7 -0
- package/src/coreTypes/Size.ts +4 -0
- package/src/coreTypes/Transform.ts +16 -0
- package/src/coreTypes/Vec2.ts +7 -0
- package/src/coreTypes/mod.ts +5 -0
- package/src/globals.d.ts +4 -0
- package/src/limits.ts +23 -0
- package/src/math/angle.ts +17 -0
- package/src/math/matrix.ts +99 -0
- package/src/math/mod.ts +2 -0
- package/src/mod.ts +22 -0
- package/src/scene/Batcher.ts +61 -0
- package/src/scene/Camera.ts +69 -0
- package/src/scene/JumboQuadNode.ts +219 -0
- package/src/scene/QuadNode.ts +403 -0
- package/src/scene/RenderComponent.ts +12 -0
- package/src/scene/SceneNode.ts +668 -0
- package/src/scene/mod.ts +4 -0
- package/src/screen/mod.ts +1 -0
- package/src/screen/resolution.ts +1 -0
- package/src/shaders/EngineUniform.ts +11 -0
- package/src/shaders/IShader.ts +20 -0
- package/src/shaders/QuadShader.ts +288 -0
- package/src/shaders/ShaderDescriptor.ts +6 -0
- package/src/shaders/mod.ts +5 -0
- package/src/shaders/parser.ts +221 -0
- package/src/shaders/postprocess/blur.ts +245 -0
- package/src/shaders/postprocess/mod.ts +71 -0
- package/src/shaders/samplers.ts +13 -0
- package/src/shaders/wgsl/example.wgsl.ts +24 -0
- package/src/shaders/wgsl/hello.wgsl.ts +62 -0
- package/src/shaders/wgsl/helloInstanced.wgsl.ts +46 -0
- package/src/shaders/wgsl/quad.wgsl.ts +140 -0
- package/src/text/FontPipeline.ts +212 -0
- package/src/text/MsdfFont.ts +190 -0
- package/src/text/TextFormatting.ts +28 -0
- package/src/text/TextNode.ts +82 -0
- package/src/text/TextShader.ts +223 -0
- package/src/text/mod.ts +8 -0
- package/src/text/shaping.ts +280 -0
- package/src/text/text.wgsl.ts +149 -0
- package/src/textures/AssetManager.ts +746 -0
- package/src/textures/TextureComputeShader.ts +434 -0
- package/src/textures/mod.ts +1 -0
- package/src/textures/pixel-scraping.wgsl.ts +131 -0
- package/src/textures/types.ts +182 -0
- package/src/textures/util.ts +352 -0
- package/src/utils/assert.ts +5 -0
- package/src/utils/boilerplate.ts +110 -0
- package/src/utils/error.ts +14 -0
- package/src/utils/mod.ts +2 -0
- package/src/utils/pool.ts +42 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SceneNode } from "../scene/SceneNode";
|
|
2
|
+
import type { AssetManager } from "../textures/AssetManager";
|
|
3
|
+
import type { EngineUniform } from "./EngineUniform";
|
|
4
|
+
import type { IShader } from "./IShader";
|
|
5
|
+
export type QuadShaderOpts = {
|
|
6
|
+
assetManager?: AssetManager;
|
|
7
|
+
blendMode?: GPUBlendState;
|
|
8
|
+
};
|
|
9
|
+
export declare class QuadShader implements IShader {
|
|
10
|
+
#private;
|
|
11
|
+
label: string;
|
|
12
|
+
code: string;
|
|
13
|
+
startFrame(device: GPUDevice, uniform: EngineUniform): void;
|
|
14
|
+
processBatch(renderPass: GPURenderPassEncoder, nodes: SceneNode[]): number;
|
|
15
|
+
endFrame(): void;
|
|
16
|
+
constructor(label: string, assetManager: AssetManager, device: GPUDevice, presentationFormat: GPUTextureFormat, userCode: string, instanceCount: number, blendMode?: GPUBlendState);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=QuadShader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuadShader.d.ts","sourceRoot":"","sources":["../../src/shaders/QuadShader.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAQ7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASzC,MAAM,MAAM,cAAc,GAAG;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,SAAS,CAAC,EAAE,aAAa,CAAC;CAC3B,CAAC;AAEF,qBAAa,UAAW,YAAW,OAAO;;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IAYb,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa;IAiBpD,YAAY,CAAC,UAAU,EAAE,oBAAoB,EAAE,KAAK,EAAE,SAAS,EAAE;IA0DjE,QAAQ;gBAGN,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,SAAS,EACjB,kBAAkB,EAAE,gBAAgB,EACpC,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,aAAa;CA4G5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShaderDescriptor.d.ts","sourceRoot":"","sources":["../../src/shaders/ShaderDescriptor.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/shaders/mod.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type StructInfo } from "wgsl_reflect";
|
|
2
|
+
import type { ShaderDescriptor } from "./ShaderDescriptor";
|
|
3
|
+
export declare function codeWithLineNumbers(code: string): string;
|
|
4
|
+
export declare function combineShaderCode(label: string, base: string, mod: string): ShaderDescriptor;
|
|
5
|
+
export declare function struct2BufferLayout(struct: StructInfo, stepMode?: GPUVertexStepMode): GPUVertexBufferLayout;
|
|
6
|
+
export declare function validateFragmentShader(shaderCode: string): void;
|
|
7
|
+
export declare function getGpuFormat(typeName: string): GPUVertexFormat;
|
|
8
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/shaders/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAe,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,UAK/C;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,GACV,gBAAgB,CA4ClB;AAuED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAClB,QAAQ,GAAE,iBAA8B,GACvC,qBAAqB,CAkDvB;AAED,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,QAaxD;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAqB9D"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Color } from "../../coreTypes/Color";
|
|
2
|
+
export declare function blur(encoder: GPUCommandEncoder, context: GPUCanvasContext, device: GPUDevice, clearColor: Color, presentationFormat: GPUTextureFormat, pingpong: [GPUTexture, GPUTexture]): void;
|
|
3
|
+
//# sourceMappingURL=blur.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blur.d.ts","sourceRoot":"","sources":["../../../src/shaders/postprocess/blur.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAInD,wBAAgB,IAAI,CAClB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,KAAK,EACjB,kBAAkB,EAAE,gBAAgB,EACpC,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,QA2InC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type PostProcess = {
|
|
2
|
+
/**
|
|
3
|
+
* A post-processor modifies the current render before it is presented to the screen.
|
|
4
|
+
*
|
|
5
|
+
* @param encoder - a GPUCommandEncoder used to create render passes
|
|
6
|
+
* @param pingpong - a pair of GPUTextures used for ping-pong rendering
|
|
7
|
+
* @param screen - the final screen GPUTexture to render to
|
|
8
|
+
*/
|
|
9
|
+
process(queue: GPUQueue, encoder: GPUCommandEncoder, pingpong: [GPUTexture, GPUTexture], screen: GPUTexture): void;
|
|
10
|
+
};
|
|
11
|
+
export declare const PostProcessDefaults: {
|
|
12
|
+
readonly sampler: (device: GPUDevice) => GPUSampler;
|
|
13
|
+
readonly vertexBufferLayout: (device: GPUDevice) => GPUVertexBufferLayout;
|
|
14
|
+
readonly vertexShader: (device: GPUDevice) => GPUShaderModule;
|
|
15
|
+
readonly pipelineDescriptor: (device: GPUDevice) => GPURenderPipelineDescriptor;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/shaders/postprocess/mod.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB;;;;;;OAMG;IACH,OAAO,CACL,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,EAClC,MAAM,EAAE,UAAU,GACjB,IAAI,CAAC;CACT,CAAC;AAEF,eAAO,MAAM,mBAAmB;+BACd,SAAS,KAAG,UAAU;0CAWX,SAAS,KAAG,qBAAqB;oCAOvC,SAAS,KAAG,eAAe;0CAuBrB,SAAS,KAAG,2BAA2B;CAY1D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"samplers.d.ts","sourceRoot":"","sources":["../../src/shaders/samplers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,EAAE,oBAK7B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,oBAK3B,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const _default: "\nstruct MyStuff {\n red: f32,\n}\n\n@vertex\nfn vert(\n @builtin(vertex_index) VertexIndex: u32,\n @builtin(instance_index) InstanceIndex: u32,\n instance: InstanceData\n) -> VertexOutput {\n var output = default_vertex_shader(VertexIndex, InstanceIndex, instance);\n return output;\n}\n\n@fragment\nfn frag(vertex: VertexOutput) -> @location(0) vec4f {\n let color = default_fragment_shader(vertex);\n color.r = vertex.myStuff_red;\n return color;\n}\n";
|
|
2
|
+
export default _default;
|
|
3
|
+
//# sourceMappingURL=example.wgsl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.wgsl.d.ts","sourceRoot":"","sources":["../../../src/shaders/wgsl/example.wgsl.ts"],"names":[],"mappings":";AAEA,wBAqBE"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const _default: "\n\n//\n// SECTION: Struct Definitions\n//\n\nstruct InstanceData {}\n\n\nstruct VertexInput {\n @builtin(vertex_index) vertexIndex: u32,\n @builtin(instance_index) instanceIndex: u32,\n}\n\nstruct VertexOutput {\n @builtin(position) engine_clip_position : vec4<f32>,\n}\n\nstruct FragmentInput {\n @builtin(position) engine_clip_position : vec4<f32>,\n}\n\nstruct FragmentOutput {\n color: vec4<f32>,\n}\n\n//\n// SECTION: Base Entrypoints\n//\n\n@vertex\nfn base_vertex_entrypoint(input: VertexInput) -> VertexOutput {\n return default_vertex_shader(input);\n}\n\n@fragment\nfn base_fragment_entrypoint(vertex: VertexOutput) -> @location(0) vec4<f32> {\n let output = base_fragment_shader(vertex);\n return output.color;\n}\n\n//\n// SECTION: Base Shaders\n//\n\nconst pos = array(vec2f(-1, -1), vec2f(1, -1), vec2f(-1, 1), vec2f(1, 1));\n\nfn base_vertex_shader(input: VertexInput) -> VertexOutput {\n var output : VertexOutput;\n output.engine_clip_position = vec4f(pos[input.vertexIndex], 0.0, 1.0);\n return output;\n}\n\nfn base_fragment_shader(vertex: VertexOutput) -> FragmentOutput {\n var output : FragmentOutput;\n output.color = vec4f(1.0, 0.0, 1.0, 1.0);\n return output;\n}\n\n";
|
|
2
|
+
export default _default;
|
|
3
|
+
//# sourceMappingURL=hello.wgsl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hello.wgsl.d.ts","sourceRoot":"","sources":["../../../src/shaders/wgsl/hello.wgsl.ts"],"names":[],"mappings":";AAEA,wBA2DE"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const _default: "\n// const pos = array(vec2f(-0.5, -0.5), vec2f(0.5, -0.5), vec2f(-0.5, 0.5), vec2f(0.5, 0.5));\nconst pos = array(vec2f(-0.5, 0.5), vec2f(-0.5, -0.5), vec2f(0.5, 0.5), vec2f(0.5, -0.5));\n\nstruct InstanceData {\n @location(0) model0: vec4<f32>,\n @location(1) model1: vec4<f32>,\n @location(2) model2: vec4<f32>,\n @location(3) color: vec4<f32>,\n}\nstruct VertexOutput {\n @builtin(position) engine_clip_position : vec4<f32>,\n @location(0) @interpolate(flat) color: vec4<f32>,\n}\n\nstruct EngineUniform {\n viewProjection: mat3x3<f32>,\n};\n\n@group(0) @binding(0) var<uniform> engineUniform: EngineUniform;\n\n\n// this is the vertex shader\n@vertex\nfn vs(\n @builtin(vertex_index) VertexIndex : u32,\n @builtin(instance_index) InstanceIndex: u32, // Instance ID for each instance\n instanceData: InstanceData,\n) -> VertexOutput {\n var output : VertexOutput;\n let modelMatrix = mat3x3(instanceData.model0.xyz, instanceData.model1.xyz, instanceData.model2.xyz);\n let worldPosition = engineUniform.viewProjection * modelMatrix * vec3f(pos[VertexIndex], 1.0);\n\n output.engine_clip_position = vec4f(worldPosition, 1.0);\n output.color = instanceData.color;\n return output;\n}\n\n// this is the fragment shader\n@fragment\nfn fs(vertex: VertexOutput) -> @location(0) vec4<f32> {\n return vertex.color;\n}\n";
|
|
2
|
+
export default _default;
|
|
3
|
+
//# sourceMappingURL=helloInstanced.wgsl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helloInstanced.wgsl.d.ts","sourceRoot":"","sources":["../../../src/shaders/wgsl/helloInstanced.wgsl.ts"],"names":[],"mappings":";AAEA,wBA2CE"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const _default: "\nstruct InstanceData {\n // location 0-2 are the model matrix for this instanced quad\n @location(0) model0: vec4<f32>,\n @location(1) model1: vec4<f32>,\n @location(2) model2: vec4<f32>,\n // location 3 is the tint - the color will be multiplied by the texture color to determine the pixel color\n @location(3) engine_tint: vec4<f32>,\n // location 4 are the uv offset and scale used to sample the texture atlas. these are in normalized texel coordinates.\n @location(4) uvOffsetAndScale: vec4<f32>,\n // location 5 is the crop offset from center and scale. These are ratios applied to the unit quad.\n @location(5) cropOffsetAndScale: vec4<f32>,\n // location 6 is the atlas index\n @location(6) atlasIndex: u32,\n // @INSTANCE_DATA SNIPPET\n}\n\nstruct VertexInput {\n @builtin(vertex_index) VertexIndex: u32,\n @builtin(instance_index) InstanceIndex: u32,\n instance: InstanceData\n}\n\nstruct VertexOutput {\n @builtin(position) engine_clip_position : vec4<f32>,\n // uv coordinates are stored as two vec2s:\n // [0,1] = atlas uv coords\n // [2,3] = uv scale\n @location(0) engine_uv: vec4<f32>,\n @location(1) @interpolate(flat) engine_tint: vec4<f32>,\n @location(2) @interpolate(flat) engine_atlasIndex: u32,\n // @VERTEX_OUTPUT SNIPPET\n}\n\nstruct EngineUniform {\n viewProjection: mat3x3<f32>,\n resolution: vec2f,\n};\n\n// we can't divide by 2 in the projection matrix because\n// it will affect the positioning as well as the geometry scale\n// so we need to divide by 2 for the initial position scale.\n// for eg a 10x10 quad in the top left of a 100x100 logical canvas with a 200x200 natural size\n// will be passed in as\n// position=[-45, 45]\n// scale=[10,10]\n// so the top left corner will be: (-0.5 * 10 - 45) * 2 / 100 = -1\n// if the top left vertex was -1, it would be: (-1 * 10 - 45) * 2 / 100 = -1.1\nconst enginePosLookup = array(vec2f(-0.5, 0.5), vec2f(-0.5, -0.5), vec2f(0.5, 0.5), vec2f(0.5, -0.5));\nconst engineUvLookup = array(vec2f(0, 0), vec2f(0, 1), vec2f(1, 0), vec2f(1, 1));\n\n@group(0) @binding(0) var<uniform> engineUniform: EngineUniform;\n@group(0) @binding(1) var linearSampler: sampler;\n@group(0) @binding(2) var nearestSampler: sampler;\n\n@group(1) @binding(0) var textureArray: texture_2d_array<f32>;\n\n@vertex\nfn engine_vs(\n @builtin(vertex_index) VertexIndex: u32,\n @builtin(instance_index) InstanceIndex: u32,\n instance: InstanceData\n) -> VertexOutput {\n var output = default_vertex_shader(VertexIndex, InstanceIndex,instance);\n return output;\n}\n\n@fragment\nfn engine_fs(vertex: VertexOutput) -> @location(0) vec4<f32> {\n return default_fragment_shader(vertex, nearestSampler);\n}\n\nfn default_vertex_shader(\n VertexIndex: u32,\n InstanceIndex: u32,\n instance: InstanceData\n) -> VertexOutput {\n var output : VertexOutput;\n output.engine_tint = instance.engine_tint;\n\n // reconstruct the model matrix from the instance data\n // bc we can't pass a mat3x3 as instance data\n let modelMatrix = mat3x3(instance.model0.xyz, instance.model1.xyz, instance.model2.xyz);\n\n // transform the vertex position\n let localPosition = enginePosLookup[VertexIndex];\n let cropOffset = instance.cropOffsetAndScale.xy;\n let cropScale = instance.cropOffsetAndScale.zw;\n let croppedPosition = localPosition * cropScale + cropOffset;\n let worldPosition = modelMatrix * vec3f(croppedPosition, 1.0);\n let clipPosition = engineUniform.viewProjection * worldPosition;\n output.engine_clip_position = vec4f(clipPosition, 1.0);\n\n // set the uv coordinates in the texture atlas.\n let original_uv = engineUvLookup[VertexIndex];\n // uvOffsetAndScale is a vec4 with the following values:\n // [0,1] = uv offset\n // [2,3] = uv scale\n let atlas_uv = original_uv * instance.uvOffsetAndScale.zw * cropScale + instance.uvOffsetAndScale.xy;\n // we also pack the original uv coordinates in the w and z components\n // since these can be useful in the fragment shader\n output.engine_uv = vec4f(atlas_uv, original_uv);\n output.engine_atlasIndex = u32(instance.atlasIndex);\n // @PASSTHROUGH_SNIPPET\n\n return output;\n}\n\nfn default_fragment_shader(vertex: VertexOutput, samp: sampler) -> vec4<f32> {\n let atlas_uv = vertex.engine_uv.xy;\n let original_uv = vertex.engine_uv.zw;\n\n // Force both samplers to be referenced without assignment\n // This prevents WGSLReflect from optimizing them away\n var nope: bool = false;\n if (nope) {\n _ = linearSampler;\n _ = nearestSampler;\n }\n\n let color = textureSample(textureArray, samp, atlas_uv, vertex.engine_atlasIndex);\n\n if (vertex.engine_atlasIndex == 1000u) {\n // rectangle - return a solid color\n return vec4f(1,1,1,1) * vertex.engine_tint;\n } else if (vertex.engine_atlasIndex == 1001u) {\n // circle:\n // edge width is 4 logical pixels\n let edgeWidth = 4. / max(engineUniform.resolution.x, engineUniform.resolution.y);\n // distance from center of the quad ranging from [0,1]\n let centerDistance = 2 * distance(vec2f(0.5, 0.5), original_uv);\n // alpha is 1 before edgeWidth and 0 after edgeWidth\n let alpha = 1. - smoothstep(1. - edgeWidth, 1. + edgeWidth, centerDistance);\n return vec4f(vertex.engine_tint.rgb, alpha * vertex.engine_tint.a);\n } else {\n // texture:\n return color * vertex.engine_tint;\n }\n}\n";
|
|
2
|
+
export default _default;
|
|
3
|
+
//# sourceMappingURL=quad.wgsl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quad.wgsl.d.ts","sourceRoot":"","sources":["../../../src/shaders/wgsl/quad.wgsl.ts"],"names":[],"mappings":";AAAA,wBA2IE"}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import type { Color } from "./coreTypes/Color";
|
|
2
|
+
import type { Point } from "./coreTypes/Point";
|
|
3
|
+
import type { Limits, LimitsOptions } from "./limits";
|
|
4
|
+
import { Batcher } from "./scene/Batcher";
|
|
5
|
+
import { Camera } from "./scene/Camera";
|
|
6
|
+
import { JumboQuadNode, type JumboQuadOptions } from "./scene/JumboQuadNode";
|
|
7
|
+
import { QuadNode, type QuadOptions } from "./scene/QuadNode";
|
|
8
|
+
import { type NodeOptions, SceneNode } from "./scene/SceneNode";
|
|
9
|
+
import type { Resolution } from "./screen/resolution";
|
|
10
|
+
import type { IShader } from "./shaders/IShader";
|
|
11
|
+
import type { PostProcess } from "./shaders/postprocess/mod";
|
|
12
|
+
import { QuadShader, QuadShaderOpts } from "./shaders/QuadShader";
|
|
13
|
+
import { TextNode, type TextOptions } from "./text/TextNode";
|
|
14
|
+
import { AssetManager, type TextureId } from "./textures/AssetManager";
|
|
15
|
+
export declare class Toodle {
|
|
16
|
+
#private;
|
|
17
|
+
/**
|
|
18
|
+
* Asset manager. Use toodle.assets.loadTexture to load texture assets.
|
|
19
|
+
*/
|
|
20
|
+
assets: AssetManager;
|
|
21
|
+
/**
|
|
22
|
+
* diagnostics can be used as a rough gauge for performance.
|
|
23
|
+
* besides frames, these stats are reset at the beginning of each frame.
|
|
24
|
+
*/
|
|
25
|
+
diagnostics: {
|
|
26
|
+
/** number of instanced draw calls issued last frame. lower is better */
|
|
27
|
+
drawCalls: number;
|
|
28
|
+
/** number of pipeline switches last frame. lower is better. to reduce pipeline switches, use fewer z-indexes or fewer custom shaders */
|
|
29
|
+
pipelineSwitches: number;
|
|
30
|
+
/** number of frames rendered */
|
|
31
|
+
frames: number;
|
|
32
|
+
/** number of instances enqueued last frame */
|
|
33
|
+
instancesEnqueued: number;
|
|
34
|
+
};
|
|
35
|
+
/** sometimes for debugging you might want to access the GPU device, this should not be necessary in normal operation */
|
|
36
|
+
debug: {
|
|
37
|
+
device: GPUDevice;
|
|
38
|
+
presentationFormat: GPUTextureFormat;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Camera. This applies a 2d perspective projection matrix to any nodes drawn with toodle.draw
|
|
42
|
+
*/
|
|
43
|
+
camera: Camera;
|
|
44
|
+
/**
|
|
45
|
+
* clearColor is the color that will be used to clear the screen at the beginning of each frame
|
|
46
|
+
* you can also think of this as the background color of the canvas
|
|
47
|
+
*/
|
|
48
|
+
clearColor: Color;
|
|
49
|
+
/**
|
|
50
|
+
* it's unlikely that you want to use the constructor directly.
|
|
51
|
+
* see {@link Toodle.attach} for creating a Toodle instance that draws to a canvas.
|
|
52
|
+
*/
|
|
53
|
+
constructor(device: GPUDevice, context: GPUCanvasContext, presentationFormat: GPUTextureFormat, canvas: HTMLCanvasElement, resolution: Resolution, options: ToodleOptions);
|
|
54
|
+
/**
|
|
55
|
+
* Screen shader is an optional slot for post-processing effects.
|
|
56
|
+
* Note that this will do the main render pass to an offscreen texture, which may impact performance.
|
|
57
|
+
*/
|
|
58
|
+
get postprocess(): PostProcess | null;
|
|
59
|
+
set postprocess(value: PostProcess | null);
|
|
60
|
+
/**
|
|
61
|
+
* call resize when the canvas is resized.
|
|
62
|
+
* this will update the projection matrix and the resolution.
|
|
63
|
+
*
|
|
64
|
+
* @param resolution - the resolution of the canvas in logical pixels.
|
|
65
|
+
* this should be `canvas.clientWidth x canvas.clientHeight` and NOT `canvas.width * canvas.height`
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
*
|
|
69
|
+
* const canvas = document.querySelector("canvas")!
|
|
70
|
+
*
|
|
71
|
+
* const observer = new ResizeObserver((entries) => {
|
|
72
|
+
* if (entries.length === 0) return
|
|
73
|
+
* toodle.resize({ width: canvas.clientWidth, height: canvas.clientHeight })
|
|
74
|
+
* })
|
|
75
|
+
*
|
|
76
|
+
* observer.observe(canvas)
|
|
77
|
+
*/
|
|
78
|
+
resize(resolution: Resolution): void;
|
|
79
|
+
/**
|
|
80
|
+
* The resolution of the canvas in css or logical pixels.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
*
|
|
84
|
+
* // devicePixelRatio is 1, resolution is 200x200
|
|
85
|
+
* <canvas width="200" height="200" style="width: 200px; height: 200px;"></canvas>
|
|
86
|
+
* // devicePixelRatio is 2, resolution is 100x100
|
|
87
|
+
* <canvas width="200" height="200" style="width: 100px; height: 100px;"></canvas>
|
|
88
|
+
*/
|
|
89
|
+
get resolution(): Resolution;
|
|
90
|
+
/**
|
|
91
|
+
* Returns the currently configured Toodle engine limits
|
|
92
|
+
*
|
|
93
|
+
* See: https://toodle.gg/f849595b3ed13fc956fc1459a5cb5f0228f9d259/limits.html
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
*
|
|
97
|
+
* const instanceLimit: number = toodle.limits.instanceCount;
|
|
98
|
+
*/
|
|
99
|
+
get limits(): Limits;
|
|
100
|
+
get batcher(): Batcher;
|
|
101
|
+
/**
|
|
102
|
+
* The maximum number of pixels that can be loaded into texture atlases for this toodle instance.
|
|
103
|
+
*/
|
|
104
|
+
get maxPixels(): number;
|
|
105
|
+
/**
|
|
106
|
+
* The maximum amount of GPU memory that will be used by the Toodle instance.
|
|
107
|
+
* This is a rough estimate and may not be exact. This will be allocated up front when calling Toodle.attach, and freed when calling toodle.destroy.
|
|
108
|
+
*/
|
|
109
|
+
get maxGpuMemory(): number;
|
|
110
|
+
/**
|
|
111
|
+
* call startFrame before drawing anything.
|
|
112
|
+
* this will create a new encoder and render pass.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
*
|
|
116
|
+
* toodle.startFrame();
|
|
117
|
+
* // draw stuff
|
|
118
|
+
* toodle.endFrame();
|
|
119
|
+
*/
|
|
120
|
+
startFrame(options?: StartFrameOptions): void;
|
|
121
|
+
/**
|
|
122
|
+
* call draw in between start frame and end frame to enqueue an instanced draw call.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
*
|
|
126
|
+
* toodle.assets.loadTexture("myImage", "assets/image.png");
|
|
127
|
+
* const quad = toodle.Quad("myImage");
|
|
128
|
+
*
|
|
129
|
+
* toodle.startFrame();
|
|
130
|
+
* toodle.draw(quad);
|
|
131
|
+
* toodle.endFrame();
|
|
132
|
+
*/
|
|
133
|
+
draw(node: SceneNode): void;
|
|
134
|
+
/**
|
|
135
|
+
* call end frame to run through enqueued draw calls and submit them to the GPU.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
*
|
|
139
|
+
* toodle.startFrame();
|
|
140
|
+
* // draw stuff
|
|
141
|
+
* toodle.endFrame();
|
|
142
|
+
*/
|
|
143
|
+
endFrame(): void;
|
|
144
|
+
/**
|
|
145
|
+
* Convert a point from one coordinate space to another.
|
|
146
|
+
*
|
|
147
|
+
* @param point - The point to convert.
|
|
148
|
+
* @param options - The options for the conversion.
|
|
149
|
+
* @returns The converted point.
|
|
150
|
+
*/
|
|
151
|
+
convertSpace(point: Point, options: {
|
|
152
|
+
from: "screen" | "world";
|
|
153
|
+
to: "world" | "screen";
|
|
154
|
+
}): Point;
|
|
155
|
+
/**
|
|
156
|
+
* The number of frames rendered since this Toodle instance was created.
|
|
157
|
+
*/
|
|
158
|
+
get frameCount(): number;
|
|
159
|
+
/**
|
|
160
|
+
* Create a custom shader for quad instances. In some engines, this might be called a material.
|
|
161
|
+
*
|
|
162
|
+
* @param label Debug name of the shader
|
|
163
|
+
* @param instanceCount - The maximum number of instances that will be processed by the shader. Note that a worst-case buffer of this many instances will be immediately allocated.
|
|
164
|
+
* @param userCode - The WGSL code to be used for the shader.
|
|
165
|
+
* @param blendMode - The blend mode to be used for the shader.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
*
|
|
169
|
+
*
|
|
170
|
+
*/
|
|
171
|
+
QuadShader(label: string, instanceCount: number, userCode: string, shaderOpts?: QuadShaderOpts): QuadShader;
|
|
172
|
+
/**
|
|
173
|
+
* Create a new quad node.
|
|
174
|
+
*
|
|
175
|
+
* @param assetId - The ID of the asset to use for the quad. This must have been loaded with toodle.assets.loadBundle.
|
|
176
|
+
*
|
|
177
|
+
* @param options - QuadOptions for Quad creation
|
|
178
|
+
* @param options
|
|
179
|
+
* @example
|
|
180
|
+
*
|
|
181
|
+
* await toodle.assets.loadTextures({
|
|
182
|
+
* "myImage": new URL("assets/image.png"),
|
|
183
|
+
* });
|
|
184
|
+
* const quad = toodle.Quad("myImage");
|
|
185
|
+
*
|
|
186
|
+
* toodle.startFrame();
|
|
187
|
+
* toodle.draw(quad);
|
|
188
|
+
* toodle.endFrame();
|
|
189
|
+
*/
|
|
190
|
+
Quad(assetId: TextureId, options?: QuadOptions): QuadNode;
|
|
191
|
+
/**
|
|
192
|
+
* Create a jumbo quad node. This contains multiple tiles for a single texture.
|
|
193
|
+
*
|
|
194
|
+
* @param assetId - The ID of the asset to use for the jumbo quad. This must have been loaded with toodle.assets.loadTextures.
|
|
195
|
+
*
|
|
196
|
+
* @param options - QuadOptions for Quad creation
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
199
|
+
JumboQuad(assetId: TextureId, options: JumboQuadOptions): JumboQuadNode;
|
|
200
|
+
/**
|
|
201
|
+
* Create a new container node.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
*
|
|
205
|
+
* const node = toodle.Node();
|
|
206
|
+
* const child = node.add(toodle.Node());
|
|
207
|
+
* node.position = [100, 100];
|
|
208
|
+
* console.log(child.matrix);
|
|
209
|
+
*/
|
|
210
|
+
Node(nodeOpts?: NodeOptions): SceneNode;
|
|
211
|
+
Text(fontId: string, text: string, textOpts?: TextOptions): TextNode;
|
|
212
|
+
shapes: {
|
|
213
|
+
Rect: (options?: QuadOptions) => QuadNode;
|
|
214
|
+
Circle: (options?: QuadOptions) => QuadNode;
|
|
215
|
+
Line: (options: LineOptions) => QuadNode;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Attach toodle to a canvas.
|
|
219
|
+
*
|
|
220
|
+
* @param canvas - The canvas to attach toodle to.
|
|
221
|
+
* @param options - ToodleOptions for the creation of the toodle instance
|
|
222
|
+
* @returns A promise that resolves to a Toodle instance.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
*
|
|
226
|
+
* const canvas = document.createElement("canvas");
|
|
227
|
+
*
|
|
228
|
+
* const toodle = await Toodle.attach(canvas);
|
|
229
|
+
*/
|
|
230
|
+
static attach(canvas: HTMLCanvasElement, options?: ToodleOptions): Promise<Toodle>;
|
|
231
|
+
/**
|
|
232
|
+
* Destroy the toodle instance and release its gpu and cpu resources.
|
|
233
|
+
*
|
|
234
|
+
* Note that calling any methods on the instance after this result in undefined behavior.
|
|
235
|
+
*/
|
|
236
|
+
destroy(): void;
|
|
237
|
+
/**
|
|
238
|
+
* Advanced and niche features
|
|
239
|
+
*/
|
|
240
|
+
extra: {
|
|
241
|
+
/**
|
|
242
|
+
* Get the GPU device used by this Toodle instance.
|
|
243
|
+
*/
|
|
244
|
+
device: () => GPUDevice;
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
export type StartFrameOptions = {
|
|
248
|
+
/**
|
|
249
|
+
* The load operation to use for the render pass.
|
|
250
|
+
*
|
|
251
|
+
* **clear**: clear the current texture to the clear color. necessary if you're using toodle without another renderer.
|
|
252
|
+
*
|
|
253
|
+
* **load**: blend the render pass with the current canvas contents. useful if you're using toodle alongside another renderer like painter or pixi.js
|
|
254
|
+
*
|
|
255
|
+
* @default "clear"
|
|
256
|
+
*
|
|
257
|
+
*/
|
|
258
|
+
loadOp?: "load" | "clear";
|
|
259
|
+
};
|
|
260
|
+
export type ToodleOptions = {
|
|
261
|
+
/**
|
|
262
|
+
* The filter mode to use for the default quad shader.
|
|
263
|
+
* see: https://webgpufundamentals.org/webgpu/lessons/webgpu-textures.html#a-mag-filter
|
|
264
|
+
*
|
|
265
|
+
* **nearest**: nearest neighbor sampling. makes pixel art look sharp and vector art look jaggy.
|
|
266
|
+
*
|
|
267
|
+
* **linear**: linear sampling. makes vector art look smooth and pixel art look blurry.
|
|
268
|
+
*
|
|
269
|
+
* @default "linear"
|
|
270
|
+
*/
|
|
271
|
+
filter?: "nearest" | "linear";
|
|
272
|
+
limits?: LimitsOptions;
|
|
273
|
+
};
|
|
274
|
+
export type LineOptions = {
|
|
275
|
+
/**
|
|
276
|
+
* The start position of the line.
|
|
277
|
+
*/
|
|
278
|
+
start: Point;
|
|
279
|
+
/**
|
|
280
|
+
* The end position of the line.
|
|
281
|
+
*/
|
|
282
|
+
end: Point;
|
|
283
|
+
/**
|
|
284
|
+
* The color of the line.
|
|
285
|
+
*/
|
|
286
|
+
color: Color;
|
|
287
|
+
/**
|
|
288
|
+
* The thickness of the line.
|
|
289
|
+
*/
|
|
290
|
+
thickness?: number;
|
|
291
|
+
/**
|
|
292
|
+
* The shader to use for the line.
|
|
293
|
+
*/
|
|
294
|
+
shader?: IShader;
|
|
295
|
+
/**
|
|
296
|
+
* The layer to draw the line on.
|
|
297
|
+
*/
|
|
298
|
+
layer?: number;
|
|
299
|
+
/**
|
|
300
|
+
* A unique identifier for the line.
|
|
301
|
+
*/
|
|
302
|
+
key?: string;
|
|
303
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toodle.d.ts","sourceRoot":"","sources":["../../src/Toodle.ts"],"names":[],"mappings":"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"}
|