Dogggg Posted August 2, 2015 Share Posted August 2, 2015 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 farvar 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. Quote Link to comment Share on other sites More sharing options...
SET001 Posted August 24, 2015 Share Posted August 24, 2015 You can give an ID or Name to your object and then access it with getObjectByName or getObjectById Quote Link to comment Share on other sites More sharing options...
lo.th Posted September 4, 2015 Share Posted September 4, 2015 hi give a name 'object' is not a good idea in javascript object is Object methode {} of javascript, use obj instead Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.