ThreeJS: does 3js modify uuid of objects in runtime? - three.js

Is it possible that 3js modify uuid of objects behind the scene? I thought that uuid is constant and only it may be changed manualy by developer.

Please read the docs first, https://threejs.org/docs/#api/en/core/Object3D.id. It clearly says it is read-only.

Related

cannon.js basic physics setup as class in three.js

Very new to coding and Im following a course on three.js using cannon-es, I have quickly come to understand the need to keep things organized in classes using constructor, (my project is currently all in one or two files and is getting messy.) But still confused as to how to convert existing code into a class. I would like to see an example of basic cannon physics setup as a class or how I can make one.
I was in the same situation and was able to make parts as classes but seems buggy as when I add new objects to the Cannon world,the objects before disappear,don't know what causes this but I can share my code with you so we can solve this issue if you are willing.

model view Object to Geometry mapping

We have followed the step-by-step tutorials for the model-derivative apis. I can use the /manifest endpoint to get the object tree. I can also create tasks to get a .obj file with geometries of some objects. There is no way to know which geometry belongs to which object.
I could potentially create a job for each object, but that would require thousands of jobs per model which seems excessively inefficient. Are we missing something? Any pointers on how to get geometry for objects while retaining the mapping between them?
The Viewer will extract the information, but as of today, we don't have a documentation for SVF, so it may get trickier to analyze the geometry from this file. You may use JavaScript, something like described in this sample or this sample.
You can extract the OBJs for each element, but may need a big number of jobs. In this case, you need to run your code for .obj files.

Are there limitations to limit to the three.js userData property?

I am using the Three.js Object3D userData property to store information from a MySQL database serialized into json pairs to give me data to perform various actions when selecting objects which represent saved data. It seems to work nicely for a few pairs.
I note from the reference a warning to not to store references to functions as they will not be cloned. Can anyone tell me if there any other limitations to this property (number of pairs, hierarchical data, etc.)? I want to store 2-3000 words of text, images, blobs etc., but prefer to ask over trial and error. the documents are a little sparse on such matters.
Many thanks... James
No there are not special limitations. It is simply a Javascript object:
https://github.com/mrdoob/three.js/blob/0fbc8afb348198e4924d9805d1d4be5869264418/src/core/Object3D.js#L85
this.userData = {};
So while your object is in memory, you can put any Javascript variables there. Only limitations are what you always have, the available memory basically. As Javascript objects can contain any types and hierarchy so you're off fine there.
I used this search to check this in the codebase: https://github.com/mrdoob/three.js/search?utf8=%E2%9C%93&q=userdata

Having trouble navigating Magento documentation

I am brand new to Magento and the documentation, primarily the phpDocs, are difficult to navigate. For example,
$attributeSet = Mage::getModel('eav/entity_attribute_set')->load($id);
In the php doc for Class Mage_Eav_Model_Entity_Attribute_Set there is no mention of the method getAttributeSetName() either in inherited methods or otherwise and yet this works.
$attributeSet = Mage::getModel('eav/entity_attribute_set')->load($id);
echo $attributeSet->getAttributeSetName();
So I suppose I have several questions.
Can someone explain to me why the documentation is this way?
Where I can find the mysterious getAttributeSetName() method in the phpDocs?
My theory is that there is some inheritance or a design pattern implementation going on that I'm not understanding, maybe someone can shed some light on this for me.
If you really want to fry your brain, take a look at the source code for Mage_Eav_Model_Entity_Attribute_Set and follow the inheritance chain all the way back. You won't find a getAttributeSetName method defined anywhere.
All Magento objects that inherit from Varien_Object can have arbitrary data members set on them. Try this.
$attributeSet = Mage::getModel('eav/entity_attribute_set')->load($id);
$attributeSet->setFooBazBar('Value');
var_dump($attributeSet->getFooBazBar());
var_dump($attributeSet->getData('foo_baz_bar'));
var_dump($attributeSet->setData('foo_baz_bar','New Value'));
var_dump($attributeSet->getFooBazBar());
You can also get all the data members by using
var_dump($attributeSet->getData());
but be careful dumping these, because if there's a data object that has a circular reference and you're not using something like xDebug, then PHP will have a fit trying to display the object.
Magento stores data properties in a special _data array property. You can get/set values in this array with getData and setData. Magento also has implemented magic getting and setter methods, so when you say something like
$object->getFooBazBar();
The method getFooBazBar is transformed into the data property foo_baz_bar. and then getData is called using this property. It's a little tricky to get your head around, but once you get it you'll start to see how much time you can save using this pattern.
One side effect of this is, of course, it's impossible to infer what data properties any object might have by looking at it's class file, so there's no phpDocs for these methods.

Explicitly setting the datasource for WebFrame

Is it possible to manually create WebDataSource objects and then set the created object to be the datasource of a webFrame object? I can't seem to find a method on WebFrame class that allows the setting of datasource. The goal is to asynchronously pre-load webpages without having to render them in a web view all at once.
Just use an offscreen WebView. It'll load the resources for you and not waste time drawing itself.
(I gather this is a follow-up to the question I answered a little while ago?)
As I alluded to in my comment on that question, you use one of the -[WebFrame load...] methods to load content. When you issue the load request the WebView instantiates a -provisionalDataSource which in turn becomes the -dataSource (so much for clear naming!). As the class documentation summarizes:
The provisional data source transitions to a committed data source
once any data is received.
Unless you are extending WebKit, I don't think there is usually a reason to create WebDataSource instances directly. Let WebFrame do it for you.

Resources