Skip to content

Instantly share code, notes, and snippets.

@matteoferla
Created December 12, 2023 06:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matteoferla/6ae0291463d802c08cfbe91667627bc4 to your computer and use it in GitHub Desktop.
Save matteoferla/6ae0291463d802c08cfbe91667627bc4 to your computer and use it in GitHub Desktop.
Add xyz to origin in NGL.js
// In NGL it may be handy to show an XYZ system axes / caltrop / cube edge
// the following is called via `addAxis(stage)`
const addAxis = (stage) => {
let shape = new NGL.Shape("shape", { dashedCylinder: true })
shape.addArrow([ 0, 0, 0 ], [ 10, 0, 0 ], [ 1, 0, 0 ], 1.0);
shape.addText([ 12, 0, 0 ], [ 1, 0, 0 ], 2.5, "x");
shape.addArrow([ 0, 0, 0 ], [ 0, 10, 0 ], [ 0, 1, 0 ], 1.0);
shape.addText([ 0, 12, 0 ], [ 0, 1, 0 ], 2.5, "y");
shape.addArrow([ 0, 0, 0 ], [ 0, 0, 10 ], [ 0, 0, 1 ], 1.0);
shape.addText([ 0, 0, 12 ], [ 0, 0, 1 ], 2.5, "z");
var shapeComp = stage.addComponentFromObject(shape)
shapeComp.addRepresentation("buffer");
shapeComp.autoView()
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment