July 19, 2017

Default blog image

The Viewer has a setCutPlanes method that, according to documentation, requires a "list of Vector4 plane representation: {x:a, y:b, z:c, w:d} Plane general equation: ax + by + cz + d = 0 where a, b, and c are not all zero Passing an empty list or null is equivalent to setting zero cut planes", but how to use it?

One way to quickly try it is by using .getState method to have some valid cut planes:

// get the current state
var state = viewer.getState();

// and the cut planes on this state
var cutplanes = state.cutplanes;

Now we have a cut plane, either created or copied from state, we can use these cut plane method:

// now prepare a list of planes for cut
var planes = [];

// the getState returns a list of cut planes, 
// so let's iterate through it
for (var p = 0; p<cutplanes.length; p++)
{
  var cutplane = cutplanes[p];

  // create a THREE.Vector4
  var vector4 = new THREE.Vector4(
    cutplane[0], cutplane[1],
    cutplane[2], cutplane[3]);

  planes.push(vector4);
}

// restore to original state
viewer.restoreState(null);

// apply the new cut planes
viewer.setCutPlanes(planes);

 

Related Posts

July 11, 2019

New Autodesk Forge Viewer 7.0 is Now Available

Autodesk Forge is our collection of Application Program Interfaces (APIs), documentation, sample code, and a community of cust

Read More

July 10, 2019

Look for exact property value and more

When using the search() function of the Viewer, you can only look for strings that at least partially match a given value.

Read More

July 9, 2019

Webpack and three.js in forge applications

In the newer versions of forge viewers( v6 and above) three.js is included in the forge viwer js file itself.

Read More