Resources Numerical accuracy Calculation policy

Manual scene in the 3D view

Draws the parts of an illustrated manual, their edges and the filled cut faces in the 3D view.

How the precision is kept

Mesh positions are copied into Float32Array buffers for the graphics card and are not read back into any saved or reported number.

Calculations under this policy

2 calculations in 1 source file. The code is read from the released app when this page loads. It is the calculation people run, not a copy kept for this page.

illustrate/scene3d.js PartCraft 0.8.1 32-bit, display only 2 calculations Reviewed

Tests None found by the review

Part geometry for the view

32-bit, display only

Builds the triangles and feature lines of a part for drawing.

Positions are expanded to one vertex per triangle corner in a Float32Array for the GPU; normals and bounds are computed by three.js from that buffer. Nothing here is saved or reported.

  • illustrate/scene3d.js
  • lines 36 to 50
  • PartCraft 0.8.1
const geoFor = (mesh) => {
  let g = cache.get(mesh);
  if (g) return g;
  const P = mesh.positions, I = mesh.indices, nt = I.length / 3;
  const pos = new Float32Array(nt * 9);
  for (let t = 0; t < nt; t++) for (let k = 0; k < 3; k++) for (let c = 0; c < 3; c++) pos[t * 9 + k * 3 + c] = P[I[t * 3 + k] * 3 + c];
  const geo = new THREE.BufferGeometry();
  geo.setAttribute('position', new THREE.BufferAttribute(pos, 3));
  geo.computeVertexNormals(); geo.computeBoundingBox(); geo.computeBoundingSphere();
  const eg = new THREE.BufferGeometry();
  eg.setAttribute('position', new THREE.BufferAttribute(featureSegments(mesh), 3));
  g = { geo, eg };
  cache.set(mesh, g);
  return g;
};

Cut faces lifted off the section plane

32-bit, display only

Places the filled cut faces so they are not hidden by the plane that cut them.

Each cap point is moved 0.001 model units along the plane normal. Drawing only.

  • illustrate/scene3d.js
  • lines 98 to 99
  • PartCraft 0.8.1
const { o, e1, e2 } = cap.frame, lift = 1e-3;
const at = (q) => [o[0] + e1[0] * q[0] + e2[0] * q[1] - cap.n[0] * lift, o[1] + e1[1] * q[0] + e2[1] * q[1] - cap.n[1] * lift, o[2] + e1[2] * q[0] + e2[2] * q[1] - cap.n[2] * lift];

In detail

Method
One three.js mesh and one set of feature lines per shown part, with clipping planes for sections.
Number types
Float32Array position buffers for three.js.

Approach: Display only

Computed to draw the screen, often in 32-bit on the graphics processor. No number a person reads, saves or exports comes from it.

Every policy that takes this approach