From 83f37b759b081e58972f20527a770ec1602ce14b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Gonz=C3=A1lez=20Viegas?= Date: Thu, 22 Feb 2024 17:38:28 +0100 Subject: [PATCH] feat: BIM tiles (#301) * feat: implement visibility checkboxes in fragmenttree * Bump version * feat: allow bounding box to use simple meshes (#213) * Allow fragment bounding box to compute regular meshes * Bump version * First version of fragment streamer * Fix geometry counter reset * Load all bounding boxes from a streamed model * Update geometry event type * Make screen culler reusable * Extract screen culler base logic * Color BoundingBoxes by geometry * Start implementing culler renderer logic * First version of memory culler * Read geometry from server * WIP: create model as boxes * First successful version of geometry streaming * Add colors and trasnparency to streamed frags * First successful unloading unseen geometries * Fix automatic translucent update * Fix handle unseen geometries * Extract bounding box logic * Set pixel threshold for streaming and detect hardly seen geometries * Adjust behavior of hardly seen geometries * Create function to compute approx bounding box * Use new function to compute bounding boxes * Update bounding box generation * Generate better Oriented Bounding Boxes * Add remove method to mesh culler * Integrate streamer with culler * Add http header to try on github pages * Revert http header * Make logs optional * Fix stream event overlap * Update build * Dispose geometry on each streaming step * Stream FragmentsGroups * Load FragmentsGroup, exclude IfcOpeningElements * Exclude IfcOpeningElements when streaming geometries * First implementation of model coordination * Changes to Enable Streaming * Fix model coordination * Apply culler (still some errors) * Update Web-IFC * Bug Fixes * Bump version * Get Mesh and Sphere for Streamer + Transformation Fix * Set Position according to Center * Bump version * fix: fix some errors from merge * feat: add threshold to culler * feat: make bounding boxes a fragment * fix: squash culler render remove bugs * fix: try some culler improvements * feat: simplify geometry culler, disregard translucency * feat: add fragments to streamer culler * feat: implement scene culler in stream loader * chore: clean up * chore: clean up * feat: make streaming work with coordination * feat: make streaming work with multiple tools * feat: streaming working with visibility * feat: update fragments * feat: stream properties, simplify json exporter * feat: first version of property streaming * feat: properties almost working (property index missing) * feat: stream properties indices * fix: update fragment plans * fix: update all examples * feat: implement floor plans with streaming * fix: correct property streamer, add progress methods * feat: implement disposing streamer * feat: implement disposing single streamed model --------- Co-authored-by: Tom Beach Co-authored-by: Vishwajeet --- .DS_Store | Bin 0 -> 6148 bytes .gitignore | 5 +- package.json | 13 +- resources/openbim-components.js | 183459 ++++++++------- resources/small.frag | Bin 442056 -> 442076 bytes resources/small.json | 2 +- resources/styles.css | 4 + src/base-types/base-types.ts | 3 + src/civil/RoadNavigator/index.html | 2 +- src/core/Components/index.ts | 4 +- src/core/DXFManager/index.ts | 203 - src/core/LocalCacher/db.ts | 17 - src/core/LocalCacher/index.ts | 203 - src/core/MaterialManager/index.ts | 14 + src/core/ScreenCuller/index.html | 41 +- src/core/ScreenCuller/index.ts | 420 +- src/core/ScreenCuller/src/culler-renderer.ts | 209 + src/core/ScreenCuller/src/index.ts | 3 + .../ScreenCuller/src/mesh-culler-renderer.ts | 218 + src/core/SimpleRaycaster/index.ts | 6 +- src/core/SimpleSVGViewport/index.ts | 6 +- src/core/SimpleScene/index.ts | 4 + src/core/index.ts | 2 - src/fragments/.DS_Store | Bin 0 -> 6148 bytes src/fragments/FragmentBoundingBox/index.ts | 4 +- src/fragments/FragmentCacher/index.ts | 193 - src/fragments/FragmentClassifier/index.ts | 37 +- src/fragments/FragmentClipStyler/index.html | 2 +- src/fragments/FragmentClipStyler/index.ts | 8 +- src/fragments/FragmentExploder/index.html | 10 +- src/fragments/FragmentHider/index.html | 2 +- src/fragments/FragmentHider/index.ts | 3 + src/fragments/FragmentHighlighter/index.ts | 8 +- src/fragments/FragmentIfcLoader/index.html | 68 +- src/fragments/FragmentIfcLoader/index.ts | 50 +- .../src/ifc-fragment-settings.ts | 3 +- .../src/spatial-structure.ts | 2 +- src/fragments/FragmentIfcLoader/src/types.ts | 6 +- src/fragments/FragmentIfcStreamer/.DS_Store | Bin 0 -> 6148 bytes src/fragments/FragmentIfcStreamer/index.html | 471 + src/fragments/FragmentIfcStreamer/index.ts | 1 + .../FragmentIfcStreamer/src/base-types.ts | 16 + .../src/fragment-ifc-stream-converter.ts | 397 + .../src/fragment-props-stream-converter.ts | 242 + .../src/fragment-stream-loader.ts | 575 + .../src/geometry-culler-renderer.ts | 484 + .../FragmentIfcStreamer/src/index.ts | 5 + .../src/streaming-settings.ts | 12 + src/fragments/FragmentManager/index.html | 4 +- src/fragments/FragmentManager/index.ts | 19 +- src/fragments/FragmentPlans/index.html | 13 +- src/fragments/FragmentPlans/index.ts | 45 +- src/fragments/FragmentTree/index.html | 4 +- src/fragments/index.ts | 2 +- src/ifc/IfcJsonExporter/index.ts | 140 +- src/ifc/IfcPropertiesFinder/index.html | 3 +- src/ifc/IfcPropertiesFinder/index.ts | 30 +- src/ifc/IfcPropertiesManager/index.html | 3 +- src/ifc/IfcPropertiesManager/index.ts | 89 +- .../IfcPropertiesManager/src/prop-actions.ts | 18 +- .../IfcPropertiesManager/src/pset-actions.ts | 9 +- src/ifc/IfcPropertiesProcessor/index.html | 26 +- src/ifc/IfcPropertiesProcessor/index.ts | 195 +- .../src/attribute-set.ts | 13 +- .../src/attribute-tag.ts | 11 +- .../src/property-tag.ts | 29 +- src/ifc/IfcPropertiesUtils/index.ts | 194 +- src/import-export/dxf-exporter/index.html | 10 +- src/index.ts | 1 - src/integrations/index.ts | 3 - src/integrations/mapbox/index.ts | 189 - src/integrations/mapbox/src/mapbox-camera.ts | 19 - .../mapbox/src/mapbox-renderer.ts | 262 - src/integrations/mapbox/src/types.ts | 15 - src/navigation/EdgesClipper/index.ts | 5 +- .../OrthoPerspectiveCamera/index.ts | 5 +- .../PostproductionRenderer/index.html | 6 +- src/services/CloudStorage/index.ts | 8 +- src/utils/GeometryUtils/bbox.ts | 338 + src/utils/GeometryUtils/index.ts | 222 +- src/utils/GeometryUtils/misc.ts | 220 + src/utils/Misc/index.ts | 25 + tsconfig.json | 2 +- yarn.lock | 277 +- 84 files changed, 96170 insertions(+), 93721 deletions(-) create mode 100644 .DS_Store delete mode 100644 src/core/DXFManager/index.ts delete mode 100644 src/core/LocalCacher/db.ts delete mode 100644 src/core/LocalCacher/index.ts create mode 100644 src/core/ScreenCuller/src/culler-renderer.ts create mode 100644 src/core/ScreenCuller/src/index.ts create mode 100644 src/core/ScreenCuller/src/mesh-culler-renderer.ts create mode 100644 src/fragments/.DS_Store delete mode 100644 src/fragments/FragmentCacher/index.ts create mode 100644 src/fragments/FragmentIfcStreamer/.DS_Store create mode 100644 src/fragments/FragmentIfcStreamer/index.html create mode 100644 src/fragments/FragmentIfcStreamer/index.ts create mode 100644 src/fragments/FragmentIfcStreamer/src/base-types.ts create mode 100644 src/fragments/FragmentIfcStreamer/src/fragment-ifc-stream-converter.ts create mode 100644 src/fragments/FragmentIfcStreamer/src/fragment-props-stream-converter.ts create mode 100644 src/fragments/FragmentIfcStreamer/src/fragment-stream-loader.ts create mode 100644 src/fragments/FragmentIfcStreamer/src/geometry-culler-renderer.ts create mode 100644 src/fragments/FragmentIfcStreamer/src/index.ts create mode 100644 src/fragments/FragmentIfcStreamer/src/streaming-settings.ts delete mode 100644 src/integrations/index.ts delete mode 100644 src/integrations/mapbox/index.ts delete mode 100644 src/integrations/mapbox/src/mapbox-camera.ts delete mode 100644 src/integrations/mapbox/src/mapbox-renderer.ts delete mode 100644 src/integrations/mapbox/src/types.ts create mode 100644 src/utils/GeometryUtils/bbox.ts create mode 100644 src/utils/GeometryUtils/misc.ts diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ec23fe7b3c44f75245051607e2c168d6ef2a6cb2 GIT binary patch literal 6148 zcmeHKyJ`bL43y$43~5}Z++Xk?EXMf)|3Dyy5C}FnkNT>7mp?5tk_g!6KpHn@1k&uz zNxR$>r<0la>T|m^TbS7#PPA`^sqr~|Vt2(5oo9S)4!gJg?j`q={7VFD2iw}Kz1zoG z{S4f}p3m4zr-+jRQa}nw0VyB_{;L3bHf?^Ns3--bfE4&ufZvA(C-%ZIF+Lp#F#-Sw z&|z4|ECFmJfW2@`1OxLd1!k$&h~ZfdzExf?922wLJZ{E0b+gxm;&D6p7U||aQBev= zfl~!$xm~dTKf?c*|4)mwlLAuUrWEjDy;-mDO4VB@FUMZn;7@So9N{#qqXZ$^F)-RO gHf+Zak(7CjYdr6TV`7wpk8+@X2B?cn3S3)(ACM*(p#T5? literal 0 HcmV?d00001 diff --git a/.gitignore b/.gitignore index 44b286cd..244916ed 100644 --- a/.gitignore +++ b/.gitignore @@ -132,4 +132,7 @@ dist/ resources/asdf.ifc resources/asdf.frag resources/asdf.json -resources/bbbb.ifc +resources/bbbb.* + +resources/*-processed.json +resources/*-processed-properties.json diff --git a/package.json b/package.json index 715ad3c9..3eec9263 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openbim-components", - "version": "1.3.4", + "version": "1.4.0-alpha.17", "main": "src/index.js", "author": "harry collin, antonio gonzalez viegas", "license": "MIT", @@ -19,13 +19,12 @@ "@tailwindcss/forms": "^0.5.3", "@types/earcut": "^2.1.1", "@types/jest": "27.0.0", - "@types/mapbox-gl": "^2.7.11", "@types/node": "^14.14.31", "@types/node-fetch": "^2.6.4", "@types/three": "0.160.0", "@typescript-eslint/eslint-plugin": "^4.27.0", "@typescript-eslint/parser": "^4.27.0", - "bim-fragment": "1.3.8", + "bim-fragment": "1.3.35", "cpy-cli": "^3.1.1", "eslint": "^7.28.0", "eslint-config-airbnb-base": "^14.2.1", @@ -33,7 +32,6 @@ "eslint-plugin-import": "^2.23.4", "eslint-plugin-prettier": "^3.4.0", "jest": "^27.0.4", - "mapbox-gl": "^2.15.0", "node-fetch": "^3.3.2", "prettier": "^2.3.1", "rollup": "^3.2.3", @@ -42,7 +40,7 @@ "ts-jest": "^27.0.3", "ts-node": "^10.0.0", "typescript": "^4.3.2", - "web-ifc": "^0.0.50" + "web-ifc": "0.0.51" }, "dependencies": { "@popperjs/core": "2.11.8", @@ -59,9 +57,8 @@ "unzipit": "^1.4.3" }, "peerDependencies": { - "bim-fragment": "1.3.8", - "mapbox-gl": "^2.15.0", + "bim-fragment": "1.3.35", "three": "^0.160.1", - "web-ifc": "^0.0.50" + "web-ifc": "0.0.51" } } diff --git a/resources/openbim-components.js b/resources/openbim-components.js index 1b5cfb1e..6556249b 100644 --- a/resources/openbim-components.js +++ b/resources/openbim-components.js @@ -1,5 +1,5 @@ import * as THREE$1 from 'three'; -import { Vector3, Matrix4, Object3D, Vector2, BufferAttribute, Plane, Line3, Triangle, Sphere, Box3, BackSide, DoubleSide, FrontSide, Mesh, Ray, Raycaster, Quaternion, Euler, MeshBasicMaterial, LineBasicMaterial, CylinderGeometry, BoxGeometry, BufferGeometry, Float32BufferAttribute, OctahedronGeometry, Line as Line$2, SphereGeometry, TorusGeometry, PlaneGeometry, OrthographicCamera, ShaderMaterial, UniformsUtils, WebGLRenderTarget, HalfFloatType, NoBlending, Clock, Color, REVISION, LinearFilter, NearestFilter, DepthTexture, UnsignedIntType, DepthFormat, DataTexture, NoColorSpace, RepeatWrapping, WebGLMultipleRenderTargets, RedFormat, FloatType, RGBAFormat, MathUtils, EventDispatcher as EventDispatcher$1, MOUSE, TOUCH, Spherical, UniformsLib, ShaderLib, InstancedBufferGeometry, InstancedInterleavedBuffer, InterleavedBufferAttribute, WireframeGeometry, Vector4 } from 'three'; +import { Vector3, Matrix4, Object3D, Vector2, BufferAttribute, Plane, Line3, Triangle, Sphere, Box3, BackSide, DoubleSide, FrontSide, Mesh, Ray, Raycaster, Quaternion, Euler, MeshBasicMaterial, LineBasicMaterial, CylinderGeometry, BoxGeometry, BufferGeometry, Float32BufferAttribute, OctahedronGeometry, Line as Line$2, SphereGeometry, TorusGeometry, PlaneGeometry, MathUtils, EventDispatcher as EventDispatcher$1, MOUSE, TOUCH, Spherical, OrthographicCamera, ShaderMaterial, UniformsUtils, WebGLRenderTarget, HalfFloatType, NoBlending, Clock, Color, REVISION, LinearFilter, NearestFilter, DepthTexture, UnsignedIntType, DepthFormat, DataTexture, NoColorSpace, RepeatWrapping, WebGLMultipleRenderTargets, RedFormat, FloatType, RGBAFormat, UniformsLib, ShaderLib, InstancedBufferGeometry, InstancedInterleavedBuffer, InterleavedBufferAttribute, WireframeGeometry, Vector4 } from 'three'; /** * Components are the building blocks of this library. Everything is a @@ -220,8 +220,7 @@ class BaseSVGAnnotation extends Component { this._svgViewport = value; } get svgViewport() { - var _a; - return (_a = this._svgViewport) !== null && _a !== void 0 ? _a : undefined; + return this._svgViewport ?? undefined; } set enabled(value) { this._enabled = value; @@ -544,6 +543,8 @@ class SimpleScene extends Component { super(components); /** {@link Component.enabled} */ this.enabled = true; + /** {@link Configurable.isSetup} */ + this.isSetup = false; /** {@link Disposable.onDisposed} */ this.onDisposed = new Event(); this.config = { @@ -585,6 +586,7 @@ class SimpleScene extends Component { directionalLight.position.copy(this.config.directionalLight.position); const ambientLight = new THREE$1.AmbientLight(this.config.ambientLight.color, this.config.ambientLight.intensity); this._scene.add(directionalLight, ambientLight); + this.isSetup = true; this.onSetup.trigger(this); } } @@ -3678,16 +3680,16 @@ class SimpleRaycaster extends BaseRaycaster { * to query. If not provided, it will query all the meshes stored in * {@link Components.meshes}. */ - castRay(items = this.components.meshes) { + castRay(items = Array.from(this.components.meshes)) { const camera = this.components.camera.get(); this._raycaster.setFromCamera(this.mouse.position, camera); return this.intersect(items); } - castRayFromVector(origin, direction, items = this.components.meshes) { + castRayFromVector(origin, direction, items = Array.from(this.components.meshes)) { this._raycaster.set(origin, direction); return this.intersect(items); } - intersect(items = this.components.meshes) { + intersect(items = Array.from(this.components.meshes)) { const result = this._raycaster.intersectObjects(items); const filtered = this.filterClippingPlanes(result); return filtered.length > 0 ? filtered[0] : null; @@ -3698,7 +3700,7 @@ class SimpleRaycaster extends BaseRaycaster { return objs; } const planes = renderer.clippingPlanes; - if (objs.length <= 0 || !planes || (planes === null || planes === void 0 ? void 0 : planes.length) <= 0) + if (objs.length <= 0 || !planes || planes?.length <= 0) return objs; return objs.filter((elem) => planes.every((elem2) => elem2.distanceToPoint(elem.point) > 0)); } @@ -3882,28 +3884,28 @@ SimpleGrid.uuid = "d1e814d5-b81c-4452-87a2-f039375e0489"; ToolComponent.libraryUUIDs.add(SimpleGrid.uuid); // Split strategy constants -const CENTER$1 = 0; -const AVERAGE$1 = 1; -const SAH$1 = 2; -const CONTAINED$1 = 2; +const CENTER = 0; +const AVERAGE = 1; +const SAH = 2; +const CONTAINED = 2; // SAH cost constants // TODO: hone these costs more. The relative difference between them should be the // difference in measured time to perform a triangle intersection vs traversing // bounds. -const TRIANGLE_INTERSECT_COST$1 = 1.25; -const TRAVERSAL_COST$1 = 1; +const TRIANGLE_INTERSECT_COST = 1.25; +const TRAVERSAL_COST = 1; // Build constants -const BYTES_PER_NODE$1 = 6 * 4 + 4 + 4; -const IS_LEAFNODE_FLAG$1 = 0xFFFF; +const BYTES_PER_NODE = 6 * 4 + 4 + 4; +const IS_LEAFNODE_FLAG = 0xFFFF; // EPSILON for computing floating point error during build // https://en.wikipedia.org/wiki/Machine_epsilon#Values_for_standard_hardware_floating_point_arithmetics -const FLOAT32_EPSILON$1 = Math.pow( 2, - 24 ); +const FLOAT32_EPSILON = Math.pow( 2, - 24 ); -const SKIP_GENERATION$1 = Symbol( 'SKIP_GENERATION' ); +const SKIP_GENERATION = Symbol( 'SKIP_GENERATION' ); function getVertexCount( geo ) { @@ -3932,7 +3934,7 @@ function getIndexArray( vertexCount, BufferConstructor = ArrayBuffer ) { } // ensures that an index is present on the geometry -function ensureIndex$1( geo, options ) { +function ensureIndex( geo, options ) { if ( ! geo.index ) { @@ -3978,7 +3980,7 @@ function getFullGeometryRange( geo ) { } -function getRootIndexRanges$1( geo ) { +function getRootIndexRanges( geo ) { if ( ! geo.groups || ! geo.groups.length ) { @@ -4029,7 +4031,7 @@ function hasGroupGaps( geometry ) { } const vertexCount = getTriCount( geometry ); - const groups = getRootIndexRanges$1( geometry ) + const groups = getRootIndexRanges( geometry ) .sort( ( a, b ) => a.offset - b.offset ); const finalGroup = groups[ groups.length - 1 ]; @@ -4041,7 +4043,7 @@ function hasGroupGaps( geometry ) { } -function arrayToBox$1( nodeIndex32, array, target ) { +function arrayToBox( nodeIndex32, array, target ) { target.min.x = array[ nodeIndex32 ]; target.min.y = array[ nodeIndex32 + 1 ]; @@ -4062,7 +4064,7 @@ function makeEmptyBounds( target ) { } -function getLongestEdgeIndex$1( bounds ) { +function getLongestEdgeIndex( bounds ) { let splitDimIdx = - 1; let splitDist = - Infinity; @@ -4084,14 +4086,14 @@ function getLongestEdgeIndex$1( bounds ) { } // copies bounds a into bounds b -function copyBounds$1( source, target ) { +function copyBounds( source, target ) { target.set( source ); } // sets bounds target to the union of bounds a and b -function unionBounds$1( a, b, target ) { +function unionBounds( a, b, target ) { let aVal, bVal; for ( let d = 0; d < 3; d ++ ) { @@ -4113,7 +4115,7 @@ function unionBounds$1( a, b, target ) { } // expands the given bounds by the provided triangle bounds -function expandByTriangleBounds$1( startIndex, triangleBounds, bounds ) { +function expandByTriangleBounds( startIndex, triangleBounds, bounds ) { for ( let d = 0; d < 3; d ++ ) { @@ -4140,7 +4142,7 @@ function expandByTriangleBounds$1( startIndex, triangleBounds, bounds ) { } // compute bounds surface area -function computeSurfaceArea$1( bounds ) { +function computeSurfaceArea( bounds ) { const d0 = bounds[ 3 ] - bounds[ 0 ]; const d1 = bounds[ 4 ] - bounds[ 1 ]; @@ -4153,7 +4155,7 @@ function computeSurfaceArea$1( bounds ) { // computes the union of the bounds of all of the given triangles and puts the resulting box in target. If // centroidTarget is provided then a bounding box is computed for the centroids of the triangles, as well. // These are computed together to avoid redundant accesses to bounds array. -function getBounds$1( triangleBounds, offset, count, target, centroidTarget = null ) { +function getBounds( triangleBounds, offset, count, target, centroidTarget = null ) { let minx = Infinity; let miny = Infinity; @@ -4224,7 +4226,7 @@ function getBounds$1( triangleBounds, offset, count, target, centroidTarget = nu } // A stand alone function for retrieving the centroid bounds. -function getCentroidBounds$1( triangleBounds, offset, count, centroidTarget ) { +function getCentroidBounds( triangleBounds, offset, count, centroidTarget ) { let cminx = Infinity; let cminy = Infinity; @@ -4264,7 +4266,7 @@ function getCentroidBounds$1( triangleBounds, offset, count, centroidTarget ) { // result is an array of size tris.length * 6 where triangle i maps to a // [x_center, x_delta, y_center, y_delta, z_center, z_delta] tuple starting at index i * 6, // representing the center and half-extent in each dimension of triangle i -function computeTriangleBounds$1( geo, fullBounds ) { +function computeTriangleBounds( geo, fullBounds ) { // clear the bounds to empty makeEmptyBounds( fullBounds ); @@ -4349,7 +4351,7 @@ function computeTriangleBounds$1( geo, fullBounds ) { const halfExtents = ( max - min ) / 2; const el2 = el * 2; triangleBounds[ tri6 + el2 + 0 ] = min + halfExtents; - triangleBounds[ tri6 + el2 + 1 ] = halfExtents + ( Math.abs( min ) + halfExtents ) * FLOAT32_EPSILON$1; + triangleBounds[ tri6 + el2 + 1 ] = halfExtents + ( Math.abs( min ) + halfExtents ) * FLOAT32_EPSILON; if ( min < fullBounds[ el ] ) fullBounds[ el ] = min; if ( max > fullBounds[ el + 3 ] ) fullBounds[ el + 3 ] = max; @@ -4362,9 +4364,9 @@ function computeTriangleBounds$1( geo, fullBounds ) { } -const BIN_COUNT$1 = 32; -const binsSort$1 = ( a, b ) => a.candidate - b.candidate; -const sahBins$1 = new Array( BIN_COUNT$1 ).fill().map( () => { +const BIN_COUNT = 32; +const binsSort = ( a, b ) => a.candidate - b.candidate; +const sahBins = new Array( BIN_COUNT ).fill().map( () => { return { @@ -4377,36 +4379,36 @@ const sahBins$1 = new Array( BIN_COUNT$1 ).fill().map( () => { }; } ); -const leftBounds$1 = new Float32Array( 6 ); +const leftBounds = new Float32Array( 6 ); -function getOptimalSplit$1( nodeBoundingData, centroidBoundingData, triangleBounds, offset, count, strategy ) { +function getOptimalSplit( nodeBoundingData, centroidBoundingData, triangleBounds, offset, count, strategy ) { let axis = - 1; let pos = 0; // Center - if ( strategy === CENTER$1 ) { + if ( strategy === CENTER ) { - axis = getLongestEdgeIndex$1( centroidBoundingData ); + axis = getLongestEdgeIndex( centroidBoundingData ); if ( axis !== - 1 ) { pos = ( centroidBoundingData[ axis ] + centroidBoundingData[ axis + 3 ] ) / 2; } - } else if ( strategy === AVERAGE$1 ) { + } else if ( strategy === AVERAGE ) { - axis = getLongestEdgeIndex$1( nodeBoundingData ); + axis = getLongestEdgeIndex( nodeBoundingData ); if ( axis !== - 1 ) { - pos = getAverage$1( triangleBounds, offset, count, axis ); + pos = getAverage( triangleBounds, offset, count, axis ); } - } else if ( strategy === SAH$1 ) { + } else if ( strategy === SAH ) { - const rootSurfaceArea = computeSurfaceArea$1( nodeBoundingData ); - let bestCost = TRIANGLE_INTERSECT_COST$1 * count; + const rootSurfaceArea = computeSurfaceArea( nodeBoundingData ); + let bestCost = TRIANGLE_INTERSECT_COST * count; // iterate over all axes const cStart = offset * 6; @@ -4416,14 +4418,14 @@ function getOptimalSplit$1( nodeBoundingData, centroidBoundingData, triangleBoun const axisLeft = centroidBoundingData[ a ]; const axisRight = centroidBoundingData[ a + 3 ]; const axisLength = axisRight - axisLeft; - const binWidth = axisLength / BIN_COUNT$1; + const binWidth = axisLength / BIN_COUNT; // If we have fewer triangles than we're planning to split then just check all // the triangle positions because it will be faster. - if ( count < BIN_COUNT$1 / 4 ) { + if ( count < BIN_COUNT / 4 ) { // initialize the bin candidates - const truncatedBins = [ ...sahBins$1 ]; + const truncatedBins = [ ...sahBins ]; truncatedBins.length = count; // set the candidates @@ -4452,11 +4454,11 @@ function getOptimalSplit$1( nodeBoundingData, centroidBoundingData, triangleBoun } - expandByTriangleBounds$1( c, triangleBounds, bounds ); + expandByTriangleBounds( c, triangleBounds, bounds ); } - truncatedBins.sort( binsSort$1 ); + truncatedBins.sort( binsSort ); // remove redundant splits let splitCount = count; @@ -4481,11 +4483,11 @@ function getOptimalSplit$1( nodeBoundingData, centroidBoundingData, triangleBoun const bin = truncatedBins[ bi ]; if ( center >= bin.candidate ) { - expandByTriangleBounds$1( c, triangleBounds, bin.rightCacheBounds ); + expandByTriangleBounds( c, triangleBounds, bin.rightCacheBounds ); } else { - expandByTriangleBounds$1( c, triangleBounds, bin.leftCacheBounds ); + expandByTriangleBounds( c, triangleBounds, bin.leftCacheBounds ); bin.count ++; } @@ -4508,18 +4510,18 @@ function getOptimalSplit$1( nodeBoundingData, centroidBoundingData, triangleBoun let leftProb = 0; if ( leftCount !== 0 ) { - leftProb = computeSurfaceArea$1( leftBounds ) / rootSurfaceArea; + leftProb = computeSurfaceArea( leftBounds ) / rootSurfaceArea; } let rightProb = 0; if ( rightCount !== 0 ) { - rightProb = computeSurfaceArea$1( rightBounds ) / rootSurfaceArea; + rightProb = computeSurfaceArea( rightBounds ) / rootSurfaceArea; } - const cost = TRAVERSAL_COST$1 + TRIANGLE_INTERSECT_COST$1 * ( + const cost = TRAVERSAL_COST + TRIANGLE_INTERSECT_COST * ( leftProb * leftCount + rightProb * rightCount ); @@ -4536,9 +4538,9 @@ function getOptimalSplit$1( nodeBoundingData, centroidBoundingData, triangleBoun } else { // reset the bins - for ( let i = 0; i < BIN_COUNT$1; i ++ ) { + for ( let i = 0; i < BIN_COUNT; i ++ ) { - const bin = sahBins$1[ i ]; + const bin = sahBins[ i ]; bin.count = 0; bin.candidate = axisLeft + binWidth + i * binWidth; @@ -4561,34 +4563,34 @@ function getOptimalSplit$1( nodeBoundingData, centroidBoundingData, triangleBoun // in the partition function if the centroid lies on the split plane then it is // considered to be on the right side of the split let binIndex = ~ ~ ( relativeCenter / binWidth ); - if ( binIndex >= BIN_COUNT$1 ) binIndex = BIN_COUNT$1 - 1; + if ( binIndex >= BIN_COUNT ) binIndex = BIN_COUNT - 1; - const bin = sahBins$1[ binIndex ]; + const bin = sahBins[ binIndex ]; bin.count ++; - expandByTriangleBounds$1( c, triangleBounds, bin.bounds ); + expandByTriangleBounds( c, triangleBounds, bin.bounds ); } // cache the unioned bounds from right to left so we don't have to regenerate them each time - const lastBin = sahBins$1[ BIN_COUNT$1 - 1 ]; - copyBounds$1( lastBin.bounds, lastBin.rightCacheBounds ); - for ( let i = BIN_COUNT$1 - 2; i >= 0; i -- ) { + const lastBin = sahBins[ BIN_COUNT - 1 ]; + copyBounds( lastBin.bounds, lastBin.rightCacheBounds ); + for ( let i = BIN_COUNT - 2; i >= 0; i -- ) { - const bin = sahBins$1[ i ]; - const nextBin = sahBins$1[ i + 1 ]; - unionBounds$1( bin.bounds, nextBin.rightCacheBounds, bin.rightCacheBounds ); + const bin = sahBins[ i ]; + const nextBin = sahBins[ i + 1 ]; + unionBounds( bin.bounds, nextBin.rightCacheBounds, bin.rightCacheBounds ); } let leftCount = 0; - for ( let i = 0; i < BIN_COUNT$1 - 1; i ++ ) { + for ( let i = 0; i < BIN_COUNT - 1; i ++ ) { - const bin = sahBins$1[ i ]; + const bin = sahBins[ i ]; const binCount = bin.count; const bounds = bin.bounds; - const nextBin = sahBins$1[ i + 1 ]; + const nextBin = sahBins[ i + 1 ]; const rightBounds = nextBin.rightCacheBounds; // don't do anything with the bounds if the new bounds have no triangles @@ -4596,11 +4598,11 @@ function getOptimalSplit$1( nodeBoundingData, centroidBoundingData, triangleBoun if ( leftCount === 0 ) { - copyBounds$1( bounds, leftBounds$1 ); + copyBounds( bounds, leftBounds ); } else { - unionBounds$1( bounds, leftBounds$1, leftBounds$1 ); + unionBounds( bounds, leftBounds, leftBounds ); } @@ -4614,18 +4616,18 @@ function getOptimalSplit$1( nodeBoundingData, centroidBoundingData, triangleBoun if ( leftCount !== 0 ) { - leftProb = computeSurfaceArea$1( leftBounds$1 ) / rootSurfaceArea; + leftProb = computeSurfaceArea( leftBounds ) / rootSurfaceArea; } const rightCount = count - leftCount; if ( rightCount !== 0 ) { - rightProb = computeSurfaceArea$1( rightBounds ) / rootSurfaceArea; + rightProb = computeSurfaceArea( rightBounds ) / rootSurfaceArea; } - const cost = TRAVERSAL_COST$1 + TRIANGLE_INTERSECT_COST$1 * ( + const cost = TRAVERSAL_COST + TRIANGLE_INTERSECT_COST * ( leftProb * leftCount + rightProb * rightCount ); @@ -4654,7 +4656,7 @@ function getOptimalSplit$1( nodeBoundingData, centroidBoundingData, triangleBoun } // returns the average coordinate on the specified axis of the all the provided triangles -function getAverage$1( triangleBounds, offset, count, axis ) { +function getAverage( triangleBounds, offset, count, axis ) { let avg = 0; for ( let i = offset, end = offset + count; i < end; i ++ ) { @@ -4667,7 +4669,7 @@ function getAverage$1( triangleBounds, offset, count, axis ) { } -let MeshBVHNode$1 = class MeshBVHNode { +class MeshBVHNode { constructor() { @@ -4676,7 +4678,7 @@ let MeshBVHNode$1 = class MeshBVHNode { } -}; +} /********************************************************/ /* This file is generated from "sortUtils.template.js". */ @@ -4684,7 +4686,7 @@ let MeshBVHNode$1 = class MeshBVHNode { // reorders `tris` such that for `count` elements after `offset`, elements on the left side of the split // will be on the left and elements on the right side of the split will be on the right. returns the index // of the first element on the right side, or offset + count if there are no elements on the right side. -function partition$1( indirectBuffer, index, triangleBounds, offset, count, split ) { +function partition( indirectBuffer, index, triangleBounds, offset, count, split ) { let left = offset; let right = offset + count - 1; @@ -4823,7 +4825,7 @@ function generateIndirectBuffer( geometry, useSharedArrayBuffer ) { } -function buildTree$1( bvh, options ) { +function buildTree( bvh, options ) { // Compute the full bounds of the geometry at the same time as triangle bounds because // we'll need it for the root bounds in the case with no groups and it should be fast here. @@ -4841,18 +4843,18 @@ function buildTree$1( bvh, options ) { const fullBounds = new Float32Array( 6 ); const cacheCentroidBoundingData = new Float32Array( 6 ); - const triangleBounds = computeTriangleBounds$1( geometry, fullBounds ); - const partionFunc = options.indirect ? partition_indirect : partition$1; + const triangleBounds = computeTriangleBounds( geometry, fullBounds ); + const partionFunc = options.indirect ? partition_indirect : partition; const roots = []; - const ranges = options.indirect ? getFullGeometryRange( geometry ) : getRootIndexRanges$1( geometry ); + const ranges = options.indirect ? getFullGeometryRange( geometry ) : getRootIndexRanges( geometry ); if ( ranges.length === 1 ) { const range = ranges[ 0 ]; - const root = new MeshBVHNode$1(); + const root = new MeshBVHNode(); root.boundingData = fullBounds; - getCentroidBounds$1( triangleBounds, range.offset, range.count, cacheCentroidBoundingData ); + getCentroidBounds( triangleBounds, range.offset, range.count, cacheCentroidBoundingData ); splitNode( root, range.offset, range.count, cacheCentroidBoundingData ); roots.push( root ); @@ -4861,9 +4863,9 @@ function buildTree$1( bvh, options ) { for ( let range of ranges ) { - const root = new MeshBVHNode$1(); + const root = new MeshBVHNode(); root.boundingData = new Float32Array( 6 ); - getBounds$1( triangleBounds, range.offset, range.count, root.boundingData, cacheCentroidBoundingData ); + getBounds( triangleBounds, range.offset, range.count, root.boundingData, cacheCentroidBoundingData ); splitNode( root, range.offset, range.count, cacheCentroidBoundingData ); roots.push( root ); @@ -4911,7 +4913,7 @@ function buildTree$1( bvh, options ) { } // Find where to split the volume - const split = getOptimalSplit$1( node.boundingData, centroidBoundingData, triangleBounds, offset, count, strategy ); + const split = getOptimalSplit( node.boundingData, centroidBoundingData, triangleBounds, offset, count, strategy ); if ( split.axis === - 1 ) { triggerProgress( offset + count ); @@ -4935,23 +4937,23 @@ function buildTree$1( bvh, options ) { node.splitAxis = split.axis; // create the left child and compute its bounding box - const left = new MeshBVHNode$1(); + const left = new MeshBVHNode(); const lstart = offset; const lcount = splitOffset - offset; node.left = left; left.boundingData = new Float32Array( 6 ); - getBounds$1( triangleBounds, lstart, lcount, left.boundingData, cacheCentroidBoundingData ); + getBounds( triangleBounds, lstart, lcount, left.boundingData, cacheCentroidBoundingData ); splitNode( left, lstart, lcount, cacheCentroidBoundingData, depth + 1 ); // repeat for right - const right = new MeshBVHNode$1(); + const right = new MeshBVHNode(); const rstart = splitOffset; const rcount = count - lcount; node.right = right; right.boundingData = new Float32Array( 6 ); - getBounds$1( triangleBounds, rstart, rcount, right.boundingData, cacheCentroidBoundingData ); + getBounds( triangleBounds, rstart, rcount, right.boundingData, cacheCentroidBoundingData ); splitNode( right, rstart, rcount, cacheCentroidBoundingData, depth + 1 ); } @@ -4962,7 +4964,7 @@ function buildTree$1( bvh, options ) { } -function buildPackedTree$1( bvh, options ) { +function buildPackedTree( bvh, options ) { const geometry = bvh.geometry; if ( options.indirect ) { @@ -4982,14 +4984,14 @@ function buildPackedTree$1( bvh, options ) { if ( ! bvh._indirectBuffer ) { - ensureIndex$1( geometry, options ); + ensureIndex( geometry, options ); } // boundingData : 6 float32 // right / offset : 1 uint32 // splitAxis / isLeaf + count : 1 uint32 / 2 uint16 - const roots = buildTree$1( bvh, options ); + const roots = buildTree( bvh, options ); let float32Array; let uint32Array; @@ -5001,7 +5003,7 @@ function buildPackedTree$1( bvh, options ) { const root = roots[ i ]; let nodeCount = countNodes( root ); - const buffer = new BufferConstructor( BYTES_PER_NODE$1 * nodeCount ); + const buffer = new BufferConstructor( BYTES_PER_NODE * nodeCount ); float32Array = new Float32Array( buffer ); uint32Array = new Uint32Array( buffer ); uint16Array = new Uint16Array( buffer ); @@ -5045,8 +5047,8 @@ function buildPackedTree$1( bvh, options ) { const count = node.count; uint32Array[ stride4Offset + 6 ] = offset; uint16Array[ stride2Offset + 14 ] = count; - uint16Array[ stride2Offset + 15 ] = IS_LEAFNODE_FLAG$1; - return byteOffset + BYTES_PER_NODE$1; + uint16Array[ stride2Offset + 15 ] = IS_LEAFNODE_FLAG; + return byteOffset + BYTES_PER_NODE; } else { @@ -5055,7 +5057,7 @@ function buildPackedTree$1( bvh, options ) { const splitAxis = node.splitAxis; let nextUnusedPointer; - nextUnusedPointer = populateBuffer( byteOffset + BYTES_PER_NODE$1, left ); + nextUnusedPointer = populateBuffer( byteOffset + BYTES_PER_NODE, left ); if ( ( nextUnusedPointer / 4 ) > Math.pow( 2, 32 ) ) { @@ -5075,7 +5077,7 @@ function buildPackedTree$1( bvh, options ) { } -let SeparatingAxisBounds$1 = class SeparatingAxisBounds { +class SeparatingAxisBounds { constructor() { @@ -5126,9 +5128,9 @@ let SeparatingAxisBounds$1 = class SeparatingAxisBounds { } -}; +} -SeparatingAxisBounds$1.prototype.setFromBox = ( function () { +SeparatingAxisBounds.prototype.setFromBox = ( function () { const p = new Vector3(); return function setFromBox( axis, box ) { @@ -5164,7 +5166,7 @@ SeparatingAxisBounds$1.prototype.setFromBox = ( function () { } )(); -const closestPointLineToLine$1 = ( function () { +const closestPointLineToLine = ( function () { // https://github.com/juj/MathGeoLib/blob/master/src/Geometry/Line.cpp#L56 const dir1 = new Vector3(); @@ -5219,7 +5221,7 @@ const closestPointLineToLine$1 = ( function () { } )(); -const closestPointsSegmentToSegment$1 = ( function () { +const closestPointsSegmentToSegment = ( function () { // https://github.com/juj/MathGeoLib/blob/master/src/Geometry/LineSegment.cpp#L187 const paramResult = new Vector2(); @@ -5227,7 +5229,7 @@ const closestPointsSegmentToSegment$1 = ( function () { const temp2 = new Vector3(); return function closestPointsSegmentToSegment( l1, l2, target1, target2 ) { - closestPointLineToLine$1( l1, l2, paramResult ); + closestPointLineToLine( l1, l2, paramResult ); let d = paramResult.x; let d2 = paramResult.y; @@ -5321,7 +5323,7 @@ const closestPointsSegmentToSegment$1 = ( function () { } )(); -const sphereIntersectTriangle$1 = ( function () { +const sphereIntersectTriangle = ( function () { // https://stackoverflow.com/questions/34043955/detect-collision-between-sphere-and-triangle-in-three-js const closestPointTemp = new Vector3(); @@ -5367,13 +5369,13 @@ const sphereIntersectTriangle$1 = ( function () { } )(); const ZERO_EPSILON = 1e-15; -function isNearZero$1( value ) { +function isNearZero( value ) { return Math.abs( value ) < ZERO_EPSILON; } -let ExtendedTriangle$1 = class ExtendedTriangle extends Triangle { +class ExtendedTriangle extends Triangle { constructor( ...args ) { @@ -5381,7 +5383,7 @@ let ExtendedTriangle$1 = class ExtendedTriangle extends Triangle { this.isExtendedTriangle = true; this.satAxes = new Array( 4 ).fill().map( () => new Vector3() ); - this.satBounds = new Array( 4 ).fill().map( () => new SeparatingAxisBounds$1() ); + this.satBounds = new Array( 4 ).fill().map( () => new SeparatingAxisBounds() ); this.points = [ this.a, this.b, this.c ]; this.sphere = new Sphere(); this.plane = new Plane(); @@ -5391,7 +5393,7 @@ let ExtendedTriangle$1 = class ExtendedTriangle extends Triangle { intersectsSphere( sphere ) { - return sphereIntersectTriangle$1( sphere, this ); + return sphereIntersectTriangle( sphere, this ); } @@ -5431,9 +5433,9 @@ let ExtendedTriangle$1 = class ExtendedTriangle extends Triangle { } -}; +} -ExtendedTriangle$1.prototype.closestPointToSegment = ( function () { +ExtendedTriangle.prototype.closestPointToSegment = ( function () { const point1 = new Vector3(); const point2 = new Vector3(); @@ -5453,7 +5455,7 @@ ExtendedTriangle$1.prototype.closestPointToSegment = ( function () { edge.start.copy( points[ i ] ); edge.end.copy( points[ nexti ] ); - closestPointsSegmentToSegment$1( edge, segment, point1, point2 ); + closestPointsSegmentToSegment( edge, segment, point1, point2 ); distSq = point1.distanceToSquared( point2 ); if ( distSq < closestDistanceSq ) { @@ -5493,13 +5495,13 @@ ExtendedTriangle$1.prototype.closestPointToSegment = ( function () { } )(); -ExtendedTriangle$1.prototype.intersectsTriangle = ( function () { +ExtendedTriangle.prototype.intersectsTriangle = ( function () { - const saTri2 = new ExtendedTriangle$1(); + const saTri2 = new ExtendedTriangle(); const arr1 = new Array( 3 ); const arr2 = new Array( 3 ); - const cachedSatBounds = new SeparatingAxisBounds$1(); - const cachedSatBounds2 = new SeparatingAxisBounds$1(); + const cachedSatBounds = new SeparatingAxisBounds(); + const cachedSatBounds2 = new SeparatingAxisBounds(); const cachedAxis = new Vector3(); const dir = new Vector3(); const dir1 = new Vector3(); @@ -5523,8 +5525,8 @@ ExtendedTriangle$1.prototype.intersectsTriangle = ( function () { end.copy( points[ ( i + 1 ) % 3 ] ); edge.delta( dir ); - const startIntersects = isNearZero$1( plane.distanceToPoint( start ) ); - if ( isNearZero$1( plane.normal.dot( dir ) ) && startIntersects ) { + const startIntersects = isNearZero( plane.distanceToPoint( start ) ); + if ( isNearZero( plane.normal.dot( dir ) ) && startIntersects ) { // if the edge lies on the plane then take the line targetEdge.copy( edge ); @@ -5542,7 +5544,7 @@ ExtendedTriangle$1.prototype.intersectsTriangle = ( function () { } // ignore the end point - if ( ( doesIntersect || startIntersects ) && ! isNearZero$1( tempPoint.distanceTo( end ) ) ) { + if ( ( doesIntersect || startIntersects ) && ! isNearZero( tempPoint.distanceTo( end ) ) ) { if ( count <= 1 ) { @@ -5772,7 +5774,7 @@ ExtendedTriangle$1.prototype.intersectsTriangle = ( function () { } )(); -ExtendedTriangle$1.prototype.distanceToPoint = ( function () { +ExtendedTriangle.prototype.distanceToPoint = ( function () { const target = new Vector3(); return function distanceToPoint( point ) { @@ -5785,7 +5787,7 @@ ExtendedTriangle$1.prototype.distanceToPoint = ( function () { } )(); -ExtendedTriangle$1.prototype.distanceToTriangle = ( function () { +ExtendedTriangle.prototype.distanceToTriangle = ( function () { const point = new Vector3(); const point2 = new Vector3(); @@ -5856,7 +5858,7 @@ ExtendedTriangle$1.prototype.distanceToTriangle = ( function () { const f22 = cornerFields[ ( i2 + 1 ) % 3 ]; line2.set( other[ f21 ], other[ f22 ] ); - closestPointsSegmentToSegment$1( line1, line2, point, point2 ); + closestPointsSegmentToSegment( line1, line2, point, point2 ); const dist = point.distanceToSquared( point2 ); if ( dist < closestDistanceSq ) { @@ -5877,7 +5879,7 @@ ExtendedTriangle$1.prototype.distanceToTriangle = ( function () { } )(); -let OrientedBox$1 = class OrientedBox { +class OrientedBox { constructor( min, max, matrix ) { @@ -5888,8 +5890,8 @@ let OrientedBox$1 = class OrientedBox { this.invMatrix = new Matrix4(); this.points = new Array( 8 ).fill().map( () => new Vector3() ); this.satAxes = new Array( 3 ).fill().map( () => new Vector3() ); - this.satBounds = new Array( 3 ).fill().map( () => new SeparatingAxisBounds$1() ); - this.alignedSatBounds = new Array( 3 ).fill().map( () => new SeparatingAxisBounds$1() ); + this.satBounds = new Array( 3 ).fill().map( () => new SeparatingAxisBounds() ); + this.alignedSatBounds = new Array( 3 ).fill().map( () => new SeparatingAxisBounds() ); this.needsUpdate = false; if ( min ) this.min.copy( min ); @@ -5916,9 +5918,9 @@ let OrientedBox$1 = class OrientedBox { } -}; +} -OrientedBox$1.prototype.update = ( function () { +OrientedBox.prototype.update = ( function () { return function update() { @@ -5974,9 +5976,9 @@ OrientedBox$1.prototype.update = ( function () { } )(); -OrientedBox$1.prototype.intersectsBox = ( function () { +OrientedBox.prototype.intersectsBox = ( function () { - const aabbBounds = new SeparatingAxisBounds$1(); + const aabbBounds = new SeparatingAxisBounds(); return function intersectsBox( box ) { // TODO: should this be doing SAT against the AABB? @@ -6019,12 +6021,12 @@ OrientedBox$1.prototype.intersectsBox = ( function () { } )(); -OrientedBox$1.prototype.intersectsTriangle = ( function () { +OrientedBox.prototype.intersectsTriangle = ( function () { - const saTri = new ExtendedTriangle$1(); + const saTri = new ExtendedTriangle(); const pointsArr = new Array( 3 ); - const cachedSatBounds = new SeparatingAxisBounds$1(); - const cachedSatBounds2 = new SeparatingAxisBounds$1(); + const cachedSatBounds = new SeparatingAxisBounds(); + const cachedSatBounds2 = new SeparatingAxisBounds(); const cachedAxis = new Vector3(); return function intersectsTriangle( triangle ) { @@ -6096,7 +6098,7 @@ OrientedBox$1.prototype.intersectsTriangle = ( function () { } )(); -OrientedBox$1.prototype.closestPointToPoint = ( function () { +OrientedBox.prototype.closestPointToPoint = ( function () { return function closestPointToPoint( point, target1 ) { @@ -6118,7 +6120,7 @@ OrientedBox$1.prototype.closestPointToPoint = ( function () { } )(); -OrientedBox$1.prototype.distanceToPoint = ( function () { +OrientedBox.prototype.distanceToPoint = ( function () { const target = new Vector3(); return function distanceToPoint( point ) { @@ -6130,7 +6132,7 @@ OrientedBox$1.prototype.distanceToPoint = ( function () { } )(); -OrientedBox$1.prototype.distanceToBox = ( function () { +OrientedBox.prototype.distanceToBox = ( function () { const xyzFields = [ 'x', 'y', 'z' ]; const segments1 = new Array( 12 ).fill().map( () => new Line3() ); @@ -6272,7 +6274,7 @@ OrientedBox$1.prototype.distanceToBox = ( function () { for ( let i2 = 0; i2 < 12; i2 ++ ) { const l2 = segments2[ i2 ]; - closestPointsSegmentToSegment$1( l1, l2, point1, point2 ); + closestPointsSegmentToSegment( l1, l2, point1, point2 ); const dist = point1.distanceToSquared( point2 ); if ( dist < closestDistanceSq ) { @@ -6294,7 +6296,7 @@ OrientedBox$1.prototype.distanceToBox = ( function () { } )(); -let PrimitivePool$1 = class PrimitivePool { +class PrimitivePool { constructor( getNewPrimitive ) { @@ -6324,13 +6326,13 @@ let PrimitivePool$1 = class PrimitivePool { } -}; +} -class ExtendedTrianglePoolBase extends PrimitivePool$1 { +class ExtendedTrianglePoolBase extends PrimitivePool { constructor() { - super( () => new ExtendedTriangle$1() ); + super( () => new ExtendedTriangle() ); } @@ -6338,43 +6340,43 @@ class ExtendedTrianglePoolBase extends PrimitivePool$1 { const ExtendedTrianglePool = /* @__PURE__ */ new ExtendedTrianglePoolBase(); -function IS_LEAF$1( n16, uint16Array ) { +function IS_LEAF( n16, uint16Array ) { return uint16Array[ n16 + 15 ] === 0xFFFF; } -function OFFSET$1( n32, uint32Array ) { +function OFFSET( n32, uint32Array ) { return uint32Array[ n32 + 6 ]; } -function COUNT$1( n16, uint16Array ) { +function COUNT( n16, uint16Array ) { return uint16Array[ n16 + 14 ]; } -function LEFT_NODE$1( n32 ) { +function LEFT_NODE( n32 ) { return n32 + 8; } -function RIGHT_NODE$1( n32, uint32Array ) { +function RIGHT_NODE( n32, uint32Array ) { return uint32Array[ n32 + 6 ]; } -function SPLIT_AXIS$1( n32, uint32Array ) { +function SPLIT_AXIS( n32, uint32Array ) { return uint32Array[ n32 + 7 ]; } -function BOUNDING_DATA_INDEX$1( n32 ) { +function BOUNDING_DATA_INDEX( n32 ) { return n32; @@ -6428,9 +6430,9 @@ const BufferStack = new _BufferStack(); let _box1, _box2; const boxStack = []; -const boxPool = /* @__PURE__ */ new PrimitivePool$1( () => new Box3() ); +const boxPool = /* @__PURE__ */ new PrimitivePool( () => new Box3() ); -function shapecast$1( bvh, root, intersectsBounds, intersectsRange, boundsTraverseOrder, byteOffset ) { +function shapecast( bvh, root, intersectsBounds, intersectsRange, boundsTraverseOrder, byteOffset ) { // setup _box1 = boxPool.getPrimitive(); @@ -6472,18 +6474,18 @@ function shapecastTraverse( const { float32Array, uint16Array, uint32Array } = BufferStack; let nodeIndex16 = nodeIndex32 * 2; - const isLeaf = IS_LEAF$1( nodeIndex16, uint16Array ); + const isLeaf = IS_LEAF( nodeIndex16, uint16Array ); if ( isLeaf ) { - const offset = OFFSET$1( nodeIndex32, uint32Array ); - const count = COUNT$1( nodeIndex16, uint16Array ); - arrayToBox$1( BOUNDING_DATA_INDEX$1( nodeIndex32 ), float32Array, _box1 ); + const offset = OFFSET( nodeIndex32, uint32Array ); + const count = COUNT( nodeIndex16, uint16Array ); + arrayToBox( BOUNDING_DATA_INDEX( nodeIndex32 ), float32Array, _box1 ); return intersectsRangeFunc( offset, count, false, depth, nodeIndexByteOffset + nodeIndex32, _box1 ); } else { - const left = LEFT_NODE$1( nodeIndex32 ); - const right = RIGHT_NODE$1( nodeIndex32, uint32Array ); + const left = LEFT_NODE( nodeIndex32 ); + const right = RIGHT_NODE( nodeIndex32, uint32Array ); let c1 = left; let c2 = right; @@ -6495,8 +6497,8 @@ function shapecastTraverse( box2 = _box2; // bounding data is not offset - arrayToBox$1( BOUNDING_DATA_INDEX$1( c1 ), float32Array, box1 ); - arrayToBox$1( BOUNDING_DATA_INDEX$1( c2 ), float32Array, box2 ); + arrayToBox( BOUNDING_DATA_INDEX( c1 ), float32Array, box1 ); + arrayToBox( BOUNDING_DATA_INDEX( c2 ), float32Array, box2 ); score1 = nodeScoreFunc( box1 ); score2 = nodeScoreFunc( box2 ); @@ -6521,15 +6523,15 @@ function shapecastTraverse( if ( ! box1 ) { box1 = _box1; - arrayToBox$1( BOUNDING_DATA_INDEX$1( c1 ), float32Array, box1 ); + arrayToBox( BOUNDING_DATA_INDEX( c1 ), float32Array, box1 ); } - const isC1Leaf = IS_LEAF$1( c1 * 2, uint16Array ); + const isC1Leaf = IS_LEAF( c1 * 2, uint16Array ); const c1Intersection = intersectsBoundsFunc( box1, isC1Leaf, score1, depth + 1, nodeIndexByteOffset + c1 ); let c1StopTraversal; - if ( c1Intersection === CONTAINED$1 ) { + if ( c1Intersection === CONTAINED ) { const offset = getLeftOffset( c1 ); const end = getRightEndOffset( c1 ); @@ -6558,13 +6560,13 @@ function shapecastTraverse( // Check box 2 intersection // cached box2 will have been overwritten by previous traversal box2 = _box2; - arrayToBox$1( BOUNDING_DATA_INDEX$1( c2 ), float32Array, box2 ); + arrayToBox( BOUNDING_DATA_INDEX( c2 ), float32Array, box2 ); - const isC2Leaf = IS_LEAF$1( c2 * 2, uint16Array ); + const isC2Leaf = IS_LEAF( c2 * 2, uint16Array ); const c2Intersection = intersectsBoundsFunc( box2, isC2Leaf, score2, depth + 1, nodeIndexByteOffset + c2 ); let c2StopTraversal; - if ( c2Intersection === CONTAINED$1 ) { + if ( c2Intersection === CONTAINED ) { const offset = getLeftOffset( c2 ); const end = getRightEndOffset( c2 ); @@ -6600,14 +6602,14 @@ function shapecastTraverse( let nodeIndex16 = nodeIndex32 * 2; // traverse until we find a leaf - while ( ! IS_LEAF$1( nodeIndex16, uint16Array ) ) { + while ( ! IS_LEAF( nodeIndex16, uint16Array ) ) { - nodeIndex32 = LEFT_NODE$1( nodeIndex32 ); + nodeIndex32 = LEFT_NODE( nodeIndex32 ); nodeIndex16 = nodeIndex32 * 2; } - return OFFSET$1( nodeIndex32, uint32Array ); + return OFFSET( nodeIndex32, uint32Array ); } @@ -6617,16 +6619,16 @@ function shapecastTraverse( let nodeIndex16 = nodeIndex32 * 2; // traverse until we find a leaf - while ( ! IS_LEAF$1( nodeIndex16, uint16Array ) ) { + while ( ! IS_LEAF( nodeIndex16, uint16Array ) ) { // adjust offset to point to the right node - nodeIndex32 = RIGHT_NODE$1( nodeIndex32, uint32Array ); + nodeIndex32 = RIGHT_NODE( nodeIndex32, uint32Array ); nodeIndex16 = nodeIndex32 * 2; } // return the end offset of the triangle range - return OFFSET$1( nodeIndex32, uint32Array ) + COUNT$1( nodeIndex16, uint16Array ); + return OFFSET( nodeIndex32, uint32Array ) + COUNT( nodeIndex16, uint16Array ); } @@ -6634,8 +6636,8 @@ function shapecastTraverse( } -const temp$1 = /* @__PURE__ */ new Vector3(); -const temp1$3 = /* @__PURE__ */ new Vector3(); +const temp = /* @__PURE__ */ new Vector3(); +const temp1$2 = /* @__PURE__ */ new Vector3(); function closestPointToPoint( bvh, @@ -6659,8 +6661,8 @@ function closestPointToPoint( boundsTraverseOrder: box => { - temp$1.copy( point ).clamp( box.min, box.max ); - return temp$1.distanceToSquared( point ); + temp.copy( point ).clamp( box.min, box.max ); + return temp.distanceToSquared( point ); }, @@ -6672,11 +6674,11 @@ function closestPointToPoint( intersectsTriangle: ( tri, triIndex ) => { - tri.closestPointToPoint( point, temp$1 ); - const distSq = point.distanceToSquared( temp$1 ); + tri.closestPointToPoint( point, temp ); + const distSq = point.distanceToSquared( temp ); if ( distSq < closestDistanceSq ) { - temp1$3.copy( temp$1 ); + temp1$2.copy( temp ); closestDistanceSq = distSq; closestDistanceTriIndex = triIndex; @@ -6702,8 +6704,8 @@ function closestPointToPoint( const closestDistance = Math.sqrt( closestDistanceSq ); - if ( ! target.point ) target.point = temp1$3.clone(); - else target.point.copy( temp1$3 ); + if ( ! target.point ) target.point = temp1$2.clone(); + else target.point.copy( temp1$2 ); target.distance = closestDistance, target.faceIndex = closestDistanceTriIndex; @@ -6713,20 +6715,20 @@ function closestPointToPoint( // Ripped and modified From THREE.js Mesh raycast // https://github.com/mrdoob/three.js/blob/0aa87c999fe61e216c1133fba7a95772b503eddf/src/objects/Mesh.js#L115 -const _vA$1 = /* @__PURE__ */ new Vector3(); -const _vB$1 = /* @__PURE__ */ new Vector3(); -const _vC$1 = /* @__PURE__ */ new Vector3(); +const _vA = /* @__PURE__ */ new Vector3(); +const _vB = /* @__PURE__ */ new Vector3(); +const _vC = /* @__PURE__ */ new Vector3(); -const _uvA$1 = /* @__PURE__ */ new Vector2(); -const _uvB$1 = /* @__PURE__ */ new Vector2(); -const _uvC$1 = /* @__PURE__ */ new Vector2(); +const _uvA = /* @__PURE__ */ new Vector2(); +const _uvB = /* @__PURE__ */ new Vector2(); +const _uvC = /* @__PURE__ */ new Vector2(); -const _normalA$1 = /* @__PURE__ */ new Vector3(); -const _normalB$1 = /* @__PURE__ */ new Vector3(); -const _normalC$1 = /* @__PURE__ */ new Vector3(); +const _normalA = /* @__PURE__ */ new Vector3(); +const _normalB = /* @__PURE__ */ new Vector3(); +const _normalC = /* @__PURE__ */ new Vector3(); -const _intersectionPoint$1 = /* @__PURE__ */ new Vector3(); -function checkIntersection$1( ray, pA, pB, pC, point, side ) { +const _intersectionPoint = /* @__PURE__ */ new Vector3(); +function checkIntersection( ray, pA, pB, pC, point, side ) { let intersect; if ( side === BackSide ) { @@ -6752,43 +6754,43 @@ function checkIntersection$1( ray, pA, pB, pC, point, side ) { } -function checkBufferGeometryIntersection$1( ray, position, normal, uv, uv1, a, b, c, side ) { +function checkBufferGeometryIntersection( ray, position, normal, uv, uv1, a, b, c, side ) { - _vA$1.fromBufferAttribute( position, a ); - _vB$1.fromBufferAttribute( position, b ); - _vC$1.fromBufferAttribute( position, c ); + _vA.fromBufferAttribute( position, a ); + _vB.fromBufferAttribute( position, b ); + _vC.fromBufferAttribute( position, c ); - const intersection = checkIntersection$1( ray, _vA$1, _vB$1, _vC$1, _intersectionPoint$1, side ); + const intersection = checkIntersection( ray, _vA, _vB, _vC, _intersectionPoint, side ); if ( intersection ) { if ( uv ) { - _uvA$1.fromBufferAttribute( uv, a ); - _uvB$1.fromBufferAttribute( uv, b ); - _uvC$1.fromBufferAttribute( uv, c ); + _uvA.fromBufferAttribute( uv, a ); + _uvB.fromBufferAttribute( uv, b ); + _uvC.fromBufferAttribute( uv, c ); - intersection.uv = Triangle.getInterpolation( _intersectionPoint$1, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2() ); + intersection.uv = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() ); } if ( uv1 ) { - _uvA$1.fromBufferAttribute( uv1, a ); - _uvB$1.fromBufferAttribute( uv1, b ); - _uvC$1.fromBufferAttribute( uv1, c ); + _uvA.fromBufferAttribute( uv1, a ); + _uvB.fromBufferAttribute( uv1, b ); + _uvC.fromBufferAttribute( uv1, c ); - intersection.uv1 = Triangle.getInterpolation( _intersectionPoint$1, _vA$1, _vB$1, _vC$1, _uvA$1, _uvB$1, _uvC$1, new Vector2() ); + intersection.uv1 = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() ); } if ( normal ) { - _normalA$1.fromBufferAttribute( normal, a ); - _normalB$1.fromBufferAttribute( normal, b ); - _normalC$1.fromBufferAttribute( normal, c ); + _normalA.fromBufferAttribute( normal, a ); + _normalB.fromBufferAttribute( normal, b ); + _normalC.fromBufferAttribute( normal, c ); - intersection.normal = Triangle.getInterpolation( _intersectionPoint$1, _vA$1, _vB$1, _vC$1, _normalA$1, _normalB$1, _normalC$1, new Vector3() ); + intersection.normal = Triangle.getInterpolation( _intersectionPoint, _vA, _vB, _vC, _normalA, _normalB, _normalC, new Vector3() ); if ( intersection.normal.dot( ray.direction ) > 0 ) { intersection.normal.multiplyScalar( - 1 ); @@ -6805,7 +6807,7 @@ function checkBufferGeometryIntersection$1( ray, position, normal, uv, uv1, a, b materialIndex: 0 }; - Triangle.getNormal( _vA$1, _vB$1, _vC$1, face.normal ); + Triangle.getNormal( _vA, _vB, _vC, face.normal ); intersection.face = face; intersection.faceIndex = a; @@ -6817,7 +6819,7 @@ function checkBufferGeometryIntersection$1( ray, position, normal, uv, uv1, a, b } // https://github.com/mrdoob/three.js/blob/0aa87c999fe61e216c1133fba7a95772b503eddf/src/objects/Mesh.js#L258 -function intersectTri$1( geo, side, ray, tri, intersections ) { +function intersectTri( geo, side, ray, tri, intersections ) { const triOffset = tri * 3; let a = triOffset + 0; @@ -6834,7 +6836,7 @@ function intersectTri$1( geo, side, ray, tri, intersections ) { } const { position, normal, uv, uv1 } = geo.attributes; - const intersection = checkBufferGeometryIntersection$1( ray, position, normal, uv, uv1, a, b, c, side ); + const intersection = checkBufferGeometryIntersection( ray, position, normal, uv, uv1, a, b, c, side ); if ( intersection ) { @@ -6849,7 +6851,7 @@ function intersectTri$1( geo, side, ray, tri, intersections ) { } // sets the vertices of triangle `tri` with the 3 vertices after i -function setTriangle$1( tri, i, index, pos ) { +function setTriangle( tri, i, index, pos ) { const ta = tri.a; const tb = tri.b; @@ -6885,20 +6887,20 @@ function setTriangle$1( tri, i, index, pos ) { /*************************************************************/ /* eslint-disable indent */ -function intersectTris$1( bvh, side, ray, offset, count, intersections ) { +function intersectTris( bvh, side, ray, offset, count, intersections ) { const { geometry, _indirectBuffer } = bvh; for ( let i = offset, end = offset + count; i < end; i ++ ) { - intersectTri$1( geometry, side, ray, i, intersections ); + intersectTri( geometry, side, ray, i, intersections ); } } -function intersectClosestTri$1( bvh, side, ray, offset, count ) { +function intersectClosestTri( bvh, side, ray, offset, count ) { const { geometry, _indirectBuffer } = bvh; let dist = Infinity; @@ -6907,7 +6909,7 @@ function intersectClosestTri$1( bvh, side, ray, offset, count ) { let intersection; - intersection = intersectTri$1( geometry, side, ray, i ); + intersection = intersectTri( geometry, side, ray, i ); if ( intersection && intersection.distance < dist ) { @@ -6923,7 +6925,7 @@ function intersectClosestTri$1( bvh, side, ray, offset, count ) { } -function iterateOverTriangles$1( +function iterateOverTriangles( offset, count, bvh, @@ -6942,7 +6944,7 @@ function iterateOverTriangles$1( tri = i; - setTriangle$1( triangle, tri * 3, index, pos ); + setTriangle( triangle, tri * 3, index, pos ); triangle.needsUpdate = true; if ( intersectsTriangleFunc( triangle, tri, contained, depth ) ) { @@ -6991,7 +6993,7 @@ function refit( bvh, nodeIndices = null ) { function _traverse( node32Index, byteOffset, force = false ) { const node16Index = node32Index * 2; - const isLeaf = uint16Array[ node16Index + 15 ] === IS_LEAFNODE_FLAG$1; + const isLeaf = uint16Array[ node16Index + 15 ] === IS_LEAFNODE_FLAG; if ( isLeaf ) { const offset = uint32Array[ node32Index + 6 ]; @@ -7127,9 +7129,9 @@ function refit( bvh, nodeIndices = null ) { } const _boundingBox = /* @__PURE__ */ new Box3(); -function intersectRay$1( nodeIndex32, array, ray, target ) { +function intersectRay( nodeIndex32, array, ray, target ) { - arrayToBox$1( nodeIndex32, array, _boundingBox ); + arrayToBox( nodeIndex32, array, _boundingBox ); return ray.intersectBox( _boundingBox, target ); } @@ -7145,7 +7147,7 @@ function intersectTris_indirect( bvh, side, ray, offset, count, intersections ) for ( let i = offset, end = offset + count; i < end; i ++ ) { let vi = _indirectBuffer ? _indirectBuffer[ i ] : i; - intersectTri$1( geometry, side, ray, vi, intersections ); + intersectTri( geometry, side, ray, vi, intersections ); } @@ -7160,7 +7162,7 @@ function intersectClosestTri_indirect( bvh, side, ray, offset, count ) { for ( let i = offset, end = offset + count; i < end; i ++ ) { let intersection; - intersection = intersectTri$1( geometry, side, ray, _indirectBuffer ? _indirectBuffer[ i ] : i ); + intersection = intersectTri( geometry, side, ray, _indirectBuffer ? _indirectBuffer[ i ] : i ); if ( intersection && intersection.distance < dist ) { @@ -7194,7 +7196,7 @@ function iterateOverTriangles_indirect( let tri; tri = bvh.resolveTriangleIndex( i ); - setTriangle$1( triangle, tri * 3, index, pos ); + setTriangle( triangle, tri * 3, index, pos ); triangle.needsUpdate = true; if ( intersectsTriangleFunc( triangle, tri, contained, depth ) ) { @@ -7214,7 +7216,7 @@ function iterateOverTriangles_indirect( /******************************************************/ const _boxIntersection$3 = /* @__PURE__ */ new Vector3(); -function raycast$1( bvh, root, side, ray, intersects ) { +function raycast( bvh, root, side, ray, intersects ) { BufferStack.setBuffer( bvh._roots[ root ] ); _raycast$1( 0, bvh, side, ray, intersects ); @@ -7226,27 +7228,27 @@ function _raycast$1( nodeIndex32, bvh, side, ray, intersects ) { const { float32Array, uint16Array, uint32Array } = BufferStack; const nodeIndex16 = nodeIndex32 * 2; - const isLeaf = IS_LEAF$1( nodeIndex16, uint16Array ); + const isLeaf = IS_LEAF( nodeIndex16, uint16Array ); if ( isLeaf ) { - const offset = OFFSET$1( nodeIndex32, uint32Array ); - const count = COUNT$1( nodeIndex16, uint16Array ); + const offset = OFFSET( nodeIndex32, uint32Array ); + const count = COUNT( nodeIndex16, uint16Array ); - intersectTris$1( bvh, side, ray, offset, count, intersects ); + intersectTris( bvh, side, ray, offset, count, intersects ); } else { - const leftIndex = LEFT_NODE$1( nodeIndex32 ); - if ( intersectRay$1( leftIndex, float32Array, ray, _boxIntersection$3 ) ) { + const leftIndex = LEFT_NODE( nodeIndex32 ); + if ( intersectRay( leftIndex, float32Array, ray, _boxIntersection$3 ) ) { _raycast$1( leftIndex, bvh, side, ray, intersects ); } - const rightIndex = RIGHT_NODE$1( nodeIndex32, uint32Array ); - if ( intersectRay$1( rightIndex, float32Array, ray, _boxIntersection$3 ) ) { + const rightIndex = RIGHT_NODE( nodeIndex32, uint32Array ); + if ( intersectRay( rightIndex, float32Array, ray, _boxIntersection$3 ) ) { _raycast$1( rightIndex, bvh, side, ray, intersects ); @@ -7261,7 +7263,7 @@ function _raycast$1( nodeIndex32, bvh, side, ray, intersects ) { /***********************************************************/ const _boxIntersection$2 = /* @__PURE__ */ new Vector3(); const _xyzFields$1 = [ 'x', 'y', 'z' ]; -function raycastFirst$1( bvh, root, side, ray ) { +function raycastFirst( bvh, root, side, ray ) { BufferStack.setBuffer( bvh._roots[ root ] ); const result = _raycastFirst$1( 0, bvh, side, ray ); @@ -7276,21 +7278,21 @@ function _raycastFirst$1( nodeIndex32, bvh, side, ray ) { const { float32Array, uint16Array, uint32Array } = BufferStack; let nodeIndex16 = nodeIndex32 * 2; - const isLeaf = IS_LEAF$1( nodeIndex16, uint16Array ); + const isLeaf = IS_LEAF( nodeIndex16, uint16Array ); if ( isLeaf ) { - const offset = OFFSET$1( nodeIndex32, uint32Array ); - const count = COUNT$1( nodeIndex16, uint16Array ); + const offset = OFFSET( nodeIndex32, uint32Array ); + const count = COUNT( nodeIndex16, uint16Array ); - return intersectClosestTri$1( bvh, side, ray, offset, count ); + return intersectClosestTri( bvh, side, ray, offset, count ); } else { // consider the position of the split plane with respect to the oncoming ray; whichever direction // the ray is coming from, look for an intersection among that side of the tree first - const splitAxis = SPLIT_AXIS$1( nodeIndex32, uint32Array ); + const splitAxis = SPLIT_AXIS( nodeIndex32, uint32Array ); const xyzAxis = _xyzFields$1[ splitAxis ]; const rayDir = ray.direction[ xyzAxis ]; const leftToRight = rayDir >= 0; @@ -7299,17 +7301,17 @@ function _raycastFirst$1( nodeIndex32, bvh, side, ray ) { let c1, c2; if ( leftToRight ) { - c1 = LEFT_NODE$1( nodeIndex32 ); - c2 = RIGHT_NODE$1( nodeIndex32, uint32Array ); + c1 = LEFT_NODE( nodeIndex32 ); + c2 = RIGHT_NODE( nodeIndex32, uint32Array ); } else { - c1 = RIGHT_NODE$1( nodeIndex32, uint32Array ); - c2 = LEFT_NODE$1( nodeIndex32 ); + c1 = RIGHT_NODE( nodeIndex32, uint32Array ); + c2 = LEFT_NODE( nodeIndex32 ); } - const c1Intersection = intersectRay$1( c1, float32Array, ray, _boxIntersection$2 ); + const c1Intersection = intersectRay( c1, float32Array, ray, _boxIntersection$2 ); const c1Result = c1Intersection ? _raycastFirst$1( c1, bvh, side, ray ) : null; // if we got an intersection in the first node and it's closer than the second node's bounding @@ -7333,7 +7335,7 @@ function _raycastFirst$1( nodeIndex32, bvh, side, ray ) { // either there was no intersection in the first node, or there could still be a closer // intersection in the second, so check the second node and then take the better of the two - const c2Intersection = intersectRay$1( c2, float32Array, ray, _boxIntersection$2 ); + const c2Intersection = intersectRay( c2, float32Array, ray, _boxIntersection$2 ); const c2Result = c2Intersection ? _raycastFirst$1( c2, bvh, side, ray ) : null; if ( c1Result && c2Result ) { @@ -7355,15 +7357,15 @@ function _raycastFirst$1( nodeIndex32, bvh, side, ray ) { /*****************************************************************/ /* eslint-disable indent */ -const boundingBox$2 = /* @__PURE__ */ new Box3(); -const triangle$1 = /* @__PURE__ */ new ExtendedTriangle$1(); -const triangle2$1 = /* @__PURE__ */ new ExtendedTriangle$1(); +const boundingBox$1 = /* @__PURE__ */ new Box3(); +const triangle$1 = /* @__PURE__ */ new ExtendedTriangle(); +const triangle2$1 = /* @__PURE__ */ new ExtendedTriangle(); const invertedMat$1 = /* @__PURE__ */ new Matrix4(); -const obb$5 = /* @__PURE__ */ new OrientedBox$1(); -const obb2$4 = /* @__PURE__ */ new OrientedBox$1(); +const obb$4 = /* @__PURE__ */ new OrientedBox(); +const obb2$3 = /* @__PURE__ */ new OrientedBox(); -function intersectsGeometry$1( bvh, root, otherGeometry, geometryToBvh ) { +function intersectsGeometry( bvh, root, otherGeometry, geometryToBvh ) { BufferStack.setBuffer( bvh._roots[ root ] ); const result = _intersectsGeometry$1( 0, bvh, otherGeometry, geometryToBvh ); @@ -7386,12 +7388,12 @@ function _intersectsGeometry$1( nodeIndex32, bvh, otherGeometry, geometryToBvh, } - obb$5.set( otherGeometry.boundingBox.min, otherGeometry.boundingBox.max, geometryToBvh ); - cachedObb = obb$5; + obb$4.set( otherGeometry.boundingBox.min, otherGeometry.boundingBox.max, geometryToBvh ); + cachedObb = obb$4; } - const isLeaf = IS_LEAF$1( nodeIndex16, uint16Array ); + const isLeaf = IS_LEAF( nodeIndex16, uint16Array ); if ( isLeaf ) { const thisGeometry = bvh.geometry; @@ -7401,8 +7403,8 @@ function _intersectsGeometry$1( nodeIndex32, bvh, otherGeometry, geometryToBvh, const index = otherGeometry.index; const pos = otherGeometry.attributes.position; - const offset = OFFSET$1( nodeIndex32, uint32Array ); - const count = COUNT$1( nodeIndex16, uint16Array ); + const offset = OFFSET( nodeIndex32, uint32Array ); + const count = COUNT( nodeIndex16, uint16Array ); // get the inverse of the geometry matrix so we can transform our triangles into the // geometry space we're trying to test. We assume there are fewer triangles being checked @@ -7412,14 +7414,14 @@ function _intersectsGeometry$1( nodeIndex32, bvh, otherGeometry, geometryToBvh, if ( otherGeometry.boundsTree ) { // if there's a bounds tree - arrayToBox$1( BOUNDING_DATA_INDEX$1( nodeIndex32 ), float32Array, obb2$4 ); - obb2$4.matrix.copy( invertedMat$1 ); - obb2$4.needsUpdate = true; + arrayToBox( BOUNDING_DATA_INDEX( nodeIndex32 ), float32Array, obb2$3 ); + obb2$3.matrix.copy( invertedMat$1 ); + obb2$3.needsUpdate = true; // TODO: use a triangle iteration function here const res = otherGeometry.boundsTree.shapecast( { - intersectsBounds: box => obb2$4.intersectsBox( box ), + intersectsBounds: box => obb2$3.intersectsBox( box ), intersectsTriangle: tri => { @@ -7432,7 +7434,7 @@ function _intersectsGeometry$1( nodeIndex32, bvh, otherGeometry, geometryToBvh, for ( let i = offset * 3, l = ( count + offset ) * 3; i < l; i += 3 ) { // this triangle needs to be transformed into the current BVH coordinate frame - setTriangle$1( triangle2$1, i, thisIndex, thisPos ); + setTriangle( triangle2$1, i, thisIndex, thisPos ); triangle2$1.needsUpdate = true; if ( tri.intersectsTriangle( triangle2$1 ) ) { @@ -7458,7 +7460,7 @@ function _intersectsGeometry$1( nodeIndex32, bvh, otherGeometry, geometryToBvh, for ( let i = offset * 3, l = ( count + offset ) * 3; i < l; i += 3 ) { // this triangle needs to be transformed into the current BVH coordinate frame - setTriangle$1( triangle$1, i, thisIndex, thisPos ); + setTriangle( triangle$1, i, thisIndex, thisPos ); triangle$1.a.applyMatrix4( invertedMat$1 ); @@ -7468,7 +7470,7 @@ function _intersectsGeometry$1( nodeIndex32, bvh, otherGeometry, geometryToBvh, for ( let i2 = 0, l2 = index.count; i2 < l2; i2 += 3 ) { - setTriangle$1( triangle2$1, i2, index, pos ); + setTriangle( triangle2$1, i2, index, pos ); triangle2$1.needsUpdate = true; if ( triangle$1.intersectsTriangle( triangle2$1 ) ) { @@ -7490,16 +7492,16 @@ function _intersectsGeometry$1( nodeIndex32, bvh, otherGeometry, geometryToBvh, const left = nodeIndex32 + 8; const right = uint32Array[ nodeIndex32 + 6 ]; - arrayToBox$1( BOUNDING_DATA_INDEX$1( left ), float32Array, boundingBox$2 ); + arrayToBox( BOUNDING_DATA_INDEX( left ), float32Array, boundingBox$1 ); const leftIntersection = - cachedObb.intersectsBox( boundingBox$2 ) && + cachedObb.intersectsBox( boundingBox$1 ) && _intersectsGeometry$1( left, bvh, otherGeometry, geometryToBvh, cachedObb ); if ( leftIntersection ) return true; - arrayToBox$1( BOUNDING_DATA_INDEX$1( right ), float32Array, boundingBox$2 ); + arrayToBox( BOUNDING_DATA_INDEX( right ), float32Array, boundingBox$1 ); const rightIntersection = - cachedObb.intersectsBox( boundingBox$2 ) && + cachedObb.intersectsBox( boundingBox$1 ) && _intersectsGeometry$1( right, bvh, otherGeometry, geometryToBvh, cachedObb ); if ( rightIntersection ) return true; @@ -7514,13 +7516,13 @@ function _intersectsGeometry$1( nodeIndex32, bvh, otherGeometry, geometryToBvh, /* This file is generated from "closestPointToGeometry.template.js". */ /*********************************************************************/ -const tempMatrix$2 = /* @__PURE__ */ new Matrix4(); -const obb$4 = /* @__PURE__ */ new OrientedBox$1(); -const obb2$3 = /* @__PURE__ */ new OrientedBox$1(); -const temp1$2 = /* @__PURE__ */ new Vector3(); -const temp2$2 = /* @__PURE__ */ new Vector3(); -const temp3$2 = /* @__PURE__ */ new Vector3(); -const temp4$2 = /* @__PURE__ */ new Vector3(); +const tempMatrix$1 = /* @__PURE__ */ new Matrix4(); +const obb$3 = /* @__PURE__ */ new OrientedBox(); +const obb2$2 = /* @__PURE__ */ new OrientedBox(); +const temp1$1 = /* @__PURE__ */ new Vector3(); +const temp2$1 = /* @__PURE__ */ new Vector3(); +const temp3$1 = /* @__PURE__ */ new Vector3(); +const temp4$1 = /* @__PURE__ */ new Vector3(); function closestPointToGeometry( bvh, @@ -7538,8 +7540,8 @@ function closestPointToGeometry( } - obb$4.set( otherGeometry.boundingBox.min, otherGeometry.boundingBox.max, geometryToBvh ); - obb$4.needsUpdate = true; + obb$3.set( otherGeometry.boundingBox.min, otherGeometry.boundingBox.max, geometryToBvh ); + obb$3.needsUpdate = true; const geometry = bvh.geometry; const pos = geometry.attributes.position; @@ -7549,29 +7551,29 @@ function closestPointToGeometry( const triangle = ExtendedTrianglePool.getPrimitive(); const triangle2 = ExtendedTrianglePool.getPrimitive(); - let tempTarget1 = temp1$2; - let tempTargetDest1 = temp2$2; + let tempTarget1 = temp1$1; + let tempTargetDest1 = temp2$1; let tempTarget2 = null; let tempTargetDest2 = null; if ( target2 ) { - tempTarget2 = temp3$2; - tempTargetDest2 = temp4$2; + tempTarget2 = temp3$1; + tempTargetDest2 = temp4$1; } let closestDistance = Infinity; let closestDistanceTriIndex = null; let closestDistanceOtherTriIndex = null; - tempMatrix$2.copy( geometryToBvh ).invert(); - obb2$3.matrix.copy( tempMatrix$2 ); + tempMatrix$1.copy( geometryToBvh ).invert(); + obb2$2.matrix.copy( tempMatrix$1 ); bvh.shapecast( { boundsTraverseOrder: box => { - return obb$4.distanceToBox( box ); + return obb$3.distanceToBox( box ); }, @@ -7583,9 +7585,9 @@ function closestPointToGeometry( // save the bounds to use during triangle checks. if ( isLeaf ) { - obb2$3.min.copy( box.min ); - obb2$3.max.copy( box.max ); - obb2$3.needsUpdate = true; + obb2$2.min.copy( box.min ); + obb2$2.max.copy( box.max ); + obb2$2.needsUpdate = true; } @@ -7607,7 +7609,7 @@ function closestPointToGeometry( return otherBvh.shapecast( { boundsTraverseOrder: box => { - return obb2$3.distanceToBox( box ); + return obb2$2.distanceToBox( box ); }, @@ -7622,7 +7624,7 @@ function closestPointToGeometry( for ( let i2 = otherOffset, l2 = otherOffset + otherCount; i2 < l2; i2 ++ ) { - setTriangle$1( triangle2, 3 * i2, otherIndex, otherPos ); + setTriangle( triangle2, 3 * i2, otherIndex, otherPos ); triangle2.a.applyMatrix4( geometryToBvh ); triangle2.b.applyMatrix4( geometryToBvh ); @@ -7632,7 +7634,7 @@ function closestPointToGeometry( for ( let i = offset, l = offset + count; i < l; i ++ ) { - setTriangle$1( triangle, 3 * i, index, pos ); + setTriangle( triangle, 3 * i, index, pos ); triangle.needsUpdate = true; @@ -7673,7 +7675,7 @@ function closestPointToGeometry( const triCount = getTriCount( otherGeometry ); for ( let i2 = 0, l2 = triCount; i2 < l2; i2 ++ ) { - setTriangle$1( triangle2, 3 * i2, otherIndex, otherPos ); + setTriangle( triangle2, 3 * i2, otherIndex, otherPos ); triangle2.a.applyMatrix4( geometryToBvh ); triangle2.b.applyMatrix4( geometryToBvh ); triangle2.c.applyMatrix4( geometryToBvh ); @@ -7682,7 +7684,7 @@ function closestPointToGeometry( for ( let i = offset, l = offset + count; i < l; i ++ ) { - setTriangle$1( triangle, 3 * i, index, pos ); + setTriangle( triangle, 3 * i, index, pos ); triangle.needsUpdate = true; @@ -7748,8 +7750,8 @@ function closestPointToGeometry( if ( ! target2.point ) target2.point = tempTargetDest2.clone(); else target2.point.copy( tempTargetDest2 ); - target2.point.applyMatrix4( tempMatrix$2 ); - tempTargetDest1.applyMatrix4( tempMatrix$2 ); + target2.point.applyMatrix4( tempMatrix$1 ); + tempTargetDest1.applyMatrix4( tempMatrix$1 ); target2.distance = tempTargetDest1.sub( target2.point ).length(); target2.faceIndex = closestDistanceOtherTriIndex; @@ -7793,7 +7795,7 @@ function refit_indirect( bvh, nodeIndices = null ) { function _traverse( node32Index, byteOffset, force = false ) { const node16Index = node32Index * 2; - const isLeaf = uint16Array[ node16Index + 15 ] === IS_LEAFNODE_FLAG$1; + const isLeaf = uint16Array[ node16Index + 15 ] === IS_LEAFNODE_FLAG; if ( isLeaf ) { const offset = uint32Array[ node32Index + 6 ]; @@ -7952,26 +7954,26 @@ function _raycast( nodeIndex32, bvh, side, ray, intersects ) { const { float32Array, uint16Array, uint32Array } = BufferStack; const nodeIndex16 = nodeIndex32 * 2; - const isLeaf = IS_LEAF$1( nodeIndex16, uint16Array ); + const isLeaf = IS_LEAF( nodeIndex16, uint16Array ); if ( isLeaf ) { - const offset = OFFSET$1( nodeIndex32, uint32Array ); - const count = COUNT$1( nodeIndex16, uint16Array ); + const offset = OFFSET( nodeIndex32, uint32Array ); + const count = COUNT( nodeIndex16, uint16Array ); intersectTris_indirect( bvh, side, ray, offset, count, intersects ); } else { - const leftIndex = LEFT_NODE$1( nodeIndex32 ); - if ( intersectRay$1( leftIndex, float32Array, ray, _boxIntersection$1 ) ) { + const leftIndex = LEFT_NODE( nodeIndex32 ); + if ( intersectRay( leftIndex, float32Array, ray, _boxIntersection$1 ) ) { _raycast( leftIndex, bvh, side, ray, intersects ); } - const rightIndex = RIGHT_NODE$1( nodeIndex32, uint32Array ); - if ( intersectRay$1( rightIndex, float32Array, ray, _boxIntersection$1 ) ) { + const rightIndex = RIGHT_NODE( nodeIndex32, uint32Array ); + if ( intersectRay( rightIndex, float32Array, ray, _boxIntersection$1 ) ) { _raycast( rightIndex, bvh, side, ray, intersects ); @@ -8001,11 +8003,11 @@ function _raycastFirst( nodeIndex32, bvh, side, ray ) { const { float32Array, uint16Array, uint32Array } = BufferStack; let nodeIndex16 = nodeIndex32 * 2; - const isLeaf = IS_LEAF$1( nodeIndex16, uint16Array ); + const isLeaf = IS_LEAF( nodeIndex16, uint16Array ); if ( isLeaf ) { - const offset = OFFSET$1( nodeIndex32, uint32Array ); - const count = COUNT$1( nodeIndex16, uint16Array ); + const offset = OFFSET( nodeIndex32, uint32Array ); + const count = COUNT( nodeIndex16, uint16Array ); return intersectClosestTri_indirect( bvh, side, ray, offset, count ); @@ -8014,7 +8016,7 @@ function _raycastFirst( nodeIndex32, bvh, side, ray ) { // consider the position of the split plane with respect to the oncoming ray; whichever direction // the ray is coming from, look for an intersection among that side of the tree first - const splitAxis = SPLIT_AXIS$1( nodeIndex32, uint32Array ); + const splitAxis = SPLIT_AXIS( nodeIndex32, uint32Array ); const xyzAxis = _xyzFields[ splitAxis ]; const rayDir = ray.direction[ xyzAxis ]; const leftToRight = rayDir >= 0; @@ -8023,17 +8025,17 @@ function _raycastFirst( nodeIndex32, bvh, side, ray ) { let c1, c2; if ( leftToRight ) { - c1 = LEFT_NODE$1( nodeIndex32 ); - c2 = RIGHT_NODE$1( nodeIndex32, uint32Array ); + c1 = LEFT_NODE( nodeIndex32 ); + c2 = RIGHT_NODE( nodeIndex32, uint32Array ); } else { - c1 = RIGHT_NODE$1( nodeIndex32, uint32Array ); - c2 = LEFT_NODE$1( nodeIndex32 ); + c1 = RIGHT_NODE( nodeIndex32, uint32Array ); + c2 = LEFT_NODE( nodeIndex32 ); } - const c1Intersection = intersectRay$1( c1, float32Array, ray, _boxIntersection ); + const c1Intersection = intersectRay( c1, float32Array, ray, _boxIntersection ); const c1Result = c1Intersection ? _raycastFirst( c1, bvh, side, ray ) : null; // if we got an intersection in the first node and it's closer than the second node's bounding @@ -8057,7 +8059,7 @@ function _raycastFirst( nodeIndex32, bvh, side, ray ) { // either there was no intersection in the first node, or there could still be a closer // intersection in the second, so check the second node and then take the better of the two - const c2Intersection = intersectRay$1( c2, float32Array, ray, _boxIntersection ); + const c2Intersection = intersectRay( c2, float32Array, ray, _boxIntersection ); const c2Result = c2Intersection ? _raycastFirst( c2, bvh, side, ray ) : null; if ( c1Result && c2Result ) { @@ -8079,13 +8081,13 @@ function _raycastFirst( nodeIndex32, bvh, side, ray ) { /*****************************************************************/ /* eslint-disable indent */ -const boundingBox$1 = /* @__PURE__ */ new Box3(); -const triangle = /* @__PURE__ */ new ExtendedTriangle$1(); -const triangle2 = /* @__PURE__ */ new ExtendedTriangle$1(); +const boundingBox = /* @__PURE__ */ new Box3(); +const triangle = /* @__PURE__ */ new ExtendedTriangle(); +const triangle2 = /* @__PURE__ */ new ExtendedTriangle(); const invertedMat = /* @__PURE__ */ new Matrix4(); -const obb$3 = /* @__PURE__ */ new OrientedBox$1(); -const obb2$2 = /* @__PURE__ */ new OrientedBox$1(); +const obb$2 = /* @__PURE__ */ new OrientedBox(); +const obb2$1 = /* @__PURE__ */ new OrientedBox(); function intersectsGeometry_indirect( bvh, root, otherGeometry, geometryToBvh ) { @@ -8110,12 +8112,12 @@ function _intersectsGeometry( nodeIndex32, bvh, otherGeometry, geometryToBvh, ca } - obb$3.set( otherGeometry.boundingBox.min, otherGeometry.boundingBox.max, geometryToBvh ); - cachedObb = obb$3; + obb$2.set( otherGeometry.boundingBox.min, otherGeometry.boundingBox.max, geometryToBvh ); + cachedObb = obb$2; } - const isLeaf = IS_LEAF$1( nodeIndex16, uint16Array ); + const isLeaf = IS_LEAF( nodeIndex16, uint16Array ); if ( isLeaf ) { const thisGeometry = bvh.geometry; @@ -8125,8 +8127,8 @@ function _intersectsGeometry( nodeIndex32, bvh, otherGeometry, geometryToBvh, ca const index = otherGeometry.index; const pos = otherGeometry.attributes.position; - const offset = OFFSET$1( nodeIndex32, uint32Array ); - const count = COUNT$1( nodeIndex16, uint16Array ); + const offset = OFFSET( nodeIndex32, uint32Array ); + const count = COUNT( nodeIndex16, uint16Array ); // get the inverse of the geometry matrix so we can transform our triangles into the // geometry space we're trying to test. We assume there are fewer triangles being checked @@ -8136,14 +8138,14 @@ function _intersectsGeometry( nodeIndex32, bvh, otherGeometry, geometryToBvh, ca if ( otherGeometry.boundsTree ) { // if there's a bounds tree - arrayToBox$1( BOUNDING_DATA_INDEX$1( nodeIndex32 ), float32Array, obb2$2 ); - obb2$2.matrix.copy( invertedMat ); - obb2$2.needsUpdate = true; + arrayToBox( BOUNDING_DATA_INDEX( nodeIndex32 ), float32Array, obb2$1 ); + obb2$1.matrix.copy( invertedMat ); + obb2$1.needsUpdate = true; // TODO: use a triangle iteration function here const res = otherGeometry.boundsTree.shapecast( { - intersectsBounds: box => obb2$2.intersectsBox( box ), + intersectsBounds: box => obb2$1.intersectsBox( box ), intersectsTriangle: tri => { @@ -8155,7 +8157,7 @@ function _intersectsGeometry( nodeIndex32, bvh, otherGeometry, geometryToBvh, ca for ( let i = offset, l = count + offset; i < l; i ++ ) { // this triangle needs to be transformed into the current BVH coordinate frame - setTriangle$1( triangle2, 3 * bvh.resolveTriangleIndex( i ), thisIndex, thisPos ); + setTriangle( triangle2, 3 * bvh.resolveTriangleIndex( i ), thisIndex, thisPos ); triangle2.needsUpdate = true; if ( tri.intersectsTriangle( triangle2 ) ) { @@ -8181,7 +8183,7 @@ function _intersectsGeometry( nodeIndex32, bvh, otherGeometry, geometryToBvh, ca // this triangle needs to be transformed into the current BVH coordinate frame const ti = bvh.resolveTriangleIndex( i ); - setTriangle$1( triangle, 3 * ti, thisIndex, thisPos ); + setTriangle( triangle, 3 * ti, thisIndex, thisPos ); triangle.a.applyMatrix4( invertedMat ); @@ -8191,7 +8193,7 @@ function _intersectsGeometry( nodeIndex32, bvh, otherGeometry, geometryToBvh, ca for ( let i2 = 0, l2 = index.count; i2 < l2; i2 += 3 ) { - setTriangle$1( triangle2, i2, index, pos ); + setTriangle( triangle2, i2, index, pos ); triangle2.needsUpdate = true; if ( triangle.intersectsTriangle( triangle2 ) ) { @@ -8212,16 +8214,16 @@ function _intersectsGeometry( nodeIndex32, bvh, otherGeometry, geometryToBvh, ca const left = nodeIndex32 + 8; const right = uint32Array[ nodeIndex32 + 6 ]; - arrayToBox$1( BOUNDING_DATA_INDEX$1( left ), float32Array, boundingBox$1 ); + arrayToBox( BOUNDING_DATA_INDEX( left ), float32Array, boundingBox ); const leftIntersection = - cachedObb.intersectsBox( boundingBox$1 ) && + cachedObb.intersectsBox( boundingBox ) && _intersectsGeometry( left, bvh, otherGeometry, geometryToBvh, cachedObb ); if ( leftIntersection ) return true; - arrayToBox$1( BOUNDING_DATA_INDEX$1( right ), float32Array, boundingBox$1 ); + arrayToBox( BOUNDING_DATA_INDEX( right ), float32Array, boundingBox ); const rightIntersection = - cachedObb.intersectsBox( boundingBox$1 ) && + cachedObb.intersectsBox( boundingBox ) && _intersectsGeometry( right, bvh, otherGeometry, geometryToBvh, cachedObb ); if ( rightIntersection ) return true; @@ -8236,13 +8238,13 @@ function _intersectsGeometry( nodeIndex32, bvh, otherGeometry, geometryToBvh, ca /* This file is generated from "closestPointToGeometry.template.js". */ /*********************************************************************/ -const tempMatrix$1 = /* @__PURE__ */ new Matrix4(); -const obb$2 = /* @__PURE__ */ new OrientedBox$1(); -const obb2$1 = /* @__PURE__ */ new OrientedBox$1(); -const temp1$1 = /* @__PURE__ */ new Vector3(); -const temp2$1 = /* @__PURE__ */ new Vector3(); -const temp3$1 = /* @__PURE__ */ new Vector3(); -const temp4$1 = /* @__PURE__ */ new Vector3(); +const tempMatrix = /* @__PURE__ */ new Matrix4(); +const obb$1 = /* @__PURE__ */ new OrientedBox(); +const obb2 = /* @__PURE__ */ new OrientedBox(); +const temp1 = /* @__PURE__ */ new Vector3(); +const temp2 = /* @__PURE__ */ new Vector3(); +const temp3 = /* @__PURE__ */ new Vector3(); +const temp4 = /* @__PURE__ */ new Vector3(); function closestPointToGeometry_indirect( bvh, @@ -8260,8 +8262,8 @@ function closestPointToGeometry_indirect( } - obb$2.set( otherGeometry.boundingBox.min, otherGeometry.boundingBox.max, geometryToBvh ); - obb$2.needsUpdate = true; + obb$1.set( otherGeometry.boundingBox.min, otherGeometry.boundingBox.max, geometryToBvh ); + obb$1.needsUpdate = true; const geometry = bvh.geometry; const pos = geometry.attributes.position; @@ -8271,29 +8273,29 @@ function closestPointToGeometry_indirect( const triangle = ExtendedTrianglePool.getPrimitive(); const triangle2 = ExtendedTrianglePool.getPrimitive(); - let tempTarget1 = temp1$1; - let tempTargetDest1 = temp2$1; + let tempTarget1 = temp1; + let tempTargetDest1 = temp2; let tempTarget2 = null; let tempTargetDest2 = null; if ( target2 ) { - tempTarget2 = temp3$1; - tempTargetDest2 = temp4$1; + tempTarget2 = temp3; + tempTargetDest2 = temp4; } let closestDistance = Infinity; let closestDistanceTriIndex = null; let closestDistanceOtherTriIndex = null; - tempMatrix$1.copy( geometryToBvh ).invert(); - obb2$1.matrix.copy( tempMatrix$1 ); + tempMatrix.copy( geometryToBvh ).invert(); + obb2.matrix.copy( tempMatrix ); bvh.shapecast( { boundsTraverseOrder: box => { - return obb$2.distanceToBox( box ); + return obb$1.distanceToBox( box ); }, @@ -8305,9 +8307,9 @@ function closestPointToGeometry_indirect( // save the bounds to use during triangle checks. if ( isLeaf ) { - obb2$1.min.copy( box.min ); - obb2$1.max.copy( box.max ); - obb2$1.needsUpdate = true; + obb2.min.copy( box.min ); + obb2.max.copy( box.max ); + obb2.needsUpdate = true; } @@ -8329,7 +8331,7 @@ function closestPointToGeometry_indirect( return otherBvh.shapecast( { boundsTraverseOrder: box => { - return obb2$1.distanceToBox( box ); + return obb2.distanceToBox( box ); }, @@ -8344,7 +8346,7 @@ function closestPointToGeometry_indirect( for ( let i2 = otherOffset, l2 = otherOffset + otherCount; i2 < l2; i2 ++ ) { const ti2 = otherBvh.resolveTriangleIndex( i2 ); - setTriangle$1( triangle2, 3 * ti2, otherIndex, otherPos ); + setTriangle( triangle2, 3 * ti2, otherIndex, otherPos ); triangle2.a.applyMatrix4( geometryToBvh ); triangle2.b.applyMatrix4( geometryToBvh ); @@ -8354,7 +8356,7 @@ function closestPointToGeometry_indirect( for ( let i = offset, l = offset + count; i < l; i ++ ) { const ti = bvh.resolveTriangleIndex( i ); - setTriangle$1( triangle, 3 * ti, index, pos ); + setTriangle( triangle, 3 * ti, index, pos ); triangle.needsUpdate = true; @@ -8395,7 +8397,7 @@ function closestPointToGeometry_indirect( const triCount = getTriCount( otherGeometry ); for ( let i2 = 0, l2 = triCount; i2 < l2; i2 ++ ) { - setTriangle$1( triangle2, 3 * i2, otherIndex, otherPos ); + setTriangle( triangle2, 3 * i2, otherIndex, otherPos ); triangle2.a.applyMatrix4( geometryToBvh ); triangle2.b.applyMatrix4( geometryToBvh ); triangle2.c.applyMatrix4( geometryToBvh ); @@ -8404,7 +8406,7 @@ function closestPointToGeometry_indirect( for ( let i = offset, l = offset + count; i < l; i ++ ) { const ti = bvh.resolveTriangleIndex( i ); - setTriangle$1( triangle, 3 * ti, index, pos ); + setTriangle( triangle, 3 * ti, index, pos ); triangle.needsUpdate = true; @@ -8470,8 +8472,8 @@ function closestPointToGeometry_indirect( if ( ! target2.point ) target2.point = tempTargetDest2.clone(); else target2.point.copy( tempTargetDest2 ); - target2.point.applyMatrix4( tempMatrix$1 ); - tempTargetDest1.applyMatrix4( tempMatrix$1 ); + target2.point.applyMatrix4( tempMatrix ); + tempTargetDest1.applyMatrix4( tempMatrix ); target2.distance = tempTargetDest1.sub( target2.point ).length(); target2.faceIndex = closestDistanceOtherTriIndex; @@ -8489,7 +8491,7 @@ function isSharedArrayBufferSupported() { const _bufferStack1 = new BufferStack.constructor(); const _bufferStack2 = new BufferStack.constructor(); -const _boxPool = new PrimitivePool$1( () => new Box3() ); +const _boxPool = new PrimitivePool( () => new Box3() ); const _leftBox1 = new Box3(); const _rightBox1 = new Box3(); @@ -8523,7 +8525,7 @@ function bvhcast( bvh, otherBvh, matrixToLocal, intersectsRanges ) { // prep the initial root box const localBox = _boxPool.getPrimitive(); - arrayToBox$1( BOUNDING_DATA_INDEX$1( 0 ), _bufferStack1.float32Array, localBox ); + arrayToBox( BOUNDING_DATA_INDEX( 0 ), _bufferStack1.float32Array, localBox ); localBox.applyMatrix4( invMat ); // iterate over the second set of roots @@ -8611,8 +8613,8 @@ function _traverse( const node1Index16 = node1Index32 * 2; const node2Index16 = node2Index32 * 2; - const isLeaf1 = IS_LEAF$1( node1Index16, uint16Array1 ); - const isLeaf2 = IS_LEAF$1( node2Index16, uint16Array2 ); + const isLeaf1 = IS_LEAF( node1Index16, uint16Array1 ); + const isLeaf2 = IS_LEAF( node2Index16, uint16Array2 ); let result = false; if ( isLeaf2 && isLeaf1 ) { @@ -8620,8 +8622,8 @@ function _traverse( if ( reversed ) { result = intersectsRangesFunc( - OFFSET$1( node2Index32, uint32Array2 ), COUNT$1( node2Index32 * 2, uint16Array2 ), - OFFSET$1( node1Index32, uint32Array1 ), COUNT$1( node1Index32 * 2, uint16Array1 ), + OFFSET( node2Index32, uint32Array2 ), COUNT( node2Index32 * 2, uint16Array2 ), + OFFSET( node1Index32, uint32Array1 ), COUNT( node1Index32 * 2, uint16Array1 ), depth2, node2IndexByteOffset + node2Index32, depth1, node1IndexByteOffset + node1Index32, ); @@ -8629,8 +8631,8 @@ function _traverse( } else { result = intersectsRangesFunc( - OFFSET$1( node1Index32, uint32Array1 ), COUNT$1( node1Index32 * 2, uint16Array1 ), - OFFSET$1( node2Index32, uint32Array2 ), COUNT$1( node2Index32 * 2, uint16Array2 ), + OFFSET( node1Index32, uint32Array1 ), COUNT( node1Index32 * 2, uint16Array1 ), + OFFSET( node2Index32, uint32Array2 ), COUNT( node2Index32 * 2, uint16Array2 ), depth1, node1IndexByteOffset + node1Index32, depth2, node2IndexByteOffset + node2Index32, ); @@ -8645,14 +8647,14 @@ function _traverse( // get the new box to use const newBox = _boxPool.getPrimitive(); - arrayToBox$1( BOUNDING_DATA_INDEX$1( node2Index32 ), float32Array2, newBox ); + arrayToBox( BOUNDING_DATA_INDEX( node2Index32 ), float32Array2, newBox ); newBox.applyMatrix4( matrix2to1 ); // get the child bounds to check before traversal - const cl1 = LEFT_NODE$1( node1Index32 ); - const cr1 = RIGHT_NODE$1( node1Index32, uint32Array1 ); - arrayToBox$1( BOUNDING_DATA_INDEX$1( cl1 ), float32Array1, _leftBox1 ); - arrayToBox$1( BOUNDING_DATA_INDEX$1( cr1 ), float32Array1, _rightBox1 ); + const cl1 = LEFT_NODE( node1Index32 ); + const cr1 = RIGHT_NODE( node1Index32, uint32Array1 ); + arrayToBox( BOUNDING_DATA_INDEX( cl1 ), float32Array1, _leftBox1 ); + arrayToBox( BOUNDING_DATA_INDEX( cr1 ), float32Array1, _rightBox1 ); // precompute the intersections otherwise the global boxes will be modified during traversal const intersectCl1 = newBox.intersectsBox( _leftBox1 ); @@ -8679,10 +8681,10 @@ function _traverse( // intersect with the current bounds // get the child bounds to check - const cl2 = LEFT_NODE$1( node2Index32 ); - const cr2 = RIGHT_NODE$1( node2Index32, uint32Array2 ); - arrayToBox$1( BOUNDING_DATA_INDEX$1( cl2 ), float32Array2, _leftBox2 ); - arrayToBox$1( BOUNDING_DATA_INDEX$1( cr2 ), float32Array2, _rightBox2 ); + const cl2 = LEFT_NODE( node2Index32 ); + const cr2 = RIGHT_NODE( node2Index32, uint32Array2 ); + arrayToBox( BOUNDING_DATA_INDEX( cl2 ), float32Array2, _leftBox2 ); + arrayToBox( BOUNDING_DATA_INDEX( cr2 ), float32Array2, _rightBox2 ); const leftIntersects = currBox.intersectsBox( _leftBox2 ); const rightIntersects = currBox.intersectsBox( _rightBox2 ); @@ -8717,10 +8719,10 @@ function _traverse( const newBox = _boxPool.getPrimitive(); newBox.copy( _leftBox2 ).applyMatrix4( matrix2to1 ); - const cl1 = LEFT_NODE$1( node1Index32 ); - const cr1 = RIGHT_NODE$1( node1Index32, uint32Array1 ); - arrayToBox$1( BOUNDING_DATA_INDEX$1( cl1 ), float32Array1, _leftBox1 ); - arrayToBox$1( BOUNDING_DATA_INDEX$1( cr1 ), float32Array1, _rightBox1 ); + const cl1 = LEFT_NODE( node1Index32 ); + const cr1 = RIGHT_NODE( node1Index32, uint32Array1 ); + arrayToBox( BOUNDING_DATA_INDEX( cl1 ), float32Array1, _leftBox1 ); + arrayToBox( BOUNDING_DATA_INDEX( cr1 ), float32Array1, _rightBox1 ); // precompute the intersections otherwise the global boxes will be modified during traversal const intersectCl1 = newBox.intersectsBox( _leftBox1 ); @@ -8761,10 +8763,10 @@ function _traverse( const newBox = _boxPool.getPrimitive(); newBox.copy( _rightBox2 ).applyMatrix4( matrix2to1 ); - const cl1 = LEFT_NODE$1( node1Index32 ); - const cr1 = RIGHT_NODE$1( node1Index32, uint32Array1 ); - arrayToBox$1( BOUNDING_DATA_INDEX$1( cl1 ), float32Array1, _leftBox1 ); - arrayToBox$1( BOUNDING_DATA_INDEX$1( cr1 ), float32Array1, _rightBox1 ); + const cl1 = LEFT_NODE( node1Index32 ); + const cr1 = RIGHT_NODE( node1Index32, uint32Array1 ); + arrayToBox( BOUNDING_DATA_INDEX( cl1 ), float32Array1, _leftBox1 ); + arrayToBox( BOUNDING_DATA_INDEX( cr1 ), float32Array1, _rightBox1 ); // precompute the intersections otherwise the global boxes will be modified during traversal const intersectCl1 = newBox.intersectsBox( _leftBox1 ); @@ -8795,10 +8797,10 @@ function _traverse( } -const obb$1 = /* @__PURE__ */ new OrientedBox$1(); -const tempBox$1 = /* @__PURE__ */ new Box3(); +const obb = /* @__PURE__ */ new OrientedBox(); +const tempBox = /* @__PURE__ */ new Box3(); -let MeshBVH$1 = class MeshBVH { +class MeshBVH { static serialize( bvh, options = {} ) { @@ -8843,7 +8845,7 @@ let MeshBVH$1 = class MeshBVH { }; const { index, roots, indirectBuffer } = data; - const bvh = new MeshBVH( geometry, { ...options, [ SKIP_GENERATION$1 ]: true } ); + const bvh = new MeshBVH( geometry, { ...options, [ SKIP_GENERATION ]: true } ); bvh._roots = roots; bvh._indirectBuffer = indirectBuffer || null; @@ -8889,7 +8891,7 @@ let MeshBVH$1 = class MeshBVH { // default options options = Object.assign( { - strategy: CENTER$1, + strategy: CENTER, maxDepth: 40, maxLeafTris: 10, verbose: true, @@ -8901,7 +8903,7 @@ let MeshBVH$1 = class MeshBVH { // undocumented options // Whether to skip generating the tree. Used for deserialization. - [ SKIP_GENERATION$1 ]: false, + [ SKIP_GENERATION ]: false, }, options ); @@ -8916,9 +8918,9 @@ let MeshBVH$1 = class MeshBVH { this.geometry = geometry; this._roots = null; this._indirectBuffer = null; - if ( ! options[ SKIP_GENERATION$1 ] ) { + if ( ! options[ SKIP_GENERATION ] ) { - buildPackedTree$1( this, options ); + buildPackedTree( this, options ); if ( ! geometry.boundingBox && options.setBoundingBox ) { @@ -8950,7 +8952,7 @@ let MeshBVH$1 = class MeshBVH { function _traverse( node32Index, depth = 0 ) { const node16Index = node32Index * 2; - const isLeaf = uint16Array[ node16Index + 15 ] === IS_LEAFNODE_FLAG$1; + const isLeaf = uint16Array[ node16Index + 15 ] === IS_LEAFNODE_FLAG; if ( isLeaf ) { const offset = uint32Array[ node32Index + 6 ]; @@ -8960,7 +8962,7 @@ let MeshBVH$1 = class MeshBVH { } else { // TODO: use node functions here - const left = node32Index + BYTES_PER_NODE$1 / 4; + const left = node32Index + BYTES_PER_NODE / 4; const right = uint32Array[ node32Index + 6 ]; const splitAxis = uint32Array[ node32Index + 7 ]; const stopTraversal = callback( depth, isLeaf, new Float32Array( buffer, node32Index * 4, 6 ), splitAxis ); @@ -8989,7 +8991,7 @@ let MeshBVH$1 = class MeshBVH { const groups = geometry.groups; const side = isMaterial ? materialOrSide.side : materialOrSide; - const raycastFunc = this.indirect ? raycast_indirect : raycast$1; + const raycastFunc = this.indirect ? raycast_indirect : raycast; for ( let i = 0, l = roots.length; i < l; i ++ ) { const materialSide = isArrayMaterial ? materialOrSide[ groups[ i ].materialIndex ].side : side; @@ -9025,7 +9027,7 @@ let MeshBVH$1 = class MeshBVH { const groups = geometry.groups; const side = isMaterial ? materialOrSide.side : materialOrSide; - const raycastFirstFunc = this.indirect ? raycastFirst_indirect : raycastFirst$1; + const raycastFirstFunc = this.indirect ? raycastFirst_indirect : raycastFirst; for ( let i = 0, l = roots.length; i < l; i ++ ) { const materialSide = isArrayMaterial ? materialOrSide[ groups[ i ].materialIndex ].side : side; @@ -9051,7 +9053,7 @@ let MeshBVH$1 = class MeshBVH { let result = false; const roots = this._roots; - const intersectsGeometryFunc = this.indirect ? intersectsGeometry_indirect : intersectsGeometry$1; + const intersectsGeometryFunc = this.indirect ? intersectsGeometry_indirect : intersectsGeometry; for ( let i = 0, l = roots.length; i < l; i ++ ) { result = intersectsGeometryFunc( this, i, otherGeometry, geomToMesh ); @@ -9071,7 +9073,7 @@ let MeshBVH$1 = class MeshBVH { shapecast( callbacks ) { const triangle = ExtendedTrianglePool.getPrimitive(); - const iterateFunc = this.indirect ? iterateOverTriangles_indirect : iterateOverTriangles$1; + const iterateFunc = this.indirect ? iterateOverTriangles_indirect : iterateOverTriangles; let { boundsTraverseOrder, intersectsBounds, @@ -9124,7 +9126,7 @@ let MeshBVH$1 = class MeshBVH { for ( let i = 0, l = roots.length; i < l; i ++ ) { const root = roots[ i ]; - result = shapecast$1( this, i, intersectsBounds, intersectsRange, boundsTraverseOrder, byteOffset ); + result = shapecast( this, i, intersectsBounds, intersectsRange, boundsTraverseOrder, byteOffset ); if ( result ) { @@ -9157,12 +9159,12 @@ let MeshBVH$1 = class MeshBVH { const ti = this.resolveTriangleIndex( i1 ); - setTriangle$1( triangle1, ti * 3, indexAttr1, positionAttr1 ); + setTriangle( triangle1, ti * 3, indexAttr1, positionAttr1 ); } : i1 => { - setTriangle$1( triangle1, i1 * 3, indexAttr1, positionAttr1 ); + setTriangle( triangle1, i1 * 3, indexAttr1, positionAttr1 ); }; @@ -9173,12 +9175,12 @@ let MeshBVH$1 = class MeshBVH { i2 => { const ti2 = otherBvh.resolveTriangleIndex( i2 ); - setTriangle$1( triangle2, ti2 * 3, indexAttr2, positionAttr2 ); + setTriangle( triangle2, ti2 * 3, indexAttr2, positionAttr2 ); } : i2 => { - setTriangle$1( triangle2, i2 * 3, indexAttr2, positionAttr2 ); + setTriangle( triangle2, i2 * 3, indexAttr2, positionAttr2 ); }; @@ -9247,13 +9249,13 @@ let MeshBVH$1 = class MeshBVH { /* Derived Cast Functions */ intersectsBox( box, boxToMesh ) { - obb$1.set( box.min, box.max, boxToMesh ); - obb$1.needsUpdate = true; + obb.set( box.min, box.max, boxToMesh ); + obb.needsUpdate = true; return this.shapecast( { - intersectsBounds: box => obb$1.intersectsBox( box ), - intersectsTriangle: tri => obb$1.intersectsTriangle( tri ) + intersectsBounds: box => obb.intersectsBox( box ), + intersectsTriangle: tri => obb.intersectsTriangle( tri ) } ); @@ -9304,8 +9306,8 @@ let MeshBVH$1 = class MeshBVH { const roots = this._roots; roots.forEach( buffer => { - arrayToBox$1( 0, new Float32Array( buffer ), tempBox$1 ); - target.union( tempBox$1 ); + arrayToBox( 0, new Float32Array( buffer ), tempBox ); + target.union( tempBox ); } ); @@ -9313,11 +9315,11 @@ let MeshBVH$1 = class MeshBVH { } -}; +} // converts the given BVH raycast intersection to align with the three.js raycast // structure (include object, world space distance and point). -function convertRaycastIntersect$1( hit, object, raycaster ) { +function convertRaycastIntersect( hit, object, raycaster ) { if ( hit === null ) { @@ -9341,23 +9343,23 @@ function convertRaycastIntersect$1( hit, object, raycaster ) { } -const ray$1 = /* @__PURE__ */ new Ray(); -const tmpInverseMatrix$1 = /* @__PURE__ */ new Matrix4(); -const origMeshRaycastFunc$1 = Mesh.prototype.raycast; +const ray = /* @__PURE__ */ new Ray(); +const tmpInverseMatrix = /* @__PURE__ */ new Matrix4(); +const origMeshRaycastFunc = Mesh.prototype.raycast; -function acceleratedRaycast$1( raycaster, intersects ) { +function acceleratedRaycast( raycaster, intersects ) { if ( this.geometry.boundsTree ) { if ( this.material === undefined ) return; - tmpInverseMatrix$1.copy( this.matrixWorld ).invert(); - ray$1.copy( raycaster.ray ).applyMatrix4( tmpInverseMatrix$1 ); + tmpInverseMatrix.copy( this.matrixWorld ).invert(); + ray.copy( raycaster.ray ).applyMatrix4( tmpInverseMatrix ); const bvh = this.geometry.boundsTree; if ( raycaster.firstHitOnly === true ) { - const hit = convertRaycastIntersect$1( bvh.raycastFirst( ray$1, this.material ), this, raycaster ); + const hit = convertRaycastIntersect( bvh.raycastFirst( ray, this.material ), this, raycaster ); if ( hit ) { intersects.push( hit ); @@ -9366,10 +9368,10 @@ function acceleratedRaycast$1( raycaster, intersects ) { } else { - const hits = bvh.raycast( ray$1, this.material ); + const hits = bvh.raycast( ray, this.material ); for ( let i = 0, l = hits.length; i < l; i ++ ) { - const hit = convertRaycastIntersect$1( hits[ i ], this, raycaster ); + const hit = convertRaycastIntersect( hits[ i ], this, raycaster ); if ( hit ) { intersects.push( hit ); @@ -9382,20 +9384,20 @@ function acceleratedRaycast$1( raycaster, intersects ) { } else { - origMeshRaycastFunc$1.call( this, raycaster, intersects ); + origMeshRaycastFunc.call( this, raycaster, intersects ); } } -function computeBoundsTree$1( options ) { +function computeBoundsTree( options ) { - this.boundsTree = new MeshBVH$1( this, options ); + this.boundsTree = new MeshBVH( this, options ); return this.boundsTree; } -function disposeBoundsTree$1() { +function disposeBoundsTree() { this.boundsTree = null; @@ -11278,8 +11280,8 @@ class SimpleUIComponent extends Component { this._visible = true; this._active = false; this._components = components; - this.id = id !== null && id !== void 0 ? id : generateUUID(); - this.template = template !== null && template !== void 0 ? template : "
"; + this.id = id ?? generateUUID(); + this.template = template ?? "
"; } cleanData() { this.data = {}; @@ -11394,7 +11396,6 @@ class Toolbar extends SimpleUIComponent { return this._position; } constructor(components, options) { - var _a, _b; const _options = { position: "bottom", ...options, @@ -11405,8 +11406,8 @@ class Toolbar extends SimpleUIComponent { super(components, template); this.children = []; this._parent = null; - this.name = (_a = _options.name) !== null && _a !== void 0 ? _a : "Toolbar"; - this.position = (_b = _options.position) !== null && _b !== void 0 ? _b : "bottom"; + this.name = _options.name ?? "Toolbar"; + this.position = _options.position ?? "bottom"; this.visible = true; } get hasElements() { @@ -11498,7 +11499,6 @@ class Button extends SimpleUIComponent { return this.innerElements.customIcon.innerHTML; } constructor(components, options) { - var _a, _b, _c; const template = `