Skip to content

Commit

Permalink
Merge pull request #256 from losnoco/nevack/spectrum-camera-mode-angles
Browse files Browse the repository at this point in the history
[Visualizer] Adjust 2d projection camera angles.
  • Loading branch information
kode54 authored May 22, 2022
2 parents 4f1ea02 + a58b11d commit b99bc67
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion Visualization/SpectrumView.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ @interface SpectrumView () {
NSColor *backgroundColor;
ddb_analyzer_t _analyzer;
ddb_analyzer_draw_data_t _draw_data;

SCNVector3 cameraPosition2d;
SCNVector3 cameraEulerAngles2d;
SCNVector3 cameraPosition3d;
SCNVector3 cameraEulerAngles3d;
}
@end

Expand Down Expand Up @@ -73,7 +78,17 @@ - (void)updateControls {
SCNNode *rootNode = [[self scene] rootNode];
SCNNode *cameraNode = [rootNode childNodeWithName:@"camera" recursively:NO];
SCNCamera *camera = [cameraNode camera];
[camera setUsesOrthographicProjection:projectionMode];
if (projectionMode) {
cameraNode.eulerAngles = cameraEulerAngles2d;
cameraNode.position = cameraPosition2d;
camera.usesOrthographicProjection = YES;
camera.orthographicScale = 0.6;
} else {
cameraNode.eulerAngles = cameraEulerAngles3d;
cameraNode.position = cameraPosition3d;
camera.usesOrthographicProjection = NO;
camera.orthographicScale = 1.0;
}

NSValueTransformer *colorToValueTransformer = [NSValueTransformer valueTransformerForName:@"ColorToValueTransformer"];

Expand Down Expand Up @@ -111,6 +126,13 @@ - (void)setup {
SCNScene *theScene = [SCNScene sceneNamed:@"Scenes.scnassets/Spectrum.scn"];
[self setScene:theScene];

SCNNode *rootNode = [[self scene] rootNode];
SCNNode *cameraNode = [rootNode childNodeWithName:@"camera" recursively:NO];
cameraPosition2d = SCNVector3Make(0.0, 0.5, 1.0);
cameraEulerAngles2d = SCNVector3Zero;
// Save initial camera position from SceneKit file.
cameraPosition3d = cameraNode.position;
cameraEulerAngles3d = cameraNode.eulerAngles;
[self updateControls];

bandsReset = NO;
Expand Down

0 comments on commit b99bc67

Please sign in to comment.