mirror of
https://github.com/troisjs/trois.git
synced 2024-11-23 20:02:32 +08:00
improve materials
This commit is contained in:
parent
73425177e5
commit
e174da23c6
@ -67,7 +67,7 @@ export default defineComponent({
|
||||
this.setProp(key, texture, true)
|
||||
},
|
||||
addWatchers() {
|
||||
['color', 'alphaTest', 'depthTest', 'depthWrite', 'fog', 'opacity', 'side', 'transparent'].forEach(p => {
|
||||
['color', 'alphaTest', 'blending', 'depthTest', 'depthWrite', 'fog', 'opacity', 'side', 'transparent'].forEach(p => {
|
||||
// @ts-ignore
|
||||
watch(() => this[p], (value) => {
|
||||
if (p === 'color') {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { defineComponent, watch } from 'vue'
|
||||
import { ShaderMaterial } from 'three'
|
||||
import Material from './Material'
|
||||
import { propsValues } from '../tools'
|
||||
|
||||
const defaultVertexShader = `
|
||||
varying vec2 vUv;
|
||||
@ -26,23 +27,15 @@ export default defineComponent({
|
||||
},
|
||||
methods: {
|
||||
createMaterial() {
|
||||
const material = new ShaderMaterial({
|
||||
uniforms: this.uniforms,
|
||||
vertexShader: this.vertexShader,
|
||||
fragmentShader: this.fragmentShader,
|
||||
})
|
||||
const material = new ShaderMaterial(propsValues(this.$props, ['color']));
|
||||
|
||||
const watchProps = ['vertexShader', 'fragmentShader']
|
||||
watchProps.forEach(p => {
|
||||
['vertexShader', 'fragmentShader'].forEach(p => {
|
||||
// @ts-ignore
|
||||
watch(() => this[p], (value) => {
|
||||
this.setProp(p, value, true)
|
||||
})
|
||||
watch(() => this[p], (value) => { material[p] = value; material.needsUpdate = true })
|
||||
})
|
||||
|
||||
return material
|
||||
},
|
||||
addWatchers() {},
|
||||
},
|
||||
__hmrId: 'ShaderMaterial',
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user