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

How to handle transparency of objects in vts-browser-js? #190

Open
shrikant-panchal opened this issue Jun 16, 2020 · 2 comments
Open

How to handle transparency of objects in vts-browser-js? #190

shrikant-panchal opened this issue Jun 16, 2020 · 2 comments

Comments

@shrikant-panchal
Copy link

shrikant-panchal commented Jun 16, 2020

I am trying to draw a 3D object on top of VTS earth environment (vts-browser-js).
Can I make that object semi-transparent by specifying some transparency factor somewhere in the code?

Also, if the model (.obj) is imported, can we play with its transparency?

I understand that we can apply a semi-transparent texture and import that texture along with mode(.obj,.mtl), but is there any other way to achieve the required transparency in vts-browser-js?

Any help would be really appreciated!

@shrikant-panchal
Copy link
Author

Thanks Horky,
As you mentioned, one way is to edit the materials in .obj file itself.
I am wondering if it is possible to tune some transparency factor in VTS code?
Or some other way to adjust transparency through code?

@davidmtech
Copy link
Member

There is example how to draw transparent meshes:
https://jsfiddle.net/ay6c5pxj/

Main prerequisite is to use render state where is blending enabled:

transparentMesh = renderer.createState({culling:true, blend:true});

and set this state when you render transparent meshes

renderer.setState(transparentMesh);

In case that you use build sharers, then you set opacity to desired value.

When you render transparent meshes then rendering order is important. There is no build in support for rendering transparent meshes. You have to sort it manually. Most common practice is to render non-transparent meshes first and then render transparent meshes. Rendering order of the transparent meshes should by sorted by distance from camera (most distant should be rendered first).

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