javascript - Three.js access scene by name -


i 6 hours three.js , coming grip new concepts. trying access objects inside scene, on page 2 canvas & scenes.

i have following html:

<div id="my-canvas">     <canvas width="....></canvas> </div>  <div id="their-canvas">     <canvas width="....></canvas> </div> 

each of these containers ends canvas generated inside , cubes rendered.

i name each scene this:

    scene = new three.scene();     scene.name = scenename; 

scenename variable containing name of scene. can see scene property correct value when console.log scene.

later in code want access scene name, have not been successful. correct way?

var activescene = three.object3d.getelementbyname(scenename); 

the method .getelementbyname not three.js method.
method .getobjectbyname exists in three.js wont work in case because loops through objects inside scene (scene top-level object).

solution: declare different variable each scene. access each scene variable name.

for example:

var my_scene = new three.scene(); var their_scene = new three.scene();  // assign variable var activescene = their_scene; // , later activescene = my_scene; 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -