Чтобы обойти эту проблему, мне пришлось переделать теневой компонент, чтобы иметь флаг для контроля, если также затрагиваются дочерние элементы.Было бы интересно узнать, есть ли лучший способ сделать это.
AFRAME.registerComponent('custom-shadow', {
schema: {
cast: {type: 'boolean', default: true},
receive: {type: 'boolean', default: true},
applyToChildren: {type: 'boolean', default: true}
},
multiple: false, //do not allow multiple instances of this component on this entity
init: function() {
this.applyShadow();
this.el.addEventListener('object3dset', this.applyShadow.bind(this));
},
applyShadow : function () {
const data = this.data;
const mesh = this.el.getObject3D('mesh');
if (!mesh) return;
mesh.traverse(function (node) {
node.castShadow = data.cast;
node.receiveShadow = data.receive;
if (data.applyToChildren) {
return;
}
});
},
update: function (oldData) {
this.applyShadow.bind(this);
}
});