Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
El cilindro no gira bien cuando la coordenada Y es diferente de 0. BabylonJs

Estoy usando babylonJs para dibujar algunos cilindros entre 2 puntos y funciona perfecto cuando los puntos tienen la coordenada Y en 0, pero cuando uno de los puntos tiene una Y diferente, entonces el cilindro está apagado como se puede ver en la imagen Error

Esta diagonal debe ir de esquina a esquina. El código que estoy usando es este:

 for(var i = 0;i+1 < newObj.attachmentPoints.length;i++){ if( newObj.attachmentPoints[i].attachmentType === "Measure" && newObj.attachmentPoints[i+1].attachmentType === "Measure") { let from = new BABYLON.Vector3(newObj.attachmentPoints[i].location.x, -newObj.attachmentPoints[i].location.y, -newObj.attachmentPoints[i].location.z); let to = new BABYLON.Vector3(newObj.attachmentPoints[i+1].location.x, -newObj.attachmentPoints[i+1].location.y, -newObj.attachmentPoints[i+1].location.z); const faceColors = [ ]; faceColors[0] = new BABYLON.Color4(0, 0, 1, 1); faceColors[1] = new BABYLON.Color4(0, 0, 1, 1); faceColors[2] = new BABYLON.Color4(0, 0, 1, 1); let distance = BABYLON.Vector3.Distance(to,from ); var options = { height:distance, diameterTop:1, diameterBottom:1, tessellation:36, faceColors:faceColors } var cylinder = BABYLON.MeshBuilder.CreateCylinder("cylinder", options, this._scene); cylinder.setPivotMatrix(BABYLON.Matrix.Translation(0, -distance / 2, 0)); cylinder.position = new BABYLON.Vector3(newObj.attachmentPoints[i+1].location.x, -distance / 2, -newObj.attachmentPoints[i+1].location.z); var v1 = to.subtract(from); v1.normalize(); var v2 = new BABYLON.Vector3(0, 1, 0); var axis = BABYLON.Vector3.Cross(v1, v2); axis.normalize(); console.log(axis); var angle = BABYLON.Vector3.Dot(v1, v2); cylinder.rotationQuaternion = BABYLON.Quaternion.RotationAxis(axis, -Math.PI / 2 + angle); } }

¿Cualquier pista?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!