1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 04:12:02 +08:00

improve hmr with __hmrId

This commit is contained in:
Kevin Levron 2020-09-19 16:40:58 +02:00
parent 2bbdf4b04c
commit 17e334444d
13 changed files with 18 additions and 4 deletions

View File

@ -32,4 +32,5 @@ export default {
render() {
return [];
},
__hmrId: 'PerspectiveCamera',
};

View File

@ -6,4 +6,5 @@ export default {
created() {
this.light = new AmbientLight(this.color, this.intensity);
},
__hmrId: 'AmbientLight',
};

View File

@ -6,4 +6,5 @@ export default {
created() {
this.light = new DirectionalLight(this.color, this.intensity);
},
__hmrId: 'DirectionalLight',
};

View File

@ -33,4 +33,5 @@ export default {
render() {
return [];
},
__hmrId: 'Light',
};

View File

@ -16,4 +16,5 @@ export default {
created() {
this.light = new PointLight(this.color, this.intensity, this.distance, this.decay);
},
__hmrId: 'PointLight',
};

View File

@ -24,4 +24,5 @@ export default {
created() {
this.light = new SpotLight(this.color, this.intensity, this.distance, this.angle, this.penumbra, this.decay);
},
__hmrId: 'SpotLight',
};

View File

@ -27,4 +27,5 @@ export default {
this.geometry = new BoxBufferGeometry(this.width, this.height, this.depth);
}
},
__hmrId: 'Box',
};

View File

@ -22,4 +22,5 @@ export default {
// this material is not mounted, it won't be auto dispose
this.material.dispose();
},
__hmrId: 'Image',
};

View File

@ -41,4 +41,5 @@ export default {
render() {
return this.$slots.default();
},
__hmrId: 'InstancedMesh',
};

View File

@ -45,4 +45,5 @@ export default {
render() {
return [];
},
__hmrId: 'Mesh',
};

View File

@ -24,4 +24,5 @@ export default {
created() {
this.geometry = new PlaneBufferGeometry(this.width, this.height, this.widthSegments, this.heightSegments);
},
__hmrId: 'Plane',
};

View File

@ -17,4 +17,5 @@ export default {
created() {
this.geometry = new SphereBufferGeometry(this.radius, this.widthSegments, this.heightSegments);
},
__hmrId: 'Sphere',
};

View File

@ -2,9 +2,11 @@ import { toRef, watch } from 'vue';
import { setFromProp } from '../tools.js';
export default function useBindProp(comp, prop, object) {
const ref = toRef(comp, prop);
setFromProp(object, ref.value);
watch(ref, () => {
if (comp[prop]) {
const ref = toRef(comp, prop);
setFromProp(object, ref.value);
}, { deep: true });
watch(ref, () => {
setFromProp(object, ref.value);
}, { deep: true });
}
};