Hi all, I’m in trouble with a problem. I want to dispose some object, for example some cone, or triangle around a circle, but i want that the tip of the cone point always to the center.
I modified a code that i found:
In this code the cones turn around the circle but they don’t point to the center.
Instead I want some like this:
The code:
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 1, 1000);
camera.position.setScalar(5);
camera.lookAt(scene.position);
var renderer = new THREE.WebGLRenderer()
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var controls = new THREE.OrbitControls(camera, renderer.domElement);
scene.add(new THREE.GridHelper(10, 10));
var circles = [];
for (let i = 0; i < 4; i++) {
setCircle()
}
function setCircle() {
let c = new THREE.Mesh(new THREE.ConeGeometry(0.5, 1, 8), new THREE.MeshBasicMaterial({
color: "white"
}));
scene.add(c);
circles.push(c);
}
var clock = new THREE.Clock();
var time = 0;
var radius = 2;
renderer.setAnimationLoop(() => {
time = clock.getElapsedTime() * 0.1 * Math.PI;
circles.forEach((c, ndx) => {
c.position.set(
Math.cos(time + Math.PI * 0.5 * ndx) * radius,
Math.sin(time + Math.PI * 0.5 * ndx) * radius,
0
)
})
renderer.render(scene, camera)
});
Can you help me please?