Skip navigation
Currently Being Moderated

Change a texture in a PDF3D

Apr 22, 2008 12:17 AM

Hello!

I have a question.

Is it possible to change the texture of a 3D object (in a PDF3D) without regenerating the PDF3D?

How to do that? With javascript?

Thank you!
 
Replies
  • Currently Being Moderated
    Apr 22, 2008 7:44 AM   in reply to (JérômeM)
    JérômeM,

    You can use a JavaScript to change many aspects of the material properties (including textures) at runtime such as scale, rotation, offset, etc.

    Specifically what did you have in mind?

    Grayson
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 6, 2008 4:15 AM   in reply to (JérômeM)
    HI Grayson,
    In your attach3dresource website. Step 10. Select the menu item: Advanced > 3D > Attach Resource to 3D Annotation.

    3D is not an option under the Advanced Menu tool. I have the API in the correct location - any thoughts to get it to be visable?
    Thanx
    Garry
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 6, 2008 6:20 AM   in reply to (JérômeM)
    Found it Grayson - thanx
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 8, 2008 3:29 AM   in reply to (JérômeM)
    Hi Grayson, When I work through your example - it works like your demo - however your demo has a bump map included, even when I include that file the bump map does not appear in the final Acro 3D. Any ideas?

    PS: Are you sure we can't talk you into publishing a cool Acro 3D tutorials? I purchased the Acrobat 3D classroom in a Book - to have the book spend 80% of it's time telling about the interface icons and limited time on the cool parts.
    gazzzz
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 9, 2008 7:14 AM   in reply to (JérômeM)
    I'm actually in the process of developing tutorials right now. They'll be going up on my site this week. Check http://www.graysonlang.com/acrobat3d/ later on.

    This weekend I was busy working with the Wii remote. I'm attempting to write a plug-in to have it manipulate 3D objects in Acrobat. That will also be posted as a tutorial.

    Grayson
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 20, 2008 2:35 PM   in reply to (JérômeM)
    Hello grayson,
    I wanted to thank you for that tutorial you wrote.
    Now I´m able to assign maps which normally get lost during importing procedures(without any knowledge of javascript btw).
    Regards, chuck
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 19, 2010 11:13 PM   in reply to (JérômeM)

    Is there any example of how to set a texture of 3DModel through Javascript?

     

    I tried following but I always get "Resource is not defined" error:

     

    // Create a new Resource with the file's URI as the argument
    modelResource = new Resource( "pdf://sphere.u3d" );


    // use Scene method "addModel" with Resource as an argument,
    // returns top level node from loaded 3D file
    model = scene.addModel( modelResource );


    // Create a new Resource with the file's URI as the argument
    imageResource = new Resource( "pdf://grid.jpg" );


    // use the Image constructor with the Resource as an argument,
    image        = new Image( imageResource );


    // set the loaded 3D model's diffuse texture to the image
    model.material.diffuseTexture.setImage( image );


    // loading of resources can be inlined if they are only used once
    bump        = new Image( new Resource( "pdf://knurl.jpg" ) );


    // set the loaded 3D model's bump texture to the image
    model.material.bumpTexture.setImage( bump );

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 20, 2012 1:39 AM   in reply to printscr

    I have the same problem, i cant change the material texture of my 3D object.

    I see in the documentation JS 3D that this function setImage is deprecated

     

    here is my code above, I want to change the texture of the mesh material which is called "ground"

     

     

    txResource = new Resource("pdf://toto.jpg");

    txImage = new Image(txResource);

    mshMatl = scene.meshes.getByName("ground").material;

    mshMatl.diffuseTexture.setImage(txImage);

     


     

    anynody know how to change the material texture by a file ressource ?

     

    thanks

     

    regards


     
    |
    Mark as:
  • Currently Being Moderated
    Jul 20, 2012 3:38 AM   in reply to StaffJim442

    Simply set the old image object to be equal to the new one. In the context of your 3D scene:

     

    var _mat = scene.meshes.getByName( 'ground' ).material;

    var _tex = new Image( new Resource( 'pdf://tot.jpg' ) );

    _mat.diffuseTexture.image = _tex;

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 20, 2012 8:36 AM   in reply to Dave Merchant

    Hi

     

    thanks for your response

     

    Unfortunately this does not work

     

    i have integrated the picture toto.jpg in the pdf resource file

     

    and I have integrated this code into a file. js :

     

    var _mat = scene.meshes.getByName( "ground" ).material;

    var _tex = new Image( new Resource( "pdf://toto.jpg" ) );

    _mat.diffuseTexture.image = _tex;

     

    in the console debug appear on line 3 (_mat.diffuseTexture.image = _tex;) :

    "Code: 45(0x2d): Object is invalid"

     

    I specify that this 3D mesh ground contains an textural  material already existing in the U3D file

     

    an idea about this problem please ?

     

    thanks for your help

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 20, 2012 1:17 PM   in reply to StaffJim442

    There's nothing wrong with the code in your last reply. Without seeing the file, all I can assume is that the names you're using are wrong. Does the node 'ground' exist in the model tree?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)