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

394
Views
Threejs: creando una clase, no se puede pasar Vector3 a través de la variable de posición

He intentado pasar la posición de un Vector3 a this.positon = position; donde la posición es == x, y, zie: 0, 2, 0; joe = new people((0, 2, 0)) sin embargo, no funciona. La esfera no aparece. No recibo ningún error, y cuando console.log(joe) la posición = 0

 class people { constructor(name, age, color, position, radius) { this.name = name, this.age = age, this.color = color, this.position = position, this.radius = radius, this.createperson() } createperson() // runs script below { this.person = new THREE.Mesh( new THREE.SphereGeometry(this.radius, 32, 16), new THREE.MeshStandardMaterial({ color: this.color, metalness: 0, roughness: 0.5 }) ) this.person.position.set(this.position) scene.add(this.person) }

}

let joe = new people('Joe', 26, '#00ff00', (0, 1, 0), 2)

pero cuando lo paso individualmente como this.x = x, this.y = y, this.z = z . joe = new people(0, 2, 0) esto funciona. Aparece como debería. Cuando console.log(joe) , la posición es un Vector3.

 class people { constructor(name, age, color, x, y, z, radius) { this.name = name, this.age = age, this.color = color, this.x = x, // this this.y = y, // part this.z = z, // here works this.radius = radius, this.createperson() } createperson() // runs script below { this.person = new THREE.Mesh( new THREE.SphereGeometry(this.radius, 32, 16), new THREE.MeshStandardMaterial({ color: this.color, metalness: 0, roughness: 0.5 }) ) this.person.position.set(this.x, this.y, this.z) scene.add(this.person) }

}

let joe = new people('Joe', 26, '#00ff00', 0, 1, 0, 2)

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

let joe = gente nueva('Joe', 26, '#00ff00', (0, 1, 0), 2)
=> let joe = gente nueva('Joe', 26, '#00ff00', new THREE.Vector3(0, 1, 0), 2)

y

esta.persona.posición.set(esta.posición) => esta.persona.posición.copy(esta.posición)

about 4 years ago · Santiago Trujillo Report
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!