赞
踩
Cesium粒子系统的官方文档最这两个参数说明不多,只给了一段示例代码,在网上的教程也很少。下面先解析一下官方的例子,然后说一下对这两个参数的理解。
- var particleSystem = viewer.scene.primitives.add(new Cesium.ParticleSystem({
- // Particle appearance
- image : 'fire.png',
- width : 20,
- height : 20,
- startScale : 1.0,
- endScale : 4.0,
- // Particle behavior
- life : 1.0,
- speed : 5.0,
- // Emitter parameters
- emitter : new Cesium.CircleEmitter(0.5),
- rate : 5.0,
- emitterModelMatrix : computeEmitterModelMatrix(),
- // Particle system parameters
- modelMatrix : computeModelMatrix(entity, Cesium.JulianDate.now()),//(模型,创建一个表示当前系统时间(朱利安时间)的新实例。)
- lifetime : 16.0
-
- //modelMatrix://4x4转换矩阵,将粒子系统从模型转换为世界坐标。(Matrix4)
- //emitterModelMatrix://4x4转换矩阵,可以在粒子系统局部坐标系中转换粒子系统发射器(Matrix4)
- }));
- function computeEmitterModelMatrix() {
- //HeadingPitchRoll(z,y,x)一个旋转
- //Cesium.HeadingPitchRoll.fromDegrees(z, y, x, 结果格式)将给定的角度转换为旋转实例
- hpr = Cesium.HeadingPitchRoll.fromDegrees(0.0, 0.0, 0.0, new Cesium.HeadingPitchRoll());
- //new Cesium.TranslationRotationScale(translation, 旋转, 三方向缩放)生成新的仿射变换
- var trs = new Cesium.TranslationRotationScale();
- //Cesium.Cartesian3.fromElements(x, y, z, result);三维坐标转三维向量
- trs.translation = Cesium.Cartesian3.fromElements(2.5, 4.0, 1.0, new Cesium.Cartesian3());
- //Cesium.Quaternion.fromHeadingPitchRoll(headingPitchRoll, result) 将旋转转化为四元数
- trs.rotation = Cesium.Quaternion.fromHeadingPitchRoll(hpr, new Cesium.Quaternion());
- //将仿生变换转换为四阶矩阵
- return Cesium.Matrix4.fromTranslationRotationScale(trs, new Cesium.Matrix4());
- }
- function computeModelMatrix(entity, time) {
- //Cesium.Property()获取随时间变化的属性值
- //position位置
- var position = Cesium.Property.getValueOrUndefined(entity.position, time, new Cesium.Cartesian3());
- if (!Cesium.defined(position)) {
- return undefined;
- }
- //orientation方向
- var orientation = Cesium.Property.getValueOrUndefined(entity.orientation, time, new Cesium.Quaternion());
- if (!Cesium.defined(orientation)) {
- var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(position, undefined, new Cesium.Matrix4());
- } else {
- //Cesium.Matrix3.fromQuaternion(orientation, new Cesium.Matrix3())由方向生成三阶矩阵
- //由旋转和转换生成四阶矩阵
- modelMatrix = Cesium.Matrix4.fromRotationTranslation(Cesium.Matrix3.fromQuaternion(orientation, new Cesium.Matrix3()), position, new Cesium.Matrix4());
- }
- return modelMatrix;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。