简体   繁体   English

在盒子 Three.js 周围渲染网格

[英]Rendering grid around box Three.js

Currently, I have created a box buffer geometry that is 8x8x8 in dimension.目前,我已经创建了一个尺寸为 8x8x8 的盒子缓冲区几何图形。 I would like to put a grid around it that matches those dimensions (eg 64 squares on each side).我想在它周围放置一个与这些尺寸匹配的网格(例如每边 64 个正方形)。 Is there any efficient ways to do this in three.js?在three.js中是否有任何有效的方法可以做到这一点? My current solution is creating 16 intersecting lines for each side of the cube, but these add up quickly and are inefficient for performance.我目前的解决方案是为立方体的每一边创建 16 条相交线,但这些线加起来很快,而且性能效率低下。

The badass way is to use this technique:坏蛋的方法是使用这种技术:

http://madebyevan.com/shaders/grid/ http://madebyevan.com/shaders/grid/

A simpler way.. is to create a grid texture or grab one off of google image search.. preferably in a power of 2 size ie 64x64 128x128 or 256x256 etc...一种更简单的方法.. 是创建一个网格纹理或从谷歌图像搜索中抓取一个.. 最好是 2 的幂,即 64x64 128x128 或 256x256 等...

and use that as the .map of a MeshBasicMaterial()并将其用作 MeshBasicMaterial() 的 .map

texture = new THREE.TextureLoader().load('yourGridTextureImage.jpg') texture.wrapS = THREE.RepeatWrapping; texture = new THREE.TextureLoader().load('yourGridTextureImage.jpg') texture.wrapS = THREE.RepeatWrapping; texture.wrapT = THREE.RepeatWrapping; texture.wrapT = THREE.RepeatWrapping; texture.repeat.set( 4, 4 );纹理.repeat.set( 4, 4 );

scene.add(new THREE.Mesh(new THREE.PlaneGeometry(64,64),new THREE.MeshBasicMaterial({map: texture}))) Scene.add(new THREE.Mesh(new THREE.PlaneGeometry(64,64),new THREE.MeshBasicMaterial({map: texture})))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM