Jump to content

Cannot move my model


Recommended Posts


Here's my class:

var rockraider;

// [...]

		class RockRaider {
			constructor(xpos,zpos) {
				var raider;
            	this.xpos = xpos; this.zpos = zpos;
            	/*this.rotation = rotation;*/
            	raider = loader.addMeshTask("build", "", "CanvasRR0/", "rockraider.obj");
                raider.onSuccess = function(t) {
                    t.loadedMeshes.forEach(function(m) {
                        m.position.x = xpos; //-75
                        m.position.z = zpos; //-50
                        m.rotation.y = Math.PI/2; //dev
						m.rotation.x = 0;
                        m.scaling = new BABYLON.Vector3(2,2,2);
                this.raider = raider;
				setTimeout(function() {
				raider.loadedMeshes.forEach(function(m) {
					m.material.emissiveColor = new BABYLON.Color3(.1, .1, .1);
				}, 3000);
			moveTo() {
				this.raider.loadedMeshes.forEach(function(m) {
					m.position.x = 100;
		rockraider = new RockRaider(125,200);


And here's my question: Why doesn't my model move when I call function rockraider.moveTo();? Instead, only one element of it moves.
I used a forEach(). In first case (in above code, under 3000ms timeout) it worked, but in second it didn't. Why?

Thanks :)

Link to comment
Share on other sites

Hi K.  Just a quick look... umm... don't you need 'moveTo()' to be this.moveTo() or maybe this.raider.moveTo()?  Not sure.  :)

Our 6-mesh 'Dude' is still walking (positioning) okay, but that's a different type of loader and different type of model.

You know how it works, Kajtek... put console.log(info) messages EVERYWHERE.  Check your loaded meshes, make sure m HAS a .position property for moveTo() to use.

Make that NEGATIVE 100... because the model starts at X = +125.  Make sure you can SEE the mesh move... by increasing the move-amount.

One segment of a mesh... moves when you call moveTo()? 

Can you please tell us about your rockraider.obj?   How many mesh/subMesh?  Perhaps share it with us?  (thx either way)

Sorry, not very helpful, am I?   I'm not very experienced with importing.  

I'll keep thinking.  You insert console.log(m) and look at it in your browser f12 dev tools object inspector (by clicking on the word 'object' in the console).  (You probably know all this already).  Your emissiveColor change at 3000 ms works fine, huh?  hmm.

Link to comment
Share on other sites

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.

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.


  • Recently Browsing   0 members

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