[SOLVED] How to get cubeMapProjection set to Box?

Hi every one !
I’m new in playCanvas and I’m not a good in scripting …
I don’t understand the API used and so I can’t set a simple thing like cubemap projected

Have read few things like

the like

mat.cubeMapProjection = pc.CUBEPROJ_BOX;
mat.cubeMapProjectionBox = aabb;
Where “aabb” is pc.shape.Aabb object defining the box, and “mat” is your material.

I know that I’m near to solve my issue with this but I don’t know how to get the materials settings from the mesh.
So I’ve tried :

this.entity.material.cubeMapProjection = pc.CUBEPROJ_BOX; 

but it still don’t work…
and so then I’ve got the problem of the aabb because I don’t know how to use it and I think that I’m gonna lose a lot of weeks to solve both…

I don’t even know how to change the color of the diffuse…

please help me because I’m looking for this thing for too long .

It is good to share project link in your post, so people can look at it.
Material is set on meshInstance. Array of mesheInstance’s in within model component of an entity:
var meshes = this.entity.model.model.meshInstances;
Then you can iterate through meshes or pick the one you need by index, and get its material:

Use your browser dev tools, for debugging, console.log'ing and inspecting the code and values within your code. That helps to understand what is what a lot.

thank you !
finally it works well !

for every one who are in the same case of me, I post the code, that is executed in initialize method in script:

// center of bounding box
var v = new pc.Vec3(0, 1.1, 0);

// size of bounding box (half extends)
var e = new pc.Vec3(4, 4, 4);

// create BoundingBox
var aabb = new pc.BoundingBox(v,e);

var meshes = this.entity.model.model.meshInstances;

// set cubemap box projection for first meshInstance of a model
meshes[0].material.cubeMapProjection = pc.CUBEPROJ_BOX;
meshes[0].material.cubeMapProjectionBox = aabb;

Thank you a lot ! because I hate script ^^
let’s make something awesome now ! :smile:

Good job! :smile:
Scripting is cool, once you get well with it, learn how to debug and get used to learning, it is very powerful and personally brings huge satisfaction to my daily work.