Skip to content

Commit

Permalink
Merge pull request #611 from gkjohnson/visualizer-rename
Browse files Browse the repository at this point in the history
Visualizer rename
  • Loading branch information
gkjohnson authored Jan 11, 2024
2 parents 82d7b05 + 1376e98 commit 5b0907c
Show file tree
Hide file tree
Showing 18 changed files with 53 additions and 38 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.7.0] - Unreleased
### Changed
- `MeshBVHVisualizer` has been deprecated and renamed `MeshBVHHelper` to align with three.js' conventions.

## [0.6.8] - 2023-10-08
### Changed
- Small performance improvements to bvhcast function (up to ~10%).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ roots : Array<ArrayBuffer>
index : TypedArray
```

## MeshBVHVisualizer
## MeshBVHHelper

_extends THREE.Group_

Expand Down
6 changes: 3 additions & 3 deletions example/asyncGenerate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as THREE from 'three';
import Stats from 'stats.js';
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';
import { GenerateMeshBVHWorker } from '../src/workers/GenerateMeshBVHWorker.js';
import { acceleratedRaycast, MeshBVH, MeshBVHVisualizer } from '..';
import { acceleratedRaycast, MeshBVH, MeshBVHHelper } from '..';

THREE.Mesh.raycast = acceleratedRaycast;

Expand Down Expand Up @@ -195,7 +195,7 @@ function regenerateKnot() {
const deltaTime = window.performance.now() - startTime;
generating = false;

helper = new MeshBVHVisualizer( knot, 0 );
helper = new MeshBVHHelper( knot, 0 );
helper.depth = params.helperDepth;

if ( params.displayHelper ) {
Expand Down Expand Up @@ -225,7 +225,7 @@ function regenerateKnot() {
const deltaTime = window.performance.now() - startTime;
generating = false;

helper = new MeshBVHVisualizer( knot );
helper = new MeshBVHHelper( knot );
helper.depth = params.helperDepth;
helper.update();
group.add( helper );
Expand Down
4 changes: 2 additions & 2 deletions example/characterMovement.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js';
import Stats from 'stats.js';
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';
import { MeshBVH, MeshBVHVisualizer, StaticGeometryGenerator } from '..';
import { MeshBVH, MeshBVHHelper, StaticGeometryGenerator } from '..';

const params = {

Expand Down Expand Up @@ -282,7 +282,7 @@ function loadColliderEnvironment() {
collider.material.opacity = 0.5;
collider.material.transparent = true;

visualizer = new MeshBVHVisualizer( collider, params.visualizeDepth );
visualizer = new MeshBVHHelper( collider, params.visualizeDepth );
scene.add( visualizer );
scene.add( collider );
scene.add( environment );
Expand Down
4 changes: 2 additions & 2 deletions example/clippedEdges.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
// import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js';
import Stats from 'stats.js';
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';
import { MeshBVH, MeshBVHVisualizer, CONTAINED } from '..';
import { MeshBVH, MeshBVHHelper, CONTAINED } from '..';

const params = {
useBVH: true,
Expand Down Expand Up @@ -257,7 +257,7 @@ function init() {
colliderMesh.rotation.copy( model.rotation );
colliderMesh.scale.copy( model.scale );

bvhHelper = new MeshBVHVisualizer( colliderMesh, parseInt( params.helperDepth ) );
bvhHelper = new MeshBVHHelper( colliderMesh, parseInt( params.helperDepth ) );
bvhHelper.depth = parseInt( params.helperDepth );
bvhHelper.update();

Expand Down
4 changes: 2 additions & 2 deletions example/distancecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js';
import { MarchingCubes } from './lib/MarchingCubes.js';
import SimplexNoise from 'simplex-noise';
import { acceleratedRaycast, computeBoundsTree, disposeBoundsTree, MeshBVHVisualizer } from '..';
import { acceleratedRaycast, computeBoundsTree, disposeBoundsTree, MeshBVHHelper } from '..';

THREE.Mesh.prototype.raycast = acceleratedRaycast;
THREE.BufferGeometry.prototype.computeBoundsTree = computeBoundsTree;
Expand Down Expand Up @@ -252,7 +252,7 @@ function updateFromOptions() {

if ( ! boundsViz && params.visualizeBounds ) {

boundsViz = new MeshBVHVisualizer( terrain );
boundsViz = new MeshBVHHelper( terrain );
scene.add( boundsViz );

}
Expand Down
4 changes: 2 additions & 2 deletions example/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FullScreenQuad } from 'three/examples/jsm/postprocessing/Pass.js';

import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';
import {
acceleratedRaycast, computeBoundsTree, disposeBoundsTree, MeshBVHVisualizer,
acceleratedRaycast, computeBoundsTree, disposeBoundsTree, MeshBVHHelper,
SAH, CENTER, AVERAGE, getBVHExtremes, estimateMemoryInBytes,
} from '..';

Expand Down Expand Up @@ -227,7 +227,7 @@ function init() {
mesh.position.set( 0, 0, 0 );
scene.add( mesh );

helper = new MeshBVHVisualizer( mesh, 40 );
helper = new MeshBVHHelper( mesh, 40 );
helper.displayEdges = false;
helper.displayParents = true;
helper.color.set( 0xffffff );
Expand Down
4 changes: 2 additions & 2 deletions example/physics.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js';

Check warning on line 4 in example/physics.js

View workflow job for this annotation

GitHub Actions / build (16.x)

'BufferGeometryUtils' is defined but never used
import Stats from 'stats.js';
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';
import { MeshBVH, MeshBVHVisualizer, StaticGeometryGenerator } from '..';
import { MeshBVH, MeshBVHHelper, StaticGeometryGenerator } from '..';

const params = {

Expand Down Expand Up @@ -208,7 +208,7 @@ function loadColliderEnvironment() {
collider.material.opacity = 0.5;
collider.material.transparent = true;

visualizer = new MeshBVHVisualizer( collider, params.visualizeDepth );
visualizer = new MeshBVHHelper( collider, params.visualizeDepth );
scene.add( visualizer );
scene.add( collider );
scene.add( environment );
Expand Down
4 changes: 2 additions & 2 deletions example/pointCloudIntersection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
import { PLYLoader } from 'three/examples/jsm/loaders/PLYLoader.js';
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';
import {
acceleratedRaycast, computeBoundsTree, disposeBoundsTree, MeshBVHVisualizer, INTERSECTED, NOT_INTERSECTED,
acceleratedRaycast, computeBoundsTree, disposeBoundsTree, MeshBVHHelper, INTERSECTED, NOT_INTERSECTED,
SAH, CENTER, AVERAGE,
} from '..';

Expand Down Expand Up @@ -99,7 +99,7 @@ function init() {
bvhMesh.geometry.computeBoundsTree( { mode: params.mode } );
console.timeEnd( 'computeBoundsTree' );

helper = new MeshBVHVisualizer( bvhMesh, params.depth );
helper = new MeshBVHHelper( bvhMesh, params.depth );
scene.add( helper );

} );
Expand Down
4 changes: 2 additions & 2 deletions example/randomSampleDebug.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as THREE from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
import { acceleratedRaycast, computeBoundsTree, disposeBoundsTree, AVERAGE, MeshBVHVisualizer } from '..';
import { acceleratedRaycast, computeBoundsTree, disposeBoundsTree, AVERAGE, MeshBVHHelper } from '..';

// Code for debugging issue #180 and other random raycast test associated issues.
THREE.Mesh.prototype.raycast = acceleratedRaycast;
Expand Down Expand Up @@ -87,7 +87,7 @@ function init() {
wireframe.material = new THREE.MeshBasicMaterial( { wireframe: true, color: 0xff6666 } );
scene.add( wireframe );

const helper = new MeshBVHVisualizer( mesh, 10 );
const helper = new MeshBVHHelper( mesh, 10 );
scene.add( helper );

// mesh.add( new THREE.AxesHelper( 10 ) );
Expand Down
4 changes: 2 additions & 2 deletions example/raycast.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as dat from 'three/examples/jsm/libs/lil-gui.module.min.js';
import * as THREE from 'three';
import {
acceleratedRaycast, computeBoundsTree, disposeBoundsTree,
CENTER, SAH, AVERAGE, MeshBVHVisualizer,
CENTER, SAH, AVERAGE, MeshBVHHelper,
} from '..';

THREE.Mesh.prototype.raycast = acceleratedRaycast;
Expand Down Expand Up @@ -289,7 +289,7 @@ function updateFromOptions() {

if ( ! boundsViz && shouldDisplayBounds ) {

boundsViz = new MeshBVHVisualizer( knots[ 0 ] );
boundsViz = new MeshBVHHelper( knots[ 0 ] );
containerObj.add( boundsViz );

}
Expand Down
4 changes: 2 additions & 2 deletions example/sculpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
CONTAINED,
INTERSECTED,
NOT_INTERSECTED,
MeshBVHVisualizer,
MeshBVHHelper,
} from '..';

THREE.Mesh.prototype.raycast = acceleratedRaycast;
Expand Down Expand Up @@ -78,7 +78,7 @@ function reset() {
// initialize bvh helper
if ( ! bvhHelper ) {

bvhHelper = new MeshBVHVisualizer( targetMesh, params.depth );
bvhHelper = new MeshBVHHelper( targetMesh, params.depth );
if ( params.displayHelper ) {

scene.add( bvhHelper );
Expand Down
4 changes: 2 additions & 2 deletions example/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Stats from 'stats.js';
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
import {
MeshBVHVisualizer,
MeshBVHHelper,
MeshBVH,
CONTAINED,
INTERSECTED,
Expand Down Expand Up @@ -96,7 +96,7 @@ function init() {
mesh.receiveShadow = true;
group.add( mesh );

helper = new MeshBVHVisualizer( mesh, 10 );
helper = new MeshBVHHelper( mesh, 10 );
group.add( helper );

// meshes for selection highlights
Expand Down
4 changes: 2 additions & 2 deletions example/shapecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as dat from 'three/examples/jsm/libs/lil-gui.module.min.js';
import * as THREE from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
import { TransformControls } from 'three/examples/jsm/controls/TransformControls.js';
import { acceleratedRaycast, computeBoundsTree, disposeBoundsTree, MeshBVHVisualizer } from '..';
import { acceleratedRaycast, computeBoundsTree, disposeBoundsTree, MeshBVHHelper } from '..';

THREE.Mesh.prototype.raycast = acceleratedRaycast;
THREE.BufferGeometry.prototype.computeBoundsTree = computeBoundsTree;
Expand Down Expand Up @@ -212,7 +212,7 @@ function updateFromOptions() {

if ( ! boundsViz && params.visualizeBounds ) {

boundsViz = new MeshBVHVisualizer( targetMesh );
boundsViz = new MeshBVHHelper( targetMesh );
scene.add( boundsViz );

}
Expand Down
4 changes: 2 additions & 2 deletions example/skinnedMesh.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as THREE from 'three';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import Stats from 'stats.js';
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';
import { computeBoundsTree, MeshBVHVisualizer, getBVHExtremes, StaticGeometryGenerator } from '..';
import { computeBoundsTree, MeshBVHHelper, getBVHExtremes, StaticGeometryGenerator } from '..';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';

THREE.BufferGeometry.prototype.computeBoundsTree = computeBoundsTree;
Expand Down Expand Up @@ -151,7 +151,7 @@ function init() {

scene.add( meshHelper );

bvhHelper = new MeshBVHVisualizer( meshHelper, 10 );
bvhHelper = new MeshBVHHelper( meshHelper, 10 );
scene.add( bvhHelper );

regenerateMesh();
Expand Down
4 changes: 2 additions & 2 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ export class SerializedBVH {

}

// MeshBVHVisualizer
export class MeshBVHVisualizer extends Group {
// MeshBVHHelper
export class MeshBVHHelper extends Group {

opacity: number;
depth: number;
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { MeshBVH } from './core/MeshBVH.js';
export { MeshBVHVisualizer } from './objects/MeshBVHVisualizer.js';
export { MeshBVHHelper } from './objects/MeshBVHHelper.js';
export { CENTER, AVERAGE, SAH, NOT_INTERSECTED, INTERSECTED, CONTAINED } from './core/Constants.js';
export { getBVHExtremes, estimateMemoryInBytes, getJSONStructure, validateBounds } from './debug/Debug.js';
export { acceleratedRaycast, computeBoundsTree, disposeBoundsTree } from './utils/ExtensionUtilities.js';
Expand Down
25 changes: 18 additions & 7 deletions src/objects/MeshBVHVisualizer.js → src/objects/MeshBVHHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { LineBasicMaterial, BufferAttribute, Box3, Group, MeshBasicMaterial, Obj
import { arrayToBox } from '../utils/ArrayBoxUtilities.js';

const boundingBox = /* @__PURE__ */ new Box3();
class MeshBVHRootVisualizer extends Object3D {
class MeshBVHRootHelper extends Object3D {

get isMesh() {

Expand All @@ -28,7 +28,7 @@ class MeshBVHRootVisualizer extends Object3D {

this.material = material;
this.geometry = new BufferGeometry();
this.name = 'MeshBVHRootVisualizer';
this.name = 'MeshBVHRootHelper';
this.depth = depth;
this.displayParents = false;
this.mesh = mesh;
Expand Down Expand Up @@ -198,7 +198,7 @@ class MeshBVHRootVisualizer extends Object3D {

}

class MeshBVHVisualizer extends Group {
class MeshBVHHelper extends Group {

get color() {

Expand All @@ -223,7 +223,7 @@ class MeshBVHVisualizer extends Group {

super();

this.name = 'MeshBVHVisualizer';
this.name = 'MeshBVHHelper';
this.depth = depth;
this.mesh = mesh;
this.displayParents = false;
Expand Down Expand Up @@ -269,7 +269,7 @@ class MeshBVHVisualizer extends Group {

if ( i >= this._roots.length ) {

const root = new MeshBVHRootVisualizer( this.mesh, this.edgeMaterial, this.depth, i );
const root = new MeshBVHRootHelper( this.mesh, this.edgeMaterial, this.depth, i );
this.add( root );
this._roots.push( root );

Expand Down Expand Up @@ -306,7 +306,7 @@ class MeshBVHVisualizer extends Group {

clone() {

return new MeshBVHVisualizer( this.mesh, this.depth );
return new MeshBVHHelper( this.mesh, this.depth );

}

Expand All @@ -326,5 +326,16 @@ class MeshBVHVisualizer extends Group {

}

export class MeshBVHVisualizer extends MeshBVHHelper {

export { MeshBVHVisualizer };
constructor( ...args ) {

super( ...args );

console.warn( 'MeshBVHVisualizer: MeshBVHVisualizer has been deprecated. Use MeshBVHHelper, instead.' );

}

}

export { MeshBVHHelper };

0 comments on commit 5b0907c

Please sign in to comment.