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

added global event for indicating ongoing rendering #29

Closed
wants to merge 1 commit into from
Closed

added global event for indicating ongoing rendering #29

wants to merge 1 commit into from

Conversation

Schiller-Stoff
Copy link

Dear fantastic 3-D Hop developers,

this event could be used to stop a loading indicator when the viewer starts to render a 3d-model
(as far as I understand).
The browser event for "page finished loading" will fire before a larger model e.g. ~300mb and therefor stop the loading animation before the 3D model is displayed.

e.g.

$(document).ready(function(){
         init3dhop();
         setup3dhop();
                       
                     
          let firstNodeCounter = 0;
          document.addEventListener('threeDNodeRendered', function () {
             if(firstNodeCounter===0){
                  //stop loading animation here

                  firstNodeCounter++;
              }
            });
           });

@potenziani
Copy link
Member

Hi @oldschmetterhand

thanks for your request.

Your contribution is technically correct (and functional for its purpose), but incomplete.

In fact, it 100% works only if you don't have textured Nexus models on the scene. If you want to be sure to intercept the start of rendering in nexus.js, you should duplicate the code you added in the loadNodeTexture function, too (again, after theif (m.status [n] = = 2)statement). This is because Nexus models can store both geometry and texture, and since these contents are loaded asynchronously, the system has to wait until both geometry and texture have been loaded (of course, this applies to each node of the multiresolution model, and not just at the beginning). However, since you cannot know if the geometry will be loaded before the texture, or vice versa (it depends on their complexity/size), you should check both branches of the nexus rendering system.

Furthermore, your workaround works only if you have on the 3D scene at least a Nexus model, but not in the case you have just PLY models (not a common situation, but still a possibility).

Another consideration concerns the "philosophy" behind this kind of feature. The event handler you proposed checks the beginning of the rendering, but this type of control doesn't work if, for instance, you have a 3D scene with the visibility status of all the models settled on "false" at the beginning (again, not a common situation, but still a possibility).
Probably, it could be more useful (and simple) to check the loading status of the whole scene, rather than the start of the rendering of the different objects. For implementing this, you just should add an event in the _testReady function of presenter.js. This event will be fired only when all the whole scene has been loaded (this includes both PLY and Nexus models), exactly as it happens to the log function in this example:

_testReady : function () {
	if (this._objectsToLoad != 0) return;

	console.log("Scene ready!");

	this._sceneReady = this._scenePrepare();

	this.repaint();
},

Another possibility, maybe more elegant, is to check the progressive loading of the data, like in #28 (comment). This would give the possibility to create also progressive loading bars. This is the direction we would like to follow, but to check the loading status of a multi-resolution model it's not easy, because you have many little chunks to load. So, how to implement this kind of feature in the best way is still an open issue.

For all these reasons, we are sorry but we would not merge your pull request. Anyway, thanks again for your time and for stimulating the discussion on this feature.

@potenziani potenziani closed this Mar 10, 2020
@potenziani potenziani self-assigned this Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants