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

Please guide in rendering the mesh? #5

Open
icarito opened this issue Sep 2, 2019 · 20 comments
Open

Please guide in rendering the mesh? #5

icarito opened this issue Sep 2, 2019 · 20 comments
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@icarito
Copy link

icarito commented Sep 2, 2019

I've tried different attempts using https://github.com/andreasplesch/aframe-triangleset-component but I get this from the Mount Fuji 256 data:

imagen
Which doesn't look to me like the input image:
fuji256

Mainly because of the pointy spikes.
I'm using
<a-triangleset projectdir="z" material="roughness: 0.2; metalness: 0.3; color: green" rotation="90" position="-60 -100 30" scale="1 1 1" :vertices="this.vertices" :triangles="this.triangles"></a-triangleset>

Where this.vertices and this.triangles come from a Vue component that uses the data from tile.getMesh(80) to make these attribute data.

Please advise what am I doing wrong?
Thanks for your guidance.

@icarito
Copy link
Author

icarito commented Sep 2, 2019

imagen
Here's my result when using getMesh(30).

@icarito
Copy link
Author

icarito commented Sep 2, 2019

@andreasplesch maybe this is a question for you? ;-)
I also tried rendering with pythreejs but found similar issues.

imagen

Obviously I'm a beginner at 3D!
Thanks in advance for you kind advice.

@andreasplesch
Copy link

andreasplesch commented Sep 3, 2019

Please provide a live example, on glitch, jsfiddle, observable etc

@icarito
Copy link
Author

icarito commented Sep 3, 2019

Thanks @andreasplesch - I should've done from the beginning but I have a backend in Python3.7 that is not compatible with Glitch's older interpreter.
I've implemented a new project doing only this:
https://glitch.com/~mahogany-eggplant

My loose aim is to make a libre ("open source") videogame / interactive-experience about the Amazonian rainforest (where I live). Thank you for your nice components!

@mourner
Copy link
Member

mourner commented Sep 3, 2019

This is likely because the vertex data generated by this library is [x, y] pairs, without the z component (assuming the renderer will look these up through a texture). I probably need to add more docs for this, and maybe add an option to add z to the buffers too.

@mourner mourner added documentation Improvements or additions to documentation question Further information is requested labels Sep 3, 2019
@andreasplesch
Copy link

andreasplesch commented Sep 3, 2019

Yes, the z component is expected to be provided with the x and y. It would be not too hard to inject the z value from the data into the returned vertices array with something like:

for (i=0, j=0; i<mesh.vertices.length/2; i++) {
  let  x = mesh.vertices[i*2], y = mesh.vertices[i*2+1];
  this.vertices.push(x);
  this.vertices.push(response.data[y*257+x]/100);
  this.vertices.push(y);
}

Typically, some processing has to be done anyways after the meshing, the returned x and y coordinates are just grid coordinates, not spatial coordinates.
[The up component is typically y]
[Also, I am not sure how well the component still works with current three and aframe]

@icarito
Copy link
Author

icarito commented Sep 3, 2019

Thanks @mourner and @andreasplesch !
imagen
That was the missing insight. I did a little tweaking to your snippet and it worked wonderfully!
Thank you both for the Library and the Component (it works fine with AFrame 0.9.2)
Here's the code and test:

https://glitch.com/~mount-fuji
https://mount-fuji.glitch.me/

@mourner Yes a little more docs would be great, I loved the demo but couldn't figure it out.

Thanks!
❤️

@icarito icarito closed this as completed Sep 3, 2019
@arpu
Copy link

arpu commented Sep 17, 2019

@icarito your glitch test is deleted?

@icarito
Copy link
Author

icarito commented Sep 17, 2019

@arpu sorry I just renamed to a more accurate name!

https://glitch.com/~mount-fuji

@arpu
Copy link

arpu commented Sep 17, 2019

@icarito thx for poinzing me to the new glitch
but i get
three.js:11050 THREE.DirectGeometry: Faceless geometries are not supported.

and nothing is shown

@icarito
Copy link
Author

icarito commented Sep 17, 2019

The mesh can be seen at the bottom, I didn't center it or anything - look to the bottom left

@icarito
Copy link
Author

icarito commented Sep 17, 2019

bottom right I mean, sorry it's not in front of the camera

@arpu
Copy link

arpu commented Sep 17, 2019

ahh :> thx, great example!

@mourner
Copy link
Member

mourner commented Sep 18, 2019

Let's reopen the issue until we have a proper demo / better docs.

@mourner mourner reopened this Sep 18, 2019
@arpu
Copy link

arpu commented Sep 19, 2019

@mourner testing with aframe master and THREEjs v108 and BufferGeometry
https://codesandbox.io/s/aframe-draco-gltf-model-plus-77rld

Bildschirmfoto von 2019-09-19 14-08-23

@arpu
Copy link

arpu commented Sep 19, 2019

@arpu
Copy link

arpu commented Sep 19, 2019

@mourner what to you think on return the indices on getMesh ?

than the BufferGeometry could be set with setIndex()
https://threejs.org/docs/#api/en/core/BufferGeometry.setIndex

@mourner
Copy link
Member

mourner commented Sep 19, 2019

@arpu that's what triangles property in the returned object contains.

@arpu
Copy link

arpu commented Sep 19, 2019

awsome works! i update the codepen on https://codesandbox.io/s/martini-aframe-8b2i8
Bildschirmfoto von 2019-09-20 00-25-02

update the link!

@arpu
Copy link

arpu commented Sep 25, 2019

@mourner one more question how can set the createTile with a BufferGeometry?

the idea is bevore i use Martini i use

  var geometry = new THREE.Geometry().fromBufferGeometry(this.groundGeometry);
    geometry.mergeVertices();
    var modifier = new THREE.SubdivisionModifier(1);
    var smoothGeometry = modifier.modify(geometry);
    if (this.groundGeometry) this.groundGeometry.dispose();
    this.groundGeometry = new THREE.BufferGeometry().fromGeometry(smoothGeometry);

to get a smoother Terrain bevore Martini

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants