Skip to content

Commit c687a36

Browse files
authored
Merge pull request #21026 from Mugen87/dev2
Decal/Edges/WireframeGeometry: Stop Geometry support.
2 parents 6f98352 + 51c424b commit c687a36

File tree

12 files changed

+74
-123
lines changed

12 files changed

+74
-123
lines changed

docs/api/en/geometries/EdgesGeometry.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h2>Examples</h2>
2929

3030
<h2>Constructor</h2>
3131

32-
<h3>[name]( [param:Geometry geometry], [param:Integer thresholdAngle] )</h3>
32+
<h3>[name]( [param:BufferGeometry geometry], [param:Integer thresholdAngle] )</h3>
3333
<p>
3434
geometry — Any geometry object.<br />
3535
thresholdAngle — An edge is only rendered if the angle (in degrees) between the face normals of the adjoining faces exceeds this value. default = 1 degree.

docs/api/en/geometries/WireframeGeometry.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ <h2>Examples</h2>
3636

3737
<h2>Constructor</h2>
3838

39-
<h3>[name]( [param:Geometry geometry] )</h3>
39+
<h3>[name]( [param:BufferGeometry geometry] )</h3>
4040
<p>
4141
geometry — any geometry object.
4242
</p>

docs/api/zh/geometries/EdgesGeometry.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h2>例子</h2>
2828

2929
<h2>构造器</h2>
3030

31-
<h3>[name]( [param:Geometry geometry], [param:Integer thresholdAngle] )</h3>
31+
<h3>[name]( [param:BufferGeometry geometry], [param:Integer thresholdAngle] )</h3>
3232
<p>
3333
geometry — 任何一个几何体对象。<br />
3434
thresholdAngle — 仅当相邻面的法线之间的角度(单位为角度)超过这个值时,才会渲染边缘。默认值为1。

docs/api/zh/geometries/WireframeGeometry.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ <h2>例子</h2>
3535

3636
<h2>构造器</h2>
3737

38-
<h3>[name]( [param:Geometry geometry] )</h3>
38+
<h3>[name]( [param:BufferGeometry geometry] )</h3>
3939
<p>
4040
geometry — 任意几何体对象。
4141
</p>

examples/js/geometries/DecalGeometry.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,23 @@ THREE.DecalGeometry = function ( mesh, position, orientation, size ) {
4949
function generate() {
5050

5151
var i;
52-
var geometry = new THREE.BufferGeometry();
52+
5353
var decalVertices = [];
5454

5555
var vertex = new THREE.Vector3();
5656
var normal = new THREE.Vector3();
5757

5858
// handle different geometry types
5959

60-
if ( mesh.geometry.isGeometry ) {
61-
62-
geometry.fromGeometry( mesh.geometry );
60+
if ( mesh.geometry.isGeometry === true ) {
6361

64-
} else {
65-
66-
geometry.copy( mesh.geometry );
62+
console.error( 'THREE.DecalGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );
63+
return;
6764

6865
}
6966

67+
var geometry = mesh.geometry;
68+
7069
var positionAttribute = geometry.attributes.position;
7170
var normalAttribute = geometry.attributes.normal;
7271

examples/jsm/geometries/DecalGeometry.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,23 @@ var DecalGeometry = function ( mesh, position, orientation, size ) {
5656
function generate() {
5757

5858
var i;
59-
var geometry = new BufferGeometry();
59+
6060
var decalVertices = [];
6161

6262
var vertex = new Vector3();
6363
var normal = new Vector3();
6464

6565
// handle different geometry types
6666

67-
if ( mesh.geometry.isGeometry ) {
68-
69-
geometry.fromGeometry( mesh.geometry );
67+
if ( mesh.geometry.isGeometry === true ) {
7068

71-
} else {
72-
73-
geometry.copy( mesh.geometry );
69+
console.error( 'THREE.DecalGeometry no longer supports THREE.Geometry. Use BufferGeometry instead.' );
70+
return;
7471

7572
}
7673

74+
var geometry = mesh.geometry;
75+
7776
var positionAttribute = geometry.attributes.position;
7877
var normalAttribute = geometry.attributes.normal;
7978

src/geometries/EdgesGeometry.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { BufferGeometry } from '../core/BufferGeometry';
2-
import { Geometry } from '../core/Geometry';
32

43
export class EdgesGeometry extends BufferGeometry {
54

65
/**
76
* @param geometry
87
* @param [thresholdAngle=1]
98
*/
10-
constructor( geometry: BufferGeometry | Geometry, thresholdAngle?: number );
9+
constructor( geometry: BufferGeometry, thresholdAngle?: number );
1110

1211
/**
1312
* @default 'EdgesGeometry'

src/geometries/EdgesGeometry.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ class EdgesGeometry extends BufferGeometry {
2323

2424
thresholdAngle = ( thresholdAngle !== undefined ) ? thresholdAngle : 1;
2525

26-
if ( geometry.isGeometry ) {
26+
if ( geometry.isGeometry === true ) {
2727

28-
geometry = new BufferGeometry().fromGeometry( geometry );
28+
console.error( 'THREE.EdgesGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );
29+
return;
2930

3031
}
3132

src/geometries/WireframeGeometry.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { Geometry } from './../core/Geometry';
21
import { BufferGeometry } from './../core/BufferGeometry';
32

43
export class WireframeGeometry extends BufferGeometry {
54

6-
constructor( geometry: Geometry | BufferGeometry );
5+
constructor( geometry: BufferGeometry );
76

87
/**
98
* @default 'WireframeGeometry'

src/geometries/WireframeGeometry.js

Lines changed: 51 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -9,146 +9,103 @@ class WireframeGeometry extends BufferGeometry {
99
super();
1010
this.type = 'WireframeGeometry';
1111

12+
if ( geometry.isGeometry === true ) {
13+
14+
console.error( 'THREE.WireframeGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );
15+
return;
16+
17+
}
18+
1219
// buffer
1320

1421
const vertices = [];
1522

1623
// helper variables
1724

1825
const edge = [ 0, 0 ], edges = {};
19-
const keys = [ 'a', 'b', 'c' ];
20-
21-
// different logic for Geometry and BufferGeometry
22-
23-
if ( geometry && geometry.isGeometry ) {
24-
25-
// create a data structure that contains all edges without duplicates
26-
27-
const faces = geometry.faces;
28-
29-
for ( let i = 0, l = faces.length; i < l; i ++ ) {
30-
31-
const face = faces[ i ];
32-
33-
for ( let j = 0; j < 3; j ++ ) {
34-
35-
const edge1 = face[ keys[ j ] ];
36-
const edge2 = face[ keys[ ( j + 1 ) % 3 ] ];
37-
edge[ 0 ] = Math.min( edge1, edge2 ); // sorting prevents duplicates
38-
edge[ 1 ] = Math.max( edge1, edge2 );
3926

40-
const key = edge[ 0 ] + ',' + edge[ 1 ];
27+
const vertex = new Vector3();
4128

42-
if ( edges[ key ] === undefined ) {
29+
if ( geometry.index !== null ) {
4330

44-
edges[ key ] = { index1: edge[ 0 ], index2: edge[ 1 ] };
31+
// indexed BufferGeometry
4532

46-
}
47-
48-
}
33+
const position = geometry.attributes.position;
34+
const indices = geometry.index;
35+
let groups = geometry.groups;
4936

50-
}
37+
if ( groups.length === 0 ) {
5138

52-
// generate vertices
53-
54-
for ( const key in edges ) {
55-
56-
const e = edges[ key ];
57-
58-
let vertex = geometry.vertices[ e.index1 ];
59-
vertices.push( vertex.x, vertex.y, vertex.z );
60-
61-
vertex = geometry.vertices[ e.index2 ];
62-
vertices.push( vertex.x, vertex.y, vertex.z );
39+
groups = [ { start: 0, count: indices.count, materialIndex: 0 } ];
6340

6441
}
6542

66-
} else if ( geometry && geometry.isBufferGeometry ) {
43+
// create a data structure that contains all eges without duplicates
6744

68-
const vertex = new Vector3();
45+
for ( let o = 0, ol = groups.length; o < ol; ++ o ) {
6946

70-
if ( geometry.index !== null ) {
47+
const group = groups[ o ];
7148

72-
// indexed BufferGeometry
49+
const start = group.start;
50+
const count = group.count;
7351

74-
const position = geometry.attributes.position;
75-
const indices = geometry.index;
76-
let groups = geometry.groups;
52+
for ( let i = start, l = ( start + count ); i < l; i += 3 ) {
7753

78-
if ( groups.length === 0 ) {
79-
80-
groups = [ { start: 0, count: indices.count, materialIndex: 0 } ];
81-
82-
}
83-
84-
// create a data structure that contains all eges without duplicates
85-
86-
for ( let o = 0, ol = groups.length; o < ol; ++ o ) {
87-
88-
const group = groups[ o ];
89-
90-
const start = group.start;
91-
const count = group.count;
92-
93-
for ( let i = start, l = ( start + count ); i < l; i += 3 ) {
94-
95-
for ( let j = 0; j < 3; j ++ ) {
96-
97-
const edge1 = indices.getX( i + j );
98-
const edge2 = indices.getX( i + ( j + 1 ) % 3 );
99-
edge[ 0 ] = Math.min( edge1, edge2 ); // sorting prevents duplicates
100-
edge[ 1 ] = Math.max( edge1, edge2 );
54+
for ( let j = 0; j < 3; j ++ ) {
10155

102-
const key = edge[ 0 ] + ',' + edge[ 1 ];
56+
const edge1 = indices.getX( i + j );
57+
const edge2 = indices.getX( i + ( j + 1 ) % 3 );
58+
edge[ 0 ] = Math.min( edge1, edge2 ); // sorting prevents duplicates
59+
edge[ 1 ] = Math.max( edge1, edge2 );
10360

104-
if ( edges[ key ] === undefined ) {
61+
const key = edge[ 0 ] + ',' + edge[ 1 ];
10562

106-
edges[ key ] = { index1: edge[ 0 ], index2: edge[ 1 ] };
63+
if ( edges[ key ] === undefined ) {
10764

108-
}
65+
edges[ key ] = { index1: edge[ 0 ], index2: edge[ 1 ] };
10966

11067
}
11168

11269
}
11370

11471
}
11572

116-
// generate vertices
73+
}
11774

118-
for ( const key in edges ) {
75+
// generate vertices
11976

120-
const e = edges[ key ];
77+
for ( const key in edges ) {
12178

122-
vertex.fromBufferAttribute( position, e.index1 );
123-
vertices.push( vertex.x, vertex.y, vertex.z );
79+
const e = edges[ key ];
12480

125-
vertex.fromBufferAttribute( position, e.index2 );
126-
vertices.push( vertex.x, vertex.y, vertex.z );
81+
vertex.fromBufferAttribute( position, e.index1 );
82+
vertices.push( vertex.x, vertex.y, vertex.z );
12783

128-
}
84+
vertex.fromBufferAttribute( position, e.index2 );
85+
vertices.push( vertex.x, vertex.y, vertex.z );
12986

130-
} else {
87+
}
13188

132-
// non-indexed BufferGeometry
89+
} else {
13390

134-
const position = geometry.attributes.position;
91+
// non-indexed BufferGeometry
13592

136-
for ( let i = 0, l = ( position.count / 3 ); i < l; i ++ ) {
93+
const position = geometry.attributes.position;
13794

138-
for ( let j = 0; j < 3; j ++ ) {
95+
for ( let i = 0, l = ( position.count / 3 ); i < l; i ++ ) {
13996

140-
// three edges per triangle, an edge is represented as (index1, index2)
141-
// e.g. the first triangle has the following edges: (0,1),(1,2),(2,0)
97+
for ( let j = 0; j < 3; j ++ ) {
14298

143-
const index1 = 3 * i + j;
144-
vertex.fromBufferAttribute( position, index1 );
145-
vertices.push( vertex.x, vertex.y, vertex.z );
99+
// three edges per triangle, an edge is represented as (index1, index2)
100+
// e.g. the first triangle has the following edges: (0,1),(1,2),(2,0)
146101

147-
const index2 = 3 * i + ( ( j + 1 ) % 3 );
148-
vertex.fromBufferAttribute( position, index2 );
149-
vertices.push( vertex.x, vertex.y, vertex.z );
102+
const index1 = 3 * i + j;
103+
vertex.fromBufferAttribute( position, index1 );
104+
vertices.push( vertex.x, vertex.y, vertex.z );
150105

151-
}
106+
const index2 = 3 * i + ( ( j + 1 ) % 3 );
107+
vertex.fromBufferAttribute( position, index2 );
108+
vertices.push( vertex.x, vertex.y, vertex.z );
152109

153110
}
154111

0 commit comments

Comments
 (0)