From 63818a994761430a26eefe5daaacd3589b2e8184 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Thu, 11 Jan 2024 22:42:39 +0900 Subject: [PATCH 1/4] Rename class --- README.md | 2 +- src/index.d.ts | 4 ++-- src/index.js | 2 +- src/objects/MeshBVHVisualizer.js | 25 ++++++++++++++++++------- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9ea8ddc38..d3760e9b0 100644 --- a/README.md +++ b/README.md @@ -577,7 +577,7 @@ roots : Array index : TypedArray ``` -## MeshBVHVisualizer +## MeshBVHHelper _extends THREE.Group_ diff --git a/src/index.d.ts b/src/index.d.ts index ef05bcbf9..8bd988804 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -178,8 +178,8 @@ export class SerializedBVH { } -// MeshBVHVisualizer -export class MeshBVHVisualizer extends Group { +// MeshBVHHelper +export class MeshBVHHelper extends Group { opacity: number; depth: number; diff --git a/src/index.js b/src/index.js index 4e28c3d69..4fd87ccd5 100644 --- a/src/index.js +++ b/src/index.js @@ -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'; diff --git a/src/objects/MeshBVHVisualizer.js b/src/objects/MeshBVHVisualizer.js index 5f9f064e2..6e55e30f0 100644 --- a/src/objects/MeshBVHVisualizer.js +++ b/src/objects/MeshBVHVisualizer.js @@ -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() { @@ -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; @@ -198,7 +198,7 @@ class MeshBVHRootVisualizer extends Object3D { } -class MeshBVHVisualizer extends Group { +class MeshBVHHelper extends Group { get color() { @@ -223,7 +223,7 @@ class MeshBVHVisualizer extends Group { super(); - this.name = 'MeshBVHVisualizer'; + this.name = 'MeshBVHHelper'; this.depth = depth; this.mesh = mesh; this.displayParents = false; @@ -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 ); @@ -306,7 +306,7 @@ class MeshBVHVisualizer extends Group { clone() { - return new MeshBVHVisualizer( this.mesh, this.depth ); + return new MeshBVHHelper( this.mesh, this.depth ); } @@ -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 }; From 0dbb6a5259904daa43a9916d90cbc136fa59c89e Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Thu, 11 Jan 2024 22:42:50 +0900 Subject: [PATCH 2/4] Update examples --- example/asyncGenerate.js | 6 +++--- example/characterMovement.js | 4 ++-- example/clippedEdges.js | 4 ++-- example/distancecast.js | 4 ++-- example/inspector.js | 4 ++-- example/physics.js | 4 ++-- example/pointCloudIntersection.js | 4 ++-- example/randomSampleDebug.js | 4 ++-- example/raycast.js | 4 ++-- example/sculpt.js | 4 ++-- example/selection.js | 4 ++-- example/shapecast.js | 4 ++-- example/skinnedMesh.js | 4 ++-- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/example/asyncGenerate.js b/example/asyncGenerate.js index 26e8dc28a..ad03cac31 100644 --- a/example/asyncGenerate.js +++ b/example/asyncGenerate.js @@ -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; @@ -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 ) { @@ -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 ); diff --git a/example/characterMovement.js b/example/characterMovement.js index 777dce776..6aa60cf55 100644 --- a/example/characterMovement.js +++ b/example/characterMovement.js @@ -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 = { @@ -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 ); diff --git a/example/clippedEdges.js b/example/clippedEdges.js index ce7aa3dcd..6b76e9873 100644 --- a/example/clippedEdges.js +++ b/example/clippedEdges.js @@ -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, @@ -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(); diff --git a/example/distancecast.js b/example/distancecast.js index 0a222d7de..dd93d71ee 100644 --- a/example/distancecast.js +++ b/example/distancecast.js @@ -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; @@ -252,7 +252,7 @@ function updateFromOptions() { if ( ! boundsViz && params.visualizeBounds ) { - boundsViz = new MeshBVHVisualizer( terrain ); + boundsViz = new MeshBVHHelper( terrain ); scene.add( boundsViz ); } diff --git a/example/inspector.js b/example/inspector.js index 89864b07d..351398a3e 100644 --- a/example/inspector.js +++ b/example/inspector.js @@ -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 '..'; @@ -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 ); diff --git a/example/physics.js b/example/physics.js index 26dc65084..533066e85 100644 --- a/example/physics.js +++ b/example/physics.js @@ -4,7 +4,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 = { @@ -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 ); diff --git a/example/pointCloudIntersection.js b/example/pointCloudIntersection.js index cb21a33d1..eb9def6d3 100644 --- a/example/pointCloudIntersection.js +++ b/example/pointCloudIntersection.js @@ -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 '..'; @@ -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 ); } ); diff --git a/example/randomSampleDebug.js b/example/randomSampleDebug.js index db39d6d26..4ccf98aa1 100644 --- a/example/randomSampleDebug.js +++ b/example/randomSampleDebug.js @@ -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; @@ -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 ) ); diff --git a/example/raycast.js b/example/raycast.js index c01443204..37e583e10 100644 --- a/example/raycast.js +++ b/example/raycast.js @@ -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; @@ -289,7 +289,7 @@ function updateFromOptions() { if ( ! boundsViz && shouldDisplayBounds ) { - boundsViz = new MeshBVHVisualizer( knots[ 0 ] ); + boundsViz = new MeshBVHHelper( knots[ 0 ] ); containerObj.add( boundsViz ); } diff --git a/example/sculpt.js b/example/sculpt.js index c3e093e1d..303377ab1 100644 --- a/example/sculpt.js +++ b/example/sculpt.js @@ -10,7 +10,7 @@ import { CONTAINED, INTERSECTED, NOT_INTERSECTED, - MeshBVHVisualizer, + MeshBVHHelper, } from '..'; THREE.Mesh.prototype.raycast = acceleratedRaycast; @@ -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 ); diff --git a/example/selection.js b/example/selection.js index 139aea192..df3103761 100644 --- a/example/selection.js +++ b/example/selection.js @@ -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, @@ -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 diff --git a/example/shapecast.js b/example/shapecast.js index 51dcbe964..d917bd550 100644 --- a/example/shapecast.js +++ b/example/shapecast.js @@ -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; @@ -212,7 +212,7 @@ function updateFromOptions() { if ( ! boundsViz && params.visualizeBounds ) { - boundsViz = new MeshBVHVisualizer( targetMesh ); + boundsViz = new MeshBVHHelper( targetMesh ); scene.add( boundsViz ); } diff --git a/example/skinnedMesh.js b/example/skinnedMesh.js index 4bf702b14..5a29efa8d 100644 --- a/example/skinnedMesh.js +++ b/example/skinnedMesh.js @@ -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; @@ -151,7 +151,7 @@ function init() { scene.add( meshHelper ); - bvhHelper = new MeshBVHVisualizer( meshHelper, 10 ); + bvhHelper = new MeshBVHHelper( meshHelper, 10 ); scene.add( bvhHelper ); regenerateMesh(); From 8dc4ce645a858427119d58b9042cbb3ecf2edbda Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Thu, 11 Jan 2024 22:45:03 +0900 Subject: [PATCH 3/4] Rename file --- src/objects/{MeshBVHVisualizer.js => MeshBVHHelper.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/objects/{MeshBVHVisualizer.js => MeshBVHHelper.js} (100%) diff --git a/src/objects/MeshBVHVisualizer.js b/src/objects/MeshBVHHelper.js similarity index 100% rename from src/objects/MeshBVHVisualizer.js rename to src/objects/MeshBVHHelper.js From 1376e98bfb9269781239739dd15847c66256839e Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Thu, 11 Jan 2024 22:45:36 +0900 Subject: [PATCH 4/4] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5df4b3d39..9132c1232 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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%).