Giter Club home page Giter Club logo

Comments (6)

dkoes avatar dkoes commented on June 1, 2024

No, currently we just provide a "nomouse" option in the viewer which disables all mouse/touch handling under the presumption you want to provide your own handlers, but then you become responsible for transforming the scene in response to user input.

What is your use case and what sort of events would you like to see?

from 3dmol.js.

benbro avatar benbro commented on June 1, 2024

My use case is to save the viewer state. After page refresh or when reloading, the model will have the same zoom, rotation and position.
For example, if you embed a 3Dmol model in iPython notebook, you'll be able to change the state of the model and it will be saved automatically by the widget embedding the model.

It will be nice to have an event for every property in the model.
For now events for rotate, zoom and translate will be great.

from 3dmol.js.

dkoes avatar dkoes commented on June 1, 2024

getView and setView can be used to get and set the viewer state. getView in particular is pretty lightweight, so there should be no trouble just binding to the mousemove/touchmove/mousewheel events on the viewer and calling getView after each event. Make sure you use jQuery to bind the HTML element (the one provided to initialize the viewer) to these events and bind them to your handler after the 3Dmol viewer has been initialized. This way getView should get called after the view has been updated based on the mouse movement.

from 3dmol.js.

benbro avatar benbro commented on June 1, 2024

A generic 'change' event that will fire when there is a change in rotation, position or zoom might be cleaner to work with but you probably think that my use case is specific so getView and setView should work.

getView and setView are method of the viewer?
I don't see them in the docs.
http://3dmol.csb.pitt.edu/doc/$3Dmol.GLViewer.html

from 3dmol.js.

dkoes avatar dkoes commented on June 1, 2024

Hmm, they were apparently missing the @function JSDoc tag. I've fixed this.

from 3dmol.js.

benbro avatar benbro commented on June 1, 2024

Thank you for the answer and fix.

from 3dmol.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.