The native runtime for three.js: three.js, down to the metal. 45× smaller than Electron, on a Sony PS3, and path-traced at 60 fps on ray-tracing GPUs.
Rust electron-alternativegame-engineglobal-illuminationgraphicsjavascript-runtimemetalpath-tracingray-tracingreal-time-renderingrenderingrustthreejstypescriptvoxelvulkanwebgpuwgpu
Scene: Box3.containsBox, as three.js has it (#112)
Kevin Rajan9ea530f73562
diff --git a/packages/scene/src/math.ts b/packages/scene/src/math.tsindex 6e60ae2..de9dd72 100644--- a/packages/scene/src/math.ts+++ b/packages/scene/src/math.ts@@ -724,6 +724,11 @@ export class Box3 {containsPoint(p: Vector3): boolean {return p.x >= this.min.x && p.x <= this.max.x && p.y >= this.min.y && p.y <= this.max.y && p.z >= this.min.z && p.z <= this.max.z;}+ containsBox(b: Box3): boolean {+ return this.min.x <= b.min.x && b.max.x <= this.max.x &&+ this.min.y <= b.min.y && b.max.y <= this.max.y &&+ this.min.z <= b.min.z && b.max.z <= this.max.z;+ }intersectsBox(b: Box3): boolean {return b.max.x >= this.min.x && b.min.x <= this.max.x && b.max.y >= this.min.y && b.min.y <= this.max.y && b.max.z >= this.min.z && b.min.z <= this.max.z;}diff --git a/packages/scene/test/three-compat.test.ts b/packages/scene/test/three-compat.test.tsindex aa298ce..1f8fe93 100644--- a/packages/scene/test/three-compat.test.ts+++ b/packages/scene/test/three-compat.test.ts@@ -75,6 +75,20 @@ test("BufferGeometry: attributes, setIndex, groups, transforms and bounds as thr}});+test("Box3.containsBox: touching faces are contained but overlap alone is not, as three.js does", () => {+ const outer = new THREE.Box3(new THREE.Vector3(-2, -3, -4), new THREE.Vector3(4, 5, 6));+ const inside = new THREE.Box3(new THREE.Vector3(-2, -1, 0), new THREE.Vector3(3, 5, 6));+ const overlapping = new THREE.Box3(new THREE.Vector3(3, 0, 0), new THREE.Vector3(7, 2, 3));+ const separate = new THREE.Box3(new THREE.Vector3(7, 0, 0), new THREE.Vector3(8, 2, 3));++ assert.equal(outer.containsBox(inside), true, "inclusive on the min x and max y/z faces");+ assert.equal(outer.containsBox(overlapping), false, "one overlapping box extends past max x");+ assert.equal(outer.intersectsBox(overlapping), true, "overlap is not full containment");+ assert.equal(outer.containsBox(separate), false, "separated boxes are not contained");+ assert.equal(inside.containsBox(outer), false, "containment is directional");+ assert.equal(outer.containsBox(outer.clone()), true, "equal bounds contain one another");+});+test("vertex colours: the geometry's `color` attribute (RGB, RGBA, normalized bytes) to the engine, `vertexColors` on the material", () => {const scene = new THREE.Scene();const camera = new THREE.PerspectiveCamera();