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

support Lines in glTFloader #754

Closed
doczoidberg opened this issue Jul 28, 2017 · 9 comments
Closed

support Lines in glTFloader #754

doczoidberg opened this issue Jul 28, 2017 · 9 comments

Comments

@doczoidberg
Copy link

please support Lines in the glTFloader.

I looked at the source coude and think that deeper knowledge of x3dom is necessary to implement it?

@doczoidberg
Copy link
Author

or is there a way to render a mesh (data from glb file) as a wireframe?

where can I adjust the source? please give me a hint

@andreasplesch
Copy link
Contributor

andreasplesch commented Jul 31, 2017

Here is all the gltf handling:

https://github.com/x3dom/x3dom/blob/master/src/util/glTF/

The final render function called from gfx_webgl.js is here:

https://github.com/x3dom/x3dom/blob/master/src/util/glTF/glTFContainer.js#L96

Here is the TODO for points and lines:

https://github.com/x3dom/x3dom/blob/master/src/util/glTF/glTFLoader.js#L165

but it appears that loadPrimitive() is not used. Instead, the very similar .loadgltfMesh() is used

https://github.com/x3dom/x3dom/blob/master/src/util/glTF/glTFLoader.js#L234

and would need the POINT and LINE handling instead, at the equivalent places.

See whereever else faces or numfaces or similar are expected since lines would not have faces.

https://github.com/x3dom/x3dom/blob/master/src/nodes/Rendering/IndexedLineSet.js

shows how the x3dom ._mesh object needs to be constructed. gltfLoader probably already does most of this. _mesh.primType is "LINES". This is translated by
https://github.com/x3dom/x3dom/blob/master/src/util/Utils.js#L913
to gl.LINES in gfx_webgl.js. So using gl.LINES above should be possible.

gfx_webgl.js may not need adjustments but is important to walk through as well. It is large but manageable. (Ignore picking, background, foreground ..).

In the end not too much code may be needed but it will take time.

@andreasplesch
Copy link
Contributor

for wireframe see #756 (comment)

@doczoidberg
Copy link
Author

thanks for your long answer. I will look into it although I have many question marks in my head for now.

@andreasplesch
Copy link
Contributor

It will take a while to work through the existing render path.

Thinking about it, a simpler solution may be to make polyMode here
https://github.com/x3dom/x3dom/blob/master/src/util/glTF/glTFContainer.js#L96
a per shape parameter, perhaps attached to this.material. Currently polyMode is a global parameter from viewarea._points .

@andreasplesch
Copy link
Contributor

I looked at the gltf loader code more and went through some experiments, so I think I understand it better now. It still looks like not too much is needed. If you have a (simple) gltf v.1.0 example binary gltf with LINES primitives (primitive mode: GL_LINES (1)), I could give it a spin.

Most gltf viewers and loaders probably currently only support triangles, and I could not find any gltf 1.0 examples for LINES, even in the official gltf example models:
KhronosGroup/glTF-Sample-Models#106

@doczoidberg
Copy link
Author

I created a simple python glb generator for testing purposes of glb in x3dom:

https://github.com/doczoidberg/glbgenerator

any ideas why x3dom throws the error?

RangeError: Invalid typed array length: 1684370261
 /polyfills.bundle.js:2740

@andreasplesch
Copy link
Contributor

You would need to step through with the debugger. "uri":"data:," looks suspect.
You may consider generating a regular text encoded glTF v.1.0, and then converting it with gltf-pipeline .

@doczoidberg
Copy link
Author

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