diff --git a/src/asset/SpaceStationParts/sphericalTank.glb b/src/asset/SpaceStationParts/sphericalTank.glb index 7c8c8cef0..f71a22929 100644 Binary files a/src/asset/SpaceStationParts/sphericalTank.glb and b/src/asset/SpaceStationParts/sphericalTank.glb differ diff --git a/src/ts/assets/objects.ts b/src/ts/assets/objects.ts index 56829e540..1a82462e1 100644 --- a/src/ts/assets/objects.ts +++ b/src/ts/assets/objects.ts @@ -41,8 +41,9 @@ import sphericalTank from "../../asset/SpaceStationParts/sphericalTank.glb"; import stationEngine from "../../asset/SpaceStationParts/engine.glb"; import { CollisionMask } from "../settings"; -import { PhysicsShape, PhysicsShapeMesh } from "@babylonjs/core/Physics/v2/physicsShape"; +import { PhysicsShape, PhysicsShapeMesh, PhysicsShapeSphere } from "@babylonjs/core/Physics/v2/physicsShape"; import { MeshBuilder } from "@babylonjs/core/Meshes/meshBuilder"; +import { Vector3 } from "@babylonjs/core/Maths/math"; export class Objects { private static WANDERER: Mesh; @@ -60,6 +61,7 @@ export class Objects { public static GRASS_BLADES: Mesh[] = []; public static SPHERICAL_TANK: Mesh; + public static SPHERICAL_TANK_PHYSICS_SHAPE: PhysicsShape; public static STATION_ENGINE: Mesh; public static CRATE: Mesh; @@ -189,9 +191,14 @@ export class Objects { const boundingBox = Objects.SPHERICAL_TANK.getBoundingInfo().boundingBox; const maxDimension = Math.max(boundingBox.extendSize.x, boundingBox.extendSize.y, boundingBox.extendSize.z); - Objects.SPHERICAL_TANK.scalingDeterminant = 20 / maxDimension; + const targetDimension = 20; + + Objects.SPHERICAL_TANK.scaling.scaleInPlace(targetDimension / maxDimension); Objects.SPHERICAL_TANK.bakeCurrentTransformIntoVertices(); + //FIXME: the scaling of the radius is caused by an issue with the mesh + Objects.SPHERICAL_TANK_PHYSICS_SHAPE = new PhysicsShapeSphere(Vector3.Zero(), targetDimension * 2.5, scene) + console.log("SphericalTank loaded"); }; diff --git a/src/ts/assets/procedural/spaceStation/landingBayMaterial.ts b/src/ts/assets/procedural/spaceStation/landingBayMaterial.ts index 87c0c7b7d..5b4006741 100644 --- a/src/ts/assets/procedural/spaceStation/landingBayMaterial.ts +++ b/src/ts/assets/procedural/spaceStation/landingBayMaterial.ts @@ -75,7 +75,8 @@ export class LandingBayMaterial extends ShaderMaterial { width: textureResolution * aspectRatio, height: textureResolution }, - scene + scene, + true ); const font_size = 128; diff --git a/src/ts/assets/procedural/spaceStation/utilitySection.ts b/src/ts/assets/procedural/spaceStation/utilitySection.ts index b46eb7b40..0de264c56 100644 --- a/src/ts/assets/procedural/spaceStation/utilitySection.ts +++ b/src/ts/assets/procedural/spaceStation/utilitySection.ts @@ -27,8 +27,9 @@ import { Mesh } from "@babylonjs/core/Meshes/mesh"; import { CollisionMask } from "../../../settings"; import { AbstractMesh } from "@babylonjs/core/Meshes/abstractMesh"; import { PhysicsAggregate } from "@babylonjs/core/Physics/v2/physicsAggregate"; -import { PhysicsShapeType } from "@babylonjs/core/Physics/v2/IPhysicsEnginePlugin"; +import { PhysicsMotionType, PhysicsShapeType } from "@babylonjs/core/Physics/v2/IPhysicsEnginePlugin"; import { getRngFromSeed } from "../../../utils/getRngFromSeed"; +import { PhysicsBody } from "@babylonjs/core/Physics/v2/physicsBody"; export class UtilitySection implements Transformable { private readonly attachment: Mesh; @@ -40,7 +41,7 @@ export class UtilitySection implements Transformable { private readonly metalSectionMaterial: MetalSectionMaterial; private readonly tanks: AbstractMesh[] = []; - private readonly tankAggregates: PhysicsAggregate[] = []; + private readonly tankBodies: PhysicsBody[] = []; constructor(seed: number, scene: Scene) { this.metalSectionMaterial = new MetalSectionMaterial(scene); @@ -95,19 +96,21 @@ export class UtilitySection implements Transformable { this.attachmentAggregate.shape.filterCollideMask = CollisionMask.DYNAMIC_OBJECTS; this.tanks.forEach((tank) => { - const tankAggregate = new PhysicsAggregate(tank, PhysicsShapeType.SPHERE, { mass: 0 }); - tankAggregate.body.disablePreStep = false; - tankAggregate.shape.filterMembershipMask = CollisionMask.ENVIRONMENT; - tankAggregate.shape.filterCollideMask = CollisionMask.DYNAMIC_OBJECTS; - - this.tankAggregates.push(tankAggregate); + const tankBody = new PhysicsBody(tank, PhysicsMotionType.STATIC, false, this.getTransform().getScene()); + tankBody.setMassProperties({ mass: 0 }); + tankBody.disablePreStep = false; + tankBody.shape = Objects.SPHERICAL_TANK_PHYSICS_SHAPE; + tankBody.shape.filterMembershipMask = CollisionMask.ENVIRONMENT; + tankBody.shape.filterCollideMask = CollisionMask.DYNAMIC_OBJECTS; + + this.tankBodies.push(tankBody); }); } else if (distanceToCamera > 360e3 && this.attachmentAggregate !== null) { this.attachmentAggregate?.dispose(); this.attachmentAggregate = null; - this.tankAggregates.forEach((tankAggregate) => tankAggregate.dispose()); - this.tankAggregates.length = 0; + this.tankBodies.forEach((tankBody) => tankBody.dispose()); + this.tankBodies.length = 0; } } @@ -120,6 +123,6 @@ export class UtilitySection implements Transformable { this.attachmentAggregate?.dispose(); this.metalSectionMaterial.dispose(); this.tanks.forEach((tank) => tank.dispose()); - this.tankAggregates.forEach((tankAggregate) => tankAggregate.dispose()); + this.tankBodies.forEach((tankAggregate) => tankAggregate.dispose()); } } diff --git a/src/ts/assets/textures.ts b/src/ts/assets/textures.ts index e8ab4d18e..44b4a6884 100644 --- a/src/ts/assets/textures.ts +++ b/src/ts/assets/textures.ts @@ -191,7 +191,8 @@ export class Textures { width: padNumberTextureResolution, height: padNumberTextureResolution * Settings.LANDING_PAD_ASPECT_RATIO }, - scene + scene, + true ); //Add text to dynamic texture