@kirknock/node-openxr-babylonjs 0.0.0-stage → 0.3.0
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/LICENSE +21 -0
- package/README.md +48 -2
- package/dist/asset-slideshow.d.ts +32 -0
- package/dist/asset-slideshow.js +120 -0
- package/dist/asset-slideshow.js.map +1 -0
- package/dist/controller-log.d.ts +35 -0
- package/dist/controller-log.js +95 -0
- package/dist/controller-log.js.map +1 -0
- package/dist/controller-visuals.d.ts +24 -0
- package/dist/controller-visuals.js +62 -0
- package/dist/controller-visuals.js.map +1 -0
- package/dist/create-engine.d.ts +6 -0
- package/dist/create-engine.js +10 -0
- package/dist/create-engine.js.map +1 -0
- package/dist/dot-grid-floor.d.ts +21 -0
- package/dist/dot-grid-floor.js +54 -0
- package/dist/dot-grid-floor.js.map +1 -0
- package/dist/each-controller.d.ts +12 -0
- package/dist/each-controller.js +29 -0
- package/dist/each-controller.js.map +1 -0
- package/dist/list-files.d.ts +6 -0
- package/dist/list-files.js +34 -0
- package/dist/list-files.js.map +1 -0
- package/dist/load-asset.d.ts +41 -0
- package/dist/load-asset.js +157 -0
- package/dist/load-asset.js.map +1 -0
- package/dist/xr.d.ts +11 -0
- package/dist/xr.js +55 -0
- package/dist/xr.js.map +1 -0
- package/package.json +68 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kirknock
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @kirknock/node-openxr-babylonjs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/kirknock/node-openxr-babylonjs/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@kirknock/node-openxr-babylonjs)
|
|
5
|
+
|
|
6
|
+
Plain browser-style Babylon.js WebXR helpers the node-openxr demo app is
|
|
7
|
+
built from: `create-engine`, `xr` (WebXRDefaultExperience setup),
|
|
8
|
+
`list-files`, `load-asset`, `asset-slideshow`, `dot-grid-floor`,
|
|
9
|
+
`controller-visuals`, `controller-log`. Imports only `@babylonjs/*` (peer
|
|
10
|
+
dependencies), so it runs in a browser unchanged.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @kirknock/node-openxr-babylonjs @babylonjs/core@9.33.2 @babylonjs/loaders@9.33.2
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Modules are imported by path, e.g.
|
|
19
|
+
`@kirknock/node-openxr-babylonjs/xr.js`.
|
|
20
|
+
|
|
21
|
+
## Development
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm ci
|
|
25
|
+
npm run build # dist/
|
|
26
|
+
npm run lint && npm run typecheck
|
|
27
|
+
npm test # pure group: controller logging over IWER + NullEngine
|
|
28
|
+
npm run push # build + yalc push to local consumers
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Tests run on [`@kirknock/node-openxr-core`](https://www.npmjs.com/package/@kirknock/node-openxr-core)
|
|
32
|
+
(dev dependency): its IWER runtime and the `nodexr-test` runner.
|
|
33
|
+
|
|
34
|
+
## Releasing
|
|
35
|
+
|
|
36
|
+
Bump `version` in `package.json`, commit, then push a matching tag:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm version patch # or minor / major / prerelease --preid beta
|
|
40
|
+
git push --follow-tags
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The `Release` workflow checks the tag, lints, tests, publishes to npm via
|
|
44
|
+
trusted publishing (with provenance) and creates a GitHub release with the
|
|
45
|
+
tarball attached.
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
MIT
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A slideshow of a folder's *.glb assets (plain Babylon.js): each is shown
|
|
3
|
+
* for a while, then the next takes its place in one frame. The next asset
|
|
4
|
+
* loads while the current one is still on show, from halfway through its
|
|
5
|
+
* time, so the stage is never empty, a slow load only keeps the current asset
|
|
6
|
+
* up longer, and the load's work is not added to the frames around a swap, the
|
|
7
|
+
* ones a user sees stutter most. Two assets are in memory during that time. The
|
|
8
|
+
* previous asset is hidden in the swap's frame and freed over the next frames.
|
|
9
|
+
* One asset alone just stays up.
|
|
10
|
+
*
|
|
11
|
+
* Each swap logs the longest gap between frames during each phase of bringing
|
|
12
|
+
* that asset in, so a run on the target shows which one stutters.
|
|
13
|
+
*/
|
|
14
|
+
import { type Scene, type TransformNode } from "@babylonjs/core";
|
|
15
|
+
import { type AssetPlacement, type LoadPhase } from "./load-asset.js";
|
|
16
|
+
export type SwapPhase = LoadPhase | "warm-up" | "wait" | "show" | "dispose" | "after";
|
|
17
|
+
/** Longest gap between frames, in ms, per phase; a phase no frame fell in is absent. */
|
|
18
|
+
export type FrameGaps = Partial<Record<SwapPhase, number>>;
|
|
19
|
+
export interface SlideshowOptions {
|
|
20
|
+
placement: Omit<AssetPlacement, "hidden">;
|
|
21
|
+
showSeconds: number;
|
|
22
|
+
/** Called with each asset's root as it goes on show. */
|
|
23
|
+
onShow(root: TransformNode): void;
|
|
24
|
+
/** Called with the frame gaps of bringing each asset in, once its predecessor is freed. */
|
|
25
|
+
onSwapMeasured?(url: string, gaps: FrameGaps): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Lists the folder's *.glb files once, then shows them in turn, forever.
|
|
29
|
+
* Assets that fail to load are skipped; stops when the scene is disposed or
|
|
30
|
+
* when every file in a row failed.
|
|
31
|
+
*/
|
|
32
|
+
export declare function showAssetsInLoop(scene: Scene, folder: string, options: SlideshowOptions): Promise<void>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { listFiles } from "./list-files.js";
|
|
2
|
+
import { loadAsset } from "./load-asset.js";
|
|
3
|
+
/** Frames the phase "show" covers: the new asset's first ones, before the old one is freed. */
|
|
4
|
+
const SHOW_FRAMES = 2;
|
|
5
|
+
/**
|
|
6
|
+
* Lists the folder's *.glb files once, then shows them in turn, forever.
|
|
7
|
+
* Assets that fail to load are skipped; stops when the scene is disposed or
|
|
8
|
+
* when every file in a row failed.
|
|
9
|
+
*/
|
|
10
|
+
export async function showAssetsInLoop(scene, folder, options) {
|
|
11
|
+
const urls = await listFiles(folder, ".glb");
|
|
12
|
+
console.log(`[assets] ${urls.length} .glb file(s) under ${folder}`);
|
|
13
|
+
if (urls.length === 0)
|
|
14
|
+
return;
|
|
15
|
+
let current = null;
|
|
16
|
+
let shownUrl = null;
|
|
17
|
+
let loadFrom = 0;
|
|
18
|
+
let showUntil = 0;
|
|
19
|
+
let failures = 0;
|
|
20
|
+
const gaps = new FrameGapWatch(scene);
|
|
21
|
+
// A load in flight may never settle once its scene is gone.
|
|
22
|
+
const disposed = new Promise((resolve) => scene.onDisposeObservable.addOnce(() => resolve(null)));
|
|
23
|
+
for (let i = 0; !scene.isDisposed; i = (i + 1) % urls.length) {
|
|
24
|
+
gaps.phase = "after";
|
|
25
|
+
await sceneDelay(scene, Math.max(0, loadFrom - performance.now()));
|
|
26
|
+
if (scene.isDisposed)
|
|
27
|
+
return;
|
|
28
|
+
if (shownUrl !== null) {
|
|
29
|
+
const report = gaps.takeReport(shownUrl); // logs it, with or without a listener
|
|
30
|
+
options.onSwapMeasured?.(shownUrl, report);
|
|
31
|
+
}
|
|
32
|
+
shownUrl = null;
|
|
33
|
+
const next = await Promise.race([disposed, loadHidden(scene, urls[i], options.placement, gaps)]);
|
|
34
|
+
if (scene.isDisposed)
|
|
35
|
+
return;
|
|
36
|
+
if (next === null) {
|
|
37
|
+
if (++failures < urls.length)
|
|
38
|
+
continue;
|
|
39
|
+
console.warn("[assets] no asset could be loaded — slideshow stopped");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
failures = 0;
|
|
43
|
+
gaps.phase = "warm-up";
|
|
44
|
+
await Promise.race([disposed, next.warmUp()]);
|
|
45
|
+
gaps.phase = "wait";
|
|
46
|
+
await sceneDelay(scene, Math.max(0, showUntil - performance.now()));
|
|
47
|
+
if (scene.isDisposed)
|
|
48
|
+
return;
|
|
49
|
+
gaps.phase = "show";
|
|
50
|
+
next.root.setEnabled(true);
|
|
51
|
+
current?.root.setEnabled(false);
|
|
52
|
+
options.onShow(next.root);
|
|
53
|
+
const previous = current;
|
|
54
|
+
current = next;
|
|
55
|
+
shownUrl = urls[i];
|
|
56
|
+
const now = performance.now();
|
|
57
|
+
loadFrom = now + (options.showSeconds * 1000) / 2;
|
|
58
|
+
showUntil = now + options.showSeconds * 1000;
|
|
59
|
+
if (urls.length === 1)
|
|
60
|
+
return;
|
|
61
|
+
await Promise.race([disposed, gaps.frames(SHOW_FRAMES)]);
|
|
62
|
+
if (scene.isDisposed)
|
|
63
|
+
return;
|
|
64
|
+
gaps.phase = "dispose";
|
|
65
|
+
await previous?.disposeGradually();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** The longest gap between frames while each phase was on; see the file's header. */
|
|
69
|
+
class FrameGapWatch {
|
|
70
|
+
scene;
|
|
71
|
+
phase = "load";
|
|
72
|
+
gaps = {};
|
|
73
|
+
lastFrame = 0;
|
|
74
|
+
constructor(scene) {
|
|
75
|
+
this.scene = scene;
|
|
76
|
+
scene.onBeforeRenderObservable.add(() => {
|
|
77
|
+
const now = performance.now();
|
|
78
|
+
if (this.lastFrame !== 0)
|
|
79
|
+
this.gaps[this.phase] = Math.max(this.gaps[this.phase] ?? 0, now - this.lastFrame);
|
|
80
|
+
this.lastFrame = now;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/** Resolves after `count` more frames. */
|
|
84
|
+
async frames(count) {
|
|
85
|
+
for (let i = 0; i < count; i++)
|
|
86
|
+
await new Promise((resolve) => this.scene.onAfterRenderObservable.addOnce(resolve));
|
|
87
|
+
}
|
|
88
|
+
takeReport(url) {
|
|
89
|
+
const report = this.gaps;
|
|
90
|
+
this.gaps = {};
|
|
91
|
+
const parts = Object.entries(report).map(([phase, ms]) => `${phase} ${ms.toFixed(1)}`);
|
|
92
|
+
if (parts.length > 0)
|
|
93
|
+
console.log(`[render] longest frame gap bringing in ${url}, ms: ${parts.join(", ")}`);
|
|
94
|
+
return report;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async function loadHidden(scene, url, placement, gaps) {
|
|
98
|
+
try {
|
|
99
|
+
return await loadAsset(scene, url, { ...placement, hidden: true }, (phase) => {
|
|
100
|
+
gaps.phase = phase;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
console.warn(`[assets] skipping ${url}: ${err instanceof Error ? err.message : String(err)}`);
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** Resolves after `ms`, or as soon as the scene is disposed. */
|
|
109
|
+
function sceneDelay(scene, ms) {
|
|
110
|
+
return new Promise((resolve) => {
|
|
111
|
+
const done = () => {
|
|
112
|
+
clearTimeout(timer);
|
|
113
|
+
scene.onDisposeObservable.remove(observer);
|
|
114
|
+
resolve();
|
|
115
|
+
};
|
|
116
|
+
const timer = setTimeout(done, ms);
|
|
117
|
+
const observer = scene.onDisposeObservable.addOnce(done);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=asset-slideshow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asset-slideshow.js","sourceRoot":"","sources":["../src/asset-slideshow.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAyD,MAAM,iBAAiB,CAAC;AAEnG,+FAA+F;AAC/F,MAAM,WAAW,GAAG,CAAC,CAAC;AAetB;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAY,EAAE,MAAc,EAAE,OAAyB;IAC5F,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,MAAM,uBAAuB,MAAM,EAAE,CAAC,CAAC;IACpE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAC9B,IAAI,OAAO,GAAuB,IAAI,CAAC;IACvC,IAAI,QAAQ,GAAkB,IAAI,CAAC;IACnC,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,MAAM,IAAI,GAAG,IAAI,aAAa,CAAC,KAAK,CAAC,CA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ylon's WebXRInput.
|
|
3
|
+
*
|
|
4
|
+
* Two availability lines per controller — input source added (WebXR-level
|
|
5
|
+
* connect) and motion-controller profile resolved (usable: component list,
|
|
6
|
+
* button/axis counts) — plus one on removal. Interaction events use edge
|
|
7
|
+
* detection so the log stays readable at frame rate:
|
|
8
|
+
*
|
|
9
|
+
* press/release transitions for every component (with the current value)
|
|
10
|
+
* analog value steps (trigger/squeeze travel, deadband ANALOG_STEP)
|
|
11
|
+
* thumbstick/trackpad axis changes (deadband AXES_STEP, plus the
|
|
12
|
+
* return-to-center line)
|
|
13
|
+
*
|
|
14
|
+
* Deliberately NO pose/position/orientation data — that belongs to the
|
|
15
|
+
* pose-debug channels, not to interaction logs.
|
|
16
|
+
*/
|
|
17
|
+
import type * as Babylon from "@babylonjs/core";
|
|
18
|
+
export interface ControllerLog {
|
|
19
|
+
/** "<hand>:<profileId>" per profile-resolved controller, live-updated. */
|
|
20
|
+
readonly controllers: string[];
|
|
21
|
+
/** Detaches every observer installed here. */
|
|
22
|
+
dispose(): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Installs availability + interaction logging on a WebXRInput. Call BEFORE
|
|
26
|
+
* the XR session starts so the first inputsourceschange is caught (same
|
|
27
|
+
* construction-order rule as WebXRInput itself).
|
|
28
|
+
*/
|
|
29
|
+
export declare function installControllerLogging(xrInput: Babylon.WebXRInput): ControllerLog;
|
|
30
|
+
/**
|
|
31
|
+
* Logs pointer-selection interaction (the xr-controller-pointer-selection
|
|
32
|
+
* feature maps controller select to scene pointerdown/pointerup on the
|
|
33
|
+
* picked mesh). Mesh names only — no pose data. Returns a stop function.
|
|
34
|
+
*/
|
|
35
|
+
export declare function installScenePointerLogging(scene: Babylon.Scene): () => void;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { PointerEventTypes } from "@babylonjs/core/Events/pointerEvents.js";
|
|
2
|
+
import { forEachController } from "./each-controller.js";
|
|
3
|
+
const controllerLog = { info: (message) => console.log(`[controller] ${message}`) };
|
|
4
|
+
/** Minimum |Δvalue| between two analog log lines (0..1 scale). */
|
|
5
|
+
const ANALOG_STEP = 0.25;
|
|
6
|
+
/** Minimum |Δx|+|Δy| between two axes log lines. */
|
|
7
|
+
const AXES_STEP = 0.25;
|
|
8
|
+
/** Below this axes magnitude the stick counts as centered. */
|
|
9
|
+
const AXES_CENTER_EPS = 0.1;
|
|
10
|
+
/**
|
|
11
|
+
* Installs availability + interaction logging on a WebXRInput. Call BEFORE
|
|
12
|
+
* the XR session starts so the first inputsourceschange is caught (same
|
|
13
|
+
* construction-order rule as WebXRInput itself).
|
|
14
|
+
*/
|
|
15
|
+
export function installControllerLogging(xrInput) {
|
|
16
|
+
const controllers = [];
|
|
17
|
+
const stop = forEachController(xrInput, (controller) => {
|
|
18
|
+
// Everything observed on this controller, removed with it.
|
|
19
|
+
const removers = [];
|
|
20
|
+
const addObs = (obs, cb) => {
|
|
21
|
+
const observer = obs.add(cb);
|
|
22
|
+
removers.push(() => obs.remove(observer));
|
|
23
|
+
};
|
|
24
|
+
const hand = String(controller.inputSource.handedness);
|
|
25
|
+
controllerLog.info(`input source added: ${hand} (resolving motion-controller profile...)`);
|
|
26
|
+
addObs(controller.onMotionControllerInitObservable, (motionController) => {
|
|
27
|
+
const ids = Object.keys(motionController.components);
|
|
28
|
+
const axesCount = controller.inputSource.gamepad?.axes.length ?? 0;
|
|
29
|
+
controllers.push(`${hand}:${motionController.profileId}`);
|
|
30
|
+
controllerLog.info(`available: ${hand} (profile ${motionController.profileId}, ` +
|
|
31
|
+
`buttons ${ids.length} [${ids.join(", ")}], axes ${axesCount})`);
|
|
32
|
+
for (const component of Object.values(motionController.components)) {
|
|
33
|
+
// Button: log press/release edges always; analog travel in steps.
|
|
34
|
+
let lastValue = component.value ?? 0;
|
|
35
|
+
let lastPressed = component.pressed ?? false;
|
|
36
|
+
addObs(component.onButtonStateChangedObservable, (changed) => {
|
|
37
|
+
const value = changed.value ?? 0;
|
|
38
|
+
const pressed = changed.pressed ?? false;
|
|
39
|
+
if (pressed !== lastPressed) {
|
|
40
|
+
controllerLog.info(`${hand} ${changed.id}: ${pressed ? "PRESSED" : "released"} (value=${value.toFixed(2)})`);
|
|
41
|
+
lastPressed = pressed;
|
|
42
|
+
lastValue = value;
|
|
43
|
+
}
|
|
44
|
+
else if (Math.abs(value - lastValue) >= ANALOG_STEP) {
|
|
45
|
+
controllerLog.info(`${hand} ${changed.id}: value=${value.toFixed(2)}`);
|
|
46
|
+
lastValue = value;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
// Axes (thumbstick/trackpad components only; never fires otherwise).
|
|
50
|
+
let lastX = 0;
|
|
51
|
+
let lastY = 0;
|
|
52
|
+
let centered = true;
|
|
53
|
+
addObs(component.onAxisValueChangedObservable, (axes) => {
|
|
54
|
+
const { x, y } = axes;
|
|
55
|
+
const offCenter = Math.abs(x) + Math.abs(y) >= AXES_CENTER_EPS;
|
|
56
|
+
if (Math.abs(x - lastX) + Math.abs(y - lastY) >= AXES_STEP || (centered === false && !offCenter)) {
|
|
57
|
+
controllerLog.info(`${hand} ${component.id}: axes x=${x.toFixed(2)} y=${y.toFixed(2)}`);
|
|
58
|
+
lastX = x;
|
|
59
|
+
lastY = y;
|
|
60
|
+
}
|
|
61
|
+
centered = !offCenter;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return (removed) => {
|
|
66
|
+
for (const remove of removers)
|
|
67
|
+
remove();
|
|
68
|
+
if (!removed)
|
|
69
|
+
return;
|
|
70
|
+
const i = controllers.findIndex((entry) => entry.startsWith(`${hand}:`));
|
|
71
|
+
if (i !== -1)
|
|
72
|
+
controllers.splice(i, 1);
|
|
73
|
+
controllerLog.info(`removed: ${hand}`);
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
return { controllers, dispose: stop };
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Logs pointer-selection interaction (the xr-controller-pointer-selection
|
|
80
|
+
* feature maps controller select to scene pointerdown/pointerup on the
|
|
81
|
+
* picked mesh). Mesh names only — no pose data. Returns a stop function.
|
|
82
|
+
*/
|
|
83
|
+
export function installScenePointerLogging(scene) {
|
|
84
|
+
const observer = scene.onPointerObservable.add((info) => {
|
|
85
|
+
const target = info.pickInfo?.pickedMesh?.name ?? "(nothing)";
|
|
86
|
+
if (info.type === PointerEventTypes.POINTERDOWN) {
|
|
87
|
+
controllerLog.info(`select: ${target}`);
|
|
88
|
+
}
|
|
89
|
+
else if (info.type === PointerEventTypes.POINTERUP) {
|
|
90
|
+
controllerLog.info(`release: ${target}`);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return () => scene.onPointerObservable.remove(observer);
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=controller-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-log.js","sourceRoot":"","sources":["../src/controller-log.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,aAAa,GAAG,EAAE,IAAI,EAAE,CAAC,OAAe,EAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,OAAO,EAAE,CAAC,EAAE,CAAC;AAElG,kEAAkE;AAClE,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,oDAAoD;AACpD,MAAM,SAAS,GAAG,IAAI,CAAC;AACvB,8DAA8D;AAC9D,MAAM,eAAe,GAAG,GAAG,CAAC;AAS5B;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAA2B;IAClE,MAAM,WAAW,GAAa,EAAE,CAAC;IAEjC,MAAM,IAAI,GAAG,iBAAiB,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE,EAAE;QACrD,2DAA2D;QAC3D,MAAM,QAAQ,GAAsB,EAAE,CAAC;QACvC,MAAM,MAA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,WAAW,MAAM,EAAE,CAAC,CAAC;QAC1C,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,CAAC,SAAS,EAAE,CAAC;YACrD,aAAa,CAAC,IAAI,CAAC,YAAY,MAAM,EAAE,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,mBAAmB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Procedural controller visuals — a small lit handle per hand.
|
|
3
|
+
*
|
|
4
|
+
* Babylon's real vendor controller models come from the online controller
|
|
5
|
+
* repository (network), which the headless app deliberately avoids; without
|
|
6
|
+
* it loadModel() simply rejects and controllers are invisible. This gives
|
|
7
|
+
* immediate in-headset presence with zero network and zero exotic-shader
|
|
8
|
+
* risk: a wand along the grip axis, blue for the left hand, orange for the
|
|
9
|
+
* right. The pointer-selection laser remains the interaction indicator.
|
|
10
|
+
*
|
|
11
|
+
* The meshes are parented to the controller's grip node (pointer node as
|
|
12
|
+
* fallback), so they follow the tracked pose and are disposed with the
|
|
13
|
+
* controller. They render like any other scene mesh.
|
|
14
|
+
*/
|
|
15
|
+
import type * as Babylon from "@babylonjs/core";
|
|
16
|
+
export interface ControllerVisuals {
|
|
17
|
+
/** Removes the visuals and every observer installed here. */
|
|
18
|
+
dispose(): void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Attaches visuals to every controller that connects. Call any time after
|
|
22
|
+
* WebXRInput construction.
|
|
23
|
+
*/
|
|
24
|
+
export declare function attachControllerVisuals(BABYLON: typeof import("@babylonjs/core"), xrInput: Babylon.WebXRInput): ControllerVisuals;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { forEachController } from "./each-controller.js";
|
|
2
|
+
const controllerLog = { info: (message) => console.log(`[controller] ${message}`) };
|
|
3
|
+
/** Diffuse/emissive tint per handedness — instant left/right identification. */
|
|
4
|
+
const HAND_TINT = {
|
|
5
|
+
left: [0.1, 0.3, 0.9],
|
|
6
|
+
right: [0.95, 0.35, 0.1],
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Attaches visuals to every controller that connects. Call any time after
|
|
10
|
+
* WebXRInput construction.
|
|
11
|
+
*/
|
|
12
|
+
export function attachControllerVisuals(BABYLON, xrInput) {
|
|
13
|
+
const stop = forEachController(xrInput, (controller) => {
|
|
14
|
+
// Meshes die with the controller's grip node; the material does not.
|
|
15
|
+
let visual = null;
|
|
16
|
+
const onInit = controller.onMotionControllerInitObservable.add(() => {
|
|
17
|
+
const anchor = controller.grip ?? controller.pointer;
|
|
18
|
+
if (anchor === undefined || anchor === null)
|
|
19
|
+
return;
|
|
20
|
+
const scene = anchor.getScene();
|
|
21
|
+
const hand = String(controller.inputSource.handedness);
|
|
22
|
+
const [r, g, b] = HAND_TINT[hand] ?? [0.45, 0.45, 0.45];
|
|
23
|
+
const mat = new BABYLON.StandardMaterial(`${hand}ControllerVisualMat`, scene);
|
|
24
|
+
mat.diffuseColor = new BABYLON.Color3(r, g, b);
|
|
25
|
+
mat.emissiveColor = new BABYLON.Color3(r * 0.35, g * 0.35, b * 0.35);
|
|
26
|
+
const root = new BABYLON.TransformNode(`${hand}ControllerVisual`, scene);
|
|
27
|
+
root.parent = anchor;
|
|
28
|
+
visual = { root, material: mat };
|
|
29
|
+
// Cylinders are Y-up; lay the wand along the grip's local +Z (Babylon
|
|
30
|
+
// LH forward). Sizes in metres. NOTE: all parts must stay
|
|
31
|
+
// non-pickable — they sit directly in the pointer ray's path and
|
|
32
|
+
// would otherwise swallow every selection (the laser does the same).
|
|
33
|
+
const layAlongZ = BABYLON.Quaternion.FromEulerAngles(Math.PI / 2, 0, 0);
|
|
34
|
+
const handle = BABYLON.MeshBuilder.CreateCylinder(`${hand}ControllerHandle`, { height: 0.1, diameter: 0.028, tessellation: 12 }, scene);
|
|
35
|
+
handle.rotationQuaternion = layAlongZ;
|
|
36
|
+
handle.position.z = -0.03; // wand reaches back into the palm
|
|
37
|
+
handle.material = mat;
|
|
38
|
+
handle.isPickable = false;
|
|
39
|
+
handle.parent = root;
|
|
40
|
+
const tip = BABYLON.MeshBuilder.CreateCylinder(`${hand}ControllerTip`, { height: 0.022, diameterTop: 0.036, diameterBottom: 0.028, tessellation: 12 }, scene);
|
|
41
|
+
tip.rotationQuaternion = layAlongZ;
|
|
42
|
+
tip.position.z = 0.028;
|
|
43
|
+
tip.material = mat;
|
|
44
|
+
tip.isPickable = false;
|
|
45
|
+
tip.parent = root;
|
|
46
|
+
const ring = BABYLON.MeshBuilder.CreateTorus(`${hand}ControllerRing`, { diameter: 0.034, thickness: 0.006, tessellation: 16 }, scene);
|
|
47
|
+
ring.position.z = 0.038;
|
|
48
|
+
ring.material = mat;
|
|
49
|
+
ring.isPickable = false;
|
|
50
|
+
ring.parent = root;
|
|
51
|
+
controllerLog.info(`visuals attached: ${hand}`);
|
|
52
|
+
});
|
|
53
|
+
return () => {
|
|
54
|
+
controller.onMotionControllerInitObservable.remove(onInit);
|
|
55
|
+
if (visual !== null && !visual.root.isDisposed())
|
|
56
|
+
visual.root.dispose();
|
|
57
|
+
visual?.material.dispose();
|
|
58
|
+
};
|
|
59
|
+
});
|
|
60
|
+
return { dispose: stop };
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=controller-visuals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller-visuals.js","sourceRoot":"","sources":["../src/controller-visuals.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,aAAa,GAAG,EAAE,IAAI,EAAE,CAAC,OAAe,EAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,OAAO,EAAE,CAAC,EAAE,CAAC;AAOlG,gFAAgF;AAChF,MAAM,SAAS,GAA6C;IAC1D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,CAAC,WAAW,CAC1C,GAAG,IAAI,gBAAgB,EACvB,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,EACvD,KAAK,CACN,CAAC;YACF,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,KAAK,CAAC;YACxB,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;YACpB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;YACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YAEnB,aAAa,CAAC,IAAI,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE;YACV,UAAU,CAAC,gCAAgC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC3D,IAAI,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE;gBAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YACxE,MAAM,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Creates the app's engine for the chosen renderer (plain Babylon.js; also valid in a browser). */
|
|
2
|
+
import { Engine, type AbstractEngine } from "@babylonjs/core";
|
|
3
|
+
export type Renderer = "webgl2" | "webgpu";
|
|
4
|
+
/** The canvas type Babylon's Engine accepts (a browser HTMLCanvasElement). */
|
|
5
|
+
export type Canvas = ConstructorParameters<typeof Engine>[0];
|
|
6
|
+
export declare function createEngine(canvas: Canvas, renderer: Renderer): Promise<AbstractEngine>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Creates the app's engine for the chosen renderer (plain Babylon.js; also valid in a browser). */
|
|
2
|
+
import { Engine, WebGPUEngine } from "@babylonjs/core";
|
|
3
|
+
export async function createEngine(canvas, renderer) {
|
|
4
|
+
if (renderer === "webgl2")
|
|
5
|
+
return new Engine(canvas, false, { stencil: true });
|
|
6
|
+
const engine = new WebGPUEngine(canvas, { stencil: true, xrCompatible: true });
|
|
7
|
+
await engine.initAsync();
|
|
8
|
+
return engine;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=create-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-engine.js","sourceRoot":"","sources":["../src/create-engine.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,OAAO,EAAE,MAAM,EAAE,YAAY,EAAuB,MAAM,iBAAiB,CAAC;AAO5E,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAc,EAAE,QAAkB;IACnE,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/E,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,MAA2B,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IACpG,MAAM,MAAM,CAAC,SAAS,EAAE,CAAC;IACzB,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* See-through "dot grid" floor: a regular grid of bright dots on an
|
|
3
|
+
* otherwise fully transparent surface, so the floor plane (and its height)
|
|
4
|
+
* reads at a glance — in VR and over passthrough alike — while the real world
|
|
5
|
+
* / the scene below stays visible through it. No tint between the dots: on
|
|
6
|
+
* Pico 4 passthrough a large semi-transparent surface visibly changes look
|
|
7
|
+
* during head motion (docs/target-testing.md). Also the teleportation floor
|
|
8
|
+
* mesh (picking ignores alpha, so the transparent surface is still a hit).
|
|
9
|
+
*
|
|
10
|
+
* The dot tile is generated on the CPU into a RawTexture and repeated
|
|
11
|
+
* across the plane (plain Babylon; works the same in a browser).
|
|
12
|
+
*/
|
|
13
|
+
import type * as Babylon from "@babylonjs/core";
|
|
14
|
+
/**
|
|
15
|
+
* Generates one RGBA8 tile: fully transparent with an anti-aliased dot at
|
|
16
|
+
* its center. Straight (non-premultiplied) alpha —
|
|
17
|
+
* the blend stage produces premultiplied output over the alpha-0 clear.
|
|
18
|
+
*/
|
|
19
|
+
export declare function makeDotTile(size?: number): Uint8Array;
|
|
20
|
+
/** Creates the dot-grid floor mesh ("ground") at y = 0 of the scene. */
|
|
21
|
+
export declare function createDotGridFloor(BABYLON: typeof Babylon, scene: Babylon.Scene): Babylon.Mesh;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Floor extent (m), dot spacing (m) and dot radius (m). */
|
|
2
|
+
const FLOOR_SIZE = 24;
|
|
3
|
+
const DOT_SPACING = 0.5;
|
|
4
|
+
const DOT_RADIUS = 0.03;
|
|
5
|
+
/** Tile resolution: one dot per tile. */
|
|
6
|
+
const TILE_PX = 64;
|
|
7
|
+
/** Alpha of the dots. */
|
|
8
|
+
const DOT_ALPHA = 0.95;
|
|
9
|
+
/**
|
|
10
|
+
* Generates one RGBA8 tile: fully transparent with an anti-aliased dot at
|
|
11
|
+
* its center. Straight (non-premultiplied) alpha —
|
|
12
|
+
* the blend stage produces premultiplied output over the alpha-0 clear.
|
|
13
|
+
*/
|
|
14
|
+
export function makeDotTile(size = TILE_PX) {
|
|
15
|
+
const data = new Uint8Array(size * size * 4);
|
|
16
|
+
const radiusPx = (DOT_RADIUS / DOT_SPACING) * size;
|
|
17
|
+
const c = (size - 1) / 2;
|
|
18
|
+
for (let y = 0; y < size; y++) {
|
|
19
|
+
for (let x = 0; x < size; x++) {
|
|
20
|
+
const d = Math.hypot(x - c, y - c);
|
|
21
|
+
// 1 inside the dot, 0 outside, ~1.5 px smooth edge.
|
|
22
|
+
const dot = Math.min(1, Math.max(0, (radiusPx + 0.75 - d) / 1.5));
|
|
23
|
+
const i = (y * size + x) * 4;
|
|
24
|
+
data[i] = Math.round(255 * (0.35 + 0.6 * dot));
|
|
25
|
+
data[i + 1] = Math.round(255 * (0.45 + 0.5 * dot));
|
|
26
|
+
data[i + 2] = Math.round(255 * (0.6 + 0.4 * dot));
|
|
27
|
+
data[i + 3] = Math.round(255 * DOT_ALPHA * dot);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
/** Creates the dot-grid floor mesh ("ground") at y = 0 of the scene. */
|
|
33
|
+
export function createDotGridFloor(BABYLON, scene) {
|
|
34
|
+
const ground = BABYLON.MeshBuilder.CreateGround("ground", { width: FLOOR_SIZE, height: FLOOR_SIZE }, scene);
|
|
35
|
+
const tile = BABYLON.RawTexture.CreateRGBATexture(makeDotTile(), TILE_PX, TILE_PX, scene, true, // mipmaps: keeps distant dots from aliasing into moiré
|
|
36
|
+
false, BABYLON.Texture.TRILINEAR_SAMPLINGMODE);
|
|
37
|
+
tile.name = "dotGridTile";
|
|
38
|
+
tile.wrapU = BABYLON.Texture.WRAP_ADDRESSMODE;
|
|
39
|
+
tile.wrapV = BABYLON.Texture.WRAP_ADDRESSMODE;
|
|
40
|
+
tile.uScale = FLOOR_SIZE / DOT_SPACING;
|
|
41
|
+
tile.vScale = FLOOR_SIZE / DOT_SPACING;
|
|
42
|
+
tile.hasAlpha = true;
|
|
43
|
+
const mat = new BABYLON.StandardMaterial("groundMat", scene);
|
|
44
|
+
mat.diffuseTexture = tile;
|
|
45
|
+
mat.useAlphaFromDiffuseTexture = true;
|
|
46
|
+
// Dots stay bright regardless of the light angle; still a lit material.
|
|
47
|
+
mat.emissiveTexture = tile;
|
|
48
|
+
mat.specularColor = BABYLON.Color3.Black();
|
|
49
|
+
mat.backFaceCulling = false; // visible from below too (floor misplaced above the head)
|
|
50
|
+
mat.transparencyMode = BABYLON.Material.MATERIAL_ALPHABLEND;
|
|
51
|
+
ground.material = mat;
|
|
52
|
+
return ground;
|
|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C,IAAI,CAAC,MAAM,GAAG,UAAU,GAAG,WAAW,CAAC;IACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IAErB,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,gBAAgB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC7D,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC;IAC1B,GAAG,CAAC,0BAA0B,GAAG,IAAI,CAAC;IACtC,wEAAwE;IACxE,GAAG,CAAC,eAAe,GAAG,IAAI,CAAC;IAC3B,GAAG,CAAC,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC3C,GAAG,CAAC,eAAe,GAAG,KAAK,CAAC,CAAC,0DAA0D;IACvF,GAAG,CAAC,gBAAgB,GAAG,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC;IAC5D,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC;IACtB,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-controller setup with matching teardown, for helpers that attach
|
|
3
|
+
* something to every controller of a WebXRInput.
|
|
4
|
+
*/
|
|
5
|
+
import type * as Babylon from "@babylonjs/core";
|
|
6
|
+
/**
|
|
7
|
+
* Calls `attach` for every controller, present now or added later. What it
|
|
8
|
+
* returns runs when that controller is removed (`removed` true), or when the
|
|
9
|
+
* returned function is called (false; this also stops watching for new
|
|
10
|
+
* controllers).
|
|
11
|
+
*/
|
|
12
|
+
export declare function forEachController(xrInput: Babylon.WebXRInput, attach: (controller: Babylon.WebXRInputSource) => ((removed: boolean) => void) | void): () => void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calls `attach` for every controller, present now or added later. What it
|
|
3
|
+
* returns runs when that controller is removed (`removed` true), or when the
|
|
4
|
+
* returned function is called (false; this also stops watching for new
|
|
5
|
+
* controllers).
|
|
6
|
+
*/
|
|
7
|
+
export function forEachController(xrInput, attach) {
|
|
8
|
+
const detachers = new Map();
|
|
9
|
+
const add = (controller) => {
|
|
10
|
+
const detacher = attach(controller);
|
|
11
|
+
if (detacher !== undefined)
|
|
12
|
+
detachers.set(controller, detacher);
|
|
13
|
+
};
|
|
14
|
+
const detach = (controller, removed) => {
|
|
15
|
+
detachers.get(controller)?.(removed);
|
|
16
|
+
detachers.delete(controller);
|
|
17
|
+
};
|
|
18
|
+
const added = xrInput.onControllerAddedObservable.add(add);
|
|
19
|
+
const removed = xrInput.onControllerRemovedObservable.add((controller) => detach(controller, true));
|
|
20
|
+
for (const controller of xrInput.controllers)
|
|
21
|
+
add(controller);
|
|
22
|
+
return () => {
|
|
23
|
+
xrInput.onControllerAddedObservable.remove(added);
|
|
24
|
+
xrInput.onControllerRemovedObservable.remove(removed);
|
|
25
|
+
for (const controller of [...detachers.keys()])
|
|
26
|
+
detach(controller, false);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=each-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"each-controller.js","sourceRoot":"","sources":["../src/each-controller.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAA2B,EAC3B,MAAqF;IAErF,MAAM,SAAS,GAAG,IAAI,GAAG,EAAwD,CAAC;IAClF,MAAM,GAAG,GAAG,CAAC,UAAoC,EAAQ,EAAE;QACzD,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACpC,IAAI,QAAQ,KAAK,SAAS;YAAE,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAClE,CAAC,CAAC;IACF,MAAM,MAAM,GAAG,CAAC,UAAoC,EAAE,OAAgB,EAAQ,EAAE;QAC9E,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QACrC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC,CAAC;IACF,MAAM,KAAK,GAAG,OAAO,CAAC,2BAA2B,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC3D,MAAM,OAAO,GAAG,OAAO,CAAC,6BAA6B,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;IACpG,KAAK,MAAM,UAAU,IAAI,OAAO,CAAC,WAAW;QAAE,GAAG,CAAC,UAAU,CAAC,CAAC;IAC9D,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,2BAA2B,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAClD,OAAO,CAAC,6BAA6B,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACtD,KAAK,MAAM,UAAU,IAAI,CAAC,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;YAAE,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC5E,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URLs of all files below `folderUrl` whose name ends with `extension`
|
|
3
|
+
* (case-insensitive), depth first, in index (name) order. A folder that
|
|
4
|
+
* cannot be read is reported and skipped.
|
|
5
|
+
*/
|
|
6
|
+
export declare function listFiles(folderUrl: string, extension: string): Promise<string[]>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lists the files under a folder URL, recursively, through the folder's
|
|
3
|
+
* JSON directory index — the format a web server serves for a directory
|
|
4
|
+
* (nginx `autoindex on; autoindex_format json;`), which the Node platform
|
|
5
|
+
* also answers with for local folders. Plain Babylon.js (Tools.LoadFileAsync),
|
|
6
|
+
* so it runs in a browser against such a server unchanged.
|
|
7
|
+
*/
|
|
8
|
+
import { Tools } from "@babylonjs/core";
|
|
9
|
+
/**
|
|
10
|
+
* URLs of all files below `folderUrl` whose name ends with `extension`
|
|
11
|
+
* (case-insensitive), depth first, in index (name) order. A folder that
|
|
12
|
+
* cannot be read is reported and skipped.
|
|
13
|
+
*/
|
|
14
|
+
export async function listFiles(folderUrl, extension) {
|
|
15
|
+
const folder = folderUrl.endsWith("/") ? folderUrl : `${folderUrl}/`;
|
|
16
|
+
let entries;
|
|
17
|
+
try {
|
|
18
|
+
entries = JSON.parse(await Tools.LoadFileAsync(folder, false));
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
console.warn(`[assets] cannot list ${folder}: ${err instanceof Error ? err.message : String(err)}`);
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
const urls = [];
|
|
25
|
+
for (const entry of entries) {
|
|
26
|
+
const url = folder + encodeURIComponent(entry.name);
|
|
27
|
+
if (entry.type === "directory")
|
|
28
|
+
urls.push(...(await listFiles(`${url}/`, extension)));
|
|
29
|
+
else if (entry.type === "file" && entry.name.toLowerCase().endsWith(extension.toLowerCase()))
|
|
30
|
+
urls.push(url);
|
|
31
|
+
}
|
|
32
|
+
return urls;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=list-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-files.js","sourceRoot":"","sources":["../src/list-files.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAOxC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,SAAiB,EAAE,SAAiB;IAClE,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC;IACrE,IAAI,OAAqB,CAAC;IAC1B,IAAI,CAAC;QACH,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAiB,CAAC;IACjF,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,wBAAwB,MAAM,KAAK,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACpG,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,GAAG,GAAG,MAAM,GAAG,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW;YAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,SAAS,CAAC,GAAG,GAAG,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;aACjF,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/G,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads a GLB/glTF asset by URL (plain Babylon.js; relative URLs resolve
|
|
3
|
+
* against the page location), scales it to a target height and places its
|
|
4
|
+
* bounds centre at a given point — under a pivot, so rotating the returned
|
|
5
|
+
* root turns the asset in place. Its shaders are compiled before it resolves,
|
|
6
|
+
* and a hidden asset can draw each of its meshes once before it shows (warmUp),
|
|
7
|
+
* so the asset's first visible frame costs no more than any other.
|
|
8
|
+
* dispose() removes it from the scene and frees everything it loaded (meshes,
|
|
9
|
+
* materials, textures, animations); disposeGradually() does so over many frames.
|
|
10
|
+
*/
|
|
11
|
+
import { TransformNode, Vector3, type Scene } from "@babylonjs/core";
|
|
12
|
+
import "@babylonjs/loaders/glTF/2.0/glTFLoader.js";
|
|
13
|
+
import "@babylonjs/loaders/glTF/2.0/Extensions/index.js";
|
|
14
|
+
export interface AssetPlacement {
|
|
15
|
+
/** World position of the asset's bounds centre (default 2.2 m ahead, 1.3 m up). */
|
|
16
|
+
center?: Vector3;
|
|
17
|
+
/** Target height in metres (default 0.6). */
|
|
18
|
+
height?: number;
|
|
19
|
+
/** Upper bound for the largest dimension in metres (default: none) — keeps flat, wide assets in reach. */
|
|
20
|
+
maxSize?: number;
|
|
21
|
+
/** Stay disabled once loaded, for the caller to show with root.setEnabled(true) (default false). */
|
|
22
|
+
hidden?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface LoadedAsset {
|
|
25
|
+
/** Pivot at the asset's bounds centre; move/rotate this. */
|
|
26
|
+
root: TransformNode;
|
|
27
|
+
/**
|
|
28
|
+
* Draws each mesh once, one per frame, too small to see, while the root stays
|
|
29
|
+
* disabled: what a driver leaves for a pipeline state's first draw (WebGPU
|
|
30
|
+
* builds its render pipelines there) then does not land in the frame the asset
|
|
31
|
+
* shows, all at once. Needs the render loop running; a hidden asset only.
|
|
32
|
+
*/
|
|
33
|
+
warmUp(): Promise<void>;
|
|
34
|
+
/** Removes the asset from the scene and frees all its resources. */
|
|
35
|
+
dispose(): void;
|
|
36
|
+
/** As dispose(), yielding to the render loop between stretches of work. */
|
|
37
|
+
disposeGradually(): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/** What loadAsset is busy with, for a caller that measures it. */
|
|
40
|
+
export type LoadPhase = "load" | "compile";
|
|
41
|
+
export declare function loadAsset(scene: Scene, url: string, placement?: AssetPlacement, onPhase?: (phase: LoadPhase) => void): Promise<LoadedAsset>;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads a GLB/glTF asset by URL (plain Babylon.js; relative URLs resolve
|
|
3
|
+
* against the page location), scales it to a target height and places its
|
|
4
|
+
* bounds centre at a given point — under a pivot, so rotating the returned
|
|
5
|
+
* root turns the asset in place. Its shaders are compiled before it resolves,
|
|
6
|
+
* and a hidden asset can draw each of its meshes once before it shows (warmUp),
|
|
7
|
+
* so the asset's first visible frame costs no more than any other.
|
|
8
|
+
* dispose() removes it from the scene and frees everything it loaded (meshes,
|
|
9
|
+
* materials, textures, animations); disposeGradually() does so over many frames.
|
|
10
|
+
*/
|
|
11
|
+
import { LoadAssetContainerAsync, Mesh, TransformNode, Vector3 } from "@babylonjs/core";
|
|
12
|
+
// Side-effect import: registers the glTF 2.0 SceneLoader plugin.
|
|
13
|
+
import "@babylonjs/loaders/glTF/2.0/glTFLoader.js";
|
|
14
|
+
// Side-effect import: registers every glTF 2.0 extension Babylon ships
|
|
15
|
+
// (KHR_materials_unlit, _pbrSpecularGlossiness, …). Extensions are opt-in
|
|
16
|
+
// modules in @babylonjs/loaders 8 and an unregistered REQUIRED extension
|
|
17
|
+
// makes the whole load throw "not available"; importing them statically also
|
|
18
|
+
// avoids the lazy per-extension import() path.
|
|
19
|
+
import "@babylonjs/loaders/glTF/2.0/Extensions/index.js";
|
|
20
|
+
import { registerGLTFExtension, unregisterGLTFExtension } from "@babylonjs/loaders/glTF/2.0/glTFLoaderExtensionRegistry.js";
|
|
21
|
+
// Except KHR_interactivity: it runs the asset's behaviour graph, which this
|
|
22
|
+
// viewer has no use for and which can throw outside the load promise on
|
|
23
|
+
// graphs Babylon does not fully support. Assets list it as optional.
|
|
24
|
+
unregisterGLTFExtension("KHR_interactivity");
|
|
25
|
+
/** Longest stretch of shader compilation or disposal between yields to the render loop. */
|
|
26
|
+
const SLICE_MS = 4;
|
|
27
|
+
/** What the meshes are scaled by during warmUp: far below a pixel, but still drawn. */
|
|
28
|
+
const WARM_UP_SCALE = 1e-6;
|
|
29
|
+
/**
|
|
30
|
+
* Finishes a load's meshes one per event-loop turn. The loader completes each
|
|
31
|
+
* mesh when its last texture has arrived, usually the same texture for all of
|
|
32
|
+
* them, and completing one computes its bounds: on the CPU through the skeleton
|
|
33
|
+
* for a skinned mesh. Together those stopped the frame loop for tens of ms.
|
|
34
|
+
*/
|
|
35
|
+
class OneMeshPerTurn {
|
|
36
|
+
loader;
|
|
37
|
+
name = "one_mesh_per_turn";
|
|
38
|
+
enabled = true;
|
|
39
|
+
lastMesh = Promise.resolve();
|
|
40
|
+
constructor(loader) {
|
|
41
|
+
this.loader = loader;
|
|
42
|
+
}
|
|
43
|
+
dispose() {
|
|
44
|
+
/* holds nothing */
|
|
45
|
+
}
|
|
46
|
+
_loadMeshPrimitiveAsync(...args) {
|
|
47
|
+
const load = this.loader._loadMeshPrimitiveAsync;
|
|
48
|
+
return load.apply(this.loader, args).then(async (mesh) => {
|
|
49
|
+
const turn = this.lastMesh.then(nextTurn);
|
|
50
|
+
this.lastMesh = turn;
|
|
51
|
+
await turn;
|
|
52
|
+
return mesh;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
registerGLTFExtension("one_mesh_per_turn", false, (loader) => new OneMeshPerTurn(loader));
|
|
57
|
+
export async function loadAsset(scene, url, placement = {}, onPhase) {
|
|
58
|
+
const center = placement.center ?? new Vector3(0, 1.3, 2.2);
|
|
59
|
+
const height = placement.height ?? 0.6;
|
|
60
|
+
onPhase?.("load");
|
|
61
|
+
const container = await LoadAssetContainerAsync(url, scene);
|
|
62
|
+
container.addAllToScene();
|
|
63
|
+
// Pivot at the bounds centre, so rotating the root turns it in place.
|
|
64
|
+
const content = new TransformNode("assetContent", scene);
|
|
65
|
+
for (const node of container.rootNodes)
|
|
66
|
+
node.parent = content;
|
|
67
|
+
const { min, max } = content.getHierarchyBoundingVectors();
|
|
68
|
+
content.position = min.add(max).scaleInPlace(-0.5);
|
|
69
|
+
const root = new TransformNode("assetRoot", scene);
|
|
70
|
+
content.parent = root;
|
|
71
|
+
const size = max.subtract(min);
|
|
72
|
+
const largest = Math.max(size.x, size.y, size.z, 0.001);
|
|
73
|
+
root.scaling.setAll(Math.min(height / Math.max(size.y, 0.001), (placement.maxSize ?? Infinity) / largest));
|
|
74
|
+
root.position.copyFrom(center);
|
|
75
|
+
root.setEnabled(false);
|
|
76
|
+
onPhase?.("compile");
|
|
77
|
+
await nextTurn(); // the loader's last continuation just ran in this one
|
|
78
|
+
await compileMaterials(container.meshes);
|
|
79
|
+
root.setEnabled(placement.hidden !== true);
|
|
80
|
+
const dispose = () => {
|
|
81
|
+
container.dispose(); // meshes, materials, textures, animation groups, skeletons
|
|
82
|
+
root.dispose(); // the two pivots (not part of the container)
|
|
83
|
+
};
|
|
84
|
+
console.log(`[render] asset ${url}: ${size.x.toFixed(2)}x${size.y.toFixed(2)}x${size.z.toFixed(2)} m, scale ${root.scaling.x.toFixed(2)}`);
|
|
85
|
+
return {
|
|
86
|
+
root,
|
|
87
|
+
warmUp: () => warmUp(scene, container.meshes, content, root),
|
|
88
|
+
dispose,
|
|
89
|
+
disposeGradually: async () => {
|
|
90
|
+
// Each is removed from the container first: its dispose() would repeat them.
|
|
91
|
+
let sliceStart = performance.now();
|
|
92
|
+
const remaining = [container.animationGroups, container.meshes, container.materials, container.textures];
|
|
93
|
+
for (const list of remaining) {
|
|
94
|
+
for (let item = list.pop(); item !== undefined && !scene.isDisposed; item = list.pop()) {
|
|
95
|
+
item.dispose();
|
|
96
|
+
if (performance.now() - sliceStart > SLICE_MS) {
|
|
97
|
+
await nextTurn();
|
|
98
|
+
sliceStart = performance.now();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (!scene.isDisposed)
|
|
103
|
+
dispose();
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function nextTurn() {
|
|
108
|
+
return new Promise((resolve) => setTimeout(resolve));
|
|
109
|
+
}
|
|
110
|
+
async function warmUp(scene, meshes, content, root) {
|
|
111
|
+
const pivot = new TransformNode("assetWarmUp", scene);
|
|
112
|
+
pivot.scaling.setAll(WARM_UP_SCALE);
|
|
113
|
+
content.parent = pivot;
|
|
114
|
+
const wasVisible = meshes.map((mesh) => mesh.isVisible);
|
|
115
|
+
const wasAlwaysActive = meshes.map((mesh) => mesh.alwaysSelectAsActiveMesh);
|
|
116
|
+
for (const mesh of meshes)
|
|
117
|
+
mesh.isVisible = false;
|
|
118
|
+
for (const [i, mesh] of meshes.entries()) {
|
|
119
|
+
if (!wasVisible[i] || mesh.getTotalVertices() === 0 || scene.isDisposed)
|
|
120
|
+
continue;
|
|
121
|
+
mesh.isVisible = true;
|
|
122
|
+
mesh.alwaysSelectAsActiveMesh = true; // whichever way the user is looking
|
|
123
|
+
await new Promise((resolve) => scene.onAfterRenderObservable.addOnce(resolve));
|
|
124
|
+
mesh.isVisible = false;
|
|
125
|
+
mesh.alwaysSelectAsActiveMesh = wasAlwaysActive[i];
|
|
126
|
+
}
|
|
127
|
+
meshes.forEach((mesh, i) => {
|
|
128
|
+
mesh.isVisible = wasVisible[i];
|
|
129
|
+
});
|
|
130
|
+
content.parent = root;
|
|
131
|
+
pivot.dispose();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Compiles what the meshes need to render, yielding to the render loop when
|
|
135
|
+
* a stretch took long (a driver without parallel shader compilation blocks
|
|
136
|
+
* for each new shader). Not the loader's compileMaterials option: that also
|
|
137
|
+
* compiles an instanced variant of every material. A material that does not
|
|
138
|
+
* compile is reported and left to behave as it would at first render.
|
|
139
|
+
*/
|
|
140
|
+
async function compileMaterials(meshes) {
|
|
141
|
+
let sliceStart = performance.now();
|
|
142
|
+
for (const mesh of meshes) {
|
|
143
|
+
if (!(mesh instanceof Mesh) || mesh.material === null)
|
|
144
|
+
continue;
|
|
145
|
+
try {
|
|
146
|
+
await mesh.material.forceCompilationAsync(mesh);
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
console.warn(`[render] material ${mesh.material.name} does not compile: ${String(err)}`);
|
|
150
|
+
}
|
|
151
|
+
if (performance.now() - sliceStart > SLICE_MS) {
|
|
152
|
+
await nextTurn();
|
|
153
|
+
sliceStart = performance.now();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=load-asset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-asset.js","sourceRoot":"","sources":["../src/load-asset.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,uBAAuB,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAiC,MAAM,iBAAiB,CAAC;AACvH,iEAAiE;AACjE,OAAO,2CAA2C,CAAC;AACnD,uEAAuE;AACvE,0EAA0E;AAC1E,yEAAyE;AACzE,6EAA6E;AAC7E,+CAA+C;AAC/C,OAAO,iDAAiD,CAAC;AAGzD,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,4DAA4D,CAAC;AAE5H,4EAA4E;AAC5E,wEAAwE;AACxE,qEAAqE;AACrE,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;AAE7C,2FAA2F;AAC3F,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,uFAAuF;AACvF,MAAM,aAAa,GAAG,IAAI,CAAC;AAI3B;;;;;GAKG;AACH,MAAM,cAAc;IAKW;IAJpB,IAAI,GAAG,mBAAmB,CAAC;IACpC,OAAO,GAAG,IAAI,CAAC;IACP,QAAQ,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;IAEvD,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAEnD,OAAO;QACL,mBAAmB;IACrB,CAAC;IAED,uBAAuB,CAAC,GAAG,IAAmC;QAC5D,MAAM,IAAI,GAAI,IAAI,CAAC,MAAoE,CAAC,uBAAuB,CAAC;QAChH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAE,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;YACxD,MAAM,IAAI,GAAG,IAAI,CAA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,IAAI,MAAM,EAAE,CAAC;QAC1B,IAAI,CAAC,CAAC,IAAI,YAAY,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI;YAAE,SAAS;QAChE,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAClD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CAAC,qBAAqB,IAAI,CAAC,QAAQ,CAAC,IAAI,sBAAsB,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC3F,CAAC;QACD,IAAI,WAAW,CAAC,GAAG,EAAE,GAAG,UAAU,GAAG,QAAQ,EAAE,CAAC;YAC9C,MAAM,QAAQ,EAAE,CAAC;YACjB,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QACjC,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/xr.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Mesh, Scene, WebXRDefaultExperience } from "@babylonjs/core";
|
|
2
|
+
import "@babylonjs/core/XR/features/WebXRLayers.js";
|
|
3
|
+
import "@babylonjs/core/Maths/math.color.js";
|
|
4
|
+
import "@babylonjs/core/Maths/math.vector.js";
|
|
5
|
+
export interface AppXr {
|
|
6
|
+
xr: WebXRDefaultExperience;
|
|
7
|
+
sessionMode: XRSessionMode;
|
|
8
|
+
/** Connected controllers (handedness:profile), for the run summary. */
|
|
9
|
+
controllers(): string[];
|
|
10
|
+
}
|
|
11
|
+
export declare function setupXr(scene: Scene, floor: Mesh): Promise<AppXr>;
|
package/dist/xr.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app's WebXR setup, plain Babylon.js: the default experience (input,
|
|
3
|
+
* pointer selection, teleportation), procedural controller visuals and
|
|
4
|
+
* interaction logging. Enters immersive-ar when the device offers it
|
|
5
|
+
* (see-through headsets), otherwise immersive-vr — the usual browser
|
|
6
|
+
* pattern.
|
|
7
|
+
*/
|
|
8
|
+
import * as BABYLON from "@babylonjs/core";
|
|
9
|
+
// Side-effect import: registers the WebXR Layers feature (Babylon 9 keeps the index pure).
|
|
10
|
+
import "@babylonjs/core/XR/features/WebXRLayers.js";
|
|
11
|
+
// What went wrong: "TypeError: Cannot read properties of undefined (reading 'r')"
|
|
12
|
+
// in InputBlock._transmit, which stopped Babylon's render loop, when the user
|
|
13
|
+
// walked through a pane.
|
|
14
|
+
// 1. Trigger: a movable pane's meshes are near-grabbable (SixDofDragBehavior).
|
|
15
|
+
// When the point just ahead of a controller gets within 10 cm of one, Babylon
|
|
16
|
+
// shows its near-interaction orb, a small sphere at the controller.
|
|
17
|
+
// 2. Bug: the orb's NodeMaterial loads its colours by looking up "BABYLON.Color3"
|
|
18
|
+
// by name. In Babylon 9.33.2, importing @babylonjs/core does not register the
|
|
19
|
+
// math classes, so the lookup fails silently and edgeColor and fillColor stay
|
|
20
|
+
// undefined.
|
|
21
|
+
// 3. Crash: the first draw of the orb reads .r from the undefined colour. The orb
|
|
22
|
+
// is hidden until something comes that close, so this only shows up then.
|
|
23
|
+
// The fix: these side-effect imports register the classes. The vector one covers
|
|
24
|
+
// the same gap for Vector2/3/4 and Matrix. smoke:near-interaction covers it.
|
|
25
|
+
import "@babylonjs/core/Maths/math.color.js";
|
|
26
|
+
import "@babylonjs/core/Maths/math.vector.js";
|
|
27
|
+
import { attachControllerVisuals } from "./controller-visuals.js";
|
|
28
|
+
import { installControllerLogging, installScenePointerLogging } from "./controller-log.js";
|
|
29
|
+
export async function setupXr(scene, floor) {
|
|
30
|
+
const xr = await BABYLON.WebXRDefaultExperience.CreateAsync(scene, {
|
|
31
|
+
floorMeshes: [floor],
|
|
32
|
+
disableDefaultUI: true,
|
|
33
|
+
// No network for controller models: resolve profiles locally and draw
|
|
34
|
+
// our own wands (controller-visuals.ts).
|
|
35
|
+
inputOptions: { disableOnlineControllerRepository: true, doNotLoadControllerMeshes: true },
|
|
36
|
+
// Keep the landing ring on the floor (the stock one bobs up to 0.4 m).
|
|
37
|
+
teleportationOptions: { defaultTargetMeshOptions: { disableAnimation: true } },
|
|
38
|
+
// A laser on each hand, so each can point at its own pane (pane-controller-input.ts).
|
|
39
|
+
pointerSelectionOptions: { enablePointerSelectionOnAllControllers: true },
|
|
40
|
+
});
|
|
41
|
+
const controllerLog = installControllerLogging(xr.input);
|
|
42
|
+
attachControllerVisuals(BABYLON, xr.input);
|
|
43
|
+
installScenePointerLogging(scene);
|
|
44
|
+
xr.baseExperience.camera.onAfterCameraTeleport.add((p) => {
|
|
45
|
+
console.log(`[teleport] camera -> (${p.x.toFixed(2)}, ${p.y.toFixed(2)}, ${p.z.toFixed(2)})`);
|
|
46
|
+
});
|
|
47
|
+
const sessionMode = (await navigator.xr?.isSessionSupported("immersive-ar")) === true ? "immersive-ar" : "immersive-vr";
|
|
48
|
+
// Babylon's WebGPU XR path is layers-only.
|
|
49
|
+
if (scene.getEngine().isWebGPU)
|
|
50
|
+
xr.baseExperience.featuresManager.enableFeature(BABYLON.WebXRFeatureName.LAYERS, "latest");
|
|
51
|
+
await xr.baseExperience.enterXRAsync(sessionMode, "local-floor");
|
|
52
|
+
console.log(`[main] entered ${sessionMode} (local-floor)`);
|
|
53
|
+
return { xr, sessionMode, controllers: () => controllerLog.controllers };
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=xr.js.map
|
package/dist/xr.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xr.js","sourceRoot":"","sources":["../src/xr.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAE3C,2FAA2F;AAC3F,OAAO,4CAA4C,CAAC;AACpD,kFAAkF;AAClF,8EAA8E;AAC9E,yBAAyB;AACzB,gFAAgF;AAChF,kFAAkF;AAClF,wEAAwE;AACxE,mFAAmF;AACnF,kFAAkF;AAClF,kF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AAC,CAAC,CAAC;IAEH,MAAM,WAAW,GAAkB,CAAC,MAAM,SAAS,CAAC,EAAE,EAAE,kBAAkB,CAAC,cAAc,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC;IACvI,2CAA2C;IAC3C,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC,QAAQ;QAAE,EAAE,CAAC,cAAc,CAAC,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC3H,MAAM,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;IACjE,OAAO,CAAC,GAAG,CAAC,kBAAkB,WAAW,gBAAgB,CAAC,CAAC;IAC3D,OAAO,EAAE,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC;AAC3E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kirknock/node-openxr-babylonjs",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Plain browser-style Babylon.js WebXR helpers (engine, default XR experience, asset loading and slideshow, floor, controller visuals and logging). Imports only @babylonjs/*.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "kirknock",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/kirknock/node-openxr-babylonjs.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/kirknock/node-openxr-babylonjs#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/kirknock/node-openxr-babylonjs/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"babylonjs",
|
|
18
|
+
"webxr",
|
|
19
|
+
"xr",
|
|
20
|
+
"vr",
|
|
21
|
+
"ar",
|
|
22
|
+
"openxr",
|
|
23
|
+
"gltf"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
"./*.js": {
|
|
27
|
+
"types": "./dist/*.d.ts",
|
|
28
|
+
"default": "./dist/*.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public",
|
|
37
|
+
"registry": "https://registry.npmjs.org/"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "node -e \"fs.rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json",
|
|
41
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
42
|
+
"lint": "eslint src tests",
|
|
43
|
+
"test": "nodexr-test all",
|
|
44
|
+
"test:pure": "nodexr-test pure",
|
|
45
|
+
"push": "npm run build && npx --yes yalc@1.0.0-pre.53 publish --push",
|
|
46
|
+
"smoke:controller-log": "tsx tests/controller-log-smoke.ts",
|
|
47
|
+
"prepack": "npm run build"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@babylonjs/core": "9.33.2",
|
|
51
|
+
"@babylonjs/loaders": "9.33.2"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@babylonjs/core": "9.33.2",
|
|
55
|
+
"@babylonjs/loaders": "9.33.2",
|
|
56
|
+
"@kirknock/node-openxr-core": "^0.3.1",
|
|
57
|
+
"@napi-rs/canvas": "1.0.11",
|
|
58
|
+
"@types/node": "^24.0.0",
|
|
59
|
+
"@types/webxr": "^0.5.14",
|
|
60
|
+
"eslint": "10.13.0",
|
|
61
|
+
"iwer": "2.7.0",
|
|
62
|
+
"koffi": "2.16.3",
|
|
63
|
+
"tsx": "^4.20.0",
|
|
64
|
+
"typescript": "^5.6.0",
|
|
65
|
+
"typescript-eslint": "8.70.0"
|
|
66
|
+
},
|
|
67
|
+
"engines": {
|
|
68
|
+
"node": ">=24"
|
|
69
|
+
}
|
|
70
|
+
}
|