组、gui可视调参工具
const gui = new dat.GUI();
gui.add(camera.position, "x", -20, 20).name("相机的x轴位置");
gui.add(camera.position, "y", -20, 20);
gui.add(camera.position, "z", -20, 20);
const folder = gui.addFolder("相机位置");
folder.add(camera.position, "x", -20, 20);
folder.add(camera.position, "y", -20, 20);
folder.add(camera.position, "z", -20, 20);
const car = new THREE.Group();
const material = new THREE.MeshNormalMaterial({ color: 0xffff00 });
const doubleWheel = new THREE.Group();
const wheel = new THREE.Group();
const torus = new THREE.Mesh(
new THREE.TorusGeometry(1, 0.15, 16, 100),
material
);
wheel.add(torus);
const cylinder = new THREE.Mesh(
new THREE.CylinderGeometry(0.1, 0.1, 2),
material
);
for (let i = 0; i < 10; i++) {
const cloneCylinder = cylinder.clone();
cloneCylinder.rotation.z = ((Math.PI * 2) / 10) * i;
wheel.add(cloneCylinder);
}
const whee2 = wheel.clone();
whee2.position.z = 3;
const cylinder2 = new THREE.Mesh(
new THREE.CylinderGeometry(0.1, 0.1, 3),
material
);
cylinder2.position.z = 1.5
cylinder2.rotation.x = 90 / 180 * Math.PI
doubleWheel.add(wheel);
doubleWheel.add(whee2);
doubleWheel.add(cylinder2)
const doubleWheel2 = doubleWheel.clone()
doubleWheel2.position.x = 4
car.add(doubleWheel);
car.add(doubleWheel2)
scene.add(car);