Interfacing Data back and forth: JSapp  Drupal
Once your step one runs, you've actually created a unique order with a unique line item that references a product.
The ID in #2 should probably just be your line-item id. 


I would consider creating a rule on the event "After adding a product to cart" and a custom action (this is an answer where I provided the code to make a custom action) that takes a line item id (something the rule will easily have access to) and sends that to the three.js app.


You really just want to add the custom data to the line item (which is unique to each line item on the order). In fact, using Customizable Products you can easily create a bundle specifically for adding as many fields as you would need to track your data (and display/hide it in views or display modes).


To do this, I would create a menu item that somehow recieves the full json object. Perhaps this blog article will help? Regardless, once you have your data, you will want to update the line item with your data and the best way to do this is with entity meta data wrappers if you are using fields to store the data.

&lt;?php

$line_item_id = 1;
$line_item = commerce_line_item_load($line_item_id);
$line_item_wrapper = entity_metadata("commerce_line_item",$line_item);
dpm($line_item_wrapper-&gt;getPropertyInfo());

// ... mess with fields

$line_item_wrapper-&gt;save();

?&gt;



If you are using the fields on a line item to store your data, the cart will already be up-to-date because it simply references all the line items.