Compare commits

..

No commits in common. "e97d3bbf3a29a8ac148af3da295036eaa992e105" and "813823934e4f76c69f110249dd58ecdf571d8eef" have entirely different histories.

6 changed files with 1 additions and 189 deletions

View File

@ -1,9 +1,4 @@
# panellum_generator
Configuration generator for Panellum Panorama Viewer.
https://pannellum.org/
## Usage
python panoconfig.py input.txt -o index.htm
https://pannellum.org/

View File

@ -1,3 +0,0 @@
570,260,50,Outside,outside.jpg,10
350,440,50,Inside,inside.jpg,270
435,530,50,Room,room.jpg,-70

View File

@ -1,122 +0,0 @@
import math
import argparse
#input config file format: x,y,z,id,filename,angleoffset
#angleoffset is 0 when center of 360 image points to the right, positive rotation means image center in pointing more CCW. value in degrees
parser = argparse.ArgumentParser(
prog = 'File Edit Script',
description = 'Read content of text file and write to file',
epilog = '')
parser.add_argument('filename') # positional argument
parser.add_argument('-o', '--output') # option that takes a value
parser.add_argument('-v', '--verbose', action='store_true') # on/off flag
args = parser.parse_args()
print(args.filename, args.output, args.verbose)
def distance(x1,y1,x2,y2):
dist = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
return dist
print("Loading Templates")
template_panellum=None
with open("template_panellum.txt",'r') as rf:
template_panellum=rf.readlines()
template_scenes=None
with open("template_scenes.txt",'r') as rf:
template_scenes=rf.readlines()
template_hotspots=None
with open("template_hotspots.txt",'r') as rf:
template_hotspots=rf.readlines()
linesinput=None
with open(args.filename,'r') as rf:
linesinput=rf.readlines()
linesinput=[x.rstrip() for x in linesinput] #remove newline and whitespaces at end
output_scenes=[]
first_sceneId=None
for iline1,line1 in enumerate(linesinput):
x1,y1,z1,id1,filename1,angleoffset1=line1.split(',')
x1,y1,z1=(float(x1),float(y1),float(z1))
angleoffset1=float(angleoffset1)
if first_sceneId is None:
first_sceneId=id1 #take first entry as start scene
# ### Set information for scene ###
current_scene=template_scenes
current_scene=[x.replace('<id>',id1) for x in current_scene]
current_scene=[x.replace('<title>',id1) for x in current_scene]
current_scene=[x.replace('<filename>',filename1) for x in current_scene]
output_hotspots=[]
for iline2,line2 in enumerate(linesinput):
x2,y2,z2,id2,filename2,angleoffset2=line2.split(',')
x2,y2,z2=(float(x2),float(y2),float(z2))
angleoffset2=float(angleoffset2)
if id1!=id2:
print()
print("from "+str(x1)+", "+str(y1)+" : "+id1)
print("to "+str(x2)+", "+str(y2)+" : "+id2)
print("dist="+str(distance(x1,y1,x2,y2)))
angle=math.degrees(math.atan2(y2-y1, x2-x1)) #in degrees
print("angle="+str(angle)+" offset1="+str(angleoffset1)+" offset2="+str(angleoffset2))
angle+=angleoffset1 #correct hotspot position by rotation of scene image
print("angle final="+str(angle))
pitch=-math.degrees(math.atan(z1/distance(x1,y1,x2,y2))) #from current looking to hotspot. 0deg=straight, 90deg=down
pitch=pitch/2 #manual correction
# ### Set information for target/hotspot ###
current_hotspot=template_hotspots
current_hotspot=[x.replace('<id>',id2) for x in current_hotspot]
current_hotspot=[x.replace('<yaw>',str(angle)) for x in current_hotspot]
current_hotspot=[x.replace('<pitch>',str(pitch)) for x in current_hotspot]
output_hotspots.append(current_hotspot)
output_hotspots_string=""
for _ihotspot,_hotspot in enumerate(output_hotspots):
if _ihotspot>0:
output_hotspots_string+=",\n" #separate blocks with comma
for _hotspotline in _hotspot:
output_hotspots_string+=_hotspotline
current_scene=[x.replace('<hotspot>',output_hotspots_string) for x in current_scene]
output_scenes.append(current_scene)
output_scenes_string=""
for _iscene,_scene in enumerate(output_scenes):
if _iscene>0:
output_scenes_string+=",\n" #separate blocks with comma
for _sceneline in _scene:
output_scenes_string+=_sceneline
output=template_panellum
output=[x.replace('<firstScene>',first_sceneId) for x in output]
output=[x.replace('<scene>',output_scenes_string) for x in output]
with open(args.output, 'w') as wf:
wf.writelines(output)

View File

@ -1,9 +0,0 @@
{
"pitch": <pitch>,
"yaw": <yaw>,
"type": "scene",
"text": "<id>",
"sceneId": "<id>",
"targetYaw": 0,
"targetPitch": 0
}

View File

@ -1,38 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tour</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pannellum@2.5.6/build/pannellum.css"/>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/pannellum@2.5.6/build/pannellum.js"></script>
<style>
#panorama {
width: 100vw;
height: 100vh;
}
body {
margin: 0;
}
</style>
</head>
<body>
<div id="panorama"></div>
<script>
pannellum.viewer('panorama', {
"default": {
"firstScene": "<firstScene>",
"author": "Author",
"sceneFadeDuration": 1000
},
"scenes": {
<scene>
}
});
</script>
</body>
</html>

View File

@ -1,11 +0,0 @@
"<id>": {
"title": "<title>",
"hfov": 150,
"pitch": 0,
"yaw": 0,
"type": "equirectangular",
"panorama": "images/<filename>",
"hotSpots": [
<hotspot>
]
}