Jump to content

THREE.js acsess objects in the scene


Dogggg
 Share

Recommended Posts

Hey all, im new to three.js and javascript (done some pixi.js work for a gamedev comp once though) but not to 3D as I have worked with XNA.
I have a scene with a obj model and a floor from primitives,
here is my new entity class so far

var tempobj=null;function entity(path) {  this.loader = new THREE.OBJLoader();this.loader.load('chair.obj',function(object){object.position.x=0;object.position.y=10;object.position.z=0;tempobj = object;   scene.add(object);});  }entity.prototype.Move = new function(x,y){  tempobj.position.x+=0.005;}

it worked untill i added the tempobj = object; code, I need a way to acsess and alter the object after it's added to the scene, i tried using she .Name to identify it but that didn't work. current code fires error
"19:53:32.255 TypeError: tempobj is undefined1 game.html:198:2

"
 Which is the "tempobj.position.x+=0.005; Any help apreciated.

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...