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

More geometry instance attributes #2150

Closed
pjcozzi opened this issue Sep 24, 2014 · 2 comments
Closed

More geometry instance attributes #2150

pjcozzi opened this issue Sep 24, 2014 · 2 comments

Comments

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 24, 2014

Currently only per-instance color and show are supported for geometries. Cesium needs classes to represent generic data like the two examples below.

var FloatInstanceAttribute = function(value) {
    value = Cesium.defaultValue(value, 0.0);

    this.value = FloatInstanceAttribute.toValue(value);
};

Cesium.defineProperties(FloatInstanceAttribute.prototype, {
    componentDatatype : {
        get : function() {
            return Cesium.ComponentDatatype.FLOAT;
        }
    },
    componentsPerAttribute : {
        get : function() {
            return 1;
        }
    },
    normalize : {
        get : function() {
            return false;
        }
    }
});

FloatInstanceAttribute.toValue = function(value, result) {
    //>>includeStart('debug', pragmas.debug);
    if (!Cesium.defined(value)) {
        throw new Cesium.DeveloperError('value is required.');
    }
    //>>includeEnd('debug');

    if (!Cesium.defined(result)) {
        return new Float32Array([value]);
    }
    result[0] = value;
    return result;
};
var Cartesian3InstanceAttribute = function(x, y, z) {
    this.value = new Float32Array([
        Cesium.defaultValue(x, 0.0),
        Cesium.defaultValue(y, 0.0),
        Cesium.defaultValue(z, 0.0)
    ]);
};

Cesium.defineProperties(Cartesian3InstanceAttribute.prototype, {
    componentDatatype : {
        get : function() {
            return Cesium.ComponentDatatype.FLOAT;
        }
    },
    componentsPerAttribute : {
        get : function() {
            return 3;
        }
    },
    normalize : {
        get : function() {
            return false;
        }
    }
});

Cartesian3InstanceAttribute.fromCartesian3 = function(cartesian) {
    //>>includeStart('debug', pragmas.debug);
    if (!Cesium.defined(cartesian)) {
        throw new Cesium.DeveloperError('cartesian is required.');
    }
    //>>includeEnd('debug');
    return new Cartesian3InstanceAttribute(cartesian.x, cartesian.y, cartesian.z);
};

Cartesian3InstanceAttribute.toValue = function(cartesian, result) {
    //>>includeStart('debug', pragmas.debug);
    if (!Cesium.defined(cartesian)) {
        throw new Cesium.DeveloperError('cartesian is required.');
    }
    //>>includeEnd('debug');

    if (!Cesium.defined(result)) {
        return new Float32Array([cartesian.x, cartesian.y, cartesian.z]);
    }
    result[0] = cartesian.x;
    result[1] = cartesian.y;
    result[2] = cartesian.z;
    return result;
};

CC #766

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Sep 25, 2014

Also the toValue functions throughout should require result.

@ggetz
Copy link
Contributor

ggetz commented Apr 13, 2023

This is unlikely to become a priority anytime soon. We'd still happily accept a PR addressing this issue. But tracking this isn't particularly useful because of its low priority, so I will close it. Thanks!

@ggetz ggetz closed this as completed Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants