Entity properties


#1

Yes another script question.

Trying to learn howto read entity properties, that seems very usefull for the things i want todo, so looking in editmodels.js see trhe section ‘function Tooltip()’ from there i know ‘this.updateText = function(properties) {’ is printingg the entity info on the screen. but convert that into a small example seems right now impossible for me because it need so many other parts.

And it seems there’s no entityPropertiesExample.js script.


#2

You have to start by creating a variable to contain the model’s properties including the URL to the model…

var originalProperties = {
    type: "Model",
    position: { x: 2.0,
                y: 2.0,
                z: 0.5 },

    radius : 0.25,

    color: { red: 0,
             green: 255,
             blue: 0 },

    modelURL: "http://highfidelity-public.s3-us-west-1.amazonaws.com/meshes/Feisar_Ship.FBX",
    
    rotation: rotation
};

then you have to load the model and get the entity ID…

var entityID = Entities.addEntity(originalProperties);

then you can change the properties by creating a new variable where the original properties are changed…

var newProperties = {
    position: {
            x: originalProperties.position.x + (count * positionDelta.x),
            y: originalProperties.position.y + (count * positionDelta.y),
            z: originalProperties.position.z + (count * positionDelta.z)
    },
};

then you “write” that back to the entity…

Entities.editEntity(entityID, newProperties);

The last function is what actually changes the model, but you have to specify the entity ID and properties.


#3

Ok… :slight_smile: now only we need to figure out how the modelurl is readed from a random object. but thats later problem. trying this first.


#4

Note: with the latest code “radius” is now obsolete and has been replaced with “dimensions” which should be set to a vector.

var newProperties = { dimensions: { x: 1.5, y: 2.5, z: 0.5 } };

#5

Thanks @ZappoMan , already figured out that radius need to be removed. Not got at the point to look what need to replace it. But i guess its just the same words that are used in the entity properties.