Created
December 12, 2023 06:16
-
-
Save matteoferla/6ae0291463d802c08cfbe91667627bc4 to your computer and use it in GitHub Desktop.
Add xyz to origin in NGL.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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