How to change the particle system's colorMap

I can’t find any Api to do this so I create this topic.

Who can tell me the way?

Thank you for your answer.

Check this if it helps:

You can’t find the API?

And:

http://developer.playcanvas.com/en/api/pc.ParticleSystemComponent.html#colorMap

Try adding a script like this to an entity with a particlesystem component:

var ChangeMap = pc.createScript('changeMap');

ChangeMap.attributes.add('maps', { type: 'asset', assetType: 'texture', array: true });

// initialize code called once per entity
ChangeMap.prototype.initialize = function() {
    this.currentMap = 0;
};

// update code called every frame
ChangeMap.prototype.update = function(dt) {
    if (this.app.keyboard.wasPressed(pc.KEY_SPACE)) {
        this.currentMap++;
        if (this.currentMap == this.maps.length) this.currentMap = 0;
        this.entity.particlesystem.colorMap = this.maps[this.currentMap].resource;
    }
};

The only thing I noticed is that changing the color map resets the particle system which might not be what you want.

Thank you for your answer,and I find the API to change the colorMap now.

Dear will

I am so sorry for my oversight.

I succeed in changing the colorMap with your answer.

Thank you,you are a nice man.

1 Like