Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/BabylonJS/Babylon.js
Browse files Browse the repository at this point in the history
  • Loading branch information
deltakosh committed May 20, 2024
2 parents 7d227a0 + aa2398e commit a93b8e5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/dev/core/src/Culling/boundingBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export class BoundingBox implements ICullable {
*/
public readonly centerWorld: Vector3 = Vector3.Zero();
/**
* Gets the extend size in local space
* Gets half the size of the extent in local space. Multiply by 2 to obtain the full size of the box!
*/
public readonly extendSize: Vector3 = Vector3.Zero();
/**
* Gets the extend size in world space
* Gets half the size of the extent in world space. Multiply by 2 to obtain the full size of the box!
*/
public readonly extendSizeWorld: Vector3 = Vector3.Zero();
/**
Expand Down
10 changes: 8 additions & 2 deletions packages/dev/core/src/DeviceInput/webDeviceInputSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ export class WebDeviceInputSystem implements IDeviceInputSystem {
const deviceType = this._getPointerType(evt);
let deviceSlot = deviceType === DeviceType.Mouse ? 0 : this._activeTouchIds.indexOf(evt.pointerId);

// In the event that we're gettting pointermove events from touch inputs that we aren't tracking,
// In the event that we're getting pointermove events from touch inputs that we aren't tracking,
// look for an available slot and retroactively connect it.
if (deviceType === DeviceType.Touch && deviceSlot === -1) {
const idx = this._activeTouchIds.indexOf(-1);
Expand Down Expand Up @@ -487,7 +487,13 @@ export class WebDeviceInputSystem implements IDeviceInputSystem {
let deviceSlot = deviceType === DeviceType.Mouse ? 0 : evt.pointerId;

if (deviceType === DeviceType.Touch) {
const idx = this._activeTouchIds.indexOf(-1);
// See if this pointerId is already using an existing slot
// (possible on some devices which raise the pointerMove event before the pointerDown event, e.g. when using a pen)
let idx = this._activeTouchIds.indexOf(evt.pointerId);
if (idx === -1) {
// If the pointerId wasn't already using a slot, find an open one
idx = this._activeTouchIds.indexOf(-1);
}

if (idx >= 0) {
deviceSlot = idx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class GaussianSplattingMaterial extends PushMaterial {

PrepareAttributesForInstances(attribs, defines);

const uniforms = ["world", "view", "projection", "vFogInfos", "vFogColor", "logarithmicDepthConstant", "viewport", "dataTextureSize", "focal"];
const uniforms = ["world", "view", "projection", "vFogInfos", "vFogColor", "logarithmicDepthConstant", "invViewport", "dataTextureSize", "focal"];
const samplers = ["covariancesATexture", "covariancesBTexture", "centersTexture", "colorsTexture"];
const uniformBuffers = ["Scene", "Mesh"];

Expand Down Expand Up @@ -214,7 +214,10 @@ export class GaussianSplattingMaterial extends PushMaterial {
const renderWidth = engine.getRenderWidth();
const renderHeight = engine.getRenderHeight();

this._activeEffect.setFloat2("viewport", renderWidth, renderHeight);
// check if rigcamera, get number of rigs
const numberOfRigs = camera?.rigParent?.rigCameras.length || 1;

this._activeEffect.setFloat2("invViewport", 1 / (renderWidth / numberOfRigs), 1 / renderHeight);

let focal = 1000;

Expand Down
6 changes: 3 additions & 3 deletions packages/dev/core/src/Shaders/gaussianSplatting.vertex.fx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ attribute vec2 position;
attribute float splatIndex;

// Uniforms
uniform vec2 viewport;
uniform vec2 invViewport;
uniform vec2 dataTextureSize;
uniform vec2 focal;

Expand Down Expand Up @@ -92,8 +92,8 @@ void main () {
vec2 vCenter = vec2(pos2d);
gl_Position = vec4(
vCenter
+ (position.x * majorAxis * 1. / viewport.x
+ position.y * minorAxis * 1. / viewport.y) * pos2d.w, pos2d.zw);
+ (position.x * majorAxis
+ position.y * minorAxis) * invViewport * pos2d.w, pos2d.zw);

#include<clipPlaneVertex>
#include<fogVertex>
Expand Down
2 changes: 1 addition & 1 deletion packages/dev/gui/src/2D/controls/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2432,7 +2432,7 @@ export class Control implements IAnimatable {
"px " +
this._getStyleProperty("fontFamily", "Arial");

this._fontOffset = Control._GetFontOffset(this._font, this._host.getScene()?.getEngine());
this._fontOffset = Control._GetFontOffset(this._font, this._host?.getScene()?.getEngine());

//children need to be refreshed
this.getDescendants().forEach((child) => child._markAllAsDirty());
Expand Down

0 comments on commit a93b8e5

Please sign in to comment.