Giter Site home page Giter Site logo

Comments (2)

potenziani avatar potenziani commented on June 11, 2024

Hi @gmiguelr87,

as you probably know Nexus is a multi-resolution format. It splits original geometries in tree structures composed by nodes. These nodes (all together) compose a representation of the original model (at different resolutions). 3DHOP uses this format just because the progressive loading of the various nodes doesn't impact too much on the performances of common browsers. Unfortunately for you, this also means that you will never have your model geometry loaded in memory all together (unless your file is very small). In fact, the system interactively loads just the nodes needed, choosing them depending on several parameters (point of view, GPU load, network conditions, etc).
So, you cannot access "all the vertices of the model" in your 3D scene (unless profound changes to the source code that would distort the basis of the 3DHOP framework). Instead, what you can do, is to access the vertices of the nodes requested and loaded from the beginning of the rendering by the 3DHOP.
To do this, take a look at the "readyNode" function in the "nexus.js" file (line 1152). As you can see, in this method, starting from the nodes buffers containing all the model information (vertices positions, colors, normals, etc.), we build indices and vertices typed arrays to be sent to the shaders. So, adding your own source code in this point you can access all the vertex information belonging to the nodes that 3DHOP is loading on the virtual scene.

Some examples...
...if your Nexus model is compressed with corto:

  • adding console.log("POS: "+v[0]+" "+v[1]+" "+v[2]); after line 1194, you can read on your browser console the x,y,z position coordinates of the first vertex of the node loaded;
  • adding console.log("NOR: "+Math.max(no[0]/32767, -1.0)+" "+Math.max(no[1]/32767, -1.0)+" "+Math.max(no[2]/32767, -1.0)); after line 1208, you can read on your browser console the x,y,z normal vector coordinates (normalized) of the first vertex of the node loaded;

...if your Nexus model is not compressed (or it is compressed with meco):

  • adding var ver = new DataView(node.buffer, 0, nv*12); console.log("POS: "+ver.getFloat32(0,true)+" "+ver.getFloat32(4,true)+" "+ver.getFloat32(8,true)); after line 1162, you can read on your browser console the x,y,z position coordinates of the first vertex of the node loaded;
  • adding var nor = new DataView(node.buffer, off, nv*6); console.log("NOR: "+Math.max(nor.getInt16(0,true)/32767, -1.0)+" "+Math.max(nor.getInt16(2,true)/32767, -1.0)+" "+Math.max(nor.getInt16(4,true)/32767, -1.0)); console.log("COL: "+co[0]+" "+co[1]+" "+co[2]+" "+co[3]); after line 1178, you can read on your browser console the x,y,z normal vector coordinates (normalized) and the rgb values of the first vertex of the node loaded (of a model with both vertex color and normal vectors);

However, also with these modifications, you could retrieve just partial information about the 3D model visualized (since new nodes are continuously loaded, and old ones are continuously discarded), so I'm not sure they can help you on your purpose.

Ps: the line numbers above mentioned refer to the current 3DHOP DEVELOPMENT version ("4.2.8").

from 3dhop.

gmiguelr87 avatar gmiguelr87 commented on June 11, 2024

Dear @potenziani ,

Thank you very much for your detailed response. One of the things I love 3DHop for is progressive loading, so I won't distort the basis of the framework.
The purpose was to be able to export the 3D model in other formats from 3DHop, and it is obvious that it is not possible without modifying the basis.
However, you have provided me with very valuable information, because I can think of interesting things to do with that information (partial model information), such as generating simplified pointclouds or estimation of volumes.

Thanks again!!

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.