Cesium添加模型并设置各种属性

一、所需文件

css样式文件:

Cesium-1.88\Apps\Sandcastle\templates\bucket.css

js文件:

Cesium-1.88\Build\Cesium\Cesium.js

Cesium-1.88\Apps\Sandcastle\Sandcastle-header.js

 二、HTML body

<div id="cesiumContainer" class="fullSize"></div>

 三、JavaScript

创建观查器

  var viewer = new Cesium.Viewer('cesiumContainer', {})

 设置一个模型属性

  var entity = viewer.entities.add({
        name: '飞机',
        position: Cesium.Cartesian3.fromDegrees(113.03, 23.42, 200),
        model: {
          uri: '../resource/mode/Cesium_Air.glb',
          minimumPixelSize: 1, //最小的模型像素
          maximumScale: 50, //最大的模型像素
          runAnimations: true, //是否显示动画
          clampAnimations: true, //是否保持最后一针的动画
          color: Cesium.Color.RED, //颜色
          color: Cesium.Color.fromAlpha(Cesium.Color.RED, parseFloat(1.0)), //包含透明度的颜色
          colorBlendMode: Cesium.ColorBlendMode['MIX'], //常用的有三个HIGHLIGHT,REPLACE,MIX
          colorBlendAmount: 0, //颜色遮罩:0-1,这个属性必须是MIX混合属性才能生效
        },
      })

 将相机设置到模型位置

viewer.trackedEntity = entity

 四、模型属性配置目录(百度翻译)

viewer.entities.add 的实体构造函数的初始化选项原文

ameTypeDescription
idStringA unique identifier for this object. If none is provided, a GUID is generated.
nameStringA human readable name to display to users. It does not have to be unique.
availabilityTimeIntervalCollectionThe availability, if any, associated with this object.
showBooleanA boolean value indicating if the entity and its children are displayed.
descriptionProperty | stringA string Property specifying an HTML description for this entity.
positionPositionProperty | Cartesian3A Property specifying the entity position.
orientationPropertyA Property specifying the entity orientation.
viewFromPropertyA suggested initial offset for viewing this object.
parentEntityA parent entity to associate with this entity.
billboardBillboardGraphics | BillboardGraphics.ConstructorOptionsA billboard to associate with this entity.
boxBoxGraphics | BoxGraphics.ConstructorOptionsA box to associate with this entity.
corridorCorridorGraphics | CorridorGraphics.ConstructorOptionsA corridor to associate with this entity.
cylinderCylinderGraphics | CylinderGraphics.ConstructorOptionsA cylinder to associate with this entity.
ellipseEllipseGraphics | EllipseGraphics.ConstructorOptionsA ellipse to associate with this entity.
ellipsoidEllipsoidGraphics | EllipsoidGraphics.ConstructorOptionsA ellipsoid to associate with this entity.
labelLabelGraphics | LabelGraphics.ConstructorOptionsA options.label to associate with this entity.
modelModelGraphics | ModelGraphics.ConstructorOptionsA model to associate with this entity.
tilesetCesium3DTilesetGraphics | Cesium3DTilesetGraphics.ConstructorOptionsA 3D Tiles tileset to associate with this entity.
pathPathGraphics | PathGraphics.ConstructorOptionsA path to associate with this entity.
planePlaneGraphics | PlaneGraphics.ConstructorOptionsA plane to associate with this entity.
pointPointGraphics | PointGraphics.ConstructorOptionsA point to associate with this entity.
polygonPolygonGraphics | PolygonGraphics.ConstructorOptionsA polygon to associate with this entity.
polylinePolylineGraphics | PolylineGraphics.ConstructorOptionsA polyline to associate with this entity.
propertiesPropertyBag | Object.<string, *>Arbitrary properties to associate with this entity.
polylineVolumePolylineVolumeGraphics | PolylineVolumeGraphics.ConstructorOptionsA polylineVolume to associate with this entity.
rectangleRectangleGraphics | RectangleGraphics.ConstructorOptionsA rectangle to associate with this entity.
wallWallGraphics | WallGraphics.ConstructorOptionsA wall to associate with this entity.

viewer.entities.add 的实体构造函数的初始化选项翻译

名字类型描述
id字符串此对象的唯一标识符。如果未提供任何内容,则生成 GUID。
name字符串要向用户显示的人类可读名称。它不必是唯一的。
availability时间间隔收集与此对象关联的可用性(如果有)。
show布尔一个布尔值,指示是否显示实体及其子实体。
description物业|字符串一个字符串 属性,用于指定此实体的 HTML 说明。
position位置属性|笛卡尔3指定实体位置的属性。
orientation财产指定实体方向的属性。
viewFrom财产用于查看此对象的建议初始偏移量。
parent实体要与此实体关联的父实体。
billboard广告牌图形BillboardGraphics.ConstructorOptions与此实体关联的广告牌。
box盒装图形BoxGraphics.ConstructorOptions要与此实体关联的框。
corridor走廊图形|走廊图形.构造器选项要与此实体关联的通道。
cylinder柱面图形CylinderGraphics.ConstructorOptions要与此实体关联的柱面。
ellipse椭圆图形|椭圆图形.构造函数选项要与此实体关联的椭圆。
ellipsoid椭圆体图形|椭圆体图形.构造函数选项要与此实体关联的椭球体。
label标签图形LabelGraphics.ConstructorOptions要与此实体关联的选项标签。
model模型图形|模型图形.构造函数选项要与此实体关联的模型。
tileset3DTilesetGraphics | Cesium3DTilesetGraphics.ConstructorOptions要与此实体关联的 3D 切片集。
path路径图形PathGraphics.ConstructorOptions与此实体关联的路径。
plane平面图形|平面图形.构造函数选项要与此实体关联的平面。
point点图形|点图形.构造函数选项要与此实体关联的点。
polygon多边形图形|多边形图形.构造函数选项要与此实体关联的面。
polyline折线图形|折线图形.构造函数选项要与此实体关联的折线。
properties物业袋|Object.<string,*>要与此实体关联的任意属性。
polylineVolume折线卷积| PolylineVolumeGraphics.ConstructorOptions要与此实体关联的折线卷。
rectangle矩形图形|矩形图形.构造函数选项要与此实体关联的矩形。
wall墙面图形WallGraphics.ConstructorOptions要与此实体关联的墙。

 模型图形构造函数的初始化选项原文

NameTypeDescription
showProperty | booleanA boolean Property specifying the visibility of the model.
uriProperty | string | ResourceA string or Resource Property specifying the URI of the glTF asset.
scaleProperty | numberA numeric Property specifying a uniform linear scale.
minimumPixelSizeProperty | numberA numeric Property specifying the approximate minimum pixel size of the model regardless of zoom.
maximumScaleProperty | numberThe maximum scale size of a model. An upper limit for minimumPixelSize.
incrementallyLoadTexturesProperty | booleanDetermine if textures may continue to stream in after the model is loaded.
runAnimationsProperty | booleanA boolean Property specifying if glTF animations specified in the model should be started.
clampAnimationsProperty | booleanA boolean Property specifying if glTF animations should hold the last pose for time durations with no keyframes.
shadowsProperty | ShadowModeAn enum Property specifying whether the model casts or receives shadows from light sources.
heightReferenceProperty | HeightReferenceA Property specifying what the height is relative to.
silhouetteColorProperty | ColorA Property specifying the Color of the silhouette.
silhouetteSizeProperty | numberA numeric Property specifying the size of the silhouette in pixels.
colorProperty | ColorA Property specifying the Color that blends with the model's rendered color.
colorBlendModeProperty | ColorBlendModeAn enum Property specifying how the color blends with the model.
colorBlendAmountProperty | numberA numeric Property specifying the color strength when the is . A value of 0.0 results in the model's rendered color while a value of 1.0 results in a solid color, with any value in-between resulting in a mix of the two.colorBlendModeMIX
imageBasedLightingFactorProperty | Cartesian2A property specifying the contribution from diffuse and specular image-based lighting.
lightColorProperty | ColorA property specifying the light color when shading the model. When the scene's light color is used instead.undefined
distanceDisplayConditionProperty | DistanceDisplayConditionA Property specifying at what distance from the camera that this model will be displayed.
nodeTransformationsPropertyBag | Object.<string, TranslationRotationScale>An object, where keys are names of nodes, and values are TranslationRotationScale Properties describing the transformation to apply to that node. The transformation is applied after the node's existing transformation as specified in the glTF, and does not replace the node's existing transformation.
articulationsPropertyBag | Object.<string, number>An object, where keys are composed of an articulation name, a single space, and a stage name, and the values are numeric properties.
clippingPlanesProperty | ClippingPlaneCollectionA property specifying the ClippingPlaneCollection used to selectively disable rendering the model.

 模型图形构造函数的初始化选项翻译

名字类型描述
show物业|布尔一个布尔属性,用于指定模型的可见性。
uri物业|字符串|资源指定 glTF 资产的 URI 的字符串或资源属性。
scale物业|数指定统一线性刻度的数值属性。
minimumPixelSize物业|数一个数值属性,指定模型的近似最小像素大小,而不考虑缩放。
maximumScale物业|数模型的最大比例大小。最小像素大小的上限。
incrementallyLoadTextures物业|布尔确定纹理在加载模型后是否可以继续流入。
runAnimations物业|布尔一个布尔属性,指定是否应启动模型中指定的 glTF 动画。
clampAnimations物业|布尔一个布尔属性,用于指定 glTF 动画是否应在没有关键帧的时间段内保持最后一个姿势。
shadows物业|阴影模式一个枚举属性,指定模型是从光源投射还是接收阴影。
heightReference物业|高度引用指定高度相对于的属性。
silhouetteColor物业|颜色指定侧面影像颜色的属性。
silhouetteSize物业|数一个数值属性,指定剪影的大小(以像素为单位)。
color物业|颜色指定与模型的渲染颜色混合的颜色的属性。
colorBlendMode物业|颜色混合模式指定颜色如何与模型混合的枚举属性。
colorBlendAmount物业|数一个数字属性,指定在 为 时的颜色强度。值 0.0 将生成模型的渲染颜色,而值 1.0 将生成纯色,介于两者之间的任何值都会导致两者的混合。colorBlendModeMIX
imageBasedLightingFactor物业|笛卡尔2指定基于漫反射和镜面反射图像的照明的贡献的属性。
lightColor物业|颜色指定对模型进行着色时的浅色的属性。当使用场景的光色时。undefined
distanceDisplayCondition物业|距离显示条件一个属性,指定将在距摄像机的距离处显示此模型。
nodeTransformations物业袋|Object.<string, TranslationRotationScale>一个对象,其中键是节点的名称,值是描述要应用于该节点的转换的TranslationRotationScale属性。该转换在 glTF 中指定的节点的现有转换之后应用,并且不会替换节点的现有转换。
articulations物业袋|对象<字符串,数字>一个对象,其中键由发音名称、单个空格和阶段名称组成,值是数值属性。
clippingPlanes物业|剪贴平面集合指定用于有选择地禁用模型呈现的"裁剪平面集合"的属性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值