-
Notifications
You must be signed in to change notification settings - Fork 92
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
feat(PanoViewer): improve cubemap support #131
Conversation
* increate mocha test timeout * change script version to "latest" on demo site * update examples for new image api * remove projectionType "vertical_cubestrip" * add projectionType "cubemap" * set preserveDrawingBuffer false only where the tremor occurs * added tile config options to support various cube map layouts ref #123
mocha.opts
Outdated
@@ -1 +1 @@ | |||
--timeout 10000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@happyhj Why change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I found we don't need to expand the timeout. I will revert that.
@@ -455,7 +480,7 @@ export default class PanoImageRenderer extends Component { | |||
gl.uniformMatrix4fv(this.shaderProgram.mvMatrixUniform, false, this.mvMatrix); | |||
|
|||
if (this._isVideo) { | |||
this._renderer.texImage2D(this.context, this._image); | |||
this._bindTexture(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@happyhj Should it be bound again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got it. I'll change the flow to prevent duplicated binding texture.
@@ -112,14 +114,34 @@ export default class PanoImageRenderer extends Component { | |||
.catch(e => setTimeout(() => { throw e; }));// Prevent exceptions from being isolated in promise chain. | |||
} | |||
|
|||
static extractImageSource(imgParam) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@happyhj Isn't this job already done in contentLoader?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I will remove those methods.
|
||
try { | ||
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); | ||
gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Foll
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The renderer doesn't need to flip the texture anymore. Now we use texture coordinate like the sphere renderer.
gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture); | ||
|
||
this.texImage2D(gl, image); | ||
if (image instanceof Array) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to separate following codes as a texImage2D. Because it is not needed to call bindTexture on every frame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
demo/examples/cubemap_video.html
Outdated
container, | ||
{ | ||
projectionType: "cubemap", | ||
video: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@happyhj I didn't catch before... I feel it makes confusion... because video
param tend to have too many types. How about to separate a cubemapConfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for feedback. I will add cubemapConfig
option as you said.
@@ -50,7 +50,7 @@ export default class SphereRenderer extends Renderer { | |||
}`; | |||
} | |||
|
|||
static bindTexture(gl, texture, image) { | |||
static updateTexture(gl, texture, image) { | |||
if (!image) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateTexture in SphereRenderer only need to call this.texImage2D and size check logic need to be moved to bindTexture
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, I'll apply that.
this._image, | ||
this._imageConfig, | ||
); | ||
this._shouldForceDraw = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldForceDraw=true
is not valid. because when user pause the video, it should not draw a frame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll remove it.
@@ -245,6 +245,24 @@ describe("PanoViewer", function() { | |||
}); | |||
}); | |||
|
|||
describe("#setter/getter", function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did't understand this test describe block. because it doesn't have it
block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I'll remove that.
@@ -43,8 +43,7 @@ describe("WebglUtils", function() { | |||
|
|||
[ | |||
{os: {name: "android", version: "4.3"}, browser: {name: "chrome"}}, | |||
{os: {name: "android", version: "4.4"}, browser: {name: "samsung internet"}}, | |||
{os: {name: "ios", version: "7"}, browser: {name: "safari"}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove {os: {name: "ios", version: "7"}, browser: {name: "safari"}}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iOS 7 safari don't support webgl. So I removed conditional logic in isStableWebGL method. and added checking webgl support using isWebGLAvailable method before conditional logic in isStableWebGL.
In real iOS7 device, isStableWebGL
will return false
because it is not support webgl.
It's not valid test anymore before mocking no-webgl environment.
if (!image) { | ||
return; | ||
} | ||
static updateTexture(gl, texture, image, imageConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
texture
param is not used.
@@ -50,6 +50,11 @@ export default class SphereRenderer extends Renderer { | |||
}`; | |||
} | |||
|
|||
static updateTexture(gl, texture, image) { | |||
// Draw first frame | |||
this.texImage2D(gl, image); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to remove texImage2D method and replace this function with following
static updateTexture(gl, image) {
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
}
test/manual/PanoViewer/Visible.html
Outdated
@@ -155,8 +155,11 @@ <h2>Visible Activation</h2> | |||
key = (new Date()).getTime() + idx; | |||
|
|||
instance = new eg.view360.PanoViewer(viewerEl,{ | |||
image: viewerEl.getAttribute("data-source"), | |||
projectionType: "vertical_cubestrip" | |||
image: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@happyhj image should not have cubemap config
_updateTexture() { | ||
this._renderer.updateTexture( | ||
this.context, | ||
this.texture, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@happyhj texture param is no more need
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…into CubeRenderer#123
…into CubeRenderer#123
Issue
#123
Details
feat
fix
test
chore
I removed code for support old mobile browsers with "vertical_cubestrip" projection, which is removed from this PR. But we should still support for those browsers.
We will continue to work on the issues below.
#132