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

How to horizontally adjust the model after loading gltf #2449

Open
liangyuan1 opened this issue Oct 24, 2024 · 0 comments
Open

How to horizontally adjust the model after loading gltf #2449

liangyuan1 opened this issue Oct 24, 2024 · 0 comments
Assignees
Labels

Comments

@liangyuan1
Copy link

After loading gltf, the model keeps displaying vertically. Adjusting rotateZ, rotateY, and rotateX does not take effect. How can I quickly make the model display horizontally on the ground and adjust the horizontal angle

Your Environment

  • Version used:2.44.2
  • Browser Name and version:

image

code

`const loader = new GLTFLoader3D()
const dracoloder = new DRACOLoader()
dracoloder.setDecoderPath('/draco/')
loader.setDRACOLoader(dracoloder)
// 开始加载
loader.load('/model5.glb', (gltf) => {
const model = gltf.scene
// building coordinate
const coord = new itowns.Coordinates(
'EPSG:4326',
113.249257,
28.408089,
0
)
console.log(coord.as(view.referenceCrs))
model.position.copy(coord.as(view.referenceCrs))

    // *********************************************************
    // align up vector with geodesic normal
    model.lookAt(model.position.clone().add(coord.geodesicNormal))
    model.rotateZ(-Math.PI / 2)
    // *********************************************************
    model.scale.set(100, 100, 100)

    // update coordinate of the mesh
    model.updateMatrixWorld()

    view.scene.add(model)
    view.notifyChange()
  })

`

@jailln jailln self-assigned this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants