# New nub library released

**URL:** <https://discourse.processing.org/t/new-nub-library-released/19644>\
**Category:** Gallery\
**Created:** [April 10, 2020, 9:13pm UTC](https://discourse.processing.org/t/new-nub-library-released/19644 "2020-04-10T21:13:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nakednous](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/nakednous/32/8763_2.png) [@nakednous](https://discourse.processing.org/u/nakednous)\
**Post date:** [April 10, 2020, 9:13pm UTC](https://discourse.processing.org/t/new-nub-library-released/19644/1 "2020-04-10T21:13:26Z")

</div>

Hello,

I’m pleased to let you know that I recently have released the [nub](https://github.com/VisualComputing/nub) library which supersedes and at the same time simplifies `proscene`. Please check the `README` for its usage and main features which include:

1. Interaction: 2D/3D navigation, object picking & manipulation through the mouse or any other device.
2. Rendering and animation frameworks which provides the ground to easily implement advanced effects such as [shadow mapping](https://github.com/VisualComputing/nub/tree/master/examples/demos/ShadowMapping) and others.

You can import the library directly from the `PDE`. Please report **issues** you may find at the project page and discuss questions and ideas here at the discourse. Please also consider sharing your creations with **nub** here at the **Processing** discourse.

Enjoy!

---

<div class="post-metadata">

**Author:** ![micycle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micycle/32/201_2.png) [@micycle](https://discourse.processing.org/u/micycle)\
**Post date:** [July 16, 2020, 9:30am UTC](https://discourse.processing.org/t/new-nub-library-released/19644/2 "2020-07-16T09:30:36Z")

</div>

I just saw this on GitHub… I think some screenshots either here or there would be useful

---

<div class="post-metadata">

**Author:** ![vkbr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/vkbr/32/16844_2.png) [@vkbr](https://discourse.processing.org/u/vkbr)\
**Post date:** [March 30, 2024, 3:35am UTC](https://discourse.processing.org/t/new-nub-library-released/19644/3 "2024-03-30T03:35:53Z")

</div>

Hello @nakednous .  
Thanks a lot for sharing and all the amazing code. Love the library.  
I was wondering how could I save a bunch of keyframes and later read them from a file.  
Can be done?  
Can I access the internal keyFrames storing structure?  
I found no way of accessing it via API. But maybe I’m just not finding it…  
: )

Anyway, thanks a lot.  
cheers  
vk

ps: Actually I’m willing to save each frame and play it back later. I’m not using, or willing to use, the interpolation. Just the “state” of each object/eye each frame.

My first test code goes like:

```auto
if (rec) {
    scene.eye().addKeyFrame();
    master.addKeyFrame();
  } else {
    if (scene.eye().removeKeyFrame(0.0) != null) {
      master.animate();
      scene.eye().animate();
    }
  }

```

I’m saving this data every frame, than later I’ll play it back, saving each frame as an image.  
This is necessary to keep the skecth flowing without the lag introduced by saving each frame.

---

<div class="post-metadata">

**Author:** ![nakednous](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/nakednous/32/8763_2.png) [@nakednous](https://discourse.processing.org/u/nakednous)\
**Post date:** [April 12, 2024, 3:29pm UTC](https://discourse.processing.org/t/new-nub-library-released/19644/4 "2024-04-12T15:29:08Z")

</div>

Hello @vkbr,

Apologies for the delayed response. I’ve just caught up with your query.

As of now, there isn’t a built-in method to achieve what you’re looking for. However, you can create a JSON serialization process to handle this. Below is a suggested approach:

```java
JSONObject toJSONObject(Node node, float time) {
  JSONObject jsonNode = new JSONObject();
  jsonNode.setFloat("time", time);
  jsonNode.setFloat("magnitude", node.worldMagnitude());
  jsonNode.setJSONArray("position", _toJSONArray(node.worldPosition()));
  jsonNode.setJSONArray("orientation", _toJSONArray(node.worldOrientation()));
  return jsonNode;
}

JSONArray _toJSONArray(Vector vector) {
  JSONArray jsonVec = new JSONArray();
  jsonVec.setFloat(0, vector.x());
  jsonVec.setFloat(1, vector.y());
  jsonVec.setFloat(2, vector.z());
  return jsonVec;
}

JSONArray _toJSONArray(Quaternion quaternion) {
  JSONArray jsonRot = new JSONArray();
  jsonRot.setFloat(0, quaternion.x());
  jsonRot.setFloat(1, quaternion.y());
  jsonRot.setFloat(2, quaternion.z());
  jsonRot.setFloat(3, quaternion.w());
  return jsonRot;
}

```

This code defines a method, toJSONObject, which converts a Node object into a JSONObject. Additionally, it includes helper methods to convert vectors and quaternions to JSONArray representations.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [April 12, 2024, 3:42pm UTC](https://discourse.processing.org/t/new-nub-library-released/19644/5 "2024-04-12T15:42:30Z")

</div>

What is nub, can you please explain in simple terms

---

<div class="post-metadata">

**Author:** ![nakednous](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/nakednous/32/8763_2.png) [@nakednous](https://discourse.processing.org/u/nakednous)\
**Post date:** [April 12, 2024, 5:00pm UTC](https://discourse.processing.org/t/new-nub-library-released/19644/6 "2024-04-12T17:00:56Z")

</div>

nub is a [scene graph](https://en.wikipedia.org/wiki/Scene_graph).

---

<div class="post-metadata">

**Author:** ![vkbr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/vkbr/32/16844_2.png) [@vkbr](https://discourse.processing.org/u/vkbr)\
**Post date:** [April 13, 2024, 2:53am UTC](https://discourse.processing.org/t/new-nub-library-released/19644/7 "2024-04-13T02:53:32Z")

</div>

Hey man, thank you very much. Will implement that. 🙂
