- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
简单的程序,以特定的高度和特定的颜色在特定的位置显示条形。 Three.js 新手,正在学习该框架。
当我运行脚本来加载栏位置、颜色、灯光、相机和控件时。我发现 Box 颜色是恒定的,基本网格体因此我尝试使用 MeshPhongMaterial 也是恒定的。所以我需要一点帮助。
// Begin
function plotRF(bar_data){
// Bar Data
this.bars = bar_data
// Call the canvas for screan sizing
this.canvas = document.getElementById("BarCanvas")
// create the scene
scene = new THREE.Scene();
// Define the camera
camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 8000 );
camera.position.z = 500;
camera.position.y = 500;
//camera.rotation.x = 90 * Math.PI / 180;
// Set the render engine
var renderer = new THREE.WebGLRenderer({ canvas: BarCanvas });
// Set the render size
renderer.setSize( this.canvas.width, this.canvas.height);
// Add some Lights
this.add_lights()
// Add controls
controls = new THREE.OrbitControls( camera, renderer.domElement );
// Define Geometry
//this.coords()
this.add_bars();
var render = function () {
requestAnimationFrame( render );
renderer.render(scene, camera);
};
render();
};
plotRF.prototype.add_bars = function(){
// Bar height
var multiplier = 20;
// Bar Size
var lw = 5;
// loop through the Javascript data
for (i = 0; i< this.bars.length; i++){
var geo = new THREE.BoxGeometry( lw, lw, this.bars[i][0]*multiplier );
//geo.add(
var rfcolour = this.colorTable(this.bars[i][0]);
var mat = new THREE.MeshPhongMaterial( {
color: rfcolour,
emissive: 0x072534,
side: THREE.DoubleSide,
shading: THREE.FlatShading} );
//mat.wireframe = true;
cube = new THREE.Mesh( geo, mat );
cube.position.x = this.bars[i][1]/10;
cube.position.y = this.bars[i][2]/10;
cube.position.z = this.bars[i][0]*multiplier/2;
scene.add( cube );
console.log("bar added, x:" + this.bars[i][1] +", y:" + this.bars[i][2] + ", RF:" + this.bars[i][0]) ;
}
};
plotRF.prototype.colorTable = function(RF){
if (RF < 1 ) {
return new THREE.Color(255,0,0);
} else if (RF < 1.2) {
return new THREE.Color(240,50,50);
} else if (RF < 1.4) {
return new THREE.Color(230,100,100);
} else if (RF < 1.6) {
return new THREE.Color(220,150,150);
} else if (RF < 1.8) {
return new THREE.Color(210,200,200);
} else if (RF < 2.0) {
return new THREE.Color(200,220,220);
} else if (RF < 3.0) {
return new THREE.Color(150,220,220);
} else {
return new THREE.Color(100,240,240);
}
plotRF.prototype.add_lights = function(RF){
var lights = [];
lights[ 0 ] = new THREE.PointLight( 0xffffff, 0.8, 500 );
lights[ 1 ] = new THREE.PointLight( 0xffffff, 0.8, 500 );
lights[ 2 ] = new THREE.PointLight( 0xffffff, 0.8, 500 );
lights[ 0 ].position.set( 0, 2000, 0 );
lights[ 1 ].position.set( 1000, 2000, 1000 );
lights[ 2 ].position.set( - 1000, - 2000, - 1000 );
scene.add( lights[ 0 ] );
scene.add( lights[ 1 ] );
scene.add( lights[ 2 ] );
}
下面是常量颜色图。请注意,颜色注册正确,THREE.Color 函数中的 R、G、B 值正确。
最佳答案
您必须像 documentation 中所述设置颜色,例如:
return new THREE.Color("rgb(255, 0, 0)"); // red
关于javascript - THREE.js 使用多个 BoxGeometries 时保持单一颜色。一切都是不变的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40678781/
我想在单个 View 中显示文本、图像。也请帮助我 我想从我的类(class)而不是 xml 提供图像的 src 请帮助谢谢 最佳答案 你可以为此使用Button Button b=new Butto
我有一个消息模型,管理员和用户都可以创建消息。但对于管理员和用户来说,有单独的模型,称为管理员和用户。 消息模型有一个名为“created_by”的列,用于存储创建者的 ID。现在的问题是我如何与 M
我无法为菜单资源充气,并且无法将其附加到我的 Activity 的工具栏上。 这似乎很简单,但是我想我缺少明显的东西。我正在使用NavGraph,所以我不知道这是否影响工具栏? 有人看到我做错了吗?
我正在开发一个应用程序,它有一个 MainActivity 并且有许多用于医院、诊所的 ImageViews ... 当按下其中一个时,它会带你到一个新的 Activity DisplayActivi
我会尽量保持简短,但我需要一些建议。 我所在的团队正在并行开发适用于 android、iphone 和 wp7 的应用程序。我们有一个设计团队,可以为所有三个平台提出一个单一的设计。 最新应用程序的设
我正在使用 Josh Smith 中的示例.他有一个显示 CustomerViewModel 列表的 WorkspaceViewModel。他使用相同的 ViewModel 来显示所有客户和编辑一个客
我是 Azure 新手,正在尝试了解各种服务,目前我正在尝试了解移动服务及其各种功能,例如身份验证和推送。 移动服务是否仅支持一种操作系统上的一个应用程序,还是可以在多个操作系统(Android、iO
我在 Stoyan Stefanov 的书中读到了关于单一变量模式的内容。 JSLint 也很好。 但我在我的代码中注意到我可能会重载此模式。整个我的 .js 文件,整个脚本只是一个大变量。 例如:
我想在一个 View 中添加多个具有不同不透明度的阴影。阴影的规范如下: Y 偏移量为 4,模糊半径为 1 Y 偏移量为 10,模糊半径为 10 Y 偏移量为 2,模糊半径为 4 1 的模糊半径,1
我们有几个 API,我们希望通过客户端凭据流授予对客户端的访问权限。流程会像这样。 客户端根据某个范围从 is4 获取 token 客户端使用 token 访问第一个 API 客户端需要使用相同的 t
我是 ruby on rails 的新手。我正在尝试在 ruby on rails 上设计一个注册表单,该表单具有 Basic 和 Paid 用户的单选按钮。当用户点击付费并点击提交时,应该会
我用 Entity Framework 6 开发了一个项目,该项目使用 MySQL 作为数据库。在我的 Windows 系统上,该项目正在运行。现在我试图在我的 linux 机器上移动那个项目。为了运
我正在为我的电子商务应用程序创 build 计。它将拥有由 AWS Lambda 支持的多项服务。 Orderservice、InventoryService、PaymentService、Loggi
我目前正在开发一个执行以下操作的单 View 应用程序: 使用 CoreLocation 获取用户位置 将他们的经/纬度发送到 API 以 JSON 格式返回潮汐数据 深入研究 JSON 中的对象和键
我想托管各种 Angular2 应用程序,这些应用程序使用相同的框架包和来自根域和子域的 node_modules: domain.com subdomain.domain.com sub2.doma
我正在尝试使用 Git Publisher 插件来标记带有 $BUILD_TAG 的成功构建,但我无法找出它将接受的 Target remote name 的值。如果我在 GIT 配置中使用 Repo
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 8年前关闭。 Improve thi
有一个带有许多控件的 View (窗口),以简化: 此 View 用于显示和编辑多个配置: public class ViewModel: INotifyPropertyChanged
我有一个 textView 和类似的文本 “这是带有 KeyWord 和 Link 浏览的简单文本” 在上面的文字中我想制作.. 点击链接可打开该网址和点击该关键字在我的应用程序中打开一个新 Acti
我在我现有的应用程序中有一个任务,我们有 2 个不同的数据库,一个在 SQL Server 中,另一个在 Oracle 中,但是两个模式是相同的。 目前我们有一个使用 Entity Framework
我是一名优秀的程序员,十分优秀!