Continue to Site

Welcome to 3DCADForums

Join our CAD community forums where over 25,000 users interact to solve day to day problems and share ideas. We encourage you to visit, invite you to participate and look forward to your input and opinions. Acrobat 3D, AutoCAD, Catia, Inventor, IronCAD, Creo, Pro/ENGINEER, Solid Edge, SolidWorks, and others.

How to change diffuse color with js

habbe

New member
This is the answer on my question I wrote in a thread in acrobat 3d section yesterday...
I found it in a new thread about this on adobe´s forum..
I thought this would be nice to spread to everyone else on this forum!:)

Here it is:
_____________________________________________
It is possible to change the diffuse color and the diffuse texture of a material. To change the texture you have to add an imageresource to your PDF-file first. Acrobat Professional and Acrobat 3D dont support adding resources. To add a resource you need a plugin. You can download such a plugin here: http://www.graysonlang.com/Attach3DResource.api

Use the following code to change the diffuse color or the diffuse texture of your meshes:

//##### changeDiffuseColor #####

function changeDiffuseColor() {
//##### if you want to call the mesh by index #####
objectMaterial = scene.meshes.getByIndex(0).material;

//##### if you want to call the mesh by name instead of index #####
//objectMaterial = scene.meshes.getByName("theMeshsName").material;

//objectMaterial.diffuseColor.setColor(c1);
objectMaterial.diffuseColor.set3(0.9,0.99,0.1);
}

//##### changeDiffuseTexture #####

function changeDiffuseTexture() {
textureRes = new Resource("pdf://yourTexture.jpg");
textureImg = new Image(textureRes);

//#### if you want to call the mesh by index #####
objectMaterial = scene.meshes.getByIndex(0).material;

//##### if you want to call the mesh by name instead of index #####
//objectMaterial = scene.meshes.getByName("theMeshsName").material;

objectMaterial.diffuseTexture.setImage(textureImg);
}

You can download a working example at my website:
http://www.web-3d.info/material.zip:D
________________________________________
The problem is that i´m not very good at Java System:mad:
anyonyone knows some good video tutorials for this application?
/habbe
 
hi Habbe, I have the same problem with "diffuse color". Can you tell me how i can change "diffuse color" for 2 different objects into 3dmodel.
10x
 
Last edited:

Articles From 3DCAD World

Sponsor

Back
Top