fragment-shader
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -39,3 +39,3 @@ import { errorStyles } from '../util/editor'; | ||
export default class CodeEditor { | ||
private config: EditorConfig; | ||
public config: EditorConfig; | ||
private state: EditorState; | ||
@@ -42,0 +42,0 @@ private view: EditorView; |
@@ -27,2 +27,3 @@ import { createShaderEditor } from '../util/editor'; | ||
this.onError = this.onError.bind(this); | ||
this.onResize = this.onResize.bind(this); | ||
this.editor = createShaderEditor({ | ||
@@ -32,3 +33,7 @@ ...this.config, | ||
}); | ||
this.shader = new Shader({ ...this.config, onError: this.onError }); | ||
this.shader = new Shader({ | ||
...this.config, | ||
onError: this.onError, | ||
onResize: this.onResize, | ||
}); | ||
} | ||
@@ -46,2 +51,8 @@ | ||
onResize() { | ||
this.editor.config.width = this.shader.config.width; | ||
this.editor.config.height = this.shader.config.height; | ||
this.editor.applyCSSVariables(); | ||
} | ||
rebuild(config: { shader?: string; uniforms?: UniformValue[] } = {}) { | ||
@@ -48,0 +59,0 @@ const { |
@@ -35,2 +35,3 @@ import Uniform from './Uniform'; | ||
onSuccess: () => {}, | ||
onResize: () => {}, | ||
}; | ||
@@ -69,2 +70,4 @@ | ||
console.log(this.config); | ||
this.state = { | ||
@@ -171,2 +174,3 @@ active: false, | ||
this.ctx?.viewport(0, 0, this.canvas.width, this.canvas.height); | ||
this.config?.onResize?.(); | ||
} | ||
@@ -265,2 +269,3 @@ | ||
this.ctx?.viewport(0, 0, this.canvas.width, this.canvas.height); | ||
this.config?.onResize?.(); | ||
} | ||
@@ -267,0 +272,0 @@ |
{ | ||
"name": "fragment-shader", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "A lightweight, performant WebGL fragment shader renderer + editor. ", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -11,2 +11,3 @@ export interface ShaderConfig { | ||
onError?: Function; | ||
onResize?: Function; | ||
animate?: boolean; | ||
@@ -13,0 +14,0 @@ debug?: boolean; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44685
1300