Viewer Release Notes: v3.3

December 5, 2017

CHANGED

None - See "ADDED" or "FIXED"

ADDED

Non-Photorealistic (NPR) Rendering Styles

Several styles of non-photorealistic rendering (NPR) are now available.

NPR is often used for artistic expression or as a way to suggest that a view is to be interpreted as a work in progress.

This is done as a post process. For desktops and laptops the cost is negligible; for mobile devices the cost is some drop in frame rate, due to a lack of multiple-render target support on these devices.

API Reference

preloadPostProcessStyle(); //OPTIONAL: loads all textures needed, for all styles.

preloadPostProcessStyle(string);  //OPTIONAL: use style string to initialize textures for a single style

Optional: 

The "graphite" and "pencil" styles require textures, so there may be a slight delay upon first launch while textures are cached. You can preload all textures or instead pass an individual style string to initialize only a single style. (If not called, the first call to setPostProcessParameter which sets a style will load the textures.)

setPostProcessParameter(string, value);  //string options and value ranges are described in the reference below
All NPR parameters are set with a combination of string and value.  See additional descriptions below.

style

string options:

  • "" (which means "off" - you can also use the word "off" if desired)
  • "edging"
  • "cel"
  • "graphite"
  • "pencil"

viewer styles

brightness

value range:  -1.0 to 1.0 (default:  0.0)
Adjust the intensity of the effect.

contrast

value range:  -1.0 to 1.0 (default:  0.0)
Adjust the variation between light and dark in the effect

preserveColor

boolean: true|false (default: false)
Enable to scale (normalize) color values or disable to clamp colors.

Example:
When false, color (4.0,1.0,0.5) becomes (1.0,1.0,0.5)
When true,  color (4.0,1.0,0.5) becomes (1.0,0.25,0.125) – each element is divided by the maximum of 4.0

grayscale

boolean: true|false (default: false)
Enable to desaturate the image after the operations above but before further processing.
Note that this will have no visible effect for the "graphite" style. 

edges

boolean: true|false (default: true)
Enable to show (screen-based) edges.  (Note that the reflected image does not show edges)
The edges parameter sets all edges on or off.  There are also three individual toggles for specific edge types:

idEdges

boolean: true|false (default: true)
Enable to show edges where objects with separate IDs or the background meet. Internal edges to these objects are not displayed.

normalEdges

boolean: true|false (default: true)
Enable to show edges where the normals differ by "enough," so that sharp edges are shown.

depthEdges

boolean: true|false (default: true)
Enable to show edges where the depths differ by "enough," so that edges between distant objects are shown. This catches cases where the planes in a single object are parallel, so that the ID and normals are the same.

levels (style "cel" only)

value range: 2.0 to 256.0 (default: 6.0)
Sets the number of levels of posterization.  Typical range: 2.0 - 8.0.
Note that fractional values are valid, giving a smooth transition from one to another level.

repeats (styles "graphite" and "pencil" only)

value range: 0.001 to 100.0 (default: 3.0)
Sets the number of times the texture patterns used in these styles is repeated in the view, top to bottom.  Typical range: 1.0 - 5.0.
Increasing this number makes the pattern smaller and more likely to be detected as repeating.

rotation (styles "graphite" and "pencil" only)

value range: 0.0 to 1.0 (default: 0.0)
Sets the clockwise rotation of the texture patterns used in these styles. 0.0 is no rotation, 1.0 is 180 degrees.
The default patterns have a lower-left to upper-right orientation.

Example Code

// Optional call, do this some time before using a style so that the required textures are loaded before the style is used.
// Not doing so may give a bad render or two while the textures are being loaded. In particular, Graphite will look black.
// This loads all textures needed, for all styles. You can instead pass an individual style string to initialize only it.
// Currently only the graphite and pencil styles require textures. If not called, the first call to setPostProcessParameter
// which sets a style will load the textures.
viewer.impl.preloadPostProcessStyle();
  
// Turn on a style. Styles are passed in as strings, for the "value" parameter:
// "" - turn off the style; back to normal, no post-process is done.
// "edging" - turn on image-based edging system
// "cel" - cartoon ("posterized") style, with edges
// "graphite" - black pencil style
// "pencil" - colored pencil and paper
var value = "graphite";
viewer.impl.setPostProcessParameter( "style", value );
  
// make the image have no edges:
viewer.impl.setPostProcessParameter( "edges", false);
  
// turn up brightness a bit:
viewer.impl.setPostProcessParameter( "brightness", 0.4);

Selection and highlight can be turned off individually using a new API

By default, the viewer changes the color of an object when you hover the mouse over it, and you can select objects by clicking them in the view or Model Browser.  This highlighting is useful when selecting and interacting with the model, but can be a distraction when you prefer a presentation mode. You can now toggle these behaviors.

API Reference

disableHighlight(boolean); //true to disable highlight, false to show highlight (defaults to false)

disableSelection(boolean); //true to disable selection, false to allow selection (defaults to false)

Example Code

// Disable highlight when cursor hovers over an object
disableHighlight(true);
 
// Enable highlight when cursor hovers over an object
disableHighlight(false);
 
// Disable selection when clicking an object in the view or Model Browser
disableSelection(true);
 
// Enable selection when clicking an object in the view or Model Browser
disableSelection(false);

Layers defined in 3d files now can accessed through the Layers Panel

The Layer Manager control now works for 3D files.  Click the Layer Manager icon to open the Layers panel, where you can toggle visibility of layers.

gif

Dutch language supported

See existing API Reference for Autodesk.Viewing.Initializer. 

Set string options.language to "nl" to enable Dutch.

FIXED

  • Hyperlinks pointing to invalid locations are no longer displayed

  • Fit to View "f" hotkey now works consistently

  • Ambient shadows now work on mobile devices

  • Measure Tool is more accurate when measuring large drawings

  • Interaction is no longer blocked in the ViewCube area when ViewCube is disabled

  • div.viewcubeUI no longer blocks interaction when the ViewCube is disabled.

Posts by author

Jaime Rosales
Sr. Developer Consultant