本文整理汇总了TypeScript中THREE.BufferGeometry.computeVertexNormals方法的典型用法代码示例。如果您正苦于以下问题:TypeScript BufferGeometry.computeVertexNormals方法的具体用法?TypeScript BufferGeometry.computeVertexNormals怎么用?TypeScript BufferGeometry.computeVertexNormals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.BufferGeometry
的用法示例。
在下文中一共展示了BufferGeometry.computeVertexNormals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
//.........这里部分代码省略.........
throw new Error("Unexpected vertex/normal/uv line: '" + line + "'")
}
} else if (lineFirstChar === 'f') {
if ((result = this.regexp.face_vertex_uv_normal.exec(line)) !== null) {
// f vertex/uv/normal vertex/uv/normal vertex/uv/normal
// 0 1 2 3 4 5 6 7 8 9 10 11 12
// ["f 1/1/1 2/2/2 3/3/3", "1", "1", "1", "2", "2", "2", "3", "3", "3", undefined, undefined, undefined]
state.addFace(
result[ 1 ], result[ 4 ], result[ 7 ], result[ 10 ],
// result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ], // ignore uv part
result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ]
)
} else if (this.regexp.face_vertex_uv.exec(line) !== null) {
// ignore uv line
} else if ((result = this.regexp.face_vertex_normal.exec(line)) !== null) {
// f vertex//normal vertex//normal vertex//normal
// 0 1 2 3 4 5 6 7 8
// ["f 1//1 2//2 3//3", "1", "1", "2", "2", "3", "3", undefined, undefined]
state.addFace(
result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],
result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]
)
} else if ((result = this.regexp.face_vertex.exec(line)) !== null) {
// f vertex vertex vertex
// 0 1 2 3 4
// ["f 1 2 3", "1", "2", "3", undefined]
state.addFace(
result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ]
)
} else {
throw new Error("Unexpected face line: '" + line + "'")
}
} else if (lineFirstChar === 'l') {
var lineParts = line.substring(1).trim().split(' ')
var lineVertices = []
var lineUVs = []
if (line.indexOf('/') === -1) {
lineVertices = lineParts
} else {
for (var li = 0, llen = lineParts.length; li < llen; li++) {
var parts = lineParts[ li ].split('/')
if (parts[ 0 ] !== '') lineVertices.push(parts[ 0 ])
if (parts[ 1 ] !== '') lineUVs.push(parts[ 1 ])
}
}
state.addLineGeometry(lineVertices, lineUVs)
} else if ((result = this.regexp.object_pattern.exec(line)) !== null) {
// o object_name
// or
// g group_name
var name = result[ 0 ].substr(1).trim()
state.startObject(name)
// ignore material related lines
// eslint-disable-next-line no-empty
} else if (this.regexp.material_use_pattern.test(line)) {
// eslint-disable-next-line no-empty
} else if (this.regexp.material_library_pattern.test(line)) {
// eslint-disable-next-line no-empty
} else if (this.regexp.smoothing_pattern.exec(line) !== null) {
} else {
// Handle null terminated files without exception
if (line === '\0') continue
throw new Error("Unexpected line: '" + line + "'")
}
}
var container = []
for (i = 0, l = state.objects.length; i < l; i++) {
var object = state.objects[ i ]
var geometry = object.geometry
// Skip o/g line declarations that did not follow with any faces
if (geometry.vertices.length === 0) continue
var buffergeometry = new BufferGeometry()
buffergeometry.addAttribute('position', new BufferAttribute(new Float32Array(geometry.vertices), 3))
if (geometry.normals.length > 0) {
buffergeometry.addAttribute('normal', new BufferAttribute(new Float32Array(geometry.normals), 3))
} else {
buffergeometry.computeVertexNormals()
}
container.push(buffergeometry)
}
return container
}