Lighting in the scene will always affect the colors of objects, that's part of the 3D experience.
Yes, i know that lightning in 3D scene is an hard part !
But is it possible or not to change the color of an object that is textured with other ways than by using the following script?
mat0 c3d.scene.materials.getByName = ("name");
In fact , i research a mean to change the object color. I research the method that would be less interference with the light in my 3D scene and that enable to have the correct RGD render.
To change the apparent colors of a 3D mesh you have to use scripting as in your example, but you must be aware of the interaction between the material and scene shaders if you want to get a specific effect. There are no other ways to modify textures in a 3D scene, other than in the 3D application which created the file in the first place. Remember that the 3D viewport is not intended to display managed colors so getting an exact RGB value on screen is very difficult - the normal color-management rules of PDF do not apply to rich media annotations.
If you have an object with some random material shader and want it to appear 'flat' red, I would typically run a zero-point function against the material and scene:
mat0.specularStrength = 0;
mat0.reflectionStrength = 0;
mat0.ambientTexture.image = undefined;
mat0.diffuseTexture.image = undefined;
mat0.emissiveTexture.image = undefined;
mat0.specularTexture.image = undefined;
mat0.reflectionTexture.image = undefined;
scene.lightScheme = "cad";
If the material has a texture applied to a shader slot, it will completely override the colors defined in the same shader slot unless the texture.amount is less than 1; so if for example you have a teapot with a brick pattern in the diffuseTexture slot and you change the diffuseColor to green, nothing will happen. Set diffuseTexture.amount = 0.5 and you'll get green bricks, set it to 0 and the bricks vanish to leave a plain green teapot.