Michal Havel
Michal Havel

Reputation: 39

Add Mesh to Forge Viewer Scene

I use Forge Viewer v7.12. and I can't add THREE.Mesh to viewer scene. This is not function from version 7.3. How can I add custom geometry (Box, Surface, Line) to Scene? And console writes this error: .WebGL-0x7f884f0a5400]GL ERROR :GL_INVALID_OPERATION : glDrawElements: buffer format and fragment output variable type incompatible. Thanks

Upvotes: 0

Views: 726

Answers (1)

michael beale
michael beale

Reputation: 1196

The recommended approach is to use an overlay instead of scene or sceneAfter, like this...

var geom = new THREE.SphereGeometry(10, 8, 8);
var material = new THREE.MeshBasicMaterial({ color: 0xff0000 });
var sphereMesh = new THREE.Mesh(geom, material);
sphereMesh.position.set(1, 2, 3);

viewer.overlays.addMesh(sphereMesh, 'custom-scene');

For more details, follow the example here: https://forge.autodesk.com/en/docs/viewer/v7/developers_guide/advanced_options/custom-geometry/

Upvotes: 2

Related Questions