javascript - 混合纹理(aframe/js)
问题描述
我有一个 360 度的电影图片,当你点击某个东西时,我尝试制作它,图片从一张浅色电影图片混合到一张深色电影图片,因此看起来灯熄灭了。一些想法我如何在 js 函数中编码?
<a-scene>
<a-assets>
<img id="cinema" src="cinema360degree.png">
<img id="cinema_dark" src="cinema360degree_dark.png">
<img id="button" src="playbutton.png">
</a-assets>
<a-image id="playit" src="#button" width="4" height="4" position="-28 5 15" rotation="0 90 0" onclick="startmovie()"></a-image>
<a-sky src="#cinema"></a-sky>
<script type="text/javascript">
function startmovie() {
//blend cinema into cinemadark
// i got this but it only change it. Its not blending:
//document.getElementById('skyid').setAttribute('src', '#cinema_dark')
}
</script>
</a-scene>
解决方案
我制作了两个球体,一个具有“白天”纹理,另一个具有“夜晚”纹理:
<a-sphere id="day" radius="100" material="side: back"></a-sphere>
<a-sphere id="night" radius="101" material="side: back"></a-sphere>
并使用动画组件,将当天的不透明度改为0:
Js:
AFRAME.registerComponent("foo", {
init: function() {
document.querySelector("#day").addEventListener("click", (e) => {
this.el.emit("fadeout")
})
}
})
html:
<a-sphere id="one" foo animation="property: material.opacity; to: 0;
delay: 500; startEvents: fadeout;"></a-sphere>
在这里 查看。
推荐阅读
- ocean - 如何使用 C# 控制台应用程序中的“ocean petrel API”运行模拟案例
- sql - SQL如何在LIKE命令中传递sysdate?
- ios - UIImagePickerController 仅显示 Videos 文件夹,但不显示 Selfies 和 Slo-mo 等其他文件夹
- delegates - 在 Func 委托中调用 Func 委托的方法
- python - 如何使用 python 和 selenium 在注册页面上解决可点击的验证码,如 recaptcha v2?
- r - 哪种回归算法可用于校正传感器值?
- properties - 如何设置硒化物属性?
- swift - Publisher 需要哪些协议存根?
- javascript - JS 发送带有 django 标签的 html
- android - 如何找出给定 .apk 中的哪个架构版本用于给定的应用程序安装?