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

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.lryc.cn/news/2392819.html

相关文章:

  • 单细胞注释前沿:CASSIA——无参考、可解释、自动化细胞注释的大语言模型
  • 历年武汉大学计算机保研上机真题
  • 日语学习-日语知识点小记-构建基础-JLPT-N4阶段(30):みます
  • AR-HUD 光波导方案优化难题待解?OAS 光学软件来破局
  • 火狐安装自动录制表单教程——仙盟自动化运营大衍灵机——仙盟创梦IDE
  • 线程池的详细知识(含有工厂模式)
  • 木愚科技闪亮第63届高博会 全栈式智能教育解决方案助力教学升级
  • Proteus寻找元器件(常见)
  • RK3566 Android12 HG24C02MM/TR EEPROM适配
  • IoTDB 集成 DBeaver,简易操作实现时序数据清晰管理
  • sqli-labs第二十八关——Trick with ‘union select‘
  • mapbox高阶,PMTiles介绍,MBTiles、PMTiles对比,加载PMTiles文件
  • Go语言通道如何实现通信
  • 投稿 IEEE Transactions on Knowledge and Data Engineering 注意事项
  • 题目 3316: 蓝桥杯2025年第十六届省赛真题-数组翻转
  • mongodb源码分析session接受客户端find命令过程
  • Netty 实战篇:为自研 RPC 框架加入异步调用与 Future 支持
  • python37天打卡
  • 变焦位移计:机器视觉如何克服人工疲劳与主观影响?精准对结构安全实时监测
  • 嵌入式硬件篇---Ne555定时器
  • 【Axure结合Echarts绘制图表】
  • 使用web3工具结合fiscobcos网络部署调用智能合约
  • Oracle/openGauss中,DATE/TIMESTAMP与数字日期/字符日期比较
  • Datatable和实体集合互转
  • Win11切换JDK版本批处理脚本
  • 爬虫学习-Scrape Center spa6 超简单 JS 逆向
  • 对数的运算困惑
  • C++ 图像处理库 CxImage 简介 (迁移至OpenCV)
  • linux系统与shell 笔记
  • 尚硅谷redis7 86 redis集群分片之3主3从集群搭建