Skip to content

Instantly share code, notes, and snippets.

@demicuz
Last active April 27, 2021 08:50
Show Gist options
  • Save demicuz/6e859457ce754bf8aaa0e8e6141e8308 to your computer and use it in GitHub Desktop.
Save demicuz/6e859457ce754bf8aaa0e8e6141e8308 to your computer and use it in GitHub Desktop.
Additional keyboard bindings for shaderoo.org, plus a minor improvement. Can be used with an extension such as "Custom Javascript for Websites".
editor.commands.addCommand({
name: 'ApplyShaderCode',
bindKey: {win: 'Alt-Enter', mac: 'Alt-Enter'},
exec: function(editor) {
reloadShadersAndRedraw();
},
readOnly: true
});
editor.commands.addCommand({
name: 'PlayPause',
bindKey: {win: 'Ctrl-Enter', mac: 'Cmd-Enter'},
exec: function(editor) {
togglePlay();
},
readOnly: true
});
editor.commands.addCommand({
name: 'SaveShader',
bindKey: {win: 'Ctrl-S', mac: 'Cmd-S'},
exec: function(editor) {
document.getElementById("saveDBButton").click();
},
readOnly: true
});
// Disable page scroll when hovering over canvas or timeline
function preventScroll(event) {
event.preventDefault();
}
const shader_canvas = document.getElementById('glcanvas');
shader_canvas.addEventListener('wheel', preventScroll);
const shader_timeline = document.getElementById('TimelineCanvas');
shader_timeline.addEventListener('wheel', preventScroll);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment