Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions examples/js/math/Octree.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,37 +411,35 @@

fromGraphNode( group ) {

group.updateWorldMatrix( true, true );
group.traverse( obj => {

if ( obj.type === 'Mesh' ) {
if ( obj.isMesh === true ) {

obj.updateMatrix();
obj.updateWorldMatrix();
let geometry,
isTemp = false;

if ( obj.geometry.index ) {
if ( obj.geometry.index !== null ) {

isTemp = true;
geometry = obj.geometry.clone().toNonIndexed();
geometry = obj.geometry.toNonIndexed();

} else {

geometry = obj.geometry;

}

const positions = geometry.attributes.position.array;
const transform = obj.matrixWorld;
const positionAttribute = geometry.getAttribute( 'position' );

for ( let i = 0; i < positions.length; i += 9 ) {
for ( let i = 0; i < positionAttribute.count; i += 3 ) {

const v1 = new THREE.Vector3( positions[ i ], positions[ i + 1 ], positions[ i + 2 ] );
const v2 = new THREE.Vector3( positions[ i + 3 ], positions[ i + 4 ], positions[ i + 5 ] );
const v3 = new THREE.Vector3( positions[ i + 6 ], positions[ i + 7 ], positions[ i + 8 ] );
v1.applyMatrix4( transform );
v2.applyMatrix4( transform );
v3.applyMatrix4( transform );
const v1 = new THREE.Vector3().fromBufferAttribute( positionAttribute, i );
const v2 = new THREE.Vector3().fromBufferAttribute( positionAttribute, i + 1 );
const v3 = new THREE.Vector3().fromBufferAttribute( positionAttribute, i + 2 );
v1.applyMatrix4( obj.matrixWorld );
v2.applyMatrix4( obj.matrixWorld );
v3.applyMatrix4( obj.matrixWorld );
this.addTriangle( new THREE.Triangle( v1, v2, v3 ) );

}
Expand Down
28 changes: 13 additions & 15 deletions examples/jsm/math/Octree.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,38 +406,36 @@ class Octree {

fromGraphNode( group ) {

group.traverse( ( obj ) => {
group.updateWorldMatrix( true, true );

if ( obj.type === 'Mesh' ) {
group.traverse( ( obj ) => {

obj.updateMatrix();
obj.updateWorldMatrix();
if ( obj.isMesh === true ) {

let geometry, isTemp = false;

if ( obj.geometry.index ) {
if ( obj.geometry.index !== null ) {

isTemp = true;
geometry = obj.geometry.clone().toNonIndexed();
geometry = obj.geometry.toNonIndexed();

} else {

geometry = obj.geometry;

}

const positions = geometry.attributes.position.array;
const transform = obj.matrixWorld;
const positionAttribute = geometry.getAttribute( 'position' );

for ( let i = 0; i < positions.length; i += 9 ) {
for ( let i = 0; i < positionAttribute.count; i += 3 ) {

const v1 = new Vector3( positions[ i ], positions[ i + 1 ], positions[ i + 2 ] );
const v2 = new Vector3( positions[ i + 3 ], positions[ i + 4 ], positions[ i + 5 ] );
const v3 = new Vector3( positions[ i + 6 ], positions[ i + 7 ], positions[ i + 8 ] );
const v1 = new Vector3().fromBufferAttribute( positionAttribute, i );
const v2 = new Vector3().fromBufferAttribute( positionAttribute, i + 1 );
const v3 = new Vector3().fromBufferAttribute( positionAttribute, i + 2 );

v1.applyMatrix4( transform );
v2.applyMatrix4( transform );
v3.applyMatrix4( transform );
v1.applyMatrix4( obj.matrixWorld );
v2.applyMatrix4( obj.matrixWorld );
v3.applyMatrix4( obj.matrixWorld );

this.addTriangle( new Triangle( v1, v2, v3 ) );

Expand Down