- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Gridhelper似乎只有使它成为正方形的尺寸。它不能是一个我可以定义宽度和高度的矩形,或者我可以在 three.js 中使用另一种方法来定义它吗?我认为它可能有“规模”,但这会使 split 扭曲。
var size = 50;
var divisions = 10;
var gridHelper = new THREE.GridHelper(size, divisions);
scene.add(gridHelper);
最佳答案
在 bocoup 找到解决方案:https://bocoup.com/blog/learning-three-js-with-real-world-challenges-that-have-already-been-solved
function createAGrid(opts) {
var config = opts || {
height: 500,
width: 500,
linesHeight: 10,
linesWidth: 10,
color: 0xDD006C
};
var material = new THREE.LineBasicMaterial({
color: config.color,
opacity: 0.2
});
var gridObject = new THREE.Object3D(),
gridGeo = new THREE.Geometry(),
stepw = 2 * config.width / config.linesWidth,
steph = 2 * config.height / config.linesHeight;
//width
for (var i = -config.width; i <= config.width; i += stepw) {
gridGeo.vertices.push(new THREE.Vector3(-config.height, i, 0));
gridGeo.vertices.push(new THREE.Vector3(config.height, i, 0));
}
//height
for (var i = -config.height; i <= config.height; i += steph) {
gridGeo.vertices.push(new THREE.Vector3(i, -config.width, 0));
gridGeo.vertices.push(new THREE.Vector3(i, config.width, 0));
}
var line = new THREE.Line(gridGeo, material, THREE.LinePieces);
gridObject.add(line);
return gridObject;
}
但不得不改变
var line = new THREE.Line(gridGeo, material, THREE.LinePieces);
(弃用)到
var line = new THREE.LineSegments(gridGeo, material);
关于javascript - 在 three.js 中更改 gridhelper 的宽度和高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56029083/
我有been told three.js 中几何的标准法向量是 (0, 0, 1)。 但是,当我创建 GridHelper 构造函数的实例时,它会创建一个由 X 轴和 Z 轴跨越的平面。这样的平面的法
我正在使用 Three JS,我可以使用 GridHelper 将网格添加到场景中。是否有类似的功能可以生成极坐标网格? 这就是生成 2D 笛卡尔平面的几何图形的方式 ( source ): var
Gridhelper似乎只有使它成为正方形的尺寸。它不能是一个我可以定义宽度和高度的矩形,或者我可以在 three.js 中使用另一种方法来定义它吗?我认为它可能有“规模”,但这会使 split 扭曲
如何获取我正在点击的 GridHelper 的坐标或 IN 坐标?尤其是当 GridHelper 之上将有一个实际的 Terrain Mesh 时? 我的 GridHelper 设置如下: let
我正在使用 Gridhelper 添加平面和网格到我的 3d 场景: // PLANE XY static var gridplaneSize = 20; var color = 0xFFDCBB;
第一张图就是我想要的。 (我什至也想要相反的对 Angular 线,但我会相应地得出它。)第二张图片是普通的 GridHelper。 这是否可以通过添加另一个网格助手但沿 y 轴旋转 45 度来实现?
我是一名优秀的程序员,十分优秀!