webglmusti 0.0.0
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/.gitattributes +2 -0
- package/idea_list.txt +13 -0
- package/index.html +17 -0
- package/package.json +20 -0
- package/public/apple.png +0 -0
- package/public/base.png +0 -0
- package/public/car.png +0 -0
- package/public/drop.png +0 -0
- package/public/font16-Sheet.png +0 -0
- package/public/font16-Sheet.txt +52 -0
- package/public/letters-Sheet.png +0 -0
- package/public/letters-Sheet.txt +27 -0
- package/public/letters_Sheet.png +0 -0
- package/public/letters_Sheet.txt +4 -0
- package/public/vite.svg +1 -0
- package/src/App/ResourceSim/car.ts +172 -0
- package/src/App/ResourceSim/grid.ts +993 -0
- package/src/App/ResourceSim/grid_app.ts +1326 -0
- package/src/App/ResourceSim/grid_test.test.ts +18 -0
- package/src/App/ResourceSim/node_graph.ts +293 -0
- package/src/App/ResourceSim/nodes.ts +151 -0
- package/src/App/ResourceSim/resource.ts +8 -0
- package/src/App/ResourceSim/texts.ts +6 -0
- package/src/App/card/card.test.ts +22 -0
- package/src/App/card/card.ts +763 -0
- package/src/App/puzzle_box/app.ts +10 -0
- package/src/App/puzzle_box/engine.ts +374 -0
- package/src/App/puzzle_box/renderer.ts +102 -0
- package/src/App/puzzle_box/test.test.ts +49 -0
- package/src/App/water/water.ts +206 -0
- package/src/Interface/button.ts +345 -0
- package/src/Interface/interface_element.ts +30 -0
- package/src/Interface/internal_window.ts +100 -0
- package/src/Interface/options.ts +332 -0
- package/src/Interface/text_input.ts +183 -0
- package/src/WebGL/Matrix/matrix.test.ts +30 -0
- package/src/WebGL/Matrix/matrix.ts +293 -0
- package/src/WebGL/Shaders/Fragment/Program/circle.ts +49 -0
- package/src/WebGL/Shaders/Fragment/Program/circle_only.ts +47 -0
- package/src/WebGL/Shaders/Fragment/Program/circle_outline.ts +54 -0
- package/src/WebGL/Shaders/Fragment/Program/colour.ts +39 -0
- package/src/WebGL/Shaders/Fragment/Program/colour_alpha.ts +37 -0
- package/src/WebGL/Shaders/Fragment/Program/line.ts +39 -0
- package/src/WebGL/Shaders/Fragment/Program/multi_colour_centre_circle_path.ts +69 -0
- package/src/WebGL/Shaders/Fragment/Program/multi_colour_path.ts +69 -0
- package/src/WebGL/Shaders/Fragment/Program/path_centre_circle.ts +69 -0
- package/src/WebGL/Shaders/Fragment/Program/rect_outline.ts +39 -0
- package/src/WebGL/Shaders/Fragment/Program/solid_path.ts +64 -0
- package/src/WebGL/Shaders/Fragment/Program/sprite_sheet.ts +54 -0
- package/src/WebGL/Shaders/Fragment/Program/sprite_sheet_colour.ts +62 -0
- package/src/WebGL/Shaders/Fragment/Program/texture.ts +34 -0
- package/src/WebGL/Shaders/Fragment/Source/circle.frag +19 -0
- package/src/WebGL/Shaders/Fragment/Source/circle_only.frag +15 -0
- package/src/WebGL/Shaders/Fragment/Source/circle_outline.frag +23 -0
- package/src/WebGL/Shaders/Fragment/Source/colour.frag +9 -0
- package/src/WebGL/Shaders/Fragment/Source/colour_alpha.frag +7 -0
- package/src/WebGL/Shaders/Fragment/Source/fragment.frag +5 -0
- package/src/WebGL/Shaders/Fragment/Source/fragment_source.ts +15 -0
- package/src/WebGL/Shaders/Fragment/Source/line.frag +12 -0
- package/src/WebGL/Shaders/Fragment/Source/multi_colour_centre_circle_path.frag +36 -0
- package/src/WebGL/Shaders/Fragment/Source/multi_colour_path.frag +34 -0
- package/src/WebGL/Shaders/Fragment/Source/path_centre_circle.frag +29 -0
- package/src/WebGL/Shaders/Fragment/Source/rect_outline.frag +20 -0
- package/src/WebGL/Shaders/Fragment/Source/solid_path.frag +24 -0
- package/src/WebGL/Shaders/Fragment/Source/sprite_sheet.frag +17 -0
- package/src/WebGL/Shaders/Fragment/Source/sprite_sheet_colour.frag +19 -0
- package/src/WebGL/Shaders/Fragment/Source/texture.frag +11 -0
- package/src/WebGL/Shaders/Fragment/fragment.ts +43 -0
- package/src/WebGL/Shaders/Fragment/fragment_old.ts +261 -0
- package/src/WebGL/Shaders/Vertex/Program/mvp2d.ts +41 -0
- package/src/WebGL/Shaders/Vertex/Program/transform2d.ts +39 -0
- package/src/WebGL/Shaders/Vertex/Source/mvp2d.vert +17 -0
- package/src/WebGL/Shaders/Vertex/Source/mvp_i_2d.vert +18 -0
- package/src/WebGL/Shaders/Vertex/Source/simple.vert +9 -0
- package/src/WebGL/Shaders/Vertex/Source/transform2d.vert +13 -0
- package/src/WebGL/Shaders/Vertex/Source/transform2d_rel.vert +16 -0
- package/src/WebGL/Shaders/Vertex/Source/translate2d.vert +7 -0
- package/src/WebGL/Shaders/Vertex/Source/vertex_source.ts +13 -0
- package/src/WebGL/Shaders/Vertex/vertex.ts +10 -0
- package/src/WebGL/Shaders/Vertex/vertex_old.ts +289 -0
- package/src/WebGL/Shaders/custom.ts +129 -0
- package/src/WebGL/Shaders/shader.ts +197 -0
- package/src/WebGL/Shapes/Line.ts +29 -0
- package/src/WebGL/Shapes/Shapes.ts +189 -0
- package/src/WebGL/Texture/texture.ts +214 -0
- package/src/WebGL/Util/file.ts +24 -0
- package/src/WebGL/app.ts +150 -0
- package/src/WebGL/colour.ts +71 -0
- package/src/WebGL/globals.ts +353 -0
- package/src/WebGL/index.ts +3 -0
- package/src/WebGL/mixin.ts +2 -0
- package/src/global.d.ts +13 -0
- package/src/index.ts +4 -0
- package/src/main.ts +139 -0
- package/src/utils/array.ts +154 -0
- package/src/utils/assert.ts +8 -0
- package/src/utils/file.ts +0 -0
- package/src/utils/mixin.ts +22 -0
- package/src/utils/numbers.ts +11 -0
- package/src/utils/utils.test.ts +23 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +25 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
precision mediump float;
|
|
2
|
+
|
|
3
|
+
varying vec2 v_position;
|
|
4
|
+
varying vec2 v_relative;
|
|
5
|
+
|
|
6
|
+
uniform sampler2D u_texture_id;
|
|
7
|
+
uniform float u_width;
|
|
8
|
+
uniform float u_height;
|
|
9
|
+
uniform float u_x;
|
|
10
|
+
uniform float u_y;
|
|
11
|
+
|
|
12
|
+
void main(){
|
|
13
|
+
float px = (u_x+v_relative.x)/u_width;
|
|
14
|
+
float py = (u_y+v_relative.y)/u_height;
|
|
15
|
+
|
|
16
|
+
gl_FragColor = texture2D(u_texture_id, vec2(px, py));
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
precision mediump float;
|
|
2
|
+
|
|
3
|
+
varying vec2 v_position;
|
|
4
|
+
varying vec2 v_relative;
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
uniform sampler2D u_texture_id;
|
|
8
|
+
uniform float u_width;
|
|
9
|
+
uniform float u_height;
|
|
10
|
+
uniform float u_x;
|
|
11
|
+
uniform float u_y;
|
|
12
|
+
uniform vec3 u_colour; //colour
|
|
13
|
+
|
|
14
|
+
void main(){
|
|
15
|
+
float px = (u_x+v_relative.x)/u_width;
|
|
16
|
+
float py = (u_y+v_relative.y)/u_height;
|
|
17
|
+
|
|
18
|
+
gl_FragColor = texture2D(u_texture_id, vec2(px, py)).a*vec4(u_colour, 1.0);
|
|
19
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as Shader from './../shader';
|
|
2
|
+
import * as Circle from './Program/circle';
|
|
3
|
+
import * as CircleOnly from './Program/circle_only'
|
|
4
|
+
import * as CircleOutline from './Program/circle_outline';
|
|
5
|
+
import * as Colour from './Program/colour';
|
|
6
|
+
import * as ColourAlpha from './Program/colour_alpha';
|
|
7
|
+
import * as Line from './Program/line';
|
|
8
|
+
import * as PathCentreCircle from './Program/path_centre_circle';
|
|
9
|
+
import * as MultiColourPath from './Program/multi_colour_path';
|
|
10
|
+
import * as RectOutline from './Program/rect_outline';
|
|
11
|
+
import * as SolidPath from './Program/solid_path';
|
|
12
|
+
import * as SpriteSheet from './Program/sprite_sheet';
|
|
13
|
+
import * as Texture from './Program/texture';
|
|
14
|
+
import * as MultiColourCentreCirclePath from './Program/multi_colour_centre_circle_path'
|
|
15
|
+
import * as SpriteSheetColour from './Program/sprite_sheet_colour'
|
|
16
|
+
|
|
17
|
+
export function loadFragmentShaders(){
|
|
18
|
+
Circle.CircleFragmentShader.load();
|
|
19
|
+
CircleOutline.CircleOutlineFragmentShader.load();
|
|
20
|
+
//Colour.ColourFragmentShader.load();
|
|
21
|
+
Line.LineFragmentShader.load();
|
|
22
|
+
MultiColourPath.MultiColourPathFragmentShader.load();
|
|
23
|
+
PathCentreCircle.PathCentreCircleFragmentShader.load();
|
|
24
|
+
RectOutline.RectOutlineFragmentShader.load();
|
|
25
|
+
SolidPath.SolidPathFragmentShader.load();
|
|
26
|
+
SpriteSheet.SpriteSheetFragmentShader.load();
|
|
27
|
+
Texture.TextureFragmentShader.load();
|
|
28
|
+
MultiColourCentreCirclePath.MultiColourCentreCirclePathFragmentShader.load();
|
|
29
|
+
}
|
|
30
|
+
export const CircleMixin = Circle.CircleShaderProgramMix;
|
|
31
|
+
export const CircleOnlyMixin = CircleOnly.CircleOnlyShaderProgramMix;
|
|
32
|
+
export const CircleOutlineMixin = CircleOutline.CircleOutlineShaderProgramMix;
|
|
33
|
+
export const ColourMixin = Colour.ColourShaderProgramMix;
|
|
34
|
+
export const ColourAlphaMixin = ColourAlpha.ColourAlphaShaderProgramMix;
|
|
35
|
+
export const LineMixin = Line.LineShaderProgramMix;
|
|
36
|
+
export const MultiColourPathMixin = MultiColourPath.MultiColourPathShaderProgramMix;
|
|
37
|
+
export const PathCentreCircleMixin = PathCentreCircle.PathCentreCircleShaderProgramMix;
|
|
38
|
+
export const RectOutlineMixin = RectOutline.RectOutlineShaderProgramMix;
|
|
39
|
+
export const SolidPathMixin = SolidPath.SolidPathShaderProgramMix;
|
|
40
|
+
export const SpriteSheetMixin = SpriteSheet.SpriteSheetShaderProgramMix;
|
|
41
|
+
export const TextureMixin = Texture.TextureShaderProgramMix;
|
|
42
|
+
export const MultiColourCentreCirclePathMixin = MultiColourCentreCirclePath.MultiColourCentreCirclePathShaderProgramMix;
|
|
43
|
+
export const SpriteSheetColourMixin = SpriteSheetColour.SpriteSheetColourShaderProgramMix;
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import * as Shader from '../shader';
|
|
2
|
+
import * as FragmentSource from './Source/fragment_source';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import * as SolidPath from './Program/solid_path'
|
|
6
|
+
|
|
7
|
+
export function loadFragmentShaders(){
|
|
8
|
+
SimpleFragmentShader.load();
|
|
9
|
+
ColourFragmentShader.load();
|
|
10
|
+
CircleFragmentShader.load();
|
|
11
|
+
OutlineCircleFragmentShader.load();
|
|
12
|
+
OutlineRectFragmentShader.load();
|
|
13
|
+
SolidLineFragmentShader.load();
|
|
14
|
+
SolidPathFragmentShader.load();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class SimpleFragmentShader{
|
|
18
|
+
static shader?: Shader.FragmentShader;
|
|
19
|
+
static load(){
|
|
20
|
+
if(this.shader == undefined){
|
|
21
|
+
this.shader = new Shader.FragmentShader();
|
|
22
|
+
if(!this.shader.addSource(FragmentSource.simple)){
|
|
23
|
+
console.log("Simple: fragment source not added");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class ColourFragmentShader{
|
|
30
|
+
static shader?: Shader.FragmentShader;
|
|
31
|
+
static load(){
|
|
32
|
+
if(!this.shader){
|
|
33
|
+
this.shader = new Shader.FragmentShader();
|
|
34
|
+
if(!this.shader.addSource(FragmentSource.colour)){
|
|
35
|
+
console.log("Colour: fragment source not added");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class CircleFragmentShader{
|
|
42
|
+
static shader?: Shader.FragmentShader;
|
|
43
|
+
static load(){
|
|
44
|
+
if(!this.shader){
|
|
45
|
+
this.shader = new Shader.FragmentShader();
|
|
46
|
+
if(!this.shader.addSource(FragmentSource.circle)){
|
|
47
|
+
console.log("Circle: fragment source not added");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export class OutlineCircleFragmentShader{
|
|
54
|
+
static shader?: Shader.FragmentShader;
|
|
55
|
+
static load(){
|
|
56
|
+
if(!this.shader){
|
|
57
|
+
this.shader = new Shader.FragmentShader();
|
|
58
|
+
if(!this.shader.addSource(FragmentSource.circle_outline)){
|
|
59
|
+
console.log("Circle outline: source not added");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export class OutlineRectFragmentShader{
|
|
66
|
+
static shader?: Shader.FragmentShader;
|
|
67
|
+
static load(){
|
|
68
|
+
if(!this.shader){
|
|
69
|
+
this.shader = new Shader.FragmentShader();
|
|
70
|
+
if(!this.shader.addSource(FragmentSource.rect_outline)){
|
|
71
|
+
console.log("Rect outline: source not added");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export class SolidLineFragmentShader{
|
|
78
|
+
static shader?: Shader.FragmentShader;
|
|
79
|
+
static load(){
|
|
80
|
+
if(!this.shader){
|
|
81
|
+
this.shader = new Shader.FragmentShader();
|
|
82
|
+
if(!this.shader.addSource(FragmentSource.solid_line)){
|
|
83
|
+
console.log("SolidLine: source not added");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export class SolidPathFragmentShader{
|
|
90
|
+
static shader?: Shader.FragmentShader;
|
|
91
|
+
static load(){
|
|
92
|
+
if(!this.shader){
|
|
93
|
+
this.shader = new Shader.FragmentShader();
|
|
94
|
+
if(!this.shader.addSource(FragmentSource.solid_path)){
|
|
95
|
+
console.log("SolidPath: source not added");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function ColourShaderProgramMixin<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
|
|
102
|
+
return class Colour extends Base{
|
|
103
|
+
private declare colour_uniform_location: WebGLUniformLocation | null;
|
|
104
|
+
protected override setupFragment(){
|
|
105
|
+
this.fragment_name = "ColourShader";
|
|
106
|
+
if(ColourFragmentShader.shader){
|
|
107
|
+
this.program.addFragment(ColourFragmentShader.shader);
|
|
108
|
+
}else{
|
|
109
|
+
throw new Error(`${this.fragment_name} not loaded`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
protected override addFragmentUniformLocations(): void {
|
|
113
|
+
this.colour_uniform_location = this.program.getUniformLocation("colour");
|
|
114
|
+
}
|
|
115
|
+
setColour(r: GLfloat, g: GLfloat, b: GLfloat){
|
|
116
|
+
this.program.setFloat3(this.colour_uniform_location!, r, g, b);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function CircleShaderProgramMixin<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
|
|
122
|
+
return class Circle extends Base{
|
|
123
|
+
private declare radius_uniform_location: WebGLUniformLocation | null;
|
|
124
|
+
private declare centre_uniform_location: WebGLUniformLocation | null;
|
|
125
|
+
private declare circle_colour_uniform_location: WebGLUniformLocation | null;
|
|
126
|
+
protected override setupFragment(){
|
|
127
|
+
this.fragment_name = "CircleShader";
|
|
128
|
+
if(CircleFragmentShader.shader){
|
|
129
|
+
this.program.addFragment(CircleFragmentShader.shader);
|
|
130
|
+
}else{
|
|
131
|
+
throw new Error(`${this.fragment_name} not loaded`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
protected override addFragmentUniformLocations(): void{
|
|
135
|
+
this.radius_uniform_location = this.program.getUniformLocation("u_radius");
|
|
136
|
+
this.centre_uniform_location = this.program.getUniformLocation("u_centre");
|
|
137
|
+
this.circle_colour_uniform_location = this.program.getUniformLocation("u_circle_colour");
|
|
138
|
+
}
|
|
139
|
+
setRadius(r: GLfloat){
|
|
140
|
+
this.program.setFloat(this.radius_uniform_location!, r);
|
|
141
|
+
}
|
|
142
|
+
setCentre(x: GLfloat, y: GLfloat){
|
|
143
|
+
this.program.setFloat2(this.centre_uniform_location!, x, y);
|
|
144
|
+
}
|
|
145
|
+
setCircleColour(r: GLfloat, g: GLfloat, b: GLfloat){
|
|
146
|
+
this.program.setFloat3(this.circle_colour_uniform_location!, r, g, b);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function CircleOutlineShaderProgramMixin<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
|
|
152
|
+
return class CircleOutline extends Base{
|
|
153
|
+
private declare radius_uniform_location: WebGLUniformLocation | null;
|
|
154
|
+
private declare centre_uniform_location: WebGLUniformLocation | null;
|
|
155
|
+
private declare outline_radius_uniform_location: WebGLUniformLocation | null;
|
|
156
|
+
private declare outline_colour_uniform_location: WebGLUniformLocation | null;
|
|
157
|
+
protected override setupFragment(){
|
|
158
|
+
this.fragment_name = "CircleOutlineShader";
|
|
159
|
+
if(OutlineCircleFragmentShader.shader){
|
|
160
|
+
this.program.addFragment(OutlineCircleFragmentShader.shader);
|
|
161
|
+
}else{
|
|
162
|
+
throw new Error(`${this.fragment_name} not loaded`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
protected override addFragmentUniformLocations(): void{
|
|
166
|
+
this.radius_uniform_location = this.program.getUniformLocation("u_radius");
|
|
167
|
+
this.centre_uniform_location = this.program.getUniformLocation("u_centre");
|
|
168
|
+
this.outline_radius_uniform_location = this.program.getUniformLocation("u_outline_radius");
|
|
169
|
+
this.outline_colour_uniform_location = this.program.getUniformLocation("u_outline_colour");
|
|
170
|
+
}
|
|
171
|
+
setRadius(r: GLfloat){
|
|
172
|
+
this.program.setFloat(this.radius_uniform_location!, r);
|
|
173
|
+
}
|
|
174
|
+
setCentre(x: GLfloat, y: GLfloat){
|
|
175
|
+
this.program.setFloat2(this.centre_uniform_location!, x, y);
|
|
176
|
+
}
|
|
177
|
+
setOutlineRadius(r: GLfloat){
|
|
178
|
+
this.program.setFloat(this.outline_radius_uniform_location!, r);
|
|
179
|
+
}
|
|
180
|
+
setOutlineColour(r: GLfloat, g: GLfloat, b: GLfloat, a: GLfloat=1.0){
|
|
181
|
+
this.program.setFloat4(this.outline_colour_uniform_location!, r, g, b, a);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function RectOutlineShaderProgramMixin<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
|
|
187
|
+
return class RectOutline extends Base{
|
|
188
|
+
private declare outline_colour_uniform_location: WebGLUniformLocation | null;
|
|
189
|
+
private declare outline_ratio_uniform_location: WebGLUniformLocation | null;
|
|
190
|
+
protected override setupFragment(){
|
|
191
|
+
this.fragment_name = "RectOutlineShader";
|
|
192
|
+
if(OutlineRectFragmentShader.shader){
|
|
193
|
+
this.program.addFragment(OutlineRectFragmentShader.shader);
|
|
194
|
+
}else{
|
|
195
|
+
throw new Error(`${this.fragment_name} not loaded`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
protected override addFragmentUniformLocations(): void{
|
|
199
|
+
this.outline_colour_uniform_location = this.program.getUniformLocation("u_outline_colour");
|
|
200
|
+
this.outline_ratio_uniform_location = this.program.getUniformLocation("u_outline_ratio");
|
|
201
|
+
}
|
|
202
|
+
setOutlineRatio(r: GLfloat){
|
|
203
|
+
this.program.setFloat(this.outline_ratio_uniform_location!, r);
|
|
204
|
+
}
|
|
205
|
+
setOutlineColour(r: GLfloat, g: GLfloat, b: GLfloat, a: GLfloat=1.0){
|
|
206
|
+
this.program.setFloat4(this.outline_colour_uniform_location!, r, g, b, a);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function SolidLineShaderProgramMixin<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
|
|
212
|
+
return class SolidLine extends Base{
|
|
213
|
+
private declare equation_uniform_location: WebGLUniformLocation | null;
|
|
214
|
+
private declare thickness_uniform_location: WebGLUniformLocation | null;
|
|
215
|
+
protected override setupFragment(){
|
|
216
|
+
this.fragment_name = "SolidLineShader";
|
|
217
|
+
if(SolidLineFragmentShader.shader){
|
|
218
|
+
this.program.addFragment(SolidLineFragmentShader.shader);
|
|
219
|
+
}else{
|
|
220
|
+
throw new Error(`${this.fragment_name} not loaded`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
protected override addFragmentUniformLocations(): void {
|
|
224
|
+
this.equation_uniform_location = this.program.getUniformLocation("u_equation");
|
|
225
|
+
this.thickness_uniform_location = this.program.getUniformLocation("u_thickness");
|
|
226
|
+
}
|
|
227
|
+
setThickness(thickness:GLfloat){
|
|
228
|
+
this.program.setFloat(this.thickness_uniform_location!, thickness);
|
|
229
|
+
}
|
|
230
|
+
setEquation(a: number, b: number, c: number){
|
|
231
|
+
this.program.setFloat3(this.equation_uniform_location!, a, b, c);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export function SolidPathShaderProgramMixin<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
|
|
237
|
+
return class SolidPath extends Base{
|
|
238
|
+
private declare colour_uniform_location: WebGLUniformLocation | null;
|
|
239
|
+
private declare size_uniform_location: WebGLUniformLocation | null;
|
|
240
|
+
private declare left_uniform_location: WebGLUniformLocation | null;
|
|
241
|
+
protected override setupFragment(){
|
|
242
|
+
this.fragment_name = "SolidPathShader";
|
|
243
|
+
if(SolidPathFragmentShader.shader){
|
|
244
|
+
this.program.addFragment(SolidPathFragmentShader.shader);
|
|
245
|
+
}else{
|
|
246
|
+
throw new Error(`${this.fragment_name} not loaded`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
protected override addFragmentUniformLocations(): void {
|
|
250
|
+
this.colour_uniform_location = this.program.getUniformLocation("u_colour");
|
|
251
|
+
this.size_uniform_location = this.program.getUniformLocation("u_size");
|
|
252
|
+
this.left_uniform_location = this.program.getUniformLocation("u_left");
|
|
253
|
+
}
|
|
254
|
+
setSize(thickness:GLfloat){
|
|
255
|
+
this.program.setFloat(this.size_uniform_location!, thickness);
|
|
256
|
+
}
|
|
257
|
+
setColour(r: number, g: number, b: number){
|
|
258
|
+
this.program.setFloat3(this.colour_uniform_location!, r, g, b);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Mvp2d from './../Source/mvp2d.vert?raw';
|
|
2
|
+
import * as Matrix from './../../../Matrix/matrix';
|
|
3
|
+
import * as Shader from './../../shader';
|
|
4
|
+
|
|
5
|
+
export class Mvp2dVertexShader{
|
|
6
|
+
static shader?: Shader.VertexShader;
|
|
7
|
+
static load(){
|
|
8
|
+
if(this.shader == undefined){
|
|
9
|
+
this.shader = new Shader.VertexShader();
|
|
10
|
+
if(!this.shader.addSource(Mvp2d)){
|
|
11
|
+
console.log('Mvp2d: vertex source not added');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function Mvp2dShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
|
|
18
|
+
return class Mvp2d extends Base{
|
|
19
|
+
private declare position_attribute_location: GLint | null;
|
|
20
|
+
private declare relative_attribute_location: GLint | null;
|
|
21
|
+
private declare mvp_uniform_location: WebGLUniformLocation | null;
|
|
22
|
+
protected override setupVertex(){
|
|
23
|
+
this.vertex_name = 'Mvp2dShader';
|
|
24
|
+
if(Mvp2dVertexShader.shader){
|
|
25
|
+
this.program.addVertex(Mvp2dVertexShader.shader)
|
|
26
|
+
}else{
|
|
27
|
+
throw new Error(`${this.vertex_name} not loaded`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
protected override addVertexAttributeLocations(): void{
|
|
31
|
+
this.position_attribute_location = this.program.getAttributeLocation('a_position');
|
|
32
|
+
this.relative_attribute_location = this.program.getAttributeLocation('a_relative');
|
|
33
|
+
}
|
|
34
|
+
protected override addVertexUniformLocations(): void{
|
|
35
|
+
this.mvp_uniform_location = this.program.getUniformLocation('u_mvp');
|
|
36
|
+
}
|
|
37
|
+
setMvp(mat: Matrix.Matrix3x3){
|
|
38
|
+
this.program.setMat3(this.mvp_uniform_location!, mat.matrix);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import Transform2d from './../Source/transform2d.vert?raw';
|
|
2
|
+
import * as Matrix from './../../../Matrix/matrix';
|
|
3
|
+
import * as Shader from './../../shader';
|
|
4
|
+
|
|
5
|
+
export class Transform2dVertexShader{
|
|
6
|
+
static shader?: Shader.VertexShader;
|
|
7
|
+
static load(){
|
|
8
|
+
if(this.shader == undefined){
|
|
9
|
+
this.shader = new Shader.VertexShader();
|
|
10
|
+
if(!this.shader.addSource(Transform2d)){
|
|
11
|
+
console.log('Transform2d: vertex source not added');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function Transform2dShaderProgramMix<TBase extends Shader.CustomShaderProgramable>(Base: TBase){
|
|
18
|
+
return class Transform2d extends Base{
|
|
19
|
+
private declare position_attribute_location: GLint | null;
|
|
20
|
+
private declare matrix_uniform_location: WebGLUniformLocation | null;
|
|
21
|
+
protected override setupVertex(){
|
|
22
|
+
this.vertex_name = 'Transform2dShader';
|
|
23
|
+
if(Transform2dVertexShader.shader){
|
|
24
|
+
this.program.addVertex(Transform2dVertexShader.shader)
|
|
25
|
+
}else{
|
|
26
|
+
throw new Error(`${this.vertex_name} not loaded`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
protected override addVertexAttributeLocations(): void{
|
|
30
|
+
this.position_attribute_location = this.program.getAttributeLocation('position');
|
|
31
|
+
}
|
|
32
|
+
protected override addVertexUniformLocations(): void{
|
|
33
|
+
this.matrix_uniform_location = this.program.getUniformLocation('u_matrix');
|
|
34
|
+
}
|
|
35
|
+
setMatrix(mat: Matrix.Matrix3x3){
|
|
36
|
+
this.program.setMat3(this.matrix_uniform_location!, mat.matrix);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
attribute vec2 a_position; // pos 0
|
|
2
|
+
attribute vec2 a_relative; // pos 1
|
|
3
|
+
|
|
4
|
+
uniform mat3 u_mvp;
|
|
5
|
+
//uniform mat3 u_view;
|
|
6
|
+
|
|
7
|
+
varying vec2 v_position;
|
|
8
|
+
varying vec2 v_relative;
|
|
9
|
+
|
|
10
|
+
void main(){
|
|
11
|
+
vec2 position = (u_mvp*vec3(a_position, 1)).xy;
|
|
12
|
+
|
|
13
|
+
gl_Position = vec4(position, 1.0, 1.0);
|
|
14
|
+
|
|
15
|
+
v_position = position;
|
|
16
|
+
v_relative = a_relative;
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
attribute vec2 a_position; // pos 0
|
|
2
|
+
attribute vec2 a_relative; // pos 1
|
|
3
|
+
|
|
4
|
+
uniform mat3 u_model;
|
|
5
|
+
uniform mat3 u_view;
|
|
6
|
+
uniform mat3 u_perspective;
|
|
7
|
+
|
|
8
|
+
varying vec2 v_position;
|
|
9
|
+
varying vec2 v_relative;
|
|
10
|
+
|
|
11
|
+
void main(){
|
|
12
|
+
vec2 position = (u_perspective*u_view*u_model*vec3(a_position, 1)).xy;
|
|
13
|
+
|
|
14
|
+
gl_Position = vec4(position, 1.0, 1.0);
|
|
15
|
+
|
|
16
|
+
v_position = position;
|
|
17
|
+
v_relative = a_relative;
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
attribute vec2 a_position; // pos 0
|
|
2
|
+
attribute vec2 a_relative; // pos 1
|
|
3
|
+
|
|
4
|
+
uniform mat3 u_matrix;
|
|
5
|
+
|
|
6
|
+
varying vec2 v_position;
|
|
7
|
+
varying vec2 v_relative;
|
|
8
|
+
|
|
9
|
+
void main(){
|
|
10
|
+
vec2 position = (u_matrix*vec3(a_position, 1)).xy;
|
|
11
|
+
|
|
12
|
+
gl_Position = vec4(position, 1.0, 1.0);
|
|
13
|
+
|
|
14
|
+
v_position = position;
|
|
15
|
+
v_relative = a_relative;
|
|
16
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Simple from "./simple.vert?raw";
|
|
2
|
+
import Translate from "./translate2d.vert?raw"
|
|
3
|
+
import Transform from "./transform2d.vert?raw"
|
|
4
|
+
import TransformRelative from "./transform2d_rel.vert?raw"
|
|
5
|
+
import MVPRel from "./mvp2d.vert?raw";
|
|
6
|
+
import MVPIRel from "./mvp_i_2d.vert?raw"
|
|
7
|
+
|
|
8
|
+
export const simple = Simple;
|
|
9
|
+
export const translate = Translate;
|
|
10
|
+
export const transform = Transform;
|
|
11
|
+
export const transform_rel = TransformRelative;
|
|
12
|
+
export const mvp_rel = MVPRel;
|
|
13
|
+
export const mvp_i_rel = MVPIRel;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as Shader from './../shader';
|
|
2
|
+
import * as Mvp2d from './Program/mvp2d';
|
|
3
|
+
import * as Transform2d from './Program/transform2d';
|
|
4
|
+
|
|
5
|
+
export function loadVertexShaders(){
|
|
6
|
+
Mvp2d.Mvp2dVertexShader.load();
|
|
7
|
+
Transform2d.Transform2dVertexShader.load();
|
|
8
|
+
}
|
|
9
|
+
export const Mvp2dMixin = Mvp2d.Mvp2dShaderProgramMix(Shader.ShaderProgramMixin);
|
|
10
|
+
export const Transform2dMixin = Transform2d.Transform2dShaderProgramMix(Shader.ShaderProgramMixin);
|