javascript - 如何使线框像方形网格但不是连接节点的类型?
问题描述
我正在设计人体OBJ的线框样式,我想制作如下图的线框。以下是我如何创建线框和图像的代码,包括它的外观以及我希望它的外观。
// child is the human body's OBJ, is type of THREE.Mesh.
const geo = new THREE.WireframeGeometry(child.geometry)
const mat = new THREE.LineBasicMaterial({color: 0xffffff})
const wireframe = new THREE.LineSegments(geo, mat)
child.add(wireframe)
现在的样子
预期外观
解决方案
import * as THREE from 'three'
function createLinesTexture() {
const width = 200
const height = 200
const color = new THREE.Color(0x05cfe8)
const size = width * height
const data = new Uint8Array(3 * size)
const r = Math.floor(color.r * 255)
const g = Math.floor(color.g * 255)
const b = Math.floor(color.b * 255)
for (let i = 0; i < size; i++) {
const stride = i * 3
// Here is the tips to change how color patterns mapping
if ((i / 3) % 4 === 0) {
data[stride] = r
data[stride + 1] = g
data[stride + 2] = b
} else {
data[stride] = 255
data[stride + 1] = 255
data[stride + 2] = 255
}
}
// used the buffer to create a DataTexture
const texture = new THREE.DataTexture(data, width, height, THREE.RGBFormat)
return texture
}
推荐阅读
- google-cloud-platform - 在网络接口中创建 ip external valid
- python-3.x - 卡尔曼滤波器从未来预测前一步
- url-parameters - 用于附加文件的 OWA URL 参数
- sql - 使用 select 语句插入值,或者如果它不存在则插入新值
- java - 如何返回特定足球俱乐部的所有球员
- ruby-on-rails - 如何使用 Rails 4 App 的一些方法,如 REST API
- ios - 使用 Phonegap 插件在 IOS cordova 上收到 Firebase FCM 通知
- javascript - 覆盖 Webpack 4.25.1 在生产模式下对 Uglify 的使用
- google-apps-script - 如何解释 Google 服务的配额
- javascript - 作为道具传递的反应元素的反应参考,动态事件