forked from serjIII/threejsSDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BufferGeometryUtils.html
146 lines (112 loc) · 6.12 KB
/
BufferGeometryUtils.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../../" />
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>
<p class="desc">
A class containing utility functions for [page:BufferGeometry BufferGeometry] instances.
</p>
<h2>Import</h2>
<p>
[name] is an add-on, and must be imported explicitly.
See [link:#manual/introduction/Installation Installation / Addons].
</p>
<code>
import * as BufferGeometryUtils from 'three/addons/utils/BufferGeometryUtils.js';
</code>
<h2>Methods</h2>
<h3>[method:Object computeMikkTSpaceTangents]( [param:BufferGeometry geometry], [param:Object MikkTSpace], [param:Boolean negateSign] = true )</h3>
<ul>
<li>geometry -- Instance of [page:BufferGeometry].</li>
<li>MikkTSpace -- Instance of <i>examples/jsm/libs/mikktspace.module.js</i>, or <i>mikktspace</i> npm package. Await <i>MikkTSpace.ready</i> before use.
<li>negateSign -- Whether to negate the sign component (.w) of each tangent. Required for normal map conventions in some formats, including glTF.</li>
</ul>
<p>
Computes vertex tangents using the [link:http://www.mikktspace.com/ MikkTSpace] algorithm.
MikkTSpace generates the same tangents consistently, and is used in most modelling tools and
normal map bakers. Use MikkTSpace for materials with normal maps, because inconsistent
tangents may lead to subtle visual issues in the normal map, particularly around mirrored
UV seams.
</p>
<p>
In comparison to this method, [page:BufferGeometry.computeTangents] (a
custom algorithm) generates tangents that probably will not match the tangents
in other software. The custom algorithm is sufficient for general use with a
[page:ShaderMaterial], and may be faster than MikkTSpace.
</p>
<p>
Returns the original [page:BufferGeometry]. Indexed geometries will be de-indexed.
Requires position, normal, and uv attributes.
</p>
<h3>[method:Object computeMorphedAttributes]( [param:Mesh | Line | Points object] )</h3>
<p>
object -- Instance of [page:Mesh Mesh] | [page:Line Line] | [page:Points Points].<br /><br />
Returns the current attributes (Position and Normal) of a morphed/skinned [page:Object3D Object3D] whose geometry is a
[page:BufferGeometry BufferGeometry], together with the original ones: An Object with 4 properties:
`positionAttribute`, `normalAttribute`, `morphedPositionAttribute` and `morphedNormalAttribute`.
Helpful for Raytracing or Decals (i.e. a [page:DecalGeometry DecalGeometry] applied to a morphed Object
with a [page:BufferGeometry BufferGeometry] will use the original BufferGeometry, not the morphed/skinned one,
generating an incorrect result.
Using this function to create a shadow Object3D the DecalGeometry can be correctly generated).
</p>
<h3>[method:Number estimateBytesUsed]( [param:BufferGeometry geometry] )</h3>
<p>
geometry -- Instance of [page:BufferGeometry BufferGeometry] to estimate the memory use of.<br /><br />
Returns the amount of bytes used by all attributes to represent the geometry.
</p>
<h3>[method:InterleavedBufferAttribute interleaveAttributes]( [param:Array attributes] )</h3>
<p>
attributes -- Array of [page:BufferAttribute BufferAttribute] instances.<br /><br />
Interleaves a set of attributes and returns a new array of corresponding attributes that share
a single InterleavedBuffer instance. All attributes must have compatible types. If merge does not
succeed, the method returns null.
</p>
<h3>[method:BufferAttribute mergeAttributes]( [param:Array attributes] )</h3>
<p>
attributes -- Array of [page:BufferAttribute BufferAttribute] instances.<br /><br />
Merges a set of attributes into a single instance. All attributes must have compatible properties
and types, and [page:InterleavedBufferAttribute InterleavedBufferAttributes] are not supported. If merge does not succeed, the method
returns null.
</p>
<h3>[method:BufferGeometry mergeGeometries]( [param:Array geometries], [param:Boolean useGroups] )</h3>
<p>
geometries -- Array of [page:BufferGeometry BufferGeometry] instances.<br />
useGroups -- Whether groups should be generated for the merged geometry or not.<br /><br />
Merges a set of geometries into a single instance. All geometries must have compatible attributes.
If merge does not succeed, the method returns null.
</p>
<h3>[method:BufferGeometry mergeGroups]( [param:BufferGeometry geometry] )</h3>
<p>
geometry -- Instance of [page:BufferGeometry BufferGeometry] to merge the groups of.<br /><br />
Merges the [page:BufferGeometry.groups groups] for the given geometry.
</p>
<h3>[method:BufferGeometry mergeVertices]( [param:BufferGeometry geometry], [param:Number tolerance] )</h3>
<p>
geometry -- Instance of [page:BufferGeometry BufferGeometry] to merge the vertices of.<br />
tolerance -- The maximum allowable difference between vertex attributes to merge. Defaults to 1e-4.<br /><br />
Returns a new [page:BufferGeometry BufferGeometry] with vertices for which all similar vertex attributes
(within tolerance) are merged.
</p>
<h3>[method:BufferGeometry toCreasedNormals]( [param:BufferGeometry geometry], [param:Number creaseAngle] )</h3>
<p>
geometry -- The input geometry. <br />
creaseAngle -- The crease angle. <br /><br />
Creates a new, non-indexed geometry with smooth normals everywhere except faces that meet at an angle greater than the crease angle.
</p>
<h3>[method:BufferGeometry toTrianglesDrawMode]( [param:BufferGeometry geometry], [param:TrianglesDrawMode drawMode] )</h3>
<p>
geometry -- Instance of [page:BufferGeometry BufferGeometry].<br />
drawMode -- The draw mode of the given geometry. Valid inputs are `THREE.TriangleStripDrawMode` and `THREE.TriangleFanDrawMode`.<br /><br />
Returns a new indexed geometry based on `THREE.TrianglesDrawMode` draw mode. This mode corresponds to the `gl.TRIANGLES` WebGL primitive.
</p>
<h2>Source</h2>
<p>
[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/BufferGeometryUtils.js examples/jsm/utils/BufferGeometryUtils.js]
</p>
</body>
</html>