@babylonjs/lite-compat 0.0.1-preview.54961

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/navigation.js ADDED
@@ -0,0 +1,139 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import { createNavigationPluginAsync, updateNavCrowd, getAgentPosition, addAgent, agentGoto, createNavMesh, addCylinderObstacle, addBoxObstacle, removeObstacle, updateNavMeshObstacles, createDebugNavMeshGeometry, createMeshFromData, addToScene, getClosestPoint, computePath, raycast, createNavCrowd } from "@babylonjs/lite";
5
+ import { V as Vector3, a as Mesh } from "./meshes-BQZyNGmT.js";
6
+ class RecastJSCrowd {
7
+ constructor(lite, plugin, scene) {
8
+ /** @internal */
9
+ __publicField(this, "_lite");
10
+ __publicField(this, "_transforms", /* @__PURE__ */ new Map());
11
+ __publicField(this, "_plugin");
12
+ this._lite = lite;
13
+ this._plugin = plugin;
14
+ scene.onBeforeRenderObservable.add(() => {
15
+ updateNavCrowd(this._lite, 1 / 60 * this._plugin.timeFactor);
16
+ for (const [index, transform] of this._transforms) {
17
+ const p = getAgentPosition(this._lite, index);
18
+ transform.position.set(p.x, p.y, p.z);
19
+ }
20
+ });
21
+ }
22
+ /** Babylon.js `crowd.addAgent(pos, parameters, transform)` — returns the agent index. */
23
+ addAgent(pos, parameters, transform) {
24
+ const index = addAgent(this._lite, { x: pos.x, y: pos.y, z: pos.z }, parameters);
25
+ this._transforms.set(index, transform);
26
+ return index;
27
+ }
28
+ /** Babylon.js `crowd.getAgentPosition(index)`. */
29
+ getAgentPosition(index) {
30
+ const p = getAgentPosition(this._lite, index);
31
+ return new Vector3(p.x, p.y, p.z);
32
+ }
33
+ /** Babylon.js `crowd.agentGoto(index, destination)` — request the agent to move toward a target. */
34
+ agentGoto(index, destination) {
35
+ agentGoto(this._lite, index, { x: destination.x, y: destination.y, z: destination.z });
36
+ }
37
+ }
38
+ class RecastNavigationJSPluginV2 {
39
+ constructor(lite) {
40
+ /** @internal */
41
+ __publicField(this, "_lite");
42
+ /**
43
+ * Babylon.js `plugin.timeFactor` — multiplier applied to each crowd update step.
44
+ * `0` pauses crowd movement (used by parity tests); default `1`.
45
+ */
46
+ __publicField(this, "timeFactor", 1);
47
+ this._lite = lite;
48
+ }
49
+ /**
50
+ * Babylon.js `plugin.createNavMesh(meshes, parameters)`. Returns a
51
+ * `{ navMesh, tileCache }` handle (both reference this plugin) so scenes using
52
+ * the tile-cache obstacle API can pass them to {@link WaitForFullTileCacheUpdate}.
53
+ * Scenes that ignore the return (the non-obstacle navmesh scenes) are unaffected.
54
+ */
55
+ createNavMesh(meshes, parameters) {
56
+ createNavMesh(
57
+ this._lite,
58
+ meshes.map((m) => m._lite),
59
+ parameters
60
+ );
61
+ return { navMesh: this, tileCache: this };
62
+ }
63
+ /** Babylon.js `plugin.addCylinderObstacle(position, radius, height)` — tile-cache obstacle. */
64
+ addCylinderObstacle(position, radius, height) {
65
+ return addCylinderObstacle(this._lite, { x: position.x, y: position.y, z: position.z }, radius, height);
66
+ }
67
+ /** Babylon.js `plugin.addBoxObstacle(position, extent, angle)` — tile-cache obstacle (`extent` = half-extents). */
68
+ addBoxObstacle(position, extent, angle) {
69
+ return addBoxObstacle(this._lite, { x: position.x, y: position.y, z: position.z }, { x: extent.x, y: extent.y, z: extent.z }, angle);
70
+ }
71
+ /** Babylon.js `plugin.removeObstacle(obstacle)` — remove a previously-added tile-cache obstacle. */
72
+ removeObstacle(obstacle) {
73
+ removeObstacle(this._lite, obstacle);
74
+ }
75
+ /** @internal Apply pending tile-cache obstacle updates (drives {@link WaitForFullTileCacheUpdate}). */
76
+ _updateObstacles() {
77
+ updateNavMeshObstacles(this._lite);
78
+ }
79
+ /** Babylon.js `plugin.createDebugNavMesh(scene)` — builds a renderable debug mesh. */
80
+ createDebugNavMesh(scene) {
81
+ const geo = createDebugNavMeshGeometry(this._lite);
82
+ const engine = scene.getEngine()._lite;
83
+ const lite = createMeshFromData(engine, "navDebugMesh", geo.positions, geo.normals, geo.indices);
84
+ const mesh = new Mesh("navDebugMesh", lite, scene);
85
+ scene._deferAdd(() => {
86
+ const mat = mesh.material;
87
+ mat == null ? void 0 : mat._ensureRenderable(engine);
88
+ if (mat == null ? void 0 : mat._lite) {
89
+ mesh._lite.material = mat._lite;
90
+ }
91
+ addToScene(scene._lite, mesh._lite);
92
+ });
93
+ return mesh;
94
+ }
95
+ /** Babylon.js `plugin.getClosestPoint(position)` — snap to the navmesh. */
96
+ getClosestPoint(position) {
97
+ const p = getClosestPoint(this._lite, { x: position.x, y: position.y, z: position.z });
98
+ return new Vector3(p.x, p.y, p.z);
99
+ }
100
+ /** Babylon.js `plugin.computePath(start, end)` — navmesh-snapped path as world points. */
101
+ computePath(start, end) {
102
+ const points = computePath(this._lite, { x: start.x, y: start.y, z: start.z }, { x: end.x, y: end.y, z: end.z });
103
+ return points.map((p) => new Vector3(p.x, p.y, p.z));
104
+ }
105
+ /** Babylon.js `plugin.computePathSmooth(start, end)` — alias of {@link computePath} (Lite smooths internally). */
106
+ computePathSmooth(start, end) {
107
+ return this.computePath(start, end);
108
+ }
109
+ /**
110
+ * Babylon.js `plugin.raycast(start, end)` — walkability raycast on the navmesh.
111
+ * Returns `{ hit, hitPoint? }` (`hitPoint` is a `Vector3` when `hit`).
112
+ */
113
+ raycast(start, end) {
114
+ const r = raycast(this._lite, { x: start.x, y: start.y, z: start.z }, { x: end.x, y: end.y, z: end.z });
115
+ return r.hit && r.hitPoint ? { hit: true, hitPoint: new Vector3(r.hitPoint.x, r.hitPoint.y, r.hitPoint.z) } : { hit: false };
116
+ }
117
+ /** Babylon.js `plugin.createCrowd(maxAgents, maxAgentRadius, scene)`. */
118
+ createCrowd(maxAgents, maxAgentRadius, scene) {
119
+ const crowd = createNavCrowd(this._lite, maxAgents, maxAgentRadius);
120
+ return new RecastJSCrowd(crowd, this, scene);
121
+ }
122
+ }
123
+ async function CreateNavigationPluginAsync(_options) {
124
+ const lite = await createNavigationPluginAsync({ locateFile: () => "/recast-navigation.wasm" });
125
+ return new RecastNavigationJSPluginV2(lite);
126
+ }
127
+ function WaitForFullTileCacheUpdate(navMesh, _tileCache) {
128
+ const plugin = navMesh;
129
+ if (plugin && typeof plugin._updateObstacles === "function") {
130
+ plugin._updateObstacles();
131
+ }
132
+ }
133
+ export {
134
+ CreateNavigationPluginAsync,
135
+ RecastJSCrowd,
136
+ RecastNavigationJSPluginV2,
137
+ WaitForFullTileCacheUpdate
138
+ };
139
+ //# sourceMappingURL=navigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"navigation.js","sources":["../src/navigation/navigation.ts"],"sourcesContent":["/**\n * Babylon.js `@babylonjs/addons/navigation` compatibility wrapper over Babylon\n * Lite's native navigation API (`createNavigationPluginAsync` / `createNavMesh` /\n * `createDebugNavMeshGeometry` / `createNavCrowd` / …).\n *\n * The Babylon.js navigation addon (`RecastNavigationJSPluginV2`, created via\n * `CreateNavigationPluginAsync`) is a thin wrapper around `recast-navigation-js`.\n * Babylon Lite ships its own Recast V2 integration with the same capabilities, so\n * this module mirrors the addon's public plugin/crowd surface and delegates to\n * Lite. The Recast instance the scene injects via `{ instance }` is ignored —\n * Lite loads its own Recast wasm (served at `/recast-navigation.wasm`).\n *\n * Only the surface exercised by ported scenes is implemented (`createNavMesh`,\n * `createDebugNavMesh`, `getClosestPoint`, `createCrowd` + `addAgent`); the rest\n * of the addon API is intentionally omitted.\n */\n\nimport {\n createNavigationPluginAsync as liteCreateNavigationPluginAsync,\n createNavMesh as liteCreateNavMesh,\n createDebugNavMeshGeometry as liteCreateDebugNavMeshGeometry,\n getClosestPoint as liteGetClosestPoint,\n computePath as liteComputePath,\n raycast as liteRaycast,\n createNavCrowd as liteCreateNavCrowd,\n addAgent as liteAddAgent,\n getAgentPosition as liteGetAgentPosition,\n agentGoto as liteAgentGoto,\n updateNavCrowd as liteUpdateNavCrowd,\n addBoxObstacle as liteAddBoxObstacle,\n addCylinderObstacle as liteAddCylinderObstacle,\n removeObstacle as liteRemoveObstacle,\n updateNavMeshObstacles as liteUpdateNavMeshObstacles,\n createMeshFromData,\n addToScene,\n type NavigationPlugin as LiteNavigationPlugin,\n type NavCrowd as LiteNavCrowd,\n type Mesh as LiteMesh,\n type ObstacleHandle as LiteObstacleHandle,\n} from \"babylon-lite\";\n\nimport { Mesh } from \"../meshes/meshes.js\";\nimport { Vector3 } from \"../math/vector.js\";\nimport type { Scene } from \"../scene/scene.js\";\n\ninterface Vec3Like {\n x: number;\n y: number;\n z: number;\n}\n\ninterface AgentTransform {\n position: { set(x: number, y: number, z: number): unknown };\n}\n\n/**\n * Result of {@link RecastNavigationJSPluginV2.createNavMesh}. Babylon.js's\n * tile-cache navmesh build returns `{ navMesh, tileCache }`; here both reference\n * the plugin so {@link WaitForFullTileCacheUpdate} can reach it.\n */\ninterface NavMeshResult {\n navMesh: RecastNavigationJSPluginV2;\n tileCache: RecastNavigationJSPluginV2;\n}\n\n/** Babylon.js `IAgentParameters` subset accepted by `RecastJSCrowd.addAgent`. */\ninterface AgentParameters {\n radius: number;\n height: number;\n maxAcceleration: number;\n maxSpeed: number;\n collisionQueryRange: number;\n pathOptimizationRange: number;\n separationWeight: number;\n reachRadius?: number;\n}\n\n/**\n * Babylon.js `RecastJSCrowd` (subset) — owns crowd agents and syncs each agent's\n * Babylon transform to the simulated position every frame, exactly like the addon.\n */\nclass RecastJSCrowd {\n /** @internal */ public readonly _lite: LiteNavCrowd;\n private readonly _transforms = new Map<number, AgentTransform>();\n private readonly _plugin: RecastNavigationJSPluginV2;\n\n public constructor(lite: LiteNavCrowd, plugin: RecastNavigationJSPluginV2, scene: Scene) {\n this._lite = lite;\n this._plugin = plugin;\n // Babylon.js' crowd advances the simulation and writes back agent transforms\n // on the scene's before-render tick; mirror that over Lite's manual crowd update.\n // The plugin's `timeFactor` scales the step (0 freezes the crowd — used by parity\n // tests via `?freeze=1`).\n scene.onBeforeRenderObservable.add(() => {\n liteUpdateNavCrowd(this._lite, (1 / 60) * this._plugin.timeFactor);\n for (const [index, transform] of this._transforms) {\n const p = liteGetAgentPosition(this._lite, index);\n transform.position.set(p.x, p.y, p.z);\n }\n });\n }\n\n /** Babylon.js `crowd.addAgent(pos, parameters, transform)` — returns the agent index. */\n public addAgent(pos: Vec3Like, parameters: AgentParameters, transform: AgentTransform): number {\n const index = liteAddAgent(this._lite, { x: pos.x, y: pos.y, z: pos.z }, parameters);\n this._transforms.set(index, transform);\n return index;\n }\n\n /** Babylon.js `crowd.getAgentPosition(index)`. */\n public getAgentPosition(index: number): Vector3 {\n const p = liteGetAgentPosition(this._lite, index);\n return new Vector3(p.x, p.y, p.z);\n }\n\n /** Babylon.js `crowd.agentGoto(index, destination)` — request the agent to move toward a target. */\n public agentGoto(index: number, destination: Vec3Like): void {\n liteAgentGoto(this._lite, index, { x: destination.x, y: destination.y, z: destination.z });\n }\n}\n\n/**\n * Babylon.js `RecastNavigationJSPluginV2` (subset) over Babylon Lite navigation.\n */\nclass RecastNavigationJSPluginV2 {\n /** @internal */ public readonly _lite: LiteNavigationPlugin;\n /**\n * Babylon.js `plugin.timeFactor` — multiplier applied to each crowd update step.\n * `0` pauses crowd movement (used by parity tests); default `1`.\n */\n public timeFactor = 1;\n\n public constructor(lite: LiteNavigationPlugin) {\n this._lite = lite;\n }\n\n /**\n * Babylon.js `plugin.createNavMesh(meshes, parameters)`. Returns a\n * `{ navMesh, tileCache }` handle (both reference this plugin) so scenes using\n * the tile-cache obstacle API can pass them to {@link WaitForFullTileCacheUpdate}.\n * Scenes that ignore the return (the non-obstacle navmesh scenes) are unaffected.\n */\n public createNavMesh(meshes: Array<{ _lite: LiteMesh }>, parameters: Record<string, unknown>): NavMeshResult {\n liteCreateNavMesh(\n this._lite,\n meshes.map((m) => m._lite),\n parameters as never\n );\n return { navMesh: this, tileCache: this };\n }\n\n /** Babylon.js `plugin.addCylinderObstacle(position, radius, height)` — tile-cache obstacle. */\n public addCylinderObstacle(position: Vec3Like, radius: number, height: number): LiteObstacleHandle | null {\n return liteAddCylinderObstacle(this._lite, { x: position.x, y: position.y, z: position.z }, radius, height);\n }\n\n /** Babylon.js `plugin.addBoxObstacle(position, extent, angle)` — tile-cache obstacle (`extent` = half-extents). */\n public addBoxObstacle(position: Vec3Like, extent: Vec3Like, angle: number): LiteObstacleHandle | null {\n return liteAddBoxObstacle(this._lite, { x: position.x, y: position.y, z: position.z }, { x: extent.x, y: extent.y, z: extent.z }, angle);\n }\n\n /** Babylon.js `plugin.removeObstacle(obstacle)` — remove a previously-added tile-cache obstacle. */\n public removeObstacle(obstacle: LiteObstacleHandle): void {\n liteRemoveObstacle(this._lite, obstacle);\n }\n\n /** @internal Apply pending tile-cache obstacle updates (drives {@link WaitForFullTileCacheUpdate}). */\n public _updateObstacles(): void {\n liteUpdateNavMeshObstacles(this._lite);\n }\n\n /** Babylon.js `plugin.createDebugNavMesh(scene)` — builds a renderable debug mesh. */\n public createDebugNavMesh(scene: Scene): Mesh {\n const geo = liteCreateDebugNavMeshGeometry(this._lite);\n const engine = scene.getEngine()._lite;\n const lite = createMeshFromData(engine, \"navDebugMesh\", geo.positions, geo.normals, geo.indices);\n const mesh = new Mesh(\"navDebugMesh\", lite, scene);\n scene._deferAdd(() => {\n const mat = mesh.material;\n mat?._ensureRenderable(engine);\n if (mat?._lite) {\n mesh._lite.material = mat._lite as never;\n }\n addToScene(scene._lite, mesh._lite);\n });\n return mesh;\n }\n\n /** Babylon.js `plugin.getClosestPoint(position)` — snap to the navmesh. */\n public getClosestPoint(position: Vec3Like): Vector3 {\n const p = liteGetClosestPoint(this._lite, { x: position.x, y: position.y, z: position.z });\n return new Vector3(p.x, p.y, p.z);\n }\n\n /** Babylon.js `plugin.computePath(start, end)` — navmesh-snapped path as world points. */\n public computePath(start: Vec3Like, end: Vec3Like): Vector3[] {\n const points = liteComputePath(this._lite, { x: start.x, y: start.y, z: start.z }, { x: end.x, y: end.y, z: end.z });\n return points.map((p) => new Vector3(p.x, p.y, p.z));\n }\n\n /** Babylon.js `plugin.computePathSmooth(start, end)` — alias of {@link computePath} (Lite smooths internally). */\n public computePathSmooth(start: Vec3Like, end: Vec3Like): Vector3[] {\n return this.computePath(start, end);\n }\n\n /**\n * Babylon.js `plugin.raycast(start, end)` — walkability raycast on the navmesh.\n * Returns `{ hit, hitPoint? }` (`hitPoint` is a `Vector3` when `hit`).\n */\n public raycast(start: Vec3Like, end: Vec3Like): { hit: boolean; hitPoint?: Vector3 } {\n const r = liteRaycast(this._lite, { x: start.x, y: start.y, z: start.z }, { x: end.x, y: end.y, z: end.z });\n return r.hit && r.hitPoint ? { hit: true, hitPoint: new Vector3(r.hitPoint.x, r.hitPoint.y, r.hitPoint.z) } : { hit: false };\n }\n\n /** Babylon.js `plugin.createCrowd(maxAgents, maxAgentRadius, scene)`. */\n public createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): RecastJSCrowd {\n const crowd = liteCreateNavCrowd(this._lite, maxAgents, maxAgentRadius);\n return new RecastJSCrowd(crowd, this, scene);\n }\n}\n\n/**\n * Babylon.js `@babylonjs/addons/navigation` `CreateNavigationPluginAsync`. The\n * injected Recast `instance` (if any) is ignored — Babylon Lite loads its own\n * Recast wasm from `/recast-navigation.wasm`.\n */\nexport async function CreateNavigationPluginAsync(_options?: { version?: string; instance?: unknown }): Promise<RecastNavigationJSPluginV2> {\n const lite = await liteCreateNavigationPluginAsync({ locateFile: () => \"/recast-navigation.wasm\" });\n return new RecastNavigationJSPluginV2(lite);\n}\n\nexport { RecastNavigationJSPluginV2, RecastJSCrowd };\n\n/**\n * Babylon.js `@babylonjs/addons/navigation/common/tile-cache`\n * `WaitForFullTileCacheUpdate(navMesh, tileCache)` — block until pending\n * tile-cache obstacle updates are applied. The addon takes the raw navMesh /\n * tileCache; here `navMesh` is the compat plugin (returned from `createNavMesh`),\n * so this delegates to Babylon Lite's `updateNavMeshObstacles`.\n */\nexport function WaitForFullTileCacheUpdate(navMesh: unknown, _tileCache?: unknown): void {\n const plugin = navMesh as RecastNavigationJSPluginV2 | undefined;\n if (plugin && typeof plugin._updateObstacles === \"function\") {\n plugin._updateObstacles();\n }\n}\n"],"names":["liteUpdateNavCrowd","liteGetAgentPosition","liteAddAgent","liteAgentGoto","liteCreateNavMesh","liteAddCylinderObstacle","liteAddBoxObstacle","liteRemoveObstacle","liteUpdateNavMeshObstacles","liteCreateDebugNavMeshGeometry","liteGetClosestPoint","liteComputePath","liteRaycast","liteCreateNavCrowd","liteCreateNavigationPluginAsync"],"mappings":";;;;;AAiFA,MAAM,cAAc;AAAA,EAKT,YAAY,MAAoB,QAAoC,OAAc;AAJxD;AAAA;AAChB,2DAAkB,IAAA;AAClB;AAGb,SAAK,QAAQ;AACb,SAAK,UAAU;AAKf,UAAM,yBAAyB,IAAI,MAAM;AACrCA,qBAAmB,KAAK,OAAQ,IAAI,KAAM,KAAK,QAAQ,UAAU;AACjE,iBAAW,CAAC,OAAO,SAAS,KAAK,KAAK,aAAa;AAC/C,cAAM,IAAIC,iBAAqB,KAAK,OAAO,KAAK;AAChD,kBAAU,SAAS,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAAA,MACxC;AAAA,IACJ,CAAC;AAAA,EACL;AAAA;AAAA,EAGO,SAAS,KAAe,YAA6B,WAAmC;AAC3F,UAAM,QAAQC,SAAa,KAAK,OAAO,EAAE,GAAG,IAAI,GAAG,GAAG,IAAI,GAAG,GAAG,IAAI,EAAA,GAAK,UAAU;AACnF,SAAK,YAAY,IAAI,OAAO,SAAS;AACrC,WAAO;AAAA,EACX;AAAA;AAAA,EAGO,iBAAiB,OAAwB;AAC5C,UAAM,IAAID,iBAAqB,KAAK,OAAO,KAAK;AAChD,WAAO,IAAI,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAAA,EACpC;AA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E,KAAK,MAAA;AAAA,EACzH;AAAA;AAAA,EAGO,YAAY,WAAmB,gBAAwB,OAA6B;AACvF,UAAM,QAAQC,eAAmB,KAAK,OAAO,WAAW,cAAc;AACtE,WAAO,IAAI,cAAc,OAAO,MAAM,KAAK;AAAA,EAC/C;AACJ;AAOA,eAAsB,4BAA4B,UAA0F;AACxI,QAAM,OAAO,MAAMC,4BAAgC,EAAE,YAAY,MAAM,2BAA2B;AAClG,SAAO,IAAI,2BAA2B,IAAI;AAC9C;AAWO,SAAS,2BAA2B,SAAkB,YAA4B;AACrF,QAAM,SAAS;AACf,MAAI,UAAU,OAAO,OAAO,qBAAqB,YAAY;AACzD,WAAO,iBAAA;AAAA,EACX;AACJ;"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@babylonjs/lite-compat",
3
+ "version": "0.0.1-preview.54961",
4
+ "license": "Apache-2.0",
5
+ "type": "module",
6
+ "description": "Opt-in Babylon.js-shaped compatibility layer implemented on top of the Babylon Lite public API. Provides a migration runway from Babylon.js to Babylon Lite.",
7
+ "main": "./index.js",
8
+ "module": "./index.js",
9
+ "types": "./index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./index.js",
13
+ "types": "./index.d.ts"
14
+ },
15
+ "./vite": {
16
+ "import": "./vite.js",
17
+ "types": "./vite.d.ts"
18
+ },
19
+ "./rollup": {
20
+ "import": "./rollup.js",
21
+ "types": "./rollup.d.ts"
22
+ },
23
+ "./webpack": {
24
+ "import": "./webpack.js",
25
+ "types": "./webpack.d.ts"
26
+ },
27
+ "./esbuild": {
28
+ "import": "./esbuild.js",
29
+ "types": "./esbuild.d.ts"
30
+ },
31
+ "./navigation": {
32
+ "import": "./navigation.js",
33
+ "types": "./navigation.d.ts"
34
+ },
35
+ "./recast-shim": {
36
+ "import": "./recast-shim.js",
37
+ "types": "./recast-shim.d.ts"
38
+ }
39
+ },
40
+ "sideEffects": false,
41
+ "peerDependencies": {
42
+ "@babylonjs/lite": "*"
43
+ },
44
+ "peerDependenciesMeta": {
45
+ "vite": {
46
+ "optional": true
47
+ }
48
+ },
49
+ "babylonLiteRelease": {
50
+ "azureBuildId": "54961",
51
+ "sourceVersion": "fbf5a62071dc7fce7c0a00f3a16080f3f5932a91",
52
+ "builtAgainstLite": "1.1.0"
53
+ }
54
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * No-op stand-in for `@recast-navigation/core` / `@recast-navigation/generators`
3
+ * inside the compat (`?compat`) subtree.
4
+ *
5
+ * Babylon.js navigation scenes import the raw `@recast-navigation` packages, call
6
+ * `init()`, and pass `{ ...RecastCore, ...RecastGenerators }` into
7
+ * `CreateNavigationPluginAsync({ instance })`. The compat navigation wrapper
8
+ * ([navigation/navigation.ts](navigation.ts)) ignores that injected instance and
9
+ * drives Babylon Lite's own navigation API (which loads its own Recast wasm), so
10
+ * the scene's direct Recast usage is reduced to a harmless no-op here — avoiding a
11
+ * second wasm download.
12
+ */
13
+ /** Babylon.js scenes call `await RecastCore.init()`; Lite loads Recast itself, so no-op. */
14
+ export declare function init(): Promise<void>;
15
+
16
+ export { }
package/recast-shim.js ADDED
@@ -0,0 +1,6 @@
1
+ async function init() {
2
+ }
3
+ export {
4
+ init
5
+ };
6
+ //# sourceMappingURL=recast-shim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recast-shim.js","sources":["../src/navigation/recast-shim.ts"],"sourcesContent":["/**\n * No-op stand-in for `@recast-navigation/core` / `@recast-navigation/generators`\n * inside the compat (`?compat`) subtree.\n *\n * Babylon.js navigation scenes import the raw `@recast-navigation` packages, call\n * `init()`, and pass `{ ...RecastCore, ...RecastGenerators }` into\n * `CreateNavigationPluginAsync({ instance })`. The compat navigation wrapper\n * ([navigation/navigation.ts](navigation.ts)) ignores that injected instance and\n * drives Babylon Lite's own navigation API (which loads its own Recast wasm), so\n * the scene's direct Recast usage is reduced to a harmless no-op here — avoiding a\n * second wasm download.\n */\n\n/** Babylon.js scenes call `await RecastCore.init()`; Lite loads Recast itself, so no-op. */\nexport async function init(): Promise<void> {\n // Intentionally empty — Babylon Lite's navigation plugin loads Recast internally.\n}\n\n// `{ ...RecastCore }` / `{ ...RecastGenerators }` spreads collect nothing else of use;\n// the compat navigation wrapper does not read the injected instance.\n"],"names":[],"mappings":"AAcA,eAAsB,OAAsB;AAE5C;"}
package/rollup.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Create the Babylon Lite compat Rollup plugin. Add it to your config's
3
+ * `plugins` array and keep your Babylon.js imports exactly as they are.
4
+ */
5
+ export declare function liteCompat(): RollupPlugin;
6
+
7
+ /** Minimal structural type for the Rollup plugin object this adapter returns. */
8
+ declare interface RollupPlugin {
9
+ name: string;
10
+ resolveId(this: RollupResolveContext, source: string, importer: string | undefined): Promise<string | null>;
11
+ }
12
+
13
+ /**
14
+ * A reusable Rollup plugin that lets an existing Babylon.js project run on
15
+ * Babylon Lite **without changing its import statements**. It rewrites
16
+ * `@babylonjs/core`, `@babylonjs/loaders`, `@babylonjs/addons`,
17
+ * `@babylonjs/materials`, and `@recast-navigation/*` imports
18
+ * onto the matching `@babylonjs/lite-compat` modules at resolve time.
19
+ *
20
+ * Usage (`rollup.config.js`):
21
+ *
22
+ * ```js
23
+ * import { liteCompat } from "@babylonjs/lite-compat/rollup";
24
+ *
25
+ * export default {
26
+ * plugins: [liteCompat()],
27
+ * };
28
+ * ```
29
+ *
30
+ * Rolldown shares Rollup's plugin API, so this adapter works there too. The
31
+ * redirect table is shared with every other adapter via
32
+ * [bundler-resolve.ts](bundler-resolve.ts).
33
+ */
34
+ /**
35
+ * Minimal structural type for the Rollup `PluginContext.resolve` available on
36
+ * `this` inside `resolveId`. Typed locally so the adapter carries no `rollup`
37
+ * dependency of its own.
38
+ */
39
+ declare interface RollupResolveContext {
40
+ resolve(source: string, importer: string | undefined, options: {
41
+ skipSelf?: boolean;
42
+ }): Promise<{
43
+ id: string;
44
+ external: boolean | string;
45
+ } | null>;
46
+ }
47
+
48
+ export { }
package/rollup.js ADDED
@@ -0,0 +1,18 @@
1
+ import { r as resolveCompatSpecifier } from "./bundler-resolve-0pEkTP9X.js";
2
+ function liteCompat() {
3
+ return {
4
+ name: "babylonjs-lite-compat",
5
+ async resolveId(source, importer) {
6
+ const specifier = resolveCompatSpecifier(source);
7
+ if (!specifier) {
8
+ return null;
9
+ }
10
+ const resolved = await this.resolve(specifier, importer, { skipSelf: true });
11
+ return (resolved == null ? void 0 : resolved.id) ?? null;
12
+ }
13
+ };
14
+ }
15
+ export {
16
+ liteCompat
17
+ };
18
+ //# sourceMappingURL=rollup.js.map
package/rollup.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rollup.js","sources":["../src/rollup.ts"],"sourcesContent":["/**\n * A reusable Rollup plugin that lets an existing Babylon.js project run on\n * Babylon Lite **without changing its import statements**. It rewrites\n * `@babylonjs/core`, `@babylonjs/loaders`, `@babylonjs/addons`,\n * `@babylonjs/materials`, and `@recast-navigation/*` imports\n * onto the matching `@babylonjs/lite-compat` modules at resolve time.\n *\n * Usage (`rollup.config.js`):\n *\n * ```js\n * import { liteCompat } from \"@babylonjs/lite-compat/rollup\";\n *\n * export default {\n * plugins: [liteCompat()],\n * };\n * ```\n *\n * Rolldown shares Rollup's plugin API, so this adapter works there too. The\n * redirect table is shared with every other adapter via\n * [bundler-resolve.ts](bundler-resolve.ts).\n */\n\nimport { resolveCompatSpecifier } from \"./bundler-resolve.js\";\n\n/**\n * Minimal structural type for the Rollup `PluginContext.resolve` available on\n * `this` inside `resolveId`. Typed locally so the adapter carries no `rollup`\n * dependency of its own.\n */\ninterface RollupResolveContext {\n resolve(source: string, importer: string | undefined, options: { skipSelf?: boolean }): Promise<{ id: string; external: boolean | string } | null>;\n}\n\n/** Minimal structural type for the Rollup plugin object this adapter returns. */\ninterface RollupPlugin {\n name: string;\n resolveId(this: RollupResolveContext, source: string, importer: string | undefined): Promise<string | null>;\n}\n\n/**\n * Create the Babylon Lite compat Rollup plugin. Add it to your config's\n * `plugins` array and keep your Babylon.js imports exactly as they are.\n */\nexport function liteCompat(): RollupPlugin {\n return {\n name: \"babylonjs-lite-compat\",\n async resolveId(source, importer) {\n const specifier = resolveCompatSpecifier(source);\n if (!specifier) {\n return null;\n }\n // Re-run resolution on the compat specifier so the package's `exports`\n // map (source vs. dist) is honored. `skipSelf` prevents re-entering\n // this same plugin for the redirect target.\n const resolved = await this.resolve(specifier, importer, { skipSelf: true });\n return resolved?.id ?? null;\n },\n };\n}\n"],"names":[],"mappings":";AA2CO,SAAS,aAA2B;AACvC,SAAO;AAAA,IACH,MAAM;AAAA,IACN,MAAM,UAAU,QAAQ,UAAU;AAC9B,YAAM,YAAY,uBAAuB,MAAM;AAC/C,UAAI,CAAC,WAAW;AACZ,eAAO;AAAA,MACX;AAIA,YAAM,WAAW,MAAM,KAAK,QAAQ,WAAW,UAAU,EAAE,UAAU,MAAM;AAC3E,cAAO,qCAAU,OAAM;AAAA,IAC3B;AAAA,EAAA;AAER;"}
package/vite.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { Plugin as Plugin_2 } from 'vite';
2
+
3
+ /**
4
+ * Create the Babylon Lite compat Vite plugin. Add it to your config's `plugins`
5
+ * array and keep your Babylon.js imports exactly as they are — they resolve to
6
+ * the compat layer instead of Babylon.js.
7
+ */
8
+ export declare function liteCompat(): Plugin_2;
9
+
10
+ export { }
package/vite.js ADDED
@@ -0,0 +1,24 @@
1
+ import { r as resolveCompatSpecifier } from "./bundler-resolve-0pEkTP9X.js";
2
+ function liteCompat() {
3
+ return {
4
+ name: "babylonjs-lite-compat",
5
+ // `pre` so the redirect happens before Vite's own resolver/optimizer sees
6
+ // the original Babylon.js specifier.
7
+ enforce: "pre",
8
+ async resolveId(source, importer, options) {
9
+ const specifier = resolveCompatSpecifier(source);
10
+ if (!specifier) {
11
+ return null;
12
+ }
13
+ const resolved = await this.resolve(specifier, importer, {
14
+ ...options,
15
+ skipSelf: true
16
+ });
17
+ return (resolved == null ? void 0 : resolved.id) ?? null;
18
+ }
19
+ };
20
+ }
21
+ export {
22
+ liteCompat
23
+ };
24
+ //# sourceMappingURL=vite.js.map
package/vite.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.js","sources":["../src/vite.ts"],"sourcesContent":["/**\n * A reusable Vite plugin that lets an existing Babylon.js project run on Babylon\n * Lite **without changing its import statements**. It rewrites `@babylonjs/core`,\n * `@babylonjs/loaders`, `@babylonjs/addons`, `@babylonjs/materials`, and\n * `@recast-navigation/*` imports\n * onto the matching `@babylonjs/lite-compat` modules at resolve time, so the\n * compat layer (which runs on Babylon Lite's WebGPU renderer) is loaded in place\n * of Babylon.js.\n *\n * Usage (`vite.config.ts`):\n *\n * ```ts\n * import { defineConfig } from \"vite\";\n * import { liteCompat } from \"@babylonjs/lite-compat/vite\";\n *\n * export default defineConfig({\n * plugins: [liteCompat()],\n * });\n * ```\n *\n * The redirect table is shared with the other bundler adapters and the lab\n * harness via [bundler-resolve.ts](bundler-resolve.ts) so they can never diverge.\n */\n\nimport type { Plugin } from \"vite\";\nimport { resolveCompatSpecifier } from \"./bundler-resolve.js\";\n\n/**\n * Create the Babylon Lite compat Vite plugin. Add it to your config's `plugins`\n * array and keep your Babylon.js imports exactly as they are — they resolve to\n * the compat layer instead of Babylon.js.\n */\nexport function liteCompat(): Plugin {\n return {\n name: \"babylonjs-lite-compat\",\n // `pre` so the redirect happens before Vite's own resolver/optimizer sees\n // the original Babylon.js specifier.\n enforce: \"pre\",\n async resolveId(source, importer, options) {\n const specifier = resolveCompatSpecifier(source);\n if (!specifier) {\n return null;\n }\n // Re-run resolution on the compat specifier so the package's `exports`\n // map (source vs. dist) is honored. `skipSelf` prevents re-entering\n // this same plugin for the redirect target.\n const resolved = await this.resolve(specifier, importer, {\n ...options,\n skipSelf: true,\n });\n return resolved?.id ?? null;\n },\n };\n}\n"],"names":[],"mappings":";AAgCO,SAAS,aAAqB;AACjC,SAAO;AAAA,IACH,MAAM;AAAA;AAAA;AAAA,IAGN,SAAS;AAAA,IACT,MAAM,UAAU,QAAQ,UAAU,SAAS;AACvC,YAAM,YAAY,uBAAuB,MAAM;AAC/C,UAAI,CAAC,WAAW;AACZ,eAAO;AAAA,MACX;AAIA,YAAM,WAAW,MAAM,KAAK,QAAQ,WAAW,UAAU;AAAA,QACrD,GAAG;AAAA,QACH,UAAU;AAAA,MAAA,CACb;AACD,cAAO,qCAAU,OAAM;AAAA,IAC3B;AAAA,EAAA;AAER;"}
package/webpack.d.ts ADDED
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Webpack (and Rspack) plugin that redirects Babylon.js imports onto the
3
+ * `@babylonjs/lite-compat` layer. Add `new LiteCompatPlugin()` to your config's
4
+ * `plugins` array and keep your Babylon.js imports exactly as they are.
5
+ */
6
+ export declare class LiteCompatPlugin {
7
+ apply(compiler: WebpackCompiler): void;
8
+ }
9
+
10
+ /** Minimal structural type for `compiler.webpack.NormalModuleReplacementPlugin`. */
11
+ declare interface NormalModuleReplacementPluginCtor {
12
+ new (resourceRegExp: RegExp, newResource: (resource: WebpackResource) => void): {
13
+ apply(compiler: WebpackCompiler): void;
14
+ };
15
+ }
16
+
17
+ /** Minimal structural type for the Webpack 5 compiler this plugin needs. */
18
+ declare interface WebpackCompiler {
19
+ webpack: {
20
+ NormalModuleReplacementPlugin: NormalModuleReplacementPluginCtor;
21
+ };
22
+ }
23
+
24
+ /**
25
+ * A reusable Webpack plugin that lets an existing Babylon.js project run on
26
+ * Babylon Lite **without changing its import statements**. It rewrites
27
+ * `@babylonjs/core`, `@babylonjs/loaders`, `@babylonjs/addons`,
28
+ * `@babylonjs/materials`, and `@recast-navigation/*` imports
29
+ * onto the matching `@babylonjs/lite-compat` modules before Webpack resolves
30
+ * them, by rewriting the request and letting Webpack's own resolver (and the
31
+ * package's `exports` map) take it from there.
32
+ *
33
+ * Usage (`webpack.config.js`):
34
+ *
35
+ * ```js
36
+ * const { LiteCompatPlugin } = require("@babylonjs/lite-compat/webpack");
37
+ *
38
+ * module.exports = {
39
+ * plugins: [new LiteCompatPlugin()],
40
+ * };
41
+ * ```
42
+ *
43
+ * Built on Webpack 5's `NormalModuleReplacementPlugin` (reached via
44
+ * `compiler.webpack`), so the adapter needs no `webpack` dependency of its own.
45
+ * Rspack implements the same plugin interface, so this adapter works there too.
46
+ * The redirect table is shared with every other adapter via
47
+ * [bundler-resolve.ts](bundler-resolve.ts).
48
+ */
49
+ /** Minimal structural type for the request object Webpack hands the replacer. */
50
+ declare interface WebpackResource {
51
+ request: string;
52
+ }
53
+
54
+ export { }
package/webpack.js ADDED
@@ -0,0 +1,16 @@
1
+ import { C as COMPAT_SOURCE_FILTER, r as resolveCompatSpecifier } from "./bundler-resolve-0pEkTP9X.js";
2
+ class LiteCompatPlugin {
3
+ apply(compiler) {
4
+ const { NormalModuleReplacementPlugin } = compiler.webpack;
5
+ new NormalModuleReplacementPlugin(COMPAT_SOURCE_FILTER, (resource) => {
6
+ const specifier = resolveCompatSpecifier(resource.request);
7
+ if (specifier) {
8
+ resource.request = specifier;
9
+ }
10
+ }).apply(compiler);
11
+ }
12
+ }
13
+ export {
14
+ LiteCompatPlugin
15
+ };
16
+ //# sourceMappingURL=webpack.js.map
package/webpack.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpack.js","sources":["../src/webpack.ts"],"sourcesContent":["/**\n * A reusable Webpack plugin that lets an existing Babylon.js project run on\n * Babylon Lite **without changing its import statements**. It rewrites\n * `@babylonjs/core`, `@babylonjs/loaders`, `@babylonjs/addons`,\n * `@babylonjs/materials`, and `@recast-navigation/*` imports\n * onto the matching `@babylonjs/lite-compat` modules before Webpack resolves\n * them, by rewriting the request and letting Webpack's own resolver (and the\n * package's `exports` map) take it from there.\n *\n * Usage (`webpack.config.js`):\n *\n * ```js\n * const { LiteCompatPlugin } = require(\"@babylonjs/lite-compat/webpack\");\n *\n * module.exports = {\n * plugins: [new LiteCompatPlugin()],\n * };\n * ```\n *\n * Built on Webpack 5's `NormalModuleReplacementPlugin` (reached via\n * `compiler.webpack`), so the adapter needs no `webpack` dependency of its own.\n * Rspack implements the same plugin interface, so this adapter works there too.\n * The redirect table is shared with every other adapter via\n * [bundler-resolve.ts](bundler-resolve.ts).\n */\n\nimport { resolveCompatSpecifier, COMPAT_SOURCE_FILTER } from \"./bundler-resolve.js\";\n\n/** Minimal structural type for the request object Webpack hands the replacer. */\ninterface WebpackResource {\n request: string;\n}\n\n/** Minimal structural type for `compiler.webpack.NormalModuleReplacementPlugin`. */\ninterface NormalModuleReplacementPluginCtor {\n new (\n resourceRegExp: RegExp,\n newResource: (resource: WebpackResource) => void\n ): {\n apply(compiler: WebpackCompiler): void;\n };\n}\n\n/** Minimal structural type for the Webpack 5 compiler this plugin needs. */\ninterface WebpackCompiler {\n webpack: { NormalModuleReplacementPlugin: NormalModuleReplacementPluginCtor };\n}\n\n/**\n * Webpack (and Rspack) plugin that redirects Babylon.js imports onto the\n * `@babylonjs/lite-compat` layer. Add `new LiteCompatPlugin()` to your config's\n * `plugins` array and keep your Babylon.js imports exactly as they are.\n */\nexport class LiteCompatPlugin {\n apply(compiler: WebpackCompiler): void {\n const { NormalModuleReplacementPlugin } = compiler.webpack;\n new NormalModuleReplacementPlugin(COMPAT_SOURCE_FILTER, (resource) => {\n const specifier = resolveCompatSpecifier(resource.request);\n if (specifier) {\n resource.request = specifier;\n }\n }).apply(compiler);\n }\n}\n"],"names":[],"mappings":";AAqDO,MAAM,iBAAiB;AAAA,EAC1B,MAAM,UAAiC;AACnC,UAAM,EAAE,kCAAkC,SAAS;AACnD,QAAI,8BAA8B,sBAAsB,CAAC,aAAa;AAClE,YAAM,YAAY,uBAAuB,SAAS,OAAO;AACzD,UAAI,WAAW;AACX,iBAAS,UAAU;AAAA,MACvB;AAAA,IACJ,CAAC,EAAE,MAAM,QAAQ;AAAA,EACrB;AACJ;"}