Closed edhyah closed 2 years ago
@edhyah thanks for reaching out.
Since you are building the ThreeJS objects yourself, you should be able to apply the desired rotation operations to the objects. See: https://threejs.org/docs/#api/en/core/Object3D.rotation
How can I access the objects themselves? object-three-object
or objectsData
doesn't seem to give me pointers to the generated threejs objects.
Specifically, I have a globe entity (globeEl), and I do the following:
globeEl.setAttribute('globe', { objectThreeObject: () => new THREE.Mesh(geometry, material) });
objectThreeObject
is a function, and I don't have access (ie. don't have access to the pointer) to the three object that is created after calling this function. Is there an API function that allows me to get pointers to the generated threejs objects?
@edhyah you do have access to the Three object itself, at generation time, since you're actually implementing that function.
Perhaps it's clearer if you re-write that function as:
objectThreeObject: objectData => {
const myObj = new THREE.Mesh(geometry, material);
myObj.rotation = /* your code, possibly depending on objectData */
return myObj;
}
Do you not have access to the object at runtime after generation? I want to be able to set the rotation after the object has been generated, based on some real-time data. If that's not possible, does that mean I have to generate all of the objects each time I want to change the rotation?
Thanks again though, this is super helpful!
You can also find the ThreeJS object attached to each the items in your data array that you have passed using objectsData
.
Each of these items have an attribute called __threeObj
that references the ThreeJS object itself. So at any point you can iterate through your data and apply rotation to each of the objects.
That worked! Thank you!
Hello,
In the 3D objects layer, after adding an object to the globe, is it possible to rotate the object to a desired orientation? Specifically, I'm trying to add a plane icon to your airline routes demo that points the plane in the direction of the route. I looked through your other demos like the satellite demo but none of them actually change the orientation of the added objects.
Thanks!