ofDrawCircle(...) facing ofCamera - SOLVED

Looking to get a shape to always face a ofCamera. Here is a basic example, at some point the circle is flipped and not working anymore. Is there a simple better way to make this happen?

ofEasyCam cam;

//--------------------------------------------------------------
void ofApp::setup(){
    cam.setDistance(80);
}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw() {
    
    ofVec3f rot = cam.getOrientationEuler();
    
    cam.begin();
    
    ofNoFill();
    ofSetColor(255);
    ofDrawBox(25);
    
    ofPushMatrix();
    ofTranslate(2, 2);
    ofRotateX(rot.x);
    ofRotateY(rot.y);
    ofRotateZ(rot.z);
    ofFill();
    ofSetColor(255, 0, 0);
    ofDrawCircle(0, 0, 0, 2);
    ofPopMatrix();
    
    cam.end();
}

the easiest is to use an ofNode i think

ofNode node;
node.lookAt(camera.getPosition(), {0,1,0});
node.setPosition(...);
node.transformGL();
ofDrawCircle(...)
node.restoreGL();

Like a charm :slight_smile: thanks Arturo!

void ofApp::draw() {
    
    cam.begin();
    
    ofNoFill();
    ofSetColor(255);
    ofDrawBox(25);
    
    ofNode node;
    node.lookAt(cam.getPosition(), {0,1,0});
    node.setPosition(cos(ofGetFrameNum() * 0.02) * 3, sin(ofGetFrameNum() * 0.02) * 3, 0);
    node.transformGL();
    ofFill();
    ofSetColor(255, 0, 0);
    ofDrawCircle(0, 0, 0, 2);
    node.restoreTransformGL();
  
    cam.end();
}