mirror of
https://github.com/troisjs/trois.git
synced 2024-11-24 04:12:02 +08:00
wip
This commit is contained in:
parent
3ecaaad06a
commit
440a854417
@ -5,7 +5,7 @@ import Mesh from './Mesh.js';
|
|||||||
export default {
|
export default {
|
||||||
extends: Mesh,
|
extends: Mesh,
|
||||||
props: {
|
props: {
|
||||||
size: { type: Number },
|
size: Number,
|
||||||
width: { type: Number, default: 1 },
|
width: { type: Number, default: 1 },
|
||||||
height: { type: Number, default: 1 },
|
height: { type: Number, default: 1 },
|
||||||
depth: { type: Number, default: 1 },
|
depth: { type: Number, default: 1 },
|
||||||
|
@ -22,27 +22,34 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.mesh = new InstancedMesh(this.geometry, this.three.materials[this.materialId], this.count);
|
this.initMesh();
|
||||||
|
|
||||||
useBindProp(this, 'position', this.mesh.position);
|
|
||||||
useBindProp(this, 'rotation', this.mesh.rotation);
|
|
||||||
useBindProp(this, 'scale', this.mesh.scale);
|
|
||||||
|
|
||||||
['castShadow', 'receiveShadow'].forEach(p => {
|
|
||||||
this.mesh[p] = this[p];
|
|
||||||
watch(() => this[p], () => { this.mesh[p] = this[p]; });
|
|
||||||
});
|
|
||||||
|
|
||||||
// watch(() => this.materialId, () => {
|
|
||||||
// this.mesh.material = this.three.materials[this.materialId];
|
|
||||||
// });
|
|
||||||
|
|
||||||
this.scene.add(this.mesh);
|
|
||||||
},
|
},
|
||||||
unmounted() {
|
unmounted() {
|
||||||
this.scene.remove(this.mesh);
|
this.scene.remove(this.mesh);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
initMesh() {
|
||||||
|
if (!this.material && this.materialId) {
|
||||||
|
this.material = this.three.materials[this.materialId];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.mesh = new InstancedMesh(this.geometry, this.material, this.count);
|
||||||
|
|
||||||
|
useBindProp(this, 'position', this.mesh.position);
|
||||||
|
useBindProp(this, 'rotation', this.mesh.rotation);
|
||||||
|
useBindProp(this, 'scale', this.mesh.scale);
|
||||||
|
|
||||||
|
['castShadow', 'receiveShadow'].forEach(p => {
|
||||||
|
this.mesh[p] = this[p];
|
||||||
|
watch(() => this[p], () => { this.mesh[p] = this[p]; });
|
||||||
|
});
|
||||||
|
|
||||||
|
// watch(() => this.materialId, () => {
|
||||||
|
// this.mesh.material = this.three.materials[this.materialId];
|
||||||
|
// });
|
||||||
|
|
||||||
|
this.scene.add(this.mesh);
|
||||||
|
},
|
||||||
setGeometry(geometry) {
|
setGeometry(geometry) {
|
||||||
this.geometry = geometry;
|
this.geometry = geometry;
|
||||||
if (this.mesh) this.mesh.geometry = geometry;
|
if (this.mesh) this.mesh.geometry = geometry;
|
||||||
|
Loading…
Reference in New Issue
Block a user