@babylonjs/lite-compat 1.25.0-preview → 1.26.0-preview
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +87 -0
- package/index.js +265 -5
- package/index.js.map +1 -1
- package/package.json +4 -4
package/index.d.ts
CHANGED
|
@@ -1188,6 +1188,27 @@ declare interface CellSize {
|
|
|
1188
1188
|
height: number;
|
|
1189
1189
|
}
|
|
1190
1190
|
|
|
1191
|
+
export declare interface CharacterShapeOptions {
|
|
1192
|
+
shape?: PhysicsShape;
|
|
1193
|
+
capsuleHeight?: number;
|
|
1194
|
+
capsuleRadius?: number;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/** Contact state of a physics character against its supporting surface. */
|
|
1198
|
+
export declare enum CharacterSupportedState {
|
|
1199
|
+
UNSUPPORTED = 0,
|
|
1200
|
+
SLIDING = 1,
|
|
1201
|
+
SUPPORTED = 2
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
export declare interface CharacterSurfaceInfo {
|
|
1205
|
+
isSurfaceDynamic: boolean;
|
|
1206
|
+
supportedState: CharacterSupportedState;
|
|
1207
|
+
averageSurfaceNormal: Vector3;
|
|
1208
|
+
averageSurfaceVelocity: Vector3;
|
|
1209
|
+
averageAngularSurfaceVelocity: Vector3;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1191
1212
|
export declare const ChromaticAberrationPostProcess: new () => never;
|
|
1192
1213
|
|
|
1193
1214
|
export declare class CircleEase extends EasingFunction {
|
|
@@ -2277,6 +2298,13 @@ export declare interface IAudioParameterRampOptions {
|
|
|
2277
2298
|
shape: AudioParameterRampShape;
|
|
2278
2299
|
}
|
|
2279
2300
|
|
|
2301
|
+
export declare interface ICharacterControllerCollisionEvent {
|
|
2302
|
+
collider: PhysicsBody;
|
|
2303
|
+
colliderIndex: number;
|
|
2304
|
+
impulse: Vector3;
|
|
2305
|
+
impulsePosition: Vector3;
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2280
2308
|
/** Babylon.js `ICreateTexture2DArrayFromImageUrlsOptions`. */
|
|
2281
2309
|
export declare interface ICreateTexture2DArrayFromImageUrlsOptions extends IUploadImageToTexture2DArrayLayerOptions {
|
|
2282
2310
|
/** Generate a full mip chain (true by default). */
|
|
@@ -3529,6 +3557,65 @@ export declare class PhysicsBody {
|
|
|
3529
3557
|
readonly transformNode: TransformNode;
|
|
3530
3558
|
applyForce(force: Vec3Like, location: Vec3Like): void;
|
|
3531
3559
|
dispose(): void;
|
|
3532
3560
|
|
|
3561
|
+
/**
|
|
3562
|
+
* Babylon.js-shaped character controller backed by Lite's native, tree-shakeable
|
|
3563
|
+
* Havok character controller.
|
|
3564
|
+
*/
|
|
3565
|
+
export declare class PhysicsCharacterController {
|
|
3533
3566
|
readonly onTriggerCollisionObservable: Observable<ICharacterControllerCollisionEvent>;
|
|
3567
|
+
private _shape;
|
|
3568
|
+
private _up;
|
|
3569
|
+
private _maxStepHeight;
|
|
3570
|
+
private _footOffset;
|
|
3571
|
+
private _disposed;
|
|
3572
|
+
constructor(position: Vector3, characterShapeOptions: CharacterShapeOptions, scene: Scene);
|
|
3573
|
+
get shape(): PhysicsShape;
|
|
3574
|
+
set shape(_value: PhysicsShape);
|
|
3575
|
+
get shapeOptions(): CharacterShapeOptions;
|
|
3576
|
+
setShapeOptions(options: CharacterShapeOptions, preserveFootPosition?: boolean): void;
|
|
3577
|
+
getPosition(): Vector3;
|
|
3578
|
+
setPosition(position: Vector3): void;
|
|
3579
|
+
getVelocity(): Vector3;
|
|
3580
|
+
setVelocity(velocity: Vector3): void;
|
|
3581
|
+
moveWithCollisions(displacement: Vector3): void;
|
|
3582
|
+
integrate(deltaTime: number, surfaceInfo: CharacterSurfaceInfo, gravity: Vector3): void;
|
|
3583
|
+
checkSupport(deltaTime: number, direction: Vector3): CharacterSurfaceInfo;
|
|
3584
|
+
checkSupportToRef(deltaTime: number, direction: Vector3, result: CharacterSurfaceInfo): void;
|
|
3585
|
+
calculateMovement(deltaTime: number, forwardWorld: Vector3, surfaceNormal: Vector3, currentVelocity: Vector3, surfaceVelocity: Vector3, desiredVelocity: Vector3, upWorld: Vector3): Vector3;
|
|
3586
|
+
calculateMovementToRef(deltaTime: number, forwardWorld: Vector3, surfaceNormal: Vector3, currentVelocity: Vector3, surfaceVelocity: Vector3, desiredVelocity: Vector3, upWorld: Vector3, result: Vector3): boolean;
|
|
3587
|
+
dispose(): void;
|
|
3588
|
+
get up(): Vector3;
|
|
3589
|
+
set up(value: Vector3);
|
|
3590
|
+
get maxStepHeight(): number;
|
|
3591
|
+
set maxStepHeight(value: number);
|
|
3592
|
+
get footOffset(): number;
|
|
3593
|
+
set footOffset(value: number);
|
|
3594
|
+
private _notifyCollision;
|
|
3595
|
+
get keepDistance(): number;
|
|
3596
|
+
set keepDistance(value: number);
|
|
3597
|
+
get keepContactTolerance(): number;
|
|
3598
|
+
set keepContactTolerance(value: number);
|
|
3599
|
+
get maxCastIterations(): number;
|
|
3600
|
+
set maxCastIterations(value: number);
|
|
3601
|
+
get penetrationRecoverySpeed(): number;
|
|
3602
|
+
set penetrationRecoverySpeed(value: number);
|
|
3603
|
+
get staticFriction(): number;
|
|
3604
|
+
set staticFriction(value: number);
|
|
3605
|
+
get dynamicFriction(): number;
|
|
3606
|
+
set dynamicFriction(value: number);
|
|
3607
|
+
get maxSlopeCosine(): number;
|
|
3608
|
+
set maxSlopeCosine(value: number);
|
|
3609
|
+
get maxCharacterSpeedForSolver(): number;
|
|
3610
|
+
set maxCharacterSpeedForSolver(value: number);
|
|
3611
|
+
get characterStrength(): number;
|
|
3612
|
+
set characterStrength(value: number);
|
|
3613
|
+
get acceleration(): number;
|
|
3614
|
+
set acceleration(value: number);
|
|
3615
|
+
get maxAcceleration(): number;
|
|
3616
|
+
set maxAcceleration(value: number);
|
|
3617
|
+
get characterMass(): number;
|
|
3618
|
+
set characterMass(value: number);
|
|
3619
|
+
}
|
|
3620
|
+
|
|
3534
3621
|
/** Type of a Physics V2 constraint. Values match Babylon.js `PhysicsConstraintType`. */
|
|
3535
3622
|
export declare enum PhysicsConstraintType {
|
|
3536
3623
|
BALL_AND_SOCKET = 1,
|
package/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { V as Vector3, a as Vector2, u as unsupported, O as Observable, L as LiteCompatError, N as Node, M as Matrix, C as Color3, S as StandardMaterial, b as Color4, A as AbstractMesh, c as Mesh, T as TransformNode, l as liteBackedVector3, Q as Quaternion } from "./meshes-nWGELV98.js";
|
|
5
5
|
import { B, d, e, f, g, h, i, j, k, m, n, o, p, q, r, G, I, s, t, v, P, w, x, y, z, D, E, F, H, J, K, R, U } from "./meshes-nWGELV98.js";
|
|
6
|
-
import { addPolarToRef, subtractPolarToRef, multiplyPolarToRef, dividePolarToRef, scalePolarToRef, polarToVec2ToRef, polarFromVec2ToRef, addSphericalToRef, subtractSphericalToRef, multiplySphericalToRef, divideSphericalToRef, scaleSphericalToRef, sphericalToVec3ToRef, sphericalFromVec3ToRef, sampleHermiteSpline, sampleCatmullRomSpline, VERSION, createEngine, onBeforeRender, stopEngine, resizeEngine, setEngineSize, disposeEngine, uploadImageToArrayLayer, enableMirroredMeshes, registerSceneWithShadowSupport, registerScene, startEngine, createNullEngine, stepScene, setPhysicsTimestep, setPhysicsGravity, disposePhysics, createHavokWorld, createPhysicsShape, createPhysicsAggregate, createPhysicsBody, setPhysicsBodyPrestepType, PhysicsPrestepType as PhysicsPrestepType$1, PhysicsMotionType as PhysicsMotionType$1, setPhysicsBodyShape, setPhysicsBodyMotionType, setPhysicsBodyMassProperties, setPhysicsBodyLinearVelocity, getPhysicsBodyLinearVelocity, setPhysicsBodyAngularVelocity, getPhysicsBodyAngularVelocity, applyPhysicsBodyImpulse, applyPhysicsBodyForce, removePhysicsBody, PhysicsShapeType as PhysicsShapeType$1, setPhysicsShapeFilterMembershipMask, setPhysicsShapeFilterCollideMask, setPhysicsShapeMaterial, setPhysicsShapeIsTrigger, releasePhysicsShape, createArcRotateCamera, attachControl, getCameraPosition, getViewMatrix, getProjectionMatrix, createGeospatialCamera, setGeospatialOrientation, attachGeospatialControls, createFreeCamera, attachFreeControl, setAnimationAdditive, playAnimation, pauseAnimation, goToFrame, stopAnimation, createSceneContext, updateAnimationManager, setFog, setClipPlane, loadHdrEnvironment, loadDdsEnvironment, loadEnvironment, createDefaultCamera, addToScene, createHemisphericLight, pickMeshesWithRay, createAnimationManager, enableAnimationBlending, addAnimationGroup, disposeScene, createDirectionalLight, createPointLight, createSpotLight, createClusteredLightContainer, createClusteredPointLight, removeFromScene, addClusteredLightContainer, markClusteredLightContainerDirty, createCsgFromMesh, csgSubtract, csgIntersect, csgUnion, createMeshFromCsg, createCsg2FromMesh, csg2Subtract, csg2Intersect, csg2Add, createMeshesFromCsg2, disposeCsg2, initializeCsg2Async, createMorphTargets, setMorphTargetWeights, createTransformNode, bakeCurrentTransformIntoVertices, loadSOG, loadSPZ, loadSplat, createDynamicTexture, updateDynamicTexture, createTexture2DFromPixels, updateTexture2DFromPixels, createTexture3DFromPixels, loadBasisTexture2D, loadKtxTexture2D, loadTexture2D, createTexture2DArrayFromUrls, createTexture2DArrayFromKtx2, loadImageToArrayLayer, createTexture2DArray, createTexture2DArrayFromPixels, updateTexture2DArrayFromPixels, setBonePosition, setBoneRotationQuaternion, setBoneScaling, clearBoneOverride, getBoneByName, enableBoneControlForSkinnedAssets, loadBabylon, loadGltf, resetVariant, getVariantNames, selectVariant, disposePicker, createGpuPicker, pickAsync, createAxisDragGizmo, attachAxisDragGizmoToNode, disposeAxisDragGizmo, createAxisScaleGizmo, attachAxisScaleGizmoToNode, disposeAxisScaleGizmo, createBoundingBoxGizmo, attachBoundingBoxGizmoToNode, disposeBoundingBoxGizmo, createCameraGizmo, attachCameraGizmoToCamera, disposeCameraGizmo, createLightGizmo, attachLightGizmoToLight, disposeLightGizmo, createPlaneDragGizmo, attachPlaneDragGizmoToNode, disposePlaneDragGizmo, createPlaneRotationGizmo, attachPlaneRotationGizmoToNode, disposePlaneRotationGizmo, createPositionGizmo, setPositionGizmoLocalCoordinates, attachPositionGizmoToNode, disposePositionGizmo, createRotationGizmo, setRotationGizmoLocalCoordinates, attachRotationGizmoToNode, disposeRotationGizmo, createScaleGizmo, setScaleGizmoLocalCoordinates, attachScaleGizmoToNode, disposeScaleGizmo, createUtilityLayer, registerUtilityLayer, disposeUtilityLayer, addBillboardSpriteIndex, updateBillboardSpriteIndex, loadSpriteAtlas, createFacingBillboardSystem, addFacingBillboardSystem, billboardBlendAdditive, billboardBlendAlpha, spriteBlendPremultiplied, spriteBlendAdditive, spriteBlendAlpha, createSprite2DLayer, addSprite2DIndex, createSpriteRenderer, registerSpriteRenderer, updateSprite2DIndex, createPcfSpotlightShadowGenerator, createPcfDirectionalShadowGenerator, createEsmDirectionalShadowGenerator, setShadowTaskCasterMeshes, parseNodeMaterialFromSnippet, createGridMaterial, getByteFrequencyData, getFloatFrequencyData, getByteTimeDomainData, getFloatTimeDomainData, enableAnalyzer, setSpatialPosition, setSpatialOrientation, enableSpatial, setSpatialListenerPosition, setSpatialListener, updateSpatialAudio, enableStereo, setStereoPan, disposeAudioBus, setBusVolume, getMasterVolume, setMasterVolume, unlockAudioEngineAsync, createSoundAsync, createSoundBufferAsync, createStreamingSoundAsync, createAudioBusAsync, createSoundSourceAsync, createMicrophoneSoundSourceAsync, disposeAudioEngine, createAudioEngineAsync, disposeSoundSource, setSoundSourceVolume, playSound, pauseSound, resumeSound, stopSound, disposeSound, setSoundVolume, playStreamingSound, pauseStreamingSound, resumeStreamingSound, stopStreamingSound, preloadStreamingInstanceAsync, preloadStreamingInstancesAsync, disposeStreamingSound, setStreamingSoundVolume, startParticleSystem, animateParticleSystem, stopParticleSystem, createParticleBillboard, syncParticleBillboard, parseNodeParticleSetFromSnippet, registerNodeParticleSet } from "@babylonjs/lite";
|
|
6
|
+
import { addPolarToRef, subtractPolarToRef, multiplyPolarToRef, dividePolarToRef, scalePolarToRef, polarToVec2ToRef, polarFromVec2ToRef, addSphericalToRef, subtractSphericalToRef, multiplySphericalToRef, divideSphericalToRef, scaleSphericalToRef, sphericalToVec3ToRef, sphericalFromVec3ToRef, sampleHermiteSpline, sampleCatmullRomSpline, VERSION, createEngine, onBeforeRender, stopEngine, resizeEngine, setEngineSize, disposeEngine, uploadImageToArrayLayer, enableMirroredMeshes, registerSceneWithShadowSupport, registerScene, startEngine, createNullEngine, stepScene, setPhysicsTimestep, setPhysicsGravity, disposePhysics, createHavokWorld, createPhysicsShape, createPhysicsAggregate, createPhysicsBody, setPhysicsBodyPrestepType, PhysicsPrestepType as PhysicsPrestepType$1, PhysicsMotionType as PhysicsMotionType$1, setPhysicsBodyShape, setPhysicsBodyMotionType, setPhysicsBodyMassProperties, setPhysicsBodyLinearVelocity, getPhysicsBodyLinearVelocity, setPhysicsBodyAngularVelocity, getPhysicsBodyAngularVelocity, applyPhysicsBodyImpulse, applyPhysicsBodyForce, removePhysicsBody, createPhysicsCharacterController, calculatePhysicsCharacterMovementToRef, PhysicsShapeType as PhysicsShapeType$1, setPhysicsShapeFilterMembershipMask, setPhysicsShapeFilterCollideMask, setPhysicsShapeMaterial, setPhysicsShapeIsTrigger, releasePhysicsShape, createArcRotateCamera, attachControl, getCameraPosition, getViewMatrix, getProjectionMatrix, createGeospatialCamera, setGeospatialOrientation, attachGeospatialControls, createFreeCamera, attachFreeControl, setAnimationAdditive, playAnimation, pauseAnimation, goToFrame, stopAnimation, createSceneContext, updateAnimationManager, setFog, setClipPlane, loadHdrEnvironment, loadDdsEnvironment, loadEnvironment, createDefaultCamera, addToScene, createHemisphericLight, pickMeshesWithRay, createAnimationManager, enableAnimationBlending, addAnimationGroup, disposeScene, createDirectionalLight, createPointLight, createSpotLight, createClusteredLightContainer, createClusteredPointLight, removeFromScene, addClusteredLightContainer, markClusteredLightContainerDirty, createCsgFromMesh, csgSubtract, csgIntersect, csgUnion, createMeshFromCsg, createCsg2FromMesh, csg2Subtract, csg2Intersect, csg2Add, createMeshesFromCsg2, disposeCsg2, initializeCsg2Async, createMorphTargets, setMorphTargetWeights, createTransformNode, bakeCurrentTransformIntoVertices, loadSOG, loadSPZ, loadSplat, createDynamicTexture, updateDynamicTexture, createTexture2DFromPixels, updateTexture2DFromPixels, createTexture3DFromPixels, loadBasisTexture2D, loadKtxTexture2D, loadTexture2D, createTexture2DArrayFromUrls, createTexture2DArrayFromKtx2, loadImageToArrayLayer, createTexture2DArray, createTexture2DArrayFromPixels, updateTexture2DArrayFromPixels, setBonePosition, setBoneRotationQuaternion, setBoneScaling, clearBoneOverride, getBoneByName, enableBoneControlForSkinnedAssets, loadBabylon, loadGltf, resetVariant, getVariantNames, selectVariant, disposePicker, createGpuPicker, pickAsync, createAxisDragGizmo, attachAxisDragGizmoToNode, disposeAxisDragGizmo, createAxisScaleGizmo, attachAxisScaleGizmoToNode, disposeAxisScaleGizmo, createBoundingBoxGizmo, attachBoundingBoxGizmoToNode, disposeBoundingBoxGizmo, createCameraGizmo, attachCameraGizmoToCamera, disposeCameraGizmo, createLightGizmo, attachLightGizmoToLight, disposeLightGizmo, createPlaneDragGizmo, attachPlaneDragGizmoToNode, disposePlaneDragGizmo, createPlaneRotationGizmo, attachPlaneRotationGizmoToNode, disposePlaneRotationGizmo, createPositionGizmo, setPositionGizmoLocalCoordinates, attachPositionGizmoToNode, disposePositionGizmo, createRotationGizmo, setRotationGizmoLocalCoordinates, attachRotationGizmoToNode, disposeRotationGizmo, createScaleGizmo, setScaleGizmoLocalCoordinates, attachScaleGizmoToNode, disposeScaleGizmo, createUtilityLayer, registerUtilityLayer, disposeUtilityLayer, addBillboardSpriteIndex, updateBillboardSpriteIndex, loadSpriteAtlas, createFacingBillboardSystem, addFacingBillboardSystem, billboardBlendAdditive, billboardBlendAlpha, spriteBlendPremultiplied, spriteBlendAdditive, spriteBlendAlpha, createSprite2DLayer, addSprite2DIndex, createSpriteRenderer, registerSpriteRenderer, updateSprite2DIndex, createPcfSpotlightShadowGenerator, createPcfDirectionalShadowGenerator, createEsmDirectionalShadowGenerator, setShadowTaskCasterMeshes, parseNodeMaterialFromSnippet, createGridMaterial, getByteFrequencyData, getFloatFrequencyData, getByteTimeDomainData, getFloatTimeDomainData, enableAnalyzer, setSpatialPosition, setSpatialOrientation, enableSpatial, setSpatialListenerPosition, setSpatialListener, updateSpatialAudio, enableStereo, setStereoPan, disposeAudioBus, setBusVolume, getMasterVolume, setMasterVolume, unlockAudioEngineAsync, createSoundAsync, createSoundBufferAsync, createStreamingSoundAsync, createAudioBusAsync, createSoundSourceAsync, createMicrophoneSoundSourceAsync, disposeAudioEngine, createAudioEngineAsync, disposeSoundSource, setSoundSourceVolume, playSound, pauseSound, resumeSound, stopSound, disposeSound, setSoundVolume, playStreamingSound, pauseStreamingSound, resumeStreamingSound, stopStreamingSound, preloadStreamingInstanceAsync, preloadStreamingInstancesAsync, disposeStreamingSound, setStreamingSoundVolume, startParticleSystem, animateParticleSystem, stopParticleSystem, createParticleBillboard, syncParticleBillboard, parseNodeParticleSetFromSnippet, registerNodeParticleSet } from "@babylonjs/lite";
|
|
7
7
|
const Epsilon = 1e-3;
|
|
8
8
|
const ToRadians = Math.PI / 180;
|
|
9
9
|
const ToDegrees = 180 / Math.PI;
|
|
@@ -1361,6 +1361,10 @@ class AbstractScene {
|
|
|
1361
1361
|
return this.meshes.find((m2) => byId(m2)) ?? this._cameras.find((c) => byId(c)) ?? this._lights.find((l) => byId(l)) ?? null;
|
|
1362
1362
|
}
|
|
1363
1363
|
}
|
|
1364
|
+
let physicsBodyWrappers = null;
|
|
1365
|
+
function getPhysicsBodyWrappers() {
|
|
1366
|
+
return physicsBodyWrappers ?? (physicsBodyWrappers = /* @__PURE__ */ new WeakMap());
|
|
1367
|
+
}
|
|
1364
1368
|
var PhysicsShapeType = /* @__PURE__ */ ((PhysicsShapeType2) => {
|
|
1365
1369
|
PhysicsShapeType2[PhysicsShapeType2["SPHERE"] = 0] = "SPHERE";
|
|
1366
1370
|
PhysicsShapeType2[PhysicsShapeType2["CAPSULE"] = 1] = "CAPSULE";
|
|
@@ -1394,6 +1398,12 @@ var PhysicsConstraintType = /* @__PURE__ */ ((PhysicsConstraintType2) => {
|
|
|
1394
1398
|
PhysicsConstraintType2[PhysicsConstraintType2["SIX_DOF"] = 7] = "SIX_DOF";
|
|
1395
1399
|
return PhysicsConstraintType2;
|
|
1396
1400
|
})(PhysicsConstraintType || {});
|
|
1401
|
+
var CharacterSupportedState = /* @__PURE__ */ ((CharacterSupportedState2) => {
|
|
1402
|
+
CharacterSupportedState2[CharacterSupportedState2["UNSUPPORTED"] = 0] = "UNSUPPORTED";
|
|
1403
|
+
CharacterSupportedState2[CharacterSupportedState2["SLIDING"] = 1] = "SLIDING";
|
|
1404
|
+
CharacterSupportedState2[CharacterSupportedState2["SUPPORTED"] = 2] = "SUPPORTED";
|
|
1405
|
+
return CharacterSupportedState2;
|
|
1406
|
+
})(CharacterSupportedState || {});
|
|
1397
1407
|
function requirePhysicsWorld(scene) {
|
|
1398
1408
|
var _a;
|
|
1399
1409
|
const world = (_a = scene == null ? void 0 : scene.getPhysicsEngine()) == null ? void 0 : _a.getPhysicsPlugin().world;
|
|
@@ -1464,6 +1474,8 @@ class PhysicsShape {
|
|
|
1464
1474
|
__publicField(this, "_isTrigger", false);
|
|
1465
1475
|
/** @internal */
|
|
1466
1476
|
__publicField(this, "_disposed", false);
|
|
1477
|
+
/** @internal Whether this wrapper is responsible for releasing the native shape. */
|
|
1478
|
+
__publicField(this, "_ownsLiteShape", true);
|
|
1467
1479
|
this._world = requirePhysicsWorld(scene);
|
|
1468
1480
|
if (options.pluginData) {
|
|
1469
1481
|
this._lite = options.pluginData;
|
|
@@ -1474,19 +1486,28 @@ class PhysicsShape {
|
|
|
1474
1486
|
}
|
|
1475
1487
|
}
|
|
1476
1488
|
/** @internal */
|
|
1477
|
-
static _fromLite(shape, world) {
|
|
1489
|
+
static _fromLite(shape, world, ownsLiteShape = true) {
|
|
1478
1490
|
const wrapper = Object.create(PhysicsShape.prototype);
|
|
1479
1491
|
Object.defineProperties(wrapper, {
|
|
1480
|
-
_lite: { value: shape, enumerable: true },
|
|
1492
|
+
_lite: { value: shape, enumerable: true, writable: true },
|
|
1481
1493
|
_world: { value: world },
|
|
1482
1494
|
_material: { value: {}, writable: true },
|
|
1483
1495
|
_membershipMask: { value: 4294967295, writable: true },
|
|
1484
1496
|
_collideMask: { value: 4294967295, writable: true },
|
|
1485
1497
|
_isTrigger: { value: false, writable: true },
|
|
1486
|
-
_disposed: { value: false, writable: true }
|
|
1498
|
+
_disposed: { value: false, writable: true },
|
|
1499
|
+
_ownsLiteShape: { value: ownsLiteShape }
|
|
1487
1500
|
});
|
|
1488
1501
|
return wrapper;
|
|
1489
1502
|
}
|
|
1503
|
+
/** @internal */
|
|
1504
|
+
_replaceLiteShape(shape) {
|
|
1505
|
+
this._lite = shape;
|
|
1506
|
+
this.material = this._material;
|
|
1507
|
+
this.filterMembershipMask = this._membershipMask;
|
|
1508
|
+
this.filterCollideMask = this._collideMask;
|
|
1509
|
+
this.isTrigger = this._isTrigger;
|
|
1510
|
+
}
|
|
1490
1511
|
getClassName() {
|
|
1491
1512
|
return "PhysicsShape";
|
|
1492
1513
|
}
|
|
@@ -1543,7 +1564,9 @@ class PhysicsShape {
|
|
|
1543
1564
|
}
|
|
1544
1565
|
dispose() {
|
|
1545
1566
|
if (!this._disposed) {
|
|
1546
|
-
|
|
1567
|
+
if (this._ownsLiteShape) {
|
|
1568
|
+
releasePhysicsShape(this._world, this._lite);
|
|
1569
|
+
}
|
|
1547
1570
|
this._disposed = true;
|
|
1548
1571
|
}
|
|
1549
1572
|
}
|
|
@@ -1568,6 +1591,7 @@ class PhysicsBody {
|
|
|
1568
1591
|
this.startAsleep = startsAsleep;
|
|
1569
1592
|
this._world = requirePhysicsWorld(scene);
|
|
1570
1593
|
this._lite = createPhysicsBody(this._world, transformNode._node, liteMotionType(motionType), startsAsleep);
|
|
1594
|
+
getPhysicsBodyWrappers().set(this._lite, this);
|
|
1571
1595
|
setPhysicsBodyPrestepType(this._lite, PhysicsPrestepType$1.DISABLED);
|
|
1572
1596
|
this._attachToNode();
|
|
1573
1597
|
}
|
|
@@ -1585,6 +1609,7 @@ class PhysicsBody {
|
|
|
1585
1609
|
startAsleep: { value: startsAsleep, enumerable: true }
|
|
1586
1610
|
});
|
|
1587
1611
|
setPhysicsBodyPrestepType(wrapper._lite, PhysicsPrestepType$1.DISABLED);
|
|
1612
|
+
getPhysicsBodyWrappers().set(wrapper._lite, wrapper);
|
|
1588
1613
|
wrapper._attachToNode();
|
|
1589
1614
|
return wrapper;
|
|
1590
1615
|
}
|
|
@@ -1688,6 +1713,7 @@ class PhysicsBody {
|
|
|
1688
1713
|
this.transformNode.onDisposeObservable.remove(this._nodeDisposeObserver);
|
|
1689
1714
|
this._nodeDisposeObserver = null;
|
|
1690
1715
|
removePhysicsBody(this._world, this._lite);
|
|
1716
|
+
getPhysicsBodyWrappers().delete(this._lite);
|
|
1691
1717
|
if (this.transformNode.physicsBody === this) {
|
|
1692
1718
|
this.transformNode.physicsBody = null;
|
|
1693
1719
|
}
|
|
@@ -1704,6 +1730,238 @@ class PhysicsBody {
|
|
|
1704
1730
|
this._nodeDisposeObserver = this.transformNode.onDisposeObservable.add(() => this.dispose());
|
|
1705
1731
|
}
|
|
1706
1732
|
}
|
|
1733
|
+
function vectorFromLite(value) {
|
|
1734
|
+
return new Vector3(value.x, value.y, value.z);
|
|
1735
|
+
}
|
|
1736
|
+
function vectorFromLiteOwned(value) {
|
|
1737
|
+
if (!(value instanceof Vector3)) {
|
|
1738
|
+
Object.setPrototypeOf(value, Vector3.prototype);
|
|
1739
|
+
}
|
|
1740
|
+
return value;
|
|
1741
|
+
}
|
|
1742
|
+
function surfaceInfoFromLite(value) {
|
|
1743
|
+
return {
|
|
1744
|
+
isSurfaceDynamic: value.isSurfaceDynamic,
|
|
1745
|
+
supportedState: Number(value.supportedState),
|
|
1746
|
+
averageSurfaceNormal: vectorFromLite(value.averageSurfaceNormal),
|
|
1747
|
+
averageSurfaceVelocity: vectorFromLite(value.averageSurfaceVelocity),
|
|
1748
|
+
averageAngularSurfaceVelocity: vectorFromLite(value.averageAngularSurfaceVelocity)
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
class PhysicsCharacterController {
|
|
1752
|
+
constructor(position, characterShapeOptions, scene) {
|
|
1753
|
+
/** @internal */
|
|
1754
|
+
__publicField(this, "_lite");
|
|
1755
|
+
__publicField(this, "onTriggerCollisionObservable", new Observable());
|
|
1756
|
+
__publicField(this, "_shape");
|
|
1757
|
+
__publicField(this, "_up");
|
|
1758
|
+
__publicField(this, "_maxStepHeight", 0);
|
|
1759
|
+
__publicField(this, "_footOffset");
|
|
1760
|
+
__publicField(this, "_disposed", false);
|
|
1761
|
+
if (characterShapeOptions.shape) {
|
|
1762
|
+
unsupported(
|
|
1763
|
+
"PhysicsCharacterController custom shapes",
|
|
1764
|
+
"Lite's controller owns and rebuilds a capsule internally; exposing caller-owned shape replacement requires an ownership/lifetime design in Lite."
|
|
1765
|
+
);
|
|
1766
|
+
}
|
|
1767
|
+
const world = requirePhysicsWorld(scene);
|
|
1768
|
+
this._lite = createPhysicsCharacterController(world, position, {
|
|
1769
|
+
capsuleHeight: characterShapeOptions.capsuleHeight ?? 1.8,
|
|
1770
|
+
capsuleRadius: characterShapeOptions.capsuleRadius ?? 0.6
|
|
1771
|
+
});
|
|
1772
|
+
this._up = vectorFromLite(this._lite.up);
|
|
1773
|
+
this._lite.up = this._up;
|
|
1774
|
+
this._footOffset = (characterShapeOptions.capsuleHeight ?? 1.8) * 0.5;
|
|
1775
|
+
const liteShape = this._lite.getBody()._shape;
|
|
1776
|
+
if (!liteShape) {
|
|
1777
|
+
throw new Error("Babylon Lite character controller did not create a collision shape.");
|
|
1778
|
+
}
|
|
1779
|
+
this._shape = PhysicsShape._fromLite(liteShape, world, false);
|
|
1780
|
+
this._lite.onTriggerCollisionObservable.add((event) => this._notifyCollision(event));
|
|
1781
|
+
}
|
|
1782
|
+
get shape() {
|
|
1783
|
+
return this._shape;
|
|
1784
|
+
}
|
|
1785
|
+
set shape(_value) {
|
|
1786
|
+
unsupported("PhysicsCharacterController.shape", "Lite's controller owns its cast shape; replacing it requires an explicit Lite ownership/lifetime contract.");
|
|
1787
|
+
}
|
|
1788
|
+
get shapeOptions() {
|
|
1789
|
+
const { capsuleHeight, capsuleRadius } = this._lite.shapeOptions;
|
|
1790
|
+
return { capsuleHeight, capsuleRadius };
|
|
1791
|
+
}
|
|
1792
|
+
setShapeOptions(options, preserveFootPosition = true) {
|
|
1793
|
+
if (options.shape) {
|
|
1794
|
+
this.shape = options.shape;
|
|
1795
|
+
return;
|
|
1796
|
+
}
|
|
1797
|
+
this._lite.setShapeOptions({ capsuleHeight: options.capsuleHeight ?? 1.8, capsuleRadius: options.capsuleRadius ?? 0.6 }, preserveFootPosition);
|
|
1798
|
+
const liteShape = this._lite.getBody()._shape;
|
|
1799
|
+
if (!liteShape) {
|
|
1800
|
+
throw new Error("Babylon Lite character controller did not rebuild its collision shape.");
|
|
1801
|
+
}
|
|
1802
|
+
this._shape._replaceLiteShape(liteShape);
|
|
1803
|
+
this._footOffset = (options.capsuleHeight ?? 1.8) * 0.5;
|
|
1804
|
+
}
|
|
1805
|
+
getPosition() {
|
|
1806
|
+
return vectorFromLiteOwned(this._lite.getPosition());
|
|
1807
|
+
}
|
|
1808
|
+
setPosition(position) {
|
|
1809
|
+
this._lite.setPosition(position);
|
|
1810
|
+
}
|
|
1811
|
+
getVelocity() {
|
|
1812
|
+
return vectorFromLiteOwned(this._lite.getVelocity());
|
|
1813
|
+
}
|
|
1814
|
+
setVelocity(velocity) {
|
|
1815
|
+
this._lite.setVelocity(velocity);
|
|
1816
|
+
}
|
|
1817
|
+
moveWithCollisions(displacement) {
|
|
1818
|
+
this._lite.moveWithCollisions(displacement);
|
|
1819
|
+
}
|
|
1820
|
+
integrate(deltaTime, surfaceInfo, gravity) {
|
|
1821
|
+
this._lite.integrate(deltaTime, { ...surfaceInfo, supportedState: Number(surfaceInfo.supportedState) }, gravity);
|
|
1822
|
+
}
|
|
1823
|
+
checkSupport(deltaTime, direction) {
|
|
1824
|
+
return surfaceInfoFromLite(this._lite.checkSupport(deltaTime, direction));
|
|
1825
|
+
}
|
|
1826
|
+
checkSupportToRef(deltaTime, direction, result) {
|
|
1827
|
+
const value = this._lite.checkSupport(deltaTime, direction);
|
|
1828
|
+
result.isSurfaceDynamic = value.isSurfaceDynamic;
|
|
1829
|
+
result.supportedState = Number(value.supportedState);
|
|
1830
|
+
result.averageSurfaceNormal.set(value.averageSurfaceNormal.x, value.averageSurfaceNormal.y, value.averageSurfaceNormal.z);
|
|
1831
|
+
result.averageSurfaceVelocity.set(value.averageSurfaceVelocity.x, value.averageSurfaceVelocity.y, value.averageSurfaceVelocity.z);
|
|
1832
|
+
result.averageAngularSurfaceVelocity.set(value.averageAngularSurfaceVelocity.x, value.averageAngularSurfaceVelocity.y, value.averageAngularSurfaceVelocity.z);
|
|
1833
|
+
}
|
|
1834
|
+
calculateMovement(deltaTime, forwardWorld, surfaceNormal, currentVelocity, surfaceVelocity, desiredVelocity, upWorld) {
|
|
1835
|
+
return vectorFromLite(this._lite.calculateMovement(deltaTime, forwardWorld, surfaceNormal, currentVelocity, surfaceVelocity, desiredVelocity, upWorld));
|
|
1836
|
+
}
|
|
1837
|
+
calculateMovementToRef(deltaTime, forwardWorld, surfaceNormal, currentVelocity, surfaceVelocity, desiredVelocity, upWorld, result) {
|
|
1838
|
+
return calculatePhysicsCharacterMovementToRef(this._lite, deltaTime, forwardWorld, surfaceNormal, currentVelocity, surfaceVelocity, desiredVelocity, upWorld, result);
|
|
1839
|
+
}
|
|
1840
|
+
dispose() {
|
|
1841
|
+
if (!this._disposed) {
|
|
1842
|
+
this._lite.dispose();
|
|
1843
|
+
this.onTriggerCollisionObservable.clear();
|
|
1844
|
+
this._disposed = true;
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
get up() {
|
|
1848
|
+
return this._up;
|
|
1849
|
+
}
|
|
1850
|
+
set up(value) {
|
|
1851
|
+
this._up = value;
|
|
1852
|
+
this._lite.up = value;
|
|
1853
|
+
}
|
|
1854
|
+
get maxStepHeight() {
|
|
1855
|
+
return this._maxStepHeight;
|
|
1856
|
+
}
|
|
1857
|
+
set maxStepHeight(value) {
|
|
1858
|
+
if (value !== 0) {
|
|
1859
|
+
unsupported(
|
|
1860
|
+
"PhysicsCharacterController.maxStepHeight",
|
|
1861
|
+
"Step-up needs a substantial additional sweep/manifold policy in Lite's controller and cannot be implemented as compat translation."
|
|
1862
|
+
);
|
|
1863
|
+
}
|
|
1864
|
+
this._maxStepHeight = 0;
|
|
1865
|
+
}
|
|
1866
|
+
get footOffset() {
|
|
1867
|
+
return this._footOffset;
|
|
1868
|
+
}
|
|
1869
|
+
set footOffset(value) {
|
|
1870
|
+
if (value !== this._footOffset) {
|
|
1871
|
+
unsupported(
|
|
1872
|
+
"PhysicsCharacterController.footOffset",
|
|
1873
|
+
"Lite derives the character foot from capsule height and does not expose the custom-shape foot-offset policy used by Babylon.js."
|
|
1874
|
+
);
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
_notifyCollision(event) {
|
|
1878
|
+
const collider = getPhysicsBodyWrappers().get(event.collider);
|
|
1879
|
+
if (!collider) {
|
|
1880
|
+
unsupported(
|
|
1881
|
+
"PhysicsCharacterController collision body mapping",
|
|
1882
|
+
"The contacted Lite body was not created through the compat physics API and has no Babylon.js TransformNode wrapper."
|
|
1883
|
+
);
|
|
1884
|
+
}
|
|
1885
|
+
this.onTriggerCollisionObservable.notifyObservers({
|
|
1886
|
+
collider,
|
|
1887
|
+
colliderIndex: 0,
|
|
1888
|
+
impulse: vectorFromLite(event.impulse),
|
|
1889
|
+
impulsePosition: vectorFromLite(event.impulsePosition)
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1892
|
+
get keepDistance() {
|
|
1893
|
+
return this._lite.keepDistance;
|
|
1894
|
+
}
|
|
1895
|
+
set keepDistance(value) {
|
|
1896
|
+
this._lite.keepDistance = value;
|
|
1897
|
+
}
|
|
1898
|
+
get keepContactTolerance() {
|
|
1899
|
+
return this._lite.keepContactTolerance;
|
|
1900
|
+
}
|
|
1901
|
+
set keepContactTolerance(value) {
|
|
1902
|
+
this._lite.keepContactTolerance = value;
|
|
1903
|
+
}
|
|
1904
|
+
get maxCastIterations() {
|
|
1905
|
+
return this._lite.maxCastIterations;
|
|
1906
|
+
}
|
|
1907
|
+
set maxCastIterations(value) {
|
|
1908
|
+
this._lite.maxCastIterations = value;
|
|
1909
|
+
}
|
|
1910
|
+
get penetrationRecoverySpeed() {
|
|
1911
|
+
return this._lite.penetrationRecoverySpeed;
|
|
1912
|
+
}
|
|
1913
|
+
set penetrationRecoverySpeed(value) {
|
|
1914
|
+
this._lite.penetrationRecoverySpeed = value;
|
|
1915
|
+
}
|
|
1916
|
+
get staticFriction() {
|
|
1917
|
+
return this._lite.staticFriction;
|
|
1918
|
+
}
|
|
1919
|
+
set staticFriction(value) {
|
|
1920
|
+
this._lite.staticFriction = value;
|
|
1921
|
+
}
|
|
1922
|
+
get dynamicFriction() {
|
|
1923
|
+
return this._lite.dynamicFriction;
|
|
1924
|
+
}
|
|
1925
|
+
set dynamicFriction(value) {
|
|
1926
|
+
this._lite.dynamicFriction = value;
|
|
1927
|
+
}
|
|
1928
|
+
get maxSlopeCosine() {
|
|
1929
|
+
return this._lite.maxSlopeCosine;
|
|
1930
|
+
}
|
|
1931
|
+
set maxSlopeCosine(value) {
|
|
1932
|
+
this._lite.maxSlopeCosine = value;
|
|
1933
|
+
}
|
|
1934
|
+
get maxCharacterSpeedForSolver() {
|
|
1935
|
+
return this._lite.maxCharacterSpeedForSolver;
|
|
1936
|
+
}
|
|
1937
|
+
set maxCharacterSpeedForSolver(value) {
|
|
1938
|
+
this._lite.maxCharacterSpeedForSolver = value;
|
|
1939
|
+
}
|
|
1940
|
+
get characterStrength() {
|
|
1941
|
+
return this._lite.characterStrength;
|
|
1942
|
+
}
|
|
1943
|
+
set characterStrength(value) {
|
|
1944
|
+
this._lite.characterStrength = value;
|
|
1945
|
+
}
|
|
1946
|
+
get acceleration() {
|
|
1947
|
+
return this._lite.acceleration;
|
|
1948
|
+
}
|
|
1949
|
+
set acceleration(value) {
|
|
1950
|
+
this._lite.acceleration = value;
|
|
1951
|
+
}
|
|
1952
|
+
get maxAcceleration() {
|
|
1953
|
+
return this._lite.maxAcceleration;
|
|
1954
|
+
}
|
|
1955
|
+
set maxAcceleration(value) {
|
|
1956
|
+
this._lite.maxAcceleration = value;
|
|
1957
|
+
}
|
|
1958
|
+
get characterMass() {
|
|
1959
|
+
return this._lite.characterMass;
|
|
1960
|
+
}
|
|
1961
|
+
set characterMass(value) {
|
|
1962
|
+
this._lite.characterMass = value;
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1707
1965
|
class PhysicsAggregate {
|
|
1708
1966
|
constructor(transformNode, type, options = { mass: 0 }, scene) {
|
|
1709
1967
|
__publicField(this, "transformNode");
|
|
@@ -8902,6 +9160,7 @@ export {
|
|
|
8902
9160
|
CameraGizmo,
|
|
8903
9161
|
CannonJSPlugin,
|
|
8904
9162
|
CascadedShadowGenerator,
|
|
9163
|
+
CharacterSupportedState,
|
|
8905
9164
|
ChromaticAberrationPostProcess,
|
|
8906
9165
|
CircleEase,
|
|
8907
9166
|
ClusteredLightContainer,
|
|
@@ -9058,6 +9317,7 @@ export {
|
|
|
9058
9317
|
PerformanceMonitor,
|
|
9059
9318
|
PhysicsAggregate,
|
|
9060
9319
|
PhysicsBody,
|
|
9320
|
+
PhysicsCharacterController,
|
|
9061
9321
|
PhysicsConstraintType,
|
|
9062
9322
|
PhysicsEngine,
|
|
9063
9323
|
PhysicsMotionType,
|