Hi,
I got a problem to render an animation from a object transparent (glass), The issue is when I try to make an animation from 0 to 1, in the first times all is great, but when the value of opacty turns to 1 all my object is bad.
This is the way to load my entity on the scene
<a-entity
id="mezcla"
gltf-model="/assets/fbx_oldfashioned000/scene.gltf"
position="0 0 0"
scale="4 4 4"
vanish-opacity-target
animation='property: vanish-opacity-target.opacity;
from: 0; to: 1; dur: 5000;loop: false;
dir: alternate; startEvents: fadeIn'
visible="true">
</a-entity>
and the custom source for animation is:
AFRAME.registerComponent('vanish-opacity-target', {
multiple: true,
schema: {opacity: {default: 1}},
init: function () {
this.el.addEventListener('fadeOut', this.update.bind(this));
this.el.addEventListener('fadeIn', this.update.bind(this));
},
update: function () {
var mesh = this.el.getObject3D('mesh');
var data = this.data;
if (!mesh) { return; }
mesh.traverse(function (node) {
if (node.isMesh) {
var material = node.material
node.material.opacity = data.opacity;
if (node.isMesh) {
node.material.depthWrite = !node.material.transparent;
}
node.material.needsUpdate = true;
}else{
if(data.opacity == 0){
node.visible = false
node.opacity = 0
}else{
node.visible = true
}
}
});
},
});
Finally this is the result:
first image, from simple loader a-frame (all is OK)
An the second image, after animation: opacity 0 to 1 value (Bad result)
Any suggestions?
Thanks in advanced.
model3d => oldfashioned.zip (3.3 MB)