Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7625ca7

Browse files
committed
Box3: Added @indif's InterleavedBufferAttribute support. See mrdoob#9171.
1 parent 6cd9b05 commit 7625ca7

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/math/Box3.js

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,36 @@ THREE.Box3.prototype = {
119119

120120
}
121121

122-
} else if ( geometry instanceof THREE.BufferGeometry && geometry.attributes[ 'position' ] !== undefined ) {
122+
} else if ( geometry instanceof THREE.BufferGeometry ) {
123123

124-
var positions = geometry.attributes[ 'position' ].array;
124+
var attribute = geometry.attributes.position;
125125

126-
for ( var i = 0, il = positions.length; i < il; i += 3 ) {
126+
if ( attribute !== undefined ) {
127127

128-
v1.fromArray( positions, i );
129-
v1.applyMatrix4( node.matrixWorld );
128+
var array, offset, stride;
130129

131-
scope.expandByPoint( v1 );
130+
if ( attribute instanceof THREE.InterleavedBufferAttribute ) {
131+
132+
array = attribute.data.array;
133+
offset = attribute.offset;
134+
stride = attribute.data.stride;
135+
136+
} else {
137+
138+
array = attribute.array;
139+
offset = 0;
140+
stride = 3;
141+
142+
}
143+
144+
for ( var i = offset, il = array.length; i < il; i += stride ) {
145+
146+
v1.fromArray( array, i );
147+
v1.applyMatrix4( node.matrixWorld );
148+
149+
scope.expandByPoint( v1 );
150+
151+
}
132152

133153
}
134154

0 commit comments

Comments
 (0)