I am currently exploring ways to update or refresh dat.gui in order to reflect the changes I make to my selection. My main objective is to generate random cubes and then manipulate a single cube by rotating, scaling, changing position, etc.
The initial focus is on selecting a cube and controlling it through dat.gui. For starters, I want to display the name of the chosen object. Once I tackle this issue, I believe I can implement methods to control rotation, position, etc.
I aim at achieving something similar to this, although the provided code is outdated and complex to comprehend.
controller = new THREE.Object3D();
controller.objects = [];
controller.scene = scene;
controller.gui = gui;
controller.color = 0xFFFFFF;
controller.number_of_objects = controller.objects.length;
controller.selected_cube = 'test123';
controller.createNew = function() {
var cube = new THREE.Mesh(
new THREE.BoxGeometry(5, 5, 5),
new THREE.MeshBasicMaterial({
color: Math.random() * 0xffffff,
opacity: 0.5})
);
cube.position.x = Math.random() * (world_size * 2) - world_size;
cube.position.z = Math.random() * (world_size * 2) - world_size;
cube.name = 'cube_' + controller.objects.length;
controller.scene.add(cube);
controller.objects.push(cube);
controller.number_of_objects = controller.objects.length;
controller.selected_cube = cube.name;
};
gui.add(controller, 'number_of_objects').listen();
gui.add(controller, 'selected_cube').listen();
gui.add(controller, 'createNew');