• Stars
    star
    649
  • Rank 69,373 (Top 2 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Spherical panorama view, iOS

360° spherical panorama view

Features

  • OpenGL powered
  • orientation sensors to look around
  • touch interactive
    • pan to look around
    • pinch to zoom
  • a split screen mode for VR headsets
  • helper functions to orient direction of camera and touches

example

Equirectangular projections

OpenGL has strict texture size requirements

acceptable image sizes:

  • 4096 × 2048
  • 2048 × 1024
  • 1024 × 512
  • 512 × 256
  • 256 × 128
  • ... (any smaller power of 2)

4096 supported on iPhone 4s / iPad2 and newer

Methods

image

-(void) setImage:(UIImage*)image
-(void) setImageWithName:(NSString*)fileName  // path or bundle. will check at both

orientation

 // auto-update (usually only one of these at a time is recommended)
-(void) setOrientToDevice:(BOOL)   // activate motion sensors
-(void) setTouchToPan:(BOOL)       // activate UIPanGesture

 // aligns z-axis (into screen)
-(void) orientToVector:(GLKVector3)
-(void) orientToAzimuth:(float) Altitude:(float)

// rotate cardinal north around the image horizon. in degrees
-(void) setCardinalOffset:(float)

field of view

-(void) setFieldOfView:(float)     // in degrees
-(void) setPinchToZoom:(BOOL)      // activate UIPinchGesture

touches

-(void) setShowTouches:(BOOL)      // overlay latitude longitude intersects
-(BOOL) touchInRect:(CGRect)       // hotspot detection in world coordinates

2D - 3D conversion

-(CGPoint) screenLocationFromVector:(GLKVector3) // 2D screen point from a 3D point
-(GLKVector3) vectorFromScreenLocation:(CGPoint) // 3D point from 2D screen point
-(CGPoint) imagePixelAtScreenLocation:(CGPoint)  // 3D point from 2D screen point
  // except this 3D point is expressed as 2D pixel unit in the panorama image

VR Split screen

-(void) setVRMode:(BOOL)

This activates a split screen that works inside of VR headsets like Google Cardboard. TBD if more VR best practices are needed, such as a barrel shader.

  • Illusion of varying depth is not available. The two screens are rendered using the same image with no difference between camera IPD.

Installation

copy PanoramaView.h/.m into your project or use CocoaPods

  1. use a GLKViewController instead of UIViewController
  2. initialize your panoramaView and set it as self.view
  3. implement glkView:drawInRect:
@interface ViewController (){
	PanoramaView *panoramaView;
}
@end

@implementation ViewController
- (void)viewDidLoad{
	[super viewDidLoad];
	panoramaView = [[PanoramaView alloc] init];
	[panoramaView setImageWithName:@"image.jpg"];
	[self setView:panoramaView];
}
-(void) glkView:(GLKView *)view drawInRect:(CGRect)rect{
	[panoramaView draw];
}
@end

Swift

  • installation is easiest with CocoaPods. add use_frameworks! to your podfile
  • or, create a bridging header, copy in PanoramaView.h/.m
import PanoramaView

class ViewController: GLKViewController {

	let panoramaView:PanoramaView

	required init?(coder aDecoder: NSCoder) {
		panoramaView = PanoramaView()
		super.init(coder: aDecoder)
	}
	override func viewDidLoad() {
		super.viewDidLoad()
		panoramaView.setImageWithName("image.jpg")
		self.view = panoramaView
	}
	override func glkView(_ view: GLKView, drawIn rect: CGRect) {
		panoramaView.draw()
	}
}

make sure

  • no device landscape/portrait auto-rotation

device

  • any of the 4 device orientations works, use only 1.

Orientation

  • azimuth and altitude
  • look direction, the Z vector pointing through the center of the screen

coordinates

The program begins by facing the center column of the image, or azimuth 0°

wikipedia

About equirectangular

sample

equirectangular images mapped to the inside of a celestial sphere come out looking like the original scene, and the math is relatively simple http://en.wikipedia.org/wiki/Equirectangular_projection

License

MIT

More Repositories

1

Origami

computational origami
JavaScript
558
star
2

SVG

creative code svg
JavaScript
77
star
3

Firebase

iOS Swift + Firebase, simple beginner apps, foundations for larger projects
Swift
67
star
4

Geodesic

geodesic geometry library in C
C
33
star
5

SimpleOculus

Oculus Rift for native Mac OS X
C++
28
star
6

Math

math for origami. linear algebra, geometry, 2D and 3D, good interoperability with SVG
JavaScript
24
star
7

World

cross-platform OpenGL creative coding in the Processing paradigm
C
16
star
8

Material-Logic

class for SFPC spring 2018 instructors Kelli Anderson, Pam Liou, Robby Kraft
16
star
9

ReferenceFinder

Robert Lang's reference finder, remade for the web
JavaScript
13
star
10

3DEarth

OpenGL elevation maps from USGS GTOPO30
C
12
star
11

math-for-artists

ITP Spring 2020
HTML
10
star
12

svg-segmentize

process an svg into a copy containing only (straight) line-segments
JavaScript
8
star
13

Domekit

geodesic dome design tool, iOS
Objective-C
6
star
14

Plotter

procedurally generated SVGs, sometimes also origami crease patterns
C
6
star
15

Platonic

platonic solid geometry arranged in the best way
C
6
star
16

Stargaze

GPS + date + time into ecliptic coordinates, for stargazing apps
Objective-C
6
star
17

StandardAtmosphere

international standard atmosphere for altitudes up to 20,000m
C
6
star
18

origami-diagrams

origami diagrams from FOLD file
JavaScript
5
star
19

Kepler

Keplerian Elements for Approximate Positions of the Major Planets
Processing
5
star
20

fold-to-svg

render FOLD format to an SVG image
JavaScript
5
star
21

Origami-Writing

specification for a sequence of origami folds on a material
4
star
22

Stage

OpenGL + UIKit interface, iOS
Objective-C
4
star
23

Origami.rs

computational origami in rust
Rust
4
star
24

Examples

rabbit ear examples
JavaScript
3
star
25

Movement

capture and analysis of iOS accelerometer & gyroscope
Objective-C
3
star
26

cp-studio

origami crease pattern editor
JavaScript
3
star
27

webgl-fold

render FOLD object in WebGL
JavaScript
3
star
28

ofxUnitySocket

send live video (and other) from openFrameworks to Unity with Socket.io
C#
2
star
29

Face

C++
2
star
30

GridAlgorithms

A * pathfinding, digital differential analyzer
Objective-C
2
star
31

classes

2
star
32

X-Files

all X-Files scripts in plain text
2
star
33

Calendar

some calendars made w code
HTML
2
star
34

Astronomy

C
2
star
35

Hoverpad

bluetooth iPhone analog joystick
Objective-C
2
star
36

MetalMeshViewer

mesh viewer in Swift/Metal for iOS and MacOS
Swift
2
star
37

Snowflake

work in progress
JavaScript
2
star
38

LucidGrasshopper

Lucid cameras + Rhino Grasshopper
C#
1
star
39

FOLDViewerMacOS

FOLD file format viewer with quicklook plugin for MacOS
Swift
1
star
40

draw-tool

TypeScript
1
star
41

Workshops

HTML
1
star
42

terminal-shell

virtual terminal and shell with access to Javascript app data
Svelte
1
star
43

Counterpoint

algorithmic harmony
C
1
star
44

Autonaut

elementary cellular automata, iOS
Objective-C
1
star
45

MTA-3D

New York City MTA subway cars in 3D augmented reality. heroku server and iOS
Objective-C
1
star
46

Onion

iOS photo taking app - with recent-image overlay to create stop-motion work (onion-skinning)
Swift
1
star
47

origami-axioms

Rust
1
star
48

AnimalTrack

Marine animal tracking with CartoDB
CSS
1
star
49

Jupiter

ephemeris of Jupiter's moons. twitterbot
JavaScript
1
star
50

WiiMote

Interface for a WiiMote in Pure Data
1
star
51

ApolloSoyuz

Apollo-Soyuz Space Test simulator
C
1
star
52

EquationOfTime

sun position, analemma, sunrise/sunset, etc for any time/location on Earth
Processing
1
star
53

Walker

simple insect movement modeling
Objective-C
1
star
54

SoundDrawing

open wave files, correct glitches/morph audio with pure data's array drawing
Pure Data
1
star
55

grapher

origami design app
JavaScript
1
star
56

Vulkan

learning Vulkan
C++
1
star
57

Pomodoro

super simple pomodoro timer, iOS
Objective-C
1
star