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

X-Repeat Images? #11

Open
kaefert opened this issue Oct 20, 2013 · 5 comments
Open

X-Repeat Images? #11

kaefert opened this issue Oct 20, 2013 · 5 comments

Comments

@kaefert
Copy link

kaefert commented Oct 20, 2013

Is it possible to have the picture repeated horizontally?

So that if the user scrolls out of the picture to the left the right side of the picture starts to be displayed again? (and vice versa)

If this feature does not exist yet, how would one go about implementing it? Do you think it would be lots of work?

@dimin
Copy link
Owner

dimin commented Oct 20, 2013

You would need to add a new tile provider serving tiles wrapping around 360

@kaefert
Copy link
Author

kaefert commented Oct 22, 2013

Okey, so..
The inline script in the html file defines the function myProvider.assembleUrl
which is called by PanoJS.js:471 - but only if [useBlankImage] is false, which is true if the searched tile is outside of the dimensions of the picture. So this is probably also a place that would need adapting for an repeating image

The inline defined myProvider.assembleUrl function calls the function ImgcnvPyramid.prototype.tile_filename to know which tile to load, so this is the second thing that I think would need adapting for repeating the image.

PanoJS.prototype.positionTiles = function(motion, reset)
--> 418 -->
PanoJS.prototype.assignTileImage = function(tile)
--> 471 -->
this.tileUrlProvider.assembleUrl(tile.xIndex, tile.yIndex, this.zoomLevel);
myProvider.assembleUrl = function(xIndex, yIndex, zoom) {
return MY_URL + '/' + MY_PREFIX + myPyramid.tile_filename( zoom, xIndex, yIndex );
-->
ImgcnvPyramid.prototype.tile_filename = function( level, x_coordinate, y_coordinate )
--> returns jpg name --> END

@kaefert
Copy link
Author

kaefert commented Oct 22, 2013

I don't really fully understand what is happening there, but the code in PanoJS.js - the function
PanoJS.prototype.positionTiles = function(motion, reset)
Lines 345 to 429 read like support for repeating images is already in there?
At least the comments state that a tile that moves out of the screen on one side could come back into the screen on the opposite side. But I do not understand it to an extend that I would know why it does not work already or what functionality is missing.

update: ah I think now I get it, a tile in that context does not mean a fixed tile from the picture, but just a "placeholder" tile that could hold any tile of the image whichever is needed, is that correct?

@kaefert
Copy link
Author

kaefert commented Oct 22, 2013

Okey, so here is my first [quick&dirty] "patch" (sorry didn't set up myself an IDE for this and I don't know how to create a real patch without one)

1.) in PanoJS.js
replace code line
if (high || left || low || right) {
with
if (high || low) { // || left || right) {

2.) in pyramid_imgcnv.js
After the line:
ImgcnvPyramid.prototype.tile_filename = function( level, x_coordinate, y_coordinate ) {
add the following lines:
var maxx = this.getLevel(level).xtiles;
while (x_coordinate >= maxx) {
x_coordinate -= maxx;
}
while (x_coordinate < 0) {
x_coordinate += maxx;
}

I don't know why but it only works on the right side, so if you scroll out to the right side (negative) the left end of the picture will begin to show again.
Also if the last tile does not have the same width as the others, then there will be a gap as wide as the last tile is smaller then others.
you can look at the modification at work here:
http://kaefert.is-a-geek.org/panojs3/

@kaefert
Copy link
Author

kaefert commented Nov 3, 2013

if anybody knows why my modifcation doesn't work as expected, or has an idea to improve it, I would be very happy to read it here.

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

No branches or pull requests

2 participants