最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to change the video on scroll according to sections of the page - Stack Overflow

programmeradmin1浏览0评论
if (child.name === "Computer") {    
   child.children[1].material = new THREE.MeshBasicMaterial({       
      map: this.resources.items.screen,     
   }); 
}

For example in this scenario i need to add different screens on scroll of different sections of page

How to achieve it?

if (child.name === "Computer") {    
   child.children[1].material = new THREE.MeshBasicMaterial({       
      map: this.resources.items.screen,     
   }); 
}

For example in this scenario i need to add different screens on scroll of different sections of page

How to achieve it?

Share Improve this question edited Feb 1 at 17:47 James Z 12.3k10 gold badges27 silver badges47 bronze badges asked Feb 1 at 11:39 Yashraj TarteYashraj Tarte 311 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

You just have to update it once you change the map. It would be better if you create the material first, outside any function and surly out side the for loop, the apply it like:

const myMaterial = new THREE.MeshBasicMaterial({
  map: this.resources.items.screen,
});


if (child.name === "Computer") {
  child.children[1].material = myMaterial;
} 

And once you update this.resources.items.screen, you can do this:

myMaterial.needsUpdate = true;

Ref: https://threejs./docs/#api/en/materials/Material.needsUpdate

发布评论

评论列表(0)

  1. 暂无评论