three.js: Access Scene Objects by Name or ID

后端 未结 1 1217
轻奢々
轻奢々 2020-12-13 18:25

I\'m generating objects from an array which I\'ve defined like this (It\'s not limited to these three):

var links = [[\'Linkedin\',\'img/linkedin.png\',\'-30         


        
相关标签:
1条回答
  • 2020-12-13 18:50

    You can do this:

    myObject.name = "objectName";
    ...
    var object = scene.getObjectByName( "objectName" );
    

    or to recursively search the scene graph

    var object = scene.getObjectByName( "objectName", true );
    

    Alternatively, you can search by ID.

    var object = scene.getObjectById( 4, true );
    

    three.js r.61

    0 讨论(0)
提交回复
热议问题