参考资料

github 讨论地址

示例代码地址

示例代码

var viewer = new Cesium.Viewer('cesiumContainer');
var scene = viewer.scene; var imagePath = '../../../../Apps/SampleData/models/CesiumAir/0_Cesium_Air.png';
var model = createModel('../../../../Apps/SampleData/models/CesiumBalloon/CesiumBalloon.glb'); // New texture must be the same size as the original texture
model.readyPromise.then(function() {
var textureIndexToReplace = 0;
var textures = model._rendererResources.textures;
var texture = textures[textureIndexToReplace];
Cesium.Resource.fetchImage({
url : imagePath
}).then(function(image) {
texture.copyFrom(image);
texture.generateMipmap(); // Also replaces textures in mipmap
});
}); function createModel(url) {
var origin = Cesium.Cartesian3.fromDegrees(-123.0744619, 44.0503706, 0.0);
var modelMatrix = Cesium.Transforms.headingPitchRollToFixedFrame(origin, new Cesium.HeadingPitchRoll(0.0, 0.0, 0.0)); var model = scene.primitives.add(Cesium.Model.fromGltf({
url : url,
modelMatrix : modelMatrix,
minimumPixelSize : 128,
incrementallyLoadTextures : false
})); model.readyPromise.then(function(model) {
var camera = viewer.camera; // Zoom to model
var controller = scene.screenSpaceCameraController;
var r = 2.0 * Math.max(model.boundingSphere.radius, camera.frustum.near);
controller.minimumZoomDistance = r * 0.5; var center = Cesium.Matrix4.multiplyByPoint(model.modelMatrix, model.boundingSphere.center, new Cesium.Cartesian3());
var heading = Cesium.Math.toRadians(230.0);
var pitch = Cesium.Math.toRadians(-20.0);
camera.lookAt(center, new Cesium.HeadingPitchRange(heading, pitch, r * 2.0));
}).otherwise(function(error){
window.alert(error);
}); return model;
} /*
// Alernate approach - but requires fix in DelayLoadedTextureUniform to return this._textures[this._textureId] instead of this._value
model.readyPromise.then(function() {
var textureIndexToReplace = 0;
var textures = model._rendererResources.textures;
var oldTexture = textures[textureIndexToReplace];
Cesium.Resource.fetchImage({
url : imagePath
}).then(function(image) {
var newTexture = new Cesium.Texture({
context : viewer.scene.frameState.context,
source : image
});
textures[textureIndexToReplace] = newTexture;
oldTexture.destroy();
});
});
*/

方法现阶段存在的问题

无法更改单个实例的贴图,所有实例的贴图都会同步发生更改

Cesium 动态更换模型贴图方法的更多相关文章

  1. Unreal Engine 4 动态切割模型实现

    转自:http://gad.qq.com/article/detail/33199 <合金装备:复仇>里面,有一个很有趣的设定,游戏里大部分的场景和物件都可以用主角的刀动态切割. UE4中 ...

  2. 分析业务模型-类图(Class Diagram)

    分析业务模型-类图(Class Diagram)     分析业务模型-类图(Class Diagram)(上) 摘要:类图(Class Diagram)可能是用得最多的一种UML图.类图的基本语法并 ...

  3. 评价指标的局限性、ROC曲线、余弦距离、A/B测试、模型评估的方法、超参数调优、过拟合与欠拟合

    1.评价指标的局限性 问题1 准确性的局限性 准确率是分类问题中最简单也是最直观的评价指标,但存在明显的缺陷.比如,当负样本占99%时,分类器把所有样本都预测为负样本也可以获得99%的准确率.所以,当 ...

  4. 【转】【iOS】动态更换App图标

    原文网址:http://www.cocoachina.com/ios/20170619/19557.html 前言 动态更换App图标这件事,在用户里总是存在需求的:有些用户喜欢“美化”自己的手机.至 ...

  5. u3d动态加入模型

    楼层一层一层的加,把模型分开,弄成prefab放到Resourse文件夹里,在代码里用Instantiate(Resources.Load("模型名字") as GameObjec ...

  6. WPF通过DynamicResource实现给界面动态更换皮肤

    在我们的程序中有时候需要去实现动态更换皮肤的效果,从而完成一些个性化的设置,那么我们究竟怎样去实现动态换皮肤的效果呢?那么我们经常用到的就是设置不同的Style,并且在主程序的xaml文件中通过Dyn ...

  7. 关于2-sat的建图方法及解决方案

    转载增减: https://blog.csdn.net/qq_24451605/article/details/47126143 https://blog.csdn.net/u012915516/ar ...

  8. Unity3D 动态地创建识别图

    前面介绍了EasyAR的单图识别,它是提前在Unity设置好图片路径的,那么如果我们的图片是存储在服务器上的,那么我们肯定不能直接把服务的图片地址填上去了.这个时候我们可以动态地创建识别图.步骤如下: ...

  9. js动态更换img的src问题

    在本地开发测试过程中,通过js动态更换img的src没有问题,图片正常切换,但是放在服务器上后测试发现,图片不显示,解决方法为:在对应onclick事件执行切换图片的js函数后加上一个return f ...

随机推荐

  1. vhdl 数组

    TYPE matrix_index is array (511 downto 0) of std_logic_vector(7 downto 0);signal cnt_freq : matrix_i ...

  2. bzoj 2816: [ZJOI2012]网络 (LCT 建多棵树)

    链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2816 题面: http://www.lydsy.com/JudgeOnline/upload ...

  3. 深入理解JVM(2)——运行时数据区

    1.运行时数据区 1.1.程序计数器 记录当前线程正在执行的字节码指令的地址,如果正在执行的是 Native 方法,这个计数器值则为空. 1.2.虚拟机栈 每个 Java 方法在执行的同时会创建一个栈 ...

  4. BZOJ2870 最长道路

    题意:给定树,有点权.求一条路径使得最小点权 * 总点数最大.只需输出这个最大值.5w. 解:树上路径问题,点分治. 考虑合并两个子树的时候,答案的形式是val1 * (d1 + d2),当1是新插入 ...

  5. 消息框MessageBox+遍历控件

    消息对话框:主要用来显示信息,也可以警告.用户确认取消等. MessageBox.Show("展示内容","标题",MessageBoxButtons.按钮种类 ...

  6. java matlab 混合编程 Failed to find the required library mclmcrrt9_2.dll on java.library.path.

    问题描述: Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to find the requir ...

  7. 队列优化的dijkstra

    #include<iostream> #include<queue> #include<cstdio> #include<cstring> #inclu ...

  8. CSS iconfont阿里巴巴矢量图库在开发中实战使用

    前言 项目开发中,是避免不了使用小图标的,那么国内比较好用的图标网站当属iconfont了,下面我们将详细介绍如何使用. iconfont选择所需图标 1.iconfont官网 2.把所需要的添加进入 ...

  9. python chrome的自定义启动

    # encoding:utf-8 """@version: python27@author: fafa@site: http://www.phpgao.com@softw ...

  10. DUMP3 企业级电商项目

    [开发模式]controller - service(合法校验问题) - dao   反过来也没问题 用户模块 登录 注册 用户名验证(实时反馈前端) 忘记密码 重置密码 退出登录 更新用户信息 获取 ...