-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from 2xAA/2.0-plugins
2.0 plugins
- Loading branch information
Showing
16 changed files
with
191 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<template> | ||
<div> | ||
<input type="text" @keypress.enter="search" class="input"> | ||
<ul> | ||
<li | ||
class="is-light" | ||
v-for="result in results" | ||
@click="makeModule(result)" | ||
>{{ result.info.name }}</li> | ||
</ul> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import ModuleShader from '@/modv/Modules/ModuleShader'; | ||
import { modV } from '@/modv'; | ||
import axios from 'axios'; | ||
const appKey = 'rt8KwW'; | ||
const url = 'https://www.shadertoy.com/api/v1'; | ||
function getShaders(shaderIds) { | ||
const promises = []; | ||
shaderIds.forEach((id) => { | ||
promises.push( | ||
axios.get(`${url}/shaders/${id}`, { | ||
params: { | ||
key: appKey, | ||
}, | ||
}), | ||
); | ||
}); | ||
return Promise.all(promises); | ||
} | ||
export default { | ||
name: 'ShadertoyGallery', | ||
data() { | ||
return { | ||
results: [], | ||
}; | ||
}, | ||
methods: { | ||
async search(e) { | ||
axios.get(`${url}/shaders/query/${e.target.value}`, { | ||
params: { | ||
key: appKey, | ||
}, | ||
}) | ||
.then(response => getShaders(response.data.Results)) | ||
.then((shaders) => { | ||
this.results = shaders | ||
.map(response => response.data.Shader) | ||
.filter(shader => shader.renderpass.length < 2); | ||
}); | ||
}, | ||
makeModule(result) { | ||
const code = result.renderpass[0].code; | ||
class newModule extends ModuleShader { | ||
constructor() { | ||
super({ | ||
info: { | ||
name: result.info.name, | ||
author: result.info.username, | ||
version: 0.1, | ||
uniforms: {}, | ||
}, | ||
fragmentShader: code, | ||
}); | ||
} | ||
} | ||
modV.register(newModule); | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import store from '@/../store'; | ||
import shadertoyStore from './store'; | ||
import galleryTabComponent from './Gallery'; | ||
|
||
const shaderToy = { | ||
name: 'Shadertoy', | ||
galleryTabComponent, | ||
|
||
/** | ||
* Only called when added as a Vue plugin, | ||
* this must be registered with vue before modV | ||
* to use vuex or vue | ||
*/ | ||
install(Vue) { | ||
Vue.component(galleryTabComponent.name, galleryTabComponent); | ||
|
||
store.registerModule('shaderToy', shadertoyStore); | ||
}, | ||
}; | ||
|
||
export default shaderToy; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.