Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

distance 函数到底从哪里来的 #5

Open
liyihongcug opened this issue Mar 29, 2019 · 2 comments
Open

distance 函数到底从哪里来的 #5

liyihongcug opened this issue Mar 29, 2019 · 2 comments

Comments

@liyihongcug
Copy link

Tools-16PrimitivePoints.js

"varying vec4 v_color;
void main()
{
float d = distance(gl_PointCoord, vec2(0.5,0.5));
if(d < 0.5){
gl_FragColor = v_color;
}else{
discard;
}
}
";

找了半天没有找到这个 distance 到底从哪里来的

@liyihongcug
Copy link
Author

在Expression.js

function distance(call, left, right) {
    if (typeof left === 'number' && typeof right === 'number') {
        return Math.abs(left - right);
    } else if (left instanceof Cartesian2 && right instanceof Cartesian2) {
        return Cartesian2.distance(left, right);
    } else if (left instanceof Cartesian3 && right instanceof Cartesian3) {
        return Cartesian3.distance(left, right);
    } else if (left instanceof Cartesian4 && right instanceof Cartesian4) {
        return Cartesian4.distance(left, right);
    }

    throw new RuntimeError('Function "' + call + '" requires vector or number arguments of matching types. Arguments are ' + left + ' and ' + right + '.');
}

@YanzheZhang
Copy link
Owner

distance是webgl中glsl语言内置函数

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants