Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/477.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 什么';这是三元混合的混合方程吗?_Javascript_Three.js - Fatal编程技术网

Javascript 什么';这是三元混合的混合方程吗?

Javascript 什么';这是三元混合的混合方程吗?,javascript,three.js,Javascript,Three.js,我在文件里找不到它。谁能告诉我等式是什么 我认为它等于以下三个 blending: THREE.CustomBlending, blendEquation: THREE.AddEquation, blendSrc: THREE.SrcAlphaFactor, blendDst: THREE.OneMinusSrcAlphaFactor 但是,当我将材质从NormalBlending更改为上面的CustomBlending时,会得到不同的结果 这是关于默认的自定义

我在文件里找不到它。谁能告诉我等式是什么

我认为它等于以下三个

    blending: THREE.CustomBlending,
    blendEquation: THREE.AddEquation,
    blendSrc: THREE.SrcAlphaFactor,
    blendDst: THREE.OneMinusSrcAlphaFactor
但是,当我将材质从
NormalBlending
更改为上面的
CustomBlending
时,会得到不同的结果

这是关于默认的
自定义混合

根据材质是否标记为使用预乘alpha,不同的Three.js混合模式是不同的

因此,如果材料被认为是预乘的,那么它应该与

blending: THREE.CustomBlending,
blendEquation: THREE.AddEquation,
blendSrc: THREE.OneFactor,
blendDst: THREE.OneMinusSrcAlphaFactor
否则就是

blending: THREE.CustomBlending,
blendEquation: THREE.AddEquation,
blendSrc: THREE.SrcAlphaFactor,
blendSrcAlpha: THREE.OneFactor,
blendDst: THREE.OneMinusSrcAlphaFactor
“严格使用”;
常量nonPremultipledBlend={
调合:3.调合,
混合方程式:3.加法方程式,
blendSrc:3.5倍,
混合阿尔法:3.1因素,
BlendSt:3.1因子,
};
常量premultipledBlend={
调合:3.调合,
混合方程式:3.加法方程式,
blendSrc:3.1因素,
BlendSt:3.1因子,
};
const renderer=new THREE.WebGLRenderer();
document.body.appendChild(renderer.doElement);
常量摄影机=新的三个正交摄影机(-1.5,1.5,1,-1,-1,1);
摄像机位置z=1;
const scene=new THREE.scene();
常量几何=新的三个平面几何(.5、.5);
[
{颜色:0xFF8080,x:-.6,y:0,z:0.2,},
{颜色:0x008040,x:-.30,y:-.25,z:0.1,},
{color:0x008040,x:-.90,y:-.25,z:0.1,blend:nonPremultipledBlend,},
{颜色:0xFF8080,x:.6,y:0,z:0.2,},
{color:0x008040,x:.30,y:-.25,z:0.1,pre:true,},
{color:0x008040,x:.90,y:-.25,z:0.1,pre:true,blend:premultipledBlend,},
].forEach(信息=>{
常量材质=新的三网格基本材质({
颜色:info.color,
透明:是的,
不透明度:.5,
});
如果(信息预处理){
material.premultipliedAlpha=info.pre;
}
如果(信息混合){
分配对象(材质、信息混合);
}
常量网格=新的三个网格(几何体、材质);
场景。添加(网格);
mesh.position.x=info.x;
mesh.position.y=info.y;
mesh.position.z=info.z;
});
渲染器。渲染(场景、摄影机)
body{margin:0;}
画布{宽度:100vw;高度:100vh;显示块;}

非常感谢您一直回答我的问题!根据阿尔法合成方程,
blendst
因子应为
DstAlpha*(1-SrcAlpha)
。但是上面的等式只是
1-SrcAlpha
。为什么?