mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
improve material hmr
This commit is contained in:
parent
0a0e495e2c
commit
9250eca910
@ -21,10 +21,10 @@ I will try to rewrite some of my [WebGL demos](https://codepen.io/collection/AGZ
|
|||||||
Thanks to VueJS/ViteJS, **TroisJS use watchers and HMR to update ThreeJS objects when you update a template**. This means the result in your browser will be automatically updated without reloading all the stuff. **This is really helpful when you are creating a TroisJS Scene**.
|
Thanks to VueJS/ViteJS, **TroisJS use watchers and HMR to update ThreeJS objects when you update a template**. This means the result in your browser will be automatically updated without reloading all the stuff. **This is really helpful when you are creating a TroisJS Scene**.
|
||||||
|
|
||||||
- [ ] HMR
|
- [ ] HMR
|
||||||
- [x] Camera : position
|
- [x] PerspectiveCamera : aspect, far, fov, near, position
|
||||||
- [x] Light : position
|
- [x] Light : position
|
||||||
- [x] Material : color
|
- [x] Material : color, depthTest, depthWrite, fog, opacity, transparent
|
||||||
- [x] Mesh : position, rotation ,scale
|
- [x] Mesh : position, rotation, scale
|
||||||
- [ ] ...
|
- [ ] ...
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
@ -19,7 +19,7 @@ export default {
|
|||||||
},
|
},
|
||||||
fog: {
|
fog: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: true,
|
||||||
},
|
},
|
||||||
opacity: {
|
opacity: {
|
||||||
type: Number,
|
type: Number,
|
||||||
@ -40,8 +40,15 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.three.materials[this.id] = this.material;
|
this.three.materials[this.id] = this.material;
|
||||||
watch(() => this.color, () => {
|
|
||||||
this.material.color = new Color(this.color);
|
['color', 'depthTest', 'depthWrite', 'fog', 'opacity', 'transparent'].forEach(p => {
|
||||||
|
watch(() => this[p], () => {
|
||||||
|
if (p === 'color') {
|
||||||
|
this.material.color = new Color(this.color);
|
||||||
|
} else {
|
||||||
|
this.material[p] = this[p];
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
unmounted() {
|
unmounted() {
|
||||||
|
Loading…
Reference in New Issue
Block a user