x3dom / x3dom

X3DOM. A framework for integrating and manipulating X3D scenes as HTML5/DOM elements.
http://x3dom.org
Other
813 stars 271 forks source link

How to achieve the effect of mouse selection #1263

Closed CYY-1100 closed 1 year ago

CYY-1100 commented 1 year ago

How to achieve the effect of mouse selection

andreasplesch commented 1 year ago

There are many ways to highlight a shape when hovering or clicking with the mouse pointer.

This tutorial turns the nose red when clicked: https://doc.x3dom.org/tutorials/models/inline/index.html

Here is another example which temporarily turns shapes yellow before returning to the original color:

https://andreasplesch.github.io/Library/Examples/html5/highlight/turnyellow.html

A more X3D way to indicate selection would be to use a Switch node which has the shape to display during selection as a choice. Or use the visible field of a Shape to toggle display based on a TouchSensor.

andreasplesch commented 1 year ago

Here is another approach. Dynamically attach an invisible highlight box to each shape of a certain class, scaled using the bounding box, and then simply turn that box on and off when desired.

https://andreasplesch.github.io/Library/Examples/html5/highlight/withBBox.html

microaaron commented 1 year ago

Maybe you're trying to highlight the outline of a shape.

andreasplesch commented 1 year ago

Outlines could be done using a custom shader:

https://alexanderameye.github.io/notes/rendering-outlines/

and many other shader examples.

Custom shaders:

https://doc.x3dom.org/tutorials/lighting/customShader/index.html

andreasplesch commented 1 year ago

Or by duplicating the shape, scaling it a bit larger, and showing only the backfaces: https://andreasplesch.github.io/Library/Examples/html5/highlight/outline.html

CYY-1100 commented 1 year ago

Or by duplicating the shape, scaling it a bit larger, and showing only the backfaces: https://andreasplesch.github.io/Library/Examples/html5/highlight/outline.html

ok, I got it thanks for you help

CYY-1100 commented 1 year ago

Maybe you're trying to highlight the outline of a shape.

yes, i do it

andreasplesch commented 1 year ago

There is now also the bboxDisplay field.

n-polys commented 1 year ago

Cool!

On Sat, Apr 8, 2023, 4:24 PM Andreas Plesch @.***> wrote:

Closed #1263 https://github.com/x3dom/x3dom/issues/1263 as completed.

— Reply to this email directly, view it on GitHub https://github.com/x3dom/x3dom/issues/1263#event-8958120456, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYQT72P4J3FQ5LWR3W7ZQILXAHCOTANCNFSM6AAAAAAV3Q43EY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

npolys commented 3 weeks ago

IS there an example of the new functionality with nodes like Shape, Transform, and Group? I think bboxDisplay would be a great feature! ... ?

Does X3DOM automatically create a bbox of the correct size? How to do this at runtime?

andreasplesch commented 3 weeks ago

https://github.com/x3dom/x3dom/blob/master/test%2Fregression-suite%2Ftest%2Fcases%2Froutes%2Froutes.html

is an example.

All grouping nodes work, and the size is automatic.

andreasplesch commented 3 weeks ago

Here are the details:

https://github.com/x3dom/x3dom/blob/master/src%2Fnodes%2FGrouping%2FX3DBoundedObject.js

So all bounded objects work, and there is also bboxColor and bboxMargin.

andreasplesch commented 3 weeks ago

live https://raw.githack.com/x3dom/x3dom/master/test/regression-suite/test/cases/routes/routes.html

andreasplesch commented 3 weeks ago

Note the TouchSensor and simple route from the TouchSensor event to bboxDisplay.

npolys commented 3 weeks ago

Fantastic! Thanks for this feature! :-)

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Andreas Plesch @.> Sent: Wednesday, May 22, 2024 8:01:35 AM To: x3dom/x3dom @.> Cc: Polys, Nicholas @.>; Comment @.> Subject: Re: [x3dom/x3dom] How to achieve the effect of mouse selection (Issue #1263)

Note the TouchSensor and simple route from the TouchSensor event to bboxDisplay.

— Reply to this email directly, view it on GitHubhttps://github.com/x3dom/x3dom/issues/1263#issuecomment-2124620685, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AB2TSMZFB3KY2ADFW2TSYDTZDSCJ7AVCNFSM6AAAAAAV3Q43E2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRUGYZDANRYGU. You are receiving this because you commented.Message ID: @.***>