Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to load a single model in Cesium

Shulou Source: shulou.com Published: 2022-06-01 03:41:07 09月26日 Update

This article mainly shows you "how to load a single model in Cesium", the content is simple and clear, hoping to help you solve your doubts, let the editor lead you to study and learn "how to load a single model in Cesium" this article.

Cesium supports loading a single 3D model, the commonly used model format is: gltf,glb, these models can be converted from 3dmax, obj and other 3D model format. The official website of Cesium also lists the ways to load a single 3D model, according to the detailed code.

The detailed code is in the Cesium example: 3D Models.html page

The model file for the sample is in the folder of: SampleData

The following is the detailed code for loading the model:

/ / location information, x, y, height information

Var position = Cesium.Cartesian3.fromDegrees (- 123.0744619, 44.0503706, height)

/ / the three directions of the model and the three directions of the three corners in the three-dimensional space can be seen in the figure above.

/ / schematic diagram of small aircraft (where direction corresponds to heading and tilt corresponds to pitch)

Var heading = Cesium.Math.toRadians

Var pitch = 0

Var roll = 0

Var hpr = new Cesium.HeadingPitchRoll (heading, pitch, roll)

/ / to make a conversion according to the position and the set corner information

Var orientation = Cesium.Transforms.headingPitchRollQuaternion (position, hpr)

/ / A single object is usually placed in an entity, and a solid object is added

Var entity = viewer.entities.add ({

/ / set position and steering information

Name: url

Position: position

Orientation: orientation

Model: {

/ / the path of the model

Uri: url

/ / scale of the model

Scale:1.0

/ / the smallest pixel size

MinimumPixelSize: 128

/ / maximum display scale

MaximumScale: 20000

}

});

The loading effect of the model, when the code is used, remove the comment information:

These are all the contents of the article "how to load a single model in Cesium". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Model single information code 3D location content article corner three entity object file direction format scale learning help maximum minimum Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux OPPO Reno Shulou Tech Info Apple MySQL