Преглед изворни кода

Frustum: Honor sprite offset in `intersectsSprite()`. (#31307)

* Frustum: Honor sprite offset in `intersectsSprite()`.

* Frustum: Improve nomenclature.
Michael Herzog пре 6 месеци
родитељ
комит
f909f5dd05
1 измењених фајлова са 6 додато и 1 уклоњено
  1. 6 1
      src/math/Frustum.js

+ 6 - 1
src/math/Frustum.js

@@ -1,9 +1,11 @@
 import { WebGLCoordinateSystem, WebGPUCoordinateSystem } from '../constants.js';
+import { Vector2 } from './Vector2.js';
 import { Vector3 } from './Vector3.js';
 import { Sphere } from './Sphere.js';
 import { Plane } from './Plane.js';
 
 const _sphere = /*@__PURE__*/ new Sphere();
+const _defaultSpriteCenter = /*@__PURE__*/ new Vector2( 0.5, 0.5 );
 const _vector = /*@__PURE__*/ new Vector3();
 
 /**
@@ -161,7 +163,10 @@ class Frustum {
 	intersectsSprite( sprite ) {
 
 		_sphere.center.set( 0, 0, 0 );
-		_sphere.radius = 0.7071067811865476;
+
+		const offset = _defaultSpriteCenter.distanceTo( sprite.center );
+
+		_sphere.radius = 0.7071067811865476 + offset;
 		_sphere.applyMatrix4( sprite.matrixWorld );
 
 		return this.intersectsSphere( _sphere );

粤ICP备19079148号