From 3844b109f234e1bbc523aa852d305da6c53a9c00 Mon Sep 17 00:00:00 2001 From: Kevin Levron Date: Fri, 12 Mar 2021 23:14:49 +0100 Subject: [PATCH] improve ShaderMaterial --- src/materials/ShaderMaterial.js | 3 ++- src/tools.js | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/materials/ShaderMaterial.js b/src/materials/ShaderMaterial.js index a4ed919..b2f20a2 100644 --- a/src/materials/ShaderMaterial.js +++ b/src/materials/ShaderMaterial.js @@ -5,12 +5,13 @@ import { propsValues, defaultFragmentShader, defaultVertexShader } from '../tool export default { inject: ['three', 'mesh'], props: { - uniforms: { type: Object, default: () => {} }, + uniforms: { type: Object, default: () => { return {}; } }, vertexShader: { type: String, default: defaultVertexShader }, fragmentShader: { type: String, default: defaultFragmentShader }, }, created() { this.createMaterial(); + console.log(this.uniforms); ['vertexShader', 'fragmentShader'].forEach(p => { watch(() => this[p], () => { // recreate material if we change either shader diff --git a/src/tools.js b/src/tools.js index 4e61729..8d7c5d7 100644 --- a/src/tools.js +++ b/src/tools.js @@ -77,15 +77,13 @@ function getMatcapFormatString(format) { // shader defaults export const defaultVertexShader = ` varying vec2 vUv; - void main(){ - vUv = uv; - gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0); + vUv = uv; + gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0); }`; export const defaultFragmentShader = ` varying vec2 vUv; - void main() { gl_FragColor = vec4(vUv.x, vUv.y, 0., 1.0); -}`; \ No newline at end of file +}`;