Changing materials in Forge

前端 未结 1 826
慢半拍i
慢半拍i 2021-01-13 23:31

We are currently making the client retrieve the object states when the page loads (which will cause the \'pending\' objects in the model to turn into different colors). Then

相关标签:
1条回答
  • 2021-01-14 00:06

    I have no idea how you implement your app, so I only tell what I found in your codes. If you want to resolve the issue you addressed, you can consider providing a reproducible case demonstrating that, I will gladly pass it to our dev team. Those following items should be in the reproducible case:

    1. A short exact description of what you are trying to achieve. The behavior you observe versus what you expect, and why this is a problem.
    2. A complete yet minimal sample source model to run a test in.
    3. A complete yet minimal Forge app that can be run and debugged with a simple procedure to analyze its behavior lives in the sample model.
    4. A complete yet minimal pure three.js app that can be run and demonstrated the shader effect you want. Note. Forge Viewer is using r71 three.js.
    5. Detailed step-by-step instructions for reproducing the issue, e.g. which element to pick, what command to launch etc.

    If your reproducible case could not be posted here publicly, please send it to the forge.help@autodesk.com and remove sensitive data or information before you send.

    === Something I found in your codes:

    I found here are some wrong types and missing actions in your ColorMaterial extension. The color property of an material should the a type of the THREE.Color. Here is my modification:

    Autodesk.Viewing.Viewer3D.prototype.setColorMaterial = function(objectIds, color)
        {
            if( !(color instanceof THREE.Color) ) throw 'Invalid argument: Color';
    
            var material = new THREE.MeshPhongMaterial
            ({
                 color:      color,
                 opacity:    0.8,
                 transparent: true
             });
    
            viewer.impl.matman().addMaterial( 'ColorMaterial-' + new Date().getTime(), material, true );
    
            // ...........
        };
    

    Its' result is here:

    In the ColorOverlay extension, The type of material color property is also wrong, it should be a type of THREE.Color, too. Changing it into THREE.Color should work fine. In addition, overlay is covers on 3D objects, so you should call viewer.hide() with your setColorOverlay() together. Otherwise, it won't look like a transparent object.

    Without hidding 3D object of the wall:

    hide 3D object of the wall:

    0 讨论(0)
提交回复
热议问题