Is there a better way to create a button in AFrame? - button

I've seen this answer to how to create a 3-dimensional button in AFrame, but I was wondering if there was a better way to accomplish this. If there isn't, could somebody please clarify how the rotation/position attributes for the text work (e.g. where the axis of rotation is, where the position is based around relative to the cube, etc.). Thanks!

Depends on which implementation of text you are using. WebGL has no inherent concept of layout like the 2D web. There are upcoming implementations of text which will make it easier to layout and size.
For now, if a text implementation doesn't have any concept of layout, I would use the A-Frame Inspector (<ctrl> + <alt> + i) to manually place your text.
If you want automatic layout in relations to a mesh, you could also try computing the bounding box of the mesh and the text, and automatically centering/aligning the text.

Related

Render 2D text in Autodesk Forge without aliasing or blurring

Turns out I’m working with the Autodesk Forge viewer and Three.js, trying to render 2D text that can be interacted with (specifically select, rotate, and move).
To do this I am working with meshes (using MeshBasicMaterial, Mesh and TextGeometry) but it turns out that the text does not look perfectly sharp, it presents aliasing and I found that according to the API reference, the antialiasing is not applicable to 2d.
Here are some examples of the problem, as you can see, the more I move away from the plane, the worse the text looks (and even up close it doesn't look perfect):
I have tried to make a test representing the text with a Sprite (despite the fact that it would mean having to change the entire implementation already made with meshes of other functionalities) but apart from the fact that I cannot see it, I have seen example images and they do not appear either well: aliasing is visible from a distance and it looks really blurry up close. Here some examples:
Is there a way to correct this problem or is this the most I can get in 2D? I've tried searching for information on this but can't find anything helpful. And what has puzzled me the most has been realizing that antialiasing was not applicable in the case of 2d, like making it clear that nothing can be done to fix it.
I would be very grateful if you could solve my doubts, thank you very much in advance for your help.
An easier alternative, is to just use a higher pixel ratio for the renderer...
window.devicePixelRatio=2;
viewer.resize();
For example, using the custom geometry text, from Joao's demo, you can see the same aliasing issue at DPR=0.5 and DPR=1.0 ...
https://joaomartins-forge.github.io/textgeometry-sample/
But when I set the DPR=2.0, the text looks clean. The trade off is rendering performance, but your 2D drawings may be simple enough that it won't matter. You can use a 'mouse up' camera settle trick, to switch between DPR of 1 and 2, if you want a better UX experience.
There are a few ways to solve this aliasing issue for 2D (and 3D text).
The way I would recommend for your use case, is to use DIV elements (THREE.CSS3DRenderer), instead of text converted into three.js tessellated triangle geometry, as shown in this blog post:
https://forge.autodesk.com/blog/how-do-you-add-labels-forge-viewer
You can find out more information about THREE.CSS3DRenderer here:
https://threejs.org/docs/#examples/en/renderers/CSS3DRenderer
and an Example here: https://threejs.org/examples/#css3d_periodictable
Using CSS3DRenderer instead of CSS2DRenderer, means you will get the correct scaling (and rotation) of the div element as you zoom into your 2D drawing and the mathematics inside the calculation for the matrix transform has less edge-cases.
Once you are using DIV elements for your text, you will notice that the text is sharper and has no aliasing issues. That's because it is not being rasterized by the webGL pipeline, but by the SKIA library used by chrome/firefox/opera/etc for rasterizing text.
There is one final option, that uses signed-distance fields, but it's probably overkill for what you need.
Let me know if you want some example code.

How to draw or plot a mesh using the mouse in JavaFX which can then be textured and deformed?

I am trying to implement a tool into my application. the tool would allow the user to plot a triangle meshes using the mouse. I have looked everywhere for a way to do this, tutorials, examples, etc and have not been successful. I have seen the FXyz library but that does not really simulate What I am trying to accomplish. The goal of the program looks as follows:
Use Case Sequence:
The user adds a png image to the 3D scene or drags it into the 3D scene using the mouse.
Once the image is being displayed the user would then be able to plot a mesh around the image.
Once the user has finished plotting the mesh. There would have to be a way to add the image being overlayed by the mesh as a texture to the mesh. The image should look the same after being added as a texture. Is this too hard or beyond the scope of what can be achieve in JavaFX?
Theoretically It would then be possible to drag the vertices of the mesh at draggable points and successfully applying transformations to the texture. Would this be possible?
Images showing what I am trying to achieve
As you can see maybe after plotting the mesh the points connecting the vertices can be dragged in order to manipulate or transform the shape of the mesh. If the mesh has a texture over it. would the image then also transform ?
Would this be possible with the TriangleMesh class that JavaFX has which by the way there is very little out there which explains how to use it and how the points, face points and texture points work. Very confusing =(.
Target End Result
My question is would the type of manipulation shown in the image above be possible in JavaFX? Can this sort of functionality be achieved using the TriangleMesh class or other similar class in JavaFX ? As you can see what I am trying to achieve is really image manipulation I would appreciate knowing if there is another better way to do this.
I unfortunately do not have any code I can share. I just cant seem to produce any regarding this task. I am not asking to be given code or for someone to solve the problem for me. I just want to see examples be guided into the right direction on how to do this and to know if it is even possible or should I just give up on it!
If you have read this far Thank you so much for your time I really appreciate it.
I have read your question till the end :-) In contrast to many people here you are at least providing a clear description of what you want to achieve. According to my own experience I would say that what you want to do is easily possible with JavaFX and the MeshView is the way to go here.
You can use your image as the texture for this mesh and you can distort the image by manipulating the vertices of this mesh. I have implemented part of your functionality myself for a project so I know that it works.

Animation of letters filling After Effect

Is it possible to animate text/object with 'end' in after effects just like you do with strokes? How can I achieve this? See the video and you'll understand what I wan't to achieve.
YouTube - Guy showing the 'end' on a stroke
Cheers,
Tommie
I think I see what you are asking. You want the shapes of a text layer (the actual lines of each character) to actually build on, right? Can't be done like that. Even if you use text and convert to shapes, you are looking at a world of pain because of the way letters are built by most fonts (for one thing, the shapes are actually filled, not stroked -- strokes are outlines).
The only way I would do this is by using the Element 3D plugin in After Effects and Cheetah3D (or whatever 3D tool you want to use). In Cheetah, I'd create the text shapes as extruded 3D text. Then I'd use the "Build" modifier ("Linear" setting) to progressively build the text. Then I'd export that out as an OBJ sequence (script for this is available on cheetah forum site -- I wrote it) and bring that sequence into Element3D and work with it that way. That will work. And as far as I know, that's the only way with a decent amount of control. Wedding video? Just curious. :-)

Drawing graphs with purely HTML5

Can any one point me to any resources for making graphs in HTML5? Most of resources I have seen through Google use animated graphs, I just want a simple static graph in HTML5. One more thing, I am really very weak in graphs, so a simple, easy to understand solution would be very helpful. I will be using this XML file to display data in graphical format.
US Canada Mortality
Thanks in advance :-)
Check out the new canvas tag. It allows you to draw shapes including rectangles and circles using javascript. Canvas Tutorials
If you're looking for just a standard bar chart, though, you can use the div tag with a specified width, height, and background color. This method avoids the use of javascript.

Approaches / libraries for resize dragging

I'm currently working on a WYSISYG editor that allows the user to move, resize and rotate shapes by directly manipulating them. The resizing seems to be fairly complex when the shape is rotated. I got this working for non-rotated shapes, but it will take some trigonometric calculations to resize shapes that are rotated. The registration point is always is the middle of the rectangle because this makes rotating a lot easier.
Before I start implementing this, I was wondering if anyone knew of any libraries or sample source code that does this, or could share some tips and tricks to calculate the transformations.
I have the following parameters:
rotation (in degrees)
width, height
x, y
mouseX, mouseY
I attached a screenshot of what I'm trying to accomplish and another one that has some lines drawn onto it that should allow me to deduct the trigonometric calculations. The cross is the cursor.
alt text http://www.herrodius.com/images/resize.jpg
alt text http://www.herrodius.com/images/resize_lines.jpg
You might look at flex-object-handles, in particular the more recent version 2.
I recommend Transform Manager - http://www.greensock.com/transformmanageras3/
It's actually not that hard. Use the mouse coordinates (mouseX / mouseY)from the rotated display object and they will be transformed for you!

Resources