Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

84
Vistas
Set a distance between two meshes in THREE.JS

I have this code which generates cylinders in position of each Poi (sprite), So i want to set a distance between the cylinder and the sprite , how can I do?

const THREE = this.context.three;
const textureLoader = new THREE.TextureLoader();
const geometry = new THREE.CylinderGeometry( 0.09, 0.09, 5, 5 );
geometry.rotateZ(-Math.PI * 0.5);
const material = new THREE.MeshBasicMaterial( {color: 0xFF00FF } );
const cylinder = new THREE.Mesh( geometry, material );
if (!this.inputs.sprite) {
  return;
}

if (!this.inputs.sprite.startsWith('/assets/')) {
  textureLoader.crossOrigin = 'Anonymous';
}

let map;
if (this.inputs.sprite.indexOf('.gif') !== -1) {
  map = new GifLoader().load(this.inputs.sprite);
} else {
  map = textureLoader.load(this.inputs.sprite);
}
map.minFilter = THREE.LinearFilter;
map.wrapS = map.wrapT = THREE.ClampToEdgeWrapping;

this.material = new THREE.SpriteMaterial( { map, color: this.inputs.color, fog: false } );
this.material.alphaTest = 0.5;
this.material.map.encoding = THREE.sRGBEncoding;
this.sprite = new THREE.Sprite( this.material );
this.sprite.add(cylinder);

this.onObjectReady(this.sprite, true);
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Since you are adding the cylinder as a child of the sprite, you can define an offset position for the cylinder. Sense:

 cylinder.position.x = 2;

Assuming that the cylinder nodes and their ancestors are not scaled, the distance from the cylinder to the sprites position would be 2 world units.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda