当前位置: 首页 > ds >正文

CesiumInstancedMesh 实例

CesiumInstancedMesh 实例

import * as Cesium from 'cesium';// Three.js 风格的 InstancedMesh 类, https://threejs.org/docs/#api/en/objects/InstancedMesh
export class CesiumInstancedMesh {/*** Creates an instance of InstancedMesh.** @param {Cesium.Geometry} geometry - Cesium geometry instance* @param {Cesium.MaterialAppearance} material - Cesium material appearance* @param {number} count - Number of instances*/constructor(geometry, material, count) {this._instances = Array.from({ length: count }, () => ({modelMatrix: null,geometry: null}));this._geometry = geometry;this._material = material;this._primitive = null;}/*** Gets the Cesium Primitive for rendering.* @returns {Cesium.Primitive}*/get primitive() {if (this._primitive) return this._primitive;// 验证所有实例是否有效for (let i = 0; i < this._instances.length; i++) {if (!this._instances[i].modelMatrix || !this._instances[i].geometry) {throw new Error(`Instance at index ${i} is not fully initialized`);}}this._primitive = new Cesium.Primitive({geometryInstances: this._instances.map(instance => new Cesium.GeometryInstance({geometry: instance.geometry,modelMatrix: instance.modelMatrix})),appearance: this._material,asynchronous: false});return this._primitive;}/*** Sets the model matrix for an instance at the specified index.* @param {number} index - Instance index* @param {Cesium.Matrix4} matrix - Model matrix*/setMatrixAt(index, matrix) {if (index < 0 || index >= this._instances.length) {throw new Error(`Index ${index} is out of bounds (0 to ${this._instances.length - 1})`);}this._instances[index].modelMatrix = Cesium.Matrix4.clone(matrix, new Cesium.Matrix4());this._instances[index].geometry = this._geometry;if (this._primitive) {this._primitive.geometryInstances = this._instances.map(instance => new Cesium.GeometryInstance({geometry: instance.geometry,modelMatrix: instance.modelMatrix}));}}/*** Destroys the instance and releases resources.*/destroy() {this._primitive = null;this._instances = null;this._geometry = null;this._material = null;}
}
http://www.xdnf.cn/news/10246.html

相关文章:

  • 从认识AI开始-----解密LSTM:RNN的进化之路
  • 比较云计算的四种部署模式:哪个是最佳选择?
  • LabVIEW与PLC液压泵测控系统
  • DPO(Direct Preference Optimization)详解-1
  • 国标GB28181设备管理软件EasyGBS实现生产全流程可视化监控与精细化管理
  • 2.从0开始搭建vue项目(node.js,vue3,Ts,ES6)
  • 【android bluetooth 案例分析 04】【Carplay 详解 1】【CarPlay 在车机侧的蓝牙通信原理与角色划分详解】
  • RPA如何支持跨平台和跨浏览器的自动化
  • 高级数据结构与算法期末考试速成记录
  • ECS-7000能耗监测系统能耗数据管理机
  • Linux之Nginx配置篇
  • 国芯思辰| 16通道12位模数转换器SC1425高性价比SGM5200替代方案,专为数字电源优化
  • 历年南开大学计算机保研上机真题
  • Wi-Fi 切换 5G 的时机
  • Express教程【001】:Express创建基本的Web服务器
  • VMware Workstation虚拟系统设置双网口
  • ETL脚本节点使用的方式
  • 2024 CKA模拟系统制作 | Step-By-Step | 18、题目搭建-备份还原Etcd
  • 面试大厂Java:从Spring Boot到微服务架构
  • ES6 深克隆与浅克隆详解:原理、实现与应用场景
  • 打破建筑管理壁垒,IBMS智能系统赋能现代建筑协同增效
  • Java 注解式限流教程(使用 Redis + AOP)
  • 【速写】PPOTrainer样例与错误思考(少量DAPO)
  • Java线程安全解决方案全面指南
  • day024-网络基础-TCP与UDP、DNS
  • 网络编程总结
  • 深度学习|pytorch基本运算
  • Spring Cloud 学习 —— 简单了解
  • 若依项目天气模块
  • 国产高安全芯片在供应链自主可控中的综合优势与案例分析