Spe*_*ctr 5 javascript three.js tweenmax gsap
我需要像这里一样用液体效果实现图像变化
我有一个带图像的简单块我需要onmouseover用此效果更改此图像(到其他图像)并返回到初始位置onmouseout也使用此效果
const avatarQuantumBreak = document.querySelector(".avatar_quantum_break");
const avatar = document.querySelector(".avatar");
avatarQuantumBreak.style.opacity = "0";
let hover = () => avatarQuantumBreak.style.opacity = "1";
let normal = () => avatarQuantumBreak.style.opacity = "0";
avatar.onmouseover = () => hover();
avatar.onmouseout = () => normal();Run Code Online (Sandbox Code Playgroud)
html , body {
height:100%;
}
.avatar {
position: relative;
border-radius: 50%;
display: flex;
justify-content: center;
height: 195px;
}
.avatar_simple,
.avatar_quantum_break {
position: absolute;
display: block;
text-align:center;
transition: opacity 1s ease-out;
}
.avatar .avatar_simple img,
.avatar .avatar_quantum_break img {
border-radius: 50%;
display: inline-block;
width: 86%;
height: 100%;
}Run Code Online (Sandbox Code Playgroud)
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.0.2/TweenMax.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/97/three.min.js"></script>
<div class=avatar>
<span class=avatar_simple>
<img src="https://pixel.nymag.com/imgs/fashion/daily/2014/05/27/27-amber-heard.w330.h330.jpg">
</span>
<span class=avatar_quantum_break>
<img src="https://pixel.nymag.com/imgs/daily/vulture/2016/05/31/31-amber-heard.w330.h330.jpg">
</span>
</div>Run Code Online (Sandbox Code Playgroud)
transition触发液体动画的图像功能 如下
transitionNext() {
TweenMax.to(this.mat.uniforms.dispPower, 2.5, {
value: 1,
ease: Expo.easeInOut,
onUpdate: this.render,
onComplete: () => {
this.mat.uniforms.dispPower.value = 0.0
this.changeTexture()
this.render.bind(this)
this.state.animating = false
}
})
Run Code Online (Sandbox Code Playgroud)
我尝试使用这个功能,但这对我没有帮助.
此外,我尝试更改此Array 行中的图像15, 但这也没有帮助.
this.images = [ //1
'https://s3-us-west-2.amazonaws.com/s.cdpn.io/58281/bg1.jpg',
'https://s3-us-west-2.amazonaws.com/s.cdpn.io/58281/bg2.jpg',
'https://s3-us-west-2.amazonaws.com/s.cdpn.io/58281/bg3.jpg'
]
Run Code Online (Sandbox Code Playgroud)
这个功能开始动画
listeners() {
window.addEventListener('wheel', this.nextSlide, { passive: true })
}
Run Code Online (Sandbox Code Playgroud)
下一张幻灯片功能
nextSlide() {
if (this.state.animating) return
this.state.animating = true
this.transitionNext()
this.data.current = this.data.current === this.data.total ? 0 : this.data.current + 1
this.data.next = this.data.current === this.data.total ? 0 : this.data.current + 1
}
Run Code Online (Sandbox Code Playgroud)
请帮忙..