Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining meshes and rotating them? #83

Closed
synthXR opened this issue Feb 24, 2022 · 1 comment
Closed

Combining meshes and rotating them? #83

synthXR opened this issue Feb 24, 2022 · 1 comment

Comments

@synthXR
Copy link

synthXR commented Feb 24, 2022

First of all, great work! Let's say there are three cubes stacked on top of each other or some more complex geometry. How is it possible to group them into one single mesh (to later rotate the mesh)? There is not much to be found about combining 3d meshes in the examples. Thanks

const c1 = app.stage.addChild(Mesh3D.createCube());
const c2 = app.stage.addChild(Mesh3D.createCube());
const c3 = app.stage.addChild(Mesh3D.createCube());

// ..? Combine & rotate c1,c2,c3 as one mesh?
@jnsmalm
Copy link
Owner

jnsmalm commented Feb 24, 2022

Hello!

Just like PixiJS you just add your objects to a container, and then rotate that container.

const container = app.stage.addChild(new PIXI3D.Container3D())

const c1 = container.addChild(PIXI3D.Mesh3D.createCube());
c1.x = -2.5
const c2 = container.addChild(PIXI3D.Mesh3D.createCube());
c2.x = 0
const c3 = container.addChild(PIXI3D.Mesh3D.createCube());
c3.x = +2.5

let rotation = 1
app.ticker.add(() => {
  container.rotationQuaternion.setEulerAngles(rotation++, 0, 0)
})

@jnsmalm jnsmalm closed this as completed Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants