Skip to content

Commit

Permalink
Merge branch 'master' into fix_scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
patriciogonzalezvivo authored Oct 29, 2022
2 parents e5c8183 + 445df57 commit 736a365
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ As you can see, in this example we are loading the fragment shader by setting th
* ```data-vertex-url``` : load a vertex shader by providing a valid url
* ```data-textures```: add a list of texture urls separated by commas (ex: ```data-textures="texture.jpg,normal_map.png,something.jpg"```). Textures will be assigned in order to ```uniform sampler2D``` variables with names following this style: ```u_tex0```, ```u_tex1```, ```u_tex2```, etc.

All the catched ```.glslCanvas``` element whill be stored in the ```windows.glslCanvases``` array.
All the cached ```.glslCanvas``` elements will be stored in the ```windows.glslCanvases``` array.

### The JS way

Expand All @@ -48,11 +48,11 @@ var canvas = document.createElement("canvas");
var sandbox = new GlslCanvas(canvas);
```

In the case you need to reload the
In case you need to reload the shader:

### Reloading shaders from JS

You can change the content of the shader as many times you want. Here are some examples:
You can change the content of the shader as many times as you want. Here are some examples:

```javascript
// Load only the Fragment Shader
Expand Down
2 changes: 2 additions & 0 deletions dist/GlslCanvas.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,8 @@ var Texture = function () {
this.sourceType = 'element';

if (element instanceof HTMLVideoElement) {
this.width = this.source.videoWidth;
this.height = this.source.videoHeight;
element.addEventListener('canplaythrough', function () {
_this2.intervalID = setInterval(function () {
_this2.update(options);
Expand Down
2 changes: 2 additions & 0 deletions dist/GlslCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -1230,6 +1230,8 @@ var Texture = function () {
this.sourceType = 'element';

if (element instanceof HTMLVideoElement) {
this.width = this.source.videoWidth;
this.height = this.source.videoHeight;
element.addEventListener('canplaythrough', function () {
_this2.intervalID = setInterval(function () {
_this2.update(options);
Expand Down
3 changes: 1 addition & 2 deletions dist/GlslCanvas.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/GlslCanvas.min.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/GlslCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,8 @@ var Texture = function () {
this.sourceType = 'element';

if (element instanceof HTMLVideoElement) {
this.width = this.source.videoWidth;
this.height = this.source.videoHeight;
element.addEventListener('canplaythrough', function () {
_this2.intervalID = setInterval(function () {
_this2.update(options);
Expand Down
9 changes: 9 additions & 0 deletions src/gl/Texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ export default class Texture {
if (isVideo) {
element = document.createElement('video');
element.autoplay = true;


element.muted = true; /* required for modern browsers to autoplay video */
setTimeout(function () {
element.play() /* doesn't block promise but needs a more elegant solution */
}, 1);

options.filtering = 'nearest';
// element.preload = 'auto';
// element.style.display = 'none';
Expand Down Expand Up @@ -157,6 +164,8 @@ export default class Texture {
this.sourceType = 'element';

if (element instanceof HTMLVideoElement) {
this.width = this.source.videoWidth;
this.height = this.source.videoHeight;
element.addEventListener('canplaythrough', () => {
this.intervalID = setInterval(()=>{
this.update(options);
Expand Down

0 comments on commit 736a365

Please sign in to comment.