Skip to content

How to horizontally adjust the model after loading gltf #2449

Open
@liangyuan1

Description

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()
  })

`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions