Giter Site home page Giter Site logo

Comments (13)

potenziani avatar potenziani commented on June 11, 2024

Hi @YILINQ ,

your issue seems something like #19 ...

Are you using the DEVELOPMENT version of 3DHOP? If not, please try to update the system to it, retry, and let us know.

from 3dhop.

YILINQ avatar YILINQ commented on June 11, 2024

Thank you for your quick reply! And yes I have tried the DEVELOPMENT version and this still occurs...

from 3dhop.

potenziani avatar potenziani commented on June 11, 2024

Ok, I also guess it might be the cache problem... but we need some other information for trying to debug this!

So, first of all, some fundamental questions: how many Nexus models are you loading? Are you visualizing all these models simultaneously? Do they all have textures? How many textures? And with which resolution?

Then, some other less fundamental (but still useful) questions: are your models compressed or not? And have they been generated using the Nexus 4.2.2? And what about your application: did you develop it for desktop or mobile devices? And are you using a standard 3DHOP implementation? Finally, did you modify some of the 3DHOP core components?

from 3dhop.

YILINQ avatar YILINQ commented on June 11, 2024

Hi, thank you for your patience again!
I loaded about 500 textured nexus model simultaneously and each of them is very simple and not too large(about 100kb per model).
I did not compress them to keep their shapes. And I used the latest version of Nexus from github.
As for the app, I develop it for desktop and I did not modify the 3DHOP components, I just follow the "how to" page and almost use 0-configuration.
Hope these information are helpful! And I surely want to load the models by their x-y-z coordinates, but since I am pretty new to the web visualization I have no idea how to achieve that, so could you please also give me some advice on which files or functions I should look at?

Looking forward to your reply!

from 3dhop.

potenziani avatar potenziani commented on June 11, 2024

Hi @YILINQ ,
500 models all together on the same 3D scene are really many many many models!

The high number of objects you are trying to load simultaneously confirms the guess that probably you are having problems with some browser technical limitations (total available cache, max number of HTTP connections with the same domain name, etc.).

Anyway, we never tested 3DHOP with this number of models, especially because, as we love to say, 3DHOP is not a "silver bullet", meaning that it is a very focused tool: very good with SIMPLE scenes made of COMPLEX objects, less for COMPLEX scenes made of SIMPLE objects...

But, why do you want to load all these models? What's your dataset? Is it a collection? Also, how about your project: are you developing a video game or what?

Let me know, because at the moment I'm not sure 3DHOP is really the right tool for your kind of project, and even if it was, I'm afraid you will have to re-design your application for overcoming the issue.

PS: please, let me know also how many textures you have for any model, and the side resolution of each texture.

PPS: to know more about model transformation in 3DHOP you can read this (tranformations in the 3DHOP environment) or this (model preparation in MeshLab)

from 3dhop.

YILINQ avatar YILINQ commented on June 11, 2024

Hi, I am back and really sorry for the delay!
I want to use 3DHOP as a tool to display a scene made up with a "tile based" map with some obj files as buildings.
Currently the design is to model each building as an obj file, but within a certain area there might be 20k buildings and I group about 300 obj files inside one nxs model, so totally there are over 500 nxs models to load...
About the texture issue, depends on how complex it is of the building, the texture size of each building is from 100100 to 10001000.
Now I will go through the transformation part in 3DHOP and see if I can get some inspiration there, really appreciate your help!

And as you said 3DHOP is good with simple scenes made of complex models, maybe I should model more buildings in one obj file?

from 3dhop.

ponchio avatar ponchio commented on June 11, 2024

Grouping objs seems to me the only viable strategy. The main problem is that the simplification algorithm (quadrics) has trouble simplifying or merging simple building groups and I am not aware of a better algorithm.

In any case, the multiresolution algorithm (nexus) could probably be improved to support the case of little geometry and a lot of textures, if you could share the dataset (or even a subset), I can see what I can do and at least tell you if it's doable at all.

from 3dhop.

potenziani avatar potenziani commented on June 11, 2024

Hi @YILINQ ,
just to add some details to what @ponchio said.

The idea to pack as many OBJ models as possible into a single Nexus file, so as to have a smaller number of multiresolution files to load on your webpage (meaning fewer index to load, fewer XMLHttpRequests, etc, etc), actually is a good idea. But it is not enough.

Indeed, in your case the problem could be structural: 500 models, each one with (let's say) one 1000*1000 texture, are about 1.5 GB of information (500 models x 1000 pixel x 1000 pixel x 3 bytes, since for each channel color of the RGB encoding you need 1 byte). And this count is not including geometry. Moreover, consider that Nexus should generate multiple levels of textures for each multi-resolution model, the first one with original size (in this case 1000 pixels x side) and the others simplified. As you can imagine, data to be transferred online in a web browser are a lot (even taking advantage of a multiresolution approach).

And this is the point: probably what you are trying to load are not true multiresolution models... Indeed in Nexus geometry and texture simplification are coupled. But, since you have very simple models (with a geometry that cannot be simplified), probably Nexus is not able to simplify the textures when you build your NXS(or NXZ) models. Paradoxically, that means Nexus models smaller and few data to load (since they don't have multiple levels of textures), but also that the viewer has to load the scene at the max level of resolution soon when you open your webpage (basically, the 1.5 GB of data calculated above).

This probably is a problem for browsers capabilities, but for sure is a problem for Nexus rendering setup, because it needs to load the complete 3D scene at the beginning, and since there is a hard limit in the amount of memory it can use as "internal" cache, by default set to 512MB (line 279 nexus.js DEV version), this operation cannot be completed. So, most probably, when the available memory is full, Nexus releases blocks of loaded data for loading other blocks, ending up in an endless loop (causing the system crash, with the browser stuck in a pending request).
Of course, you can change the amount of cache Nexus can use (modifying the value in Nexus.js), but still you will handling a "fake" multi-resolution dataset...

This is the reason why I told you that 3DHOP may not be the right tool for your application. Decoupling geometry and texture simplification could be a solution, and we are asking you a subset of your data just for working in this direction (but we cannot provide you with planning for the release of this improvement).

However, if you want to be sure that your issue is due to Nexus, you could try to increase the cache value in nexus.js. Or alternatively, you could try to remove the textures from your OBJs before to convert them to Nexus (best option).
Finally, if you want to be sure that you are not hitting any limit of the browser too, you could try to build your 3D scene using only textured PLY models (instead of the Nexus ones).

from 3dhop.

YILINQ avatar YILINQ commented on June 11, 2024

Thank you for your advice and I now see the problem to be loading too many nxs files at the same time, which cause the browser to crash......
Now I wonder if I can load and render my models separately, say if I zoom in to a certain area, the only models I need to load and render is those within this area, and I do not need to load the models outside of this area. If I slide the window, the view changes and I will re-compute which models to load and render. I am not sure if this loading & rendering process is supported in 3DHOP, if so, could you please give me some advice on which part of the library to look at and modify, and I think maybe this is better than loading all models at beginning to avoid browser crashing.

from 3dhop.

potenziani avatar potenziani commented on June 11, 2024

In 3DHOP there is not an automatic way for doing this loading & rendering process (essentially because this is pretty much what Nexus already does with every single multiresolution model), but you could work on the code to design something similar.

First of all, you should take a look at the visibility feature how-to. Basically, if a model has the visibility tag set as "false" the Nexus engine doesn't load it. So you could set all your buildings as not visible at the beginning (checking if your system still crashes).

Then you should design a routine for setting visible just what you want.

If you have a tiled terrain, a very simple way could be something like this: click on a specific tile of the terrain (using onclick events) for automatically zoom in it (using camera animations) and visualize its details, i.e. the buildings models (again using the visibility feature).

Another possibility to drive the model's visibility is to play with the camera distance, getting something similar to this (focus on the hotspot behavior: when you zoom out from them they magically disappear). But developing this feature is not simple, and it requires to modify the trackball code. Anyway, you can use this example (and its source code) as inspiration for your project.

from 3dhop.

YILINQ avatar YILINQ commented on June 11, 2024

Thank you for your advice and I think setting and toggling the "visible" property is a good way for now(Got rid of the browser crashing problem!).

Now I am designing the routine to check and set models now.

And one last question is, is it possible to not declare all models at beginning, and while I check the visibility of the model I decide which groups of model to declare and load, because with the growth of the project, there might be many many areas and models, so I am afraid I cannot declare them all at the beginning.

Again thank you for your help and I think I am almost there to get everything done!

from 3dhop.

potenziani avatar potenziani commented on June 11, 2024

Hi @YILINQ ,

at the moment 3DHOP does not provide an official way for the dynamic declaration of the 3D scene, but it can support it. The only drawback is that you have to use private functions.

There are two possibilities in dynamic scene declaration:

  1. to declare all the meshes needed in the 3DHOP "setScene" setup and then to dynamically create the additional instances;
  2. to dynamically declare both additional meshes and instances after the "setScene" setup;

Let's start with the first case.

  1. Let's pretend to be in this situation:
presenter.setScene({
	meshes: {
		"mesh_1" : { url: "models/multires/my_model_1.nxz" },
		"mesh_2" : { url: "models/multires/my_model_2.nxz" }
	},
	modelInstances : {
		"instance_1" : { mesh : "mesh_1" }
	}
});

So, at the beginning we declared 2 meshes, but we instanced just one of them ("mesh_1").
It's important to understand that with this setup, if "mesh_2" is a Nexus file the system loads just the file header and index, but no other data. Conversely, if "mesh_2" is a PLY file the system will load the whole file.

Later, and after the 3D scene creation, we want to dynamically add an instance linked to "mesh_2".
To do that, firstly we have to create the new instance object (I'll call it "instance_2") and link it to "mesh_2" using the private function "_parseModelInstance":

presenter._scene.modelInstances.instance_2 = presenter._parseModelInstance({ mesh : "mesh_2" });

Then, we have to update the scene using another private function ("_createMeshModels"):

presenter._createMeshModels();

That's all. Now we should have a 3D scene with both the meshes instanced.
Just note that this procedure is the same we have to use if we want to dynamically add a second (or a third, or a fourth...) instance of an already declared mesh.

Now, let's see the second case.

  1. We are in this situation:
presenter.setScene({
	meshes: {
		"mesh_1" : { url: "models/multires/my_model_1.nxz" }
	},
	modelInstances : {
		"instance_1" : { mesh : "mesh_1" }
	}
});

So, at the beginning we declared only one mesh ("mesh_1") and one instance ("instance_1") linked to it. Later, and after the 3D scene creation, we want to dynamically add another mesh ("mesh_2") and an instance ("instance_2") linked to it.
Of course, with this setup "mesh_2" (independently by the file format) is not loaded at the beginning, but just when we declare it.

To add a new mesh to the 3DHOP scene firstly we have to create the new mesh object (I'll call it "mesh_2") and link it to its file URL using the private function "_parseMesh":

presenter._scene.meshes.mesh_2= presenter._parseMesh({ url: "models/multires/my_model_2.nxz" });

Then, like in the previous case, we have to create also the new instance object (I'll call it "instance_2") and link it to "mesh_2" using the private function "_parseModelInstance":

presenter._scene.modelInstances.instance_2 = presenter._parseModelInstance({ mesh : "mesh_2" });

Finally, we have to update the scene using the usual private function ("_createMeshModels") and we are done:

presenter._createMeshModels();

Now we should have a 3D scene with two meshes and two instances.

In both cases (1. and 2.) the structure of the final scene will be:

presenter.setScene({
	meshes: {
		"mesh_1" : { url: "models/multires/my_model_1.nxz" },
		"mesh_2" : { url: "models/multires/my_model_2.nxz" }
	},
	modelInstances : {
		"instance_1" : { mesh : "mesh_1" },
		"instance_2" : { mesh : "mesh_2" }
	}
});

That's all! Quite long to explain, but not so difficult to implement.
I hope everything is clear, otherwise do not hesitate to contact us again.

Disclaimer: currently dynamic scene creation is NOT an official 3DHOP feature, so it has not been properly tested. Side effects may include some errors in the console because there might be a small time frame where positioning of the models is undefined, no trackball exists, interaction is freezing, etc, etc.

IMPORTANT: the routine introduced above refers to the latest 3DHOP DEVELOPMENT version (4.2.10)

from 3dhop.

YILINQ avatar YILINQ commented on June 11, 2024

Thank you for your detailed instruction! It took me quite a while to explore the source code and found this is really helpful. Now I am designing a whole new routine to achieve the goal, and I really appreciate your step-by-step guidance. Again I want to thank you guys for this amazing library and your kindness, I will let you know if I make some progress in the future!

from 3dhop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.