Mugen87 / yuka

JavaScript library for developing Game AI.
https://mugen87.github.io/yuka/
MIT License
1.1k stars 90 forks source link

how to set initial mesh #53

Closed loveacat closed 2 years ago

loveacat commented 2 years ago

sorry for my pool english. 1. i want to load a .fbx model as a vehicle mesh,and use arriveBehave class to simulate a scraper move. model load is success, but model is too large and position is not good, i have to scale the model and set the inital position. but when i set mesh.matrixAutoUpdate too false, all my initial set is not work. i am a noob to three js, thans for your reply。2. i want the model don't turn the direction when arrive the target and move to the next target , is there a paremeter to control behave ? `loader.load('model/pingcangji.fbx', function (object) { object.traverse(function (child) { if (child.isMesh) { child.castShadow = true; child.receiveShadow = true; child.scale.x = child.scale.y = child.scale.z = 0.5;

        //yukavehicle.setRenderComponent(child, sync);
        child.rotation.x = Math.PI;
        child.rotation.y = 0;
        child.matrixAutoUpdate = false;
    }
});
object.position.x = 9 * positionWidth;
object.position.y = 10 * positionWidth;
object.position.z = 90;
object.visible = true;
scene.add(object);

});`

Mugen87 commented 2 years ago
  1. Please do not change the transformation properties of three.js (meaning position, rotation and scale). Just set the matrixAutoUpdate property to false and modify the game entity instead. Alternatively, you can change the geometry. However you should only apply one-time changes to the geometry.

  2. Try to set the updateOrientation flag of your vehicle to false.