Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support also partial cubemap/fallback images: backgroundColor for missing face(s) #570

Merged
merged 8 commits into from
Mar 23, 2018

Conversation

DDvO
Copy link
Contributor

@DDvO DDvO commented Mar 11, 2018

Similarly to the recently added support for missing tiles in multires panoramas,
this PR adds support for missing faces in cubemap (which includes fallback) panoramas.
Any areas for which no data is available are shown with the configurable backgroundColor.

I updated the documentation of backgroundColor accordingly.

This PR also includes a couple of minor improvements of related code.

This is in a sense a continuation of PR #563.

@DDvO
Copy link
Contributor Author

DDvO commented Mar 17, 2018

I've continued this branch with a major extension of utils/multires/generate.py to cylindrical input and partial panoramas.

The tile and fallback face files will only be produced when they actually contain image data.
For those files produced, the background color used past the edges of a partial pano can be defined.

I also added some generally useful options. Some options are just passed through in the .json file to the viewer.

Added options regarding partial panoramas:

  • -b --backgroundcolor: RGB triple of values [0, 1] defining background color shown past the edges of a partial panorama (defaults to "[0.0, 0.0, 0.0]")
  • -B --avoidbackground: viewer should limit view to avoid showing background, so using --backgroundcolor is not needed
  • -H --haov: horizontal angle of view (defaults to 360.0 for full panorama)
  • -V --vaov: vertical angle of view (defaults to 180.0 for full panorama)

Added options regarding cylindrical input:

  • -C --cylindrical: input projection is cylindrical (default is equirectangular)
  • -e --horizon: offset of the horizon in pixels (negative if above middle, defaults to 0)

Added general options:

  • -F --hfov: starting horizontal field of view (defaults to 100.0)
  • -O --voffset: starting pitch position (defaults to 0.0)
  • -f --fallbacksize: fallback tile size in pixels (defaults to 1024)
  • -a --autoload: automatically load panorama in viewer
  • -G --gpu: perform image remapping by nona on the GPU
  • -d --debug: debug mode (print status info and keep intermediate files

Copy link
Owner

@mpetroff mpetroff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good. The only major change I'd like is to define missing cubemap faces in the configuration instead of checking by trial and error.

console.log(config.strings.fileAccessError.replace('%s', e.target.src)+'; will use background instead');
onLoad();
return;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prevents helpful error messages when URLs are incorrect. Missing faces should be defined as null in the configuration, and this should then be checked instead of trying and failing to load the face.

origHeight = str(origHeight)
origWidth = str(origWidth)
origFilename = os.path.join(os.getcwd(), args.inputFile)
extension = '.jpg'
if args.png:
extension = '.png'
colorList = eval(args.backgroundColor)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling eval is unsafe; ast.literal_eval should be used instead.


# Create output directory
os.makedirs(args.output)
if not os.path.exists(args.output):
os.makedirs(args.output)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was intended to fail if the output directory already exists. A check could be added to print a descriptive error message instead of a stack trace, but I don't think the script should continue if the output directory already exists.

@@ -101,6 +101,37 @@ function Renderer(container) {
pose = undefined;

var s;
var faceMissing = false;
var cubeImgWidth = undefined;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The = undefined part is unnecessary; var cubeImgWidth; is functionally identical.

if (imageType == 'cubemap') {
for (s = 0; s < 6; s++) {
if (image[s].width > 0) {
if (cubeImgWidth == undefined)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strict comparison, ===, should be used.

if (loaded == 5 && this.width == 0) // support partial fallback/cubemap image
this.width = fallbackImgSize;
if (this.width > 0) {
if (fallbackImgSize == undefined)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strict comparison, ===, should be used.

@DDvO
Copy link
Contributor Author

DDvO commented Mar 18, 2018

Thanks for your swift feedback;
I've just done all requested changes.

for convenience, no need to delete output directory every time while testing
@mpetroff mpetroff merged commit 0c92d85 into mpetroff:master Mar 23, 2018
@mpetroff
Copy link
Owner

Great. Thanks!

@DDvO DDvO deleted the partial_cubemap_fallback branch April 7, 2018 08:53
NiHoel pushed a commit to NiHoel/pannellum that referenced this pull request Jun 15, 2020
…sing face(s) (mpetroff#570)

* support also partial cubemap/fallback images: backgroundColor for missing face(s)

* extend multires/generate.py to cylindrical input and partial panoramas

* fixed a few typos in new help strings of generate.py

* Missing cubemap faces now need to be defined as null in the configuration

* made generate.py strict again on existing output directory, printing descriptive error message

* replaced unsafe eval by ast.literal_eval in generate.py

* a couple of minor improvements regarding 'undefined' in libpannellum.js

* made generate.py allow existing output directory in debug mode

for convenience, no need to delete output directory every time while testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants