Skip to content

Commit

Permalink
Merge pull request #82 from martinlaxenaire/develop
Browse files Browse the repository at this point in the history
Minor bugs fixes and improvements - v0.7.7
  • Loading branch information
martinlaxenaire committed Jun 27, 2024
2 parents 7383c3d + 4862104 commit 0830e51
Show file tree
Hide file tree
Showing 419 changed files with 4,242 additions and 4,242 deletions.
24 changes: 12 additions & 12 deletions dist/esm/core/DOM/DOMFrustum.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DOMFrustum {
}
}) {
this.boundingBox = boundingBox;
this.clipSpaceAABB = new Box3();
this.clipSpaceOBB = new Box3();
this.modelViewProjectionMatrix = modelViewProjectionMatrix;
this.containerBoundingRect = containerBoundingRect;
this.DOMFrustumMargins = { ...defaultDOMFrustumMargins, ...DOMFrustumMargins };
Expand Down Expand Up @@ -71,21 +71,21 @@ class DOMFrustum {
};
}
/**
* Compute the axis aligned bounding box in clip space.
* Compute the oriented bounding box in clip space.
*/
computeClipSpaceAABB() {
this.clipSpaceAABB.set();
this.boundingBox.applyMat4(this.modelViewProjectionMatrix, this.clipSpaceAABB);
computeClipSpaceOBB() {
this.clipSpaceOBB.set();
this.boundingBox.applyMat4(this.modelViewProjectionMatrix, this.clipSpaceOBB);
}
/**
* Applies all {@link modelViewProjectionMatrix} transformations to our {@link boundingBox}, i.e. apply AABB to document coordinates and set {@link projectedBoundingRect}.
* Applies all {@link modelViewProjectionMatrix} transformations to our {@link boundingBox}, i.e. apply OBB to document coordinates and set {@link projectedBoundingRect}.
*/
setDocumentCoordsFromClipSpaceAABB() {
this.computeClipSpaceAABB();
const minX = (this.clipSpaceAABB.min.x + 1) * 0.5;
const maxX = (this.clipSpaceAABB.max.x + 1) * 0.5;
const minY = 1 - (this.clipSpaceAABB.min.y + 1) * 0.5;
const maxY = 1 - (this.clipSpaceAABB.max.y + 1) * 0.5;
setDocumentCoordsFromClipSpaceOBB() {
this.computeClipSpaceOBB();
const minX = (this.clipSpaceOBB.min.x + 1) * 0.5;
const maxX = (this.clipSpaceOBB.max.x + 1) * 0.5;
const minY = 1 - (this.clipSpaceOBB.min.y + 1) * 0.5;
const maxY = 1 - (this.clipSpaceOBB.max.y + 1) * 0.5;
const { width, height, top, left } = this.containerBoundingRect;
this.projectedBoundingRect = {
left: minX * width + left,
Expand Down
4 changes: 2 additions & 2 deletions dist/esm/core/meshes/mixins/ProjectedMeshBaseMixin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import default_normal_fsWgsl from '../../shaders/chunks/default_normal_fs.wgsl.m

const defaultProjectedMeshParams = {
// frustum culling and visibility
frustumCulling: "AABB",
frustumCulling: "OBB",
DOMFrustumMargins: {
top: 0,
right: 0,
Expand Down Expand Up @@ -289,7 +289,7 @@ function ProjectedMeshBaseMixin(Base) {
if (this.frustumCulling === "sphere") {
this.domFrustum.setDocumentCoordsFromClipSpaceSphere(this.clipSpaceBoundingSphere);
} else {
this.domFrustum.setDocumentCoordsFromClipSpaceAABB();
this.domFrustum.setDocumentCoordsFromClipSpaceOBB();
}
this.domFrustum.intersectsContainer();
}
Expand Down
28 changes: 14 additions & 14 deletions dist/gpu-curtains.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -5954,7 +5954,7 @@
}
}) {
this.boundingBox = boundingBox;
this.clipSpaceAABB = new Box3();
this.clipSpaceOBB = new Box3();
this.modelViewProjectionMatrix = modelViewProjectionMatrix;
this.containerBoundingRect = containerBoundingRect;
this.DOMFrustumMargins = { ...defaultDOMFrustumMargins, ...DOMFrustumMargins };
Expand Down Expand Up @@ -5992,21 +5992,21 @@
};
}
/**
* Compute the axis aligned bounding box in clip space.
* Compute the oriented bounding box in clip space.
*/
computeClipSpaceAABB() {
this.clipSpaceAABB.set();
this.boundingBox.applyMat4(this.modelViewProjectionMatrix, this.clipSpaceAABB);
computeClipSpaceOBB() {
this.clipSpaceOBB.set();
this.boundingBox.applyMat4(this.modelViewProjectionMatrix, this.clipSpaceOBB);
}
/**
* Applies all {@link modelViewProjectionMatrix} transformations to our {@link boundingBox}, i.e. apply AABB to document coordinates and set {@link projectedBoundingRect}.
* Applies all {@link modelViewProjectionMatrix} transformations to our {@link boundingBox}, i.e. apply OBB to document coordinates and set {@link projectedBoundingRect}.
*/
setDocumentCoordsFromClipSpaceAABB() {
this.computeClipSpaceAABB();
const minX = (this.clipSpaceAABB.min.x + 1) * 0.5;
const maxX = (this.clipSpaceAABB.max.x + 1) * 0.5;
const minY = 1 - (this.clipSpaceAABB.min.y + 1) * 0.5;
const maxY = 1 - (this.clipSpaceAABB.max.y + 1) * 0.5;
setDocumentCoordsFromClipSpaceOBB() {
this.computeClipSpaceOBB();
const minX = (this.clipSpaceOBB.min.x + 1) * 0.5;
const maxX = (this.clipSpaceOBB.max.x + 1) * 0.5;
const minY = 1 - (this.clipSpaceOBB.min.y + 1) * 0.5;
const maxY = 1 - (this.clipSpaceOBB.max.y + 1) * 0.5;
const { width, height, top, left } = this.containerBoundingRect;
this.projectedBoundingRect = {
left: minX * width + left,
Expand Down Expand Up @@ -8022,7 +8022,7 @@ struct VSOutput {

const defaultProjectedMeshParams = {
// frustum culling and visibility
frustumCulling: "AABB",
frustumCulling: "OBB",
DOMFrustumMargins: {
top: 0,
right: 0,
Expand Down Expand Up @@ -8305,7 +8305,7 @@ struct VSOutput {
if (this.frustumCulling === "sphere") {
this.domFrustum.setDocumentCoordsFromClipSpaceSphere(this.clipSpaceBoundingSphere);
} else {
this.domFrustum.setDocumentCoordsFromClipSpaceAABB();
this.domFrustum.setDocumentCoordsFromClipSpaceOBB();
}
this.domFrustum.intersectsContainer();
}
Expand Down
16 changes: 8 additions & 8 deletions dist/gpu-curtains.umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/gpu-curtains.umd.min.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dist/types/core/DOM/DOMFrustum.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export interface DOMFrustumParams {
export declare class DOMFrustum {
/** Our 3D Object bounding box, i.e. size in world space before any transform. Usually defined by a {@link core/geometries/Geometry.Geometry | Geometry} */
boundingBox: Box3;
/** Axis aligned bounding {@link Box3} in clip space. */
clipSpaceAABB: Box3;
/** Oriented bounding {@link Box3} in clip space. */
clipSpaceOBB: Box3;
/** A model view projection matrix defining transformations, usually from a {@link core/objects3D/ProjectedObject3D.ProjectedObject3D | ProjectedObject3D}, to use for frustum calculations */
modelViewProjectionMatrix: Mat4;
/** The DOM bounding rectangle to check against, usually the renderer DOM Element bounding rectangle */
Expand Down Expand Up @@ -60,13 +60,13 @@ export declare class DOMFrustum {
*/
get DOMFrustumBoundingRect(): RectCoords;
/**
* Compute the axis aligned bounding box in clip space.
* Compute the oriented bounding box in clip space.
*/
computeClipSpaceAABB(): void;
computeClipSpaceOBB(): void;
/**
* Applies all {@link modelViewProjectionMatrix} transformations to our {@link boundingBox}, i.e. apply AABB to document coordinates and set {@link projectedBoundingRect}.
* Applies all {@link modelViewProjectionMatrix} transformations to our {@link boundingBox}, i.e. apply OBB to document coordinates and set {@link projectedBoundingRect}.
*/
setDocumentCoordsFromClipSpaceAABB(): void;
setDocumentCoordsFromClipSpaceOBB(): void;
/**
* Apply the bounding sphere in clip space to document coordinates and set {@link projectedBoundingRect}.
* @param boundingSphere - bounding sphere in clip space.
Expand Down
6 changes: 3 additions & 3 deletions dist/types/core/meshes/mixins/ProjectedMeshBaseMixin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { RenderMaterialParams } from '../../../types/Materials';
import { ProjectedObject3D } from '../../objects3D/ProjectedObject3D';
import { Vec3 } from '../../../math/Vec3';
/** Define all possible frustum culling checks. */
export type FrustumCullingCheck = 'AABB' | 'sphere' | boolean;
export type FrustumCullingCheck = 'OBB' | 'sphere' | boolean;
/**
* Base parameters used to create a ProjectedMesh
*/
export interface ProjectedMeshBaseParams {
/** Frustum culling check to use. Accepts `AABB`, `sphere` or a boolean. Default to `AABB`. When set to `true`, `AABB` is used. */
/** Frustum culling check to use. Accepts `OBB`, `sphere` or a boolean. Default to `OBB`. When set to `true`, `OBB` is used. */
frustumCulling?: FrustumCullingCheck;
/** Margins (in pixels) to applied to the {@link ProjectedMeshBaseClass#domFrustum | DOM Frustum} to determine if this ProjectedMesh should be frustum culled or not */
DOMFrustumMargins?: RectCoords;
Expand All @@ -36,7 +36,7 @@ export declare class ProjectedMeshBaseClass extends MeshBaseClass {
renderer: CameraRenderer;
/** The ProjectedMesh {@link DOMFrustum} class object */
domFrustum: DOMFrustum;
/** Frustum culling check to use. Accepts `AABB`, `sphere` or a boolean. Default to `AABB`. When set to `true`, `AABB` is used. */
/** Frustum culling check to use. Accepts `OBB`, `sphere` or a boolean. Default to `OBB`. When set to `true`, `OBB` is used. */
frustumCulling: FrustumCullingCheck;
/** Margins (in pixels) to applied to the {@link ProjectedMeshBaseClass#domFrustum | DOM Frustum} to determine if this ProjectedMesh should be frustum culled or not */
DOMFrustumMargins: RectCoords;
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/search.js

Large diffs are not rendered by default.

Loading

0 comments on commit 0830e51

Please sign in to comment.